Skip to content

Documentation / scene / PlaneShape

Class: PlaneShape

Defined in: libs/scene/src/shapes/plane.ts:36

The plane shape

Extends

Implements

  • Clonable<PlaneShape>

Constructors

Constructor

new PlaneShape(options?): PlaneShape

Defined in: libs/scene/src/shapes/plane.ts:48

Creates an instance of plane shape

Parameters

options?

PlaneCreationOptions

The creation options

Returns

PlaneShape

Overrides

Shape.constructor

Properties

_defaultOptions

static _defaultOptions: object

Defined in: libs/scene/src/shapes/plane.ts:37

size

size: number = 1

resolution

resolution: number = 1

twoSided

twoSided: boolean = false

anchor

anchor: number = 0.5

needNormal

needNormal: boolean = true

needTangent

needTangent: boolean = true

needUV

needUV: boolean = true

transform

transform: any = null

Overrides

Shape._defaultOptions


_options

protected _options: object

Defined in: libs/scene/src/shapes/shape.ts:35

size

size: number

Default size of axis x and axis y, default is 1

sizeX

sizeX: number

Size of axis x, default value equals to size

sizeY

sizeY: number

Size of axis y, default value equals to size

resolution

resolution: number

Resolution, default is 1

resolutionX

resolutionX: number

Resolution X, default value equals to resolution

resolutionY

resolutionY: number

Resolution Y, default value equals to resolution

twoSided

twoSided: boolean

Whether this plane have front side, default is true

anchor

anchor: number

Anchor, default is 0.5

anchorX

anchorX: number

Anchor X, default value equals to anchor

anchorY

anchorY: number

Anchor Z, default value equals to anchor

needNormal

needNormal: boolean

true if we need to calculate normals for the shape

needTangent

needTangent: boolean

true if we need to calculate tangents for the shape

needUV

needUV: boolean

true if we need to calculate texture coordinates for the shape

transform

transform: object

Transform matrix for the shape

Index Signature

[key: number]: number

transform.equalsTo()

equalsTo(other, epsl?): boolean

Check if all data is close enough to another

Parameters
other

Float32Array<ArrayBuffer>

The data to be compared with.

epsl?

number

Returns

boolean

true if close enough, otherwise false.

transform.toString()

toString(): string

Convert this to string object.

Returns

string

transform.isNaN()

isNaN(): boolean

Check the data for the presence of NaN.

Returns

boolean

true if NaN is present, otherwise false.

transform.setRandom()

setRandom(minValue, maxValue): void

Generate random vector

Parameters
minValue

number

Minimum value of any component of the vector

maxValue

number

Maximum value of any component of the vector

Returns

void

transform.clone()

clone(): Matrix4x4

Creates a new Matrix4x4 initialized with values from this matrix.

Returns

Matrix4x4

The new matrix.

transform.m00

m00: number

transform.m10

m10: number

transform.m20

m20: number

transform.m30

m30: number

transform.m01

m01: number

transform.m11

m11: number

transform.m21

m21: number

transform.m31

m31: number

transform.m02

m02: number

transform.m12

m12: number

transform.m22

m22: number

transform.m32

m32: number

transform.m03

m03: number

transform.m13

m13: number

transform.m23

m23: number

transform.m33

m33: number

transform.getRow()

getRow(row, result?): Vector4

Get the values in a row as a Vector4

Parameters
row

number

The row index

result?

Vector4

The output vector, if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.setRow()

setRow(row, v): this

Set values to a row in the matrix.

Parameters
row

number

The row index

v

Vector4

The values to be set

Returns

this

  • self
transform.setRowXYZW()

setRowXYZW(row, x, y, z, w): this

Set values to a row in the matrix.

Parameters
row

number

The row index

x

number

The first value of the row to be set

y

number

The second value of the row to be set

z

number

The third value of the row to be set

w

number

The fourth value of the row to be set

Returns

this

  • self
transform.getCol()

getCol(col, result?): Vector4

Get the values in a column as a Vector4

Parameters
col

number

The column index

result?

Vector4

The output vector, if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.setCol()

setCol(col, v): this

Set values to a column in the matrix.

Parameters
col

number

The column index.

v

Vector4

The values to be set.

Returns

this

self

transform.setColXYZW()

setColXYZW(col, x, y, z, w): this

Set values to a column in the matrix.

Parameters
col

number

The column index.

x

number

The first value of the column to be set.

y

number

The second value of the column to be set.

z

number

The third value of the column to be set.

w

number

The fourth value of the column to be set.

Returns

this

self

transform.subBy()

subBy(other): this

Subtract a matrix from this matrix component-wise.

Parameters
other

Matrix4x4

The matrix that will be subtract.

Returns

this

self

transform.addBy()

addBy(other): this

Add a matrix to this matrix component-wise.

Parameters
other

Matrix4x4

The matrix that will be added.

Returns

this

self

transform.mulBy()

mulBy(other): this

Multiplies this matrix by a matrix component-wise.

Parameters
other

Matrix4x4

The matrix that will be multiplied by.

Returns

this

self

transform.divBy()

divBy(other): this

Divide this matrix by a matrix component-wise.

Parameters
other

Matrix4x4

The matrix that will be divide by.

Returns

this

self

transform.scaleBy()

scaleBy(f): this

Scale this matrix by a scalar number component-wise.

Parameters
f

number

amount to scale this matrix by.

Returns

this

self

transform.identity()

identity(): this

Make this matrix identity.

Returns

this

self

transform.perspective()

perspective(fovY, aspect, znear, zfar): this

Calculates a right-handed perspective projection matrix inplace.

Parameters
fovY

number

The vertical field of view in radians.

