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

width

width 是 Yuka js 库的 CellSpacePartitioning 类中的一个属性,用于设置网格区域的宽度。

语法

cellSpacePartitioning.width = value;
  • value:网格区域的宽度,为正整数。

描述

width 属性用于设置网格区域的宽度。在初始化 CellSpacePartitioning 类实例时,需要传入整个区域的宽度和高度,然后根据 widthheight 的值,计算出整个区域被分成了多少个网格。在后续的运算中,每个游戏对象所在的网格将直接影响它附近的对象。

默认情况下,width 属性被设置为 100。

示例

以下示例显示如何使用 width 属性更改网格区域的宽度:

import { CellSpacePartitioning } from 'yuka';

const cellSpacePartitioning = new CellSpacePartitioning( 500, 500 );
cellSpacePartitioning.width = 50;

// 输出结果:10
console.log( cellSpacePartitioning.grid.length );

参考