Просмотр исходного кода

Docs: fix types (#30677)

Co-authored-by: Samuel Rigaud <srigaud@duodisplay.com>
Samuel Rigaud 11 месяцев назад
Родитель
Сommit
ddfa74b9e4

+ 1 - 1
examples/jsm/libs/motion-controllers.module.js

@@ -338,7 +338,7 @@ class MotionController {
   /**
    * @param {Object} xrInputSource - The XRInputSource to build the MotionController around
    * @param {Object} profile - The best matched profile description for the supplied xrInputSource
-   * @param {Object} assetUrl
+   * @param {string} assetUrl
    */
   constructor(xrInputSource, profile, assetUrl) {
     if (!xrInputSource) {

+ 3 - 3
examples/jsm/math/ConvexHull.js

@@ -328,7 +328,7 @@ class ConvexHull {
 	 *
 	 * @private
 	 * @param {Face} face - The target face.
-	 * @return {ConvexHull} A reference to this convex hull.
+	 * @return {VertexNode|undefined} A reference to this convex hull.
 	 */
 	_removeAllVerticesFromFace( face ) {
 
@@ -1391,7 +1391,7 @@ class VertexNode {
 		 * Reference to the previous vertex in the double linked list.
 		 *
 		 * @private
-		 * @type {?Vector3}
+		 * @type {?VertexNode}
 		 * @default null
 		 */
 		this.prev = null;
@@ -1400,7 +1400,7 @@ class VertexNode {
 		 * Reference to the next vertex in the double linked list.
 		 *
 		 * @private
-		 * @type {?Vector3}
+		 * @type {?VertexNode}
 		 * @default null
 		 */
 		this.next = null;

+ 1 - 1
examples/jsm/objects/MarchingCubes.js

@@ -22,7 +22,7 @@ class MarchingCubes extends Mesh {
 	 * @param {Material} material - The cube's material.
 	 * @param {boolean} [enableUvs=false] - Whether texture coordinates should be animated or not.
 	 * @param {boolean} [enableColors=false] - Whether colors should be animated or not.
-	 * @param {boolean} [maxPolyCount=10000] - The maximum size of the geometry buffers.
+	 * @param {number} [maxPolyCount=10000] - The maximum size of the geometry buffers.
 	 */
 	constructor( resolution, material, enableUvs = false, enableColors = false, maxPolyCount = 10000 ) {
 

+ 4 - 4
examples/jsm/tsl/display/PixelationPassNode.js

@@ -234,8 +234,8 @@ class PixelationPassNode extends PassNode {
 	 * @param {Scene} scene - The scene to render.
 	 * @param {Camera} camera - The camera to render the scene with.
 	 * @param {Node<float> | number} [pixelSize=6] - The pixel size.
-	 * @param {Node<float> | number} [normalEdgeStrength=03] - The normal edge strength.
-	 * @param {Node<float> | number} [depthEdgeStrength=03] - The depth edge strength.
+	 * @param {Node<float> | number} [normalEdgeStrength=0.3] - The normal edge strength.
+	 * @param {Node<float> | number} [depthEdgeStrength=0.4] - The depth edge strength.
 	 */
 	constructor( scene, camera, pixelSize = 6, normalEdgeStrength = 0.3, depthEdgeStrength = 0.4 ) {
 
@@ -324,8 +324,8 @@ class PixelationPassNode extends PassNode {
  * @param {Scene} scene - The scene to render.
  * @param {Camera} camera - The camera to render the scene with.
  * @param {Node<float> | number} [pixelSize=6] - The pixel size.
- * @param {Node<float> | number} [normalEdgeStrength=03] - The normal edge strength.
- * @param {Node<float> | number} [depthEdgeStrength=03] - The depth edge strength.
+ * @param {Node<float> | number} [normalEdgeStrength=0.3] - The normal edge strength.
+ * @param {Node<float> | number} [depthEdgeStrength=0.4] - The depth edge strength.
  * @returns {PixelationPassNode}
  */
 export const pixelationPass = ( scene, camera, pixelSize, normalEdgeStrength, depthEdgeStrength ) => nodeObject( new PixelationPassNode( scene, camera, pixelSize, normalEdgeStrength, depthEdgeStrength ) );

+ 2 - 2
examples/jsm/utils/BufferGeometryUtils.js

@@ -102,7 +102,7 @@ function computeMikkTSpaceTangents( geometry, MikkTSpace, negateSign = true ) {
 /**
  * @param  {Array<BufferGeometry>} geometries
  * @param  {boolean} useGroups
- * @return {BufferGeometry}
+ * @return {?BufferGeometry}
  */
 function mergeGeometries( geometries, useGroups = false ) {
 
@@ -297,7 +297,7 @@ function mergeGeometries( geometries, useGroups = false ) {
 
 /**
  * @param {Array<BufferAttribute>} attributes
- * @return {BufferAttribute}
+ * @return {?BufferAttribute}
  */
 function mergeAttributes( attributes ) {
 

+ 2 - 2
examples/jsm/utils/GeometryUtils.js

@@ -14,7 +14,7 @@ import { Vector3 } from 'three';
  * @param {number} [v1=1] - Corner index -X, +Z.
  * @param {number} [v2=2] - Corner index +X, +Z.
  * @param {number} [v3=3] - Corner index +X, -Z.
- * @returns {Array<Array<number>>} The Hilbert curve points.
+ * @returns {Array<Vector3>} The Hilbert curve points.
  */
 function hilbert2D( center = new Vector3( 0, 0, 0 ), size = 10, iterations = 1, v0 = 0, v1 = 1, v2 = 2, v3 = 3 ) {
 
@@ -68,7 +68,7 @@ function hilbert2D( center = new Vector3( 0, 0, 0 ), size = 10, iterations = 1,
  * @param {number} [v5=5] - Corner index +X, -Y, +Z.
  * @param {number} [v6=6] - Corner index +X, +Y, +Z.
  * @param {number} [v7=7] - Corner index +X, +Y, -Z.
- * @returns {Array<Array<number>>}  - The Hilbert curve points.
+ * @returns {Array<Vector3>}  - The Hilbert curve points.
  */
 function hilbert3D( center = new Vector3( 0, 0, 0 ), size = 10, iterations = 1, v0 = 0, v1 = 1, v2 = 2, v3 = 3, v4 = 4, v5 = 5, v6 = 6, v7 = 7 ) {
 

+ 2 - 2
src/animation/AnimationUtils.js

@@ -93,7 +93,7 @@ function sortedArray( values, stride, order ) {
  * @param {Array<number>} jsonKeys - A list of JSON keyframes.
  * @param {Array<number>} times - This array will be filled with keyframe times by this function.
  * @param {Array<number>} values - This array will be filled with keyframe values by this function.
- * @param {Object<string, any>} valuePropertyName - A dictionary assigning values to property names.
+ * @param {string} valuePropertyName - The name of the property to use.
  */
 function flattenJSON( jsonKeys, times, values, valuePropertyName ) {
 
@@ -451,7 +451,7 @@ class AnimationUtils {
 	 * @param {Array<number>} jsonKeys - A list of JSON keyframes.
 	 * @param {Array<number>} times - This array will be filled with keyframe times by this method.
 	 * @param {Array<number>} values - This array will be filled with keyframe values by this method.
-	 * @param {Object<string, any>} valuePropertyName - A dictionary assigning values to property names.
+	 * @param {string} valuePropertyName - The name of the property to use.
 	 */
 	static flattenJSON( jsonKeys, times, values, valuePropertyName ) {
 

+ 1 - 1
src/constants.js

@@ -11,7 +11,7 @@ export const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2
 /**
  * Represents touch interaction types in context of controls.
  *
- * @type {ConstantsMouse}
+ * @type {ConstantsTouch}
  * @constant
  */
 export const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };

+ 1 - 1
src/core/BufferAttribute.js

@@ -92,7 +92,7 @@ class BufferAttribute {
 		 * `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}
+		 * @type {boolean}
 		 */
 		this.normalized = normalized;
 

+ 1 - 1
src/extras/core/Curve.js

@@ -62,7 +62,7 @@ class Curve {
 	 * @abstract
 	 * @param {number} t - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`.
 	 * @param {(Vector2|Vector3)} [optionalTarget] - The optional target vector the result is written to.
-	 * @return {?(Vector2|Vector3)} The position on the curve. It can be a 2D or 3D vector depending on the curve definition.
+	 * @return {(Vector2|Vector3)} The position on the curve. It can be a 2D or 3D vector depending on the curve definition.
 	 */
 	getPoint( /* t, optionalTarget */ ) {
 

+ 1 - 1
src/geometries/LatheGeometry.js

@@ -25,7 +25,7 @@ class LatheGeometry extends BufferGeometry {
 	/**
 	 * Constructs a new lathe geometry.
 	 *
-	 * @param {Array<Vector2>} [points] - An array of points in 2D space. The x-coordinate of each point
+	 * @param {Array<Vector2|Vector3>} [points] - An array of points in 2D space. The x-coordinate of each point
 	 * must be greater than zero.
 	 * @param {number} [segments=12] - The number of circumference segments to generate.
 	 * @param {number} [phiStart=0] - The starting angle in radians.

+ 1 - 1
src/math/Color.js

@@ -559,7 +559,7 @@ class Color {
 	 * Converts the colors RGB values into the HSL format and stores them into the
 	 * given target object.
 	 *
-	 * @param {{h:0,s:0,l:0}} target - The target object that is used to store the method's result.
+	 * @param {{h:number,s:number,l:number}} target - The target object that is used to store the method's result.
 	 * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.
 	 * @return {{h:number,s:number,l:number}} The HSL representation of this color.
 	 */

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

@@ -388,7 +388,7 @@ export default ReferenceNode;
  * @function
  * @param {string} name - The name of the property the node refers to.
  * @param {string} type - The uniform type that should be used to represent the property value.
- * @param {?Object} object - The object the property belongs to.
+ * @param {?Object} [object] - The object the property belongs to.
  * @returns {ReferenceNode}
  */
 export const reference = ( name, type, object ) => nodeObject( new ReferenceNode( name, type, object ) );

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

@@ -342,7 +342,7 @@ export default UniformArrayNode;
  * @tsl
  * @function
  * @param {Array<any>} values - Array-like data.
- * @param {?string} nodeType - The data type of the array elements.
+ * @param {?string} [nodeType] - The data type of the array elements.
  * @returns {UniformArrayNode}
  */
 export const uniformArray = ( values, nodeType ) => nodeObject( new UniformArrayNode( values, nodeType ) );

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

@@ -92,7 +92,7 @@ export default CacheNode;
  * @tsl
  * @function
  * @param {Node} node - The node that should be cached.
- * @param {boolean} parent - Whether this node refers to a shared parent cache or not.
+ * @param {boolean} [parent] - Whether this node refers to a shared parent cache or not.
  * @returns {CacheNode}
  */
 export const cache = ( node, parent ) => nodeObject( new CacheNode( nodeObject( node ), parent ) );

+ 3 - 1
src/nodes/core/NodeBuilder.js

@@ -314,8 +314,10 @@ class NodeBuilder {
 		/**
 		 * This dictionary holds the node variables of this builder.
 		 * The variables are maintained in an array for each shader stage.
+		 * This dictionary is also used to count the number of variables
+		 * according to their type (const, vars).
 		 *
-		 * @type {Object<string,Array<NodeVar>>}
+		 * @type {Object<string,Array<NodeVar>|number>}
 		 */
 		this.vars = {};
 

+ 8 - 0
src/nodes/lighting/AnalyticLightNode.js

@@ -128,9 +128,17 @@ class AnalyticLightNode extends LightingNode {
 	 *
 	 * @abstract
 	 * @param {NodeBuilder} builder - The builder object used for setting up the light.
+	 * @return {Object|undefined} The direct light data (color and direction).
 	 */
 	setupDirect( /*builder*/ ) { }
 
+	/**
+	 * Sets up the direct rect area lighting for the analytic light node.
+	 *
+	 * @abstract
+	 * @param {NodeBuilder} builder - The builder object used for setting up the light.
+	 * @return {Object|undefined} The direct rect area light data.
+	 */
 	setupDirectRectArea( /*builder*/ ) { }
 
 	/**

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

@@ -806,7 +806,7 @@ export default ShadowNode;
  * @tsl
  * @function
  * @param {Light} light - The shadow casting light.
- * @param {LightShadow} shadow - The light shadow.
+ * @param {?LightShadow} [shadow] - The light shadow.
  * @return {ShadowNode} The created shadow node.
  */
 export const shadow = ( light, shadow ) => nodeObject( new ShadowNode( light, shadow ) );

+ 1 - 1
src/objects/InstancedMesh.js

@@ -71,7 +71,7 @@ class InstancedMesh extends Mesh {
 		 * {@link Texture#needsUpdate} flag to true if you modify instanced data
 		 * via {@link InstancedMesh#setMorphAt}.
 		 *
-		 * @type {?InstancedBufferAttribute}
+		 * @type {?DataTexture}
 		 * @default null
 		 */
 		this.morphTexture = null;

+ 1 - 1
src/objects/Skeleton.js

@@ -310,7 +310,7 @@ class Skeleton {
 	 * Setups the skeleton by the given JSON and bones.
 	 *
 	 * @param {Object} json - The skeleton as serialized JSON.
-	 * @param {Array<Bone>} bones - An array of bones.
+	 * @param {Object<string, Bone>} bones - An array of bones.
 	 * @return {Skeleton} A reference of this instance.
 	 */
 	fromJSON( json, bones ) {

+ 1 - 1
src/renderers/common/Animation.js

@@ -103,7 +103,7 @@ class Animation {
 	/**
 	 * Defines the user-level animation loop.
 	 *
-	 * @param {Function} callback - The animation loop.
+	 * @param {?Function} callback - The animation loop.
 	 */
 	setAnimationLoop( callback ) {
 

+ 1 - 1
src/renderers/common/Renderer.js

@@ -1510,7 +1510,7 @@ class Renderer {
 	 * for best compatibility.
 	 *
 	 * @async
-	 * @param {Function} callback - The application's animation loop.
+	 * @param {?Function} callback - The application's animation loop.
 	 * @return {Promise} A Promise that resolves when the set has been executed.
 	 */
 	async setAnimationLoop( callback ) {

+ 3 - 3
src/renderers/common/XRManager.js

@@ -229,7 +229,7 @@ class XRManager extends EventDispatcher {
 		 * The current XR reference space type.
 		 *
 		 * @private
-		 * @type {string}
+		 * @type {XRReferenceSpaceType}
 		 * @default 'local-floor'
 		 */
 		this._referenceSpaceType = 'local-floor';
@@ -439,7 +439,7 @@ class XRManager extends EventDispatcher {
 	/**
 	 * Returns the reference space type.
 	 *
-	 * @return {string} The reference space type.
+	 * @return {XRReferenceSpaceType} The reference space type.
 	 */
 	getReferenceSpaceType() {
 
@@ -452,7 +452,7 @@ class XRManager extends EventDispatcher {
 	 *
 	 * This method can not be used during a XR session.
 	 *
-	 * @param {string} type - The reference space type.
+	 * @param {XRReferenceSpaceType} type - The reference space type.
 	 */
 	setReferenceSpaceType( type ) {
 

+ 1 - 1
src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js

@@ -79,7 +79,7 @@ class GLSLNodeBuilder extends NodeBuilder {
 		 * An array that holds objects defining the varying and attribute data in
 		 * context of Transform Feedback.
 		 *
-		 * @type {Object<string,Map<string,Object>>}
+		 * @type {Array<Object<string,AttributeNode|string>>}
 		 */
 		this.transforms = [];
 

粤ICP备19079148号