@woosh/meep-engine 2.114.0 → 2.115.0
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/meep.cjs +92 -53
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +92 -53
- package/editor/ecs/component/editors/Sampler2DEditor.js +3 -3
- package/package.json +1 -1
- package/src/core/binary/clz32.d.ts +7 -0
- package/src/core/binary/clz32.d.ts.map +1 -0
- package/src/core/binary/clz32.js +37 -0
- package/src/core/binary/is_data_url.d.ts.map +1 -1
- package/src/core/binary/is_data_url.js +1 -0
- package/src/core/binary/makeArrayBuffer.d.ts.map +1 -1
- package/src/core/binary/makeArrayBuffer.js +1 -0
- package/src/core/binary/msb_32.d.ts +7 -1
- package/src/core/binary/msb_32.d.ts.map +1 -1
- package/src/core/binary/msb_32.js +3 -12
- package/src/core/collection/RingBuffer.d.ts +1 -1
- package/src/core/collection/RingBuffer.js +1 -1
- package/src/core/collection/array/combine_hash.js +1 -1
- package/src/core/{primitives → collection}/array/compareArrays.d.ts.map +1 -1
- package/src/core/{primitives → collection}/array/computeIntegerArrayHash.d.ts.map +1 -1
- package/src/core/{primitives → collection}/array/computeStridedArrayHash.d.ts.map +1 -1
- package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.d.ts.map +1 -1
- package/src/core/collection/array/randomMultipleFromArray.d.ts +6 -6
- package/src/core/collection/array/randomMultipleFromArray.d.ts.map +1 -1
- package/src/core/collection/array/randomMultipleFromArray.js +5 -5
- package/src/core/collection/array/typed/sparse_typed_array_hash.js +1 -1
- package/src/core/collection/array/typed/typedArrayConstructorByInstance.d.ts.map +1 -0
- package/src/core/geom/2d/Rectangle.d.ts.map +1 -1
- package/src/core/geom/2d/Rectangle.js +18 -5
- package/src/core/geom/2d/aabb/aabb2_overlap_exists.d.ts.map +1 -1
- package/src/core/geom/2d/aabb/aabb2_overlap_exists.js +4 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.d.ts +3 -3
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.d.ts.map +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +11 -4
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +2 -2
- package/src/core/geom/2d/convex-hull/orientation3_array.js +2 -2
- package/src/core/geom/2d/intersect_ray_2d.d.ts.map +1 -1
- package/src/core/geom/2d/intersect_ray_2d.js +5 -5
- package/src/core/geom/2d/{compute_triangle_area_2d.d.ts → triangle2d_compute_area.d.ts} +2 -2
- package/src/core/geom/2d/triangle2d_compute_area.d.ts.map +1 -0
- package/src/core/geom/2d/{compute_triangle_area_2d.js → triangle2d_compute_area.js} +1 -1
- package/src/core/geom/2d/triangle2d_contains_point.d.ts +14 -0
- package/src/core/geom/2d/triangle2d_contains_point.d.ts.map +1 -0
- package/src/core/geom/2d/triangle2d_contains_point.js +39 -0
- package/src/core/geom/2d/triangle2d_get_barycentric.d.ts +2 -2
- package/src/core/geom/2d/triangle2d_get_barycentric.d.ts.map +1 -1
- package/src/core/geom/2d/triangle2d_get_barycentric.js +1 -1
- package/src/core/geom/Vector2.d.ts.map +1 -1
- package/src/core/geom/Vector2.js +2 -2
- package/src/core/math/bessel_3.d.ts +1 -1
- package/src/core/math/bessel_3.js +1 -1
- package/src/core/math/computeWholeDivisorLow.d.ts +1 -1
- package/src/core/math/computeWholeDivisorLow.d.ts.map +1 -1
- package/src/core/math/computeWholeDivisorLow.js +8 -5
- package/src/core/math/interval/separation1D.d.ts.map +1 -0
- package/src/core/math/{separation1D.js → interval/separation1D.js} +3 -3
- package/src/core/math/solveQuadratic.d.ts.map +1 -1
- package/src/core/math/solveQuadratic.js +10 -0
- package/src/core/model/object/compareValues.js +3 -3
- package/src/engine/EntityCreator.d.ts +11 -11
- package/src/engine/EntityCreator.d.ts.map +1 -1
- package/src/engine/EntityCreator.js +2 -4
- package/src/engine/ecs/grid/HeightMap2NormalMap.js +2 -2
- package/src/engine/ecs/grid/NormalMap2AOMap.js +3 -3
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +2 -2
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +5 -55
- package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.d.ts +9 -0
- package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.d.ts.map +1 -0
- package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.js +64 -0
- package/src/engine/graphics/sh3/path_tracer/material/MaterialConverter.js +2 -2
- package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +4 -2
- package/src/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +1 -1
- package/src/engine/graphics/texture/sampler/filter/sampler2d_scale_down_generic.js +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_multiply_vector.d.ts +8 -0
- package/src/engine/graphics/texture/sampler/sampler2d_multiply_vector.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/{sampler_multiply_vector.js → sampler2d_multiply_vector.js} +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_to_float32_texture.d.ts +8 -0
- package/src/engine/graphics/texture/sampler/sampler2d_to_float32_texture.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/{sampler2DToFloat32Texture.js → sampler2d_to_float32_texture.js} +2 -2
- package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.js +3 -1
- package/src/engine/grid/obstacle/GridObstacle.d.ts.map +1 -1
- package/src/engine/grid/obstacle/GridObstacle.js +1 -1
- package/src/engine/physics/computeInterceptPoint.js +20 -6
- package/src/engine/physics/mls-mpm/MLS_MPM.d.ts.map +1 -1
- package/src/engine/physics/mls-mpm/MLS_MPM.js +14 -17
- package/src/core/UUID.d.ts +0 -6
- package/src/core/UUID.d.ts.map +0 -1
- package/src/core/UUID.js +0 -21
- package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +0 -1
- package/src/core/geom/2d/convex-hull/orientation3.d.ts +0 -12
- package/src/core/geom/2d/convex-hull/orientation3.d.ts.map +0 -1
- package/src/core/geom/2d/convex-hull/orientation3.js +0 -489
- package/src/core/geom/2d/convex-hull/orientation3_v2.d.ts +0 -9
- package/src/core/geom/2d/convex-hull/orientation3_v2.d.ts.map +0 -1
- package/src/core/geom/2d/convex-hull/orientation3_v2.js +0 -12
- package/src/core/math/separation1D.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.d.ts +0 -8
- package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/sampler_multiply_vector.d.ts +0 -8
- package/src/engine/graphics/texture/sampler/sampler_multiply_vector.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/typedArrayConstructorByInstance.d.ts.map +0 -1
- package/src/engine/save/storage/InMemoryLocalStorage.d.ts +0 -6
- package/src/engine/save/storage/InMemoryLocalStorage.d.ts.map +0 -1
- package/src/engine/save/storage/InMemoryLocalStorage.js +0 -13
- /package/src/core/{primitives → collection}/array/compareArrays.d.ts +0 -0
- /package/src/core/{primitives → collection}/array/compareArrays.js +0 -0
- /package/src/core/{primitives → collection}/array/computeIntegerArrayHash.d.ts +0 -0
- /package/src/core/{primitives → collection}/array/computeIntegerArrayHash.js +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedArrayHash.d.ts +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedArrayHash.js +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.d.ts +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.js +0 -0
- /package/src/{engine/graphics/texture/sampler → core/collection/array/typed}/typedArrayConstructorByInstance.d.ts +0 -0
- /package/src/{engine/graphics/texture/sampler → core/collection/array/typed}/typedArrayConstructorByInstance.js +0 -0
- /package/src/core/math/{separation1D.d.ts → interval/separation1D.d.ts} +0 -0
package/build/meep.module.js
CHANGED
|
@@ -47413,7 +47413,7 @@ class Vector2 {
|
|
|
47413
47413
|
|
|
47414
47414
|
/**
|
|
47415
47415
|
*
|
|
47416
|
-
* @param {number[]} array
|
|
47416
|
+
* @param {number[]|Float32Array} array
|
|
47417
47417
|
* @param {number} offset
|
|
47418
47418
|
*/
|
|
47419
47419
|
fromArray(array, offset = 0) {
|
|
@@ -47425,7 +47425,7 @@ class Vector2 {
|
|
|
47425
47425
|
|
|
47426
47426
|
/**
|
|
47427
47427
|
*
|
|
47428
|
-
* @param {number[]} array
|
|
47428
|
+
* @param {number[]|Float32Array} array
|
|
47429
47429
|
* @param {number} offset
|
|
47430
47430
|
*/
|
|
47431
47431
|
toArray(array, offset = 0) {
|
|
@@ -49001,6 +49001,34 @@ function compute_typed_array_constructor_from_data_type(dt) {
|
|
|
49001
49001
|
return r;
|
|
49002
49002
|
}
|
|
49003
49003
|
|
|
49004
|
+
/**
|
|
49005
|
+
* Useful for computing hashes of large arrays, can pick a relevant stride and skip large chunks of memory while still capturing good amount of unique information from evenly-spaced areas of the array
|
|
49006
|
+
* @param {number[]|Uint32Array|Uint16Array|Uint8Array} array
|
|
49007
|
+
* @param {number} offset
|
|
49008
|
+
* @param {number} length
|
|
49009
|
+
* @param {number} stride
|
|
49010
|
+
* @return {number}
|
|
49011
|
+
*/
|
|
49012
|
+
function computeStridedIntegerArrayHash(
|
|
49013
|
+
array, offset, length, stride
|
|
49014
|
+
) {
|
|
49015
|
+
let hash = length;
|
|
49016
|
+
|
|
49017
|
+
for (let i = offset; i < length; i += stride) {
|
|
49018
|
+
const value = array[i] >>> 0; //force uint32
|
|
49019
|
+
|
|
49020
|
+
/**
|
|
49021
|
+
* Simple hashing scheme, multiplying existing hash by a prime and adding next value
|
|
49022
|
+
* (h<<5) - h === h*31
|
|
49023
|
+
* @type {number}
|
|
49024
|
+
*/
|
|
49025
|
+
hash = ((hash << 5) - hash) + value;
|
|
49026
|
+
}
|
|
49027
|
+
|
|
49028
|
+
// force uint32
|
|
49029
|
+
return hash >>> 0;
|
|
49030
|
+
}
|
|
49031
|
+
|
|
49004
49032
|
/**
|
|
49005
49033
|
*
|
|
49006
49034
|
* @param {*} array
|
|
@@ -49126,47 +49154,6 @@ function is_typed_array_equals(a, b) {
|
|
|
49126
49154
|
return isArrayEqualStrict(a_proxy, b_proxy);
|
|
49127
49155
|
}
|
|
49128
49156
|
|
|
49129
|
-
/**
|
|
49130
|
-
* Based on code from reddit https://www.reddit.com/r/javascript/comments/jxa8x/bicubic_interpolation/
|
|
49131
|
-
* @param {number} t ratio
|
|
49132
|
-
* @param {number} a position -2
|
|
49133
|
-
* @param {number} b position -1
|
|
49134
|
-
* @param {number} c position +1
|
|
49135
|
-
* @param {number} d position +2
|
|
49136
|
-
* @returns {number}
|
|
49137
|
-
*/
|
|
49138
|
-
function interpolate_bicubic(t, a, b, c, d) {
|
|
49139
|
-
return 0.5 * (c - a + (2.0 * a - 5.0 * b + 4.0 * c - d + (3.0 * (b - c) + d - a) * t) * t) * t + b;
|
|
49140
|
-
}
|
|
49141
|
-
|
|
49142
|
-
/**
|
|
49143
|
-
* Useful for computing hashes of large arrays, can pick a relevant stride and skip large chunks of memory while still capturing good amount of unique information from evenly-spaced areas of the array
|
|
49144
|
-
* @param {number[]|Uint32Array|Uint16Array|Uint8Array} array
|
|
49145
|
-
* @param {number} offset
|
|
49146
|
-
* @param {number} length
|
|
49147
|
-
* @param {number} stride
|
|
49148
|
-
* @return {number}
|
|
49149
|
-
*/
|
|
49150
|
-
function computeStridedIntegerArrayHash(
|
|
49151
|
-
array, offset, length, stride
|
|
49152
|
-
) {
|
|
49153
|
-
let hash = length;
|
|
49154
|
-
|
|
49155
|
-
for (let i = offset; i < length; i += stride) {
|
|
49156
|
-
const value = array[i] >>> 0; //force uint32
|
|
49157
|
-
|
|
49158
|
-
/**
|
|
49159
|
-
* Simple hashing scheme, multiplying existing hash by a prime and adding next value
|
|
49160
|
-
* (h<<5) - h === h*31
|
|
49161
|
-
* @type {number}
|
|
49162
|
-
*/
|
|
49163
|
-
hash = ((hash << 5) - hash) + value;
|
|
49164
|
-
}
|
|
49165
|
-
|
|
49166
|
-
// force uint32
|
|
49167
|
-
return hash >>> 0;
|
|
49168
|
-
}
|
|
49169
|
-
|
|
49170
49157
|
function typedArrayConstructorByInstance(a) {
|
|
49171
49158
|
if (a instanceof Int8Array) {
|
|
49172
49159
|
return Int8Array;
|
|
@@ -49193,6 +49180,19 @@ function typedArrayConstructorByInstance(a) {
|
|
|
49193
49180
|
}
|
|
49194
49181
|
}
|
|
49195
49182
|
|
|
49183
|
+
/**
|
|
49184
|
+
* Based on code from reddit https://www.reddit.com/r/javascript/comments/jxa8x/bicubic_interpolation/
|
|
49185
|
+
* @param {number} t ratio
|
|
49186
|
+
* @param {number} a position -2
|
|
49187
|
+
* @param {number} b position -1
|
|
49188
|
+
* @param {number} c position +1
|
|
49189
|
+
* @param {number} d position +2
|
|
49190
|
+
* @returns {number}
|
|
49191
|
+
*/
|
|
49192
|
+
function interpolate_bicubic(t, a, b, c, d) {
|
|
49193
|
+
return 0.5 * (c - a + (2.0 * a - 5.0 * b + 4.0 * c - d + (3.0 * (b - c) + d - a) * t) * t) * t + b;
|
|
49194
|
+
}
|
|
49195
|
+
|
|
49196
49196
|
/**
|
|
49197
49197
|
* Data Texture class, providing an abstraction around 2d numerical arrays, mostly for sampling purposes
|
|
49198
49198
|
* Inspired by OpenGL's glsl sampler2d API
|
|
@@ -54442,7 +54442,10 @@ function overlap1D(a0, a1, b0, b1) {
|
|
|
54442
54442
|
* @param {number} by1
|
|
54443
54443
|
* @returns {boolean} true if overlap exists, false if no overlap
|
|
54444
54444
|
*/
|
|
54445
|
-
function aabb2_overlap_exists(
|
|
54445
|
+
function aabb2_overlap_exists(
|
|
54446
|
+
ax0, ay0, ax1, ay1,
|
|
54447
|
+
bx0, by0, bx1, by1
|
|
54448
|
+
) {
|
|
54446
54449
|
return overlap1D(ax0, ax1, bx0, bx1)
|
|
54447
54450
|
&& overlap1D(ay0, ay1, by0, by1);
|
|
54448
54451
|
}
|
|
@@ -59310,7 +59313,7 @@ function computeThreeTextureInternalFormatFromDataType(dt, channel_count) {
|
|
|
59310
59313
|
* @param {Sampler2D} sampler
|
|
59311
59314
|
* @returns {DataTexture}
|
|
59312
59315
|
*/
|
|
59313
|
-
function
|
|
59316
|
+
function sampler2d_to_float32_texture(sampler) {
|
|
59314
59317
|
|
|
59315
59318
|
const width = sampler.width;
|
|
59316
59319
|
const height = sampler.height;
|
|
@@ -59383,7 +59386,7 @@ function heightMap2NormalMap(renderer, sampler) {
|
|
|
59383
59386
|
const width = sampler.width;
|
|
59384
59387
|
const height = sampler.height;
|
|
59385
59388
|
|
|
59386
|
-
const texture =
|
|
59389
|
+
const texture = sampler2d_to_float32_texture(sampler);
|
|
59387
59390
|
|
|
59388
59391
|
//construct shader
|
|
59389
59392
|
const shader = new NormalMapShader();
|
|
@@ -59686,9 +59689,9 @@ function normalMap2OcclusionMap(
|
|
|
59686
59689
|
const width = resultSize.x;
|
|
59687
59690
|
const height = resultSize.y;
|
|
59688
59691
|
//
|
|
59689
|
-
const normalTexture =
|
|
59692
|
+
const normalTexture = sampler2d_to_float32_texture(normalMap);
|
|
59690
59693
|
|
|
59691
|
-
const heightTexture =
|
|
59694
|
+
const heightTexture = sampler2d_to_float32_texture(heightMap);
|
|
59692
59695
|
|
|
59693
59696
|
|
|
59694
59697
|
//construct shader
|
|
@@ -87418,7 +87421,7 @@ class RingBuffer {
|
|
|
87418
87421
|
}
|
|
87419
87422
|
|
|
87420
87423
|
/**
|
|
87421
|
-
*
|
|
87424
|
+
* Removed first element that fulfills the criteria
|
|
87422
87425
|
* @param {function(V):boolean} condition
|
|
87423
87426
|
* @param {*} [thisArg]
|
|
87424
87427
|
* @returns {V|undefined}
|
|
@@ -99187,6 +99190,30 @@ function intersects1D(a0, a1, b0, b1) {
|
|
|
99187
99190
|
return a1 >= b0 && b1 >= a0;
|
|
99188
99191
|
}
|
|
99189
99192
|
|
|
99193
|
+
/**
|
|
99194
|
+
*
|
|
99195
|
+
* @param {number} bounds_x0
|
|
99196
|
+
* @param {number} bounds_y0
|
|
99197
|
+
* @param {number} bounds_x1
|
|
99198
|
+
* @param {number} bounds_y1
|
|
99199
|
+
* @param {number} x0
|
|
99200
|
+
* @param {number} y0
|
|
99201
|
+
* @param {number} x1
|
|
99202
|
+
* @param {number} y1
|
|
99203
|
+
* @return {boolean}
|
|
99204
|
+
*/
|
|
99205
|
+
function aabb2_contains(
|
|
99206
|
+
bounds_x0, bounds_y0, bounds_x1, bounds_y1,
|
|
99207
|
+
x0, y0, x1, y1
|
|
99208
|
+
) {
|
|
99209
|
+
|
|
99210
|
+
return x0 >= bounds_x0
|
|
99211
|
+
&& x1 <= bounds_x1
|
|
99212
|
+
&& y0 >= bounds_y0
|
|
99213
|
+
&& y1 <= bounds_y1
|
|
99214
|
+
;
|
|
99215
|
+
}
|
|
99216
|
+
|
|
99190
99217
|
class Rectangle {
|
|
99191
99218
|
/**
|
|
99192
99219
|
*
|
|
@@ -99323,8 +99350,13 @@ class Rectangle {
|
|
|
99323
99350
|
|
|
99324
99351
|
const _x0 = p.x;
|
|
99325
99352
|
const _y0 = p.y;
|
|
99353
|
+
const _x1 = s.x + _x0;
|
|
99354
|
+
const _y1 = _y0 + s.y;
|
|
99326
99355
|
|
|
99327
|
-
return
|
|
99356
|
+
return aabb2_overlap_exists(
|
|
99357
|
+
_x0, _y0, _x1, _y1,
|
|
99358
|
+
x0, y0, x1, y1
|
|
99359
|
+
);
|
|
99328
99360
|
}
|
|
99329
99361
|
|
|
99330
99362
|
/**
|
|
@@ -99337,6 +99369,7 @@ class Rectangle {
|
|
|
99337
99369
|
const y0 = other.position.y;
|
|
99338
99370
|
const y1 = other.size.y + y0;
|
|
99339
99371
|
const x1 = other.size.x + x0;
|
|
99372
|
+
|
|
99340
99373
|
return this._overlaps(x0, y0, x1, y1);
|
|
99341
99374
|
}
|
|
99342
99375
|
|
|
@@ -99396,13 +99429,18 @@ class Rectangle {
|
|
|
99396
99429
|
_contains(x0, y0, x1, y1) {
|
|
99397
99430
|
const size = this.size;
|
|
99398
99431
|
|
|
99399
|
-
const
|
|
99400
|
-
|
|
99432
|
+
const position = this.position;
|
|
99433
|
+
|
|
99434
|
+
const _x0 = position.x;
|
|
99435
|
+
const _y0 = position.y;
|
|
99401
99436
|
|
|
99402
99437
|
const _y1 = size.y + _y0;
|
|
99403
99438
|
const _x1 = size.x + _x0;
|
|
99404
99439
|
|
|
99405
|
-
return
|
|
99440
|
+
return aabb2_contains(
|
|
99441
|
+
_x0, _y0, _x1, _y1,
|
|
99442
|
+
x0, y0, x1, y1
|
|
99443
|
+
);
|
|
99406
99444
|
}
|
|
99407
99445
|
|
|
99408
99446
|
/**
|
|
@@ -99413,6 +99451,7 @@ class Rectangle {
|
|
|
99413
99451
|
contains(other) {
|
|
99414
99452
|
const x0 = other.position.x;
|
|
99415
99453
|
const y0 = other.position.y;
|
|
99454
|
+
|
|
99416
99455
|
const y1 = other.size.y + y0;
|
|
99417
99456
|
const x1 = other.size.x + x0;
|
|
99418
99457
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
typedArrayConstructorByInstance
|
|
3
|
+
} from "../../../../src/core/collection/array/typed/typedArrayConstructorByInstance.js";
|
|
1
4
|
import { FrameRunner } from "../../../../src/engine/graphics/FrameRunner.js";
|
|
2
5
|
import canvas2Sampler2D from "../../../../src/engine/graphics/texture/Canvas2Sampler2D.js";
|
|
3
6
|
import {
|
|
@@ -10,9 +13,6 @@ import {
|
|
|
10
13
|
sampler2d_compute_texel_value_conversion_scale_to_uint8
|
|
11
14
|
} from "../../../../src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js";
|
|
12
15
|
import sampler2D2Canvas from "../../../../src/engine/graphics/texture/sampler/sampler2d_to_html_canvas.js";
|
|
13
|
-
import {
|
|
14
|
-
typedArrayConstructorByInstance
|
|
15
|
-
} from "../../../../src/engine/graphics/texture/sampler/typedArrayConstructorByInstance.js";
|
|
16
16
|
import { MouseEvents } from "../../../../src/engine/input/devices/events/MouseEvents.js";
|
|
17
17
|
import { CanvasView } from "../../../../src/view/elements/CanvasView.js";
|
|
18
18
|
import EmptyView from "../../../../src/view/elements/EmptyView.js";
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clz32.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/clz32.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,yBAHW,MAAM,GACJ,MAAM,CAiClB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Count leading zeroes in a 32bit integer
|
|
3
|
+
* @param {number} x
|
|
4
|
+
* @returns {number}
|
|
5
|
+
*/
|
|
6
|
+
export function clz32(x) {
|
|
7
|
+
if (x === 0) {
|
|
8
|
+
return 32;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let v = x >>> 0;
|
|
12
|
+
let result = 0;
|
|
13
|
+
|
|
14
|
+
// Binary search.
|
|
15
|
+
if ((v & 0xFFFF0000) === 0) {
|
|
16
|
+
v <<= 16;
|
|
17
|
+
result += 16;
|
|
18
|
+
}
|
|
19
|
+
if ((v & 0xFF000000) === 0) {
|
|
20
|
+
v <<= 8;
|
|
21
|
+
result += 8;
|
|
22
|
+
}
|
|
23
|
+
if ((v & 0xF0000000) === 0) {
|
|
24
|
+
v <<= 4;
|
|
25
|
+
result += 4;
|
|
26
|
+
}
|
|
27
|
+
if ((v & 0xC0000000) === 0) {
|
|
28
|
+
v <<= 2;
|
|
29
|
+
result += 2;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if ((v & 0x80000000) === 0) {
|
|
33
|
+
result += 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is_data_url.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/is_data_url.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is_data_url.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/is_data_url.js"],"names":[],"mappings":"AACA;;;;GAIG;AACH,iCAHW,MAAM,GACL,OAAO,CAQlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeArrayBuffer.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/makeArrayBuffer.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,2CAJW,MAAM,WACN,OAAO,GACN,WAAW,GAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"makeArrayBuffer.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/makeArrayBuffer.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,2CAJW,MAAM,WACN,OAAO,GACN,WAAW,GAAC,iBAAiB,CAexC"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* get most significant set bit
|
|
3
|
+
* @see https://graphics.stanford.edu/~seander/bithacks.html
|
|
4
|
+
* @param {number} x 32 bit integer
|
|
5
|
+
* @returns {number} integer position of most significant bit
|
|
6
|
+
*/
|
|
7
|
+
export function msb_32(x: number): number;
|
|
2
8
|
//# sourceMappingURL=msb_32.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msb_32.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/msb_32.js"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"msb_32.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/msb_32.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,0BAHW,MAAM,GACJ,MAAM,CAIlB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { clz32 } from "./clz32.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* get most significant set bit
|
|
@@ -6,15 +6,6 @@ import { msb_lut_de_bruijn } from "./msb_lut_de_bruijn.js";
|
|
|
6
6
|
* @param {number} x 32 bit integer
|
|
7
7
|
* @returns {number} integer position of most significant bit
|
|
8
8
|
*/
|
|
9
|
-
function msb_32(x) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
v |= v >>> 1;
|
|
13
|
-
v |= v >>> 2;
|
|
14
|
-
v |= v >>> 4;
|
|
15
|
-
v |= v >>> 8;
|
|
16
|
-
v |= v >>> 16;
|
|
17
|
-
v = (v >>> 1) + 1;
|
|
18
|
-
|
|
19
|
-
return msb_lut_de_bruijn[(v * 0x077CB531) >>> 27];
|
|
9
|
+
export function msb_32(x) {
|
|
10
|
+
return 31 - clz32(x);
|
|
20
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../assert.js";
|
|
2
|
-
import { computeIntegerArrayHash } from "
|
|
2
|
+
import { computeIntegerArrayHash } from "./computeIntegerArrayHash.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Computes hash on integer values, useful for building composite hashes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareArrays.d.ts","sourceRoot":"","sources":["../../../../../src/core/
|
|
1
|
+
{"version":3,"file":"compareArrays.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/compareArrays.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qFAHyB,MAAM,GACnB,MAAM,CAwBjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeIntegerArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/
|
|
1
|
+
{"version":3,"file":"computeIntegerArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/computeIntegerArrayHash.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,8CAJW,UAAU,GAAC,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,UAAU,UAChD,MAAM,UACN,MAAM,UAIhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeStridedArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/
|
|
1
|
+
{"version":3,"file":"computeStridedArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/computeStridedArrayHash.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wGAPW,MAAM,UACN,MAAM,UACN,MAAM,4BACM,MAAM,6BAEjB,MAAM,CAwBjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeStridedIntegerArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/
|
|
1
|
+
{"version":3,"file":"computeStridedIntegerArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/computeStridedIntegerArrayHash.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,sDANW,MAAM,EAAE,GAAC,WAAW,GAAC,WAAW,GAAC,UAAU,UAC3C,MAAM,UACN,MAAM,UACN,MAAM,GACL,MAAM,CAoBjB"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Pick multiple random items from an array
|
|
3
3
|
*
|
|
4
4
|
* @template T
|
|
5
|
-
* @param {function} random
|
|
6
|
-
* @param {T[]} source
|
|
7
|
-
* @param {T[]} target
|
|
8
|
-
* @param {number} count how many items to pick
|
|
9
|
-
* @returns {
|
|
5
|
+
* @param {function} random random function, must return a value between 0 and 1
|
|
6
|
+
* @param {T[]} source Where to pick elements from
|
|
7
|
+
* @param {T[]} target Where to place picked elements
|
|
8
|
+
* @param {number} count how many items to pick, if this number is greater than the length of {@link source}, it will be limited to length of {@link source} instead
|
|
9
|
+
* @returns {number} number of picked elements
|
|
10
10
|
*/
|
|
11
|
-
export function randomMultipleFromArray<T>(random: Function, source: T[], target: T[], count: number):
|
|
11
|
+
export function randomMultipleFromArray<T>(random: Function, source: T[], target: T[], count: number): number;
|
|
12
12
|
//# sourceMappingURL=randomMultipleFromArray.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randomMultipleFromArray.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/randomMultipleFromArray.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,8FAHW,MAAM,
|
|
1
|
+
{"version":3,"file":"randomMultipleFromArray.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/randomMultipleFromArray.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,8FAHW,MAAM,GACJ,MAAM,CAsBlB"}
|
|
@@ -5,11 +5,11 @@ import { array_shuffle } from "./array_shuffle.js";
|
|
|
5
5
|
* Pick multiple random items from an array
|
|
6
6
|
*
|
|
7
7
|
* @template T
|
|
8
|
-
* @param {function} random
|
|
9
|
-
* @param {T[]} source
|
|
10
|
-
* @param {T[]} target
|
|
11
|
-
* @param {number} count how many items to pick
|
|
12
|
-
* @returns {
|
|
8
|
+
* @param {function} random random function, must return a value between 0 and 1
|
|
9
|
+
* @param {T[]} source Where to pick elements from
|
|
10
|
+
* @param {T[]} target Where to place picked elements
|
|
11
|
+
* @param {number} count how many items to pick, if this number is greater than the length of {@link source}, it will be limited to length of {@link source} instead
|
|
12
|
+
* @returns {number} number of picked elements
|
|
13
13
|
*/
|
|
14
14
|
export function randomMultipleFromArray(random, source, target, count) {
|
|
15
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { min2 } from "../../../math/min2.js";
|
|
2
|
-
import { computeStridedArrayHash } from "../../../primitives/array/computeStridedArrayHash.js";
|
|
3
2
|
import { computeHashFloat } from "../../../primitives/numbers/computeHashFloat.js";
|
|
3
|
+
import { computeStridedArrayHash } from "../computeStridedArrayHash.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedArrayConstructorByInstance.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/typedArrayConstructorByInstance.js"],"names":[],"mappings":"AAAA,8SAwBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rectangle.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/Rectangle.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Rectangle.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/Rectangle.js"],"names":[],"mappings":";AAOA;IACI;;;;;;;OAOG;IACH,gBANW,MAAM,MACN,MAAM,UACN,MAAM,WACN,MAAM,EAgBhB;IAXG;;;OAGG;IACH,mBAFU,OAAO,CAEgB;IAEjC;;;OAGG;IACH,eAFU,OAAO,CAEqB;IAG1C;;;OAGG;IACH,iBAEC;IAED;;;OAGG;IACH,iBAEC;IAED;;;OAGG;IACH,iBAEC;IAED;;;OAGG;IACH,iBAEC;IAED;;;;;;OAMG;IACH,OALW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,QAKhB;IAED;;;OAGG;IACH,SAFa,SAAS,CAUrB;IAED;;;OAGG;IACH,YAFW,SAAS,QAKnB;IAED;;;;;;;OAOG;IACH,gBANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAUnB;IAED;;;;OAIG;IACH,kBAHW,SAAS,GACP,OAAO,CAQnB;IAED;;;;;;;OAOG;IACH,cANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAenB;IAED;;;;OAIG;IACH,gBAHW,SAAS,GACP,OAAO,CASnB;IAED;;;;;;OAMG;IACH,iBALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAyBhB;IAED;;;OAGG;IACH,mBAFW,SAAS,QASnB;IAED;;;;;;;OAOG;IACH,cANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAiBnB;IAED;;;;OAIG;IACH,gBAHW,SAAS,GACP,OAAO,CAUnB;IAED;;;OAGG;IACH,sBAFW,OAAO,QAUjB;IAED;;;OAGG;IACH,eAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,gBAHW,MAAO,MAAM,CAAC,GAAC,YAAY,GAAC,YAAY,GAAC,UAAU,iBACnD,MAAM,QAOhB;IAED;;;MAKC;IAED,0BAGC;IAGL;;;OAGG;IACH,sBAFU,OAAO,CAEc;CAN9B;oBArSmB,eAAe"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { intersects1D } from "../../math/interval/intersects1D.js";
|
|
2
|
-
import { overlap1D } from "../../math/interval/overlap1D.js";
|
|
3
2
|
import { max2 } from "../../math/max2.js";
|
|
4
3
|
import { min2 } from "../../math/min2.js";
|
|
5
4
|
import Vector2 from "../Vector2.js";
|
|
5
|
+
import { aabb2_contains } from "./aabb/aabb2_contains.js";
|
|
6
|
+
import { aabb2_overlap_exists } from "./aabb/aabb2_overlap_exists.js";
|
|
6
7
|
|
|
7
8
|
class Rectangle {
|
|
8
9
|
/**
|
|
@@ -140,8 +141,13 @@ class Rectangle {
|
|
|
140
141
|
|
|
141
142
|
const _x0 = p.x;
|
|
142
143
|
const _y0 = p.y;
|
|
144
|
+
const _x1 = s.x + _x0;
|
|
145
|
+
const _y1 = _y0 + s.y;
|
|
143
146
|
|
|
144
|
-
return
|
|
147
|
+
return aabb2_overlap_exists(
|
|
148
|
+
_x0, _y0, _x1, _y1,
|
|
149
|
+
x0, y0, x1, y1
|
|
150
|
+
);
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
/**
|
|
@@ -154,6 +160,7 @@ class Rectangle {
|
|
|
154
160
|
const y0 = other.position.y;
|
|
155
161
|
const y1 = other.size.y + y0;
|
|
156
162
|
const x1 = other.size.x + x0;
|
|
163
|
+
|
|
157
164
|
return this._overlaps(x0, y0, x1, y1);
|
|
158
165
|
}
|
|
159
166
|
|
|
@@ -213,13 +220,18 @@ class Rectangle {
|
|
|
213
220
|
_contains(x0, y0, x1, y1) {
|
|
214
221
|
const size = this.size;
|
|
215
222
|
|
|
216
|
-
const
|
|
217
|
-
|
|
223
|
+
const position = this.position;
|
|
224
|
+
|
|
225
|
+
const _x0 = position.x;
|
|
226
|
+
const _y0 = position.y;
|
|
218
227
|
|
|
219
228
|
const _y1 = size.y + _y0;
|
|
220
229
|
const _x1 = size.x + _x0;
|
|
221
230
|
|
|
222
|
-
return
|
|
231
|
+
return aabb2_contains(
|
|
232
|
+
_x0, _y0, _x1, _y1,
|
|
233
|
+
x0, y0, x1, y1
|
|
234
|
+
);
|
|
223
235
|
}
|
|
224
236
|
|
|
225
237
|
/**
|
|
@@ -230,6 +242,7 @@ class Rectangle {
|
|
|
230
242
|
contains(other) {
|
|
231
243
|
const x0 = other.position.x;
|
|
232
244
|
const y0 = other.position.y;
|
|
245
|
+
|
|
233
246
|
const y1 = other.size.y + y0;
|
|
234
247
|
const x1 = other.size.x + x0;
|
|
235
248
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aabb2_overlap_exists.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/aabb2_overlap_exists.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,0CAVW,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,GACJ,OAAO,
|
|
1
|
+
{"version":3,"file":"aabb2_overlap_exists.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/aabb2_overlap_exists.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,0CAVW,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,GACJ,OAAO,CAQnB"}
|
|
@@ -12,7 +12,10 @@ import { overlap1D } from "../../../math/interval/overlap1D.js";
|
|
|
12
12
|
* @param {number} by1
|
|
13
13
|
* @returns {boolean} true if overlap exists, false if no overlap
|
|
14
14
|
*/
|
|
15
|
-
export function aabb2_overlap_exists(
|
|
15
|
+
export function aabb2_overlap_exists(
|
|
16
|
+
ax0, ay0, ax1, ay1,
|
|
17
|
+
bx0, by0, bx1, by1
|
|
18
|
+
) {
|
|
16
19
|
return overlap1D(ax0, ax1, bx0, bx1)
|
|
17
20
|
&& overlap1D(ay0, ay1, by0, by1);
|
|
18
21
|
}
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* @param {number[]|Float32Array} output result will be written here
|
|
7
7
|
* @param {number} output_offset offset into output array where to write the result
|
|
8
8
|
* @param {number} output_point_count number of points to comprise bounding polygon
|
|
9
|
-
* @param {number[]} input_points Points to be bounded, must be an ordered loop
|
|
9
|
+
* @param {number[]} input_points Points to be bounded, must be an ordered loop. Must form a convex hull
|
|
10
10
|
* @param {number} input_point_count number of points in the input to consider
|
|
11
|
-
* @returns {
|
|
11
|
+
* @returns {number} number of points added to the output
|
|
12
12
|
*
|
|
13
13
|
* @see 2014 "Implementation of linear minimum area enclosing triangle algorithm" Ovidiu Pârvu & David Gilbert
|
|
14
14
|
* @see https://github.com/MagnusTiberius/humus3/blob/9d43412d6e6be869e224817f0a966fe48a1af40f/Util/ConvexHull.cpp#L281
|
|
15
15
|
*/
|
|
16
|
-
export function fixed_convex_hull_humus(output: number[] | Float32Array, output_offset: number, output_point_count: number, input_points: number[], input_point_count: number):
|
|
16
|
+
export function fixed_convex_hull_humus(output: number[] | Float32Array, output_offset: number, output_point_count: number, input_points: number[], input_point_count: number): number;
|
|
17
17
|
//# sourceMappingURL=fixed_convex_hull_humus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixed_convex_hull_humus.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,gDAVW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,sBACN,MAAM,gBACN,MAAM,EAAE,qBACR,MAAM,GACJ,
|
|
1
|
+
{"version":3,"file":"fixed_convex_hull_humus.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,gDAVW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,sBACN,MAAM,gBACN,MAAM,EAAE,qBACR,MAAM,GACJ,MAAM,CA0IlB"}
|