View
A view represents a portion of canvas on which webGL can draw. The view is defined and tracked by a dom node on which the drawing take place.
Constructor Summary
| Public Constructor | ||
| public |
constructor(canvas: Object, options: Object): Object Construct a new View |
|
Member Summary
| Public Members | ||
| public |
ambient: * |
|
| public |
ambientHud: * |
|
| public |
aspect: * |
|
| public |
background: * |
|
| public |
bottom: * |
|
| public |
bounds: * |
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
camera: * |
|
| public |
cameraHud: * |
|
| public |
canvas: * |
|
| public |
controls: * |
|
| public |
controlsHud: * |
|
| public |
cursor: * |
|
| public |
|
|
| public |
|
|
| public |
dom: * |
|
| public |
|
|
| public |
height: * |
|
| public |
|
|
| public |
id: * |
|
| public |
input: * |
|
| public |
interaction: * |
|
| public |
|
|
| public |
left: * |
|
| public |
new: * |
|
| public |
old: * |
|
| public |
opacity: * |
|
| public |
renderAlways: * |
|
| public |
renderer: * |
|
| public |
scene: * |
|
| public |
sceneHud: * |
|
| public set |
showStats: * |
|
| public |
stats: * |
|
| public |
top: * |
|
| public |
visible: * |
|
| public |
width: * |
|
Method Summary
| Public Methods | ||
| public |
calibrate(width: *, height: *) |
|
| public |
clear(time: *): * |
|
| public |
getPoint2(point3: THREE.Vector3): THREE.Vector2 Projects 2-dimensional coordinate from a 3-dimensional point within the view's scene. |
|
| public |
getPoint3(point2: *): * |
|
| public |
getViewLine3(point2: *): * |
|
| public |
invalidate(frames: number): * |
|
| public |
measure(): * |
|
| public |
render(time: *) |
|
| public |
Sets the cursor style. |
|
| public |
updateBounds(box: *): * |
|
| public |
|
|
| public |
|
|
Public Constructors
public constructor(canvas: Object, options: Object): Object source
Construct a new View
Params:
| Name | Type | Attribute | Description |
| canvas | Object |
|
The parent canvas, if none defined the lastCreated will be used |
| options | Object |
|
Options to initialize the View with |
| options.dom | HTMLElement |
|
The HTML element on which the view will draw |
| options.renderAlways | Boolean |
|
Set to true the view will render 60fps, set to false it will render on changes (default, recommended) |
| options.visible | Boolean |
|
Set to true the view will render |
| options.callbackBefore | Function |
|
Callback before the render pass |
| options.callbackRender | Function |
|
Callback to custom-render the scene |
| options.callbackAfter | Function |
|
Callback after the render pass |
| options.background | Number |
|
Background color |
| options.opacity | Number |
|
Background opacity |
| options.ambientColor | Number |
|
Ambient color |
| options.ambientIntensity | Number |
|
Ambient intensity |
Example:
import View from 'view';
// Create a view, defaults into the same dom as the canvas
const view = new View(canvas, { dom: '#view', ambient: 0x909090 });
// Add model to the view's scene
view.scene.add(model);
Public Members
public ambient: * source
public ambientHud: * source
public aspect: * source
public background: * source
public bottom: * source
public bounds: * source
public callbackAfter: * source
public callbackBefore: * source
public callbackRender: * source
public camera: * source
public cameraHud: * source
public canvas: * source
public controls: * source
public controlsHud: * source
public cursor: * source
public defaultCursor: * source
public dom: * source
public height: * source
public id: * source
public input: * source
public interaction: * source
public left: * source
public new: * source
public old: * source
public opacity: * source
public renderAlways: * source
public renderer: * source
public scene: * source
public sceneHud: * source
public set showStats: * source
public stats: * source
public top: * source
public visible: * source
public width: * source
Public Methods
public calibrate(width: *, height: *) source
Params:
| Name | Type | Attribute | Description |
| width | * | ||
| height | * |
public getPoint2(point3: THREE.Vector3): THREE.Vector2 source
Projects 2-dimensional coordinate from a 3-dimensional point within the view's scene.
Params:
| Name | Type | Attribute | Description |
| point3 | THREE.Vector3 | Input point |
Return:
| THREE.Vector2 | The projected point |
Example:
// Grab x and y off THREE's projected Vector2
let {x, y} = view.getPoint2D(new THREE.Vector3(10, 20, 100));
public invalidate(frames: number): * source
Params:
| Name | Type | Attribute | Description |
| frames | number |
|
Return:
| * |
public render(time: *) source
Params:
| Name | Type | Attribute | Description |
| time | * |
public setCursor(style: String, fallback: String): * source
Sets the cursor style. Applies when the mouse is inside the view's rect.
Return:
| * |
Example:
// 'grab' is available in WebKit and Blink only
view.setCursor('grab', 'move');
public updateBounds(box: *): * source
Params:
| Name | Type | Attribute | Description |
| box | * |
|
Return:
| * |