Error loading Node Material that contains VectorMergeBlock

I’m getting a exception thrown when loading a Node Material either using loadFromSerialization or loadAsync

From what I can see, the serialization data has 8 inputs (xyzw, xyz, xy, zw, x,y,z,w) while the actual VectorMergeBlock only has 6 inputs.

So then there’s essentially an index out of bounds here:

// nodeMaterialBlock.ts
 if (serializedInputs) {
            serializedInputs.forEach((port: any, i: number) => {
                if (port.displayName) {
                    this.inputs[i].displayName = port.displayName;
                if (port.isExposedOnFrame) {
                    this.inputs[i].isExposedOnFrame = port.isExposedOnFrame; <<<< KABOOM!
                    this.inputs[i].exposedPortPosition = port.exposedPortPosition;

I’m trying to load this Node Material Model

using @babylonjs/core@4.2.0

It show this error thrown

TypeError: Cannot set properties of undefined (setting 'isExposedOnFrame')
    at http://localhost:3000/static/js/vendors~main.chunk.js:100127:44
    at Array.forEach (<anonymous>)
    at VectorMergerBlock.NodeMaterialBlock._deserializePortDisplayNamesAndExposedOnFrame (http://localhost:3000/static/js/vendors~main.chunk.js:100121:24)
    at VectorMergerBlock.NodeMaterialBlock._deserialize (http://localhost:3000/static/js/vendors~main.chunk.js:100111:10)
    at NodeMaterial.loadFromSerialization (http://localhost:3000/static/js/vendors~main.chunk.js:99065:15)
    at http://localhost:3000/static/js/main.chunk.js:9300:20 {stack: 'TypeError: Cannot set properties of undefined…ocalhost:3000/static/js/main.chunk.js:9300:20', message: 'Cannot set properties of undefined (setting 'isExposedOnFrame')'}

VectorMergerBlock has been updated in 5.0, so if you create a node material with 5.0 and try to load it in 4.2 it won’t work: you need to use 5.0 to load this node material.

1 Like