【发布时间】:2020-10-14 16:31:37
【问题描述】:
我有一个带有一些半透明自定义几何图形的 Forge 场景。升级到 Forge 查看器的 7.21.0 版本后,我们必须将自定义几何图形移动到覆盖场景中,如 Forge guide 中所述。导航时生成的几何图形是半透明的,但在停止大约半秒后变为不透明。
此代码可用于在http://lmv.ninja.autodesk.com 上进行测试。在此示例中,您可以透过绿色球体看到蓝色球体,但是一旦将鼠标悬停在飞机上(我测试了玩具飞机模型),就无法看到。
const geometry = new THREE.SphereGeometry(20,32,32)
const material = new THREE.MeshBasicMaterial({
color: '#00ff00',
transparent: true,
opacity: 0.5,
})
const sphere1 = new THREE.Mesh(geometry, material)
sphere1.position.y = 90
NOP_VIEWER.overlays.addScene('custom-scene')
NOP_VIEWER.overlays.addMesh(sphere1, 'custom-scene')
const material2 = new THREE.MeshBasicMaterial({color: '#0000ff'})
const sphere2 = new THREE.Mesh(geometry.clone(), material2)
sphere2.position.y = 60
NOP_VIEWER.overlays.addMesh(sphere2, 'custom-scene')
如何使几何图形保持透明?
我已尝试设置useIdBufferSelection: true,正如建议的here。
在材质中设置depthTest: false 或depthWrite: false 可修复透明度问题,但(不出所料)会破坏渲染顺序,因此靠近的物体可能会出现在远处的物体后面。
【问题讨论】:
-
我在 lmv.ninja.autodesk.com 的开发者控制台中使用“Toy Plane”模型尝试了您的代码。球体将在座椅顶盖的中间结束,对我来说它保持透明。那里也适合你吗?
-
@AdamNagy 感谢您的回复。恐怕我以前没有使用过 lmv.ninja.autodesk.com - 我如何掌握现场?
-
使用可以使用NOP_VIEWER forge.autodesk.com/blog/do-simple-viewer-api-tests-quickly
-
好的,这也适用于我。我想我必须进行更多调查才能制作一个可重复的示例。谢谢。
-
@AdamNagy 透明度问题似乎只与覆盖场景中的其他几何体有关。我将代码更新为在 lmv.ninja.autodesk.com 上显示的内容。
标签: autodesk-forge autodesk-viewer