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

applyMatrix4方法

applyMatrix4方法用于将一个4x4的矩阵作用(乘法)于一个边界球体(BoundingSphere)。该方法会改变该边界球体的中心点和半径。

语法

applyMatrix4(matrix: Matrix4): BoundingSphere

参数

  • matrix :应用于边界球体的4x4矩阵(Matrix4)。

返回值

返回边界球体(BoundingSphere)。

描述

被应用的矩阵(matrix)必须是一个非平移矩阵,否则结果会不正确。所以当矩阵中有平移成分时,建议使用translate方法来改变边界球体。

示例

// 创建一个边界球体
const boundingSphere = new THREE.Sphere(new THREE.Vector3(0, 0, 0), 1);

// 创建一个模型矩阵
const matrix = new THREE.Matrix4();
matrix.rotateX(Math.PI / 4);
matrix.rotateY(Math.PI / 4);
matrix.scale(new THREE.Vector3(2, 2, 2));

// 将矩阵作用于边界球体
boundingSphere.applyMatrix4(matrix);

// 输出结果
console.log(boundingSphere.center); // 2.121320343559641, 0, 2.121320343559641
console.log(boundingSphere.radius); // 2.8284271247461903

参考文献