# SpeckleRenderer
# Accessors
 # Methods
 # Typedefs
 | DynamicAOPassParams | PipelineOptions | PipelineOutputType | RenderingStats | 
|---|---|---|---|
| StaticAoPassParams | SunLightConfiguration | 
# Constants
 | DefaultPipelineOptions | DefaultDynamicAOPassParams | DefaultStaticAoPassParams | 
|---|
# Accessors
 # allObjects
get allObjects(): Object3D
 Gets the parent three.js object for all loaded scene content.
Returns: Object3D (opens new window)
# clippingPlanes
get clippingPlanes(): Plane[]
set clippingPlanes(value: Plane[])
 2
Gets or set the clipping Plane (opens new window)s for the scene. Anything outside the volume determined by the clipping planes will get visually clipped.
# clippingVolume
get clippingVolume(): Box3
set clippingVolume(box: Box3)
 2
Gets or set the clipping volume for the renderer as a Box3 (opens new window). Anything outside the clipping volume is not interactible by default.
# indirectIBL
set indirectIBL(texture: Texture)
 Sets the texture for indirect image based lighting. Works as per existing three.js Scene (opens new window) documentation.
# indirectIBLIntensity
set indirectIBLIntensity(value: number)
 Sets the envMapIntensity (opens new window) for all SpeckleStandardMaterials in the scene.
# intersections
get intersections(): Intersections
 Gets the Intersections instance associated with the renderer.
Returns: Intersections
# needsRender
set needsRender(value: boolean)
 Signals the renderer that it needs to render at least one frame. Assigning a false value has no effect.
# pipelineOptions
get pipelineOptions()
set pipelineOptions(value: PipelineOptions)
 2
Gets or sets the renderer's PipelineOptions.
# renderer
get renderer(): SpeckleWebGLRenderer
 Gets the underlying SpeckleWebGLRenderer which is small extension of WebGLRenderer (opens new window).
Returns: SpeckleWebGLRenderer (opens new window)
# renderingCamera
get renderingCamera(): Camera
 Gets the currently rendering Camera (opens new window).
Returns: Camera (opens new window)
# renderingStats
get renderingStats(): RenderingStats
 Gets the up to date RenderingStats.
Returns: RenderingStats
# scene
get scene(): Scene
 Gets the underlying three.js Scene (opens new window).
Returns: Scene (opens new window)
# sceneBox
get sceneBox(): Box3
 Gets the total bounds of the scene.
Returns: Box3 (opens new window)
# sceneCenter
get sceneCenter(): Vector3
 Gets the center of the total bounds of the scene.
Returns: Vector3 (opens new window)
# sceneSphere
get sceneSphere(): Sphere
 Gets the sphere encompasing the entire scene.
Returns: Sphere (opens new window)
# shadowcatcher
get shadowcatcher(): Shadowcatcher
 Gets The Shadowcatcher🛸 instance associated with the renderer.
Returns: Shadowcatcher
# shadowMapNeedsUpdate
set shadowMapNeedsUpdate(value: boolean)
 Signals the renderer to render the shadowmap.
# sunLight
get sunLight(): DirectionalLight
 Gets the DirectionalLight (opens new window) sun instance.
Returns: DirectionalLight (opens new window)
# Methods
 # addRenderTree
async *addRenderTree(subtreeId: string): AsyncGenerator<any, void, unknown>
 Generator function which takes the id of a render tree, builds the batches, then adds the batches to the scene. The function will yield after each batch has been created, allowing for user defined code to be run in the following fashion.
for await (const step of speckleRenderer.addRenderTree(id)) {
  // User defined code
}
 2
3
Parameters
- subtreeId: The id of the render tree to add to the scene
 
Returns: AsyncGenerator (opens new window)
# boxFromObjects
boxFromObjects(objectIds: string[]): Box3
 Builds the bounds of the provided object ids as a Box3 (opens new window).
