@woosh/meep-engine 2.33.20 → 2.33.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/core/assert.js +3 -1
  2. package/core/bvh2/BinaryNode.js +1 -1
  3. package/core/bvh2/aabb3/AABB3.js +18 -0
  4. package/core/bvh2/aabb3/AABB3Math.js +1 -1
  5. package/core/bvh2/binary/2/BinaryUint32BVH.js +498 -0
  6. package/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
  7. package/core/bvh2/binary/IndexedBinaryBVH.js +22 -26
  8. package/core/bvh2/traversal/__detailed_box_volume_intersection.js +11 -8
  9. package/core/collection/ArrayUtils.js +1 -1
  10. package/core/collection/HashMap.js +66 -22
  11. package/core/collection/array/arrayQuickSort.js +9 -6
  12. package/core/collection/array/array_swap.js +22 -0
  13. package/core/collection/array/computeHashArray.js +22 -0
  14. package/core/collection/array/computeHashIntegerArray.js +15 -0
  15. package/core/collection/table/DataType2TypedArrayConstructorMapping.js +15 -0
  16. package/core/color/Color.js +2 -1
  17. package/core/function/FunctionCompiler.js +2 -1
  18. package/core/geom/3d/CircleMath.js +4 -4
  19. package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
  20. package/core/geom/3d/cone/computeConeBoundingBox.js +4 -4
  21. package/core/geom/3d/{compute_bounding_cone_of_2_cones.js → cone/compute_bounding_cone_of_2_cones.js} +3 -3
  22. package/core/geom/3d/{compute_bounding_cone_of_2_cones.spec.js → cone/compute_bounding_cone_of_2_cones.spec.js} +1 -1
  23. package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +1 -1
  24. package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +11 -3
  25. package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +41 -0
  26. package/core/geom/3d/morton/mortonEncode_magicbits.js +2 -1
  27. package/core/geom/3d/morton/reinterpret_float32_as_int32.js +13 -0
  28. package/core/geom/3d/morton/v3_morton_encode_transformed.js +33 -0
  29. package/core/geom/3d/{encode_unit3_hemioct.js → normal/hemioct/encode_unit3_hemioct.js} +0 -0
  30. package/core/geom/3d/{unit_hemioct.spec.js → normal/hemioct/unit_hemioct.spec.js} +1 -1
  31. package/core/geom/3d/normal/lamber_azimuth/transform.js +61 -0
  32. package/core/geom/3d/normal/spherical/sphere_map_transform.js +77 -0
  33. package/core/geom/3d/{lerp_planes_to_array.js → plane/lerp_planes_to_array.js} +1 -3
  34. package/core/geom/3d/plane/plane3_lerp.js +3 -1
  35. package/core/geom/3d/plane/plane3_slerp.js +4 -1
  36. package/core/geom/3d/{plane_computeConvex3PlaneIntersection.js → plane/plane_computeConvex3PlaneIntersection.js} +14 -16
  37. package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
  38. package/core/geom/3d/shape/AbstractShape3D.js +29 -0
  39. package/core/geom/3d/shape/CompositeShape.js +60 -0
  40. package/core/geom/3d/shape/TransformedShape3D.js +70 -0
  41. package/core/geom/3d/shape/UnitCubeShape3D.js +13 -0
  42. package/core/geom/3d/shape/UnitSphereShape3D.js +16 -0
  43. package/core/geom/3d/topology/TopoTriangle.js +1 -1
  44. package/core/geom/3d/topology/TopoVertex.js +1 -1
  45. package/core/geom/3d/topology/bounds/computeTraingleClusterNormalBoundingCone.js +2 -2
  46. package/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +1 -1
  47. package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +1 -1
  48. package/core/geom/3d/triangle/computeTrianglePlaneSide.js +1 -1
  49. package/core/geom/3d/triangle/computeTriangleRayIntersection.js +1 -1
  50. package/core/geom/3d/voxel/DenseBitVolume3D.js +87 -0
  51. package/core/geom/3d/voxel/buildVolumeFromProjectedGeometry.js +23 -0
  52. package/core/geom/AABB2.js +1 -1
  53. package/core/geom/ConicRay.js +3 -1
  54. package/core/geom/LineSegment.js +1 -77
  55. package/core/geom/Matrix4.js +8 -8
  56. package/core/geom/Plane.js +15 -10
  57. package/core/geom/Quaternion.js +2 -1
  58. package/core/geom/Rectangle.js +2 -1
  59. package/core/geom/Vector1.js +1 -1
  60. package/core/geom/Vector3.d.ts +2 -0
  61. package/core/geom/Vector3.js +35 -159
  62. package/core/geom/Vector3.spec.js +2 -1
  63. package/core/geom/Vector4.js +2 -1
  64. package/core/geom/random/randomPointInBox.js +7 -3
  65. package/core/geom/random/randomPointInPoint.js +6 -3
  66. package/core/geom/random/randomPointInSphere.js +6 -3
  67. package/core/geom/random/randomPointOnBox.js +7 -3
  68. package/core/geom/random/randomPointOnSphere.js +6 -3
  69. package/core/geom/v3_angle_between.js +31 -0
  70. package/core/geom/v3_distance.js +16 -0
  71. package/core/geom/v3_distance_sqr.js +17 -0
  72. package/core/geom/v3_dot.js +13 -0
  73. package/core/geom/v3_length.js +10 -0
  74. package/core/geom/v3_length_sqr.js +10 -0
  75. package/core/geom/v3_lerp.js +21 -0
  76. package/core/geom/v3_slerp.js +48 -0
  77. package/core/graph/graph_k_means_cluster.js +1 -1
  78. package/core/math/MathUtils.js +0 -354
  79. package/core/math/MathUtils.spec.js +7 -1
  80. package/core/math/gaussian.js +9 -0
  81. package/core/math/hash/computeHashFloat.js +17 -0
  82. package/core/math/hash/computeHashFloatArray.js +34 -0
  83. package/core/math/hash/computeObjectHash.js +54 -0
  84. package/core/math/intersects1D.js +19 -0
  85. package/core/math/interval/NumericInterval.js +2 -2
  86. package/core/math/isValueBetween.js +10 -0
  87. package/core/math/isValueBetweenInclusive.js +10 -0
  88. package/core/math/noise/curl_noise_3dt.js +1 -1
  89. package/core/math/noise/sdnoise.js +10 -10
  90. package/core/math/overlap1D.js +19 -0
  91. package/core/math/pingpong.js +17 -0
  92. package/core/math/random/makeRangedRandom.js +19 -0
  93. package/core/math/random/randomFloatBetween.js +14 -0
  94. package/core/math/random/randomFromArray.js +19 -0
  95. package/core/math/random/randomGaussian.js +15 -0
  96. package/core/math/random/randomIntegerBetween.js +14 -0
  97. package/core/math/random/roundFair.js +15 -0
  98. package/core/math/separation1D.js +21 -0
  99. package/core/math/solveQuadratic.js +25 -0
  100. package/core/model/BoundedValue.js +1 -1
  101. package/core/model/node-graph/node/NodeInstancePortReference.js +1 -1
  102. package/core/model/node-graph/node/Port.js +1 -1
  103. package/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +3 -1
  104. package/core/model/reactive/model/ReactiveBinaryExpression.js +1 -1
  105. package/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +1 -1
  106. package/core/model/reactive/model/terminal/ReactiveReference.js +1 -1
  107. package/core/model/reactive/model/util/createRandomReactiveExpression.js +1 -1
  108. package/core/model/stat/LinearModifier.js +1 -1
  109. package/core/primitives/array/computeIntegerArrayHash.js +6 -1
  110. package/engine/animation/curve/AnimationCurve.js +72 -0
  111. package/engine/animation/curve/Keyframe.js +27 -0
  112. package/engine/animation/keyed2/AnimationTrack.js +27 -3
  113. package/engine/asset/Asset.js +1 -1
  114. package/engine/asset/loaders/GLTFAssetLoader.d.ts +1 -1
  115. package/engine/asset/loaders/GLTFAssetLoader.js +10 -0
  116. package/engine/asset/loaders/image/ImageRGBADataAsset.js +8 -1
  117. package/engine/asset/loaders/material/computeImageBitmapEquality.js +11 -0
  118. package/engine/asset/loaders/material/computeImageBitmapHash.js +22 -28
  119. package/engine/asset/loaders/material/computeMaterialHash.js +4 -3
  120. package/engine/asset/loaders/material/computeTextureEquality.js +13 -5
  121. package/engine/asset/loaders/material/computeTextureHash.js +2 -1
  122. package/engine/ecs/animation/Animation.js +2 -1
  123. package/engine/ecs/animation/InverseKinematics.js +2 -1
  124. package/engine/ecs/animation/OneBoneSurfaceAlignmentSolver.js +3 -1
  125. package/engine/ecs/animation/TwoBoneInverseKinematicsSolver.js +3 -1
  126. package/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
  127. package/engine/ecs/dynamic_actions/DynamicRuleDescriptionTable.spec.js +3 -5
  128. package/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +1 -1
  129. package/engine/ecs/evaluation/complex/PointFitnessGaussianBlur.js +1 -1
  130. package/engine/ecs/foliage/ecs/Foliage2.js +1 -1
  131. package/engine/ecs/fow/FogOfWar.js +2 -3
  132. package/engine/ecs/fow/shader/FogOfWarRenderer.js +1 -1
  133. package/engine/ecs/gui/GUIElement.js +1 -1
  134. package/engine/ecs/gui/hud/HeadsUpDisplay.js +1 -1
  135. package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +1 -1
  136. package/engine/ecs/gui/position/ViewportPosition.js +2 -1
  137. package/engine/ecs/systems/RangedAttackSystem.js +1 -1
  138. package/engine/ecs/systems/SteeringSystem.js +3 -2
  139. package/engine/ecs/terrain/ecs/Terrain.js +6 -0
  140. package/engine/ecs/terrain/ecs/layers/TerrainLayers.js +5 -0
  141. package/engine/ecs/terrain/ecs/splat/SplatMapping.js +5 -0
  142. package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
  143. package/engine/ecs/tooltip/TooltipComponent.js +15 -0
  144. package/engine/ecs/util/hideEntityGracefully.js +18 -0
  145. package/engine/graphics/GraphicsEngine.js +1 -0
  146. package/engine/graphics/camera/testClippingPlaneComputation.js +2 -2
  147. package/engine/graphics/ecs/animation/animator/AnimationClip.js +2 -1
  148. package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -1
  149. package/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -1
  150. package/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -1
  151. package/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +2 -1
  152. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -1
  153. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +1 -1
  154. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +2 -1
  155. package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +2 -2
  156. package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
  157. package/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +0 -53
  158. package/engine/graphics/ecs/light/Light.d.ts +1 -1
  159. package/engine/graphics/ecs/light/Light.js +3 -0
  160. package/engine/graphics/ecs/mesh/Mesh.js +2 -1
  161. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
  162. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
  163. package/engine/graphics/ecs/path/testPathDisplaySystem.js +98 -98
  164. package/engine/graphics/ecs/trail2d/Trail2D.js +17 -4
  165. package/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts +2 -3
  166. package/engine/graphics/ecs/trail2d/Trail2DSystem.js +34 -118
  167. package/engine/graphics/geometry/AttributeSpec.js +105 -0
  168. package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
  169. package/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +2 -1
  170. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
  171. package/engine/graphics/micron/build/clustering/computeFaceCurvatureScore.js +1 -1
  172. package/engine/graphics/micron/build/clustering/compute_face_connection_weight.js +1 -1
  173. package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
  174. package/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +1 -1
  175. package/engine/graphics/micron/build/hierarchy/patch_combine.js +1 -1
  176. package/engine/graphics/micron/buildPatchwork.js +1 -1
  177. package/engine/graphics/micron/format/MicronGeometry.js +3 -3
  178. package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +2 -2
  179. package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
  180. package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
  181. package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
  182. package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +5 -5
  183. package/engine/graphics/micron/render/refinement/is_patch_facing_back.js +2 -2
  184. package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
  185. package/engine/graphics/particles/particular/engine/ParticularEngine.js +4 -2
  186. package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +84 -0
  187. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +92 -144
  188. package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +14 -3
  189. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +51 -12
  190. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +3 -2
  191. package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +37 -0
  192. package/engine/graphics/particles/particular/engine/emitter/distance_to_camera.js +25 -0
  193. package/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +8 -2
  194. package/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +2 -1
  195. package/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js +1 -1
  196. package/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +1 -1
  197. package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +21 -0
  198. package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +0 -20
  199. package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
  200. package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +7 -25
  201. package/engine/graphics/particles/particular/engine/simulator/SimulationStepApplyForce.js +2 -5
  202. package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseAcceleration.js +2 -6
  203. package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.js +2 -7
  204. package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +2 -5
  205. package/engine/graphics/particles/particular/engine/simulator/update_parameters.js +1 -1
  206. package/engine/graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js +1 -1
  207. package/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.js +1 -1
  208. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +384 -0
  209. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +558 -0
  210. package/engine/graphics/particles/particular/group/Operation.js +18 -0
  211. package/engine/graphics/particles/particular/group/OperationType.js +9 -0
  212. package/engine/graphics/particles/particular/group/ParticleAttribute.js +2 -1
  213. package/engine/graphics/particles/particular/group/ParticleAttributeType.js +11 -0
  214. package/engine/graphics/particles/particular/group/ParticleDataType.js +10 -0
  215. package/engine/graphics/particles/particular/group/ParticleGroup.js +7 -245
  216. package/engine/graphics/particles/particular/group/ParticleGroup.spec.js +3 -1
  217. package/engine/graphics/particles/particular/group/ParticleSpecification.js +21 -14
  218. package/engine/graphics/particles/particular/group/itemSizeFromAttributeType.js +20 -0
  219. package/engine/graphics/particles/particular/group/optimizeCommandQueue.js +162 -0
  220. package/engine/graphics/particles/particular/group/typedArrayConstructorFromDataType.js +19 -0
  221. package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +2 -2
  222. package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +1 -1
  223. package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameter.js +2 -1
  224. package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameterSet.js +1 -1
  225. package/engine/graphics/render/forward_plus/LightManager.js +126 -95
  226. package/engine/graphics/render/forward_plus/PointLight.js +9 -0
  227. package/engine/graphics/render/forward_plus/PointLightData.js +1 -1
  228. package/engine/graphics/render/forward_plus/SpotLight.js +9 -0
  229. package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +2 -2
  230. package/engine/graphics/render/forward_plus/computeFrustumCorners.js +15 -33
  231. package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
  232. package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +12 -2
  233. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +6 -6
  234. package/engine/graphics/render/forward_plus/prototypeLightManager.js +231 -136
  235. package/engine/graphics/render/forward_plus/query/analytical_triplanar_corner_mapping.js +8 -0
  236. package/engine/graphics/render/forward_plus/query/cube_mapping.js +38 -0
  237. package/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +86 -0
  238. package/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +73 -0
  239. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +131 -0
  240. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +129 -0
  241. package/engine/graphics/render/forward_plus/query/spot_light_inside_volume.js +33 -0
  242. package/engine/graphics/render/forward_plus/read_frustum_corner.js +14 -0
  243. package/engine/graphics/render/forward_plus/testClusterEquality.js +22 -0
  244. package/engine/graphics/render/layers/RenderLayerUtils.js +8 -5
  245. package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
  246. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -2
  247. package/engine/graphics/texture/atlas/AtlasPatch.js +7 -2
  248. package/engine/graphics/texture/atlas/TextureAtlas.js +18 -14
  249. package/engine/graphics/texture/sampler/HarmonicDiffusionGrid.spec.js +1 -1
  250. package/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
  251. package/engine/graphics/texture/sampler/Sampler2D.js +8 -7
  252. package/engine/graphics/texture/sampler/distanceField.spec.js +1 -1
  253. package/engine/graphics/texture/sampler/scaleSampler2D.js +7 -10
  254. package/engine/graphics/trail/x/RibbonMaterialX.js +3 -3
  255. package/engine/graphics/trail/x/RibbonX.js +17 -2
  256. package/engine/graphics/trail/x/RibbonXPlugin.js +51 -1
  257. package/engine/graphics/util/projectSphere.js +1 -1
  258. package/engine/grid/components/GridObstacle.js +3 -10
  259. package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
  260. package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
  261. package/engine/navigation/ecs/components/Path.js +3 -2
  262. package/engine/navigation/grid/FastBinaryHeap.spec.js +1 -1
  263. package/engine/reference/v2/Reference.js +6 -0
  264. package/engine/sound/ecs/emitter/SoundEmitter.js +2 -1
  265. package/engine/sound/ecs/emitter/SoundTrack.js +2 -1
  266. package/engine/sound/material/concrete/RandomSoundMaterial.js +1 -1
  267. package/engine/ui/notification/notificationGenerator.js +1 -1
  268. package/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +3 -2
  269. package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +1 -1
  270. package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
  271. package/generation/markers/GridCellActionPlaceMarker.js +13 -1
  272. package/generation/markers/MarkerNode.js +6 -0
  273. package/generation/markers/actions/MarkerNodeActionSelectRandom.js +1 -1
  274. package/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +1 -1
  275. package/generation/placement/action/random/CellActionSelectRandom.js +1 -1
  276. package/generation/theme/ThemeEngine.js +5 -2
  277. package/misc/makeMaterialIconCached.js +2 -2
  278. package/package.json +3 -3
  279. package/view/View.js +4 -2
  280. package/view/elements/image/HTMLElementCacheKey.js +2 -1
  281. package/view/elements/radial/RadialText.js +2 -1
  282. package/view/minimap/gl/MinimapMarkersGL.js +19 -101
  283. package/view/minimap/gl/buildMaterial.js +94 -0
  284. package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +0 -71
  285. package/engine/graphics/render/forward_plus/queryBVH_Frustum.js +0 -345
