Jump to content

Full NPM support for BabylonJS 3.1.x


RaananW
 Share

Recommended Posts

Hello dear people,

As already hinted in some other topics, I have finished the implementation of NPM packages for BabylonJS and its submodules.

Starting babylonjs 3.1.0-alpha3.4 you can use NPM to include BabylonJS and its modules in both JavaScript and TypeScript projects.

The available npm packages can be found here - https://www.npmjs.com/~babylonjs . Full usage is currently being documented, but here is a simple way to get started:

First install the latest babylonjs

npm install --save babylonjs babylonjs-gui babylonjs-materials

then, use those modules in your JS/TS file:

import * as BABYLON from 'babylonjs';
import 'babylonjs-materials';
import * as GUI from 'babylonjs-gui';

let engine = new BABYLON.Engine(.........)

I will update here when the documentation will be ready.

Link to comment
Share on other sites

I have tried out the GUI import and it works perfectly!  So, really happy to have this working in my project :)

I have a comment about the ES6 import.  This comment is not related to importing for side-effects only (ie: import 'babylonjs-materials';).  With "import * as GUI..." we would now do something like GUI.AdvancedDynamicTexture.CreateFullscreenUI("myUI"); instead of BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("myUI"); as per the documentation (and PGs).  I wonder if it makes sense to unify both usages somehow and also for traditional BJS projects with <script src...> tags.  It's obvious to me the usage, but I think it may confuse some people, whereas a framework should aim to guide down the path to success via simplicity/consistency.  I've seen already some related questions in Q&A about namespaces and imports.  Curious about your thoughts going forward as 3.1 is still in alpha.  Thanks.

Link to comment
Share on other sites

Hi @Arte,

BabylonJS is currently not supported on server-side applications, mainly due to the many references to canvas and window (which are sadly missing on a regular node backend).

The NPM support is more for wepack/browserify projects.

We are considering a headless version of Babylon, which will allow you to use Babylon on your server. This will probably be done in future releases and not in 3.1.

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