为了在伪造查看器中为许多对象设置颜色,我做了一个扩展,可以在材质上设置颜色并将对象连接到材料。这样,我只更新一次查看器,而不是多次。但是,我希望没有透明性,但是即使将材料透明性设置为false,我也会继续这样做。我该如何解决?
void setColorMaterial(material, viewer)
{
var mesh_material = this.addMaterial(material, viewer)
for (var i=0; i< material.dbIds.length; i++) {
var dbid = material.dbIds[i]
var it = viewer.model.getData().instanceTree
it.enumNodeFragments(dbid, function (fragId) {
var renderProxy = viewer.impl.getRenderProxy(viewer.model, fragId)
renderProxy.meshProxy = new THREE.Mesh(renderProxy.geometry, renderProxy.material)
renderProxy.meshProxy.matrix.copy(renderProxy.matrixWorld)
renderProxy.meshProxy.matrixWorldNeedsUpdate = true
renderProxy.meshProxy.matrixAutoUpdate = false
renderProxy.meshProxy.frustumCulled = false
viewer.impl.addOverlay(material.name, renderProxy.meshProxy)
}, false)
}
this.materialHolder.push(material)
viewer.impl.invalidate(true)
}
void addMaterial(material, viewer)
{
var mesh_material = new THREE.MeshPhongMaterial({
color: #007dfa,
opacity: 1,
transparent: false,
name: 'materialName'
})
viewer.impl.matman().addMaterial(this.newGuid(), mesh_material)
viewer.impl.createOverlayScene(material.name, mesh_material, mesh_material)
}
答案 0 :(得分:0)
首先,感谢您的答复,很遗憾,透明度仍然存在。
Alex:我消除了不透明度。
Bryan:我根据您的建议修复了代码(据我了解)。下面是更新的代码。
从链接的图片中可以看到,透明度仍然存在。任何其他建议将不胜感激。
setColorMaterial(material, viewer) {
var mesh_material = this.addMaterial(material, viewer)
for (var i=0; i< material.dbIds.length; i++) {
var dbid = material.dbIds[i]
//from dbid to node, to fragid
var it = viewer.model.getData().instanceTree
it.enumNodeFragments(dbid, function (fragId) {
var renderProxy = viewer.impl.getRenderProxy(viewer.model, fragId)
renderProxy.meshProxy = new THREE.Mesh(renderProxy.geometry, mesh_material)
renderProxy.meshProxy.matrix.copy(renderProxy.matrixWorld)
renderProxy.meshProxy.matrixWorldNeedsUpdate = true
renderProxy.meshProxy.matrixAutoUpdate = false
renderProxy.meshProxy.frustumCulled = false
viewer.impl.addOverlay(material.name, renderProxy.meshProxy)
}, false)
}
viewer.impl.invalidate(true)
}
addMaterial(material, viewer) {
var mesh_material = new THREE.MeshPhongMaterial({
color: material.color,
transparent: false,
blendEquationAlpha: false,
name: material.name
})
viewer.impl.matman().addMaterial(this.newGuid(), mesh_material)
viewer.impl.createOverlayScene(material.name, mesh_material)
return mesh_material
}