@woosh/meep-engine 2.33.57 → 2.33.61

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 (95) hide show
  1. package/core/bvh2/aabb3/AABB3.js +4 -1
  2. package/core/bvh2/traversal/traverseBinaryNodeUsingVisitor.js +6 -6
  3. package/core/cache/Cache.js +7 -0
  4. package/core/collection/array/fastArrayEquals.js +17 -0
  5. package/core/collection/array/typed/is_typed_array_equals.js +58 -0
  6. package/core/collection/map/AbstractAsyncMap.js +30 -0
  7. package/core/collection/map/AsyncMapWrapper.js +16 -0
  8. package/core/collection/map/AsyncRemoteHashMap.js +358 -0
  9. package/core/collection/map/CachedAsyncMap.js +34 -0
  10. package/core/geom/3d/SurfacePoint3.js +44 -5
  11. package/core/geom/Vector2.d.ts +2 -0
  12. package/core/geom/Vector4.js +5 -5
  13. package/core/geom/packing/MaxRectangles.js +13 -4
  14. package/core/math/hash/murmur3_32.js +3 -3
  15. package/engine/animation/removeEntityGenericEffect.js +22 -31
  16. package/engine/asset/Asset.js +0 -45
  17. package/engine/asset/AssetDescription.js +51 -0
  18. package/engine/asset/AssetManager.d.ts +7 -0
  19. package/engine/asset/AssetManager.js +98 -2
  20. package/engine/asset/AssetTransformer.d.ts +5 -0
  21. package/engine/asset/AssetTransformer.js +15 -0
  22. package/engine/asset/loaders/GLTFAssetLoader.js +27 -25
  23. package/engine/asset/loaders/material/computeImageBitmapEquality.js +2 -2
  24. package/engine/asset/loaders/material/computeTextureEquality.js +2 -2
  25. package/engine/asset/loaders/material/computeTextureHash.js +7 -13
  26. package/engine/ecs/attachment/AttachmentSystem.js +18 -17
  27. package/engine/ecs/grid/HeightMap2NormalMap.js +1 -1
  28. package/engine/ecs/grid/NormalMap2AOMap.js +1 -1
  29. package/engine/ecs/gui/GUIElement.js +0 -106
  30. package/engine/ecs/gui/GUIElementSerializationAdapter.js +108 -0
  31. package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +60 -45
  32. package/engine/ecs/gui/position/ViewportPositionSystem.js +5 -5
  33. package/engine/ecs/parent/EntityNode.d.ts +20 -0
  34. package/engine/ecs/parent/EntityNode.js +284 -0
  35. package/engine/ecs/parent/FaceEditor.js +137 -0
  36. package/engine/ecs/parent/testCompositionEntityNode.js +153 -0
  37. package/engine/ecs/parent/testHuDPerf.js +123 -0
  38. package/engine/ecs/storage/binary/BinaryClassUpgrader.js +1 -0
  39. package/engine/ecs/terrain/ecs/Terrain.js +14 -5
  40. package/engine/ecs/util/removeComponentsExcept.js +3 -3
  41. package/engine/graphics/GraphicsEngine.js +4 -5
  42. package/engine/graphics/camera/testClippingPlaneComputation.js +0 -4
  43. package/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +0 -1
  44. package/engine/graphics/ecs/camera/topdown/TopDownCameraController.spec.js +8 -0
  45. package/engine/graphics/ecs/light/LightSystem.js +1 -1
  46. package/engine/graphics/ecs/mesh/Mesh.js +5 -5
  47. package/engine/graphics/ecs/mesh/MeshSystem.js +12 -20
  48. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +29 -0
  49. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +158 -1
  50. package/engine/graphics/ecs/path/PathDisplaySystem.d.ts +3 -1
  51. package/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
  52. package/engine/graphics/ecs/trail2d/Trail2D.js +35 -1
  53. package/engine/graphics/ecs/trail2d/Trail2DSystem.js +26 -19
  54. package/engine/graphics/ecs/trail2d/makeGradientTrail.js +68 -0
  55. package/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +55 -11
  56. package/engine/graphics/micron/convert_three_object_to_micron.js +24 -7
  57. package/engine/graphics/micron/plugin/MicronRenderPlugin.js +107 -4
  58. package/engine/graphics/micron/plugin/serialization/BufferGeometrySerializationAdapter.js +176 -0
  59. package/engine/graphics/micron/render/v1/MaterialContext.js +1 -0
  60. package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +19 -3
  61. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.d.ts +2 -0
  62. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -4
  63. package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
  64. package/engine/graphics/render/buffer/simple-fx/DepthLimitedBlur.js +2 -2
  65. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +0 -2
  66. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +3 -1
  67. package/engine/graphics/render/frame_graph/FrameGraphBuilder.js +36 -0
  68. package/engine/graphics/render/frame_graph/IRenderContext.js +8 -0
  69. package/engine/graphics/render/frame_graph/RenderPass.js +32 -0
  70. package/engine/graphics/render/frame_graph/RenderPassFlags.js +6 -0
  71. package/engine/graphics/render/frame_graph/RenderPassResources.js +15 -0
  72. package/engine/graphics/render/frame_graph/Resource.js +21 -0
  73. package/engine/graphics/render/frame_graph/ResourceReference.js +14 -0
  74. package/engine/graphics/render/frame_graph/TextureDescriptor.js +30 -0
  75. package/engine/graphics/render/frame_graph/UsageModeType.js +5 -0
  76. package/engine/graphics/render/frame_graph/sample/deferred/GBufferDrawPass.js +27 -0
  77. package/engine/graphics/render/frame_graph/sample/deferred/PresentPass.js +17 -0
  78. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
  79. package/engine/graphics/render/webgpu/sample/_main.ts +650 -0
  80. package/engine/graphics/render/webgpu/sample/fragmentDeferredRendering.wgsl +67 -0
  81. package/engine/graphics/render/webgpu/sample/fragmentGBuffersDebugView.wgsl +38 -0
  82. package/engine/graphics/render/webgpu/sample/fragmentWriteGBuffers.wgsl +21 -0
  83. package/engine/graphics/render/webgpu/sample/lightUpdate.wgsl +34 -0
  84. package/engine/graphics/render/webgpu/sample/main.js +566 -0
  85. package/engine/graphics/render/webgpu/sample/vertexTextureQuad.wgsl +9 -0
  86. package/engine/graphics/render/webgpu/sample/vertexWriteGBuffers.wgsl +28 -0
  87. package/engine/graphics/shadows/ShadowMapRenderer.js +10 -4
  88. package/engine/graphics/shadows/testShadowMapRendering.js +0 -2
  89. package/engine/graphics/texture/sampler/Sampler2D.js +24 -45
  90. package/engine/{ecs/grid → graphics/texture/sampler}/sampler2DToFloat32Texture.js +1 -1
  91. package/engine/intelligence/behavior/ecs/WaitForEventBehavior.js +3 -0
  92. package/engine/save/storage/IndexedDBStorage.js +8 -1
  93. package/package.json +1 -1
  94. package/samples/terrain/main.js +117 -0
  95. package/engine/ecs/sockets/AttachmentSocketsSystem.js +0 -10
