Răsfoiți Sursa

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

Michael Herzog 4 luni în urmă
părinte
comite
eeec0f48f4
2 a modificat fișierele cu 16 adăugiri și 1 ștergeri
  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 );
 
+		/**
+		 * 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 ) {
 
 			onAnimationFrameCallback = callback;

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

@@ -1617,7 +1617,7 @@ class Renderer {
 	 * for best compatibility.
 	 *
 	 * @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.
 	 */
 	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;

粤ICP备19079148号