autodesk-viewer - 伪造查看器房间颜色更改不起作用
问题描述
我有一个级别列表,单击每个级别都会显示房间。我想更改每个房间对象的颜色。我尝试使用以下代码片段:
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 );
};
两者都没有工作,你能帮我解决这个问题吗?
解决方案
该函数的第二个参数viewer.setThemingColor
只接受THREE.Vector4
,这就是它不适合你的原因。您必须将代码更改为这种方式,请在此处查看答案:
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/
希望能帮助到你。
推荐阅读
- postgresql - 带有 EXECUTE 和嵌套 format() 的动态 SQL
- javascript - Javascript 中的井字游戏 - 改变玩家
- json - 我可以在不使用 Javascript 的情况下将图像添加到 json 文件吗?
- python - 根据两个数据帧中的条件将列添加到另一个数据帧的数据帧
- python - Colab FileNotFoundError:[Errno 2] 没有这样的文件或目录:'labelfile_path'
- design-patterns - 设计模式的“意图”和“问题”有什么区别?
- mongodb - 使用 mongoose 中的现有值一次更新多个值
- python - 我在 Python 上不断收到错误,TypeError: unsupported operand type(s) for /: 'tuple' and 'int' 我做错了什么?
- bit-manipulation - 以 8 位发送 12 位数字
- emacs - 如何在 emacs (slime) 上使用 package-initialize 来阻止包初始化