egret-docs-master/Engine3D/interactive/modelPoint/README.md

47 lines
890 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

## 模型与点碰撞
### 原理:
* 检测模型与点碰撞其实就是检测一个点是否在模型内。在 egret3d 中,模型与点碰撞,是通过模型的 bound 来检测是否包含这个点egret3d.Vector3D来实现。
这里为了更好的理解,我们将“点“想象成一个稍微大些的球。
* 未碰撞:
![image](575cd7a180397.png)
* 碰撞:
![image](575cd7a1ab7fb.png)
### apiegret3d.Bound:
~~~
pointIntersect ( pos :egret3d.Vector3D ):boolean
~~~
~~~
pos:egret3d.Vector3D — 检测的点
~~~
### 示例:
```
var vector3d:egret3d.Vector3D = new egret3d.Vector3D(ball.x, ball.y, ball.z);
var result:boolean = cube.bound.pointIntersect(vector3d);
```
```
* cube一个模型
* bound模型的数据
* pointIntersect检测方法
* vector3d 点的数据
* result 是否碰撞true 碰撞false 未碰撞
```