@woosh/meep-engine 2.75.6 → 2.75.8

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 (81) hide show
  1. package/build/meep.cjs +268 -252
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +268 -252
  4. package/editor/ecs/component/createObjectEditor.js +2 -2
  5. package/package.json +1 -1
  6. package/src/core/geom/3d/frustum/read_three_planes_to_array.d.ts +3 -0
  7. package/src/core/model/object/ImmutableObjectPool.js +14 -5
  8. package/src/engine/ecs/storage/BinaryBufferDeSerializer.js +7 -9
  9. package/src/engine/ecs/storage/BinaryBufferSerializer.js +15 -16
  10. package/src/engine/ecs/storage/binary/BinaryClassUpgrader.js +10 -59
  11. package/src/engine/ecs/storage/binary/BinarySerializationRegistry.js +14 -15
  12. package/src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js +3 -3
  13. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +60 -62
  14. package/src/engine/ecs/storage/binary/executeBinaryClassUpgraderChain.js +46 -0
  15. package/src/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter.js +2 -2
  16. package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.js +37 -31
  17. package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +8 -7
  18. package/src/engine/graphics/render/RendererPool.js +36 -40
  19. package/src/engine/graphics/render/buffer/FrameBuffer.js +25 -24
  20. package/src/engine/graphics/render/buffer/RenderGraph.js +21 -21
  21. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
  22. package/src/engine/graphics/render/frame_graph/IRenderContext.js +31 -1
  23. package/src/engine/graphics/render/frame_graph/RenderGraph.js +5 -5
  24. package/src/engine/graphics/render/frame_graph/RenderTarget.js +9 -0
  25. package/src/engine/graphics/render/frame_graph/RenderTextureManager.js +57 -0
  26. package/src/engine/graphics/render/frame_graph/ResourceEntry.js +7 -5
  27. package/src/engine/graphics/render/frame_graph/TextureDescriptor.js +48 -33
  28. package/src/engine/graphics/render/frame_graph/TextureInitialState.js +14 -0
  29. package/src/engine/graphics/render/frame_graph/sample/deferred/CopyPass.js +20 -0
  30. package/src/engine/graphics/render/frame_graph/sample/deferred/LightingPass.js +4 -0
  31. package/src/engine/graphics/render/frame_graph/sample/deferred/run.js +34 -6
  32. package/src/engine/graphics/render/frame_graph/webgl/WebGLRenderContext.js +34 -0
  33. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +3 -2
  34. package/src/engine/graphics/sh3/gi/prototypeSHGI.js +92 -0
  35. package/src/engine/graphics/texture/virtual/{v2/VirtualTextureMemoryMapping.js → VirtualTextureMemoryMapping.js} +2 -26
  36. package/src/engine/graphics/texture/virtual/{v2/VirtualTexturePage.js → VirtualTexturePage.js} +10 -10
  37. package/src/engine/graphics/texture/virtual/{v2/VirtualTextureTileLoader.js → VirtualTextureTileLoader.js} +7 -7
  38. package/src/engine/graphics/texture/virtual/{v2/VirtualTextureUsage.js → VirtualTextureUsage.js} +1 -1
  39. package/src/engine/graphics/texture/virtual/{v2/VirtualTextureUsageUpdater.js → VirtualTextureUsageUpdater.js} +7 -7
  40. package/src/engine/graphics/texture/virtual/{v2/debug → debug}/ResidencyDebugView.js +4 -4
  41. package/src/engine/graphics/texture/virtual/{v2/debug → debug}/UsageDebugView.js +2 -2
  42. package/src/engine/graphics/texture/virtual/{v2/debug → debug}/UsagePyramidDebugView.js +4 -4
  43. package/src/engine/graphics/texture/virtual/{v2/prototype.js → prototype.js} +7 -7
  44. package/src/engine/graphics/texture/virtual/{v2/tile → tile}/compose_finger_print.js +1 -1
  45. package/src/engine/graphics/texture/virtual/{v2/tile → tile}/compose_tile_address.js +2 -2
  46. package/src/engine/graphics/texture/virtual/{v2/tile → tile}/tile_address_to_finger_print.js +1 -1
  47. package/src/core/geom/3d/frustum/read_frustum_planes_to_array.d.ts +0 -3
  48. package/src/engine/ecs/storage/json/Blueprint.js +0 -129
  49. package/src/engine/ecs/storage/json/EntityFactory.js +0 -207
  50. package/src/engine/ecs/storage/json/JSONDeSerializer.js +0 -148
  51. package/src/engine/ecs/storage/json/JSONSerializer.js +0 -132
  52. package/src/engine/ecs/storage/json/README.md +0 -5
  53. package/src/engine/graphics/render/webgpu/sample/MeshInstance.js +0 -108
  54. package/src/engine/graphics/render/webgpu/sample/fragmentDeferredRendering.wgsl +0 -71
  55. package/src/engine/graphics/render/webgpu/sample/fragmentGBuffersDebugView.wgsl +0 -39
  56. package/src/engine/graphics/render/webgpu/sample/fragmentWriteGBuffers.wgsl +0 -21
  57. package/src/engine/graphics/render/webgpu/sample/lightUpdate.wgsl +0 -41
  58. package/src/engine/graphics/render/webgpu/sample/main.js +0 -605
  59. package/src/engine/graphics/render/webgpu/sample/vertexTextureQuad.wgsl +0 -9
  60. package/src/engine/graphics/render/webgpu/sample/vertexWriteGBuffers.wgsl +0 -30
  61. package/src/engine/graphics/texture/virtual/TileOperation.js +0 -13
  62. package/src/engine/graphics/texture/virtual/TileTree.js +0 -150
  63. package/src/engine/graphics/texture/virtual/TileTree.spec.js +0 -58
  64. package/src/engine/graphics/texture/virtual/TileUsage.js +0 -137
  65. package/src/engine/graphics/texture/virtual/VirtualTexture.js +0 -238
  66. package/src/engine/graphics/texture/virtual/VirtualTexture.spec.js +0 -39
  67. package/src/engine/graphics/texture/virtual/page/TilePage.js +0 -148
  68. package/src/engine/graphics/texture/virtual/page/TilePageSlot.js +0 -36
  69. package/src/engine/graphics/texture/virtual/tile/Tile.js +0 -44
  70. package/src/engine/graphics/texture/virtual/tile/Tile.spec.js +0 -11
  71. package/src/engine/graphics/texture/virtual/tile/TileAddress.js +0 -63
  72. package/src/engine/graphics/texture/virtual/tile/TileAddress.spec.js +0 -30
  73. package/src/engine/graphics/texture/virtual/tile/TileLoader.js +0 -178
  74. package/src/engine/graphics/texture/virtual/tile/TileRequest.js +0 -40
  75. package/src/engine/graphics/texture/virtual/tile/TileStatus.js +0 -10
  76. /package/src/engine/graphics/texture/virtual/{v2/NOTES.md → NOTES.md} +0 -0
  77. /package/src/engine/graphics/texture/virtual/{v2/VirtualTextureMaterial.js → VirtualTextureMaterial.js} +0 -0
  78. /package/src/engine/graphics/texture/virtual/{v2/VirtualTextureUsageShader.js → VirtualTextureUsageShader.js} +0 -0
  79. /package/src/engine/graphics/texture/virtual/{v2/tile → tile}/VirtualTextureTile.js +0 -0
  80. /package/src/engine/graphics/texture/virtual/{v2/tile → tile}/decompose_finger_print.js +0 -0
  81. /package/src/engine/graphics/texture/virtual/{v2/tile → tile}/finger_print_to_tile_address.js +0 -0
