@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.
- package/core/assert.js +3 -1
- package/core/bvh2/BinaryNode.js +1 -1
- package/core/bvh2/aabb3/AABB3.js +18 -0
- 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/__detailed_box_volume_intersection.js +11 -8
- package/core/collection/ArrayUtils.js +1 -1
- package/core/collection/HashMap.js +66 -22
- package/core/collection/array/arrayQuickSort.js +9 -6
- package/core/collection/array/array_swap.js +22 -0
- package/core/collection/array/computeHashArray.js +22 -0
- package/core/collection/array/computeHashIntegerArray.js +15 -0
- 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/CircleMath.js +4 -4
- package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
- package/core/geom/3d/cone/computeConeBoundingBox.js +4 -4
- package/core/geom/3d/{compute_bounding_cone_of_2_cones.js → cone/compute_bounding_cone_of_2_cones.js} +3 -3
- package/core/geom/3d/{compute_bounding_cone_of_2_cones.spec.js → cone/compute_bounding_cone_of_2_cones.spec.js} +1 -1
- package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +1 -1
- package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +11 -3
- 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/{encode_unit3_hemioct.js → normal/hemioct/encode_unit3_hemioct.js} +0 -0
- package/core/geom/3d/{unit_hemioct.spec.js → normal/hemioct/unit_hemioct.spec.js} +1 -1
- package/core/geom/3d/normal/lamber_azimuth/transform.js +61 -0
- package/core/geom/3d/normal/spherical/sphere_map_transform.js +77 -0
- package/core/geom/3d/{lerp_planes_to_array.js → plane/lerp_planes_to_array.js} +1 -3
- package/core/geom/3d/plane/plane3_lerp.js +3 -1
- package/core/geom/3d/plane/plane3_slerp.js +4 -1
- package/core/geom/3d/{plane_computeConvex3PlaneIntersection.js → plane/plane_computeConvex3PlaneIntersection.js} +14 -16
- package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
- package/core/geom/3d/shape/AbstractShape3D.js +29 -0
- package/core/geom/3d/shape/CompositeShape.js +60 -0
- package/core/geom/3d/shape/TransformedShape3D.js +70 -0
- package/core/geom/3d/shape/UnitCubeShape3D.js +13 -0
- package/core/geom/3d/shape/UnitSphereShape3D.js +16 -0
- package/core/geom/3d/topology/TopoTriangle.js +1 -1
- package/core/geom/3d/topology/TopoVertex.js +1 -1
- package/core/geom/3d/topology/bounds/computeTraingleClusterNormalBoundingCone.js +2 -2
- package/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +1 -1
- package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +1 -1
- package/core/geom/3d/triangle/computeTrianglePlaneSide.js +1 -1
- package/core/geom/3d/triangle/computeTriangleRayIntersection.js +1 -1
- package/core/geom/3d/voxel/DenseBitVolume3D.js +87 -0
- package/core/geom/3d/voxel/buildVolumeFromProjectedGeometry.js +23 -0
- package/core/geom/AABB2.js +1 -1
- package/core/geom/ConicRay.js +3 -1
- package/core/geom/LineSegment.js +1 -77
- package/core/geom/Matrix4.js +8 -8
- package/core/geom/Plane.js +15 -10
- package/core/geom/Quaternion.js +2 -1
- package/core/geom/Rectangle.js +2 -1
- package/core/geom/Vector1.js +1 -1
- package/core/geom/Vector3.d.ts +2 -0
- package/core/geom/Vector3.js +35 -159
- package/core/geom/Vector3.spec.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 +6 -3
- package/core/geom/random/randomPointOnBox.js +7 -3
- package/core/geom/random/randomPointOnSphere.js +6 -3
- package/core/geom/v3_angle_between.js +31 -0
- package/core/geom/v3_distance.js +16 -0
- package/core/geom/v3_distance_sqr.js +17 -0
- package/core/geom/v3_dot.js +13 -0
- package/core/geom/v3_length.js +10 -0
- package/core/geom/v3_length_sqr.js +10 -0
- package/core/geom/v3_lerp.js +21 -0
- package/core/geom/v3_slerp.js +48 -0
- package/core/graph/graph_k_means_cluster.js +1 -1
- 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/primitives/array/computeIntegerArrayHash.js +6 -1
- 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 +10 -0
- package/engine/asset/loaders/image/ImageRGBADataAsset.js +8 -1
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +11 -0
- package/engine/asset/loaders/material/computeImageBitmapHash.js +22 -28
- package/engine/asset/loaders/material/computeMaterialHash.js +4 -3
- package/engine/asset/loaders/material/computeTextureEquality.js +13 -5
- package/engine/asset/loaders/material/computeTextureHash.js +2 -1
- package/engine/ecs/animation/Animation.js +2 -1
- package/engine/ecs/animation/InverseKinematics.js +2 -1
- package/engine/ecs/animation/OneBoneSurfaceAlignmentSolver.js +3 -1
- package/engine/ecs/animation/TwoBoneInverseKinematicsSolver.js +3 -1
- 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/ecs/Foliage2.js +1 -1
- package/engine/ecs/fow/FogOfWar.js +2 -3
- 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 +1 -1
- package/engine/ecs/gui/position/ViewportPosition.js +2 -1
- package/engine/ecs/systems/RangedAttackSystem.js +1 -1
- package/engine/ecs/systems/SteeringSystem.js +3 -2
- package/engine/ecs/terrain/ecs/Terrain.js +6 -0
- package/engine/ecs/terrain/ecs/layers/TerrainLayers.js +5 -0
- package/engine/ecs/terrain/ecs/splat/SplatMapping.js +5 -0
- package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
- package/engine/ecs/tooltip/TooltipComponent.js +15 -0
- package/engine/ecs/util/hideEntityGracefully.js +18 -0
- package/engine/graphics/GraphicsEngine.js +1 -0
- package/engine/graphics/camera/testClippingPlaneComputation.js +2 -2
- 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 +2 -2
- package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
- package/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +0 -53
- package/engine/graphics/ecs/light/Light.d.ts +1 -1
- package/engine/graphics/ecs/light/Light.js +3 -0
- package/engine/graphics/ecs/mesh/Mesh.js +2 -1
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
- package/engine/graphics/ecs/path/testPathDisplaySystem.js +98 -98
- package/engine/graphics/ecs/trail2d/Trail2D.js +17 -4
- package/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts +2 -3
- package/engine/graphics/ecs/trail2d/Trail2DSystem.js +34 -118
- package/engine/graphics/geometry/AttributeSpec.js +105 -0
- package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
- package/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +2 -1
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
- package/engine/graphics/micron/build/clustering/computeFaceCurvatureScore.js +1 -1
- package/engine/graphics/micron/build/clustering/compute_face_connection_weight.js +1 -1
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
- package/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +1 -1
- package/engine/graphics/micron/build/hierarchy/patch_combine.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 +5 -5
- package/engine/graphics/micron/render/refinement/is_patch_facing_back.js +2 -2
- package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +4 -2
- package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +84 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +92 -144
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +14 -3
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +51 -12
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +3 -2
- package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +37 -0
- package/engine/graphics/particles/particular/engine/emitter/distance_to_camera.js +25 -0
- 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 +21 -0
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +0 -20
- package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +7 -25
- 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/ParticleVolume.js +384 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +558 -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/buffers/prototypeNormalFrameBuffer.js +2 -2
- package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +1 -1
- 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 +126 -95
- 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/computeFrustumCorners.js +15 -33
- package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
- package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +12 -2
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +6 -6
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +231 -136
- 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 +73 -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/layers/RenderLayerUtils.js +8 -5
- package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -2
- package/engine/graphics/texture/atlas/AtlasPatch.js +7 -2
- package/engine/graphics/texture/atlas/TextureAtlas.js +18 -14
- 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 +8 -7
- package/engine/graphics/texture/sampler/distanceField.spec.js +1 -1
- package/engine/graphics/texture/sampler/scaleSampler2D.js +7 -10
- package/engine/graphics/trail/x/RibbonMaterialX.js +3 -3
- package/engine/graphics/trail/x/RibbonX.js +17 -2
- package/engine/graphics/trail/x/RibbonXPlugin.js +51 -1
- package/engine/graphics/util/projectSphere.js +1 -1
- package/engine/grid/components/GridObstacle.js +3 -10
- package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
- package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
- package/engine/navigation/ecs/components/Path.js +3 -2
- package/engine/navigation/grid/FastBinaryHeap.spec.js +1 -1
- package/engine/reference/v2/Reference.js +6 -0
- 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/CellFilterAngleToNormal.js +3 -2
- package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +1 -1
- package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
- package/generation/markers/GridCellActionPlaceMarker.js +13 -1
- package/generation/markers/MarkerNode.js +6 -0
- 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 +5 -2
- package/misc/makeMaterialIconCached.js +2 -2
- package/package.json +3 -3
- package/view/View.js +4 -2
- package/view/elements/image/HTMLElementCacheKey.js +2 -1
- package/view/elements/radial/RadialText.js +2 -1
- package/view/minimap/gl/MinimapMarkersGL.js +19 -101
- 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 -345
|
@@ -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(data, from, scratch_aabb_0, 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
|
/**
|
|
@@ -4,9 +4,8 @@ import { computePointDistanceToPlane, plane3_computeLineSegmentIntersection } fr
|
|
|
4
4
|
import { aabb3_corner_edge_mapping } from "../aabb3/aabb3_corner_edge_mapping.js";
|
|
5
5
|
import { aabb3_edge_corner_mapping } from "../aabb3/aabb3_edge_corner_mapping.js";
|
|
6
6
|
import { __process_point_if_within_planes } from "./__process_point_if_within_planes.js";
|
|
7
|
-
import { plane_computeConvex3PlaneIntersection } from "../../geom/3d/plane_computeConvex3PlaneIntersection.js";
|
|
7
|
+
import { plane_computeConvex3PlaneIntersection } from "../../geom/3d/plane/plane_computeConvex3PlaneIntersection.js";
|
|
8
8
|
import { EPSILON } from "../../math/MathUtils.js";
|
|
9
|
-
import Vector3 from "../../geom/Vector3.js";
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
*
|
|
@@ -26,7 +25,11 @@ const scratch_aabb_planes = new Float32Array(24);
|
|
|
26
25
|
*/
|
|
27
26
|
const scratch_corner_out_bitfields = new Uint32Array(8);
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @type {number[]}
|
|
31
|
+
*/
|
|
32
|
+
const scratch_v3_array = new Float32Array(3);
|
|
30
33
|
|
|
31
34
|
/**
|
|
32
35
|
*
|
|
@@ -183,7 +186,7 @@ export function __detailed_box_volume_intersection(
|
|
|
183
186
|
const c = planes[plane_address + 3];
|
|
184
187
|
|
|
185
188
|
const edge_intersects = plane3_computeLineSegmentIntersection(
|
|
186
|
-
|
|
189
|
+
scratch_v3_array, 0,
|
|
187
190
|
corner_0_x, corner_0_y, corner_0_z,
|
|
188
191
|
corner_1_x, corner_1_y, corner_1_z,
|
|
189
192
|
nx, ny, nz, c
|
|
@@ -192,7 +195,7 @@ export function __detailed_box_volume_intersection(
|
|
|
192
195
|
if (edge_intersects) {
|
|
193
196
|
// a possible candidate, let's see if this point is within rest of the planes
|
|
194
197
|
__process_point_if_within_planes(
|
|
195
|
-
|
|
198
|
+
scratch_v3_array[0], scratch_v3_array[1], scratch_v3_array[2],
|
|
196
199
|
(plane_mask ^ plane_bit_mask),
|
|
197
200
|
planes,
|
|
198
201
|
plane_count,
|
|
@@ -230,7 +233,7 @@ export function __detailed_box_volume_intersection(
|
|
|
230
233
|
const cp_1 = next_orthogonal_plane_index * 4;
|
|
231
234
|
|
|
232
235
|
const intersection_exists = plane_computeConvex3PlaneIntersection(
|
|
233
|
-
|
|
236
|
+
scratch_v3_array, 0,
|
|
234
237
|
aabb_plane_nx, aabb_plane_ny, aabb_plane_nz, aabb_plane_constant,
|
|
235
238
|
planes[cp_0], planes[cp_0 + 1], planes[cp_0 + 2], planes[cp_0 + 3],
|
|
236
239
|
planes[cp_1], planes[cp_1 + 1], planes[cp_1 + 2], planes[cp_1 + 3]
|
|
@@ -238,14 +241,14 @@ export function __detailed_box_volume_intersection(
|
|
|
238
241
|
|
|
239
242
|
if (intersection_exists) {
|
|
240
243
|
|
|
241
|
-
const point_within_box = box.containsPointWithTolerance(
|
|
244
|
+
const point_within_box = box.containsPointWithTolerance(scratch_v3_array[0], scratch_v3_array[1], scratch_v3_array[2], EPSILON);
|
|
242
245
|
|
|
243
246
|
if (point_within_box) {
|
|
244
247
|
// point is within the AABB bounds
|
|
245
248
|
|
|
246
249
|
// ThreeClippingPlaneComputingBVHVisitor.DEBUG_POINTS_2.send3(scratch_v3.x, scratch_v3.y, scratch_v3.z);
|
|
247
250
|
|
|
248
|
-
callback.call(thisArg,
|
|
251
|
+
callback.call(thisArg, scratch_v3_array[0], scratch_v3_array[1], scratch_v3_array[2]);
|
|
249
252
|
}
|
|
250
253
|
}
|
|
251
254
|
}
|
|
@@ -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
|
/**
|
|
@@ -26,6 +26,18 @@ class MapEntry {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* @readonly
|
|
31
|
+
* @type {number}
|
|
32
|
+
*/
|
|
33
|
+
const DEFAULT_INITIAL_CAPACITY = 16;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @readonly
|
|
37
|
+
* @type {number}
|
|
38
|
+
*/
|
|
39
|
+
const DEFAULT_LOAD_FACTOR = 0.75;
|
|
40
|
+
|
|
29
41
|
/**
|
|
30
42
|
* Implements part of {@link Map} interface
|
|
31
43
|
* @template K,V
|
|
@@ -36,10 +48,14 @@ export class HashMap {
|
|
|
36
48
|
* @template K, V
|
|
37
49
|
* @param {function(K):number} [keyHashFunction]
|
|
38
50
|
* @param {function(K,K):boolean} [keyEqualityFunction]
|
|
51
|
+
* @param {number} [capacity] initial number of buckets in the hash table
|
|
52
|
+
* @param {number} [loadFactor] a measure of how full the hash table is allowed to get before its capacity is automatically increased
|
|
39
53
|
*/
|
|
40
54
|
constructor({
|
|
41
55
|
keyHashFunction = invokeObjectHash,
|
|
42
|
-
keyEqualityFunction = invokeObjectEquals
|
|
56
|
+
keyEqualityFunction = invokeObjectEquals,
|
|
57
|
+
capacity = DEFAULT_INITIAL_CAPACITY,
|
|
58
|
+
loadFactor = DEFAULT_LOAD_FACTOR
|
|
43
59
|
} = {}) {
|
|
44
60
|
assert.typeOf(keyHashFunction, 'function', 'keyHashFunction');
|
|
45
61
|
assert.typeOf(keyEqualityFunction, 'function', 'keyEqualityFunction');
|
|
@@ -69,14 +85,21 @@ export class HashMap {
|
|
|
69
85
|
* @type {number}
|
|
70
86
|
* @private
|
|
71
87
|
*/
|
|
72
|
-
this.__bucket_count =
|
|
88
|
+
this.__bucket_count = capacity;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* How full the table can get before number of buckets is increased
|
|
92
|
+
* @type {number}
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
this.__load_factor = loadFactor;
|
|
73
96
|
}
|
|
74
97
|
|
|
75
98
|
/**
|
|
76
99
|
* Proportion between actual number of records in the map and the bucket count (number of potential hashes)
|
|
77
100
|
* @returns {number}
|
|
78
101
|
*/
|
|
79
|
-
|
|
102
|
+
getCurrentLoad() {
|
|
80
103
|
return this.size / this.__bucket_count;
|
|
81
104
|
}
|
|
82
105
|
|
|
@@ -133,7 +156,7 @@ export class HashMap {
|
|
|
133
156
|
this.__bucket_count = count;
|
|
134
157
|
if (this.size > 0) {
|
|
135
158
|
// re-hash
|
|
136
|
-
this.
|
|
159
|
+
this.rebuild();
|
|
137
160
|
}
|
|
138
161
|
}
|
|
139
162
|
|
|
@@ -167,31 +190,49 @@ export class HashMap {
|
|
|
167
190
|
let bucket = this.records[bucket_index];
|
|
168
191
|
|
|
169
192
|
if (bucket === undefined) {
|
|
170
|
-
|
|
193
|
+
|
|
194
|
+
// bucket for this value doesn't exist
|
|
195
|
+
|
|
196
|
+
bucket = [];
|
|
197
|
+
|
|
171
198
|
this.records[bucket_index] = bucket;
|
|
172
199
|
|
|
173
|
-
|
|
200
|
+
} else {
|
|
174
201
|
|
|
175
|
-
|
|
176
|
-
}
|
|
202
|
+
// bucket exists
|
|
177
203
|
|
|
178
|
-
|
|
204
|
+
const bucketSize = bucket.length;
|
|
179
205
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
206
|
+
//check if key already exists
|
|
207
|
+
for (let i = 0; i < bucketSize; i++) {
|
|
208
|
+
const entry = bucket[i];
|
|
183
209
|
|
|
184
|
-
|
|
185
|
-
if (entryKey === key || this.keyEqualityFunction(entryKey, key)) {
|
|
210
|
+
const entryKey = entry.key;
|
|
186
211
|
|
|
187
|
-
|
|
188
|
-
|
|
212
|
+
if (entryKey === key || this.keyEqualityFunction(entryKey, key)) {
|
|
213
|
+
|
|
214
|
+
entry.value = value;
|
|
215
|
+
return;
|
|
216
|
+
|
|
217
|
+
}
|
|
189
218
|
|
|
190
219
|
}
|
|
220
|
+
|
|
191
221
|
}
|
|
192
222
|
|
|
193
223
|
bucket.push(new MapEntry(key, value));
|
|
194
|
-
|
|
224
|
+
|
|
225
|
+
const old_size = this.size;
|
|
226
|
+
const new_size = old_size + 1;
|
|
227
|
+
this.size = new_size;
|
|
228
|
+
|
|
229
|
+
// compute actual current load
|
|
230
|
+
const load = new_size / this.__bucket_count;
|
|
231
|
+
|
|
232
|
+
if (load > this.__load_factor) {
|
|
233
|
+
// increase table size
|
|
234
|
+
this.setBucketCount(this.__bucket_count * 2);
|
|
235
|
+
}
|
|
195
236
|
}
|
|
196
237
|
|
|
197
238
|
/**
|
|
@@ -308,20 +349,22 @@ export class HashMap {
|
|
|
308
349
|
}
|
|
309
350
|
|
|
310
351
|
/**
|
|
311
|
-
*
|
|
352
|
+
* Rebuild table, useful for when table is resized or hashes of stored keys change
|
|
312
353
|
*/
|
|
313
|
-
|
|
354
|
+
rebuild() {
|
|
314
355
|
|
|
315
356
|
let h, i, l;
|
|
316
357
|
|
|
317
358
|
const records = this.records;
|
|
318
359
|
|
|
319
360
|
for (h in records) {
|
|
361
|
+
const stored_bucket_index = parseInt(h);
|
|
362
|
+
|
|
320
363
|
if (!records.hasOwnProperty(h)) {
|
|
321
364
|
continue;
|
|
322
365
|
}
|
|
323
366
|
|
|
324
|
-
const bucket = records[
|
|
367
|
+
const bucket = records[stored_bucket_index];
|
|
325
368
|
|
|
326
369
|
for (i = 0, l = bucket.length; i < l; i++) {
|
|
327
370
|
/**
|
|
@@ -333,7 +376,6 @@ export class HashMap {
|
|
|
333
376
|
const raw_hash = this.keyHashFunction(entry.key);
|
|
334
377
|
const actual_bucket_index = this.__compute_bucket_index(raw_hash);
|
|
335
378
|
|
|
336
|
-
const stored_bucket_index = parseInt(h);
|
|
337
379
|
|
|
338
380
|
if (actual_bucket_index !== stored_bucket_index) {
|
|
339
381
|
//remove entry from the bucket
|
|
@@ -345,15 +387,17 @@ export class HashMap {
|
|
|
345
387
|
|
|
346
388
|
if (bucket.length === 0) {
|
|
347
389
|
//delete empty bucket
|
|
348
|
-
delete records[
|
|
390
|
+
delete records[stored_bucket_index];
|
|
349
391
|
}
|
|
350
392
|
|
|
351
393
|
const newBucket = records[actual_bucket_index];
|
|
394
|
+
|
|
352
395
|
if (newBucket === undefined) {
|
|
353
396
|
records[actual_bucket_index] = [entry];
|
|
354
397
|
} else {
|
|
355
398
|
newBucket.push(entry);
|
|
356
399
|
}
|
|
400
|
+
|
|
357
401
|
}
|
|
358
402
|
}
|
|
359
403
|
}
|
|
@@ -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
|
+
}
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v3_angle_between } from "../v3_angle_between.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* NOTE: based on https://stackoverflow.com/questions/2592011/bounding-boxes-for-circle-and-arcs-in-3d
|
|
@@ -12,9 +12,9 @@ import { v3_angleBetween } from "../Vector3.js";
|
|
|
12
12
|
* @param {number} radius
|
|
13
13
|
*/
|
|
14
14
|
export function computeCircleBoundingBox(result, centerX, centerY, centerZ, normalX, normalY, normalZ, radius) {
|
|
15
|
-
const ax =
|
|
16
|
-
const ay =
|
|
17
|
-
const az =
|
|
15
|
+
const ax = v3_angle_between(normalX, normalY, normalZ, 1, 0, 0);
|
|
16
|
+
const ay = v3_angle_between(normalX, normalY, normalZ, 0, 1, 0);
|
|
17
|
+
const az = v3_angle_between(normalX, normalY, normalZ, 0, 0, 1);
|
|
18
18
|
|
|
19
19
|
const rX = Math.sin(ax) * radius;
|
|
20
20
|
const rY = Math.sin(ay) * radius;
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
import { max2 } from "../../../math/max2.js";
|
|
2
2
|
import { min2 } from "../../../math/min2.js";
|
|
3
|
-
import {
|
|
3
|
+
import { v3_angle_between } from "../../v3_angle_between.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* NOTE: used stackoverflow answer as a basis for circle part: https://stackoverflow.com/questions/2592011/bounding-boxes-for-circle-and-arcs-in-3d
|
|
@@ -15,9 +15,9 @@ import { v3_angleBetween } from "../../Vector3.js";
|
|
|
15
15
|
* @param {number} length
|
|
16
16
|
*/
|
|
17
17
|
export function computeConeBoundingBox(result, originX, originY, originZ, directionX, directionY, directionZ, angle, length) {
|
|
18
|
-
const ax =
|
|
19
|
-
const ay =
|
|
20
|
-
const az =
|
|
18
|
+
const ax = v3_angle_between(directionX, directionY, directionZ, 1, 0, 0);
|
|
19
|
+
const ay = v3_angle_between(directionX, directionY, directionZ, 0, 1, 0);
|
|
20
|
+
const az = v3_angle_between(directionX, directionY, directionZ, 0, 0, 1);
|
|
21
21
|
|
|
22
22
|
//compute radius of the base of the cone
|
|
23
23
|
const radius = length * Math.tan(angle);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import Vector3 from "
|
|
5
|
-
import Quaternion, { quat3_createFromAxisAngle } from "
|
|
6
|
-
import { max2 } from "
|
|
4
|
+
import Vector3 from "../../Vector3.js";
|
|
5
|
+
import Quaternion, { quat3_createFromAxisAngle } from "../../Quaternion.js";
|
|
6
|
+
import { max2 } from "../../../math/max2.js";
|
|
7
7
|
|
|
8
8
|
const tangent = new Vector3();
|
|
9
9
|
|