@woosh/meep-engine 2.33.23 → 2.33.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/core/bvh2/BinaryNode.js +1 -1
  2. package/core/bvh2/aabb3/AABB3.js +18 -0
  3. package/core/bvh2/aabb3/AABB3Math.js +1 -1
  4. package/core/bvh2/binary/2/BinaryUint32BVH.js +498 -0
  5. package/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
  6. package/core/bvh2/binary/IndexedBinaryBVH.js +22 -26
  7. package/core/collection/ArrayUtils.js +1 -1
  8. package/core/collection/array/arrayQuickSort.js +9 -6
  9. package/core/collection/array/array_swap.js +22 -0
  10. package/core/collection/array/computeHashArray.js +22 -0
  11. package/core/collection/array/computeHashIntegerArray.js +15 -0
  12. package/core/collection/table/DataType2TypedArrayConstructorMapping.js +15 -0
  13. package/core/color/Color.js +2 -1
  14. package/core/function/FunctionCompiler.js +2 -1
  15. package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
  16. package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
  17. package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +41 -0
  18. package/core/geom/3d/morton/mortonEncode_magicbits.js +2 -1
  19. package/core/geom/3d/morton/reinterpret_float32_as_int32.js +13 -0
  20. package/core/geom/3d/morton/v3_morton_encode_transformed.js +33 -0
  21. package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
  22. package/core/geom/3d/shape/AbstractShape3D.js +29 -0
  23. package/core/geom/3d/shape/CompositeShape.js +60 -0
  24. package/core/geom/3d/shape/TransformedShape3D.js +70 -0
  25. package/core/geom/3d/shape/UnitCubeShape3D.js +13 -0
  26. package/core/geom/3d/shape/UnitSphereShape3D.js +16 -0
  27. package/core/geom/AABB2.js +1 -1
  28. package/core/geom/ConicRay.js +3 -1
  29. package/core/geom/LineSegment.js +0 -78
  30. package/core/geom/Matrix4.js +7 -8
  31. package/core/geom/Rectangle.js +2 -1
  32. package/core/geom/Vector1.js +1 -1
  33. package/core/geom/Vector3.js +2 -1
  34. package/core/geom/Vector4.js +2 -1
  35. package/core/geom/random/randomPointInBox.js +7 -3
  36. package/core/geom/random/randomPointInPoint.js +6 -3
  37. package/core/geom/random/randomPointInSphere.js +6 -3
  38. package/core/geom/random/randomPointOnBox.js +7 -3
  39. package/core/geom/random/randomPointOnSphere.js +6 -3
  40. package/core/geom/v3_length.js +8 -3
  41. package/core/graph/graph_k_means_cluster.js +1 -1
  42. package/core/math/MathUtils.js +0 -354
  43. package/core/math/MathUtils.spec.js +7 -1
  44. package/core/math/gaussian.js +9 -0
  45. package/core/math/hash/computeHashFloat.js +17 -0
  46. package/core/math/hash/computeHashFloatArray.js +34 -0
  47. package/core/math/hash/computeObjectHash.js +54 -0
  48. package/core/math/intersects1D.js +19 -0
  49. package/core/math/interval/NumericInterval.js +2 -2
  50. package/core/math/isValueBetween.js +10 -0
  51. package/core/math/isValueBetweenInclusive.js +10 -0
  52. package/core/math/noise/curl_noise_3dt.js +1 -1
  53. package/core/math/noise/sdnoise.js +10 -10
  54. package/core/math/overlap1D.js +19 -0
  55. package/core/math/pingpong.js +17 -0
  56. package/core/math/random/makeRangedRandom.js +19 -0
  57. package/core/math/random/randomFloatBetween.js +14 -0
  58. package/core/math/random/randomFromArray.js +19 -0
  59. package/core/math/random/randomGaussian.js +15 -0
  60. package/core/math/random/randomIntegerBetween.js +14 -0
  61. package/core/math/random/roundFair.js +15 -0
  62. package/core/math/separation1D.js +21 -0
  63. package/core/math/solveQuadratic.js +25 -0
  64. package/core/model/BoundedValue.js +1 -1
  65. package/core/model/node-graph/node/NodeInstancePortReference.js +1 -1
  66. package/core/model/node-graph/node/Port.js +1 -1
  67. package/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +3 -1
  68. package/core/model/reactive/model/ReactiveBinaryExpression.js +1 -1
  69. package/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +1 -1
  70. package/core/model/reactive/model/terminal/ReactiveReference.js +1 -1
  71. package/core/model/reactive/model/util/createRandomReactiveExpression.js +1 -1
  72. package/core/model/stat/LinearModifier.js +1 -1
  73. package/engine/animation/curve/AnimationCurve.js +72 -0
  74. package/engine/animation/curve/Keyframe.js +27 -0
  75. package/engine/animation/keyed2/AnimationTrack.js +27 -3
  76. package/engine/asset/Asset.js +1 -1
  77. package/engine/asset/loaders/GLTFAssetLoader.d.ts +1 -1
  78. package/engine/asset/loaders/GLTFAssetLoader.js +10 -0
  79. package/engine/asset/loaders/image/ImageRGBADataAsset.js +8 -1
  80. package/engine/asset/loaders/material/computeMaterialHash.js +3 -1
  81. package/engine/asset/loaders/material/computeTextureHash.js +2 -1
  82. package/engine/ecs/animation/Animation.js +2 -1
  83. package/engine/ecs/animation/InverseKinematics.js +2 -1
  84. package/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
  85. package/engine/ecs/dynamic_actions/DynamicRuleDescriptionTable.spec.js +3 -5
  86. package/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +1 -1
  87. package/engine/ecs/evaluation/complex/PointFitnessGaussianBlur.js +1 -1
  88. package/engine/ecs/foliage/ecs/Foliage2.js +1 -1
  89. package/engine/ecs/fow/shader/FogOfWarRenderer.js +1 -1
  90. package/engine/ecs/gui/GUIElement.js +1 -1
  91. package/engine/ecs/gui/hud/HeadsUpDisplay.js +1 -1
  92. package/engine/ecs/gui/position/ViewportPosition.js +2 -1
  93. package/engine/ecs/systems/RangedAttackSystem.js +1 -1
  94. package/engine/ecs/systems/SteeringSystem.js +1 -1
  95. package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
  96. package/engine/ecs/tooltip/TooltipComponent.js +15 -0
  97. package/engine/graphics/ecs/animation/animator/AnimationClip.js +2 -1
  98. package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -1
  99. package/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -1
  100. package/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -1
  101. package/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +2 -1
  102. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -1
  103. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +1 -1
  104. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +2 -1
  105. package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
  106. package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
  107. package/engine/graphics/ecs/light/Light.d.ts +1 -1
  108. package/engine/graphics/ecs/light/Light.js +3 -0
  109. package/engine/graphics/ecs/mesh/Mesh.js +2 -1
  110. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
  111. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
  112. package/engine/graphics/geometry/AttributeSpec.js +105 -0
  113. package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
  114. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
  115. package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
  116. package/engine/graphics/micron/buildPatchwork.js +1 -1
  117. package/engine/graphics/micron/format/MicronGeometry.js +3 -3
  118. package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +2 -2
  119. package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
  120. package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
  121. package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
  122. package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +5 -5
  123. package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
  124. package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +80 -16
  125. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +57 -52
  126. package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +2 -1
  127. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +51 -12
  128. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +3 -2
  129. package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +1 -1
  130. package/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +8 -2
  131. package/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +2 -1
  132. package/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js +1 -1
  133. package/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +1 -1
  134. package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +21 -0
  135. package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +0 -20
  136. package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
  137. package/engine/graphics/particles/particular/engine/simulator/SimulationStepApplyForce.js +2 -5
  138. package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseAcceleration.js +2 -6
  139. package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.js +2 -7
  140. package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +2 -5
  141. package/engine/graphics/particles/particular/engine/simulator/update_parameters.js +1 -1
  142. package/engine/graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js +1 -1
  143. package/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.js +1 -1
  144. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +384 -0
  145. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +558 -0
  146. package/engine/graphics/particles/particular/group/Operation.js +18 -0
  147. package/engine/graphics/particles/particular/group/OperationType.js +9 -0
  148. package/engine/graphics/particles/particular/group/ParticleAttribute.js +2 -1
  149. package/engine/graphics/particles/particular/group/ParticleAttributeType.js +11 -0
  150. package/engine/graphics/particles/particular/group/ParticleDataType.js +10 -0
  151. package/engine/graphics/particles/particular/group/ParticleGroup.js +7 -245
  152. package/engine/graphics/particles/particular/group/ParticleGroup.spec.js +3 -1
  153. package/engine/graphics/particles/particular/group/ParticleSpecification.js +21 -14
  154. package/engine/graphics/particles/particular/group/itemSizeFromAttributeType.js +20 -0
  155. package/engine/graphics/particles/particular/group/optimizeCommandQueue.js +162 -0
  156. package/engine/graphics/particles/particular/group/typedArrayConstructorFromDataType.js +19 -0
  157. package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +1 -1
  158. package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameter.js +2 -1
  159. package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameterSet.js +1 -1
  160. package/engine/graphics/render/forward_plus/LightManager.js +117 -94
  161. package/engine/graphics/render/forward_plus/PointLight.js +9 -0
  162. package/engine/graphics/render/forward_plus/PointLightData.js +1 -1
  163. package/engine/graphics/render/forward_plus/SpotLight.js +9 -0
  164. package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +2 -2
  165. package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
  166. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +5 -5
  167. package/engine/graphics/render/forward_plus/prototypeLightManager.js +180 -86
  168. package/engine/graphics/render/forward_plus/query/analytical_triplanar_corner_mapping.js +8 -0
  169. package/engine/graphics/render/forward_plus/query/cube_mapping.js +38 -0
  170. package/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +86 -0
  171. package/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +73 -0
  172. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +131 -0
  173. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +129 -0
  174. package/engine/graphics/render/forward_plus/query/spot_light_inside_volume.js +33 -0
  175. package/engine/graphics/render/forward_plus/read_frustum_corner.js +14 -0
  176. package/engine/graphics/render/forward_plus/testClusterEquality.js +22 -0
  177. package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
  178. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
  179. package/engine/graphics/texture/sampler/HarmonicDiffusionGrid.spec.js +1 -1
  180. package/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
  181. package/engine/graphics/texture/sampler/distanceField.spec.js +1 -1
  182. package/engine/grid/components/GridObstacle.js +1 -1
  183. package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
  184. package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
  185. package/engine/navigation/ecs/components/Path.js +1 -1
  186. package/engine/navigation/grid/FastBinaryHeap.spec.js +1 -1
  187. package/engine/sound/ecs/emitter/SoundEmitter.js +2 -1
  188. package/engine/sound/ecs/emitter/SoundTrack.js +2 -1
  189. package/engine/sound/material/concrete/RandomSoundMaterial.js +1 -1
  190. package/engine/ui/notification/notificationGenerator.js +1 -1
  191. package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +1 -1
  192. package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
  193. package/generation/markers/actions/MarkerNodeActionSelectRandom.js +1 -1
  194. package/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +1 -1
  195. package/generation/placement/action/random/CellActionSelectRandom.js +1 -1
  196. package/generation/theme/ThemeEngine.js +1 -1
  197. package/misc/makeMaterialIconCached.js +2 -2
  198. package/package.json +1 -1
  199. package/view/elements/image/HTMLElementCacheKey.js +2 -1
  200. package/view/elements/radial/RadialText.js +2 -1
  201. package/view/minimap/gl/MinimapMarkersGL.js +6 -100
  202. package/view/minimap/gl/buildMaterial.js +94 -0
  203. package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +0 -71
  204. package/engine/graphics/render/forward_plus/queryBVH_Frustum.js +0 -357
