@urso/core 0.7.88 → 0.7.89

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.
@@ -1,9 +1,3 @@
1
- /*
2
- object-assign
3
- (c) Sindre Sorhus
4
- @license MIT
5
- */
6
-
7
1
  /*!
8
2
  * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
9
3
  *
@@ -36,30 +30,6 @@ object-assign
36
30
  * Copyright 2019-2020, Ivan Igorevich Popelyshev <ivan.popelyshev@gmail.com>, All Rights Reserved
37
31
  */
38
32
 
39
- /*!
40
- * @pixi/accessibility - v6.5.10
41
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
42
- *
43
- * @pixi/accessibility is licensed under the MIT License.
44
- * http://www.opensource.org/licenses/mit-license
45
- */
46
-
47
- /*!
48
- * @pixi/app - v6.5.10
49
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
50
- *
51
- * @pixi/app is licensed under the MIT License.
52
- * http://www.opensource.org/licenses/mit-license
53
- */
54
-
55
- /*!
56
- * @pixi/compressed-textures - v6.5.10
57
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
58
- *
59
- * @pixi/compressed-textures is licensed under the MIT License.
60
- * http://www.opensource.org/licenses/mit-license
61
- */
62
-
63
33
  /*!
64
34
  * @pixi/constants - v6.5.10
65
35
  * Compiled Thu, 06 Jul 2023 15:25:11 UTC
@@ -92,86 +62,6 @@ object-assign
92
62
  * http://www.opensource.org/licenses/mit-license
93
63
  */
94
64
 
95
- /*!
96
- * @pixi/extract - v6.5.10
97
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
98
- *
99
- * @pixi/extract is licensed under the MIT License.
100
- * http://www.opensource.org/licenses/mit-license
101
- */
102
-
103
- /*!
104
- * @pixi/filter-alpha - v6.5.10
105
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
106
- *
107
- * @pixi/filter-alpha is licensed under the MIT License.
108
- * http://www.opensource.org/licenses/mit-license
109
- */
110
-
111
- /*!
112
- * @pixi/filter-blur - v6.5.10
113
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
114
- *
115
- * @pixi/filter-blur is licensed under the MIT License.
116
- * http://www.opensource.org/licenses/mit-license
117
- */
118
-
119
- /*!
120
- * @pixi/filter-color-matrix - v6.5.10
121
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
122
- *
123
- * @pixi/filter-color-matrix is licensed under the MIT License.
124
- * http://www.opensource.org/licenses/mit-license
125
- */
126
-
127
- /*!
128
- * @pixi/filter-displacement - v6.5.10
129
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
130
- *
131
- * @pixi/filter-displacement is licensed under the MIT License.
132
- * http://www.opensource.org/licenses/mit-license
133
- */
134
-
135
- /*!
136
- * @pixi/filter-fxaa - v6.5.10
137
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
138
- *
139
- * @pixi/filter-fxaa is licensed under the MIT License.
140
- * http://www.opensource.org/licenses/mit-license
141
- */
142
-
143
- /*!
144
- * @pixi/filter-noise - v6.5.10
145
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
146
- *
147
- * @pixi/filter-noise is licensed under the MIT License.
148
- * http://www.opensource.org/licenses/mit-license
149
- */
150
-
151
- /*!
152
- * @pixi/graphics - v6.5.10
153
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
154
- *
155
- * @pixi/graphics is licensed under the MIT License.
156
- * http://www.opensource.org/licenses/mit-license
157
- */
158
-
159
- /*!
160
- * @pixi/interaction - v6.5.10
161
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
162
- *
163
- * @pixi/interaction is licensed under the MIT License.
164
- * http://www.opensource.org/licenses/mit-license
165
- */
166
-
167
- /*!
168
- * @pixi/loaders - v6.5.10
169
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
170
- *
171
- * @pixi/loaders is licensed under the MIT License.
172
- * http://www.opensource.org/licenses/mit-license
173
- */
174
-
175
65
  /*!
176
66
  * @pixi/math - v6.5.10
177
67
  * Compiled Thu, 06 Jul 2023 15:25:11 UTC
@@ -180,78 +70,6 @@ object-assign
180
70
  * http://www.opensource.org/licenses/mit-license
181
71
  */
182
72
 
