@urso/core 0.3.11 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urso/core",
3
- "version": "0.3.11",
3
+ "version": "0.4.2",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -42,20 +42,20 @@ class ComponentsDeviceRotateController extends ComponentsBaseController {
42
42
  }
43
43
 
44
44
  get _showOnLandscape() {
45
- return !this._resolutionsConfig.find(resolution => resolution.orientation === 'landscape');
45
+ return !this._resolutionsConfig.find(resolution => resolution.orientation === Urso.device.ScreenOrientation.LANDSCAPE);
46
46
  }
47
47
 
48
48
  get _showOnPortrait() {
49
- return !this._resolutionsConfig.find(resolution => resolution.orientation === 'portrait');
49
+ return !this._resolutionsConfig.find(resolution => resolution.orientation === Urso.device.ScreenOrientation.PORTRAIT);
50
50
  }
51
51
 
52
52
  get _isPortrait() {
53
- return this._orientation === 'portrait';
53
+ return this._orientation === Urso.device.ScreenOrientation.PORTRAIT;
54
54
  }
55
55
 
56
56
  get _needShow() {
57
- return (this._orientation === 'portrait' && this._showOnPortrait) ||
58
- (this._orientation !== 'portrait' && this._showOnLandscape)
57
+ return (this._orientation === Urso.device.ScreenOrientation.PORTRAIT && this._showOnPortrait) ||
58
+ (this._orientation !== Urso.device.ScreenOrientation.PORTRAIT && this._showOnLandscape)
59
59
  }
60
60
 
