Help need with NME material

Hey, we made a material with the help of the NME.(material)
I saved it as json, uploaded to server, and from there I’m trying to get it like this

 async loadNodeMaterial(name: string, url: string, scene: Scene) {
    return await NodeMaterial.ParseFromFileAsync(name, url, scene).then((material) => {

but I have this error in console

Build of NodeMaterial failed:
input transform from block WorldPos[TransformBlock] is not connected and is not optional.
input rgba from block FragmentOutput[FragmentOutputBlock] is not connected and is not optional.

Any help is welcome. THanks

The similar code works here - Babylon.js Playground
Did you try to load any another Node material json?

Yep, all good here, I saved it as json and load in pg and all good. I have no ideea

Probably you’ll need to remake your function.
I am not sure if you need to use then when using await.

You are right, I tried few methods, and by mistake I didn’t copy the right code
So I tried both

async loadNodeMaterial(name: string, url: string, scene: Scene) {
    const material = await NodeMaterial.ParseFromFileAsync(name, url, scene)
loadNodeMaterial(name: string, url: string, scene: Scene) {
    return NodeMaterial.ParseFromFileAsync(name, url, scene).then((material) => {

In both case I got the error, and I didn’t get the console

It works here -
I believe the problem is with your json loading.

1 Like

I was feeling a bit hopeless, but this topic gave me an idea, and it seems I’ve identified the issue. It looks like it was a problem only on es6 (this is why in pg all good) and it appears that just importing

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

is not enough. I also need to include

import "@babylonjs/core/Materials/Node/Blocks";

Otherwise, the error persists. I’m not sure whom to ping or contact to resolve the import issue at the package level, or at least to add this to the documentation, perhaps on the ES6 page.
@RaananW , @carolhmj

That’s not an issue with the package, this is by design, to provide tree shaking, while still maintain package structure and the engine’s architecture.

It is required to either load the blocks you are using, or all of the blocks if you are unsure. This way the final package size is the smallest possible.
So what you are doing is right! You could also solve it by importing the NodeMaterial class this way:

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