# How to set Inspector visible properties of node material in code?

**URL:** <https://forum.babylonjs.com/t/how-to-set-inspector-visible-properties-of-node-material-in-code/38345>\
**Category:** Questions\
**Created:** [February 18, 2023, 2:45pm UTC](https://forum.babylonjs.com/t/how-to-set-inspector-visible-properties-of-node-material-in-code/38345 "2023-02-18T14:45:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peet](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/peet/32/30087_2.png) [@Peet](https://forum.babylonjs.com/u/Peet)\
**Post date:** [February 18, 2023, 2:45pm UTC](https://forum.babylonjs.com/t/how-to-set-inspector-visible-properties-of-node-material-in-code/38345/1 "2023-02-18T14:45:22Z")

</div>

Does anyone know how to set a property value of a json exported node material in code?  
I fetch in the material from file like this:

```
    let checkerMat = await NodeMaterial.ParseFromFileAsync('checker_M', './materials/checker.json', this._scene);

```

then add an observable callback:

```
    checkerMat.onEffectCreatedObservable.add(data => {
        data.effect.setVector2('repeatXY', new Vector2(100, 50));
    });

```

when it gets to the setVector2 it says could not find property repeatXY  
i tried u\_repeatXY as well (as it described as uniform in the fragment shader) but that didnt help.

I created a playground scene to demonstrate the problem:

> **[Babylon.js Playground](https://playground.babylonjs.com/#RFCGZJ)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

After page load, open up the browser javascript console output, you can see the error message:  
Uncaught TypeError: Cannot read properties of undefined (reading ‘repeatXY’)

You can see in the console output, that the effect instance exists, and if you check in that you can see that the fragment shader has a uniform vec2 named u\_repeatXY.  
What am I missing here? How to set these kind of parameters in json parsed NodeMaterials?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 18, 2023, 6:13pm UTC](https://forum.babylonjs.com/t/how-to-set-inspector-visible-properties-of-node-material-in-code/38345/2 "2023-02-18T18:13:40Z")

</div>

You need to use `nodeMaterial.getBlockByName` (or any other `getBlockXXX` method) to get a pointer on the block and change the value property:

> **[Babylon.js Playground](https://playground.babylonjs.com/#RFCGZJ%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Peet](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/peet/32/30087_2.png) [@Peet](https://forum.babylonjs.com/u/Peet)\
**Post date:** [February 18, 2023, 7:10pm UTC](https://forum.babylonjs.com/t/how-to-set-inspector-visible-properties-of-node-material-in-code/38345/3 "2023-02-18T19:10:47Z")

</div>

This is exactly what I was looking for, thank you! Marked as solved!

If I use typescript, value property is not visible on the NodeMaterialBlock class. I have a workaround to set is as nodeBlock[‘value’] = new Vector2(…).  
Is there a more strongly typed approach for typescript?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 18, 2023, 7:45pm UTC](https://forum.babylonjs.com/t/how-to-set-inspector-visible-properties-of-node-material-in-code/38345/4 "2023-02-18T19:45:24Z")

</div>

You can use the `nodeMaterial.getInputBlockByPredicate` method instead of `getBlockByName`:

> **[Babylon.js Playground](https://playground.babylonjs.com/#RFCGZJ%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes
