three-stdlib 2.21.1 → 2.21.2
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/misc/Timer.cjs.js +1 -0
- package/misc/Timer.d.ts +26 -0
- package/misc/Timer.js +120 -0
- package/package.json +1 -1
- package/renderers/CSS2DRenderer.js +4 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var i=e(require("@babel/runtime/helpers/defineProperty"));function t(){!1===document.hidden&&this.reset()}exports.Timer=class{constructor(){i.default(this,"_previousTime",void 0),i.default(this,"_currentTime",void 0),i.default(this,"_delta",void 0),i.default(this,"_elapsed",void 0),i.default(this,"_timescale",void 0),i.default(this,"_useFixedDelta",void 0),i.default(this,"_fixedDelta",void 0),i.default(this,"_usePageVisibilityAPI",void 0),i.default(this,"_pageVisibilityHandler",void 0),this._previousTime=0,this._currentTime=0,this._delta=0,this._elapsed=0,this._timescale=1,this._useFixedDelta=!1,this._fixedDelta=16.67,this._usePageVisibilityAPI="undefined"!=typeof document&&void 0!==document.hidden}connect(){return this._usePageVisibilityAPI&&(this._pageVisibilityHandler=t.bind(this),document.addEventListener("visibilitychange",this._pageVisibilityHandler,!1)),this}dispose(){return this._usePageVisibilityAPI&&this._pageVisibilityHandler&&document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this}disableFixedDelta(){return this._useFixedDelta=!1,this}enableFixedDelta(){return this._useFixedDelta=!0,this}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getFixedDelta(){return this._fixedDelta/1e3}getTimescale(){return this._timescale}reset(){return this._currentTime=this._now(),this}setFixedDelta(e){return this._fixedDelta=1e3*e,this}setTimescale(e){return this._timescale=e,this}update(){return!0===this._useFixedDelta?this._delta=this._fixedDelta:(this._previousTime=this._currentTime,this._currentTime=this._now(),this._delta=this._currentTime-this._previousTime),this._delta*=this._timescale,this._elapsed+=this._delta,this}_now(){return("undefined"==typeof performance?Date:performance).now()}};
|
package/misc/Timer.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare class Timer {
|
|
2
|
+
private _previousTime;
|
|
3
|
+
private _currentTime;
|
|
4
|
+
private _delta;
|
|
5
|
+
private _elapsed;
|
|
6
|
+
private _timescale;
|
|
7
|
+
private _useFixedDelta;
|
|
8
|
+
private _fixedDelta;
|
|
9
|
+
private _usePageVisibilityAPI;
|
|
10
|
+
private _pageVisibilityHandler;
|
|
11
|
+
constructor();
|
|
12
|
+
connect(): this;
|
|
13
|
+
dispose(): this;
|
|
14
|
+
disableFixedDelta(): this;
|
|
15
|
+
enableFixedDelta(): this;
|
|
16
|
+
getDelta(): number;
|
|
17
|
+
getElapsed(): number;
|
|
18
|
+
getFixedDelta(): number;
|
|
19
|
+
getTimescale(): number;
|
|
20
|
+
reset(): this;
|
|
21
|
+
setFixedDelta(fixedDelta: number): this;
|
|
22
|
+
setTimescale(timescale: number): this;
|
|
23
|
+
update(): this;
|
|
24
|
+
private _now;
|
|
25
|
+
}
|
|
26
|
+
export { Timer };
|
package/misc/Timer.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
|
|
3
|
+
class Timer {
|
|
4
|
+
constructor() {
|
|
5
|
+
_defineProperty(this, "_previousTime", void 0);
|
|
6
|
+
|
|
7
|
+
_defineProperty(this, "_currentTime", void 0);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "_delta", void 0);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "_elapsed", void 0);
|
|
12
|
+
|
|
13
|
+
_defineProperty(this, "_timescale", void 0);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "_useFixedDelta", void 0);
|
|
16
|
+
|
|
17
|
+
_defineProperty(this, "_fixedDelta", void 0);
|
|
18
|
+
|
|
19
|
+
_defineProperty(this, "_usePageVisibilityAPI", void 0);
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "_pageVisibilityHandler", void 0);
|
|
22
|
+
|
|
23
|
+
this._previousTime = 0;
|
|
24
|
+
this._currentTime = 0;
|
|
25
|
+
this._delta = 0;
|
|
26
|
+
this._elapsed = 0;
|
|
27
|
+
this._timescale = 1;
|
|
28
|
+
this._useFixedDelta = false;
|
|
29
|
+
this._fixedDelta = 16.67; // ms, corresponds to approx. 60 FPS
|
|
30
|
+
|
|
31
|
+
this._usePageVisibilityAPI = typeof document !== 'undefined' && document.hidden !== undefined;
|
|
32
|
+
} // https://github.com/mrdoob/three.js/issues/20575
|
|
33
|
+
// use Page Visibility API to avoid large time delta values
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
connect() {
|
|
37
|
+
if (this._usePageVisibilityAPI) {
|
|
38
|
+
this._pageVisibilityHandler = handleVisibilityChange.bind(this);
|
|
39
|
+
document.addEventListener('visibilitychange', this._pageVisibilityHandler, false);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
dispose() {
|
|
46
|
+
if (this._usePageVisibilityAPI && this._pageVisibilityHandler) {
|
|
47
|
+
document.removeEventListener('visibilitychange', this._pageVisibilityHandler);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
disableFixedDelta() {
|
|
54
|
+
this._useFixedDelta = false;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
enableFixedDelta() {
|
|
59
|
+
this._useFixedDelta = true;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getDelta() {
|
|
64
|
+
return this._delta / 1000;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getElapsed() {
|
|
68
|
+
return this._elapsed / 1000;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getFixedDelta() {
|
|
72
|
+
return this._fixedDelta / 1000;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getTimescale() {
|
|
76
|
+
return this._timescale;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
reset() {
|
|
80
|
+
this._currentTime = this._now();
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
setFixedDelta(fixedDelta) {
|
|
85
|
+
this._fixedDelta = fixedDelta * 1000;
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setTimescale(timescale) {
|
|
90
|
+
this._timescale = timescale;
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
update() {
|
|
95
|
+
if (this._useFixedDelta === true) {
|
|
96
|
+
this._delta = this._fixedDelta;
|
|
97
|
+
} else {
|
|
98
|
+
this._previousTime = this._currentTime;
|
|
99
|
+
this._currentTime = this._now();
|
|
100
|
+
this._delta = this._currentTime - this._previousTime;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this._delta *= this._timescale;
|
|
104
|
+
this._elapsed += this._delta; // _elapsed is the accumulation of all previous deltas
|
|
105
|
+
|
|
106
|
+
return this;
|
|
107
|
+
} // private
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
_now() {
|
|
111
|
+
return (typeof performance === 'undefined' ? Date : performance).now();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function handleVisibilityChange() {
|
|
117
|
+
if (document.hidden === false) this.reset();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { Timer };
|
package/package.json
CHANGED
|
@@ -59,7 +59,10 @@ class CSS2DRenderer {
|
|
|
59
59
|
|
|
60
60
|
this.render = function (scene, camera) {
|
|
61
61
|
if (scene.matrixWorldAutoUpdate === true || scene.autoUpdate === true) scene.updateMatrixWorld();
|
|
62
|
-
|
|
62
|
+
|
|
63
|
+
if (camera.parent === null && (camera.matrixWorldAutoUpdate == null || camera.matrixWorldAutoUpdate === true)) {
|
|
64
|
+
camera.updateMatrixWorld();
|
|
65
|
+
}
|
|
63
66
|
|
|
64
67
|
_viewMatrix.copy(camera.matrixWorldInverse);
|
|
65
68
|
|