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

简介

vertices属性是MeshGeometry对象的一个属性,表示网格模型中所有顶点的位置信息。该属性是一个一维浮点型数组,每三个连续的数字表示一个顶点的三维坐标。如:[x1, y1, z1, x2, y2, z2, ... , xn, yn, zn]

用法

可以通过以下方式来访问vertices属性:

mesh.geometry.vertices;

示例

以下示例将创建一个立方体网格模型并打印其所有顶点的位置信息:

// 创建立方体网格模型
var geometry = new Yuka.MeshGeometry();
geometry.vertices = [
    -1, 1, 1,   // v0
    1, 1, 1,    // v1
    1, -1, 1,   // v2
    -1, -1, 1,  // v3
    -1, 1, -1,  // v4
    1, 1, -1,   // v5
    1, -1, -1,  // v6
    -1, -1, -1  // v7
];
geometry.indices = [
    0, 1, 2, 0, 2, 3,  // front
    1, 5, 6, 1, 6, 2,  // right
    5, 4, 7, 5, 7, 6,  // back
    4, 0, 3, 4, 3, 7,  // left
    4, 5, 1, 4, 1, 0,  // up
    3, 2, 6, 3, 6, 7   // down
];
var material = new Yuka.MeshBasicMaterial({ color: 0x00ff00 });
var mesh = new Yuka.Mesh(geometry, material);

// 打印所有顶点的位置信息
console.log(mesh.geometry.vertices);

注意事项

  • 该属性只能在MeshGeometry对象创建时设置,不能在后期更新。
  • vertices属性必须具有三个连续的浮点型数字,否则会导致渲染错误。