HomeWeb Components API Reference - v0.10.1
    Preparing search index...

    Class MaterialElement

    The MaterialElement interface provides properties and methods for manipulating <pc-material> elements. The MaterialElement interface also inherits the properties and methods of the HTMLElement interface.

    A pc-material must be a direct child of pc-app — elements placed elsewhere log a warning and never create a material. Elements inserted while the application is already running are created on insertion.

    The element is metal/rough by default: unlike a bare StandardMaterial it enables the metalness workflow, which is what the metalness-* attributes assume and what glTF means by PBR. It also defaults metalness to 0 rather than the engine's 1, because those two defaults have to be chosen together - the engine's 1 is unreachable under its own useMetalness of false, and with the workflow on it would make every material fully metallic, so <pc-material diffuse="crimson"> would render as dark tinted reflections of an environment that may not exist rather than as a crimson surface. metalness="1" remains one attribute away.

    The roughness and roughness-map attributes are aliases for gloss and gloss-map that additionally invert the gloss channel; do not mix the two families on one element.

    The two aliases are documented here rather than on an accessor, because they resolve to the gloss properties and would otherwise inherit gloss's description - which reads inverted.

    roughness - The roughness of the material, from 0 (shiny) to 1 (rough). An alias for gloss that also inverts it, so do not combine it with the gloss attributes.

    roughness-map - The id of the pc-asset to use as the roughness map. An alias for gloss-map that also inverts the gloss channel, so do not combine it with the gloss attributes.

    Hierarchy

    Index
    • get alphaTest(): number

      Gets the alpha test reference value.

      Returns number

      The alpha test reference value.

    • set alphaTest(value: number): void

      Sets the alpha test reference value. Fragments with an opacity below this value are discarded.

      Parameters

      • value: number

        The alpha test reference value.

      Returns void

    • get alphaToCoverage(): boolean

      Gets whether to use alpha to coverage.

      Returns boolean

      The alpha to coverage flag.

    • set alphaToCoverage(value: boolean): void

      Sets whether to use alpha to coverage, which resolves transparency using multisampling.

      Parameters

      • value: boolean

        The alpha to coverage flag.

      Returns void

    • get aoIntensity(): number

      Gets the strength of the ambient occlusion map.

      Returns number

      The ambient occlusion intensity.

    • set aoIntensity(value: number): void

      Sets the strength of the ambient occlusion map, from 0 to 1.

      Parameters

      • value: number

        The ambient occlusion intensity.

      Returns void

    • get aoMap(): string

      Gets the id of the pc-asset used as the ambient occlusion map.

      Returns string

      The asset id.

    • set aoMap(value: string): void

      Sets the id of the pc-asset to use as the ambient occlusion map.

      Parameters

      • value: string

        The asset id.

      Returns void

    • get aoMapChannel(): ScalarChannel

      Gets the color channel of the ambient occlusion map to sample.

      Returns ScalarChannel

      The channel.

    • set aoMapChannel(value: ScalarChannel): void

      Sets the color channel of the ambient occlusion map to sample.

      Parameters

      • value: ScalarChannel

        The channel.

      Returns void

    • get aoMapOffset(): Vec2

      Gets the 2D offset of the ambient occlusion map.

      Returns Vec2

      The offset.

    • set aoMapOffset(value: Vec2): void

      Sets the 2D offset of the ambient occlusion map.

      Parameters

      • value: Vec2

        The offset.

      Returns void

    • get aoMapRotation(): number

      Gets the 2D rotation of the ambient occlusion map.

      Returns number

      The rotation.

    • set aoMapRotation(value: number): void

      Sets the 2D rotation of the ambient occlusion map, in degrees.

      Parameters

      • value: number

        The rotation.

      Returns void

    • get aoMapTiling(): Vec2

      Gets the 2D tiling of the ambient occlusion map.

      Returns Vec2

      The tiling.

    • set aoMapTiling(value: Vec2): void

      Sets the 2D tiling of the ambient occlusion map.

      Parameters

      • value: Vec2

        The tiling.

      Returns void

    • get aoMapUv(): number

      Gets the UV channel the ambient occlusion map samples.

      Returns number

      The UV channel.

    • set aoMapUv(value: number): void

      Sets the UV channel the ambient occlusion map samples.

      Parameters

      • value: number

        The UV channel.

      Returns void

    • get blendType(): BlendType

      Gets how the material is blended with the scene behind it.

      Returns BlendType

      The blend type.

    • set blendType(value: BlendType): void

      Sets how the material is blended with the scene behind it.

      Parameters

      • value: BlendType

        The blend type.

      Returns void

    • get bumpiness(): number

      Gets the strength of the normal map.

      Returns number

      The bumpiness.

    • set bumpiness(value: number): void

      Sets the strength of the normal map, where 0 is flat and 1 is the map's full effect.

      Parameters

      • value: number

        The bumpiness.

      Returns void

    • get cull(): CullMode

      Gets which faces of a mesh are culled.

      Returns CullMode

      The cull mode.

    • set cull(value: CullMode): void

      Sets which faces of a mesh are culled.

      Parameters

      • value: CullMode

        The cull mode.

      Returns void

    • get depthBias(): number

      Gets the offset applied to the depth of a fragment.

      Returns number

      The depth bias.

    • set depthBias(value: number): void

      Sets the offset applied to the depth of a fragment, used to resolve z-fighting.

      Parameters

      • value: number

        The depth bias.

      Returns void

    • get depthTest(): boolean

      Gets whether fragments are tested against the depth buffer.

      Returns boolean

      The depth test flag.

    • set depthTest(value: boolean): void

      Sets whether fragments are tested against the depth buffer.

      Parameters

      • value: boolean

        The depth test flag.

      Returns void

    • get depthWrite(): boolean

      Gets whether fragments write to the depth buffer.

      Returns boolean

      The depth write flag.

    • set depthWrite(value: boolean): void

      Sets whether fragments write to the depth buffer.

      Parameters

      • value: boolean

        The depth write flag.

      Returns void

    • get diffuse(): Color

      Gets the diffuse color of the material.

      Returns Color

      The diffuse color.

    • set diffuse(value: Color): void

      Sets the diffuse color of the material. With the metalness workflow this doubles as the specular color where the surface is metallic.

      Parameters

      • value: Color

        The diffuse color.

      Returns void

    • get diffuseMap(): string

      Gets the id of the pc-asset used as the diffuse map.

      Returns string

      The asset id.

    • set diffuseMap(value: string): void

      Sets the id of the pc-asset to use as the diffuse map.

      Parameters

      • value: string

        The asset id.

      Returns void

    • get diffuseMapChannel(): ColorChannel

      Gets the color channels of the diffuse map to sample.

      Returns ColorChannel

      The channels.

    • set diffuseMapChannel(value: ColorChannel): void

      Sets the color channels of the diffuse map to sample.

      Parameters

      • value: ColorChannel

        The channels.

      Returns void

    • get diffuseMapOffset(): Vec2

      Gets the 2D offset of the diffuse map.

      Returns Vec2

      The offset.

    • set diffuseMapOffset(value: Vec2): void

      Sets the 2D offset of the diffuse map.

      Parameters

      • value: Vec2

        The offset.

      Returns void

    • get diffuseMapRotation(): number

      Gets the 2D rotation of the diffuse map.

      Returns number

      The rotation.

    • set diffuseMapRotation(value: number): void

      Sets the 2D rotation of the diffuse map, in degrees.

      Parameters

      • value: number

        The rotation.

      Returns void

    • get diffuseMapTiling(): Vec2

      Gets the 2D tiling of the diffuse map.

      Returns Vec2

      The tiling.

    • set diffuseMapTiling(value: Vec2): void

      Sets the 2D tiling of the diffuse map.

      Parameters

      • value: Vec2

        The tiling.

      Returns void

    • get diffuseMapUv(): number

      Gets the UV channel the diffuse map samples.

      Returns number

      The UV channel.

    • set diffuseMapUv(value: number): void

      Sets the UV channel the diffuse map samples.

      Parameters

      • value: number

        The UV channel.

      Returns void

    • get emissive(): Color

      Gets the emissive color of the material.

      Returns Color

      The emissive color.

    • set emissive(value: Color): void

      Sets the emissive color of the material, which is added to the lit result.

      Parameters

      • value: Color

        The emissive color.

      Returns void

    • get emissiveIntensity(): number

      Gets the multiplier applied to the emissive color and map.

      Returns number

      The emissive intensity.

    • set emissiveIntensity(value: number): void

      Sets the multiplier applied to the emissive color and map.

      Parameters

      • value: number

        The emissive intensity.

      Returns void

    • get emissiveMap(): string

      Gets the id of the pc-asset used as the emissive map.

      Returns string

      The asset id.

    • set emissiveMap(value: string): void

      Sets the id of the pc-asset to use as the emissive map.

      Parameters

      • value: string

        The asset id.

      Returns void

    • get emissiveMapChannel(): ColorChannel

      Gets the color channels of the emissive map to sample.

      Returns ColorChannel

      The channels.

    • set emissiveMapChannel(value: ColorChannel): void

      Sets the color channels of the emissive map to sample.

      Parameters

      • value: ColorChannel

        The channels.

      Returns void

    • get emissiveMapOffset(): Vec2

      Gets the 2D offset of the emissive map.

      Returns Vec2

      The offset.

    • set emissiveMapOffset(value: Vec2): void

      Sets the 2D offset of the emissive map.

      Parameters

      • value: Vec2

        The offset.

      Returns void

    • get emissiveMapRotation(): number

      Gets the 2D rotation of the emissive map.

      Returns number

      The rotation.

    • set emissiveMapRotation(value: number): void

      Sets the 2D rotation of the emissive map, in degrees.

      Parameters

      • value: number

        The rotation.

      Returns void

    • get emissiveMapTiling(): Vec2

      Gets the 2D tiling of the emissive map.

      Returns Vec2

      The tiling.

    • set emissiveMapTiling(value: Vec2): void

      Sets the 2D tiling of the emissive map.

      Parameters

      • value: Vec2

        The tiling.

      Returns void

    • get emissiveMapUv(): number

      Gets the UV channel the emissive map samples.

      Returns number

      The UV channel.

    • set emissiveMapUv(value: number): void

      Sets the UV channel the emissive map samples.

      Parameters

      • value: number

        The UV channel.

      Returns void

    • get enableGGXSpecular(): boolean

      Gets whether to use the GGX specular model.

      Returns boolean

      The GGX specular flag.

    • set enableGGXSpecular(value: boolean): void

      Sets whether to use the GGX specular model, which supports anisotropy.

      Parameters

      • value: boolean

        The GGX specular flag.

      Returns void

    • get fresnelModel(): FresnelModel

      Gets the Fresnel model used for specular reflections at grazing angles.

      Returns FresnelModel

      The Fresnel model.

    • set fresnelModel(value: FresnelModel): void

      Sets the Fresnel model used for specular reflections at grazing angles.

      Parameters

      • value: FresnelModel

        The Fresnel model.

      Returns void

    • get gloss(): number

      Gets the glossiness of the material.

      Returns number

      The gloss.

    • set gloss(value: number): void

      Sets the glossiness of the material, from 0 (rough) to 1 (shiny). See also roughness.

      Parameters

      • value: number

        The gloss.

      Returns void

    • get glossInvert(): boolean

      Gets whether the gloss value and map are inverted.

      Returns boolean

      The gloss invert flag.

    • set glossInvert(value: boolean): void

      Sets whether the gloss value and map are inverted, which makes the material treat them as roughness. Setting roughness or roughness-map enables this automatically.

      Parameters

      • value: boolean

        The gloss invert flag.

      Returns void

    • get glossMap(): string

      Gets the id of the pc-asset used as the gloss map.

      Returns string

      The asset id.

    • set glossMap(value: string): void

      Sets the id of the pc-asset to use as the gloss map. See also roughnessMap.

      Parameters

      • value: string

        The asset id.

      Returns void

    • get glossMapChannel(): ScalarChannel

      Gets the color channel of the gloss map to sample.

      Returns ScalarChannel

      The channel.

    • set glossMapChannel(value: ScalarChannel): void

      Sets the color channel of the gloss map to sample.

      Parameters

      • value: ScalarChannel

        The channel.

      Returns void

    • get glossMapRotation(): number

      Gets the 2D rotation of the gloss map.

      Returns number

      The rotation.

    • set glossMapRotation(value: number): void

      Sets the 2D rotation of the gloss map, in degrees.

      Parameters

      • value: number

        The rotation.

      Returns void

    • get glossMapUv(): number

      Gets the UV channel the gloss map samples.

      Returns number

      The UV channel.

    • set glossMapUv(value: number): void

      Sets the UV channel the gloss map samples.

      Parameters

      • value: number

        The UV channel.

      Returns void

    • get heightMap(): string

      Gets the id of the pc-asset used as the height map.

      Returns string

      The asset id.

    • set heightMap(value: string): void

      Sets the id of the pc-asset to use as the height map, which drives parallax mapping.

      Parameters

      • value: string

        The asset id.

      Returns void

    • get heightMapChannel(): ScalarChannel

      Gets the color channel of the height map to sample.

      Returns ScalarChannel

      The channel.

    • set heightMapChannel(value: ScalarChannel): void

      Sets the color channel of the height map to sample.

      Parameters

      • value: ScalarChannel

        The channel.

      Returns void

    • get heightMapFactor(): number

      Gets the strength of the parallax effect driven by the height map.

      Returns number

      The height map factor.

    • set heightMapFactor(value: number): void

      Sets the strength of the parallax effect driven by the height map.

      Parameters

      • value: number

        The height map factor.

      Returns void

    • get heightMapRotation(): number

      Gets the 2D rotation of the height map.

      Returns number

      The rotation.

    • set heightMapRotation(value: number): void

      Sets the 2D rotation of the height map, in degrees.

      Parameters

      • value: number

        The rotation.

      Returns void

    • get heightMapUv(): number

      Gets the UV channel the height map samples.

      Returns number

      The UV channel.

    • set heightMapUv(value: number): void

      Sets the UV channel the height map samples.

      Parameters

      • value: number

        The UV channel.

      Returns void

    • get metalness(): number

      Gets how metallic the surface is.

      Returns number

      The metalness.

    • set metalness(value: number): void

      Sets how metallic the surface is, from 0 (dielectric) to 1 (metal).

      Parameters

      • value: number

        The metalness.

      Returns void

    • get metalnessMap(): string

      Gets the id of the pc-asset used as the metalness map.

      Returns string

      The asset id.

    • set metalnessMap(value: string): void

      Sets the id of the pc-asset to use as the metalness map.

      Parameters

      • value: string

        The asset id.

      Returns void

    • get metalnessMapChannel(): ScalarChannel

      Gets the color channel of the metalness map to sample.

      Returns ScalarChannel

      The channel.

    • set metalnessMapChannel(value: ScalarChannel): void

      Sets the color channel of the metalness map to sample.

      Parameters

      • value: ScalarChannel

        The channel.

      Returns void

    • get metalnessMapOffset(): Vec2

      Gets the 2D offset of the metalness map.

      Returns Vec2

      The offset.

    • set metalnessMapOffset(value: Vec2): void

      Sets the 2D offset of the metalness map.

      Parameters

      • value: Vec2

        The offset.

      Returns void

    • get metalnessMapRotation(): number

      Gets the 2D rotation of the metalness map.

      Returns number

      The rotation.

    • set metalnessMapRotation(value: number): void

      Sets the 2D rotation of the metalness map, in degrees.

      Parameters

      • value: number

        The rotation.

      Returns void

    • get metalnessMapTiling(): Vec2

      Gets the 2D tiling of the metalness map.

      Returns Vec2

      The tiling.

    • set metalnessMapTiling(value: Vec2): void

      Sets the 2D tiling of the metalness map.

      Parameters

      • value: Vec2

        The tiling.

      Returns void

    • get metalnessMapUv(): number

      Gets the UV channel the metalness map samples.

      Returns number

      The UV channel.

    • set metalnessMapUv(value: number): void

      Sets the UV channel the metalness map samples.

      Parameters

      • value: number

        The UV channel.

      Returns void

    • get normalMap(): string

      Gets the id of the pc-asset used as the normal map.

      Returns string

      The asset id.

    • set normalMap(value: string): void

      Sets the id of the pc-asset to use as the normal map.

      Parameters

      • value: string

        The asset id.

      Returns void

    • get normalMapRotation(): number

      Gets the 2D rotation of the normal map.

      Returns number

      The rotation.

    • set normalMapRotation(value: number): void

      Sets the 2D rotation of the normal map, in degrees.

      Parameters

      • value: number

        The rotation.

      Returns void

    • get normalMapUv(): number

      Gets the UV channel the normal map samples.

      Returns number

      The UV channel.

    • set normalMapUv(value: number): void

      Sets the UV channel the normal map samples.

      Parameters

      • value: number

        The UV channel.

      Returns void

    • get occludeDirect(): boolean

      Gets whether ambient occlusion also attenuates direct lighting.

      Returns boolean

      The occlude direct flag.

    • set occludeDirect(value: boolean): void

      Sets whether ambient occlusion also attenuates direct lighting.

      Parameters

      • value: boolean

        The occlude direct flag.

      Returns void

    • get occludeSpecular(): OccludeSpecular

      Gets how specular reflections are occluded.

      Returns OccludeSpecular

      The specular occlusion mode.

    • set occludeSpecular(value: OccludeSpecular): void

      Sets how specular reflections are occluded.

      Parameters

      • value: OccludeSpecular

        The specular occlusion mode.

      Returns void

    • get opacity(): number

      Gets the opacity of the material, which requires a blend-type other than none to have any visible effect.

      Returns number

      The opacity.

    • set opacity(value: number): void

      Sets the opacity of the material, from 0 (transparent) to 1 (opaque), which requires a blend-type other than none to have any visible effect.

      Parameters

      • value: number

        The opacity.

      Returns void

    • get opacityDither(): OpacityDither

      Gets the dithering used to render opacity.

      Returns OpacityDither

      The dither mode.

    • set opacityDither(value: OpacityDither): void

      Sets the dithering used to render opacity, which approximates transparency without blending.

      Parameters

      • value: OpacityDither

        The dither mode.

      Returns void

    • get opacityFadesSpecular(): boolean

      Gets whether specular highlights fade out as the material becomes transparent.

      Returns boolean

      The opacity fades specular flag.

    • set opacityFadesSpecular(value: boolean): void

      Sets whether specular highlights fade out as the material becomes transparent.

      Parameters

      • value: boolean

        The opacity fades specular flag.

      Returns void

    • get opacityMap(): string

      Gets the id of the pc-asset used as the opacity map.

      Returns string

      The asset id.

    • set opacityMap(value: string): void

      Sets the id of the pc-asset to use as the opacity map.

      Parameters

      • value: string

        The asset id.

      Returns void

    • get opacityMapChannel(): ScalarChannel

      Gets the color channel of the opacity map to sample.

      Returns ScalarChannel

      The channel.

    • set opacityMapChannel(value: ScalarChannel): void

      Sets the color channel of the opacity map to sample.

      Parameters

      • value: ScalarChannel

        The channel.

      Returns void

    • get opacityMapOffset(): Vec2

      Gets the 2D offset of the opacity map.

      Returns Vec2

      The offset.

    • set opacityMapOffset(value: Vec2): void

      Sets the 2D offset of the opacity map.

      Parameters

      • value: Vec2

        The offset.

      Returns void

    • get opacityMapRotation(): number

      Gets the 2D rotation of the opacity map.

      Returns number

      The rotation.

    • set opacityMapRotation(value: number): void

      Sets the 2D rotation of the opacity map, in degrees.

      Parameters

      • value: number

        The rotation.

      Returns void

    • get opacityMapTiling(): Vec2

      Gets the 2D tiling of the opacity map.

      Returns Vec2

      The tiling.

    • set opacityMapTiling(value: Vec2): void

      Sets the 2D tiling of the opacity map.

      Parameters

      • value: Vec2

        The tiling.

      Returns void

    • get opacityMapUv(): number

      Gets the UV channel the opacity map samples.

      Returns number

      The UV channel.

    • set opacityMapUv(value: number): void

      Sets the UV channel the opacity map samples.

      Parameters

      • value: number

        The UV channel.

      Returns void

    • get roughness(): number

      Gets the roughness of the material.

      Returns number

      The roughness.

    • set roughness(value: number): void

      Sets the roughness of the material, from 0 (shiny) to 1 (rough). This is an alias for gloss that also inverts the gloss channel, so do not combine it with the gloss attributes.

      Parameters

      • value: number

        The roughness.

      Returns void

    • get roughnessMap(): string

      Gets the id of the pc-asset used as the roughness map.

      Returns string

      The asset id.

    • set roughnessMap(value: string): void

      Sets the id of the pc-asset to use as the roughness map. This is an alias for glossMap that also inverts the gloss channel, so do not combine it with the gloss attributes.

      Parameters

      • value: string

        The asset id.

      Returns void

    • get slopeDepthBias(): number

      Gets the depth offset applied in proportion to a surface's slope.

      Returns number

      The slope depth bias.

    • set slopeDepthBias(value: number): void

      Sets the depth offset applied in proportion to a surface's slope, used to resolve z-fighting.

      Parameters

      • value: number

        The slope depth bias.

      Returns void

    • get specular(): Color

      Gets the specular color of the material, which applies only when the metalness workflow is disabled or use-metalness-specular-color is enabled.

      Returns Color

      The specular color.

    • set specular(value: Color): void

      Sets the specular color of the material, which applies only when the metalness workflow is disabled or use-metalness-specular-color is enabled.

      Parameters

      • value: Color

        The specular color.

      Returns void

    • get specularityFactor(): number

      Gets the strength of specular reflections at direct angles, which applies only when use-metalness-specular-color is enabled.

      Returns number

      The specularity factor.

    • set specularityFactor(value: number): void

      Sets the strength of specular reflections at direct angles, from 0 to 1, which applies only when use-metalness-specular-color is enabled.

      Parameters

      • value: number

        The specularity factor.

      Returns void

    • get twoSidedLighting(): boolean

      Gets whether back faces are lit as though their normals were flipped.

      Returns boolean

      The two sided lighting flag.

    • set twoSidedLighting(value: boolean): void

      Sets whether back faces are lit as though their normals were flipped.

      Parameters

      • value: boolean

        The two sided lighting flag.

      Returns void

    • get useFog(): boolean

      Gets whether the material is affected by scene fog.

      Returns boolean

      The use fog flag.

    • set useFog(value: boolean): void

      Sets whether the material is affected by scene fog.

      Parameters

      • value: boolean

        The use fog flag.

      Returns void

    • get useLighting(): boolean

      Gets whether the material is affected by scene lights.

      Returns boolean

      The use lighting flag.

    • set useLighting(value: boolean): void

      Sets whether the material is affected by scene lights. When disabled the material renders unlit, using the diffuse color and map alone.

      Parameters

      • value: boolean

        The use lighting flag.

      Returns void

    • get useMetalness(): boolean

      Gets whether to use the metalness workflow.

      Returns boolean

      The use metalness flag.

    • set useMetalness(value: boolean): void

      Sets whether to use the metalness workflow rather than the older specular workflow. Unlike a bare StandardMaterial this defaults to true, because the metalness-* attributes have no effect without it.

      Parameters

      • value: boolean

        The use metalness flag.

      Returns void

    • get useMetalnessSpecularColor(): boolean

      Gets whether the specular color tints reflections while the metalness workflow is in use.

      Returns boolean

      The use metalness specular color flag.

    • set useMetalnessSpecularColor(value: boolean): void

      Sets whether the specular color tints reflections while the metalness workflow is in use.

      Parameters

      • value: boolean

        The use metalness specular color flag.

      Returns void

    • get useSkybox(): boolean

      Gets whether the material is lit by the scene's skybox.

      Returns boolean

      The use skybox flag.

    • set useSkybox(value: boolean): void

      Sets whether the material is lit by the scene's skybox.

      Parameters

      • value: boolean

        The use skybox flag.

      Returns void

    • get useTonemap(): boolean

      Gets whether the camera's tone mapping is applied to the material.

      Returns boolean

      The use tonemap flag.

    • set useTonemap(value: boolean): void

      Sets whether the camera's tone mapping is applied to the material.

      Parameters

      • value: boolean

        The use tonemap flag.

      Returns void

    • Points a texture slot at the resource of a pc-asset, waiting for the asset to load when it has not already. An empty id clears the slot.

      Parameters

      • id: string

        The id of the pc-asset, or an empty string to clear the slot.

      • slot: TextureSlot

        The material property to write.

      Returns void