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

fromMatrix4Column

该函数是Vector3类的一个静态方法,用于从给定的Matrix4对象的索引值中获取Vector3对象。

语法

Vector3.fromMatrix4Column(matrix, index);

参数

  • matrix: 一个Matrix4对象,表示要获取Vector3对象的矩阵。
  • index: 一个整数,表示在该矩阵的第几列中获取Vector3对象。索引值从0开始。

返回值

一个 Vector3对象,表示在矩阵的指定列中提取的3D矢量坐标。

示例

//导入Vector3类
import { Vector3 } from 'Yuka.js';

//创建Matrix4矩阵
const matrix = new Matrix4();

//设置矩阵的值
matrix.set(
    1, 0, 0, 0, 
    0, 1, 0, 0,
    0, 0, 1, 0,
    1, 2, 3, 1
);

//从矩阵的第三列中提取Vector3对象
const vector = Vector3.fromMatrix4Column(matrix, 2);

console.log( vector ); //output: Vector3 { x: 0, y: 3, z: 0 }

备注

  • 该方法属于Vector3类的静态方法,因此可以直接从Vector3类中调用。
  • 确认矩阵中有足够的列可以提取Vector3对象的值,否则会返回无效值。
  • 根据索引值访问矩阵时,请确保矩阵中是列优先存储的。