61
61
  set _isVisible(needShowDiv) {
@@ -63,7 +63,7 @@ class ComponentsDeviceRotateController extends ComponentsBaseController {
63
63
  }
64
64
 
65
65
  _updateOrientation() {
66
- this._orientation = innerWidth > innerHeight ? 'landscape' : 'portrait';
66
+ this._orientation = innerWidth > innerHeight ? Urso.device.ScreenOrientation.LANDSCAPE : Urso.device.ScreenOrientation.PORTRAIT;
67
67
  }
68
68
 
69
69
  _updateVisibility() {
@@ -33,7 +33,7 @@ class ComponentsFullscreenAndroid {
33
33
  }
34
34
 
35
35
  _updateOrientation() {
36
- this._orientation = innerWidth > innerHeight ? 'landscape' : 'portrait';
36
+ this._orientation = innerWidth > innerHeight ? Urso.device.ScreenOrientation.LANDSCAPE : Urso.device.ScreenOrientation.PORTRAIT;
37
37
  }
38
38
 
39
39
  get isFullscreen() {
@@ -49,7 +49,7 @@ class ComponentsFullscreenAndroid {
49
49
  }
50
50
 
51
51
  get _isPortrait() {
52
- return this._orientation === 'portrait';
52
+ return this._orientation === Urso.device.ScreenOrientation.PORTRAIT;
53
53
  }
54
54
 
55
55
  get _needShowOnCurrentOrientation() {
@@ -58,11 +58,11 @@ class ComponentsFullscreenAndroid {
58
58
  }
59
59
 
60
60
  get _showOnLandscape() {
61
- return this._orientationsConfig.find(resolution => resolution.orientation === 'landscape');
61
+ return this._orientationsConfig.find(resolution => resolution.orientation === Urso.device.ScreenOrientation.LANDSCAPE);
62
62
  }
63
63
 
64
64
  get _showOnPortrait() {
65
- return this._orientationsConfig.find(resolution => resolution.orientation === 'portrait');
65
+ return this._orientationsConfig.find(resolution => resolution.orientation === Urso.device.ScreenOrientation.PORTRAIT);
66
66
  }
67
67
 
68
68
  set isVisible(needShowDiv) {
@@ -37,15 +37,15 @@ class ComponentsFullscreenController extends ComponentsBaseController {
37
37
  }
38
38
 
39
39
  get _showOnLandscape() {
40
- return this._resolutionsConfig.find(resolution => resolution.orientation === 'landscape');
40
+ return this._resolutionsConfig.find(resolution => resolution.orientation === Urso.device.ScreenOrientation.LANDSCAPE);
41
41
  }
42
42
 
43
43
  get _showOnPortrait() {
44
- return this._resolutionsConfig.find(resolution => resolution.orientation === 'portrait');
44
+ return this._resolutionsConfig.find(resolution => resolution.orientation === Urso.device.ScreenOrientation.PORTRAIT);
45
45
  }
46
46
 
47
47
  get _isPortrait() {
48
- return innerWidth > innerHeight ? 'portrait' : 'landscape';
48
+ return innerWidth > innerHeight ? Urso.device.ScreenOrientation.PORTRAIT : Urso.device.ScreenOrientation.LANDSCAPE;
49
49
  }
50
50
 
51
51
  get isFullscreen() {
@@ -55,7 +55,7 @@ class ComponentsFullscreenIos {
55
55
  }
56
56
 
57
57
  _updateOrientation() {
58
- this._orientation = innerWidth > innerHeight ? 'landscape' : 'portrait';
58
+ this._orientation = innerWidth > innerHeight ? Urso.device.ScreenOrientation.LANDSCAPE : Urso.device.ScreenOrientation.PORTRAIT;
59
59
  }
60
60
 
61
61
  _updateResize() {
@@ -68,7 +68,7 @@ class ComponentsFullscreenIos {
68
68
  }
69
69
 
70
70
  get _isPortrait() {
71
- return this._orientation === 'portrait';
71
+ return this._orientation === Urso.device.ScreenOrientation.PORTRAIT;
72
72
  }
73
73
 
74
74
  get _needShowOnCurrentOrientation() {
@@ -76,11 +76,11 @@ class ComponentsFullscreenIos {
76
76
  }
77
77
 
78
78
  get _showOnLandscape() {
79
- return this._orientationsConfig.find(resolution => resolution.orientation === 'landscape');
79
+ return this._orientationsConfig.find(resolution => resolution.orientation === Urso.device.ScreenOrientation.LANDSCAPE);
80
80
  }
81
81
 
82
82
  get _showOnPortrait() {
83
- return this._orientationsConfig.find(resolution => resolution.orientation === 'portrait');
83
+ return this._orientationsConfig.find(resolution => resolution.orientation === Urso.device.ScreenOrientation.PORTRAIT);
84
84
  }
85
85
 
86
86
  set isVisible(needShowDiv) {
@@ -1,48 +1,44 @@
1
1
  // Class for creating multi inheritance.
2
- class LibComposition
3
- {
2
+ class LibComposition {
4
3
  // Inherit method to create base classes.
5
- static inherit(..._bases)
6
- {
4
+ static inherit(..._bases) {
7
5
  class classes {
8
6
 
9
7
  // The base classes
10
- get base() { return _bases; }
8
+ get base() { return _bases; }
11
9
 
12
- constructor(..._args)
13
- {
10
+ constructor(..._args) {
14
11
  let index = 0;
15
12
 
16
- for (let b of this.base)
17
- {
13
+ for (let b of this.base) {
18
14
  let obj = new b(_args[index++]);
19
- LibComposition.copy(this, obj);
15
+ LibComposition.copy(this, obj);
20
16
  }
21
17
  }
22
-
18
+
23
19
  }
24
20
 
25
21
  // Copy over properties and methods
26
- for (let base of _bases)
27
- {
28
- LibComposition.copy(classes, base);
29
- LibComposition.copy(classes.prototype, base.prototype);
22
+ for (let base of _bases) {
23
+ LibComposition.copy(classes, base);
24
+ LibComposition.copy(classes.prototype, base.prototype, true);
30
25
  }
31
26
 
32
27
  return classes;
33
28
  }
34
29
 
35
30
  // Copies the properties from one class to another
36
- static copy(_target, _source)
37
- {
38
- for (let key of Reflect.ownKeys(_source))
39
- {
40
- if (key !== "constructor" && key !== "prototype" && key !== "name")
41
- {
42
- let desc = Object.getOwnPropertyDescriptor(_source, key);
43
- Object.defineProperty(_target, key, desc);
44
- }
45
- }
31
+ static copy(_target, _source, protoFlag) {
32
+ for (let key of Reflect.ownKeys(_source)) {
33
+ if (key !== "constructor" && key !== "prototype" && key !== "name") {
34
+ let desc = Object.getOwnPropertyDescriptor(_source, key);
35
+ Object.defineProperty(_target, key, desc);
36
+ }
37
+ }
38
+
39
+ if (protoFlag && Object.getPrototypeOf(_source) !== Object.prototype) {
40
+ LibComposition.copy(_target, Object.getPrototypeOf(_source));
41
+ }
46
42
  }
47
43
  }
48
44
 
@@ -50,7 +46,7 @@ module.exports = LibComposition;
50
46
 
51
47
 
52
48
  /**
53
- *
49
+ *
54
50
  example:
55
51
 
56
52
 
@@ -476,6 +476,16 @@ LibDevice = function () {
476
476
  */
477
477
  this.fullscreenKeyboard = false;
478
478
 
479
+ /**
480
+ * Enum for possible screen orientations.
481
+ * @readonly
482
+ * @enum {string}
483
+ */
484
+ this.ScreenOrientation = {
485
+ LANDSCAPE: 'landscape',
486
+ PORTRAIT: 'portrait'
487
+ };
488
+
479
489
  };
480
490
 
481
491
  // Device is really a singleton/static entity; instantiate it
@@ -2,6 +2,8 @@ class ModulesAssetsConfig {
2
2
  constructor() {
3
3
  this.singleton = true;
4
4
 
5
+ this.defaultQualityFactor = 1;
6
+
5
7
  /**
6
8
  * quality settings for resource loading selection
7
9
  */
@@ -18,7 +18,14 @@ class ModulesAssetsController {
18
18
  * Current quality getter
19
19
  */
20
20
  getQuality() {
21
- this.getInstance('Service').getQuality();
21
+ return this.getInstance('Service').getQuality();
22
+ }
23
+
24
+ /**
25
+ * Current asset resolution
26
+ */
27
+ getCurrentResolution() {
28
+ return this.getInstance('Service').getCurrentResolution();
22
29
  }
23
30
 
24
31
  /**
@@ -160,10 +160,13 @@ class ModulesAssetsService {
160
160
  }
161
161
  }
162
162
 
163
- _processLoadedImage(assetModel) {
164
- const { qualityFactors } = this.getInstance('Config');
163
+ getCurrentResolution() {
164
+ const { qualityFactors, defaultQualityFactor } = this.getInstance('Config');
165
+ return qualityFactors[this._currentQuality] || defaultQualityFactor || 1;
166
+ }
165
167
 
166
- const resolution = qualityFactors[this._currentQuality] || 1;
168
+ _processLoadedImage(assetModel) {
169
+ const resolution = this.getCurrentResolution();
167
170
 
168
171
  const assetKey = assetModel.key;
169
172
  //textures cache
@@ -1,3 +1,6 @@
1
+ const MODES_NAMESPACE = 'modifications';
2
+ const MIXINS_NAMESPACE = 'mixins';
3
+
1
4
  class ModulesInstancesController {
2
5
  constructor() {
3
6
  this._modes = [];
@@ -181,10 +184,18 @@ class ModulesInstancesController {
181
184
  _checkPathExist(entitiesArray, noModes) {
182
185
  let currentTestObject = window;
183
186
  let testMode;
187
+ let mixins = [];
184
188
 
185
189
  for (let entitiesIndex = 0; entitiesIndex < entitiesArray.length; entitiesIndex++) {
186
- if (!noModes && this._modes && entitiesIndex === entitiesArray.length - 1)
187
- testMode = this._checkPathWithModes(currentTestObject, entitiesArray, entitiesIndex);
190
+ const lastElementModesCondition = !noModes && this._modes && entitiesIndex === entitiesArray.length - 1;
191
+
192
+ //get path modification
193
+ if (lastElementModesCondition && currentTestObject[MODES_NAMESPACE])
194
+ testMode = this._checkPathWithModes(currentTestObject[MODES_NAMESPACE], entitiesArray, entitiesIndex);
195
+
196
+ //get path mixins
197
+ if (lastElementModesCondition && currentTestObject[MIXINS_NAMESPACE])
198
+ mixins = this._getMixins(currentTestObject[MIXINS_NAMESPACE], entitiesArray, entitiesIndex);
188
199
 
189
200
  if (testMode)
190
201
  currentTestObject = testMode;
@@ -194,6 +205,13 @@ class ModulesInstancesController {
194
205
  return false;
195
206
  }
196
207
 
208
+ //mixins
209
+ mixins.forEach((mixin) => {
210
+ //use this mixin constructions:
211
+ //const ComponentsMixinEntitie = (superclass) => class extends superclass { ... }
212
+ currentTestObject = mixin(currentTestObject);
213
+ })
214
+
197
215
  return currentTestObject;
198
216
  }
199
217
 
@@ -214,6 +232,20 @@ class ModulesInstancesController {
214
232
 
215
233
  return false;
216
234
  }
235
+
236
+ _getMixins(currentTestObject, entitiesArray, entitiesIndex) {
237
+ const mixins = [];
238
+
239
+ for (let mode of this._modes) {
240
+ const capMode = Urso.helper.capitaliseFirstLetter(mode);
241
+
242
+ if (currentTestObject[capMode] && currentTestObject[capMode][entitiesArray[entitiesIndex]]) {
243
+ mixins.push(currentTestObject[capMode][entitiesArray[entitiesIndex]]);
244
+ }
245
+ }
246
+
247
+ return mixins;
248
+ }
217
249
  }
218
250
 
219
251
  module.exports = ModulesInstancesController;
@@ -12,8 +12,13 @@ class ModulesObjectsBaseModel {
12
12
  this._baseObject = null; //link to pixi object
13
13
  this._uid = Urso.helper.recursiveGet('_uid', params, false); //will setup on create
14
14
  this._templatePath = false;
15
+ this._parsed = false;
15
16
  }
16
17
 
18
+ /**
19
+ * setup params to object model
20
+ * @param {Object} params
21
+ */
17
22
  setupParams(params) {
18
23
  this.type = Urso.helper.recursiveGet('type', params, null);
19
24
 
@@ -11,16 +11,17 @@ class ModulesObjectsController {
11
11
  this._applyClassesToWorld = this._applyClassesToWorld.bind(this);
12
12
  };
13
13
 
14
- create(objects, parent, doNotRefreshStylesFlag) { //TODO parse template for assets and objects (groups, components)
14
+ create(objects, parent, doNotRefreshStylesFlag) {
15
15
  let result;
16
16
 
17
17
  if (Array.isArray(objects)) {
18
18
  result = [];
19
+
19
20
  for (const object of objects) {
20
- result.push(this.getInstance('Create').add(object, parent));
21
+ result.push(this._createSingleObject(object, parent, doNotRefreshStylesFlag));
21
22
  }
22
23
  } else
23
- result = this.getInstance('Create').add(objects, parent);
24
+ result = this._createSingleObject(objects, parent, doNotRefreshStylesFlag);
24
25
 
25
26
  if (!doNotRefreshStylesFlag)
26
27
  this.refreshStyles(parent);
@@ -28,6 +29,15 @@ class ModulesObjectsController {
28
29
  return result;
29
30
  }
30
31
 
32
+ _createSingleObject(object, parent, doNotRefreshStylesFlag) {
33
+ //parse template for assets and objects (groups, components)
34
+ if (!object._parsed) { //todo only for objects, contains components && groups in future
35
+ return Urso.scenes.addObject(object, parent, doNotRefreshStylesFlag);
36
+ }
37
+
38
+ return this.getInstance('Create').add(object, parent);
39
+ }
40
+
31
41
  find(selector) {
32
42
  return this.getInstance('Find').do(selector);
33
43
  }
@@ -6,6 +6,10 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
6
6
  this._addBaseObject();
7
7
  }
8
8
 
9
+ /**
10
+ * setup params to object model
11
+ * @param {Object} params
12
+ */
9
13
  setupParams(params) {
10
14
  super.setupParams(params);
11
15
 
@@ -21,27 +25,98 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
21
25
  params.animation = this.animation; //we redefine original property here
22
26
  }
23
27
 
28
+ /**
29
+ * play spine animation
30
+ * @param {String} animationName
31
+ * @param {Boolean} [loopFlag]
32
+ * @param {Number} [track] - you can define track number for current animation
33
+ */
24
34
  play(animationName, loopFlag = false, track = 0) {
25
35
  this._baseObject.state.setAnimation(track, animationName, loopFlag);
26
36
  }
27
37
 
28
- addToSlot(object, slotName) {
29
- const spine = this._baseObject;
30
- const slotIndex = spine.spineData.slots.findIndex(({ name }) => name === slotName);
31
- const currentSlot = spine.slotContainers[slotIndex];
38
+ /**
39
+ * play spine animation and execute function after animation completes
40
+ * @param {String} animation - name of the animation to be played
41
+ * @param {Function} func - function to be executed
42
+ */
43
+ playAndThen(animation, func) {
44
+ this.playInSequenceAndThen([animation], func);
45
+ }
32
46
 
33
- if (currentSlot) {
34
- object._baseObject.scale.y = -1;
47
+ /**
48
+ * play spine animations in sequence
49
+ * @param {String[]} animations - names of the animations to be played
50
+ */
51
+ playInSequence(animations) {
52
+ this.stop();
53
+ const defaultTrack = 0;
54
+ animations.forEach(e => this._baseObject.state.addAnimation(defaultTrack, e));
55
+ }
35
56
 
36
- Urso.objects.removeChild(object.parent, object)
37
- currentSlot.addChild(object._baseObject);
38
- } else {
39
- Urso.logger.warn('ModulesObjectsModelsSpine addToSlot error: no spine slot ' + slotName);
40
- }
57
+ /**
58
+ * play spine animations in sequence and execute function after last animation completes
59
+ * @param {String[]} animations - names of the animations to be played
60
+ * @param {Function} func - function to be executed
61
+ */
62
+ playInSequenceAndThen(animations, func) {
63
+ let animationsLeft = animations.length;
64
+ let removeSelf = () => { };
65
+ let completer = {
66
+ complete: () => {
67
+ if (--animationsLeft === 0) {
68
+ func();
69
+ removeSelf();
70
+ }
71
+ }
72
+ };
73
+ removeSelf = () => this._baseObject.state.removeListener(completer);
74
+ this._baseObject.state.addListener(completer);
75
+ this.playInSequence(animations);
41
76
  }
42
77
 
43
78
  /**
44
- *
79
+ * stop track animation
80
+ * @param {Number} [track] - you can define track number to stop
81
+ */
82
+ stopTrack(track) {
83
+ this._baseObject.state.clearTrack(track);
84
+ }
85
+
86
+ /**
87
+ * stop all animations
88
+ */
89
+ stop() {
90
+ this._baseObject.state.clearTracks();
91
+ }
92
+
93
+ /**
94
+ * reset all animations
95
+ */
96
+ reset() {
97
+ this._baseObject.state.setEmptyAnimations();
98
+ }
99
+
100
+ /**
101
+ * add object to spine slot
102
+ * @param {String} slotName
103
+ * @param {Object} object - created by engine object
104
+ */
105
+ addToSlot(slotName, object) {
106
+ this._addToSlot(slotName, object, false);
107
+ }
108
+
109
+ /**
110
+ * replace spine slot with new object
111
+ * @param {String} slotName
112
+ * @param {Object} object - created by engine object
113
+ */
114
+ replaceSlotWith(slotName, object) {
115
+ this._addToSlot(slotName, object, true);
116
+ }
117
+
118
+ /**
119
+ * set/update animation config
45
120
  * @param {*} config
46
121
  * @param {boolean} [noObjectCreate] dont use this flag out of core
47
122
  *
@@ -59,11 +134,18 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
59
134
  this._baseObject.state.timeScale = config.timeScale;*/ //deprecated - now we use getTimeScale getter
60
135
 
61
136
  if (config.onComplete) {
137
+ if (this._baseObject.state.listeners.length !== 0) {
138
+ Urso.logger.warn('ModulesObjectsModelsSpine setAnimationConfig warning: animation state listeners will be cleared');
139
+ }
62
140
  this._baseObject.state.clearListeners();
63
141
  this._baseObject.state.addListener({ complete: this.animation.onComplete });
64
142
  }
65
143
  }
66
144
 
145
+ /**
146
+ * system function
147
+ * add object to pixi tree
148
+ */
67
149
  _addBaseObject() {
68
150
  let spineAsset = Urso.cache.getSpine(this.assetKey);
69
151
 
@@ -81,6 +163,30 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
81
163
  this.play(this.animation.name, this.animation.loop);
82
164
  };
83
165
 
166
+ _addToSlot(slotName, object, replaceSlotContents) {
167
+ const spine = this._baseObject;
168
+ const slotIndex = spine.spineData.slots.findIndex(({ name }) => name === slotName);
169
+ const currentSlot = spine.slotContainers[slotIndex];
170
+
171
+ if (currentSlot) {
172
+ object._baseObject.scale.y = -1;
173
+
174
+ Urso.objects.removeChild(object.parent, object);
175
+
176
+ if (replaceSlotContents)
177
+ currentSlot.removeChildren(); //todo check if its proxy and reset parent
178
+
179
+ //object.parent = this; //todo && make removeChild
180
+ currentSlot.addChild(object._baseObject);
181
+ } else {
182
+ Urso.logger.warn('ModulesObjectsModelsSpine _addToSlot error: no spine slot ' + slotName);
183
+ }
184
+ }
185
+
186
+ /**
187
+ * get animation timeScale
188
+ * @returns Number
189
+ */
84
190
  getTimeScale() {
85
191
  return Urso.scenes.timeScale * this.animation.timeScale;
86
192
  }
@@ -30,6 +30,10 @@ class ModulesScenesController {
30
30
  return this.getInstance('PixiWrapper').getCachedMouseCoords();
31
31
  }
32
32
 
33
+ addObject(objects, parent, doNotRefreshStylesFlag) {
34
+ this._service.addObject(objects, parent, doNotRefreshStylesFlag);
35
+ }
36
+
33
37
  get timeScale() {
34
38
  return this._service.timeScale;
35
39
  }
@@ -4,7 +4,6 @@ class ModulesScenesResolutions {
4
4
  this.singleton = true;
5
5
  this._activeResolution = false; //object
6
6
  this._templateSize = { orientation: 0, width: 0, height: 0 };
7
- this._orientations = { landscape: 'landscape', portrait: 'portrait' }
8
7
  this._currentOrientation = null;
9
8
 
10
9
  this.refreshSceneSize = this.refreshSceneSize.bind(this);
@@ -53,7 +52,7 @@ class ModulesScenesResolutions {
53
52
  console.log('[SCENE] New Template Size', this._templateSize);
54
53
 
55
54
  //update InstancesModes
56
- Object.values(this._orientations).forEach((orientationValue) => Urso.removeInstancesMode(orientationValue + 'Orientation'));
55
+ Object.values(Urso.device.ScreenOrientation).forEach((orientationValue) => Urso.removeInstancesMode(orientationValue + 'Orientation'));
57
56
  Urso.addInstancesMode(orientation + 'Orientation');
58
57
 
59
58
  //send new resolution event
@@ -68,12 +67,9 @@ class ModulesScenesResolutions {
68
67
  };
69
68
 
70
69
  _getWindowSize() {
71
- const iOS = Urso.device.iOS;
72
- const { width, height } = document.body.getBoundingClientRect();
73
-
74
70
  let windowSize = {
75
- width: iOS ? window.innerWidth : width,
76
- height: iOS ? window.innerHeight : height
71
+ width: window.innerWidth,
72
+ height: window.innerHeight
77
73
  };
78
74
 
79
75
  if (window.devicePixelRatio && window.devicePixelRatio !== 1) {
@@ -85,7 +81,7 @@ class ModulesScenesResolutions {
85
81
  }
86
82
 
87
83
  _getOrientation(windowSize) {
88
- return windowSize.width > windowSize.height ? this._orientations.landscape : this._orientations.portrait; //todo move to constants
84
+ return windowSize.width > windowSize.height ? Urso.device.ScreenOrientation.LANDSCAPE : Urso.device.ScreenOrientation.PORTRAIT;
89
85
  }
90
86
 
91
87
  _getResolutionConfig(windowSize) {
@@ -2,14 +2,14 @@ class ModulesScenesResolutionsConfig {
2
2
  constructor() {
3
3
  this.singleton = true;
4
4
 
5
- this._orientations = ['landscape', 'portrait'];
5
+ this._orientations = [Urso.device.ScreenOrientation.LANDSCAPE, Urso.device.ScreenOrientation.PORTRAIT]; //you can use only one orientation for config contents
6
6
 
7
7
  this.contents = [
8
8
  {
9
9
  "name": 'default',
10
10
  "width": 1920,
11
11
  "height": 1080,
12
- "orientation": 'landscape',
12
+ "orientation": Urso.device.ScreenOrientation.LANDSCAPE,
13
13
  "adaptive": true
14
14
  }
15
15
  ];
@@ -26,6 +26,19 @@ class ModulesScenesService {
26
26
  gsap.globalTimeline.timeScale(this.timeScale);
27
27
  }
28
28
 
29
+ addObject(objects, parent, doNotRefreshStylesFlag) {
30
+ const newTemplatePart = Urso.template.parse({ objects: [objects] }, true);
31
+ Urso.assets.preload(newTemplatePart.assets, () => this._newTemplateAssetsLoadedHandler(newTemplatePart, parent, doNotRefreshStylesFlag));
32
+ }
33
+
34
+ _newTemplateAssetsLoadedHandler(newTemplatePart, parent, doNotRefreshStylesFlag) {
35
+ Urso.objects.create(newTemplatePart.objects, parent, doNotRefreshStylesFlag);
36
+
37
+ //components create
38
+ newTemplatePart.components.forEach(component => component.create());
39
+ this._currentSceneTemplate.components = Urso.helper.mergeArrays(this._currentSceneTemplate.components, newTemplatePart.components);
40
+ }
41
+
29
42
  display(name) {
30
43
  if (this._displayInProgress) {
31
44
  console.warn("Scenes.display is busy ", this._currentSceneName);
@@ -68,12 +81,12 @@ class ModulesScenesService {
68
81
  this.emit(Urso.events.MODULES_SCENES_NEW_SCENE_INIT, name);
69
82
 
70
83
  Urso.assets.preload(this._currentSceneTemplate.assets, this._assetsLoadedHandler);
71
-
72
84
  }
73
85
 
74
86
  loadUpdate(loadProgress) {
75
87
  if (!this._sceneModel)
76
88
  return;
89
+
77
90
  this._sceneModel.loadUpdate(loadProgress);
78
91
  this.emit(Urso.events.MODULES_ASSETS_LOAD_PROGRESS, loadProgress);
79
92
  }
@@ -19,8 +19,8 @@ class ModulesTemplateController {
19
19
  };
20
20
 
21
21
  //make template
22
- parse(template) {
23
- return this.getInstance('Service').parse(template);
22
+ parse(template, additionalTemplateFlag) {
23
+ return this.getInstance('Service').parse(template, additionalTemplateFlag);
24
24
  }
25
25
 
26
26
  }