@urso/core 0.8.20-dev → 0.9.0-dev

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.
Files changed (134) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +227 -227
  3. package/build/js/index.js +77216 -2
  4. package/package.json +36 -50
  5. package/src/js/app.js +105 -104
  6. package/src/js/components/base/controller.js +76 -78
  7. package/src/js/components/debug/controller.js +39 -39
  8. package/src/js/components/debug/coords.js +23 -23
  9. package/src/js/components/debug/fps.js +36 -36
  10. package/src/js/components/debug/template.js +55 -55
  11. package/src/js/components/debug/timescale.js +60 -60
  12. package/src/js/components/deviceRotate/controller.js +95 -95
  13. package/src/js/components/editor/api.js +127 -127
  14. package/src/js/components/editor/controller.js +13 -13
  15. package/src/js/components/fullscreen/android.js +104 -104
  16. package/src/js/components/fullscreen/controller.js +76 -76
  17. package/src/js/components/fullscreen/desktop.js +49 -49
  18. package/src/js/components/fullscreen/ios.js +115 -115
  19. package/src/js/components/layersSwitcher/config.js +26 -26
  20. package/src/js/components/layersSwitcher/controller.js +36 -36
  21. package/src/js/components/loader/controller.js +66 -66
  22. package/src/js/components/loader/template.js +71 -71
  23. package/src/js/components/soundInitialPopup/controller.js +43 -43
  24. package/src/js/components/soundInitialPopup/template.js +110 -110
  25. package/src/js/components/stateDriven/controller.js +123 -123
  26. package/src/js/config/load.js +325 -194
  27. package/src/js/config/main.js +17 -17
  28. package/src/js/extra/browserEvents.js +57 -57
  29. package/src/js/extra/main.js +23 -25
  30. package/src/js/extra/pixiPatch.js +173 -171
  31. package/src/js/index.js +7 -7
  32. package/src/js/lib/cache.js +199 -125
  33. package/src/js/lib/composition.js +85 -85
  34. package/src/js/lib/device.js +1215 -1215
  35. package/src/js/lib/helper.js +678 -678
  36. package/src/js/lib/loader.js +216 -218
  37. package/src/js/lib/localData.js +29 -29
  38. package/src/js/lib/logger.js +69 -69
  39. package/src/js/lib/math.js +161 -161
  40. package/src/js/lib/objectPool.js +208 -208
  41. package/src/js/lib/time.js +19 -19
  42. package/src/js/lib/tween.js +153 -153
  43. package/src/js/modules/assets/baseModel.js +21 -21
  44. package/src/js/modules/assets/config.js +38 -38
  45. package/src/js/modules/assets/controller.js +65 -65
  46. package/src/js/modules/assets/models/atlas.js +19 -19
  47. package/src/js/modules/assets/models/audiosprite.js +28 -28
  48. package/src/js/modules/assets/models/bitmapFont.js +11 -11
  49. package/src/js/modules/assets/models/container.js +19 -19
  50. package/src/js/modules/assets/models/font.js +11 -11
  51. package/src/js/modules/assets/models/html.js +11 -11
  52. package/src/js/modules/assets/models/image.js +17 -17
  53. package/src/js/modules/assets/models/json.js +11 -11
  54. package/src/js/modules/assets/models/jsonAtlas.js +11 -11
  55. package/src/js/modules/assets/models/sound.js +17 -17
  56. package/src/js/modules/assets/models/spine.js +18 -17
  57. package/src/js/modules/assets/models/spineAtlas.js +11 -0
  58. package/src/js/modules/assets/service.js +564 -553
  59. package/src/js/modules/i18n/config.js +17 -17
  60. package/src/js/modules/i18n/controller.js +71 -71
  61. package/src/js/modules/instances/controller.js +357 -357
  62. package/src/js/modules/logic/config/sounds.js +23 -23
  63. package/src/js/modules/logic/controller.js +52 -52
  64. package/src/js/modules/logic/main.js +8 -8
  65. package/src/js/modules/logic/sounds.js +103 -103
  66. package/src/js/modules/objects/baseModel.js +205 -207
  67. package/src/js/modules/objects/cache.js +99 -99
  68. package/src/js/modules/objects/config.js +10 -10
  69. package/src/js/modules/objects/controller.js +139 -139
  70. package/src/js/modules/objects/find.js +58 -58
  71. package/src/js/modules/objects/models/bitmapText.js +56 -49
  72. package/src/js/modules/objects/models/button.js +208 -209
  73. package/src/js/modules/objects/models/buttonComposite.js +38 -38
  74. package/src/js/modules/objects/models/checkbox.js +100 -100
  75. package/src/js/modules/objects/models/collection.js +56 -54
  76. package/src/js/modules/objects/models/component.js +48 -48
  77. package/src/js/modules/objects/models/container.js +22 -22
  78. package/src/js/modules/objects/models/emitterFx.js +103 -114
  79. package/src/js/modules/objects/models/graphics.js +40 -40
  80. package/src/js/modules/objects/models/group.js +22 -22
  81. package/src/js/modules/objects/models/hitArea.js +187 -187
  82. package/src/js/modules/objects/models/image.js +36 -36
  83. package/src/js/modules/objects/models/imagesAnimation.js +115 -115
  84. package/src/js/modules/objects/models/mask.js +40 -40
  85. package/src/js/modules/objects/models/nineSlicePlane.js +32 -32
  86. package/src/js/modules/objects/models/slider.js +357 -357
  87. package/src/js/modules/objects/models/spine.js +354 -339
  88. package/src/js/modules/objects/models/text.js +70 -70
  89. package/src/js/modules/objects/models/toggle.js +186 -186
  90. package/src/js/modules/objects/models/world.js +22 -22
  91. package/src/js/modules/objects/pool.js +68 -68
  92. package/src/js/modules/objects/propertyAdapter.js +592 -592
  93. package/src/js/modules/objects/proxy.js +299 -298
  94. package/src/js/modules/objects/selector.js +136 -136
  95. package/src/js/modules/objects/service.js +255 -254
  96. package/src/js/modules/objects/styles.js +210 -210
  97. package/src/js/modules/observer/controller.js +168 -168
  98. package/src/js/modules/observer/events.js +51 -56
  99. package/src/js/modules/scenes/controller.js +126 -127
  100. package/src/js/modules/scenes/model.js +28 -28
  101. package/src/js/modules/scenes/pixiWrapper.js +359 -351
  102. package/src/js/modules/scenes/resolutions.js +173 -173
  103. package/src/js/modules/scenes/resolutionsConfig.js +73 -73
  104. package/src/js/modules/scenes/service.js +144 -146
  105. package/src/js/modules/soundManager/controller.js +103 -103
  106. package/src/js/modules/soundManager/soundSprite.js +314 -314
  107. package/src/js/modules/statesManager/action.js +97 -97
  108. package/src/js/modules/statesManager/all.js +23 -23
  109. package/src/js/modules/statesManager/configStates.js +77 -77
  110. package/src/js/modules/statesManager/controller.js +219 -219
  111. package/src/js/modules/statesManager/functionsStorage.js +83 -83
  112. package/src/js/modules/statesManager/helper.js +27 -27
  113. package/src/js/modules/statesManager/race.js +91 -91
  114. package/src/js/modules/statesManager/sequence.js +48 -48
  115. package/src/js/modules/template/controller.js +28 -28
  116. package/src/js/modules/template/model.js +11 -11
  117. package/src/js/modules/template/service.js +137 -137
  118. package/src/js/modules/template/types.js +50 -49
  119. package/src/js/modules/transport/baseConnectionType.js +25 -25
  120. package/src/js/modules/transport/config.js +13 -13
  121. package/src/js/modules/transport/connectionTypes/websocket.js +77 -77
  122. package/src/js/modules/transport/connectionTypes/xhr.js +47 -47
  123. package/src/js/modules/transport/controller.js +48 -48
  124. package/src/js/modules/transport/decorator.js +17 -17
  125. package/src/js/modules/transport/service.js +150 -150
  126. package/vite.config.js +31 -0
  127. package/.babelrc +0 -12
  128. package/build/js/index.js.LICENSE.txt +0 -227
  129. package/src/js/modules/objects/models/atlasImage.js +0 -52
  130. package/src/js/modules/objects/models/dragContainer.js +0 -665
  131. package/src/js/modules/objects/models/emitter.js +0 -69
  132. package/src/js/modules/objects/models/scrollbox.js +0 -67
  133. package/src/js/modules/objects/models/textInput.js +0 -68
  134. package/webpack.config.js +0 -47