aspect

number

The aspect ratio.

znear

number

The near clip plane.

zfar

number

The far clip plane.

Returns

this

self

transform.frustum()

frustum(left, right, bottom, top, znear, zfar): this

Calculates a perspective projection matrix from a frustum inplace.

Parameters
left

number

Left bound of the frustum.

number

Right bound of the frustum.

bottom

number

Bottom bound of the frustum.

top

number

Top bound of the frustum.

znear

number

Near bound of the frustum.

zfar

number

Far bound of the frustum.

Returns

this

self

transform.ortho()

ortho(left, right, bottom, top, near, far): this

Calculates an orthogonal projection matrix inplace.

Parameters
left

number

Left bound of the frustum.

right

number

Right bound of the frustum.

bottom

number

Bottom bound of the frustum.

top

number

Top bound of the frustum.

near

number

Near bound of the frustum.

far

number

Far bound of the frustum.

Returns

this

self

transform.isOrtho()

isOrtho(): boolean

Check if this matrix is orthogonal projection matrix.

Returns

boolean

true if this is an orthogonal projection matrix, otherwise false

Remarks

This method assumes that this is an affine transform matrix or a projection matrix (perspective or orthogonal).

transform.isPerspective()

isPerspective(): boolean

Check if this matrix is perspective projection matrix.

Returns

boolean

true if this is a perspective projection matrix, otherwise false

Remarks

This method assumes that this is an affine transform matrix or a projection matrix (perspective or orthogonal).

transform.getNearPlaneWidth()

getNearPlaneWidth(): number

Get width of the near clip plane.

Returns

number

Width of the near clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getNearPlaneHeight()

getNearPlaneHeight(): number

Get height of the near clip plane.

Returns

number

Height of the near clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getNearPlane()

getNearPlane(): number

Get near clip plane.

Returns

number

The near clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getFarPlaneWidth()

getFarPlaneWidth(): number

Get width of the far clip plane.

Returns

number

Width of the far clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getFarPlaneHeight()

getFarPlaneHeight(): number

Get height of the far clip plane.

Returns

number

Height of the far clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getFarPlane()

getFarPlane(): number

Get far clip plane.

Returns

number

The far clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getFov()

getFov(): number

Get the vertical field of view in radians.

Returns

number

0 if this is an orthogonal projection matrix, otherwise the vertical field of view

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getTanHalfFov()

getTanHalfFov(): number

Get tangent value of half of the vertical field of view.

Returns

number

0 if this is an orthogonal projection matrix, otherwise the tangent value of half of the vertical field of view

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal). If the matrix is orthogonal, 0 is returned.

transform.getAspect()

getAspect(): number

Get the aspect ratio.

Returns

number

The aspect ratio

Remarks

This method assumes that the matrix is a perspective projection matrix.

transform.getLeftPlane()

getLeftPlane(): number

Get the left clip plane.

Returns

number

The left clip plane

Remarks

This method assumes that the matrix is an orthogonal projection matrix.

transform.getRightPlane()

getRightPlane(): number

Get the right clip plane.

Returns

number

The right clip plane

Remarks

This method assumes that the matrix is an orthogonal projection matrix.

transform.getTopPlane()

getTopPlane(): number

Get the top clip plane.

Returns

number

The top clip plane

Remarks

This method assumes that the matrix is an orthogonal projection matrix.

transform.getBottomPlane()

getBottomPlane(): number

Get the bottom clip plane.

Returns

number

The bottom clip plane

Remarks

This method assumes that the matrix is an orthogonal projection matrix.

transform.setNearFar()

setNearFar(znear, zfar): this

Set the near clip plane and far clip plane.

Parameters
znear

number

The near clip plane.

zfar

number

The far clip plane.

Returns

this

self

Remarks

This method assumes that the matrix is a projection matrix (perspective or orthogonal).

transform.translation()

translation(t): this

Calculate a translation matrix inplace.

Parameters
t

Vector3

The translate vector.

Returns

this

self

transform.translationXYZ()

translationXYZ(tx, ty, tz): this

Calculates a translation matrix inplace with individual translation factors.

Parameters
tx

number

The translation of x axis.

ty

number

The translation of y axis.

tz

number

The translation of z axis.

Returns

this

self

transform.scaling()

scaling(s): this

Calculates a scale matrix inplace.

Parameters
s

Vector3

The scale vector.

Returns

this

self

transform.scalingXYZ()

scalingXYZ(sx, sy, sz): this

Calculates a scale matrix inplace with individual scale factors.

Parameters
sx

number

The scale of x axis.

sy

number

The scale of y axis.

sz

number

The scale of z axis.

Returns

this

self

transform.inplaceInvert()

inplaceInvert(): this

Invert this matrix inplace.

Returns

this

self

transform.inplaceInvertAffine()

inplaceInvertAffine(): this

Invert this matrix inplace, assuming this matrix presents an affine transformation.

Returns

this

self

transform.transpose()

transpose(): this

Calculates the transpose of this matrix inplace.

Returns

this

self

transform.multiplyRight()

multiplyRight(other): this

Post-multiply by a matrix inplace.

Parameters
other

Matrix4x4

The matrix that will be multiplied by.

Returns

this

self

Remarks

this = this * other

transform.multiplyRightAffine()

multiplyRightAffine(other): this

Post-multiply by a matrix inplace, assuming both matrices present affine transformations.

Parameters
other

Matrix4x4

The matrix that will be multiplied by.

Returns

this

self

Remarks

this = this * other

transform.multiplyLeft()

multiplyLeft(other): this

Pre-multiply by a matrix inplace.

Parameters
other

Matrix4x4

