Canvas
Extends:
Manages its Scene's HTML canvas.
- Provides the HTML canvas element in Canvas#canvas.
- Has a Spinner, provided at Canvas#spinner, which manages the loading progress indicator.
Member Summary
Public Members | ||
public get |
Gets the canvas clear color. |
|
public set |
Sets the canvas clear color. |
|
public get |
Gets whether the canvas clear color will be derived from AmbientLight or Canvas#backgroundColor
when Canvas#transparent is |
|
public set |
Sets if the canvas background color is derived from an AmbientLight. |
|
public |
Boundary of the Canvas in absolute browser window coordinates. |
|
public |
canvas: HTMLCanvasElement The HTML canvas. |
|
public |
contextAttr: {}|* Attributes for the WebGL context |
|
public |
gl: WebGLRenderingContext The WebGL rendering context. |
|
public get |
resolutionScale: * | number: * Gets the scale of the canvas back buffer relative to the CSS-defined size of the canvas. |
|
public set |
resolutionScale(resolutionScale: * | number) Sets the scale of the canvas back buffer relative to the CSS-defined size of the canvas. |
|
public get |
spinner: * The busy Spinner for this Canvas. |
|
public |
Indicates if this Canvas is transparent. |
|
public |
True when WebGL 2 support is enabled. |
Method Summary
Public Methods | ||
public |
destroy() |
|
public |
Simulates lost WebGL context. |
|
public |
readPixels(pixels: Number[], colors: Number[], size: Number, opaqueOnly: Boolean): * Reads colors of pixels from the last rendered frame. |
Inherited Summary
From class Component | ||
public get |
The Component that owns the lifecycle of this Component, if any. |
|
public |
True as soon as this Component has been destroyed |
|
public |
ID of this Component, unique within the Scene. |
|
public |
meta: * Arbitrary, user-defined metadata on this component. |
|
public |
The parent Scene that contains this Component. |
|
public |
The viewer that contains this Scene. |
|
public |
clear() Destroys all Components that are owned by this. |
|
public |
destroy() Destroys this component. |
|
public |
Logs an error for this component to the JavaScript console. |
|
public |
Fires an event on this component. |
|
public |
Returns true if there are any subscribers to the given event on this component. |
|
public |
Tests if this component is of the given type, or is a subclass of the given type. |
|
public |
Logs a console debugging message for this component. |
|
public |
Cancels an event subscription that was previously made with Component#on or Component#once. |
|
public |
Subscribes to an event on this component. |
|
public |
Subscribes to the next occurrence of the given event, then un-subscribes as soon as the event is subIdd. |
|
public |
scheduleTask(task: *) Schedule a task to perform on the next browser interval |
|
public |
Logs a warning for this component to the JavaScript console. |
Public Members
public get backgroundColor: Number[] source
Gets the canvas clear color.
Default value is [1, 1, 1]
.
public set backgroundColor: Number[] source
Sets the canvas clear color.
Default value is [1, 1, 1]
.
public get backgroundColorFromAmbientLight: Boolean source
Gets whether the canvas clear color will be derived from AmbientLight or Canvas#backgroundColor
when Canvas#transparent is true
.
When Canvas#transparent is true
and this is true
, then the canvas clear color will
be taken from the Scene's ambient light color.
When Canvas#transparent is true
and this is false
, then the canvas clear color will
be taken from Canvas#backgroundColor.
Default value is true
.
public set backgroundColorFromAmbientLight: Boolean source
Sets if the canvas background color is derived from an AmbientLight.
This only has effect when the canvas is not transparent. When not enabled, the background color will be the canvas element's HTML/CSS background color.
Default value is true
.
public boundary: Number[] source
Boundary of the Canvas in absolute browser window coordinates.
Usage:
var boundary = myScene.canvas.boundary;
var xmin = boundary[0];
var ymin = boundary[1];
var width = boundary[2];
var height = boundary[3];
Properties:
Name | Type | Attribute | Description |
boundary | * |
public canvas: HTMLCanvasElement source
The HTML canvas.
Properties:
Name | Type | Attribute | Description |
canvas | * |
public gl: WebGLRenderingContext source
The WebGL rendering context.
Properties:
Name | Type | Attribute | Description |
gl | * |
public get resolutionScale: * | number: * source
Gets the scale of the canvas back buffer relative to the CSS-defined size of the canvas.
This is a common way to trade off rendering quality for speed. If the canvas size is defined in CSS, then
setting this to a value between [0..1]
(eg 0.5
) will render into a smaller back buffer, giving
a performance boost.
public set resolutionScale(resolutionScale: * | number) source
Sets the scale of the canvas back buffer relative to the CSS-defined size of the canvas.
This is a common way to trade off rendering quality for speed. If the canvas size is defined in CSS, then
setting this to a value between [0..1]
(eg 0.5
) will render into a smaller back buffer, giving
a performance boost.
public get spinner: * source
The busy Spinner for this Canvas.
Properties:
Name | Type | Attribute | Description |
spinner | * |
Public Methods
public readPixels(pixels: Number[], colors: Number[], size: Number, opaqueOnly: Boolean): * source
Reads colors of pixels from the last rendered frame.
Call this method like this:
// Ignore transparent pixels (default is false)
var opaqueOnly = true;
var colors = new Float32Array(8);
viewer.scene.canvas.readPixels([ 100, 22, 12, 33 ], colors, 2, opaqueOnly);
Then the r,g,b components of the colors will be set to the colors at those pixels.
Return:
* |