WebGL renderer options

SceneRendererOptions

2023.12.26

yisky

interface WebGLOptions {
    alpha?: boolean;
    antialias?: boolean;
    canvas?: HTMLCanvasElement | OffscreenCanvas;
    clearAlpha?: number;
    clearColor?: ColorRepresentation;
    context?: WebGLRenderingContext;
    depth?: boolean;
    failIfMajorPerformanceCaveat?: boolean;
    localClippingEnabled?: boolean;
    logarithmicDepthBuffer?: boolean;
    outputColorSpace?: ColorSpace;
    pixelRatio?: number;
    powerPreference?: string;
    precision?: string;
    premultipliedAlpha?: boolean;
    preserveDrawingBuffer?: boolean;
    shadowMap?: {
        autoUpdate?: boolean;
        enabled?: boolean;
        needsUpdate?: boolean;
        softShadow?: SoftShadowOptions;
        type?: ShadowMapType;
    };
    stencil?: boolean;
    toneMapping?: ToneMapping;
    toneMappingExposure?: number;
    viewport?: HTMLDivElement;
}

Hierarchy

  • WebGLRendererParameters
    • WebGLOptions

Properties

alpha?: boolean

default is false.

antialias?: boolean

default is false.

canvas?: HTMLCanvasElement | OffscreenCanvas

A Canvas where the renderer draws its output.

clearAlpha?: number

Clear alpha, default is 1.0

SceneRendererOptions

clearColor?: ColorRepresentation

Clear color, default is '#f0fff0'

SceneRendererOptions

context?: WebGLRenderingContext
depth?: boolean

default is true.

failIfMajorPerformanceCaveat?: boolean

default is false.

localClippingEnabled?: boolean

Whether to enable local clipping, default is false

SceneRendererOptions

logarithmicDepthBuffer?: boolean

default is false.

outputColorSpace?: ColorSpace

Output color space

SceneRendererOptions

pixelRatio?: number

Pixel ratio, default is window.devicePixelRatio

SceneRendererOptions

powerPreference?: string

Can be "high-performance", "low-power" or "default"

precision?: string

shader precision. Can be "highp", "mediump" or "lowp".

premultipliedAlpha?: boolean

default is true.

preserveDrawingBuffer?: boolean

default is false.

shadowMap?: {
    autoUpdate?: boolean;
    enabled?: boolean;
    needsUpdate?: boolean;
    softShadow?: SoftShadowOptions;
    type?: ShadowMapType;
}

Shadow map options, default is { enabled: false, autoUpdate: true, needsUpdate: false, softShadow: undefined, type: PCFSoftShadowMap }

WebGLOptions

stencil?: boolean

default is false.

toneMapping?: ToneMapping

ToneMapping type, default is NoToneMapping

SceneRendererOptions

toneMappingExposure?: number

ToneMapping exposure, default is 1.0

SceneRendererOptions

viewport?: HTMLDivElement

Rendering viewport, the div that will contain the render canvas, default is document.body

SceneRendererOptions