The matrix that will be multiplied by.

Returns

this

self

Remarks

this = other * this

transform.multiplyLeftAffine()

multiplyLeftAffine(other): this

Pre-multiply by a matrix inplace, assuming both matrices present affine transformations.

Parameters
other

Matrix4x4

The matrix that will be multiplied by.

Returns

this

self

Remarks

this = other * this

transform.rotationX()

rotationX(angle): this

Calculates a rotation around x axis inplace.

Parameters
angle

number

The rotate angle in radians.

Returns

this

self

transform.rotationY()

rotationY(angle): this

Calculates a rotation around y axis inplace.

Parameters
angle

number

The rotate angle in radians.

Returns

this

self

transform.rotationZ()

rotationZ(angle): this

Calculates a rotation around z axis inplace.

Parameters
angle

number

The rotate angle in radians.

Returns

this

self

transform.rotation()

rotation(axis, angle): this

Calculates a rotation around a given axis inplace.

Parameters
axis

Vector3

The rotation axis.

angle

number

The rotate angle in radians.

Returns

this

self

transform.translateRight()

translateRight(t): this

Post-translate by a vector inplace.

Parameters
t

Vector3

The translate vector.

Returns

this

self

Remarks

this = this * (translate matrix for t)

transform.translateLeft()

translateLeft(t): this

Pre-translate by a vector inplace.

Parameters
t

Vector3

The translate vector.

Returns

this

self

Remarks

this = (translate matrix for t) * this

transform.scaleRight()

scaleRight(s): this

Post-scale by a vector inplace.

Parameters
s

Vector3

The scale vector.

Returns

this

self

Remarks

this = this * (scale matrix for s)

transform.scaleLeft()

scaleLeft(s): this

Pre-scale by a vector inplace.

Parameters
s

Vector3

The scale vector.

Returns

this

self

Remarks

this = (scale matrix for s) * this

transform.rotateRight()

rotateRight(r): this

Post-rotate by a rotation matrix or quaternion inplace.

Parameters
r

Matrix4x4 | Quaternion | Matrix3x3

The rotation matrix or quaternion.

Returns

this

self

Remarks

this = this * r

transform.rotateLeft()

rotateLeft(r): this

Pre-rotate by a rotation matrix or quaternion inplace.

Parameters
r

Matrix4x4 | Quaternion | Matrix3x3

The rotation matrix or quaternion.

Returns

this

self

Remarks

this = r * this

transform.lookAt()

lookAt(eye, target, up): this

Calculates a look-at matrix inplace.

Parameters
eye

Vector3

Position of the eye.

target

Vector3

The point that the eye is looking at.

up

Vector3

The up vector.

Returns

this

self

transform.transformPoint()

transformPoint(point, result?): Vector4

Transform a point by this matrix.

Parameters
point

Vector3

The point to be transformed.

result?

Vector4

The output vector, if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.transformPointP()

transformPointP(point, result?): Vector3

Transform a point by this matrix and then do a perspective divide.

Parameters
point

Vector3

The point to be transformed.

result?

Vector3

The output vector, if not specified, a new vector will be created.

Returns

Vector3

The output vector

transform.transformPointAffine()

transformPointAffine(point, result?): Vector3

Transform a point by this matrix, assuming this matrix presents an affine transformation.

Parameters
point

Vector3

The point to be transformed.

result?

Vector3

The output vector (can be the same as point), if not specified, a new vector will be created.

Returns

Vector3

The output vector

transform.transformVector()

transformVector(vec, result?): Vector4

Transform a vector by this matrix.

Parameters
vec

Vector3

The vector to be transformed.

result?

Vector4

The output vector, if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.transformVectorAffine()

transformVectorAffine(vec, result?): Vector3

Transform a vector by this matrix assuming this matrix presents an affine transformation.

Parameters
vec

Vector3

The vector to be transformed.

result?

Vector3

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns

Vector3

The output vector

transform.transformP()

transformP(vec, result?): Vector4

Transform a vector by this matrix and then do a perspective divide.

Parameters
vec

Vector4

The vector to be transformed.

result?

Vector4

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.transform()

transform(vec, result?): Vector4

Transform a vector by this matrix.

Parameters
vec

Vector4

The vector to be transformed.

result?

Vector4

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.transformAffine()

transformAffine(vec, result?): Vector4

Transform a vector by this matrix, assuming this matrix presents an affine transformation.

Parameters
vec

Vector4

The vector to be transformed.

result?

Vector4

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.det()

det(): number

Calculates the determinant of this matrix.

Returns

number

The determinant

transform.compose()

compose(scale, rotation, translation): this

Compose matrix from rotation, translation and scale components.

Parameters
scale

Vector3

The input scale vector.

rotation

Matrix4x4 | Quaternion | Matrix3x3

The input rotation matrix or quaternion.

translation

Vector3

The input translation vector.

Returns

this

self

transform.decompose()

decompose(scale?, rotation?, translation?): this

Decompose this matrix into its rotation, translation and scale components.

Parameters
scale?

Vector3

The output scale vector.

rotation?

Matrix4x4 | Quaternion | Matrix3x3

The output rotation matrix or quaternion.

translation?

Vector3

The output translation vector.

Returns

this

self

transform.decomposeLookAt()

decomposeLookAt(eye?, target?, up?): this

Decompose this matrix into a look-at form.

Parameters
eye?

Vector3

The output eye vector.

target?

Vector3

The output target vector.

up?

Vector3

The output up vector.

Returns

this

self

Inherited from

Shape._options

Accessors

disposed

Get Signature

get disposed(): boolean

Defined in: libs/base/dist/index.d.ts:6065

Returns

boolean

