@woosh/meep-engine 2.165.4 → 2.165.5

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 (141) hide show
  1. package/editor/Editor.d.ts +65 -65
  2. package/editor/SelectionVisualizer.d.ts +19 -19
  3. package/editor/actions/concrete/ActionUpdateTexture.d.ts +11 -11
  4. package/editor/actions/concrete/ArrayCopyAction.d.ts +19 -19
  5. package/editor/actions/concrete/ComponentAddAction.d.ts +14 -14
  6. package/editor/actions/concrete/ComponentRemoveAction.d.ts +10 -10
  7. package/editor/actions/concrete/EntityCreateAction.d.ts +17 -17
  8. package/editor/actions/concrete/EntityRemoveAction.d.ts +10 -10
  9. package/editor/actions/concrete/ModifyPatchSampler2DAction.d.ts +46 -46
  10. package/editor/actions/concrete/ModifyPatchTextureArray2DAction.d.ts +37 -37
  11. package/editor/actions/concrete/PaintTerrainOverlayAction.d.ts +22 -22
  12. package/editor/actions/concrete/PatchTerrainHeightAction.d.ts +18 -18
  13. package/editor/actions/concrete/SelectionAddAction.d.ts +18 -18
  14. package/editor/actions/concrete/SelectionClearAction.d.ts +8 -8
  15. package/editor/actions/concrete/SelectionRemoveAction.d.ts +9 -9
  16. package/editor/actions/concrete/TransformModifyAction.d.ts +16 -16
  17. package/editor/actions/concrete/WriteGridValueAction.d.ts +14 -14
  18. package/editor/ecs/EditorEntity.d.ts +15 -15
  19. package/editor/ecs/EditorEntitySystem.d.ts +7 -7
  20. package/editor/ecs/component/FieldDescriptor.d.ts +26 -26
  21. package/editor/ecs/component/FieldValueAdapter.d.ts +6 -6
  22. package/editor/ecs/component/TypeEditor.d.ts +24 -24
  23. package/editor/ecs/component/createFieldEditor.d.ts +8 -8
  24. package/editor/ecs/component/createObjectEditor.d.ts +13 -13
  25. package/editor/ecs/component/editors/ColorEditor.d.ts +6 -6
  26. package/editor/ecs/component/editors/HTMLElementEditor.d.ts +6 -6
  27. package/editor/ecs/component/editors/ImagePathEditor.d.ts +6 -6
  28. package/editor/ecs/component/editors/LargeStringEditor.d.ts +15 -15
  29. package/editor/ecs/component/editors/NumericIntervalEditor.d.ts +6 -6
  30. package/editor/ecs/component/editors/ObservedBooleanEditor.d.ts +6 -6
  31. package/editor/ecs/component/editors/ObservedEnumEditor.d.ts +6 -6
  32. package/editor/ecs/component/editors/ObservedIntegerEditor.d.ts +6 -6
  33. package/editor/ecs/component/editors/ObservedStringEditor.d.ts +6 -6
  34. package/editor/ecs/component/editors/Sampler2DEditor.d.ts +6 -6
  35. package/editor/ecs/component/editors/collection/ListEditor.d.ts +7 -7
  36. package/editor/ecs/component/editors/common/BitFlagsEditor.d.ts +11 -11
  37. package/editor/ecs/component/editors/common/EnumEditor.d.ts +7 -7
  38. package/editor/ecs/component/editors/common/makeV3_editor.d.ts +14 -14
  39. package/editor/ecs/component/editors/common/noEditor.d.ts +2 -2
  40. package/editor/ecs/component/editors/ecs/GridObstacleEditor.d.ts +6 -6
  41. package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.d.ts +13 -13
  42. package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.d.ts +66 -66
  43. package/editor/ecs/component/editors/ecs/ParameterTrackEditor.d.ts +11 -11
  44. package/editor/ecs/component/editors/ecs/ParameterTrackSetEditor.d.ts +13 -13
  45. package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.d.ts +51 -51
  46. package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.d.ts +47 -47
  47. package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.d.ts +15 -15
  48. package/editor/ecs/component/editors/ecs/Trail2DEditor.d.ts +29 -29
  49. package/editor/ecs/component/editors/ecs/TransformEditor.d.ts +19 -19
  50. package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.d.ts +18 -18
  51. package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.d.ts +38 -38
  52. package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.d.ts +15 -15
  53. package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.d.ts +18 -18
  54. package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.d.ts +17 -17
  55. package/editor/ecs/component/editors/geom/QuaternionEditor.d.ts +5 -5
  56. package/editor/ecs/component/editors/geom/Vector1Editor.d.ts +6 -6
  57. package/editor/ecs/component/editors/geom/Vector2Editor.d.ts +5 -5
  58. package/editor/ecs/component/editors/geom/Vector3Editor.d.ts +5 -5
  59. package/editor/ecs/component/editors/geom/Vector4Editor.d.ts +5 -5
  60. package/editor/ecs/component/editors/primitive/ArrayEditor.d.ts +7 -7
  61. package/editor/ecs/component/editors/primitive/BooleanEditor.d.ts +6 -6
  62. package/editor/ecs/component/editors/primitive/FunctionEditor.d.ts +6 -6
  63. package/editor/ecs/component/editors/primitive/NumberEditor.d.ts +7 -7
  64. package/editor/ecs/component/editors/primitive/ObjectEditor.d.ts +5 -5
  65. package/editor/ecs/component/editors/primitive/StringEditor.d.ts +6 -6
  66. package/editor/ecs/component/editors/three/BufferGeometryEditor.d.ts +6 -6
  67. package/editor/ecs/component/editors/three/MaterialEditor.d.ts +6 -6
  68. package/editor/ecs/component/editors/three/MeshEditor.d.ts +6 -6
  69. package/editor/ecs/component/editors/three/TextureEditor.d.ts +6 -6
  70. package/editor/ecs/component/findNearestRegisteredType.d.ts +7 -7
  71. package/editor/enableEditor.d.ts +13 -13
  72. package/editor/library/MeshLibrary.d.ts +12 -12
  73. package/editor/process/DisableGameUIProcess.d.ts +7 -7
  74. package/editor/process/EditorProcess.d.ts +18 -18
  75. package/editor/process/ObstacleGridDisplayProcess.d.ts +12 -12
  76. package/editor/process/ProcessEngine.d.ts +29 -29
  77. package/editor/process/SymbolicDisplayProcess.d.ts +18 -18
  78. package/editor/process/symbolic/ComponentSymbolicDisplay.d.ts +10 -10
  79. package/editor/process/symbolic/SymbolicDisplayInternalAPI.d.ts +64 -64
  80. package/editor/process/symbolic/buildThreeJSHelperEntity.d.ts +8 -8
  81. package/editor/process/symbolic/make3DSymbolicDisplay.d.ts +9 -9
  82. package/editor/process/symbolic/makeCameraSymbolicDisplay.d.ts +6 -6
  83. package/editor/process/symbolic/makeGridPositionSymbolDisplay.d.ts +5 -5
  84. package/editor/process/symbolic/makeHelperBoxGeometry.d.ts +2 -2
  85. package/editor/process/symbolic/makeHelperSphereGeometry.d.ts +8 -8
  86. package/editor/process/symbolic/makeLightSymbolicDisplay.d.ts +6 -6
  87. package/editor/process/symbolic/makeParticleEmitterSymbolicDisplay.d.ts +5 -5
  88. package/editor/process/symbolic/makePathSymbolicDisplay.d.ts +6 -6
  89. package/editor/process/symbolic/makePositionedIconDisplaySymbol.d.ts +8 -8
  90. package/editor/process/symbolic/makeSocketsSymbolicDisplay.d.ts +6 -6
  91. package/editor/process/symbolic/makeSolidArrowGeometry.d.ts +25 -25
  92. package/editor/process/symbolic/makeSoundEmitterSymbolicDisplay.d.ts +5 -5
  93. package/editor/process/symbolic/synchronizeTransform.d.ts +11 -11
  94. package/editor/tools/GridPaintTool.d.ts +16 -16
  95. package/editor/tools/SelectionTool.d.ts +26 -26
  96. package/editor/tools/TopDownCameraControlTool.d.ts +12 -12
  97. package/editor/tools/engine/Tool.d.ts +63 -63
  98. package/editor/tools/engine/ToolEngine.d.ts +22 -22
  99. package/editor/tools/engine/ToolState.d.ts +6 -6
  100. package/editor/tools/paint/TerrainHeightPaintTool.d.ts +17 -17
  101. package/editor/tools/paint/TerrainPaintTool.d.ts +30 -30
  102. package/editor/tools/paint/TerrainTexturePaintTool.d.ts +17 -17
  103. package/editor/tools/v2/TransformMode.d.ts +6 -6
  104. package/editor/view/EditorView.d.ts +38 -38
  105. package/editor/view/ecs/ComponentControlFactory.d.ts +18 -18
  106. package/editor/view/ecs/ComponentControlView.d.ts +23 -23
  107. package/editor/view/ecs/EntityEditor.d.ts +29 -29
  108. package/editor/view/ecs/EntityList.d.ts +21 -21
  109. package/editor/view/ecs/HierarchicalEntityListView.d.ts +7 -7
  110. package/editor/view/ecs/components/DatGuiController.d.ts +45 -45
  111. package/editor/view/ecs/components/GridObstacleController.d.ts +13 -13
  112. package/editor/view/ecs/components/color/GaugeView.d.ts +12 -12
  113. package/editor/view/ecs/components/common/AutoCanvasView.d.ts +19 -19
  114. package/editor/view/ecs/components/common/LineView.d.ts +11 -11
  115. package/editor/view/ecs/components/common/NumberController.d.ts +17 -17
  116. package/editor/view/ecs/components/particles/ColorParameterLUTController.d.ts +13 -13
  117. package/editor/view/makeEntityDecorators.d.ts +5 -5
  118. package/editor/view/tools/ToolSettingsView.d.ts +10 -10
  119. package/editor/view/tools/ToolView.d.ts +12 -12
  120. package/editor/view/v2/SplitView.d.ts +16 -16
  121. package/package.json +1 -1
  122. package/samples/generation/grid/GridTags.d.ts +15 -15
  123. package/samples/generation/grid/MirGridLayers.d.ts +7 -7
  124. package/samples/generation/rules/matcher_tag_occupied.d.ts +2 -2
  125. package/samples/generation/rules/matcher_tag_traversable.d.ts +2 -2
  126. package/samples/generation/rules/matcher_tag_unoccupied.d.ts +2 -2
  127. package/src/engine/graphics/ecs/light/LightContext.d.ts +8 -0
  128. package/src/engine/graphics/ecs/light/LightContext.d.ts.map +1 -1
  129. package/src/engine/graphics/ecs/light/LightContext.js +33 -3
  130. package/src/engine/graphics/ecs/light/LightSystem.d.ts.map +1 -1
  131. package/src/engine/graphics/ecs/light/LightSystem.js +13 -6
  132. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts +12 -0
  133. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts.map +1 -1
  134. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +184 -6
  135. package/src/engine/graphics/render/buffer/simple-fx/ao/SAOShader.js +381 -362
  136. package/src/engine/graphics/shadows/ShadowMapRenderer.d.ts +10 -0
  137. package/src/engine/graphics/shadows/ShadowMapRenderer.d.ts.map +1 -1
  138. package/src/engine/graphics/shadows/ShadowMapRenderer.js +83 -10
  139. package/src/engine/graphics/shadows/testPointShadowMapRendering.d.ts +2 -0
  140. package/src/engine/graphics/shadows/testPointShadowMapRendering.d.ts.map +1 -0
  141. package/src/engine/graphics/shadows/testPointShadowMapRendering.js +242 -0
