Class: Renderer

Renderer(containerIn) → {Renderer}

new Renderer(containerIn) → {Renderer}

Create a Zinc 3D renderer in the container provided. The primary function of a Zinc 3D renderer is to display the current scene (@link Scene} set to the renderer and each scene may contain as many geometries, glyphset and other primitives as the system can support. Zinc.Renderer also allows additional scenes to be displayed.
Parameters:
Name Type Description
containerIn Object Container to create the renderer on.
Author:
  • Alan Wu
Source:
Returns:
Type
Renderer

Methods

addActiveScene(additionalScene)

Add additional active scene for rendering, this scene will also be rendered but viewport of the currentScene will be used.
Parameters:
Name Type Description
additionalScene Zinc.Scene Scene to be added to the rendering.
Source:

addContextLostCallbackFunction(callbackFunction) → {Number}

Add a callback function which will be called when the gl context is lost.
Parameters:
Name Type Description
callbackFunction function callbackFunction to be added.
Source:
Returns:
Type
Number

addContextRestoredCallbackFunction(callbackFunction) → {Number}

Add a callback function which will be called when the gl context is restored.
Parameters:
Name Type Description
callbackFunction function callbackFunction to be added.
Source:
Returns:
Type
Number

addPostRenderCallbackFunction(callbackFunction) → {Number}

Add a callback function which will be called everytime after the renderer renders its scene.
Parameters:
Name Type Description
callbackFunction function callbackFunction to be added.
Source:
Returns:
Type
Number

addPreRenderCallbackFunction(callbackFunction) → {Number}

Add a callback function which will be called everytime before the renderer renders its scene.
Parameters:
Name Type Description
callbackFunction function callbackFunction to be added.
Source:
Returns:
Type
Number

addToOrthoScene()

Add {Three.Object} to the ortho scene, objects added to the ortho scene are rendered in normalised coordinates and overlay on top of current scene.
Source:

addToScene()

Add {Three.Object} to the current scene.
Source:

animate()

Start the animation and begin the rendering loop.
Source:

clearAllActiveScene()

Clear all additional scenes from rendering except for curentScene.
Source:

dispose()

Dispose all memory allocated, this will effetively destroy all scenes.
Source:

getCurrentScene() → {Zinc.Scene}

Get the current scene on display.
Source:
Returns:
;
Type
Zinc.Scene

getPlayRate()

Get the current play rate, playrate affects how fast an animated object animates. Also see Zinc.Scene#duration.
Source:

getSceneByName(name) → {Zinc.Scene}

Return scene with the matching name if scene with that name has been created.
Parameters:
Name Type Description
name String Name to match
Source:
Returns:
Type
Zinc.Scene

getThreeJSRenderer()

Get the internal Three.Renderer, to gain access to ThreeJS APIs.
Source:

getZincGeometryByID() → {Zinc.Geometry}

Get {Zinc.Geoemtry} by its id. This should be called from Zinc.Scene;
Source:
Returns:
Type
Zinc.Geometry

initialiseVisualisation()

Initialise the renderer and its visualisations.
Source:

invalidate()

Request the scenes to be drawn on the next frame, this is only required when render on demand is enabled.
Source:

isRenderOnDemand() → {Boolean}

Check if render on demand is enabled.
Source:
Returns:
Type
Boolean

isSceneActive(sceneIn)

Check if a scene is currently active.
Parameters:
Name Type Description
sceneIn Zinc.Scene Scene to check if it is currently rendered.
Source:

isWebGL2() → {Boolean}

Check if the renderer is running on the WebGL 2 fallback backend. WebGPURenderer never uses WebGL 1, so this is false when WebGPU is used.
Source:
Returns:
Type
Boolean

isWebGPU() → {Boolean}

Check if the renderer is running on the WebGPU backend.
Source:
Returns:
Type
Boolean

loadFromViewURL(URL)

