Jump to content

How to get glb mesh information?


Amir2020
 Share

Recommended Posts

Hi, I'm trying to get the width and height of the imported object in my scene, but I got this error. "Cannot read property 'getBoundingInfo' of undefined"

and this is my code:

        var createScene = function(){

            var scene   = new BABYLON.Scene(engine);

            var camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 2, Math.PI / 2, 4, BABYLON.Vector3.Zero(), scene);
            camera.attachControl(canvas, true);

            var front = BABYLON.SceneLoader.ImportMesh("", "model/", "front.glb", scene, function (meshes) {          
                scene.createDefaultCameraOrLight(true, true, true);
                var light1 = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 0, -50), this.scene);
                var light2 = new BABYLON.PointLight("light2", new BABYLON.Vector3(0, 1, -1), this.scene);

                
                scene.executeWhenReady(function () {

                    var camera = new BABYLON.ArcRotateCamera("camera",  -Math.PI/2.1, 1.2, 45, 
                        new BABYLON.Vector3(4.85, -8.01, 3.93), scene);
                    camera.attachControl(canvas, true);
                    scene.activeCamera = camera;
                   
                    engine.runRenderLoop(function() {
                        scene.render();
                    });
                });
                  
            });

            scene.createDefaultLight();

            scene.clearColor    = new BABYLON.Color4(0,0,0,0.0000000000000001);
            scene.ambientColor  = new BABYLON.Color3(1, 1, 1);


            var size = front[0].getBoundingInfo().boundingBox.extendSize;
            console.log(size);

            return scene;
        };

 

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...