import RendererThree from '@mobilizing/library/js/Mobilizing/renderer/3D/RendererThree.js'
RendererThree
Extends:
Constructor Summary
Public Constructor | ||
public | constructor(params: Object) Renderer3D is a Three.js based simple renderer. |
Member Summary
Method Summary
Public Methods | ||
public | Adds a camera to the current context | |
public | addToCurrentScene(object: Object) Adds on object to the current scene | |
public | clear() clears this renderer buffers | |
public | erase() erases this renderer contents : remove all cameras and scene objects | |
public | Returns the current canvas | |
public | Returns the current canvas'height divided by 2 | |
public | Returns the current canvas'width divided by 2 | |
public | Returns the current canvas'height | |
public | Get the canvas position as {x, y} | |
public | Returns the current canvas'size as {width, height} | |
public | Returns the current canvas'width | |
public | ||
public | getInfo(): * | |
public | Avoid Infinite Logs coming from browser shader bad compilation | |
public | ||
public | removeCamera(cam: Camera) Removes the camera from the current context | |
public | removeFromCurrentScene(object: Object) Remove from the current scene | |
public | render() Renders all the camera in the context | |
public | saveImageAs(name: String, format: String) Saves the current frame to an image file. | |
public | setClearColor(color: *) change the clearcolor of this renderer color buffers | |
public | setCurrentScene(name: String) Tells the context to use this scene (defined by a string) or create it and switch to it. | |
public | setEnableShadowMap(state: Boolean) Activates the rendering of projected shadows | |
public | Defines the type and color of the fog to be used for rendering the scene | |
public | setFogColor(color: Color) Defines the fog color | |
public | setFogDensity(density: Number) Defines the density of the exponential fog. | |
public | Defines the far distance of the linear fog. | |
public | setFogNear(near: Number) Defines the near distance of the linear fog. | |
public | update() | |
public | Update the canvas position in screen |
Inherited Summary
From class Component | ||
public | ||
public | context: * | |
public | events: * | |
public | id: * | |
public | name: * | |
private | _nexts: *[] | |
private | ||
public | byPass() | |
public | Adds a component to this chained component array | |
public | Returns the array of attached children components | |
public | off() Deactivate the component | |
public | on() Activate the component A call to this method calls the setup method if it has not been run yet | |
public | Run code after the update of all components is run This empty method is usually overriden to perform post-update actions for the component It is called periodically by an internal Mobilizing mechanism | |
public | preLoad() preLoad the component This empty method is usually overriden to perform preLoad actions for the component. | |
public | Run code before the update of all components is run This empty method is usually overriden to perform pre-update actions for the component It is called once per component by an internal Mobilizing mechanism | |
public | prepare() prepare the component This empty method is usually overriden to perform preparation actions for the component, from external process as a server. | |
public | setup() Set's up the component This empty method is usually overriden to perform setup actions for the component This is where all the initialization (such as adding event listeners)should be done It is called automatically by an internal Mobilizing mechanism and should thus not be called directly | |
public | update() Update the component This empty method is usually overriden to perform update actions for the component It is called periodically by an internal Mobilizing mechanism |
Public Constructors
public constructor(params: Object) source
Renderer3D is a Three.js based simple renderer.
Override:
Component#constructorParams:
Name | Type | Attribute | Description |
params | Object | Parameters object, given by the constructor. | |
params.canvas | Canvas | the canvas to draw to | |
params.alpha | Boolean | alpha channel in the webgl canvas | |
params.antialias | Boolean | global antialiasing | |
params.preserveDrawingBuffer | Boolean | ||
params.powerPreference | String | "high-performance", "low-power" or "default" |
Example:
//to do
Public Members
public alpha: * source
public antialias: * source
public cameras: *[] source
public canvas: * source
public canvasPosition: * source
public fog: * source
public objects: *[] source
public powerPreference: * source
public preserveDrawingBuffer: * source
public renderer: * source
public scene: * source
public scenes: {} source
Public Methods
public addCamera(cam: Camera) source
Adds a camera to the current context
Params:
Name | Type | Attribute | Description |
cam | Camera | the camera to add |
public addToCurrentScene(object: Object) source
Adds on object to the current scene
Params:
Name | Type | Attribute | Description |
object | Object | A Mesh or Light to add the scene |
public clear() source
clears this renderer buffers
public erase() source
erases this renderer contents : remove all cameras and scene objects
public getCanvasHalfHeight(): Number source
Returns the current canvas'height divided by 2
Return:
Number | the half height of the canvas |
public getCanvasHalfWidth(): Number source
Returns the current canvas'width divided by 2
Return:
Number | the half width of the canvas |
public getCanvasHeight(): Number source
Returns the current canvas'height
Return:
Number | the height of the canvas |
public getCanvasPosition(): Object source
Get the canvas position as {x, y}
Return:
Object | the position of the canvas as {x, y} |
public getCanvasSize(): Object source
Returns the current canvas'size as {width, height}
Return:
Object | the size of the canvas as {width, height} |
public getCanvasWidth(): Number source
Returns the current canvas'width
Return:
Number | the width of the canvas |
public getInfo(): * source
Return:
* |
public killShaderInfoLog() source
Avoid Infinite Logs coming from browser shader bad compilation
public onWindowResize() source
public removeCamera(cam: Camera) source
Removes the camera from the current context
Params:
Name | Type | Attribute | Description |
cam | Camera |
public removeFromCurrentScene(object: Object) source
Remove from the current scene
Params:
Name | Type | Attribute | Description |
object | Object | the object to remove |
public render() source
Renders all the camera in the context
public saveImageAs(name: String, format: String) source
Saves the current frame to an image file. Note that the preserveFrameBuffer must be "true" on renderer construction
public setClearColor(color: *) source
change the clearcolor of this renderer color buffers
Params:
Name | Type | Attribute | Description |
color | * |
public setCurrentScene(name: String) source
Tells the context to use this scene (defined by a string) or create it and switch to it.
Params:
Name | Type | Attribute | Description |
name | String |
public setEnableShadowMap(state: Boolean) source
Activates the rendering of projected shadows
Params:
Name | Type | Attribute | Description |
state | Boolean |
public setFog(type: String, color: Color) source
Defines the type and color of the fog to be used for rendering the scene
public setFogColor(color: Color) source
Defines the fog color
Params:
Name | Type | Attribute | Description |
color | Color |
public setFogDensity(density: Number) source
Defines the density of the exponential fog. Default is 0.00025.
Params:
Name | Type | Attribute | Description |
density | Number |
public setFogFar(far: Number) source
Defines the far distance of the linear fog. Default is 1000.
Params:
Name | Type | Attribute | Description |
far | Number |
public setFogNear(near: Number) source
Defines the near distance of the linear fog. Default is 1.
Params:
Name | Type | Attribute | Description |
near | Number |
public update() source
Update the component This empty method is usually overriden to perform update actions for the component It is called periodically by an internal Mobilizing mechanism
Override:
Component#updatepublic updateCanvasPosition() source
Update the canvas position in screen