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

fromArray

将给定的数组作为四元数的元素创建一个新的Quaternion对象。

语法

Quaternion.fromArray(array, offset)

参数

  • array:传入的数组,其中包含四元数的元素。
  • offset:可选参数,指定在数组中从哪个索引开始读取四元数元素。默认为0。

返回值

返回一个新的Quaternion对象,其元素来自传入的数组。

示例

const array = [0.707, 0, 0, 0.707];
const quat = Quaternion.fromArray(array);
console.log(quat); // Quaternion { x: 0.707, y: 0, z: 0, w: 0.707 }
const array = [1, 2, 3, 4, 0.5, 0.5];
const quat = Quaternion.fromArray(array, 1);
console.log(quat); // Quaternion { x: 2, y: 3, z: 4, w: 0.5 }

版本说明

此函数在Yuka 2.0.0版中被引入。

参考文献