@@ -95,12 +95,18 @@ export class ShadowMapRenderer {
95
95
 
96
96
  this.onBeforeRender.send3(renderer, shadow_camera, scene);
97
97
 
98
- renderer.render(scene, shadow_camera);
99
-
100
- if (renderer.shadowMap.type === VSMShadowMap) {
101
- this.__do_vsm_pass(shadow);
98
+ if (target.width <= 0 || target.height <= 0) {
99
+ // no point in rendering
100
+ } else {
101
+ // do the draw
102
+ renderer.render(scene, shadow_camera);
103
+
104
+ if (renderer.shadowMap.type === VSMShadowMap) {
105
+ this.__do_vsm_pass(shadow);
106
+ }
102
107
  }
103
108
 
109
+
104
110
  // restore state
105
111
  renderer.setRenderTarget(__rt, __acf, __aml);
106
112
  renderer.setScissorTest(__scissor);
@@ -5,7 +5,6 @@ import { MeshSystem } from "../ecs/mesh/MeshSystem.js";
5
5
  import GUIElementSystem from "../../ecs/gui/GUIElementSystem.js";
6
6
  import HeadsUpDisplaySystem from "../../ecs/gui/hud/HeadsUpDisplaySystem.js";
7
7
  import TagSystem from "../../ecs/systems/TagSystem.js";
8
- import { AttachmentSocketsSystem } from "../../ecs/sockets/AttachmentSocketsSystem.js";
9
8
  import { AttachmentSystem } from "../../ecs/attachment/AttachmentSystem.js";
10
9
  import { SoundEmitterSystem } from "../../sound/ecs/emitter/SoundEmitterSystem.js";
11
10
  import SoundControllerSystem from "../../sound/ecs/SoundControllerSystem.js";
@@ -72,7 +71,6 @@ function makeConfig(engine) {
72
71
 
73
72
  config.addManySystems(
74
73
  new TagSystem(),
75
- new AttachmentSocketsSystem(),
76
74
  new AttachmentSystem(),
77
75
  new SoundEmitterSystem(assetManager, sound.destination, sound.context),
78
76
  new SoundControllerSystem(),
@@ -570,6 +570,10 @@ Sampler2D.prototype.sampleChannelBicubic = function (x, y, channel) {
570
570
  const x1 = clamp(x, 0, x_max) | 0;
571
571
  const y1 = clamp(y, 0, y_max) | 0;
572
572
 
573
+ // fractional texel position (from the nearest low texel)
574
+ const xd = x - x1;
575
+ const yd = y - y1;
576
+
573
577
  const x0 = max2(0, x1 - 1);
574
578
  const y0 = max2(0, y1 - 1);
575
579
 
@@ -595,61 +599,36 @@ Sampler2D.prototype.sampleChannelBicubic = function (x, y, channel) {
595
599
  const col2_offset = x2 * itemSize;
596
600
  const col3_offset = x3 * itemSize;
597
601
 
598
- // compute sample addresses
599
- const i0 = row0_address + col0_offset;
600
- const i1 = row0_address + col1_offset;
601
- const i2 = row0_address + col2_offset;
602
- const i3 = row0_address + col3_offset;
603
-
604
- const j0 = row1_address + col0_offset;
605
- const j1 = row1_address + col1_offset;
606
- const j2 = row1_address + col2_offset;
607
- const j3 = row1_address + col3_offset;
602
+ // read samples
603
+ const vi0 = data[row0_address + col0_offset];
604
+ const vi1 = data[row0_address + col1_offset];
605
+ const vi2 = data[row0_address + col2_offset];
606
+ const vi3 = data[row0_address + col3_offset];
608
607
 
609
- const k0 = row2_address + col0_offset;
610
- const k1 = row2_address + col1_offset;
611
- const k2 = row2_address + col2_offset;
612
- const k3 = row2_address + col3_offset;
608
+ const vj0 = data[row1_address + col0_offset];
609
+ const vj1 = data[row1_address + col1_offset];
610
+ const vj2 = data[row1_address + col2_offset];
611
+ const vj3 = data[row1_address + col3_offset];
613
612
 
614
- const l0 = row3_address + col0_offset;
615
- const l1 = row3_address + col1_offset;
616
- const l2 = row3_address + col2_offset;
617
- const l3 = row3_address + col3_offset;
613
+ const vk0 = data[row2_address + col0_offset];
614
+ const vk1 = data[row2_address + col1_offset];
615
+ const vk2 = data[row2_address + col2_offset];
616
+ const vk3 = data[row2_address + col3_offset];
618
617
 
619
- // read samples
620
- const vi0 = data[i0];
621
- const vi1 = data[i1];
622
- const vi2 = data[i2];
623
- const vi3 = data[i3];
624
-
625
- const vj0 = data[j0];
626
- const vj1 = data[j1];
627
- const vj2 = data[j2];
628
- const vj3 = data[j3];
629
-
630
- const vk0 = data[k0];
631
- const vk1 = data[k1];
632
- const vk2 = data[k2];
633
- const vk3 = data[k3];
634
-
635
- const vl0 = data[l0];
636
- const vl1 = data[l1];
637
- const vl2 = data[l2];
638
- const vl3 = data[l3];
618
+ const vl0 = data[row3_address + col0_offset];
619
+ const vl1 = data[row3_address + col1_offset];
620
+ const vl2 = data[row3_address + col2_offset];
621
+ const vl3 = data[row3_address + col3_offset];
639
622
 
640
- const xd = x - x1;
641
- const yd = y - y1;
642
623
 
643
- // perform filtering in X
624
+ // perform filtering in X (rows)
644
625
  const s0 = bicubic_terp(xd, vi0, vi1, vi2, vi3);
645
626
  const s1 = bicubic_terp(xd, vj0, vj1, vj2, vj3);
646
627
  const s2 = bicubic_terp(xd, vk0, vk1, vk2, vk3);
647
628
  const s3 = bicubic_terp(xd, vl0, vl1, vl2, vl3);
648
629
 
649
- // filter in Y
650
- const result = bicubic_terp(yd, s0, s1, s2, s3);
651
-
652
- return result;
630
+ // filter in Y (columns)
631
+ return bicubic_terp(yd, s0, s1, s2, s3);
653
632
  };
654
633
 
655
634
  /**
@@ -1,5 +1,5 @@
1
1
  import { ClampToEdgeWrapping, DataTexture, FloatType, LinearFilter, NearestFilter, RedFormat } from "three";
2
- import { assert } from "../../../core/assert.js";
2
+ import { assert } from "../../../../core/assert.js";
3
3
 
4
4
  /**
5
5
  *
@@ -1,6 +1,7 @@
1
1
  import { EntityBehavior } from "./EntityBehavior.js";
2
2
  import { BehaviorStatus } from "../BehaviorStatus.js";
3
3
  import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
4
+ import { assert } from "../../../../core/assert.js";
4
5
 
5
6
  export class WaitForEventBehavior extends EntityBehavior {
6
7
  constructor() {
@@ -26,6 +27,8 @@ export class WaitForEventBehavior extends EntityBehavior {
26
27
  }
27
28
 
28
29
  fromJSON({ event, target = -1 }) {
30
+ assert.isString(event, 'event');
31
+
29
32
  this.event = event;
30
33
  this.target = target;
31
34
  }
@@ -1,12 +1,18 @@
1
1
  import Storage from "../Storage.js";
2
2
  import { IndexedDBTransactionMode } from "./IndexedDBTransactionMode.js";
3
+ import { assert } from "../../../core/assert.js";
3
4
 
4
5
  const MAIN_STORE_NAME = 'main';
5
6
 
7
+ /**
8
+ * TODO add QuotaExceededError handling
9
+ */
6
10
  export class IndexedDBStorage extends Storage {
7
11
  constructor(name) {
8
12
  super();
9
13
 
14
+ assert.isString(name, 'name');
15
+
10
16
  /**
11
17
  *
12
18
  * @param {IDBDatabase} database
@@ -43,7 +49,7 @@ export class IndexedDBStorage extends Storage {
43
49
 
44
50
  const objectStore = transaction.objectStore(MAIN_STORE_NAME);
45
51
 
46
- const idbRequest = objectStore.delete( key);
52
+ const idbRequest = objectStore.delete(key);
47
53
 
48
54
  if (typeof resolve === "function") {
49
55
 
@@ -60,6 +66,7 @@ export class IndexedDBStorage extends Storage {
60
66
  });
61
67
 
62
68
  }
69
+
63
70
  });
64
71
 
65
72
  if (typeof reject === "function") {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.33.57",
8
+ "version": "2.33.61",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",
@@ -0,0 +1,117 @@
1
+ import { EngineConfiguration } from "../../engine/EngineConfiguration.js";
2
+ import { EngineHarness } from "../../engine/EngineHarness.js";
3
+ import { GameAssetType } from "../../engine/asset/GameAssetType.js";
4
+ import { TextureAssetLoader } from "../../engine/asset/loaders/texture/TextureAssetLoader.js";
5
+ import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
6
+ import { ImprovedNoise } from "three/examples/jsm/math/ImprovedNoise.js";
7
+ import { lerp } from "../../core/math/lerp.js";
8
+ import Vector2 from "../../core/geom/Vector2.js";
9
+ import Vector3 from "../../core/geom/Vector3.js";
10
+
11
+ const eh = new EngineHarness();
12
+
13
+ /**
14
+ *
15
+ * @param {Engine} engine
16
+ * @return {EngineConfiguration}
17
+ */
18
+ function makeConfig(engine) {
19
+ const r = new EngineConfiguration();
20
+
21
+ // configure engine here, add systems, loaders etc.
22
+ r.addLoader(GameAssetType.Texture, new TextureAssetLoader());
23
+
24
+ return r;
25
+ }
26
+
27
+ /**
28
+ *
29
+ * @param {Terrain} terrain
30
+ * @param {number} resolution
31
+ * @param {number} heightMin
32
+ * @param {number} heightMax
33
+ */
34
+ async function buildRandomTerrainHeights({
35
+ terrain,
36
+ resolution = 64,
37
+ heightMin = -5,
38
+ heightMax = 20
39
+ }) {
40
+
41
+ const terrain_height = terrain.samplerHeight;
42
+
43
+ terrain_height.resize(resolution, resolution);
44
+
45
+ const noise = new ImprovedNoise();
46
+
47
+ let x, y;
48
+
49
+ for (y = 0; y < resolution; y++) {
50
+ for (x = 0; x < resolution; x++) {
51
+
52
+ const u = x / (resolution - 1);
53
+ const v = y / (resolution - 1);
54
+
55
+ const noise_value = noise.noise(u * 13.456, v * 13.456, 0) * noise.noise(u * 3.71, v * 3.71, 0.8);
56
+
57
+ const height_value = lerp(heightMin, heightMax, noise_value);
58
+
59
+ terrain_height.set(x, y, [height_value]);
60
+ }
61
+ }
62
+
63
+ await terrain.updateWorkerHeights();
64
+ terrain.updateHeightTexture();
65
+ terrain.buildLightMap();
66
+
67
+ terrain.tiles.rebuild();
68
+ }
69
+
70
+ /**
71
+ *
72
+ * @param {Engine} engine
73
+ */
74
+ async function main(engine) {
75
+
76
+
77
+ await EngineHarness.buildBasics({
78
+ engine,
79
+ enableWater: false,
80
+ terrainResolution: 4,
81
+ terrainSize: new Vector2(64, 64),
82
+ focus: new Vector3(64, 0, 54),
83
+ yaw: 0,
84
+ pitch: 0.909,
85
+ distance: 169
86
+ });
87
+
88
+ /**
89
+ *
90
+ * @type {EntityComponentDataset}
91
+ */
92
+ const ecd = engine.entityManager.dataset;
93
+
94
+ /**
95
+ *
96
+ * @type {Terrain|null}
97
+ */
98
+ const terrain = obtainTerrain(ecd);
99
+
100
+ buildRandomTerrainHeights({ terrain: terrain });
101
+ }
102
+
103
+ /**
104
+ *
105
+ * @param {EngineHarness} harness
106
+ */
107
+ async function init(harness) {
108
+ const engine = eh.engine;
109
+
110
+ await makeConfig(engine).apply(engine);
111
+
112
+ await eh.initialize();
113
+
114
+ main(engine);
115
+ }
116
+
117
+ init(eh);
@@ -1,10 +0,0 @@
1
- import { System } from "../System.js";
2
- import { AttachmentSockets } from "./AttachmentSockets.js";
3
-
4
- export class AttachmentSocketsSystem extends System {
5
- constructor() {
6
- super();
7
-
8
- this.dependencies = [AttachmentSockets];
9
- }
10
- }