183
- /*!
184
- * @pixi/mesh - v6.5.10
185
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
186
- *
187
- * @pixi/mesh is licensed under the MIT License.
188
- * http://www.opensource.org/licenses/mit-license
189
- */
190
-
191
- /*!
192
- * @pixi/mesh-extras - v6.5.10
193
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
194
- *
195
- * @pixi/mesh-extras is licensed under the MIT License.
196
- * http://www.opensource.org/licenses/mit-license
197
- */
198
-
199
- /*!
200
- * @pixi/mixin-cache-as-bitmap - v6.5.10
201
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
202
- *
203
- * @pixi/mixin-cache-as-bitmap is licensed under the MIT License.
204
- * http://www.opensource.org/licenses/mit-license
205
- */
206
-
207
- /*!
208
- * @pixi/mixin-get-child-by-name - v6.5.10
209
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
210
- *
211
- * @pixi/mixin-get-child-by-name is licensed under the MIT License.
212
- * http://www.opensource.org/licenses/mit-license
213
- */
214
-
215
- /*!
216
- * @pixi/mixin-get-global-position - v6.5.10
217
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
218
- *
219
- * @pixi/mixin-get-global-position is licensed under the MIT License.
220
- * http://www.opensource.org/licenses/mit-license
221
- */
222
-
223
- /*!
224
- * @pixi/particle-container - v6.5.10
225
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
226
- *
227
- * @pixi/particle-container is licensed under the MIT License.
228
- * http://www.opensource.org/licenses/mit-license
229
- */
230
-
231
- /*!
232
- * @pixi/polyfill - v6.5.10
233
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
234
- *
235
- * @pixi/polyfill is licensed under the MIT License.
236
- * http://www.opensource.org/licenses/mit-license
237
- */
238
-
239
- /*!
240
- * @pixi/prepare - v6.5.10
241
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
242
- *
243
- * @pixi/prepare is licensed under the MIT License.
244
- * http://www.opensource.org/licenses/mit-license
245
- */
246
-
247
- /*!
248
- * @pixi/runner - v6.5.10
249
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
250
- *
251
- * @pixi/runner is licensed under the MIT License.
252
- * http://www.opensource.org/licenses/mit-license
253
- */
254
-
255
73
  /*!
256
74
  * @pixi/settings - v6.5.10
257
75
  * Compiled Thu, 06 Jul 2023 15:25:11 UTC
@@ -260,54 +78,6 @@ object-assign
260
78
  * http://www.opensource.org/licenses/mit-license
261
79
  */
262
80
 
263
- /*!
264
- * @pixi/sprite - v6.5.10
265
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
266
- *
267
- * @pixi/sprite is licensed under the MIT License.
268
- * http://www.opensource.org/licenses/mit-license
269
- */
270
-
271
- /*!
272
- * @pixi/sprite-animated - v6.5.10
273
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
274
- *
275
- * @pixi/sprite-animated is licensed under the MIT License.
276
- * http://www.opensource.org/licenses/mit-license
277
- */
278
-
279
- /*!
280
- * @pixi/sprite-tiling - v6.5.10
281
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
282
- *
283
- * @pixi/sprite-tiling is licensed under the MIT License.
284
- * http://www.opensource.org/licenses/mit-license
285
- */
286
-
287
- /*!
288
- * @pixi/spritesheet - v6.5.10
289
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
290
- *
291
- * @pixi/spritesheet is licensed under the MIT License.
292
- * http://www.opensource.org/licenses/mit-license
293
- */
294
-
295
- /*!
296
- * @pixi/text - v6.5.10
297
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
298
- *
299
- * @pixi/text is licensed under the MIT License.
300
- * http://www.opensource.org/licenses/mit-license
301
- */
302
-
303
- /*!
304
- * @pixi/text-bitmap - v6.5.10
305
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
306
- *
307
- * @pixi/text-bitmap is licensed under the MIT License.
308
- * http://www.opensource.org/licenses/mit-license
309
- */
310
-
311
81
  /*!
312
82
  * @pixi/ticker - v6.5.10
313
83
  * Compiled Thu, 06 Jul 2023 15:25:11 UTC
@@ -316,14 +86,6 @@ object-assign
316
86
  * http://www.opensource.org/licenses/mit-license
317
87
  */
318
88
 
319
- /*!
320
- * @pixi/utils - v6.5.10
321
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
322
- *
323
- * @pixi/utils is licensed under the MIT License.
324
- * http://www.opensource.org/licenses/mit-license
325
- */
326
-
327
89
  /*!
328
90
  * GSAP 3.12.5
329
91
  * https://gsap.com
@@ -362,14 +124,6 @@ object-assign
362
124
  * Copyright 2019-2020, David Figatner, All Rights Reserved
363
125
  */
364
126
 
