CanvasSprite Class

Extends THREE.Sprite
Module: Sprite

Canvas sprite is used to render canvas based elements in a 2D canvas.

The sprite can be configured to keep a relative size to the screen of an absolute size.

Methods

draw

()

Redraw the content on the canvas.

Should be called everytime that information that needs to be displayed is updated.

When relative scalling is enabled size changed should be applied here.

setSizingMode

(
  • sizingMode
)

Set the sizing mode for this canvas.

Parameters:

  • sizingMode Number

Attributes

ABSOLUTE

Number static

Absolute sizing is performed directly in px.

canvas

DOM

DOM canvas to draw.

RELATIVE

Number static

Relative sizing is done relative to the screen height.

resizeMode

Number

Sizing mode, can be relative of absolute.

SCALED

Number static

Scaled sizing is done relative to the camera position.

Is similar to the RELATIVE sizing but the actual sprite size is recalculated (slower) but allows for raytracing to be performed properly.

size

Number

Size of the sprite.

If configured as relative to the screen (from 0 to 1) or absolutely in px.

texture

THREE.CanvasTexture

Texture where the text is drawn to.