@woosh/meep-engine 2.33.58 → 2.33.62

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 (120) 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/editor/actions/concrete/PaintTerrainOverlayAction.js +1 -1
  16. package/editor/process/ObstacleGridDisplayProcess.js +1 -1
  17. package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +1 -1
  18. package/editor/tools/FoliagePaintTool.js +1 -1
  19. package/editor/tools/GridPaintTool.js +1 -1
  20. package/editor/tools/paint/TerrainPaintTool.js +1 -1
  21. package/editor/tools/paint/TerrainTexturePaintTool.js +1 -1
  22. package/editor/view/EditorView.js +1 -1
  23. package/editor/view/GridPickCoordinateView.js +1 -1
  24. package/engine/animation/removeEntityGenericEffect.js +22 -31
  25. package/engine/asset/Asset.js +0 -45
  26. package/engine/asset/AssetDescription.js +51 -0
  27. package/engine/asset/AssetManager.d.ts +7 -0
  28. package/engine/asset/AssetManager.js +98 -2
  29. package/engine/asset/AssetTransformer.d.ts +5 -0
  30. package/engine/asset/AssetTransformer.js +15 -0
  31. package/engine/asset/loaders/GLTFAssetLoader.js +27 -25
  32. package/engine/asset/loaders/material/computeImageBitmapEquality.js +2 -2
  33. package/engine/asset/loaders/material/computeTextureEquality.js +2 -2
  34. package/engine/asset/loaders/material/computeTextureHash.js +7 -13
  35. package/engine/ecs/animation/InverseKinematicsSystem.js +1 -1
  36. package/engine/ecs/attachment/AttachmentSystem.js +18 -17
  37. package/engine/ecs/evaluation/world/ReadTerrainLayerWeightPointFitness.js +1 -1
  38. package/engine/ecs/fow/FogOfWarRevealerSystem.js +1 -1
  39. package/engine/ecs/grid/HeightMap2NormalMap.js +1 -1
  40. package/engine/ecs/grid/NormalMap2AOMap.js +1 -1
  41. package/engine/ecs/gui/GUIElement.js +0 -106
  42. package/engine/ecs/gui/GUIElementSerializationAdapter.js +108 -0
  43. package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +60 -45
  44. package/engine/ecs/gui/position/ViewportPositionSystem.js +5 -5
  45. package/engine/ecs/parent/EntityNode.d.ts +20 -0
  46. package/engine/ecs/parent/EntityNode.js +284 -0
  47. package/engine/ecs/parent/FaceEditor.js +137 -0
  48. package/engine/ecs/parent/testCompositionEntityNode.js +153 -0
  49. package/engine/ecs/parent/testHuDPerf.js +123 -0
  50. package/engine/ecs/storage/binary/BinaryClassUpgrader.js +1 -0
  51. package/engine/ecs/terrain/ecs/ClingToTerrainSystem.js +2 -2
  52. package/engine/ecs/terrain/ecs/Terrain.js +14 -5
  53. package/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +112 -0
  54. package/engine/ecs/terrain/util/obtainTerrain.js +23 -0
  55. package/engine/ecs/util/removeComponentsExcept.js +3 -3
  56. package/engine/graphics/GraphicsEngine.js +4 -5
  57. package/engine/graphics/camera/testClippingPlaneComputation.js +0 -4
  58. package/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +0 -1
  59. package/engine/graphics/ecs/camera/topdown/TopDownCameraController.spec.js +8 -0
  60. package/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.js +1 -1
  61. package/engine/graphics/ecs/light/LightSystem.js +1 -1
  62. package/engine/graphics/ecs/mesh/Mesh.js +5 -5
  63. package/engine/graphics/ecs/mesh/MeshSystem.js +12 -20
  64. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +29 -0
  65. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +158 -1
  66. package/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
  67. package/engine/graphics/ecs/trail2d/Trail2D.js +35 -1
  68. package/engine/graphics/ecs/trail2d/Trail2DSystem.js +26 -19
  69. package/engine/graphics/ecs/trail2d/makeGradientTrail.js +68 -0
  70. package/engine/graphics/ecs/water/WaterSystem.js +1 -1
  71. package/engine/graphics/ecs/water2/shader/testWaterShader.js +1 -1
  72. package/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +55 -11
  73. package/engine/graphics/micron/convert_three_object_to_micron.js +24 -7
  74. package/engine/graphics/micron/plugin/MicronRenderPlugin.js +107 -4
  75. package/engine/graphics/micron/plugin/serialization/BufferGeometrySerializationAdapter.js +176 -0
  76. package/engine/graphics/micron/render/v1/MaterialContext.js +1 -0
  77. package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +19 -3
  78. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.d.ts +2 -0
  79. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +2 -5
  80. package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
  81. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -3
  82. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +3 -1
  83. package/engine/graphics/render/frame_graph/FrameGraphBuilder.js +36 -0
  84. package/engine/graphics/render/frame_graph/IRenderContext.js +8 -0
  85. package/engine/graphics/render/frame_graph/RenderPass.js +32 -0
  86. package/engine/graphics/render/frame_graph/RenderPassFlags.js +6 -0
  87. package/engine/graphics/render/frame_graph/RenderPassResources.js +15 -0
  88. package/engine/graphics/render/frame_graph/Resource.js +21 -0
  89. package/engine/graphics/render/frame_graph/ResourceReference.js +14 -0
  90. package/engine/graphics/render/frame_graph/TextureDescriptor.js +30 -0
  91. package/engine/graphics/render/frame_graph/UsageModeType.js +5 -0
  92. package/engine/graphics/render/frame_graph/sample/deferred/GBufferDrawPass.js +27 -0
  93. package/engine/graphics/render/frame_graph/sample/deferred/PresentPass.js +17 -0
  94. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
  95. package/engine/graphics/render/webgpu/sample/MeshInstance.js +87 -0
  96. package/engine/graphics/render/webgpu/sample/fragmentDeferredRendering.wgsl +71 -0
  97. package/engine/graphics/render/webgpu/sample/fragmentGBuffersDebugView.wgsl +39 -0
  98. package/engine/graphics/render/webgpu/sample/fragmentWriteGBuffers.wgsl +21 -0
  99. package/engine/graphics/render/webgpu/sample/lightUpdate.wgsl +41 -0
  100. package/engine/graphics/render/webgpu/sample/main.js +604 -0
  101. package/engine/graphics/render/webgpu/sample/vertexTextureQuad.wgsl +9 -0
  102. package/engine/graphics/render/webgpu/sample/vertexWriteGBuffers.wgsl +30 -0
  103. package/engine/graphics/shadows/ShadowMapRenderer.js +10 -4
  104. package/engine/graphics/shadows/testShadowMapRendering.js +0 -2
  105. package/engine/graphics/texture/sampler/Sampler2D.js +24 -45
  106. package/engine/{ecs/grid → graphics/texture/sampler}/sampler2DToFloat32Texture.js +1 -1
  107. package/engine/grid/systems/GridPosition2TransformSystem.js +1 -1
  108. package/engine/grid/systems/ViewportGridProjectionSystem.js +1 -1
  109. package/engine/grid/transform2grid/Transform2GridPositionSystem.js +1 -1
  110. package/engine/intelligence/behavior/ecs/WaitForEventBehavior.js +3 -0
  111. package/engine/save/storage/IndexedDBStorage.js +8 -1
  112. package/engine/scene/transitionToScene.js +1 -1
  113. package/generation/grid/actions/ContinuousGridCellActionSetTerrainHeight.js +1 -1
  114. package/generation/markers/actions/placement/MarkerNodeEntityProcessorClingToTerrain.js +1 -1
  115. package/generation/markers/debug/visualizeMarkers.js +1 -1
  116. package/generation/theme/ThemeEngine.js +1 -1
  117. package/package.json +1 -1
  118. package/samples/terrain/main.js +117 -0
  119. package/view/minimap/Minimap.js +1 -1
  120. package/engine/ecs/sockets/AttachmentSocketsSystem.js +0 -10
