Class: ScaledVector

PD. ScaledVector

A normalised THREE.Vector3 direction vector that includes a scale component.

This is a vector where the x, y and z components give the normalised direction vector between two points, and the scale component is the absolute distance between them, or the magnitude of the vector, stored in model units.

Whilst this class is similar in some ways to a THREE.Vector4, its instances are almost invariably used with THREE.Vector3 instances, so it is critical that it inherit methods that take THREE.Vector3 instances as input in order to be entirely interchangeable. Using a THREE.Vector4 would have meant having to deal with methods that require other THREE.Vector4 instances as input.


new ScaledVector(x, y, z, scale)

Creates a new 3D scaled direction vector.

Parameters:
Name Type Default Description
x number 0

The normalised X-axis component of the vector.

y number 0

The normalised Y-axis component of the vector

z number 0

The normalised Z-axis component of the vector

scale number 0

The magnitude of the vector.

Author:
  • drajmarsh

Extends

  • THREE.Vector3

Members


:boolean

isScaledVector <readonly>

A flag identifying this object as a scaled vector.

Type
  • boolean

:number

scale

Stores a distance component in model units.

Type
  • number

Methods


copyWithScale(m_vec)

Copies the x, y, z and scale components.

Parameters:
Name Type Description
m_vec PD.ScaledVector

The magnitude vector to copy from.

Returns:

Returns this vector to support method chaining.

Type
PD.ScaledVector

setFromPoints(pt1, pt2)

Calculates the projected vector between two 3D points.

NOTE: This method changes values within the out parameter, however it is safe to use the same instance as pt1 or pt2 to change it in-place.

Parameters:
Name Type Description
pt1 THREE.Vector3

The start position of the line.

pt2 THREE.Vector3

The end position of the line.

Returns:

Returns this vector to support method chaining.

Type
PD.ScaledVector

fromPoints(pt1, pt2) <static>

Create a new vector with the magnitude of the vector between the given points.

Parameters:
Name Type Description
pt1 THREE.Vector3

The start position of the line.

pt2 THREE.Vector3

The end position of the line.

Returns:

Returns a new magnitude vector.

Type
PD.ScaledVector

fromVector3(vec) <static>

Create a new vector with the magnitude of the given vector.

Parameters:
Name Type Description
vec THREE.Vector3

A generic vector object.

Returns:

Returns a new magnitude vector.

Type
PD.ScaledVector