Sketchfab Forum

Can i "move" with the translate function a material instead of a node?


(4535992) #1

Hi, i have sucessed to move a node with the method translate of the api, but i wonder if there is some way to move a material on the same way. I read the documentation and it's say "Important: Only MatrixTransform nodes can be translated" but i just wonder if someone has found it some alternative solution for reach the same result.

(Madalin Berechet) #2

Do you have a multi material node? Use a prefix for all nodes you want to move, i.e. prefix.node1, prefix.node2 and so on. Then you can select all nodes begining with this prefix.
You can find an answer using this:

var myNodes = [];
api.getNodeMap( function ( err, nodes ) {
if ( !err ) {
console.log( nodes);//you can see here all nodes and nodes type.
var index;
for (var key in Object.keys(nodes)){
index = Object.keys(nodes)[key];
if (nodes[index].type == "replace here with node types containing Matrix" ){
geometryName = nodes[index].name;
myNodes[geometryName] = {id: index};
for (var key in myNodes){
if(key.startsWith('replace here with some prefix')){
// try some matrix operations

(4535992) #3

ty @MadalinBerechet is a valid alternative if there is no way to use the material directly a multinode solution seem be the only solution. I hope the sketchfab team provide for such implementation in the future, it can be very useful for anyone can't adjust the materials/nodes on the model.