@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.
- package/core/binary/BitSet.js +151 -167
- package/core/binary/BitSet.spec.js +99 -1
- package/core/binary/ValidatingBitSetWrapper.js +81 -0
- package/core/bvh2/BinaryNode.js +1 -1
- package/core/bvh2/aabb3/AABB3.js +21 -10
- package/core/bvh2/aabb3/AABB3Math.js +1 -1
- package/core/bvh2/binary/2/BinaryUint32BVH.js +498 -0
- package/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
- package/core/bvh2/binary/IndexedBinaryBVH.js +22 -26
- package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +5 -1
- package/core/bvh2/traversal/__detailed_box_volume_intersection.js +22 -5
- package/core/cache/Cache.d.ts +4 -2
- package/core/cache/Cache.js +5 -2
- package/core/collection/ArrayUtils.js +1 -1
- package/core/collection/HashMap.d.ts +9 -2
- package/core/collection/HashSet.d.ts +7 -2
- package/core/collection/HashSet.js +7 -2
- package/core/collection/array/arrayQuickSort.js +9 -6
- package/core/collection/array/array_swap.js +22 -0
- package/core/collection/array/binarySearchHighIndex.js +1 -1
- package/core/collection/array/computeHashArray.js +22 -0
- package/core/collection/array/computeHashIntegerArray.js +15 -0
- package/core/collection/array/copyArray.js +2 -2
- package/core/collection/array/typed/typed_array_copy.js +1 -1
- package/core/collection/table/DataType2TypedArrayConstructorMapping.js +15 -0
- package/core/color/Color.js +2 -1
- package/core/function/FunctionCompiler.js +2 -1
- package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
- package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +3 -3
- package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
- package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +41 -0
- package/core/geom/3d/morton/mortonEncode_magicbits.js +2 -1
- package/core/geom/3d/morton/reinterpret_float32_as_int32.js +13 -0
- package/core/geom/3d/morton/v3_morton_encode_transformed.js +33 -0
- package/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
- package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
- package/core/geom/3d/shape/AbstractShape3D.js +65 -0
- package/core/geom/3d/shape/TransformedShape3D.js +181 -0
- package/core/geom/3d/shape/TransformedShape3D.spec.js +33 -0
- package/core/geom/3d/shape/UnionShape3D.js +255 -0
- package/core/geom/3d/shape/UnitCubeShape3D.js +101 -0
- package/core/geom/3d/shape/UnitCubeShape3D.spec.js +42 -0
- package/core/geom/3d/shape/UnitSphereShape3D.js +55 -0
- package/core/geom/3d/shape/util/compute_signed_distance_gradient_by_sampling.js +48 -0
- package/core/geom/3d/shape/util/shape_to_visual_entity.js +159 -0
- package/core/geom/AABB2.js +1 -1
- package/core/geom/ConicRay.js +3 -1
- package/core/geom/LineSegment.js +0 -78
- package/core/geom/Matrix4.js +7 -8
- package/core/geom/Rectangle.js +2 -1
- package/core/geom/Vector1.js +1 -1
- package/core/geom/Vector3.js +2 -1
- package/core/geom/Vector4.js +2 -1
- package/core/geom/random/randomPointInBox.js +7 -3
- package/core/geom/random/randomPointInPoint.js +6 -3
- package/core/geom/random/randomPointInSphere.js +9 -5
- package/core/geom/random/randomPointOnBox.js +7 -3
- package/core/geom/random/randomPointOnSphere.js +6 -3
- package/core/geom/v3_length.js +8 -3
- package/core/graph/graph_k_means_cluster.js +1 -1
- package/core/json/resolvePathByArray.js +2 -2
- package/core/math/MathUtils.js +0 -354
- package/core/math/MathUtils.spec.js +7 -1
- package/core/math/gaussian.js +9 -0
- package/core/math/hash/computeHashFloat.js +17 -0
- package/core/math/hash/computeHashFloatArray.js +34 -0
- package/core/math/hash/computeObjectHash.js +54 -0
- package/core/math/intersects1D.js +19 -0
- package/core/math/interval/NumericInterval.js +2 -2
- package/core/math/isValueBetween.js +10 -0
- package/core/math/isValueBetweenInclusive.js +10 -0
- package/core/math/noise/curl_noise_3dt.js +1 -1
- package/core/math/noise/sdnoise.js +10 -10
- package/core/math/overlap1D.js +19 -0
- package/core/math/pingpong.js +17 -0
- package/core/math/random/makeRangedRandom.js +19 -0
- package/core/math/random/randomFloatBetween.js +14 -0
- package/core/math/random/randomFromArray.js +19 -0
- package/core/math/random/randomGaussian.js +15 -0
- package/core/math/random/randomIntegerBetween.js +14 -0
- package/core/math/random/roundFair.js +15 -0
- package/core/math/separation1D.js +21 -0
- package/core/math/solveQuadratic.js +25 -0
- package/core/model/BoundedValue.js +1 -1
- package/core/model/node-graph/node/NodeInstancePortReference.js +1 -1
- package/core/model/node-graph/node/Port.js +1 -1
- package/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +3 -1
- package/core/model/reactive/model/ReactiveBinaryExpression.js +1 -1
- package/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +1 -1
- package/core/model/reactive/model/terminal/ReactiveReference.js +1 -1
- package/core/model/reactive/model/util/createRandomReactiveExpression.js +1 -1
- package/core/model/stat/LinearModifier.js +1 -1
- package/core/parser/simple/Token.d.ts +13 -0
- package/core/parser/simple/Token.js +61 -27
- package/{engine/graphics/render/forward_plus/materials → core/primitives/strings}/insert_after.js +3 -0
- package/core/primitives/strings/insert_after_or_replace.js +27 -0
- package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
- package/editor/tools/FoliagePaintTool.js +4 -4
- package/editor/view/ecs/EntityEditor.js +2 -2
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +2 -2
- package/engine/EngineHarness.js +1 -0
- package/engine/animation/AnimationUtils.js +5 -5
- package/engine/animation/curve/AnimationCurve.js +72 -0
- package/engine/animation/curve/Keyframe.js +27 -0
- package/engine/animation/keyed2/AnimationTrack.js +27 -3
- package/engine/asset/Asset.js +1 -1
- package/engine/asset/loaders/GLTFAssetLoader.d.ts +1 -1
- package/engine/asset/loaders/GLTFAssetLoader.js +62 -1
- package/engine/asset/loaders/image/ImageDecoderWorker.js +4 -3
- package/engine/asset/loaders/image/ImageRGBADataAsset.js +10 -2
- package/engine/asset/loaders/image/ImageRGBADataLoader.js +3 -3
- package/engine/asset/loaders/image/codec/NativeImageDecoder.js +2 -1
- package/engine/asset/loaders/image/png/PNG.js +113 -6
- package/engine/asset/loaders/image/png/PNGReader.js +5 -0
- package/engine/asset/loaders/material/bitmap2sampler_gl.js +1 -1
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +6 -1
- package/engine/asset/loaders/material/computeMaterialHash.js +3 -1
- package/engine/asset/loaders/material/computeTextureEquality.js +40 -49
- package/engine/asset/loaders/material/computeTextureHash.js +2 -1
- package/engine/ecs/EntityBuilder.js +25 -5
- package/engine/ecs/EntityComponentDataset.js +1 -1
- package/engine/ecs/animation/Animation.js +2 -1
- package/engine/ecs/animation/InverseKinematics.js +2 -1
- package/engine/ecs/attachment/AttachmentBinding.js +8 -0
- package/engine/ecs/attachment/AttachmentSystem.js +4 -0
- package/engine/ecs/attachment/TransformAttachmentBinding.js +14 -44
- package/engine/ecs/components/Tag.js +27 -6
- package/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
- package/engine/ecs/dynamic_actions/DynamicRuleDescriptionTable.spec.js +3 -5
- package/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +1 -1
- package/engine/ecs/evaluation/complex/PointFitnessGaussianBlur.js +1 -1
- package/engine/ecs/foliage/InstancedFoliage.js +277 -266
- package/engine/ecs/foliage/ecs/Foliage2System.js +7 -7
- package/engine/ecs/foliage/ecs/InstancedMeshComponent.js +37 -0
- package/engine/ecs/foliage/ecs/{Foliage2.js → InstancedMeshLayer.js} +3 -45
- package/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +6 -5
- package/engine/ecs/foliage/ecs/InstancedMeshUtils.js +7 -6
- package/engine/ecs/fow/FogOfWar.js +4 -0
- package/engine/ecs/fow/FogOfWarSystem.js +2 -0
- package/engine/ecs/fow/shader/FogOfWarRenderer.js +1 -1
- package/engine/ecs/gui/GUIElement.js +1 -1
- package/engine/ecs/gui/hud/HeadsUpDisplay.js +1 -1
- package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -0
- package/engine/ecs/gui/position/ViewportPosition.js +2 -1
- package/engine/ecs/storage/binary/BinarySerializationRegistry.js +1 -1
- package/engine/ecs/system/AbstractContextSystem.js +1 -1
- package/engine/ecs/systems/RangedAttackSystem.js +1 -1
- package/engine/ecs/systems/SteeringSystem.js +1 -1
- package/engine/ecs/systems/TagSystem.js +17 -0
- package/engine/ecs/terrain/ecs/layers/TerrainLayer.js +12 -16
- package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
- package/engine/ecs/tooltip/TooltipComponent.js +15 -0
- package/engine/ecs/transform/Transform.js +19 -6
- package/engine/graphics/GraphicsEngine.js +11 -6
- package/engine/graphics/composit/CompositLayer.js +17 -4
- package/engine/graphics/composit/CompositingStages.js +8 -0
- package/engine/graphics/composit/LayerCompositer.js +35 -6
- package/engine/graphics/ecs/animation/animator/AnimationClip.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +1 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +2 -1
- package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
- package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
- package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +11 -7
- package/engine/graphics/ecs/light/Light.d.ts +1 -1
- package/engine/graphics/ecs/light/Light.js +5 -0
- package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +5 -1
- package/engine/graphics/ecs/mesh/Mesh.js +2 -1
- package/engine/graphics/ecs/mesh-v2/DrawMode.js +5 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +32 -18
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
- package/engine/graphics/geometry/AttributeSpec.js +105 -0
- package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +14 -72
- package/engine/graphics/geometry/instancing/rewriteMaterial.js +70 -0
- package/engine/graphics/material/manager/MaterialManager.js +2 -1
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
- package/engine/graphics/micron/buildPatchwork.js +1 -1
- package/engine/graphics/micron/format/MicronGeometry.js +3 -3
- package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +2 -2
- package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
- package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
- package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +11 -9
- package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +0 -2
- package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
- package/engine/graphics/particles/ParticleEmitterLibrary.js +3 -0
- package/engine/graphics/particles/ecs/{ParticleEmitterSystem2.js → ParticleEmitterSystem.js} +17 -9
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +8 -2
- package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +80 -16
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +71 -77
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +2 -1
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +141 -14
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +8 -7
- package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +1 -1
- package/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +8 -2
- package/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +2 -1
- package/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js +1 -1
- package/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +1 -1
- package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +24 -0
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +262 -71
- package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +81 -48
- package/engine/graphics/particles/particular/engine/shader/debugAtlas.js +14 -0
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepApplyForce.js +2 -5
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseAcceleration.js +2 -6
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.js +2 -7
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +2 -5
- package/engine/graphics/particles/particular/engine/simulator/update_parameters.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +141 -0
- package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +478 -0
- package/engine/graphics/particles/particular/engine/utils/volume/lut_to_sampler.js +27 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +938 -0
- package/engine/graphics/particles/particular/group/Operation.js +18 -0
- package/engine/graphics/particles/particular/group/OperationType.js +9 -0
- package/engine/graphics/particles/particular/group/ParticleAttribute.js +2 -1
- package/engine/graphics/particles/particular/group/ParticleAttributeType.js +11 -0
- package/engine/graphics/particles/particular/group/ParticleDataType.js +10 -0
- package/engine/graphics/particles/particular/group/ParticleGroup.js +7 -245
- package/engine/graphics/particles/particular/group/ParticleGroup.spec.js +3 -1
- package/engine/graphics/particles/particular/group/ParticleSpecification.js +21 -14
- package/engine/graphics/particles/particular/group/itemSizeFromAttributeType.js +20 -0
- package/engine/graphics/particles/particular/group/optimizeCommandQueue.js +162 -0
- package/engine/graphics/particles/particular/group/typedArrayConstructorFromDataType.js +19 -0
- package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +16 -11
- package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameter.js +2 -1
- package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameterSet.js +1 -1
- package/engine/graphics/render/forward_plus/LightManager.js +117 -94
- package/engine/graphics/render/forward_plus/PointLight.js +9 -0
- package/engine/graphics/render/forward_plus/PointLightData.js +1 -1
- package/engine/graphics/render/forward_plus/SpotLight.js +9 -0
- package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +2 -2
- package/engine/graphics/render/forward_plus/materials/FP_INJECTION_POINT_ACCUMULATION.js +1 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +32 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_DECODE_PARS.js +51 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +25 -0
- package/engine/graphics/render/forward_plus/materials/FPlusDebugMaterial.js +3 -3
- package/engine/graphics/render/forward_plus/materials/ForwardPlusThreeMaterial.js +1 -1
- package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +31 -120
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_lighting_shared.js +35 -0
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_shader.js +4 -5
- package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
- package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +10 -3
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +594 -59
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +208 -89
- package/engine/graphics/render/forward_plus/query/analytical_triplanar_corner_mapping.js +8 -0
- package/engine/graphics/render/forward_plus/query/cube_mapping.js +38 -0
- package/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +86 -0
- package/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +74 -0
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +131 -0
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +129 -0
- package/engine/graphics/render/forward_plus/query/spot_light_inside_volume.js +33 -0
- package/engine/graphics/render/forward_plus/read_frustum_corner.js +14 -0
- package/engine/graphics/render/forward_plus/testClusterEquality.js +22 -0
- package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
- package/engine/graphics/shaders/TerrainShader.js +4 -5
- package/engine/graphics/shadows/ShadowMapRenderer.js +8 -2
- package/engine/graphics/texture/atlas/ManagedTextureAtlas.js +12 -1
- package/engine/graphics/texture/sampler/HarmonicDiffusionGrid.spec.js +1 -1
- package/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
- package/engine/graphics/texture/sampler/Sampler2D.js +3 -1
- package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +1 -1
- package/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js +66 -0
- package/engine/graphics/texture/sampler/distanceField.spec.js +1 -1
- package/engine/graphics/util/composeMatrix4.js +33 -23
- package/engine/graphics/util/decompose_matrix_4_array.js +61 -0
- package/engine/grid/components/GridObstacle.js +1 -1
- package/engine/intelligence/behavior/ecs/BehaviorComponent.js +30 -14
- package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
- package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
- package/engine/knowledge/database/StaticKnowledgeDataTable.js +6 -1
- package/engine/navigation/ecs/components/Path.js +1 -6
- package/engine/navigation/grid/FastBinaryHeap.spec.js +1 -1
- package/engine/sound/ecs/emitter/SoundEmitter.js +2 -1
- package/engine/sound/ecs/emitter/SoundTrack.js +2 -1
- package/engine/sound/material/concrete/RandomSoundMaterial.js +1 -1
- package/engine/ui/notification/notificationGenerator.js +1 -1
- package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +1 -1
- package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
- package/generation/markers/actions/MarkerNodeActionSelectRandom.js +1 -1
- package/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +1 -1
- package/generation/placement/action/random/CellActionSelectRandom.js +1 -1
- package/generation/theme/ThemeEngine.js +1 -1
- package/misc/makeMaterialIconCached.js +2 -2
- package/package.json +1 -1
- package/view/elements/image/HTMLElementCacheKey.js +2 -1
- package/view/elements/radial/RadialText.js +2 -1
- package/view/minimap/gl/MinimapMarkersGL.js +6 -100
- package/view/minimap/gl/MinimapWorldGL.js +12 -5
- package/view/minimap/gl/buildMaterial.js +94 -0
- package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +0 -71
- package/engine/graphics/render/forward_plus/queryBVH_Frustum.js +0 -357
|
@@ -6,8 +6,13 @@ import { min2 } from "../../math/min2.js";
|
|
|
6
6
|
import { IndexedBinaryBVHVisitor } from "./IndexedBinaryBVHVisitor.js";
|
|
7
7
|
import { NodeType } from "./NodeType.js";
|
|
8
8
|
import { RayLeafIntersectionVisitor } from "./RayLeafIntersectionVisitor.js";
|
|
9
|
+
import { array_copy } from "../../collection/array/copyArray.js";
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @type {Float32Array|number[]}
|
|
15
|
+
*/
|
|
11
16
|
const scratch_aabb_0 = new Float32Array(6);
|
|
12
17
|
|
|
13
18
|
|
|
@@ -30,16 +35,16 @@ export default class IndexedBinaryBVH {
|
|
|
30
35
|
this.binaryNodeCount = 0;
|
|
31
36
|
|
|
32
37
|
/**
|
|
33
|
-
*
|
|
38
|
+
* Total number of boxes contained in the tree, some might be unused
|
|
34
39
|
* @type {number}
|
|
35
40
|
*/
|
|
36
41
|
this.boxCount = 0;
|
|
37
42
|
|
|
38
43
|
/**
|
|
39
44
|
*
|
|
40
|
-
* @type {
|
|
45
|
+
* @type {Float32Array|number[]}
|
|
41
46
|
*/
|
|
42
|
-
this.data =
|
|
47
|
+
this.data = new Float32Array(16);
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
/**
|
|
@@ -59,7 +64,14 @@ export default class IndexedBinaryBVH {
|
|
|
59
64
|
|
|
60
65
|
this.boxCount = this.leafNodeCount + this.binaryNodeCount;
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
// possibly resize the storage
|
|
68
|
+
const storage_size = this.boxCount * 6;
|
|
69
|
+
|
|
70
|
+
if (this.data.length < storage_size) {
|
|
71
|
+
this.data = new Float32Array(storage_size);
|
|
72
|
+
} else {
|
|
73
|
+
this.data.fill(0);
|
|
74
|
+
}
|
|
63
75
|
}
|
|
64
76
|
|
|
65
77
|
unsortedBuiltIntermediate() {
|
|
@@ -117,7 +129,7 @@ export default class IndexedBinaryBVH {
|
|
|
117
129
|
}
|
|
118
130
|
|
|
119
131
|
//set bounds of the bvh
|
|
120
|
-
|
|
132
|
+
array_copy(data, 0, scratch_aabb_0, 0, 6);
|
|
121
133
|
|
|
122
134
|
this.x0 = scratch_aabb_0[0];
|
|
123
135
|
this.y0 = scratch_aabb_0[1];
|
|
@@ -238,7 +250,7 @@ export default class IndexedBinaryBVH {
|
|
|
238
250
|
}
|
|
239
251
|
|
|
240
252
|
/**
|
|
241
|
-
*
|
|
253
|
+
* @deprecated use a visitor object instead
|
|
242
254
|
* @param {number} startX
|
|
243
255
|
* @param {number} startY
|
|
244
256
|
* @param {number} startZ
|
|
@@ -265,22 +277,6 @@ export default class IndexedBinaryBVH {
|
|
|
265
277
|
}
|
|
266
278
|
}
|
|
267
279
|
|
|
268
|
-
/**
|
|
269
|
-
*
|
|
270
|
-
* @param {number} source_offset
|
|
271
|
-
* @param {number[]|Float32Array} source
|
|
272
|
-
* @param {number[]|Float32Array} destination
|
|
273
|
-
* @param {number} destination_offset
|
|
274
|
-
*/
|
|
275
|
-
function copy_box_array(source_offset, source, destination, destination_offset) {
|
|
276
|
-
destination[destination_offset] = source[source_offset];
|
|
277
|
-
destination[destination_offset + 1] = source[source_offset + 1];
|
|
278
|
-
destination[destination_offset + 2] = source[source_offset + 2];
|
|
279
|
-
destination[destination_offset + 3] = source[source_offset + 3];
|
|
280
|
-
destination[destination_offset + 4] = source[source_offset + 4];
|
|
281
|
-
destination[destination_offset + 5] = source[source_offset + 5];
|
|
282
|
-
}
|
|
283
|
-
|
|
284
280
|
/**
|
|
285
281
|
*
|
|
286
282
|
* @param {number[]|Float32Array} source
|
|
@@ -348,23 +344,23 @@ function writeBox(array, address, x0, y0, z0, x1, y1, z1) {
|
|
|
348
344
|
* @param {Float32Array} array
|
|
349
345
|
*/
|
|
350
346
|
function copyBox(from, to, array) {
|
|
351
|
-
|
|
347
|
+
array_copy(array, from, array, to, 6);
|
|
352
348
|
}
|
|
353
349
|
|
|
354
350
|
/**
|
|
355
351
|
*
|
|
356
352
|
* @param {number} from
|
|
357
353
|
* @param {number} to
|
|
358
|
-
* @param {Float32Array} array
|
|
354
|
+
* @param {Float32Array|number[]} array
|
|
359
355
|
*/
|
|
360
356
|
function copyBoxZeroSize(from, to, array) {
|
|
361
|
-
|
|
357
|
+
array_copy(array, from, scratch_aabb_0, 0, 3);
|
|
362
358
|
|
|
363
359
|
scratch_aabb_0[3] = scratch_aabb_0[0];
|
|
364
360
|
scratch_aabb_0[4] = scratch_aabb_0[1];
|
|
365
361
|
scratch_aabb_0[5] = scratch_aabb_0[2];
|
|
366
362
|
|
|
367
|
-
|
|
363
|
+
array_copy(scratch_aabb_0, 0, array, to, 6);
|
|
368
364
|
}
|
|
369
365
|
|
|
370
366
|
/**
|
|
@@ -7,37 +7,54 @@ import { __process_point_if_within_planes } from "./__process_point_if_within_pl
|
|
|
7
7
|
import { plane_computeConvex3PlaneIntersection } from "../../geom/3d/plane/plane_computeConvex3PlaneIntersection.js";
|
|
8
8
|
import { EPSILON } from "../../math/MathUtils.js";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Common piece of continuous memory for better cache coherence
|
|
12
|
+
* @type {ArrayBuffer}
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
const __scratch_buffer = new ArrayBuffer(
|
|
16
|
+
24 * 4
|
|
17
|
+
+ 24 * 4
|
|
18
|
+
+ 8 * 4
|
|
19
|
+
+ 3 * 4
|
|
20
|
+
);
|
|
21
|
+
|
|
10
22
|
/**
|
|
11
23
|
*
|
|
12
24
|
* @type {number[]}
|
|
13
25
|
*/
|
|
14
|
-
const scratch_aabb_corners = new Float32Array(24);
|
|
26
|
+
const scratch_aabb_corners = new Float32Array(__scratch_buffer, 0, 24);
|
|
15
27
|
|
|
16
28
|
/**
|
|
17
29
|
*
|
|
18
30
|
* @type {number[]}
|
|
19
31
|
*/
|
|
20
|
-
const scratch_aabb_planes = new Float32Array(24);
|
|
32
|
+
const scratch_aabb_planes = new Float32Array(__scratch_buffer, 96, 24);
|
|
21
33
|
|
|
22
34
|
/**
|
|
23
35
|
*
|
|
24
36
|
* @type {number[]}
|
|
25
37
|
*/
|
|
26
|
-
const scratch_corner_out_bitfields = new Uint32Array(8);
|
|
38
|
+
const scratch_corner_out_bitfields = new Uint32Array(__scratch_buffer, 192, 8);
|
|
27
39
|
|
|
28
40
|
/**
|
|
29
41
|
*
|
|
30
42
|
* @type {number[]}
|
|
31
43
|
*/
|
|
32
|
-
const scratch_v3_array = new Float32Array(3);
|
|
44
|
+
const scratch_v3_array = new Float32Array(__scratch_buffer, 224, 3);
|
|
33
45
|
|
|
34
46
|
/**
|
|
47
|
+
* Figures out intersection volume between an AABB and a frustum for much tighter bounds
|
|
48
|
+
*
|
|
49
|
+
* Especially beneficial when trying to intersect a large AABB against a small frustum,
|
|
50
|
+
* where where traditionally only AABB corners would be considered,
|
|
51
|
+
* we're instead able to compute minimum bounds of the overlap of the two
|
|
35
52
|
*
|
|
36
53
|
* @param {AABB3} box
|
|
37
54
|
* @param {number[]} planes
|
|
38
55
|
* @param {number} plane_count
|
|
39
56
|
* @param {number} plane_mask
|
|
40
|
-
* @param {function} callback
|
|
57
|
+
* @param {function(x:number,y:number,z:number)} callback
|
|
41
58
|
* @param {*} [thisArg]
|
|
42
59
|
* @private
|
|
43
60
|
*/
|
package/core/cache/Cache.d.ts
CHANGED
|
@@ -4,13 +4,15 @@ export class Cache<K, V> {
|
|
|
4
4
|
keyWeigher,
|
|
5
5
|
valueWeigher,
|
|
6
6
|
keyHashFunction,
|
|
7
|
-
keyEqualityFunction
|
|
7
|
+
keyEqualityFunction,
|
|
8
|
+
capacity
|
|
8
9
|
}?: {
|
|
9
10
|
maxWeight?: number,
|
|
10
11
|
keyWeigher?: (key: K) => number,
|
|
11
12
|
valueWeigher?: (value: V) => number,
|
|
12
13
|
keyHashFunction?: (key: K) => number,
|
|
13
|
-
keyEqualityFunction?: (a: K, b: K) => boolean
|
|
14
|
+
keyEqualityFunction?: (a: K, b: K) => boolean,
|
|
15
|
+
capacity?: number
|
|
14
16
|
})
|
|
15
17
|
|
|
16
18
|
size(): number
|
package/core/cache/Cache.js
CHANGED
|
@@ -16,6 +16,7 @@ export class Cache {
|
|
|
16
16
|
* @param {function(key:Key, value:Value)} [removeListener] will be notified when element is either explicitly removed or evicted
|
|
17
17
|
* @param {function(Key):number} [keyHashFunction]
|
|
18
18
|
* @param {function(Key, Key):boolean} [keyEqualityFunction]
|
|
19
|
+
* @param {number} capacity initial capacity for the cache, helps prevent early resizing
|
|
19
20
|
* @constructor
|
|
20
21
|
* @template Key, Value
|
|
21
22
|
*/
|
|
@@ -25,7 +26,8 @@ export class Cache {
|
|
|
25
26
|
valueWeigher = returnOne,
|
|
26
27
|
removeListener = noop,
|
|
27
28
|
keyHashFunction = returnZero,
|
|
28
|
-
keyEqualityFunction = strictEquals
|
|
29
|
+
keyEqualityFunction = strictEquals,
|
|
30
|
+
capacity
|
|
29
31
|
} = {}) {
|
|
30
32
|
|
|
31
33
|
assert.isNumber(maxWeight, 'maxWeight');
|
|
@@ -95,7 +97,8 @@ export class Cache {
|
|
|
95
97
|
*/
|
|
96
98
|
this.data = new HashMap({
|
|
97
99
|
keyHashFunction,
|
|
98
|
-
keyEqualityFunction
|
|
100
|
+
keyEqualityFunction,
|
|
101
|
+
capacity
|
|
99
102
|
});
|
|
100
103
|
|
|
101
104
|
/**
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { assert } from "../assert.js";
|
|
8
8
|
import { returnZero } from "../function/Functions.js";
|
|
9
|
-
import { randomIntegerBetween } from "../math/MathUtils.js";
|
|
10
9
|
import { min2 } from "../math/min2.js";
|
|
11
10
|
import { HashMap } from "./HashMap.js";
|
|
11
|
+
import { randomIntegerBetween } from "../math/random/randomIntegerBetween.js";
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
export class HashMap<K, V> implements Iterable<[V, K]> {
|
|
2
|
-
constructor({
|
|
2
|
+
constructor({
|
|
3
|
+
keyHashFunction,
|
|
4
|
+
keyEqualityFunction,
|
|
5
|
+
capacity,
|
|
6
|
+
loadFactor
|
|
7
|
+
}: {
|
|
3
8
|
keyHashFunction: (k: K) => number,
|
|
4
|
-
keyEqualityFunction: (a: K, b: K) => boolean
|
|
9
|
+
keyEqualityFunction: (a: K, b: K) => boolean,
|
|
10
|
+
capacity?: number,
|
|
11
|
+
loadFactor?: number
|
|
5
12
|
})
|
|
6
13
|
|
|
7
14
|
constructor()
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export class HashSet<T> {
|
|
2
|
-
constructor({
|
|
2
|
+
constructor({
|
|
3
|
+
keyHashFunction,
|
|
4
|
+
keyEqualityFunction,
|
|
5
|
+
capacity
|
|
6
|
+
}: {
|
|
3
7
|
keyHashFunction: (k: T) => number,
|
|
4
|
-
keyEqualityFunction: (a: T, b: T) => boolean
|
|
8
|
+
keyEqualityFunction: (a: T, b: T) => boolean,
|
|
9
|
+
capacity?: number
|
|
5
10
|
})
|
|
6
11
|
|
|
7
12
|
constructor()
|
|
@@ -11,7 +11,11 @@ export class HashSet {
|
|
|
11
11
|
/**
|
|
12
12
|
* @template T
|
|
13
13
|
*/
|
|
14
|
-
constructor({
|
|
14
|
+
constructor({
|
|
15
|
+
keyHashFunction = invokeObjectHash,
|
|
16
|
+
keyEqualityFunction = invokeObjectEquals,
|
|
17
|
+
capacity
|
|
18
|
+
} = {}) {
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
21
|
* Using HashMap as a backing, this is not the most efficient approach, but it works
|
|
@@ -20,7 +24,8 @@ export class HashSet {
|
|
|
20
24
|
*/
|
|
21
25
|
this.__map = new HashMap({
|
|
22
26
|
keyHashFunction,
|
|
23
|
-
keyEqualityFunction
|
|
27
|
+
keyEqualityFunction,
|
|
28
|
+
capacity
|
|
24
29
|
});
|
|
25
30
|
}
|
|
26
31
|
|
|
@@ -5,11 +5,14 @@ const stack = [];
|
|
|
5
5
|
/**
|
|
6
6
|
* @template T
|
|
7
7
|
* @param {T[]} data
|
|
8
|
-
* @param {function(T):number}
|
|
8
|
+
* @param {function(T):number} score_function
|
|
9
|
+
* @param {*} score_function_context
|
|
9
10
|
* @param {number} start
|
|
10
11
|
* @param {number} end
|
|
12
|
+
* @param {function(T[],number, number):*} [swap_operator]
|
|
13
|
+
* @param {*} [swap_context]
|
|
11
14
|
*/
|
|
12
|
-
export function arrayQuickSort(data,
|
|
15
|
+
export function arrayQuickSort(data, score_function, score_function_context, start, end, swap_operator = arraySwapElements, swap_context = undefined) {
|
|
13
16
|
if (start >= end) {
|
|
14
17
|
// section of 0 size, nothing to sort
|
|
15
18
|
return;
|
|
@@ -32,15 +35,15 @@ export function arrayQuickSort(data, keyExtractor, start, end) {
|
|
|
32
35
|
|
|
33
36
|
const pivotIndex = (left + right) >> 1;
|
|
34
37
|
|
|
35
|
-
const pivot =
|
|
38
|
+
const pivot = score_function.call(score_function_context,data[pivotIndex]);
|
|
36
39
|
|
|
37
40
|
/* partition */
|
|
38
41
|
while (i <= j) {
|
|
39
|
-
while (
|
|
42
|
+
while (score_function.call(score_function_context,data[i]) < pivot) {
|
|
40
43
|
i++;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
while (
|
|
46
|
+
while (score_function.call(score_function_context,data[j]) > pivot) {
|
|
44
47
|
j--;
|
|
45
48
|
}
|
|
46
49
|
|
|
@@ -48,7 +51,7 @@ export function arrayQuickSort(data, keyExtractor, start, end) {
|
|
|
48
51
|
|
|
49
52
|
if (i !== j) {
|
|
50
53
|
//do swap
|
|
51
|
-
|
|
54
|
+
swap_operator.call(swap_context, data, i, j);
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
i++;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array} a
|
|
4
|
+
* @param {number} a_offset
|
|
5
|
+
* @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array} b
|
|
6
|
+
* @param {number} b_offset
|
|
7
|
+
* @param {number} length How many elements should be moved
|
|
8
|
+
*/
|
|
9
|
+
export function array_swap(a, a_offset, b, b_offset, length) {
|
|
10
|
+
|
|
11
|
+
let i, j, k;
|
|
12
|
+
|
|
13
|
+
for (k = 0; k < length; k++) {
|
|
14
|
+
i = a_offset + k;
|
|
15
|
+
j = b_offset + k;
|
|
16
|
+
|
|
17
|
+
const t = b[j];
|
|
18
|
+
|
|
19
|
+
b[j] = a[i];
|
|
20
|
+
a[i] = t;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @param {T[]} array
|
|
4
|
+
* @param {function(T):number} elementHashFunction
|
|
5
|
+
*/
|
|
6
|
+
export function computeHashArray(array, elementHashFunction) {
|
|
7
|
+
|
|
8
|
+
const numArguments = array.length;
|
|
9
|
+
let hash = numArguments;
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < numArguments; i++) {
|
|
12
|
+
|
|
13
|
+
const singleValue = array[i];
|
|
14
|
+
|
|
15
|
+
const elementHash = elementHashFunction(singleValue);
|
|
16
|
+
|
|
17
|
+
hash = ((hash << 5) - hash) + elementHash;
|
|
18
|
+
hash |= 0; // Convert to 32bit integer
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return hash;
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes hash on integer values
|
|
3
|
+
* @param {...number} value
|
|
4
|
+
* @returns {number}
|
|
5
|
+
*/
|
|
6
|
+
export function computeHashIntegerArray(value) {
|
|
7
|
+
let hash = 0;
|
|
8
|
+
const numArguments = arguments.length;
|
|
9
|
+
for (let i = 0; i < numArguments; i++) {
|
|
10
|
+
const singleValue = arguments[i];
|
|
11
|
+
hash = ((hash << 5) - hash) + singleValue;
|
|
12
|
+
hash |= 0; // Convert to 32bit integer
|
|
13
|
+
}
|
|
14
|
+
return hash;
|
|
15
|
+
}
|
|
@@ -25,9 +25,9 @@ export function copyArray(source, target) {
|
|
|
25
25
|
* Follows Java System.arraycopy interface
|
|
26
26
|
* Copy data from one array to another
|
|
27
27
|
* @template T
|
|
28
|
-
* @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array} source The source array
|
|
28
|
+
* @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array|Float32Array|Float64Array} source The source array
|
|
29
29
|
* @param {number} source_position Starting position where to copy from inside the source array
|
|
30
|
-
* @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array} destination The destination array
|
|
30
|
+
* @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array|Float32Array|Float64Array} destination The destination array
|
|
31
31
|
* @param {number} destination_position Starting position where to copy to inside the destination array
|
|
32
32
|
* @param {number} length How many elements should be copied
|
|
33
33
|
*/
|
|
@@ -16,4 +16,19 @@ export const DataType2TypedArrayConstructorMapping = {
|
|
|
16
16
|
[DataType.Float16]: Uint16Array,
|
|
17
17
|
[DataType.Float32]: Float32Array,
|
|
18
18
|
[DataType.Float64]: Float64Array,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {DataType} dt
|
|
24
|
+
* @returns {constructor|function}
|
|
25
|
+
*/
|
|
26
|
+
export function compute_typed_array_constructor_from_data_type(dt) {
|
|
27
|
+
const r = DataType2TypedArrayConstructorMapping[dt];
|
|
28
|
+
|
|
29
|
+
if (r === undefined) {
|
|
30
|
+
throw new Error(`Unsupported data type '${dt}'`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return r;
|
|
19
34
|
}
|
package/core/color/Color.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { assert } from "../assert.js";
|
|
2
2
|
import Signal from "../events/signal/Signal.js";
|
|
3
|
-
import { computeHashFloat, computeHashIntegerArray } from "../math/MathUtils.js";
|
|
4
3
|
import { parseColor, rgb2hsv } from "./ColorUtils.js";
|
|
5
4
|
import { clamp } from "../math/clamp.js";
|
|
6
5
|
import { min2 } from "../math/min2.js";
|
|
7
6
|
import { max2 } from "../math/max2.js";
|
|
8
7
|
import { min3 } from "../math/min3.js";
|
|
8
|
+
import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
|
|
9
|
+
import { computeHashFloat } from "../math/hash/computeHashFloat.js";
|
|
9
10
|
|
|
10
11
|
class Color {
|
|
11
12
|
/**
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { assert } from "../assert.js";
|
|
2
2
|
import { Cache } from "../cache/Cache.js";
|
|
3
3
|
import { isArrayEqualStrict } from "../collection/array/isArrayEqualStrict.js";
|
|
4
|
-
import { computeHashArray, computeHashIntegerArray } from "../math/MathUtils.js";
|
|
5
4
|
import { invokeObjectEquals } from "../model/object/invokeObjectEquals.js";
|
|
6
5
|
import { invokeObjectHash } from "../model/object/invokeObjectHash.js";
|
|
7
6
|
import { computeStringHash } from "../primitives/strings/computeStringHash.js";
|
|
8
7
|
import { computeUTF8StringByteSize } from "../primitives/strings/StringUtils.js";
|
|
8
|
+
import { computeHashArray } from "../collection/array/computeHashArray.js";
|
|
9
|
+
import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Hash is an integer value, so this is an invalid value for a computed hash
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { computePointDistanceToPlane } from "../../Plane.js";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* @param {number} plane_normal_x
|
|
5
3
|
* @param {number} plane_normal_y
|
|
@@ -14,38 +12,16 @@ import { computePointDistanceToPlane } from "../../Plane.js";
|
|
|
14
12
|
* @returns {number}
|
|
15
13
|
*/
|
|
16
14
|
export function aabb3_computeDistanceAbovePlane(
|
|
17
|
-
plane_normal_x,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
plane_constant,
|
|
21
|
-
_x0,
|
|
22
|
-
_y0,
|
|
23
|
-
_z0,
|
|
24
|
-
_x1,
|
|
25
|
-
_y1,
|
|
26
|
-
_z1
|
|
15
|
+
plane_normal_x, plane_normal_y, plane_normal_z, plane_constant,
|
|
16
|
+
_x0, _y0, _z0,
|
|
17
|
+
_x1, _y1, _z1
|
|
27
18
|
) {
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
px = _x1;
|
|
34
|
-
} else {
|
|
35
|
-
px = _x0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (plane_normal_y > 0) {
|
|
39
|
-
py = _y1;
|
|
40
|
-
} else {
|
|
41
|
-
py = _y0;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (plane_normal_z > 0) {
|
|
45
|
-
pz = _z1;
|
|
46
|
-
} else {
|
|
47
|
-
pz = _z0;
|
|
48
|
-
}
|
|
20
|
+
// pick a corner point furthest along the plane normal
|
|
21
|
+
const px = plane_normal_x > 0 ? _x1 : _x0;
|
|
22
|
+
const py = plane_normal_y > 0 ? _y1 : _y0;
|
|
23
|
+
const pz = plane_normal_z > 0 ? _z1 : _z0;
|
|
49
24
|
|
|
50
|
-
|
|
25
|
+
// dot(v4,v4) inlined for speed
|
|
26
|
+
return (plane_normal_x * px + plane_normal_y * py + plane_normal_z * pz) + plane_constant;
|
|
51
27
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { v3_length } from "../../v3_length.js";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
*
|
|
5
3
|
* @param {number[]} destination
|
|
@@ -10,10 +8,12 @@ import { v3_length } from "../../v3_length.js";
|
|
|
10
8
|
* @param {number} w
|
|
11
9
|
*/
|
|
12
10
|
function array_set_plane_normalized(destination, destination_offset, x, y, z, w) {
|
|
13
|
-
|
|
11
|
+
// compute vector length
|
|
12
|
+
const length = Math.hypot(x, y, z);
|
|
14
13
|
|
|
15
14
|
const inverseNormalLength = 1.0 / length;
|
|
16
15
|
|
|
16
|
+
// apply normalization
|
|
17
17
|
destination[destination_offset] = x * inverseNormalLength;
|
|
18
18
|
destination[destination_offset + 1] = y * inverseNormalLength;
|
|
19
19
|
destination[destination_offset + 2] = z * inverseNormalLength;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ray_computeNearestPointToPoint } from "../../LineSegment.js";
|
|
2
1
|
import { computePlanePlaneIntersection, computePointDistanceToPlane } from "../../Plane.js";
|
|
3
2
|
import Vector3 from "../../Vector3.js";
|
|
4
3
|
import { plane3_projectPoint } from "../plane/plane3_projectPoint.js";
|
|
5
4
|
import { plane_three_computeConvex3PlaneIntersection } from "../plane/plane_computeConvex3PlaneIntersection.js";
|
|
5
|
+
import { ray_computeNearestPointToPoint } from "../ray/ray_computeNearestPointToPoint.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { clamp } from "../../../math/clamp.js";
|
|
2
|
+
import { v3_distance_sqr } from "../../v3_distance_sqr.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Computes shortest distance between a line segment(defined by 2 points) and a point
|
|
6
|
+
* @param {number} x0
|
|
7
|
+
* @param {number} y0
|
|
8
|
+
* @param {number} z0
|
|
9
|
+
* @param {number} x1
|
|
10
|
+
* @param {number} y1
|
|
11
|
+
* @param {number} z1
|
|
12
|
+
* @param {number} px
|
|
13
|
+
* @param {number} py
|
|
14
|
+
* @param {number} pz
|
|
15
|
+
*/
|
|
16
|
+
export function line3_computeSegmentPointDistance_sqr(x0, y0, z0, x1, y1, z1, px, py, pz) {
|
|
17
|
+
// get line delta
|
|
18
|
+
const line_delta_x = x1 - x0;
|
|
19
|
+
const line_delta_y = y1 - y0;
|
|
20
|
+
const line_delta_z = z1 - z0;
|
|
21
|
+
|
|
22
|
+
// find closest point
|
|
23
|
+
const sp0_x = px - x0;
|
|
24
|
+
const sp0_y = py - y0;
|
|
25
|
+
const sp0_z = pz - z0;
|
|
26
|
+
|
|
27
|
+
//
|
|
28
|
+
const d2 = line_delta_x * line_delta_x + line_delta_y * line_delta_y + line_delta_z * line_delta_z;
|
|
29
|
+
|
|
30
|
+
const d3 = line_delta_x * sp0_x + line_delta_y * sp0_y + line_delta_z * sp0_z;
|
|
31
|
+
|
|
32
|
+
const t = clamp(d3 / d2, 0, 1);
|
|
33
|
+
|
|
34
|
+
// compute point on the line
|
|
35
|
+
const lp_x = line_delta_x * t + x0;
|
|
36
|
+
const lp_y = line_delta_y * t + y0;
|
|
37
|
+
const lp_z = line_delta_z * t + z0;
|
|
38
|
+
|
|
39
|
+
// compute distance from the point in question to the point on the line
|
|
40
|
+
return v3_distance_sqr(px, py, pz, lp_x, lp_y, lp_z);
|
|
41
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* method to separate bits from a given integer 3 positions apart
|
|
3
|
+
* we only look at the first 10 bits
|
|
3
4
|
* @param {number} a
|
|
4
5
|
* @returns {number}
|
|
5
6
|
*/
|
|
6
7
|
function splitBy3(a) {
|
|
7
|
-
let x = a
|
|
8
|
+
let x = a;
|
|
8
9
|
x = (x | x << 16) & 0x30000ff;
|
|
9
10
|
x = (x | x << 8) & 0x0300f00f;
|
|
10
11
|
x = (x | x << 4) & 0x30c30c3;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const b = new ArrayBuffer(4);
|
|
2
|
+
const b_f32 = new Float32Array(b);
|
|
3
|
+
const b_i32 = new Int32Array(b);
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {number} value
|
|
8
|
+
* @returns {number}
|
|
9
|
+
*/
|
|
10
|
+
export function reinterpret_float32_as_int32(value) {
|
|
11
|
+
b_f32[0] = value;
|
|
12
|
+
return b_i32[0];
|
|
13
|
+
}
|