@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
@@ -10,10 +10,10 @@ import PhysicalBody from '../components/PhysicalBody.js';
10
10
  import Motion from '../components/Motion.js';
11
11
  import { Transform } from '../transform/Transform.js';
12
12
  import Steering, { SteeringEvents, SteeringFlags } from '../components/Steering.js';
13
- import { solveQuadratic } from "../../../core/math/MathUtils.js";
14
13
  import Vector3 from "../../../core/geom/Vector3.js";
15
14
  import { alignToVector } from "../terrain/ecs/ClingToTerrainSystem.js";
16
15
  import { v3_dot } from "../../../core/geom/v3_dot.js";
16
+ import { solveQuadratic } from "../../../core/math/solveQuadratic.js";
17
17
 
18
18
  /**
19
19
  *
@@ -14,7 +14,6 @@ import CheckersTexture from '../../../graphics/texture/CheckersTexture.js';
14
14
  import { MeshPhongMaterial } from 'three';
15
15
  import { assert } from "../../../../core/assert.js";
16
16
  import { Color } from "../../../../core/color/Color.js";
17
- import { randomFloatBetween } from "../../../../core/math/MathUtils.js";
18
17
  import { noop } from "../../../../core/function/Functions.js";
19
18
  import Vector3 from "../../../../core/geom/Vector3.js";
20
19
  import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
@@ -24,6 +23,7 @@ import { traverseBinaryNodeUsingVisitor } from "../../../../core/bvh2/traversal/
24
23
  import { aabb2_overlapExists } from "../../../../core/geom/AABB2.js";
25
24
  import ObservedInteger from "../../../../core/model/ObservedInteger.js";
26
25
  import { NumericInterval } from "../../../../core/math/interval/NumericInterval.js";
26
+ import { randomFloatBetween } from "../../../../core/math/random/randomFloatBetween.js";
27
27
 
28
28
  class TerrainTileManager {
29
29
  /**
@@ -1,3 +1,5 @@
1
+ import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
2
+
1
3
  export class TooltipComponent {
2
4
  constructor() {
3
5
  /**
@@ -7,6 +9,19 @@ export class TooltipComponent {
7
9
  this.key = '';
8
10
  }
9
11
 
12
+ hash() {
13
+ return computeStringHash(this.key);
14
+ }
15
+
16
+ /**
17
+ *
18
+ * @param {TooltipComponent} other
19
+ * @return {boolean}
20
+ */
21
+ equals(other) {
22
+ return this.key === other.key;
23
+ }
24
+
10
25
  toJSON() {
11
26
  return {
12
27
  key: this.key
@@ -1,8 +1,9 @@
1
- import { computeHashFloat, computeHashIntegerArray} from "../../../../../core/math/MathUtils.js";
2
1
  import { min2 } from "../../../../../core/math/min2.js";
3
2
  import { AnimationClipFlag } from "./AnimationClipFlag.js";
4
3
  import { LoopOnce, LoopRepeat } from "three";
5
4
  import { AnimationEventTypes } from "./AnimationEventTypes.js";
5
+ import { computeHashIntegerArray } from "../../../../../core/collection/array/computeHashIntegerArray.js";
6
+ import { computeHashFloat } from "../../../../../core/math/hash/computeHashFloat.js";
6
7
 
7
8
  export class AnimationClip {
8
9
  constructor() {
@@ -1,7 +1,8 @@
1
1
  import { isArrayEqual } from "../../../../../core/collection/ArrayUtils.js";
2
- import { computeHashArray, computeHashIntegerArray } from "../../../../../core/math/MathUtils.js";
3
2
  import { computeStringHash } from "../../../../../core/primitives/strings/computeStringHash.js";
4
3
  import { invokeObjectHash } from "../../../../../core/model/object/invokeObjectHash.js";
4
+ import { computeHashArray } from "../../../../../core/collection/array/computeHashArray.js";
5
+ import { computeHashIntegerArray } from "../../../../../core/collection/array/computeHashIntegerArray.js";
5
6
 
6
7
  /**
7
8
  *
@@ -1,4 +1,5 @@
1
- import { computeHashFloat, computeHashIntegerArray } from "../../../../../core/math/MathUtils.js";
1
+ import { computeHashIntegerArray } from "../../../../../core/collection/array/computeHashIntegerArray.js";
2
+ import { computeHashFloat } from "../../../../../core/math/hash/computeHashFloat.js";
2
3
 
3
4
  export class AnimationNotification {
4
5
  constructor() {
@@ -1,6 +1,7 @@
1
- import { computeHashIntegerArray, computeObjectHash } from "../../../../../core/math/MathUtils.js";
2
1
  import { objectDeepEquals } from "../../../../../core/model/object/objectDeepEquals.js";
3
2
  import { computeStringHash } from "../../../../../core/primitives/strings/computeStringHash.js";
3
+ import { computeHashIntegerArray } from "../../../../../core/collection/array/computeHashIntegerArray.js";
4
+ import { computeObjectHash } from "../../../../../core/math/hash/computeObjectHash.js";
4
5
 
5
6
  export class AnimationNotificationDefinition {
6
7
  constructor() {
@@ -3,11 +3,12 @@ import { AnimationTransition } from "./AnimationTransition.js";
3
3
  import { AnimationStateType } from "./AnimationStateType.js";
4
4
  import { AnimationMixer } from "three";
5
5
  import { AnimationGraphFlag } from "./AnimationGraphFlag.js";
6
- import { computeHashFloat, computeHashIntegerArray } from "../../../../../../core/math/MathUtils.js";
7
6
  import { writeAnimationGraphDefinitionToJSON } from "./definition/serialization/writeAnimationGraphDefinitionToJSON.js";
8
7
  import { readAnimationGraphDefinitionFromJSON } from "./definition/serialization/readAnimationGraphDefinitionFromJSON.js";
9
8
  import { assert } from "../../../../../../core/assert.js";
10
9
  import { threeUpdateTransform } from "../../../../util/threeUpdateTransform.js";
10
+ import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
11
+ import { computeHashFloat } from "../../../../../../core/math/hash/computeHashFloat.js";
11
12
 
12
13
  export class AnimationGraph {
13
14
  constructor() {
@@ -4,8 +4,9 @@ import { AnimationStateDefinition } from "./AnimationStateDefinition.js";
4
4
  import { AnimationClipDefinition } from "../../AnimationClipDefinition.js";
5
5
  import { AnimationClip } from "../../AnimationClip.js";
6
6
  import { isArrayEqual } from "../../../../../../../core/collection/ArrayUtils.js";
7
- import { computeHashArray, computeHashIntegerArray } from "../../../../../../../core/math/MathUtils.js";
8
7
  import { invokeObjectHash } from "../../../../../../../core/model/object/invokeObjectHash.js";
8
+ import { computeHashArray } from "../../../../../../../core/collection/array/computeHashArray.js";
9
+ import { computeHashIntegerArray } from "../../../../../../../core/collection/array/computeHashIntegerArray.js";
9
10
 
10
11
  export class AnimationGraphDefinition {
11
12
  constructor() {
@@ -1,5 +1,5 @@
1
1
  import { AnimationStateType } from "../AnimationStateType.js";
2
- import { computeHashIntegerArray } from "../../../../../../../core/math/MathUtils.js";
2
+ import { computeHashIntegerArray } from "../../../../../../../core/collection/array/computeHashIntegerArray.js";
3
3
 
4
4
  export class AnimationStateDefinition {
5
5
  constructor() {
@@ -1,5 +1,6 @@
1
- import { computeHashFloat, computeHashIntegerArray } from "../../../../../../../core/math/MathUtils.js";
2
1
  import { computeStringHash } from "../../../../../../../core/primitives/strings/computeStringHash.js";
2
+ import { computeHashIntegerArray } from "../../../../../../../core/collection/array/computeHashIntegerArray.js";
3
+ import { computeHashFloat } from "../../../../../../../core/math/hash/computeHashFloat.js";
3
4
 
4
5
  export class AnimationTransitionDefinition {
5
6
  constructor() {
@@ -1,7 +1,7 @@
1
- import { isValueBetweenInclusive } from "../../../../core/math/MathUtils.js";
2
1
  import { frustumFromCamera } from "./CameraSystem.js";
3
2
  import { Frustum as ThreeFrustum } from "three";
4
3
  import { v3_dot } from "../../../../core/geom/v3_dot.js";
4
+ import { isValueBetweenInclusive } from "../../../../core/math/isValueBetweenInclusive.js";
5
5
 
6
6
  const CLIPPING_EPSILON = 0.001;
7
7
 
@@ -1,7 +1,8 @@
1
1
  import { Color } from "../../../../core/color/Color.js";
2
2
  import { assert } from "../../../../core/assert.js";
3
- import { computeHashFloat, computeHashIntegerArray } from "../../../../core/math/MathUtils.js";
4
3
  import { COMPONENT_SERIALIZATION_TRANSIENT_FIELD } from "../../../ecs/storage/COMPONENT_SERIALIZATION_TRANSIENT_FIELD.js";
4
+ import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
5
+ import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
5
6
 
6
7
  export class HighlightDefinition {
7
8
  constructor() {
@@ -1,6 +1,6 @@
1
1
  import ObservedEnum from "../../../../core/model/ObservedEnum";
2
2
  import {Color} from "../../../../core/color/Color";
3
- import {Vector1} from "../../../../core/geom/Vector1";
3
+ import Vector1 from "../../../../core/geom/Vector1";
4
4
  import ObservedBoolean from "../../../../core/model/ObservedBoolean";
5
5
  import {LightType} from "./LightType";
6
6
 
@@ -103,7 +103,10 @@ export class Light {
103
103
 
104
104
  if (json.intensity !== undefined) {
105
105
  this.intensity.fromJSON(json.intensity);
106
+ } else {
107
+ this.intensity.set(1);
106
108
  }
109
+
107
110
  if (json.castShadow !== undefined) {
108
111
  this.castShadow.fromJSON(json.castShadow);
109
112
  }
@@ -3,13 +3,14 @@
3
3
  */
4
4
  import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
5
5
  import { LeafNode } from "../../../../core/bvh2/LeafNode.js";
6
- import { computeHashFloat, computeHashIntegerArray } from "../../../../core/math/MathUtils.js";
7
6
  import { getSkeletonBoneByType } from "./SkeletonUtils.js";
8
7
  import { assert } from "../../../../core/assert.js";
9
8
  import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
10
9
  import { Transform } from "../../../ecs/transform/Transform.js";
11
10
  import { updateNodeByTransformAndBBB } from "./updateNodeByTransformAndBBB.js";
12
11
  import { applyTransformToThreeObject } from "./applyTransformToThreeObject.js";
12
+ import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
13
+ import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
13
14
 
14
15
  /**
15
16
  *
@@ -0,0 +1,13 @@
1
+ import {BufferGeometry, Material} from "three";
2
+ import {AABB3} from "../../../../core/bvh2/aabb3/AABB3";
3
+
4
+ export class ShadedGeometry {
5
+ readonly geometry: BufferGeometry
6
+ readonly material: Material
7
+
8
+ readonly bvh: Readonly<AABB3>
9
+
10
+ from(geometry: BufferGeometry, material: Material): void
11
+
12
+ static from(geometry: BufferGeometry, material: Material): ShadedGeometry
13
+ }
@@ -0,0 +1,6 @@
1
+ import {System} from "../../../ecs/System";
2
+ import Engine from "../../../Engine";
3
+
4
+ export class ShadedGeometrySystem extends System {
5
+ constructor(engine: Engine)
6
+ }
@@ -0,0 +1,105 @@
1
+ import { DataType } from "../../../core/collection/table/DataType.js";
2
+ import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
3
+ import { DataTypeByteSizes } from "../../../core/collection/table/DataTypeByteSizes.js";
4
+ import { assert } from "../../../core/assert.js";
5
+
6
+ export class AttributeSpec {
7
+ constructor() {
8
+ /**
9
+ *
10
+ * @type {string}
11
+ */
12
+ this.name = "";
13
+
14
+ /**
15
+ *
16
+ * @type {DataType}
17
+ */
18
+ this.type = DataType.Float32;
19
+
20
+ /**
21
+ *
22
+ * @type {number}
23
+ */
24
+ this.itemSize = 1;
25
+
26
+ /**
27
+ * Normalized values will be automatically converted to float32 in the shader
28
+ * This gives good optimization opportunities for things like normal vectors
29
+ * Applies to integer types only
30
+ * @type {boolean}
31
+ */
32
+ this.normalized = false;
33
+ }
34
+
35
+ static fromJSON(j) {
36
+ const r = new AttributeSpec();
37
+
38
+ r.fromJSON(j);
39
+
40
+ return r;
41
+ }
42
+
43
+ fromJSON({
44
+ name,
45
+ type,
46
+ itemSize,
47
+ normalized = false
48
+ }) {
49
+
50
+ assert.isString(name, 'name');
51
+ assert.enum(type, DataType, 'type');
52
+
53
+ assert.isNumber(itemSize, 'itemSize');
54
+ assert.isNonNegativeInteger(itemSize, 'itemSize');
55
+ assert.greaterThanOrEqual(itemSize, 1, 'itemSize must be >= 1');
56
+
57
+ assert.isBoolean(normalized, 'normalized');
58
+
59
+ this.name = name;
60
+ this.type = type;
61
+ this.itemSize = itemSize;
62
+ this.normalized = normalized;
63
+ }
64
+
65
+ hash() {
66
+ return computeStringHash(this.name);
67
+ }
68
+
69
+ /**
70
+ *
71
+ * @param {AttributeSpec} other
72
+ * @returns {boolean}
73
+ */
74
+ equals(other) {
75
+ return this.type === other.type
76
+ && this.itemSize === other.itemSize
77
+ && this.normalized === other.normalized
78
+ && this.name === other.name
79
+ ;
80
+ }
81
+
82
+ /**
83
+ *
84
+ * @returns {number}
85
+ */
86
+ getByteSize() {
87
+ return this.itemSize * DataTypeByteSizes[this.type];
88
+ }
89
+
90
+ /**
91
+ *
92
+ * @param {AttributeSpec} a
93
+ * @param {AttributeSpec} b
94
+ * @return {number}
95
+ */
96
+ static byName(a, b) {
97
+ return a.name.localeCompare(b.name);
98
+ }
99
+ }
100
+
101
+ /**
102
+ * @readonly
103
+ * @type {boolean}
104
+ */
105
+ AttributeSpec.prototype.isAttributeSpec = true;
@@ -1,14 +1,14 @@
1
- import { isArrayEqual } from "../../../../core/collection/ArrayUtils.js";
2
- import { computeHashArray } from "../../../../core/math/MathUtils.js";
3
- import { invokeObjectHash } from "../../../../core/model/object/invokeObjectHash.js";
1
+ import { isArrayEqual } from "../../../core/collection/ArrayUtils.js";
2
+ import { invokeObjectHash } from "../../../core/model/object/invokeObjectHash.js";
3
+ import { computeHashArray } from "../../../core/collection/array/computeHashArray.js";
4
4
 
5
5
  const DEFAULT_HASH = 123456;
6
6
 
7
- export class MicronVertexDataSpec {
7
+ export class VertexDataSpec {
8
8
  constructor() {
9
9
  /**
10
10
  *
11
- * @type {MicronGeometryBufferAttributeSpec[]}
11
+ * @type {AttributeSpec[]}
12
12
  */
13
13
  this.attributes = [];
14
14
 
@@ -22,7 +22,49 @@ export class MicronVertexDataSpec {
22
22
 
23
23
  /**
24
24
  *
25
- * @param {MicronGeometryBufferAttributeSpec[]} attributes
25
+ * @param {string} name
26
+ * @return {AttributeSpec|undefined}
27
+ */
28
+ getAttributeByName(name) {
29
+
30
+ const attributes = this.attributes;
31
+ const n = attributes.length;
32
+
33
+ for (let i = 0; i < n; i++) {
34
+ const attribute = attributes[i];
35
+
36
+ if (attribute.name === name) {
37
+ return attribute;
38
+ }
39
+ }
40
+
41
+ return undefined;
42
+ }
43
+
44
+ /**
45
+ *
46
+ * @param {AttributeSpec} attribute
47
+ * @return {VertexDataSpec}
48
+ */
49
+ add(attribute) {
50
+
51
+ //check uniqueness of name
52
+ if (this.getAttributeByName(attribute.name) !== undefined) {
53
+ throw new Error(`Attribute named '${attribute.name}' already exists`);
54
+ }
55
+
56
+ this.attributes.push(attribute);
57
+
58
+ // reset hash
59
+ this.__hash = DEFAULT_HASH;
60
+
61
+ //for chaining, return self
62
+ return this;
63
+ }
64
+
65
+ /**
66
+ *
67
+ * @param {AttributeSpec[]} attributes
26
68
  */
27
69
  setAttributes(attributes) {
28
70
  this.attributes = attributes;
@@ -33,7 +75,7 @@ export class MicronVertexDataSpec {
33
75
 
34
76
  /**
35
77
  *
36
- * @param {MicronVertexDataSpec} other
78
+ * @param {VertexDataSpec} other
37
79
  * @returns {boolean}
38
80
  */
39
81
  equals(other) {
@@ -56,24 +98,6 @@ export class MicronVertexDataSpec {
56
98
  return this.__hash;
57
99
  }
58
100
 
59
- /**
60
- *
61
- * @param {string} name
62
- * @return {MicronGeometryBufferAttributeSpec|undefined}
63
- */
64
- getAttributeByName(name) {
65
- const attributes = this.attributes;
66
- const n = attributes.length;
67
- for (let i = 0; i < n; i++) {
68
- const spec = attributes[i];
69
-
70
- if (spec.name === name) {
71
- return spec;
72
- }
73
- }
74
-
75
- }
76
-
77
101
  /**
78
102
  *
79
103
  * @returns {number}
@@ -93,3 +117,10 @@ export class MicronVertexDataSpec {
93
117
  return result;
94
118
  }
95
119
  }
120
+
121
+
122
+ /**
123
+ * @readonly
124
+ * @type {boolean}
125
+ */
126
+ VertexDataSpec.prototype.isVertexDataSpec = true;
@@ -2,7 +2,7 @@ import { TopoMesh } from "../../../../core/geom/3d/topology/TopoMesh.js";
2
2
  import { PatchRepresentation } from "./PatchRepresentation.js";
3
3
  import { MicronGeometry } from "../format/MicronGeometry.js";
4
4
  import { buildAbstractPatchHierarchy } from "./hierarchy/buildAbstractPatchHierarchy.js";
5
- import { MicronGeometryBufferAttributeSpec } from "../format/MicronGeometryBufferAttributeSpec.js";
5
+ import { AttributeSpec } from "../../geometry/AttributeSpec.js";
6
6
  import { typedArrayToDataType } from "../../../../core/collection/array/typedArrayToDataType.js";
7
7
  import { DataType } from "../../../../core/collection/table/DataType.js";
8
8
  import { MicronGeometryPatch } from "../format/MicronGeometryPatch.js";
@@ -28,7 +28,7 @@ function current_time_millis() {
28
28
 
29
29
  /**
30
30
  *
31
- * @param {MicronGeometryBufferAttributeSpec} spec
31
+ * @param {AttributeSpec} spec
32
32
  * @param {THREE.BufferAttribute} source
33
33
  */
34
34
  function custom_attribute_format_normal(spec, source) {
@@ -39,7 +39,7 @@ function custom_attribute_format_normal(spec, source) {
39
39
 
40
40
  /**
41
41
  *
42
- * @param {MicronGeometryBufferAttributeSpec} spec
42
+ * @param {AttributeSpec} spec
43
43
  * @param {THREE.BufferAttribute} source
44
44
  */
45
45
  function custom_attribute_format_uv(spec, source) {
@@ -49,7 +49,7 @@ function custom_attribute_format_uv(spec, source) {
49
49
 
50
50
  /**
51
51
  *
52
- * @param {MicronGeometryBufferAttributeSpec} spec
52
+ * @param {AttributeSpec} spec
53
53
  * @param {THREE.BufferAttribute} source
54
54
  * @param {string} name
55
55
  */
@@ -76,7 +76,7 @@ function format_attribute(spec, source, name) {
76
76
  /**
77
77
  *
78
78
  * @param {THREE.BufferGeometry} buffer_geometry
79
- * @returns {MicronGeometryBufferAttributeSpec[]}
79
+ * @returns {AttributeSpec[]}
80
80
  */
81
81
  function attributes_from_buffer_geometry(buffer_geometry) {
82
82
  const result = [];
@@ -84,7 +84,7 @@ function attributes_from_buffer_geometry(buffer_geometry) {
84
84
  const source_attributes = buffer_geometry.attributes;
85
85
  for (const attributesKey in source_attributes) {
86
86
  const source_attribute = source_attributes[attributesKey];
87
- const spec = new MicronGeometryBufferAttributeSpec();
87
+ const spec = new AttributeSpec();
88
88
 
89
89
  format_attribute(spec, source_attribute, attributesKey);
90
90
 
@@ -92,7 +92,7 @@ function attributes_from_buffer_geometry(buffer_geometry) {
92
92
  }
93
93
 
94
94
  // to ensure that input order of attributes does not matter, we sort the attributes by name
95
- result.sort(MicronGeometryBufferAttributeSpec.byName);
95
+ result.sort(AttributeSpec.byName);
96
96
 
97
97
  return result;
98
98
  }
@@ -110,7 +110,7 @@ const DataConverterType = {
110
110
 
111
111
  /**
112
112
  * How to convert data from source three.js buffer attribute to what we store in the patch description based on the supplied micron spec
113
- * @param {MicronGeometryBufferAttributeSpec} spec
113
+ * @param {AttributeSpec} spec
114
114
  * @param {THREE.BufferAttribute} source
115
115
  * @returns {DataConverterType}
116
116
  */
@@ -2,7 +2,7 @@ import { FrontSide, Group, Mesh, MeshBasicMaterial, MeshStandardMaterial } from
2
2
  import { patchToBufferGeometry } from "./util/patchToBufferGeometry.js";
3
3
  import { Color } from "../../../core/color/Color.js";
4
4
  import { seededRandom } from "../../../core/math/random/seededRandom.js";
5
- import { randomFloatBetween } from "../../../core/math/MathUtils.js";
5
+ import { randomFloatBetween } from "../../../core/math/random/randomFloatBetween.js";
6
6
 
7
7
  /**
8
8
  *
@@ -1,4 +1,4 @@
1
- import { MicronVertexDataSpec } from "./MicronVertexDataSpec.js";
1
+ import { VertexDataSpec } from "../../geometry/VertexDataSpec.js";
2
2
  import { assert } from "../../../../core/assert.js";
3
3
 
4
4
  let id_counter = 0;
@@ -30,9 +30,9 @@ export class MicronGeometry {
30
30
 
31
31
  /**
32
32
  *
33
- * @type {MicronVertexDataSpec|null}
33
+ * @type {VertexDataSpec|null}
34
34
  */
35
- this.vertex_spec = new MicronVertexDataSpec();
35
+ this.vertex_spec = new VertexDataSpec();
36
36
 
37
37
  /**
38
38
  *
@@ -1,6 +1,6 @@
1
1
  import { BinaryClassSerializationAdapter } from "../../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
2
2
  import { MicronGeometry } from "../MicronGeometry.js";
3
- import { MicronGeometryBufferAttributeSpec } from "../MicronGeometryBufferAttributeSpec.js";
3
+ import { AttributeSpec } from "../../../geometry/AttributeSpec.js";
4
4
  import { MicronGeometryPatch } from "../MicronGeometryPatch.js";
5
5
  import { serialize_patch } from "./serialize_patch.js";
6
6
  import { deserialize_patch } from "./deserialize_patch.js";
@@ -63,7 +63,7 @@ export class MicronGeometryBinarySerializationAdapter extends BinaryClassSeriali
63
63
  const attribute_count = buffer.readUintVar();
64
64
  const attributes = [];
65
65
  for (let i = 0; i < attribute_count; i++) {
66
- const spec = new MicronGeometryBufferAttributeSpec();
66
+ const spec = new AttributeSpec();
67
67
 
68
68
  deserialize_attribute_spec(buffer, spec);
69
69
  attributes[i] = spec;
@@ -3,7 +3,7 @@ import { computeDataTypeByIndex } from "../../../../../core/collection/table/com
3
3
  /**
4
4
  *
5
5
  * @param {BinaryBuffer} buffer
6
- * @param {MicronGeometryBufferAttributeSpec} spec
6
+ * @param {AttributeSpec} spec
7
7
  */
8
8
  export function deserialize_attribute_spec(buffer, spec) {
9
9
 
@@ -3,7 +3,7 @@ import { DataTypeIndices } from "../../../../../core/collection/table/DataTypeIn
3
3
  /**
4
4
  *
5
5
  * @param {BinaryBuffer} buffer
6
- * @param {MicronGeometryBufferAttributeSpec} spec
6
+ * @param {AttributeSpec} spec
7
7
  */
8
8
  export function serialize_attribute_spec(buffer, spec) {
9
9
  buffer.writeUTF8String(spec.name);
@@ -1,7 +1,7 @@
1
1
  import { mortonEncode_magicbits } from "../../../../core/geom/3d/morton/mortonEncode_magicbits.js";
2
- import { computeHashFloat } from "../../../../core/math/MathUtils.js";
3
2
  import { isArrayEqualStrict } from "../../../../core/collection/array/isArrayEqualStrict.js";
4
3
  import { SimpleObjectPoolFactory } from "../../../../core/model/object/SimpleObjectPoolFactory.js";
4
+ import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
5
5
 
6
6
  export class PatchCacheKey {
7
7
  constructor() {
@@ -53,18 +53,18 @@ function normalized_internal_format(dt, channel_count) {
53
53
  export class AttributeDataTexture {
54
54
  /**
55
55
  *
56
- * @param {MicronGeometryBufferAttributeSpec} spec
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.isMicronGeometryBufferAttributeSpec, true, 'spec.isMicronGeometryBufferAttributeSpec !== true');
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 {MicronGeometryBufferAttributeSpec}
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 {MicronGeometryBufferAttributeSpec}
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 {MicronGeometryBufferAttributeSpec} spec
323
+ * @param {AttributeSpec} spec
324
324
  * @param {number} column_count
325
325
  */
326
326
  static from(spec, column_count) {
@@ -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/MathUtils.js";
7
+ import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
8
8
 
9
9
 
10
10
  const scratch_random = seededRandom(0);