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

lookAt

lookAt()方法是Matrix3库中的一个函数,用于设置相机的位置和视角。

语法

Matrix3.lookAt(position: Vector3, target: Vector3, up: Vector3): Matrix3

参数

  • position: Vector3 - 相机的位置向量。
  • target: Vector3 - 相机视角朝向的目标向量。
  • up: Vector3 - 相机方向中的上向量。

返回值

返回一个Matrix3对象,它包含相机的位置和视角。

描述

lookAt()方法是用于让相机朝向特定方向的函数。确定相机位置、视角和上向量并将它们传递给此函数,相机将在透视图中呈现。

示例

const position = new Vector3(0, 0, 5);
const target = new Vector3(0, 0, 0);
const up = new Vector3(0, 1, 0);

const viewMatrix = Matrix3.lookAt(position, target, up);

注意事项

  • 此函数只能在3D世界中使用,不适用于2D画布。
  • up向量不应该平行于position - target的向量,否则可能导致视图反转。
  • 在使用相机进行渲染之前,需要将视角矩阵与投影矩阵相乘来生成最终的变换矩阵。