@shapediver/viewer.rendering-engine.animation-frame-engine 3.3.4 → 3.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapediver/viewer.rendering-engine.animation-frame-engine",
3
- "version": "3.3.4",
3
+ "version": "3.3.6",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "Michael Oppitz <michael@shapediver.com>",
@@ -10,11 +10,10 @@
10
10
  "test": "__tests__"
11
11
  },
12
12
  "files": [
13
- "dist",
14
- "src",
15
13
  "package.json",
14
+ "dist/",
16
15
  "README.md",
17
- "tsconfig.json"
16
+ "LICENSE"
18
17
  ],
19
18
  "publishConfig": {
20
19
  "access": "public"
@@ -39,10 +38,10 @@
39
38
  "testEnvironment": "node"
40
39
  },
41
40
  "dependencies": {
42
- "@shapediver/viewer.rendering-engine.animation-engine": "3.3.4",
43
- "@shapediver/viewer.shared.services": "3.3.4",
41
+ "@shapediver/viewer.rendering-engine.animation-engine": "3.3.6",
42
+ "@shapediver/viewer.shared.services": "3.3.6",
44
43
  "@tweenjs/tween.js": "^18.6.4",
45
44
  "gl-matrix": "3.3.0"
46
45
  },
47
- "gitHead": "8193da527b4e3fc4d90181018bd60d6ac70be3e8"
46
+ "gitHead": "13aea937b128a001e6e93be300674c4a04624c29"
48
47
  }
@@ -1,74 +0,0 @@
1
- import { AnimationFrameCallback, IAnimationFrameEngine } from "../interfaces/IAnimationFrameEngine";
2
- import * as TWEEN from '@tweenjs/tween.js'
3
- import { UuidGenerator } from "@shapediver/viewer.shared.services";
4
- import { AnimationEngine } from "@shapediver/viewer.rendering-engine.animation-engine";
5
-
6
- export class AnimationFrameEngine implements IAnimationFrameEngine {
7
- // #region Properties (5)
8
-
9
- readonly #animationEngine: AnimationEngine = AnimationEngine.instance;
10
- readonly #uuidGenerator: UuidGenerator = UuidGenerator.instance;
11
-
12
- private static _instance: AnimationFrameEngine;
13
-
14
- private _animationFrameCallbacks: {
15
- [key: string]: AnimationFrameCallback
16
- } = {};
17
- private _lastTime: number = 0;
18
-
19
- // #endregion Properties (5)
20
-
21
- // #region Constructors (1)
22
-
23
- private constructor() {
24
- this.animate(0);
25
- }
26
-
27
- // #endregion Constructors (1)
28
-
29
- // #region Public Static Accessors (1)
30
-
31
- public static get instance() {
32
- return this._instance || (this._instance = new this());
33
- }
34
-
35
- // #endregion Public Static Accessors (1)
36
-
37
- // #region Public Methods (2)
38
-
39
- public addAnimationFrameCallback(cb: AnimationFrameCallback): string {
40
- const token = this.#uuidGenerator.create();
41
- this._animationFrameCallbacks[token] = cb;
42
-
43
- return token;
44
- }
45
-
46
- public removeAnimationFrameCallback(token: string): boolean {
47
- if(!this._animationFrameCallbacks[token]) return false;
48
-
49
- delete this._animationFrameCallbacks[token];
50
- (<any>this._animationFrameCallbacks[token]) = undefined;
51
-
52
- return true;
53
- }
54
-
55
- // #endregion Public Methods (2)
56
-
57
- // #region Private Methods (1)
58
-
59
- private animate(time: number): void {
60
- // animation loop - part 2: requesting and timings
61
- requestAnimationFrame((time: number) => this.animate(time));
62
- TWEEN.update(time);
63
-
64
- const deltaTime = time - this._lastTime < 0 ? 0 : time - this._lastTime;
65
- this._lastTime = time;
66
-
67
- const runningAnimation = this.#animationEngine.update(deltaTime);
68
-
69
- for(let a in this._animationFrameCallbacks)
70
- this._animationFrameCallbacks[a](time, deltaTime, runningAnimation);
71
- }
72
-
73
- // #endregion Private Methods (1)
74
- }
package/src/index.ts DELETED
@@ -1,7 +0,0 @@
1
- import { AnimationFrameEngine } from "./implementation/AnimationFrameEngine";
2
- import { IAnimationFrameEngine } from "./interfaces/IAnimationFrameEngine";
3
-
4
- export {
5
- IAnimationFrameEngine,
6
- AnimationFrameEngine
7
- }
@@ -1,19 +0,0 @@
1
- export type AnimationFrameCallback = (time: number, deltaTime: number, runningAnimation: boolean) => void;
2
-
3
- export interface IAnimationFrameEngine {
4
- /**
5
- * Add a callback that is called whenever the requestAnimationFrame is triggered.
6
- * The callback is supplied with the current time (passthrough from requestAnimationFrame), the deltaTime (delta from last call) and if an animation is currently running.
7
- * A token is returned to be able to remove this callback again {@link removeAnimationFrameCallback}.
8
- *
9
- * @param cb
10
- */
11
- addAnimationFrameCallback(cb: AnimationFrameCallback): string;
12
-
13
- /**
14
- * Remove a callback that has been registered with {@link addAnimationFrameCallback} via the returned token.
15
- *
16
- * @param token
17
- */
18
- removeAnimationFrameCallback(token: string): boolean;
19
- }
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "include": [
4
- "./**/*.ts"
5
- ],
6
- "compilerOptions": {
7
- "rootDir": "src",
8
- "outDir": "dist"
9
- },
10
- "exclude": [
11
- "__tests__",
12
- "node_modules",
13
- "dist",
14
- "dist-dev",
15
- "dist-prod"
16
- ]
17
- }