@@ -1,150 +1,150 @@
1
- class ModulesTransportService {
2
- constructor() {
3
- this._callbacks = {};
4
- this._config = this.getInstance('Config').getConfig();
5
- this._communicator = null;
6
- }
7
-
8
- on(event, callback, force) {
9
- if (!this._checkCallback(event) || force)
10
- this._setCallback(event, callback);
11
- };
12
-
13
- init() {
14
- this._createConnection();
15
- };
16
-
17
- send(message) {
18
- if (!this._checkCommunicatorReady())
19
- return false;
20
-
21
- const decoratedMessage = this.getInstance('Decorator', { callbacks: this._callbacks }).toServer(message);
22
-
23
- if(!decoratedMessage) {
24
- return false;
25
- }
26
-
27
- const validatedMessage = this._validateMessage(decoratedMessage);
28
-
29
- if(!validatedMessage) {
30
- return false;
31
- }
32
-
33
- this._communicator.send(validatedMessage);
34
-
35
- return true;
36
- };
37
-
38
- reconnect() {
39
- if (!this._checkCommunicatorReady())
40
- return false;
41
-
42
- this._communicator.reconnect(this._getAutoReconnetionDelay());
43
-
44
- return true;
45
- };
46
-
47
- close() {
48
- if (!this._checkCommunicatorReady())
49
- return false;
50
-
51
- this._communicator.close();
52
-
53
- return true;
54
- };
55
-
56
- _checkCallback(event) {
57
- const result = !!this._callbacks[event];
58
-
59
- if (result)
60
- Urso.logger.error(`Overwrite ${event} event detected!`);
61
-
62
- return result;
63
- };
64
-
65
- _checkCommunicatorReady() {
66
- if (!this._communicator) {
67
- Urso.logger.error('Communicator was not created!');
68
- return false;
69
- }
70
- return this._communicator.readyCheck();
71
- };
72
-
73
- _destroyCommunicator() {
74
- this._communicator = null;
75
- };
76
-
77
- _prepareCallback(event, callback) {
78
- const func = message => {
79
- const data = this._runMiddleWare(event, message);
80
- return callback(data);
81
- };
82
-
83
- return func;
84
- }
85
-
86
- _runMiddleWare(event, data) {
87
- switch (event) {
88
- case 'response':
89
- const decoratedMessage = this.getInstance('Decorator', { callbacks: this._callbacks }).toFront(data);
90
-
91
- if(!decoratedMessage) {
92
- return;
93
- }
94
-
95
- return this._validateMessage(decoratedMessage);
96
-
97
- case 'close':
98
- case 'error':
99
- this._tryReconnect();;
100
- default:
101
- return data;
102
- }
103
- };
104
-
105
- _autoReconnectCheck() {
106
- return this._config.reconnectTimeout;
107
- }
108
-
109
- _getAutoReconnetionDelay() {
110
- return this._config.autoReconnect || 0;
111
- }
112
-
113
- _tryReconnect() {
114
- if (!this._autoReconnectCheck())
115
- return false;
116
-
117
- this._communicator.reconnect(this._getAutoReconnetionDelay());
118
- };
119
-
120
- _setCallback(event, callback) {
121
- this._callbacks[event] = this._prepareCallback(event, callback);
122
- };
123
-
124
- _validateMessage(message) {
125
- // TODO : SET VALIDATION MODELS
126
- return { ...message };
127
- };
128
-
129
- _getHost() {
130
- return this._config.host;
131
- };
132
-
133
- _getType() {
134
- return this._config.type;
135
- }
136
-
137
- _createConnection() {
138
- const host = this._getHost();
139
- const type = this._getType();
140
- const callbacks = this._callbacks;
141
- const capitalizedType = Urso.helper.capitaliseFirstLetter(type);
142
-
143
- this._communicator = this.getInstance(`ConnectionTypes.${capitalizedType}`, { callbacks, host });
144
-
145
- if (!this._communicator)
146
- Urso.logger.error(`Transport type: '${capitalizedType}' was not found!`);
147
- };
148
- }
149
-
150
- module.exports = ModulesTransportService;
1
+ class ModulesTransportService {
2
+ constructor() {
3
+ this._callbacks = {};
4
+ this._config = this.getInstance('Config').getConfig();
5
+ this._communicator = null;
6
+ }
7
+
8
+ on(event, callback, force) {
9
+ if (!this._checkCallback(event) || force)
10
+ this._setCallback(event, callback);
11
+ };
12
+
13
+ init() {
14
+ this._createConnection();
15
+ };
16
+
17
+ send(message) {
18
+ if (!this._checkCommunicatorReady())
19
+ return false;
20
+
21
+ const decoratedMessage = this.getInstance('Decorator', { callbacks: this._callbacks }).toServer(message);
22
+
23
+ if(!decoratedMessage) {
24
+ return false;
25
+ }
26
+
27
+ const validatedMessage = this._validateMessage(decoratedMessage);
28
+
29
+ if(!validatedMessage) {
30
+ return false;
31
+ }
32
+
33
+ this._communicator.send(validatedMessage);
34
+
35
+ return true;
36
+ };
37
+
38
+ reconnect() {
39
+ if (!this._checkCommunicatorReady())
40
+ return false;
41
+
42
+ this._communicator.reconnect(this._getAutoReconnetionDelay());
43
+
44
+ return true;
45
+ };
46
+
47
+ close() {
48
+ if (!this._checkCommunicatorReady())
49
+ return false;
50
+
51
+ this._communicator.close();
52
+
53
+ return true;
54
+ };
55
+
56
+ _checkCallback(event) {
57
+ const result = !!this._callbacks[event];
58
+
59
+ if (result)
60
+ Urso.logger.error(`Overwrite ${event} event detected!`);
61
+
62
+ return result;
63
+ };
64
+
65
+ _checkCommunicatorReady() {
66
+ if (!this._communicator) {
67
+ Urso.logger.error('Communicator was not created!');
68
+ return false;
69
+ }
70
+ return this._communicator.readyCheck();
71
+ };
72
+
73
+ _destroyCommunicator() {
74
+ this._communicator = null;
75
+ };
76
+
77
+ _prepareCallback(event, callback) {
78
+ const func = message => {
79
+ const data = this._runMiddleWare(event, message);
80
+ return callback(data);
81
+ };
82
+
83
+ return func;
84
+ }
85
+
86
+ _runMiddleWare(event, data) {
87
+ switch (event) {
88
+ case 'response':
89
+ const decoratedMessage = this.getInstance('Decorator', { callbacks: this._callbacks }).toFront(data);
90
+
91
+ if(!decoratedMessage) {
92
+ return;
93
+ }
94
+
95
+ return this._validateMessage(decoratedMessage);
96
+
97
+ case 'close':
98
+ case 'error':
99
+ this._tryReconnect();;
100
+ default:
101
+ return data;
102
+ }
103
+ };
104
+
105
+ _autoReconnectCheck() {
106
+ return this._config.reconnectTimeout;
107
+ }
108
+
109
+ _getAutoReconnetionDelay() {
110
+ return this._config.autoReconnect || 0;
111
+ }
112
+
113
+ _tryReconnect() {
114
+ if (!this._autoReconnectCheck())
115
+ return false;
116
+
117
+ this._communicator.reconnect(this._getAutoReconnetionDelay());
118
+ };
119
+
120
+ _setCallback(event, callback) {
121
+ this._callbacks[event] = this._prepareCallback(event, callback);
122
+ };
123
+
124
+ _validateMessage(message) {
125
+ // TODO : SET VALIDATION MODELS
126
+ return { ...message };
127
+ };
128
+
129
+ _getHost() {
130
+ return this._config.host;
131
+ };
132
+
133
+ _getType() {
134
+ return this._config.type;
135
+ }
136
+
137
+ _createConnection() {
138
+ const host = this._getHost();
139
+ const type = this._getType();
140
+ const callbacks = this._callbacks;
141
+ const capitalizedType = Urso.helper.capitaliseFirstLetter(type);
142
+
143
+ this._communicator = this.getInstance(`ConnectionTypes.${capitalizedType}`, { callbacks, host });
144
+
145
+ if (!this._communicator)
146
+ Urso.logger.error(`Transport type: '${capitalizedType}' was not found!`);
147
+ };
148
+ }
149
+
150
+ export default ModulesTransportService;
package/vite.config.js ADDED
@@ -0,0 +1,31 @@
1
+ import { defineConfig } from 'vite';
2
+
3
+ export default defineConfig({
4
+ plugins: [],
5
+ build: {
6
+ outDir: 'build',
7
+ emptyOutDir: true,
8
+ lib: {
9
+ entry: './src/js/index.js',
10
+ name: 'Urso',
11
+ fileName: 'js/index',
12
+ formats: ['es'],
13
+ sourcemap: true,
14
+
15
+ },
16
+ rollupOptions: {
17
+ external: [], // add external dependencies if needed
18
+ output: {
19
+ inlineDynamicImports: true
20
+ }
21
+ },
22
+ minify: 'terser',
23
+ terserOptions: {
24
+ compress: true,
25
+ mangle: true,
26
+ format: {
27
+ comments: false
28
+ }
29
+ },
30
+ }
31
+ });
package/.babelrc DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "esmodules": true
8
- }
9
- }
10
- ]
11
- ]
12
- }
@@ -1,227 +0,0 @@
1
- /*
2
- object-assign
3
- (c) Sindre Sorhus
4
- @license MIT
5
- */
6
-
7
- /*!
8
- * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
9
- *
10
- * howler.js v2.2.4
11
- * howlerjs.com
12
- *
13
- * (c) 2013-2020, James Simpson of GoldFire Studios
14
- * goldfirestudios.com
15
- *
16
- * MIT License
17
- */
18
-
19
- /*!
20
- * howler.js v2.2.4
21
- * howlerjs.com
22
- *
23
- * (c) 2013-2020, James Simpson of GoldFire Studios
24
- * goldfirestudios.com
25
- *
26
- * MIT License
27
- */
28
-
29
- /*!
30
- * @pixi-spine/loader-base - v3.1.2
31
- * Compiled Tue, 10 Jan 2023 14:17:32 UTC
32
- *
33
- * @pixi-spine/loader-base is licensed under the MIT License.
34
- * http://www.opensource.org/licenses/mit-license
35
- *
36
- * Copyright 2019-2020, Ivan Igorevich Popelyshev <ivan.popelyshev@gmail.com>, All Rights Reserved
37
- */
38
-
39
- /*!
40
- * @pixi/app - v6.5.10
41
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
42
- *
43
- * @pixi/app is licensed under the MIT License.
44
- * http://www.opensource.org/licenses/mit-license
45
- */
46
-
47
- /*!
48
- * @pixi/constants - v6.5.10
49
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
50
- *
51
- * @pixi/constants is licensed under the MIT License.
52
- * http://www.opensource.org/licenses/mit-license
53
- */
54
-
55
- /*!
56
- * @pixi/core - v6.5.10
57
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
58
- *
59
- * @pixi/core is licensed under the MIT License.
60
- * http://www.opensource.org/licenses/mit-license
61
- */
62
-
63
- /*!
64
- * @pixi/display - v6.5.10
65
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
66
- *
67
- * @pixi/display is licensed under the MIT License.
68
- * http://www.opensource.org/licenses/mit-license
69
- */
70
-
71
- /*!
72
- * @pixi/extensions - v6.5.10
73
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
74
- *
75
- * @pixi/extensions is licensed under the MIT License.
76
- * http://www.opensource.org/licenses/mit-license
77
- */
78
-
79
- /*!
80
- * @pixi/filter-displacement - v6.5.10
81
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
82
- *
83
- * @pixi/filter-displacement is licensed under the MIT License.
84
- * http://www.opensource.org/licenses/mit-license
85
- */
86
-
87
- /*!
88
- * @pixi/math - v6.5.10
89
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
90
- *
91
- * @pixi/math is licensed under the MIT License.
92
- * http://www.opensource.org/licenses/mit-license
93
- */
94
-
95
- /*!
96
- * @pixi/mixin-get-child-by-name - v6.5.10
97
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
98
- *
99
- * @pixi/mixin-get-child-by-name is licensed under the MIT License.
100
- * http://www.opensource.org/licenses/mit-license
101
- */
102
-
103
- /*!
104
- * @pixi/mixin-get-global-position - v6.5.10
105
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
106
- *
107
- * @pixi/mixin-get-global-position is licensed under the MIT License.
108
- * http://www.opensource.org/licenses/mit-license
109
- */
110
-
111
- /*!
112
- * @pixi/polyfill - v6.5.10
113
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
114
- *
115
- * @pixi/polyfill is licensed under the MIT License.
116
- * http://www.opensource.org/licenses/mit-license
117
- */
118
-
119
- /*!
120
- * @pixi/prepare - v6.5.10
121
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
122
- *
123
- * @pixi/prepare is licensed under the MIT License.
124
- * http://www.opensource.org/licenses/mit-license
125
- */
126
-
127
- /*!
128
- * @pixi/runner - v6.5.10
129
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
130
- *
131
- * @pixi/runner is licensed under the MIT License.
132
- * http://www.opensource.org/licenses/mit-license
133
- */
134
-
135
- /*!
136
- * @pixi/settings - v6.5.10
137
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
138
- *
139
- * @pixi/settings is licensed under the MIT License.
140
- * http://www.opensource.org/licenses/mit-license
141
- */
142
-
143
- /*!
144
- * @pixi/ticker - v6.5.10
145
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
146
- *
147
- * @pixi/ticker is licensed under the MIT License.
148
- * http://www.opensource.org/licenses/mit-license
149
- */
150
-
151
- /*!
152
- * GSAP 3.12.7
153
- * https://gsap.com
154
- *
155
- * @license Copyright 2008-2025, GreenSock. All rights reserved.
156
- * Subject to the terms at https://gsap.com/standard-license or for
157
- * Club GSAP members, the agreement issued with that membership.
158
- * @author: Jack Doyle, jack@greensock.com
159
- */
160
-
161
- /*!
162
- * pixi-particles - v4.3.1
163
- * Compiled Wed, 09 Jun 2021 13:12:54 UTC
164
- *
165
- * pixi-particles is licensed under the MIT License.
166
- * http://www.opensource.org/licenses/mit-license
167
- */
168
-
169
- /*!
170
- * pixi-spine - v3.1.2
171
- * Compiled Tue, 10 Jan 2023 14:17:40 UTC
172
- *
173
- * pixi-spine is licensed under the MIT License.
174
- * http://www.opensource.org/licenses/mit-license
175
- *
176
- * Copyright 2019-2020, Ivan Igorevich Popelyshev <ivan.popelyshev@gmail.com>, All Rights Reserved
177
- */
178
-
179
- /*!
180
- * pixi-viewport - v4.38.0
181
- * Compiled Sun, 27 Nov 2022 13:43:58 UTC
182
- *
183
- * pixi-viewport is licensed under the MIT License.
184
- * http://www.opensource.org/licenses/mit-license
185
- *
186
- * Copyright 2019-2020, David Figatner, All Rights Reserved
187
- */
188
-
189
- /*!
190
- * pixi.js - v6.5.10
191
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
192
- *
193
- * pixi.js is licensed under the MIT License.
194
- * http://www.opensource.org/licenses/mit-license
195
- */
196
-
197
- /*! *****************************************************************************
198
- Copyright (c) Microsoft Corporation.
199
-
200
- Permission to use, copy, modify, and/or distribute this software for any
201
- purpose with or without fee is hereby granted.
202
-
203
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
204
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
205
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
206
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
207
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
208
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
209
- PERFORMANCE OF THIS SOFTWARE.
210
- ***************************************************************************** */
211
-
212
- /*! *****************************************************************************
213
- Copyright (c) Microsoft Corporation. All rights reserved.
214
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
215
- this file except in compliance with the License. You may obtain a copy of the
216
- License at http://www.apache.org/licenses/LICENSE-2.0
217
-
218
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
219
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
220
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
221
- MERCHANTABLITY OR NON-INFRINGEMENT.
222
-
223
- See the Apache Version 2.0 License for specific language governing permissions
224
- and limitations under the License.
225
- ***************************************************************************** */
226
-
227
- /*! https://mths.be/punycode v1.4.1 by @mathias */
@@ -1,52 +0,0 @@
1
- const ModulesObjectsBaseModel = require('./../baseModel');
2
-
3
- class ModulesObjectsModelsAtlasImage extends ModulesObjectsBaseModel {
4
- constructor(params) {
5
- super(params);
6
-
7
- this.type = Urso.types.objects.ATLASIMAGE;
8
- this._addBaseObject();
9
- }
10
-
11
- setupParams(params) {
12
- super.setupParams(params);
13
-
14
- this.assetKey = Urso.helper.recursiveGet('assetKey', params, false);
15
- this.filenameKey = Urso.helper.recursiveGet('filenameKey', params, false);
16
- }
17
-
18
- changeTexture(filenameKey, assetKey) {
19
- if (assetKey)
20
- this.assetKey = assetKey;
21
-
22
- if (filenameKey)
23
- this.filenameKey = filenameKey;
24
-
25
- this._addBaseObject();
26
- }
27
-
28
- _addBaseObject() {
29
- const sheet = Urso.cache.getAtlas(this.assetKey)
30
-
31
- if (!sheet)
32
- Urso.logger.error('ModulesObjectsModelsImage assets error: no atlas ' + this.assetKey);
33
-
34
- let textureKey = this.filenameKey;
35
-
36
- if (!sheet.textures[textureKey] && typeof this.filenameKey === 'string') {
37
- let keyIndex = sheet.data.frames.findIndex((el) => { return el.filename === this.filenameKey });
38
-
39
- if (keyIndex !== -1)
40
- textureKey = keyIndex;
41
- }
42
-
43
- const texture = sheet.textures[textureKey];
44
-
45
- if (!this._baseObject)
46
- this._baseObject = new PIXI.Sprite(texture);
47
- else
48
- this._baseObject.texture = texture;
49
- };
50
- }
51
-
52
- module.exports = ModulesObjectsModelsAtlasImage;