AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

plane

plane方法可以创建一个平面。

参数

  • points:类型为Array,包含平面上的所有点坐标。
  • normal:类型为Array,表示平面的法向量。

返回值

平面对象,包括以下属性和方法:

  • points:平面上的点坐标数组。
  • normal:平面的法向量。
  • distanceToPoint方法:获取平面到某一点的距离。
  • projectPoint方法:投影点到平面上。

示例

const points = [
  [0, 0, 0],
  [10, 0, 0],
  [10, 10, 0],
  [0, 10, 0]
];
const normal = [0, 0, 1];
const plane = Yuka.Polygon.plane(points, normal);
console.log(plane.points); // [ [ 0, 0, 0 ], [ 10, 0, 0 ], [ 10, 10, 0 ], [ 0, 10, 0 ] ]
console.log(plane.normal); // [ 0, 0, 1 ]
const point = [5, 5, 1];
console.log(plane.distanceToPoint(point)); // -1
console.log(plane.projectPoint(point)); // [ 5, 5, 0 ]

异常

如果points数组中的点数量小于3,则会抛出异常。