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

Primitives

介绍

在Yuka.js库的BVHNode中,Primitives是一组几何物体,如三角形或球体,作为场景中的基本元素。BVHNode将这些几何物体分割成子节点,以加速光线追踪与其他基于射线的技术。

方法

add( primitive )

Primitives中添加一个几何物体。

  • primitive:要添加的几何物体。
const primitives = new YUKA.Primitives();
const sphere = new YUKA.Sphere( 1 );
primitives.add( sphere );

remove( primitive )

Primitives中删除指定的几何物体。

  • primitive:要删除的几何物体。
primitives.remove( sphere );

clear()

Primitives中删除所有几何物体。

primitives.clear();

getBoundingSphere( sphree )

计算该节点及其子节点包围盒的边界球体。

  • sphree:返回计算出的边界球体。
const sphere = new YUKA.Sphere();
primitives.getBoundingSphere( sphere );

属性

primitives

一个包含所有几何物体的数组。

console.log( primitives.primitives );

示例

const primitives = new YUKA.Primitives();
const sphere = new YUKA.Sphere( 1 );
primitives.add( sphere );

const ray = new YUKA.Ray( new YUKA.Vector3( 0, 0, -2 ), new YUKA.Vector3( 0, 0, 1 ) );
const intersections = [];
primitives.intersectRay( ray, intersections );

if ( intersections.length > 0 ) {
    console.log( 'Intersection found!' );
}