Huge skeletonViewer(and rotated) in my code?

i can run this demo

skeleonViewer can draw correct bone line(or changeDisplayMode() ).

but when using my own code, the viewer’s result is magnified 100 times, and it is lying down. Do you need further assistance or explanation?

i use TS, npm install latest babylonjs(7.49.0)

and code here:

    SceneLoader.ImportMeshAsync("", "models/", "tpose_xmodel.glb", this.scene).then((result) => {
        const { meshes, particleSystems, skeletons, animationGroups } = result;
        this.animationGroups = animationGroups;

        var xBotRoot = meshes[0];
        var xBotSkeleton = skeletons[0];
        xBotRoot.name = "~xBot";
        xBotRoot.scaling = new Vector3(0.1, 0.1, 0.1);
        xBotRoot.position = new Vector3(0, 0, 0);
        xBotRoot.rotate(Vector3.Up(), Math.PI / 2);
        
        const viewer = new SkeletonViewer(xBotSkeleton, xBotRoot, this.scene);
        viewer.isEnabled = true;
        viewer.color = Color3.Red();
        viewer.update();
        // viewer.changeDisplayMode(0);

        xBotRoot.receiveShadows = true;
        shadowGenerator.addShadowCaster(xBotRoot);
        
        console.log(`Skeleton:`, xBotSkeleton.name);
        xBotSkeleton.bones.forEach((bone, bIdx) => {
            console.log(`Bone #${bIdx}: ${bone.name}`);
        });
    });

Welcome aboard!

Are you passing the right mesh to new SkeletonViewer(...) (2nd parameter)?

You should update the PG with your own model, to make it easier for us to help you. This page can help you if you need to store your resource somewhere so that it is available from the Playground:

https://doc.babylonjs.com/toolsAndResources/thePlayground/externalPGAssets/

Thank thee very much!

const viewer = new SkeletonViewer(xBotSkeleton, xBotRoot, this.scene);

the 2nd parameter is xBotRoot, which is var xBotRoot = meshes[0];

is that right?

/////////
i upload my model to dropbox, and load from PG,

same errror… so the problem is model? i download the x-bot from mixamo, and export from blender from fbx to glb format… any problem?

You should pass a mesh that has the skeleton applied (newMeshes[0] is the root node and doesn’t have a skeleton). For example:

my foolish… neeed scale x100 in blender before export to babylon…

1 Like