Jump to content

Cannot read property 'calculateWorldAABB' of undefined


PhilT
 Share

Recommended Posts

<!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`

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