Browse Source

Docs: Properly document animation loop parameter. (#31853)

Michael Herzog 4 months ago
parent
commit
eeec0f48f4
2 changed files with 16 additions and 1 deletions
  1. 7 0
      src/renderers/WebGLRenderer.js
  2. 9 1
      src/renderers/common/Renderer.js

+ 7 - 0
src/renderers/WebGLRenderer.js

@@ -1492,6 +1492,13 @@ class WebGLRenderer {
 
 
 		if ( typeof self !== 'undefined' ) animation.setContext( self );
 		if ( typeof self !== 'undefined' ) animation.setContext( self );
 
 
+		/**
+		 * Applications are advised to always define the animation loop
+		 * with this method and not manually with `requestAnimationFrame()`
+		 * for best compatibility.
+		 *
+		 * @param {?onAnimationCallback} callback - The application's animation loop.
+		 */
 		this.setAnimationLoop = function ( callback ) {
 		this.setAnimationLoop = function ( callback ) {
 
 
 			onAnimationFrameCallback = callback;
 			onAnimationFrameCallback = callback;

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

@@ -1617,7 +1617,7 @@ class Renderer {
 	 * for best compatibility.
 	 * for best compatibility.
 	 *
 	 *
 	 * @async
 	 * @async
-	 * @param {?Function} callback - The application's animation loop.
+	 * @param {?onAnimationCallback} callback - The application's animation loop.
 	 * @return {Promise} A Promise that resolves when the set has been executed.
 	 * @return {Promise} A Promise that resolves when the set has been executed.
 	 */
 	 */
 	async setAnimationLoop( callback ) {
 	async setAnimationLoop( callback ) {
@@ -3114,4 +3114,12 @@ class Renderer {
 
 
 }
 }
 
 
+/**
+ * Animation loop parameter of `renderer.setAnimationLoop()`.
+ *
+ * @callback onAnimationCallback
+ * @param {DOMHighResTimeStamp} time - A timestamp indicating the end time of the previous frame's rendering.
+ * @param {XRFrame} [frame] - A reference to the current XR frame. Only relevant when using XR rendering.
+ */
+
 export default Renderer;
 export default Renderer;

粤ICP备19079148号