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

subScalar

subScalar是Vector3对象的一个方法,用于将Vector3的每一个元素都减去一个标量scalar,返回一个新的Vector3对象。

语法

vector.subScalar(scalar)

参数

  • scalar: 数值类型,指代要减去的标量。

返回值

返回一个新的Vector3对象。

示例

const vector1 = new THREE.Vector3(10, 20, 30);
const vector2 = vector1.subScalar(5);

console.log(vector1);  // 输出:Vector3 {x: 10, y: 20, z: 30}
console.log(vector2);  // 输出:Vector3 {x: 5, y: 15, z: 25}

在上面的示例中,我们定义了一个初始值为(10, 20, 30)的Vector3对象vector1,并使用subScalar方法将其每个元素都减去了5,得到新的Vector3对象vector2,然后输出结果。

注意事项

  • subScalar方法不改变原有的Vector3对象,而是返回一个新的Vector3对象。
  • scalar参数可以是正数、负数或0。

参考文献