Inherited from

Shape.disposed


id

Get Signature

get id(): number

Defined in: libs/scene/src/render/primitive.ts:100

Unique runtime identifier of this primitive.

Returns

number

The numeric instance id.

Inherited from

Shape.id


changeTag

Get Signature

get changeTag(): number

Defined in: libs/scene/src/render/primitive.ts:109

Change tag that increments whenever draw-affecting state changes. Useful for invalidating cached render bundles.

Returns

number

The current change tag value.

Inherited from

Shape.changeTag


primitiveType

Get Signature

get primitiveType(): PrimitiveType

Defined in: libs/scene/src/render/primitive.ts:146

Primitive topology.

Returns

PrimitiveType

Set Signature

set primitiveType(type): void

Defined in: libs/scene/src/render/primitive.ts:149

Parameters
type

PrimitiveType

Returns

void

Inherited from

Shape.primitiveType


indexStart

Get Signature

get indexStart(): number

Defined in: libs/scene/src/render/primitive.ts:159

Starting index/vertex for drawing.

Returns

number

Set Signature

set indexStart(val): void

Defined in: libs/scene/src/render/primitive.ts:162

Parameters
val

number

Returns

void

Inherited from

Shape.indexStart


indexCount

Get Signature

get indexCount(): number

Defined in: libs/scene/src/render/primitive.ts:172

Number of indices/vertices to draw.

Returns

number

Set Signature

set indexCount(val): void

Defined in: libs/scene/src/render/primitive.ts:176

Parameters
val

number

Returns

void

Inherited from

Shape.indexCount


type

Get Signature

get type(): "Plane"

Defined in: libs/scene/src/shapes/plane.ts:55

type of the shape

Returns

"Plane"

Overrides

Shape.type


options

Get Signature

get options(): DeepRequireOptionals<T>

Defined in: libs/scene/src/shapes/shape.ts:102

Get shape creation options

Returns

DeepRequireOptionals<T>

Set Signature

set options(options): void

Defined in: libs/scene/src/shapes/shape.ts:105

Parameters
options

T

Returns

void

Inherited from

Shape.options

Methods

on()

Call Signature

on<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:635

IEventTarget.on

Type Parameters
K

K extends "dispose" | "bv_changed"

Parameters
type

K

listener

EventListener<object & object, K>

context?

unknown

Returns

void

Inherited from

Shape.on

Call Signature

on<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:594

IEventTarget.on

Type Parameters
K

K extends "dispose"

Parameters
type

K

listener

EventListener<{ dispose: []; }, K>

context?

unknown

Returns

void

Inherited from

Shape.on


once()

Call Signature

once<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:639

IEventTarget.once

Type Parameters
K

K extends "dispose" | "bv_changed"

Parameters
type

K

listener

EventListener<object & object, K>

context?

unknown

Returns

void

Inherited from

Shape.once

Call Signature

once<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:598

IEventTarget.once

Type Parameters
K

K extends "dispose"

Parameters
type

K

listener

EventListener<{ dispose: []; }, K>

context?

unknown

Returns

void

Inherited from

Shape.once


off()

Call Signature

off<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:643

IEventTarget.off

Type Parameters
K

K extends "dispose" | "bv_changed"

Parameters
type

K

listener

EventListener<object & object, K>

context?

unknown

Returns

void

Inherited from

Shape.off

Call Signature

off<K>(type, listener?, context?): void

Defined in: libs/base/dist/index.d.ts:602

IEventTarget.off

Type Parameters
K

K extends "dispose"

Parameters
type

K

listener?

EventListener<{ dispose: []; }>

context?

unknown

Returns

void

Inherited from

Shape.off


dispatchEvent()

Call Signature

dispatchEvent<K>(type, ...args): void

Defined in: libs/base/dist/index.d.ts:647

IEventTarget.dispatchEvent

Type Parameters
K

K extends "dispose" | "bv_changed"

Parameters
type

K

args

...object & object[K]

Returns

void

Inherited from

Shape.dispatchEvent

Call Signature

dispatchEvent<K>(type, ...args): void

Defined in: libs/base/dist/index.d.ts:606

IEventTarget.dispatchEvent

Type Parameters
K

K extends "dispose"

Parameters
type

K

args

...object[K]

Returns

void

Inherited from

Shape.dispatchEvent


dispose()

dispose(): void

Defined in: libs/base/dist/index.d.ts:6066

Returns

void

Inherited from

Shape.dispose


copyFrom()

copyFrom(other): void

Defined in: libs/scene/src/render/primitive.ts:134

Copy from another primitive.

Copies:

  • All vertex buffers and the index buffer
  • Primitive type, index start, index count

Parameters

other

this

The source primitive to copy from.

Returns

void

void

Inherited from

Shape.copyFrom


getNumVertices()

getNumVertices(): number

Defined in: libs/scene/src/render/primitive.ts:188

Query total vertex count from the position buffer, if present.

Returns

number

Total vertex count; 0 if no position buffer is set.

Inherited from

Shape.getNumVertices


getNumFaces()

getNumFaces(): number

Defined in: libs/scene/src/render/primitive.ts:200

Query total face/segment count based on topology and buffer size.

  • For indexed geometry: derived from index buffer.
  • For non-indexed: derived from position vertex count.

Returns

number

Total primitive count for the current topology.

Inherited from

Shape.getNumFaces


removeVertexBuffer()

removeVertexBuffer(semantic): void

Defined in: libs/scene/src/render/primitive.ts:230

Remove all vertex buffers that match a given semantic.

This releases retained buffers, marks the layout dirty, and invalidates bundles.

Parameters

semantic

VertexSemantic

