@woosh/meep-engine 2.33.23 → 2.33.24

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 (204) hide show
  1. package/core/bvh2/BinaryNode.js +1 -1
  2. package/core/bvh2/aabb3/AABB3.js +18 -0
  3. package/core/bvh2/aabb3/AABB3Math.js +1 -1
  4. package/core/bvh2/binary/2/BinaryUint32BVH.js +498 -0
  5. package/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
  6. package/core/bvh2/binary/IndexedBinaryBVH.js +22 -26
  7. package/core/collection/ArrayUtils.js +1 -1
  8. package/core/collection/array/arrayQuickSort.js +9 -6
  9. package/core/collection/array/array_swap.js +22 -0
  10. package/core/collection/array/computeHashArray.js +22 -0
  11. package/core/collection/array/computeHashIntegerArray.js +15 -0
  12. package/core/collection/table/DataType2TypedArrayConstructorMapping.js +15 -0
  13. package/core/color/Color.js +2 -1
  14. package/core/function/FunctionCompiler.js +2 -1
  15. package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
  16. package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
  17. package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +41 -0
  18. package/core/geom/3d/morton/mortonEncode_magicbits.js +2 -1
  19. package/core/geom/3d/morton/reinterpret_float32_as_int32.js +13 -0
  20. package/core/geom/3d/morton/v3_morton_encode_transformed.js +33 -0
  21. package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
  22. package/core/geom/3d/shape/AbstractShape3D.js +29 -0
  23. package/core/geom/3d/shape/CompositeShape.js +60 -0
  24. package/core/geom/3d/shape/TransformedShape3D.js +70 -0
  25. package/core/geom/3d/shape/UnitCubeShape3D.js +13 -0
  26. package/core/geom/3d/shape/UnitSphereShape3D.js +16 -0
  27. package/core/geom/AABB2.js +1 -1
  28. package/core/geom/ConicRay.js +3 -1
  29. package/core/geom/LineSegment.js +0 -78
  30. package/core/geom/Matrix4.js +7 -8
  31. package/core/geom/Rectangle.js +2 -1
  32. package/core/geom/Vector1.js +1 -1
  33. package/core/geom/Vector3.js +2 -1
  34. package/core/geom/Vector4.js +2 -1
  35. package/core/geom/random/randomPointInBox.js +7 -3
  36. package/core/geom/random/randomPointInPoint.js +6 -3
  37. package/core/geom/random/randomPointInSphere.js +6 -3
  38. package/core/geom/random/randomPointOnBox.js +7 -3
  39. package/core/geom/random/randomPointOnSphere.js +6 -3
  40. package/core/geom/v3_length.js +8 -3
  41. package/core/graph/graph_k_means_cluster.js +1 -1
  42. package/core/math/MathUtils.js +0 -354
  43. package/core/math/MathUtils.spec.js +7 -1
  44. package/core/math/gaussian.js +9 -0
  45. package/core/math/hash/computeHashFloat.js +17 -0
  46. package/core/math/hash/computeHashFloatArray.js +34 -0
  47. package/core/math/hash/computeObjectHash.js +54 -0
  48. package/core/math/intersects1D.js +19 -0
  49. package/core/math/interval/NumericInterval.js +2 -2
  50. package/core/math/isValueBetween.js +10 -0
  51. package/core/math/isValueBetweenInclusive.js +10 -0
  52. package/core/math/noise/curl_noise_3dt.js +1 -1
  53. package/core/math/noise/sdnoise.js +10 -10
  54. package/core/math/overlap1D.js +19 -0
  55. package/core/math/pingpong.js +17 -0
  56. package/core/math/random/makeRangedRandom.js +19 -0
  57. package/core/math/random/randomFloatBetween.js +14 -0
  58. package/core/math/random/randomFromArray.js +19 -0
  59. package/core/math/random/randomGaussian.js +15 -0
  60. package/core/math/random/randomIntegerBetween.js +14 -0
  61. package/core/math/random/roundFair.js +15 -0
  62. package/core/math/separation1D.js +21 -0
  63. package/core/math/solveQuadratic.js +25 -0
  64. package/core/model/BoundedValue.js +1 -1
  65. package/core/model/node-graph/node/NodeInstancePortReference.js +1 -1
  66. package/core/model/node-graph/node/Port.js +1 -1
  67. package/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +3 -1
  68. package/core/model/reactive/model/ReactiveBinaryExpression.js +1 -1
  69. package/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +1 -1
  70. package/core/model/reactive/model/terminal/ReactiveReference.js +1 -1
  71. package/core/model/reactive/model/util/createRandomReactiveExpression.js +1 -1
  72. package/core/model/stat/LinearModifier.js +1 -1
  73. package/engine/animation/curve/AnimationCurve.js +72 -0
  74. package/engine/animation/curve/Keyframe.js +27 -0
  75. package/engine/animation/keyed2/AnimationTrack.js +27 -3
  76. package/engine/asset/Asset.js +1 -1
  77. package/engine/asset/loaders/GLTFAssetLoader.d.ts +1 -1
  78. package/engine/asset/loaders/GLTFAssetLoader.js +10 -0
  79. package/engine/asset/loaders/image/ImageRGBADataAsset.js +8 -1
  80. package/engine/asset/loaders/material/computeMaterialHash.js +3 -1
  81. package/engine/asset/loaders/material/computeTextureHash.js +2 -1
  82. package/engine/ecs/animation/Animation.js +2 -1
  83. package/engine/ecs/animation/InverseKinematics.js +2 -1
  84. package/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
  85. package/engine/ecs/dynamic_actions/DynamicRuleDescriptionTable.spec.js +3 -5
  86. package/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +1 -1
  87. package/engine/ecs/evaluation/complex/PointFitnessGaussianBlur.js +1 -1
  88. package/engine/ecs/foliage/ecs/Foliage2.js +1 -1
  89. package/engine/ecs/fow/shader/FogOfWarRenderer.js +1 -1
  90. package/engine/ecs/gui/GUIElement.js +1 -1
  91. package/engine/ecs/gui/hud/HeadsUpDisplay.js +1 -1
  92. package/engine/ecs/gui/position/ViewportPosition.js +2 -1
  93. package/engine/ecs/systems/RangedAttackSystem.js +1 -1
  94. package/engine/ecs/systems/SteeringSystem.js +1 -1
  95. package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
  96. package/engine/ecs/tooltip/TooltipComponent.js +15 -0
  97. package/engine/graphics/ecs/animation/animator/AnimationClip.js +2 -1
  98. package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -1
  99. package/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -1
  100. package/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -1
  101. package/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +2 -1
  102. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -1
  103. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +1 -1
  104. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +2 -1
  105. package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
  106. package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
  107. package/engine/graphics/ecs/light/Light.d.ts +1 -1
  108. package/engine/graphics/ecs/light/Light.js +3 -0
  109. package/engine/graphics/ecs/mesh/Mesh.js +2 -1
  110. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
  111. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
  112. package/engine/graphics/geometry/AttributeSpec.js +105 -0
  113. package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
  114. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
  115. package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
  116. package/engine/graphics/micron/buildPatchwork.js +1 -1
  117. package/engine/graphics/micron/format/MicronGeometry.js +3 -3
  118. package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +2 -2
  119. package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
  120. package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
  121. package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
  122. package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +5 -5
  123. package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
  124. package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +80 -16
  125. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +57 -52
  126. package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +2 -1
  127. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +51 -12
  128. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +3 -2
  129. package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +1 -1
  130. package/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +8 -2
  131. package/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +2 -1
  132. package/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js +1 -1
  133. package/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +1 -1
  134. package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +21 -0
  135. package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +0 -20
  136. package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
  137. package/engine/graphics/particles/particular/engine/simulator/SimulationStepApplyForce.js +2 -5
  138. package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseAcceleration.js +2 -6
  139. package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.js +2 -7
  140. package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +2 -5
  141. package/engine/graphics/particles/particular/engine/simulator/update_parameters.js +1 -1
  142. package/engine/graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js +1 -1
  143. package/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.js +1 -1
  144. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +384 -0
  145. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +558 -0
  146. package/engine/graphics/particles/particular/group/Operation.js +18 -0
  147. package/engine/graphics/particles/particular/group/OperationType.js +9 -0
  148. package/engine/graphics/particles/particular/group/ParticleAttribute.js +2 -1
  149. package/engine/graphics/particles/particular/group/ParticleAttributeType.js +11 -0
  150. package/engine/graphics/particles/particular/group/ParticleDataType.js +10 -0
  151. package/engine/graphics/particles/particular/group/ParticleGroup.js +7 -245
  152. package/engine/graphics/particles/particular/group/ParticleGroup.spec.js +3 -1
  153. package/engine/graphics/particles/particular/group/ParticleSpecification.js +21 -14
  154. package/engine/graphics/particles/particular/group/itemSizeFromAttributeType.js +20 -0
  155. package/engine/graphics/particles/particular/group/optimizeCommandQueue.js +162 -0
  156. package/engine/graphics/particles/particular/group/typedArrayConstructorFromDataType.js +19 -0
  157. package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +1 -1
  158. package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameter.js +2 -1
  159. package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameterSet.js +1 -1
  160. package/engine/graphics/render/forward_plus/LightManager.js +117 -94
  161. package/engine/graphics/render/forward_plus/PointLight.js +9 -0
  162. package/engine/graphics/render/forward_plus/PointLightData.js +1 -1
  163. package/engine/graphics/render/forward_plus/SpotLight.js +9 -0
  164. package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +2 -2
  165. package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
  166. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +5 -5
  167. package/engine/graphics/render/forward_plus/prototypeLightManager.js +180 -86
  168. package/engine/graphics/render/forward_plus/query/analytical_triplanar_corner_mapping.js +8 -0
  169. package/engine/graphics/render/forward_plus/query/cube_mapping.js +38 -0
  170. package/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +86 -0
  171. package/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +73 -0
  172. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +131 -0
  173. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +129 -0
  174. package/engine/graphics/render/forward_plus/query/spot_light_inside_volume.js +33 -0
  175. package/engine/graphics/render/forward_plus/read_frustum_corner.js +14 -0
  176. package/engine/graphics/render/forward_plus/testClusterEquality.js +22 -0
  177. package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
  178. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
  179. package/engine/graphics/texture/sampler/HarmonicDiffusionGrid.spec.js +1 -1
  180. package/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
  181. package/engine/graphics/texture/sampler/distanceField.spec.js +1 -1
  182. package/engine/grid/components/GridObstacle.js +1 -1
  183. package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
  184. package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
  185. package/engine/navigation/ecs/components/Path.js +1 -1
  186. package/engine/navigation/grid/FastBinaryHeap.spec.js +1 -1
  187. package/engine/sound/ecs/emitter/SoundEmitter.js +2 -1
  188. package/engine/sound/ecs/emitter/SoundTrack.js +2 -1
  189. package/engine/sound/material/concrete/RandomSoundMaterial.js +1 -1
  190. package/engine/ui/notification/notificationGenerator.js +1 -1
  191. package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +1 -1
  192. package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
  193. package/generation/markers/actions/MarkerNodeActionSelectRandom.js +1 -1
  194. package/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +1 -1
  195. package/generation/placement/action/random/CellActionSelectRandom.js +1 -1
  196. package/generation/theme/ThemeEngine.js +1 -1
  197. package/misc/makeMaterialIconCached.js +2 -2
  198. package/package.json +1 -1
  199. package/view/elements/image/HTMLElementCacheKey.js +2 -1
  200. package/view/elements/radial/RadialText.js +2 -1
  201. package/view/minimap/gl/MinimapMarkersGL.js +6 -100
  202. package/view/minimap/gl/buildMaterial.js +94 -0
  203. package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +0 -71
  204. package/engine/graphics/render/forward_plus/queryBVH_Frustum.js +0 -357
