【问题标题】:Forge viewer rooms color changes were not working伪造查看器房间颜色更改不起作用
【发布时间】:2018-12-03 20:35:20
【问题描述】:

我有一个级别列表,点击每个级别都会显示房间。我想更改每个房间对象的颜色。我尝试过使用以下代码 sn-p:

var selSet1 = NOP_VIEWER.getSelection();
NOP_VIEWER.clearSelection();
var color = new THREE.Color( 255 / 255, 0, 0, 1 );
for( let i = 0; i < selSet1.length; i++ ) {
    NOP_VIEWER.setThemingColor( selSet1[i], color );
}


Autodesk.Viewing.Viewer3D.prototype.setColorMaterial = function(objectIds, color){
  if( !(color instanceof THREE.Color) ) throw 'Invalid argument: Color';
    var material = new THREE.MeshPhongMaterial
      ({
        color:      color,
        opacity:    0.8,
        transparent: true
      });
    NOP_VIEWER.impl.matman().addMaterial( 'ColorMaterial-' + new Date().getTime(), material, true );
};

两者都不工作,你能帮我解决这个问题吗?

【问题讨论】:

    标签: autodesk-viewer


    【解决方案1】:

    函数viewer.setThemingColor 的第二个参数只接受THREE.Vector4,这就是它不适合你的原因。你得把你的代码改成这样,请查看答案here

    var selSet1 = NOP_VIEWER.getSelection();
    NOP_VIEWER.clearSelection();
    var color = new THREE.Vector4( 255 / 255, 0, 0, 1 );
    for( let i = 0; i < selSet1.length; i++ ) {
        NOP_VIEWER.setThemingColor( selSet1[i], color );
    }
    

    这里是查看器文档:https://developer.autodesk.com/en/docs/viewer/v2/reference/javascript/viewer3d/

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2021-03-14
      • 2021-04-25
      • 2017-11-03
      • 1970-01-01
      • 2018-06-28
      • 2018-10-22
      • 2019-05-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多