@woosh/meep-engine 2.42.8 → 2.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/core/binary/BitSet.js +4 -4
  2. package/core/binary/ctz32.js +40 -0
  3. package/core/collection/ObservedMap.js +61 -57
  4. package/core/collection/heap/FastBinaryHeap.js +7 -1
  5. package/core/collection/heap/Uint32Heap.js +19 -0
  6. package/core/collection/map/AsyncLoadingCache.js +3 -1
  7. package/core/geom/2d/compute_polygon_area_2d.js +32 -0
  8. package/core/geom/2d/compute_polygon_area_2d.spec.js +10 -0
  9. package/core/geom/2d/compute_triangle_area_2d.js +15 -0
  10. package/core/geom/2d/compute_triangle_area_2d.spec.js +9 -0
  11. package/core/geom/2d/convex-hull/convex_hull_jarvis_2d.js +64 -0
  12. package/core/geom/2d/convex-hull/convex_hull_jarvis_2d.spec.js +33 -0
  13. package/core/geom/2d/convex-hull/convex_hull_monotone_2d.js +82 -0
  14. package/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +135 -0
  15. package/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +282 -0
  16. package/core/geom/2d/convex-hull/orientation3.js +444 -0
  17. package/core/geom/2d/convex-hull/orientation3_array.js +22 -0
  18. package/core/geom/2d/convex-hull/orientation3_v2.js +12 -0
  19. package/core/geom/2d/intersect_ray_2d.js +56 -0
  20. package/core/geom/2d/quad-tree/QuadTreeNode.js +0 -81
  21. package/core/geom/2d/quad-tree/qt_match_data_by_circle.js +70 -0
  22. package/core/geom/3d/matrix/m4_multiply_alphatensor.js +131 -0
  23. package/core/geom/3d/plane/orient3d_fast.js +2 -6
  24. package/core/geom/3d/tetrahedra/README.md +7 -0
  25. package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +3 -1
  26. package/core/geom/3d/tetrahedra/delaunay/Cavity.js +48 -0
  27. package/core/geom/3d/tetrahedra/{compute_delaunay_tetrahedral_mesh.js → delaunay/compute_delaunay_tetrahedral_mesh.js} +15 -7
  28. package/core/geom/3d/tetrahedra/{compute_delaunay_tetrahedral_mesh.spec.js → delaunay/compute_delaunay_tetrahedral_mesh.spec.js} +0 -0
  29. package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_cavity.js +73 -0
  30. package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_toward_cavity.js +48 -0
  31. package/core/geom/3d/tetrahedra/hxt/a.js +524 -0
  32. package/core/geom/3d/tetrahedra/hxt/hxt.js +140 -0
  33. package/core/geom/3d/tetrahedra/hxt/hxt.wasm +0 -0
  34. package/core/geom/3d/tetrahedra/point_in_tetrahedron_circumsphere.js +35 -20
  35. package/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +98 -0
  36. package/core/geom/3d/tetrahedra/tetrahedra_collection.js +60 -131
  37. package/core/geom/packing/{MaxRectangles.js → max-rect/MaxRectangles.js} +28 -124
  38. package/core/geom/packing/max-rect/removeRedundantBoxes.js +69 -0
  39. package/core/geom/packing/max-rect/removeRedundantBoxesArray.js +40 -0
  40. package/core/geom/v3_distance_above_plane.js +1 -1
  41. package/core/graph/layout/BoxLayouter.js +2 -88
  42. package/core/graph/layout/CircleLayout.js +2 -1
  43. package/core/graph/layout/box/forceIntoBox.js +45 -0
  44. package/core/graph/layout/box/pullBoxTowardsPoint.js +20 -0
  45. package/core/graph/layout/box/resolveAABB2Overlap.js +22 -0
  46. package/core/math/bessel_3.js +11 -0
  47. package/core/math/bessel_i0.js +26 -0
  48. package/core/process/executor/ConcurrentExecutor.spec.js +2 -1
  49. package/core/process/task/util/actionTask.js +19 -0
  50. package/core/process/task/util/countTask.js +62 -0
  51. package/core/process/task/util/delayTask.js +45 -0
  52. package/core/process/task/util/emptyTask.js +19 -0
  53. package/core/process/task/util/failingTask.js +17 -0
  54. package/core/process/task/util/futureTask.js +48 -0
  55. package/core/process/task/util/promiseTask.js +42 -0
  56. package/core/process/task/util/randomCountTask.js +64 -0
  57. package/core/process/task/util/wrapTaskIgnoreFailure.js +47 -0
  58. package/engine/Engine.js +8 -8
  59. package/engine/EngineBootstrapper.js +1 -1
  60. package/engine/asset/AssetManager.d.ts +2 -0
  61. package/engine/asset/AssetManager.js +197 -53
  62. package/engine/asset/AssetRequest.js +32 -0
  63. package/engine/asset/loaders/ArrayBufferLoader.js +62 -50
  64. package/engine/asset/loaders/image/png/PNG.js +15 -1
  65. package/engine/asset/loaders/image/png/PNGReader.js +3 -2
  66. package/engine/ecs/foliage/ecs/InstancedMeshUtils.js +2 -1
  67. package/engine/ecs/storage/BinaryBufferDeSerializer.js +1 -1
  68. package/engine/ecs/storage/JSONDeSerializer.js +2 -1
  69. package/engine/ecs/terrain/ecs/splat/SplatMapOptimizer.js +2 -1
  70. package/engine/ecs/terrain/ecs/splat/SplatMapping.js +1 -1
  71. package/engine/graphics/camera/makeScreenScissorFrustum.js +1 -1
  72. package/engine/graphics/camera/testClippingPlaneComputation.js +4 -45
  73. package/engine/graphics/ecs/camera/FrustumProjector.js +6 -0
  74. package/engine/graphics/ecs/decal/v2/FPDecalSystem.js +5 -0
  75. package/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +23 -4
  76. package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +1 -1
  77. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +11 -0
  78. package/engine/graphics/geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js +1 -2
  79. package/engine/graphics/impostors/octahedral/ImpostorBaker.js +5 -2
  80. package/engine/graphics/impostors/octahedral/ImpostorDescription.js +18 -0
  81. package/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +15 -0
  82. package/engine/graphics/impostors/octahedral/prototypeBaker.js +66 -79
  83. package/engine/graphics/impostors/octahedral/shader/ImpostorShaderWireframeV0.js +134 -0
  84. package/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +128 -0
  85. package/engine/graphics/impostors/octahedral/util/build_geometry_from_cutout_shape.js +32 -0
  86. package/engine/graphics/impostors/octahedral/util/load_mesh_for_bake.js +31 -0
  87. package/engine/graphics/impostors/octahedral/util/makeImpostorAtlasPreview.js +107 -0
  88. package/engine/graphics/material/manager/ManagedMaterial.js +4 -0
  89. package/engine/graphics/material/manager/MaterialManager.js +1 -0
  90. package/engine/graphics/material/optimization/MaterialOptimizationContext.js +7 -3
  91. package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +2 -2
  92. package/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
  93. package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +83 -27
  94. package/engine/graphics/shadows/ShadowMapRenderer.js +11 -4
  95. package/engine/graphics/texture/atlas/AbstractTextureAtlas.js +2 -1
  96. package/engine/graphics/texture/atlas/CachingTextureAtlas.js +208 -38
  97. package/engine/graphics/texture/atlas/TextureAtlas.js +31 -24
  98. package/engine/graphics/texture/atlas/gpu/WebGLTextureAtlas.js +1 -1
  99. package/engine/graphics/texture/sampler/filter/box.js +16 -0
  100. package/engine/graphics/texture/sampler/filter/cubic2.js +32 -0
  101. package/engine/graphics/texture/sampler/filter/gaussian.js +16 -0
  102. package/engine/graphics/texture/sampler/filter/kaiser_1.js +19 -0
  103. package/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +19 -0
  104. package/engine/graphics/texture/sampler/filter/mitchell.js +55 -0
  105. package/engine/graphics/texture/sampler/filter/sampler2d_scale_down_generic.js +109 -0
  106. package/engine/graphics/texture/sampler/filter/triangle.js +19 -0
  107. package/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +187 -86
  108. package/engine/graphics/texture/sampler/sampler2_d_scale_down_lanczos.js +77 -25
  109. package/engine/graphics/texture/sampler/search/make_edge_condition_channel_threshold.js +34 -0
  110. package/engine/graphics/texture/sampler/search/sampler2d_find_pixels.js +24 -0
  111. package/engine/graphics/texture/sprite/prototypeSpriteCutoutGeometry.js +212 -0
  112. package/engine/knowledge/database/StaticKnowledgeDataTable.js +1 -1
  113. package/engine/navigation/grid/AStar.js +1 -1
  114. package/engine/scene/Scene.js +1 -1
  115. package/engine/scene/SerializedScene.js +1 -1
  116. package/engine/scene/transitionToScene.js +3 -1
  117. package/generation/example/main.js +1 -1
  118. package/generation/grid/generation/GridTaskApplyActionToCells.js +1 -1
  119. package/generation/grid/generation/GridTaskDensityMarkerDistribution.js +1 -1
  120. package/generation/grid/generation/GridTaskExecuteRuleTimes.js +1 -1
  121. package/generation/grid/generation/NoopGridTaskGenerator.js +1 -1
  122. package/generation/grid/generation/discrete/GridTaskCellularAutomata.js +2 -1
  123. package/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
  124. package/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +3 -2
  125. package/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +1 -1
  126. package/generation/grid/generation/grid/GridTaskAddNodesFixed.js +1 -1
  127. package/generation/grid/generation/road/GridTaskGenerateRoads.js +3 -2
  128. package/generation/grid/generation/util/buildDistanceMapToObjective.js +1 -1
  129. package/generation/markers/GridActionRuleSet.js +2 -1
  130. package/generation/placement/GridCellActionTransformNearbyMarkers.js +2 -4
  131. package/generation/theme/ThemeEngine.js +4 -1
  132. package/package.json +1 -1
  133. package/view/asset/AssetLoaderStatusView.js +5 -5
  134. package/view/minimap/gl/MinimapTerrainGL.js +1 -2
  135. package/view/renderModel.js +1 -1
  136. package/view/tooltip/TooltipView.js +5 -5
  137. package/core/process/task/TaskUtils.js +0 -352