The vertex semantic to remove (e.g., 'position', 'normal').

Returns

void

void

Inherited from

Shape.removeVertexBuffer


getVertexBuffer()

getVertexBuffer(semantic): StructuredBuffer<unknown>

Defined in: libs/scene/src/render/primitive.ts:250

Get the vertex buffer that matches a given semantic.

Parameters

semantic

VertexSemantic

The vertex semantic to look up.

Returns

StructuredBuffer<unknown>

The matching vertex buffer, or null if not found.

Inherited from

Shape.getVertexBuffer


getVertexBufferInfo()

getVertexBufferInfo(semantic): VertexBufferInfo

Defined in: libs/scene/src/render/primitive.ts:264

Get vertex buffer information for a given semantic.

Parameters

semantic

VertexSemantic

The vertex semantic to look up.

Returns

VertexBufferInfo

The VertexBufferInfo, or null if not found.

Inherited from

Shape.getVertexBufferInfo


createAndSetVertexBuffer()

createAndSetVertexBuffer(format, data, stepMode?): StructuredBuffer<unknown>

Defined in: libs/scene/src/render/primitive.ts:279

Create a vertex buffer from data and add it to the primitive.

  • For interleaved layouts, pass an array of VertexAttribFormat.
  • For a single attribute, pass a single VertexAttribFormat.

Parameters

format

VertexAttribFormat | VertexAttribFormat[]

Vertex attribute format(s).

data

TypedArray

Typed array with vertex data.

stepMode?

VertexStepMode

Optional step mode (e.g., 'vertex', 'instance').

Returns

StructuredBuffer<unknown>

The created StructuredBuffer.

Inherited from

Shape.createAndSetVertexBuffer


setVertexBuffer()

setVertexBuffer(buffer, stepMode?): StructuredBuffer<unknown>

Defined in: libs/scene/src/render/primitive.ts:299

Add an existing vertex buffer to the primitive.

Ownership note: The primitive retains the buffer; it will be released or disposed when replaced or on dispose.

Parameters

buffer

StructuredBuffer

The vertex buffer to add.

stepMode?

VertexStepMode

Optional step mode for the buffer.

Returns

StructuredBuffer<unknown>

The same buffer.

Inherited from

Shape.setVertexBuffer


createAndSetIndexBuffer()

createAndSetIndexBuffer(data, dynamic?): IndexBuffer<unknown>

Defined in: libs/scene/src/render/primitive.ts:317

Create an index buffer from data and set it on the primitive.

Parameters

data

Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer>

Index data as Uint16Array or Uint32Array.

dynamic?

boolean

Whether the index buffer is dynamic (unmanaged).

Returns

IndexBuffer<unknown>

The created IndexBuffer.

Inherited from

Shape.createAndSetIndexBuffer


setIndexBuffer()

setIndexBuffer(buffer): void

Defined in: libs/scene/src/render/primitive.ts:335

Set or replace the index buffer.

Ownership note: The primitive retains the buffer; previous buffer is released. Marks the vertex layout dirty and invalidates bundles.

Parameters

buffer

IndexBuffer<unknown>

The index buffer to set (non-null).

Returns

void

void

Inherited from

Shape.setIndexBuffer


getIndexBuffer()

getIndexBuffer(): IndexBuffer<unknown>

Defined in: libs/scene/src/render/primitive.ts:350

Get the current index buffer.

Returns

IndexBuffer<unknown>

The index buffer, or undefined/null if none set.

Inherited from

Shape.getIndexBuffer


draw()

draw(): void

Defined in: libs/scene/src/render/primitive.ts:358

Issue a non-instanced draw for the current topology and range.

Preconditions: A valid vertex layout and indexCount > 0.

Returns

void

Inherited from

Shape.draw


drawInstanced()

drawInstanced(numInstances): void

Defined in: libs/scene/src/render/primitive.ts:371

Issue an instanced draw for the current topology and range.

Preconditions: A valid vertex layout and indexCount > 0.

Parameters

numInstances

number

Number of instances to draw.

Returns

void

Inherited from

Shape.drawInstanced


onDispose()

protected onDispose(): void

Defined in: libs/scene/src/render/primitive.ts:380

Dispose this primitive and release associated GPU resources.

Returns

void

Inherited from

Shape.onDispose


getBoundingVolume()

getBoundingVolume(): BoundingVolume

Defined in: libs/scene/src/render/primitive.ts:405

Get the bounding volume associated with this primitive.

Returns

BoundingVolume

The current bounding volume, or null if not set.

Inherited from

Shape.getBoundingVolume


setBoundingVolume()

setBoundingVolume(bv): void

Defined in: libs/scene/src/render/primitive.ts:416

Set or replace the bounding volume of this primitive.

Triggers registered bounding-volume change callbacks.

Parameters

bv

BoundingVolume

The bounding volume to set.

Returns

void

void

Inherited from

Shape.setBoundingVolume


clone()

clone(): PlaneShape

Defined in: libs/scene/src/shapes/plane.ts:51

Create a shallow clone: copies topology, draw range, and buffers.

Note: Buffers are re-retained on the new primitive.

Returns

PlaneShape

A cloned Primitive instance.

Implementation of

Clonable.clone

Overrides

Shape.clone


raycast()

raycast(ray): number

Defined in: libs/scene/src/shapes/plane.ts:62

Intersects the ray with the finite XZ plane (y = 0) whose bounds are determined by size/anchor options.

Parameters

ray

Ray

Returns

number

Overrides

Shape.raycast


generateData()

static generateData(opt, vertices, normals, tangents, uvs, indices, bbox?, indexOffset?, vertexCallback?): "triangle-list"

Defined in: libs/scene/src/shapes/plane.ts:99