365
- /*!
366
- * pixi.js - v6.5.10
367
- * Compiled Thu, 06 Jul 2023 15:25:11 UTC
368
- *
369
- * pixi.js is licensed under the MIT License.
370
- * http://www.opensource.org/licenses/mit-license
371
- */
372
-
373
127
  /*! *****************************************************************************
374
128
  Copyright (c) Microsoft Corporation.
375
129
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urso/core",
3
- "version": "0.7.88",
3
+ "version": "0.7.89",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -123,11 +123,19 @@ class LibLoader {
123
123
 
124
124
  let params = asset.params || false; // TODO: Set params field in base mode
125
125
 
126
- if (asset.type === Urso.types.assets.JSON) { // check json in JSONATLAS
126
+ if (asset.type === Urso.types.assets.JSON || asset.type === Urso.types.assets.ATLAS) { // check json in JSONATLAS
127
127
  const jsonData = this._getJsonDataFromJsonAtlases(asset.key);
128
-
128
+ alert(123)
129
129
  if (jsonData) {
130
- Urso.cache.addJson(asset.key, { data: jsonData });
130
+ switch (asset.type) {
131
+ case Urso.types.assets.JSON:
132
+ Urso.cache.addJson(asset.key, { data: jsonData });
133
+ break;
134
+ case Urso.types.assets.ATLAS:
135
+ this._loader.add(asset.key, jsonData, params, (resource) => this._storeAsset(asset, resource));
136
+ break;
137
+ }
138
+
131
139
  return;
132
140
  }
133
141
  }
@@ -148,7 +156,7 @@ class LibLoader {
148
156
  }
149
157
 
150
158
  const loadPath = this._getLoadPath(asset);
151
- this._loader.add(asset.key, loadPath, params, (resource) => this._storeAsset(asset, resource)) //TODO set assets resolution instead _processLoadedImage baseTexture resolution
159
+ this._loader.add(asset.key, loadPath, params, (resource) => this._storeAsset(asset, resource)); //TODO set assets resolution instead _processLoadedImage baseTexture resolution
152
160
  });
153
161
 
154
162
  this._onLoadUpdate({ progress: 0 });
@@ -184,7 +192,7 @@ class LibLoader {
184
192
  const spineAtlasLoader = new PIXI.spine.AtlasAttachmentLoader(params.metadata.spineAtlas);
185
193
  const spineJsonParser = new PIXI.spine.SkeletonJson(spineAtlasLoader);
186
194
  const spineData = spineJsonParser.readSkeletonData(jsonData);
187
- Urso.cache.addSpine(asset.key, {spineData});
195
+ Urso.cache.addSpine(asset.key, { spineData });
188
196
  }
189
197
 
190
198
  _onError(error) {
@@ -1,36 +1,161 @@
1
1
  class LibMath {
2
- /**
3
- * validate number to make it value between min and max values
4
- * @param {Number} num
5
- * @param {Number} min
6
- * @param {Number} max
7
- */
8
- intMakeBetween(num, min, max) {
9
- return Math.max.apply(Math, [min, Math.min.apply(Math, [max, num])]);
10
- }
2
+ /**
3
+ * validate number to make it value between min and max values
4
+ * @param {Number} num
5
+ * @param {Number} min
6
+ * @param {Number} max
7
+ */
8
+ intMakeBetween(num, min, max) {
9
+ return Math.max.apply(Math, [min, Math.min.apply(Math, [max, num])]);
10
+ }
11
11
 
12
- getRandomInt(max) {
13
- return this.getRandomIntBetween(0, max);
14
- }
12
+ /**
13
+ * Generates a random integer between 0 and the specified maximum value.
14
+ *
15
+ * @param {number} max - The maximum value for the random integer.
16
+ * @returns {number} The random integer generated.
17
+ */
18
+ getRandomInt(max) {
19
+ return this.getRandomIntBetween(0, max);
20
+ }
15
21
 
