@woosh/meep-engine 2.94.2 → 2.94.4
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/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +91 -64
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +91 -64
- package/package.json +1 -1
- package/src/core/assert.d.ts +6 -0
- package/src/core/assert.d.ts.map +1 -1
- package/src/core/assert.js +13 -0
- package/src/core/binary/BitSet.js +3 -3
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +29 -18
- package/src/core/geom/Quaternion.spec.js +27 -1
- package/src/core/json/resolvePath.d.ts +1 -1
- package/src/core/json/resolvePath.d.ts.map +1 -1
- package/src/core/json/resolvePath.js +5 -1
- package/src/core/math/iabs.d.ts +9 -0
- package/src/core/math/iabs.d.ts.map +1 -0
- package/src/core/math/iabs.js +15 -0
- package/src/core/math/iabs.spec.d.ts +2 -0
- package/src/core/math/iabs.spec.d.ts.map +1 -0
- package/src/core/math/iabs.spec.js +9 -0
- package/src/engine/ecs/transform/Transform.d.ts.map +1 -1
- package/src/engine/ecs/transform/Transform.js +18 -13
- package/src/engine/ecs/transform/Transform.spec.js +50 -11
package/build/meep.cjs
CHANGED
|
@@ -504,6 +504,19 @@ assert.isFunction = function (value, name = 'value') {
|
|
|
504
504
|
}
|
|
505
505
|
};
|
|
506
506
|
|
|
507
|
+
/**
|
|
508
|
+
*
|
|
509
|
+
* @param {Object|*} value
|
|
510
|
+
* @param {string} [name]
|
|
511
|
+
*/
|
|
512
|
+
assert.isObject = function (value, name = 'value') {
|
|
513
|
+
const typeofValue = typeof value;
|
|
514
|
+
|
|
515
|
+
if (typeofValue !== 'object') {
|
|
516
|
+
throw new Error(`expected ${name} to be an object, instead was '${typeofValue}'(=${value})`);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
|
|
507
520
|
/**
|
|
508
521
|
*
|
|
509
522
|
* @param {number|*} value
|
|
@@ -1725,6 +1738,23 @@ function clamp$1(value, min, max) {
|
|
|
1725
1738
|
}
|
|
1726
1739
|
}
|
|
1727
1740
|
|
|
1741
|
+
/**
|
|
1742
|
+
* Clamps a value to 0..1 range
|
|
1743
|
+
* Same as `clamp(value, 0, 1)`
|
|
1744
|
+
* Works the same as `saturate` function in GLSL
|
|
1745
|
+
* @param {number} value
|
|
1746
|
+
* @returns {number}
|
|
1747
|
+
*/
|
|
1748
|
+
function clamp01(value) {
|
|
1749
|
+
if (value < 0) {
|
|
1750
|
+
return 0;
|
|
1751
|
+
} else if (value > 1) {
|
|
1752
|
+
return 1;
|
|
1753
|
+
} else {
|
|
1754
|
+
return value;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1728
1758
|
/**
|
|
1729
1759
|
* Very small value, used for comparison when compensation for rounding error is required
|
|
1730
1760
|
* @type {number}
|
|
@@ -1754,16 +1784,6 @@ function lerp$1(a, b, fraction) {
|
|
|
1754
1784
|
return (b - a) * fraction + a;
|
|
1755
1785
|
}
|
|
1756
1786
|
|
|
1757
|
-
/**
|
|
1758
|
-
* Returns lowest value out of 2 supplied
|
|
1759
|
-
* @param {number} a
|
|
1760
|
-
* @param {number} b
|
|
1761
|
-
* @returns {number}
|
|
1762
|
-
*/
|
|
1763
|
-
function min2(a, b) {
|
|
1764
|
-
return a < b ? a : b;
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
1787
|
/**
|
|
1768
1788
|
*
|
|
1769
1789
|
* @param {number} v
|
|
@@ -4254,23 +4274,23 @@ let Quaternion$1 = class Quaternion {
|
|
|
4254
4274
|
this.set(x, y, z, w);
|
|
4255
4275
|
}
|
|
4256
4276
|
|
|
4257
|
-
|
|
4258
4277
|
/**
|
|
4259
|
-
*
|
|
4260
|
-
* @param {Quaternion}
|
|
4278
|
+
*
|
|
4279
|
+
* @param {Quaternion} from
|
|
4280
|
+
* @param {Quaternion} to
|
|
4261
4281
|
* @param {number} t
|
|
4262
4282
|
*/
|
|
4263
|
-
|
|
4283
|
+
slerpQuaternions(from, to, t) {
|
|
4264
4284
|
|
|
4265
|
-
const ax =
|
|
4266
|
-
ay =
|
|
4267
|
-
az =
|
|
4268
|
-
aw =
|
|
4285
|
+
const ax = from.x,
|
|
4286
|
+
ay = from.y,
|
|
4287
|
+
az = from.z,
|
|
4288
|
+
aw = from.w;
|
|
4269
4289
|
|
|
4270
|
-
let bx =
|
|
4271
|
-
by =
|
|
4272
|
-
bz =
|
|
4273
|
-
bw =
|
|
4290
|
+
let bx = to.x,
|
|
4291
|
+
by = to.y,
|
|
4292
|
+
bz = to.z,
|
|
4293
|
+
bw = to.w;
|
|
4274
4294
|
|
|
4275
4295
|
let omega, cosom, sinom, scale0, scale1;
|
|
4276
4296
|
|
|
@@ -4308,6 +4328,16 @@ let Quaternion$1 = class Quaternion {
|
|
|
4308
4328
|
this.set(_x, _y, _z, _w);
|
|
4309
4329
|
}
|
|
4310
4330
|
|
|
4331
|
+
|
|
4332
|
+
/**
|
|
4333
|
+
* @see https://github.com/toji/gl-matrix/blob/master/src/gl-matrix/quat.js
|
|
4334
|
+
* @param {Quaternion} other
|
|
4335
|
+
* @param {number} t
|
|
4336
|
+
*/
|
|
4337
|
+
slerp(other, t) {
|
|
4338
|
+
this.slerpQuaternions(this, other, t);
|
|
4339
|
+
}
|
|
4340
|
+
|
|
4311
4341
|
/**
|
|
4312
4342
|
* @see https://github.com/gareth-cross/quat/blob/master/include/quaternion.hpp
|
|
4313
4343
|
* TODO implement
|
|
@@ -4589,9 +4619,9 @@ let Quaternion$1 = class Quaternion {
|
|
|
4589
4619
|
|
|
4590
4620
|
/**
|
|
4591
4621
|
*
|
|
4592
|
-
* @param {number} x
|
|
4593
|
-
* @param {number} y
|
|
4594
|
-
* @param {number} z
|
|
4622
|
+
* @param {number} x in radians
|
|
4623
|
+
* @param {number} y in radians
|
|
4624
|
+
* @param {number} z in radians
|
|
4595
4625
|
* @returns {Quaternion}
|
|
4596
4626
|
*/
|
|
4597
4627
|
static fromEulerAngles(x, y, z) {
|
|
@@ -4618,9 +4648,9 @@ let Quaternion$1 = class Quaternion {
|
|
|
4618
4648
|
result.copy(to);
|
|
4619
4649
|
} else {
|
|
4620
4650
|
// clamp to 1, to make sure we don't overshoot
|
|
4621
|
-
const t =
|
|
4651
|
+
const t = clamp01(max_delta / angle);
|
|
4622
4652
|
|
|
4623
|
-
|
|
4653
|
+
result.slerpQuaternions(from, to, t);
|
|
4624
4654
|
}
|
|
4625
4655
|
|
|
4626
4656
|
}
|
|
@@ -5003,6 +5033,24 @@ class Transform {
|
|
|
5003
5033
|
toString() {
|
|
5004
5034
|
return `{ position: ${this.position}, rotation: ${this.rotation}, scale: ${this.scale} }`;
|
|
5005
5035
|
}
|
|
5036
|
+
|
|
5037
|
+
/**
|
|
5038
|
+
* @deprecated use {@link Quaternion.rotateTowards} instead
|
|
5039
|
+
* @param {Quaternion} sourceQuaternion
|
|
5040
|
+
* @param {Vector3} targetVector
|
|
5041
|
+
* @param {Number} limit
|
|
5042
|
+
*/
|
|
5043
|
+
static adjustRotation(
|
|
5044
|
+
sourceQuaternion,
|
|
5045
|
+
targetVector,
|
|
5046
|
+
limit = Infinity
|
|
5047
|
+
) {
|
|
5048
|
+
const q = new Quaternion$1();
|
|
5049
|
+
|
|
5050
|
+
q.lookRotation(targetVector);
|
|
5051
|
+
|
|
5052
|
+
sourceQuaternion.rotateTowards(q, limit);
|
|
5053
|
+
}
|
|
5006
5054
|
}
|
|
5007
5055
|
|
|
5008
5056
|
/**
|
|
@@ -5015,22 +5063,7 @@ Transform.typeName = "Transform";
|
|
|
5015
5063
|
* @readonly
|
|
5016
5064
|
* @type {boolean}
|
|
5017
5065
|
*/
|
|
5018
|
-
Transform.prototype.isTransform = true;
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
/**
|
|
5022
|
-
* @deprecated use {@link Quaternion.rotateTowards} instead
|
|
5023
|
-
* @param {Quaternion} sourceQuaternion
|
|
5024
|
-
* @param {Vector3} targetVector
|
|
5025
|
-
* @param {Number} limit
|
|
5026
|
-
*/
|
|
5027
|
-
Transform.adjustRotation = function (sourceQuaternion, targetVector, limit = Infinity) {
|
|
5028
|
-
const q = new Quaternion$1();
|
|
5029
|
-
|
|
5030
|
-
q.lookRotation(targetVector);
|
|
5031
|
-
|
|
5032
|
-
sourceQuaternion.rotateTowards(q, limit);
|
|
5033
|
-
};
|
|
5066
|
+
Transform.prototype.isTransform = true;
|
|
5034
5067
|
|
|
5035
5068
|
/**
|
|
5036
5069
|
* Common utilities
|
|
@@ -47277,6 +47310,16 @@ function max2(a, b) {
|
|
|
47277
47310
|
return a < b ? b : a;
|
|
47278
47311
|
}
|
|
47279
47312
|
|
|
47313
|
+
/**
|
|
47314
|
+
* Returns lowest value out of 2 supplied
|
|
47315
|
+
* @param {number} a
|
|
47316
|
+
* @param {number} b
|
|
47317
|
+
* @returns {number}
|
|
47318
|
+
*/
|
|
47319
|
+
function min2(a, b) {
|
|
47320
|
+
return a < b ? a : b;
|
|
47321
|
+
}
|
|
47322
|
+
|
|
47280
47323
|
/**
|
|
47281
47324
|
*
|
|
47282
47325
|
* @param {number} x
|
|
@@ -53302,23 +53345,6 @@ function bvh_query_leaves_ray(
|
|
|
53302
53345
|
return result_cursor - result_offset;
|
|
53303
53346
|
}
|
|
53304
53347
|
|
|
53305
|
-
/**
|
|
53306
|
-
* Clamps a value to 0..1 range
|
|
53307
|
-
* Same as `clamp(value, 0, 1)`
|
|
53308
|
-
* Works the same as `saturate` function in GLSL
|
|
53309
|
-
* @param {number} value
|
|
53310
|
-
* @returns {number}
|
|
53311
|
-
*/
|
|
53312
|
-
function clamp01(value) {
|
|
53313
|
-
if (value < 0) {
|
|
53314
|
-
return 0;
|
|
53315
|
-
} else if (value > 1) {
|
|
53316
|
-
return 1;
|
|
53317
|
-
} else {
|
|
53318
|
-
return value;
|
|
53319
|
-
}
|
|
53320
|
-
}
|
|
53321
|
-
|
|
53322
53348
|
/**
|
|
53323
53349
|
* Returns lowest value out of 3 supplied
|
|
53324
53350
|
* @param {number} a
|
|
@@ -70088,7 +70114,7 @@ BitSet.prototype.nextSetBit = function (fromIndex) {
|
|
|
70088
70114
|
|
|
70089
70115
|
|
|
70090
70116
|
//scan the rest of the words
|
|
70091
|
-
const word_count = bit_length /
|
|
70117
|
+
const word_count = (bit_length + 31) >> 5; // Math.ceil(x /32)
|
|
70092
70118
|
for (; word_index < word_count; word_index++) {
|
|
70093
70119
|
word = data[word_index];
|
|
70094
70120
|
|
|
@@ -70124,8 +70150,6 @@ BitSet.prototype.nextClearBit = function (fromIndex) {
|
|
|
70124
70150
|
// treat first word specially, as we may need to mask out portion of a word to skip certain number of bits
|
|
70125
70151
|
let bit_index = fromIndex & 31;
|
|
70126
70152
|
|
|
70127
|
-
const set_length = this.__length;
|
|
70128
|
-
const word_count = set_length / 32;
|
|
70129
70153
|
const data = this.__data_uint32;
|
|
70130
70154
|
|
|
70131
70155
|
if (bit_index !== 0) {
|
|
@@ -70145,6 +70169,8 @@ BitSet.prototype.nextClearBit = function (fromIndex) {
|
|
|
70145
70169
|
|
|
70146
70170
|
word_index++;
|
|
70147
70171
|
}
|
|
70172
|
+
const set_length = this.__length;
|
|
70173
|
+
const word_count = (set_length + 31) >> 5; // Math.ceil(x /32)
|
|
70148
70174
|
|
|
70149
70175
|
//scan the rest
|
|
70150
70176
|
for (; word_index < word_count; word_index++) {
|
|
@@ -113613,12 +113639,13 @@ function resolvePathByArray(object, parts, missingPropertyHandler) {
|
|
|
113613
113639
|
/**
|
|
113614
113640
|
*
|
|
113615
113641
|
* @param {object} object
|
|
113616
|
-
* @param {string} path
|
|
113642
|
+
* @param {string} path separated with forward slash "/"
|
|
113617
113643
|
* @param {function} [missingPropertyHandler] Allows custom handling of missing properties
|
|
113618
113644
|
* @returns {*}
|
|
113619
113645
|
* @throws {Error} if a path can not be resolved
|
|
113620
113646
|
*/
|
|
113621
113647
|
function resolvePath(object, path, missingPropertyHandler) {
|
|
113648
|
+
|
|
113622
113649
|
const parts = path.split("/");
|
|
113623
113650
|
|
|
113624
113651
|
return resolvePathByArray(object, parts, missingPropertyHandler);
|