Typing Support for Babylon

Hi! I’m starting out Babylon for the first time, so I’m a bit new to all this (and coding in general tbh), but I was wondering how would I go about importing the documentation/typing support for Babylon in Javascript into my IDE (VS Code) while using the CDN link in script tags? As of right now, everything works, it’s just that there’s no autocomplete, which is slightly inconvenient.

Or would I have to use npm and install it, if so, how would I do that, as when I do

npm install babylonjs --save

the same thing as before happens. Or is the typing support only for Typescript?

Sorry if this is a stupid question, but if anyone could point me in the right direction, that’d be appreciated.

This can be a tricky problem because modern web development has kind of exploded in complexity, so don’t worry: it’s not a stupid question.
What you’re requesting is perfectly reasonable, but personally I’d recommend learning how to use a bundler. This essentially compiles down all your code and whatnot into a nice, easily deployable folder.

So let’s assume a directory structure like this:

| index.html
| package.json
| node_modules
| src
| - index.js

I personally use ParcelJS because I’m exceptionally lazy. Once that is installed (npm install -g parcel-bundler) simply type parcel index.html in the same directory as your index.html file. Make sure your HTML file has a script tag that points to your src/index.js file.

Make sure you’ve downloaded Babylon npm install --save babylonjs

Now at the top of your index.js file add the line:
import * as BABYLON from 'babylonjs';
Parcel will bundle everything up including Babylon and you can access it at localhost:1234
This should also get your types showing up using VS Code.

Hope this helps.

1 Like

Thanks, it works now!