@urso/core 0.3.5 → 0.3.9
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/build/js/index.js +1 -1
- package/package.json +1 -1
- package/src/js/components/debug/_info.js +2 -1
- package/src/js/components/debug/controller.js +1 -1
- package/src/js/components/debug/template.js +22 -0
- package/src/js/components/debug/timescale.js +60 -0
- package/src/js/components/stateDriven/controller.js +33 -11
- package/src/js/extra/_info.js +1 -0
- package/src/js/extra/browserEvents.js +7 -1
- package/src/js/extra/setTimeout.js +7 -0
- package/src/js/lib/cache.js +7 -0
- package/src/js/lib/loader.js +18 -12
- package/src/js/lib/math.js +15 -0
- package/src/js/modules/assets/models/image.js +0 -1
- package/src/js/modules/assets/models/spine.js +6 -0
- package/src/js/modules/assets/service.js +29 -3
- package/src/js/modules/objects/models/slider.js +52 -28
- package/src/js/modules/objects/models/spine.js +10 -3
- package/src/js/modules/objects/proxy.js +4 -1
- package/src/js/modules/observer/events.js +3 -1
- package/src/js/modules/scenes/controller.js +8 -0
- package/src/js/modules/scenes/pixiWrapper.js +9 -1
- package/src/js/modules/scenes/resolutions.js +8 -0
- package/src/js/modules/scenes/service.js +11 -3
- package/src/js/modules/statesManager/controller.js +42 -12
|
@@ -71,7 +71,7 @@ class ModulesScenesPixiWrapper {
|
|
|
71
71
|
|
|
72
72
|
_getDeltaTime() {
|
|
73
73
|
let newTime = Date.now();
|
|
74
|
-
let deltaTime = newTime - this._loopLastCall;
|
|
74
|
+
let deltaTime = Urso.scenes.timeScale * (newTime - this._loopLastCall);
|
|
75
75
|
this._loopLastCall = newTime;
|
|
76
76
|
|
|
77
77
|
return Urso.math.intMakeBetween(deltaTime, 0, 1000);
|
|
@@ -114,6 +114,14 @@ class ModulesScenesPixiWrapper {
|
|
|
114
114
|
this.renderer.resize(width, height);
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
+
hideCanvas() {
|
|
118
|
+
this.renderer.view.style.display = 'none';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
showCanvas() {
|
|
122
|
+
this.renderer.view.style.display = '';
|
|
123
|
+
}
|
|
124
|
+
|
|
117
125
|
setWorldScale(x, y) {
|
|
118
126
|
this.world.scale.x = x;
|
|
119
127
|
this.world.scale.y = y;
|
|
@@ -8,6 +8,7 @@ class ModulesScenesResolutions {
|
|
|
8
8
|
this._currentOrientation = null;
|
|
9
9
|
|
|
10
10
|
this.refreshSceneSize = this.refreshSceneSize.bind(this);
|
|
11
|
+
this.preResize = this.preResize.bind(this);
|
|
11
12
|
this.refreshSceneSize();
|
|
12
13
|
|
|
13
14
|
//TODO optimization (performance)
|
|
@@ -16,6 +17,7 @@ class ModulesScenesResolutions {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
_subscribeOnce() {
|
|
20
|
+
this.addListener(Urso.events.EXTRA_BROWSEREVENTS_WINDOW_PRE_RESIZE, this.preResize, true);
|
|
19
21
|
this.addListener(Urso.events.EXTRA_BROWSEREVENTS_WINDOW_RESIZE, this.refreshSceneSize, true);
|
|
20
22
|
this.addListener(Urso.events.MODULES_SCENES_NEW_SCENE_INIT, this.refreshSceneSize, true);
|
|
21
23
|
}
|
|
@@ -24,6 +26,11 @@ class ModulesScenesResolutions {
|
|
|
24
26
|
return this._templateSize;
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
preResize() {
|
|
30
|
+
if (Urso.helper.mobileAndTabletCheck())
|
|
31
|
+
this.getInstance('PixiWrapper').hideCanvas();
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
refreshSceneSize() {
|
|
28
35
|
let windowSize = this._getWindowSize();
|
|
29
36
|
let orientation = this._getOrientation(windowSize);
|
|
@@ -155,6 +162,7 @@ class ModulesScenesResolutions {
|
|
|
155
162
|
height: ~~(resolution.height * maxResolutionFactor)
|
|
156
163
|
};
|
|
157
164
|
|
|
165
|
+
this.getInstance('PixiWrapper').showCanvas();
|
|
158
166
|
this.getInstance('PixiWrapper').resize(canvasSize.width, canvasSize.height);
|
|
159
167
|
this.getInstance('PixiWrapper').setWorldScale(canvasSize.width / this._templateSize.width, canvasSize.height / this._templateSize.height);
|
|
160
168
|
this.getInstance('PixiWrapper').setCanvasWidth(resolution.width / dp);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
class ModulesScenesService {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.singleton = true;
|
|
4
|
+
|
|
4
5
|
this._displayInProgress = false;
|
|
5
6
|
this._currentSceneName = false;
|
|
6
7
|
this._currentSceneTemplate = false;
|
|
7
8
|
this._sceneModel;
|
|
8
9
|
|
|
10
|
+
this.timeScale = 1;
|
|
11
|
+
|
|
9
12
|
this._pixiWrapper;
|
|
10
13
|
|
|
11
14
|
this.init();
|
|
@@ -18,6 +21,11 @@ class ModulesScenesService {
|
|
|
18
21
|
this._pixiWrapper.init();
|
|
19
22
|
}
|
|
20
23
|
|
|
24
|
+
setTimeScale(value) {
|
|
25
|
+
this.timeScale = value;
|
|
26
|
+
gsap.globalTimeline.timeScale(this.timeScale);
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
display(name) {
|
|
22
30
|
if (this._displayInProgress) {
|
|
23
31
|
console.warn("Scenes.display is busy ", this._currentSceneName);
|
|
@@ -62,9 +70,9 @@ class ModulesScenesService {
|
|
|
62
70
|
Urso.assets.preload(this._currentSceneTemplate.assets, this._assetsLoadedHandler);
|
|
63
71
|
|
|
64
72
|
}
|
|
65
|
-
|
|
66
|
-
loadUpdate(loadProgress){
|
|
67
|
-
if(!this._sceneModel)
|
|
73
|
+
|
|
74
|
+
loadUpdate(loadProgress) {
|
|
75
|
+
if (!this._sceneModel)
|
|
68
76
|
return;
|
|
69
77
|
this._sceneModel.loadUpdate(loadProgress);
|
|
70
78
|
this.emit(Urso.events.MODULES_ASSETS_LOAD_PROGRESS, loadProgress);
|
|
@@ -5,6 +5,8 @@ class ModulesStatesManagerController {
|
|
|
5
5
|
this._configStates;
|
|
6
6
|
this._currentState;
|
|
7
7
|
this._started = false;
|
|
8
|
+
this._paused = false;
|
|
9
|
+
this._pauseNeedResume = false;
|
|
8
10
|
|
|
9
11
|
this.statesGuards = this.getInstance('FunctionsStorage');
|
|
10
12
|
this.actionsGuards = this.getInstance('FunctionsStorage');
|
|
@@ -12,7 +14,7 @@ class ModulesStatesManagerController {
|
|
|
12
14
|
this.actionsTerminations = this.getInstance('FunctionsStorage');
|
|
13
15
|
|
|
14
16
|
|
|
15
|
-
this._iterator
|
|
17
|
+
this._iterator; //will be defined after start
|
|
16
18
|
this._nextState = this._nextState.bind(this);
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -20,14 +22,29 @@ class ModulesStatesManagerController {
|
|
|
20
22
|
if (this._started)
|
|
21
23
|
return;
|
|
22
24
|
|
|
25
|
+
this._currentState = null;
|
|
26
|
+
this._iterator = this._iteratorConstructor();
|
|
23
27
|
this._started = true;
|
|
24
28
|
this._configStates = this.getInstance('ConfigStates').get();
|
|
25
29
|
this._nextState();
|
|
26
30
|
}
|
|
27
31
|
|
|
32
|
+
pause() {
|
|
33
|
+
this._paused = true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
resume() {
|
|
37
|
+
this._paused = false;
|
|
38
|
+
|
|
39
|
+
if (this._pauseNeedResume) {
|
|
40
|
+
this._pauseNeedResume = false;
|
|
41
|
+
this._nextState();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
28
45
|
_iteratorConstructor() {
|
|
29
46
|
let nextIndex = 0;
|
|
30
|
-
|
|
47
|
+
|
|
31
48
|
|
|
32
49
|
const getNextStateByOrder = () => {
|
|
33
50
|
let statesArray = Object.keys(this._configStates);
|
|
@@ -75,6 +92,11 @@ class ModulesStatesManagerController {
|
|
|
75
92
|
}
|
|
76
93
|
|
|
77
94
|
_nextState() {
|
|
95
|
+
if (this._paused) {
|
|
96
|
+
this._pauseNeedResume = true;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
78
100
|
this._currentState = this._iterator.next();
|
|
79
101
|
|
|
80
102
|
this.emit(Urso.events.MODULES_STATES_MANAGER_STATE_CHANGE, this._currentState);
|
|
@@ -92,46 +114,54 @@ class ModulesStatesManagerController {
|
|
|
92
114
|
}
|
|
93
115
|
|
|
94
116
|
//actions guards
|
|
95
|
-
addActionGuard(key, guard) {
|
|
117
|
+
addActionGuard = (key, guard) => {
|
|
96
118
|
this.actionsGuards.add(key, guard, true);
|
|
97
119
|
}
|
|
98
120
|
|
|
99
|
-
checkActionGuard(key) {
|
|
121
|
+
checkActionGuard = (key) => {
|
|
100
122
|
return this.actionsGuards.checkGuard(key);
|
|
101
123
|
}
|
|
102
124
|
|
|
103
|
-
removeActionGuard(key, guard) {
|
|
125
|
+
removeActionGuard = (key, guard) => {
|
|
104
126
|
this.actionsGuards.remove(key, guard);
|
|
105
127
|
}
|
|
106
128
|
|
|
107
129
|
//actions runs
|
|
108
|
-
addActionRun(key, runFunction) {
|
|
130
|
+
addActionRun = (key, runFunction) => {
|
|
109
131
|
this.actionsRuns.add(key, runFunction);
|
|
110
132
|
}
|
|
111
133
|
|
|
112
|
-
runAction(key, onFinishCallback) {
|
|
134
|
+
runAction = (key, onFinishCallback) => {
|
|
113
135
|
this.actionsRuns.runAndCallbackOnFinish(key, onFinishCallback);
|
|
114
136
|
}
|
|
115
137
|
|
|
138
|
+
removeActionRun = (key, runFunction) => {
|
|
139
|
+
this.actionsRuns.remove(key, runFunction);
|
|
140
|
+
}
|
|
141
|
+
|
|
116
142
|
//actions terminations
|
|
117
|
-
addActionTerminate(key, terminateFunction) {
|
|
143
|
+
addActionTerminate = (key, terminateFunction) => {
|
|
118
144
|
this.actionsTerminations.add(key, terminateFunction);
|
|
119
145
|
}
|
|
120
146
|
|
|
121
|
-
terminateAction(key) {
|
|
147
|
+
terminateAction = (key) => {
|
|
122
148
|
this.actionsTerminations.run(key);
|
|
123
149
|
}
|
|
124
150
|
|
|
151
|
+
removeActionTerminate = (key, terminateFunction) => {
|
|
152
|
+
this.actionsTerminations.remove(key, terminateFunction);
|
|
153
|
+
}
|
|
154
|
+
|
|
125
155
|
//states guards
|
|
126
|
-
setStateGuard(key, guard) {
|
|
156
|
+
setStateGuard = (key, guard) => {
|
|
127
157
|
this.statesGuards.add(key, guard, true);
|
|
128
158
|
}
|
|
129
159
|
|
|
130
|
-
checkStateGuard(key) {
|
|
160
|
+
checkStateGuard = (key) => {
|
|
131
161
|
return this.statesGuards.checkGuard(key);
|
|
132
162
|
}
|
|
133
163
|
|
|
134
|
-
removeStateGuard(key, guard) {
|
|
164
|
+
removeStateGuard = (key, guard) => {
|
|
135
165
|
this.statesGuards.remove(key, guard);
|
|
136
166
|
}
|
|
137
167
|
|