Ver código fonte

Docs: More JSDoc. (#30633)

Michael Herzog 10 meses atrás
pai
commit
6d005b10c4

+ 413 - 3
src/core/BufferAttribute.js

@@ -9,8 +9,23 @@ const _vector2 = /*@__PURE__*/ new Vector2();
 
 let _id = 0;
 
+/**
+ * This class stores data for an attribute (such as vertex positions, face
+ * indices, normals, colors, UVs, and any custom attributes ) associated with
+ * a geometry, which allows for more efficient passing of data to the GPU.
+ *
+ * When working with vector-like data, the `fromBufferAttribute( attribute, index )`
+ * helper methods on vector and color class might be helpful. E.g. {@link Vector3#fromBufferAttribute}.
+ */
 class BufferAttribute {
 
+	/**
+	 * Constructs a new buffer attribute.
+	 *
+	 * @param {TypedArray} array - The array holding the attribute data.
+	 * @param {number} itemSize - The item size.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 */
 	constructor( array, itemSize, normalized = false ) {
 
 		if ( Array.isArray( array ) ) {
@@ -19,33 +34,133 @@ class BufferAttribute {
 
 		}
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isBufferAttribute = true;
 
+		/**
+		 * The ID of the buffer attribute.
+		 *
+		 * @name BufferAttribute#id
+		 * @type {number}
+		 * @readonly
+		 */
 		Object.defineProperty( this, 'id', { value: _id ++ } );
 
+		/**
+		 * The name of the buffer attribute.
+		 *
+		 * @type {string}
+		 */
 		this.name = '';
 
+		/**
+		 * The array holding the attribute data. It should have `itemSize * numVertices`
+		 * elements, where `numVertices` is the number of vertices in the associated geometry.
+		 *
+		 * @type {TypedArray}
+		 */
 		this.array = array;
+
+		/**
+		 * The number of values of the array that should be associated with a particular vertex.
+		 * For instance, if this attribute is storing a 3-component vector (such as a position,
+		 * normal, or color), then the value should be `3`.
+		 *
+		 * @type {number}
+		 */
 		this.itemSize = itemSize;
+
+		/**
+		 * Represents the number of items this buffer attribute stores. It is internally computed
+		 * by dividing the `array` length by the `itemSize`.
+		 *
+		 * @type {number}
+		 * @readonly
+		 */
 		this.count = array !== undefined ? array.length / itemSize : 0;
+
+		/**
+		 * Applies to integer data only. Indicates how the underlying data in the buffer maps to
+		 * the values in the GLSL code. For instance, if `array` is an instance of `UInt16Array`,
+		 * and `normalized` is `true`, the values `0 -+65535` in the array data will be mapped to
+		 * `0.0f - +1.0f` in the GLSL attribute. If `normalized` is `false`, the values will be converted
+		 * to floats unmodified, i.e. `65535` becomes `65535.0f`.
+		 *
+		 * @type {number}
+		 */
 		this.normalized = normalized;
 
+		/**
+		 * Defines the intended usage pattern of the data store for optimization purposes.
+		 *
+		 * Note: After the initial use of a buffer, its usage cannot be changed. Instead,
+		 * instantiate a new one and set the desired usage before the next render.
+		 *
+		 * @type {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)}
+		 * @default StaticDrawUsage
+		 */
 		this.usage = StaticDrawUsage;
+
+		/**
+		 * This can be used to only update some components of stored vectors (for example, just the
+		 * component related to color). Use the `addUpdateRange()` function to add ranges to this array.
+		 *
+		 * @type {Array<Object>}
+		 */
 		this.updateRanges = [];
+
+		/**
+		 * Configures the bound GPU type for use in shaders.
+		 *
+		 * Note: this only has an effect for integer arrays and is not configurable for float arrays.
+		 * For lower precision float types, use `Float16BufferAttribute`.
+		 *
+		 * @type {(FloatType|IntType)}
+		 * @default FloatType
+		 */
 		this.gpuType = FloatType;
 
+		/**
+		 * A version number, incremented every time the `needsUpdate` is set to `true`.
+		 *
+		 * @type {number}
+		 */
 		this.version = 0;
 
 	}
 
+	/**
+	 * A callback function that is executed after the renderer has transferred the attribute
+	 * array data to the GPU.
+	 */
 	onUploadCallback() {}
 
+	/**
+	 * Flag to indicate that this attribute has changed and should be re-sent to
+	 * the GPU. Set this to `true` when you modify the value of the array.
+	 *
+	 * @type {number}
+	 * @default false
+	 * @param {boolean} value
+	 */
 	set needsUpdate( value ) {
 
 		if ( value === true ) this.version ++;
 
 	}
 
+	/**
+	 * Sets the usage of this buffer attribute.
+	 *
+	 * @param {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)} value - The usage to set.
+	 * @return {BufferAttribute} A reference to this buffer attribute.
+	 */
 	setUsage( value ) {
 
 		this.usage = value;
@@ -54,18 +169,33 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Adds a range of data in the data array to be updated on the GPU.
+	 *
+	 * @param {number} start - Position at which to start update.
+	 * @param {number} count - The number of components to update.
+	 */
 	addUpdateRange( start, count ) {
 
 		this.updateRanges.push( { start, count } );
 
 	}
 
+	/**
+	 * Clears the update ranges.
+	 */
 	clearUpdateRanges() {
 
 		this.updateRanges.length = 0;
 
 	}
 
+	/**
+	 * Copies the values of the given buffer attribute to this instance.
+	 *
+	 * @param {BufferAttribute} source - The buffer attribute to copy.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	copy( source ) {
 
 		this.name = source.name;
@@ -81,6 +211,16 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Copies a vector from the given buffer attribute to this one. The start
+	 * and destination position in the attribute buffers are represented by the
+	 * given indices.
+	 *
+	 * @param {number} index1 - The destintation index into this buffer attribute.
+	 * @param {BufferAttribute} attribute - The buffer attribute to copy from.
+	 * @param {number} index2 - The source index into the given buffer attribute.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	copyAt( index1, attribute, index2 ) {
 
 		index1 *= this.itemSize;
@@ -96,6 +236,12 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Copies the given array data into this buffer attribute.
+	 *
+	 * @param {(TypedArray|Array)} array - The array to copy.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	copyArray( array ) {
 
 		this.array.set( array );
@@ -104,6 +250,13 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Applies the given 3x3 matrix to the given attribute. Works with
+	 * item size `2` and `3`.
+	 *
+	 * @param {Matrix3} m - The matrix to apply.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	applyMatrix3( m ) {
 
 		if ( this.itemSize === 2 ) {
@@ -134,6 +287,13 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Applies the given 4x4 matrix to the given attribute. Only works with
+	 * item size `3`.
+	 *
+	 * @param {Matrix4} m - The matrix to apply.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	applyMatrix4( m ) {
 
 		for ( let i = 0, l = this.count; i < l; i ++ ) {
@@ -150,6 +310,13 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Applies the given 3x3 normal matrix to the given attribute. Only works with
+	 * item size `3`.
+	 *
+	 * @param {Matrix3} m - The normal matrix to apply.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	applyNormalMatrix( m ) {
 
 		for ( let i = 0, l = this.count; i < l; i ++ ) {
@@ -166,6 +333,13 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Applies the given 4x4 matrix to the given attribute. Only works with
+	 * item size `3` and with direction vectors.
+	 *
+	 * @param {Matrix4} m - The matrix to apply.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	transformDirection( m ) {
 
 		for ( let i = 0, l = this.count; i < l; i ++ ) {
@@ -182,6 +356,13 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Sets the given array data in the buffer attribute.
+	 *
+	 * @param {(TypedArray|Array)} value - The array data to set.
+	 * @param {number} [offset=0] - The offset in this buffer attribute's array.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	set( value, offset = 0 ) {
 
 		// Matching BufferAttribute constructor, do not normalize the array.
@@ -191,6 +372,13 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Returns the given component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} component - The component index.
+	 * @return {number} The returned value.
+	 */
 	getComponent( index, component ) {
 
 		let value = this.array[ index * this.itemSize + component ];
@@ -201,6 +389,14 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Sets the given value tothe given component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} component - The component index.
+	 * @param {number} value - The value to set.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setComponent( index, component, value ) {
 
 		if ( this.normalized ) value = normalize( value, this.array );
@@ -211,6 +407,12 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Returns the x component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @return {number} The x component.
+	 */
 	getX( index ) {
 
 		let x = this.array[ index * this.itemSize ];
@@ -221,6 +423,13 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Sets the x component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} x - The value to set.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setX( index, x ) {
 
 		if ( this.normalized ) x = normalize( x, this.array );
@@ -231,6 +440,12 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Returns the y component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @return {number} The y component.
+	 */
 	getY( index ) {
 
 		let y = this.array[ index * this.itemSize + 1 ];
@@ -241,6 +456,13 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Sets the y component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} y - The value to set.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setY( index, y ) {
 
 		if ( this.normalized ) y = normalize( y, this.array );
@@ -251,6 +473,12 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Returns the z component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @return {number} The z component.
+	 */
 	getZ( index ) {
 
 		let z = this.array[ index * this.itemSize + 2 ];
@@ -261,6 +489,13 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Sets the z component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} z - The value to set.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setZ( index, z ) {
 
 		if ( this.normalized ) z = normalize( z, this.array );
@@ -271,6 +506,12 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Returns the w component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @return {number} The w component.
+	 */
 	getW( index ) {
 
 		let w = this.array[ index * this.itemSize + 3 ];
@@ -281,6 +522,13 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Sets the w component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} w - The value to set.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setW( index, w ) {
 
 		if ( this.normalized ) w = normalize( w, this.array );
@@ -291,6 +539,14 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Sets the x and y component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} x - The value for the x component to set.
+	 * @param {number} y - The value for the y component to set.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setXY( index, x, y ) {
 
 		index *= this.itemSize;
@@ -309,6 +565,15 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Sets the x, y and z component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} x - The value for the x component to set.
+	 * @param {number} y - The value for the y component to set.
+	 * @param {number} z - The value for the z component to set.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setXYZ( index, x, y, z ) {
 
 		index *= this.itemSize;
@@ -329,6 +594,16 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Sets the x, y, z and w component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} x - The value for the x component to set.
+	 * @param {number} y - The value for the y component to set.
+	 * @param {number} z - The value for the z component to set.
+	 * @param {number} w - The value for the w component to set.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setXYZW( index, x, y, z, w ) {
 
 		index *= this.itemSize;
@@ -351,6 +626,14 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Sets the given callback function that is executed after the Renderer has transferred
+	 * the attribute array data to the GPU. Can be used to perform clean-up operations after
+	 * the upload when attribute data are not needed anymore on the CPU side.
+	 *
+	 * @param {Function} callback - The `onUpload()` callback.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	onUpload( callback ) {
 
 		this.onUploadCallback = callback;
@@ -359,12 +642,22 @@ class BufferAttribute {
 
 	}
 
+	/**
+	 * Returns a new buffer attribute with copied values from this instance.
+	 *
+	 * @return {BufferAttribute} A clone of this instance.
+	 */
 	clone() {
 
 		return new this.constructor( this.array, this.itemSize ).copy( this );
 
 	}
 
+	/**
+	 * Serializes the buffer attribute into JSON.
+	 *
+	 * @return {Object} A JSON object representing the serialized buffer attribute.
+	 */
 	toJSON() {
 
 		const data = {
@@ -383,10 +676,21 @@ class BufferAttribute {
 
 }
 
-//
-
+/**
+ * Convenient class that can be used when creating a `Int8` buffer attribute with
+ * a plain `Array` instance.
+ *
+ * @augments BufferAttribute
+ */
 class Int8BufferAttribute extends BufferAttribute {
 
+	/**
+	 * Constructs a new buffer attribute.
+	 *
+	 * @param {(Array<number>|Int8Array)} array - The array holding the attribute data.
+	 * @param {number} itemSize - The item size.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 */
 	constructor( array, itemSize, normalized ) {
 
 		super( new Int8Array( array ), itemSize, normalized );
@@ -395,8 +699,21 @@ class Int8BufferAttribute extends BufferAttribute {
 
 }
 
+/**
+ * Convenient class that can be used when creating a `UInt8` buffer attribute with
+ * a plain `Array` instance.
+ *
+ * @augments BufferAttribute
+ */
 class Uint8BufferAttribute extends BufferAttribute {
 
+	/**
+	 * Constructs a new buffer attribute.
+	 *
+	 * @param {(Array<number>|Uint8Array)} array - The array holding the attribute data.
+	 * @param {number} itemSize - The item size.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 */
 	constructor( array, itemSize, normalized ) {
 
 		super( new Uint8Array( array ), itemSize, normalized );
@@ -405,8 +722,21 @@ class Uint8BufferAttribute extends BufferAttribute {
 
 }
 
+/**
+ * Convenient class that can be used when creating a `UInt8Clamped` buffer attribute with
+ * a plain `Array` instance.
+ *
+ * @augments BufferAttribute
+ */
 class Uint8ClampedBufferAttribute extends BufferAttribute {
 
+	/**
+	 * Constructs a new buffer attribute.
+	 *
+	 * @param {(Array<number>|Uint8ClampedArray)} array - The array holding the attribute data.
+	 * @param {number} itemSize - The item size.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 */
 	constructor( array, itemSize, normalized ) {
 
 		super( new Uint8ClampedArray( array ), itemSize, normalized );
@@ -415,8 +745,21 @@ class Uint8ClampedBufferAttribute extends BufferAttribute {
 
 }
 
+/**
+ * Convenient class that can be used when creating a `Int16` buffer attribute with
+ * a plain `Array` instance.
+ *
+ * @augments BufferAttribute
+ */
 class Int16BufferAttribute extends BufferAttribute {
 
+	/**
+	 * Constructs a new buffer attribute.
+	 *
+	 * @param {(Array<number>|Int16Array)} array - The array holding the attribute data.
+	 * @param {number} itemSize - The item size.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 */
 	constructor( array, itemSize, normalized ) {
 
 		super( new Int16Array( array ), itemSize, normalized );
@@ -425,8 +768,21 @@ class Int16BufferAttribute extends BufferAttribute {
 
 }
 
+/**
+ * Convenient class that can be used when creating a `UInt16` buffer attribute with
+ * a plain `Array` instance.
+ *
+ * @augments BufferAttribute
+ */
 class Uint16BufferAttribute extends BufferAttribute {
 
+	/**
+	 * Constructs a new buffer attribute.
+	 *
+	 * @param {(Array<number>|Uint16Array)} array - The array holding the attribute data.
+	 * @param {number} itemSize - The item size.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 */
 	constructor( array, itemSize, normalized ) {
 
 		super( new Uint16Array( array ), itemSize, normalized );
@@ -435,8 +791,21 @@ class Uint16BufferAttribute extends BufferAttribute {
 
 }
 
+/**
+ * Convenient class that can be used when creating a `Int32` buffer attribute with
+ * a plain `Array` instance.
+ *
+ * @augments BufferAttribute
+ */
 class Int32BufferAttribute extends BufferAttribute {
 
+	/**
+	 * Constructs a new buffer attribute.
+	 *
+	 * @param {(Array<number>|Int32Array)} array - The array holding the attribute data.
+	 * @param {number} itemSize - The item size.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 */
 	constructor( array, itemSize, normalized ) {
 
 		super( new Int32Array( array ), itemSize, normalized );
@@ -445,8 +814,21 @@ class Int32BufferAttribute extends BufferAttribute {
 
 }
 
+/**
+ * Convenient class that can be used when creating a `UInt32` buffer attribute with
+ * a plain `Array` instance.
+ *
+ * @augments BufferAttribute
+ */
 class Uint32BufferAttribute extends BufferAttribute {
 
+	/**
+	 * Constructs a new buffer attribute.
+	 *
+	 * @param {(Array<number>|Uint32Array)} array - The array holding the attribute data.
+	 * @param {number} itemSize - The item size.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 */
 	constructor( array, itemSize, normalized ) {
 
 		super( new Uint32Array( array ), itemSize, normalized );
@@ -455,8 +837,24 @@ class Uint32BufferAttribute extends BufferAttribute {
 
 }
 
+/**
+ * Convenient class that can be used when creating a `Float16` buffer attribute with
+ * a plain `Array` instance.
+ *
+ * This class automatically converts to to and from FP16 since `Float16Array` is not
+ * natively supported in JavaScript.
+ *
+ * @augments BufferAttribute
+ */
 class Float16BufferAttribute extends BufferAttribute {
 
+	/**
+	 * Constructs a new buffer attribute.
+	 *
+	 * @param {(Array<number>|Uint16Array)} array - The array holding the attribute data.
+	 * @param {number} itemSize - The item size.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 */
 	constructor( array, itemSize, normalized ) {
 
 		super( new Uint16Array( array ), itemSize, normalized );
@@ -607,9 +1005,21 @@ class Float16BufferAttribute extends BufferAttribute {
 
 }
 
-
+/**
+ * Convenient class that can be used when creating a `Float32` buffer attribute with
+ * a plain `Array` instance.
+ *
+ * @augments BufferAttribute
+ */
 class Float32BufferAttribute extends BufferAttribute {
 
+	/**
+	 * Constructs a new buffer attribute.
+	 *
+	 * @param {(Array<number>|Float32Array)} array - The array holding the attribute data.
+	 * @param {number} itemSize - The item size.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 */
 	constructor( array, itemSize, normalized ) {
 
 		super( new Float32Array( array ), itemSize, normalized );

+ 336 - 0
src/core/BufferGeometry.js

@@ -19,45 +19,191 @@ const _box = /*@__PURE__*/ new Box3();
 const _boxMorphTargets = /*@__PURE__*/ new Box3();
 const _vector = /*@__PURE__*/ new Vector3();
 
+/**
+ * A representation of mesh, line, or point geometry. Includes vertex
+ * positions, face indices, normals, colors, UVs, and custom attributes
+ * within buffers, reducing the cost of passing all this data to the GPU.
+ *
+ * ```js
+ * const geometry = new THREE.BufferGeometry();
+ * // create a simple square shape. We duplicate the top left and bottom right
+ * // vertices because each vertex needs to appear once per triangle.
+ * const vertices = new Float32Array( [
+ * 	-1.0, -1.0,  1.0, // v0
+ * 	 1.0, -1.0,  1.0, // v1
+ * 	 1.0,  1.0,  1.0, // v2
+ *
+ * 	 1.0,  1.0,  1.0, // v3
+ * 	-1.0,  1.0,  1.0, // v4
+ * 	-1.0, -1.0,  1.0  // v5
+ * ] );
+ * // itemSize = 3 because there are 3 values (components) per vertex
+ * geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
+ * const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
+ * const mesh = new THREE.Mesh( geometry, material );
+ * ```
+ *
+ * @augments EventDispatcher
+ */
 class BufferGeometry extends EventDispatcher {
 
+	/**
+	 * Constructs a new geometry.
+	 */
 	constructor() {
 
 		super();
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isBufferGeometry = true;
 
+		/**
+		 * The ID of the geometry.
+		 *
+		 * @name BufferGeometry#id
+		 * @type {number}
+		 * @readonly
+		 */
 		Object.defineProperty( this, 'id', { value: _id ++ } );
 
+		/**
+		 * The UUID of the geometry.
+		 *
+		 * @type {string}
+		 * @readonly
+		 */
 		this.uuid = generateUUID();
 
+		/**
+		 * The name of the geometry.
+		 *
+		 * @type {string}
+		 */
 		this.name = '';
 		this.type = 'BufferGeometry';
 
+		/**
+		 * Allows for vertices to be re-used across multiple triangles; this is
+		 * called using "indexed triangles". Each triangle is associated with the
+		 * indices of three vertices. This attribute therefore stores the index of
+		 * each vertex for each triangular face. If this attribute is not set, the
+		 * renderer assumes that each three contiguous positions represent a single triangle.
+		 *
+		 * @type {?BufferAttribute}
+		 * @default null
+		 */
 		this.index = null;
+
+		/**
+		 * A (storage) buffer attribute which was generated with a compute shader and
+		 * now defines indirect draw calls.
+		 *
+		 * Can only be used with {@link WebGPURenderer} and a WebGPU backend.
+		 *
+		 * @type {?BufferAttribute}
+		 * @default null
+		 */
 		this.indirect = null;
+
+		/**
+		 * This dictionary has as id the name of the attribute to be set and as value
+		 * the buffer attribute to set it to. Rather than accessing this property directly,
+		 * use `setAttribute()` and `getAttribute()` to access attributes of this geometry.
+		 *
+		 * @type {Object<string,(BufferAttribute|InterleavedBufferAttribute)>}
+		 */
 		this.attributes = {};
 
+		/**
+		 * This dictionary holds the morph targets of the geometry.
+		 *
+		 * Note: Once the geometry has been rendered, the morph attribute data cannot
+		 * be changed. You will have to call `dispose()?, and create a new geometry instance.
+		 *
+		 * @type {Object}
+		 */
 		this.morphAttributes = {};
+
+		/**
+		 * Used to control the morph target behavior; when set to `true`, the morph
+		 * target data is treated as relative offsets, rather than as absolute
+		 * positions/normals.
+		 *
+		 * @type {boolean}
+		 * @default false
+		 */
 		this.morphTargetsRelative = false;
 
+		/**
+		 * Split the geometry into groups, each of which will be rendered in a
+		 * separate draw call. This allows an array of materials to be used with the geometry.
+		 *
+		 * Use `addGroup()` and `clearGroups()` to edtir groups, rather than modifying this array directly.
+		 *
+		 * Every vertex and index must belong to exactly one group — groups must not share vertices or
+		 * indices, and must not leave vertices or indices unused.
+		 *
+		 * @type {Array<Object>}
+		 */
 		this.groups = [];
 
+		/**
+		 * Bounding box for the geometry which can be calculated with `computeBoundingBox()`.
+		 *
+		 * @type {Box3}
+		 * @default null
+		 */
 		this.boundingBox = null;
+
+		/**
+		 * Bounding sphere for the geometry which can be calculated with `computeBoundingSphere()`.
+		 *
+		 * @type {Sphere}
+		 * @default null
+		 */
 		this.boundingSphere = null;
 
+		/**
+		 * Determines the part of the geometry to render. This should not be set directly,
+		 * instead use `setDrawRange()`.
+		 *
+		 * @type {{start:number,count:number}}
+		 */
 		this.drawRange = { start: 0, count: Infinity };
 
+		/**
+		 * An object that can be used to store custom data about the geometry.
+		 * It should not hold references to functions as these will not be cloned.
+		 *
+		 * @type {Object}
+		 */
 		this.userData = {};
 
 	}
 
+	/**
+	 * Returns the index of this geometry.
+	 *
+	 * @return {?BufferAttribute} The index. Returns `null` if no index is defined.
+	 */
 	getIndex() {
 
 		return this.index;
 
 	}
 
+	/**
+	 * Sets the given index to this geometry.
+	 *
+	 * @param {Array<number>|BufferAttribute} index - The index to set.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	setIndex( index ) {
 
 		if ( Array.isArray( index ) ) {
@@ -74,6 +220,12 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Sets the given indirect attribute to this geometry.
+	 *
+	 * @param {BufferAttribute} indirect - The attribute holding indirect draw calls.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	setIndirect( indirect ) {
 
 		this.indirect = indirect;
@@ -82,18 +234,37 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Returns the indirect attribute of this geometry.
+	 *
+	 * @return {?BufferAttribute} The indirect attribute. Returns `null` if no indirect attribute is defined.
+	 */
 	getIndirect() {
 
 		return this.indirect;
 
 	}
 
+	/**
+	 * Returns the buffer attribute for the given name.
+	 *
+	 * @param {string} name - The attribute name.
+	 * @return {BufferAttribute|InterleavedBufferAttribute|undefined} The buffer attribute.
+	 * Returns `undefined` if not attribute has been found.
+	 */
 	getAttribute( name ) {
 
 		return this.attributes[ name ];
 
 	}
 
+	/**
+	 * Sets the given attribute for the given name.
+	 *
+	 * @param {string} name - The attribute name.
+	 * @param {BufferAttribute|InterleavedBufferAttribute} attribute - The attribute to set.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	setAttribute( name, attribute ) {
 
 		this.attributes[ name ] = attribute;
@@ -102,6 +273,12 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Deletes the attribute for the given name.
+	 *
+	 * @param {string} name - The attribute name to delete.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	deleteAttribute( name ) {
 
 		delete this.attributes[ name ];
@@ -110,12 +287,26 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Returns `true` if this geometry has an attribute for the given name.
+	 *
+	 * @param {string} name - The attribute name.
+	 * @return {boolean} Whether this geometry has an attribute for the given name or not.
+	 */
 	hasAttribute( name ) {
 
 		return this.attributes[ name ] !== undefined;
 
 	}
 
+	/**
+	 * Adds a group to this geometry.
+	 *
+	 * @param {number} start - The first element in this draw call. That is the first
+	 * vertex for non-indexed geometry, otherwise the first triangle index.
+	 * @param {number} count - Specifies how many vertices (or indices) are part of this group.
+	 * @param {number} [materialIndex=0] - The material array index to use.
+	 */
 	addGroup( start, count, materialIndex = 0 ) {
 
 		this.groups.push( {
@@ -128,12 +319,22 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Clears all groups.
+	 */
 	clearGroups() {
 
 		this.groups = [];
 
 	}
 
+	/**
+	 * Sets the draw range for this geometry.
+	 *
+	 * @param {number} start - The first vertex for non-indexed geometry, otherwise the first triangle index.
+	 * @param {number} count - For non-indexed BufferGeometry, `count` is the number of vertices to render.
+	 * For indexed BufferGeometry, `count` is the number of indices to render.
+	 */
 	setDrawRange( start, count ) {
 
 		this.drawRange.start = start;
@@ -141,6 +342,12 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Applies the given 4x4 tranformation matrix to the geometry.
+	 *
+	 * @param {Matrix4} matrix - The matrix to apply.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	applyMatrix4( matrix ) {
 
 		const position = this.attributes.position;
@@ -191,6 +398,12 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Applies the rotation represented by the Quaternion to the geometry.
+	 *
+	 * @param {Quaternion} q - The Quaternion to apply.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	applyQuaternion( q ) {
 
 		_m1.makeRotationFromQuaternion( q );
@@ -201,6 +414,14 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Rotates the geometry about the X axis. This is typically done as a one time
+	 * operation, and not during a loop. Use {@link Object3D#rotation} for typical
+	 * real-time mesh rotation.
+	 *
+	 * @param {number} angle - The angle in radians.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	rotateX( angle ) {
 
 		// rotate geometry around world x-axis
@@ -213,6 +434,14 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Rotates the geometry about the Y axis. This is typically done as a one time
+	 * operation, and not during a loop. Use {@link Object3D#rotation} for typical
+	 * real-time mesh rotation.
+	 *
+	 * @param {number} angle - The angle in radians.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	rotateY( angle ) {
 
 		// rotate geometry around world y-axis
@@ -225,6 +454,14 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Rotates the geometry about the Z axis. This is typically done as a one time
+	 * operation, and not during a loop. Use {@link Object3D#rotation} for typical
+	 * real-time mesh rotation.
+	 *
+	 * @param {number} angle - The angle in radians.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	rotateZ( angle ) {
 
 		// rotate geometry around world z-axis
@@ -237,6 +474,16 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Translates the geometry. This is typically done as a one time
+	 * operation, and not during a loop. Use {@link Object3D#position} for typical
+	 * real-time mesh rotation.
+	 *
+	 * @param {number} x - The x offset.
+	 * @param {number} y - The y offset.
+	 * @param {number} z - The z offset.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	translate( x, y, z ) {
 
 		// translate geometry
@@ -249,6 +496,16 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Scales the geometry. This is typically done as a one time
+	 * operation, and not during a loop. Use {@link Object3D#scale} for typical
+	 * real-time mesh rotation.
+	 *
+	 * @param {number} x - The x scale.
+	 * @param {number} y - The y scale.
+	 * @param {number} z - The z scale.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	scale( x, y, z ) {
 
 		// scale geometry
@@ -261,6 +518,14 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Rotates the geometry to face a point in 3D space. This is typically done as a one time
+	 * operation, and not during a loop. Use {@link Object3D#lookAt} for typical
+	 * real-time mesh rotation.
+	 *
+	 * @param {Vector3} vector - The target point.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	lookAt( vector ) {
 
 		_obj.lookAt( vector );
@@ -273,6 +538,11 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Center the geometry based on its bounding box.
+	 *
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	center() {
 
 		this.computeBoundingBox();
@@ -285,6 +555,17 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Defines a geometry by creating a `position` attribute based on the given array of points. The array
+	 * can hold 2D or 3D vectoes. When using two-dimensional data, the `z` coordinate for all vertices is
+	 * set to `0`.
+	 *
+	 * If the method is used with an existing `position` attribute, the vertex data are overwritten with the
+	 * data from the array. The length of the array must match the vertex count.
+	 *
+	 * @param {Array<Vector2>|Array<Vector3>} points - The points.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	setFromPoints( points ) {
 
 		const positionAttribute = this.getAttribute( 'position' );
@@ -327,6 +608,11 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Computes the bounding box of the geometry, and updates the `boundingBox` member.
+	 * The bounding box is not computed by the engine; it must be computed by your app.
+	 * You may need to recompute the bounding box if the geometry vertices are modified.
+	 */
 	computeBoundingBox() {
 
 		if ( this.boundingBox === null ) {
@@ -397,6 +683,11 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Computes the bounding sphere of the geometry, and updates the `boundingSphere` member.
+	 * The engine automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling.
+	 * You may need to recompute the bounding sphere if the geometry vertices are modified.
+	 */
 	computeBoundingSphere() {
 
 		if ( this.boundingSphere === null ) {
@@ -509,6 +800,13 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Calculates and adds a tangent attribute to this geometry.
+	 *
+	 * The computation is only supported for indexed geometries and if position, normal, and uv attributes
+	 * are defined. When using a tangent space normal map, prefer the MikkTSpace algorithm provided by
+	 * {@link BufferGeometryUtils#computeMikkTSpaceTangents} instead.
+	 */
 	computeTangents() {
 
 		const index = this.index;
@@ -668,6 +966,12 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Computes vertex normals for the given vertex data. For indexed geometries, the method sets
+	 * each vertex normal to be the average of the face normals of the faces that share that vertex.
+	 * For non-indexed geometries, vertices are not shared, and the method sets each vertex normal
+	 * to be the same as the face normal.
+	 */
 	computeVertexNormals() {
 
 		const index = this.index;
@@ -760,6 +1064,10 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Ensures every normal vector in a geometry will have a magnitude of `1`. This will
+	 * correct lighting on the geometry surfaces.
+	 */
 	normalizeNormals() {
 
 		const normals = this.attributes.normal;
@@ -776,6 +1084,12 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Return a new non-index version of this indexed geometry. If the geometry
+	 * is already non-indexed, the method is a NOOP.
+	 *
+	 * @return {BufferGeometry} The non-indexed version of this indexed geometry.
+	 */
 	toNonIndexed() {
 
 		function convertBufferAttribute( attribute, indices ) {
@@ -878,6 +1192,11 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Serializes the geometry into JSON.
+	 *
+	 * @return {Object} A JSON object representing the serialized geometry.
+	 */
 	toJSON() {
 
 		const data = {
@@ -991,12 +1310,23 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Returns a new geometry with copied values from this instance.
+	 *
+	 * @return {BufferGeometry} A clone of this instance.
+	 */
 	clone() {
 
 		return new this.constructor().copy( this );
 
 	}
 
+	/**
+	 * Copies the values of the given geometry to this instance.
+	 *
+	 * @param {BufferGeometry} source - The geometry to copy.
+	 * @return {BufferGeometry} A reference to this instance.
+	 */
 	copy( source ) {
 
 		// reset
@@ -1102,6 +1432,12 @@ class BufferGeometry extends EventDispatcher {
 
 	}
 
+	/**
+	 * Frees the GPU-related resources allocated by this instance. Call this
+	 * method whenever this instance is no longer used in your app.
+	 *
+	 * @fires BufferGeometry#dispose
+	 */
 	dispose() {
 
 		this.dispatchEvent( { type: 'dispose' } );

+ 60 - 0
src/core/Clock.js

@@ -1,17 +1,64 @@
+/**
+ * Class for keeping track of time.
+ */
 class Clock {
 
+	/**
+	 * Constructs a new clock.
+	 *
+	 * @param {boolean} [autoStart=true] - Whether to automatically start the clock when
+	 * `getDelta()` is called for the first time.
+	 */
 	constructor( autoStart = true ) {
 
+		/**
+		 * If set to `true`, the clock starts automatically when `getDelta()` is called
+		 * for the first time.
+		 *
+		 * @type {boolean}
+		 * @default true
+		 */
 		this.autoStart = autoStart;
 
+		/**
+		 * Holds the time at which the clock's `start()` method was last called.
+		 *
+		 * @type {number}
+		 * @default 0
+		 */
 		this.startTime = 0;
+
+		/**
+		 * Holds the time at which the clock's `start()`, `getElapsedTime()` or
+		 * `getDelta()` methods were last called.
+		 *
+		 * @type {number}
+		 * @default 0
+		 */
 		this.oldTime = 0;
+
+		/**
+		 * Keeps track of the total time that the clock has been running.
+		 *
+		 * @type {number}
+		 * @default 0
+		 */
 		this.elapsedTime = 0;
 
+		/**
+		 * Whether the clock is running or not.
+		 *
+		 * @type {boolean}
+		 * @default true
+		 */
 		this.running = false;
 
 	}
 
+	/**
+	 * Starts the clock. When `autoStart` is set to `true`, the method is automatically
+	 * called by the class.
+	 */
 	start() {
 
 		this.startTime = now();
@@ -22,6 +69,9 @@ class Clock {
 
 	}
 
+	/**
+	 * Stops the clock.
+	 */
 	stop() {
 
 		this.getElapsedTime();
@@ -30,6 +80,11 @@ class Clock {
 
 	}
 
+	/**
+	 * Returns the elapsed time in seconds.
+	 *
+	 * @return {number} The elapsed time.
+	 */
 	getElapsedTime() {
 
 		this.getDelta();
@@ -37,6 +92,11 @@ class Clock {
 
 	}
 
+	/**
+	 * Returns the delta time in seconds.
+	 *
+	 * @return {number} The delta time.
+	 */
 	getDelta() {
 
 		let diff = 0;

+ 99 - 0
src/core/GLBufferAttribute.js

@@ -1,27 +1,107 @@
+/**
+ * An alternative version of a buffer attribute with more control over the VBO.
+ *
+ * The renderer does not construct a VBO for this kind of attribute. Instead, it uses
+ * whatever VBO is passed in constructor and can later be altered via the `buffer` property.
+ *
+ * The most common use case for this class is when some kind of GPGPU calculation interferes
+ * or even produces the VBOs in question.
+ *
+ * Notice that this class can only be used with {@link WebGLRenderer}.
+ */
 class GLBufferAttribute {
 
+	/**
+	 * Constructs a new GL buffer attribute.
+	 *
+	 * @param {WebGLBuffer} buffer - The native WebGL buffer.
+	 * @param {number} type - The native data type (e.g. `gl.FLOAT`).
+	 * @param {number} itemSize - The item size.
+	 * @param {number} elementSize - The corresponding size (in bytes) for the given `type` parameter.
+	 * @param {number} count - The expected number of vertices in VBO.
+	 */
 	constructor( buffer, type, itemSize, elementSize, count ) {
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isGLBufferAttribute = true;
 
+		/**
+		 * The name of the buffer attribute.
+		 *
+		 * @type {string}
+		 */
 		this.name = '';
 
+		/**
+		 * The native WebGL buffer.
+		 *
+		 * @type {WebGLBuffer}
+		 */
 		this.buffer = buffer;
+
+		/**
+		 * The native data type.
+		 *
+		 * @type {number}
+		 */
 		this.type = type;
+
+		/**
+		 * The item size, see {@link BufferAttribute#itemSize}.
+		 *
+		 * @type {number}
+		 */
 		this.itemSize = itemSize;
+
+		/**
+		 * The corresponding size (in bytes) for the given `type` parameter.
+		 *
+		 * @type {number}
+		 */
 		this.elementSize = elementSize;
+
+		/**
+		 * The expected number of vertices in VBO.
+		 *
+		 * @type {number}
+		 */
 		this.count = count;
 
+		/**
+		 * A version number, incremented every time the `needsUpdate` is set to `true`.
+		 *
+		 * @type {number}
+		 */
 		this.version = 0;
 
 	}
 
+	/**
+	 * Flag to indicate that this attribute has changed and should be re-sent to
+	 * the GPU. Set this to `true` when you modify the value of the array.
+	 *
+	 * @type {number}
+	 * @default false
+	 * @param {boolean} value
+	 */
 	set needsUpdate( value ) {
 
 		if ( value === true ) this.version ++;
 
 	}
 
+	/**
+	 * Sets the given native WebGL buffer.
+	 *
+	 * @param {WebGLBuffer} buffer - The buffer to set.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setBuffer( buffer ) {
 
 		this.buffer = buffer;
@@ -30,6 +110,13 @@ class GLBufferAttribute {
 
 	}
 
+	/**
+	 * Sets the given native data type and element size.
+	 *
+	 * @param {number} type - The native data type (e.g. `gl.FLOAT`).
+	 * @param {number} elementSize - The corresponding size (in bytes) for the given `type` parameter.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setType( type, elementSize ) {
 
 		this.type = type;
@@ -39,6 +126,12 @@ class GLBufferAttribute {
 
 	}
 
+	/**
+	 * Sets the item size.
+	 *
+	 * @param {number} itemSize - The item size.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setItemSize( itemSize ) {
 
 		this.itemSize = itemSize;
@@ -47,6 +140,12 @@ class GLBufferAttribute {
 
 	}
 
+	/**
+	 * Sets the count (the expected number of vertices in VBO).
+	 *
+	 * @param {number} count - The count.
+	 * @return {BufferAttribute} A reference to this instance.
+	 */
 	setCount( count ) {
 
 		this.count = count;

+ 29 - 0
src/core/InstancedBufferAttribute.js

@@ -1,13 +1,42 @@
 import { BufferAttribute } from './BufferAttribute.js';
 
+/**
+ * An instanced version of a buffer attribute.
+ *
+ * @augments BufferAttribute
+ */
 class InstancedBufferAttribute extends BufferAttribute {
 
+	/**
+	 * Constructs a new instanced buffer attribute.
+	 *
+	 * @param {TypedArray} array - The array holding the attribute data.
+	 * @param {number} itemSize - The item size.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 * @param {number} [meshPerAttribute=1] - How often a value of this buffer attribute should be repeated.
+	 */
 	constructor( array, itemSize, normalized, meshPerAttribute = 1 ) {
 
 		super( array, itemSize, normalized );
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isInstancedBufferAttribute = true;
 
+		/**
+		 * Defines how often a value of this buffer attribute should be repeated. A
+		 * value of one means that each value of the instanced attribute is used for
+		 * a single instance. A value of two means that each value is used for two
+		 * consecutive instances (and so on).
+		 *
+		 * @type {number}
+		 * @default 1
+		 */
 		this.meshPerAttribute = meshPerAttribute;
 
 	}

+ 20 - 0
src/core/InstancedBufferGeometry.js

@@ -1,14 +1,34 @@
 import { BufferGeometry } from './BufferGeometry.js';
 
+/**
+ * An instanced version of a geometry.
+ */
 class InstancedBufferGeometry extends BufferGeometry {
 
+	/**
+	 * Constructs a new instanced buffer geometry.
+	 */
 	constructor() {
 
 		super();
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isInstancedBufferGeometry = true;
 
 		this.type = 'InstancedBufferGeometry';
+
+		/**
+		 * The instance count.
+		 *
+		 * @type {number}
+		 * @default Infinity
+		 */
 		this.instanceCount = Infinity;
 
 	}

+ 26 - 0
src/core/InstancedInterleavedBuffer.js

@@ -1,13 +1,39 @@
 import { InterleavedBuffer } from './InterleavedBuffer.js';
 
+/**
+ * An instanced version of an interleaved buffer.
+ *
+ * @augments InterleavedBuffer
+ */
 class InstancedInterleavedBuffer extends InterleavedBuffer {
 
+	/**
+	 * Constructs a new instanced interleaved buffer.
+	 *
+	 * @param {TypedArray} array - A typed array with a shared buffer storing attribute data.
+	 * @param {number} stride - The number of typed-array elements per vertex.
+	 * @param {number} [meshPerAttribute=1] - Defines how often a value of this interleaved buffer should be repeated.
+	 */
 	constructor( array, stride, meshPerAttribute = 1 ) {
 
 		super( array, stride );
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isInstancedInterleavedBuffer = true;
 
+		/**
+		 * Defines how often a value of this buffer attribute should be repeated,
+		 * see {@link InstancedBufferAttribute#meshPerAttribute}.
+		 *
+		 * @type {number}
+		 * @default 1
+		 */
 		this.meshPerAttribute = meshPerAttribute;
 
 	}

+ 137 - 3
src/core/InterleavedBuffer.js

@@ -1,33 +1,115 @@
 import { generateUUID } from '../math/MathUtils.js';
 import { StaticDrawUsage } from '../constants.js';
 
+/**
+ * "Interleaved" means that multiple attributes, possibly of different types,
+ * (e.g., position, normal, uv, color) are packed into a single array buffer.
+ *
+ * An introduction into interleaved arrays can be found here: [Interleaved array basics]{@link https://blog.tojicode.com/2011/05/interleaved-array-basics.html}
+ */
 class InterleavedBuffer {
 
+	/**
+	 * Constructs a new interleaved buffer.
+	 *
+	 * @param {TypedArray} array - A typed array with a shared buffer storing attribute data.
+	 * @param {number} stride - The number of typed-array elements per vertex.
+	 */
 	constructor( array, stride ) {
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isInterleavedBuffer = true;
 
+		/**
+		 * A typed array with a shared buffer storing attribute data.
+		 *
+		 * @type {TypedArray}
+		 */
 		this.array = array;
+
+		/**
+		 * The number of typed-array elements per vertex.
+		 *
+		 * @type {number}
+		 */
 		this.stride = stride;
+
+		/**
+		 * The total number of elements in the array
+		 *
+		 * @type {number}
+		 * @readonly
+		 */
 		this.count = array !== undefined ? array.length / stride : 0;
 
+		/**
+		 * Defines the intended usage pattern of the data store for optimization purposes.
+		 *
+		 * Note: After the initial use of a buffer, its usage cannot be changed. Instead,
+		 * instantiate a new one and set the desired usage before the next render.
+		 *
+		 * @type {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)}
+		 * @default StaticDrawUsage
+		 */
 		this.usage = StaticDrawUsage;
+
+		/**
+		 * This can be used to only update some components of stored vectors (for example, just the
+		 * component related to color). Use the `addUpdateRange()` function to add ranges to this array.
+		 *
+		 * @type {Array<Object>}
+		 */
 		this.updateRanges = [];
 
+		/**
+		 * A version number, incremented every time the `needsUpdate` is set to `true`.
+		 *
+		 * @type {number}
+		 */
 		this.version = 0;
 
+		/**
+		 * The UUID of the interleaved buffer.
+		 *
+		 * @type {string}
+		 * @readonly
+		 */
 		this.uuid = generateUUID();
 
 	}
 
+	/**
+	 * A callback function that is executed after the renderer has transferred the attribute array
+	 * data to the GPU.
+	 */
 	onUploadCallback() {}
 
+	/**
+	 * Flag to indicate that this attribute has changed and should be re-sent to
+	 * the GPU. Set this to `true` when you modify the value of the array.
+	 *
+	 * @type {number}
+	 * @default false
+	 * @param {boolean} value
+	 */
 	set needsUpdate( value ) {
 
 		if ( value === true ) this.version ++;
 
 	}
 
+	/**
+	 * Sets the usage of this interleaved buffer.
+	 *
+	 * @param {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)} value - The usage to set.
+	 * @return {InterleavedBuffer} A reference to this interleaved buffer.
+	 */
 	setUsage( value ) {
 
 		this.usage = value;
@@ -36,18 +118,33 @@ class InterleavedBuffer {
 
 	}
 
+	/**
+	 * Adds a range of data in the data array to be updated on the GPU.
+	 *
+	 * @param {number} start - Position at which to start update.
+	 * @param {number} count - The number of components to update.
+	 */
 	addUpdateRange( start, count ) {
 
 		this.updateRanges.push( { start, count } );
 
 	}
 
+	/**
+	 * Clears the update ranges.
+	 */
 	clearUpdateRanges() {
 
 		this.updateRanges.length = 0;
 
 	}
 
+	/**
+	 * Copies the values of the given interleaved buffer to this instance.
+	 *
+	 * @param {InterleavedBuffer} source - The interleaved buffer to copy.
+	 * @return {InterleavedBuffer} A reference to this instance.
+	 */
 	copy( source ) {
 
 		this.array = new source.array.constructor( source.array );
@@ -59,14 +156,24 @@ class InterleavedBuffer {
 
 	}
 
-	copyAt( index1, attribute, index2 ) {
+	/**
+	 * Copies a vector from the given interleaved buffer to this one. The start
+	 * and destination position in the attribute buffers are represented by the
+	 * given indices.
+	 *
+	 * @param {number} index1 - The destintation index into this interleaved buffer.
+	 * @param {InterleavedBuffer} interleavedBuffer - The interleaved buffer to copy from.
+	 * @param {number} index2 - The source index into the given interleaved buffer.
+	 * @return {InterleavedBuffer} A reference to this instance.
+	 */
+	copyAt( index1, interleavedBuffer, index2 ) {
 
 		index1 *= this.stride;
-		index2 *= attribute.stride;
+		index2 *= interleavedBuffer.stride;
 
 		for ( let i = 0, l = this.stride; i < l; i ++ ) {
 
-			this.array[ index1 + i ] = attribute.array[ index2 + i ];
+			this.array[ index1 + i ] = interleavedBuffer.array[ index2 + i ];
 
 		}
 
@@ -74,6 +181,13 @@ class InterleavedBuffer {
 
 	}
 
+	/**
+	 * Sets the given array data in the interleaved buffer.
+	 *
+	 * @param {(TypedArray|Array)} value - The array data to set.
+	 * @param {number} [offset=0] - The offset in this interleaved buffer's array.
+	 * @return {InterleavedBuffer} A reference to this instance.
+	 */
 	set( value, offset = 0 ) {
 
 		this.array.set( value, offset );
@@ -82,6 +196,12 @@ class InterleavedBuffer {
 
 	}
 
+	/**
+	 * Returns a new interleaved buffer with copied values from this instance.
+	 *
+	 * @param {Object} [data] - An object with shared array buffers that allows to retain shared structures.
+	 * @return {InterleavedBuffer} A clone of this instance.
+	 */
 	clone( data ) {
 
 		if ( data.arrayBuffers === undefined ) {
@@ -111,6 +231,14 @@ class InterleavedBuffer {
 
 	}
 
+	/**
+	 * Sets the given callback function that is executed after the Renderer has transferred
+	 * the array data to the GPU. Can be used to perform clean-up operations after
+	 * the upload when data are not needed anymore on the CPU side.
+	 *
+	 * @param {Function} callback - The `onUpload()` callback.
+	 * @return {InterleavedBuffer} A reference to this instance.
+	 */
 	onUpload( callback ) {
 
 		this.onUploadCallback = callback;
@@ -119,6 +247,12 @@ class InterleavedBuffer {
 
 	}
 
+	/**
+	 * Serializes the interleaved buffer into JSON.
+	 *
+	 * @param {Object} [data] - An optional value holding meta information about the serialization.
+	 * @return {Object} A JSON object representing the serialized interleaved buffer.
+	 */
 	toJSON( data ) {
 
 		if ( data.arrayBuffers === undefined ) {

+ 197 - 0
src/core/InterleavedBufferAttribute.js

@@ -4,40 +4,113 @@ import { denormalize, normalize } from '../math/MathUtils.js';
 
 const _vector = /*@__PURE__*/ new Vector3();
 
+/**
+ * An alternative version of a buffer attribute with interleaved data. Interleaved
+ * attributes share a common interleaved data storage ({@link InterleavedBuffer}) and refer with
+ * different offsets into the buffer.
+ */
 class InterleavedBufferAttribute {
 
+	/**
+	 * Constructs a new interleaved buffer attribute.
+	 *
+	 * @param {InterleavedBuffer} interleavedBuffer - The buffer holding the interleaved data.
+	 * @param {number} itemSize - The item size.
+	 * @param {number} offset - The attribute offset into the buffer.
+	 * @param {boolean} [normalized=false] - Whether the data are normalized or not.
+	 */
 	constructor( interleavedBuffer, itemSize, offset, normalized = false ) {
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isInterleavedBufferAttribute = true;
 
+		/**
+		 * The name of the buffer attribute.
+		 *
+		 * @type {string}
+		 */
 		this.name = '';
 
+		/**
+		 * The buffer holding the interleaved data.
+		 *
+		 * @type {InterleavedBuffer}
+		 */
 		this.data = interleavedBuffer;
+
+		/**
+		 * The item size, see {@link BufferAttribute#itemSize}.
+		 *
+		 * @type {number}
+		 */
 		this.itemSize = itemSize;
+
+		/**
+		 * The attribute offset into the buffer.
+		 *
+		 * @type {number}
+		 */
 		this.offset = offset;
 
+		/**
+		 * Whether the data are normalized or not, see {@link BufferAttribute#normalized}
+		 *
+		 * @type {InterleavedBuffer}
+		 */
 		this.normalized = normalized;
 
 	}
 
+	/**
+	 * The item count of this buffer attribute.
+	 *
+	 * @type {number}
+	 * @readonly
+	 */
 	get count() {
 
 		return this.data.count;
 
 	}
 
+	/**
+	 * The array holding the interleaved buffer attribute data.
+	 *
+	 * @type {TypedArray}
+	 */
 	get array() {
 
 		return this.data.array;
 
 	}
 
+	/**
+	 * Flag to indicate that this attribute has changed and should be re-sent to
+	 * the GPU. Set this to `true` when you modify the value of the array.
+	 *
+	 * @type {number}
+	 * @default false
+	 * @param {boolean} value
+	 */
 	set needsUpdate( value ) {
 
 		this.data.needsUpdate = value;
 
 	}
 
+	/**
+	 * Applies the given 4x4 matrix to the given attribute. Only works with
+	 * item size `3`.
+	 *
+	 * @param {Matrix4} m - The matrix to apply.
+	 * @return {InterleavedBufferAttribute} A reference to this instance.
+	 */
 	applyMatrix4( m ) {
 
 		for ( let i = 0, l = this.data.count; i < l; i ++ ) {
@@ -54,6 +127,13 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Applies the given 3x3 normal matrix to the given attribute. Only works with
+	 * item size `3`.
+	 *
+	 * @param {Matrix3} m - The normal matrix to apply.
+	 * @return {InterleavedBufferAttribute} A reference to this instance.
+	 */
 	applyNormalMatrix( m ) {
 
 		for ( let i = 0, l = this.count; i < l; i ++ ) {
@@ -70,6 +150,13 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Applies the given 4x4 matrix to the given attribute. Only works with
+	 * item size `3` and with direction vectors.
+	 *
+	 * @param {Matrix4} m - The matrix to apply.
+	 * @return {InterleavedBufferAttribute} A reference to this instance.
+	 */
 	transformDirection( m ) {
 
 		for ( let i = 0, l = this.count; i < l; i ++ ) {
@@ -86,6 +173,13 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Returns the given component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} component - The component index.
+	 * @return {number} The returned value.
+	 */
 	getComponent( index, component ) {
 
 		let value = this.array[ index * this.data.stride + this.offset + component ];
@@ -96,6 +190,14 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Sets the given value tothe given component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} component - The component index.
+	 * @param {number} value - The value to set.
+	 * @return {InterleavedBufferAttribute} A reference to this instance.
+	 */
 	setComponent( index, component, value ) {
 
 		if ( this.normalized ) value = normalize( value, this.array );
@@ -106,6 +208,13 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Sets the x component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} x - The value to set.
+	 * @return {InterleavedBufferAttribute} A reference to this instance.
+	 */
 	setX( index, x ) {
 
 		if ( this.normalized ) x = normalize( x, this.array );
@@ -116,6 +225,13 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Sets the y component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} y - The value to set.
+	 * @return {InterleavedBufferAttribute} A reference to this instance.
+	 */
 	setY( index, y ) {
 
 		if ( this.normalized ) y = normalize( y, this.array );
@@ -126,6 +242,13 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Sets the z component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} z - The value to set.
+	 * @return {InterleavedBufferAttribute} A reference to this instance.
+	 */
 	setZ( index, z ) {
 
 		if ( this.normalized ) z = normalize( z, this.array );
@@ -136,6 +259,13 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Sets the w component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} w - The value to set.
+	 * @return {InterleavedBufferAttribute} A reference to this instance.
+	 */
 	setW( index, w ) {
 
 		if ( this.normalized ) w = normalize( w, this.array );
@@ -146,6 +276,12 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Returns the x component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @return {number} The x component.
+	 */
 	getX( index ) {
 
 		let x = this.data.array[ index * this.data.stride + this.offset ];
@@ -156,6 +292,12 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Returns the y component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @return {number} The y component.
+	 */
 	getY( index ) {
 
 		let y = this.data.array[ index * this.data.stride + this.offset + 1 ];
@@ -166,6 +308,12 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Returns the z component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @return {number} The z component.
+	 */
 	getZ( index ) {
 
 		let z = this.data.array[ index * this.data.stride + this.offset + 2 ];
@@ -176,6 +324,12 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Returns the w component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @return {number} The w component.
+	 */
 	getW( index ) {
 
 		let w = this.data.array[ index * this.data.stride + this.offset + 3 ];
@@ -186,6 +340,14 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Sets the x and y component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} x - The value for the x component to set.
+	 * @param {number} y - The value for the y component to set.
+	 * @return {InterleavedBufferAttribute} A reference to this instance.
+	 */
 	setXY( index, x, y ) {
 
 		index = index * this.data.stride + this.offset;
@@ -204,6 +366,15 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Sets the x, y and z component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} x - The value for the x component to set.
+	 * @param {number} y - The value for the y component to set.
+	 * @param {number} z - The value for the z component to set.
+	 * @return {InterleavedBufferAttribute} A reference to this instance.
+	 */
 	setXYZ( index, x, y, z ) {
 
 		index = index * this.data.stride + this.offset;
@@ -224,6 +395,16 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Sets the x, y, z and w component of the vector at the given index.
+	 *
+	 * @param {number} index - The index into the buffer attribute.
+	 * @param {number} x - The value for the x component to set.
+	 * @param {number} y - The value for the y component to set.
+	 * @param {number} z - The value for the z component to set.
+	 * @param {number} w - The value for the w component to set.
+	 * @return {InterleavedBufferAttribute} A reference to this instance.
+	 */
 	setXYZW( index, x, y, z, w ) {
 
 		index = index * this.data.stride + this.offset;
@@ -246,6 +427,14 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Returns a new buffer attribute with copied values from this instance.
+	 *
+	 * If no parameter is provided, cloning an interleaved buffer attribute will de-interleave buffer data.
+	 *
+	 * @param {Object} [data] - An object with interleaved buffers that allows to retain the interleaved property.
+	 * @return {BufferAttribute|InterleavedBufferAttribute} A clone of this instance.
+	 */
 	clone( data ) {
 
 		if ( data === undefined ) {
@@ -288,6 +477,14 @@ class InterleavedBufferAttribute {
 
 	}
 
+	/**
+	 * Serializes the buffer attribute into JSON.
+	 *
+	 * If no parameter is provided, cloning an interleaved buffer attribute will de-interleave buffer data.
+	 *
+	 * @param {Object} [data] - An optional value holding meta information about the serialization.
+	 * @return {Object} A JSON object representing the serialized buffer attribute.
+	 */
 	toJSON( data ) {
 
 		if ( data === undefined ) {

+ 71 - 10
src/core/Layers.js

@@ -1,56 +1,117 @@
+/**
+ * A layers object assigns an 3D object to 1 or more of 32
+ * layers numbered `0` to `31` - internally the layers are stored as a
+ * bit mask], and by default all 3D objects are a member of layer `0`.
+ *
+ * This can be used to control visibility - an object must share a layer with
+ * a camera to be visible when that camera's view is
+ * rendered.
+ *
+ * All classes that inherit from {@link Object3D} have an `layers` property which
+ * is an instance of this class.
+ */
 class Layers {
 
+	/**
+	 * Constructs a new layers instance, with membership
+	 * initially set to layer `0`.
+	 */
 	constructor() {
 
+		/**
+		 * A bit mask storing which of the 32 layers this layers object is currently
+		 * a member of.
+		 *
+		 * @type {number}
+		 */
 		this.mask = 1 | 0;
 
 	}
 
-	set( channel ) {
+	/**
+	 * Sets membership to the given layer, and remove membership all other layers.
+	 *
+	 * @param {number} layer - The layer to set.
+	 */
+	set( layer ) {
 
-		this.mask = ( 1 << channel | 0 ) >>> 0;
+		this.mask = ( 1 << layer | 0 ) >>> 0;
 
 	}
 
-	enable( channel ) {
+	/**
+	 * Adds membership of the given layer.
+	 *
+	 * @param {number} layer - The layer to enable.
+	 */
+	enable( layer ) {
 
-		this.mask |= 1 << channel | 0;
+		this.mask |= 1 << layer | 0;
 
 	}
 
+	/**
+	 * Adds membership to all layers.
+	 */
 	enableAll() {
 
 		this.mask = 0xffffffff | 0;
 
 	}
 
-	toggle( channel ) {
+	/**
+	 * Toggles the membership of the given layer.
+	 *
+	 * @param {number} layer - The layer to toggle.
+	 */
+	toggle( layer ) {
 
-		this.mask ^= 1 << channel | 0;
+		this.mask ^= 1 << layer | 0;
 
 	}
 
-	disable( channel ) {
+	/**
+	 * Removes membership of the given layer.
+	 *
+	 * @param {number} layer - The layer to enable.
+	 */
+	disable( layer ) {
 
-		this.mask &= ~ ( 1 << channel | 0 );
+		this.mask &= ~ ( 1 << layer | 0 );
 
 	}
 
+	/**
+	 * Removes the membership from all layers.
+	 */
 	disableAll() {
 
 		this.mask = 0;
 
 	}
 
+	/**
+	 * Returns `true` if this and the given layers object have at least one
+	 * layer in common.
+	 *
+	 * @param {Layers} layers - The layers to test.
+	 * @return {boolean } Whether this and the given layers object have at least one layer in common or not.
+	 */
 	test( layers ) {
 
 		return ( this.mask & layers.mask ) !== 0;
 
 	}
 
-	isEnabled( channel ) {
+	/**
+	 * Returns `true` if the given layer is enabled.
+	 *
+	 * @param {number} layer - The layer to test.
+	 * @return {boolean } Whether the given layer is enabled or not.
+	 */
+	isEnabled( layer ) {
 
-		return ( this.mask & ( 1 << channel | 0 ) ) !== 0;
+		return ( this.mask & ( 1 << layer | 0 ) ) !== 0;
 
 	}
 

+ 134 - 1
src/core/Raycaster.js

@@ -4,18 +4,86 @@ import { Layers } from './Layers.js';
 
 const _matrix = /*@__PURE__*/ new Matrix4();
 
+/**
+ * This class is designed to assist with raycasting] Raycasting is used for
+ * mouse picking (working out what objects in the 3d space the mouse is over)
+ * amongst other things.
+ */
 class Raycaster {
 
+	/**
+	 * Constructs a new raycaster.
+	 *
+	 * @param {Vector3} origin - The origin vector where the ray casts from.
+	 * @param {Vector3} direction - The (normalized) direction vector that gives direction to the ray.
+	 * @param {number} [near=0] - All results returned are further away than near. Near can't be negative.
+	 * @param {number} [far=Infinity] - All results returned are closer than far. Far can't be lower than near.
+	 */
 	constructor( origin, direction, near = 0, far = Infinity ) {
 
+		/**
+		 * The ray used for raycasting.
+		 *
+		 * @type {Ray}
+		 */
 		this.ray = new Ray( origin, direction );
-		// direction is assumed to be normalized (for accurate distance calculations)
 
+		/**
+		 * All results returned are further away than near. Near can't be negative.
+		 *
+		 * @type {number}
+		 * @default 0
+		 */
 		this.near = near;
+
+		/**
+		 * All results returned are further away than near. Near can't be negative.
+		 *
+		 * @type {number}
+		 * @default Infinity
+		 */
 		this.far = far;
+
+		/**
+		 * The camera to use when raycasting against view-dependent objects such as
+		 * billboarded objects like sprites. This field can be set manually or
+		 * is set when calling `setFromCamera()`.
+		 *
+		 * @type {?Camera}
+		 * @default null
+		 */
 		this.camera = null;
+
+		/**
+		 * Allows to selectively ignore 3D objects when performing intersection tests.
+		 * The following code example ensures that only 3D objects on layer `1` will be
+		 * honored by raycaster.
+		 * ```js
+		 * raycaster.layers.set( 1 );
+		 * object.layers.enable( 1 );
+		 * ```
+		 *
+		 * @type {Layers}
+		 */
 		this.layers = new Layers();
 
+
+		/**
+		 * A parameter object that configures the raycasting. It has the structure:
+		 *
+		 * ```
+		 * {
+		 * 	Mesh: {},
+		 * 	Line: { threshold: 1 },
+		 * 	LOD: {},
+		 * 	Points: { threshold: 1 },
+		 * 	Sprite: {}
+		 * }
+		 * ```
+		 * Where `threshold` is the precision of the raycaster when intersecting objects, in world units.
+		 *
+		 * @type {Object}
+		 */
 		this.params = {
 			Mesh: {},
 			Line: { threshold: 1 },
@@ -26,6 +94,12 @@ class Raycaster {
 
 	}
 
+	/**
+	 * Updates the ray with a new origin and direction by copying the values from the arguments.
+	 *
+	 * @param {Vector3} origin - The origin vector where the ray casts from.
+	 * @param {Vector3} direction - The (normalized) direction vector that gives direction to the ray.
+	 */
 	set( origin, direction ) {
 
 		// direction is assumed to be normalized (for accurate distance calculations)
@@ -34,6 +108,13 @@ class Raycaster {
 
 	}
 
+	/**
+	 * Uses the given coordinates and camera to compute a new origin and direction for the internal ray.
+	 *
+	 * @param {Vector2} coords - 2D coordinates of the mouse, in normalized device coordinates (NDC).
+	 * X and Y components should be between `-1` and `1`.
+	 * @param {Camera} camera - The camera from which the ray should originate.
+	 */
 	setFromCamera( coords, camera ) {
 
 		if ( camera.isPerspectiveCamera ) {
@@ -56,6 +137,12 @@ class Raycaster {
 
 	}
 
+	/**
+	 * Uses the given WebXR controller to compute a new origin and direction for the internal ray.
+	 *
+	 * @param {WebXRController} controller - The controller to copy the position and direction from.
+	 * @return {Raycaster} A reference to this raycaster.
+	 */
 	setFromXRController( controller ) {
 
 		_matrix.identity().extractRotation( controller.matrixWorld );
@@ -67,6 +154,42 @@ class Raycaster {
 
 	}
 
+	/**
+	 * The intersection point of a raycaster intersection test.
+	 * @typedef {Object} Raycaster~Intersection
+	 * @property {number} distance - The distance from the ray's origin to the intersection point.
+	 * @property {number} distanceToRay -  Some 3D objects e.g. {@link Points} provide the distance of the
+	 * intersection to the nearest point on the ray. For other objects it will be `undefined`.
+	 * @property {Vector3} point - The intersesction point, in world coordinates.
+	 * @property {Object} face - The face that has been intersected.
+	 * @property {number} faceIndex - The face index.
+	 * @property {Object3D} object - The 3D object that has been intersected.
+	 * @property {Vector2} uv - U,V coordinates at point of intersection.
+	 * @property {Vector2} uv1 - Second set of U,V coordinates at point of intersection.
+	 * @property {Vector3} uv1 - Interpolated normal vector at point of intersection.
+	 * @property {number} instanceId - The index number of the instance where the ray
+	 * intersects the {@link InstancedMesh}.
+	 */
+
+	/**
+	 * Checks all intersection between the ray and the object with or without the
+	 * descendants. Intersections are returned sorted by distance, closest first.
+	 *
+	 * `Raycaster` delegates to the `raycast()` method of the passed 3D object, when
+	 * evaluating whether the ray intersects the object or not. This allows meshes to respond
+	 * differently to ray casting than lines or points.
+	 *
+	 * Note that for meshes, faces must be pointed towards the origin of the ray in order
+	 * to be detected; intersections of the ray passing through the back of a face will not
+	 * be detected. To raycast against both faces of an object, you'll want to set  {@link Material#side}
+	 * to `THREE.DoubleSide`.
+	 *
+	 * @param {Object3D} object - The 3D object to check for intersection with the ray.
+	 * @param {boolean} [recursive=true] - If set to `true`, it also checks all descendants.
+	 * Otherwise it only checks intersection with the object.
+	 * @param {Array<Raycaster~Intersection>} [intersects=[]] The target array that holds the result of the method.
+	 * @return {Array<Raycaster~Intersection>} An array holding the intersection points.
+	 */
 	intersectObject( object, recursive = true, intersects = [] ) {
 
 		intersect( object, this, intersects, recursive );
@@ -77,6 +200,16 @@ class Raycaster {
 
 	}
 
+	/**
+	 * Checks all intersection between the ray and the objects with or without
+	 * the descendants. Intersections are returned sorted by distance, closest first.
+	 *
+	 * @param {Array<Object3D>} objects - The 3D objects to check for intersection with the ray.
+	 * @param {boolean} [recursive=true] - If set to `true`, it also checks all descendants.
+	 * Otherwise it only checks intersection with the object.
+	 * @param {Array<Raycaster~Intersection>} [intersects=[]] The target array that holds the result of the method.
+	 * @return {Array<Raycaster~Intersection>} An array holding the intersection points.
+	 */
 	intersectObjects( objects, recursive = true, intersects = [] ) {
 
 		for ( let i = 0, l = objects.length; i < l; i ++ ) {

+ 166 - 7
src/core/RenderTarget.js

@@ -4,26 +4,107 @@ import { LinearFilter } from '../constants.js';
 import { Vector4 } from '../math/Vector4.js';
 import { Source } from '../textures/Source.js';
 
-/*
- In options, we can specify:
- * Texture parameters for an auto-generated target texture
- * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
-*/
+/**
+ * A render target is a buffer where the video card draws pixels for a scene
+ * that is being rendered in the background. It is used in different effects,
+ * such as applying postprocessing to a rendered image before displaying it
+ * on the screen.
+ *
+ * @augments EventDispatcher
+ */
 class RenderTarget extends EventDispatcher {
 
+	/**
+	 * Render target options.
+	 *
+	 * @typedef {Object} RenderTarget~Options
+	 * @property {boolean} [generateMipmaps=false] - Whether to generate mipmaps or not.
+	 * @property {number} [magFilter=LinearFilter] - The mag filter.
+	 * @property {number} [minFilter=LinearFilter] - The min filter.
+	 * @property {number} [format=RGBAFormat] - The texture format.
+	 * @property {number} [type=UnsignedByteType] - The texture type.
+	 * @property {?string} [internalFormat=null] - The texture's internal format.
+	 * @property {number} [wrapS=ClampToEdgeWrapping] - The texture's uv wrapping mode.
+	 * @property {number} [wrapT=ClampToEdgeWrapping] - The texture's uv wrapping mode.
+	 * @property {number} [anisotropy=1] - The texture's anisotropy value.
+	 * @property {string} [colorSpace=NoColorSpace] - The texture's color space.
+	 * @property {boolean} [depthBuffer=true] - Whether to allocate a depth buffer or not.
+	 * @property {boolean} [stencilBuffer=false] - Whether to allocate a stencil buffer or not.
+	 * @property {boolean} [resolveDepthBuffer=true] - Whether to resolve the depth buffer or not.
+	 * @property {boolean} [resolveStencilBuffer=true] - Whether  to resolve the stencil buffer or not.
+	 * @property {?Texture} [depthTexture=null] - Reference to a depth texture.
+	 * @property {number} [samples=0] - The MSAA samples count.
+	 * @property {number} [count=1] - Defines the number of color attachments . Must be at least `1`.
+	 */
+
+	/**
+	 * Constructs a new render target.
+	 *
+	 * @param {number} [width=1] - The width of the render target.
+	 * @param {number} [height=1] - The height of the render target.
+	 * @param {RenderTarget~Options} [options] - The configuration object.
+	 */
 	constructor( width = 1, height = 1, options = {} ) {
 
 		super();
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isRenderTarget = true;
 
+		/**
+		 * The width of the render target.
+		 *
+		 * @type {number}
+		 * @default 1
+		 */
 		this.width = width;
+
+		/**
+		 * The height of the render target.
+		 *
+		 * @type {number}
+		 * @default 1
+		 */
 		this.height = height;
+
+		/**
+		 * The depth of the render target.
+		 *
+		 * @type {number}
+		 * @default 1
+		 */
 		this.depth = 1;
 
+		/**
+		 * A rectangular area inside the render target's viewport. Fragments that are
+		 * outside the area will be discarded.
+		 *
+		 * @type {Vector4}
+		 * @default (0,0,width,height)
+		 */
 		this.scissor = new Vector4( 0, 0, width, height );
+
+		/**
+		 * Indicates whether the scissor test should be enabled when rendering into
+		 * this render target or not.
+		 *
+		 * @type {boolean}
+		 * @default false
+		 */
 		this.scissorTest = false;
 
+		/**
+		 * A rectangular area representing the render target's viewport.
+		 *
+		 * @type {Vector4}
+		 * @default (0,0,width,height)
+		 */
 		this.viewport = new Vector4( 0, 0, width, height );
 
 		const image = { width: width, height: height, depth: 1 };
@@ -47,6 +128,12 @@ class RenderTarget extends EventDispatcher {
 		texture.generateMipmaps = options.generateMipmaps;
 		texture.internalFormat = options.internalFormat;
 
+		/**
+		 * An array of textures. Each color attachment is represented as a separate texture.
+		 * Has at least a single entry for the default color attachment.
+		 *
+		 * @type {Array<Texture>}
+		 */
 		this.textures = [];
 
 		const count = options.count;
@@ -58,19 +145,57 @@ class RenderTarget extends EventDispatcher {
 
 		}
 
+		/**
+		 * Whether to allocate a depth buffer or not.
+		 *
+		 * @type {boolean}
+		 * @default true
+		 */
 		this.depthBuffer = options.depthBuffer;
+
+		/**
+		 * Whether to allocate a stencil buffer or not.
+		 *
+		 * @type {boolean}
+		 * @default false
+		 */
 		this.stencilBuffer = options.stencilBuffer;
 
+		/**
+		 * Whether to resolve the depth buffer or not.
+		 *
+		 * @type {boolean}
+		 * @default true
+		 */
 		this.resolveDepthBuffer = options.resolveDepthBuffer;
+
+		/**
+		 * Whether to resolve the stencil buffer or not.
+		 *
+		 * @type {boolean}
+		 * @default true
+		 */
 		this.resolveStencilBuffer = options.resolveStencilBuffer;
 
-		this._depthTexture = null;
-		this.depthTexture = options.depthTexture;
+		this._depthTexture = options.depthTexture;
 
+		/**
+		 * The number of MSAA samples.
+		 *
+		 * A value of `0` disables MSAA.
+		 *
+		 * @type {number}
+		 * @default 0
+		 */
 		this.samples = options.samples;
 
 	}
 
+	/**
+	 * The texture representing the default color attachment.
+	 *
+	 * @type {Texture}
+	 */
 	get texture() {
 
 		return this.textures[ 0 ];
@@ -92,12 +217,27 @@ class RenderTarget extends EventDispatcher {
 
 	}
 
+	/**
+	 * Instead of saving the depth in a renderbuffer, a texture
+	 * can be used instead which is useful for further processing
+	 * e.g. in context of post-processing.
+	 *
+	 * @type {?DepthTexture}
+	 * @default null
+	 */
 	get depthTexture() {
 
 		return this._depthTexture;
 
 	}
 
+	/**
+	 * Sets the size of this render target.
+	 *
+	 * @param {number} width - The width.
+	 * @param {number} height - The height.
+	 * @param {number} [depth=1] - The depth.
+	 */
 	setSize( width, height, depth = 1 ) {
 
 		if ( this.width !== width || this.height !== height || this.depth !== depth ) {
@@ -123,12 +263,25 @@ class RenderTarget extends EventDispatcher {
 
 	}
 
+	/**
+	 * Returns a new render target with copied values from this instance.
+	 *
+	 * @return {RenderTarget} A clone of this instance.
+	 */
 	clone() {
 
 		return new this.constructor().copy( this );
 
 	}
 
+	/**
+	 * Copies the settings of the given render target. This is a structural copy so
+	 * no resources are shared between render targets after the copy. That includes
+	 * all MRT textures and the depth texture.
+	 *
+	 * @param {RenderTarget} source - The render target to copy.
+	 * @return {RenderTarget} A reference to this instance.
+	 */
 	copy( source ) {
 
 		this.width = source.width;
@@ -169,6 +322,12 @@ class RenderTarget extends EventDispatcher {
 
 	}
 
+	/**
+	 * Frees the GPU-related resources allocated by this instance. Call this
+	 * method whenever this instance is no longer used in your app.
+	 *
+	 * @fires RenderTarget#dispose
+	 */
 	dispose() {
 
 		this.dispatchEvent( { type: 'dispose' } );

+ 25 - 0
src/core/RenderTarget3D.js

@@ -1,16 +1,41 @@
 import { RenderTarget } from './RenderTarget.js';
 import { Data3DTexture } from '../textures/Data3DTexture.js';
 
+/**
+ * Represents a 3D render target.
+ *
+ * @augments RenderTarget
+ */
 class RenderTarget3D extends RenderTarget {
 
+	/**
+	 * Constructs a new 3D render target.
+	 *
+	 * @param {number} [width=1] - The width of the render target.
+	 * @param {number} [height=1] - The height of the render target.
+	 * @param {number} [depth=1] - The height of the render target.
+	 * @param {RenderTarget~Options} [options] - The configuration object.
+	 */
 	constructor( width = 1, height = 1, depth = 1, options = {} ) {
 
 		super( width, height, options );
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isRenderTarget3D = true;
 
 		this.depth = depth;
 
+		/**
+		 * Overwritten with a different texture type.
+		 *
+		 * @type {Data3DTexture}
+		 */
 		this.texture = new Data3DTexture( null, width, height, depth );
 
 		this.texture.isRenderTargetTexture = true;

+ 18 - 0
src/core/RenderTargetArray.js

@@ -1,8 +1,21 @@
 import { RenderTarget } from './RenderTarget.js';
 import { DataArrayTexture } from '../textures/DataArrayTexture.js';
 
+/**
+ * Represents an array render target.
+ *
+ * @augments RenderTarget
+ */
 class RenderTargetArray extends RenderTarget {
 
+	/**
+	 * Constructs a new 3D render target.
+	 *
+	 * @param {number} [width=1] - The width of the render target.
+	 * @param {number} [height=1] - The height of the render target.
+	 * @param {number} [depth=1] - The height of the render target.
+	 * @param {RenderTarget~Options} [options] - The configuration object.
+	 */
 	constructor( width = 1, height = 1, depth = 1, options = {} ) {
 
 		super( width, height, options );
@@ -11,6 +24,11 @@ class RenderTargetArray extends RenderTarget {
 
 		this.depth = depth;
 
+		/**
+		 * Overwritten with a different texture type.
+		 *
+		 * @type {DataArrayTexture}
+		 */
 		this.texture = new DataArrayTexture( null, width, height, depth );
 
 		this.texture.isRenderTargetTexture = true;

+ 29 - 0
src/core/Uniform.js

@@ -1,11 +1,40 @@
+/**
+ * Represents a uniform which is a global shader variable. They are passed to shader programs.
+ *
+ * When declaring a uniform of a {@link ShaderMaterial}, it is declared by value or by object.
+ * ```js
+ * uniforms: {
+ * 	time: { value: 1.0 },
+ * 	resolution: new Uniform( new Vector2() )
+ * };
+ * ```
+ * Since this class can only be used in context of {@link ShaderMaterial}, it is only supported
+ * in {@link WebGLRenderer}.
+ */
 class Uniform {
 
+	/**
+	 * Constructs a new uniform.
+	 *
+	 * @param {any} value - The uniform value.
+	 */
 	constructor( value ) {
 
+		/**
+		 * The uniform value.
+		 *
+		 * @type {any}
+		 */
 		this.value = value;
 
 	}
 
+	/**
+	 * Returns a new uniform with copied values from this instance.
+	 * If the value has a `clone()` method, the value is cloned as well.
+	 *
+	 * @return {Uniform} A clone of this instance.
+	 */
 	clone() {
 
 		return new Uniform( this.value.clone === undefined ? this.value : this.value.clone() );

+ 84 - 2
src/core/UniformsGroup.js

@@ -3,23 +3,72 @@ import { StaticDrawUsage } from '../constants.js';
 
 let _id = 0;
 
+/**
+ * A class for managing multiple uniforms in a single group. The renderer will process
+ * such a definition as a single UBO.
+ *
+ * Since this class can only be used in context of {@link ShaderMaterial}, it is only supported
+ * in {@link WebGLRenderer}.
+ *
+ * @augments EventDispatcher
+ */
 class UniformsGroup extends EventDispatcher {
 
+	/**
+	 * Constructs a new uniforms group.
+	 */
 	constructor() {
 
 		super();
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isUniformsGroup = true;
 
+		/**
+		 * The ID of the 3D object.
+		 *
+		 * @name UniformsGroup#id
+		 * @type {number}
+		 * @readonly
+		 */
 		Object.defineProperty( this, 'id', { value: _id ++ } );
 
+		/**
+		 * The name of the uniforms group.
+		 *
+		 * @type {string}
+		 */
 		this.name = '';
 
+		/**
+		 * The buffer usage.
+		 *
+		 * @type {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)}
+		 * @default StaticDrawUsage
+		 */
 		this.usage = StaticDrawUsage;
+
+		/**
+		 * An array holding the uniforms.
+		 *
+		 * @type {Array<Uniform>}
+		 */
 		this.uniforms = [];
 
 	}
 
+	/**
+	 * Adds the given uniform to this uniforms group.
+	 *
+	 * @param {Uniform} uniform - The uniform to add.
+	 * @return {UniformsGroup} A reference to this uniforms group.
+	 */
 	add( uniform ) {
 
 		this.uniforms.push( uniform );
@@ -28,6 +77,12 @@ class UniformsGroup extends EventDispatcher {
 
 	}
 
+	/**
+	 * Removes the given uniform from this uniforms group.
+	 *
+	 * @param {Uniform} uniform - The uniform to remove.
+	 * @return {UniformsGroup} A reference to this uniforms group.
+	 */
 	remove( uniform ) {
 
 		const index = this.uniforms.indexOf( uniform );
@@ -38,6 +93,12 @@ class UniformsGroup extends EventDispatcher {
 
 	}
 
+	/**
+	 * Sets the name of this uniforms group.
+	 *
+	 * @param {string} name - The name to set.
+	 * @return {UniformsGroup} A reference to this uniforms group.
+	 */
 	setName( name ) {
 
 		this.name = name;
@@ -46,6 +107,12 @@ class UniformsGroup extends EventDispatcher {
 
 	}
 
+	/**
+	 * Sets the usage of this uniforms group.
+	 *
+	 * @param {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)} value - The usage to set.
+	 * @return {UniformsGroup} A reference to this uniforms group.
+	 */
 	setUsage( value ) {
 
 		this.usage = value;
@@ -54,14 +121,24 @@ class UniformsGroup extends EventDispatcher {
 
 	}
 
+	/**
+	 * Frees the GPU-related resources allocated by this instance. Call this
+	 * method whenever this instance is no longer used in your app.
+	 *
+	 * @fires Texture#dispose
+	 */
 	dispose() {
 
 		this.dispatchEvent( { type: 'dispose' } );
 
-		return this;
-
 	}
 
+	/**
+	 * Copies the values of the given uniforms group to this instance.
+	 *
+	 * @param {UniformsGroup} source - The uniforms group to copy.
+	 * @return {UniformsGroup} A reference to this uniforms group.
+	 */
 	copy( source ) {
 
 		this.name = source.name;
@@ -87,6 +164,11 @@ class UniformsGroup extends EventDispatcher {
 
 	}
 
+	/**
+	 * Returns a new uniforms group with copied values from this instance.
+	 *
+	 * @return {UniformsGroup} A clone of this instance.
+	 */
 	clone() {
 
 		return new this.constructor().copy( this );

+ 25 - 0
src/renderers/WebGL3DRenderTarget.js

@@ -1,16 +1,41 @@
 import { WebGLRenderTarget } from './WebGLRenderTarget.js';
 import { Data3DTexture } from '../textures/Data3DTexture.js';
 
+/**
+ * A 3D render target used in context of {@link WebGLRenderer}.
+ *
+ * @augments WebGLRenderTarget
+ */
 class WebGL3DRenderTarget extends WebGLRenderTarget {
 
+	/**
+	 * Constructs a new 3D render target.
+	 *
+	 * @param {number} [width=1] - The width of the render target.
+	 * @param {number} [height=1] - The height of the render target.
+	 * @param {number} [depth=1] - The height of the render target.
+	 * @param {RenderTarget~Options} [options] - The configuration object.
+	 */
 	constructor( width = 1, height = 1, depth = 1, options = {} ) {
 
 		super( width, height, options );
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isWebGL3DRenderTarget = true;
 
 		this.depth = depth;
 
+		/**
+		 * Overwritten with a different texture type.
+		 *
+		 * @type {Data3DTexture}
+		 */
 		this.texture = new Data3DTexture( null, width, height, depth );
 
 		this.texture.isRenderTargetTexture = true;

+ 25 - 0
src/renderers/WebGLArrayRenderTarget.js

@@ -1,16 +1,41 @@
 import { WebGLRenderTarget } from './WebGLRenderTarget.js';
 import { DataArrayTexture } from '../textures/DataArrayTexture.js';
 
+/**
+ * An array render target used in context of {@link WebGLRenderer}.
+ *
+ * @augments WebGLRenderTarget
+ */
 class WebGLArrayRenderTarget extends WebGLRenderTarget {
 
+	/**
+	 * Constructs a new array render target.
+	 *
+	 * @param {number} [width=1] - The width of the render target.
+	 * @param {number} [height=1] - The height of the render target.
+	 * @param {number} [depth=1] - The height of the render target.
+	 * @param {RenderTarget~Options} [options] - The configuration object.
+	 */
 	constructor( width = 1, height = 1, depth = 1, options = {} ) {
 
 		super( width, height, options );
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isWebGLArrayRenderTarget = true;
 
 		this.depth = depth;
 
+		/**
+		 * Overwritten with a different texture type.
+		 *
+		 * @type {DataArrayTexture}
+		 */
 		this.texture = new DataArrayTexture( null, width, height, depth );
 
 		this.texture.isRenderTargetTexture = true;

+ 39 - 1
src/renderers/WebGLCubeRenderTarget.js

@@ -7,17 +7,40 @@ import { WebGLRenderTarget } from './WebGLRenderTarget.js';
 import { CubeCamera } from '../cameras/CubeCamera.js';
 import { CubeTexture } from '../textures/CubeTexture.js';
 
+/**
+ * A cube render target used in context of {@link WebGLRenderer}.
+ *
+ * @augments WebGLRenderTarget
+ */
 class WebGLCubeRenderTarget extends WebGLRenderTarget {
 
+	/**
+	 * Constructs a new cube render target.
+	 *
+	 * @param {number} [size=1] - The size of the render target.
+	 * @param {RenderTarget~Options} [options] - The configuration object.
+	 */
 	constructor( size = 1, options = {} ) {
 
 		super( size, size, options );
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isWebGLCubeRenderTarget = true;
 
 		const image = { width: size, height: size, depth: 1 };
 		const images = [ image, image, image, image, image, image ];
 
+		/**
+		 * Overwritten with a different texture type.
+		 *
+		 * @type {DataArrayTexture}
+		 */
 		this.texture = new CubeTexture( images, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
 
 		// By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js)
@@ -35,6 +58,13 @@ class WebGLCubeRenderTarget extends WebGLRenderTarget {
 
 	}
 
+	/**
+	 * Converts the given equirectangular texture to a cube map.
+	 *
+	 * @param {WebGLRenderer} renderer - The renderer.
+	 * @param {Texture} texture - The equirectangular texture.
+	 * @return {WebGLCubeRenderTarget} A reference to this cube render target.
+	 */
 	fromEquirectangularTexture( renderer, texture ) {
 
 		this.texture.type = texture.type;
@@ -125,7 +155,15 @@ class WebGLCubeRenderTarget extends WebGLRenderTarget {
 
 	}
 
-	clear( renderer, color, depth, stencil ) {
+	/**
+	 * Clears this cube render target.
+	 *
+	 * @param {WebGLRenderer} renderer - The renderer.
+	 * @param {boolean} [color=true] - Whether the color buffer should be cleared or not.
+	 * @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not.
+	 * @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
+	 */
+	clear( renderer, color = true, depth = true, stencil = true ) {
 
 		const currentRenderTarget = renderer.getRenderTarget();
 

+ 19 - 0
src/renderers/WebGLRenderTarget.js

@@ -1,11 +1,30 @@
 import { RenderTarget } from '../core/RenderTarget.js';
 
+/**
+ * A render target used in context of {@link WebGLRenderer}.
+ *
+ * @augments RenderTarget
+ */
 class WebGLRenderTarget extends RenderTarget {
 
+	/**
+	 * Constructs a new 3D render target.
+	 *
+	 * @param {number} [width=1] - The width of the render target.
+	 * @param {number} [height=1] - The height of the render target.
+	 * @param {RenderTarget~Options} [options] - The configuration object.
+	 */
 	constructor( width = 1, height = 1, options = {} ) {
 
 		super( width, height, options );
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isWebGLRenderTarget = true;
 
 	}

+ 7 - 0
src/renderers/common/CubeRenderTarget.js

@@ -24,6 +24,13 @@ class CubeRenderTarget extends WebGLCubeRenderTarget {
 
 		super( size, options );
 
+		/**
+		 * This flag can be used for type testing.
+		 *
+		 * @type {boolean}
+		 * @readonly
+		 * @default true
+		 */
 		this.isCubeRenderTarget = true;
 
 	}

+ 18 - 11
src/renderers/common/Renderer.js

@@ -40,21 +40,28 @@ const _vector4 = /*@__PURE__*/ new Vector4();
  */
 class Renderer {
 
+	/**
+	 * Renderer options.
+	 *
+	 * @typedef {Object} Renderer~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. This parameter can set to any other integer value than 0
+	 * to overwrite the default.
+	 * @property {?Function} [getFallback=null] - This callback function can be used to provide a fallback backend, if the primary backend can't be targeted.
+	 * @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 renderer.
 	 *
 	 * @param {Backend} backend - The backend the renderer is targeting (e.g. WebGPU or WebGL 2).
-	 * @param {Object} parameters - The configuration parameter.
-	 * @param {boolean} [parameters.logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
-	 * @param {boolean} [parameters.alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
-	 * @param {boolean} [parameters.depth=true] - Whether the default framebuffer should have a depth buffer or not.
-	 * @param {boolean} [parameters.stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
-	 * @param {boolean} [parameters.antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
-	 * @param {number} [parameters.samples=0] - When `antialias` is `true`, `4` samples are used by default. This parameter can set to any other integer value than 0
-	 * to overwrite the default.
-	 * @param {?Function} [parameters.getFallback=null] - This callback function can be used to provide a fallback backend, if the primary backend can't be targeted.
-	 * @param {number} [parameters.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.
+	 * @param {Renderer~Options} [parameters] - The configuration parameter.
+
 	 */
 	constructor( backend, parameters = {} ) {
 

+ 15 - 9
src/renderers/webgl-fallback/WebGLBackend.js

@@ -23,18 +23,24 @@ import WebGLTimestampQueryPool from './utils/WebGLTimestampQueryPool.js';
  */
 class WebGLBackend extends Backend {
 
+	/**
+	 * WebGLBackend options.
+	 *
+	 * @typedef {Object} WebGLBackend~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 {WebGL2RenderingContext} [context=undefined] - A WebGL 2 rendering context.
+	 */
+
 	/**
 	 * Constructs a new WebGPU backend.
 	 *
-	 * @param {Object} parameters - The configuration parameter.
-	 * @param {boolean} [parameters.logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
-	 * @param {boolean} [parameters.alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
-	 * @param {boolean} [parameters.depth=true] - Whether the default framebuffer should have a depth buffer or not.
-	 * @param {boolean} [parameters.stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
-	 * @param {boolean} [parameters.antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
-	 * @param {number} [parameters.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.
-	 * @param {boolean} [parameters.forceWebGL=false] - If set to `true`, the renderer uses a WebGL 2 backend no matter if WebGPU is supported or not.
-	 * @param {WebGL2RenderingContext} [parameters.context=undefined] - A WebGL 2 rendering context.
+	 * @param {WebGLBackend~Options} [parameters] - The configuration parameter.
 	 */
 	constructor( parameters = {} ) {
 

+ 19 - 13
src/renderers/webgpu/WebGPUBackend.js

@@ -25,22 +25,28 @@ import { warnOnce } from '../../utils.js';
  */
 class WebGPUBackend extends Backend {
 
+	/**
+	 * WebGPUBackend options.
+	 *
+	 * @typedef {Object} WebGPUBackend~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} [trackTimestamp=false] - Whether to track timestamps with a Timestamp Query API or not.
+	 * @property {string} [powerPreference=undefined] - The power preference.
+	 * @property {Object} [requiredLimits=undefined] - Specifies the limits that are required by the device request. The request will fail if the adapter cannot provide these limits.
+	 * @property {GPUDevice} [device=undefined] - If there is an existing GPU device on app level, it can be passed to the renderer as a parameter.
+	 * @property {number} [outputType=undefined] - Texture type for output to canvas. By default, device's preferred format is used; other formats may incur overhead.
+	 */
+
 	/**
 	 * Constructs a new WebGPU backend.
 	 *
-	 * @param {Object} parameters - The configuration parameter.
-	 * @param {boolean} [parameters.logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
-	 * @param {boolean} [parameters.alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
-	 * @param {boolean} [parameters.depth=true] - Whether the default framebuffer should have a depth buffer or not.
-	 * @param {boolean} [parameters.stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
-	 * @param {boolean} [parameters.antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
-	 * @param {number} [parameters.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.
-	 * @param {boolean} [parameters.forceWebGL=false] - If set to `true`, the renderer uses a WebGL 2 backend no matter if WebGPU is supported or not.
-	 * @param {boolean} [parameters.trackTimestamp=false] - Whether to track timestamps with a Timestamp Query API or not.
-	 * @param {string} [parameters.powerPreference=undefined] - The power preference.
-	 * @param {Object} [parameters.requiredLimits=undefined] - Specifies the limits that are required by the device request. The request will fail if the adapter cannot provide these limits.
-	 * @param {GPUDevice} [parameters.device=undefined] - If there is an existing GPU device on app level, it can be passed to the renderer as a parameter.
-	 * @param {number} [parameters.outputType=undefined] - Texture type for output to canvas. By default, device's preferred format is used; other formats may incur overhead.
+	 * @param {WebGPUBackend~Options} [parameters] - The configuration parameter.
 	 */
 	constructor( parameters = {} ) {
 

+ 1 - 11
src/renderers/webgpu/WebGPURenderer.Nodes.js

@@ -15,17 +15,7 @@ class WebGPURenderer extends Renderer {
 	/**
 	 * Constructs a new WebGPU renderer.
 	 *
-	 * @param {Object} parameters - The configuration parameter.
-	 * @param {boolean} [parameters.logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
-	 * @param {boolean} [parameters.alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
-	 * @param {boolean} [parameters.depth=true] - Whether the default framebuffer should have a depth buffer or not.
-	 * @param {boolean} [parameters.stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
-	 * @param {boolean} [parameters.antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
-	 * @param {number} [parameters.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.
-	 * @param {boolean} [parameters.forceWebGL=false] - If set to `true`, the renderer uses it WebGL 2 backend no matter if WebGPU is supported or not.
-	 * @param {number} [parameters.outputType=undefined] - Texture type for output to canvas. By default, device's preferred format is used; other formats may incur overhead.
-	 * @param {number} [parameters.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.
+	 * @param {WebGPURenderer~Options} [parameters] - The configuration parameter.
 	 */
 	constructor( parameters = {} ) {
 

+ 17 - 11
src/renderers/webgpu/WebGPURenderer.js

@@ -27,20 +27,26 @@ const debugHandler = {
 class WebGPURenderer extends Renderer {
 
 	/**
-	 * Constructs a new WebGPU renderer.
+	 * WebGPURenderer options.
 	 *
-	 * @param {Object} parameters - The configuration parameter.
-	 * @param {boolean} [parameters.logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
-	 * @param {boolean} [parameters.alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
-	 * @param {boolean} [parameters.depth=true] - Whether the default framebuffer should have a depth buffer or not.
-	 * @param {boolean} [parameters.stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
-	 * @param {boolean} [parameters.antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
-	 * @param {number} [parameters.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.
-	 * @param {boolean} [parameters.forceWebGL=false] - If set to `true`, the renderer uses a WebGL 2 backend no matter if WebGPU is supported or not.
-	 * @param {number} [parameters.outputType=undefined] - Texture type for output to canvas. By default, device's preferred format is used; other formats may incur overhead.
-	 * @param {number} [parameters.colorBufferType=HalfFloatType] - Defines the type of color buffers. The default `HalfFloatType` is recommend for best
+	 * @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 {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;

+ 8 - 9
utils/docs/jsdoc.config.json

@@ -16,21 +16,20 @@
             "src/animation",
             "src/audio",
             "src/cameras",
-            "src/core/Object3D.js",
-            "src/core/EventDispatcher.js",
+            "src/core",
             "src/extras",
             "src/geometries",
             "src/helpers",
             "src/lights",
             "src/loaders",
             "src/materials",
-            "src/math", 
-            "src/nodes", 
-            "src/objects", 
-            "src/renderers/common", 
-            "src/renderers/webgpu" ,
-            "src/scenes" ,
-            "src/textures" 
+            "src/math",
+            "src/nodes",
+            "src/objects",
+            "src/renderers/common",
+            "src/renderers/webgpu",
+            "src/scenes",
+            "src/textures"
         ],
         "exclude": [
             "src/extras/PMREMGenerator.js"

粤ICP备19079148号