@woosh/meep-engine 2.33.23 → 2.33.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/core/binary/BitSet.js +151 -167
  2. package/core/binary/BitSet.spec.js +99 -1
  3. package/core/binary/ValidatingBitSetWrapper.js +81 -0
  4. package/core/bvh2/BinaryNode.js +1 -1
  5. package/core/bvh2/aabb3/AABB3.js +21 -10
  6. package/core/bvh2/aabb3/AABB3Math.js +1 -1
  7. package/core/bvh2/binary/2/BinaryUint32BVH.js +498 -0
  8. package/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
  9. package/core/bvh2/binary/IndexedBinaryBVH.js +22 -26
  10. package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +5 -1
  11. package/core/bvh2/traversal/__detailed_box_volume_intersection.js +22 -5
  12. package/core/cache/Cache.d.ts +4 -2
  13. package/core/cache/Cache.js +5 -2
  14. package/core/collection/ArrayUtils.js +1 -1
  15. package/core/collection/HashMap.d.ts +9 -2
  16. package/core/collection/HashSet.d.ts +7 -2
  17. package/core/collection/HashSet.js +7 -2
  18. package/core/collection/array/arrayQuickSort.js +9 -6
  19. package/core/collection/array/array_swap.js +22 -0
  20. package/core/collection/array/binarySearchHighIndex.js +1 -1
  21. package/core/collection/array/computeHashArray.js +22 -0
  22. package/core/collection/array/computeHashIntegerArray.js +15 -0
  23. package/core/collection/array/copyArray.js +2 -2
  24. package/core/collection/array/typed/typed_array_copy.js +1 -1
  25. package/core/collection/table/DataType2TypedArrayConstructorMapping.js +15 -0
  26. package/core/color/Color.js +2 -1
  27. package/core/function/FunctionCompiler.js +2 -1
  28. package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
  29. package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +3 -3
  30. package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
  31. package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +41 -0
  32. package/core/geom/3d/morton/mortonEncode_magicbits.js +2 -1
  33. package/core/geom/3d/morton/reinterpret_float32_as_int32.js +13 -0
  34. package/core/geom/3d/morton/v3_morton_encode_transformed.js +33 -0
  35. package/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
  36. package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
  37. package/core/geom/3d/shape/AbstractShape3D.js +65 -0
  38. package/core/geom/3d/shape/TransformedShape3D.js +181 -0
  39. package/core/geom/3d/shape/TransformedShape3D.spec.js +33 -0
  40. package/core/geom/3d/shape/UnionShape3D.js +255 -0
  41. package/core/geom/3d/shape/UnitCubeShape3D.js +101 -0
  42. package/core/geom/3d/shape/UnitCubeShape3D.spec.js +42 -0
  43. package/core/geom/3d/shape/UnitSphereShape3D.js +55 -0
  44. package/core/geom/3d/shape/util/compute_signed_distance_gradient_by_sampling.js +48 -0
  45. package/core/geom/3d/shape/util/shape_to_visual_entity.js +159 -0
  46. package/core/geom/AABB2.js +1 -1
  47. package/core/geom/ConicRay.js +3 -1
  48. package/core/geom/LineSegment.js +0 -78
  49. package/core/geom/Matrix4.js +7 -8
  50. package/core/geom/Rectangle.js +2 -1
  51. package/core/geom/Vector1.js +1 -1
  52. package/core/geom/Vector3.js +2 -1
  53. package/core/geom/Vector4.js +2 -1
  54. package/core/geom/random/randomPointInBox.js +7 -3
  55. package/core/geom/random/randomPointInPoint.js +6 -3
  56. package/core/geom/random/randomPointInSphere.js +9 -5
  57. package/core/geom/random/randomPointOnBox.js +7 -3
  58. package/core/geom/random/randomPointOnSphere.js +6 -3
  59. package/core/geom/v3_length.js +8 -3
  60. package/core/graph/graph_k_means_cluster.js +1 -1
  61. package/core/json/resolvePathByArray.js +2 -2
  62. package/core/math/MathUtils.js +0 -354
  63. package/core/math/MathUtils.spec.js +7 -1
  64. package/core/math/gaussian.js +9 -0
  65. package/core/math/hash/computeHashFloat.js +17 -0
  66. package/core/math/hash/computeHashFloatArray.js +34 -0
  67. package/core/math/hash/computeObjectHash.js +54 -0
  68. package/core/math/intersects1D.js +19 -0
  69. package/core/math/interval/NumericInterval.js +2 -2
  70. package/core/math/isValueBetween.js +10 -0
  71. package/core/math/isValueBetweenInclusive.js +10 -0
  72. package/core/math/noise/curl_noise_3dt.js +1 -1
  73. package/core/math/noise/sdnoise.js +10 -10
  74. package/core/math/overlap1D.js +19 -0
  75. package/core/math/pingpong.js +17 -0
  76. package/core/math/random/makeRangedRandom.js +19 -0
  77. package/core/math/random/randomFloatBetween.js +14 -0
  78. package/core/math/random/randomFromArray.js +19 -0
  79. package/core/math/random/randomGaussian.js +15 -0
  80. package/core/math/random/randomIntegerBetween.js +14 -0
  81. package/core/math/random/roundFair.js +15 -0
  82. package/core/math/separation1D.js +21 -0
  83. package/core/math/solveQuadratic.js +25 -0
  84. package/core/model/BoundedValue.js +1 -1
  85. package/core/model/node-graph/node/NodeInstancePortReference.js +1 -1
  86. package/core/model/node-graph/node/Port.js +1 -1
  87. package/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +3 -1
  88. package/core/model/reactive/model/ReactiveBinaryExpression.js +1 -1
  89. package/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +1 -1
  90. package/core/model/reactive/model/terminal/ReactiveReference.js +1 -1
  91. package/core/model/reactive/model/util/createRandomReactiveExpression.js +1 -1
  92. package/core/model/stat/LinearModifier.js +1 -1
  93. package/core/parser/simple/Token.d.ts +13 -0
  94. package/core/parser/simple/Token.js +61 -27
  95. package/{engine/graphics/render/forward_plus/materials → core/primitives/strings}/insert_after.js +3 -0
  96. package/core/primitives/strings/insert_after_or_replace.js +27 -0
  97. package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
  98. package/editor/tools/FoliagePaintTool.js +4 -4
  99. package/editor/view/ecs/EntityEditor.js +2 -2
  100. package/editor/view/ecs/components/particles/ParticleEmitterController.js +2 -2
  101. package/engine/EngineHarness.js +1 -0
  102. package/engine/animation/AnimationUtils.js +5 -5
  103. package/engine/animation/curve/AnimationCurve.js +72 -0
  104. package/engine/animation/curve/Keyframe.js +27 -0
  105. package/engine/animation/keyed2/AnimationTrack.js +27 -3
  106. package/engine/asset/Asset.js +1 -1
  107. package/engine/asset/loaders/GLTFAssetLoader.d.ts +1 -1
  108. package/engine/asset/loaders/GLTFAssetLoader.js +62 -1
  109. package/engine/asset/loaders/image/ImageDecoderWorker.js +4 -3
  110. package/engine/asset/loaders/image/ImageRGBADataAsset.js +10 -2
  111. package/engine/asset/loaders/image/ImageRGBADataLoader.js +3 -3
  112. package/engine/asset/loaders/image/codec/NativeImageDecoder.js +2 -1
  113. package/engine/asset/loaders/image/png/PNG.js +113 -6
  114. package/engine/asset/loaders/image/png/PNGReader.js +5 -0
  115. package/engine/asset/loaders/material/bitmap2sampler_gl.js +1 -1
  116. package/engine/asset/loaders/material/computeImageBitmapEquality.js +6 -1
  117. package/engine/asset/loaders/material/computeMaterialHash.js +3 -1
  118. package/engine/asset/loaders/material/computeTextureEquality.js +40 -49
  119. package/engine/asset/loaders/material/computeTextureHash.js +2 -1
  120. package/engine/ecs/EntityBuilder.js +25 -5
  121. package/engine/ecs/EntityComponentDataset.js +1 -1
  122. package/engine/ecs/animation/Animation.js +2 -1
  123. package/engine/ecs/animation/InverseKinematics.js +2 -1
  124. package/engine/ecs/attachment/AttachmentBinding.js +8 -0
  125. package/engine/ecs/attachment/AttachmentSystem.js +4 -0
  126. package/engine/ecs/attachment/TransformAttachmentBinding.js +14 -44
  127. package/engine/ecs/components/Tag.js +27 -6
  128. package/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
  129. package/engine/ecs/dynamic_actions/DynamicRuleDescriptionTable.spec.js +3 -5
  130. package/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +1 -1
  131. package/engine/ecs/evaluation/complex/PointFitnessGaussianBlur.js +1 -1
  132. package/engine/ecs/foliage/InstancedFoliage.js +277 -266
  133. package/engine/ecs/foliage/ecs/Foliage2System.js +7 -7
  134. package/engine/ecs/foliage/ecs/InstancedMeshComponent.js +37 -0
  135. package/engine/ecs/foliage/ecs/{Foliage2.js → InstancedMeshLayer.js} +3 -45
  136. package/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +6 -5
  137. package/engine/ecs/foliage/ecs/InstancedMeshUtils.js +7 -6
  138. package/engine/ecs/fow/FogOfWar.js +4 -0
  139. package/engine/ecs/fow/FogOfWarSystem.js +2 -0
  140. package/engine/ecs/fow/shader/FogOfWarRenderer.js +1 -1
  141. package/engine/ecs/gui/GUIElement.js +1 -1
  142. package/engine/ecs/gui/hud/HeadsUpDisplay.js +1 -1
  143. package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -0
  144. package/engine/ecs/gui/position/ViewportPosition.js +2 -1
  145. package/engine/ecs/storage/binary/BinarySerializationRegistry.js +1 -1
  146. package/engine/ecs/system/AbstractContextSystem.js +1 -1
  147. package/engine/ecs/systems/RangedAttackSystem.js +1 -1
  148. package/engine/ecs/systems/SteeringSystem.js +1 -1
  149. package/engine/ecs/systems/TagSystem.js +17 -0
  150. package/engine/ecs/terrain/ecs/layers/TerrainLayer.js +12 -16
  151. package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
  152. package/engine/ecs/tooltip/TooltipComponent.js +15 -0
  153. package/engine/ecs/transform/Transform.js +19 -6
  154. package/engine/graphics/GraphicsEngine.js +11 -6
  155. package/engine/graphics/composit/CompositLayer.js +17 -4
  156. package/engine/graphics/composit/CompositingStages.js +8 -0
  157. package/engine/graphics/composit/LayerCompositer.js +35 -6
  158. package/engine/graphics/ecs/animation/animator/AnimationClip.js +2 -1
  159. package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -1
  160. package/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -1
  161. package/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -1
  162. package/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +2 -1
  163. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -1
  164. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +1 -1
  165. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +2 -1
  166. package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
  167. package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
  168. package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +11 -7
  169. package/engine/graphics/ecs/light/Light.d.ts +1 -1
  170. package/engine/graphics/ecs/light/Light.js +5 -0
  171. package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +5 -1
  172. package/engine/graphics/ecs/mesh/Mesh.js +2 -1
  173. package/engine/graphics/ecs/mesh-v2/DrawMode.js +5 -0
  174. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
  175. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +32 -18
  176. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
  177. package/engine/graphics/geometry/AttributeSpec.js +105 -0
  178. package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
  179. package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +14 -72
  180. package/engine/graphics/geometry/instancing/rewriteMaterial.js +70 -0
  181. package/engine/graphics/material/manager/MaterialManager.js +2 -1
  182. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
  183. package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
  184. package/engine/graphics/micron/buildPatchwork.js +1 -1
  185. package/engine/graphics/micron/format/MicronGeometry.js +3 -3
  186. package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +2 -2
  187. package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
  188. package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
  189. package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
  190. package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +11 -9
  191. package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +0 -2
  192. package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
  193. package/engine/graphics/particles/ParticleEmitterLibrary.js +3 -0
  194. package/engine/graphics/particles/ecs/{ParticleEmitterSystem2.js → ParticleEmitterSystem.js} +17 -9
  195. package/engine/graphics/particles/particular/engine/ParticularEngine.js +8 -2
  196. package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +80 -16
  197. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +71 -77
  198. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
  199. package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +2 -1
  200. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +141 -14
  201. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +8 -7
  202. package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +1 -1
  203. package/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +8 -2
  204. package/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +2 -1
  205. package/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js +1 -1
  206. package/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +1 -1
  207. package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +24 -0
  208. package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +262 -71
  209. package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
  210. package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +81 -48
  211. package/engine/graphics/particles/particular/engine/shader/debugAtlas.js +14 -0
  212. package/engine/graphics/particles/particular/engine/simulator/SimulationStepApplyForce.js +2 -5
  213. package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseAcceleration.js +2 -6
  214. package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.js +2 -7
  215. package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +2 -5
  216. package/engine/graphics/particles/particular/engine/simulator/update_parameters.js +1 -1
  217. package/engine/graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js +1 -1
  218. package/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.js +1 -1
  219. package/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +141 -0
  220. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +478 -0
  221. package/engine/graphics/particles/particular/engine/utils/volume/lut_to_sampler.js +27 -0
  222. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +938 -0
  223. package/engine/graphics/particles/particular/group/Operation.js +18 -0
  224. package/engine/graphics/particles/particular/group/OperationType.js +9 -0
  225. package/engine/graphics/particles/particular/group/ParticleAttribute.js +2 -1
  226. package/engine/graphics/particles/particular/group/ParticleAttributeType.js +11 -0
  227. package/engine/graphics/particles/particular/group/ParticleDataType.js +10 -0
  228. package/engine/graphics/particles/particular/group/ParticleGroup.js +7 -245
  229. package/engine/graphics/particles/particular/group/ParticleGroup.spec.js +3 -1
  230. package/engine/graphics/particles/particular/group/ParticleSpecification.js +21 -14
  231. package/engine/graphics/particles/particular/group/itemSizeFromAttributeType.js +20 -0
  232. package/engine/graphics/particles/particular/group/optimizeCommandQueue.js +162 -0
  233. package/engine/graphics/particles/particular/group/typedArrayConstructorFromDataType.js +19 -0
  234. package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +16 -11
  235. package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameter.js +2 -1
  236. package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameterSet.js +1 -1
  237. package/engine/graphics/render/forward_plus/LightManager.js +117 -94
  238. package/engine/graphics/render/forward_plus/PointLight.js +9 -0
  239. package/engine/graphics/render/forward_plus/PointLightData.js +1 -1
  240. package/engine/graphics/render/forward_plus/SpotLight.js +9 -0
  241. package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +2 -2
  242. package/engine/graphics/render/forward_plus/materials/FP_INJECTION_POINT_ACCUMULATION.js +1 -0
  243. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +32 -0
  244. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_DECODE_PARS.js +51 -0
  245. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +25 -0
  246. package/engine/graphics/render/forward_plus/materials/FPlusDebugMaterial.js +3 -3
  247. package/engine/graphics/render/forward_plus/materials/ForwardPlusThreeMaterial.js +1 -1
  248. package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +31 -120
  249. package/engine/graphics/render/forward_plus/materials/fp_build_vertex_lighting_shared.js +35 -0
  250. package/engine/graphics/render/forward_plus/materials/fp_build_vertex_shader.js +4 -5
  251. package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
  252. package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +10 -3
  253. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +594 -59
  254. package/engine/graphics/render/forward_plus/prototypeLightManager.js +208 -89
  255. package/engine/graphics/render/forward_plus/query/analytical_triplanar_corner_mapping.js +8 -0
  256. package/engine/graphics/render/forward_plus/query/cube_mapping.js +38 -0
  257. package/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +86 -0
  258. package/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +74 -0
  259. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +131 -0
  260. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +129 -0
  261. package/engine/graphics/render/forward_plus/query/spot_light_inside_volume.js +33 -0
  262. package/engine/graphics/render/forward_plus/read_frustum_corner.js +14 -0
  263. package/engine/graphics/render/forward_plus/testClusterEquality.js +22 -0
  264. package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
  265. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
  266. package/engine/graphics/shaders/TerrainShader.js +4 -5
  267. package/engine/graphics/shadows/ShadowMapRenderer.js +8 -2
  268. package/engine/graphics/texture/atlas/ManagedTextureAtlas.js +12 -1
  269. package/engine/graphics/texture/sampler/HarmonicDiffusionGrid.spec.js +1 -1
  270. package/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
  271. package/engine/graphics/texture/sampler/Sampler2D.js +3 -1
  272. package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +1 -1
  273. package/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js +66 -0
  274. package/engine/graphics/texture/sampler/distanceField.spec.js +1 -1
  275. package/engine/graphics/util/composeMatrix4.js +33 -23
  276. package/engine/graphics/util/decompose_matrix_4_array.js +61 -0
  277. package/engine/grid/components/GridObstacle.js +1 -1
  278. package/engine/intelligence/behavior/ecs/BehaviorComponent.js +30 -14
  279. package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
  280. package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
  281. package/engine/knowledge/database/StaticKnowledgeDataTable.js +6 -1
  282. package/engine/navigation/ecs/components/Path.js +1 -6
  283. package/engine/navigation/grid/FastBinaryHeap.spec.js +1 -1
  284. package/engine/sound/ecs/emitter/SoundEmitter.js +2 -1
  285. package/engine/sound/ecs/emitter/SoundTrack.js +2 -1
  286. package/engine/sound/material/concrete/RandomSoundMaterial.js +1 -1
  287. package/engine/ui/notification/notificationGenerator.js +1 -1
  288. package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +1 -1
  289. package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
  290. package/generation/markers/actions/MarkerNodeActionSelectRandom.js +1 -1
  291. package/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +1 -1
  292. package/generation/placement/action/random/CellActionSelectRandom.js +1 -1
  293. package/generation/theme/ThemeEngine.js +1 -1
  294. package/misc/makeMaterialIconCached.js +2 -2
  295. package/package.json +1 -1
  296. package/view/elements/image/HTMLElementCacheKey.js +2 -1
  297. package/view/elements/radial/RadialText.js +2 -1
  298. package/view/minimap/gl/MinimapMarkersGL.js +6 -100
  299. package/view/minimap/gl/MinimapWorldGL.js +12 -5
  300. package/view/minimap/gl/buildMaterial.js +94 -0
  301. package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +0 -71
  302. package/engine/graphics/render/forward_plus/queryBVH_Frustum.js +0 -357
