# SpeckleMaterial

All speckle-derived materials inherit this class. Internally, all speckle materials are mixins between three materials and this class.

It's not meant to be used directly, but rather the already existing implementations which work just like regular three.js materials but offer relative to eye rendering support.

  • SpeckleStandardMaterial
  • SpeckleBasicMaterial
  • SpeckleLineMaterial
  • SpecklePointMaterial
  • SpeckleTextMaterial

#

Accessors

baseUniforms fragmentProgram pointSize stencilOutline
uniformsDef vertexProgram

#

Methods

fastCopy

#

Typedefs

DisplayStyle FilterMaterial FilterMaterialType MaterialOptions
RenderMaterial StencilOutlineType

#

Accessors

# baseUniforms

protected get baseUniforms(): { [uniform: string]: IUniform }
1

Gets the base three.js uniforms for this material. So for example SpeckleStandardMaterial has the base uniforms as ShaderLib.standard.uniforms.

Returns: An object containing the uniforms

# fragmentProgram

protected get fragmentProgram(): string
1

Gets the fragment program source code.

Returns: string

# pointSize

protected set pointSize(value: number)
1

Sets the point size for point materials.

Returns: number

# stencilOutline

protected set stencilOutline(value: boolean)
1

Can enable the material to have stencil outlines.

Returns: void

# uniformsDef

protected get uniformsDef(): Uniforms
1

Define the custom uniforms for the material.

Returns: Uniforms which is an alias for Record<string, any>

# vertexProgram

protected get vertexProgram(): string
1

Gets the vertex program source code.

Returns: string

#

Methods

# fastCopy

fastCopy(from: Material, to: Material)
1

Copies properties from one from Material to to Material. The data copied over is restricted to no more and no less than what the viewer needs, so unlike three.js default material copying this aims to be as fast as possible.

Parameters

Returns: void

#

Typedefs

# DisplayStyle

interface DisplayStyle {
  id: string;
  color: number;
  lineWeight: number;
  opacity?: number;
}
1
2
3
4
5
6

Speckle model for material properties on lines.

  • id: The id of the style object
  • color: The color of the line
  • lineWeigth: The thickness of the line in world units
  • optional opacity: The opacity of the line

# FilterMaterial

interface FilterMaterial {
  filterType: FilterMaterialType;
  rampIndex?: number;
  rampIndexColor?: Color;
  rampTexture?: Texture;
}
1
2
3
4
5
6

Filter materials are pre-defined materials that you can directly apply with as little configuration as possible.

  • filterType: FilterMaterialType
  • optional rampIndex: The index of the color in the ramp texture. Applies only for FilterMaterialType.COLORED and FilterMaterialType.GRADIENT
  • optional rampIndexColor: The actual color from the ramp texture. Applies only for FilterMaterialType.COLORED and FilterMaterialType.GRADIENT
  • optional rampTexture: The ramp texture. Applies only for FilterMaterialType.COLORED and FilterMaterialType.GRADIENT

# FilterMaterialType

enum FilterMaterialType {
  GHOST,
  GRADIENT,
  COLORED,
  HIDDEN,
}
1
2
3
4
5
6

The list of available filter materials.

# MaterialOptions

interface MaterialOptions {
  stencilOutlines?: StencilOutlineType;
  pointSize?: number;
  depthWrite?: number;
}
1
2
3
4
5

Custom options for materials.

  • optional stencilOutlines: StencilOutlineType. Only applies to meshes
  • optional pointSize: The point size for point materials. Only applies to points
  • optional depthWrite: Whether the material should write to depth

# RenderMaterial

interface RenderMaterial {
  id: string;
  color: number;
  opacity: number;
  roughness: number;
  metalness: number;
  vertexColors: boolean;
}
1
2
3
4
5
6
7
8

Speckle model for material properties of meshes.

  • id: The id if the render material
  • color: Color as a int32
  • opacity: Opacity
  • roughness: Roughness
  • metalness: Metalness
  • vertexColors: Whether the material reads vertex colors

# StencilOutlineType

enum StencilOutlineType {
  NONE,
  OVERLAY,
  OUTLINE_ONLY,
}
1
2
3
4
5
  • NONE: No outlines
  • OVERLAY: Outline on top of object
  • OUTLINE_ONLY: Outline only, rest of the object is not visible