@@ -18,6 +18,16 @@ export class ShadowMapRenderer {
18
18
  * @param {Light} light
19
19
  */
20
20
  update(renderer: THREE.WebGLRenderer, shadow: LightShadow, scene: Scene, light: Light): void;
21
+ /**
22
+ * Render each cube face of a point light shadow into its own viewport of
23
+ * the shadow map atlas (4x2 face grid, matching three.js cubeToUV layout)
24
+ * @param {THREE.WebGLRenderer} renderer
25
+ * @param {PointLightShadow} shadow
26
+ * @param {Scene} scene
27
+ * @param {THREE.PointLight} light
28
+ * @private
29
+ */
30
+ private __render_cube_faces;
21
31
  /**
22
32
  *
23
33
  * @param {LightShadow} shadow
@@ -1 +1 @@
1
- {"version":3,"file":"ShadowMapRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/shadows/ShadowMapRenderer.js"],"names":[],"mappings":"AAuCA;IAGQ;;;;OAIG;IACH,mBAAsB;IAEtB;;;OAGG;IACH,gBAFU,MAAM,CAEkB;IAItC;;;;;;OAMG;IACH,iBALW,MAAM,aAAa,8BAEnB,KAAK,sBAuEf;IAED;;;;OAIG;IACH,sBAyCC;IAED;;;;;OAKG;IACH,qBA8BC;CACJ;mBAhNkB,uCAAuC;sBADnD,OAAO"}
1
+ {"version":3,"file":"ShadowMapRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/shadows/ShadowMapRenderer.js"],"names":[],"mappings":"AAuCA;IAGQ;;;;OAIG;IACH,mBAAsB;IAEtB;;;OAGG;IACH,gBAFU,MAAM,CAEkB;IAItC;;;;;;OAMG;IACH,iBALW,MAAM,aAAa,8BAEnB,KAAK,sBAoFf;IAED;;;;;;;;OAQG;IACH,4BA8BC;IAED;;;;OAIG;IACH,sBAyCC;IAED;;;;;OAKG;IACH,qBAiDC;CACJ;mBAzRkB,uCAAuC;sBADnD,OAAO"}
@@ -102,18 +102,31 @@ export class ShadowMapRenderer {
102
102
 
103
103
  renderer.clear(true, true, false);
104
104
 
105
- shadow.updateMatrices(light, 0);
105
+ if (shadow.isPointLightShadow === true) {
106
106
 
107
- this.onBeforeRender.send3(renderer, shadow_camera, scene);
107
+ if (target.width > 0 && target.height > 0) {
108
+
109
+ this.__render_cube_faces(renderer, shadow, scene, light);
110
+
111
+ // no VSM pass: three.js point shadow sampling (getPointShadow)
112
+ // reads plain RGBA-packed distance regardless of shadow map type
113
+ }
108
114
 
109
- if (target.width <= 0 || target.height <= 0) {
110
- // no point in rendering
111
115
  } else {
112
- // do the draw
113
- renderer.render(scene, shadow_camera);
114
116
 
115
- if (renderer.shadowMap.type === VSMShadowMap) {
116
- this.__do_vsm_pass(shadow);
117
+ shadow.updateMatrices(light, 0);
118
+
119
+ this.onBeforeRender.send3(renderer, shadow_camera, scene);
120
+
121
+ if (target.width <= 0 || target.height <= 0) {
122
+ // no point in rendering
123
+ } else {
124
+ // do the draw
125
+ renderer.render(scene, shadow_camera);
126
+
127
+ if (renderer.shadowMap.type === VSMShadowMap) {
128
+ this.__do_vsm_pass(shadow);
129
+ }
117
130
  }
118
131
  }
119
132
 
@@ -132,6 +145,47 @@ export class ShadowMapRenderer {
132
145
  renderer.info.render.frame++;
133
146
  }
134
147
 
148
+ /**
149
+ * Render each cube face of a point light shadow into its own viewport of
150
+ * the shadow map atlas (4x2 face grid, matching three.js cubeToUV layout)
151
+ * @param {THREE.WebGLRenderer} renderer
152
+ * @param {PointLightShadow} shadow
153
+ * @param {Scene} scene
154
+ * @param {THREE.PointLight} light
155
+ * @private
156
+ */
157
+ __render_cube_faces(renderer, shadow, scene, light) {
158
+ const target = shadow.map;
159
+ const shadow_camera = shadow.camera;
160
+ const map_size = shadow.mapSize;
161
+
162
+ const viewport_count = shadow.getViewportCount();
163
+
164
+ for (let i = 0; i < viewport_count; i++) {
165
+ // orient the shadow camera along the face direction
166
+ shadow.updateMatrices(light, i);
167
+
168
+ const viewport = shadow.getViewport(i);
169
+
170
+ target.viewport.set(
171
+ map_size.x * viewport.x,
172
+ map_size.y * viewport.y,
173
+ map_size.x * viewport.z,
174
+ map_size.y * viewport.w
175
+ );
176
+
177
+ // re-bind to apply the updated viewport
178
+ renderer.setRenderTarget(target);
179
+
180
+ this.onBeforeRender.send3(renderer, shadow_camera, scene);
181
+
182
+ renderer.render(scene, shadow_camera);
183
+ }
184
+
185
+ // leave the target with a full-size viewport to keep other consumers unaffected
186
+ target.viewport.set(0, 0, target.width, target.height);
187
+ }
188
+
135
189
  /**
136
190
  *
137
191
  * @param {LightShadow} shadow
@@ -191,6 +245,25 @@ export class ShadowMapRenderer {
191
245
 
192
246
  if (shadow.map === null) {
193
247
 
248
+ // point light shadows pack six cube faces into a 4x2 viewport
249
+ // atlas, other shadow types occupy the full target (extents 1x1)
250
+ const frame_extents = shadow.getFrameExtents();
251
+
252
+ // clamp so the atlas fits into a single texture, shrinking the
253
+ // per-face resolution if necessary (mirrors THREE.WebGLShadowMap)
254
+ const max_texture_size = renderer.capabilities.maxTextureSize;
255
+
256
+ if (_shadowMapSize.x * frame_extents.x > max_texture_size) {
257
+ _shadowMapSize.x = Math.floor(max_texture_size / frame_extents.x);
258
+ }
259
+
260
+ if (_shadowMapSize.y * frame_extents.y > max_texture_size) {
261
+ _shadowMapSize.y = Math.floor(max_texture_size / frame_extents.y);
262
+ }
263
+
264
+ const target_width = _shadowMapSize.x * frame_extents.x;
265
+ const target_height = _shadowMapSize.y * frame_extents.y;
266
+
194
267
  const pars = {
195
268
  format: RGBAFormat,
196
269
  scissorTest: false,
@@ -201,7 +274,7 @@ export class ShadowMapRenderer {
201
274
  pars.minFilter = LinearFilter;
202
275
  pars.magFilter = LinearFilter;
203
276
 
204
- shadow.mapPass = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, Object.assign({
277
+ shadow.mapPass = new WebGLRenderTarget(target_width, target_height, Object.assign({
205
278
  depthBuffer: false
206
279
  }, pars));
207
280
 
@@ -211,7 +284,7 @@ export class ShadowMapRenderer {
211
284
 
212
285
  }
213
286
 
214
- shadow.map = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars);
287
+ shadow.map = new WebGLRenderTarget(target_width, target_height, pars);
215
288
  shadow.map.texture.name = '.shadowMap';
216
289
 
217
290
  shadow.camera.updateProjectionMatrix();
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=testPointShadowMapRendering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testPointShadowMapRendering.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/shadows/testPointShadowMapRendering.js"],"names":[],"mappings":""}
@@ -0,0 +1,242 @@
1
+ import {
2
+ initializeGameBinarySerializationRegistry
3
+ } from "../../../../../model/game/GameBinarySerializationRegistry.js";
4
+ import { enableEditor } from "../../../../editor/enableEditor.js";
5
+ import Vector2 from "../../../core/geom/Vector2.js";
6
+ import Vector3 from "../../../core/geom/Vector3.js";
7
+ import { ArrayBufferLoader } from "../../asset/loaders/ArrayBufferLoader.js";
8
+ import { AttachmentSystem } from "../../ecs/attachment/AttachmentSystem.js";
9
+ import { SerializationMetadata } from "../../ecs/components/SerializationMetadata.js";
10
+ import Entity from "../../ecs/Entity.js";
11
+ import GUIElement from "../../ecs/gui/GUIElement.js";
12
+ import GUIElementSystem from "../../ecs/gui/GUIElementSystem.js";
13
+ import HeadsUpDisplaySystem from "../../ecs/gui/hud/HeadsUpDisplaySystem.js";
14
+ import ViewportPosition from "../../ecs/gui/position/ViewportPosition.js";
15
+ import ViewportPositionSystem from "../../ecs/gui/position/ViewportPositionSystem.js";
16
+ import AnimationSystem from "../../ecs/systems/AnimationSystem.js";
17
+ import ClingToTerrainSystem from "../../ecs/terrain/ecs/cling/ClingToTerrainSystem.js";
18
+ import TerrainSystem from "../../ecs/terrain/ecs/TerrainSystem.js";
19
+ import { Transform } from "../../ecs/transform/Transform.js";
20
+ import { EngineConfiguration } from "../../EngineConfiguration.js";
21
+ import { EngineHarness } from "../../EngineHarness.js";
22
+ import InputControllerSystem from "../../input/ecs/systems/InputControllerSystem.js";
23
+ import { InputSystem } from "../../input/ecs/systems/InputSystem.js";
24
+ import { BehaviorSystem } from "../../intelligence/behavior/ecs/BehaviorSystem.js";
25
+ import { loadSerializedScene } from "../../scene/SerializedScene.js";
26
+ import { SoundEmitterSystem } from "../../sound/ecs/emitter/SoundEmitterSystem.js";
27
+ import SoundControllerSystem from "../../sound/ecs/SoundControllerSystem.js";
28
+ import SoundListenerSystem from "../../sound/ecs/SoundListenerSystem.js";
29
+ import { CameraSystem } from "../ecs/camera/CameraSystem.js";
30
+ import TopDownCameraControllerSystem from "../ecs/camera/topdown/TopDownCameraControllerSystem.js";
31
+ import MeshHighlightSystem from "../ecs/highlight/system/MeshHighlightSystem.js";
32
+ import { Light } from "../ecs/light/Light.js";
33
+ import LightSystem from "../ecs/light/LightSystem.js";
34
+ import { LightType } from "../ecs/light/LightType.js";
35
+ import { ShadedGeometrySystem } from "../ecs/mesh-v2/ShadedGeometrySystem.js";
36
+ import Mesh from "../ecs/mesh/Mesh.js";
37
+ import { MeshSystem } from "../ecs/mesh/MeshSystem.js";
38
+ import { PathDisplaySystem } from "../ecs/path/PathDisplaySystem.js";
39
+ import Trail2DSystem from "../ecs/trail2d/Trail2DSystem.js";
40
+ import WaterSystem from "../ecs/water/WaterSystem.js";
41
+ import { ParticleEmitterSystem } from "../particles/ecs/ParticleEmitterSystem.js";
42
+ import { buildCanvasViewFromTexture } from "../render/visibility/hiz/buildCanvasViewFromTexture.js";
43
+
44
+ const eh = new EngineHarness();
45
+
46
+ /**
47
+ *
48
+ * @param {Engine} engine
49
+ * @returns {EngineConfiguration}
50
+ */
51
+ function makeConfig(engine) {
52
+
53
+ const config = new EngineConfiguration();
54
+
55
+ /**
56
+ *
57
+ * @type {SoundEngine}
58
+ */
59
+ const sound = engine.sound;
60
+ const graphics = engine.graphics;
61
+ const assetManager = engine.assetManager;
62
+ const devices = engine.devices;
63
+
64
+ const guiSystem = new GUIElementSystem(engine.gui.view, engine);
65
+ const headsUpDisplaySystem = new HeadsUpDisplaySystem(graphics);
66
+
67
+ config.addLoader('arraybuffer', new ArrayBufferLoader());
68
+
69
+ initializeGameBinarySerializationRegistry(engine.binarySerializationRegistry);
70
+
71
+ config.addManySystems(
72
+ new AttachmentSystem(),
73
+ new SoundEmitterSystem(assetManager, sound),
74
+ new SoundControllerSystem(),
75
+ new SoundListenerSystem(sound.context),
76
+ guiSystem,
77
+ new AnimationSystem(graphics.viewport.size),
78
+ new TopDownCameraControllerSystem(graphics),
79
+ new CameraSystem(engine.graphics),
80
+ new MeshSystem(engine),
81
+ new ClingToTerrainSystem(),
82
+ new TerrainSystem(graphics, assetManager),
83
+ new Trail2DSystem(engine),
84
+ new ViewportPositionSystem(graphics.viewport.size),
85
+ new InputControllerSystem(devices),
86
+ new InputSystem(devices),
87
+ new MeshHighlightSystem(engine),
88
+ new LightSystem(engine, {
89
+ shadowResolution: 2048
90
+ }),
91
+ headsUpDisplaySystem,
92
+ new BehaviorSystem(engine),
93
+ new PathDisplaySystem(engine),
94
+ new ParticleEmitterSystem(engine),
95
+ new ShadedGeometrySystem(engine),
96
+ new WaterSystem(graphics)
97
+ );
98
+
99
+ return config;
100
+ }
101
+
102
+ /**
103
+ *
104
+ * @param {Engine} engine
105
+ */
106
+ function get_three_light(engine) {
107
+
108
+ return engine.graphics.scene.children.find(l => l.isPointLight && l.castShadow);
109
+ }
110
+
111
+ /**
112
+ * Preview the 4x2 cube face atlas of the point light's shadow map
113
+ * @param {Engine} engine
114
+ */
115
+ function init_shadowmap_preview(engine) {
116
+ const ecd = engine.entityManager.dataset;
117
+
118
+ const graphics = engine.graphics;
119
+ const preview = buildCanvasViewFromTexture({
120
+ width: 1024,
121
+ height: 512,
122
+ renderer: graphics.renderer,
123
+ texture: null
124
+ });
125
+
126
+ graphics.on.postOpaquePass.add(() => {
127
+
128
+ const light = get_three_light(engine);
129
+
130
+ if (light !== undefined && light.shadow.map !== null) {
131
+ preview.texture = light.shadow.map.texture;
132
+
133
+ preview.render();
134
+ }
135
+ });
136
+
137
+
138
+ new Entity()
139
+ .add(ViewportPosition.fromJSON({
140
+ offset: new Vector2(10, 10)
141
+ }))
142
+ .add(GUIElement.fromView(preview.view))
143
+ .add(SerializationMetadata.Transient)
144
+ .build(ecd);
145
+ }
146
+
147
+ /**
148
+ * Point light above the character, casters placed on every axis so all six
149
+ * cube faces receive geometry
150
+ * @param {Engine} engine
151
+ * @param {Vector3} center
152
+ */
153
+ function build_point_light_scene(engine, center) {
154
+ const ecd = engine.entityManager.dataset;
155
+
156
+ const CASTER_URL = "data/models/Conqueror Mech/Conqueror Mech.gltf";
157
+ const LIGHT_HEIGHT = 3;
158
+ const RING_RADIUS = 4;
159
+
160
+ // light itself
161
+ const light = new Light();
162
+ light.type.set(LightType.POINT);
163
+ light.color.setRGB(1.0, 0.85, 0.6);
164
+ light.intensity.set(2);
165
+ light.distance.set(20);
166
+ light.castShadow.set(true);
167
+
168
+ const light_transform = new Transform();
169
+ light_transform.position.set(center.x, center.y + LIGHT_HEIGHT, center.z);
170
+
171
+ new Entity()
172
+ .add(light)
173
+ .add(light_transform)
174
+ .add(SerializationMetadata.Transient)
175
+ .build(ecd);
176
+
177
+ // casters on +X/-X/+Z/-Z of the light; the ground receives -Y, the caster
178
+ // hovering above the light exercises the +Y face
179
+ const positions = [
180
+ [RING_RADIUS, 0, 0],
181
+ [-RING_RADIUS, 0, 0],
182
+ [0, 0, RING_RADIUS],
183
+ [0, 0, -RING_RADIUS],
184
+ [0, LIGHT_HEIGHT + 2, 0]
185
+ ];
186
+
187
+ for (const [x, y, z] of positions) {
188
+ const transform = new Transform();
189
+ transform.position.set(center.x + x, center.y + y, center.z + z);
190
+
191
+ new Entity()
192
+ .add(Mesh.fromURL(CASTER_URL))
193
+ .add(transform)
194
+ .add(SerializationMetadata.Transient)
195
+ .build(ecd);
196
+ }
197
+ }
198
+
199
+ /**
200
+ *
201
+ * @param {Engine} engine
202
+ * @returns {Promise<void>}
203
+ */
204
+ async function main(engine) {
205
+
206
+ const ecd = engine.entityManager.dataset;
207
+ await loadSerializedScene('data/levels/character_creation/level.bin', ecd, engine);
208
+
209
+
210
+ // center the test scene on any placed mesh, fall back to the origin
211
+ let center = new Vector3(0, 0, 0);
212
+
213
+ ecd.traverseComponents(Mesh, (mesh, entity) => {
214
+ const transform = ecd.getComponent(entity, Transform);
215
+
216
+ if (transform !== undefined) {
217
+ center = transform.position;
218
+ return false;
219
+ }
220
+ });
221
+
222
+ build_point_light_scene(engine, center);
223
+
224
+ init_shadowmap_preview(engine);
225
+
226
+ window.light = get_three_light(engine);
227
+ }
228
+
229
+ async function init(engineHarness) {
230
+
231
+ const engine = await engineHarness.initialize();
232
+
233
+ const config = makeConfig(engine);
234
+
235
+ await config.apply(engine);
236
+
237
+ enableEditor(engine);
238
+
239
+ main(engine).catch(e => console.error('testPointShadowMapRendering failed:', e));
240
+ }
241
+
242
+ init(eh);