Parameters
- objectIds: An array of ids that participate in the bounds calculation
 
Returns: Box3 (opens new window)
# cancelRenderTree
cancelRenderTree(subtreeId: string): void
 Cancels any ongoing render tree adding operations. Effective cancelling happens as soon as the current running generator step yields.
Parameters
- objectIds: An array of ids that participate in the bounds calculation
 
Returns: void
# enableLayers
enableLayers(layers: ObjectLayers[], value: boolean): void
 Enables/Disables ObjectLayers from rendering. By default all layers are enabled.
Parameters
- objectIds: An array of ids that participate in the bounds calculation
 
Returns: void
# getBatch
getBatch(id: string): Batch
 Gets a Batch by id.
Parameters
- id: The id of the batch
 
Returns: Batch
# getBatchMaterial
getBatchMaterial(rv: NodeRenderView): Material
 Gets the default material of the provided NodeRenderView. It's originally defined material.
Parameters
- rv: NodeRenderView
 
Returns: Material (opens new window)
# getMaterial
getMaterial(rv: NodeRenderView): Material
 Gets the current material of the provided NodeRenderView.
Parameters
- rv: NodeRenderView
 
Returns: Material (opens new window)
# getObject
getObject(rv: NodeRenderView): BatchObject
 Gets the associated BatchObject with the provided NodeRenderView.
Parameters
- rv: NodeRenderView
 
Returns: BatchObject
# getObjects
getObjects(): BatchObject[]
 Gets all BatchObject instances from the renderer.
Returns: BatchObject[]
# removeRenderTree
removeRenderTree(subtreeId: string)
 Removes the specified render tree along with all it's generated objects from the scene.
Parameters
- subtreeId: The id of the render tree to remove from the scene
 
Returns: void
# renderViewFromIntersection
renderViewFromIntersection(intersection: ExtendedIntersection): NodeRenderView
 Takes an intersection result produced by intersections and outputs the intersected NodeRenderView.
Parameters
- intersection: ExtendedIntersection
 
Returns: NodeRenderView
# resetMaterials
resetMaterials(): void
 Resets all object materials to their original default.
Returns: void
# resetPipeline
resetPipeline(): void
 Resets the rendering pipeline, retriggering the accumulation stage.
Returns: void
# resize
resize(width: number, height: number): void
 Manually resizes the renderer.
Returns: void
# setMaterial
There are several overloads of this method.
setMaterial(rvs: NodeRenderView[], material: Material): void
 Sets the material instance to the specified rvs.
Parameters
- rvs: NodeRenderView
 - material: The material instance to apply. It can be a vanilla three.js Material (opens new window) but also a SpeckleMaterial
 
setMaterial(
    rvs: NodeRenderView[],
    material: RenderMaterial & DisplayStyle & MaterialOptions
): void
 2
3
4
Creates a material based on the intersection between RenderMaterial, DisplayStyle and MaterialOptions. Because this method does not discriminate based on the render view's geometry type (mesh, lines, points) it needs to be able to build materials suitable for all gometry types.
Parameters
- rvs: NodeRenderView
 - material: RenderMaterial & DisplayStyle & MaterialOptions
 
Returns: void
setMaterial(rvs: NodeRenderView[], material: FilterMaterial): void
 Sets the filter material to the specified rvs. FilterMaterials are a set of predefined material types which are commonly used.
Parameters
- rvs: NodeRenderView
 - material: FilterMaterial
 
Returns: void
# setSunLightConfiguration
setSunLightConfiguration(config: SunLightConfiguration): void
 Sets the provided SunLightConfiguration.
Parameters
- config: SunLightConfiguration
 
Returns: void
# updateShadowCatcher
updateShadowCatcher(): void
 Updates The Shadowcatcher🛸.
Returns: void
# Typedefs
 # DynamicAOPassParams
