@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,33 @@
1
+ import { mortonEncode_magicbits } from "./mortonEncode_magicbits.js";
2
+
3
+ /**
4
+ * Assumes that coordinates will be mapped to -1..1 range after transform
5
+ * @param {number} x
6
+ * @param {number} y
7
+ * @param {number} z
8
+ * @param {number[]} matrix matrix to transform supplied coordinates to Normalized Device Coordinates
9
+ * @returns {number}
10
+ */
11
+ export function v3_morton_encode_transformed(x, y, z, matrix) {
12
+
13
+ // apply matrix transform
14
+ const _x = matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12];
15
+ const _y = matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13];
16
+ const _z = matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14];
17
+ const _w = matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15];
18
+
19
+ const d = 1 / _w;
20
+
21
+ // apply perspective divide, values are now in Normalized Coordinate system (-1,1)
22
+ const px = _x * d;
23
+ const py = _y * d;
24
+ const pz = _z * d;
25
+
26
+ // scale each value up to 10 bits (for 10 bits, the multiplier = 1024. As we have -1,1 range, we do (v+1)/2. 1024/2 = 512)
27
+
28
+ const cx = ((px + 1) * 512) | 0;
29
+ const cy = ((py + 1) * 512) | 0;
30
+ const cz = ((pz + 1) * 512) | 0;
31
+
32
+ return mortonEncode_magicbits(cx, cy, cz);
33
+ }
@@ -1,5 +1,5 @@
1
1
  import { decode_hemioct_to_unit, encode_unit_to_hemioct } from "./encode_unit3_hemioct.js";
2
- import { v3_length } from "../../../Vector3.d.ts";
2
+ import { v3_length } from "../../../v3_length.js";
3
3
 
