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

fromMatrix3

静态方法 fromMatrix3 用于从一个 3x3 矩阵生成一个 4x4 矩阵。

语法

Matrix4.fromMatrix3(matrix3: Matrix3): Matrix4

参数

  • matrix3Matrix3 类型,需要转换成 4x4 矩阵的 3x3 矩阵。

返回值

  • Matrix4 类型,返回生成的 4x4 矩阵。

示例

import { Matrix3, Matrix4 } from 'yuka';

const matrix3 = new Matrix3().set(
    0, 1, 2,
    3, 4, 5,
    6, 7, 8
);

const matrix4 = Matrix4.fromMatrix3( matrix3 );
console.log( matrix4 );

描述

通过 Matrix4.fromMatrix3 方法,可以将一个 3x3 的矩阵转换成为 4x4 的矩阵。转换后,矩阵右侧新增一列和底部新增一行分别填充的是 [0, 0, 0, 1]。这个方法可以方便的将 3D 的旋转矩阵转换成一个 4x4 的变换矩阵,以便于应用平移和缩放等变换。

异常

如果参数 matrix3 不是 Matrix3 类型,则会抛出 TypeError

参考