@@ -1,28 +1,28 @@
1
- import { RenderProgramInstance } from "./node/RenderProgramInstance.js";
2
- import { ProgramValueSlotConnectionEndpoint } from "./conection/ProgramValueSlotConnectionEndpoint.js";
3
- import { ProgramValueSlotConnection } from "./conection/ProgramValueSlotConnection.js";
4
1
  import { assert } from "../../../../core/assert.js";
2
+ import { ProgramValueSlotConnection } from "./conection/ProgramValueSlotConnection.js";
3
+ import { ProgramValueSlotConnectionEndpoint } from "./conection/ProgramValueSlotConnectionEndpoint.js";
4
+ import { RenderProgramInstance } from "./node/RenderProgramInstance.js";
5
5
  import { ProgramValueType } from "./slot/ProgramValueType.js";
6
6
 
7
7
  export class RenderGraph {
8
- constructor() {
9
- /**
10
- *
11
- * @type {RenderProgramInstance[]}
12
- */
13
- this.nodes = [];
14
- /**
15
- *
16
- * @type {ProgramValueSlotConnection[]}
17
- */
18
- this.connections = [];
19
-
20
- /**
21
- *
22
- * @type {ProgramValueSlotConnectionEndpoint|null}
23
- */
24
- this.finalOutput = null;
25
- }
8
+
9
+ /**
10
+ *
11
+ * @type {RenderProgramInstance[]}
12
+ */
13
+ nodes = [];
14
+ /**
15
+ *
16
+ * @type {ProgramValueSlotConnection[]}
17
+ */
18
+ connections = [];
19
+
20
+ /**
21
+ *
22
+ * @type {ProgramValueSlotConnectionEndpoint|null}
23
+ */
24
+ finalOutput = null;
25
+
26
26
 
27
27
  /**
28
28
  *
@@ -33,9 +33,9 @@ import HeadsUpDisplaySystem from "../../../../ecs/gui/hud/HeadsUpDisplaySystem.j
33
33
  import ViewportPositionSystem from "../../../../ecs/gui/position/ViewportPositionSystem.js";
34
34
  import { InverseKinematicsSystem } from "../../../../ecs/ik/InverseKinematicsSystem.js";
35
35
  import Renderable from "../../../../ecs/renderable/Renderable.js";
36
+ import RenderSystem from "../../../../ecs/renderable/RenderSystem.js";
36
37
  import AnimationSystem from "../../../../ecs/systems/AnimationSystem.js";
37
38
  import MotionSystem from "../../../../ecs/systems/MotionSystem.js";
38
- import RenderSystem from "../../../../ecs/systems/RenderSystem.js";
39
39
  import ScriptSystem from "../../../../ecs/systems/ScriptSystem.js";
40
40
  import SteeringSystem from "../../../../ecs/systems/SteeringSystem.js";
41
41
  import TagSystem from "../../../../ecs/systems/TagSystem.js";
@@ -1,8 +1,38 @@
1
1
  //
2
2
 
3
+ import { RenderTextureManager } from "./RenderTextureManager.js";
4
+
3
5
  /**
4
6
  * Abstracts rendering context, such as "WebGLRenderer" in THREE.js or WebGL/WebGPU
5
7
  */
6
8
  export class IRenderContext {
7
- //TODO implement
9
+
10
+ resource_manager = new RenderTextureManager();
11
+
12
+ constructor() {
13
+ this.resource_manager.attach(this);
14
+ }
15
+
16
+
17
+ /**
18
+ *
19
+ * @param {TextureDescriptor} descriptor
20
+ * @returns {RenderTarget}
21
+ */
22
+ createRenderTarget(descriptor) {
23
+ throw new Error('Not Implemented')
24
+ }
25
+
26
+ /**
27
+ *
28
+ * @param {RenderTarget} target
29
+ * @returns {boolean}
30
+ */
31
+ destroyRenderTarget(target) {
32
+ throw new Error('Not Implemented')
33
+ }
34
+
35
+ destroy() {
36
+ // override as necessary
37
+ }
8
38
  }
@@ -1,10 +1,10 @@
1
- import { RenderGraphBuilder } from "./RenderGraphBuilder.js";
2
- import { RenderPassNode } from "./RenderPassNode.js";
3
- import { ResourceNode } from "./ResourceNode.js";
4
1
  import { assert } from "../../../../core/assert.js";
5
2
  import LineBuilder from "../../../../core/codegen/LineBuilder.js";
3
+ import { RenderGraphBuilder } from "./RenderGraphBuilder.js";
4
+ import { RenderPassNode } from "./RenderPassNode.js";
6
5
  import { RenderPassResources } from "./RenderPassResources.js";
7
6
  import { ResourceEntry } from "./ResourceEntry.js";
7
+ import { ResourceNode } from "./ResourceNode.js";
8
8
 
9
9
  /**
10
10
  * Based on the Frostbite's GDC paper "FrameGraph: Extensible Rendering Architecture in Frostbite" by Yuriy O'Donnell
@@ -319,7 +319,7 @@ export class RenderGraph {
319
319
 
320
320
  for (const id of node.resource_creates) {
321
321
  // allocate resource
322
- this.getResourceEntry(id).create();
322
+ this.getResourceEntry(id).create(context.resource_manager);
323
323
  }
324
324
 
325
325
  const resources = new RenderPassResources();
@@ -331,7 +331,7 @@ export class RenderGraph {
331
331
  for (const entry of this.__resource_registry) {
332
332
  if (entry.last === node && entry.isTransient()) {
333
333
  // this was the last user of the resource and the resource is transient (no external usage)
334
- entry.destroy();
334
+ entry.destroy(context.resource_manager);
335
335
  }
336
336
  }
337
337
 
@@ -0,0 +1,9 @@
1
+ export class RenderTarget {
2
+ /**
3
+ *
4
+ * @type {TextureDescriptor|null}
5
+ */
6
+ descriptor = null
7
+
8
+ handle = -1
9
+ }
@@ -0,0 +1,57 @@
1
+ import { ImmutableObjectPool } from "../../../../core/model/object/ImmutableObjectPool.js";
2
+
3
+
4
+ export class RenderTextureManager {
5
+
6
+
7
+ /**
8
+ *
9
+ * @type {IRenderContext|null}
10
+ */
11
+ #ctx = null;
12
+
13
+ /**
14
+ *
15
+ * @type {ImmutableObjectPool<TextureDescriptor, RenderTarget>}
16
+ */
17
+ #cache = new ImmutableObjectPool();
18
+
19
+ attach(ctx) {
20
+ this.#ctx = ctx;
21
+ }
22
+
23
+ constructor() {
24
+ this.#cache.onRemoved.add((descriptor, texture) => {
25
+
26
+ this.#ctx.destroyRenderTarget(texture);
27
+
28
+ });
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @param {TextureDescriptor} descriptor
34
+ * @returns {RenderTarget}
35
+ */
36
+ get(descriptor) {
37
+ const existing = this.#cache.get(descriptor);
38
+
39
+ if (existing !== undefined) {
40
+ return existing;
41
+ }
42
+
43
+ // nothing in cache, create a new one
44
+ return this.#ctx.createRenderTarget(descriptor);
45
+
46
+ }
47
+
48
+ /**
49
+ *
50
+ * @param {RenderTarget} handle
51
+ */
52
+ release(handle) {
53
+
54
+ this.#cache.add(handle.descriptor, handle);
55
+
56
+ }
57
+ }
@@ -1,5 +1,5 @@
1
- import { TextureDescriptor } from "./TextureDescriptor.js";
2
1
  import { assert } from "../../../../core/assert.js";