4
4
  test('encode-decode', () => {
5
5
  const v0 = [];
@@ -0,0 +1,37 @@
1
+ import { v3_dot } from "../../v3_dot.js";
2
+
3
+ /**
4
+ *
5
+ * @param {Vector3} result
6
+ * @param {number} origin_x
7
+ * @param {number} origin_y
8
+ * @param {number} origin_z
9
+ * @param {number} direction_x
10
+ * @param {number} direction_y
11
+ * @param {number} direction_z
12
+ * @param {number} px
13
+ * @param {number} py
14
+ * @param {number} pz
15
+ * @returns {number} distance from origin, negative means that the point lies behind the origin in the direction opposite to the ray's own
16
+ */
17
+ export function ray_computeNearestPointToPoint(result, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, px, py, pz) {
18
+ // find closest point
19
+ const sp0_x = px - origin_x;
20
+ const sp0_y = py - origin_y;
21
+ const sp0_z = pz - origin_z;
22
+
23
+ //
24
+ const d2 = v3_dot(direction_x, direction_y, direction_z, direction_x, direction_y, direction_z);
25
+ const d3 = v3_dot(direction_x, direction_y, direction_z, sp0_x, sp0_y, sp0_z);
26
+
27
+ const t = d3 / d2;
28
+
29
+ // compute point on the ray
30
+ const lp_x = direction_x * t + origin_x;
31
+ const lp_y = direction_y * t + origin_y;
32
+ const lp_z = direction_z * t + origin_z;
33
+
34
+ result.set(lp_x, lp_y, lp_z);
35
+
36
+ return t;
37
+ }
@@ -0,0 +1,65 @@
1
+ export class AbstractShape3D {
2
+ /**
3
+ * Signed distance to boundary of the shape from the given point
4
+ * @param {number[]} point
5
+ * @returns {number}
6
+ */
7
+ signed_distance_at_point(point) {
8
+ throw new Error('Not Implemented');
9
+ }
10
+
11
+ /**
12
+ * Samples both distances as well as the gradient
13
+ * @param {number[]} result resulting gradient is written here
14
+ * @param {number[]} point sampling point
15
+ * @returns {number}
16
+ */
17
+ signed_distance_gradient_at_point(result, point) {
18
+ throw new Error('Not Implemented');
19
+ }
20
+
21
+ /**
22
+ *
23
+ * @param {number[]} result where the resulting point is stored
24
+ * @param {number[]} reference reference point from which to go
25
+ * @returns {void}
26
+ */
27
+ nearest_point_on_surface(result, reference) {
28
+ throw new Error('Not Implemented');
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @param {number[]} result
34
+ * @param {number} result_offset
35
+ * @param {function} random
36
+ * @returns {void}
37
+ */
38
+ sample_random_point_in_volume(result, result_offset, random) {
39
+ throw new Error('Not Implemented');
40
+ }
41
+
42
+ /**
43
+ * Whether or not given point is inside the shape
44
+ * @param {number[]} point
45
+ * @returns {boolean}
46
+ */
47
+ contains_point(point) {
48
+ throw new Error('Not Implemented');
49
+ }
50
+
51
+ /**
52
+ * Total volume of the shape
53
+ * @returns {number}
54
+ */
55
+ get volume() {
56
+ throw new Error('Not Implemented');
57
+ }
58
+
59
+ /**
60
+ * @returns {number}
61
+ */
62
+ get surface_area() {
63
+ throw new Error('Not Implemented');
64
+ }
65
+ }
@@ -0,0 +1,181 @@
1
+ import { mat4, vec3 } from "gl-matrix";
2
+ import { AbstractShape3D } from "./AbstractShape3D.js";
3
+ import { sign } from "../../../math/sign.js";
4
+
5
+ /**
6
+ *
7
+ * @type {number[]|Float32Array|vec3}
8
+ */
9
+ const scratch_v3_0 = [];
10
+
11
+ export class TransformedShape3D extends AbstractShape3D {
12
+ constructor() {
13
+ super();
14
+
15
+ /**
16
+ *
17
+ * @type {number[]|Float32Array|mat4}
18
+ * @private
19
+ */
20
+ this.__matrix = new Float32Array(16);
21
+
22
+ /**
23
+ *
24
+ * @type {Float32Array|mat4}
25
+ * @private
26
+ */
27
+ this.__inverse_matrix = new Float32Array(16);
28
+
29
+ /**
30
+ *
31
+ * @type {AbstractShape3D|null}
32
+ * @private
33
+ */
34
+ this.__subject = null;
35
+ }
36
+
37
+ /**
38
+ *
39
+ * @returns {AbstractShape3D|null}
40
+ */
41
+ get subject() {
42
+ return this.__subject;
43
+ }
44
+
45
+ /**
46
+ *
47
+ * @param {number[]|Float32Array|mat4} m4
48
+ * @param {AbstractShape3D} subject
49
+ * @returns {TransformedShape3D}
50
+ */
51
+ static from_m4(subject, m4) {
52
+ const r = new TransformedShape3D();
53
+
54
+ r.__subject = subject;
55
+ r.transform = m4;
56
+
57
+ return r;
58
+ }
59
+
60
+ /**
61
+ *
62
+ * @param {AbstractShape3D} subject
63
+ * @param {number[]} translation
64
+ * @param {number[]} scale
65
+ */
66
+ static from_translation_scale(subject, translation, scale) {
67
+
68
+ const mat = mat4.create();
69
+ mat4.fromRotationTranslationScale(mat, [0, 0, 0, 1], translation, scale);
70
+
71
+ return TransformedShape3D.from_m4(subject, mat);
72
+ }
73
+
74
+ /**
75
+ *
76
+ * @returns {TransformedShape3D}
77
+ * @param {AbstractShape3D} subject
78
+ * @param {number[]|Float32Array|vec3} scale
79
+ */
80
+ static from_scale(subject, scale) {
81
+ const mat = mat4.create();
82
+ mat4.fromScaling(mat, scale);
83
+
84
+ return TransformedShape3D.from_m4(subject, mat);
85
+ }
86
+
87
+ /**
88
+ *
89
+ * @param {number[]|Float32Array} m
90
+ */
91
+ set transform(m) {
92
+ this.__matrix.set(m);
93
+
94
+ mat4.invert(this.__inverse_matrix, this.__matrix);
95
+ }
96
+
97
+ get transform() {
98
+ return this.__matrix;
99
+ }
100
+
101
+ get volume() {
102
+ mat4.getScaling(scratch_v3_0, this.__matrix);
103
+
104
+ const scale_modifier = scratch_v3_0[0] * scratch_v3_0[1] * scratch_v3_0[2];
105
+
106
+ return this.__subject.volume * scale_modifier;
107
+ }
108
+
109
+ signed_distance_gradient_at_point(result, point) {
110
+ // transform point to subject's local space
111
+ vec3.transformMat4(scratch_v3_0, point, this.__inverse_matrix);
112
+
113
+ const subject = this.__subject;
114
+
115
+ // sample gradient at the point
116
+ const distance = subject.signed_distance_gradient_at_point(scratch_v3_0, scratch_v3_0);
117
+
118
+ const m = this.__matrix;
119
+
120
+ const m11 = m[0];
121
+ const m12 = m[1];
122
+ const m13 = m[2];
123
+
124
+ const m21 = m[4];
125
+ const m22 = m[5];
126
+ const m23 = m[6];
127
+
128
+ const m31 = m[8];
129
+ const m32 = m[9];
130
+ const m33 = m[10];
131
+
132
+ const scale_x = Math.hypot(m11, m12, m13);
133
+ const scale_y = Math.hypot(m21, m22, m23);
134
+ const scale_z = Math.hypot(m31, m32, m33);
135
+
136
+ const scaled_gx = scratch_v3_0[0] * scale_x;
137
+ const scaled_gy = scratch_v3_0[1] * scale_y;
138
+ const scaled_gz = scratch_v3_0[2] * scale_z;
139
+
140
+ // normalize gradient
141
+ const gd = distance / Math.hypot(scratch_v3_0[0], scratch_v3_0[1], scratch_v3_0[2]);
142
+
143
+ const scaled_dx = scaled_gx * gd ;
144
+ const scaled_dy = scaled_gy * gd ;
145
+ const scaled_dz = scaled_gz * gd ;
146
+
147
+ // determine sign
148
+ const result_sign = sign(distance);
149
+
150
+ const scaled_distance = result_sign * Math.sqrt(scaled_dx * scaled_dx + scaled_dy * scaled_dy + scaled_dz * scaled_dz);
151
+
152
+ result[0] = scaled_gx;
153
+ result[1] = scaled_gy;
154
+ result[2] = scaled_gz;
155
+
156
+ return scaled_distance;
157
+ }
158
+
159
+ signed_distance_at_point(point) {
160
+ return this.signed_distance_gradient_at_point(scratch_v3_0, point);
161
+ }
162
+
163
+ contains_point(point) {
164
+ // transform point to subject's local space
165
+ vec3.transformMat4(scratch_v3_0, point, this.__inverse_matrix);
166
+
167
+ return this.__subject.contains_point(scratch_v3_0);
168
+ }
169
+
170
+ sample_random_point_in_volume(result, result_offset, random) {
171
+ this.__subject.sample_random_point_in_volume(scratch_v3_0, 0, random);
172
+
173
+ // apply transform
174
+ vec3.transformMat4(scratch_v3_0, scratch_v3_0, this.__matrix);
175
+
176
+ // write out
177
+ result[0] = scratch_v3_0[0];
178
+ result[1] = scratch_v3_0[1];
179
+ result[2] = scratch_v3_0[2];
180
+ }
181
+ }
@@ -0,0 +1,33 @@
1
+ import { UnitCubeShape3D } from "./UnitCubeShape3D.js";
2
+ import { TransformedShape3D } from "./TransformedShape3D.js";
3
+
4
+ test('signed distance identity transform', () => {
5
+
6
+ const s = TransformedShape3D.from_translation_scale(new UnitCubeShape3D(), [0, 0, 0], [1, 1, 1]);
7
+
8
+ expect(s.signed_distance_at_point([0, 0, 0])).toBeCloseTo(-0.5);
9
+
10
+ expect(s.signed_distance_at_point([1, 0, 0])).toBeCloseTo(0.5);
11
+ });
12
+
13
+ test('signed distance translation', () => {
14
+
15
+ const s = TransformedShape3D.from_translation_scale(new UnitCubeShape3D(), [1, 0, 0], [1, 1, 1]);
16
+
17
+ expect(s.signed_distance_at_point([0, 0, 0])).toBeCloseTo(0.5);
18
+
19
+ expect(s.signed_distance_at_point([-1, 0, 0])).toBeCloseTo(1.5);
20
+
21
+ expect(s.signed_distance_at_point([1, 0, 0])).toBeCloseTo(-0.5);
22
+ });
23
+
24
+ test('signed distance scale', () => {
25
+
26
+ const s = TransformedShape3D.from_translation_scale(new UnitCubeShape3D(), [0, 0, 0], [2, 2, 2]);
27
+
28
+ expect(s.signed_distance_at_point([0, 0, 0])).toBeCloseTo(-1);
29
+
30
+ expect(s.signed_distance_at_point([1, 0, 0])).toBeCloseTo(0);
31
+
32
+ expect(s.signed_distance_at_point([2, 0, 0])).toBeCloseTo(1);
33
+ });
@@ -0,0 +1,255 @@
1
+ import { AbstractShape3D } from "./AbstractShape3D.js";
2
+ import { seededRandom } from "../../../math/random/seededRandom.js";
3
+ import { binarySearchHighIndex } from "../../../collection/array/binarySearchHighIndex.js";
4
+ import { compareNumbers } from "../../../primitives/numbers/compareNumbers.js";
5
+ import { min2 } from "../../../math/min2.js";
6
+ import { compute_signed_distance_gradient_by_sampling } from "./util/compute_signed_distance_gradient_by_sampling.js";
7
+
8
+ /**
9
+ * To avoid severe performance overhead, we limit number of possible rejections
10
+ * @type {number}
11
+ */
12
+ const SAMPLE_REJECTION_ATTEMPT_MAX = 4;
13
+
14
+ /**
15
+ * Number of samples taken to estimate overlap level
16
+ * @type {number}
17
+ */
18
+ const VOLUME_OVERLAP_ESTIMATION_TAPS = 1024;
19
+ const VOLUME_OVERLAP_ESTIMATION_SUB_TAPS = 4;
20
+
21
+ const scratch_array = [];
22
+
23
+ export class UnionShape3D extends AbstractShape3D {
24
+ constructor() {
25
+ super();
26
+
27
+ /**
28
+ *
29
+ * @type {AbstractShape3D[]}
30
+ */
31
+ this.children = [];
32
+
33
+ /**
34
+ * Estimator of how much volume is in overlap,
35
+ * expressed as fraction of volume occupied by overlapping region of 2 shapes over the sum of volume occupied by each child
36
+ * @type {number}
37
+ * @private
38
+ */
39
+ this.__volume_overlap_fraction = -1;
40
+
41
+ this.__volume_sum = -1;
42
+ this.__volume_sums = [];
43
+ this.__child_volumes = [];
44
+ }
45
+
46
+ /**
47
+ *
48
+ * @private
49
+ */
50
+ __compute_volume_variables() {
51
+ this.__volume_sum = 0;
52
+
53
+ const children = this.children;
54
+ const child_count = children.length;
55
+
56
+ const child_volumes = this.__child_volumes = new Float32Array(child_count);
57
+ const child_volume_sums = this.__volume_sums = new Float32Array(child_count);
58
+
59
+ for (let i = 0; i < child_count; i++) {
60
+ const child_volume = children[i].volume;
61
+
62
+ child_volumes[i] = child_volume;
63
+ this.__volume_sum += child_volume;
64
+
65
+ child_volume_sums[i] = this.__volume_sum;
66
+ }
67
+
68
+ }
69
+
70
+ /**
71
+ * Monte-carlo-style volume overlap estimation
72
+ * @private
73
+ */
74
+ __estimate_volume_overlap_fraction() {
75
+
76
+ if (this.__volume_sum === -1) {
77
+ this.__compute_volume_variables();
78
+ }
79
+
80
+ const children = this.children;
81
+ const child_count = children.length;
82
+
83
+ const random = seededRandom(1);
84
+
85
+ const child_volume_sums = this.__volume_sums;
86
+ const child_volume_sum = this.__volume_sum;
87
+
88
+ let i = 0, j = 0, k = 0, tap_overlaps = 0;
89
+
90
+ for (i = 0; i < VOLUME_OVERLAP_ESTIMATION_TAPS; i++) {
91
+
92
+ const target_weight = random() * child_volume_sum;
93
+
94
+ // weighted search for a sample candidate, preferring larger volumes, resulting in more uniform sample distribution
95
+ const target_child_index = binarySearchHighIndex(child_volume_sums, target_weight, compareNumbers, 0, child_count - 1);
96
+
97
+ const child_0 = children[target_child_index];
98
+
99
+ for (j = 0; j < VOLUME_OVERLAP_ESTIMATION_SUB_TAPS; j++, i++) {
100
+
101
+ child_0.sample_random_point_in_volume(scratch_array, 0, random);
102
+
103
+ for (k = 0; k < child_count; k++) {
104
+ if (target_child_index === k) {
105
+ // skip self
106
+ continue;
107
+ }
108
+
109
+ const child_1 = children[k];
110
+
111
+ if (child_1.contains_point(scratch_array)) {
112
+ tap_overlaps++;
113
+ }
114
+ }
115
+
116
+ }
117
+ }
118
+
119
+ this.__volume_overlap_fraction = tap_overlaps / (VOLUME_OVERLAP_ESTIMATION_TAPS);
120
+ }
121
+
122
+ static from(children) {
123
+ const r = new UnionShape3D();
124
+
125
+ r.children = children;
126
+
127
+ return r;
128
+ }
129
+
130
+ get volume() {
131
+ if (this.__volume_overlap_fraction < 0) {
132
+ this.__estimate_volume_overlap_fraction();
133
+ }
134
+
135
+ let volume_sum = 0;
136
+
137
+ const children = this.children;
138
+ const child_count = children.length;
139
+
140
+ for (let i = 0; i < child_count; i++) {
141
+ const child = children[i];
142
+
143
+ volume_sum += child.volume;
144
+ }
145
+
146
+ /**
147
+ * Unbias the volume by taking overlap into account
148
+ * @type {number}
149
+ */
150
+ const unbiased_volume = volume_sum / (this.__volume_overlap_fraction + 1);
151
+
152
+ return unbiased_volume;
153
+ }
154
+
155
+ get surface_area() {
156
+ let r = 0;
157
+
158
+ const children = this.children;
159
+ const child_count = children.length;
160
+ for (let i = 0; i < child_count; i++) {
161
+ const child = children[i];
162
+
163
+ r += child.surface_area;
164
+ }
165
+
166
+ return r;
167
+ }
168
+
169
+ signed_distance_gradient_at_point(result, point) {
170
+ return compute_signed_distance_gradient_by_sampling(result, this, point);
171
+ }
172
+
173
+ signed_distance_at_point(point) {
174
+ let r = Infinity;
175
+
176
+ const children = this.children;
177
+ const child_count = children.length;
178
+
179
+ for (let i = 0; i < child_count; i++) {
180
+ const child = children[i];
181
+
182
+ r = min2(child.signed_distance_at_point(point), r);
183
+ }
184
+
185
+ return r;
186
+ }
187
+
188
+ contains_point(point) {
189
+ const children = this.children;
190
+ const n = children.length;
191
+ for (let i = 0; i < n; i++) {
192
+ const child = children[i];
193
+
194
+ if (child.contains_point(point)) {
195
+ return true;
196
+ }
197
+ }
198
+
199
+ return false;
200
+ }
201
+
202
+ sample_random_point_in_volume(result, result_offset, random) {
203
+ const children = this.children;
204
+ const child_count = children.length;
205
+
206
+
207
+ const target_weight = random() * this.__volume_sum;
208
+
209
+ // weighted search for a sample candidate, preferring larger volumes, resulting in more uniform sample distribution
210
+ const target_child_index = binarySearchHighIndex(this.__volume_sums, target_weight, compareNumbers, 0, child_count - 1);
211
+
212
+ const child = children[target_child_index];
213
+
214
+ let collision_count, i, j;
215
+
216
+ for (i = 0; i < SAMPLE_REJECTION_ATTEMPT_MAX; i++) {
217
+
218
+ // sample shape
219
+ child.sample_random_point_in_volume(result, result_offset, random);
220
+
221
+ /*
222
+ because underlying shapes can overlap and we wish to offer a union, just returning the sample would result in over-sampling in areas where shapes overlap
223
+ to avoid this oversampling, we reject samples in such areas with probability proportional to number of overlapping shapes at the sampled point
224
+ */
225
+ collision_count = 0;
226
+
227
+ for (j = 0; j < child_count; j++) {
228
+ const child_1 = children[j];
229
+
230
+ if (child_1 === child) {
231
+ // exclude sampled child itself
232
+ continue;
233
+ }
234
+
235
+ if (child_1.contains_point(result)) {
236
+ collision_count++;
237
+ }
238
+ }
239
+
240
+ if (collision_count > 0) {
241
+ const rejection_chance = collision_count / (collision_count + 1);
242
+
243
+ const rejection_roll = random();
244
+
245
+ if (rejection_roll < rejection_chance) {
246
+ //reject
247
+ continue;
248
+ }
249
+ }
250
+
251
+ // no collisions, or survived rejection
252
+ break;
253
+ }
254
+ }
255
+ }