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

fromAABB

该方法是Yuka js库中的一个函数,用于从AABB(轴对齐的包围盒)生成一个OBB(有向包围盒)。

用法

import { Vector3, Quaternion, Box3 } from 'three';
import { OBB } from 'yuka';

const aabb = new Box3(new Vector3(-1, -1, -1), new Vector3(1, 1, 1));
const obb = new OBB().fromAABB(aabb, new Quaternion());

参数说明

  • aabb: {Box3} AABB对象。
  • orientation: {Quaternion} 在生成OBB时用来设置朝向的四元数。如果未提供,则默认为单位矩阵。

返回值

返回一个OBB实例,代表从AABB生成的有向包围盒。

示例说明

import { Vector3, Quaternion, Box3 } from 'three';
import { OBB } from 'yuka';

const aabb = new Box3(new Vector3(-1, -1, -1), new Vector3(1, 1, 1));
const obb = new OBB().fromAABB(aabb, new Quaternion());

console.log(aabb.min.toArray()); // [-1, -1, -1]
console.log(aabb.max.toArray()); // [1, 1, 1]
console.log(obb.center.toArray()); // [0, 0, 0]
console.log(obb.halfSizes.toArray()); // [1, 1, 1]
console.log(obb.rotation.toArray()); // [0, 0, 0, 1]

在上面的示例中,我们首先定义了一个AABB对象,表示一个在3D场景中占据一定空间的立方体。接着,我们使用该AABB对象和一个默认四元数值调用fromAABB方法生成一个OBB有向包围盒实例。最后,我们打印出了OBB的一些属性,包括中心点坐标、半尺寸、旋转矩阵等。