@@ -1,352 +0,0 @@
1
- /**
2
- * Created by Alex on 22/05/2016.
3
- */
4
- import { randomizeArrayElementOrder } from "../../collection/ArrayUtils.js";
5
- import { seededRandom } from "../../math/random/seededRandom.js";
6
- import Task from "./Task.js";
7
- import { TaskSignal } from "./TaskSignal.js";
8
- import { clamp01 } from "../../math/clamp01.js";
9
-
10
- /**
11
- *
12
- * @param {function} action
13
- * @param {string} name
14
- * @return {Task}
15
- */
16
- export function actionTask(action, name = "unnamed") {
17
- return new Task({
18
- name,
19
- cycleFunction() {
20
- action();
21
-
22
- return TaskSignal.EndSuccess;
23
- }
24
- });
25
- }
26
-
27
- /**
28
- *
29
- * @param {number} seed RNG seed
30
- * @param {number|function(*):number} initial
31
- * @param {number|function(*):number} limit
32
- * @param {function(index:int)} callback
33
- * @returns {Task}
34
- */
35
- export function randomCountTask(seed, initial, limit, callback) {
36
-
37
- const random = seededRandom(seed);
38
-
39
- const span = limit - initial;
40
-
41
- const sequence = new Uint16Array(span);
42
-
43
- let i = 0;
44
-
45
- function cycle() {
46
- if (i >= span) {
47
- return TaskSignal.EndSuccess;
48
- }
49
-
50
- const order = sequence[i];
51
-
52
- const index = order + initial;
53
-
54
- callback(index);
55
-
56
- i++;
57
-
58
- return TaskSignal.Continue;
59
- }
60
-
61
- return new Task({
62
- name: `Count ${initial} -> ${limit}`,
63
- initializer() {
64
-
65
- i = 0;
66
-
67
- //generate sequence
68
- for (let i = 0; i < span; i++) {
69
- sequence[i] = i;
70
- }
71
-
72
- //shuffle
73
- randomizeArrayElementOrder(random, sequence);
74
- },
75
- cycleFunction: cycle,
76
- computeProgress: function () {
77
-
78
- if (span === 0) {
79
- return 0;
80
- }
81
-
82
- return i / span;
83
- }
84
- });
85
- }
86
-
87
- /**
88
- *
89
- * @param {number|function(*):number} initial
90
- * @param {number|function(*):number} limit
91
- * @param {function(index:int)} callback
92
- * @returns {Task}
93
- */
94
- export function countTask(initial, limit, callback) {
95
- let initialValue = 0;
96
- let limitValue = 0;
97
-
98
- let i = initialValue;
99
-
100
- function cycle() {
101
- if (i >= limitValue) {
102
- return TaskSignal.EndSuccess;
103
- }
104
- callback(i);
105
- i++;
106
-
107
- return TaskSignal.Continue;
108
- }
109
-
110
- const initialType = typeof initial;
111
- const limitType = typeof limit;
112
-
113
- const name = "count (from " + ((initialType === 'number') ? initial : 'variable') + " to " + ((limitType === 'number') ? limit : 'variable') + ")";
114
-
115
- return new Task({
116
- name: name,
117
- initializer() {
118
-
119
- if (initialType === "number") {
120
- initialValue = initial;
121
- } else if (initialType === "function") {
122
- initialValue = initial();
123
- }
124
-
125
- if (limitType === "number") {
126
- limitValue = limit;
127
- } else if (limitType === "function") {
128
- limitValue = limit();
129
- }
130
-
131
- i = initialValue;
132
-
133
- },
134
- cycleFunction: cycle,
135
- computeProgress: function () {
136
- const span = limitValue - initialValue;
137
-
138
- if (span === 0) {
139
- return 0;
140
- }
141
-
142
- return (i - initialValue) / span;
143
- }
144
- });
145
- }
146
-
147
- /**
148
- *
149
- * @param {number} delay in milliseconds
150
- * @param {string} [name]
151
- * @returns {Task}
152
- */
153
- export function delayTask(delay, name = "unnamed") {
154
- let startTime = -1;
155
-
156
- const estimatedDuration = delay / 1000;
157
- return new Task({
158
- name: `delay (${delay}ms): ${name}`,
159
- initializer() {
160
- startTime = Date.now();
161
- },
162
- cycleFunction() {
163
- if (Date.now() >= startTime + delay) {
164
- return TaskSignal.EndSuccess;
165
- } else {
166
- return TaskSignal.Yield;
167
- }
168
- },
169
- computeProgress() {
170
- if (startTime === -1) {
171
- return 0;
172
- }
173
-
174
- const currentTime = Date.now();
175
- const remainingTime = currentTime - startTime;
176
-
177
- let fraction = remainingTime / delay;
178
-
179
- if (Number.isNaN(fraction)) {
180
- fraction = 0;
181
- }
182
-
183
- return clamp01(fraction);
184
- },
185
- estimatedDuration
186
- });
187
- }
188
-
189
- /**
190
- *
191
- * @param {string} [name="no-operation"]
192
- * @returns {Task}
193
- */
194
- export function emptyTask(name = "no-operation") {
195
- return new Task({
196
- name,
197
- cycleFunction: function () {
198
- return TaskSignal.EndSuccess;
199
- },
200
- computeProgress: function () {
201
- return 1;
202
- }
203
- });
204
- }
205
-
206
- /**
207
- *
208
- * @param e value to be thrown
209
- */
210
- export function failingTask(e) {
211
- return new Task({
212
- name: "Failing Task",
213
- cycleFunction: function () {
214
- throw e;
215
- },
216
- computeProgress: function () {
217
- return 0;
218
- }
219
- });
220
- }
221
-
222
- /**
223
- *
224
- * @param {Future} future
225
- * @param {String} name
226
- * @returns {Task}
227
- */
228
- export function futureTask(future, name) {
229
- if (typeof future.resolve !== 'function') {
230
- // Not a future
231
- throw new Error("No resolve function on the supplied object");
232
- }
233
-
234
- let resolved = false;
235
- let rejected = false;
236
- let error = null;
237
-
238
- future.then(function () {
239
- resolved = true;
240
- }, function (e) {
241
- rejected = true;
242
- error = e;
243
- });
244
-
245
- function cycle() {
246
- future.resolve();
247
- if (resolved) {
248
- return TaskSignal.EndSuccess;
249
- } else if (rejected) {
250
- throw error;
251
- } else {
252
- //give up CPU share
253
- return TaskSignal.Yield;
254
- }
255
- }
256
-
257
- function progress() {
258
- return resolved ? 1 : 0;
259
- }
260
-
261
- return new Task({
262
- name: name,
263
- cycleFunction: cycle,
264
- computeProgress: progress
265
- });
266
- }
267
-
268
- /**
269
- *
270
- * @param {Promise} promise
271
- * @param {string} name
272
- * @returns {Task}
273
- */
274
- export function promiseTask(promise, name) {
275
- let resolved = false;
276
- let rejected = false;
277
- let error = null;
278
-
279
- promise.then(function () {
280
- resolved = true;
281
- }, function (e) {
282
- rejected = true;
283
- error = e;
284
- });
285
-
286
- function cycle() {
287
- if (resolved) {
288
- return TaskSignal.EndSuccess;
289
- } else if (rejected) {
290
- throw error;
291
- } else {
292
- //give up CPU share
293
- return TaskSignal.Yield;
294
- }
295
- }
296
-
297
- function progress() {
298
- return resolved ? 1 : 0;
299
- }
300
-
301
- return new Task({
302
- name: name,
303
- cycleFunction: cycle,
304
- computeProgress: progress
305
- });
306
- }
307
-
308
-
309
- /**
310
- *
311
- * @param {Task} task
312
- * @returns {Task}
313
- */
314
- export function wrapTaskIgnoreFailure(task) {
315
- let initializationFailed = false;
316
-
317
- const wrapper = new Task({
318
- name: `Ignore Failure of [${task.name}]`,
319
- initializer() {
320
- try {
321
- task.initialize();
322
- } catch (e) {
323
- initializationFailed = true;
324
- console.warn(e);
325
- }
326
- },
327
- estimatedDuration: task.estimatedDuration,
328
- cycleFunction() {
329
-
330
- task.__executedCpuTime = wrapper.__executedCpuTime;
331
- task.__executedCycleCount = wrapper.__executedCycleCount;
332
-
333
- if (initializationFailed) {
334
- //initializer failed, don't execute the source task
335
- return TaskSignal.EndSuccess;
336
- }
337
-
338
- const c = task.cycle();
339
-
340
- if (c === TaskSignal.EndFailure) {
341
- return TaskSignal.EndSuccess;
342
- }
343
-
344
- return c;
345
- },
346
- computeProgress() {
347
- return task.computeProgress();
348
- }
349
- });
350
-
351
- return wrapper;
352
- }