From f958a1359b4d63e20753291168886d1c85a647f4 Mon Sep 17 00:00:00 2001 From: Samuel Rigaud <46346622+s-rigaud@users.noreply.github.com> Date: Wed, 22 Jan 2025 10:53:44 -0500 Subject: [PATCH] JsDoc: improve type hinting for constructors (#30382) Co-authored-by: Samuel Rigaud --- editor/js/Command.js | 11 +++++------ examples/jsm/animation/CCDIKSolver.js | 9 +++++---- examples/jsm/loaders/GCodeLoader.js | 4 +++- examples/jsm/loaders/TDSLoader.js | 1 - examples/jsm/misc/GPUComputationRenderer.js | 13 ++++++------- examples/jsm/misc/ProgressiveLightMap.js | 7 ++++--- examples/jsm/misc/ProgressiveLightMapGPU.js | 7 ++++--- examples/jsm/misc/Volume.js | 12 +++++++----- examples/jsm/misc/VolumeSlice.js | 8 +++++--- 9 files changed, 39 insertions(+), 33 deletions(-) diff --git a/editor/js/Command.js b/editor/js/Command.js index b9c85bee48fd16..9a227b3118ce81 100644 --- a/editor/js/Command.js +++ b/editor/js/Command.js @@ -1,11 +1,10 @@ -/** - * @param editor pointer to main editor object used to initialize - * each command object with a reference to the editor - * @constructor - */ - class Command { + /** + * @param {Editor} editor pointer to main editor object used to initialize + * each command object with a reference to the editor + * @constructor + */ constructor( editor ) { this.id = - 1; diff --git a/examples/jsm/animation/CCDIKSolver.js b/examples/jsm/animation/CCDIKSolver.js index c935ac1569392d..daa9547b63508d 100644 --- a/examples/jsm/animation/CCDIKSolver.js +++ b/examples/jsm/animation/CCDIKSolver.js @@ -277,13 +277,14 @@ function setPositionOfBoneToAttributeArray( array, index, bone, matrixWorldInv ) /** * Visualize IK bones - * - * @param {SkinnedMesh} mesh - * @param {Array} iks - * @param {number} sphereSize */ class CCDIKHelper extends Object3D { + /** + * @param {SkinnedMesh} mesh + * @param {Array} [iks=[]] + * @param {number} [sphereSize=0.25] + */ constructor( mesh, iks = [], sphereSize = 0.25 ) { super(); diff --git a/examples/jsm/loaders/GCodeLoader.js b/examples/jsm/loaders/GCodeLoader.js index 3f22064700b9b3..66138209178207 100644 --- a/examples/jsm/loaders/GCodeLoader.js +++ b/examples/jsm/loaders/GCodeLoader.js @@ -14,11 +14,13 @@ import { * Gcode files are composed by commands used by machines to create objects. * * @class GCodeLoader - * @param {Manager} manager Loading manager. */ class GCodeLoader extends Loader { + /** + * @param {Manager} manager Loading manager. + */ constructor( manager ) { super( manager ); diff --git a/examples/jsm/loaders/TDSLoader.js b/examples/jsm/loaders/TDSLoader.js index c88879f74ecc0e..bf80885306cc8b 100644 --- a/examples/jsm/loaders/TDSLoader.js +++ b/examples/jsm/loaders/TDSLoader.js @@ -20,7 +20,6 @@ import { * Loads geometry with uv and materials basic properties with texture support. * * @class TDSLoader - * @constructor */ class TDSLoader extends Loader { diff --git a/examples/jsm/misc/GPUComputationRenderer.js b/examples/jsm/misc/GPUComputationRenderer.js index 7fd42df60da41a..c8d67370e0ca61 100644 --- a/examples/jsm/misc/GPUComputationRenderer.js +++ b/examples/jsm/misc/GPUComputationRenderer.js @@ -99,16 +99,15 @@ import { FullScreenQuad } from '../postprocessing/Pass.js'; * // And compute each frame, before rendering to screen: * gpuCompute.doRenderTarget( myFilter1, myRenderTarget ); * gpuCompute.doRenderTarget( myFilter2, outputRenderTarget ); - * - * - * - * @param {int} sizeX Computation problem size is always 2d: sizeX * sizeY elements. - * @param {int} sizeY Computation problem size is always 2d: sizeX * sizeY elements. - * @param {WebGLRenderer} renderer The renderer - */ + */ class GPUComputationRenderer { + /** + * @param {Number} sizeX Computation problem size is always 2d: sizeX * sizeY elements. + * @param {Number} sizeY Computation problem size is always 2d: sizeX * sizeY elements. + * @param {WebGLRenderer} renderer The renderer + */ constructor( sizeX, sizeY, renderer ) { this.variables = []; diff --git a/examples/jsm/misc/ProgressiveLightMap.js b/examples/jsm/misc/ProgressiveLightMap.js index fe95d50327205f..be78f3c62803af 100644 --- a/examples/jsm/misc/ProgressiveLightMap.js +++ b/examples/jsm/misc/ProgressiveLightMap.js @@ -13,12 +13,13 @@ import { potpack } from '../libs/potpack.module.js'; * This should begin accumulating lightmaps which apply to * your objects, so you can start jittering lighting to achieve * the texture-space effect you're looking for. - * - * @param {WebGLRenderer} renderer An instance of WebGLRenderer. - * @param {number} res The side-long dimension of you total lightmap. */ class ProgressiveLightMap { + /** + * @param {WebGLRenderer} renderer An instance of WebGLRenderer. + * @param {number} [res=1024] The side-long dimension of you total lightmap. + */ constructor( renderer, res = 1024 ) { this.renderer = renderer; diff --git a/examples/jsm/misc/ProgressiveLightMapGPU.js b/examples/jsm/misc/ProgressiveLightMapGPU.js index e615c4f3f3b2a7..8531b35605447f 100644 --- a/examples/jsm/misc/ProgressiveLightMapGPU.js +++ b/examples/jsm/misc/ProgressiveLightMapGPU.js @@ -15,12 +15,13 @@ import { potpack } from '../libs/potpack.module.js'; * This should begin accumulating lightmaps which apply to * your objects, so you can start jittering lighting to achieve * the texture-space effect you're looking for. - * - * @param {WebGPURenderer} renderer An instance of WebGPURenderer. - * @param {number} resolution The side-long dimension of you total lightmap. */ class ProgressiveLightMap { + /** + * @param {WebGPURenderer} renderer An instance of WebGPURenderer. + * @param {number} [resolution=1024] The side-long dimension of you total lightmap. + */ constructor( renderer, resolution = 1024 ) { this.renderer = renderer; diff --git a/examples/jsm/misc/Volume.js b/examples/jsm/misc/Volume.js index 5e96997316836e..803969bde4c42a 100644 --- a/examples/jsm/misc/Volume.js +++ b/examples/jsm/misc/Volume.js @@ -11,14 +11,16 @@ import { VolumeSlice } from '../misc/VolumeSlice.js'; * For now it only handles 3 dimensional data. * See the webgl_loader_nrrd.html example and the loaderNRRD.js file to see how to use this class. * @class - * @param {number} xLength Width of the volume - * @param {number} yLength Length of the volume - * @param {number} zLength Depth of the volume - * @param {string} type The type of data (uint8, uint16, ...) - * @param {ArrayBuffer} arrayBuffer The buffer with volume data */ class Volume { + /** + * @param {number} xLength Width of the volume + * @param {number} yLength Length of the volume + * @param {number} zLength Depth of the volume + * @param {string} type The type of data (uint8, uint16, ...) + * @param {ArrayBuffer} arrayBuffer The buffer with volume data + */ constructor( xLength, yLength, zLength, type, arrayBuffer ) { if ( xLength !== undefined ) { diff --git a/examples/jsm/misc/VolumeSlice.js b/examples/jsm/misc/VolumeSlice.js index 3b087f16645058..923486c9dc0bf4 100644 --- a/examples/jsm/misc/VolumeSlice.js +++ b/examples/jsm/misc/VolumeSlice.js @@ -12,13 +12,15 @@ import { /** * This class has been made to hold a slice of a volume data * @class - * @param {Volume} volume The associated volume - * @param {number} [index=0] The index of the slice - * @param {string} [axis='z'] For now only 'x', 'y' or 'z' but later it will change to a normal vector * @see Volume */ class VolumeSlice { + /** + * @param {Volume} volume The associated volume + * @param {number} [index=0] The index of the slice + * @param {string} [axis='z'] For now only 'x', 'y' or 'z' but later it will change to a normal vector + */ constructor( volume, index, axis ) { const slice = this;