Skip to content

@tmrw-realityos/charmDocs


@tmrw-realityos/charm / WebGPUMesh

Class: WebGPUMesh

WebGPUMesh is the class that manages a mesh in the GPU. It contains a set of primitives and a WebGPUBuffer where the primitives geometry is stored. It doesnt store in RAM the geometry unless it is created using the Mesh class. It inherits from Mesh class to implement some containers in case we want to create dynamic geometry.

Extends

Constructors

new WebGPUMesh()

new WebGPUMesh(): WebGPUMesh

Returns

WebGPUMesh

Overrides

Mesh.constructor

Defined in

packages/charm/src/graphics/WebGPU/WebGPUMesh.ts:87

Properties

bounding

bounding: AABB

Inherited from

Mesh.bounding

Defined in

packages/charm/src/graphics/mesh.ts:25


buffer?

optional buffer: WebGPUBuffer

Defined in

packages/charm/src/graphics/WebGPU/WebGPUMesh.ts:84


colors?

optional colors: Uint8Array | number[]

Inherited from

Mesh.colors

Defined in

packages/charm/src/graphics/mesh.ts:32


indices?

optional indices: Uint16Array | Uint32Array | number[]

Inherited from

Mesh.indices

Defined in

packages/charm/src/graphics/mesh.ts:33


mustUpdate

mustUpdate: boolean = false

Inherited from

Mesh.mustUpdate

Defined in

packages/charm/src/graphics/mesh.ts:34


normals?

optional normals: Float32Array | number[]

Inherited from

Mesh.normals

Defined in

packages/charm/src/graphics/mesh.ts:28


positions?

optional positions: Float32Array | number[]

Inherited from

Mesh.positions

Defined in

packages/charm/src/graphics/mesh.ts:27


primitives

primitives: WebGPUPrimitive[] = []

Overrides

Mesh.primitives

Defined in

packages/charm/src/graphics/WebGPU/WebGPUMesh.ts:85


tangents?

optional tangents: Float32Array | number[]

Inherited from

Mesh.tangents

Defined in

packages/charm/src/graphics/mesh.ts:31


texcoords?

optional texcoords: Float32Array | number[]

Inherited from

Mesh.texcoords

Defined in

packages/charm/src/graphics/mesh.ts:29


texcoords1?

optional texcoords1: Float32Array | number[]

Inherited from

Mesh.texcoords1

Defined in

packages/charm/src/graphics/mesh.ts:30


attribProperties

static attribProperties: object[]

Defined in

packages/charm/src/graphics/WebGPU/WebGPUMesh.ts:98

Methods

appendMesh()

appendMesh(mesh, transform): void

Parameters

mesh: Mesh

transform: undefined | mat4 = undefined

Returns

void

Inherited from

Mesh.appendMesh

Defined in

packages/charm/src/graphics/mesh.ts:121


bakeTransform()

bakeTransform(transform, start, range): void

applies a transformation in place to every vertex and normal

Parameters

transform: mat4

a mat4 that contains the transform to apply

start: number = 0

an offset defined from which primitive to start

range: number = -1

the number of primitives that must be affected

Returns

void

Inherited from

Mesh.bakeTransform

Defined in

packages/charm/src/graphics/mesh.ts:90


bindToRenderPass()

bindToRenderPass(pass): void

Parameters

pass: GPURenderPassEncoder

Returns

void

Defined in

packages/charm/src/graphics/WebGPU/WebGPUMesh.ts:287


computeNormals()

computeNormals(): void

computes the normals for every vertex based on connectivity and face orientation

Returns

void

Inherited from

Mesh.computeNormals

Defined in

packages/charm/src/graphics/mesh.ts:178


copyFrom()

copyFrom(mesh): void

Parameters

mesh: Mesh

Returns

void

Inherited from

Mesh.copyFrom

Defined in

packages/charm/src/graphics/mesh.ts:67


createCube()

createCube(halfsize): void

Parameters

halfsize: number

Returns

void

Inherited from

Mesh.createCube

Defined in

packages/charm/src/graphics/mesh.ts:264


createCylinder()

createCylinder(height, lowRadius, highRadius, subdivisions): void

Parameters

height: number

lowRadius: number

highRadius: number

subdivisions: number = 32

Returns

void

Inherited from

Mesh.createCylinder

Defined in

packages/charm/src/graphics/mesh.ts:287


createPlane()

createPlane(halfsize, xy): void

Parameters

halfsize: number

xy: boolean = false

Returns

void

Inherited from

Mesh.createPlane

Defined in

packages/charm/src/graphics/mesh.ts:243


createPrimitive()

createPrimitive(): WebGPUPrimitive

Returns

WebGPUPrimitive

Overrides

Mesh.createPrimitive

Defined in

packages/charm/src/graphics/WebGPU/WebGPUMesh.ts:91


createSphere()

createSphere(radius, subdivisions, arc, hemi): void

Parameters

radius: number

subdivisions: number = 24

arc: number = 24

hemi: boolean = false

Returns

void

Inherited from

Mesh.createSphere

Defined in

packages/charm/src/graphics/mesh.ts:334


createTorus()

createTorus(innerradius, outerradius, angle, innerslices, outerslices): void

innerradius is the small, outerradius is the big one. Use angle to only create a partial torus

Parameters

innerradius: number

outerradius: number

angle: number = ...

innerslices: number = 24

outerslices: number = 32

Returns

void

Inherited from

Mesh.createTorus

Defined in

packages/charm/src/graphics/mesh.ts:387


updateBounding()

updateBounding(): void

Returns

void

Inherited from

Mesh.updateBounding

Defined in

packages/charm/src/graphics/mesh.ts:48


uploadToGPU()

uploadToGPU(device): void

Called from SceneToRenderables before rendering to upload geometry to GPU

Parameters

device: GPUDevice

Returns

void

Defined in

packages/charm/src/graphics/WebGPU/WebGPUMesh.ts:151