marble3 / WorldLabel
Class: WorldLabel
Defined in: src/world-label.ts:43
A label in the scene shaped as a thin rounded card, which walls hide like any other object. Draw on ctx, a transparent canvas of px pixels laid over a card of size world units, then call flush(). Add mesh under your entity and position it.
By default it is a fixed sign, readable from both sides. With billboard: true and a call to faceCamera(camera) every frame, it stays turned to the viewer.
Constructors
Constructor
new WorldLabel(
px,size,opts?):WorldLabel
Defined in: src/world-label.ts:59
Parameters
px
[number, number]
size
[number, number]
opts?
WorldLabelOptions = {}
Returns
WorldLabel
Properties
ctx
readonlyctx:CanvasRenderingContext2D
Defined in: src/world-label.ts:46
Draw the label's content here, then call flush().
h
readonlyh:number
Defined in: src/world-label.ts:50
Canvas height, in pixels.
mesh
readonlymesh:Group
Defined in: src/world-label.ts:44
w
readonlyw:number
Defined in: src/world-label.ts:48
Canvas width, in pixels.
Methods
dispose()
dispose():
void
Defined in: src/world-label.ts:131
Returns
void
faceCamera()
faceCamera(
camera):void
Defined in: src/world-label.ts:110
Turns a billboard label flat-on to the camera, however its parent is rotated. Does nothing to a fixed sign.
Parameters
camera
Camera
Returns
void
flush()
flush():
void
Defined in: src/world-label.ts:129
Shows what has been drawn on ctx since the last call.
Returns
void
roundRect()
roundRect(
x,y,w,h,r):void
Defined in: src/world-label.ts:123
Begins a rounded-rectangle path on ctx, to fill or stroke.
Parameters
x
number
y
number
w
number
h
number
r
number
Returns
void