问题
I'm trying to add custom geometry to my forge viewer, following this example. It mostly works fine, except when using certain colors.
I'm using the following code to add a sphere mesh:
const geometry = new THREE.SphereGeometry(0.4, 32, 32)
const material = new THREE.MeshBasicMaterial({
color: someColor,
transparent: false,
})
const sphere = new THREE.Mesh(geometry, material)
viewer.overlays.addScene('sphere-mesh-scene')
viewer.overlays.addMesh(sphere, 'sphere-mesh-scene')
for certain values of someColor
the sphere is transparent, for other values, it's not:
e.g.
#6b6e75
and #54ffff
yields a transparent sphere,
while
#000000
and #988888
yields an opaque sphere.
Is there any material properties I need to set to avoid this? Or do I need to deal with the material manager in forge?
I'm using forge viewer version 7.14.0.
Edit
I also get the same result for point clouds - with a point cloud with many different colors, some of the points are transparent, and get a "glowing outline" against the Forge geometry.
回答1:
This is happending because by default the blend shader determines if it should add transparency (to selected nodes for instance) by its hue color in the overlay...
We can suppress this behavior by turning useIdBufferSelection
in the initOptions
like below when calling viewer.start/loadModel(svf,options,cb,cb,cb,initOptions)
:
viewer.loadModel(svf,null,null,null,{useIdBufferSelection:true});
See live demo here
来源:https://stackoverflow.com/questions/60717863/overlay-mesh-is-transparent-for-certain-material-colors-in-forge-3d-viewer