@@ -1,20 +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
+
1
5
  //build particle spec
2
- import { ParticleSpecification } from "../../group/ParticleSpecification.js";
3
- import { ParticleAttribute } from "../../group/ParticleAttribute.js";
4
- import { ParticleAttributeType, ParticleDataType } from "../../group/ParticleGroup.js";
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
+ }));
5
33
 
6
- export const PARTICULAR_PARTICLE_SPECIFICATION = new ParticleSpecification();
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
+ }));
7
41
 
8
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('position', ParticleAttributeType.Vector3, ParticleDataType.Float32));
9
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('age', ParticleAttributeType.Scalar, ParticleDataType.Float32));
10
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('deathAge', ParticleAttributeType.Scalar, ParticleDataType.Float32));
11
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('atlasPatch', ParticleAttributeType.Vector4, ParticleDataType.Float32));
12
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('size', ParticleAttributeType.Scalar, ParticleDataType.Float32));
13
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('layerPosition', ParticleAttributeType.Scalar, ParticleDataType.Float32));
14
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('velocity', ParticleAttributeType.Vector3, ParticleDataType.Float32));
15
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('rotation', ParticleAttributeType.Scalar, ParticleDataType.Float32));
16
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('rotationSpeed', ParticleAttributeType.Scalar, ParticleDataType.Float32));
17
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('color', ParticleAttributeType.Vector4, ParticleDataType.Float32));
18
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('blending', ParticleAttributeType.Scalar, ParticleDataType.Uint8));
19
- PARTICULAR_PARTICLE_SPECIFICATION.add(new ParticleAttribute('size_initial', ParticleAttributeType.Scalar, ParticleDataType.Float32));
42
+ PARTICULAR_PARTICLE_SPECIFICATION.add(AttributeSpec.fromJSON({
43
+ name: 'layerPosition',
44
+ itemSize: 1,
45
+ type: DataType.Uint8,
46
+ normalized: false
47
+ }));
20
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
+ }));
@@ -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,7 @@ 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),
239
275
  blendingMode: this.blendingMode,
