@woosh/meep-engine 2.33.23 → 2.33.27
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/binary/BitSet.js +151 -167
- package/core/binary/BitSet.spec.js +99 -1
- package/core/binary/ValidatingBitSetWrapper.js +81 -0
- package/core/bvh2/BinaryNode.js +1 -1
- package/core/bvh2/aabb3/AABB3.js +21 -10
- 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 +22 -5
- package/core/cache/Cache.d.ts +4 -2
- package/core/cache/Cache.js +5 -2
- package/core/collection/ArrayUtils.js +1 -1
- package/core/collection/HashMap.d.ts +9 -2
- package/core/collection/HashSet.d.ts +7 -2
- package/core/collection/HashSet.js +7 -2
- 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/array/typed/typed_array_copy.js +1 -1
- 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/array_setFromProjectionMatrix.js +3 -3
- package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
- 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/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/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/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/parser/simple/Token.d.ts +13 -0
- package/core/parser/simple/Token.js +61 -27
- 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/tools/FoliagePaintTool.js +4 -4
- 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 +62 -1
- package/engine/asset/loaders/image/ImageDecoderWorker.js +4 -3
- package/engine/asset/loaders/image/ImageRGBADataAsset.js +10 -2
- package/engine/asset/loaders/image/ImageRGBADataLoader.js +3 -3
- package/engine/asset/loaders/image/codec/NativeImageDecoder.js +2 -1
- package/engine/asset/loaders/image/png/PNG.js +113 -6
- package/engine/asset/loaders/image/png/PNGReader.js +5 -0
- package/engine/asset/loaders/material/bitmap2sampler_gl.js +1 -1
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +6 -1
- package/engine/asset/loaders/material/computeMaterialHash.js +3 -1
- package/engine/asset/loaders/material/computeTextureEquality.js +40 -49
- package/engine/asset/loaders/material/computeTextureHash.js +2 -1
- package/engine/ecs/EntityBuilder.js +25 -5
- package/engine/ecs/EntityComponentDataset.js +1 -1
- 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/InstancedFoliage.js +277 -266
- package/engine/ecs/foliage/ecs/Foliage2System.js +7 -7
- package/engine/ecs/foliage/ecs/InstancedMeshComponent.js +37 -0
- package/engine/ecs/foliage/ecs/{Foliage2.js → InstancedMeshLayer.js} +3 -45
- package/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +6 -5
- package/engine/ecs/foliage/ecs/InstancedMeshUtils.js +7 -6
- 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/storage/binary/BinarySerializationRegistry.js +1 -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/ecs/layers/TerrainLayer.js +12 -16
- 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/graphics/GraphicsEngine.js +11 -6
- 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/geometry/AttributeSpec.js +105 -0
- package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +14 -72
- package/engine/graphics/geometry/instancing/rewriteMaterial.js +70 -0
- package/engine/graphics/material/manager/MaterialManager.js +2 -1
- 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 +11 -9
- package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +0 -2
- 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 +8 -2
- package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +80 -16
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +71 -77
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +2 -1
- 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 +1 -1
- 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 +81 -48
- 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 +938 -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/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +16 -11
- 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 +117 -94
- 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/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/FPlusDebugMaterial.js +3 -3
- package/engine/graphics/render/forward_plus/materials/ForwardPlusThreeMaterial.js +1 -1
- 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 +594 -59
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +208 -89
- 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 +74 -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/visibility/IncrementalDeltaSet.js +11 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
- package/engine/graphics/shaders/TerrainShader.js +4 -5
- package/engine/graphics/shadows/ShadowMapRenderer.js +8 -2
- package/engine/graphics/texture/atlas/ManagedTextureAtlas.js +12 -1
- 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 +3 -1
- package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +1 -1
- package/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js +66 -0
- package/engine/graphics/texture/sampler/distanceField.spec.js +1 -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 +1 -1
- 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/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 +1 -1
- package/misc/makeMaterialIconCached.js +2 -2
- package/package.json +1 -1
- 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/MinimapWorldGL.js +12 -5
- 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 -357
|
@@ -14,7 +14,6 @@ import { ParticleLayer } from "./ParticleLayer.js";
|
|
|
14
14
|
import { ParticleParameters } from "./ParticleParameters.js";
|
|
15
15
|
import { BlendingType } from "../../../../texture/sampler/BlendingType.js";
|
|
16
16
|
import Quaternion from "../../../../../../core/geom/Quaternion.js";
|
|
17
|
-
import { computeHashIntegerArray } from "../../../../../../core/math/MathUtils.js";
|
|
18
17
|
import { ParticleEmitterFlag } from "./ParticleEmitterFlag.js";
|
|
19
18
|
import { AABB3 } from "../../../../../../core/bvh2/aabb3/AABB3.js";
|
|
20
19
|
import {
|
|
@@ -35,6 +34,7 @@ import { update_parameters } from "../simulator/update_parameters.js";
|
|
|
35
34
|
import { distance_to_camera } from "./distance_to_camera.js";
|
|
36
35
|
import { computeEmissionFunction } from "./computeEmissionFunction.js";
|
|
37
36
|
import { PARTICULAR_PARTICLE_SPECIFICATION } from "./PARTICULAR_PARTICLE_SPECIFICATION.js";
|
|
37
|
+
import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
|
|
38
38
|
|
|
39
39
|
const EMPTY_GEOMETRY = new BufferGeometry();
|
|
40
40
|
|
|
@@ -59,6 +59,12 @@ const corners = new Float64Array(24);
|
|
|
59
59
|
*/
|
|
60
60
|
const scratch_array = [];
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @type {number[]}
|
|
65
|
+
*/
|
|
66
|
+
const scratch_v3_array = [];
|
|
67
|
+
|
|
62
68
|
/**
|
|
63
69
|
*
|
|
64
70
|
* @param {ParameterSet} parameters
|
|
@@ -74,6 +80,35 @@ function generateStandardParameterSet(parameters) {
|
|
|
74
80
|
parameters.add(pColor);
|
|
75
81
|
}
|
|
76
82
|
|
|
83
|
+
|
|
84
|
+
const uint16_mul = 65536;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @param {AtlasPatch} atlasPatch
|
|
89
|
+
* @param {ParticlePool} particles
|
|
90
|
+
* @param {number} ref
|
|
91
|
+
*/
|
|
92
|
+
function write_particle_patch_uv(atlasPatch, particles, ref) {
|
|
93
|
+
const uv = atlasPatch.uv;
|
|
94
|
+
|
|
95
|
+
const uv_position = uv.position;
|
|
96
|
+
|
|
97
|
+
const u0 = uv_position.x;
|
|
98
|
+
const v0 = uv_position.y;
|
|
99
|
+
|
|
100
|
+
const uv_size = uv.size;
|
|
101
|
+
|
|
102
|
+
const u1 = uv_size.x;
|
|
103
|
+
const v1 = uv_size.y;
|
|
104
|
+
|
|
105
|
+
particles.writeAttributeVector4(
|
|
106
|
+
ref,
|
|
107
|
+
PARTICLE_ATTRIBUTE_UV,
|
|
108
|
+
u0 * uint16_mul, v0 * uint16_mul, u1 * uint16_mul, v1 * uint16_mul
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
77
112
|
export class ParticleEmitter {
|
|
78
113
|
constructor() {
|
|
79
114
|
/**
|
|
@@ -236,6 +271,8 @@ export class ParticleEmitter {
|
|
|
236
271
|
readDepth: !this.getFlag(ParticleEmitterFlag.DepthReadDisabled),
|
|
237
272
|
softDepth: !this.getFlag(ParticleEmitterFlag.DepthSoftDisabled),
|
|
238
273
|
velocityAlign: this.getFlag(ParticleEmitterFlag.AlignOnVelocity),
|
|
274
|
+
depthSort: this.getFlag(ParticleEmitterFlag.DepthSorting),
|
|
275
|
+
receiveLight: this.getFlag(ParticleEmitterFlag.Lit),
|
|
239
276
|
blendingMode: this.blendingMode,
|
|
240
277
|
layers: this.layers.toJSON()
|
|
241
278
|
};
|
|
@@ -288,6 +325,18 @@ export class ParticleEmitter {
|
|
|
288
325
|
this.writeFlag(ParticleEmitterFlag.AlignOnVelocity, false);
|
|
289
326
|
}
|
|
290
327
|
|
|
328
|
+
if (typeof json.depthSort === "boolean") {
|
|
329
|
+
this.writeFlag(ParticleEmitterFlag.DepthSorting, json.depthSort);
|
|
330
|
+
} else {
|
|
331
|
+
this.writeFlag(ParticleEmitterFlag.DepthSorting, true);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (typeof json.receiveLight === "boolean") {
|
|
335
|
+
this.writeFlag(ParticleEmitterFlag.Lit, json.receiveLight);
|
|
336
|
+
} else {
|
|
337
|
+
this.clearFlag(ParticleEmitterFlag.Lit);
|
|
338
|
+
}
|
|
339
|
+
|
|
291
340
|
this.layers.fromJSON(json.layers, ParticleLayer);
|
|
292
341
|
|
|
293
342
|
this.writeFlag(ParticleEmitterFlag.Built, false);
|
|
@@ -343,8 +392,6 @@ export class ParticleEmitter {
|
|
|
343
392
|
throw new Error('Layer not found');
|
|
344
393
|
}
|
|
345
394
|
|
|
346
|
-
const numLayers = layers.length;
|
|
347
|
-
|
|
348
395
|
const particles = this.particles;
|
|
349
396
|
const occupancy = particles.occupancy;
|
|
350
397
|
|
|
@@ -358,9 +405,7 @@ export class ParticleEmitter {
|
|
|
358
405
|
|
|
359
406
|
const layerPosition = particles.readAttributeScalar(i, PARTICLE_ATTRIBUTE_LAYER_POSITION);
|
|
360
407
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (layerIndex !== targetLayerIndex) {
|
|
408
|
+
if (layerPosition !== targetLayerIndex) {
|
|
364
409
|
// not the layer we want
|
|
365
410
|
continue;
|
|
366
411
|
}
|
|
@@ -446,33 +491,15 @@ export class ParticleEmitter {
|
|
|
446
491
|
//retire dead particles
|
|
447
492
|
const particles = this.particles;
|
|
448
493
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
let bounds_x0 = Infinity;
|
|
452
|
-
let bounds_y0 = Infinity;
|
|
453
|
-
let bounds_z0 = Infinity;
|
|
454
|
-
|
|
455
|
-
let bounds_x1 = -Infinity;
|
|
456
|
-
let bounds_y1 = -Infinity;
|
|
457
|
-
let bounds_z1 = -Infinity;
|
|
458
|
-
|
|
459
|
-
for (let i = 0; i < liveParticleCount; i++) {
|
|
494
|
+
particles.computeAttributeVector3AxisAlignedBoundingBox(PARTICLE_ATTRIBUTE_POSITION, scratch_array);
|
|
460
495
|
|
|
461
|
-
|
|
496
|
+
let bounds_x0 = scratch_array[0];
|
|
497
|
+
let bounds_y0 = scratch_array[1];
|
|
498
|
+
let bounds_z0 = scratch_array[2];
|
|
462
499
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
//update bounds
|
|
468
|
-
bounds_x0 = min2(bounds_x0, p_x);
|
|
469
|
-
bounds_y0 = min2(bounds_y0, p_y);
|
|
470
|
-
bounds_z0 = min2(bounds_z0, p_z);
|
|
471
|
-
|
|
472
|
-
bounds_x1 = max2(bounds_x1, p_x);
|
|
473
|
-
bounds_y1 = max2(bounds_y1, p_y);
|
|
474
|
-
bounds_z1 = max2(bounds_z1, p_z);
|
|
475
|
-
}
|
|
500
|
+
let bounds_x1 = scratch_array[3];
|
|
501
|
+
let bounds_y1 = scratch_array[4];
|
|
502
|
+
let bounds_z1 = scratch_array[5];
|
|
476
503
|
|
|
477
504
|
//expand bounds by maximum sprite size
|
|
478
505
|
const extents = this.computeSpriteMaxHalfSize();
|
|
@@ -837,29 +864,19 @@ export class ParticleEmitter {
|
|
|
837
864
|
|
|
838
865
|
const layers = this.layers;
|
|
839
866
|
|
|
840
|
-
const numLayers = layers.length;
|
|
841
|
-
|
|
842
867
|
let missingFlag = false;
|
|
843
868
|
|
|
844
869
|
//cycle through each particle
|
|
845
870
|
for (let i = occupancy.nextSetBit(0); i !== -1; i = occupancy.nextSetBit(i + 1)) {
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
const layerIndex = Math.round(layerPosition * numLayers);
|
|
871
|
+
const layerIndex = particles.readAttributeScalar(i, PARTICLE_ATTRIBUTE_LAYER_POSITION);
|
|
849
872
|
|
|
850
873
|
const layer = layers.get(layerIndex);
|
|
851
874
|
|
|
852
875
|
const atlasPatch = layer.__atlasPatch;
|
|
853
876
|
|
|
854
877
|
if (atlasPatch !== null) {
|
|
855
|
-
const uv = atlasPatch.uv;
|
|
856
|
-
|
|
857
|
-
const u0 = uv.position.x;
|
|
858
|
-
const v0 = uv.position.y;
|
|
859
|
-
const u1 = uv.size.x;
|
|
860
|
-
const v1 = uv.size.y;
|
|
861
878
|
|
|
862
|
-
|
|
879
|
+
write_particle_patch_uv(atlasPatch, particles, i);
|
|
863
880
|
} else {
|
|
864
881
|
missingFlag = true;
|
|
865
882
|
}
|
|
@@ -891,8 +908,6 @@ export class ParticleEmitter {
|
|
|
891
908
|
|
|
892
909
|
const emissionPeriod = 1 / layer.emissionRate;
|
|
893
910
|
|
|
894
|
-
const layerPosition = layerIndex / this.layers.length;
|
|
895
|
-
|
|
896
911
|
//compute transform matrix of the emitter
|
|
897
912
|
const emitter_position = this.position;
|
|
898
913
|
const last_spawn_position = this.__lastSpawnPosition;
|
|
@@ -910,7 +925,9 @@ export class ParticleEmitter {
|
|
|
910
925
|
const f = time / timeDelta;
|
|
911
926
|
|
|
912
927
|
//compute position for particle
|
|
913
|
-
emissionFunction(random,
|
|
928
|
+
emissionFunction(random, scratch_v3_array, 0);
|
|
929
|
+
|
|
930
|
+
v3position.readFromArray(scratch_v3_array, 0);
|
|
914
931
|
|
|
915
932
|
//apply layer transform
|
|
916
933
|
v3position.multiply(layer.scale);
|
|
@@ -969,24 +986,13 @@ export class ParticleEmitter {
|
|
|
969
986
|
//write UV
|
|
970
987
|
const atlasPatch = layer.__atlasPatch;
|
|
971
988
|
if (atlasPatch !== null) {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
const uv_position = uv.position;
|
|
975
|
-
|
|
976
|
-
const u0 = uv_position.x;
|
|
977
|
-
const v0 = uv_position.y;
|
|
978
|
-
|
|
979
|
-
const uv_size = uv.size;
|
|
980
|
-
|
|
981
|
-
const u1 = uv_size.x;
|
|
982
|
-
const v1 = uv_size.y;
|
|
983
|
-
|
|
984
|
-
particles.writeAttributeVector4(ref, PARTICLE_ATTRIBUTE_UV, u0, v0, u1, v1);
|
|
989
|
+
//patch exists, write it
|
|
990
|
+
write_particle_patch_uv(atlasPatch, particles, ref);
|
|
985
991
|
} else {
|
|
986
992
|
this.setFlag(ParticleEmitterFlag.SpritesNeedUpdate);
|
|
987
993
|
}
|
|
988
994
|
|
|
989
|
-
particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION,
|
|
995
|
+
particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION, layerIndex);
|
|
990
996
|
|
|
991
997
|
update_parameters(ref, particles, layer, initialAge / deathAge);
|
|
992
998
|
|
|
@@ -1025,8 +1031,6 @@ export class ParticleEmitter {
|
|
|
1025
1031
|
|
|
1026
1032
|
const emissionFunction = computeEmissionFunction(layer.emissionFrom, layer.emissionShape);
|
|
1027
1033
|
|
|
1028
|
-
const layerPosition = layerIndex / layers.length;
|
|
1029
|
-
|
|
1030
1034
|
//compute transform matrix of the emitter
|
|
1031
1035
|
composeMatrix4(matrix4, this.position, this.rotation, this.scale);
|
|
1032
1036
|
|
|
@@ -1039,7 +1043,9 @@ export class ParticleEmitter {
|
|
|
1039
1043
|
const ref = particles.create();
|
|
1040
1044
|
|
|
1041
1045
|
//compute position for particle
|
|
1042
|
-
emissionFunction(random,
|
|
1046
|
+
emissionFunction(random, scratch_v3_array, 0);
|
|
1047
|
+
|
|
1048
|
+
v3position.readFromArray(scratch_v3_array, 0);
|
|
1043
1049
|
|
|
1044
1050
|
//apply layer transform
|
|
1045
1051
|
v3position.multiply(layer.scale);
|
|
@@ -1097,25 +1103,13 @@ export class ParticleEmitter {
|
|
|
1097
1103
|
|
|
1098
1104
|
if (atlasPatch !== null) {
|
|
1099
1105
|
//patch exists, write it
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
const uv_position = uv.position;
|
|
1103
|
-
|
|
1104
|
-
const u0 = uv_position.x;
|
|
1105
|
-
const v0 = uv_position.y;
|
|
1106
|
-
|
|
1107
|
-
const uv_size = uv.size;
|
|
1108
|
-
|
|
1109
|
-
const u1 = uv_size.x;
|
|
1110
|
-
const v1 = uv_size.y;
|
|
1111
|
-
|
|
1112
|
-
particles.writeAttributeVector4(ref, PARTICLE_ATTRIBUTE_UV, u0, v0, u1, v1);
|
|
1106
|
+
write_particle_patch_uv(atlasPatch, particles, ref);
|
|
1113
1107
|
} else {
|
|
1114
1108
|
//patch is not loaded yet, request update
|
|
1115
1109
|
spritesNeedUpdate = true;
|
|
1116
1110
|
}
|
|
1117
1111
|
|
|
1118
|
-
particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION,
|
|
1112
|
+
particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION, layerIndex);
|
|
1119
1113
|
|
|
1120
1114
|
update_parameters(ref, particles, layer, initialAge / deathAge);
|
|
1121
1115
|
|
|
@@ -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
|
/**
|
|
@@ -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
|
+
});
|
|
@@ -10,7 +10,7 @@ import { randomPointOnBox } from "../../../../../../core/geom/random/randomPoint
|
|
|
10
10
|
*
|
|
11
11
|
* @param {EmissionFromType} emissionType
|
|
12
12
|
* @param {EmissionShapeType} emissionShape
|
|
13
|
-
* @returns {function(random: function, result:
|
|
13
|
+
* @returns {function(random: function, result:(number[]|Float32Array|Float64Array), result_offset:number):void}
|
|
14
14
|
*/
|
|
15
15
|
export function computeEmissionFunction(emissionType, emissionShape) {
|
|
16
16
|
if (emissionShape === EmissionShapeType.Point) {
|
|
@@ -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 }));
|