@woosh/meep-engine 2.33.22 → 2.33.26
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/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 +65 -0
- package/core/geom/3d/shape/TransformedShape3D.js +181 -0
- package/core/geom/3d/shape/TransformedShape3D.spec.js +33 -0
- package/core/geom/3d/shape/UnionShape3D.js +255 -0
- package/core/geom/3d/shape/UnitCubeShape3D.js +101 -0
- package/core/geom/3d/shape/UnitCubeShape3D.spec.js +42 -0
- package/core/geom/3d/shape/UnitSphereShape3D.js +55 -0
- package/core/geom/3d/shape/util/compute_signed_distance_gradient_by_sampling.js +48 -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/shadows/ShadowMapRenderer.js +8 -2
- 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
|
@@ -3,7 +3,6 @@ import { NumericInterval } from "../../../../../../core/math/interval/NumericInt
|
|
|
3
3
|
import { ParameterTrackSet } from "../parameter/ParameterTrackSet.js";
|
|
4
4
|
import { AABB3 } from "../../../../../../core/bvh2/aabb3/AABB3.js";
|
|
5
5
|
import { ParticleParameters } from "./ParticleParameters.js";
|
|
6
|
-
import { computeHashFloat, computeHashIntegerArray } from "../../../../../../core/math/MathUtils.js";
|
|
7
6
|
import { ConicRay } from "../../../../../../core/geom/ConicRay.js";
|
|
8
7
|
import { SimulationStepDefinition } from "../simulator/SimulationStepDefinition.js";
|
|
9
8
|
import List from "../../../../../../core/collection/list/List.js";
|
|
@@ -12,6 +11,8 @@ import { computeStringHash } from "../../../../../../core/primitives/strings/com
|
|
|
12
11
|
import { computeConeBoundingBox } from "../../../../../../core/geom/3d/cone/computeConeBoundingBox.js";
|
|
13
12
|
import { EmissionFromType } from "./EmissionFromType.js";
|
|
14
13
|
import { EmissionShapeType } from "./EmissionShapeType.js";
|
|
14
|
+
import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
|
|
15
|
+
import { computeHashFloat } from "../../../../../../core/math/hash/computeHashFloat.js";
|
|
15
16
|
|
|
16
17
|
function ParticleLayer() {
|
|
17
18
|
/**
|
|
@@ -68,6 +69,7 @@ function ParticleLayer() {
|
|
|
68
69
|
* @type {number}
|
|
69
70
|
*/
|
|
70
71
|
this.emissionRate = 1;
|
|
72
|
+
|
|
71
73
|
/**
|
|
72
74
|
* When layer is added - it will immediately emit this number of particles
|
|
73
75
|
* @type {number}
|
|
@@ -97,6 +99,11 @@ function ParticleLayer() {
|
|
|
97
99
|
* @type {ConicRay}
|
|
98
100
|
*/
|
|
99
101
|
this.particleVelocityDirection = new ConicRay();
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
*
|
|
105
|
+
* @type {NumericInterval}
|
|
106
|
+
*/
|
|
100
107
|
this.particleSpeed = new NumericInterval(0, 0);
|
|
101
108
|
|
|
102
109
|
/**
|
|
@@ -111,7 +118,6 @@ function ParticleLayer() {
|
|
|
111
118
|
*/
|
|
112
119
|
this.isEmitting = true;
|
|
113
120
|
|
|
114
|
-
|
|
115
121
|
/**
|
|
116
122
|
* Simulation steps that are to be applied
|
|
117
123
|
* @type {List<SimulationStepDefinition>}
|
|
@@ -173,7 +179,12 @@ ParticleLayer.prototype.computePointBoundingBox = function (result) {
|
|
|
173
179
|
//displace by current position
|
|
174
180
|
const position = this.position;
|
|
175
181
|
|
|
176
|
-
computeConeBoundingBox(
|
|
182
|
+
computeConeBoundingBox(
|
|
183
|
+
aabb3,
|
|
184
|
+
position.x, position.y, position.z,
|
|
185
|
+
direction.x, direction.y, direction.z,
|
|
186
|
+
particleVelocityDirection.angle, maxDisplacement
|
|
187
|
+
);
|
|
177
188
|
|
|
178
189
|
x0 = aabb3.x0;
|
|
179
190
|
y0 = aabb3.y0;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { BitSet } from "../../../../../../core/binary/BitSet.js";
|
|
2
2
|
import { max3 } from "../../../../../../core/math/max3.js";
|
|
3
|
-
import {
|
|
4
|
-
import { BufferAttribute, BufferGeometry, DynamicDrawUsage } from 'three';
|
|
3
|
+
import { BufferAttribute, BufferGeometry, StreamDrawUsage } from 'three';
|
|
5
4
|
import ObservedValue from "../../../../../../core/model/ObservedValue.js";
|
|
6
5
|
import { typed_array_copy } from "../../../../../../core/collection/array/typed/typed_array_copy.js";
|
|
6
|
+
import { assert } from "../../../../../../core/assert.js";
|
|
7
|
+
import { compute_typed_array_constructor_from_data_type } from "../../../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
8
|
+
import { min2 } from "../../../../../../core/math/min2.js";
|
|
9
|
+
import { max2 } from "../../../../../../core/math/max2.js";
|
|
7
10
|
|
|
8
11
|
const SHRINK_THRESHOLD = 64;
|
|
9
12
|
const GROW_MIN_STEP = 32;
|
|
@@ -11,13 +14,15 @@ const GROW_MIN_STEP = 32;
|
|
|
11
14
|
export class ParticlePool {
|
|
12
15
|
/**
|
|
13
16
|
*
|
|
14
|
-
* @param {
|
|
17
|
+
* @param {VertexDataSpec} spec
|
|
15
18
|
* @constructor
|
|
16
19
|
*/
|
|
17
20
|
constructor(spec) {
|
|
21
|
+
assert.equal(spec.isVertexDataSpec, true, 'spec.VertexDataSpec !== true');
|
|
22
|
+
|
|
18
23
|
/**
|
|
19
24
|
*
|
|
20
|
-
* @type {
|
|
25
|
+
* @type {VertexDataSpec}
|
|
21
26
|
*/
|
|
22
27
|
this.spec = spec;
|
|
23
28
|
|
|
@@ -215,15 +220,50 @@ export class ParticlePool {
|
|
|
215
220
|
const addressA = offsetA + j;
|
|
216
221
|
const addressB = offsetB + j;
|
|
217
222
|
|
|
218
|
-
const
|
|
223
|
+
const temp = array[addressA];
|
|
219
224
|
|
|
220
225
|
array[addressA] = array[addressB];
|
|
221
226
|
|
|
222
|
-
array[addressB] =
|
|
227
|
+
array[addressB] = temp;
|
|
223
228
|
}
|
|
224
229
|
}
|
|
225
230
|
}
|
|
226
231
|
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
* @param {AttributeSpec} spec
|
|
235
|
+
* @return {number}
|
|
236
|
+
* @private
|
|
237
|
+
*/
|
|
238
|
+
__compute_attribute_byte_size(spec) {
|
|
239
|
+
|
|
240
|
+
const item_size = spec.itemSize;
|
|
241
|
+
|
|
242
|
+
const TypedArrayConstructor = compute_typed_array_constructor_from_data_type(spec.type);
|
|
243
|
+
|
|
244
|
+
const element_byte_size = TypedArrayConstructor.BYTES_PER_ELEMENT;
|
|
245
|
+
|
|
246
|
+
return item_size * element_byte_size * this.capacity;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
*
|
|
251
|
+
* @return {number}
|
|
252
|
+
* @private
|
|
253
|
+
*/
|
|
254
|
+
__compute_attribute_byte_size_total() {
|
|
255
|
+
|
|
256
|
+
const spec_attributes = this.spec.attributes;
|
|
257
|
+
const l = spec_attributes.length;
|
|
258
|
+
|
|
259
|
+
let r = 0;
|
|
260
|
+
for (let i = 0; i < l; i++) {
|
|
261
|
+
r += this.__compute_attribute_byte_size(spec_attributes[i]);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return r;
|
|
265
|
+
}
|
|
266
|
+
|
|
227
267
|
build() {
|
|
228
268
|
const geometry = new BufferGeometry();
|
|
229
269
|
geometry.dynamic = true;
|
|
@@ -234,25 +274,26 @@ export class ParticlePool {
|
|
|
234
274
|
for (let i = 0; i < l; i++) {
|
|
235
275
|
|
|
236
276
|
/**
|
|
237
|
-
* @type {
|
|
277
|
+
* @type {AttributeSpec}
|
|
238
278
|
*/
|
|
239
279
|
const attributeSpec = spec_attributes[i];
|
|
240
280
|
|
|
241
|
-
const itemSize =
|
|
242
|
-
const TypedArrayConstructor =
|
|
281
|
+
const itemSize = attributeSpec.itemSize;
|
|
282
|
+
const TypedArrayConstructor = compute_typed_array_constructor_from_data_type(attributeSpec.type);
|
|
243
283
|
|
|
244
284
|
const newArrayLength = itemSize * this.capacity;
|
|
245
285
|
const newArray = new TypedArrayConstructor(newArrayLength);
|
|
246
286
|
|
|
247
|
-
const
|
|
248
|
-
|
|
287
|
+
const old_attribute = this.attributes[i];
|
|
288
|
+
|
|
289
|
+
if (old_attribute !== undefined && old_attribute.count !== 0) {
|
|
249
290
|
//copy old data
|
|
250
|
-
typed_array_copy(
|
|
291
|
+
typed_array_copy(old_attribute.array, newArray);
|
|
251
292
|
}
|
|
252
293
|
|
|
253
|
-
const newAttribute = new BufferAttribute(newArray, itemSize);
|
|
294
|
+
const newAttribute = new BufferAttribute(newArray, itemSize, attributeSpec.normalized);
|
|
254
295
|
|
|
255
|
-
newAttribute.setUsage(
|
|
296
|
+
newAttribute.setUsage(StreamDrawUsage);
|
|
256
297
|
newAttribute.name = attributeSpec.name;
|
|
257
298
|
|
|
258
299
|
this.attributes[i] = newAttribute;
|
|
@@ -466,6 +507,92 @@ export class ParticlePool {
|
|
|
466
507
|
array[address + 3] = w;
|
|
467
508
|
}
|
|
468
509
|
|
|
510
|
+
/**
|
|
511
|
+
* Write the same attribute value for every particle.
|
|
512
|
+
* Assumes particles are packed (no holes).
|
|
513
|
+
* @param {number} attribute_index
|
|
514
|
+
* @param {number[]|Float32Array|Uint8Array|Uint16Array|Int8Array|Int32Array} value
|
|
515
|
+
*/
|
|
516
|
+
writeAttributeForAllArray(attribute_index, value) {
|
|
517
|
+
const attribute = this.attributes[attribute_index];
|
|
518
|
+
|
|
519
|
+
const itemSize = attribute.itemSize;
|
|
520
|
+
|
|
521
|
+
if (value.length < itemSize) {
|
|
522
|
+
throw new Error(`Argument underflow, attribute.itemSize is '${itemSize}', but supplier argument's length is '${value.length}'`);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const n = this.size();
|
|
526
|
+
|
|
527
|
+
const destination = attribute.array;
|
|
528
|
+
|
|
529
|
+
let k;
|
|
530
|
+
for (let i = 0; i < n; i++) {
|
|
531
|
+
const offset = i * itemSize;
|
|
532
|
+
|
|
533
|
+
for (k = 0; k < itemSize; k++) {
|
|
534
|
+
destination[offset + k] = value[k];
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// mark for update
|
|
539
|
+
attribute.needsUpdate = true;
|
|
540
|
+
attribute.updateRange.count = n;
|
|
541
|
+
attribute.updateRange.offset = 0;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
*
|
|
546
|
+
* @param {number} attribute_index
|
|
547
|
+
* @param {number[]} result
|
|
548
|
+
*/
|
|
549
|
+
computeAttributeVector3AxisAlignedBoundingBox(attribute_index, result) {
|
|
550
|
+
const attribute = this.attributes[attribute_index];
|
|
551
|
+
const item_size = attribute.itemSize;
|
|
552
|
+
|
|
553
|
+
if (item_size !== 3) {
|
|
554
|
+
throw new Error(`Attribute item_size is expected to be 3, instead was '${item_size}'`);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
let bounds_x0 = Infinity;
|
|
558
|
+
let bounds_y0 = Infinity;
|
|
559
|
+
let bounds_z0 = Infinity;
|
|
560
|
+
|
|
561
|
+
let bounds_x1 = -Infinity;
|
|
562
|
+
let bounds_y1 = -Infinity;
|
|
563
|
+
let bounds_z1 = -Infinity;
|
|
564
|
+
|
|
565
|
+
const particle_count = this.size();
|
|
566
|
+
|
|
567
|
+
const data = attribute.array;
|
|
568
|
+
|
|
569
|
+
for (let i = 0; i < particle_count; i++) {
|
|
570
|
+
const particle_address = i * 3;
|
|
571
|
+
|
|
572
|
+
const x = data[particle_address];
|
|
573
|
+
const y = data[particle_address + 1];
|
|
574
|
+
const z = data[particle_address + 2];
|
|
575
|
+
|
|
576
|
+
bounds_x0 = min2(bounds_x0, x);
|
|
577
|
+
bounds_y0 = min2(bounds_y0, y);
|
|
578
|
+
bounds_z0 = min2(bounds_z0, z);
|
|
579
|
+
|
|
580
|
+
bounds_x1 = max2(bounds_x1, x);
|
|
581
|
+
bounds_y1 = max2(bounds_y1, y);
|
|
582
|
+
bounds_z1 = max2(bounds_z1, z);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// read out
|
|
586
|
+
result[0] = bounds_x0;
|
|
587
|
+
result[1] = bounds_y0;
|
|
588
|
+
result[2] = bounds_z0;
|
|
589
|
+
|
|
590
|
+
result[3] = bounds_x1;
|
|
591
|
+
result[4] = bounds_y1;
|
|
592
|
+
result[5] = bounds_z1;
|
|
593
|
+
|
|
594
|
+
}
|
|
595
|
+
|
|
469
596
|
dispose() {
|
|
470
597
|
const bufferGeometry = this.geometry.getValue();
|
|
471
598
|
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { ParticlePool } from "./ParticlePool.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { VertexDataSpec } from "../../../../geometry/VertexDataSpec.js";
|
|
3
|
+
import { DataType } from "../../../../../../core/collection/table/DataType.js";
|
|
4
|
+
import { AttributeSpec } from "../../../../geometry/AttributeSpec.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @returns {ParticlePool}
|
|
9
9
|
*/
|
|
10
10
|
function samplePool() {
|
|
11
|
-
const specification = new
|
|
12
|
-
|
|
13
|
-
specification.add(
|
|
11
|
+
const specification = new VertexDataSpec();
|
|
12
|
+
|
|
13
|
+
specification.add(AttributeSpec.fromJSON({name:'a', type:DataType.Float32, itemSize:1}));
|
|
14
|
+
specification.add(AttributeSpec.fromJSON({name:'b', type:DataType.Float32, itemSize:4}));
|
|
14
15
|
|
|
15
16
|
const pool = new ParticlePool(specification);
|
|
16
17
|
|
|
@@ -184,4 +185,4 @@ test('read/write scalar attribute', () => {
|
|
|
184
185
|
pool.writeAttributeScalar(1, 0, 42);
|
|
185
186
|
|
|
186
187
|
expect(pool.readAttributeScalar(1, 0)).toBe(42);
|
|
187
|
-
});
|
|
188
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EmissionShapeType } from "./EmissionShapeType.js";
|
|
2
|
+
import { randomPointInPoint } from "../../../../../../core/geom/random/randomPointInPoint.js";
|
|
3
|
+
import { EmissionFromType } from "./EmissionFromType.js";
|
|
4
|
+
import { randomPointInSphere } from "../../../../../../core/geom/random/randomPointInSphere.js";
|
|
5
|
+
import { randomPointOnSphere } from "../../../../../../core/geom/random/randomPointOnSphere.js";
|
|
6
|
+
import { randomPointInBox } from "../../../../../../core/geom/random/randomPointInBox.js";
|
|
7
|
+
import { randomPointOnBox } from "../../../../../../core/geom/random/randomPointOnBox.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {EmissionFromType} emissionType
|
|
12
|
+
* @param {EmissionShapeType} emissionShape
|
|
13
|
+
* @returns {function(random: function, result:(number[]|Float32Array|Float64Array), result_offset:number):void}
|
|
14
|
+
*/
|
|
15
|
+
export function computeEmissionFunction(emissionType, emissionShape) {
|
|
16
|
+
if (emissionShape === EmissionShapeType.Point) {
|
|
17
|
+
return randomPointInPoint;
|
|
18
|
+
} else if (emissionShape === EmissionShapeType.Sphere) {
|
|
19
|
+
if (emissionType === EmissionFromType.Volume) {
|
|
20
|
+
return randomPointInSphere;
|
|
21
|
+
} else if (emissionType === EmissionFromType.Shell) {
|
|
22
|
+
return randomPointOnSphere;
|
|
23
|
+
} else {
|
|
24
|
+
throw new TypeError('Unsupported EmissionFrom Type');
|
|
25
|
+
}
|
|
26
|
+
} else if (emissionShape === EmissionShapeType.Box) {
|
|
27
|
+
if (emissionType === EmissionFromType.Volume) {
|
|
28
|
+
return randomPointInBox;
|
|
29
|
+
} else if (emissionType === EmissionFromType.Shell) {
|
|
30
|
+
return randomPointOnBox;
|
|
31
|
+
} else {
|
|
32
|
+
throw new TypeError('Unsupported EmissionFrom Type');
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
throw new TypeError('Unsupported emission shape');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number} index
|
|
4
|
+
* @param {number[]|Float32Array} positionArray
|
|
5
|
+
* @param {Vector3} planeNormal
|
|
6
|
+
* @return {number}
|
|
7
|
+
*/
|
|
8
|
+
export function distance_to_camera(index, positionArray, planeNormal) {
|
|
9
|
+
const address = index * 3;
|
|
10
|
+
|
|
11
|
+
// extract position components of the particle
|
|
12
|
+
const x = positionArray[address];
|
|
13
|
+
const y = positionArray[address + 1];
|
|
14
|
+
const z = positionArray[address + 2];
|
|
15
|
+
|
|
16
|
+
const planeNormalX = planeNormal.x;
|
|
17
|
+
const planeNormalY = planeNormal.y;
|
|
18
|
+
const planeNormalZ = planeNormal.z;
|
|
19
|
+
|
|
20
|
+
// compute dot product
|
|
21
|
+
const dot = x * planeNormalX + y * planeNormalY + z * planeNormalZ;
|
|
22
|
+
|
|
23
|
+
// use dot product instead of the actual distance to save computation. Difference is going to be constant
|
|
24
|
+
return dot;
|
|
25
|
+
}
|
|
@@ -86,10 +86,16 @@ export class ParameterLookupTableSerializationAdapter extends BinaryClassSeriali
|
|
|
86
86
|
|
|
87
87
|
const dataLength = itemCount * value.itemSize;
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Reserve a continuous chunk of memory for faster access
|
|
91
|
+
* @type {ArrayBuffer}
|
|
92
|
+
*/
|
|
93
|
+
const array_buffer = new ArrayBuffer((dataLength + itemCount) * 4);
|
|
94
|
+
|
|
95
|
+
const data = new Float32Array(array_buffer, itemCount * 4, dataLength);
|
|
90
96
|
buffer.readFloat32Array(data, 0, dataLength);
|
|
91
97
|
|
|
92
|
-
const positions = new Float32Array(itemCount);
|
|
98
|
+
const positions = new Float32Array(array_buffer, 0, itemCount);
|
|
93
99
|
buffer.readFloat32Array(positions, 0, itemCount);
|
|
94
100
|
|
|
95
101
|
value.write(data, positions);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { inverseLerp } from "../../../../../../core/math/inverseLerp.js";
|
|
2
|
-
import { computeHashFloatArray, computeHashIntegerArray } from "../../../../../../core/math/MathUtils.js";
|
|
3
2
|
import { assert } from "../../../../../../core/assert.js";
|
|
4
3
|
import { max2 } from "../../../../../../core/math/max2.js";
|
|
5
4
|
import { min2 } from "../../../../../../core/math/min2.js";
|
|
6
5
|
import { mix } from "../../../../../../core/math/mix.js";
|
|
7
6
|
import { ParameterLookupTableFlags } from "./ParameterLookupTableFlags.js";
|
|
8
7
|
import { ParameterLookupTableSerializationAdapter } from "../emitter/serde/ParameterLookupTableSerializationAdapter.js";
|
|
8
|
+
import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
|
|
9
|
+
import { computeHashFloatArray } from "../../../../../../core/math/hash/computeHashFloatArray.js";
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
export class ParameterLookupTable {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* @constructor
|
|
6
6
|
*/
|
|
7
7
|
import { ParameterLookupTable } from "./ParameterLookupTable.js";
|
|
8
|
-
import { computeHashIntegerArray } from "../../../../../../core/math/MathUtils.js";
|
|
9
8
|
import { computeStringHash } from "../../../../../../core/primitives/strings/computeStringHash.js";
|
|
9
|
+
import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
|
|
10
10
|
|
|
11
11
|
export class ParameterTrack {
|
|
12
12
|
constructor(name, lut) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { computeHashIntegerArray} from "../../../../../../core/math/MathUtils.js";
|
|
2
1
|
import { assert } from "../../../../../../core/assert.js";
|
|
3
2
|
import { max2 } from "../../../../../../core/math/max2.js";
|
|
4
3
|
import { min2 } from "../../../../../../core/math/min2.js";
|
|
5
4
|
import { ParameterLookupTable } from "./ParameterLookupTable.js";
|
|
6
5
|
import List from "../../../../../../core/collection/list/List.js";
|
|
7
6
|
import { computeStringHash } from "../../../../../../core/primitives/strings/computeStringHash.js";
|
|
7
|
+
import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
export class ParticleParameter {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { VertexDataSpec } from "../../../../../geometry/VertexDataSpec.js";
|
|
2
|
+
import { AttributeSpec } from "../../../../../geometry/AttributeSpec.js";
|
|
3
|
+
import { DataType } from "../../../../../../../core/collection/table/DataType.js";
|
|
4
|
+
|
|
5
|
+
export const BILLBOARD_PARTICLE_ATTRIBUTE_POSITION = 0;
|
|
6
|
+
export const BILLBOARD_PARTICLE_ATTRIBUTE_UV = 1;
|
|
7
|
+
export const BILLBOARD_PARTICLE_ATTRIBUTE_SIZE = 2;
|
|
8
|
+
export const BILLBOARD_PARTICLE_ATTRIBUTE_VELOCITY = 3;
|
|
9
|
+
export const BILLBOARD_PARTICLE_ATTRIBUTE_COLOR = 5;
|
|
10
|
+
export const BILLBOARD_PARTICLE_ATTRIBUTE_BLEND = 6;
|
|
11
|
+
|
|
12
|
+
export const BILLBOARD_PARTICLE_SPECIFICATION = new VertexDataSpec();
|
|
13
|
+
|
|
14
|
+
BILLBOARD_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({ name: 'position', itemSize: 3, type: DataType.Float32 }));
|
|
15
|
+
BILLBOARD_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
16
|
+
name: 'atlasPatch',
|
|
17
|
+
itemSize: 4,
|
|
18
|
+
type: DataType.Float32
|
|
19
|
+
}));
|
|
20
|
+
BILLBOARD_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({ name: 'size', itemSize: 1, type: DataType.Float32 }));
|
|
21
|
+
BILLBOARD_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({ name: 'velocity', itemSize: 3, type: DataType.Float32 }));
|
|
22
|
+
BILLBOARD_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({ name: 'rotation', itemSize: 1, type: DataType.Float32 }));
|
|
23
|
+
BILLBOARD_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({ name: 'color', itemSize: 1, type: DataType.Float32 }));
|
|
24
|
+
BILLBOARD_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({ name: 'blending', itemSize: 1, type: DataType.Uint8 }));
|