DEV Community

Discussion on: Build a Web VR game with JavaScript using BabylonJS

Collapse
 
cassiebreviu profile image
Cassie Breviu • Edited

Yes it is a separate package that needs to be installed.

Update the package.json to look like this and then run npm install

 "dependencies": {
    "babylonjs": "^3.3.0",
    "babylonjs-gui": "^3.3.0",
    "babylonjs-loaders": "^3.3.0",
    "babylonjs-materials": "^3.3.0",
    "babylonjs-procedural-textures": "^3.3.0",
    "cannon": "^0.6.2"
  }

And make sure its imported at the top of the index.ts as shown below:

import { Engine, Scene, HemisphericLight, Vector3, CannonJSPlugin, StandardMaterial, DirectionalLight, Color4 } from "babylonjs";

If you want to install the cannon package directly from npm vs updating the package.json you can also do it like this npm install --save cannon

Collapse
 
seanmclem profile image
Seanmclem

Okay thanks for making it explicit. I guess the real issue I'm having is that I'm using stencil JS and it doesn't seem to play nice with non-default Imports

Thread Thread
 
cassiebreviu profile image
Cassie Breviu

I'm curious now, what are you using stencil for in a web vr project?

Thread Thread
 
seanmclem profile image
Seanmclem • Edited

Because in essence you're just writing vanilla Js. It feels closer to the Raw HTML/JS specs than any framework might. But not as discombobulated as plain old HTML and js.

Also what I'm developing might not end up being VR at all. At this point I'm just kind of cobbling together resources and piecing logic together from various tutorials and documentation.