Using BabylonJS v4.0 in an IONIC4 project

Hi,

i do have a BabylonJS v4.0 project and wanna run it in IONIC4 framework.
I tried to set it up as described here:
https://doc.babylonjs.com/resources/babylonjs_and_ionic_angular

Unfortunately it does not work.

Does anyone has an idea what i do have to change with the newer versions?

Manuel

What is error?

I think the issue is how to export and import the BABYLON.

How should i install Babylon?
I tried:
npm install babylonjs --save
Is that correct or do i need to add a version?

How should i export babylon?
In the docu (How to use BabylonJS in an Ionic Angular app - Babylon.js Documentation) it is written to do that in the line of babylon.d.ts (in node_modules/babylonjs/dist).
Actually i do not see the subfolder dist and the file babylon.d.ts

So i did add the export in the last line of the babylon.module.d.ts - which seems to be wrong.

I got the following errors (just a snippet):
    [ng]     node_modules/babylonjs/babylon.module.d.ts(59464,19): error TS2307: Cannot find module 'babylonjs/Sprites/index'.
    [ng]     node_modules/babylonjs/babylon.module.d.ts(59465,19): error TS2307: Cannot find module 'babylonjs/States/index'.
    [ng]     node_modules/babylonjs/babylon.module.d.ts(59466,19): error TS2307: Cannot find module 'babylonjs/Misc/index'.
    [ng]     node_modules/babylonjs/babylon.module.d.ts(59467,19): error TS2307: Cannot find module 'babylonjs/types'.
    [ng]     node_modules/babylonjs/babylon.module.d.ts(59470,36): error TS2307: Cannot find module 'babylonjs/Maths/math'.
    [ng]     node_modules/babylonjs/babylon.module.d.ts(59536,30): error TS2307: Cannot find module 'babylonjs/index'.
    [ng]     node_modules/babylonjs/babylon.module.d.ts(59537,19): error TS2307: Cannot find module 'babylonjs/index'.
    [ng]     node_modules/babylonjs/babylon.module.d.ts(60102,5): error TS2666: Exports and export assignments are not permitted in module augmentations.
    [ng]     node_modules/babylonjs/babylon.module.d.ts(60102,19): error TS2307: Cannot find module 'babylonjs/Legacy/legacy'.

How is the correct way to install BabylonJS and export it?

1 Like

pinging @sebavan

Hello, I think it should just work by default.

Could you try just npm install babylonjs@preview --save ? (it is the latest version fitting with master)

Then you should not add the export at the end of the file, BABYLON is already exported as a UMD module in 4.x

Let me know if that works

2 Likes

Ah - it is already exported. Perfect. Good job.
Issue solved. Thanks for your help.

A short update or side-note in the resources topic How to use BabylonJS in an Ionic Angular app - Babylon.js Documentation would be nice. So others won’t get stuck in that issue in the future.

Do you fancy doing a PR on the doc for this ?

Else I will happily do it.

Thanks for asking.
I think i am not experienced enough with BabylonJS to not make any mistake. I would prefer if you do it.

no problem I ll do.

1 Like