@@ -0,0 +1,101 @@
1
+ import { AbstractShape3D } from "./AbstractShape3D.js";
2
+ import { randomPointInBox } from "../../random/randomPointInBox.js";
3
+ import { v3_length } from "../../v3_length.js";
4
+ import { max2 } from "../../../math/max2.js";
5
+ import { max3 } from "../../../math/max3.js";
6
+ import { min2 } from "../../../math/min2.js";
7
+ import { clamp } from "../../../math/clamp.js";
8
+ import { compute_signed_distance_gradient_by_sampling } from "./util/compute_signed_distance_gradient_by_sampling.js";
9
+
10
+ export class UnitCubeShape3D extends AbstractShape3D {
11
+
12
+ get volume() {
13
+ return 1;
14
+ }
15
+
16
+ nearest_point_on_surface(result, reference) {
17
+ const r_x = reference[0];
18
+ const r_y = reference[1];
19
+ const r_z = reference[2];
20
+
21
+ // figure out closest face to the reference point
22
+ const ar_x = Math.abs(r_x);
23
+ const ar_y = Math.abs(r_y);
24
+ const ar_z = Math.abs(r_z);
25
+
26
+ if (ar_x > ar_y && ar_x > ar_z) {
27
+ // X is smallest, project onto X axis
28
+ if (r_x <= 0) {
29
+ result[0] = -0.5;
30
+ } else {
31
+ result[0] = 0.5;
32
+ }
33
+
34
+ result[1] = clamp(r_y, -0.5, 0.5);
35
+ result[2] = clamp(r_z, -0.5, 0.5);
36
+ } else if (ar_y > ar_x && ar_y > ar_z) {
37
+ // Y is smallest, project onto X axis
38
+ if (r_y <= 0) {
39
+ result[1] = -0.5;
40
+ } else {
41
+ result[1] = 0.5;
42
+ }
43
+
44
+ result[0] = clamp(r_x, -0.5, 0.5);
45
+ result[2] = clamp(r_z, -0.5, 0.5);
46
+ } else {
47
+ // project onto Z axis
48
+
49
+ if (r_z <= 0) {
50
+ result[2] = -0.5;
51
+ } else {
52
+ result[2] = 0.5;
53
+ }
54
+
55
+ result[0] = clamp(r_x, -0.5, 0.5);
56
+ result[1] = clamp(r_y, -0.5, 0.5);
57
+ }
58
+ }
59
+
60
+ signed_distance_gradient_at_point(result, point) {
61
+ return compute_signed_distance_gradient_by_sampling(result,this, point);
62
+ }
63
+
64
+ signed_distance_at_point(point) {
65
+ /*
66
+ based on https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
67
+ original shader code:
68
+ ------------
69
+ float sdBox( vec3 p, vec3 b )
70
+ {
71
+ vec3 q = abs(p) - b;
72
+ return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);
73
+ }
74
+ ------------
75
+ */
76
+ const q_x = Math.abs(point[0]) - 0.5;
77
+ const q_y = Math.abs(point[1]) - 0.5;
78
+ const q_z = Math.abs(point[2]) - 0.5;
79
+
80
+ return v3_length(
81
+ max2(q_x, 0),
82
+ max2(q_y, 0),
83
+ max2(q_z, 0)
84
+ ) + min2(max3(q_x, q_y, q_z), 0);
85
+ }
86
+
87
+ contains_point(point) {
88
+ const x = point[0];
89
+ const y = point[1];
90
+ const z = point[2];
91
+
92
+ return x > -0.5 && x < 0.5
93
+ && y > -0.5 && y < 0.5
94
+ && z > -0.5 && z < 0.5
95
+ ;
96
+ }
97
+
98
+ sample_random_point_in_volume(result, result_offset, random) {
99
+ randomPointInBox(random, result, result_offset);
100
+ }
101
+ }
@@ -0,0 +1,42 @@
1
+ import { UnitCubeShape3D } from "./UnitCubeShape3D.js";
2
+
3
+ test('signed distance', () => {
4
+ const s = new UnitCubeShape3D();
5
+
6
+ expect(s.signed_distance_at_point([0, 0, 0])).toBeCloseTo(-0.5);
7
+
8
+ expect(s.signed_distance_at_point([0.5, 0, 0])).toBeCloseTo(0);
9
+ expect(s.signed_distance_at_point([0, 0.5, 0])).toBeCloseTo(0);
10
+ expect(s.signed_distance_at_point([0, 0, 0.5])).toBeCloseTo(0);
11
+
12
+ expect(s.signed_distance_at_point([-0.5, 0, 0])).toBeCloseTo(0);
13
+ expect(s.signed_distance_at_point([0, -0.5, 0])).toBeCloseTo(0);
14
+ expect(s.signed_distance_at_point([0, 0, -0.5])).toBeCloseTo(0);
15
+
16
+ expect(s.signed_distance_at_point([0.5, 0.5, 0])).toBeCloseTo(0);
17
+ expect(s.signed_distance_at_point([0, 0.5, 0.5])).toBeCloseTo(0);
18
+ expect(s.signed_distance_at_point([0.5, 0, 0.5])).toBeCloseTo(0);
19
+
20
+ expect(s.signed_distance_at_point([-0.5, 0.5, 0])).toBeCloseTo(0);
21
+ expect(s.signed_distance_at_point([0.5, -0.5, 0])).toBeCloseTo(0);
22
+ expect(s.signed_distance_at_point([-0.5, -0.5, 0])).toBeCloseTo(0);
23
+
24
+ expect(s.signed_distance_at_point([0, -0.5, 0.5])).toBeCloseTo(0);
25
+ expect(s.signed_distance_at_point([0, 0.5, -0.5])).toBeCloseTo(0);
26
+ expect(s.signed_distance_at_point([0, -0.5, -0.5])).toBeCloseTo(0);
27
+
28
+ expect(s.signed_distance_at_point([-0.5, 0, 0.5])).toBeCloseTo(0);
29
+ expect(s.signed_distance_at_point([0.5, 0, -0.5])).toBeCloseTo(0);
30
+ expect(s.signed_distance_at_point([-0.5, 0, -0.5])).toBeCloseTo(0);
31
+
32
+ expect(s.signed_distance_at_point([0.5, 0.5, 0.5])).toBeCloseTo(0);
33
+ expect(s.signed_distance_at_point([-0.5, 0.5, 0.5])).toBeCloseTo(0);
34
+ expect(s.signed_distance_at_point([0.5, -0.5, 0.5])).toBeCloseTo(0);
35
+ expect(s.signed_distance_at_point([0.5, 0.5, -0.5])).toBeCloseTo(0);
36
+ expect(s.signed_distance_at_point([-0.5, -0.5, 0.5])).toBeCloseTo(0);
37
+ expect(s.signed_distance_at_point([0.5, -0.5, -0.5])).toBeCloseTo(0);
38
+ expect(s.signed_distance_at_point([-0.5, 0.5, -0.5])).toBeCloseTo(0);
39
+ expect(s.signed_distance_at_point([-0.5, -0.5, -0.5])).toBeCloseTo(0);
40
+
41
+ expect(s.signed_distance_at_point([1, 0, 0])).toBeCloseTo(0.5);
42
+ });
@@ -0,0 +1,55 @@
1
+ import { AbstractShape3D } from "./AbstractShape3D.js";
2
+ import { randomPointInSphere } from "../../random/randomPointInSphere.js";
3
+ import { v3_length } from "../../v3_length.js";
4
+ import { compute_signed_distance_gradient_by_sampling } from "./util/compute_signed_distance_gradient_by_sampling.js";
5
+
6
+ /**
7
+ * Sphere with diameter of 1 (radius = 0.5)
8
+ */
9
+ export class UnitSphereShape3D extends AbstractShape3D {
10
+ get volume() {
11
+ return 0.523598776;
12
+ }
13
+
14
+ get surface_area() {
15
+ return 3.14159265;
16
+ }
17
+
18
+ nearest_point_on_surface(result, reference) {
19
+
20
+ const r_x = reference[0];
21
+ const r_y = reference[1];
22
+ const r_z = reference[2];
23
+
24
+ // normalize vector to 0.5 radius
25
+ const d = 0.5 / Math.hypot(r_x, r_y, r_z);
26
+
27
+ result[0] = r_x * d;
28
+ result[1] = r_y * d;
29
+ result[2] = r_z * d;
30
+ }
31
+
32
+ signed_distance_gradient_at_point(result, point) {
33
+ return compute_signed_distance_gradient_by_sampling(result,this, point);
34
+ }
35
+
36
+ signed_distance_at_point(point) {
37
+ return v3_length(
38
+ point[0],
39
+ point[1],
40
+ point[2]
41
+ ) - 0.5;
42
+ }
43
+
44
+ contains_point(point) {
45
+ const x = point[0];
46
+ const y = point[1];
47
+ const z = point[2];
48
+
49
+ return (x * x + y * y + z * z) < 0.25;
50
+ }
51
+
52
+ sample_random_point_in_volume(result, result_offset, random) {
53
+ randomPointInSphere(random, result, result_offset);
54
+ }
55
+ }
@@ -0,0 +1,48 @@
1
+ const scratch_v = [];
2
+
3
+ /**
4
+ *
5
+ * @param {number[]} result
6
+ * @param {AbstractShape3D} shape
7
+ * @param {number[]} point
8
+ * @returns {number}
9
+ */
10
+ export function compute_signed_distance_gradient_by_sampling(result, shape, point) {
11
+ const v0 = shape.signed_distance_at_point(point);
12
+
13
+ scratch_v[0] = point[0] + 1e-5;
14
+ scratch_v[1] = point[1];
15
+ scratch_v[2] = point[2];
16
+
17
+ const vx = shape.signed_distance_at_point(scratch_v);
18
+
19
+ scratch_v[0] = point[0];
20
+ scratch_v[1] = point[1] + 1e-5;
21
+ scratch_v[2] = point[2];
22
+
23
+ const vy = shape.signed_distance_at_point(point);
24
+
25
+ scratch_v[0] = point[0];
26
+ scratch_v[1] = point[1];
27
+ scratch_v[2] = point[2] + 1e-5;
28
+
29
+ const vz = shape.signed_distance_at_point(point);
30
+
31
+ // convert absolute sample values to relative
32
+ const rx = vx - v0;
33
+ const ry = vy - v0;
34
+ const rz = vz - v0;
35
+
36
+ // normalize by sampling distance
37
+ const d = 1e-5 / 1.73205080757;
38
+
39
+ const nx = rx * d;
40
+ const ny = ry * d;
41
+ const nz = rz * d;
42
+
43
+ result[0] = nx;
44
+ result[1] = ny;
45
+ result[2] = nz;
46
+
47
+ return v0;
48
+ }
@@ -0,0 +1,159 @@
1
+ import { UnionShape3D } from "../UnionShape3D.js";
2
+ import { UnitCubeShape3D } from "../UnitCubeShape3D.js";
3
+ import { UnitSphereShape3D } from "../UnitSphereShape3D.js";
4
+ import { TransformedShape3D } from "../TransformedShape3D.js";
5
+ import EntityBuilder from "../../../../../engine/ecs/EntityBuilder.js";
6
+ import { Transform } from "../../../../../engine/ecs/transform/Transform.js";
7
+ import { AttachmentSockets } from "../../../../../engine/ecs/sockets/AttachmentSockets.js";
8
+ import { Attachment } from "../../../../../engine/ecs/attachment/Attachment.js";
9
+ import { ShadedGeometry } from "../../../../../engine/graphics/ecs/mesh-v2/ShadedGeometry.js";
10
+ import { LineBasicMaterial } from "three";
11
+ import { makeHelperSphereGeometry } from "../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
12
+ import { DrawMode } from "../../../../../engine/graphics/ecs/mesh-v2/DrawMode.js";
13
+ import { makeHelperBoxGeometry } from "../../../../../editor/process/symbolic/makeHelperBoxGeometry.js";
14
+ import Tag from "../../../../../engine/ecs/components/Tag.js";
15
+
16
+ const g_unit_sphere = makeHelperSphereGeometry(0.5, 32);
17
+ const g_unit_cube = makeHelperBoxGeometry(1, 1, 1);
18
+
19
+ const lineMaterial = new LineBasicMaterial({
20
+ depthTest: true,
21
+ depthWrite: false,
22
+ transparent: true,
23
+ linewidth: 1,
24
+ fog: false,
25
+ color: '#FFFFFF',
26
+ opacity: 1
27
+ });
28
+
29
+ export const SHAPE_VISUAL_ENTITY_TAG = 'util/vis/Shape3D';
30
+
31
+ /**
32
+ *
33
+ * @param {UnionShape3D} shape
34
+ * @param {EntityComponentDataset} ecd
35
+ * @returns {EntityBuilder}
36
+ */
37
+ function composite_shape_to_entity(shape, ecd) {
38
+
39
+ const parent = new EntityBuilder();
40
+ parent
41
+ .add(new Transform())
42
+ .add(AttachmentSockets.fromJSON({
43
+ elements: [
44
+ {
45
+ type: 0,
46
+ id: 0
47
+ }
48
+ ]
49
+ }))
50
+ .build(ecd);
51
+
52
+ shape.children.forEach(c => {
53
+
54
+ const child_entity = shape_to_visual_entity(c, ecd);
55
+
56
+ child_entity.add(Attachment.fromJSON({
57
+ socket: 0,
58
+ parent: parent.entity,
59
+ immediate: true
60
+ }));
61
+
62
+ })
63
+
64
+ return parent;
65
+ }
66
+
67
+
68
+ /**
69
+ *
70
+ * @param {UnitCubeShape3D} shape
71
+ * @param {EntityComponentDataset} ecd
72
+ * @returns {EntityBuilder}
73
+ */
74
+ function cube_shape_to_entity(shape, ecd) {
75
+ const eb = new EntityBuilder();
76
+
77
+ eb.add(new Transform());
78
+ eb.add(Tag.fromOne(SHAPE_VISUAL_ENTITY_TAG));
79
+ eb.add(ShadedGeometry.from(g_unit_cube, lineMaterial, DrawMode.LineSegments));
80
+
81
+ eb.build(ecd);
82
+
83
+ return eb;
84
+ }
85
+
86
+
87
+ /**
88
+ *
89
+ * @param {UnitSphereShape3D} shape
90
+ * @param {EntityComponentDataset} ecd
91
+ * @returns {EntityBuilder}
92
+ */
93
+ function sphere_shape_to_entity(shape, ecd) {
94
+ const eb = new EntityBuilder();
95
+
96
+ eb.add(new Transform());
97
+ eb.add(Tag.fromOne(SHAPE_VISUAL_ENTITY_TAG));
98
+ eb.add(ShadedGeometry.from(g_unit_sphere, lineMaterial, DrawMode.Lines));
99
+
100
+ eb.build(ecd);
101
+
102
+ return eb;
103
+
104
+ }
105
+
106
+ /**
107
+ *
108
+ * @param {TransformedShape3D} shape
109
+ * @param {EntityComponentDataset} ecd
110
+ * @returns {EntityBuilder}
111
+ */
112
+ function transformed_shape_to_entity(shape, ecd) {
113
+ const subject = shape_to_visual_entity(shape.subject, ecd);
114
+
115
+ const parent = new EntityBuilder();
116
+ parent
117
+ .add(new Transform())
118
+ .add(AttachmentSockets.fromJSON({
119
+ elements: [
120
+ {
121
+ type: 0,
122
+ id: 0
123
+ }
124
+ ]
125
+ }))
126
+ .build(ecd);
127
+
128
+ const attachment = Attachment.fromJSON({
129
+ socket: 0,
130
+ parent: parent.entity,
131
+ immediate: true
132
+ });
133
+
134
+ attachment.transform.fromMatrix4(shape.transform);
135
+
136
+ subject.add(attachment);
137
+
138
+ return parent;
139
+ }
140
+
141
+ /**
142
+ *
143
+ * @param {AbstractShape3D} shape
144
+ * @param {EntityComponentDataset} ecd
145
+ * @returns {EntityBuilder}
146
+ */
147
+ export function shape_to_visual_entity(shape, ecd) {
148
+ if (shape instanceof UnionShape3D) {
149
+ return composite_shape_to_entity(shape, ecd);
150
+ } else if (shape instanceof UnitCubeShape3D) {
151
+ return cube_shape_to_entity(shape, ecd);
152
+ } else if (shape instanceof UnitSphereShape3D) {
153
+ return sphere_shape_to_entity(shape, ecd);
154
+ } else if (shape instanceof TransformedShape3D) {
155
+ return transformed_shape_to_entity(shape, ecd);
156
+ } else {
157
+ throw new Error('Unsupported shape type');
158
+ }
159
+ }
@@ -6,11 +6,11 @@
6
6
 