240
276
  layers: this.layers.toJSON()
241
277
  };
@@ -288,6 +324,12 @@ export class ParticleEmitter {
288
324
  this.writeFlag(ParticleEmitterFlag.AlignOnVelocity, false);
289
325
  }
290
326
 
327
+ if (typeof json.depthSort === "boolean") {
328
+ this.writeFlag(ParticleEmitterFlag.DepthSorting, json.depthSort);
329
+ } else {
330
+ this.writeFlag(ParticleEmitterFlag.DepthSorting, true);
331
+ }
332
+
291
333
  this.layers.fromJSON(json.layers, ParticleLayer);
292
334
 
293
335
  this.writeFlag(ParticleEmitterFlag.Built, false);
@@ -343,8 +385,6 @@ export class ParticleEmitter {
343
385
  throw new Error('Layer not found');
344
386
  }
345
387
 
346
- const numLayers = layers.length;
347
-
348
388
  const particles = this.particles;
349
389
  const occupancy = particles.occupancy;
350
390
 
@@ -358,9 +398,7 @@ export class ParticleEmitter {
358
398
 
359
399
  const layerPosition = particles.readAttributeScalar(i, PARTICLE_ATTRIBUTE_LAYER_POSITION);
360
400
 
361
- const layerIndex = Math.round(layerPosition * numLayers);
362
-
363
- if (layerIndex !== targetLayerIndex) {
401
+ if (layerPosition !== targetLayerIndex) {
364
402
  // not the layer we want
365
403
  continue;
366
404
  }
@@ -837,29 +875,19 @@ export class ParticleEmitter {
837
875
 
838
876
  const layers = this.layers;
839
877
 
840
- const numLayers = layers.length;
841
-
842
878
  let missingFlag = false;
843
879
 
844
880
  //cycle through each particle
845
881
  for (let i = occupancy.nextSetBit(0); i !== -1; i = occupancy.nextSetBit(i + 1)) {
846
- const layerPosition = particles.readAttributeScalar(i, PARTICLE_ATTRIBUTE_LAYER_POSITION);
847
-
848
- const layerIndex = Math.round(layerPosition * numLayers);
882
+ const layerIndex = particles.readAttributeScalar(i, PARTICLE_ATTRIBUTE_LAYER_POSITION);
849
883
 
850
884
  const layer = layers.get(layerIndex);
851
885
 
852
886
  const atlasPatch = layer.__atlasPatch;
853
887
 
854
888
  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
889
 
862
- particles.writeAttributeVector4(i, PARTICLE_ATTRIBUTE_UV, u0, v0, u1, v1);
890
+ write_particle_patch_uv(atlasPatch, particles, i);
863
891
  } else {
864
892
  missingFlag = true;
865
893
  }
@@ -891,8 +919,6 @@ export class ParticleEmitter {
891
919
 
892
920
  const emissionPeriod = 1 / layer.emissionRate;
893
921
 
894
- const layerPosition = layerIndex / this.layers.length;
895
-
896
922
  //compute transform matrix of the emitter
897
923
  const emitter_position = this.position;
898
924
  const last_spawn_position = this.__lastSpawnPosition;
@@ -910,7 +936,9 @@ export class ParticleEmitter {
910
936
  const f = time / timeDelta;
911
937
 
912
938
  //compute position for particle
913
- emissionFunction(random, v3position);
939
+ emissionFunction(random, scratch_v3_array, 0);
940
+
941
+ v3position.readFromArray(scratch_v3_array, 0);
914
942
 
915
943
  //apply layer transform
916
944
  v3position.multiply(layer.scale);
@@ -969,24 +997,13 @@ export class ParticleEmitter {
969
997
  //write UV
970
998
  const atlasPatch = layer.__atlasPatch;
971
999
  if (atlasPatch !== null) {
972
- const uv = atlasPatch.uv;
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);
1000
+ //patch exists, write it
1001
+ write_particle_patch_uv(atlasPatch, particles, ref);
985
1002
  } else {
986
1003
  this.setFlag(ParticleEmitterFlag.SpritesNeedUpdate);
987
1004
  }
988
1005
 
989
- particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION, layerPosition);
1006
+ particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION, layerIndex);
990
1007
 
991
1008
  update_parameters(ref, particles, layer, initialAge / deathAge);
992
1009
 
@@ -1025,8 +1042,6 @@ export class ParticleEmitter {
1025
1042
 
1026
1043
  const emissionFunction = computeEmissionFunction(layer.emissionFrom, layer.emissionShape);
1027
1044
 
1028
- const layerPosition = layerIndex / layers.length;
1029
-
1030
1045
  //compute transform matrix of the emitter
1031
1046
  composeMatrix4(matrix4, this.position, this.rotation, this.scale);
1032
1047
 
@@ -1039,7 +1054,9 @@ export class ParticleEmitter {
1039
1054
  const ref = particles.create();
1040
1055
 
1041
1056
  //compute position for particle
1042
- emissionFunction(random, v3position);
1057
+ emissionFunction(random, scratch_v3_array, 0);
1058
+
1059
+ v3position.readFromArray(scratch_v3_array, 0);
1043
1060
 
1044
1061
  //apply layer transform
1045
1062
  v3position.multiply(layer.scale);
@@ -1097,25 +1114,13 @@ export class ParticleEmitter {
1097
1114
 
1098
1115
  if (atlasPatch !== null) {
1099
1116
  //patch exists, write it
1100
- const uv = atlasPatch.uv;
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);
1117
+ write_particle_patch_uv(atlasPatch, particles, ref);
1113
1118
  } else {
1114
1119
  //patch is not loaded yet, request update
1115
1120
  spritesNeedUpdate = true;
1116
1121
  }
1117
1122
 
1118
- particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION, layerPosition);
1123
+ particles.writeAttributeScalar(ref, PARTICLE_ATTRIBUTE_LAYER_POSITION, layerIndex);
1119
1124
 
1120
1125
  update_parameters(ref, particles, layer, initialAge / deathAge);
1121
1126
 
@@ -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,10 @@
1
1
  import { BitSet } from "../../../../../../core/binary/BitSet.js";
2
2
  import { max3 } from "../../../../../../core/math/max3.js";
3
- import { itemSizeFromAttributeType, typedArrayConstructorFromDataType } from "../../group/ParticleGroup.js";
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";
7
8
 
8
9
  const SHRINK_THRESHOLD = 64;
9
10
  const GROW_MIN_STEP = 32;
@@ -11,13 +12,15 @@ const GROW_MIN_STEP = 32;
11
12
  export class ParticlePool {
12
13
  /**
13
14
  *
14
- * @param {ParticleSpecification} spec
15
+ * @param {VertexDataSpec} spec
15
16
  * @constructor
16
17
  */
17
18
  constructor(spec) {
19
+ assert.equal(spec.isVertexDataSpec, true, 'spec.VertexDataSpec !== true');
20
+
18
21
  /**
19
22
  *
20
- * @type {ParticleSpecification}
23
+ * @type {VertexDataSpec}
21
24
  */
22
25
  this.spec = spec;
23
26
 
@@ -224,6 +227,41 @@ export class ParticlePool {
224
227
  }
225
228
  }
226
229
 
230
+ /**
231
+ *
232
+ * @param {AttributeSpec} spec
233
+ * @return {number}
234
+ * @private
235
+ */
236
+ __compute_attribute_byte_size(spec) {
237
+
238
+ const item_size = spec.itemSize;
239
+
240
+ const TypedArrayConstructor = compute_typed_array_constructor_from_data_type(spec.type);
241
+
242
+ const element_byte_size = TypedArrayConstructor.BYTES_PER_ELEMENT;
243
+
244
+ return item_size * element_byte_size * this.capacity;
245
+ }
246
+
247
+ /**
248
+ *
249
+ * @return {number}
250
+ * @private
251
+ */
252
+ __compute_attribute_byte_size_total() {
253
+
254
+ const spec_attributes = this.spec.attributes;
255
+ const l = spec_attributes.length;
256
+
257
+ let r = 0;
258
+ for (let i = 0; i < l; i++) {
259
+ r += this.__compute_attribute_byte_size(spec_attributes[i]);
260
+ }
261
+
262
+ return r;
263
+ }
264
+
227
265
  build() {
228
266
  const geometry = new BufferGeometry();
229
267
  geometry.dynamic = true;
@@ -234,25 +272,26 @@ export class ParticlePool {
234
272
  for (let i = 0; i < l; i++) {
235
273
 
236
274
  /**
237
- * @type {ParticleAttribute}
275
+ * @type {AttributeSpec}
238
276
  */
239
277
  const attributeSpec = spec_attributes[i];
240
278
 
241
- const itemSize = itemSizeFromAttributeType(attributeSpec.type);
242
- const TypedArrayConstructor = typedArrayConstructorFromDataType(attributeSpec.dataType);
279
+ const itemSize = attributeSpec.itemSize;
280
+ const TypedArrayConstructor = compute_typed_array_constructor_from_data_type(attributeSpec.type);
243
281
 
244
282
  const newArrayLength = itemSize * this.capacity;
245
283
  const newArray = new TypedArrayConstructor(newArrayLength);
246
284
 
247
- const attribute = this.attributes[i];
248
- if (attribute !== undefined && attribute.count !== 0) {
285
+ const old_attribute = this.attributes[i];
286
+
287
+ if (old_attribute !== undefined && old_attribute.count !== 0) {
249
288
  //copy old data
250
- typed_array_copy(attribute.array, newArray);
289
+ typed_array_copy(old_attribute.array, newArray);
251
290
  }
252
291
 
253
- const newAttribute = new BufferAttribute(newArray, itemSize);
292
+ const newAttribute = new BufferAttribute(newArray, itemSize, attributeSpec.normalized);
254
293
 
255
- newAttribute.setUsage(DynamicDrawUsage);
294
+ newAttribute.setUsage(StreamDrawUsage);
256
295
  newAttribute.name = attributeSpec.name;
257
296
 
258
297
  this.attributes[i] = newAttribute;
@@ -1,7 +1,8 @@
1
1
  import { ParticlePool } from "./ParticlePool.js";
2
- import { ParticleAttributeType, ParticleDataType, } from "../../group/ParticleGroup.js";
3
2
  import { ParticleSpecification } from "../../group/ParticleSpecification.js";
4
3
  import { ParticleAttribute } from "../../group/ParticleAttribute.js";
4
+ import { ParticleDataType } from "../../group/ParticleDataType.js";
5
+ import { ParticleAttributeType } from "../../group/ParticleAttributeType.js";
5
6
 
6
7
  /**
7
8
  *
@@ -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:Vector3):void}
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
- const data = new Float32Array(dataLength);
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,21 @@
1
+ import { ParticleSpecification } from "../../../group/ParticleSpecification.js";
2
+ import { ParticleAttribute } from "../../../group/ParticleAttribute.js";
3
+ import { ParticleAttributeType } from "../../../group/ParticleAttributeType.js";
4
+ import { ParticleDataType } from "../../../group/ParticleDataType.js";
5
+
6
+ export const BILLBOARD_PARTICLE_ATTRIBUTE_POSITION = 0;
7
+ export const BILLBOARD_PARTICLE_ATTRIBUTE_UV = 1;
8
+ export const BILLBOARD_PARTICLE_ATTRIBUTE_SIZE = 2;
9
+ export const BILLBOARD_PARTICLE_ATTRIBUTE_VELOCITY = 3;
10
+ export const BILLBOARD_PARTICLE_ATTRIBUTE_COLOR = 5;
11
+ export const BILLBOARD_PARTICLE_ATTRIBUTE_BLEND = 6;
12
+
13
+ export const BILLBOARD_PARTICLE_SPECIFICATION = new ParticleSpecification();
14
+
15
+ BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('position', ParticleAttributeType.Vector3, ParticleDataType.Float32));
16
+ BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('atlasPatch', ParticleAttributeType.Vector4, ParticleDataType.Float32));
17
+ BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('size', ParticleAttributeType.Scalar, ParticleDataType.Float32));
18
+ BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('velocity', ParticleAttributeType.Vector3, ParticleDataType.Float32));
19
+ BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('rotation', ParticleAttributeType.Scalar, ParticleDataType.Float32));
20
+ BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('color', ParticleAttributeType.Vector4, ParticleDataType.Float32));
21
+ BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('blending', ParticleAttributeType.Scalar, ParticleDataType.Uint8));
@@ -1,25 +1,5 @@
1
1
  import { AddEquation, CustomBlending, Matrix4, OneFactor, OneMinusSrcAlphaFactor, ShaderMaterial } from "three";
2
2
  import { Vector2 as ThreeVector2 } from "three/src/math/Vector2.js";
3
- import { ParticleSpecification } from "../../../group/ParticleSpecification.js";
4
- import { ParticleAttribute } from "../../../group/ParticleAttribute.js";
5
- import { ParticleAttributeType, ParticleDataType } from "../../../group/ParticleGroup.js";
6
-
7
- export const BILLBOARD_PARTICLE_SPECIFICATION = new ParticleSpecification();
8
-
9
- BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('position', ParticleAttributeType.Vector3, ParticleDataType.Float32));
10
- BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('atlasPatch', ParticleAttributeType.Vector4, ParticleDataType.Float32));
11
- BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('size', ParticleAttributeType.Scalar, ParticleDataType.Float32));
12
- BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('velocity', ParticleAttributeType.Vector3, ParticleDataType.Float32));
13
- BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('rotation', ParticleAttributeType.Scalar, ParticleDataType.Float32));
14
- BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('color', ParticleAttributeType.Vector4, ParticleDataType.Float32));
15
- BILLBOARD_PARTICLE_SPECIFICATION.add(new ParticleAttribute('blending', ParticleAttributeType.Scalar, ParticleDataType.Uint8));
16
-
17
- export const BILLBOARD_PARTICLE_ATTRIBUTE_POSITION = 0;
18
- export const BILLBOARD_PARTICLE_ATTRIBUTE_UV = 1;
19
- export const BILLBOARD_PARTICLE_ATTRIBUTE_SIZE = 2;
20
- export const BILLBOARD_PARTICLE_ATTRIBUTE_VELOCITY = 3;
21
- export const BILLBOARD_PARTICLE_ATTRIBUTE_COLOR = 5;
22
- export const BILLBOARD_PARTICLE_ATTRIBUTE_BLEND = 6;
23
3
 
24
4
  const DEPTH_ERROR_MARGIN = 0.0001;
25
5
 
@@ -1,14 +1,6 @@
1
1
  import { EngineHarness } from "../../../../../../EngineHarness.js";
2
2
  import { ParticlePool } from "../../emitter/ParticlePool.js";
3
- import {
4
- BILLBOARD_PARTICLE_ATTRIBUTE_BLEND,
5
- BILLBOARD_PARTICLE_ATTRIBUTE_COLOR,
6
- BILLBOARD_PARTICLE_ATTRIBUTE_POSITION,
7
- BILLBOARD_PARTICLE_ATTRIBUTE_SIZE,
8
- BILLBOARD_PARTICLE_ATTRIBUTE_UV,
9
- BILLBOARD_PARTICLE_SPECIFICATION,
10
- make_particle_billboard_shader
11
- } from "./ParticleBillboardMaterial.js";
3
+ import { make_particle_billboard_shader } from "./ParticleBillboardMaterial.js";
12
4
  import { DataTexture, LinearFilter, LinearMipMapLinearFilter, Matrix4, Points } from "three";
13
5
  import { ManagedAtlas } from "../../../../../texture/atlas/ManagedTextureAtlas.js";
14
6
  import { writeSample2DDataToDataTexture } from "../../../../../texture/sampler/writeSampler2DDataToDataTexture.js";
@@ -21,6 +13,14 @@ import Mesh from "../../../../../ecs/mesh/Mesh.js";
21
13
  import Vector3 from "../../../../../../../core/geom/Vector3.js";
22
14
  import { RenderPassType } from "../../../../../render/RenderPassType.js";
23
15
  import { StandardFrameBuffers } from "../../../../../StandardFrameBuffers.js";
16
+ import {
17
+ BILLBOARD_PARTICLE_ATTRIBUTE_BLEND,
18
+ BILLBOARD_PARTICLE_ATTRIBUTE_COLOR,
19
+ BILLBOARD_PARTICLE_ATTRIBUTE_POSITION,
20
+ BILLBOARD_PARTICLE_ATTRIBUTE_SIZE,
21
+ BILLBOARD_PARTICLE_ATTRIBUTE_UV,
22
+ BILLBOARD_PARTICLE_SPECIFICATION
23
+ } from "./BILLBOARD_PARTICLE_SPECIFICATION.js";
24
24
 
25
25
 
26
26
  const engineHarness = new EngineHarness();
@@ -18,15 +18,12 @@ export class SimulationStepApplyForce extends AbstractSimulationStep {
18
18
  const liveParticleCount = particles.size();
19
19
 
20
20
  const layerMask = this.layer_mask;
21
- const layerCount = this.layer_count;
22
21
 
23
22
  for (let i = 0; i < liveParticleCount; i++) {
24
23
 
25
24
  const layer_position = particles.readAttributeScalar(i, PARTICLE_ATTRIBUTE_LAYER_POSITION);
26
25
 
27
- const layer_index = layer_position * layerCount;
28
-
29
- if ((layerMask & (1 << layer_index)) === 0) {
26
+ if ((layerMask & (1 << layer_position)) === 0) {
30
27
  //skip
31
28
  continue;
32
29
  }
@@ -35,7 +32,7 @@ export class SimulationStepApplyForce extends AbstractSimulationStep {
35
32
  particles.readAttributeVector3(i, PARTICLE_ATTRIBUTE_VELOCITY, velocity);
36
33
 
37
34
 
38
- const params = layer_parameters[layer_index];
35
+ const params = layer_parameters[layer_position];
39
36
 
40
37
  const force_x = params[0];
41
38
  const force_y = params[1];