How to detect collision in webgl?

后端 未结 4 729
陌清茗
陌清茗 2021-01-05 18:13

How to detect collision in webgl, without using any library like three.js?

4条回答
  •  余生分开走
    2021-01-05 18:45

    A simple approach it to do ray collision detection on the GPU. Checkout the following blogpost about the topic.

    http://blog.xeolabs.com/ray-picking-in-scenejs

    The main idea is to render the scene to a texture (using a FBO) using a shader that saves object ids instead of color. Then you can very fast do a lookup in this texture to see what a ray collides with.

提交回复
热议问题