AutoComplete in VS Code

Is their a way to get Babylon JS snippets in a JS project?

You can find the folder structure here (Babylon is in the libraries folder).

1 Like

This is the file we use for the playground, Babylon.js/templates.json at master · sebavan/Babylon.js · GitHub

And might be able to reference them from Snippets in Visual Studio Code

I meant IntelliSense for the class definitions. For example typing BABYLON.Arc would have ArcRotateCamera in the tab options, which I currently do not have.

2 Likes

The declaration file is part of the npm package, and you can reference it in you ts.config.json types property

I’m not using the NPM package though, I’m using the minified JS file.

@RaananW might know if they are still available to DL from the CDN ?

Of course, they are available on the cdn, and are referenced in both max and monitored versions of each package. You can download them and add to your project, of reference them using a reference comment, providing their path or type (https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html)

1 Like

Which path[s] should I use? I’m not entirely sure which files your talking about (I’m assuming a .d.ts?)

oh, yes. you need to reference it locally. the path is the path to the file (relative path usually). change the .js with .d.ts when downloading from the server

1 Like

Thanks so much! Using the triple slash with the .d.ts worked great.

2 Likes

Just in case someone is trying to use this with plain JavaScript (not TypeScript): it works exactly the same.

  1. Get the .d.ts file from somewhere (e.g. cdnjs).
  2. Put it somewhere in your project.
  3. Add this line to your JS file using babylon.js:
/// <reference path="your/relative/path/to/babylon.d.ts" />

Voilà!

1 Like