interface DynamicAOPassParams {
  intensity: number;
  scale: number;
  kernelRadius: number;
  bias: number;
  normalsType: NormalsType;
  blurEnabled: boolean;
  blurRadius: number;
  blurStdDev: number;
  blurDepthCutoff: number;
}
 2
3
4
5
6
7
8
9
10
11
- intensity: Intensity of dynamic AO
 - scale: Scale of dynamic AO
 - kernelRadius: Radius of the sampling kernel in screen space
 - bias: Dynamic AO bias
 - normalsType: Reconstructed normals quality: DEFAULT, IMPROVED = 1, ACCURATE = 2
 - blurEnabled: Enables/Disables dynamic AO blue
 - blurRadius: Radius of the blur in screen space
 - blurStdDev: Blur standard deviation
 - blurDepthCutoff: Cutoff value for depth aware blur
 
# PipelineOptions
interface PipelineOptions {
  pipelineOutput: PipelineOutputType;
  accumulationFrames: number;
  dynamicAoEnabled: boolean;
  dynamicAoParams: DynamicAOPassParams;
  staticAoEnabled: boolean;
  staticAoParams: StaticAoPassParams;
  depthSide: Side;
}
 2
3
4
5
6
7
8
9
- pipelineOutput: PipelineOutputType.
 - accumulationFrames: Number of frames used for accumulation
 - dynamicAoEnabled: Enables dynamic AO
 - dynamicAoParams: DynamicAOPassParams
 - staticAoEnabled: Enables static AO.
 - staticAoParams: StaticAoPassParams
 - depthSide: Face side when rendering depth
 
# RenderingStats
{
  objects: number
  batchCount: number
  drawCalls: number
  trisCount: number
  vertCount: number
  batchDetails: Array<{
    drawCalls: number
    minDrawCalls: number
    tris: number
    verts: number
  }
}
 2
3
4
5
6
7
8
9
10
11
12
13
Details regarding rendering state.
# StaticAoPassParams
interface StaticAoPassParams {
  intensity?: number
  kernelRadius?: number
  kernelSize?: number
  bias?: number
 2
3
4
5
- intensity: Intensity of the static AO.
 - kernelRadius: Sampling kernel radius in screen space
 - kernelSize: Size of the sampling kernel
 - bias: AO bias
 
# SunLightConfiguration
interface SunLightConfiguration extends LightConfiguration {
  elevation?: number;
  azimuth?: number;
  radius?: number;
}
 2
3
4
5
- elevation: Elevation in polar coordinates
 - azimuth: Azimuth in polar coordinates
 - radius: Distance from the camera target
 
# Constants
 # DefaultPipelineOptions
const DefaultPipelineOptions: PipelineOptions = {
  pipelineOutput: PipelineOutputType.FINAL,
  accumulationFrames: 16,
  dynamicAoEnabled: true,
  dynamicAoParams: DefaultDynamicAOPassParams,
  staticAoEnabled: true,
  staticAoParams: DefaultStaticAoPassParams,
  depthSide: DoubleSide,
};
 2
3
4
5
6
7
8
9
Default values for PipelineOptions.
# DefaultDynamicAOPassParams
const DefaultDynamicAOPassParams: DynamicAOPassParams = {
  intensity: 1.5,
  scale: 0,
  kernelRadius: 5,
  bias: 0.2,
  normalsType: NormalsType.ACCURATE,
  blurEnabled: true,
  blurRadius: 2,
  blurStdDev: 4,
  blurDepthCutoff: 0.007,
};
 2
3
4
5
6
7
8
9
10
11
Default values for DynamicAOPassParams.
# DefaultStaticAoPassParams
const DefaultStaticAoPassParams: StaticAoPassParams = {
  intensity: 1,
  kernelRadius: 30, // Screen space
  kernelSize: 16,
  bias: 0.01,
  minDistance: 0,
  maxDistance: 0.008,
};
 2
3
4
5
6
7
8
Default values for StaticAoPassParams.