Ver Fonte

Node: fix types (#30103)

* Node: fix types

* Improve types

* Fix more types

* Update UniformNode.js

* Update PassNode.js

* Update AnalyticLightNode.js

* Update MathNode.js

* Update MathNode.js

---------

Co-authored-by: Samuel Rigaud <srigaud@duodisplay.com>
Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>
Samuel Rigaud há 1 ano atrás
pai
commit
a8aaca32f6

+ 3 - 3
src/nodes/accessors/ReferenceNode.js

@@ -172,7 +172,7 @@ class ReferenceNode extends Node {
 		this.group = null;
 
 		/**
-		 * An optinal label of the internal uniform node.
+		 * An optional label of the internal uniform node.
 		 *
 		 * @type {String?}
 		 * @default null
@@ -383,7 +383,7 @@ class ReferenceNode extends Node {
 export default ReferenceNode;
 
 /**
- * TSL function for creating a reference node with the given paramters.
+ * TSL function for creating a reference node with the given parameters.
  *
  * @function
  * @param {String} name - The name of the property the node refers to.
@@ -394,7 +394,7 @@ export default ReferenceNode;
 export const reference = ( name, type, object ) => nodeObject( new ReferenceNode( name, type, object ) );
 
 /**
- * TSL function for creating a reference node with the given paramters.
+ * TSL function for creating a reference node with the given parameters.
  *
  * @function
  * @param {String} name - The name of the property the node refers to.

+ 1 - 1
src/nodes/accessors/TextureSizeNode.js

@@ -68,7 +68,7 @@ class TextureSizeNode extends Node {
 export default TextureSizeNode;
 
 /**
- * TSL function for creating a texture size node with the given paramters.
+ * TSL function for creating a texture size node with the given parameters.
  *
  * @function
  * @param {TextureNode} textureNode - A texture node which size should be retrieved.

+ 2 - 2
src/nodes/accessors/UV.js

@@ -6,7 +6,7 @@ import { attribute } from '../core/AttributeNode.js';
  * TSL function for creating an uv attribute node with the given index.
  *
  * @function
- * @param {Number} index - The uv index.
+ * @param {Number} [index=0] - The uv index.
  * @return {AttributeNode<vec2>} The uv attribute node.
  */
-export const uv = ( index ) => attribute( 'uv' + ( index > 0 ? index : '' ), 'vec2' );
+export const uv = ( index = 0 ) => attribute( 'uv' + ( index > 0 ? index : '' ), 'vec2' );

+ 1 - 1
src/nodes/accessors/UserDataNode.js

@@ -67,7 +67,7 @@ class UserDataNode extends ReferenceNode {
 export default UserDataNode;
 
 /**
- * TSL function for creating a user data node with the given paramters.
+ * TSL function for creating a user data node with the given parameters.
  *
  * @function
  * @param {String} name - The property name that should be referenced by the node.

+ 1 - 1
src/nodes/accessors/VertexColorNode.js

@@ -102,7 +102,7 @@ class VertexColorNode extends AttributeNode {
 export default VertexColorNode;
 
 /**
- * TSL function for creating a reference node with the given paramters.
+ * TSL function for creating a reference node with the given parameters.
  *
  * @function
  * @param {Number} index - The attribute index.

+ 4 - 4
src/nodes/code/CodeNode.js

@@ -141,7 +141,7 @@ class CodeNode extends Node {
 export default CodeNode;
 
 /**
- * TSL function for creating a code node with the given paramters.
+ * TSL function for creating a code node with the given parameters.
  *
  * @function
  * @param {String} [code=''] - The native code.
@@ -152,7 +152,7 @@ export default CodeNode;
 export const code = /*@__PURE__*/ nodeProxy( CodeNode );
 
 /**
- * TSL function for creating a JS code node with the given paramters.
+ * TSL function for creating a JS code node with the given parameters.
  *
  * @function
  * @param {String} src - The native code.
@@ -162,7 +162,7 @@ export const code = /*@__PURE__*/ nodeProxy( CodeNode );
 export const js = ( src, includes ) => code( src, includes, 'js' );
 
 /**
- * TSL function for creating a WGSL code node with the given paramters.
+ * TSL function for creating a WGSL code node with the given parameters.
  *
  * @function
  * @param {String} src - The native code.
@@ -172,7 +172,7 @@ export const js = ( src, includes ) => code( src, includes, 'js' );
 export const wgsl = ( src, includes ) => code( src, includes, 'wgsl' );
 
 /**
- * TSL function for creating a GLSL code node with the given paramters.
+ * TSL function for creating a GLSL code node with the given parameters.
  *
  * @function
  * @param {String} src - The native code.

+ 1 - 1
src/nodes/code/ExpressionNode.js

@@ -59,7 +59,7 @@ class ExpressionNode extends Node {
 export default ExpressionNode;
 
 /**
- * TSL function for creating an expression node with the given paramters.
+ * TSL function for creating an expression node with the given parameters.
  *
  * @function
  * @param {String} [snippet=''] - The native code snippet.

+ 1 - 1
src/nodes/core/ParameterNode.js

@@ -54,7 +54,7 @@ class ParameterNode extends PropertyNode {
 export default ParameterNode;
 
 /**
- * TSL function for creating a parameter node with the given paramters.
+ * TSL function for creating a parameter node with the given parameters.
  *
  * @function
  * @param {String} type - The type of the node.

+ 1 - 1
src/nodes/core/UniformNode.js

@@ -159,7 +159,7 @@ class UniformNode extends InputNode {
 export default UniformNode;
 
 /**
- * TSL function for creating a uniform node with the given paramters.
+ * TSL function for creating a uniform node with the given parameters.
  *
  * @function
  * @param {Any} arg1 - The value of this node. Usually a JS primitive or three.js object (vector, matrix, color, texture).

+ 1 - 1
src/nodes/core/VarNode.js

@@ -99,7 +99,7 @@ class VarNode extends Node {
 export default VarNode;
 
 /**
- * TSL function for creating a var node with the given paramters.
+ * TSL function for creating a var node with the given parameters.
  *
  * @function
  * @param {Node} node - The node for which a variable should be created.

+ 1 - 1
src/nodes/core/VaryingNode.js

@@ -167,7 +167,7 @@ class VaryingNode extends Node {
 export default VaryingNode;
 
 /**
- * TSL function for creating a varying node with the given paramters.
+ * TSL function for creating a varying node with the given parameters.
  *
  * @function
  * @param {Node} node - The node for which a varying should be created.

+ 1 - 1
src/nodes/display/NormalMapNode.js

@@ -139,7 +139,7 @@ class NormalMapNode extends TempNode {
 export default NormalMapNode;
 
 /**
- * TSL function for creating a normal map node with the given paramters.
+ * TSL function for creating a normal map node with the given parameters.
  *
  * @function
  * @param {Node} node - Represents the normal map data.

+ 8 - 8
src/nodes/display/PassNode.js

@@ -186,7 +186,7 @@ class PassNode extends TempNode {
 		/**
 		 * A reference to the camera.
 		 *
-		 * @type {camera}
+		 * @type {Camera}
 		 */
 		this.camera = camera;
 
@@ -242,7 +242,7 @@ class PassNode extends TempNode {
 		 * A dictionary holding the internal result textures.
 		 *
 		 * @private
-		 * @type {Object}
+		 * @type {Object<String, Texture>}
 		 */
 		this._textures = {
 			output: renderTarget.texture,
@@ -253,7 +253,7 @@ class PassNode extends TempNode {
 		 * A dictionary holding the internal texture nodes.
 		 *
 		 * @private
-		 * @type {Object}
+		 * @type {Object<String, TextureNode>}
 		 */
 		this._textureNodes = {};
 
@@ -278,7 +278,7 @@ class PassNode extends TempNode {
 		 * Used for computing velocity/motion vectors.
 		 *
 		 * @private
-		 * @type {Object}
+		 * @type {Object<String, Texture>}
 		 */
 		this._previousTextures = {};
 
@@ -287,7 +287,7 @@ class PassNode extends TempNode {
 		 * Used for computing velocity/motion vectors.
 		 *
 		 * @private
-		 * @type {Object}
+		 * @type {Object<String, TextureNode>}
 		 */
 		this._previousTextureNodes = {};
 
@@ -639,7 +639,7 @@ PassNode.DEPTH = 'depth';
 export default PassNode;
 
 /**
- * TSL function for creating a pass node with the given paramters.
+ * TSL function for creating a pass node with the given parameters.
  *
  * @function
  * @param {Scene} scene - A reference to the scene.
@@ -650,7 +650,7 @@ export default PassNode;
 export const pass = ( scene, camera, options ) => nodeObject( new PassNode( PassNode.COLOR, scene, camera, options ) );
 
 /**
- * TSL function for creating a pass texture node with the given paramters.
+ * TSL function for creating a pass texture node with the given parameters.
  *
  * @function
  * @param {PassNode} pass - The pass node.
@@ -660,7 +660,7 @@ export const pass = ( scene, camera, options ) => nodeObject( new PassNode( Pass
 export const passTexture = ( pass, texture ) => nodeObject( new PassTextureNode( pass, texture ) );
 
 /**
- * TSL function for creating a depth pass node with the given paramters.
+ * TSL function for creating a depth pass node with the given parameters.
  *
  * @function
  * @param {Scene} scene - A reference to the scene.

+ 1 - 1
src/nodes/display/PosterizeNode.js

@@ -56,7 +56,7 @@ class PosterizeNode extends TempNode {
 export default PosterizeNode;
 
 /**
- * TSL function for creating a posterize node with the given paramters.
+ * TSL function for creating a posterize node with the given parameters.
  *
  * @function
  * @param {Node} sourceNode - The input color.

+ 3 - 3
src/nodes/display/RenderOutputNode.js

@@ -41,7 +41,7 @@ class RenderOutputNode extends TempNode {
 	 * Constructs a new render output node.
 	 *
 	 * @param {Node} colorNode - The color node to process.
-	 * @param {String} toneMapping - The tone mapping type.
+	 * @param {Number} toneMapping - The tone mapping type.
 	 * @param {String} outputColorSpace - The output color space.
 	 */
 	constructor( colorNode, toneMapping, outputColorSpace ) {
@@ -112,11 +112,11 @@ class RenderOutputNode extends TempNode {
 export default RenderOutputNode;
 
 /**
- * TSL function for creating a posterize node with the given paramters.
+ * TSL function for creating a posterize node with the given parameters.
  *
  * @function
  * @param {Node} color - The color node to process.
- * @param {String?} [toneMapping=null] - The tone mapping type.
+ * @param {Number?} [toneMapping=null] - The tone mapping type.
  * @param {String?} [outputColorSpace=null] - The output color space.
  * @returns {RenderOutputNode}
  */

+ 1 - 1
src/nodes/display/ViewportDepthNode.js

@@ -45,7 +45,7 @@ class ViewportDepthNode extends Node {
 		 * Can be used to define a custom depth value.
 		 * The property is ignored in the `ViewportDepthNode.DEPTH` scope.
 		 *
-		 * @type {Node}
+		 * @type {Node?}
 		 * @default null
 		 */
 		this.valueNode = valueNode;

+ 1 - 1
src/nodes/functions/PhongLightingModel.js

@@ -33,7 +33,7 @@ const BRDF_BlinnPhong = /*@__PURE__*/ Fn( ( { lightDirection } ) => {
 /**
  * Represents the lighting model for a phong material. Used in {@link MeshPhongNodeMaterial}.
  *
- * @augments LightingModel
+ * @augments BasicLightingModel
  */
 class PhongLightingModel extends BasicLightingModel {
 

+ 1 - 1
src/nodes/geometry/RangeNode.js

@@ -163,7 +163,7 @@ class RangeNode extends Node {
 export default RangeNode;
 
 /**
- * TSL function for creating a range node with the given paramters.
+ * TSL function for creating a range node with the given parameters.
  *
  * @function
  * @param {Node<any>} [minNode=float()] - A node defining the lower bound of the range.

+ 7 - 4
src/nodes/lighting/AnalyticLightNode.js

@@ -32,7 +32,7 @@ class AnalyticLightNode extends LightingNode {
 		/**
 		 * The light source.
 		 *
-		 * @type {Light}
+		 * @type {Light?}
 		 * @default null
 		 */
 		this.light = light;
@@ -56,21 +56,24 @@ class AnalyticLightNode extends LightingNode {
 		 * This property is used to retain a reference to the original value of {@link AnalyticLightNode#colorNode}.
 		 * The final color node is represented by a different node when using shadows.
 		 *
-		 * @type {Node}
+		 * @type {Node?}
+		 * @default null
 		 */
 		this.baseColorNode = null;
 
 		/**
 		 * Represents the light's shadow.
 		 *
-		 * @type {ShadowNode}
+		 * @type {ShadowNode?}
+   		 * @default null
 		 */
 		this.shadowNode = null;
 
 		/**
 		 * Represents the light's shadow color.
 		 *
-		 * @type {Node}
+		 * @type {Node?}
+   		 * @default null
 		 */
 		this.shadowColorNode = null;
 

+ 1 - 0
src/nodes/lighting/PointShadowNode.js

@@ -218,6 +218,7 @@ class PointShadowNode extends ShadowNode {
 	 * @param {NodeBuilder} builder - A reference to the current node builder.
 	 * @param {Object} inputs - A configuration object that defines the shadow filtering.
 	 * @param {Function} inputs.filterFn - This function defines the filtering type of the shadow map e.g. PCF.
+	 * @param {Texture} inputs.shadowTexture - A reference to the shadow map's texture.
 	 * @param {DepthTexture} inputs.depthTexture - A reference to the shadow map's texture data.
 	 * @param {Node<vec3>} inputs.shadowCoord - Shadow coordinates which are used to sample from the shadow map.
 	 * @param {LightShadow} inputs.shadow - The light shadow.

+ 1 - 1
src/nodes/lighting/ShadowBaseNode.js

@@ -60,7 +60,7 @@ class ShadowBaseNode extends Node {
 	/**
 	 * Setups the shadow position node which is by default the predefined TSL node object `shadowWorldPosition`.
 	 *
-	 * @param {(NodeBuilder|{material})} object - A configuration object that must at least hold a material reference.
+	 * @param {(NodeBuilder|{Material})} object - A configuration object that must at least hold a material reference.
 	 */
 	setupShadowPosition( { material } ) {
 

+ 1 - 1
src/nodes/math/ConditionalNode.js

@@ -10,7 +10,7 @@ import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
  * ```js
  * velocity = position.greaterThanEqual( limit ).select( velocity.negate(), velocity );
  * ```
- * The `select()` method is called in a chaining fashion on a codition. The parameter nodes of `select()`
+ * The `select()` method is called in a chaining fashion on a condition. The parameter nodes of `select()`
  * determine the outcome of the entire statement.
  *
  * @augments Node

+ 2 - 4
src/nodes/math/MathNode.js

@@ -33,11 +33,9 @@ class MathNode extends TempNode {
 		super();
 
 		/**
-		 * This flag can be used for type testing.
+		 * The method name.
 		 *
-		 * @type {Boolean}
-		 * @readonly
-		 * @default true
+		 * @type {String}
 		 */
 		this.method = method;
 

+ 1 - 1
src/nodes/math/MathUtils.js

@@ -22,7 +22,7 @@ export const parabola = ( x, k ) => pow( mul( 4.0, x.mul( sub( 1.0, x ) ) ), k )
  *
  * @method
  * @param {Node<float>} x - The value to remap.
- * @param {Node<float>} k - `k=1` is the identity curve,`k<1` produces the classic `gain()` shape, and `k>1` produces "s" shaped curces.
+ * @param {Node<float>} k - `k=1` is the identity curve,`k<1` produces the classic `gain()` shape, and `k>1` produces "s" shaped curves.
  * @return {Node<float>} The remapped value.
  */
 export const gain = ( x, k ) => x.lessThan( 0.5 ) ? parabola( x.mul( 2.0 ), k ).div( 2.0 ) : sub( 1.0, parabola( mul( sub( 1.0, x ), 2.0 ), k ).div( 2.0 ) );

+ 1 - 1
src/nodes/pmrem/PMREMNode.js

@@ -362,7 +362,7 @@ function isEquirectangularMapReady( image ) {
 }
 
 /**
- * TSL function for creating a PMREM node with the given paramters.
+ * TSL function for creating a PMREM node with the given parameters.
  *
  * @function
  * @param {Texture} value - The input texture.

+ 1 - 1
src/nodes/procedural/Checker.js

@@ -7,7 +7,7 @@ import { Fn } from '../tsl/TSLBase.js';
  * Creates a 2x2 checkerboard pattern that can be used as procedural texture data.
  *
  * @method
- * @param {Node<vec2>} uv - The uv coordinates.
+ * @param {Node<vec2>} coord - The uv coordinates.
  * @return {Node<float>} The result data.
  */
 export const checker = /*@__PURE__*/ Fn( ( [ coord = uv() ] ) => {

+ 1 - 1
src/nodes/utils/LoopNode.js

@@ -15,7 +15,7 @@ import { nodeObject, nodeArray } from '../tsl/TSLBase.js';
  *
  * } );
  *```
- * Nested loops can be definde in a compacted form:
+ * Nested loops can be defined in a compacted form:
  * ```js
  * Loop( 10, 5, ( { i, j } ) => {
  *

+ 6 - 4
src/nodes/utils/ReflectorNode.js

@@ -65,6 +65,8 @@ class ReflectorNode extends TextureNode {
 	 * @param {Boolean} [parameters.generateMipmaps=false] - Whether mipmaps should be generated or not.
 	 * @param {Boolean} [parameters.bounces=true] - Whether reflectors can render other reflector nodes or not.
 	 * @param {Boolean} [parameters.depth=false] - Whether depth data should be generated or not.
+	 * @param {TextureNode} [parameters.defaultTexture] - The default texture node.
+	 * @param {ReflectorBaseNode} [parameters.reflector] - The reflector base node.
 	 */
 	constructor( parameters = {} ) {
 
@@ -74,7 +76,7 @@ class ReflectorNode extends TextureNode {
 		 * A reference to the internal reflector base node which holds the actual implementation.
 		 *
 		 * @private
-		 * @type {Node?}
+		 * @type {ReflectorBaseNode?}
 		 * @default null
 		 */
 		this._reflectorBaseNode = parameters.reflector || new ReflectorBaseNode( this, parameters );
@@ -95,7 +97,7 @@ class ReflectorNode extends TextureNode {
 	/**
 	 * A reference to the internal reflector node.
 	 *
-	 * @type {Node}
+	 * @type {ReflectorBaseNode}
 	 */
 	get reflector() {
 
@@ -164,7 +166,7 @@ class ReflectorNode extends TextureNode {
 /**
  * Holds the actual implementation of the reflector.
  *
- * TOOD: Explain why `ReflectorBaseNode`. Originally the entire logic was implemented
+ * TODO: Explain why `ReflectorBaseNode`. Originally the entire logic was implemented
  * in `ReflectorNode`, see #29619.
  *
  * @private
@@ -260,7 +262,7 @@ class ReflectorBaseNode extends Node {
 		/**
 		 * Weak map for managing virtual cameras.
 		 *
-		 * @type {WeakMap<Camera,Camera>}
+		 * @type {WeakMap<Camera, Camera>}
 		 */
 		this.virtualCameras = new WeakMap();
 

粤ICP备19079148号