Overlay mesh is transparent for certain material colors in Forge 3D viewer

此生再无相见时 提交于 2021-02-05 08:07:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!