javascript - How to change the color of widgets through API?
巴扎黑
巴扎黑 2017-07-05 10:59:19
0
1
1204

How to change the color of a component in Forge Viewer?

巴扎黑
巴扎黑

reply all(1)
習慣沉默

Yes, you can set it through the viewer.setThemingColor() function. The parameter it accepts is a THREE.Vector4. Forge Viewer uses (x, y, z) of THREE.Vector4 to represent the three primary colors (r, g, b), w represents the opacity alpha, note that each parameter is between 0 Between 1 and 1, the color codes of the three primary colors must be divided by 255. The calling example is as follows:

// 变成红色
var color = new THREE.Vector4( 255/255, 0, 0, 1 );

viewer.setThemingColor( 2498, color);

Screenshot of the result, the original green space turned red:

If you want to restore the color of the component, you can call viewer.clearThemingColors() This function will clear the color settings. The results are as follows:

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template