I want to change the tiling, and I did this:
var box=app.scene.root.findByName("Box").model.meshInstances[0];
box.material.diffuseMapOffset=new pc.Vec2(.5,.5);
box.material.update();
But, nothing happened. How do I change those settings from js?
I want to change the tiling, and I did this:
var box=app.scene.root.findByName("Box").model.meshInstances[0];
box.material.diffuseMapOffset=new pc.Vec2(.5,.5);
box.material.update();
But, nothing happened. How do I change those settings from js?
This works:
box.material.opacityMapTransformUniform[2]=.2
But is this the right way?
Edit: Nope. Not working anymore
That should throw an error.
findByName
returns a graphNode and material
is not a property of a graphNode.
It is returning an entity for me and I can manipulate the instance Ok.
And I am also able to get the material.
Entity inherits from graphNode. In any case, material
is not a property of either.
//from console
pc.app.scene.root.findByName("2D Box1b").model.meshInstances[0].material
//output
StandardMaterial {name: "Material", id: 28, _shader: Shader, variants: {…}, parameters: {…}, …}
Oops, my bad. Mobile view chopped off the model.meshInstances[0]
part.
I only saw:
var box=app.scene.root.findByName("Box");
box.material.diffuseMapOffset=new pc.Vec2(.5,.5);
box.material.update();
It seems if I set the tiling from the editor, I can update. Otherwise, the parameters are missing from the shader.
I think I’ll try to make a new project to see if I can isolate it. I feel like I tried everything
Yeah, opacityMapOffset needs to be set as well as I’m having an alpha channel
6 hours of struggle took me away from my main experiment