NinjaMark Posted January 10, 2017 Share Posted January 10, 2017 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 10, 2017 Share Posted January 10, 2017 Hello you can generate it manually by calling mesh.computeWorldMatrix(true); Ping @Luaacro FYI Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted January 10, 2017 Share Posted January 10, 2017 Areyou doing it in the callback of the SceneLoader ? if yes, the loading process is incremental for the gltf loader so meshes are created but not their geometries Do you confirm that you are doing it in the callback ? Quote Link to comment Share on other sites More sharing options...
NinjaMark Posted January 11, 2017 Author Share Posted January 11, 2017 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(); } Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 11, 2017 Share Posted January 11, 2017 @Luaacro is working on it Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted January 11, 2017 Share Posted January 11, 2017 Hi @NinjaPigeon The pull request is available here : https://github.com/BabylonJS/Babylon.js/pull/1666 You can just set BABYLON.GLTFFileLoader.IncrementalLoading = false; in your code. Then you'll be able to retrieve the bounding infos and all other datas Quote Link to comment Share on other sites More sharing options...
NinjaMark Posted January 12, 2017 Author Share Posted January 12, 2017 Thanks @Luaacro, can confirm that the BoundingInfo is being set after the update and setting IncrementalLoading = false Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.