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

halfSizes

说明

halfSizesYuka js库中的一个用于计算 OBB(有向边界框) 一半尺寸的函数。

OBB 是一种包含对象的最小轴对齐的矩形,具有定义对象位置、朝向和尺寸的优点。

语法

halfSizes(obb, result)

参数

  • obb :定义了对象位置、朝向和尺寸的有向边界框。类型为 OBB
  • result :可选参数。存储计算结果的向量对象。如果未提供该参数,则会创建一个新的向量并将其返回。类型为 Vector3

返回值

返回一个 Vector3 向量对象,该向量对象的值为 OBB 的一半尺寸。

示例

import { OBB, Vector3, halfSizes } from 'yuka';

const obb = new OBB();
obb.halfSizes.set( 1, 2, 3 ); // 设置OBB的一半尺寸

const result = new Vector3();
halfSizes( obb, result );

console.log( result ); // 输出: { x: 1, y: 2, z: 3 }

参考