@@ -0,0 +1,87 @@
1
+ import { array_copy } from "../../../../../core/collection/array/copyArray.js";
2
+
3
+ export class MeshInstance {
4
+ constructor() {
5
+
6
+ /**
7
+ *
8
+ * @type {THREE.BufferGeometry|null}
9
+ */
10
+ this.geometry = null;
11
+
12
+ /**
13
+ *
14
+ * @type {GPUBuffer|null}
15
+ */
16
+ this.vertex_buffer = null;
17
+
18
+ /**
19
+ *
20
+ * @type {GPUBuffer|null}
21
+ */
22
+ this.index_buffer = null;
23
+ }
24
+
25
+ /**
26
+ *
27
+ * @param {GPUDevice} device
28
+ */
29
+ init(device) {
30
+ const mesh = this.geometry;
31
+
32
+ const kVertexStride = 8;
33
+ const attribute_position = mesh.getAttribute('position');
34
+ const vertexBuffer = device.createBuffer({
35
+ // position: vec3, normal: vec3, uv: vec2
36
+ size: attribute_position.array.length * kVertexStride * Float32Array.BYTES_PER_ELEMENT,
37
+ usage: GPUBufferUsage.VERTEX,
38
+ mappedAtCreation: true,
39
+ });
40
+
41
+ {
42
+ const mapping = new Float32Array(vertexBuffer.getMappedRange());
43
+
44
+ const attribute_normal = mesh.getAttribute('normal');
45
+ const attribute_uv = mesh.getAttribute('uv');
46
+
47
+ const vertex_count = attribute_position.count;
48
+
49
+ for (let i = 0; i < vertex_count; ++i) {
50
+ const address = kVertexStride * i;
51
+ array_copy(attribute_position.array, i * 3, mapping, address, 3);
52
+ array_copy(attribute_normal.array, i * 3, mapping, address + 3, 3);
53
+ array_copy(attribute_uv.array, i * 2, mapping, address + 6, 2);
54
+ }
55
+ vertexBuffer.unmap();
56
+ }
57
+
58
+ this.vertex_buffer = vertexBuffer;
59
+
60
+ const indexCount = mesh.getIndex().array.length;
61
+ const indexBuffer = device.createBuffer({
62
+ size: indexCount * Uint32Array.BYTES_PER_ELEMENT,
63
+ usage: GPUBufferUsage.INDEX,
64
+ mappedAtCreation: true,
65
+ });
66
+ {
67
+ const mapping = new Uint32Array(indexBuffer.getMappedRange());
68
+
69
+ mapping.set(mesh.getIndex().array);
70
+
71
+ indexBuffer.unmap();
72
+ }
73
+
74
+ this.index_buffer = indexBuffer;
75
+
76
+ }
77
+
78
+ /**
79
+ *
80
+ * @param {GPURenderPassEncoder} pass
81
+ */
82
+ draw(pass) {
83
+ pass.setVertexBuffer(0, this.vertex_buffer);
84
+ pass.setIndexBuffer(this.index_buffer, 'uint32');
85
+ pass.drawIndexed(this.geometry.getIndex().array.length);
86
+ }
87
+ }
@@ -0,0 +1,71 @@
1
+ [[group(0), binding(0)]] var gBufferPosition: texture_2d<f32>;
2
+ [[group(0), binding(1)]] var gBufferNormal: texture_2d<f32>;
3
+ [[group(0), binding(2)]] var gBufferAlbedo: texture_2d<f32>;
4
+
5
+ struct LightData {
6
+ position : vec4<f32>;
7
+ color : vec3<f32>;
8
+ radius : f32;
9
+ };
10
+
11
+ struct LightsBuffer {
12
+ lights: array<LightData>;
13
+ };
14
+
15
+ [[group(1), binding(0)]] var<storage, read> lightsBuffer: LightsBuffer;
16
+
17
+ struct Config {
18
+ numLights : u32;
19
+ };
20
+
21
+ [[group(1), binding(1)]] var<uniform> config: Config;
22
+
23
+ struct CanvasConstants {
24
+ size: vec2<f32>;
25
+ };
26
+
27
+ [[group(2), binding(0)]] var<uniform> canvas : CanvasConstants;
28
+
29
+ [[stage(fragment)]]
30
+ fn main([[builtin(position)]] coord : vec4<f32>)
31
+ -> [[location(0)]] vec4<f32> {
32
+ var result = vec3<f32>(0.0, 0.0, 0.0);
33
+
34
+ let position = textureLoad(
35
+ gBufferPosition,
36
+ vec2<i32>(floor(coord.xy)),
37
+ 0
38
+ ).xyz;
39
+
40
+ if (position.z > 10000.0) {
41
+ discard;
42
+ }
43
+
44
+ let normal = textureLoad(
45
+ gBufferNormal,
46
+ vec2<i32>(floor(coord.xy)),
47
+ 0
48
+ ).xyz;
49
+
50
+ let albedo = textureLoad(
51
+ gBufferAlbedo,
52
+ vec2<i32>(floor(coord.xy)),
53
+ 0
54
+ ).rgb;
55
+
56
+ for (var i : u32 = 0u; i < config.numLights; i = i + 1u) {
57
+ let L = lightsBuffer.lights[i].position.xyz - position;
58
+ let distance = length(L);
59
+ if (distance > lightsBuffer.lights[i].radius) {
60
+ continue;
61
+ }
62
+ let lambert = max(dot(normal, normalize(L)), 0.0);
63
+ result = result + vec3<f32>(
64
+ lambert * pow(1.0 - distance / lightsBuffer.lights[i].radius, 2.0) * lightsBuffer.lights[i].color * albedo);
65
+ }
66
+
67
+ // some manual ambient
68
+ result = result + vec3<f32>(0.2, 0.2, 0.2);
69
+
70
+ return vec4<f32>(result, 1.0);
71
+ }
@@ -0,0 +1,39 @@
1
+ [[group(0), binding(0)]] var gBufferPosition: texture_2d<f32>;
2
+ [[group(0), binding(1)]] var gBufferNormal: texture_2d<f32>;
3
+ [[group(0), binding(2)]] var gBufferAlbedo: texture_2d<f32>;
4
+
5
+ struct CanvasConstants {
6
+ size: vec2<f32>;
7
+ };
8
+
9
+ [[group(1), binding(0)]] var<uniform> canvas : CanvasConstants;
10
+
11
+ [[stage(fragment)]]
12
+ fn main([[builtin(position)]] coord : vec4<f32>)
13
+ -> [[location(0)]] vec4<f32> {
14
+ var result : vec4<f32>;
15
+ let c = coord.xy / canvas.size;
16
+ if (c.x < 0.33333) {
17
+ result = textureLoad(
18
+ gBufferPosition,
19
+ vec2<i32>(floor(coord.xy)),
20
+ 0
21
+ );
22
+ } else if (c.x < 0.66667) {
23
+ result = textureLoad(
24
+ gBufferNormal,
25
+ vec2<i32>(floor(coord.xy)),
26
+ 0
27
+ );
28
+ result.x = (result.x + 1.0) * 0.5;
29
+ result.y = (result.y + 1.0) * 0.5;
30
+ result.z = (result.z + 1.0) * 0.5;
31
+ } else {
32
+ result = textureLoad(
33
+ gBufferAlbedo,
34
+ vec2<i32>(floor(coord.xy)),
35
+ 0
36
+ );
37
+ }
38
+ return result;
39
+ }
@@ -0,0 +1,21 @@
1
+ struct GBufferOutput {
2
+ [[location(0)]] position : vec4<f32>;
3
+ [[location(1)]] normal : vec4<f32>;
4
+
5
+ // Textures: diffuse color, specular color, smoothness, emissive etc. could go here
6
+ [[location(2)]] albedo : vec4<f32>;
7
+ };
8
+
9
+ [[stage(fragment)]]
10
+ fn main([[location(0)]] fragPosition: vec3<f32>,
11
+ [[location(1)]] fragNormal: vec3<f32>,
12
+ [[location(2)]] fragUV : vec2<f32>) -> GBufferOutput {
13
+ var output : GBufferOutput;
14
+ output.position = vec4<f32>(fragPosition, 1.0);
15
+ output.normal = vec4<f32>(fragNormal, 1.0);
16
+ // faking some kind of checkerboard texture
17
+ let uv = floor(30.0 * fragUV);
18
+ let c = 0.2 + 0.5 * ((uv.x + uv.y) - 2.0 * floor((uv.x + uv.y) / 2.0));
19
+ output.albedo = vec4<f32>(c, c, c, 1.0);
20
+ return output;
21
+ }
@@ -0,0 +1,41 @@
1
+ struct LightData {
2
+ position : vec4<f32>;
3
+ color : vec3<f32>;
4
+ radius : f32;
5
+ };
6
+ struct LightsBuffer {
7
+ lights: array<LightData>;
8
+ };
9
+ [[group(0), binding(0)]] var<storage, read_write> lightsBuffer: LightsBuffer;
10
+
11
+ struct Config {
12
+ numLights : u32;
13
+ };
14
+
15
+ [[group(0), binding(1)]] var<uniform> config: Config;
16
+
17
+ struct LightExtent {
18
+ min : vec4<f32>;
19
+ max : vec4<f32>;
20
+ };
21
+
22
+ [[group(0), binding(2)]] var<uniform> lightExtent: LightExtent;
23
+
24
+ [[stage(compute), workgroup_size(64, 1, 1)]]
25
+ fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
26
+ var index = GlobalInvocationID.x;
27
+ if (index >= config.numLights) {
28
+ return;
29
+ }
30
+
31
+ let light = &lightsBuffer.lights[index];
32
+
33
+ (*light).position.y = (*light).position.y - 0.001 - 0.003 * (f32(index) - 64.0 * floor(f32(index) / 64.0));
34
+
35
+ if ((*light).position.y < lightExtent.min.y) {
36
+ (*light).position.y = lightExtent.max.y;
37
+ }
38
+
39
+ // write out
40
+ // lightBuffer.lighs[index] = light;
41
+ }