NME code imports (TS)


I’m trying to use an NME material I created in my application.
In the NME editor, I generated the code and saved but it seems that it does not contain any imports.
I’m using Typescript + NPM packages, and I’m having trouble figuring out from which package to import what.
I can fix some of the issues with the legacy import:

import * as BABYLON from "@babylonjs/core/Legacy/legacy";

but some issues still remain like BABYLON.PBRMetallicRoughnessBlock or Texture.convertToLinearSpace or BABYLON.ReflectionBlock, etc…

I looked in the documentation and found some of those types but there doesn’t seem to be any indication regarding which packages they belong to.
Also the fact that there are 2 sets of packages for BabylonJS on NPM confuses me a bit (the @babylonjs ones and the babylonjs ones) and I am not sure if I got the right one.

  • How/where can I find which packages correspond to which types?
  • And do I need to get the @babylonjs or babylonjs packages from NPM
  • What is the difference between the two?

Thanks in advance! Help would be highly appreciated!

1 Like

Ok, I’ve checked out the github repo and run the following command to find when ReflectionBlock was added:

git log -S ReflectionBlock --oneline

I get:

commit 7d49ccbf89144be0ecd5aff9e0b2fb4285caf6e5
Author: Popov72 <github@evpopov.com>
Date:   Thu Apr 9 22:18:37 2020 +0200

    Add reflection block (WIP)

I then checked which release version that corresponds to:

npm view @babylonjs/core time --json

and it seems to me that it is a change that’s for 4.2.x
Comparing the version of babylon in my package.json (4.1.0) with the NME Editor (4.2.0-beta.5) seems to confirm that this is the problem!

Is there a way to change the version of babylon that the NME editor uses? Or will I need to build it locally to be able to use it for 4.1.0?

Thanks in advance!

The PBR blocks have been added in the NME in version 4.2 so you won’t be able to use them with 4.1.

I don’t think there’s a way to change the Babylon.js version NME is using online but you can get the package for the 4.1 NME from Babylon.js/dist/nodeEditor at master · BabylonJS/Babylon.js · GitHub.

1 Like

Thanks for your help Evgeni!

Ok, Since it seems 4.1 is the latest stable version I was expecting that this would be the version deployed on nme.babylonjs.com. In any case now I know and I’ll run nme locally :slight_smile: Thanks again!