@@ -0,0 +1,558 @@
1
+ import { EngineHarness } from "../../../../../../EngineHarness.js";
2
+ import { EngineConfiguration } from "../../../../../../EngineConfiguration.js";
3
+ import GUIElementSystem from "../../../../../../ecs/gui/GUIElementSystem.js";
4
+ import HeadsUpDisplaySystem from "../../../../../../ecs/gui/hud/HeadsUpDisplaySystem.js";
5
+ import ScriptSystem from "../../../../../../ecs/systems/ScriptSystem.js";
6
+ import FacingDirectionSystem from "../../../../../../../../model/game/ecs/system/FacingDirectionSystem.js";
7
+ import PathFollowingSystem from "../../../../../../navigation/ecs/path_following/PathFollowingSystem.js";
8
+ import SteeringSystem from "../../../../../../ecs/systems/SteeringSystem.js";
9
+ import MotionSystem from "../../../../../../ecs/systems/MotionSystem.js";
10
+ import TagSystem from "../../../../../../ecs/systems/TagSystem.js";
11
+ import { AttachmentSocketsSystem } from "../../../../../../ecs/sockets/AttachmentSocketsSystem.js";
12
+ import { AttachmentSystem } from "../../../../../../ecs/attachment/AttachmentSystem.js";
13
+ import { SoundEmitterSystem } from "../../../../../../sound/ecs/emitter/SoundEmitterSystem.js";
14
+ import SoundControllerSystem from "../../../../../../sound/ecs/SoundControllerSystem.js";
15
+ import SoundListenerSystem from "../../../../../../sound/ecs/SoundListenerSystem.js";
16
+ import TimerSystem from "../../../../../../ecs/systems/TimerSystem.js";
17
+ import AnimationSystem from "../../../../../../ecs/systems/AnimationSystem.js";
18
+ import TopDownCameraControllerSystem from "../../../../../ecs/camera/topdown/TopDownCameraControllerSystem.js";
19
+ import { TopDownCameraLanderSystem } from "../../../../../ecs/camera/topdown/TopDownCameraLanderSystem.js";
20
+ import { CameraSystem } from "../../../../../ecs/camera/CameraSystem.js";
21
+ import { MeshSystem } from "../../../../../ecs/mesh/MeshSystem.js";
22
+ import ClingToTerrainSystem from "../../../../../../ecs/terrain/ecs/ClingToTerrainSystem.js";
23
+ import TerrainSystem from "../../../../../../ecs/terrain/ecs/TerrainSystem.js";
24
+ import WaterSystem from "../../../../../ecs/water/WaterSystem.js";
25
+ import Trail2DSystem from "../../../../../ecs/trail2d/Trail2DSystem.js";
26
+ import { Foliage2System } from "../../../../../../ecs/foliage/ecs/Foliage2System.js";
27
+ import ViewportPositionSystem from "../../../../../../ecs/gui/position/ViewportPositionSystem.js";
28
+ import { GridPosition2TransformSystem } from "../../../../../../grid/systems/GridPosition2TransformSystem.js";
29
+ import { Transform2GridPositionSystem } from "../../../../../../grid/transform2grid/Transform2GridPositionSystem.js";
30
+ import SynchronizePositionSystem from "../../../../../../ecs/systems/SynchronizePositionSystem.js";
31
+ import GridObstacleSystem from "../../../../../../grid/systems/GridObstacleSystem.js";
32
+ import GridPositionSystem from "../../../../../../grid/systems/GridPositionSystem.js";
33
+ import InputControllerSystem from "../../../../../../input/ecs/systems/InputControllerSystem.js";
34
+ import { InputSystem } from "../../../../../../input/ecs/systems/InputSystem.js";
35
+ import MeshHighlightSystem from "../../../../../ecs/highlight/system/MeshHighlightSystem.js";
36
+ import LightSystem from "../../../../../ecs/light/LightSystem.js";
37
+ import AnimationControllerSystem from "../../../../../ecs/animation/AnimationControllerSystem.js";
38
+ import { AnimationGraphSystem } from "../../../../../ecs/animation/animator/AnimationGraphSystem.js";
39
+ import { FogOfWarSystem } from "../../../../../../ecs/fow/FogOfWarSystem.js";
40
+ import { FogOfWarRevealerSystem } from "../../../../../../ecs/fow/FogOfWarRevealerSystem.js";
41
+ import { BehaviorSystem } from "../../../../../../intelligence/behavior/ecs/BehaviorSystem.js";
42
+ import { SerializationMetadataSystem } from "../../../../../../ecs/systems/SerializationMetadataSystem.js";
43
+ import { InverseKinematicsSystem } from "../../../../../../ecs/animation/InverseKinematicsSystem.js";
44
+ import { PathDisplaySystem } from "../../../../../ecs/path/PathDisplaySystem.js";
45
+ import { MicronRenderPlugin } from "../../../../../micron/plugin/MicronRenderPlugin.js";
46
+ import RenderSystem from "../../../../../../ecs/systems/RenderSystem.js";
47
+ import { makeEngineOptionsModel } from "../../../../../../../../model/game/options/makeEngineOptionsModel.js";
48
+ import { enableEditor } from "../../../../../../../editor/enableEditor.js";
49
+ import { buildCubeURLs } from "../../../../../texture/cubemap/buildCubeURLs.js";
50
+ import { AmbientOcclusionPostProcessEffect } from "../../../../../render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js";
51
+ import Vector2 from "../../../../../../../core/geom/Vector2.js";
52
+ import Vector3 from "../../../../../../../core/geom/Vector3.js";
53
+ import EntityBuilder from "../../../../../../ecs/EntityBuilder.js";
54
+ import { Transform } from "../../../../../../ecs/transform/Transform.js";
55
+ import Mesh from "../../../../../ecs/mesh/Mesh.js";
56
+ import { AABB3 } from "../../../../../../../core/bvh2/aabb3/AABB3.js";
57
+ import { ParticleVolume } from "./ParticleVolume.js";
58
+ import { ParticleEmitterSystem2 } from "../../../../ecs/ParticleEmitterSystem2.js";
59
+ import { BehaviorComponent } from "../../../../../../intelligence/behavior/ecs/BehaviorComponent.js";
60
+ import { RepeatBehavior } from "../../../../../../intelligence/behavior/decorator/RepeatBehavior.js";
61
+ import { ActionBehavior } from "../../../../../../intelligence/behavior/primitive/ActionBehavior.js";
62
+ import { pingpong } from "../../../../../../../core/math/pingpong.js";
63
+ import { ParameterLookupTable } from "../../parameter/ParameterLookupTable.js";
64
+ import { pick } from "../../../../../../../../model/game/util/ScreenGridPicker.js";
65
+ import { obtainTerrain } from "../../../../../../../../model/game/scenes/SceneUtils.js";
66
+ import GUIElement from "../../../../../../ecs/gui/GUIElement.js";
67
+ import EmptyView from "../../../../../../../view/elements/EmptyView.js";
68
+ import HeadsUpDisplay from "../../../../../../ecs/gui/hud/HeadsUpDisplay.js";
69
+ import ViewportPosition from "../../../../../../ecs/gui/position/ViewportPosition.js";
70
+ import { Sampler2D } from "../../../../../texture/sampler/Sampler2D.js";
71
+ import { CanvasView } from "../../../../../../../view/elements/CanvasView.js";
72
+ import convertSampler2D2Canvas from "../../../../../texture/sampler/Sampler2D2Canvas.js";
73
+ import Vector1 from "../../../../../../../core/geom/Vector1.js";
74
+ import { clamp } from "../../../../../../../core/math/clamp.js";
75
+
76
+ const engineHarness = new EngineHarness();
77
+
78
+ function makeConfig(engine) {
79
+
80
+ const config = new EngineConfiguration();
81
+
82
+ /**
83
+ *
84
+ * @type {SoundEngine}
85
+ */
86
+ const sound = engine.sound;
87
+ const graphics = engine.graphics;
88
+ const assetManager = engine.assetManager;
89
+ const devices = engine.devices;
90
+
91
+ const guiSystem = new GUIElementSystem(engine.gui.view, engine);
92
+ const headsUpDisplaySystem = new HeadsUpDisplaySystem(graphics);
93
+
94
+ config.systems.push(
95
+ new ScriptSystem(),
96
+ new FacingDirectionSystem(),
97
+ new PathFollowingSystem(),
98
+ new SteeringSystem(),
99
+ new MotionSystem(),
100
+ new TagSystem(),
101
+ new AttachmentSocketsSystem(),
102
+ new AttachmentSystem(),
103
+ new SoundEmitterSystem(assetManager, sound.destination, sound.context),
104
+ new SoundControllerSystem(),
105
+ new SoundListenerSystem(sound.context),
106
+ new TimerSystem(),
107
+ guiSystem,
108
+ new AnimationSystem(graphics.viewport.size),
109
+ new TopDownCameraControllerSystem(graphics),
110
+ new TopDownCameraLanderSystem(),
111
+ new CameraSystem(graphics.scene, graphics),
112
+ new MeshSystem(engine),
113
+ new ClingToTerrainSystem(),
114
+ new TerrainSystem(graphics, assetManager),
115
+ new WaterSystem(graphics),
116
+ new Trail2DSystem(engine),
117
+ new Foliage2System(assetManager, graphics),
118
+ new ViewportPositionSystem(graphics.viewport.size),
119
+ new GridPosition2TransformSystem(),
120
+ new Transform2GridPositionSystem(),
121
+ new SynchronizePositionSystem(),
122
+ new GridObstacleSystem(),
123
+ new GridPositionSystem(),
124
+ new InputControllerSystem(devices),
125
+ new InputSystem(devices),
126
+ new MeshHighlightSystem(engine),
127
+ new LightSystem(engine, {
128
+ shadowResolution: 2048
129
+ }),
130
+ new AnimationControllerSystem(),
131
+ new AnimationGraphSystem(graphics.viewport.size),
132
+ headsUpDisplaySystem,
133
+ new FogOfWarSystem(graphics),
134
+ new FogOfWarRevealerSystem(0),
135
+ new BehaviorSystem(engine),
136
+ new SerializationMetadataSystem(),
137
+ new InverseKinematicsSystem(),
138
+ new PathDisplaySystem(engine),
139
+ );
140
+
141
+
142
+ // Plugins
143
+ config.addPlugin(MicronRenderPlugin);
144
+
145
+
146
+ // Knowledge
147
+
148
+ return config;
149
+ }
150
+
151
+
152
+ /**
153
+ *
154
+ * @param {EngineHarness} harness
155
+ * @return {Promise<void>}
156
+ */
157
+ async function init(harness) {
158
+ const engine = harness.engine;
159
+
160
+ engine.entityManager.addSystem(new RenderSystem(engine.graphics));
161
+
162
+ makeEngineOptionsModel(engine.options, engine);
163
+
164
+ await makeConfig(engine).apply(engine);
165
+
166
+ enableEditor(engine);
167
+
168
+ await engine.graphics.loadEnvironmentMap(buildCubeURLs('data/textures/cubemaps/hip_miramar/32/', '.png'));
169
+
170
+
171
+ await engine.plugins.acquire(AmbientOcclusionPostProcessEffect);
172
+
173
+ await harness.initialize();
174
+
175
+ main(engine);
176
+ }
177
+
178
+
179
+ const heatmap_lut_0 = new ParameterLookupTable(4);
180
+ heatmap_lut_0.write([
181
+ 0, 0, 255, 10,
182
+ 0, 179, 179, 10,
183
+ 0, 255, 0, 10,
184
+ 255, 255, 0, 10,
185
+ 255, 5, 5, 10
186
+ ]);
187
+ heatmap_lut_0.computeUniformPositions();
188
+
189
+ const heatmap_lut_1 = new ParameterLookupTable(4);
190
+ heatmap_lut_1.write([
191
+ 255, 127, 0, 100,
192
+ 206, 2, 86, 100
193
+ ]);
194
+ heatmap_lut_1.computeUniformPositions();
195
+
196
+ const heatmap_lut_2 = new ParameterLookupTable(4);
197
+ heatmap_lut_2.write([
198
+ 255, 151, 213, 50,
199
+ 2, 243, 255, 50
200
+ ]);
201
+ heatmap_lut_2.computeUniformPositions();
202
+
203
+ const heatmap_lut_3 = new ParameterLookupTable(4);
204
+ heatmap_lut_3.write(
205
+ [
206
+ 196, 196, 196, 255,
207
+ 196, 196, 196, 255,
208
+ 0, 230, 0, 255,
209
+ 0, 230, 0, 255,
210
+ 255, 212, 0, 255,
211
+ 255, 212, 0, 255,
212
+ ],
213
+ [
214
+ 0,
215
+ 0.1,
216
+ 0.1,
217
+ 0.7,
218
+ 0.7,
219
+ 1
220
+ ]
221
+ );
222
+
223
+ /**
224
+ *
225
+ * @param {Engine} engine
226
+ */
227
+ async function main(engine) {
228
+ EngineHarness.buildBasics({
229
+ engine,
230
+ enableWater: false,
231
+ // enableTerrain: false,
232
+ enableTerrain: true,
233
+ terrainSize: new Vector2(100, 100),
234
+ focus: new Vector3(102, 0, 61),
235
+ // pitch: -0.5,
236
+ // yaw: 2.2,
237
+ // distance: 3
238
+ pitch: 0.9,
239
+ yaw: 3.1,
240
+ distance: 20
241
+ });
242
+
243
+
244
+ engine.graphics.renderer.setClearColor('rgba(99,99,99,1)');
245
+
246
+
247
+ const ecd = engine.entityManager.dataset;
248
+
249
+ new EntityBuilder()
250
+ .add(Transform.fromJSON({
251
+ position: {
252
+ x: 20,
253
+ y: -5.8,
254
+ z: 100
255
+ },
256
+ scale: {
257
+ x: 1,
258
+ y: 1,
259
+ z: 1
260
+ }
261
+ }))
262
+ .add(Mesh.fromJSON({
263
+ url: 'data/models/moicon/05-ground-floor/model.gltf',
264
+ castShadow: true,
265
+ receiveShadow: true
266
+ }))
267
+ // .build(ecd);
268
+ new EntityBuilder()
269
+ .add(Transform.fromJSON({
270
+ position: {
271
+ x: 20,
272
+ y: -5.8,
273
+ z: 100
274
+ },
275
+ scale: {
276
+ x: 1,
277
+ y: 1,
278
+ z: 1
279
+ }
280
+ }))
281
+ .add(Mesh.fromJSON({
282
+ url: 'data/models/moicon/08-clickable-assets/model.gltf',
283
+ castShadow: true,
284
+ receiveShadow: true
285
+ }))
286
+ // .build(ecd);
287
+
288
+ await make_demo_volume({
289
+ ecd: ecd,
290
+ lut: heatmap_lut_0,
291
+ bounds: new AABB3(67.73, 0, 89, 115.84, 3, 118.34),
292
+ particle_size: 4,
293
+ density: 4,
294
+ period: 10
295
+ });
296
+
297
+ await make_demo_volume({
298
+ ecd: ecd,
299
+ lut: heatmap_lut_0,
300
+ bounds: new AABB3(43.8, 0, 89, 67.40, 3, 131),
301
+ particle_size: 2,
302
+ density: 1,
303
+ period: 10,
304
+ period_offset: 3,
305
+ });
306
+
307
+ await make_demo_volume({
308
+ ecd: ecd,
309
+ lut: heatmap_lut_1,
310
+ bounds: new AABB3(97.68, 0, 67.71, 115.76, 3, 76.14),
311
+ particle_size: 1,
312
+ density: 1.2,
313
+ period: 7,
314
+ period_offset: 2,
315
+ });
316
+
317
+ await make_demo_volume({
318
+ ecd: ecd,
319
+ lut: heatmap_lut_2,
320
+ bounds: new AABB3(79.0, 0, 67.71, 97.35, 3, 76.14),
321
+ particle_size: 4,
322
+ density: 4,
323
+ period: 7,
324
+ period_offset: 2,
325
+ });
326
+
327
+ await make_demo_volume({
328
+ ecd: ecd,
329
+ lut: heatmap_lut_3,
330
+ bounds: new AABB3(67.85, 0, 31.1, 109.8, 3, 67.02),
331
+ particle_size: 0.1,
332
+ density: 5,
333
+ period: 7,
334
+ period_offset: 2,
335
+ });
336
+
337
+ engine.devices.pointer.on.down.add((p) => {
338
+ pick(p.x, p.y, engine.graphics, obtainTerrain(ecd), (grid_position, position, normal) => {
339
+ console.log(position.toJSON());
340
+ });
341
+ });
342
+ }
343
+
344
+ /**
345
+ *
346
+ * @param {ParameterLookupTable} lut
347
+ * @param {number} width
348
+ * @param {number} height
349
+ * @returns {Sampler2D}
350
+ */
351
+ function lut_to_sampler(lut, width, height) {
352
+ const sampler = Sampler2D.uint8(4, width, height);
353
+
354
+ const s = [];
355
+
356
+ for (let i = 0; i < width; i++) {
357
+
358
+ lut.sample(i / (width - 1), s);
359
+ s[3] = 255;
360
+
361
+ for (let j = 0; j < height; j++) {
362
+ sampler.set(i, j, s);
363
+ }
364
+
365
+ }
366
+
367
+ return sampler;
368
+ }
369
+
370
+ async function create_volume({
371
+ bounds = new AABB3(0, 0, 0, 1, 1, 1),
372
+ density = 10,
373
+ particle_size = 1
374
+ }) {
375
+
376
+ const aabb_bounds = new AABB3();
377
+ aabb_bounds.fromJSON(bounds);
378
+
379
+ const hs = particle_size / 4;
380
+
381
+ aabb_bounds.x0 += hs;
382
+ aabb_bounds.z0 += hs;
383
+
384
+ aabb_bounds.x1 -= hs;
385
+ aabb_bounds.z1 -= hs;
386
+
387
+ const adjusted_density = density / particle_size;
388
+
389
+ const v = new ParticleVolume();
390
+
391
+ const dx = aabb_bounds.x1 - aabb_bounds.x0;
392
+ const dy = aabb_bounds.y1 - aabb_bounds.y0;
393
+ const dz = aabb_bounds.z1 - aabb_bounds.z0;
394
+
395
+ v.transform.scale.set(
396
+ dx,
397
+ dy,
398
+ dz
399
+ );
400
+
401
+ v.transform.position.set(
402
+ aabb_bounds.x0 + dx / 2,
403
+ aabb_bounds.y0 + dy / 2,
404
+ aabb_bounds.z0 + dz / 2
405
+ );
406
+
407
+
408
+ const em = engine.entityManager;
409
+
410
+ if (em.getSystem(ParticleEmitterSystem2) === null) {
411
+ await em.addSystem(new ParticleEmitterSystem2(engine.assetManager, engine.graphics));
412
+ }
413
+
414
+ v.from({
415
+ density: adjusted_density,
416
+ particle_size
417
+ });
418
+
419
+ v.build();
420
+
421
+ v.entity.build(em.dataset);
422
+
423
+ return v;
424
+ }
425
+
426
+ /**
427
+ *
428
+ * @param {AABB3} bounds
429
+ * @param {ParameterLookupTable} lut
430
+ * @return {{position: Vector1}}
431
+ */
432
+ function make_symbol_view({
433
+ bounds,
434
+ lut
435
+ }) {
436
+
437
+ const r = {
438
+ position: new Vector1(1)
439
+ };
440
+
441
+ const symbol_view = new EmptyView();
442
+ symbol_view.size.set(128, 20);
443
+
444
+ symbol_view.css({
445
+ position: 'absolute',
446
+ whiteSpace: 'pre',
447
+ left: 0,
448
+ top: 0
449
+ });
450
+
451
+ const view_lut = new CanvasView();
452
+ view_lut.size.set(128, 10);
453
+ view_lut.css({
454
+ position: 'absolute',
455
+ border: '1px solid white',
456
+ boxShadow: '0 0 6px rgba(0,0,0,0.4)',
457
+ left: 0,
458
+ top: 0
459
+ });
460
+
461
+ const sampler_lut = lut_to_sampler(lut, view_lut.size.x, view_lut.size.y);
462
+
463
+ convertSampler2D2Canvas(sampler_lut, 1, 0, view_lut.el);
464
+
465
+ symbol_view.addChild(view_lut)
466
+
467
+ const view_cursor = new EmptyView();
468
+
469
+ view_cursor.css({
470
+ position: 'absolute',
471
+ left: 0,
472
+ top: "-1px",
473
+ height: "10px",
474
+ width: "4px",
475
+ border: '2px solid white',
476
+ zIndex: 2,
477
+ boxShadow: '0 0 4px black'
478
+ });
479
+
480
+
481
+ r.position.process(f => {
482
+ const c = new Uint8Array(4);
483
+
484
+ lut.sample(f, c);
485
+
486
+ const hex_string = `rgb(${c[0]},${c[1]},${c[2]})`;
487
+
488
+ view_cursor.position.set(f * view_lut.size.x, 0);
489
+ view_cursor.css({
490
+ backgroundColor: hex_string
491
+ })
492
+ });
493
+
494
+ symbol_view.addChild(view_cursor);
495
+
496
+ const symbol_transform = new Transform();
497
+ bounds.getCenter(symbol_transform.position);
498
+
499
+ const vp = new ViewportPosition();
500
+ vp.anchor.set(0.5, 1);
501
+
502
+ const entity = new EntityBuilder()
503
+ .add(GUIElement.fromView(symbol_view))
504
+ .add(new HeadsUpDisplay())
505
+ .add(vp)
506
+ .add(symbol_transform);
507
+
508
+ r.entity = entity;
509
+
510
+ return r;
511
+ }
512
+
513
+ async function make_demo_volume({
514
+ ecd,
515
+ bounds = new AABB3(0, 0, 0, 20, 10, 20),
516
+ lut,
517
+ period = 5,
518
+ period_offset = 0,
519
+ density,
520
+ particle_size
521
+ }) {
522
+
523
+ const v = await create_volume({
524
+ bounds,
525
+ density,
526
+ particle_size
527
+ });
528
+
529
+ let time_total = 0;
530
+
531
+ const symbol = make_symbol_view({
532
+ bounds,
533
+ lut
534
+ });
535
+
536
+ symbol.entity.build(ecd);
537
+
538
+ new EntityBuilder()
539
+ .add(BehaviorComponent.fromOne(RepeatBehavior.from(new ActionBehavior((time) => {
540
+ time_total += time;
541
+
542
+ const _t = pingpong(time_total + period_offset, period);
543
+
544
+ const f = clamp(_t / period, 0, 1);
545
+
546
+ symbol.position.set(f);
547
+
548
+ const s = [];
549
+ lut.sample(f, s);
550
+
551
+ // console.log(JSON.stringify(s));
552
+
553
+ v.setColor(s[0] , s[1] , s[2] , s[3] );
554
+ }))))
555
+ .build(ecd);
556
+ }
557
+
558
+ init(engineHarness);
@@ -0,0 +1,18 @@
1
+ /**
2
+ *
3
+ * @param {OperationType} operator
4
+ * @param {Array} operands
5
+ * @constructor
6
+ */
7
+ export function Operation(operator, operands) {
8
+ /**
9
+ *
10
+ * @type {OperationType}
11
+ */
12
+ this.operator = operator;
13
+ /**
14
+ *
15
+ * @type {Array}
16
+ */
17
+ this.operands = operands;
18
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ * @enum {number}
4
+ */
5
+ export const OperationType = {
6
+ Remove: 0,
7
+ Add: 1,
8
+ WriteAttribute: 2
9
+ };
@@ -3,6 +3,7 @@
3
3
  * @param {string} name
4
4
  * @param {ParticleAttributeType} attributeType
5
5
  * @param {ParticleDataType} dataType
6
+ * @deprecated use {@link AttributeSpec} instead
6
7
  * @constructor
7
8
  */
8
9
  export function ParticleAttribute(name, attributeType, dataType) {
@@ -21,4 +22,4 @@ export function ParticleAttribute(name, attributeType, dataType) {
21
22
  * @type {ParticleDataType}
22
23
  */
23
24
  this.dataType = dataType;
24
- }
25
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ * @enum {number}
4
+ */
5
+ const ParticleAttributeType = {
6
+ Scalar: 1,
7
+ Vector2: 2,
8
+ Vector3: 3,
9
+ Vector4: 4
10
+ };
11
+ export { ParticleAttributeType };
@@ -0,0 +1,10 @@
1
+ /**
2
+ *
3
+ * @enum {number}
4
+ */
5
+ const ParticleDataType = {
6
+ Float32: 0,
7
+ Float64: 1,
8
+ Uint8: 2
9
+ };
10
+ export { ParticleDataType };