Load a legacy file format containing the viewport and its model file from an external location provided by the url. Use the new metadata format with Zinc.Scene#loadMetadataURL instead. This should be called from Zinc.Scene;
Parameters:
Name Type Description
URL String address to the file containing viewport and model information.
Deprecated:
  • Yes
Source:

loadModelsURL()

Load a legacy model(s) format with the provided URLs and parameters. This only loads the geometry without any of the metadata. Therefore, extra parameters should be provided. This should be called from Zinc.Scene.
Deprecated:
  • Yes
Source:

loadViewURL(URL)

Load the viewport from an external location provided by the url. This should be called from Zinc.Scene;
Parameters:
Name Type Description
URL String address to the file containing viewport information.
Deprecated:
  • Yes
Source:

onWindowResize()

Call this to resize the renderer, this is normally call automatically.
Source:

removeActiveScene(additionalScene)

Remove a currenrtly active scene from the renderer, this scene will also be rendered but viewport of the currentScene will be used.
Parameters:
Name Type Description
additionalScene Zinc.Scene Scene to be removed from rendering.
Source:

removeContextLostCallbackFunction(id)

Remove a callback function that is previously added to the renderer.
Parameters:
Name Type Description
id Number identifier of the previously added callback function.
Source:

removeContextRestoredCallbackFunction(id)

Remove a callback function that is previously added to the renderer.
Parameters:
Name Type Description
id Number identifier of the previously added callback function.
Source:

removePostRenderCallbackFunction(id)

Remove a callback function that is previously added to the scene.
Parameters:
Name Type Description
id Number identifier of the previously added callback function.
Source:

removePreRenderCallbackFunction(id)

Remove a callback function that is previously added to the scene.
Parameters:
Name Type Description
id Number identifier of the previously added callback function.
Source:

render()

Render the current and all additional scenes. It will first update all geometries and glyphsets in scenes, clear depth buffer and render the ortho scene, call the preRenderCallbackFunctions stack , render the scenes then postRenderCallback.
Source:

resetView()

}; const updateOrthoCamera = () => { if (cameraOrtho != undefined) { const width = this.getDrawingWidth(); const height = this.getDrawingHeight(); cameraOrtho.left = -width / 2; cameraOrtho.right = width / 2; cameraOrtho.top = height / 2; cameraOrtho.bottom = -height / 2; cameraOrtho.updateProjectionMatrix(); } }; /** Reset the viewport of the current scene to its original state.
Source:

setCurrentScene(sceneIn)

Set the current scene on display.
Parameters:
Name Type Description
sceneIn Zinc.Scene The scene to be set, only scene created by this instance of ZincRenderer is supported currently.
Source:

setMorphsTime()

Get the current play rate, playrate affects how fast an animated object animates. Also see Zinc.Scene#duration.
Source:

setPlayRate(PlayRateIn)

Set the current play rate, playrate affects how fast an animated object animates.
Parameters:
Name Type Description
PlayRateIn Number value to set the playrate to. Also see Zinc.Scene#duration.
Source:

setRenderOnDemand(flag)

Enable or disable render on demand, it is disabled by default. When enabled, the scenes are only drawn when something has changed, e.g. camera movement, animation, loading and changes made through the Zinc APIs. Call Renderer#invalidate after modifying THREE.js objects directly or after changing the THREE.js renderer, e.g. setClearColor. Pre-render callbacks are called on every frame, post-render callbacks are only called when the scenes are drawn.
Parameters:
Name Type Description
flag Boolean Enable or disable render on demand.
Source:

stopAnimate()

Stop the animation and renderer to get into the render loop.
Source:

transitionScene(endingScene, duration)

Transition from the current viewport to the endingScene's viewport in the specified duration.
Parameters:
Name Type Description
endingScene Zinc.Scene Viewport of this scene will be used as the destination.
duration Number Amount of time to transition from current viewport to the endingScene's viewport.
Source:

viewAll()

Adjust zoom distance to include all primitives in scene and also the additional scenes but the lookat direction and up vectors will remain constant.
Source: