【发布时间】:2019-07-29 10:46:07
【问题描述】:
我试图通过 fragId 保存元素的旧材料,但无法执行此操作,因为 tree.enumNodeFragments() 文档或窗口内部不可访问。
highlight(externalId, color, dict) {
let viewer = this.viewer;
var dbId = dict[externalId];
let myMaterial = this.createMaterial(color);
// used to rescale and remove the z-fighting
let scaleRatio = 1.005; // this was determined as optimal through visual inspection
var tree = NOP_VIEWER.model.getData().instanceTree;
document.oldMaterials = {};
tree.enumNodeFragments(dbId,
function(fragId) {
document.oldMaterials[fragId] = viewer.model.getFragmentList().getMaterial(fragId);
viewer.model.getFragmentList().setMaterial(fragId, myMaterial);
/* important technique if you want to remove z-fighting */
let fragProxy = viewer.impl.getFragmentProxy(viewer.model, fragId);
fragProxy.scale = new THREE.Vector3(scaleRatio, scaleRatio, scaleRatio);
fragProxy.updateAnimTransform();
},
true);
viewer.impl.invalidate(true);
}
【问题讨论】:
标签: javascript autodesk-forge autodesk-viewer