1

I am currently attempting to import the Babylon library to my typescript files. Normally I would just put export in front of the class to make it work, but due to the structure of the library which starts with Declare Module BABYLON{ ... and then adds the classes, I cannot use that method. When attempting to import this into another class, I receive an error saying that Babylon is not a module. Any suggestions to fix this? (I will also have access to webpack if that helps).

1 Answer 1

1

as a temporary solution (working on a permanent one :smile:) - go to your npm modules and search for babylon.

Edit babylon.d.ts and add the following line at the end of the file:

export = BABYLON;

Problem will be resolved. To keep it like that make sure you specify the current babylon version in your package.json file (with a fixed version). Otherwise it will change back in the next update.

You can then import babylonjs:

import * as BABYLON from 'babylonjs';

Or better - import only the parts you need:

import { Scene, Engine, ArcRotateCamera, Vector3, HemisphericLight } from 'babylonjs';

Again - I do hope I will find a proper solution to please everyone until the next version of Babylon will be released.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.