16
- getRandomIntBetween(min, max) {
17
- return Math.floor(Math.random() * (max - min + 1)) + min;
18
- }
22
+ /**
23
+ * Generates a random integer between the given minimum and maximum values (inclusive).
24
+ *
25
+ * @param {number} min - The minimum value.
26
+ * @param {number} max - The maximum value.
27
+ * @returns {number} The random integer between min and max.
28
+ */
29
+ getRandomIntBetween(min, max) {
30
+ return Math.floor(Math.random() * (max - min + 1)) + min;
31
+ }
32
+
33
+ /**
34
+ * round float number to digits count
35
+ * @param {Number} num
36
+ * @param {Number} digits - rounding digits count
37
+ * @returns {Number}
38
+ */
39
+ roundToDigits(num, digits) {
40
+ if (isNaN(num) || isNaN(digits)) return false;
41
+
42
+ const pow = Math.pow(10, digits);
43
+ return Math.round(num * pow) / pow;
44
+ }
45
+
46
+ /**
47
+ * Checks if a given value is an integer.
48
+ *
49
+ * @param {number} n - The value to be checked.
50
+ * @returns {boolean} - Returns true if the value is an integer, otherwise returns false.
51
+ */
52
+ isInt(n) {
53
+ return Number(n) === n && n % 1 === 0;
54
+ }
55
+
56
+ /**
57
+ * Checks if a given number is a floating-point number.
58
+ *
59
+ * @param {number} n - The number to be checked.
60
+ * @returns {boolean} - Returns true if the number is a floating-point number, otherwise returns false.
61
+ */
62
+ isFloat(n) {
63
+ return Number(n) === n && n % 1 !== 0;
64
+ }
65
+
66
+ /**
67
+ * Calculates the length of the decimal part of a number.
68
+ *
69
+ * @param {number} number - The number to calculate the decimal length for.
70
+ * @returns {number} The length of the decimal part of the number.
71
+ */
72
+ getDecimalsLength(number) {
73
+ return Number(number.toString().split(".")[1]?.length || 0);
74
+ }
75
+
76
+ /**
77
+ * Multiplies an array of floating-point numbers.
78
+ *
79
+ * @param {number[]} numsArray - The array of numbers to be multiplied.
80
+ * @returns {number} The result of multiplying all the numbers in the array.
81
+ */
82
+ multiplyFloats(numsArray) {
83
+ let result = numsArray.reduce((acc, num) => acc * num);
84
+ return this._processFloat(result, numsArray);
85
+ }
19
86
 
20
- /**
21
- * round float number to digits count
22
- * @param {Number} num
23
- * @param {Number} digits - rounding digits count
24
- * @returns {Number}
25
- */
26
- roundToDigits(num, digits) {
27
- if (isNaN(num) || isNaN(digits))
28
- return false;
29
-
30
- const pow = Math.pow(10, digits);
31
- return Math.round(num * pow) / pow;
87
+ /**
88
+ * Adds an array of floating-point numbers.
89
+ *
90
+ * @param {number[]} numsArray - The array of numbers to be added.
91
+ * @returns {number} - The sum of the numbers in the array.
92
+ */
93
+ addFloats(numsArray) {
94
+ let result = numsArray.reduce((acc, num) => acc + num);
95
+ return this._processFloat(result, numsArray);
96
+ }
97
+
98
+ /**
99
+ * Subtracts an array of floating-point numbers.
100
+ *
101
+ * @param {number[]} numsArray - The array of numbers to subtract.
102
+ * @returns {number} - The result of subtracting the numbers.
103
+ */
104
+ subtractFloats(numsArray) {
105
+ let result = numsArray.reduce((acc, num) => acc - num);
106
+ return this._processFloat(result, numsArray);
107
+ }
108
+
109
+ /**
110
+ * Processes the float values in the given array and returns the result.
111
+ * @param {number} result - The initial result value.
112
+ * @param {number[]} numsArray - The array of numbers to process.
113
+ * @returns {number} - The processed result value.
114
+ */
115
+ _processFloat(result, numsArray) {
116
+ let floatsExist = false;
117
+
118
+ numsArray.forEach((element) => {
119
+ if (this.isFloat(element)) {
120
+ floatsExist = true;
121
+ }
122
+ });
123
+
124
+ if (floatsExist) {
125
+ result = this._strip(result);
32
126
  }
33
127
 
128
+ return result;
129
+ }
130
+
131
+ /**
132
+ * Calculates the maximum length of decimals in an array of numbers.
133
+ *
134
+ * @param {number[]} numsArray - The array of numbers.
135
+ * @returns {number} - The maximum length of decimals.
136
+ */
137
+ getMaxDecimalsLength(numsArray) {
138
+ let maxDecimalLength = 0;
139
+
140
+ numsArray.forEach((num) => {
141
+ if (!num) return 0;
142
+
143
+ const currentDecimalLength = this.getDecimalsLength(num);
144
+ maxDecimalLength = Math.max(currentDecimalLength, maxDecimalLength);
145
+ });
146
+
147
+ return maxDecimalLength;
148
+ }
149
+
150
+ /**
151
+ * Strips the decimal places of a number.
152
+ *
153
+ * @param {number} number - The number to strip the decimal places from.
154
+ * @returns {number} - The number with stripped decimal places.
155
+ */
156
+ _strip(number) {
157
+ return Number(number.toPrecision(12));
158
+ }
34
159
  }
35
160
 
36
- module.exports = LibMath;
161
+ module.exports = LibMath;