@@ -1,4 +1,4 @@
1
- import { v3_dot } from "../../Vector3.js";
1
+ import { v3_dot } from "../../v3_dot.js";
2
2
 
3
3
  /**
4
4
  * Produces a numeric result to indicate which side of the plane the triangle is on
@@ -1,4 +1,4 @@
1
- import { v3_dot } from "../../Vector3.js";
1
+ import { v3_dot } from "../../v3_dot.js";
2
2
 
3
3
  /**
4
4
  * NOTE: adapted from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
@@ -0,0 +1,87 @@
1
+ import Vector3 from "../../Vector3.js";
2
+ import { BitSet } from "../../../binary/BitSet.js";
3
+
4
+ export class DenseBitVolume3D {
5
+ constructor() {
6
+ this.size = new Vector3(1, 1, 1);
7
+
8
+ this.__data = new BitSet();
9
+ this.__data.preventShrink();
10
+ }
11
+
12
+ clear() {
13
+ this.__data.reset();
14
+ }
15
+
16
+ resize(x, y, z) {
17
+ // TODO consider how we can resize while keeping the data
18
+ this.clear();
19
+
20
+ this.size.set(x, y, z);
21
+ }
22
+
23
+ /**
24
+ *
25
+ * @param {number} x
26
+ * @param {number} y
27
+ * @param {number} z
28
+ * @return {number}
29
+ * @private
30
+ */
31
+ __compute_address(x, y, z) {
32
+
33
+ const size = this.size;
34
+
35
+ const dx = size.x;
36
+ const dy = size.y;
37
+
38
+ return y * dx + z * dx * dy + x;
39
+ }
40
+
41
+ /**
42
+ *
43
+ * @param {number} x
44
+ * @param {number} y
45
+ * @param {number} z
46
+ * @return {boolean}
47
+ */
48
+ get(x, y, z) {
49
+ const address = this.__compute_address(x, y, z);
50
+
51
+ return this.__data.get(address)
52
+ }
53
+
54
+ /**
55
+ *
56
+ * @param {boolean} value
57
+ * @param {number} x
58
+ * @param {number} y
59
+ * @param {number} z
60
+ */
61
+ set(value, x, y, z) {
62
+ const address = this.__compute_address(x, y, z);
63
+
64
+ this.__data.set(address, value);
65
+ }
66
+
67
+ /**
68
+ *
69
+ * @param {number} u x-coordinate, normalized to [0,1] range
70
+ * @param {number} v y-coordinate, normalized to [0,1] range
71
+ * @param {number} w z-coordinate, normalized to [0,1] range
72
+ * @returns {boolean}
73
+ */
74
+ sampleNearest(u, v, w) {
75
+ const s = this.size;
76
+
77
+ const dx = s.x;
78
+ const dy = s.y;
79
+ const dz = s.z;
80
+
81
+ const x = Math.round(dx * u) % dx
82
+ const y = Math.round(dy * v) % dy
83
+ const z = Math.round(dz * w) % dz
84
+
85
+ return this.get(x, y, z);
86
+ }
87
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Build a world-space oriented volume
3
+ * @param {DenseBitVolume3D} volume
4
+ * @param {AABB3} bounds
5
+ * @param {{raycast:function(source_x:number, source_y:number, source_z:number, direction_x:number, direction_y:number, direction_z:number):number}} sampler
6
+ * @param {number[]} frustum 3d frustum, defined as series of 6 planes in order: normal_x, normal_y, normal_z, plane_offset
7
+ */
8
+ export function buildVolumeFromProjectedGeometry({ volume, sampler, frustum }) {
9
+ // get frustum corners
10
+
11
+ // get first hits from "front" plane to seed the volume
12
+ for (let x = 0; x < 64; x++) {
13
+ for (let y = 0; y < 64; y++) {
14
+
15
+ }
16
+ }
17
+
18
+ // fit volume to the frustum
19
+
20
+ // create a connectivity graph to identify disconnected regions
21
+
22
+ // clear out disconnected regions starting from smallest until only one is left
23
+ }
@@ -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
  /**
@@ -2,7 +2,7 @@
2
2
  * Created by Alex on 18/03/14.
3
3
  */
