Jump to content

GLTF Loader not setting BoundingInfo


NinjaMark
 Share

Recommended Posts

Hi,

I'm having an issue getting the method getBoundingInfo() working with the GLTF Loader plugin. Using other formats this data would be automatically set when using ImportMesh, for instance with the skull.babylon example:

1.	BoundingInfo
1.	_isLocked:false
2.	boundingBox:BoundingBox
3.	boundingSphere:BoundingSphere
4.	isLocked:false
5.	maximum:Vector3
1.	x:23.7722
2.	y:30.4701
3.	z:29.0242
6.	minimum:Vector3
1.	x:-23.7722
2.	y:-30.4938
3.	z:-29.0169

Using the same code but replacing skull.babylon with duck.gltf :

1.	BoundingInfo
1.	_isLocked:false
2.	boundingBox:BoundingBox
3.	boundingSphere:BoundingSphere
4.	isLocked:(...)
5.	maximum:Vector3
1.	x:0
2.	y:0
3.	z:0
6.	minimum:Vector3
1.	x:0
2.	y:0
3.	z:0

All values get set to 0, including those on boundingBox and boundingSphere. I'm seeing the same result with other GLTF models I've tried.

Is this a bug in the GLTF loader, or is there something else I need to do to set the bounding info for these meshes?

Link to comment
Share on other sites

computeWorldMatrix doesn't seem to have an effect here.

This is a full code sample loading each type of mesh and logging the BoundingInfo;


    <script>
        if (BABYLON.Engine.isSupported()) {

            var canvas = document.getElementById("canvas");
            var engine = new BABYLON.Engine(canvas, true);

            var createScene = function () {
                var scene = new BABYLON.Scene(engine);

                //Adding a light
                var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene);

                //Adding an Arc Rotate Camera
                var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene);
                camera.attachControl(canvas, false);

                BABYLON.SceneLoader.ImportMesh("", "", "skull.babylon", scene, function (newMeshes) {
                    console.log("Import .babylon mesh " + newMeshes[0].name);
                    console.log(newMeshes[0].getBoundingInfo()); // Returns correct BoundingInfo
                });
                

                BABYLON.SceneLoader.ImportMesh("", "", "duck.gltf", scene, function (newMeshes) {
                    console.log("Import GLTF mesh " + newMeshes[0].name);

                    newMeshes[0].computeWorldMatrix(true);

                    console.log(newMeshes[0].getBoundingInfo()); // Returns empty BoundingInfo
                });

                return scene;
            }

            createScene();
        }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...