@woosh/meep-engine 2.33.21 → 2.33.25
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.
- package/core/assert.js +3 -1
- package/core/bvh2/BinaryNode.js +1 -1
- package/core/bvh2/aabb3/AABB3.js +18 -0
- package/core/bvh2/aabb3/AABB3Math.js +1 -1
- package/core/bvh2/binary/2/BinaryUint32BVH.js +498 -0
- package/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
- package/core/bvh2/binary/IndexedBinaryBVH.js +22 -26
- package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +5 -1
- package/core/bvh2/traversal/__detailed_box_volume_intersection.js +31 -11
- package/core/collection/ArrayUtils.js +1 -1
- package/core/collection/array/arrayQuickSort.js +9 -6
- package/core/collection/array/array_swap.js +22 -0
- package/core/collection/array/binarySearchHighIndex.js +1 -1
- package/core/collection/array/computeHashArray.js +22 -0
- package/core/collection/array/computeHashIntegerArray.js +15 -0
- package/core/collection/array/copyArray.js +2 -2
- package/core/collection/table/DataType2TypedArrayConstructorMapping.js +15 -0
- package/core/color/Color.js +2 -1
- package/core/function/FunctionCompiler.js +2 -1
- package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
- package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +10 -2
- package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +41 -0
- package/core/geom/3d/morton/mortonEncode_magicbits.js +2 -1
- package/core/geom/3d/morton/reinterpret_float32_as_int32.js +13 -0
- package/core/geom/3d/morton/v3_morton_encode_transformed.js +33 -0
- package/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
- package/core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js +13 -14
- package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
- package/core/geom/3d/shape/AbstractShape3D.js +38 -0
- package/core/geom/3d/shape/CompositeShape.js +240 -0
- package/core/geom/3d/shape/TransformedShape3D.js +126 -0
- package/core/geom/3d/shape/UnitCubeShape3D.js +24 -0
- package/core/geom/3d/shape/UnitSphereShape3D.js +24 -0
- package/core/geom/3d/shape/util/shape_to_visual_entity.js +159 -0
- package/core/geom/3d/voxel/DenseBitVolume3D.js +87 -0
- package/core/geom/3d/voxel/buildVolumeFromProjectedGeometry.js +23 -0
- package/core/geom/AABB2.js +1 -1
- package/core/geom/ConicRay.js +3 -1
- package/core/geom/LineSegment.js +0 -78
- package/core/geom/Matrix4.js +7 -8
- package/core/geom/Plane.js +14 -9
- package/core/geom/Rectangle.js +2 -1
- package/core/geom/Vector1.js +1 -1
- package/core/geom/Vector3.js +2 -1
- package/core/geom/Vector4.js +2 -1
- package/core/geom/random/randomPointInBox.js +7 -3
- package/core/geom/random/randomPointInPoint.js +6 -3
- package/core/geom/random/randomPointInSphere.js +9 -5
- package/core/geom/random/randomPointOnBox.js +7 -3
- package/core/geom/random/randomPointOnSphere.js +6 -3
- package/core/geom/v3_length.js +8 -3
- package/core/graph/graph_k_means_cluster.js +1 -1
- package/core/json/resolvePathByArray.js +2 -2
- package/core/math/MathUtils.js +0 -354
- package/core/math/MathUtils.spec.js +7 -1
- package/core/math/gaussian.js +9 -0
- package/core/math/hash/computeHashFloat.js +17 -0
- package/core/math/hash/computeHashFloatArray.js +34 -0
- package/core/math/hash/computeObjectHash.js +54 -0
- package/core/math/intersects1D.js +19 -0
- package/core/math/interval/NumericInterval.js +2 -2
- package/core/math/isValueBetween.js +10 -0
- package/core/math/isValueBetweenInclusive.js +10 -0
- package/core/math/noise/curl_noise_3dt.js +1 -1
- package/core/math/noise/sdnoise.js +10 -10
- package/core/math/overlap1D.js +19 -0
- package/core/math/pingpong.js +17 -0
- package/core/math/random/makeRangedRandom.js +19 -0
- package/core/math/random/randomFloatBetween.js +14 -0
- package/core/math/random/randomFromArray.js +19 -0
- package/core/math/random/randomGaussian.js +15 -0
- package/core/math/random/randomIntegerBetween.js +14 -0
- package/core/math/random/roundFair.js +15 -0
- package/core/math/separation1D.js +21 -0
- package/core/math/solveQuadratic.js +25 -0
- package/core/model/BoundedValue.js +1 -1
- package/core/model/node-graph/node/NodeInstancePortReference.js +1 -1
- package/core/model/node-graph/node/Port.js +1 -1
- package/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +3 -1
- package/core/model/reactive/model/ReactiveBinaryExpression.js +1 -1
- package/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +1 -1
- package/core/model/reactive/model/terminal/ReactiveReference.js +1 -1
- package/core/model/reactive/model/util/createRandomReactiveExpression.js +1 -1
- package/core/model/stat/LinearModifier.js +1 -1
- package/core/primitives/array/computeIntegerArrayHash.js +1 -1
- package/{engine/graphics/render/forward_plus/materials → core/primitives/strings}/insert_after.js +3 -0
- package/core/primitives/strings/insert_after_or_replace.js +27 -0
- package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
- package/editor/view/ecs/EntityEditor.js +2 -2
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +2 -2
- package/engine/EngineHarness.js +1 -0
- package/engine/animation/AnimationUtils.js +5 -5
- package/engine/animation/curve/AnimationCurve.js +72 -0
- package/engine/animation/curve/Keyframe.js +27 -0
- package/engine/animation/keyed2/AnimationTrack.js +27 -3
- package/engine/asset/Asset.js +1 -1
- package/engine/asset/loaders/GLTFAssetLoader.d.ts +1 -1
- package/engine/asset/loaders/GLTFAssetLoader.js +10 -0
- package/engine/asset/loaders/image/ImageRGBADataAsset.js +8 -1
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +11 -0
- package/engine/asset/loaders/material/computeImageBitmapHash.js +22 -28
- package/engine/asset/loaders/material/computeMaterialHash.js +3 -1
- package/engine/asset/loaders/material/computeTextureHash.js +2 -1
- package/engine/ecs/EntityBuilder.js +25 -5
- package/engine/ecs/animation/Animation.js +2 -1
- package/engine/ecs/animation/InverseKinematics.js +2 -1
- package/engine/ecs/attachment/AttachmentBinding.js +8 -0
- package/engine/ecs/attachment/AttachmentSystem.js +4 -0
- package/engine/ecs/attachment/TransformAttachmentBinding.js +14 -44
- package/engine/ecs/components/Tag.js +27 -6
- package/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
- package/engine/ecs/dynamic_actions/DynamicRuleDescriptionTable.spec.js +3 -5
- package/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +1 -1
- package/engine/ecs/evaluation/complex/PointFitnessGaussianBlur.js +1 -1
- package/engine/ecs/foliage/ecs/Foliage2.js +1 -1
- package/engine/ecs/fow/FogOfWar.js +4 -0
- package/engine/ecs/fow/FogOfWarSystem.js +2 -0
- package/engine/ecs/fow/shader/FogOfWarRenderer.js +1 -1
- package/engine/ecs/gui/GUIElement.js +1 -1
- package/engine/ecs/gui/hud/HeadsUpDisplay.js +1 -1
- package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -0
- package/engine/ecs/gui/position/ViewportPosition.js +2 -1
- package/engine/ecs/system/AbstractContextSystem.js +1 -1
- package/engine/ecs/systems/RangedAttackSystem.js +1 -1
- package/engine/ecs/systems/SteeringSystem.js +1 -1
- package/engine/ecs/systems/TagSystem.js +17 -0
- package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
- package/engine/ecs/tooltip/TooltipComponent.js +15 -0
- package/engine/ecs/transform/Transform.js +19 -6
- package/engine/ecs/util/hideEntityGracefully.js +18 -0
- package/engine/graphics/GraphicsEngine.js +11 -23
- package/engine/graphics/camera/testClippingPlaneComputation.js +2 -2
- package/engine/graphics/composit/CompositLayer.js +17 -4
- package/engine/graphics/composit/CompositingStages.js +8 -0
- package/engine/graphics/composit/LayerCompositer.js +35 -6
- package/engine/graphics/ecs/animation/animator/AnimationClip.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +1 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +2 -1
- package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
- package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
- package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +11 -7
- package/engine/graphics/ecs/light/Light.d.ts +1 -1
- package/engine/graphics/ecs/light/Light.js +5 -0
- package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +5 -1
- package/engine/graphics/ecs/mesh/Mesh.js +2 -1
- package/engine/graphics/ecs/mesh-v2/DrawMode.js +5 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +32 -18
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
- package/engine/graphics/ecs/path/testPathDisplaySystem.js +98 -98
- package/engine/graphics/ecs/trail2d/Trail2D.js +17 -4
- package/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts +2 -3
- package/engine/graphics/ecs/trail2d/Trail2DSystem.js +34 -118
- package/engine/graphics/geometry/AttributeSpec.js +105 -0
- package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
- package/engine/graphics/micron/buildPatchwork.js +1 -1
- package/engine/graphics/micron/format/MicronGeometry.js +3 -3
- package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +2 -2
- package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
- package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
- package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +5 -5
- package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
- package/engine/graphics/particles/ParticleEmitterLibrary.js +3 -0
- package/engine/graphics/particles/ecs/{ParticleEmitterSystem2.js → ParticleEmitterSystem.js} +17 -9
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +12 -4
- package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +84 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +106 -169
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +14 -3
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +141 -14
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +8 -7
- package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +37 -0
- package/engine/graphics/particles/particular/engine/emitter/distance_to_camera.js +25 -0
- package/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +8 -2
- package/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +2 -1
- package/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js +1 -1
- package/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +1 -1
- package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +24 -0
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +262 -71
- package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +80 -46
- package/engine/graphics/particles/particular/engine/shader/debugAtlas.js +14 -0
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepApplyForce.js +2 -5
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseAcceleration.js +2 -6
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.js +2 -7
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +2 -5
- package/engine/graphics/particles/particular/engine/simulator/update_parameters.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +141 -0
- package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +478 -0
- package/engine/graphics/particles/particular/engine/utils/volume/lut_to_sampler.js +27 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +935 -0
- package/engine/graphics/particles/particular/group/Operation.js +18 -0
- package/engine/graphics/particles/particular/group/OperationType.js +9 -0
- package/engine/graphics/particles/particular/group/ParticleAttribute.js +2 -1
- package/engine/graphics/particles/particular/group/ParticleAttributeType.js +11 -0
- package/engine/graphics/particles/particular/group/ParticleDataType.js +10 -0
- package/engine/graphics/particles/particular/group/ParticleGroup.js +7 -245
- package/engine/graphics/particles/particular/group/ParticleGroup.spec.js +3 -1
- package/engine/graphics/particles/particular/group/ParticleSpecification.js +21 -14
- package/engine/graphics/particles/particular/group/itemSizeFromAttributeType.js +20 -0
- package/engine/graphics/particles/particular/group/optimizeCommandQueue.js +162 -0
- package/engine/graphics/particles/particular/group/typedArrayConstructorFromDataType.js +19 -0
- package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +2 -2
- package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +13 -7
- package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameter.js +2 -1
- package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameterSet.js +1 -1
- package/engine/graphics/render/forward_plus/LightManager.js +126 -95
- package/engine/graphics/render/forward_plus/PointLight.js +9 -0
- package/engine/graphics/render/forward_plus/PointLightData.js +1 -1
- package/engine/graphics/render/forward_plus/SpotLight.js +9 -0
- package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +2 -2
- package/engine/graphics/render/forward_plus/computeFrustumCorners.js +14 -32
- package/engine/graphics/render/forward_plus/materials/FP_INJECTION_POINT_ACCUMULATION.js +1 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +32 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_DECODE_PARS.js +51 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +25 -0
- package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +31 -120
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_lighting_shared.js +35 -0
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_shader.js +4 -5
- package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
- package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +10 -3
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +595 -60
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +256 -136
- package/engine/graphics/render/forward_plus/query/analytical_triplanar_corner_mapping.js +8 -0
- package/engine/graphics/render/forward_plus/query/cube_mapping.js +38 -0
- package/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +86 -0
- package/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +73 -0
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +131 -0
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +129 -0
- package/engine/graphics/render/forward_plus/query/spot_light_inside_volume.js +33 -0
- package/engine/graphics/render/forward_plus/read_frustum_corner.js +14 -0
- package/engine/graphics/render/forward_plus/testClusterEquality.js +22 -0
- package/engine/graphics/render/layers/RenderLayerUtils.js +7 -4
- package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -2
- package/engine/graphics/shaders/TerrainShader.js +4 -5
- package/engine/graphics/texture/atlas/AtlasPatch.js +7 -2
- package/engine/graphics/texture/atlas/TextureAtlas.js +2 -2
- package/engine/graphics/texture/sampler/HarmonicDiffusionGrid.spec.js +1 -1
- package/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
- package/engine/graphics/texture/sampler/Sampler2D.js +8 -7
- package/engine/graphics/texture/sampler/distanceField.spec.js +1 -1
- package/engine/graphics/texture/sampler/scaleSampler2D.js +7 -10
- package/engine/graphics/trail/x/RibbonMaterialX.js +3 -3
- package/engine/graphics/trail/x/RibbonX.js +17 -2
- package/engine/graphics/trail/x/RibbonXPlugin.js +51 -1
- package/engine/graphics/util/composeMatrix4.js +33 -23
- package/engine/graphics/util/decompose_matrix_4_array.js +61 -0
- package/engine/grid/components/GridObstacle.js +3 -10
- package/engine/intelligence/behavior/ecs/BehaviorComponent.js +30 -14
- package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
- package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
- package/engine/knowledge/database/StaticKnowledgeDataTable.js +6 -1
- package/engine/navigation/ecs/components/Path.js +1 -6
- package/engine/navigation/grid/FastBinaryHeap.spec.js +1 -1
- package/engine/reference/v2/Reference.js +6 -0
- package/engine/sound/ecs/emitter/SoundEmitter.js +2 -1
- package/engine/sound/ecs/emitter/SoundTrack.js +2 -1
- package/engine/sound/material/concrete/RandomSoundMaterial.js +1 -1
- package/engine/ui/notification/notificationGenerator.js +1 -1
- package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +1 -1
- package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
- package/generation/markers/actions/MarkerNodeActionSelectRandom.js +1 -1
- package/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +1 -1
- package/generation/placement/action/random/CellActionSelectRandom.js +1 -1
- package/generation/theme/ThemeEngine.js +2 -2
- package/misc/makeMaterialIconCached.js +2 -2
- package/package.json +3 -3
- package/view/View.js +4 -2
- package/view/elements/image/HTMLElementCacheKey.js +2 -1
- package/view/elements/radial/RadialText.js +2 -1
- package/view/minimap/gl/MinimapMarkersGL.js +6 -100
- package/view/minimap/gl/buildMaterial.js +94 -0
- package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +0 -71
- package/engine/graphics/render/forward_plus/queryBVH_Frustum.js +0 -345
|
@@ -0,0 +1,935 @@
|
|
|
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 TagSystem from "../../../../../../ecs/systems/TagSystem.js";
|
|
6
|
+
import { AttachmentSocketsSystem } from "../../../../../../ecs/sockets/AttachmentSocketsSystem.js";
|
|
7
|
+
import { AttachmentSystem } from "../../../../../../ecs/attachment/AttachmentSystem.js";
|
|
8
|
+
import { SoundEmitterSystem } from "../../../../../../sound/ecs/emitter/SoundEmitterSystem.js";
|
|
9
|
+
import SoundControllerSystem from "../../../../../../sound/ecs/SoundControllerSystem.js";
|
|
10
|
+
import SoundListenerSystem from "../../../../../../sound/ecs/SoundListenerSystem.js";
|
|
11
|
+
import AnimationSystem from "../../../../../../ecs/systems/AnimationSystem.js";
|
|
12
|
+
import TopDownCameraControllerSystem from "../../../../../ecs/camera/topdown/TopDownCameraControllerSystem.js";
|
|
13
|
+
import { CameraSystem } from "../../../../../ecs/camera/CameraSystem.js";
|
|
14
|
+
import { MeshSystem } from "../../../../../ecs/mesh/MeshSystem.js";
|
|
15
|
+
import ClingToTerrainSystem from "../../../../../../ecs/terrain/ecs/ClingToTerrainSystem.js";
|
|
16
|
+
import TerrainSystem from "../../../../../../ecs/terrain/ecs/TerrainSystem.js";
|
|
17
|
+
import Trail2DSystem from "../../../../../ecs/trail2d/Trail2DSystem.js";
|
|
18
|
+
import { Foliage2System } from "../../../../../../ecs/foliage/ecs/Foliage2System.js";
|
|
19
|
+
import ViewportPositionSystem from "../../../../../../ecs/gui/position/ViewportPositionSystem.js";
|
|
20
|
+
import SynchronizePositionSystem from "../../../../../../ecs/systems/SynchronizePositionSystem.js";
|
|
21
|
+
import InputControllerSystem from "../../../../../../input/ecs/systems/InputControllerSystem.js";
|
|
22
|
+
import { InputSystem } from "../../../../../../input/ecs/systems/InputSystem.js";
|
|
23
|
+
import MeshHighlightSystem from "../../../../../ecs/highlight/system/MeshHighlightSystem.js";
|
|
24
|
+
import LightSystem from "../../../../../ecs/light/LightSystem.js";
|
|
25
|
+
import { BehaviorSystem } from "../../../../../../intelligence/behavior/ecs/BehaviorSystem.js";
|
|
26
|
+
import { SerializationMetadataSystem } from "../../../../../../ecs/systems/SerializationMetadataSystem.js";
|
|
27
|
+
import { PathDisplaySystem } from "../../../../../ecs/path/PathDisplaySystem.js";
|
|
28
|
+
import RenderSystem from "../../../../../../ecs/systems/RenderSystem.js";
|
|
29
|
+
import { makeEngineOptionsModel } from "../../../../../../../../model/game/options/makeEngineOptionsModel.js";
|
|
30
|
+
import { enableEditor } from "../../../../../../../editor/enableEditor.js";
|
|
31
|
+
import { buildCubeURLs } from "../../../../../texture/cubemap/buildCubeURLs.js";
|
|
32
|
+
import { AmbientOcclusionPostProcessEffect } from "../../../../../render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js";
|
|
33
|
+
import Vector2 from "../../../../../../../core/geom/Vector2.js";
|
|
34
|
+
import Vector3 from "../../../../../../../core/geom/Vector3.js";
|
|
35
|
+
import EntityBuilder from "../../../../../../ecs/EntityBuilder.js";
|
|
36
|
+
import { Transform } from "../../../../../../ecs/transform/Transform.js";
|
|
37
|
+
import Mesh from "../../../../../ecs/mesh/Mesh.js";
|
|
38
|
+
import { AABB3 } from "../../../../../../../core/bvh2/aabb3/AABB3.js";
|
|
39
|
+
import { ParticleVolume } from "./ParticleVolume.js";
|
|
40
|
+
import { ParticleEmitterSystem } from "../../../../ecs/ParticleEmitterSystem.js";
|
|
41
|
+
import { BehaviorComponent } from "../../../../../../intelligence/behavior/ecs/BehaviorComponent.js";
|
|
42
|
+
import { RepeatBehavior } from "../../../../../../intelligence/behavior/decorator/RepeatBehavior.js";
|
|
43
|
+
import { ActionBehavior } from "../../../../../../intelligence/behavior/primitive/ActionBehavior.js";
|
|
44
|
+
import { pingpong } from "../../../../../../../core/math/pingpong.js";
|
|
45
|
+
import { ParameterLookupTable } from "../../parameter/ParameterLookupTable.js";
|
|
46
|
+
import { pick } from "../../../../../../../../model/game/util/ScreenGridPicker.js";
|
|
47
|
+
import { obtainTerrain } from "../../../../../../../../model/game/scenes/SceneUtils.js";
|
|
48
|
+
import GUIElement from "../../../../../../ecs/gui/GUIElement.js";
|
|
49
|
+
import EmptyView from "../../../../../../../view/elements/EmptyView.js";
|
|
50
|
+
import HeadsUpDisplay from "../../../../../../ecs/gui/hud/HeadsUpDisplay.js";
|
|
51
|
+
import ViewportPosition from "../../../../../../ecs/gui/position/ViewportPosition.js";
|
|
52
|
+
import { CanvasView } from "../../../../../../../view/elements/CanvasView.js";
|
|
53
|
+
import convertSampler2D2Canvas from "../../../../../texture/sampler/Sampler2D2Canvas.js";
|
|
54
|
+
import Vector1 from "../../../../../../../core/geom/Vector1.js";
|
|
55
|
+
import { clamp } from "../../../../../../../core/math/clamp.js";
|
|
56
|
+
import { UnitCubeShape3D } from "../../../../../../../core/geom/3d/shape/UnitCubeShape3D.js";
|
|
57
|
+
import { ShadedGeometrySystem } from "../../../../../ecs/mesh-v2/ShadedGeometrySystem.js";
|
|
58
|
+
import { lut_to_sampler } from "./lut_to_sampler.js";
|
|
59
|
+
import {
|
|
60
|
+
shape_to_visual_entity,
|
|
61
|
+
SHAPE_VISUAL_ENTITY_TAG
|
|
62
|
+
} from "../../../../../../../core/geom/3d/shape/util/shape_to_visual_entity.js";
|
|
63
|
+
import { seededRandom } from "../../../../../../../core/math/random/seededRandom.js";
|
|
64
|
+
import { TransformedShape3D } from "../../../../../../../core/geom/3d/shape/TransformedShape3D.js";
|
|
65
|
+
import { mat4 } from "gl-matrix";
|
|
66
|
+
import { CompositeShape3D } from "../../../../../../../core/geom/3d/shape/CompositeShape.js";
|
|
67
|
+
import { ShadedGeometry } from "../../../../../ecs/mesh-v2/ShadedGeometry.js";
|
|
68
|
+
import { DrawMode } from "../../../../../ecs/mesh-v2/DrawMode.js";
|
|
69
|
+
import { makeHelperBoxGeometry } from "../../../../../../../editor/process/symbolic/makeHelperBoxGeometry.js";
|
|
70
|
+
import { LineBasicMaterial } from "three";
|
|
71
|
+
import Renderable from "../../../../../../ecs/components/Renderable.js";
|
|
72
|
+
import { TransformControls } from "three/examples/jsm/controls/TransformControls.js";
|
|
73
|
+
import { threeUpdateTransform } from "../../../../../util/threeUpdateTransform.js";
|
|
74
|
+
import InputController from "../../../../../../input/ecs/components/InputController.js";
|
|
75
|
+
import { computeStatisticalMean } from "../../../../../../../core/math/statistics/computeStatisticalMean.js";
|
|
76
|
+
import ButtonView from "../../../../../../../view/elements/button/ButtonView.js";
|
|
77
|
+
import { UnitSphereShape3D } from "../../../../../../../core/geom/3d/shape/UnitSphereShape3D.js";
|
|
78
|
+
import TopDownCameraController from "../../../../../ecs/camera/topdown/TopDownCameraController.js";
|
|
79
|
+
import { randomFloatBetween } from "../../../../../../../core/math/random/randomFloatBetween.js";
|
|
80
|
+
|
|
81
|
+
const engineHarness = new EngineHarness();
|
|
82
|
+
|
|
83
|
+
function makeConfig(engine) {
|
|
84
|
+
|
|
85
|
+
const config = new EngineConfiguration();
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
* @type {SoundEngine}
|
|
90
|
+
*/
|
|
91
|
+
const sound = engine.sound;
|
|
92
|
+
const graphics = engine.graphics;
|
|
93
|
+
const assetManager = engine.assetManager;
|
|
94
|
+
const devices = engine.devices;
|
|
95
|
+
|
|
96
|
+
const guiSystem = new GUIElementSystem(engine.gui.view, engine);
|
|
97
|
+
const headsUpDisplaySystem = new HeadsUpDisplaySystem(graphics);
|
|
98
|
+
|
|
99
|
+
config.systems.push(
|
|
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
|
+
guiSystem,
|
|
107
|
+
new AnimationSystem(graphics.viewport.size),
|
|
108
|
+
new TopDownCameraControllerSystem(graphics),
|
|
109
|
+
new CameraSystem(graphics.scene, graphics),
|
|
110
|
+
new MeshSystem(engine),
|
|
111
|
+
new ClingToTerrainSystem(),
|
|
112
|
+
new TerrainSystem(graphics, assetManager),
|
|
113
|
+
new Trail2DSystem(engine),
|
|
114
|
+
new Foliage2System(assetManager, graphics),
|
|
115
|
+
new ViewportPositionSystem(graphics.viewport.size),
|
|
116
|
+
new SynchronizePositionSystem(),
|
|
117
|
+
new InputControllerSystem(devices),
|
|
118
|
+
new InputSystem(devices),
|
|
119
|
+
new MeshHighlightSystem(engine),
|
|
120
|
+
new LightSystem(engine, {
|
|
121
|
+
shadowResolution: 2048
|
|
122
|
+
}),
|
|
123
|
+
headsUpDisplaySystem,
|
|
124
|
+
new BehaviorSystem(engine),
|
|
125
|
+
new SerializationMetadataSystem(),
|
|
126
|
+
new PathDisplaySystem(engine),
|
|
127
|
+
new ParticleEmitterSystem(engine),
|
|
128
|
+
new ShadedGeometrySystem(engine)
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
// Plugins
|
|
133
|
+
// config.addPlugin(MicronRenderPlugin);
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
// Knowledge
|
|
137
|
+
|
|
138
|
+
return config;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* @param {EngineHarness} harness
|
|
145
|
+
* @return {Promise<void>}
|
|
146
|
+
*/
|
|
147
|
+
async function init(harness) {
|
|
148
|
+
const engine = harness.engine;
|
|
149
|
+
|
|
150
|
+
engine.entityManager.addSystem(new RenderSystem(engine.graphics));
|
|
151
|
+
|
|
152
|
+
makeEngineOptionsModel(engine.options, engine);
|
|
153
|
+
|
|
154
|
+
await makeConfig(engine).apply(engine);
|
|
155
|
+
|
|
156
|
+
enableEditor(engine);
|
|
157
|
+
|
|
158
|
+
await engine.graphics.loadEnvironmentMap(buildCubeURLs('data/textures/cubemaps/hip_miramar/32/', '.png'));
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
await engine.plugins.acquire(AmbientOcclusionPostProcessEffect);
|
|
162
|
+
|
|
163
|
+
await harness.initialize();
|
|
164
|
+
|
|
165
|
+
main(engine);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
const heatmap_lut_0 = new ParameterLookupTable(4);
|
|
170
|
+
heatmap_lut_0.write([
|
|
171
|
+
0, 0, 255, 10,
|
|
172
|
+
0, 179, 179, 10,
|
|
173
|
+
0, 255, 0, 10,
|
|
174
|
+
255, 255, 0, 10,
|
|
175
|
+
255, 5, 5, 10
|
|
176
|
+
]);
|
|
177
|
+
heatmap_lut_0.computeUniformPositions();
|
|
178
|
+
|
|
179
|
+
const heatmap_lut_orange_to_red = new ParameterLookupTable(4);
|
|
180
|
+
heatmap_lut_orange_to_red.write([
|
|
181
|
+
255, 127, 0, 100,
|
|
182
|
+
206, 2, 86, 100
|
|
183
|
+
]);
|
|
184
|
+
heatmap_lut_orange_to_red.computeUniformPositions();
|
|
185
|
+
|
|
186
|
+
const heatmap_lut_pink_to_blue = new ParameterLookupTable(4);
|
|
187
|
+
heatmap_lut_pink_to_blue.write([
|
|
188
|
+
255, 151, 213, 50,
|
|
189
|
+
2, 243, 255, 50
|
|
190
|
+
]);
|
|
191
|
+
heatmap_lut_pink_to_blue.computeUniformPositions();
|
|
192
|
+
|
|
193
|
+
const heatmap_lut_3 = new ParameterLookupTable(4);
|
|
194
|
+
heatmap_lut_3.write(
|
|
195
|
+
[
|
|
196
|
+
196, 196, 196, 255,
|
|
197
|
+
196, 196, 196, 255,
|
|
198
|
+
0, 230, 0, 255,
|
|
199
|
+
0, 230, 0, 255,
|
|
200
|
+
255, 212, 0, 255,
|
|
201
|
+
255, 212, 0, 255,
|
|
202
|
+
],
|
|
203
|
+
[
|
|
204
|
+
0,
|
|
205
|
+
0.1,
|
|
206
|
+
0.1,
|
|
207
|
+
0.7,
|
|
208
|
+
0.7,
|
|
209
|
+
1
|
|
210
|
+
]
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
*
|
|
216
|
+
* @param {Engine} engine
|
|
217
|
+
*/
|
|
218
|
+
function make_shape_vis_toggle(engine) {
|
|
219
|
+
const ecd = engine.entityManager.dataset;
|
|
220
|
+
const entities = TagSystem.find_entities_with_tag(SHAPE_VISUAL_ENTITY_TAG, ecd);
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
const builders = entities.map(e => EntityBuilder.readFromDataset(e, ecd));
|
|
224
|
+
|
|
225
|
+
function toggle() {
|
|
226
|
+
if (builders.length <= 1) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (builders[0].isBuilt) {
|
|
231
|
+
builders.forEach(b => b.destroy());
|
|
232
|
+
} else {
|
|
233
|
+
builders.forEach(b => b.build(ecd));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const buttonView = new ButtonView({
|
|
238
|
+
action: toggle,
|
|
239
|
+
name: 'Toggle Shapes',
|
|
240
|
+
css: {
|
|
241
|
+
position: 'absolute',
|
|
242
|
+
bottom: '10px',
|
|
243
|
+
right: '10px',
|
|
244
|
+
background: 'rgba(255,255,255,0.8)',
|
|
245
|
+
border: '1px solid rgba(0,0,0,1)',
|
|
246
|
+
padding: '2px'
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
new EntityBuilder()
|
|
251
|
+
.add(GUIElement.fromView(buttonView))
|
|
252
|
+
.build(ecd);
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
toggle
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function mat_from_aabb3(aabb3) {
|
|
260
|
+
const m4 = mat4.create();
|
|
261
|
+
|
|
262
|
+
mat4.fromRotationTranslationScale(m4, [0, 0, 0, 1], [(aabb3.x0 + aabb3.x1) / 2, (aabb3.y0 + aabb3.y1) / 2, (aabb3.z0 + aabb3.z1) / 2], [aabb3.getExtentsX(), aabb3.getExtentsY(), aabb3.getExtentsZ()]);
|
|
263
|
+
|
|
264
|
+
return m4;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
*
|
|
269
|
+
* @param {string} url
|
|
270
|
+
* @param {EntityComponentDataset} ecd
|
|
271
|
+
* @returns {EntityBuilder}
|
|
272
|
+
*/
|
|
273
|
+
function load_model(url, ecd) {
|
|
274
|
+
|
|
275
|
+
const b = new EntityBuilder();
|
|
276
|
+
b
|
|
277
|
+
.add(new Transform())
|
|
278
|
+
.add(Mesh.fromJSON({
|
|
279
|
+
url: url,
|
|
280
|
+
castShadow: true,
|
|
281
|
+
receiveShadow: true
|
|
282
|
+
}))
|
|
283
|
+
.build(ecd);
|
|
284
|
+
|
|
285
|
+
return b;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
*
|
|
290
|
+
* @param {Engine} engine
|
|
291
|
+
* @returns {Promise<void>}
|
|
292
|
+
*/
|
|
293
|
+
async function sample_scene_0(engine) {
|
|
294
|
+
const ecd = engine.entityManager.dataset;
|
|
295
|
+
|
|
296
|
+
function load_model_s(url, y_offset = 0) {
|
|
297
|
+
const b = load_model(url, ecd);
|
|
298
|
+
b.getComponent(Transform).position.set(
|
|
299
|
+
20,
|
|
300
|
+
-5.8 + y_offset,
|
|
301
|
+
100
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
return b;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// load_model('moicon/06_04_hapro/00-environment/model.gltf', -0.1);
|
|
308
|
+
load_model_s('moicon/06_04_hapro/05-ground-floor/model.gltf');
|
|
309
|
+
// load_model('moicon/06_04_hapro/02-bearers/model.gltf');
|
|
310
|
+
// load_model('moicon/06_04_hapro/04-1st-floor/model.gltf');
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
await make_demo_volume({
|
|
314
|
+
ecd: ecd,
|
|
315
|
+
lut: heatmap_lut_0,
|
|
316
|
+
shape: CompositeShape3D.from([
|
|
317
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), mat_from_aabb3(new AABB3(67.73, 0, 89, 115.84, 3, 118.34))),
|
|
318
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), mat_from_aabb3(new AABB3(98, 0, 76.5, 109.5, 3, 89)))
|
|
319
|
+
]),
|
|
320
|
+
particle_size: 4,
|
|
321
|
+
density: 4,
|
|
322
|
+
period: 10
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
await make_demo_volume({
|
|
326
|
+
ecd: ecd,
|
|
327
|
+
lut: heatmap_lut_0,
|
|
328
|
+
shape: CompositeShape3D.from([
|
|
329
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [14.980091485108495, 0, 0, 0, 0, 2.812495250139616, 0, 0, 0, 0, 7.469446746375293, 0, 54.83080514238756, 1.568241402881399, 92.51937192481576, 1]),
|
|
330
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [6.644515553810907, 0, 0, 0, 0, 2.812495250139616, 0, 0, 0, 0, 5.507507223409315, 0, 46.95032009188344, 1.568241402881399, 95.54148649329517, 1]),
|
|
331
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [23.762890107594952, 0, 0, 0, 0, 2.812495250139616, 0, 0, 0, 0, 34.57956316503163, 0, 55.436098243647756, 1.568241402881399, 113.46988143189215, 1])
|
|
332
|
+
]),
|
|
333
|
+
particle_size: 2,
|
|
334
|
+
density: 1,
|
|
335
|
+
period: 10,
|
|
336
|
+
period_offset: 3,
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
await make_demo_volume({
|
|
340
|
+
ecd: ecd,
|
|
341
|
+
lut: heatmap_lut_orange_to_red,
|
|
342
|
+
shape: TransformedShape3D.from_m4(new UnitCubeShape3D(), mat_from_aabb3(new AABB3(97.68, 0, 67.71, 115.76, 3, 76.14))),
|
|
343
|
+
particle_size: 1,
|
|
344
|
+
density: 1.2,
|
|
345
|
+
period: 7,
|
|
346
|
+
period_offset: 2,
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
await make_demo_volume({
|
|
350
|
+
ecd: ecd,
|
|
351
|
+
lut: heatmap_lut_pink_to_blue,
|
|
352
|
+
shape: CompositeShape3D.from([
|
|
353
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [15.218520811592711, 0, 0, 0, 0, 3.058639690434693, 0, 0, 0, 0, 5.828701399328644, 0, 89.53848861962253, 2.0721850959505907, 73.05504876489894, 1]),
|
|
354
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [18.10977091153633, 0, 0, 0, 0, 3.058639690434693, 0, 0, 0, 0, 2.5862076050328002, 0, 88.03260126722904, 2.0721850959505907, 69.0797462656922, 1])
|
|
355
|
+
]),
|
|
356
|
+
particle_size: 4,
|
|
357
|
+
density: 4,
|
|
358
|
+
period: 7,
|
|
359
|
+
period_offset: 2,
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// large open room, dense particles
|
|
363
|
+
await make_demo_volume({
|
|
364
|
+
ecd: ecd,
|
|
365
|
+
lut: heatmap_lut_3,
|
|
366
|
+
shape: CompositeShape3D.from([
|
|
367
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [20.977896627021547, 0, 0, 0, 0, 2.956899734575006, 0, 0, 0, 0, 36.201589869571954, 0, 99.2120028317975, 1.5919924971428276, 49.21655402009093, 1]),
|
|
368
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [24.455615450514458, 0, 0, 0, 0, 2.956899734575006, 0, 0, 0, 0, 28.081536987027807, 0, 80.11618755300161, 1.5919924971428276, 45.13808745329574, 1]),
|
|
369
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [5.562874425497998, 0, 0, 0, 0, 2.956899734575006, 0, 0, 0, 0, 2.654155224548708, 0, 70.80986716000054, 1.5919924971428276, 59.679876796143446, 1])
|
|
370
|
+
]),
|
|
371
|
+
particle_size: 0.15,
|
|
372
|
+
density: 5,
|
|
373
|
+
period: 7,
|
|
374
|
+
period_offset: 2,
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// popsicle
|
|
378
|
+
await make_demo_volume({
|
|
379
|
+
ecd: ecd,
|
|
380
|
+
lut: heatmap_lut_orange_to_red,
|
|
381
|
+
shape: CompositeShape3D.from([
|
|
382
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [-3.8971594611231577, -1.9562533614625899, -0.5725042419276598, 0, -8.346390838999248, 16.986127440019352, -1.226109479938015, 0, 0.12112312197093604, 0, -0.8245111322851176, 0, 55.83305788880312, 9.579537179233043, 83.59013920067233, 1]),
|
|
383
|
+
TransformedShape3D.from_m4(new UnitSphereShape3D(), [10.237283879346698, 0, 0, 0, 0, 10.237283879346698, 0, 0, 0, 0, 10.237283879346698, 0, 51.783732965076716, 18.028888481196716, 82.91084586075068, 1])
|
|
384
|
+
]),
|
|
385
|
+
particle_size: 0.7,
|
|
386
|
+
density: 5,
|
|
387
|
+
period: 3,
|
|
388
|
+
period_offset: 2,
|
|
389
|
+
sort: true
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
engine.devices.pointer.on.down.add((p) => {
|
|
393
|
+
pick(p.x, p.y, engine.graphics, obtainTerrain(ecd), (grid_position, position, normal) => {
|
|
394
|
+
console.log(position.toJSON());
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
make_shape_vis_toggle(engine).toggle(); // turn off shape vis initially
|
|
399
|
+
|
|
400
|
+
// editing box
|
|
401
|
+
make_box_editor(engine, Transform.fromJSON({
|
|
402
|
+
position: {
|
|
403
|
+
x: 20,
|
|
404
|
+
y: 5,
|
|
405
|
+
z: 100
|
|
406
|
+
},
|
|
407
|
+
scale: {
|
|
408
|
+
x: 1,
|
|
409
|
+
y: 1,
|
|
410
|
+
z: 1
|
|
411
|
+
}
|
|
412
|
+
}));
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
*
|
|
418
|
+
* @param {Engine} engine
|
|
419
|
+
* @returns {Promise<void>}
|
|
420
|
+
*/
|
|
421
|
+
async function sample_scene_nam(engine) {
|
|
422
|
+
const ecd = engine.entityManager.dataset;
|
|
423
|
+
|
|
424
|
+
ecd.getAnyComponent(TopDownCameraController).component.fromJSON({
|
|
425
|
+
"target": {
|
|
426
|
+
"x": 21.09522080045099,
|
|
427
|
+
"y": -0.6327784109623013,
|
|
428
|
+
"z": 6.138907038731565
|
|
429
|
+
},
|
|
430
|
+
"pitch": 1.1099999999999923,
|
|
431
|
+
"yaw": -3.143185307179591,
|
|
432
|
+
"roll": 0,
|
|
433
|
+
"distance": 29,
|
|
434
|
+
"distanceMin": 0,
|
|
435
|
+
"distanceMax": 1000
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
load_model('moicon/20_Dec_2021_Nammo/with_assets(for_alex)/model.gltf', ecd)
|
|
439
|
+
|
|
440
|
+
const P_SIZE_SMALL = 0.15;
|
|
441
|
+
const P_SIZE_MEDIUM = 0.6;
|
|
442
|
+
const P_SIZE_LARGE = 2;
|
|
443
|
+
|
|
444
|
+
const random = seededRandom(42);
|
|
445
|
+
|
|
446
|
+
const PERIOD_LONG = 13;
|
|
447
|
+
|
|
448
|
+
await make_demo_volume({
|
|
449
|
+
ecd: ecd,
|
|
450
|
+
lut: heatmap_lut_pink_to_blue,
|
|
451
|
+
shape: TransformedShape3D.from_m4(new UnitCubeShape3D(), [5.267098043281134, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 6.606365126660234, 0, 2.8037239954452864, 1.4169994923726943, 11.460158766988037, 1]),
|
|
452
|
+
particle_size: P_SIZE_MEDIUM,
|
|
453
|
+
density: 3,
|
|
454
|
+
period: PERIOD_LONG,
|
|
455
|
+
period_offset: randomFloatBetween(random, 0, PERIOD_LONG),
|
|
456
|
+
sprite: 'data/textures/particle/UETools/Hexagon_01.png'
|
|
457
|
+
});
|
|
458
|
+
await make_demo_volume({
|
|
459
|
+
ecd: ecd,
|
|
460
|
+
lut: heatmap_lut_orange_to_red,
|
|
461
|
+
shape: TransformedShape3D.from_m4(new UnitCubeShape3D(), [4.7577406314060395, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 6.606365126660234, 0, 8.075207307031247, 1.4169994923726943, 11.460158766988037, 1]),
|
|
462
|
+
particle_size: P_SIZE_MEDIUM,
|
|
463
|
+
density: 3,
|
|
464
|
+
period: PERIOD_LONG,
|
|
465
|
+
period_offset: randomFloatBetween(random, 0, PERIOD_LONG),
|
|
466
|
+
sprite: 'data/textures/particle/UETools/Circle_04.png'
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
await make_demo_volume({
|
|
470
|
+
ecd: ecd,
|
|
471
|
+
lut: heatmap_lut_pink_to_blue,
|
|
472
|
+
shape: TransformedShape3D.from_m4(new UnitCubeShape3D(), [6.956797095914032, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 6.606365126660234, 0, 14.17733466985805, 1.4169994923726943, 11.460158766988037, 1]),
|
|
473
|
+
particle_size: P_SIZE_MEDIUM,
|
|
474
|
+
density: 3,
|
|
475
|
+
period: PERIOD_LONG,
|
|
476
|
+
period_offset: randomFloatBetween(random, 0, PERIOD_LONG),
|
|
477
|
+
sprite: 'data/textures/particle/travnik/plus_2.png'
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
await make_demo_volume({
|
|
481
|
+
ecd: ecd,
|
|
482
|
+
lut: heatmap_lut_pink_to_blue,
|
|
483
|
+
shape: TransformedShape3D.from_m4(new UnitCubeShape3D(), [4.733772190018377, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 6.606365126660234, 0, 20.284613387782148, 1.4169994923726943, 11.460158766988037, 1]),
|
|
484
|
+
particle_size: P_SIZE_MEDIUM,
|
|
485
|
+
density: 3,
|
|
486
|
+
period: PERIOD_LONG,
|
|
487
|
+
period_offset: randomFloatBetween(random, 0, PERIOD_LONG),
|
|
488
|
+
sprite: 'data/textures/particle/UETools/Circle_04.png'
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
await make_demo_volume({
|
|
492
|
+
ecd: ecd,
|
|
493
|
+
lut: heatmap_lut_pink_to_blue,
|
|
494
|
+
shape: TransformedShape3D.from_m4(new UnitCubeShape3D(), [5.924905976332568, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 6.606365126660234, 0, 31.662442543335885, 1.4169994923726943, 11.460158766988037, 1]),
|
|
495
|
+
particle_size: P_SIZE_MEDIUM,
|
|
496
|
+
density: 3,
|
|
497
|
+
period: PERIOD_LONG,
|
|
498
|
+
period_offset: randomFloatBetween(random, 0, PERIOD_LONG),
|
|
499
|
+
sprite: 'data/textures/particle/UETools/Circle_04.png'
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
await make_demo_volume({
|
|
503
|
+
ecd: ecd,
|
|
504
|
+
lut: heatmap_lut_0,
|
|
505
|
+
shape: TransformedShape3D.from_m4(new UnitCubeShape3D(), [5.7305058801925, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 6.606365126660234, 0, 37.70942297505848, 1.4169994923726943, 11.460158766988037, 1]),
|
|
506
|
+
particle_size: P_SIZE_MEDIUM,
|
|
507
|
+
density: 8,
|
|
508
|
+
period: PERIOD_LONG,
|
|
509
|
+
period_offset: randomFloatBetween(random, 0, PERIOD_LONG),
|
|
510
|
+
sprite: 'data/textures/particle/UETools/Circle_04.png'
|
|
511
|
+
});
|
|
512
|
+
await make_demo_volume({
|
|
513
|
+
ecd: ecd,
|
|
514
|
+
lut: heatmap_lut_0,
|
|
515
|
+
shape: TransformedShape3D.from_m4(new UnitCubeShape3D(), [6.575632395877399, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 4.51714948412602, 0, 37.272800538855826, 1.4169994923726943, 2.4066558057134095, 1]),
|
|
516
|
+
particle_size: P_SIZE_MEDIUM,
|
|
517
|
+
density: 8,
|
|
518
|
+
period: PERIOD_LONG,
|
|
519
|
+
period_offset: randomFloatBetween(random, 0, PERIOD_LONG),
|
|
520
|
+
sprite: 'data/textures/particle/UETools/Circle_04.png'
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
await make_demo_volume({
|
|
524
|
+
ecd: ecd,
|
|
525
|
+
lut: heatmap_lut_0,
|
|
526
|
+
shape: TransformedShape3D.from_m4(new UnitCubeShape3D(), [6.410614101275306, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 4.51714948412602, 0, 30.458756650580582, 1.4169994923726943, 2.4066558057134095, 1]),
|
|
527
|
+
particle_size: P_SIZE_MEDIUM,
|
|
528
|
+
density: 8,
|
|
529
|
+
period: PERIOD_LONG,
|
|
530
|
+
period_offset: randomFloatBetween(random, 0, PERIOD_LONG),
|
|
531
|
+
sprite: 'data/textures/particle/UETools/Circle_04.png'
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
await make_demo_volume({
|
|
535
|
+
ecd: ecd,
|
|
536
|
+
lut: heatmap_lut_3,
|
|
537
|
+
shape: TransformedShape3D.from_m4(new UnitCubeShape3D(), [4.260857135913424, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 4.51714948412602, 0, 24.82865688356064, 1.4169994923726943, 2.4066558057134095, 1]),
|
|
538
|
+
particle_size: P_SIZE_SMALL,
|
|
539
|
+
density: 3,
|
|
540
|
+
period: PERIOD_LONG,
|
|
541
|
+
period_offset: randomFloatBetween(random, 0, PERIOD_LONG),
|
|
542
|
+
sprite: 'data/textures/particle/UETools/Circle_01.png'
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
await make_demo_volume({
|
|
546
|
+
ecd: ecd,
|
|
547
|
+
lut: heatmap_lut_3,
|
|
548
|
+
shape: TransformedShape3D.from_m4(new UnitCubeShape3D(), [4.870266350649175, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 4.51714948412602, 0, 20.022408905267525, 1.4169994923726943, 2.4066558057134095, 1]),
|
|
549
|
+
particle_size: P_SIZE_SMALL,
|
|
550
|
+
density: 3,
|
|
551
|
+
period: PERIOD_LONG,
|
|
552
|
+
period_offset: randomFloatBetween(random, 0, PERIOD_LONG),
|
|
553
|
+
sprite: 'data/textures/particle/UETools/Cross_04.png'
|
|
554
|
+
});
|
|
555
|
+
await make_demo_volume({
|
|
556
|
+
ecd: ecd,
|
|
557
|
+
lut: heatmap_lut_pink_to_blue,
|
|
558
|
+
shape: CompositeShape3D.from([
|
|
559
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [5.985827128973811, 0, 0, 0, 0, 2.435269776236539, 0, 0, 0, 0, 4.669621139110231, 0, 11.08356834576874, 1.2643565739307023, 2.4360416869081885, 1]),
|
|
560
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [8.413758403821523, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 7.775469675813772, 0, 4.313201108449287, 1.4169994923726943, 4.011630095541064, 1]),
|
|
561
|
+
TransformedShape3D.from_m4(new UnitCubeShape3D(), [8.413758403821523, 0, 0, 0, 0, 2.3166487265965343, 0, 0, 0, 0, 2.925065210015915, 0, 12.417224289491141, 1.4169994923726943, 6.432483110925785, 1])
|
|
562
|
+
]),
|
|
563
|
+
particle_size: P_SIZE_LARGE,
|
|
564
|
+
density: 4,
|
|
565
|
+
period: PERIOD_LONG,
|
|
566
|
+
period_offset: randomFloatBetween(random, 0, PERIOD_LONG),
|
|
567
|
+
sprite: 'data/textures/particle/UETools/Circle_04.png'
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
make_shape_vis_toggle(engine).toggle(); // turn off shape vis initially
|
|
571
|
+
|
|
572
|
+
// editing box
|
|
573
|
+
// make_box_editor(engine, Transform.fromJSON({
|
|
574
|
+
// position: {
|
|
575
|
+
// x: -2,
|
|
576
|
+
// y: 5,
|
|
577
|
+
// z: 0
|
|
578
|
+
// },
|
|
579
|
+
// scale: {
|
|
580
|
+
// x: 1,
|
|
581
|
+
// y: 1,
|
|
582
|
+
// z: 1
|
|
583
|
+
// }
|
|
584
|
+
// }));
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
*
|
|
589
|
+
* @param {Engine} engine
|
|
590
|
+
*/
|
|
591
|
+
async function main(engine) {
|
|
592
|
+
EngineHarness.buildBasics({
|
|
593
|
+
engine,
|
|
594
|
+
enableWater: false,
|
|
595
|
+
enableTerrain: false,
|
|
596
|
+
// enableTerrain: true,
|
|
597
|
+
terrainSize: new Vector2(100, 100),
|
|
598
|
+
focus: new Vector3(102, 0, 61),
|
|
599
|
+
// pitch: -0.5,
|
|
600
|
+
// yaw: 2.2,
|
|
601
|
+
// distance: 3
|
|
602
|
+
pitch: 0.9,
|
|
603
|
+
yaw: 3.1,
|
|
604
|
+
distance: 20
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
engine.graphics.renderer.setClearColor('rgba(99,99,99,1)');
|
|
609
|
+
|
|
610
|
+
await sample_scene_nam(engine);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
*
|
|
615
|
+
* @param {Engine} engine
|
|
616
|
+
* @param {Transform} [transform]
|
|
617
|
+
*/
|
|
618
|
+
function make_box_editor(engine, transform = new Transform()) {
|
|
619
|
+
const controls = new TransformControls(engine.graphics.camera, engine.graphics.domElement);
|
|
620
|
+
|
|
621
|
+
const eb = new EntityBuilder();
|
|
622
|
+
const g_unit_cube = makeHelperBoxGeometry(1, 1, 1);
|
|
623
|
+
|
|
624
|
+
const ecd = engine.entityManager.dataset;
|
|
625
|
+
|
|
626
|
+
const lineMaterial = new LineBasicMaterial({
|
|
627
|
+
depthTest: true,
|
|
628
|
+
depthWrite: false,
|
|
629
|
+
transparent: true,
|
|
630
|
+
linewidth: 1,
|
|
631
|
+
fog: false,
|
|
632
|
+
color: '#4aff51',
|
|
633
|
+
opacity: 1
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
const box_transform = transform.clone();
|
|
637
|
+
eb.add(box_transform);
|
|
638
|
+
const sg = ShadedGeometry.from(g_unit_cube, lineMaterial, DrawMode.LineSegments);
|
|
639
|
+
eb.add(sg);
|
|
640
|
+
|
|
641
|
+
eb.build(ecd);
|
|
642
|
+
|
|
643
|
+
const cachedObject = sg.__cached_object;
|
|
644
|
+
cachedObject.frustumCulled = false;
|
|
645
|
+
controls.attach(cachedObject);
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
controls.setSize(1);
|
|
649
|
+
const r_controls = new Renderable(controls);
|
|
650
|
+
r_controls.matrixAutoUpdate = true;
|
|
651
|
+
r_controls.boundingBoxNeedsUpdate = false;
|
|
652
|
+
r_controls.boundingBox.setBounds(0, 0, 0, 1, 1, 1);
|
|
653
|
+
|
|
654
|
+
// make camera controller holder
|
|
655
|
+
const entity = TagSystem.find_entities_with_tag('CameraController', ecd)[0];
|
|
656
|
+
|
|
657
|
+
const camera_controls = EntityBuilder.readFromDataset(entity, ecd);
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
new EntityBuilder()
|
|
661
|
+
.add(r_controls)
|
|
662
|
+
.add(new Transform())
|
|
663
|
+
.add(new InputController([
|
|
664
|
+
{
|
|
665
|
+
path: 'keyboard/keys/w/down',
|
|
666
|
+
listener() {
|
|
667
|
+
controls.setMode('translate');
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
path: 'keyboard/keys/e/down',
|
|
672
|
+
listener() {
|
|
673
|
+
controls.setMode('scale');
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
path: 'keyboard/keys/r/down',
|
|
678
|
+
listener() {
|
|
679
|
+
controls.setMode('rotate');
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
path: 'keyboard/keys/s/down',
|
|
684
|
+
listener() {
|
|
685
|
+
// output current box
|
|
686
|
+
|
|
687
|
+
const code_snippet = `TransformedShape3D.from_m4(new UnitCubeShape3D(), ${JSON.stringify(cachedObject.matrix.elements)})`;
|
|
688
|
+
console.warn(code_snippet);
|
|
689
|
+
|
|
690
|
+
navigator.clipboard.writeText(code_snippet);
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
path: 'keyboard/keys/space/down',
|
|
695
|
+
listener() {
|
|
696
|
+
// reset scale and rotation
|
|
697
|
+
box_transform.scale.setScalar(1);
|
|
698
|
+
box_transform.rotation.set(0, 0, 0, 1);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
]))
|
|
702
|
+
.add(BehaviorComponent.looping_function(() => {
|
|
703
|
+
|
|
704
|
+
threeUpdateTransform(controls);
|
|
705
|
+
|
|
706
|
+
if (controls.dragging) {
|
|
707
|
+
if (camera_controls.isBuilt) {
|
|
708
|
+
camera_controls.destroy();
|
|
709
|
+
}
|
|
710
|
+
} else {
|
|
711
|
+
if (!camera_controls.isBuilt) {
|
|
712
|
+
camera_controls.build(ecd);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
cachedObject.updateMatrix();
|
|
717
|
+
const matrix = cachedObject.matrix;
|
|
718
|
+
const t = eb.getComponent(Transform);
|
|
719
|
+
|
|
720
|
+
t.position.onChanged.mute();
|
|
721
|
+
t.rotation.onChanged.mute();
|
|
722
|
+
t.scale.onChanged.mute();
|
|
723
|
+
|
|
724
|
+
t.fromMatrix4(matrix.elements);
|
|
725
|
+
|
|
726
|
+
t.position.onChanged.unmute();
|
|
727
|
+
t.rotation.onChanged.unmute();
|
|
728
|
+
t.scale.onChanged.unmute();
|
|
729
|
+
|
|
730
|
+
sg.updateTransform();
|
|
731
|
+
|
|
732
|
+
}))
|
|
733
|
+
.build(ecd);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
*
|
|
738
|
+
* @param {EntityComponentDataset} ecd
|
|
739
|
+
* @param {AbstractShape3D} shape
|
|
740
|
+
* @param {number} density
|
|
741
|
+
* @param {number} particle_size
|
|
742
|
+
* @param {boolean} sort
|
|
743
|
+
* @returns {ParticleVolume}
|
|
744
|
+
*/
|
|
745
|
+
function create_volume({
|
|
746
|
+
ecd,
|
|
747
|
+
shape = new UnitCubeShape3D(),
|
|
748
|
+
density = 10,
|
|
749
|
+
particle_size = 1,
|
|
750
|
+
sort = false,
|
|
751
|
+
sprite
|
|
752
|
+
}) {
|
|
753
|
+
|
|
754
|
+
const adjusted_density = density / particle_size;
|
|
755
|
+
|
|
756
|
+
const v = new ParticleVolume();
|
|
757
|
+
|
|
758
|
+
v.from({
|
|
759
|
+
density: adjusted_density,
|
|
760
|
+
particle_size,
|
|
761
|
+
shape: shape,
|
|
762
|
+
sort,
|
|
763
|
+
sprite
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
v.build();
|
|
767
|
+
|
|
768
|
+
v.entity.build(ecd);
|
|
769
|
+
|
|
770
|
+
return v;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
*
|
|
775
|
+
* @param {Vector3} position
|
|
776
|
+
* @param {ParameterLookupTable} lut
|
|
777
|
+
* @return {{position: Vector1}}
|
|
778
|
+
*/
|
|
779
|
+
function make_symbol_view({
|
|
780
|
+
position,
|
|
781
|
+
lut
|
|
782
|
+
}) {
|
|
783
|
+
|
|
784
|
+
const r = {
|
|
785
|
+
position: new Vector1(1)
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
const symbol_view = new EmptyView();
|
|
789
|
+
symbol_view.size.set(128, 20);
|
|
790
|
+
|
|
791
|
+
symbol_view.css({
|
|
792
|
+
position: 'absolute',
|
|
793
|
+
whiteSpace: 'pre',
|
|
794
|
+
left: 0,
|
|
795
|
+
top: 0
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
const view_lut = new CanvasView();
|
|
799
|
+
view_lut.size.set(128, 10);
|
|
800
|
+
view_lut.css({
|
|
801
|
+
position: 'absolute',
|
|
802
|
+
border: '1px solid white',
|
|
803
|
+
boxShadow: '0 0 6px rgba(0,0,0,0.4)',
|
|
804
|
+
left: 0,
|
|
805
|
+
top: 0
|
|
806
|
+
});
|
|
807
|
+
|
|
808
|
+
const sampler_lut = lut_to_sampler(lut, view_lut.size.x, view_lut.size.y);
|
|
809
|
+
|
|
810
|
+
convertSampler2D2Canvas(sampler_lut, 1, 0, view_lut.el);
|
|
811
|
+
|
|
812
|
+
symbol_view.addChild(view_lut)
|
|
813
|
+
|
|
814
|
+
const view_cursor = new EmptyView();
|
|
815
|
+
|
|
816
|
+
view_cursor.css({
|
|
817
|
+
position: 'absolute',
|
|
818
|
+
left: 0,
|
|
819
|
+
top: "-1px",
|
|
820
|
+
height: "10px",
|
|
821
|
+
width: "4px",
|
|
822
|
+
border: '2px solid white',
|
|
823
|
+
zIndex: 2,
|
|
824
|
+
boxShadow: '0 0 4px black'
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
r.position.process(f => {
|
|
829
|
+
const c = new Uint8Array(4);
|
|
830
|
+
|
|
831
|
+
lut.sample(f, c);
|
|
832
|
+
|
|
833
|
+
const hex_string = `rgb(${c[0]},${c[1]},${c[2]})`;
|
|
834
|
+
|
|
835
|
+
view_cursor.position.set(f * view_lut.size.x, 0);
|
|
836
|
+
view_cursor.css({
|
|
837
|
+
backgroundColor: hex_string
|
|
838
|
+
})
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
symbol_view.addChild(view_cursor);
|
|
842
|
+
|
|
843
|
+
const symbol_transform = new Transform();
|
|
844
|
+
symbol_transform.position.copy(position);
|
|
845
|
+
|
|
846
|
+
const vp = new ViewportPosition();
|
|
847
|
+
vp.anchor.set(0.5, 1);
|
|
848
|
+
|
|
849
|
+
const entity = new EntityBuilder()
|
|
850
|
+
.add(GUIElement.fromView(symbol_view))
|
|
851
|
+
.add(new HeadsUpDisplay())
|
|
852
|
+
.add(vp)
|
|
853
|
+
.add(symbol_transform);
|
|
854
|
+
|
|
855
|
+
r.entity = entity;
|
|
856
|
+
|
|
857
|
+
return r;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
async function make_demo_volume({
|
|
861
|
+
ecd,
|
|
862
|
+
shape,
|
|
863
|
+
lut,
|
|
864
|
+
period = 5,
|
|
865
|
+
period_offset = 0,
|
|
866
|
+
density,
|
|
867
|
+
particle_size,
|
|
868
|
+
sort = false,
|
|
869
|
+
sprite
|
|
870
|
+
}) {
|
|
871
|
+
|
|
872
|
+
// estimate bounds
|
|
873
|
+
const bounds = new AABB3();
|
|
874
|
+
bounds.setNegativelyInfiniteBounds();
|
|
875
|
+
|
|
876
|
+
const sample = [];
|
|
877
|
+
const samples_x = [];
|
|
878
|
+
const samples_y = [];
|
|
879
|
+
const samples_z = [];
|
|
880
|
+
|
|
881
|
+
const random = seededRandom(0xBEEF);
|
|
882
|
+
|
|
883
|
+
for (let i = 0; i < 1024; i++) {
|
|
884
|
+
shape.sample_random_point_in_volume(sample, 0, random);
|
|
885
|
+
|
|
886
|
+
samples_x.push(sample[0]);
|
|
887
|
+
samples_y.push(sample[1]);
|
|
888
|
+
samples_z.push(sample[2]);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
const v = create_volume({
|
|
892
|
+
ecd,
|
|
893
|
+
shape,
|
|
894
|
+
density,
|
|
895
|
+
particle_size,
|
|
896
|
+
sort,
|
|
897
|
+
sprite
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
let time_total = 0;
|
|
901
|
+
|
|
902
|
+
const symbol = make_symbol_view({
|
|
903
|
+
position: new Vector3(
|
|
904
|
+
computeStatisticalMean(samples_x),
|
|
905
|
+
computeStatisticalMean(samples_y),
|
|
906
|
+
computeStatisticalMean(samples_z),
|
|
907
|
+
),
|
|
908
|
+
lut
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
symbol.entity.build(ecd);
|
|
912
|
+
|
|
913
|
+
v.attributes.color.lookup = lut;
|
|
914
|
+
|
|
915
|
+
new EntityBuilder()
|
|
916
|
+
.add(BehaviorComponent.fromOne(RepeatBehavior.from(new ActionBehavior((time) => {
|
|
917
|
+
time_total += time;
|
|
918
|
+
|
|
919
|
+
const _t = pingpong(time_total + period_offset, period);
|
|
920
|
+
|
|
921
|
+
const f = clamp(_t / period, 0, 1);
|
|
922
|
+
|
|
923
|
+
symbol.position.set(f);
|
|
924
|
+
|
|
925
|
+
v.attributes.color.write_lookup_value(f);
|
|
926
|
+
}))))
|
|
927
|
+
.build(ecd);
|
|
928
|
+
|
|
929
|
+
const shape_entity = shape_to_visual_entity(v.shape, ecd);
|
|
930
|
+
shape_entity
|
|
931
|
+
.getComponent(Transform)
|
|
932
|
+
.copy(v.transform);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
init(engineHarness);
|