PHP 7.4.33
Preview: Animation.js Size: 2.48 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/three/src/renderers/common/Animation.js
/**
 * This module manages the internal animation loop of the renderer.
 *
 * @private
 */
class Animation {

	/**
	 * Constructs a new animation loop management component.
	 *
	 * @param {Nodes} nodes - Renderer component for managing nodes related logic.
	 * @param {Info} info - Renderer component for managing metrics and monitoring data.
	 */
	constructor( nodes, info ) {

		/**
		 * Renderer component for managing nodes related logic.
		 *
		 * @type {Nodes}
		 */
		this.nodes = nodes;

		/**
		 * Renderer component for managing metrics and monitoring data.
		 *
		 * @type {Info}
		 */
		this.info = info;

		/**
		 * A reference to the context from `requestAnimationFrame()` can
		 * be called (usually `window`).
		 *
		 * @type {Window|XRSession}
		 */
		this._context = self;

		/**
		 * The user-defined animation loop.
		 *
		 * @type {?Function}
		 * @default null
		 */
		this._animationLoop = null;

		/**
		 * The requestId which is returned from the `requestAnimationFrame()` call.
		 * Can be used to cancel the stop the animation loop.
		 *
		 * @type {?number}
		 * @default null
		 */
		this._requestId = null;

	}

	/**
	 * Starts the internal animation loop.
	 */
	start() {

		const update = ( time, xrFrame ) => {

			this._requestId = this._context.requestAnimationFrame( update );

			if ( this.info.autoReset === true ) this.info.reset();

			this.nodes.nodeFrame.update();

			this.info.frame = this.nodes.nodeFrame.frameId;

			if ( this._animationLoop !== null ) this._animationLoop( time, xrFrame );

		};

		update();

	}

	/**
	 * Stops the internal animation loop.
	 */
	stop() {

		this._context.cancelAnimationFrame( this._requestId );

		this._requestId = null;

	}

	/**
	 * Returns the user-level animation loop.
	 *
	 * @return {Function} The animation loop.
	 */
	getAnimationLoop() {

		return this._animationLoop;

	}

	/**
	 * Defines the user-level animation loop.
	 *
	 * @param {Function} callback - The animation loop.
	 */
	setAnimationLoop( callback ) {

		this._animationLoop = callback;

	}

	/**
	 * Returns the animation context.
	 *
	 * @return {Window|XRSession} The animation context.
	 */
	getContext() {

		return this._context;

	}

	/**
	 * Defines the context in which `requestAnimationFrame()` is executed.
	 *
	 * @param {Window|XRSession} context - The context to set.
	 */
	setContext( context ) {

		this._context = context;

	}

	/**
	 * Frees all internal resources and stops the animation loop.
	 */
	dispose() {

		this.stop();

	}

}

export default Animation;

Directory Contents

Dirs: 2 × Files: 50
Name Size Perms Modified Actions
extras DIR
- drwxr-xr-x 2025-03-28 11:04:39
Edit Download
nodes DIR
- drwxr-xr-x 2025-03-28 11:04:38
Edit Download
2.48 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
2.39 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
15.92 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
5.20 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.11 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.01 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
6.81 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.26 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.50 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.71 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.74 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
5.46 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
1.53 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
740 B lrw-r--r-- 2025-03-28 11:04:38
Edit Download
283 B lrw-r--r-- 2025-03-28 11:04:38
Edit Download
2.61 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
1.28 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
7.19 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
998 B lrw-r--r-- 2025-03-28 11:04:38
Edit Download
3.73 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
1.34 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
484 B lrw-r--r-- 2025-03-28 11:04:38
Edit Download
11.50 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
4.27 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.72 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
2.33 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
458 B lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.13 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
4.86 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
2.53 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
74.32 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
5.37 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
10.09 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.27 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
17.04 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
5.19 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
806 B lrw-r--r-- 2025-03-28 11:04:39
Edit Download
3.65 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
769 B lrw-r--r-- 2025-03-28 11:04:39
Edit Download
718 B lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.44 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.52 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.26 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
10.13 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.61 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
5.83 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
561 B lrw-r--r-- 2025-03-28 11:04:39
Edit Download
10.22 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
27.59 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.72 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).