nytimes / three-loader-3dtiles

This is a Three.js loader module for handling OGC 3D Tiles, created by Cesium. It currently supports the two main formats, Batched 3D Model (b3dm) - based on glTF Point cloud.
Other
452 stars 63 forks source link

the trouble of raycaster #97

Closed AHSss closed 6 months ago

AHSss commented 1 year ago

When I used the raycaster in threejs to get coordinates of some points on 3dtitles-model's surface . But sometimes coordinates witch I got was not on the surface . It seems raycaster get the lower LODs model‘s surface . How can I avoidance the lower LODs model‘s surface ?Or how can I got the right coordinates of points on 3dtitles-model's surface?I need your help!Thanks very much! @Avnerus

1691681492615
wanyanyan commented 6 months ago

I get the same problem and found a solution. I discarded the objects witch is not visible, and intersect only visible objects.

    let allMeshs = []
    tileset.children.forEach(d => {
      if (!d.visible) {
        return
      }
      d.traverse(e => {
        if (e.isMesh) {
          allMeshs.push(e)
        }
      })
    })
    const intersects = raycaster.intersectObjects(allMeshs)
    if (!intersects.length) {
      return null
    }
    return intersects[0].point
AHSss commented 6 months ago

Thanks very much !!!I tried your solution and it‘s solved my problem. It took a long time, but you did help me. Thank you again, my friend. @wanyanyan