2
+ import { TextureDescriptor } from "./TextureDescriptor.js";
3
3
 
4
4
  /**
5
5
  * @template T
@@ -39,20 +39,22 @@ export class ResourceEntry {
39
39
 
40
40
  /**
41
41
  * Creates actual resource
42
+ * @param {RenderTextureManager} resources
42
43
  */
43
- create() {
44
+ create(resources) {
44
45
  assert.ok(this.isTransient(), 'Only transient resources can be allocated');
45
46
 
46
- throw new Error('Not Implemented');
47
+ this.resource = resources.get(this.resource_descriptor)
47
48
  }
48
49
 
49
50
  /**
50
51
  * De-allocated memory for the resource
52
+ * @param {RenderTextureManager} resources
51
53
  */
52
- destroy() {
54
+ destroy(resources) {
53
55
  assert.ok(this.isTransient(), 'Only transient resources can be destroyed, that is resources that are created by the graph itself');
54
56
 
55
- throw new Error('Not Implemented');
57
+ resources.release(this.resource);
56
58
  }
57
59
 
58
60
  isImported() {
@@ -1,48 +1,63 @@
1
1
  import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
2
+ import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
3
+ import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
4
+ import { TextureInitialState } from "./TextureInitialState.js";
5
+
6
+ export class TextureDescriptor {
2
7
 
3
- export const TextureInitialState = {
4
8
  /**
5
- * Clear the texture.
9
+ *
10
+ * @type {number}
6
11
  */
7
- Clear: 0,
12
+ height = 0;
8
13
  /**
9
- * Doesn't matter. No need to clear
14
+ *
15
+ * @type {number}
10
16
  */
11
- Undefined: 1
12
- };
17
+ width = 0;
13
18
 
14
- export class TextureDescriptor {
15
- constructor() {
16
- /**
17
- *
18
- * @type {number}
19
- */
20
- this.height = 0;
21
- /**
22
- *
23
- * @type {number}
24
- */
25
- this.width = 0;
19
+ /**
20
+ * Render texture type
21
+ * @type {BinaryDataType}
22
+ */
23
+ format = BinaryDataType.Uint8;
24
+
25
+ /**
26
+ *
27
+ * @type {number}
28
+ */
29
+ channel_count = 1;
26
30
 
27
- /**
28
- * Render texture type
29
- * @type {BinaryDataType}
30
- */
31
- this.format = BinaryDataType.Uint8;
31
+ /**
32
+ * What should the texture be initialized to
33
+ * @type {number}
34
+ */
35
+ initial_state = TextureInitialState.Clear;
32
36
 
33
- /**
34
- *
35
- * @type {number}
36
- */
37
- this.channel_count = 1;
37
+ hash() {
38
+ return computeHashIntegerArray(
39
+ this.width,
40
+ this.height,
41
+ computeStringHash(this.format),
42
+ this.channel_count,
43
+ )
44
+ }
38
45
 
39
- /**
40
- * What should the texture be initialized to
41
- * @type {number}
42
- */
43
- this.initial_state = TextureInitialState.Clear;
46
+ /**
47
+ *
48
+ * @param {TextureDescriptor} other
49
+ * @returns {boolean}
50
+ */
51
+ equals(other) {
52
+ return this.width === other.width
53
+ && this.height === other.height
54
+ && this.format === other.format
55
+ && this.channel_count === other.channel_count
56
+ && this.initial_state === other.initial_state
57
+ ;
44
58
  }
45
59
 
60
+
46
61
  static from({
47
62
  height = 0,
48
63
  width = 0,
@@ -0,0 +1,14 @@
1
+ /**
2
+ *
3
+ * @enum {number}
4
+ */
5
+ export const TextureInitialState = {
6
+ /**
7
+ * Clear the texture.
8
+ */
9
+ Clear: 0,
10
+ /**
11
+ * Doesn't matter. No need to clear
12
+ */
13
+ Undefined: 1
14
+ };
@@ -0,0 +1,20 @@
1
+ import { RenderPass } from "../../RenderPass.js";
2
+
3
+ export class CopyPass extends RenderPass {
4
+ name = "Copy"
5
+
6
+ setup(builder, { input, output }) {
7
+
8
+ builder.read(input);
9
+
10
+ const destination = builder.write(output);
11
+
12
+ return {
13
+ output: destination
14
+ }
15
+ }
16
+
17
+ execute(data, resources, render_context) {
18
+
19
+ }
20
+ }
@@ -21,4 +21,8 @@ export class LightingPass extends RenderPass {
21
21
  output: destination
22
22
  };
23
23
  }
24
+
25
+ execute(data, resources, render_context) {
26
+ // TODO implement
27
+ }
24
28
  }
@@ -1,8 +1,8 @@
1
- import { GBufferDrawPass } from "./GBufferDrawPass.js";
2
- import { LightingPass } from "./LightingPass.js";
3
1
  import { RenderGraph } from "../../RenderGraph.js";
4
- import { WebGLRenderContext } from "../../webgl/WebGLRenderContext.js";
5
2
  import { TextureDescriptor } from "../../TextureDescriptor.js";
3
+ import { WebGLRenderContext } from "../../webgl/WebGLRenderContext.js";
4
+ import { GBufferDrawPass } from "./GBufferDrawPass.js";
5
+ import { LightingPass } from "./LightingPass.js";
6
6
 
7
7
 
8
8
  const graph = new RenderGraph();
@@ -23,9 +23,37 @@ const p_p = new LightingPass({
23
23
  });
24
24
  graph.add(p_p);
25
25
 
26
- const ctx = new WebGLRenderContext();
26
+ function makeContext() {
27
+ const canvas = document.createElement('canvas');
27
28
 
28
- graph.compile();
29
29
 
30
+ canvas.width = 800;
31
+ canvas.height = 600;
32
+
33
+ document.body.appendChild(canvas);
34
+
35
+ const ctx = canvas.getContext("webgl2");
36
+
37
+ return new WebGLRenderContext(ctx);
38
+ }
39
+
40
+ const ctx = makeContext();
41
+
42
+
43
+ graph.compile();
30
44
  console.log(graph.exportToDot());
31
- graph.execute(ctx);
45
+
46
+
47
+ function render() {
48
+ graph.compile();
49
+
50
+ graph.execute(ctx);
51
+ }
52
+
53
+ function update() {
54
+ requestAnimationFrame(update);
55
+
56
+ render();
57
+ }
58
+
59
+ update();
@@ -1,5 +1,39 @@
1
1
  import { IRenderContext } from "../IRenderContext.js";
2
+ import { RenderTarget } from "../RenderTarget.js";
2
3
 
3
4
  export class WebGLRenderContext extends IRenderContext {
5
+ /**
6
+ *
7
+ * @type {WebGL2RenderingContext|null}
8
+ */
9
+ #gl = null;
4
10
 
11
+ /**
12
+ *
13
+ * @param {WebGL2RenderingContext} ctx
14
+ */
15
+ constructor(ctx) {
16
+ super();
17
+
18
+ this.#gl = ctx;
19
+ }
20
+
21
+ /**
22
+ *
23
+ * @param {TextureDescriptor} descriptor
24
+ */
25
+ createRenderTarget(descriptor) {
26
+ console.log("createRenderTarget", descriptor)
27
+
28
+ const rt = new RenderTarget();
29
+
30
+ rt.descriptor = descriptor;
31
+ rt.handle = 0;
32
+
33
+ return rt;
34
+ }
35
+
36
+ destroyRenderTarget(target) {
37
+ return true;
38
+ }
5
39
  }
@@ -1,5 +1,6 @@
1
1
  import { mat4 } from "gl-matrix";
2
2
  import FacingDirectionSystem from "../../../../../../../model/game/ecs/system/FacingDirectionSystem.js";
3
+ import { initializeEditor } from "../../../../../../../model/game/initializeEditor.js";
3
4
  import { makeEngineOptionsModel } from "../../../../../../../model/game/options/makeEngineOptionsModel.js";
4
5
  import { enableEditor } from "../../../../../../editor/enableEditor.js";
5
6
  import { AABB3 } from "../../../../../core/geom/3d/aabb/AABB3.js";
@@ -26,9 +27,9 @@ import HeadsUpDisplaySystem from "../../../../ecs/gui/hud/HeadsUpDisplaySystem.j
26
27
  import ViewportPosition from "../../../../ecs/gui/position/ViewportPosition.js";
27
28
  import ViewportPositionSystem from "../../../../ecs/gui/position/ViewportPositionSystem.js";
28
29
  import { InverseKinematicsSystem } from "../../../../ecs/ik/InverseKinematicsSystem.js";
30
+ import RenderSystem from "../../../../ecs/renderable/RenderSystem.js";
29
31
  import AnimationSystem from "../../../../ecs/systems/AnimationSystem.js";
30
32
  import MotionSystem from "../../../../ecs/systems/MotionSystem.js";
31
- import RenderSystem from "../../../../ecs/systems/RenderSystem.js";
32
33
  import ScriptSystem from "../../../../ecs/systems/ScriptSystem.js";
33
34
  import SteeringSystem from "../../../../ecs/systems/SteeringSystem.js";
34
35
  import TagSystem from "../../../../ecs/systems/TagSystem.js";
@@ -151,7 +152,7 @@ async function init(harness) {
151
152
 
152
153
  await makeConfig(engine).apply(engine);
153
154
 
154
- enableEditor(engine);
155
+ enableEditor(engine, initializeEditor);
155
156
 
156
157
  await load_and_set_cubemap_v0(engine.graphics, 'data/textures/cubemaps/hip_miramar/32/', '.png');
157
158
 
@@ -0,0 +1,92 @@
1
+ import { make_justified_point_grid } from "../../../../core/geom/3d/util/make_justified_point_grid.js";
2
+ import Vector2 from "../../../../core/geom/Vector2.js";
3
+ import Vector3 from "../../../../core/geom/Vector3.js";
4
+ import { GameAssetType } from "../../../asset/GameAssetType.js";
5
+ import { GLTFAssetLoader } from "../../../asset/loaders/GLTFAssetLoader.js";
6
+ import { TextureAssetLoader } from "../../../asset/loaders/texture/TextureAssetLoader.js";
7
+ import Entity from "../../../ecs/Entity.js";
8
+ import { TransformAttachmentSystem } from "../../../ecs/transform-attachment/TransformAttachmentSystem.js";
9
+ import { Transform } from "../../../ecs/transform/Transform.js";
10
+ import { EngineHarness } from "../../../EngineHarness.js";
11
+ import { BehaviorSystem } from "../../../intelligence/behavior/ecs/BehaviorSystem.js";
12
+ import { SGMesh } from "../../ecs/mesh-v2/aggregate/SGMesh.js";
13
+ import { SGMeshSystem } from "../../ecs/mesh-v2/aggregate/SGMeshSystem.js";
14
+ import { ShadedGeometry } from "../../ecs/mesh-v2/ShadedGeometry.js";
15
+ import { ShadedGeometrySystem } from "../../ecs/mesh-v2/ShadedGeometrySystem.js";
16
+
17
+
18
+ /**
19
+ *
20
+ * @param {AABB3} bounds
21
+ * @param {number} [spacing]
22
+ */
23
+ function buildProbeGrid(bounds, spacing = 1) {
24
+ const positions = [];
25
+
26
+ make_justified_point_grid(bounds, spacing, (x, y, z) => {
27
+ positions.push(x, y, z);
28
+ })
29
+
30
+ }
31
+
32
+ /**
33
+ *
34
+ * @param {Engine} engine
35
+ */
36
+ async function buildGI(engine) {
37
+
38
+ const ecd = engine.entityManager.dataset;
39
+
40
+ ecd.traverseEntities([ShadedGeometry, Transform], (sg, transform, entity) => {
41
+
42
+ });
43
+
44
+ new Entity()
45
+ .add(SGMesh.fromURL("moicon/gnutti_not_optimized/model.gltf"))
46
+ .add(Transform.fromJSON({
47
+ position: { x: 10, y: 3, z: 10 },
48
+ scale: 1.5
49
+ }));
50
+
51
+ }
52
+
53
+
54
+ function init() {
55
+
56
+ /**
57
+ *
58
+ * @param {Engine} engine
59
+ */
60
+ async function main(engine) {
61
+
62
+ await EngineHarness.buildBasics({
63
+ engine,
64
+ focus: new Vector3(128, 0, 128),
65
+ distance: 30,
66
+ terrainResolution: 1,
67
+ terrainSize: new Vector2(128, 128),
68
+ enableWater: false,
69
+ });
70
+
71
+ }
72
+
73
+ new EngineHarness().initialize({
74
+ configuration(config, engine) {
75
+ config.addLoader(GameAssetType.Texture, new TextureAssetLoader());
76
+
77
+ const gltfAssetLoader = new GLTFAssetLoader();
78
+
79
+ config.addLoader(GameAssetType.ModelGLTF_JSON, gltfAssetLoader);
80
+ config.addLoader(GameAssetType.ModelGLTF, gltfAssetLoader);
81
+
82
+ config.addSystem(new BehaviorSystem(engine))
83
+ config.addSystem(new SGMeshSystem(engine));
84
+ config.addSystem(new ShadedGeometrySystem(engine));
85
+ config.addSystem(new TransformAttachmentSystem(engine));
86
+ }
87
+ })
88
+ .then(main);
89
+ }
90
+
91
+
92
+ init();
@@ -1,6 +1,6 @@
1
1
  import { ClampToEdgeWrapping, DataTexture, NearestFilter, RedIntegerFormat, UnsignedIntType } from "three";
2
- import { assert } from "../../../../../core/assert.js";
3
- import { UINT32_MAX } from "../../../../../core/binary/UINT32_MAX.js";
2
+ import { assert } from "../../../../core/assert.js";
3
+ import { UINT32_MAX } from "../../../../core/binary/UINT32_MAX.js";
4
4
  import { compose_tile_address } from "./tile/compose_tile_address.js";
5
5
  import { decompose_finger_print } from "./tile/decompose_finger_print.js";
6
6
 
@@ -51,8 +51,6 @@ export class VirtualTextureMemoryMapping {
51
51
 
52
52
  texture.magFilter = NearestFilter;
53
53
  texture.minFilter = NearestFilter;
54
- // texture.minFilter = NearestMipMapNearestFilter;
55
- // texture.magFilter = NearestMipMapNearestFilter;
56
54
  }
57
55
 
58
56
  /**
@@ -91,28 +89,6 @@ export class VirtualTextureMemoryMapping {
91
89
  texture.image.width = texture_dimension;
92
90
  texture.image.height = texture_dimension;
93
91
 
94
- // texture.mipmaps.splice(0, texture.mipmaps.length);
95
- // let buffer_offset = 0;
96
- // for (let mip_level = 0; mip_level <= max_mip_level; mip_level++) {
97
- // const mip_resolution = 1 << mip_level;
98
- //
99
- // const texel_count = mip_resolution * mip_resolution;
100
- // texture.mipmaps[mip_level] = {
101
- // data: new Uint32Array(arrayBuffer, buffer_offset, texel_count),
102
- // width: mip_resolution,
103
- // height: mip_resolution
104
- // };
105
- //
106
- // buffer_offset += texel_count * 4;
107
- // }
108
- //
109
- // texture.mipmaps.reverse();
110
- //
111
- // const top_mip = texture.mipmaps[0];
112
- // texture.image.data = top_mip.data;
113
- // texture.image.width = top_mip.width;
114
- // texture.image.height = top_mip.height;
115
-
116
92
  texture.needsUpdate = true;
117
93
  }
118
94
 
@@ -1,14 +1,14 @@
1
1
  import { ClampToEdgeWrapping, DataTexture, LinearFilter, NearestFilter, Vector2 } from "three";
2
- import { assert } from "../../../../../core/assert.js";
3
- import { BitSet } from "../../../../../core/binary/BitSet.js";
4
- import { Cache } from "../../../../../core/cache/Cache.js";
5
- import { array_copy } from "../../../../../core/collection/array/array_copy.js";
6
- import { HashMap } from "../../../../../core/collection/map/HashMap.js";
7
- import { passThrough, strictEquals } from "../../../../../core/function/Functions.js";
8
- import { max2 } from "../../../../../core/math/max2.js";
9
- import { min2 } from "../../../../../core/math/min2.js";
10
- import { Sampler2D } from "../../sampler/Sampler2D.js";
11
- import { writeSample2DDataToDataTexture } from "../../sampler/writeSampler2DDataToDataTexture.js";
2
+ import { assert } from "../../../../core/assert.js";
3
+ import { BitSet } from "../../../../core/binary/BitSet.js";
4
+ import { Cache } from "../../../../core/cache/Cache.js";
5
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
6
+ import { HashMap } from "../../../../core/collection/map/HashMap.js";
7
+ import { passThrough, strictEquals } from "../../../../core/function/Functions.js";
8
+ import { max2 } from "../../../../core/math/max2.js";
9
+ import { min2 } from "../../../../core/math/min2.js";
10
+ import { Sampler2D } from "../sampler/Sampler2D.js";
11
+ import { writeSample2DDataToDataTexture } from "../sampler/writeSampler2DDataToDataTexture.js";
12
12
  import { tile_address_to_finger_print } from "./tile/tile_address_to_finger_print.js";
13
13
  import { VirtualTextureTileLoader } from "./VirtualTextureTileLoader.js";
14
14