@woosh/meep-engine 2.33.20 → 2.33.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/__detailed_box_volume_intersection.js +11 -8
- package/core/collection/ArrayUtils.js +1 -1
- package/core/collection/HashMap.js +66 -22
- package/core/collection/array/arrayQuickSort.js +9 -6
- package/core/collection/array/array_swap.js +22 -0
- package/core/collection/array/computeHashArray.js +22 -0
- package/core/collection/array/computeHashIntegerArray.js +15 -0
- 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/CircleMath.js +4 -4
- package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
- package/core/geom/3d/cone/computeConeBoundingBox.js +4 -4
- package/core/geom/3d/{compute_bounding_cone_of_2_cones.js → cone/compute_bounding_cone_of_2_cones.js} +3 -3
- package/core/geom/3d/{compute_bounding_cone_of_2_cones.spec.js → cone/compute_bounding_cone_of_2_cones.spec.js} +1 -1
- package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +1 -1
- package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +11 -3
- 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/{encode_unit3_hemioct.js → normal/hemioct/encode_unit3_hemioct.js} +0 -0
- package/core/geom/3d/{unit_hemioct.spec.js → normal/hemioct/unit_hemioct.spec.js} +1 -1
- package/core/geom/3d/normal/lamber_azimuth/transform.js +61 -0
- package/core/geom/3d/normal/spherical/sphere_map_transform.js +77 -0
- package/core/geom/3d/{lerp_planes_to_array.js → plane/lerp_planes_to_array.js} +1 -3
- package/core/geom/3d/plane/plane3_lerp.js +3 -1
- package/core/geom/3d/plane/plane3_slerp.js +4 -1
- package/core/geom/3d/{plane_computeConvex3PlaneIntersection.js → plane/plane_computeConvex3PlaneIntersection.js} +14 -16
- package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
- package/core/geom/3d/shape/AbstractShape3D.js +29 -0
- package/core/geom/3d/shape/CompositeShape.js +60 -0
- package/core/geom/3d/shape/TransformedShape3D.js +70 -0
- package/core/geom/3d/shape/UnitCubeShape3D.js +13 -0
- package/core/geom/3d/shape/UnitSphereShape3D.js +16 -0
- package/core/geom/3d/topology/TopoTriangle.js +1 -1
- package/core/geom/3d/topology/TopoVertex.js +1 -1
- package/core/geom/3d/topology/bounds/computeTraingleClusterNormalBoundingCone.js +2 -2
- package/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +1 -1
- package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +1 -1
- package/core/geom/3d/triangle/computeTrianglePlaneSide.js +1 -1
- package/core/geom/3d/triangle/computeTriangleRayIntersection.js +1 -1
- 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 +1 -77
- package/core/geom/Matrix4.js +8 -8
- package/core/geom/Plane.js +15 -10
- package/core/geom/Quaternion.js +2 -1
- package/core/geom/Rectangle.js +2 -1
- package/core/geom/Vector1.js +1 -1
- package/core/geom/Vector3.d.ts +2 -0
- package/core/geom/Vector3.js +35 -159
- package/core/geom/Vector3.spec.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 +6 -3
- package/core/geom/random/randomPointOnBox.js +7 -3
- package/core/geom/random/randomPointOnSphere.js +6 -3
- package/core/geom/v3_angle_between.js +31 -0
- package/core/geom/v3_distance.js +16 -0
- package/core/geom/v3_distance_sqr.js +17 -0
- package/core/geom/v3_dot.js +13 -0
- package/core/geom/v3_length.js +10 -0
- package/core/geom/v3_length_sqr.js +10 -0
- package/core/geom/v3_lerp.js +21 -0
- package/core/geom/v3_slerp.js +48 -0
- package/core/graph/graph_k_means_cluster.js +1 -1
- 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 +6 -1
- 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 +4 -3
- package/engine/asset/loaders/material/computeTextureEquality.js +13 -5
- package/engine/asset/loaders/material/computeTextureHash.js +2 -1
- package/engine/ecs/animation/Animation.js +2 -1
- package/engine/ecs/animation/InverseKinematics.js +2 -1
- package/engine/ecs/animation/OneBoneSurfaceAlignmentSolver.js +3 -1
- package/engine/ecs/animation/TwoBoneInverseKinematicsSolver.js +3 -1
- 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 +2 -3
- 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 +1 -1
- package/engine/ecs/gui/position/ViewportPosition.js +2 -1
- package/engine/ecs/systems/RangedAttackSystem.js +1 -1
- package/engine/ecs/systems/SteeringSystem.js +3 -2
- package/engine/ecs/terrain/ecs/Terrain.js +6 -0
- package/engine/ecs/terrain/ecs/layers/TerrainLayers.js +5 -0
- package/engine/ecs/terrain/ecs/splat/SplatMapping.js +5 -0
- package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
- package/engine/ecs/tooltip/TooltipComponent.js +15 -0
- package/engine/ecs/util/hideEntityGracefully.js +18 -0
- package/engine/graphics/GraphicsEngine.js +1 -0
- package/engine/graphics/camera/testClippingPlaneComputation.js +2 -2
- 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 +2 -2
- package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
- package/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +0 -53
- package/engine/graphics/ecs/light/Light.d.ts +1 -1
- package/engine/graphics/ecs/light/Light.js +3 -0
- package/engine/graphics/ecs/mesh/Mesh.js +2 -1
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
- 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/geometry/bvh/buffered/BVHGeometryRaycaster.js +2 -1
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
- package/engine/graphics/micron/build/clustering/computeFaceCurvatureScore.js +1 -1
- package/engine/graphics/micron/build/clustering/compute_face_connection_weight.js +1 -1
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
- package/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +1 -1
- package/engine/graphics/micron/build/hierarchy/patch_combine.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/refinement/is_patch_facing_back.js +2 -2
- package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +4 -2
- package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +84 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +92 -144
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +14 -3
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +51 -12
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +3 -2
- 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 +21 -0
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +0 -20
- package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +7 -25
- 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/ParticleVolume.js +384 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +558 -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 +1 -1
- 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 +15 -33
- package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
- package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +12 -2
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +6 -6
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +231 -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 +8 -5
- package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -2
- package/engine/graphics/texture/atlas/AtlasPatch.js +7 -2
- package/engine/graphics/texture/atlas/TextureAtlas.js +18 -14
- 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/projectSphere.js +1 -1
- package/engine/grid/components/GridObstacle.js +3 -10
- package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
- package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
- package/engine/navigation/ecs/components/Path.js +3 -2
- 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/CellFilterAngleToNormal.js +3 -2
- package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +1 -1
- package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
- package/generation/markers/GridCellActionPlaceMarker.js +13 -1
- package/generation/markers/MarkerNode.js +6 -0
- 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 +5 -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 +19 -101
- 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
|
@@ -53,18 +53,18 @@ function normalized_internal_format(dt, channel_count) {
|
|
|
53
53
|
export class AttributeDataTexture {
|
|
54
54
|
/**
|
|
55
55
|
*
|
|
56
|
-
* @param {
|
|
56
|
+
* @param {AttributeSpec} spec
|
|
57
57
|
* @param {number} column_count
|
|
58
58
|
*/
|
|
59
59
|
constructor(spec, column_count) {
|
|
60
60
|
assert.defined(spec, 'spec');
|
|
61
|
-
assert.equal(spec.
|
|
61
|
+
assert.equal(spec.isAttributeSpec, true, 'spec.isAttributeSpec !== true');
|
|
62
62
|
|
|
63
63
|
assert.isNonNegativeInteger(column_count, 'column_count');
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
*
|
|
67
|
-
* @type {
|
|
67
|
+
* @type {AttributeSpec}
|
|
68
68
|
* @private
|
|
69
69
|
*/
|
|
70
70
|
this.__spec = spec;
|
|
@@ -90,7 +90,7 @@ export class AttributeDataTexture {
|
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
*
|
|
93
|
-
* @return {
|
|
93
|
+
* @return {AttributeSpec}
|
|
94
94
|
*/
|
|
95
95
|
get spec() {
|
|
96
96
|
return this.__spec;
|
|
@@ -320,7 +320,7 @@ export class AttributeDataTexture {
|
|
|
320
320
|
/**
|
|
321
321
|
*
|
|
322
322
|
* @return {AttributeDataTexture}
|
|
323
|
-
* @param {
|
|
323
|
+
* @param {AttributeSpec} spec
|
|
324
324
|
* @param {number} column_count
|
|
325
325
|
*/
|
|
326
326
|
static from(spec, column_count) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PI_HALF } from "../../../../../core/math/MathUtils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { v3_angle_between } from "../../../../../core/geom/v3_angle_between.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
@@ -28,7 +28,7 @@ function is_patch_facing_back(refinement_spec, patch) {
|
|
|
28
28
|
// compute view angle of the bounding sphere
|
|
29
29
|
const normal_cone_direction = normal_cone.direction;
|
|
30
30
|
|
|
31
|
-
const angle =
|
|
31
|
+
const angle = v3_angle_between(
|
|
32
32
|
view_direction_x, view_direction_y, view_direction_z,
|
|
33
33
|
normal_cone_direction.x, normal_cone_direction.y, normal_cone_direction.z
|
|
34
34
|
);
|
|
@@ -4,7 +4,7 @@ import { DataType2TypedArrayConstructorMapping } from "../../../../../core/colle
|
|
|
4
4
|
import { getTransformedPositionsCached } from "./getTransformedPositionsCached.js";
|
|
5
5
|
import { Color } from "../../../../../core/color/Color.js";
|
|
6
6
|
import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
|
|
7
|
-
import { randomFloatBetween } from "../../../../../core/math/
|
|
7
|
+
import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
const scratch_random = seededRandom(0);
|
|
@@ -63,10 +63,12 @@ ParticularEngine.prototype.add = function (emitter) {
|
|
|
63
63
|
* @param {ParticleEmitter} emitter
|
|
64
64
|
*/
|
|
65
65
|
ParticularEngine.prototype.remove = function (emitter) {
|
|
66
|
-
const
|
|
66
|
+
const emitters = this.emitters;
|
|
67
|
+
|
|
68
|
+
const i = emitters.indexOf(emitter);
|
|
67
69
|
|
|
68
70
|
if (i !== -1) {
|
|
69
|
-
|
|
71
|
+
emitters.remove(i);
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
this.shaderManager.deregister(emitter);
|
package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
//build particle spec
|
|
6
|
+
export const PARTICULAR_PARTICLE_SPECIFICATION = new VertexDataSpec();
|
|
7
|
+
|
|
8
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
9
|
+
name: 'position',
|
|
10
|
+
itemSize: 3,
|
|
11
|
+
type: DataType.Float32,
|
|
12
|
+
normalized: false
|
|
13
|
+
}));
|
|
14
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
15
|
+
name: 'age',
|
|
16
|
+
itemSize: 1,
|
|
17
|
+
type: DataType.Float32,
|
|
18
|
+
normalized: false
|
|
19
|
+
}));
|
|
20
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
21
|
+
name: 'deathAge',
|
|
22
|
+
itemSize: 1,
|
|
23
|
+
type: DataType.Float32,
|
|
24
|
+
normalized: false
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
28
|
+
name: 'atlasPatch',
|
|
29
|
+
itemSize: 4,
|
|
30
|
+
type: DataType.Uint16,
|
|
31
|
+
normalized: true
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
// TODO convert "size" to scale instead
|
|
35
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
36
|
+
name: 'size',
|
|
37
|
+
itemSize: 1,
|
|
38
|
+
type: DataType.Float32,
|
|
39
|
+
normalized: false
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
43
|
+
name: 'layerPosition',
|
|
44
|
+
itemSize: 1,
|
|
45
|
+
type: DataType.Uint8,
|
|
46
|
+
normalized: false
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
50
|
+
name: 'velocity',
|
|
51
|
+
itemSize: 3,
|
|
52
|
+
type: DataType.Float32,
|
|
53
|
+
normalized: false
|
|
54
|
+
}));
|
|
55
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
56
|
+
name: 'rotation',
|
|
57
|
+
itemSize: 1,
|
|
58
|
+
type: DataType.Float32,
|
|
59
|
+
normalized: false
|
|
60
|
+
}));
|
|
61
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
62
|
+
name: 'rotationSpeed',
|
|
63
|
+
itemSize: 1,
|
|
64
|
+
type: DataType.Float32,
|
|
65
|
+
normalized: false
|
|
66
|
+
}));
|
|
67
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
68
|
+
name: 'color',
|
|
69
|
+
itemSize: 4,
|
|
70
|
+
type: DataType.Uint8,
|
|
71
|
+
normalized: true
|
|
72
|
+
}));
|
|
73
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
74
|
+
name: 'blending',
|
|
75
|
+
itemSize: 1,
|
|
76
|
+
type: DataType.Float32,
|
|
77
|
+
normalized: false
|
|
78
|
+
}));
|
|
79
|
+
PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
|
|
80
|
+
name: 'size_initial',
|
|
81
|
+
itemSize: 1,
|
|
82
|
+
type: DataType.Float32,
|
|
83
|
+
normalized: false
|
|
84
|
+
}));
|
|
@@ -3,7 +3,6 @@ import List from "../../../../../../core/collection/list/List.js";
|
|
|
3
3
|
import { lerp } from "../../../../../../core/math/lerp.js";
|
|
4
4
|
import { max2 } from "../../../../../../core/math/max2.js";
|
|
5
5
|
import { min2 } from "../../../../../../core/math/min2.js";
|
|
6
|
-
import { ParticleAttributeType, ParticleDataType } from "../../group/ParticleGroup.js";
|
|
7
6
|
import { Box3, BufferGeometry, Frustum, Matrix4, Points, PointsMaterial } from 'three';
|
|
8
7
|
import { frustumFromCamera } from "../../../../ecs/camera/CameraSystem.js";
|
|
9
8
|
import { ParticlePool } from "./ParticlePool.js";
|
|
@@ -15,9 +14,6 @@ import { ParticleLayer } from "./ParticleLayer.js";
|
|
|
15
14
|
import { ParticleParameters } from "./ParticleParameters.js";
|
|
16
15
|
import { BlendingType } from "../../../../texture/sampler/BlendingType.js";
|
|
17
16
|
import Quaternion from "../../../../../../core/geom/Quaternion.js";
|
|
18
|
-
import { computeHashIntegerArray } from "../../../../../../core/math/MathUtils.js";
|
|
19
|
-
import { ParticleSpecification } from "../../group/ParticleSpecification.js";
|
|
20
|
-
import { ParticleAttribute } from "../../group/ParticleAttribute.js";
|
|
21
17
|
import { ParticleEmitterFlag } from "./ParticleEmitterFlag.js";
|
|
22
18
|
import { AABB3 } from "../../../../../../core/bvh2/aabb3/AABB3.js";
|
|
23
19
|
import {
|
|
@@ -34,14 +30,11 @@ import {
|
|
|
34
30
|
PARTICLE_ATTRIBUTE_VELOCITY
|
|
35
31
|
} from "./PARTICLE_ATTRIBUTES.js";
|
|
36
32
|
import { composeMatrix4 } from "../../../../util/composeMatrix4.js";
|
|
37
|
-
import { randomPointInPoint } from "../../../../../../core/geom/random/randomPointInPoint.js";
|
|
38
|
-
import { randomPointInSphere } from "../../../../../../core/geom/random/randomPointInSphere.js";
|
|
39
|
-
import { randomPointOnSphere } from "../../../../../../core/geom/random/randomPointOnSphere.js";
|
|
40
|
-
import { randomPointInBox } from "../../../../../../core/geom/random/randomPointInBox.js";
|
|
41
|
-
import { randomPointOnBox } from "../../../../../../core/geom/random/randomPointOnBox.js";
|
|
42
|
-
import { EmissionFromType } from "./EmissionFromType.js";
|
|
43
|
-
import { EmissionShapeType } from "./EmissionShapeType.js";
|
|
44
33
|
import { update_parameters } from "../simulator/update_parameters.js";
|
|
34
|
+
import { distance_to_camera } from "./distance_to_camera.js";
|
|
35
|
+
import { computeEmissionFunction } from "./computeEmissionFunction.js";
|
|
36
|
+
import { PARTICULAR_PARTICLE_SPECIFICATION } from "./PARTICULAR_PARTICLE_SPECIFICATION.js";
|
|
37
|
+
import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
|
|
45
38
|
|
|
46
39
|
const EMPTY_GEOMETRY = new BufferGeometry();
|
|
47
40
|
|
|
@@ -68,57 +61,9 @@ const scratch_array = [];
|
|
|
68
61
|
|
|
69
62
|
/**
|
|
70
63
|
*
|
|
71
|
-
* @
|
|
72
|
-
* @param {EmissionShapeType} emissionShape
|
|
73
|
-
* @returns {function(random: function, result:Vector3):void}
|
|
74
|
-
*/
|
|
75
|
-
function computeEmissionFunction(emissionType, emissionShape) {
|
|
76
|
-
if (emissionShape === EmissionShapeType.Point) {
|
|
77
|
-
return randomPointInPoint;
|
|
78
|
-
} else if (emissionShape === EmissionShapeType.Sphere) {
|
|
79
|
-
if (emissionType === EmissionFromType.Volume) {
|
|
80
|
-
return randomPointInSphere;
|
|
81
|
-
} else if (emissionType === EmissionFromType.Shell) {
|
|
82
|
-
return randomPointOnSphere;
|
|
83
|
-
} else {
|
|
84
|
-
throw new TypeError(`Unsupported EmissionFrom Type`);
|
|
85
|
-
}
|
|
86
|
-
} else if (emissionShape === EmissionShapeType.Box) {
|
|
87
|
-
if (emissionType === EmissionFromType.Volume) {
|
|
88
|
-
return randomPointInBox;
|
|
89
|
-
} else if (emissionType === EmissionFromType.Shell) {
|
|
90
|
-
return randomPointOnBox;
|
|
91
|
-
} else {
|
|
92
|
-
throw new TypeError(`Unsupported EmissionFrom Type`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
* @param {number} index
|
|
100
|
-
* @param {number[]|Float32Array} positionArray
|
|
101
|
-
* @param {Vector3} planeNormal
|
|
102
|
-
* @return {number}
|
|
64
|
+
* @type {number[]}
|
|
103
65
|
*/
|
|
104
|
-
|
|
105
|
-
const address = index * 3;
|
|
106
|
-
|
|
107
|
-
// extract position components of the particle
|
|
108
|
-
const x = positionArray[address];
|
|
109
|
-
const y = positionArray[address + 1];
|
|
110
|
-
const z = positionArray[address + 2];
|
|
111
|
-
|
|
112
|
-
const planeNormalX = planeNormal.x;
|
|
113
|
-
const planeNormalY = planeNormal.y;
|
|
114
|
-
const planeNormalZ = planeNormal.z;
|
|
115
|
-
|
|
116
|
-
// compute dot product
|
|
117
|
-
const dot = x * planeNormalX + y * planeNormalY + z * planeNormalZ;
|
|
118
|
-
|
|
119
|
-
// use dot product instead of the actual distance to save computation. Difference is going to be constant
|
|
120
|
-
return dot;
|
|
121
|
-
}
|
|
66
|
+
const scratch_v3_array = [];
|
|
122
67
|
|
|
123
68
|
/**
|
|
124
69
|
*
|
|
@@ -135,6 +80,35 @@ function generateStandardParameterSet(parameters) {
|
|
|
135
80
|
parameters.add(pColor);
|
|
136
81
|
}
|
|
137
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
|
+
|
|
138
112
|
export class ParticleEmitter {
|
|
139
113
|
constructor() {
|
|
140
114
|
/**
|
|
@@ -297,6 +271,7 @@ export class ParticleEmitter {
|
|
|
297
271
|
readDepth: !this.getFlag(ParticleEmitterFlag.DepthReadDisabled),
|
|
298
272
|
softDepth: !this.getFlag(ParticleEmitterFlag.DepthSoftDisabled),
|
|
299
273
|
velocityAlign: this.getFlag(ParticleEmitterFlag.AlignOnVelocity),
|
|
274
|
+
depthSort: this.getFlag(ParticleEmitterFlag.DepthSorting),
|
|
300
275
|
blendingMode: this.blendingMode,
|
|
301
276
|
layers: this.layers.toJSON()
|
|
302
277
|
};
|
|
@@ -349,6 +324,12 @@ export class ParticleEmitter {
|
|
|
349
324
|
this.writeFlag(ParticleEmitterFlag.AlignOnVelocity, false);
|
|
350
325
|
}
|
|
351
326
|
|
|
327
|
+
if (typeof json.depthSort === "boolean") {
|
|
328
|
+
this.writeFlag(ParticleEmitterFlag.DepthSorting, json.depthSort);
|
|
329
|
+
} else {
|
|
330
|
+
this.writeFlag(ParticleEmitterFlag.DepthSorting, true);
|
|
331
|
+
}
|
|
332
|
+
|
|
352
333
|
this.layers.fromJSON(json.layers, ParticleLayer);
|
|
353
334
|
|
|
354
335
|
this.writeFlag(ParticleEmitterFlag.Built, false);
|
|
@@ -404,19 +385,20 @@ export class ParticleEmitter {
|
|
|
404
385
|
throw new Error('Layer not found');
|
|
405
386
|
}
|
|
406
387
|
|
|
407
|
-
const numLayers = layers.length;
|
|
408
|
-
|
|
409
388
|
const particles = this.particles;
|
|
410
389
|
const occupancy = particles.occupancy;
|
|
411
390
|
|
|
412
391
|
let removeCount = 0;
|
|
413
392
|
|
|
414
|
-
for (
|
|
415
|
-
|
|
393
|
+
for (
|
|
394
|
+
let i = occupancy.nextSetBit(0);
|
|
395
|
+
i !== -1;
|
|
396
|
+
i = occupancy.nextSetBit(i + 1)
|
|
397
|
+
) {
|
|
416
398
|
|
|
417
|
-
const
|
|
399
|
+
const layerPosition = particles.readAttributeScalar(i, PARTICLE_ATTRIBUTE_LAYER_POSITION);
|
|
418
400
|
|
|
419
|
-
if (
|
|
401
|
+
if (layerPosition !== targetLayerIndex) {
|
|
420
402
|
// not the layer we want
|
|
421
403
|
continue;
|
|
422
404
|
}
|
|
@@ -425,6 +407,7 @@ export class ParticleEmitter {
|
|
|
425
407
|
occupancy.set(i, false);
|
|
426
408
|
|
|
427
409
|
removeCount++;
|
|
410
|
+
|
|
428
411
|
}
|
|
429
412
|
|
|
430
413
|
if (removeCount > 0) {
|
|
@@ -489,7 +472,10 @@ export class ParticleEmitter {
|
|
|
489
472
|
}
|
|
490
473
|
}
|
|
491
474
|
|
|
492
|
-
this.emisionBounds.setBounds(
|
|
475
|
+
this.emisionBounds.setBounds(
|
|
476
|
+
bounds_x0, bounds_y0, bounds_z0,
|
|
477
|
+
bounds_x1, bounds_y1, bounds_z1
|
|
478
|
+
);
|
|
493
479
|
|
|
494
480
|
this.clearFlag(ParticleEmitterFlag.BaseBoundsNeedUpdate);
|
|
495
481
|
}
|
|
@@ -708,8 +694,8 @@ export class ParticleEmitter {
|
|
|
708
694
|
}
|
|
709
695
|
|
|
710
696
|
computeHash() {
|
|
711
|
-
const
|
|
712
|
-
const
|
|
697
|
+
const parameters_hash = this.parameters.hash();
|
|
698
|
+
const layers_hash = this.layers.hash();
|
|
713
699
|
|
|
714
700
|
/**
|
|
715
701
|
* Extract relevant flags
|
|
@@ -717,7 +703,12 @@ export class ParticleEmitter {
|
|
|
717
703
|
*/
|
|
718
704
|
const flags = this.flags & (SERIALIZABLE_FLAGS);
|
|
719
705
|
|
|
720
|
-
return computeHashIntegerArray(
|
|
706
|
+
return computeHashIntegerArray(
|
|
707
|
+
parameters_hash,
|
|
708
|
+
layers_hash,
|
|
709
|
+
this.blendingMode,
|
|
710
|
+
flags
|
|
711
|
+
);
|
|
721
712
|
}
|
|
722
713
|
|
|
723
714
|
hash() {
|
|
@@ -799,14 +790,19 @@ export class ParticleEmitter {
|
|
|
799
790
|
|
|
800
791
|
const pivotIndex = (left + right) >> 1;
|
|
801
792
|
|
|
802
|
-
const pivot =
|
|
793
|
+
const pivot = distance_to_camera(pivotIndex, positionArray, nearPlaneNormal);
|
|
803
794
|
|
|
804
795
|
/* partition */
|
|
805
796
|
while (i <= j) {
|
|
806
|
-
|
|
797
|
+
|
|
798
|
+
while (distance_to_camera(i, positionArray, nearPlaneNormal) > pivot) {
|
|
807
799
|
i++;
|
|
808
|
-
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
while (distance_to_camera(j, positionArray, nearPlaneNormal) < pivot) {
|
|
809
803
|
j--;
|
|
804
|
+
}
|
|
805
|
+
|
|
810
806
|
if (i <= j) {
|
|
811
807
|
|
|
812
808
|
if (i !== j) {
|
|
@@ -879,29 +875,19 @@ export class ParticleEmitter {
|
|
|
879
875
|
|
|
880
876
|
const layers = this.layers;
|
|
881
877
|
|
|
882
|
-
const numLayers = layers.length;
|
|
883
|
-
|
|
884
878
|
let missingFlag = false;
|
|
885
879
|
|
|
886
880
|
//cycle through each particle
|
|
887
881
|
for (let i = occupancy.nextSetBit(0); i !== -1; i = occupancy.nextSetBit(i + 1)) {
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
const layerIndex = Math.round(layerPosition * numLayers);
|
|
882
|
+
const layerIndex = particles.readAttributeScalar(i, PARTICLE_ATTRIBUTE_LAYER_POSITION);
|
|
891
883
|
|
|
892
884
|
const layer = layers.get(layerIndex);
|
|
893
885
|
|
|
894
886
|
const atlasPatch = layer.__atlasPatch;
|
|
895
887
|
|
|
896
888
|
if (atlasPatch !== null) {
|
|
897
|
-
const uv = atlasPatch.uv;
|
|
898
|
-
|
|
899
|
-
const u0 = uv.position.x;
|
|
900
|
-
const v0 = uv.position.y;
|
|
901
|
-
const u1 = uv.size.x;
|
|
902
|
-
const v1 = uv.size.y;
|
|
903
889
|
|
|
904
|
-
|
|
890
|
+
write_particle_patch_uv(atlasPatch, particles, i);
|
|
905
891
|
} else {
|
|
906
892
|
missingFlag = true;
|
|
907
893
|
}
|
|
@@ -933,8 +919,6 @@ export class ParticleEmitter {
|
|
|
933
919
|
|
|
934
920
|
const emissionPeriod = 1 / layer.emissionRate;
|
|
935
921
|
|
|
936
|
-
const layerPosition = layerIndex / this.layers.length;
|
|
937
|
-
|
|
938
922
|
//compute transform matrix of the emitter
|
|
939
923
|
const emitter_position = this.position;
|
|
940
924
|
const last_spawn_position = this.__lastSpawnPosition;
|
|
@@ -952,7 +936,9 @@ export class ParticleEmitter {
|
|
|
952
936
|
const f = time / timeDelta;
|
|
953
937
|
|
|
954
938
|
//compute position for particle
|
|
955
|
-
emissionFunction(random,
|
|
939
|
+
emissionFunction(random, scratch_v3_array, 0);
|
|
940
|
+
|
|
941
|
+
v3position.readFromArray(scratch_v3_array, 0);
|
|
956
942
|
|
|
957
943
|
//apply layer transform
|
|
958
944
|
v3position.multiply(layer.scale);
|
|
@@ -1011,28 +997,17 @@ export class ParticleEmitter {
|
|
|
1011
997
|
//write UV
|
|
1012
998
|
const atlasPatch = layer.__atlasPatch;
|
|
1013
999
|
if (atlasPatch !== null) {
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
const uv_position = uv.position;
|
|
1017
|
-
|
|
1018
|
-
const u0 = uv_position.x;
|
|
1019
|
-
const v0 = uv_position.y;
|
|
1020
|
-
|
|
1021
|
-
const uv_size = uv.size;
|
|
1022
|
-
|
|
1023
|
-
const u1 = uv_size.x;
|
|
1024
|
-
const v1 = uv_size.y;
|
|
1025
|
-
|
|
1026
|
-
particles.writeAttributeVector4(ref, PARTICLE_ATTRIBUTE_UV, u0, v0, u1, v1);
|
|
1000
|
+
//patch exists, write it
|
|
1001
|
+
write_particle_patch_uv(atlasPatch, particles, ref);
|
|
1027
1002
|
} else {
|
|
1028
1003
|
this.setFlag(ParticleEmitterFlag.SpritesNeedUpdate);
|
|
1029
1004
|
}
|
|
1030
1005
|
|
|
1031
|
-
particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION,
|
|
1006
|
+
particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION, layerIndex);
|
|
1032
1007
|
|
|
1033
1008
|
update_parameters(ref, particles, layer, initialAge / deathAge);
|
|
1034
1009
|
|
|
1035
|
-
particles.writeAttributeScalar(ref,PARTICLE_ATTRIBUTE_BLEND,this.blendingMode);
|
|
1010
|
+
particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_BLEND, this.blendingMode);
|
|
1036
1011
|
}
|
|
1037
1012
|
|
|
1038
1013
|
//update time buffer
|
|
@@ -1051,9 +1026,11 @@ export class ParticleEmitter {
|
|
|
1051
1026
|
return;
|
|
1052
1027
|
}
|
|
1053
1028
|
|
|
1054
|
-
|
|
1029
|
+
const layers = this.layers;
|
|
1055
1030
|
|
|
1056
|
-
|
|
1031
|
+
assert.ok(layerIndex < layers.length && layerIndex >= 0, `layerIndex[=${layerIndex}] is out of bounds`);
|
|
1032
|
+
|
|
1033
|
+
const layer = layers.get(layerIndex);
|
|
1057
1034
|
|
|
1058
1035
|
const random = Math.random;
|
|
1059
1036
|
|
|
@@ -1065,8 +1042,6 @@ export class ParticleEmitter {
|
|
|
1065
1042
|
|
|
1066
1043
|
const emissionFunction = computeEmissionFunction(layer.emissionFrom, layer.emissionShape);
|
|
1067
1044
|
|
|
1068
|
-
const layerPosition = layerIndex / this.layers.length;
|
|
1069
|
-
|
|
1070
1045
|
//compute transform matrix of the emitter
|
|
1071
1046
|
composeMatrix4(matrix4, this.position, this.rotation, this.scale);
|
|
1072
1047
|
|
|
@@ -1079,7 +1054,9 @@ export class ParticleEmitter {
|
|
|
1079
1054
|
const ref = particles.create();
|
|
1080
1055
|
|
|
1081
1056
|
//compute position for particle
|
|
1082
|
-
emissionFunction(random,
|
|
1057
|
+
emissionFunction(random, scratch_v3_array, 0);
|
|
1058
|
+
|
|
1059
|
+
v3position.readFromArray(scratch_v3_array, 0);
|
|
1083
1060
|
|
|
1084
1061
|
//apply layer transform
|
|
1085
1062
|
v3position.multiply(layer.scale);
|
|
@@ -1137,29 +1114,17 @@ export class ParticleEmitter {
|
|
|
1137
1114
|
|
|
1138
1115
|
if (atlasPatch !== null) {
|
|
1139
1116
|
//patch exists, write it
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
const uv_position = uv.position;
|
|
1143
|
-
|
|
1144
|
-
const u0 = uv_position.x;
|
|
1145
|
-
const v0 = uv_position.y;
|
|
1146
|
-
|
|
1147
|
-
const uv_size = uv.size;
|
|
1148
|
-
|
|
1149
|
-
const u1 = uv_size.x;
|
|
1150
|
-
const v1 = uv_size.y;
|
|
1151
|
-
|
|
1152
|
-
particles.writeAttributeVector4(ref, PARTICLE_ATTRIBUTE_UV, u0, v0, u1, v1);
|
|
1117
|
+
write_particle_patch_uv(atlasPatch, particles, ref);
|
|
1153
1118
|
} else {
|
|
1154
1119
|
//patch is not loaded yet, request update
|
|
1155
1120
|
spritesNeedUpdate = true;
|
|
1156
1121
|
}
|
|
1157
1122
|
|
|
1158
|
-
particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION,
|
|
1123
|
+
particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION, layerIndex);
|
|
1159
1124
|
|
|
1160
1125
|
update_parameters(ref, particles, layer, initialAge / deathAge);
|
|
1161
1126
|
|
|
1162
|
-
particles.writeAttributeScalar(ref,PARTICLE_ATTRIBUTE_BLEND,this.blendingMode);
|
|
1127
|
+
particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_BLEND, this.blendingMode);
|
|
1163
1128
|
}
|
|
1164
1129
|
|
|
1165
1130
|
if (spritesNeedUpdate) {
|
|
@@ -1197,7 +1162,9 @@ export class ParticleEmitter {
|
|
|
1197
1162
|
continue;
|
|
1198
1163
|
}
|
|
1199
1164
|
|
|
1200
|
-
const
|
|
1165
|
+
const particleLife = layer.particleLife;
|
|
1166
|
+
|
|
1167
|
+
const averageLifetime = (particleLife.max + particleLife.min) / 2;
|
|
1201
1168
|
|
|
1202
1169
|
//emitting more than averageLifetime lifetime is unproductive, so we'll crop the emission
|
|
1203
1170
|
let emissionDelta;
|
|
@@ -1260,27 +1227,8 @@ const matrix4 = new Matrix4();
|
|
|
1260
1227
|
|
|
1261
1228
|
const defaultPointsMaterial = new PointsMaterial({ color: 0xFFFFFF });
|
|
1262
1229
|
|
|
1263
|
-
|
|
1264
|
-
//build particle spec
|
|
1265
|
-
export const PARTICULAR_PARTICLE_SPECIFICATION = new ParticleSpecification();
|
|
1266
|
-
|
|
1267
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('position', ParticleAttributeType.Vector3, ParticleDataType.Float32));
|
|
1268
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('age', ParticleAttributeType.Scalar, ParticleDataType.Float32));
|
|
1269
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('deathAge', ParticleAttributeType.Scalar, ParticleDataType.Float32));
|
|
1270
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('atlasPatch', ParticleAttributeType.Vector4, ParticleDataType.Float32));
|
|
1271
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('size', ParticleAttributeType.Scalar, ParticleDataType.Float32));
|
|
1272
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('layerPosition', ParticleAttributeType.Scalar, ParticleDataType.Float32));
|
|
1273
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('velocity', ParticleAttributeType.Vector3, ParticleDataType.Float32));
|
|
1274
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('rotation', ParticleAttributeType.Scalar, ParticleDataType.Float32));
|
|
1275
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('rotationSpeed', ParticleAttributeType.Scalar, ParticleDataType.Float32));
|
|
1276
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('color', ParticleAttributeType.Vector4, ParticleDataType.Float32));
|
|
1277
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('blending', ParticleAttributeType.Scalar, ParticleDataType.Uint8));
|
|
1278
|
-
PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('size_initial', ParticleAttributeType.Scalar, ParticleDataType.Float32));
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
1230
|
const frustum = new Frustum();
|
|
1282
1231
|
|
|
1283
|
-
const velocity = [];
|
|
1284
1232
|
const position = [];
|
|
1285
1233
|
|
|
1286
1234
|
const v3position = new Vector3();
|
|
@@ -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;
|