@woosh/meep-engine 2.49.8 → 2.50.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/editor/actions/concrete/ArrayCopyAction.js +1 -1
- package/package.json +1 -1
- package/src/core/binary/BinaryBuffer.js +1 -1
- package/src/core/binary/BinaryBuffer.spec.js +128 -0
- package/src/core/binary/int32_to_binary_string.js +4 -1
- package/src/core/binary/int32_to_binary_string.spec.js +9 -0
- package/src/core/bvh2/BinaryNode.js +0 -30
- package/src/core/bvh2/binary/2/BinaryUint32BVH.js +1 -1
- package/src/core/bvh2/binary/IndexedBinaryBVH.js +1 -1
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -1
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +1 -1
- package/src/core/cache/Cache.js +31 -29
- package/src/core/cache/Cache.spec.js +4 -1
- package/src/core/collection/HashMap.js +1 -1
- package/src/core/collection/array/{copyArray.js → array_copy.js} +1 -24
- package/src/core/collection/array/array_copy_entire.js +21 -0
- package/src/core/collection/array/typed/typed_array_copy.js +1 -1
- package/src/core/collection/queue/Deque.d.ts +4 -0
- package/src/core/collection/queue/Deque.js +5 -7
- package/src/core/collection/queue/Deque.spec.js +107 -0
- package/src/core/collection/table/RowFirstTable.js +1 -1
- package/src/core/geom/2d/aabb/AABB2.d.ts +14 -0
- package/src/core/geom/2d/aabb/AABB2.js +9 -7
- package/src/core/geom/2d/aabb/AABB2.spec.js +100 -0
- package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.spec.js +11 -0
- package/src/core/geom/2d/aabb/aabb2_compute_overlap.spec.js +56 -0
- package/src/core/geom/2d/aabb/aabb2_contains.spec.js +40 -0
- package/src/core/geom/2d/bvh/Node2.js +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +1 -1
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_2d.js +35 -0
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_array_2d.js +51 -0
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_2d.js +15 -0
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_array_2d.js +30 -0
- package/src/core/geom/2d/line/line_segment_line_segment_intersection_exists_2d.js +29 -0
- package/src/core/geom/3d/aabb/AABB3.d.ts +4 -0
- package/src/core/geom/3d/aabb/AABB3.spec.js +30 -0
- package/src/core/geom/3d/matrix/m4_make_translation.js +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +1 -1
- package/src/core/geom/3d/tetrahedra/compute_circumsphere.js +1 -1
- package/src/core/geom/3d/tetrahedra/delaunay/fill_in_a_cavity.js +1 -1
- package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +1 -1
- package/src/core/geom/3d/topology/expandConnectivityByLocality.js +1 -1
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +1 -1
- package/src/core/geom/Quaternion.d.ts +11 -0
- package/src/core/geom/Quaternion.js +36 -27
- package/src/core/geom/Quaternion.spec.js +141 -0
- package/src/core/geom/Vector2.d.ts +5 -1
- package/src/core/geom/Vector2.js +24 -0
- package/src/core/geom/Vector3.d.ts +4 -0
- package/src/core/geom/Vector3.spec.js +60 -0
- package/src/core/graph/GraphUtils.js +4 -2
- package/src/core/graph/layout/CircleLayout.js +4 -2
- package/src/core/math/bessel_i0.spec.js +43 -0
- package/src/core/math/bessel_j0.js +30 -0
- package/src/core/math/hash/murmur3_32.spec.js +8 -0
- package/src/core/math/hash/squirrel3.spec.js +16 -0
- package/src/core/math/interval/NumericInterval.js +1 -0
- package/src/core/math/{bessel_i0.js → modified_bessel_i0.js} +5 -2
- package/src/core/math/noise/{create_noise_2d.js → create_simplex_noise_2d.js} +2 -2
- package/src/core/math/noise/create_simplex_noise_2d.spec.js +21 -0
- package/src/core/math/physics/irradiance/interpolate_irradiance_linear.spec.js +20 -0
- package/src/core/math/physics/irradiance/interpolate_irradiance_lograrithmic.js +4 -4
- package/src/core/math/physics/irradiance/interpolate_irradiance_lograrithmic.spec.js +18 -0
- package/src/core/math/physics/irradiance/interpolate_irradiance_smith.js +1 -1
- package/src/core/math/physics/irradiance/interpolate_irradiance_smith.spec.js +20 -0
- package/src/core/math/random/seededRandomMersenneTwister.spec.js +10 -0
- package/src/core/math/spline/spline_bezier3.js +1 -1
- package/src/core/math/spline/spline_bezier3_bounds.js +2 -1
- package/src/core/math/spline/spline_bezier3_bounds.spec.js +37 -0
- package/src/core/math/statistics/computeSampleSize_Cochran.spec.js +12 -0
- package/src/core/math/statistics/computeStatisticalPartialMedian.js +4 -0
- package/src/core/math/statistics/computeStatisticalPartialMedian.spec.js +13 -0
- package/src/core/math/vector_nd_dot.js +16 -0
- package/src/core/math/{normalizeArrayVector.js → vector_nd_normalize.js} +3 -3
- package/src/core/math/vector_nd_normalize.spec.js +15 -0
- package/src/core/process/PromiseWatcher.spec.js +1 -1
- package/src/engine/achievements/Achievement.spec.js +21 -0
- package/src/engine/animation/curve/compression/downsample_float_array_curve_by_error.js +1 -1
- package/src/engine/animation/curve/compression/prototypeCurveCompression.js +2 -2
- package/src/engine/animation/curve/compression/{animation_curve_to_float_array.js → sample_animation_curve_to_float_array.js} +10 -3
- package/src/engine/animation/curve/compression/sample_animation_curve_to_float_array.spec.js +29 -0
- package/src/engine/animation/curve/draw/build_curve_editor.js +3 -3
- package/src/engine/development/performance/RingBufferMetric.js +1 -1
- package/src/engine/ecs/EntityManager.js +1 -205
- package/src/engine/ecs/animation/Animation.js +2 -180
- package/src/engine/ecs/animation/AnimationClip.js +132 -0
- package/src/engine/ecs/animation/AnimationClip.spec.js +5 -0
- package/src/engine/ecs/animation/AnimationClipFlag.js +7 -0
- package/src/engine/ecs/animation/AnimationFlags.js +8 -0
- package/src/engine/ecs/animation/AnimationSerializationAdapter.js +32 -0
- package/src/engine/ecs/fow/FogOfWar.js +1 -1
- package/src/engine/ecs/guid/GUID.js +1 -1
- package/src/engine/ecs/systems/AnimationSystem.js +3 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +1 -1
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +1 -1
- package/src/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
- package/src/engine/ecs/transform/Transform.d.ts +2 -0
- package/src/engine/ecs/transform/Transform.spec.js +63 -0
- package/src/engine/ecs/transform-attachment/TransformAttachment.d.ts +17 -1
- package/src/engine/ecs/transform-attachment/TransformAttachment.js +12 -2
- package/src/engine/ecs/transform-attachment/TransformAttachment.spec.js +103 -0
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +1 -1
- package/src/engine/graphics/ecs/animation/AnimationControllerSystem.js +2 -1
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +1 -1
- package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.js +1 -1
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +1 -1
- package/src/engine/graphics/geometry/MikkT/GenerateTSpaces.js +1 -1
- package/src/engine/graphics/geometry/MikkT/m_getNormal.js +1 -1
- package/src/engine/graphics/geometry/MikkT/m_getTexCoord.js +1 -1
- package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +1 -1
- package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +1 -1
- package/src/engine/graphics/load_and_set_cubemap_v0.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +1 -1
- package/src/engine/graphics/render/Lines.js +1 -1
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +1 -1
- package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.js +1 -1
- package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
- package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +1 -1
- package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +1 -1
- package/src/engine/graphics/render/view/CameraView.js +1 -1
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
- package/src/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +1 -1
- package/src/engine/graphics/render/webgpu/sample/MeshInstance.js +1 -1
- package/src/engine/graphics/sh3/LightProbeVolume.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.js +1 -1
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +1 -1
- package/src/engine/graphics/texture/3d/scs3d_read_2d_slice.js +1 -1
- package/src/engine/graphics/texture/CanvasClone.js +5 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +14 -75
- package/src/engine/graphics/texture/sampler/bicubic.js +19 -19
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.spec.js +10 -0
- package/src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.spec.js +90 -0
- package/src/engine/graphics/texture/sampler/differenceSampler.js +13 -8
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_Chamfer.js +140 -0
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js +130 -0
- package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.js +10 -0
- package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.spec.js +183 -0
- package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.js +133 -0
- package/src/engine/graphics/texture/sampler/filter/kaiser_1.js +8 -4
- package/src/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +2 -0
- package/src/engine/graphics/texture/sampler/filter/mitchell.js +4 -0
- package/src/engine/graphics/texture/sampler/loadSampler2D.js +5 -2
- package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +8 -3
- package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.spec.js +13 -0
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.js +58 -0
- package/src/engine/graphics/trail/TemporalPath.js +0 -36
- package/src/engine/intelligence/behavior/composite/ParallelBehavior.spec.js +12 -12
- package/src/engine/intelligence/behavior/composite/SequenceBehavior.spec.js +17 -0
- package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.js +2 -0
- package/src/engine/knowledge/database/StaticKnowledgeDataTable.d.ts +7 -1
- package/src/engine/knowledge/database/StaticKnowledgeDataTable.spec.js +21 -0
- package/src/engine/knowledge/database/StaticKnowledgeDataTableDescriptor.d.ts +2 -2
- package/src/engine/logging/ConsoleLoggerBackend.js +4 -0
- package/src/engine/logging/VoidLoggerBackend.js +12 -0
- package/src/engine/navigation/ecs/components/computeCatmullRomSpline.js +1 -1
- package/src/engine/navigation/ecs/components/computeCatmullRomSplineUniformDistance.js +1 -1
- package/src/engine/physics/cannon/CannonJSPhysicsSystem.js +1 -1
- package/src/engine/save/GameStateLoader.js +1 -1
- package/src/engine/scene/Scene.d.ts +2 -0
- package/src/engine/scene/Scene.js +2 -2
- package/src/engine/scene/Scene.spec.js +20 -0
- package/src/engine/scene/SceneManager.d.ts +4 -0
- package/src/engine/scene/SceneManager.js +46 -23
- package/src/engine/scene/SceneManager.spec.js +107 -0
- package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.js +2 -2
- package/src/engine/ui/GUIEngine.js +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +11 -4
- package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.spec.js +30 -0
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +18 -2
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.spec.js +17 -0
- package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +2 -2
- package/src/generation/grid/GridData.js +0 -60
- package/src/generation/grid/generation/util/buildUnsignedDistanceField.js +3 -1
- package/src/generation/markers/MarkerNode.js +2 -2
- package/src/generation/theme/AreaMask.js +3 -1
- package/src/view/elements/progress/RectangularPieProgressView.js +8 -6
- package/src/core/geom/2d/LineSegment2.js +0 -175
- package/src/core/geom/Matrix4.js +0 -275
- package/src/engine/graphics/texture/sampler/distanceField.js +0 -411
- package/src/engine/graphics/texture/sampler/distanceField.spec.js +0 -184
- package/src/engine/physics/cannon/cannon.min.js +0 -27
- /package/src/engine/ecs/{animation → ik}/IKMath.js +0 -0
- /package/src/engine/ecs/{animation → ik}/IKProblem.js +0 -0
- /package/src/engine/ecs/{animation → ik}/IKSolver.js +0 -0
- /package/src/engine/ecs/{animation → ik}/InverseKinematics.js +0 -0
- /package/src/engine/ecs/{animation → ik}/InverseKinematicsSystem.js +0 -0
- /package/src/engine/ecs/{animation → ik}/OneBoneSurfaceAlignmentSolver.js +0 -0
- /package/src/engine/ecs/{animation → ik}/TwoBoneInverseKinematicsSolver.js +0 -0
- /package/src/engine/physics/spring/{Spring.js → computeHookeForce.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
2
|
-
import { array_copy } from "../../../src/core/collection/array/
|
|
2
|
+
import { array_copy } from "../../../src/core/collection/array/array_copy.js";
|
|
3
3
|
|
|
4
4
|
export class ArrayCopyAction extends Action {
|
|
5
5
|
/**
|
package/package.json
CHANGED
|
@@ -114,6 +114,19 @@ test('string read write consistency, complex', () => {
|
|
|
114
114
|
expect(actual).toEqual(expected);
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
+
test('string read write consistency, 4byte characters', () => {
|
|
118
|
+
const buffer = new BinaryBuffer();
|
|
119
|
+
|
|
120
|
+
const expected = "𓀀𓀁𓂀𓂇𓃵";
|
|
121
|
+
buffer.writeUTF8String(expected);
|
|
122
|
+
|
|
123
|
+
buffer.position = 0;
|
|
124
|
+
|
|
125
|
+
const actual = buffer.readUTF8String();
|
|
126
|
+
|
|
127
|
+
expect(actual).toEqual(expected);
|
|
128
|
+
});
|
|
129
|
+
|
|
117
130
|
test('string read write consistency, russian', () => {
|
|
118
131
|
const buffer = new BinaryBuffer();
|
|
119
132
|
|
|
@@ -166,6 +179,64 @@ test('string read write, multiple', () => {
|
|
|
166
179
|
expect(buffer.readUTF8String()).toBe('b');
|
|
167
180
|
});
|
|
168
181
|
|
|
182
|
+
test("ASCII read write consistency", () => {
|
|
183
|
+
const buffer = new BinaryBuffer();
|
|
184
|
+
|
|
185
|
+
const expected = "is this ascii?";
|
|
186
|
+
buffer.writeASCIIString(expected);
|
|
187
|
+
|
|
188
|
+
buffer.position = 0;
|
|
189
|
+
|
|
190
|
+
const actual = buffer.readASCIICharacters(expected.length);
|
|
191
|
+
|
|
192
|
+
expect(actual).toEqual(expected);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test('int8 read write consistency', () => {
|
|
196
|
+
const buffer = new BinaryBuffer();
|
|
197
|
+
|
|
198
|
+
buffer.writeInt8(0);
|
|
199
|
+
buffer.writeInt8(1);
|
|
200
|
+
buffer.writeInt8(-1);
|
|
201
|
+
buffer.writeInt8(-128);//max value
|
|
202
|
+
buffer.writeInt8(127);//max value
|
|
203
|
+
|
|
204
|
+
buffer.position = 0;
|
|
205
|
+
|
|
206
|
+
expect(buffer.readInt8()).toBe(0);
|
|
207
|
+
expect(buffer.readInt8()).toBe(1);
|
|
208
|
+
expect(buffer.readInt8()).toBe(-1);
|
|
209
|
+
expect(buffer.readInt8()).toBe(-128);
|
|
210
|
+
expect(buffer.readInt8()).toBe(127);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test('uint16 LE read write consistency', () => {
|
|
214
|
+
const buffer = new BinaryBuffer();
|
|
215
|
+
|
|
216
|
+
buffer.writeUint16LE(0);
|
|
217
|
+
buffer.writeUint16LE(1);
|
|
218
|
+
buffer.writeUint16LE(65535); //max value
|
|
219
|
+
|
|
220
|
+
buffer.position = 0;
|
|
221
|
+
|
|
222
|
+
expect(buffer.readUint16LE()).toBe(0);
|
|
223
|
+
expect(buffer.readUint16LE()).toBe(1);
|
|
224
|
+
expect(buffer.readUint16LE()).toBe(65535);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
test('uint16 BE read write consistency', () => {
|
|
228
|
+
const buffer = new BinaryBuffer();
|
|
229
|
+
|
|
230
|
+
buffer.writeUint16BE(0);
|
|
231
|
+
buffer.writeUint16BE(1);
|
|
232
|
+
buffer.writeUint16BE(65535); //max value
|
|
233
|
+
|
|
234
|
+
buffer.position = 0;
|
|
235
|
+
|
|
236
|
+
expect(buffer.readUint16BE()).toBe(0);
|
|
237
|
+
expect(buffer.readUint16BE()).toBe(1);
|
|
238
|
+
expect(buffer.readUint16BE()).toBe(65535);
|
|
239
|
+
});
|
|
169
240
|
|
|
170
241
|
test('uint24 LE read write consistency', () => {
|
|
171
242
|
const buffer = new BinaryBuffer();
|
|
@@ -194,3 +265,60 @@ test('uint24 BE read write consistency', () => {
|
|
|
194
265
|
expect(buffer.readUint24BE()).toBe(1);
|
|
195
266
|
expect(buffer.readUint24BE()).toBe(16777215);
|
|
196
267
|
});
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
test("setCapacity", () => {
|
|
271
|
+
|
|
272
|
+
const buffer = new BinaryBuffer();
|
|
273
|
+
|
|
274
|
+
buffer.setCapacity(1);
|
|
275
|
+
|
|
276
|
+
expect(buffer.capacity).toBe(1);
|
|
277
|
+
|
|
278
|
+
buffer.setCapacity(7);
|
|
279
|
+
|
|
280
|
+
expect(buffer.capacity).toBe(7);
|
|
281
|
+
|
|
282
|
+
// trying to reduce capacity below position should throw
|
|
283
|
+
buffer.position = 5;
|
|
284
|
+
|
|
285
|
+
expect(() => buffer.setCapacity(4)).toThrow();
|
|
286
|
+
|
|
287
|
+
// setting capacity to equal position should be fine
|
|
288
|
+
buffer.setCapacity(5);
|
|
289
|
+
|
|
290
|
+
expect(buffer.capacity).toBe(5);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
test("trim sets capacity to current size", () => {
|
|
294
|
+
const buffer = new BinaryBuffer();
|
|
295
|
+
|
|
296
|
+
buffer.setCapacity(100);
|
|
297
|
+
|
|
298
|
+
buffer.writeUint24(123456);
|
|
299
|
+
|
|
300
|
+
buffer.trim();
|
|
301
|
+
|
|
302
|
+
expect(buffer.capacity).toBe(3);
|
|
303
|
+
|
|
304
|
+
// check that data was not destroyed
|
|
305
|
+
buffer.position = 0;
|
|
306
|
+
|
|
307
|
+
expect(buffer.readUint24()).toBe(123456);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
test("ensureCapacity grows capacity as expected", () => {
|
|
311
|
+
const buffer = new BinaryBuffer();
|
|
312
|
+
buffer.setCapacity(1);
|
|
313
|
+
|
|
314
|
+
buffer.ensureCapacity(3);
|
|
315
|
+
|
|
316
|
+
expect(buffer.capacity).toBeGreaterThanOrEqual(3);
|
|
317
|
+
|
|
318
|
+
const capacity = buffer.capacity;
|
|
319
|
+
|
|
320
|
+
buffer.ensureCapacity(capacity);
|
|
321
|
+
|
|
322
|
+
// we're already at that capacity, we expect no change
|
|
323
|
+
expect(buffer.capacity).toEqual(capacity);
|
|
324
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { assert } from "../assert.js";
|
|
2
2
|
|
|
3
3
|
const RX = /\B(?=(.{8})+(?!.))/g;
|
|
4
4
|
|
|
@@ -15,6 +15,7 @@ const MAX_VALUE = 2 ** 31 - 1;
|
|
|
15
15
|
const MIN_VALUE = -1 * (2 ** 31);
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
+
* Converts an integer to easily readable binary string representation
|
|
18
19
|
* @see https://stackoverflow.com/questions/9939760/how-do-i-convert-an-integer-to-binary-in-javascript
|
|
19
20
|
* @example 1024 -> "00000000 00000000 00000100 00000000"
|
|
20
21
|
* @example -1 -> "11111111 11111111 11111111 11111111"
|
|
@@ -30,6 +31,8 @@ export function int32_to_binary_string(nMask) {
|
|
|
30
31
|
throw "number too far negative, number shouldn't be < 2**31"//added
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
assert.isInteger(nMask, 'nMask');
|
|
35
|
+
|
|
33
36
|
let nFlag = 0, nShifted = nMask, sMask = '';
|
|
34
37
|
|
|
35
38
|
for (; nFlag < 32;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { int32_to_binary_string } from "./int32_to_binary_string.js";
|
|
2
|
+
|
|
3
|
+
test("sanity", () => {
|
|
4
|
+
expect(int32_to_binary_string(1024))
|
|
5
|
+
.toBe("00000000 00000000 00000100 00000000");
|
|
6
|
+
|
|
7
|
+
expect(int32_to_binary_string(-1))
|
|
8
|
+
.toBe("11111111 11111111 11111111 11111111");
|
|
9
|
+
});
|
|
@@ -1149,36 +1149,6 @@ export class BinaryNode extends Node {
|
|
|
1149
1149
|
*/
|
|
1150
1150
|
BinaryNode.prototype.isBinaryNode = true;
|
|
1151
1151
|
|
|
1152
|
-
/**
|
|
1153
|
-
* @see "Dynamic BVH" by Erin Catto / Blizzard
|
|
1154
|
-
* @param {AABB3} node
|
|
1155
|
-
* @param {AABB3} addition
|
|
1156
|
-
* @returns {number}
|
|
1157
|
-
*/
|
|
1158
|
-
function inclusion_surface_area_heuristic(node, addition) {
|
|
1159
|
-
return aabb3_combined_surface_area(node, addition) - aabb3_box_surface_area_2(node);
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
/**
|
|
1163
|
-
*
|
|
1164
|
-
* @param {BinaryNode|LeafNode} node
|
|
1165
|
-
* @param {AABB3} addition
|
|
1166
|
-
*/
|
|
1167
|
-
function inclusion_cost_lower_bound(node, addition) {
|
|
1168
|
-
let n = node;
|
|
1169
|
-
let r = aabb3_box_surface_area_2(addition);
|
|
1170
|
-
|
|
1171
|
-
while (n !== null) {
|
|
1172
|
-
|
|
1173
|
-
r += n.costForInclusion(addition);
|
|
1174
|
-
|
|
1175
|
-
n = n.parentNode;
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
return r;
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
1152
|
/**
|
|
1183
1153
|
* @private
|
|
1184
1154
|
* Used in intersection traversal methods. Should be invoked via Function.apply and Function.call only and not be called directly
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { array_copy } from "../../../collection/array/
|
|
1
|
+
import { array_copy } from "../../../collection/array/array_copy.js";
|
|
2
2
|
import { min2 } from "../../../math/min2.js";
|
|
3
3
|
import { max2 } from "../../../math/max2.js";
|
|
4
4
|
import { ceilPowerOfTwo } from "../../../binary/operations/ceilPowerOfTwo.js";
|
|
@@ -6,7 +6,7 @@ import { min2 } from "../../math/min2.js";
|
|
|
6
6
|
import { IndexedBinaryBVHVisitor } from "./IndexedBinaryBVHVisitor.js";
|
|
7
7
|
import { NodeType } from "./NodeType.js";
|
|
8
8
|
import { RayLeafIntersectionVisitor } from "./RayLeafIntersectionVisitor.js";
|
|
9
|
-
import { array_copy } from "../../collection/array/
|
|
9
|
+
import { array_copy } from "../../collection/array/array_copy.js";
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -3,7 +3,7 @@ import { min2 } from "../../math/min2.js";
|
|
|
3
3
|
import { max2 } from "../../math/max2.js";
|
|
4
4
|
import { assert } from "../../assert.js";
|
|
5
5
|
import { typed_array_copy } from "../../collection/array/typed/typed_array_copy.js";
|
|
6
|
-
import { array_copy } from "../../collection/array/
|
|
6
|
+
import { array_copy } from "../../collection/array/array_copy.js";
|
|
7
7
|
|
|
8
8
|
export const COLUMN_PARENT = 6;
|
|
9
9
|
export const COLUMN_CHILD_1 = 7;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import { array_copy } from "../../../collection/array/
|
|
4
|
+
import { array_copy } from "../../../collection/array/array_copy.js";
|
|
5
5
|
import { NULL_NODE } from "../ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
6
6
|
import { aabb3_array_intersects_frustum_degree } from "../../../geom/3d/aabb/aabb3_array_intersects_frustum_degree.js";
|
|
7
7
|
import { bvh_collect_user_data } from "./bvh_collect_user_data.js";
|
package/src/core/cache/Cache.js
CHANGED
|
@@ -301,6 +301,15 @@ export class Cache {
|
|
|
301
301
|
this.onSet.send2(key, value);
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
+
/**
|
|
305
|
+
*
|
|
306
|
+
* @param {Key} key
|
|
307
|
+
* @returns {boolean}
|
|
308
|
+
*/
|
|
309
|
+
contains(key) {
|
|
310
|
+
return this.data.has(key);
|
|
311
|
+
}
|
|
312
|
+
|
|
304
313
|
/**
|
|
305
314
|
*
|
|
306
315
|
* @param {Key} key
|
|
@@ -318,31 +327,26 @@ export class Cache {
|
|
|
318
327
|
}
|
|
319
328
|
}
|
|
320
329
|
|
|
321
|
-
/**
|
|
322
|
-
*
|
|
323
|
-
* @param {Key} key
|
|
324
|
-
* @returns {boolean}
|
|
325
|
-
*/
|
|
326
|
-
contains(key) {
|
|
327
|
-
return this.data.has(key);
|
|
328
|
-
}
|
|
329
330
|
|
|
330
331
|
/**
|
|
331
|
-
*
|
|
332
|
+
* Please note that the key will be stored inside the cache, so it must be treated as immutable
|
|
332
333
|
* @param {Key} key
|
|
333
|
-
* @
|
|
334
|
+
* @param {function(Key):Value} compute
|
|
335
|
+
* @param {*} [compute_context]
|
|
336
|
+
* @return {Value}
|
|
334
337
|
*/
|
|
335
|
-
|
|
336
|
-
const
|
|
338
|
+
getOrCompute(key, compute, compute_context) {
|
|
339
|
+
const existing = this.get(key);
|
|
337
340
|
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
return false;
|
|
341
|
+
if (existing !== null) {
|
|
342
|
+
return existing;
|
|
341
343
|
}
|
|
342
344
|
|
|
343
|
-
|
|
345
|
+
const value = compute.call(compute_context, key);
|
|
344
346
|
|
|
345
|
-
|
|
347
|
+
this.set(key, value);
|
|
348
|
+
|
|
349
|
+
return value;
|
|
346
350
|
}
|
|
347
351
|
|
|
348
352
|
/**
|
|
@@ -398,24 +402,22 @@ export class Cache {
|
|
|
398
402
|
}
|
|
399
403
|
|
|
400
404
|
/**
|
|
401
|
-
*
|
|
405
|
+
* Remove without triggering {@link #removeListener}
|
|
406
|
+
* NOTE: please be sure you understand what you're doing when you use this method
|
|
402
407
|
* @param {Key} key
|
|
403
|
-
* @
|
|
404
|
-
* @param {*} [compute_context]
|
|
405
|
-
* @return {Value}
|
|
408
|
+
* @returns {boolean} true if element was removed, false otherwise
|
|
406
409
|
*/
|
|
407
|
-
|
|
408
|
-
const
|
|
410
|
+
silentRemove(key) {
|
|
411
|
+
const element = this.data.get(key);
|
|
409
412
|
|
|
410
|
-
if (
|
|
411
|
-
|
|
413
|
+
if (element === undefined) {
|
|
414
|
+
//nothing to do
|
|
415
|
+
return false;
|
|
412
416
|
}
|
|
413
417
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
this.set(key, value);
|
|
418
|
+
this.__removeElement(element);
|
|
417
419
|
|
|
418
|
-
return
|
|
420
|
+
return true;
|
|
419
421
|
}
|
|
420
422
|
|
|
421
423
|
/**
|
|
@@ -93,12 +93,15 @@ test("store and retrieve the same item", () => {
|
|
|
93
93
|
test("remove method", () => {
|
|
94
94
|
const cache = new Cache();
|
|
95
95
|
|
|
96
|
+
expect(cache.remove("a")).toBe(false);
|
|
97
|
+
|
|
96
98
|
cache.put("a", "b");
|
|
97
99
|
|
|
98
|
-
cache.remove("a");
|
|
100
|
+
expect(cache.remove("a")).toBe(true);
|
|
99
101
|
|
|
100
102
|
expect(cache.size()).toBe(0);
|
|
101
103
|
expect(cache.get("a")).toBe(null);
|
|
104
|
+
|
|
102
105
|
});
|
|
103
106
|
|
|
104
107
|
test("replacing element with the same key", () => {
|
|
@@ -5,7 +5,7 @@ import { isPowerOfTwo } from "../math/isPowerOrTwo.js";
|
|
|
5
5
|
import { ctz32 } from "../binary/ctz32.js";
|
|
6
6
|
import { ceilPowerOfTwo } from "../binary/operations/ceilPowerOfTwo.js";
|
|
7
7
|
import { UintArrayForCount } from "./array/typed/uint_array_for_count.js";
|
|
8
|
-
import { array_copy } from "./array/
|
|
8
|
+
import { array_copy } from "./array/array_copy.js";
|
|
9
9
|
import { min2 } from "../math/min2.js";
|
|
10
10
|
import { arraySwapElements } from "./array/arraySwapElements.js";
|
|
11
11
|
|
|
@@ -1,29 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @template T
|
|
3
|
-
* @param {T[]} source
|
|
4
|
-
* @param {T[]} target
|
|
5
|
-
*/
|
|
6
|
-
export function copyArray(source, target) {
|
|
7
|
-
|
|
8
|
-
const n = source.length;
|
|
9
|
-
for (let i = 0; i < n; i++) {
|
|
10
|
-
const v = source[i];
|
|
11
|
-
|
|
12
|
-
target[i] = v;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const tL = target.length;
|
|
17
|
-
|
|
18
|
-
if (n > tL) {
|
|
19
|
-
target.splice(n, tL - n);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Follows Java System.arraycopy interface
|
|
26
2
|
* Copy data from one array to another
|
|
3
|
+
* Follows Java System.arraycopy interface
|
|
27
4
|
* @template T
|
|
28
5
|
* @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array|Uint32Array|Int32Array|Float32Array|Float64Array} source The source array
|
|
29
6
|
* @param {number} source_position Starting position where to copy from inside the source array
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @param {T[]} source
|
|
4
|
+
* @param {T[]} target
|
|
5
|
+
*/
|
|
6
|
+
export function array_copy_entire(source, target) {
|
|
7
|
+
|
|
8
|
+
const n = source.length;
|
|
9
|
+
for (let i = 0; i < n; i++) {
|
|
10
|
+
const v = source[i];
|
|
11
|
+
|
|
12
|
+
target[i] = v;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const tL = target.length;
|
|
17
|
+
|
|
18
|
+
if (n > tL) {
|
|
19
|
+
target.splice(n, tL - n);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ceilPowerOfTwo } from "../../binary/operations/ceilPowerOfTwo.js";
|
|
2
2
|
import { max2 } from "../../math/max2.js";
|
|
3
|
-
import { array_copy } from "../array/
|
|
3
|
+
import { array_copy } from "../array/array_copy.js";
|
|
4
4
|
import { assert } from "../../assert.js";
|
|
5
5
|
|
|
6
6
|
const DEFAULT_SIZE = 16;
|
|
@@ -21,7 +21,7 @@ export class Deque {
|
|
|
21
21
|
|
|
22
22
|
assert.isNonNegativeInteger(minSize, 'minSize');
|
|
23
23
|
|
|
24
|
-
const size = ceilPowerOfTwo(max2(
|
|
24
|
+
const size = ceilPowerOfTwo(max2(1, minSize));
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Using static array allocator to preserve data locality.
|
|
@@ -254,11 +254,10 @@ export class Deque {
|
|
|
254
254
|
|
|
255
255
|
/**
|
|
256
256
|
* Peek element from the front of the queue without removing it
|
|
257
|
-
* @returns {T}
|
|
257
|
+
* @returns {T|undefined}
|
|
258
258
|
*/
|
|
259
259
|
getFirst() {
|
|
260
|
-
|
|
261
|
-
return element;
|
|
260
|
+
return this.__data[this.__head];
|
|
262
261
|
}
|
|
263
262
|
|
|
264
263
|
/**
|
|
@@ -292,8 +291,7 @@ export class Deque {
|
|
|
292
291
|
*/
|
|
293
292
|
getLast() {
|
|
294
293
|
const last = this.__circularSmallerPos(this.__tail);
|
|
295
|
-
|
|
296
|
-
return element;
|
|
294
|
+
return this.__data[last];
|
|
297
295
|
}
|
|
298
296
|
}
|
|
299
297
|
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { Deque } from "./Deque.js";
|
|
2
2
|
|
|
3
3
|
test("constructor doesn't throw ", () => {
|
|
4
|
+
expect(() => new Deque()).not.toThrow();
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
test("add one element", () => {
|
|
4
8
|
const deque = new Deque();
|
|
9
|
+
|
|
10
|
+
deque.add(1);
|
|
11
|
+
|
|
12
|
+
expect(deque.size()).toBe(1);
|
|
5
13
|
});
|
|
6
14
|
|
|
7
15
|
test('first in last out, forward', () => {
|
|
@@ -138,3 +146,102 @@ test("remove middle item", () => {
|
|
|
138
146
|
expect(deque.pop()).toBe(7);
|
|
139
147
|
expect(deque.pop()).toBe(17);
|
|
140
148
|
});
|
|
149
|
+
|
|
150
|
+
test("remove non-existent element", () => {
|
|
151
|
+
|
|
152
|
+
const deque = new Deque();
|
|
153
|
+
|
|
154
|
+
expect(deque.remove(1)).toBe(false);
|
|
155
|
+
|
|
156
|
+
deque.add(3);
|
|
157
|
+
|
|
158
|
+
expect(deque.remove(1)).toBe(false);
|
|
159
|
+
|
|
160
|
+
expect(deque.size()).toBe(1);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
test("clear", () => {
|
|
165
|
+
|
|
166
|
+
const deque = new Deque();
|
|
167
|
+
|
|
168
|
+
expect(() => deque.clear()).not.toThrow();
|
|
169
|
+
|
|
170
|
+
expect(deque.size()).toBe(0);
|
|
171
|
+
|
|
172
|
+
deque.add('x');
|
|
173
|
+
|
|
174
|
+
deque.clear();
|
|
175
|
+
|
|
176
|
+
expect(deque.size()).toBe(0);
|
|
177
|
+
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("has", () => {
|
|
181
|
+
|
|
182
|
+
const deque = new Deque();
|
|
183
|
+
|
|
184
|
+
expect(deque.has(1)).toBe(false);
|
|
185
|
+
|
|
186
|
+
deque.add(1);
|
|
187
|
+
|
|
188
|
+
expect(deque.has(1)).toBe(true);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test("getFirst", () => {
|
|
192
|
+
|
|
193
|
+
const deque = new Deque();
|
|
194
|
+
|
|
195
|
+
expect(deque.getFirst()).toBeUndefined();
|
|
196
|
+
|
|
197
|
+
deque.addFirst(1);
|
|
198
|
+
|
|
199
|
+
expect(deque.getFirst()).toBe(1);
|
|
200
|
+
|
|
201
|
+
deque.addFirst(3);
|
|
202
|
+
|
|
203
|
+
expect(deque.getFirst()).toBe(3);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test("getLast", () => {
|
|
207
|
+
|
|
208
|
+
const deque = new Deque();
|
|
209
|
+
|
|
210
|
+
expect(deque.getFirst()).toBeUndefined();
|
|
211
|
+
|
|
212
|
+
deque.addFirst(1);
|
|
213
|
+
|
|
214
|
+
expect(deque.getLast()).toBe(1);
|
|
215
|
+
|
|
216
|
+
deque.addFirst(3);
|
|
217
|
+
|
|
218
|
+
expect(deque.getLast()).toBe(1);
|
|
219
|
+
|
|
220
|
+
deque.removeLast();
|
|
221
|
+
|
|
222
|
+
expect(deque.getLast()).toBe(3);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("fill queue beyond default size and then drain it", () => {
|
|
226
|
+
const queue = new Deque(1);
|
|
227
|
+
|
|
228
|
+
queue.add(1);
|
|
229
|
+
expect(queue.size()).toBe(1);
|
|
230
|
+
|
|
231
|
+
queue.add(2);
|
|
232
|
+
expect(queue.size()).toBe(2);
|
|
233
|
+
|
|
234
|
+
queue.add(3);
|
|
235
|
+
expect(queue.size()).toBe(3);
|
|
236
|
+
|
|
237
|
+
// Drain
|
|
238
|
+
|
|
239
|
+
expect(queue.pop()).toBe(1);
|
|
240
|
+
expect(queue.size()).toBe(2);
|
|
241
|
+
|
|
242
|
+
expect(queue.pop()).toBe(2);
|
|
243
|
+
expect(queue.size()).toBe(1);
|
|
244
|
+
|
|
245
|
+
expect(queue.pop()).toBe(3);
|
|
246
|
+
expect(queue.size()).toBe(0);
|
|
247
|
+
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { assert } from "../../assert.js";
|
|
7
7
|
import Signal from "../../events/signal/Signal.js";
|
|
8
8
|
import { max2 } from "../../math/max2.js";
|
|
9
|
-
import { array_copy } from "../array/
|
|
9
|
+
import { array_copy } from "../array/array_copy.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import Vector2 from "../../Vector2";
|
|
2
|
+
|
|
1
3
|
export default class AABB2 {
|
|
2
4
|
x0: number
|
|
3
5
|
y0: number
|
|
@@ -12,6 +14,10 @@ export default class AABB2 {
|
|
|
12
14
|
|
|
13
15
|
copy(other: AABB2): void
|
|
14
16
|
|
|
17
|
+
clone(): AABB2
|
|
18
|
+
|
|
19
|
+
equals(other: AABB2): boolean
|
|
20
|
+
|
|
15
21
|
setBoundsUnordered(x0: number, y0: number, x1: number, y1: number): void
|
|
16
22
|
|
|
17
23
|
getHeight(): number
|
|
@@ -24,5 +30,13 @@ export default class AABB2 {
|
|
|
24
30
|
|
|
25
31
|
shrink(size: number): void
|
|
26
32
|
|
|
33
|
+
_expandToFitPoint(x: number, y: number): void
|
|
34
|
+
|
|
27
35
|
setNegativelyInfiniteBounds(): void
|
|
36
|
+
|
|
37
|
+
lineIntersectionPoint(v0: Vector2, v1: Vector2, result: Vector2): boolean
|
|
38
|
+
|
|
39
|
+
toJSON(): any
|
|
40
|
+
|
|
41
|
+
fromJSON(json: any): void
|
|
28
42
|
}
|