Skip to content

Commit b35ad2a

Browse files
authored
Renderer: Document more modules. (#30221)
* Renderer: Document more modules. * Fix typo. * Fix typo.
1 parent 6462c8a commit b35ad2a

15 files changed

+634
-24
lines changed

src/nodes/accessors/BufferAttributeNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { StaticDrawUsage, DynamicDrawUsage } from '../../constants.js';
2424
* material.colorNode = bufferAttribute( new THREE.Float32BufferAttribute( colors, 3 ) );
2525
* ```
2626
* This new approach is especially interesting when geometry data are generated via
27-
* compute shaders. The below line converts a storage buffer into an attribute.
27+
* compute shaders. The below line converts a storage buffer into an attribute node.
2828
* ```js
2929
* material.positionNode = positionBuffer.toAttribute();
3030
* ```

src/nodes/accessors/StorageBufferNode.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { getTypeFromLength } from '../core/NodeUtils.js';
1212
* storage buffer for data. A typical workflow is to create instances of
1313
* this node with the convenience functions `attributeArray()` or `instancedArray()`,
1414
* setup up a compute shader that writes into the buffers and then convert
15-
* the storage buffers to attributes for rendering.
15+
* the storage buffers to attribute nodes for rendering.
1616
*
1717
* ```js
1818
* const positionBuffer = instancedArray( particleCount, 'vec3' ); // the storage buffer node
@@ -49,7 +49,7 @@ class StorageBufferNode extends BufferNode {
4949
/**
5050
* Constructs a new storage buffer node.
5151
*
52-
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute} value - The buffer data.
52+
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute|BufferAttribute} value - The buffer data.
5353
* @param {String?} [bufferType=null] - The buffer type (e.g. `'vec3'`).
5454
* @param {Number} [bufferCount=0] - The buffer count.
5555
*/
@@ -337,7 +337,7 @@ export default StorageBufferNode;
337337
* TSL function for creating a storage buffer node.
338338
*
339339
* @function
340-
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute} value - The buffer data.
340+
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute|BufferAttribute} value - The buffer data.
341341
* @param {String?} [type=null] - The buffer type (e.g. `'vec3'`).
342342
* @param {Number} [count=0] - The buffer count.
343343
* @returns {StorageBufferNode}

src/objects/ClippingGroup.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,64 @@
11
import { Group } from './Group.js';
22

3+
/**
4+
* In earlier three.js versions, clipping was defined globally
5+
* on the renderer or on material level. This special version of
6+
* `THREE.Group` allows to encode the clipping state into the scene
7+
* graph. Meaning if you create an instance of this group, all
8+
* descendant 3D objects will be affected by the respective clipping
9+
* planes.
10+
*
11+
* Note: `ClippingGroup` can only be used with `WebGPURenderer`.
12+
*
13+
* @augments Group
14+
*/
315
class ClippingGroup extends Group {
416

17+
/**
18+
* Constructs a new clipping group.
19+
*/
520
constructor() {
621

722
super();
823

24+
/**
25+
* This flag can be used for type testing.
26+
*
27+
* @type {Boolean}
28+
* @readonly
29+
* @default true
30+
*/
931
this.isClippingGroup = true;
32+
33+
/**
34+
* An array with clipping planes.
35+
*
36+
* @type {Array<Plane>}
37+
*/
1038
this.clippingPlanes = [];
39+
40+
/**
41+
* Whether clipping should be enabled or not.
42+
*
43+
* @type {Boolean}
44+
* @default true
45+
*/
1146
this.enabled = true;
47+
48+
/**
49+
* Whether the intersection of the clipping planes is used to clip objects, rather than their union.
50+
*
51+
* @type {Boolean}
52+
* @default false
53+
*/
1254
this.clipIntersection = false;
55+
56+
/**
57+
* Whether shadows should be clipped or not.
58+
*
59+
* @type {Boolean}
60+
* @default false
61+
*/
1362
this.clipShadows = false;
1463

1564
}

src/renderers/common/Binding.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,54 @@
1+
/**
2+
* A binding represents the connection between a resource (like a texture, sampler
3+
* or uniform buffer) and the resource definition in a shader stage.
4+
*
5+
* This module is an abstract base class for all concrete bindings types.
6+
*
7+
* @abstract
8+
* @private
9+
*/
110
class Binding {
211

12+
/**
13+
* Constructs a new binding.
14+
*
15+
* @param {String} [name=''] - The binding's name.
16+
*/
317
constructor( name = '' ) {
418

19+
/**
20+
* The binding's name.
21+
*
22+
* @type {String}
23+
*/
524
this.name = name;
625

26+
/**
27+
* A bitmask that defines in what shader stages the
28+
* binding's resource is accessible.
29+
*
30+
* @type {String}
31+
*/
732
this.visibility = 0;
833

934
}
1035

36+
/**
37+
* Makes sure binding's resource is visible for the given shader stage.
38+
*
39+
* @param {Number} visibility - The shader stage.
40+
*/
1141
setVisibility( visibility ) {
1242

1343
this.visibility |= visibility;
1444

1545
}
1646

47+
/**
48+
* Clones the binding.
49+
*
50+
* @return {Binding} The cloned binding.
51+
*/
1752
clone() {
1853

1954
return Object.assign( new this.constructor(), this );

src/renderers/common/Buffer.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,81 @@
11
import Binding from './Binding.js';
22
import { getFloatLength } from './BufferUtils.js';
33

4+
/**
5+
* Represents a buffer binding type.
6+
*
7+
* @private
8+
* @abstract
9+
* @augments Binding
10+
*/
411
class Buffer extends Binding {
512

13+
/**
14+
* Constructs a new buffer.
15+
*
16+
* @param {String} name - The buffer's name.
17+
* @param {TypedArray} [buffer=null] - The buffer.
18+
*/
619
constructor( name, buffer = null ) {
720

821
super( name );
922

23+
/**
24+
* This flag can be used for type testing.
25+
*
26+
* @type {Boolean}
27+
* @readonly
28+
* @default true
29+
*/
1030
this.isBuffer = true;
1131

32+
/**
33+
* The bytes per element.
34+
*
35+
* @type {Number}
36+
*/
1237
this.bytesPerElement = Float32Array.BYTES_PER_ELEMENT;
1338

39+
/**
40+
* A reference to the internal buffer.
41+
*
42+
* @private
43+
* @type {TypedArray}
44+
*/
1445
this._buffer = buffer;
1546

1647
}
1748

49+
/**
50+
* The buffer's byte length.
51+
*
52+
* @type {Number}
53+
* @readonly
54+
*/
1855
get byteLength() {
1956

2057
return getFloatLength( this._buffer.byteLength );
2158

2259
}
2360

61+
/**
62+
* A reference to the internal buffer.
63+
*
64+
* @type {Number}
65+
* @readonly
66+
*/
2467
get buffer() {
2568

2669
return this._buffer;
2770

2871
}
2972

73+
/**
74+
* Updates the binding.
75+
*
76+
* @return {Boolean} Whether the buffer has been updated and must be
77+
* uploaded to the GPU.
78+
*/
3079
update() {
3180

3281
return true;

0 commit comments

Comments
 (0)