Hello!
I’m working on a three js model editor and one of things we’d like to be able to do is to toggle triplanar mapping on and off on a material.
I’ve been doing a ton of research and found out about the new node system. Perhaps this is naive but my first attempt was this:
useTriplanarMapping(obj) {
const triplanarMaterial = Nodes.NodeMaterial.fromMaterial(obj.material);
triplanarMaterial.colorNode = Nodes.triplanarTexture(Nodes.texture(obj.material.map));
triplanarMaterial.normalNode = Nodes.triplanarTexture(Nodes.texture(obj.material.normalMap));
obj.material = triplanarMaterial;
}
This code runs without errors but the object doesn’t look any different on the next and subsequent renders. I’ve included the mesh I was testing on (I was trying to create the same effect seen in GitHub - adamringhede/triplanar-demo)
triplanar-sphere-test.glb (2.4 MB)
I feel like I’ve misunderstood something but I can’t seem to figure it out by googling.
What am I missing here?
Also, can I do this same sort of thing for all the other maps in a MeshPhysicalMaterial (metalness, ao, transmission, etc…)?