Using the Sketchfab API examples and documentation Ive found the following code
api.getSceneGraph(function (err, result) {
if (err) {
console.log('Error getting nodes');
return;
} // get the id from that log
for (let i = 0 ; i < result.length;i++) {
console.log('Model Number' + i + result[i].name);
}
console.log(result);
});
This returns all of the relevant information that I need including the material and object ID along with its name. But how do I get an array of the models/objects in the scene?
In the following code I am able to get exactly that with the material number
api.getMaterialList( function( err, materials ) {
for (let i = 0 ; i < materials.length;i++) {
if (materials[i].name == "Material__01_Red") {
materialNumber_Group_01 = i;
}
console.log('Material Number' + i + materials[i].name);
}
var materialToUpdate = materials[3];
var materialToCopy = materials[materialNumber_Group_01];
materialToCopy.stateSetID = materialToUpdate.stateSetID;
api.setMaterial( materialToCopy, function() {
console.log( 'Material updated' );
} );
} );