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

vertices

Introduction

在几何学中,一个多面体的顶点(vertices)是它的角落或它最远的顶点。在Yuka库中,vertices用于表示多面体的顶点信息。此文档将介绍如何使用Yuka库的Polyhedron类的vertices属性。

Syntax

const vertices = polyhedron.vertices;

Returns

该属性返回包含多面体顶点数据的数组对象。其中每个元素都表示多面体一个顶点的位置坐标。

Example

import { Polyhedron } from 'yuka';

const vertices = [
    new Vector3( 0, 0, 1.2 ),
    new Vector3( 0, 1.2, 0 ),
    new Vector3( -1.1, -0.6, 0 ),
    new Vector3( 1.1, -0.6, 0 ),
    new Vector3( 0, 0, -1.2 )
];

const indices = [
    0, 1, 2,
    0, 2, 3,
    1, 0, 4,
    2, 1, 4,
    3, 2, 4,
    0, 3, 4
];

const polyhedron = new Polyhedron( vertices, indices );

console.log( polyhedron.vertices );

输出结果:

[
    Vector3 { x: 0, y: 0, z: 1.2 },
    Vector3 { x: 0, y: 1.2, z: 0 },
    Vector3 { x: -1.1, y: -0.6, z: 0 },
    Vector3 { x: 1.1, y: -0.6, z: 0 },
    Vector3 { x: 0, y: 0, z: -1.2 }
]

Remarks

在该属性返回的顶点数组中,每个顶点的索引顺序顺序按顺序排列。如果是通过其他方式创建的多面体实例,该顺序可能会有所不同。

See Also