7
7
  import { assert } from "../assert.js";
8
8
  import { clamp } from "../math/clamp.js";
9
- import { overlap1D } from "../math/MathUtils.js";
10
9
  import { max2 } from "../math/max2.js";
11
10
  import { min2 } from "../math/min2.js";
12
11
  import LineSegment2 from "./LineSegment2.js";
13
12
  import Vector2 from "./Vector2.js";
13
+ import { overlap1D } from "../math/overlap1D.js";
14
14
 
15
15
  /**
16
16
  *
@@ -1,6 +1,8 @@
1
1
  import { assert } from "../assert.js";
2
- import { computeHashFloat, computeHashIntegerArray, EPSILON, epsilonEquals } from "../math/MathUtils.js";
2
+ import { EPSILON, epsilonEquals } from "../math/MathUtils.js";
3
3
  import Vector3 from "./Vector3.js";
4
+ import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
5
+ import { computeHashFloat } from "../math/hash/computeHashFloat.js";
4
6
 
5
7
 
6
8
  /**
@@ -3,8 +3,6 @@
3
3
  */
4
4
  import { clamp } from "../math/clamp.js";
5
5
  import Vector3 from "./Vector3.js";
6
- import { v3_dot } from "./v3_dot.js";
7
- import { v3_distance_sqr } from "./v3_distance_sqr.js";
8
6
 
