⬅️ Back to Table of Contents
📄 WebGPURenderer.js
📊 Analysis Summary
Metric |
Count |
🧱 Classes |
1 |
📦 Imports |
4 |
📊 Variables & Constants |
2 |
📚 Table of Contents
🛠️ File Location:
📂 src/renderers/webgpu/WebGPURenderer.js
📦 Imports
Name |
Source |
Renderer |
../common/Renderer.js |
WebGLBackend |
../webgl-fallback/WebGLBackend.js |
WebGPUBackend |
./WebGPUBackend.js |
StandardNodeLibrary |
./nodes/StandardNodeLibrary.js |
Variables & Constants
Name |
Type |
Kind |
Value |
Exported |
BackendClass |
any |
let/var |
*not shown* |
✗ |
backend |
WebGLBackend \| WebGPUBackend |
let/var |
new BackendClass( parameters ) |
✗ |
Classes
WebGPURenderer
Class Code
class WebGPURenderer extends Renderer {
/**
* WebGPURenderer options.
*
* @typedef {Object} WebGPURenderer~Options
* @property {boolean} [logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
* @property {boolean} [alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
* @property {boolean} [depth=true] - Whether the default framebuffer should have a depth buffer or not.
* @property {boolean} [stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
* @property {boolean} [antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
* @property {number} [samples=0] - When `antialias` is `true`, `4` samples are used by default. Set this parameter to any other integer value than 0 to overwrite the default.
* @property {boolean} [forceWebGL=false] - If set to `true`, the renderer uses a WebGL 2 backend no matter if WebGPU is supported or not.
* @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported.
* @property {number} [outputType=undefined] - Texture type for output to canvas. By default, device's preferred format is used; other formats may incur overhead.
* @property {number} [colorBufferType=HalfFloatType] - Defines the type of color buffers. The default `HalfFloatType` is recommend for best
* quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though.
*/
/**
* Constructs a new WebGPU renderer.
*
* @param {WebGPURenderer~Options} [parameters] - The configuration parameter.
*/
constructor( parameters = {} ) {
let BackendClass;
if ( parameters.forceWebGL ) {
BackendClass = WebGLBackend;
} else {
BackendClass = WebGPUBackend;
parameters.getFallback = () => {
console.warn( 'THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.' );
return new WebGLBackend( parameters );
};
}
const backend = new BackendClass( parameters );
//super( new Proxy( backend, debugHandler ) );
super( backend, parameters );
/**
* The generic default value is overwritten with the
* standard node library for type mapping.
*
* @type {StandardNodeLibrary}
*/
this.library = new StandardNodeLibrary();
/**
* This flag can be used for type testing.
*
* @type {boolean}
* @readonly
* @default true
*/
this.isWebGPURenderer = true;
if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
}
}
}