Generates the data for the cylinder shape

Parameters

opt

PlaneCreationOptions

vertices

number[]

vertex positions

normals

number[]

vertex normals

tangents

number[]

uvs

number[]

vertex uvs

indices

number[]

vertex indices

bbox?

AABB

indexOffset?

number

vertexCallback?

(index, x, y, z) => void

Returns

"triangle-list"


computeTangent()

protected static computeTangent(v0, v1, v2, uv0, uv1, uv2, normal): number[]

Defined in: libs/scene/src/shapes/shape.ts:44

Parameters

v0

number[]

v1

number[]

v2

number[]

uv0

number[]

uv1

number[]

uv2

number[]

normal

number[]

Returns

number[]

Inherited from

Shape.computeTangent


normalizeOptions()

normalizeOptions(options?): object

Defined in: libs/scene/src/shapes/shape.ts:115

Normalize options

Parameters

options?

PlaneCreationOptions

creation options

Returns

Normalized creation options

size

size: number

Default size of axis x and axis y, default is 1

sizeX

sizeX: number

Size of axis x, default value equals to size

sizeY

sizeY: number

Size of axis y, default value equals to size

resolution

resolution: number

Resolution, default is 1

resolutionX

resolutionX: number

Resolution X, default value equals to resolution

resolutionY

resolutionY: number

Resolution Y, default value equals to resolution

twoSided

twoSided: boolean

Whether this plane have front side, default is true

anchor

anchor: number

Anchor, default is 0.5

anchorX

anchorX: number

Anchor X, default value equals to anchor

anchorY

anchorY: number

Anchor Z, default value equals to anchor

needNormal

needNormal: boolean

true if we need to calculate normals for the shape

needTangent

needTangent: boolean

true if we need to calculate tangents for the shape

needUV

needUV: boolean

true if we need to calculate texture coordinates for the shape

transform

transform: object

Transform matrix for the shape

Index Signature

[key: number]: number

transform.equalsTo()

equalsTo(other, epsl?): boolean

Check if all data is close enough to another

Parameters
other

Float32Array<ArrayBuffer>

The data to be compared with.

epsl?

number

Returns

boolean

true if close enough, otherwise false.

transform.toString()

toString(): string

Convert this to string object.

Returns

string

transform.isNaN()

isNaN(): boolean

Check the data for the presence of NaN.

Returns

boolean

true if NaN is present, otherwise false.

transform.setRandom()

setRandom(minValue, maxValue): void

Generate random vector

Parameters
minValue

number

Minimum value of any component of the vector

maxValue

number

Maximum value of any component of the vector

Returns

void

transform.clone()

clone(): Matrix4x4

Creates a new Matrix4x4 initialized with values from this matrix.

Returns

Matrix4x4

The new matrix.

transform.m00

m00: number

transform.m10

m10: number

transform.m20

m20: number

transform.m30

m30: number

transform.m01

m01: number

transform.m11

m11: number

transform.m21

m21: number

transform.m31

m31: number

transform.m02

m02: number

transform.m12

m12: number

transform.m22

m22: number

transform.m32

m32: number

transform.m03

m03: number

transform.m13

m13: number

transform.m23

m23: number

transform.m33

m33: number

transform.getRow()

getRow(row, result?): Vector4

Get the values in a row as a Vector4

Parameters
row

number

The row index

result?

Vector4

The output vector, if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.setRow()

setRow(row, v): this

Set values to a row in the matrix.

Parameters
row

number

The row index

v

Vector4

The values to be set

Returns

this

  • self
transform.setRowXYZW()

setRowXYZW(row, x, y, z, w): this

Set values to a row in the matrix.

Parameters
row

number

The row index

x

number

The first value of the row to be set

y

number

The second value of the row to be set

z

number

The third value of the row to be set

w

number

The fourth value of the row to be set

Returns

this

  • self
transform.getCol()

getCol(col, result?): Vector4

Get the values in a column as a Vector4

Parameters
col

number

The column index

result?

Vector4

The output vector, if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.setCol()

setCol(col, v): this

Set values to a column in the matrix.

Parameters
col

number

The column index.

v

Vector4

The values to be set.

Returns

this

self

transform.setColXYZW()

setColXYZW(col, x, y, z, w): this

Set values to a column in the matrix.

Parameters
col

number

The column index.

x

number

The first value of the column to be set.

y

number

The second value of the column to be set.

z

number

The third value of the column to be set.

w

number

The fourth value of the column to be set.

Returns

this

self

transform.subBy()

subBy(other): this

Subtract a matrix from this matrix component-wise.

Parameters
other

Matrix4x4

The matrix that will be subtract.

Returns

this

self

transform.addBy()

addBy(other): this

Add a matrix to this matrix component-wise.

Parameters
other

Matrix4x4

The matrix that will be added.

Returns

this

self

transform.mulBy()

mulBy(other): this

Multiplies this matrix by a matrix component-wise.

Parameters
other

Matrix4x4

The matrix that will be multiplied by.

Returns

this

self

transform.divBy()

divBy(other): this

Divide this matrix by a matrix component-wise.

Parameters
other

Matrix4x4

The matrix that will be divide by.

Returns

this

self

transform.scaleBy()

scaleBy(f): this

Scale this matrix by a scalar number component-wise.

Parameters
f

number

amount to scale this matrix by.

Returns

this

self

transform.identity()

identity(): this

Make this matrix identity.

Returns

this

self

transform.perspective()

perspective(fovY, aspect, znear, zfar): this

Calculates a right-handed perspective projection matrix inplace.

Parameters
fovY

number

The vertical field of view in radians.

aspect

number

