Class: BoxLayer
A layer of a canvas box. This is a group of six canvases that are rendered as a single mesh.
Hierarchy
-
Mesh↳
BoxLayer
Constructors
constructor
• new BoxLayer(width, height, depth, widthSegments, heightSegments, depthSegments, side, transparent, receiveShadows?, mergeFaces?): BoxLayer
Create a six-sided canvas box layer.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
width | number | undefined | The width of the box layer. |
height | number | undefined | The height of the box layer. |
depth | number | undefined | The depth of the box layer. |
widthSegments | number | undefined | The width segments of the box layer. |
heightSegments | number | undefined | The height segments of the box layer. |
depthSegments | number | undefined | The depth segments of the box layer. |
side | Side | undefined | The side of the box layer to render. |
transparent | boolean | undefined | Whether or not should this canvas box be rendered as transparent. |
receiveShadows | boolean | false | Whether or not should this canvas box receive shadows. |
mergeFaces | boolean | false | Whether to draw the six faces in one call through an atlas. |
Returns
Overrides
Mesh.constructor
Properties
atlas
• atlas: Object = null
The one atlas this layer draws with when its faces are merged
(CanvasBoxOptions.mergeFaces), else null and the layer draws each
face with its own material.
Type declaration
| Name | Type |
|---|---|
canvas | HTMLCanvasElement |
layout | CanvasBoxAtlasLayout |
material | MeshBasicNodeMaterial |
texture | CanvasTexture<HTMLCanvasElement> |
depth
• depth: number
The depth of the box layer.
depthSegments
• depthSegments: number
The depth segments of the box layer.
height
• height: number
The height of the box layer.
heightSegments
• heightSegments: number
The height segments of the box layer.
materials
• materials: Map<string, MeshBasicNodeMaterial>
The materials of the six faces of this box layer.
shadowBody
• shadowBody: EntityShadowBody = null
The body this layer's faces are shaded as part of (only set if receiveShadows is true): its own until setShadowBody points it at the body it belongs to (a character's).
width
• width: number
The width of the box layer.
widthSegments
• widthSegments: number
The width segments of the box layer.
Methods
dispose
▸ dispose(): void
Free this layer's GPU resources: its geometry, and each face's canvas texture and material (and a merged layer's atlas). The canvases themselves are left intact, so a consumer that still borrows a face (a portrait) re-uploads it instead of drawing garbage. Call once the layer has left the scene for good.
Returns
void
Overrides
Mesh.dispose
paint
▸ paint(side, art): void
Add art to the canvas(s) of this box layer.
Parameters
| Name | Type | Description |
|---|---|---|
side | BoxSides | BoxSides[] | The side(s) of the box layer to draw on. |
art | Color | Texture<unknown, TextureEventMap> | ArtFunction | The art or art function to draw on the box layer's side. |
Returns
void
setShadowBody
▸ setShadowBody(body): void
Shades this layer's faces (and its merged atlas) as part of body.
No-op for a layer that does not receive shadows.
Parameters
| Name | Type |
|---|---|
body | EntityShadowBody |
Returns
void
syncAtlas
▸ syncAtlas(faces?): void
Bring a merged layer's atlas up to date with its face canvases: relay
the atlas out and re-point the UVs when a face canvas was resized or the
geometry replaced, then copy the given faces (every face after a
relayout) into it. paint calls this; call it after editing a face
canvas directly. A no-op on a per-face layer.
Parameters
| Name | Type | Default value |
|---|---|---|
faces | readonly BoxSides[] | BOX_SIDES |
Returns
void