9
7
 
10
8
  const SMALL_NUM = 1e-9;
@@ -19,82 +17,6 @@ const LineSegment = function (first, second) {
19
17
 
20
18
  };
21
19
 
22
- /**
23
- *
24
- * @param {Vector3} result
25
- * @param {number} origin_x
26
- * @param {number} origin_y
27
- * @param {number} origin_z
28
- * @param {number} direction_x
29
- * @param {number} direction_y
30
- * @param {number} direction_z
31
- * @param {number} px
32
- * @param {number} py
33
- * @param {number} pz
34
- * @returns {number} distance from origin, negative means that the point lies behind the origin in the direction opposite to the ray's own
35
- */
36
- export function ray_computeNearestPointToPoint(result, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, px, py, pz) {
37
- // find closest point
38
- const sp0_x = px - origin_x;
39
- const sp0_y = py - origin_y;
40
- const sp0_z = pz - origin_z;
41
-
42
- //
43
- const d2 = v3_dot(direction_x, direction_y, direction_z, direction_x, direction_y, direction_z);
44
- const d3 = v3_dot(direction_x, direction_y, direction_z, sp0_x, sp0_y, sp0_z);
45
-
46
- const t = d3 / d2;
47
-
48
- // compute point on the ray
49
- const lp_x = direction_x * t + origin_x;
50
- const lp_y = direction_y * t + origin_y;
51
- const lp_z = direction_z * t + origin_z;
52
-
53
- result.set(lp_x, lp_y, lp_z);
54
-
55
- return t;
56
- }
57
-
58
- /**
59
- * Computes shortest distance between a line segment(defined by 2 points) and a point
60
- * @param {number} x0
61
- * @param {number} y0
62
- * @param {number} z0
63
- * @param {number} x1
64
- * @param {number} y1
65
- * @param {number} z1
66
- * @param {number} px
67
- * @param {number} py
68
- * @param {number} pz
69
- */
70
- export function line3_computeSegmentPointDistance_sqr(x0, y0, z0, x1, y1, z1, px, py, pz) {
71
- // find closest point
72
- const sp0_x = px - x0;
73
- const sp0_y = py - y0;
74
- const sp0_z = pz - z0;
75
-
76
- // get line delta
77
- const line_delta_x = x1 - x0;
78
- const line_delta_y = y1 - y0;
79
- const line_delta_z = z1 - z0;
80
-
81
- //
82
- const d2 = line_delta_x * line_delta_x + line_delta_y * line_delta_y + line_delta_z * line_delta_z;
83
-
84
-
85
- const d3 = line_delta_x * sp0_x + line_delta_y * sp0_y + line_delta_z * sp0_z;
86
-
87
- const t = clamp(d3 / d2, 0, 1);
88
-
89
- // compute point on the line
90
- const lp_x = line_delta_x * t + x0;
91
- const lp_y = line_delta_y * t + y0;
92
- const lp_z = line_delta_z * t + z0;
93
-
94
- // compute distance from the point in question to the point on the line
95
- return v3_distance_sqr(px, py, pz, lp_x, lp_y, lp_z);
96
- }
97
-
98
20
  LineSegment.prototype.closestPointToPointParameter = function (point, clampToLine) {
99
21
 
100
22
 
@@ -1,5 +1,4 @@
1
1
  import Vector3 from "./Vector3.js";
2
- import { v3_length } from "./v3_length.js";
3
2
 
4
3
  const _z = new Vector3();
5
4
  const _x = new Vector3();
@@ -193,12 +192,12 @@ export class Matrix4 {
193
192
  decompose(position, rotation, scale) {
194
193
 
195
194
 
196
- var sx = v3_length(this.a0, this.a1, this.a2);
197
- var sy = v3_length(this.b0, this.b1, this.b2);
198
- var sz = v3_length(this.c0, this.c1, this.c2);
195
+ let sx = Math.hypot(this.a0, this.a1, this.a2);
196
+ const sy = Math.hypot(this.b0, this.b1, this.b2);
197
+ const sz = Math.hypot(this.c0, this.c1, this.c2);
199
198
 
200
199
  // if determine is negative, we need to invert one scale
201
- var det = this.determinant();
200
+ const det = this.determinant();
202
201
  if (det < 0) sx = -sx;
203
202
 
204
203
  position.set(
@@ -208,9 +207,9 @@ export class Matrix4 {
208
207
  );
209
208
 
210
209
  // scale the rotation part
211
- var invSX = 1 / sx;
212
- var invSY = 1 / sy;
213
- var invSZ = 1 / sz;
210
+ const invSX = 1 / sx;
211
+ const invSY = 1 / sy;
212
+ const invSZ = 1 / sz;
214
213
 
215
214
  const i_a0 = this.a0 * invSX;
216
215
  const i_a1 = this.a1 * invSX;
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Created by Alex on 14/03/2016.
3
3
  */
4
- import { intersects1D, overlap1D } from "../math/MathUtils.js";
5
4
  import { max2 } from "../math/max2.js";
6
5
  import { min2 } from "../math/min2.js";
7
6
  import Vector2 from "./Vector2.js";
7
+ import { intersects1D } from "../math/intersects1D.js";
8
+ import { overlap1D } from "../math/overlap1D.js";
8
9
 
9
10
 
10
11
  /**
@@ -6,7 +6,7 @@
6
6
  import { assert } from "../assert.js";
7
7
  import Signal from "../events/signal/Signal.js";
8
8
  import { clamp } from "../math/clamp.js";
9
- import { computeHashFloat } from "../math/MathUtils.js";
9
+ import { computeHashFloat } from "../math/hash/computeHashFloat.js";
10
10
 
11
11
 
12
12
  class Vector1 extends Number {
@@ -6,7 +6,7 @@
6
6
  import { assert } from "../assert.js";
7
7
  import Signal from "../events/signal/Signal.js";
8
8
  import { lerp } from "../math/lerp.js";
9
- import { computeHashFloat, EPSILON, epsilonEquals } from "../math/MathUtils.js";
9
+ import { EPSILON, epsilonEquals } from "../math/MathUtils.js";
10
10
  import { sign } from "../math/sign.js";
11
11
  import { v3_dot } from "./v3_dot.js";
12
12
  import { v3_length_sqr } from "./v3_length_sqr.js";
@@ -14,6 +14,7 @@ import { v3_length } from "./v3_length.js";
14
14
  import { v3_angle_between } from "./v3_angle_between.js";
15
15
  import { v3_lerp } from "./v3_lerp.js";
16
16
  import { v3_slerp } from "./v3_slerp.js";
17
+ import { computeHashFloat } from "../math/hash/computeHashFloat.js";
17
18
 
18
19
  class Vector3 {
19
20
  /**
@@ -5,7 +5,8 @@
5
5
  import { assert } from "../assert.js";
6
6
  import { Signal } from "../events/signal/Signal.js";
7
7
  import { lerp } from "../math/lerp.js";
8
- import { computeHashFloat, computeHashIntegerArray } from "../math/MathUtils.js";
8
+ import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
9
+ import { computeHashFloat } from "../math/hash/computeHashFloat.js";
9
10
 
10
11
  /**
11
12
  *
@@ -1,12 +1,16 @@
1
1
  /**
2
2
  *
3
3
  * @param {function} random
4
- * @param {Vector3} result
4
+ * @param {number[]} result
5
+ * @param {number} result_offset
5
6
  */
6
- export function randomPointInBox(random, result) {
7
+ export function randomPointInBox(random, result, result_offset) {
7
8
  const x = random() - 0.5;
8
9
  const y = random() - 0.5;
9
10
  const z = random() - 0.5;
10
11
 
11
- result.set(x, y, z);
12
+ //write the result
13
+ result[result_offset] = x;
14
+ result[result_offset + 1] = y;
15
+ result[result_offset + 2] = z;
12
16
  }
@@ -1,8 +1,11 @@
1
1
  /**
2
2
  * Volumetric sampling method, since sample volume is a point, it simply sets result to origin
3
3
  * @param {function} random
4
- * @param {Vector3} result
4
+ * @param {number[]} result
5
+ * @param {number} destination_offset
5
6
  */
6
- export function randomPointInPoint(random, result) {
7
- result.set(0, 0, 0);
7
+ export function randomPointInPoint(random, result, destination_offset) {
8
+ result[destination_offset] = 0;
9
+ result[destination_offset + 1] = 0;
10
+ result[destination_offset + 2] = 0;
8
11
  }
@@ -4,18 +4,20 @@ import { PI2 } from "../../math/MathUtils.js";
4
4
  *
5
5
  * @see based on python code suggested here: https://stackoverflow.com/questions/5408276/sampling-uniformly-distributed-random-points-inside-a-spherical-volume
6
6
  * @param {function} random
7
- * @param {Vector3} result
7
+ * @param {number[]} result
8
+ * @param {number} result_offset
8
9
  */
9
- export function randomPointInSphere(random, result) {
10
+ export function randomPointInSphere(random, result, result_offset) {
10
11
  const phi = PI2 * random();
11
12
 
12
13
  const cosTheta = random() * 2 - 1;
13
14
 
14
- const u = random() * 0.5;
15
+ const u = random();
15
16
 
16
17
  const theta = Math.acos(cosTheta);
17
18
 
18
- const r = Math.cbrt(u);
19
+ // compute radius
20
+ const r = Math.cbrt(u) * 0.5;
19
21
 
20
22
  const sinTheta = Math.sin(theta);
21
23
 
@@ -27,5 +29,7 @@ export function randomPointInSphere(random, result) {
27
29
  const z = r * cosTheta;
28
30
 
29
31
  //write the result
30
- result.set(x, y, z);
32
+ result[result_offset] = x;
33
+ result[result_offset + 1] = y;
34
+ result[result_offset + 2] = z;
31
35
  }