The aspect ratio.

znear

number

The near clip plane.

zfar

number

The far clip plane.

Returns

this

self

transform.frustum()

frustum(left, right, bottom, top, znear, zfar): this

Calculates a perspective projection matrix from a frustum inplace.

Parameters
left

number

Left bound of the frustum.

right

number

Right bound of the frustum.

bottom

number

Bottom bound of the frustum.

top

number

Top bound of the frustum.

znear

number

Near bound of the frustum.

zfar

number

Far bound of the frustum.

Returns

this

self

transform.ortho()

ortho(left, right, bottom, top, near, far): this

Calculates an orthogonal projection matrix inplace.

Parameters
left

number

Left bound of the frustum.

right

number

Right bound of the frustum.

bottom

number

Bottom bound of the frustum.

top

number

Top bound of the frustum.

near

number

Near bound of the frustum.

far

number

Far bound of the frustum.

Returns

this

self

transform.isOrtho()

isOrtho(): boolean

Check if this matrix is orthogonal projection matrix.

Returns

boolean

true if this is an orthogonal projection matrix, otherwise false

Remarks

This method assumes that this is an affine transform matrix or a projection matrix (perspective or orthogonal).

transform.isPerspective()

isPerspective(): boolean

Check if this matrix is perspective projection matrix.

Returns

boolean

true if this is a perspective projection matrix, otherwise false

Remarks

This method assumes that this is an affine transform matrix or a projection matrix (perspective or orthogonal).

transform.getNearPlaneWidth()

getNearPlaneWidth(): number

Get width of the near clip plane.

Returns

number

Width of the near clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getNearPlaneHeight()

getNearPlaneHeight(): number

Get height of the near clip plane.

Returns

number

Height of the near clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getNearPlane()

getNearPlane(): number

Get near clip plane.

Returns

number

The near clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getFarPlaneWidth()

getFarPlaneWidth(): number

Get width of the far clip plane.

Returns

number

Width of the far clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getFarPlaneHeight()

getFarPlaneHeight(): number

Get height of the far clip plane.

Returns

number

Height of the far clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getFarPlane()

getFarPlane(): number

Get far clip plane.

Returns

number

The far clip plane

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getFov()

getFov(): number

Get the vertical field of view in radians.

Returns

number

0 if this is an orthogonal projection matrix, otherwise the vertical field of view

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal).

transform.getTanHalfFov()

getTanHalfFov(): number

Get tangent value of half of the vertical field of view.

Returns

number

0 if this is an orthogonal projection matrix, otherwise the tangent value of half of the vertical field of view

Remarks

This method assumes that this is a projection matrix (perspective or orthogonal). If the matrix is orthogonal, 0 is returned.

transform.getAspect()

getAspect(): number

Get the aspect ratio.

Returns

number

The aspect ratio

Remarks

This method assumes that the matrix is a perspective projection matrix.

transform.getLeftPlane()

getLeftPlane(): number

Get the left clip plane.

Returns

number

The left clip plane

Remarks

This method assumes that the matrix is an orthogonal projection matrix.

transform.getRightPlane()

getRightPlane(): number

Get the right clip plane.

Returns

number

The right clip plane

Remarks

This method assumes that the matrix is an orthogonal projection matrix.

transform.getTopPlane()

getTopPlane(): number

Get the top clip plane.

Returns

number

The top clip plane

Remarks

This method assumes that the matrix is an orthogonal projection matrix.

transform.getBottomPlane()

getBottomPlane(): number

Get the bottom clip plane.

Returns

number

The bottom clip plane

Remarks

This method assumes that the matrix is an orthogonal projection matrix.

transform.setNearFar()

setNearFar(znear, zfar): this

Set the near clip plane and far clip plane.

Parameters
znear

number

The near clip plane.

zfar

number

The far clip plane.

Returns

this

self

Remarks

This method assumes that the matrix is a projection matrix (perspective or orthogonal).

transform.translation()

translation(t): this

Calculate a translation matrix inplace.

Parameters
t

Vector3

The translate vector.

Returns

this

self

transform.translationXYZ()

translationXYZ(tx, ty, tz): this

Calculates a translation matrix inplace with individual translation factors.

Parameters
tx

number

The translation of x axis.

ty

number

The translation of y axis.

tz

number

The translation of z axis.

Returns

this

self

transform.scaling()

scaling(s): this

Calculates a scale matrix inplace.

Parameters
s

Vector3

The scale vector.

Returns

this

self

transform.scalingXYZ()

scalingXYZ(sx, sy, sz): this

Calculates a scale matrix inplace with individual scale factors.

Parameters
sx

number

The scale of x axis.

sy

number

The scale of y axis.

sz

number

The scale of z axis.

Returns

this

self

transform.inplaceInvert()

inplaceInvert(): this

Invert this matrix inplace.

Returns

this

self

transform.inplaceInvertAffine()

inplaceInvertAffine(): this

Invert this matrix inplace, assuming this matrix presents an affine transformation.

Returns

this

self

transform.transpose()

transpose(): this

Calculates the transpose of this matrix inplace.

Returns

this

self

transform.multiplyRight()

multiplyRight(other): this

Post-multiply by a matrix inplace.

Parameters
other

Matrix4x4

The matrix that will be multiplied by.

Returns

this

self

Remarks

this = this * other

transform.multiplyRightAffine()

multiplyRightAffine(other): this

Post-multiply by a matrix inplace, assuming both matrices present affine transformations.

Parameters
other

Matrix4x4

The matrix that will be multiplied by.

Returns

this

self

Remarks

this = this * other

transform.multiplyLeft()

multiplyLeft(other): this