4
4
  import { clamp } from "../math/clamp.js";
5
- import Vector3, { v3_distance_sqr, v3_dot } from "./Vector3.js";
5
+ import Vector3 from "./Vector3.js";
6
6
 
7
7
 
8
8
  const SMALL_NUM = 1e-9;
@@ -17,82 +17,6 @@ const LineSegment = function (first, second) {
17
17
 
18
18
  };
19
19
 
20
- /**
21
- *
22
- * @param {Vector3} result
23
- * @param {number} origin_x
24
- * @param {number} origin_y
25
- * @param {number} origin_z
26
- * @param {number} direction_x
27
- * @param {number} direction_y
28
- * @param {number} direction_z
29
- * @param {number} px
30
- * @param {number} py
31
- * @param {number} pz
32
- * @returns {number} distance from origin, negative means that the point lies behind the origin in the direction opposite to the ray's own
33
- */
34
- export function ray_computeNearestPointToPoint(result, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, px, py, pz) {
35
- // find closest point
36
- const sp0_x = px - origin_x;
37
- const sp0_y = py - origin_y;
38
- const sp0_z = pz - origin_z;
39
-
40
- //
41
- const d2 = v3_dot(direction_x, direction_y, direction_z, direction_x, direction_y, direction_z);
42
- const d3 = v3_dot(direction_x, direction_y, direction_z, sp0_x, sp0_y, sp0_z);
43
-
44
- const t = d3 / d2;
45
-
46
- // compute point on the ray
47
- const lp_x = direction_x * t + origin_x;
48
- const lp_y = direction_y * t + origin_y;
49
- const lp_z = direction_z * t + origin_z;
50
-
51
- result.set(lp_x, lp_y, lp_z);
52
-
53
- return t;
54
- }
55
-
56
- /**
57
- * Computes shortest distance between a line segment(defined by 2 points) and a point
58
- * @param {number} x0
59
- * @param {number} y0
60
- * @param {number} z0
61
- * @param {number} x1
62
- * @param {number} y1
63
- * @param {number} z1
64
- * @param {number} px
65
- * @param {number} py
66
- * @param {number} pz
67
- */
68
- export function line3_computeSegmentPointDistance_sqr(x0, y0, z0, x1, y1, z1, px, py, pz) {
69
- // find closest point
70
- const sp0_x = px - x0;
71
- const sp0_y = py - y0;
72
- const sp0_z = pz - z0;
73
-
74
- // get line delta
75
- const line_delta_x = x1 - x0;
76
- const line_delta_y = y1 - y0;
77
- const line_delta_z = z1 - z0;
78
-
79
- //
80
- const d2 = line_delta_x * line_delta_x + line_delta_y * line_delta_y + line_delta_z * line_delta_z;
81
-
82
-
83
- const d3 = line_delta_x * sp0_x + line_delta_y * sp0_y + line_delta_z * sp0_z;
84
-
85
- const t = clamp(d3 / d2, 0, 1);
86
-
87
- // compute point on the line
88
- const lp_x = line_delta_x * t + x0;
89
- const lp_y = line_delta_y * t + y0;
90
- const lp_z = line_delta_z * t + z0;
91
-
92
- // compute distance from the point in question to the point on the line
93
- return v3_distance_sqr(px, py, pz, lp_x, lp_y, lp_z);
94
- }
95
-
96
20
  LineSegment.prototype.closestPointToPointParameter = function (point, clampToLine) {
97
21
 
98
22
 
@@ -1,4 +1,4 @@
1
- import Vector3, { v3_length } from "./Vector3.js";
1
+ import Vector3 from "./Vector3.js";
2
2
 
3
3
  const _z = new Vector3();
4
4
  const _x = new Vector3();
@@ -192,12 +192,12 @@ export class Matrix4 {
192
192
  decompose(position, rotation, scale) {
193
193
 
194
194
 
195
- var sx = v3_length(this.a0, this.a1, this.a2);
196
- var sy = v3_length(this.b0, this.b1, this.b2);
197
- 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);
198
198
 
199
199
  // if determine is negative, we need to invert one scale
200
- var det = this.determinant();
200
+ const det = this.determinant();
201
201
  if (det < 0) sx = -sx;
202
202
 
203
203
  position.set(
@@ -207,9 +207,9 @@ export class Matrix4 {
207
207
  );
208
208
 
209
209
  // scale the rotation part
210
- var invSX = 1 / sx;
211
- var invSY = 1 / sy;
212
- var invSZ = 1 / sz;
210
+ const invSX = 1 / sx;
211
+ const invSY = 1 / sy;
212
+ const invSZ = 1 / sz;
213
213
 
214
214
  const i_a0 = this.a0 * invSX;
215
215
  const i_a1 = this.a1 * invSX;
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
 
6
- import { v3_dot } from "./Vector3.js";
6
+ import { v3_dot } from "./v3_dot.js";
7
7
 
8
8
  function Plane() {
9
9
 
@@ -192,7 +192,8 @@ export function computePlaneLineIntersection(out, originX, originY, originZ, dir
192
192
 
193
193
  /**
194
194
  *
195
- * @param {Vector3} result
195
+ * @param {Float32Array|number[]|vec3} result
196
+ * @param {number} result_offset
196
197
  * @param {number} x0
197
198
  * @param {number} y0
198
199
  * @param {number} z0
@@ -205,30 +206,34 @@ export function computePlaneLineIntersection(out, originX, originY, originZ, dir
205
206
  * @param {number} dist
206
207
  * @returns {boolean}
207
208
  */
208
- export function plane3_computeLineSegmentIntersection(result, x0, y0, z0, x1, y1, z1, normalX, normalY, normalZ, dist) {
209
+ export function plane3_computeLineSegmentIntersection(
210
+ result, result_offset,
211
+ x0, y0, z0,
212
+ x1, y1, z1,
213
+ normalX, normalY, normalZ, dist
214
+ ) {
215
+
209
216
  const directionX = x1 - x0;
210
217
  const directionY = y1 - y0;
211
218
  const directionZ = z1 - z0;
212
219
 
213
220
  const denom = v3_dot(directionX, directionY, directionZ, normalX, normalY, normalZ);
214
221
 
215
- const p = v3_dot(normalX, normalY, normalZ, x0, y0, z0) + dist;
216
-
217
222
  if (denom === 0) {
218
223
  return false;
219
224
  }
220
225
 
226
+ const p = v3_dot(normalX, normalY, normalZ, x0, y0, z0) + dist;
227
+
221
228
  const t = -p / denom;
222
229
 
223
230
  if (t < 0 || t > 1) {
224
231
  return false;
225
232
  }
226
233
 
227
- result.set(
228
- directionX * t + x0,
229
- directionY * t + y0,
230
- directionZ * t + z0
231
- );
234
+ result[result_offset] = directionX * t + x0;
235
+ result[result_offset + 1] = directionY * t + y0;
236
+ result[result_offset + 2] = directionZ * t + z0;
232
237
 
233
238
  return true;
234
239
 
@@ -10,7 +10,8 @@ import { clamp } from "../math/clamp.js";
10
10
  import { copysign } from "../math/copysign.js";
11
11
  import { lerp } from "../math/lerp.js";
12
12
  import { EPSILON, epsilonEquals, PI2, PI_HALF } from "../math/MathUtils.js";
13
- import Vector3, { v3_dot } from "./Vector3.js";
13
+ import Vector3 from "./Vector3.js";
14
+ import { v3_dot } from "./v3_dot.js";
14
15
 
15
16
  const matrix = new ThreeMatrix4();
16
17
 
@@ -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 {
@@ -65,6 +65,8 @@ export default class Vector3 implements Vector3Like {
65
65
 
66
66
  applyMatrix3_three(m4: Matrix3): void
67
67
 
68
+ transformDirection_three(m4: Matrix4): void
69
+
68
70
  angleTo(other: Vector3Like): number
69
71
 
70
72
  toJSON(): any
@@ -5,10 +5,16 @@
5
5
 
6
6
  import { assert } from "../assert.js";
7
7
  import Signal from "../events/signal/Signal.js";
8
- import { clamp } from "../math/clamp.js";
9
8
  import { lerp } from "../math/lerp.js";
10
- import { computeHashFloat, EPSILON, epsilonEquals } from "../math/MathUtils.js";
9
+ import { EPSILON, epsilonEquals } from "../math/MathUtils.js";
11
10
  import { sign } from "../math/sign.js";
11
+ import { v3_dot } from "./v3_dot.js";
12
+ import { v3_length_sqr } from "./v3_length_sqr.js";
13
+ import { v3_length } from "./v3_length.js";
14
+ import { v3_angle_between } from "./v3_angle_between.js";
15
+ import { v3_lerp } from "./v3_lerp.js";
16
+ import { v3_slerp } from "./v3_slerp.js";
17
+ import { computeHashFloat } from "../math/hash/computeHashFloat.js";
12
18
 
13
19
  class Vector3 {
14
20
  /**
@@ -442,7 +448,7 @@ class Vector3 {
442
448
  * @returns {number}
443
449
  */
444
450
  angleTo(other) {
445
- return v3_angleBetween(this.x, this.y, this.z, other.x, other.y, other.z);
451
+ return v3_angle_between(this.x, this.y, this.z, other.x, other.y, other.z);
446
452
  }
447
453
 
448
454
  /**
@@ -534,6 +540,32 @@ class Vector3 {
534
540
  return this.set(_x, _y, _z);
535
541
  }
536
542
 
543
+ /**
544
+ * Assume current vector holds a direction, transform using a matrix to produce a new directional unit vector
545
+ * @param {THREE.Matrix4} m
546
+ */
547
+ transformDirection_three(m) {
548
+
549
+ // input: THREE.Matrix4 affine matrix
550
+ // vector interpreted as a direction
551
+
552
+ const x = this.x, y = this.y, z = this.z;
553
+ const e = m.elements;
554
+
555
+ const _x = e[0] * x + e[4] * y + e[8] * z;
556
+ const _y = e[1] * x + e[5] * y + e[9] * z;
557
+ const _z = e[2] * x + e[6] * y + e[10] * z;
558
+
559
+ // normalize the result
560
+ const _l = 1 / v3_length(_x, _y, _z);
561
+
562
+ this.set(
563
+ _x * _l,
564
+ _y * _l,
565
+ _z * _l
566
+ );
567
+ }
568
+
537
569
  /**
538
570
  *
539
571
  * @param {THREE.Matrix3} m
@@ -947,20 +979,6 @@ Vector3.back = Object.freeze(new Vector3(0, 0, -1));
947
979
  Vector3.typeName = "Vector3";
948
980
 
949
981
 
950
- /**
951
- *
952
- * @param {number} x0
953
- * @param {number} y0
954
- * @param {number} z0
955
- * @param {number} x1
956
- * @param {number} y1
957
- * @param {number} z1
958
- * @returns {number}
959
- */
960
- export function v3_dot(x0, y0, z0, x1, y1, z1) {
961
- return (x0 * x1 + y0 * y1 + z0 * z1);
962
- }
963
-
964
982
  /**
965
983
  *
966
984
  * @param {number} x0
@@ -973,87 +991,11 @@ export function v3_dot(x0, y0, z0, x1, y1, z1) {
973
991
  */
974
992
  Vector3._dot = v3_dot;
975
993
 
976
- /**
977
- *
978
- * @param {number} x0
979
- * @param {number} y0
980
- * @param {number} z0
981
- * @param {number} x1
982
- * @param {number} y1
983
- * @param {number} z1
984
- * @returns {number}
985
- */
986
- export function v3_distance(x0, y0, z0, x1, y1, z1) {
987
-
988
- return Math.sqrt(v3_distance_sqr(x0, y0, z0, x1, y1, z1));
989
- }
990
-
991
- /**
992
- *
993
- * @param {number} x0
994
- * @param {number} y0
995
- * @param {number} z0
996
- * @param {number} x1
997
- * @param {number} y1
998
- * @param {number} z1
999
- * @returns {number}
1000
- */
1001
- export function v3_distance_sqr(x0, y0, z0, x1, y1, z1) {
1002
- const x = x0 - x1;
1003
- const y = y0 - y1;
1004
- const z = z0 - z1;
1005
-
1006
- return x * x + y * y + z * z;
1007
- }
1008
-
1009
994
 
1010
995
  function v3Length(v) {
1011
996
  return v3_length(v.x, v.y, v.z);
1012
997
  }
1013
998
 
1014
- export function v3_length(x, y, z) {
1015
- return Math.sqrt(v3_length_sqr(x, y, z));
1016
- }
1017
-
1018
- /**
1019
- *
1020
- * @param {number} x
1021
- * @param {number} y
1022
- * @param {number} z
1023
- * @return {number}
1024
- */
1025
- export function v3_length_sqr(x, y, z) {
1026
- return x * x + y * y + z * z;
1027
- }
1028
-
1029
-
1030
- /**
1031
- *
1032
- * @param {number} x0
1033
- * @param {number} y0
1034
- * @param {number} z0
1035
- * @param {number} x1
1036
- * @param {number} y1
1037
- * @param {number} z1
1038
- * @returns {number}
1039
- */
1040
- export function v3_angleBetween(x0, y0, z0, x1, y1, z1) {
1041
- const d = v3_dot(x0, y0, z0, x1, y1, z1);
1042
-
1043
- const magnitude_0 = v3_length(x0, y0, z0);
1044
- const magnitude_1 = v3_length(x1, y1, z1);
1045
-
1046
- const l = magnitude_0 * magnitude_1;
1047
-
1048
- if (l === 0) {
1049
- // collective magnitude is 0, provide arbitrary angle
1050
- return 0;
1051
- }
1052
-
1053
- const theta = clamp(d / l, -1, 1);
1054
-
1055
- return Math.acos(theta);
1056
- }
1057
999
 
1058
1000
  /**
1059
1001
  *
@@ -1067,70 +1009,4 @@ function v3Lerp(result, a, b, fraction) {
1067
1009
  v3_lerp(result, a.x, a.y, a.z, b.x, b.y, b.z, fraction);
1068
1010
  }
1069
1011
 
1070
- /**
1071
- *
1072
- * @param {Vector3} result
1073
- * @param {number} a_x
1074
- * @param {number} a_y
1075
- * @param {number} a_z
1076
- * @param {number} b_x
1077
- * @param {number} b_y
1078
- * @param {number} b_z
1079
- * @param {number} fraction
1080
- */
1081
- function v3_lerp(result, a_x, a_y, a_z, b_x, b_y, b_z, fraction) {
1082
-
1083
- const x = lerp(a_x, b_x, fraction);
1084
- const y = lerp(a_y, b_y, fraction);
1085
- const z = lerp(a_z, b_z, fraction);
1086
-
1087
- result.set(x, y, z);
1088
- }
1089
-
1090
- /**
1091
- * Spherical linear interpolation
1092
- * @see https://en.wikipedia.org/wiki/Slerp
1093
- * @param {Vector3} result
1094
- * @param {number} a_x
1095
- * @param {number} a_y
1096
- * @param {number} a_z
1097
- * @param {number} b_x
1098
- * @param {number} b_y
1099
- * @param {number} b_z
1100
- * @param {number} fraction
1101
- */
1102
- export function v3_slerp(
1103
- result,
1104
- a_x, a_y, a_z,
1105
- b_x, b_y, b_z,
1106
- fraction
1107
- ) {
1108
- const dot = v3_dot(
1109
- a_x, a_y, a_z,
1110
- b_x, b_y, b_z
1111
- );
1112
-
1113
- if (dot >= 1 || dot <= -1) {
1114
- // avoid division by 0, both vectors are pointing in the same direction, use lerp instead
1115
- v3_lerp(result, a_x, a_y, a_z, b_x, b_y, b_z, fraction);
1116
- return;
1117
- }
1118
-
1119
- // compute angle between two vectors
1120
- const theta = Math.acos(dot);
1121
-
1122
- const sin_theta = Math.sin(theta);
1123
-
1124
- const inv_sin_theta = 1 / sin_theta;
1125
-
1126
- const scale_0 = Math.sin((1 - fraction) * theta) * inv_sin_theta;
1127
- const scale_1 = Math.sin((fraction) * theta) * inv_sin_theta;
1128
-
1129
- const x = a_x * scale_0 + b_x * scale_1;
1130
- const y = a_y * scale_0 + b_y * scale_1;
1131
- const z = a_z * scale_0 + b_z * scale_1;
1132
-
1133
- result.set(x, y, z);
1134
- }
1135
-
1136
1012
  export default Vector3;
@@ -1,4 +1,5 @@
1
- import Vector3, { v3_slerp } from "./Vector3.js";
1
+ import Vector3 from "./Vector3.js";
2
+ import { v3_slerp } from "./v3_slerp.js";
2
3
 
3
4
  test('slerp', () => {
4
5
 
@@ -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
  }