PhilT Posted March 10, 2018 Share Posted March 10, 2018 <!DOCTYPE html> <html> <head> <script src='./node_modules/babylonjs/dist/preview release/babylon.js'></script> <script src='./node_modules/babylonjs/dist/preview release/cannon.js'></script> <script> document.addEventListener('DOMContentLoaded', () => { const canvas = document.getElementById('renderCanvas') const engine = new BABYLON.Engine(canvas) const scene = new BABYLON.Scene(engine) scene.enablePhysics() const physicsHelper = new BABYLON.PhysicsHelper(scene) const camera = new BABYLON.ArcRotateCamera('camera', 1, 20, 10, new BABYLON.Vector3(20, 0, 0)) camera.setPosition(new BABYLON.Vector3(0, 20, -30)) scene.activeCamera.attachControl(canvas) const sun = new BABYLON.HemisphericLight('', new BABYLON.Vector3(0, 1, 0)) sun.diffuse = new BABYLON.Color3(0.8, 0.8, 0.8) sun.groundColor = new BABYLON.Color3(0.1, 0.1, 0.1) const box = BABYLON.MeshBuilder.CreateBox('active', { size: 0.9 }) const boxMaterial = new BABYLON.StandardMaterial('') boxMaterial.diffuseColor = new BABYLON.Color3(0.5, 0.5, 1) box.material = boxMaterial box.physicsImposter = new BABYLON.PhysicsImpostor(box, BABYLON.PhysicsImpostor.BoxImposter, { mass: 1, restitution: 0.9, friction: 1 }) }) </script> </head> <body> <canvas id='renderCanvas'></canvas> </body> </html> Any ideas why this code gives the following error? cannon.js:5756 Uncaught TypeError: Cannot read property 'calculateWorldAABB' of undefined at Body.computeAABB (cannon.js:5756) at Body.updateMassProperties (cannon.js:5930) at Body.addShape (cannon.js:5693) at t.generatePhysicsBody (babylon.js:43) at t.addImpostor (babylon.js:43) at t._init (babylon.js:43) at new t (babylon.js:43) at HTMLDocument.document.addEventListener ((index):32) I'm using the latest GitHub code `Babylon.js engine (v3.2.0-alphaC) launched` Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted March 10, 2018 Share Posted March 10, 2018 Hi @PhilT Just typo's box.physicsImpostor = new BABYLON.PhysicsImpostor(box, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 1, restitution: 0.9, friction: 1 }) http://playground.babylonjs.com/#AEK13E#1 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
PhilT Posted March 10, 2018 Author Share Posted March 10, 2018 OMG! Thanks! 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.