Pre-multiply by a matrix inplace.

Parameters
other

Matrix4x4

The matrix that will be multiplied by.

Returns

this

self

Remarks

this = other * this

transform.multiplyLeftAffine()

multiplyLeftAffine(other): this

Pre-multiply by a matrix inplace, assuming both matrices present affine transformations.

Parameters
other

Matrix4x4

The matrix that will be multiplied by.

Returns

this

self

Remarks

this = other * this

transform.rotationX()

rotationX(angle): this

Calculates a rotation around x axis inplace.

Parameters
angle

number

The rotate angle in radians.

Returns

this

self

transform.rotationY()

rotationY(angle): this

Calculates a rotation around y axis inplace.

Parameters
angle

number

The rotate angle in radians.

Returns

this

self

transform.rotationZ()

rotationZ(angle): this

Calculates a rotation around z axis inplace.

Parameters
angle

number

The rotate angle in radians.

Returns

this

self

transform.rotation()

rotation(axis, angle): this

Calculates a rotation around a given axis inplace.

Parameters
axis

Vector3

The rotation axis.

angle

number

The rotate angle in radians.

Returns

this

self

transform.translateRight()

translateRight(t): this

Post-translate by a vector inplace.

Parameters
t

Vector3

The translate vector.

Returns

this

self

Remarks

this = this * (translate matrix for t)

transform.translateLeft()

translateLeft(t): this

Pre-translate by a vector inplace.

Parameters
t

Vector3

The translate vector.

Returns

this

self

Remarks

this = (translate matrix for t) * this

transform.scaleRight()

scaleRight(s): this

Post-scale by a vector inplace.

Parameters
s

Vector3

The scale vector.

Returns

this

self

Remarks

this = this * (scale matrix for s)

transform.scaleLeft()

scaleLeft(s): this

Pre-scale by a vector inplace.

Parameters
s

Vector3

The scale vector.

Returns

this

self

Remarks

this = (scale matrix for s) * this

transform.rotateRight()

rotateRight(r): this

Post-rotate by a rotation matrix or quaternion inplace.

Parameters
r

Matrix4x4 | Quaternion | Matrix3x3

The rotation matrix or quaternion.

Returns

this

self

Remarks

this = this * r

transform.rotateLeft()

rotateLeft(r): this

Pre-rotate by a rotation matrix or quaternion inplace.

Parameters
r

Matrix4x4 | Quaternion | Matrix3x3

The rotation matrix or quaternion.

Returns

this

self

Remarks

this = r * this

transform.lookAt()

lookAt(eye, target, up): this

Calculates a look-at matrix inplace.

Parameters
eye

Vector3

Position of the eye.

target

Vector3

The point that the eye is looking at.

up

Vector3

The up vector.

Returns

this

self

transform.transformPoint()

transformPoint(point, result?): Vector4

Transform a point by this matrix.

Parameters
point

Vector3

The point to be transformed.

result?

Vector4

The output vector, if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.transformPointP()

transformPointP(point, result?): Vector3

Transform a point by this matrix and then do a perspective divide.

Parameters
point

Vector3

The point to be transformed.

result?

Vector3

The output vector, if not specified, a new vector will be created.

Returns

Vector3

The output vector

transform.transformPointAffine()

transformPointAffine(point, result?): Vector3

Transform a point by this matrix, assuming this matrix presents an affine transformation.

Parameters
point

Vector3

The point to be transformed.

result?

Vector3

The output vector (can be the same as point), if not specified, a new vector will be created.

Returns

Vector3

The output vector

transform.transformVector()

transformVector(vec, result?): Vector4

Transform a vector by this matrix.

Parameters
vec

Vector3

The vector to be transformed.

result?

Vector4

The output vector, if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.transformVectorAffine()

transformVectorAffine(vec, result?): Vector3

Transform a vector by this matrix assuming this matrix presents an affine transformation.

Parameters
vec

Vector3

The vector to be transformed.

result?

Vector3

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns

Vector3

The output vector

transform.transformP()

transformP(vec, result?): Vector4

Transform a vector by this matrix and then do a perspective divide.

Parameters
vec

Vector4

The vector to be transformed.

result?

Vector4

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.transform()

transform(vec, result?): Vector4

Transform a vector by this matrix.

Parameters
vec

Vector4

The vector to be transformed.

result?

Vector4

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.transformAffine()

transformAffine(vec, result?): Vector4

Transform a vector by this matrix, assuming this matrix presents an affine transformation.

Parameters
vec

Vector4

The vector to be transformed.

result?

Vector4

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns

Vector4

The output vector

transform.det()

det(): number

Calculates the determinant of this matrix.

Returns

number

The determinant

transform.compose()

compose(scale, rotation, translation): this

Compose matrix from rotation, translation and scale components.

Parameters
scale

Vector3

The input scale vector.

rotation

Matrix4x4 | Quaternion | Matrix3x3

The input rotation matrix or quaternion.

translation

Vector3

The input translation vector.

Returns

this

self

transform.decompose()

decompose(scale?, rotation?, translation?): this

Decompose this matrix into its rotation, translation and scale components.

Parameters
scale?

Vector3

The output scale vector.

rotation?

Matrix4x4 | Quaternion | Matrix3x3

The output rotation matrix or quaternion.

translation?

Vector3

The output translation vector.

Returns

this

self

transform.decomposeLookAt()

decomposeLookAt(eye?, target?, up?): this

Decompose this matrix into a look-at form.

Parameters
eye?

Vector3

The output eye vector.

target?

Vector3

The output target vector.

up?

Vector3

The output up vector.

Returns

this

self

Inherited from

Shape.normalizeOptions

Released under the MIT License.