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

Docs: fix types (#31450)

* Docs: fix types

* Update Backend.js

---------

Co-authored-by: Samuel Rigaud <rigaud@gmail.com>
Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>
Samuel Rigaud 7 месяцев назад
Родитель
Сommit
7ff0f18c4f

+ 1 - 1
examples/jsm/capabilities/WebGPU.js

@@ -2,7 +2,7 @@ let isAvailable = ( typeof navigator !== 'undefined' && navigator.gpu !== undefi
 
 if ( typeof window !== 'undefined' && isAvailable ) {
 
-	isAvailable = await navigator.gpu.requestAdapter();
+	isAvailable = Boolean( await navigator.gpu.requestAdapter() );
 
 }
 

+ 4 - 4
examples/jsm/physics/RapierPhysics.js

@@ -282,17 +282,17 @@ async function RapierPhysics() {
 	function addHeightfield( mesh, width, depth, heights, scale ) {
 
 		const shape = RAPIER.ColliderDesc.heightfield( width, depth, heights, scale );
-		
+
 		const bodyDesc = RAPIER.RigidBodyDesc.fixed();
 		bodyDesc.setTranslation( mesh.position.x, mesh.position.y, mesh.position.z );
 		bodyDesc.setRotation( mesh.quaternion );
-		
+
 		const body = world.createRigidBody( bodyDesc );
 		world.createCollider( shape, body );
-		
+
 		if ( ! mesh.userData.physics ) mesh.userData.physics = {};
 		mesh.userData.physics.body = body;
-		
+
 		return body;
 
 	}

+ 2 - 2
examples/jsm/tsl/display/TRAANode.js

@@ -14,7 +14,7 @@ let _rendererState;
  * - {@link https://alextardif.com/TAA.html}
  * - {@link https://www.elopezr.com/temporal-aa-and-the-quest-for-the-holy-trail/}
  *
- * @augments PassNode
+ * @augments TempNode
  * @three_import import { traa } from 'three/addons/tsl/display/TRAANode.js';
  */
 class TRAANode extends TempNode {
@@ -456,6 +456,6 @@ const _JitterVectors = [
  * @param {TextureNode} depthNode - A node that represents the scene's depth.
  * @param {TextureNode} velocityNode - A node that represents the scene's velocity.
  * @param {Camera} camera - The camera the scene is rendered with.
- * @returns {TRAAPassNode}
+ * @returns {TRAANode}
  */
 export const traa = ( beautyNode, depthNode, velocityNode, camera ) => nodeObject( new TRAANode( convertToTexture( beautyNode ), depthNode, velocityNode, camera ) );

+ 1 - 1
examples/webgl_renderer_pathtracer.html

@@ -392,7 +392,7 @@
 
 			function updateProgressBar( fraction ) {
 
-				progressBarDiv.innerText = 'Loading... ' + Math.round( fraction * 100, 2 ) + '%';
+				progressBarDiv.innerText = 'Loading... ' + Math.round( fraction * 100 ) + '%';
 
 			}
 

+ 1 - 1
examples/webgpu_xr_native_layers.html

@@ -465,7 +465,7 @@
 				gui.add( parameters, 'thickness', 0, 1 ).onChange( onThicknessChange );
 				gui.domElement.style.visibility = 'hidden';
 
-				guiGroup = new InteractiveGroup( renderer, guiCamera );
+				guiGroup = new InteractiveGroup();
 				guiScene.add( guiGroup );
 
 				const mesh = new HTMLMesh( gui.domElement );

+ 2 - 1
src/loaders/FileLoader.js

@@ -41,7 +41,8 @@ class FileLoader extends Loader {
 		super( manager );
 
 		/**
-		 * The expected mime type.
+		 * The expected mime type. Valid values can be found
+		 * [here]{@link hhttps://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#mimetype}
 		 *
 		 * @type {string}
 		 */

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

@@ -91,7 +91,7 @@ class ViewportTextureNode extends TextureNode {
 		/**
 		 * The framebuffer texture for the current renderer context.
 		 *
-		 * @type {WeakMap}
+		 * @type {WeakMap<RenderTarget, FramebufferTexture>}
 		 * @private
 		 */
 		this._textures = new WeakMap();

+ 2 - 2
src/nodes/functions/PhysicalLightingModel.js

@@ -575,7 +575,7 @@ class PhysicalLightingModel extends LightingModel {
 	 * @param {Object} lightData - The light data.
 	 * @param {NodeBuilder} builder - The current node builder.
 	 */
-	direct( { lightDirection, lightColor, reflectedLight } ) {
+	direct( { lightDirection, lightColor, reflectedLight }, /* builder */ ) {
 
 		const dotNL = normalView.dot( lightDirection ).clamp();
 		const irradiance = dotNL.mul( lightColor );
@@ -608,7 +608,7 @@ class PhysicalLightingModel extends LightingModel {
 	 * @param {Object} input - The input data.
 	 * @param {NodeBuilder} builder - The current node builder.
 	 */
-	directRectArea( { lightColor, lightPosition, halfWidth, halfHeight, reflectedLight, ltc_1, ltc_2 } ) {
+	directRectArea( { lightColor, lightPosition, halfWidth, halfHeight, reflectedLight, ltc_1, ltc_2 }, /* builder */ ) {
 
 		const p0 = lightPosition.add( halfWidth ).sub( halfHeight ); // counterclockwise; light shines in local neg z direction
 		const p1 = lightPosition.sub( halfWidth ).sub( halfHeight );

+ 2 - 2
src/renderers/common/Color4.js

@@ -34,8 +34,8 @@ class Color4 extends Color {
 	 * string argument to this method.
 	 *
 	 * @param {number|string|Color} r - The red value.
-	 * @param {number} g - The green value.
-	 * @param {number} b - The blue value.
+	 * @param {number} [g] - The green value.
+	 * @param {number} [b] - The blue value.
 	 * @param {number} [a=1] - The alpha value.
 	 * @return {Color4} A reference to this object.
 	 */

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

@@ -2963,7 +2963,7 @@ class Renderer {
 	 * @param {LightsNode} lightsNode - The current lights node.
 	 * @param {?{start: number, count: number}} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
 	 * @param {ClippingContext} clippingContext - The clipping context.
-	 * @param {?string} [passId=null] - An optional ID for identifying the pass.
+	 * @param {string} [passId] - An optional ID for identifying the pass.
 	 */
 	_renderObjectDirect( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
 
@@ -3018,7 +3018,7 @@ class Renderer {
 	 * @param {LightsNode} lightsNode - The current lights node.
 	 * @param {?{start: number, count: number}} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
 	 * @param {ClippingContext} clippingContext - The clipping context.
-	 * @param {?string} [passId=null] - An optional ID for identifying the pass.
+	 * @param {string} [passId] - An optional ID for identifying the pass.
 	 */
 	_createObjectPipeline( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
 

+ 1 - 1
src/renderers/webgl-fallback/WebGLBackend.js

@@ -183,7 +183,7 @@ class WebGLBackend extends Backend {
 		 * A unique collection of bindings.
 		 *
 		 * @private
-		 * @type {WeakSet}
+		 * @type {WeakSet<Array<BindGroup>>}
 		 */
 		this._knownBindings = new WeakSet();
 

+ 1 - 1
src/renderers/webgpu/utils/WebGPUPipelineUtils.js

@@ -712,7 +712,7 @@ class WebGPUPipelineUtils {
 	 *
 	 * @private
 	 * @param {Material} material - The material.
-	 * @return {string} The GPU color write mask.
+	 * @return {number} The GPU color write mask.
 	 */
 	_getColorWriteMask( material ) {
 

+ 1 - 1
src/renderers/webxr/WebXRManager.js

@@ -810,7 +810,7 @@ class WebXRManager extends EventDispatcher {
 		/**
 		 * Returns the amount of foveation used by the XR compositor for the projection layer.
 		 *
-		 * @return {number} The amount of foveation.
+		 * @return {number|undefined} The amount of foveation.
 		 */
 		this.getFoveation = function () {
 

+ 2 - 2
src/textures/FramebufferTexture.js

@@ -30,8 +30,8 @@ class FramebufferTexture extends Texture {
 	/**
 	 * Constructs a new framebuffer texture.
 	 *
-	 * @param {number} width - The width of the texture.
-	 * @param {number} height - The height of the texture.
+	 * @param {number} [width] - The width of the texture.
+	 * @param {number} [height] - The height of the texture.
 	 */
 	constructor( width, height ) {
 

粤ICP备19079148号