Back to the Shapespark home page

Extensions on change trigger

Hello team Shapespark.

Does Shapespark support functions for changing options within extensions (with “type”: “MaterialPicker”) ?

Example:
I have a trigger with “name”: “1” and 3 Pick,
In there:
“toReplace”: “Flooring-light”,
“toPick”: [ “Flooring-Med”, “Flooring-Dark”],

==> I want to use the event to change it without having to click on the trigger.

There are no such functions.

Do you need to use the Material Picker extension? If not, you could change materials in the scene with JavaScript using the viewer API, see: API change material for another - #2 by jan

1 Like

I have tried and it works for my requirements
see: API change material for another - #2 by jan
Thank you.

var dark = viewer.findMaterial('Flooring-Dark');
var light = viewer.findMeshesWithMaterial('Flooring-light');
var med = viewer.findMeshesWithMaterial('Flooring-Med');

for (var i = 0; i < light.length; ++i) {
  viewer.setMaterialForMesh(dark, light[i]);
}

for (var i = 0; i < med.length; ++i) {
  viewer.setMaterialForMesh(dark, med[i]);
}
viewer.requestFrame();
1 Like