# SpeckleRenderer

#

Accessors

allObjects clippingPlanes clippingVolume indirectIBL
indirectIBLIntensity intersections needsRender pipelineOptions
renderer renderingCamera renderingStats scene
sceneBox sceneCenter sceneSphere shadowcatcher
shadowMapNeedsUpdate sunLight

#

Methods

addRenderTree boxFromObjects cancelRenderTree enableLayers
getBatch getBatchMaterial getMaterial getObject
getObjects removeRenderTree renderViewFromIntersection resetMaterials
resetPipeline resize setMaterial setSunLightConfiguration
screenshot updateShadowCatcher

#

Typedefs

DynamicAOPassParams PipelineOptions PipelineOutputType RenderingStats
StaticAoPassParams SunLightConfiguration

#

Constants

DefaultPipelineOptions DefaultDynamicAOPassParams DefaultStaticAoPassParams

#

Accessors

# allObjects

get allObjects(): Object3D
1

Gets the parent three.js object for all loaded scene content.

Returns: Object3D (opens new window)

# clippingPlanes

get clippingPlanes(): Plane[]
set clippingPlanes(value: Plane[])
1
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)
1
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)
1

Sets the texture for indirect image based lighting. Works as per existing three.js Scene (opens new window) documentation.

# indirectIBLIntensity

set indirectIBLIntensity(value: number)
1

Sets the envMapIntensity (opens new window) for all SpeckleStandardMaterials in the scene.

# intersections

get intersections(): Intersections
1

Gets the Intersections instance associated with the renderer.

Returns: Intersections

# needsRender

set needsRender(value: boolean)
1

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)
1
2

Gets or sets the renderer's PipelineOptions.

# renderer

get renderer(): SpeckleWebGLRenderer
1

Gets the underlying SpeckleWebGLRenderer which is small extension of WebGLRenderer (opens new window).

Returns: SpeckleWebGLRenderer (opens new window)

# renderingCamera

get renderingCamera(): Camera
1

Gets the currently rendering Camera (opens new window).

Returns: Camera (opens new window)

# renderingStats

get renderingStats(): RenderingStats
1

Gets the up to date RenderingStats.

Returns: RenderingStats

# scene

get scene(): Scene
1

Gets the underlying three.js Scene (opens new window).

Returns: Scene (opens new window)

# sceneBox

get sceneBox(): Box3
1

Gets the total bounds of the scene.

Returns: Box3 (opens new window)

# sceneCenter

get sceneCenter(): Vector3
1

Gets the center of the total bounds of the scene.

Returns: Vector3 (opens new window)

# sceneSphere

get sceneSphere(): Sphere
1

Gets the sphere encompasing the entire scene.

Returns: Sphere (opens new window)

# shadowcatcher

get shadowcatcher(): Shadowcatcher
1

Gets The Shadowcatcher🛸 instance associated with the renderer.

Returns: Shadowcatcher

# shadowMapNeedsUpdate

set shadowMapNeedsUpdate(value: boolean)
1

Signals the renderer to render the shadowmap.

# sunLight

get sunLight(): DirectionalLight
1

Gets the DirectionalLight (opens new window) sun instance.

Returns: DirectionalLight (opens new window)

#

Methods

# addRenderTree

async *addRenderTree(subtreeId: string): AsyncGenerator<any, void, unknown>
1

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
}
1
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
1

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
1

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
1

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
1

Gets a Batch by id.

Parameters

  • id: The id of the batch

Returns: Batch

# getBatchMaterial

getBatchMaterial(rv: NodeRenderView): Material
1

Gets the default material of the provided NodeRenderView. It's originally defined material.

Parameters

Returns: Material (opens new window)

# getMaterial

getMaterial(rv: NodeRenderView): Material
1

Gets the current material of the provided NodeRenderView.

Parameters

Returns: Material (opens new window)

# getObject

getObject(rv: NodeRenderView): BatchObject
1

Gets the associated BatchObject with the provided NodeRenderView.

Parameters

Returns: BatchObject

# getObjects

getObjects(): BatchObject[]
1

Gets all BatchObject instances from the renderer.

Returns: BatchObject[]

# removeRenderTree

removeRenderTree(subtreeId: string)
1

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
1

Takes an intersection result produced by intersections and outputs the intersected NodeRenderView.

Parameters

Returns: NodeRenderView

# resetMaterials

resetMaterials(): void
1

Resets all object materials to their original default.

Returns: void

# resetPipeline

resetPipeline(): void
1

Resets the rendering pipeline, retriggering the accumulation stage.

Returns: void

# resize

resize(width: number, height: number): void
1

Manually resizes the renderer.

Returns: void

# setMaterial

There are several overloads of this method.

setMaterial(rvs: NodeRenderView[], material: Material): void
1

Sets the material instance to the specified rvs.

Parameters

setMaterial(
    rvs: NodeRenderView[],
    material: RenderMaterial & DisplayStyle & MaterialOptions
): void
1
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

Returns: void

setMaterial(rvs: NodeRenderView[], material: FilterMaterial): void
1

Sets the filter material to the specified rvs. FilterMaterials are a set of predefined material types which are commonly used.

Parameters

Returns: void

# setSunLightConfiguration

setSunLightConfiguration(config: SunLightConfiguration): void
1

Sets the provided SunLightConfiguration.

Parameters

Returns: void

# updateShadowCatcher

updateShadowCatcher(): void
1

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;
}
1
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;
}
1
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
  }
}
1
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
1
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;
}
1
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,
};
1
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,
};
1
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,
};
1
2
3
4
5
6
7
8

Default values for StaticAoPassParams.