How to import NodeMaterial with tree shaking?

Doing tree shaking I have errors with Nodematerials import.

image

(Of course, it works when doing import * as BABYLON from "@babylonjs/core";

There was the thread - Importing NodeMaterial with tree shaking with similar issues, but still I am not able to make it work in any import combinations which I’ve tried.

Could anybody provide the right import statement for Nodematerial?

You probably need to import all the blocks that are usefull in your serialization for side effects.

or better import { NodeMaterial } as BABYLON from “@babylonjs/core/Materials/Node”; to have all the node mat side effects.

In this case I have

image

with the next errors shown:

image

image

image

(Babylon version 5.16.0)

so sorry my bad with copy paste… I meant:

mport { NodeMaterial } from “@babylonjs/core/Materials/Node”

This one I tried already:

import { NodeMaterial } from "@babylonjs/core/Materials/Node";

and it gives the next error:

Ohhhhh… can you provide a quick repro project so that I can dig in ?

Will try :slight_smile:

How to know which blocks I need to import?

import { NodeMaterial } from “@babylonjs/core/Materials/Node”; should import them all so it might not be this unfortunately :frowning: and to know the nodes, it would be all the ones in the material you are trying to parse so kind of hard to really go deep on this front.

1 Like

Hey @labris how are you? :smiley: Just checking in to see if you need any more help on this

1 Like

I’ll check and let you know :slight_smile:

2 Likes