GithubHelp home page GithubHelp logo

Cant work with GLTF about gltf-toolkit HOT 2 CLOSED

microsoft avatar microsoft commented on July 23, 2024
Cant work with GLTF

from gltf-toolkit.

Comments (2)

robertos avatar robertos commented on July 23, 2024

Hi @neuxxx ,

I tried it here and it seems to work fine.

A few notes: The CopyFileToTempFolderAsync function from UWPTest specifically copies a file from the app package (ms-appx://) to a temp folder. How did you get your assets in the LocalFolder? Did you change CopyFileToTempFolderAsync?

Also note that you don't have to pack the GLTF to a GLB before converting. ConvertAssetToWindowsMR accepts GLTF files as well, as long as all the resources it depends on are also in the temp folder.

Here's my code to test your Avocado scenario from the app package (I added this directly to UWPTest.cs, and added the Avocado gltf and resources as Content to the Assets/Avocado folder on the app package):

public async Task GLBTestForNeuxxx()
{
    const string gltfFileName = "Avocado.gltf";

    // Copy all the resources to a temp folder, and save a reference to the GLTF file
    var folder = await StorageFolder.GetFolderFromPathAsync(Path.Combine(Package.Current.InstalledLocation.Path, "Assets", "Avocado"));
    StorageFile copiedGltfFile = null;

    foreach (var resource in await folder.GetFilesAsync())
    {
        var copied = await resource.CopyAsync(ApplicationData.Current.TemporaryFolder, resource.Name, NameCollisionOption.ReplaceExisting);

        if (resource.Name == gltfFileName)
        {
            copiedGltfFile = copied;
        }
    }

    if (copiedGltfFile != null)
    {
        // Convert the file for Windows MR and pack it.
        StorageFolder outputFolder = await CreateTemporaryOutputFolderAsync("Out_" + Path.GetFileNameWithoutExtension(gltfFileName));

        var converted = await WindowsMRConversion.ConvertAssetForWindowsMR(copiedGltfFile, outputFolder, 512, TexturePacking.OcclusionRoughnessMetallic);
    }
}

from gltf-toolkit.

robertos avatar robertos commented on July 23, 2024

Closing - please reopen if necessary

from gltf-toolkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.