@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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import Vector3 from "../../Vector3.js";
|
|
2
|
+
import { BitSet } from "../../../binary/BitSet.js";
|
|
3
|
+
|
|
4
|
+
export class DenseBitVolume3D {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.size = new Vector3(1, 1, 1);
|
|
7
|
+
|
|
8
|
+
this.__data = new BitSet();
|
|
9
|
+
this.__data.preventShrink();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
clear() {
|
|
13
|
+
this.__data.reset();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
resize(x, y, z) {
|
|
17
|
+
// TODO consider how we can resize while keeping the data
|
|
18
|
+
this.clear();
|
|
19
|
+
|
|
20
|
+
this.size.set(x, y, z);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {number} x
|
|
26
|
+
* @param {number} y
|
|
27
|
+
* @param {number} z
|
|
28
|
+
* @return {number}
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
__compute_address(x, y, z) {
|
|
32
|
+
|
|
33
|
+
const size = this.size;
|
|
34
|
+
|
|
35
|
+
const dx = size.x;
|
|
36
|
+
const dy = size.y;
|
|
37
|
+
|
|
38
|
+
return y * dx + z * dx * dy + x;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param {number} x
|
|
44
|
+
* @param {number} y
|
|
45
|
+
* @param {number} z
|
|
46
|
+
* @return {boolean}
|
|
47
|
+
*/
|
|
48
|
+
get(x, y, z) {
|
|
49
|
+
const address = this.__compute_address(x, y, z);
|
|
50
|
+
|
|
51
|
+
return this.__data.get(address)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param {boolean} value
|
|
57
|
+
* @param {number} x
|
|
58
|
+
* @param {number} y
|
|
59
|
+
* @param {number} z
|
|
60
|
+
*/
|
|
61
|
+
set(value, x, y, z) {
|
|
62
|
+
const address = this.__compute_address(x, y, z);
|
|
63
|
+
|
|
64
|
+
this.__data.set(address, value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @param {number} u x-coordinate, normalized to [0,1] range
|
|
70
|
+
* @param {number} v y-coordinate, normalized to [0,1] range
|
|
71
|
+
* @param {number} w z-coordinate, normalized to [0,1] range
|
|
72
|
+
* @returns {boolean}
|
|
73
|
+
*/
|
|
74
|
+
sampleNearest(u, v, w) {
|
|
75
|
+
const s = this.size;
|
|
76
|
+
|
|
77
|
+
const dx = s.x;
|
|
78
|
+
const dy = s.y;
|
|
79
|
+
const dz = s.z;
|
|
80
|
+
|
|
81
|
+
const x = Math.round(dx * u) % dx
|
|
82
|
+
const y = Math.round(dy * v) % dy
|
|
83
|
+
const z = Math.round(dz * w) % dz
|
|
84
|
+
|
|
85
|
+
return this.get(x, y, z);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a world-space oriented volume
|
|
3
|
+
* @param {DenseBitVolume3D} volume
|
|
4
|
+
* @param {AABB3} bounds
|
|
5
|
+
* @param {{raycast:function(source_x:number, source_y:number, source_z:number, direction_x:number, direction_y:number, direction_z:number):number}} sampler
|
|
6
|
+
* @param {number[]} frustum 3d frustum, defined as series of 6 planes in order: normal_x, normal_y, normal_z, plane_offset
|
|
7
|
+
*/
|
|
8
|
+
export function buildVolumeFromProjectedGeometry({ volume, sampler, frustum }) {
|
|
9
|
+
// get frustum corners
|
|
10
|
+
|
|
11
|
+
// get first hits from "front" plane to seed the volume
|
|
12
|
+
for (let x = 0; x < 64; x++) {
|
|
13
|
+
for (let y = 0; y < 64; y++) {
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// fit volume to the frustum
|
|
19
|
+
|
|
20
|
+
// create a connectivity graph to identify disconnected regions
|
|
21
|
+
|
|
22
|
+
// clear out disconnected regions starting from smallest until only one is left
|
|
23
|
+
}
|
package/core/geom/AABB2.js
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
import { assert } from "../assert.js";
|
|
8
8
|
import { clamp } from "../math/clamp.js";
|
|
9
|
-
import { overlap1D } from "../math/MathUtils.js";
|
|
10
9
|
import { max2 } from "../math/max2.js";
|
|
11
10
|
import { min2 } from "../math/min2.js";
|
|
12
11
|
import LineSegment2 from "./LineSegment2.js";
|
|
13
12
|
import Vector2 from "./Vector2.js";
|
|
13
|
+
import { overlap1D } from "../math/overlap1D.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
*
|
package/core/geom/ConicRay.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { assert } from "../assert.js";
|
|
2
|
-
import {
|
|
2
|
+
import { EPSILON, epsilonEquals } from "../math/MathUtils.js";
|
|
3
3
|
import Vector3 from "./Vector3.js";
|
|
4
|
+
import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
|
|
5
|
+
import { computeHashFloat } from "../math/hash/computeHashFloat.js";
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
/**
|
package/core/geom/LineSegment.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Created by Alex on 18/03/14.
|
|
3
3
|
*/
|
|
4
4
|
import { clamp } from "../math/clamp.js";
|
|
5
|
-
import Vector3
|
|
5
|
+
import Vector3 from "./Vector3.js";
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
const SMALL_NUM = 1e-9;
|
|
@@ -17,82 +17,6 @@ const LineSegment = function (first, second) {
|
|
|
17
17
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param {Vector3} result
|
|
23
|
-
* @param {number} origin_x
|
|
24
|
-
* @param {number} origin_y
|
|
25
|
-
* @param {number} origin_z
|
|
26
|
-
* @param {number} direction_x
|
|
27
|
-
* @param {number} direction_y
|
|
28
|
-
* @param {number} direction_z
|
|
29
|
-
* @param {number} px
|
|
30
|
-
* @param {number} py
|
|
31
|
-
* @param {number} pz
|
|
32
|
-
* @returns {number} distance from origin, negative means that the point lies behind the origin in the direction opposite to the ray's own
|
|
33
|
-
*/
|
|
34
|
-
export function ray_computeNearestPointToPoint(result, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, px, py, pz) {
|
|
35
|
-
// find closest point
|
|
36
|
-
const sp0_x = px - origin_x;
|
|
37
|
-
const sp0_y = py - origin_y;
|
|
38
|
-
const sp0_z = pz - origin_z;
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
const d2 = v3_dot(direction_x, direction_y, direction_z, direction_x, direction_y, direction_z);
|
|
42
|
-
const d3 = v3_dot(direction_x, direction_y, direction_z, sp0_x, sp0_y, sp0_z);
|
|
43
|
-
|
|
44
|
-
const t = d3 / d2;
|
|
45
|
-
|
|
46
|
-
// compute point on the ray
|
|
47
|
-
const lp_x = direction_x * t + origin_x;
|
|
48
|
-
const lp_y = direction_y * t + origin_y;
|
|
49
|
-
const lp_z = direction_z * t + origin_z;
|
|
50
|
-
|
|
51
|
-
result.set(lp_x, lp_y, lp_z);
|
|
52
|
-
|
|
53
|
-
return t;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Computes shortest distance between a line segment(defined by 2 points) and a point
|
|
58
|
-
* @param {number} x0
|
|
59
|
-
* @param {number} y0
|
|
60
|
-
* @param {number} z0
|
|
61
|
-
* @param {number} x1
|
|
62
|
-
* @param {number} y1
|
|
63
|
-
* @param {number} z1
|
|
64
|
-
* @param {number} px
|
|
65
|
-
* @param {number} py
|
|
66
|
-
* @param {number} pz
|
|
67
|
-
*/
|
|
68
|
-
export function line3_computeSegmentPointDistance_sqr(x0, y0, z0, x1, y1, z1, px, py, pz) {
|
|
69
|
-
// find closest point
|
|
70
|
-
const sp0_x = px - x0;
|
|
71
|
-
const sp0_y = py - y0;
|
|
72
|
-
const sp0_z = pz - z0;
|
|
73
|
-
|
|
74
|
-
// get line delta
|
|
75
|
-
const line_delta_x = x1 - x0;
|
|
76
|
-
const line_delta_y = y1 - y0;
|
|
77
|
-
const line_delta_z = z1 - z0;
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
const d2 = line_delta_x * line_delta_x + line_delta_y * line_delta_y + line_delta_z * line_delta_z;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const d3 = line_delta_x * sp0_x + line_delta_y * sp0_y + line_delta_z * sp0_z;
|
|
84
|
-
|
|
85
|
-
const t = clamp(d3 / d2, 0, 1);
|
|
86
|
-
|
|
87
|
-
// compute point on the line
|
|
88
|
-
const lp_x = line_delta_x * t + x0;
|
|
89
|
-
const lp_y = line_delta_y * t + y0;
|
|
90
|
-
const lp_z = line_delta_z * t + z0;
|
|
91
|
-
|
|
92
|
-
// compute distance from the point in question to the point on the line
|
|
93
|
-
return v3_distance_sqr(px, py, pz, lp_x, lp_y, lp_z);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
20
|
LineSegment.prototype.closestPointToPointParameter = function (point, clampToLine) {
|
|
97
21
|
|
|
98
22
|
|
package/core/geom/Matrix4.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Vector3
|
|
1
|
+
import Vector3 from "./Vector3.js";
|
|
2
2
|
|
|
3
3
|
const _z = new Vector3();
|
|
4
4
|
const _x = new Vector3();
|
|
@@ -192,12 +192,12 @@ export class Matrix4 {
|
|
|
192
192
|
decompose(position, rotation, scale) {
|
|
193
193
|
|
|
194
194
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
let sx = Math.hypot(this.a0, this.a1, this.a2);
|
|
196
|
+
const sy = Math.hypot(this.b0, this.b1, this.b2);
|
|
197
|
+
const sz = Math.hypot(this.c0, this.c1, this.c2);
|
|
198
198
|
|
|
199
199
|
// if determine is negative, we need to invert one scale
|
|
200
|
-
|
|
200
|
+
const det = this.determinant();
|
|
201
201
|
if (det < 0) sx = -sx;
|
|
202
202
|
|
|
203
203
|
position.set(
|
|
@@ -207,9 +207,9 @@ export class Matrix4 {
|
|
|
207
207
|
);
|
|
208
208
|
|
|
209
209
|
// scale the rotation part
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
const invSX = 1 / sx;
|
|
211
|
+
const invSY = 1 / sy;
|
|
212
|
+
const invSZ = 1 / sz;
|
|
213
213
|
|
|
214
214
|
const i_a0 = this.a0 * invSX;
|
|
215
215
|
const i_a1 = this.a1 * invSX;
|
package/core/geom/Plane.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import { v3_dot } from "./
|
|
6
|
+
import { v3_dot } from "./v3_dot.js";
|
|
7
7
|
|
|
8
8
|
function Plane() {
|
|
9
9
|
|
|
@@ -192,7 +192,8 @@ export function computePlaneLineIntersection(out, originX, originY, originZ, dir
|
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
194
|
*
|
|
195
|
-
* @param {
|
|
195
|
+
* @param {Float32Array|number[]|vec3} result
|
|
196
|
+
* @param {number} result_offset
|
|
196
197
|
* @param {number} x0
|
|
197
198
|
* @param {number} y0
|
|
198
199
|
* @param {number} z0
|
|
@@ -205,30 +206,34 @@ export function computePlaneLineIntersection(out, originX, originY, originZ, dir
|
|
|
205
206
|
* @param {number} dist
|
|
206
207
|
* @returns {boolean}
|
|
207
208
|
*/
|
|
208
|
-
export function plane3_computeLineSegmentIntersection(
|
|
209
|
+
export function plane3_computeLineSegmentIntersection(
|
|
210
|
+
result, result_offset,
|
|
211
|
+
x0, y0, z0,
|
|
212
|
+
x1, y1, z1,
|
|
213
|
+
normalX, normalY, normalZ, dist
|
|
214
|
+
) {
|
|
215
|
+
|
|
209
216
|
const directionX = x1 - x0;
|
|
210
217
|
const directionY = y1 - y0;
|
|
211
218
|
const directionZ = z1 - z0;
|
|
212
219
|
|
|
213
220
|
const denom = v3_dot(directionX, directionY, directionZ, normalX, normalY, normalZ);
|
|
214
221
|
|
|
215
|
-
const p = v3_dot(normalX, normalY, normalZ, x0, y0, z0) + dist;
|
|
216
|
-
|
|
217
222
|
if (denom === 0) {
|
|
218
223
|
return false;
|
|
219
224
|
}
|
|
220
225
|
|
|
226
|
+
const p = v3_dot(normalX, normalY, normalZ, x0, y0, z0) + dist;
|
|
227
|
+
|
|
221
228
|
const t = -p / denom;
|
|
222
229
|
|
|
223
230
|
if (t < 0 || t > 1) {
|
|
224
231
|
return false;
|
|
225
232
|
}
|
|
226
233
|
|
|
227
|
-
result
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
directionZ * t + z0
|
|
231
|
-
);
|
|
234
|
+
result[result_offset] = directionX * t + x0;
|
|
235
|
+
result[result_offset + 1] = directionY * t + y0;
|
|
236
|
+
result[result_offset + 2] = directionZ * t + z0;
|
|
232
237
|
|
|
233
238
|
return true;
|
|
234
239
|
|
package/core/geom/Quaternion.js
CHANGED
|
@@ -10,7 +10,8 @@ import { clamp } from "../math/clamp.js";
|
|
|
10
10
|
import { copysign } from "../math/copysign.js";
|
|
11
11
|
import { lerp } from "../math/lerp.js";
|
|
12
12
|
import { EPSILON, epsilonEquals, PI2, PI_HALF } from "../math/MathUtils.js";
|
|
13
|
-
import Vector3
|
|
13
|
+
import Vector3 from "./Vector3.js";
|
|
14
|
+
import { v3_dot } from "./v3_dot.js";
|
|
14
15
|
|
|
15
16
|
const matrix = new ThreeMatrix4();
|
|
16
17
|
|
package/core/geom/Rectangle.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Created by Alex on 14/03/2016.
|
|
3
3
|
*/
|
|
4
|
-
import { intersects1D, overlap1D } from "../math/MathUtils.js";
|
|
5
4
|
import { max2 } from "../math/max2.js";
|
|
6
5
|
import { min2 } from "../math/min2.js";
|
|
7
6
|
import Vector2 from "./Vector2.js";
|
|
7
|
+
import { intersects1D } from "../math/intersects1D.js";
|
|
8
|
+
import { overlap1D } from "../math/overlap1D.js";
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
/**
|
package/core/geom/Vector1.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { assert } from "../assert.js";
|
|
7
7
|
import Signal from "../events/signal/Signal.js";
|
|
8
8
|
import { clamp } from "../math/clamp.js";
|
|
9
|
-
import { computeHashFloat } from "../math/
|
|
9
|
+
import { computeHashFloat } from "../math/hash/computeHashFloat.js";
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class Vector1 extends Number {
|
package/core/geom/Vector3.d.ts
CHANGED
package/core/geom/Vector3.js
CHANGED
|
@@ -5,10 +5,16 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "../assert.js";
|
|
7
7
|
import Signal from "../events/signal/Signal.js";
|
|
8
|
-
import { clamp } from "../math/clamp.js";
|
|
9
8
|
import { lerp } from "../math/lerp.js";
|
|
10
|
-
import {
|
|
9
|
+
import { EPSILON, epsilonEquals } from "../math/MathUtils.js";
|
|
11
10
|
import { sign } from "../math/sign.js";
|
|
11
|
+
import { v3_dot } from "./v3_dot.js";
|
|
12
|
+
import { v3_length_sqr } from "./v3_length_sqr.js";
|
|
13
|
+
import { v3_length } from "./v3_length.js";
|
|
14
|
+
import { v3_angle_between } from "./v3_angle_between.js";
|
|
15
|
+
import { v3_lerp } from "./v3_lerp.js";
|
|
16
|
+
import { v3_slerp } from "./v3_slerp.js";
|
|
17
|
+
import { computeHashFloat } from "../math/hash/computeHashFloat.js";
|
|
12
18
|
|
|
13
19
|
class Vector3 {
|
|
14
20
|
/**
|
|
@@ -442,7 +448,7 @@ class Vector3 {
|
|
|
442
448
|
* @returns {number}
|
|
443
449
|
*/
|
|
444
450
|
angleTo(other) {
|
|
445
|
-
return
|
|
451
|
+
return v3_angle_between(this.x, this.y, this.z, other.x, other.y, other.z);
|
|
446
452
|
}
|
|
447
453
|
|
|
448
454
|
/**
|
|
@@ -534,6 +540,32 @@ class Vector3 {
|
|
|
534
540
|
return this.set(_x, _y, _z);
|
|
535
541
|
}
|
|
536
542
|
|
|
543
|
+
/**
|
|
544
|
+
* Assume current vector holds a direction, transform using a matrix to produce a new directional unit vector
|
|
545
|
+
* @param {THREE.Matrix4} m
|
|
546
|
+
*/
|
|
547
|
+
transformDirection_three(m) {
|
|
548
|
+
|
|
549
|
+
// input: THREE.Matrix4 affine matrix
|
|
550
|
+
// vector interpreted as a direction
|
|
551
|
+
|
|
552
|
+
const x = this.x, y = this.y, z = this.z;
|
|
553
|
+
const e = m.elements;
|
|
554
|
+
|
|
555
|
+
const _x = e[0] * x + e[4] * y + e[8] * z;
|
|
556
|
+
const _y = e[1] * x + e[5] * y + e[9] * z;
|
|
557
|
+
const _z = e[2] * x + e[6] * y + e[10] * z;
|
|
558
|
+
|
|
559
|
+
// normalize the result
|
|
560
|
+
const _l = 1 / v3_length(_x, _y, _z);
|
|
561
|
+
|
|
562
|
+
this.set(
|
|
563
|
+
_x * _l,
|
|
564
|
+
_y * _l,
|
|
565
|
+
_z * _l
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
|
|
537
569
|
/**
|
|
538
570
|
*
|
|
539
571
|
* @param {THREE.Matrix3} m
|
|
@@ -947,20 +979,6 @@ Vector3.back = Object.freeze(new Vector3(0, 0, -1));
|
|
|
947
979
|
Vector3.typeName = "Vector3";
|
|
948
980
|
|
|
949
981
|
|
|
950
|
-
/**
|
|
951
|
-
*
|
|
952
|
-
* @param {number} x0
|
|
953
|
-
* @param {number} y0
|
|
954
|
-
* @param {number} z0
|
|
955
|
-
* @param {number} x1
|
|
956
|
-
* @param {number} y1
|
|
957
|
-
* @param {number} z1
|
|
958
|
-
* @returns {number}
|
|
959
|
-
*/
|
|
960
|
-
export function v3_dot(x0, y0, z0, x1, y1, z1) {
|
|
961
|
-
return (x0 * x1 + y0 * y1 + z0 * z1);
|
|
962
|
-
}
|
|
963
|
-
|
|
964
982
|
/**
|
|
965
983
|
*
|
|
966
984
|
* @param {number} x0
|
|
@@ -973,87 +991,11 @@ export function v3_dot(x0, y0, z0, x1, y1, z1) {
|
|
|
973
991
|
*/
|
|
974
992
|
Vector3._dot = v3_dot;
|
|
975
993
|
|
|
976
|
-
/**
|
|
977
|
-
*
|
|
978
|
-
* @param {number} x0
|
|
979
|
-
* @param {number} y0
|
|
980
|
-
* @param {number} z0
|
|
981
|
-
* @param {number} x1
|
|
982
|
-
* @param {number} y1
|
|
983
|
-
* @param {number} z1
|
|
984
|
-
* @returns {number}
|
|
985
|
-
*/
|
|
986
|
-
export function v3_distance(x0, y0, z0, x1, y1, z1) {
|
|
987
|
-
|
|
988
|
-
return Math.sqrt(v3_distance_sqr(x0, y0, z0, x1, y1, z1));
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
/**
|
|
992
|
-
*
|
|
993
|
-
* @param {number} x0
|
|
994
|
-
* @param {number} y0
|
|
995
|
-
* @param {number} z0
|
|
996
|
-
* @param {number} x1
|
|
997
|
-
* @param {number} y1
|
|
998
|
-
* @param {number} z1
|
|
999
|
-
* @returns {number}
|
|
1000
|
-
*/
|
|
1001
|
-
export function v3_distance_sqr(x0, y0, z0, x1, y1, z1) {
|
|
1002
|
-
const x = x0 - x1;
|
|
1003
|
-
const y = y0 - y1;
|
|
1004
|
-
const z = z0 - z1;
|
|
1005
|
-
|
|
1006
|
-
return x * x + y * y + z * z;
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
994
|
|
|
1010
995
|
function v3Length(v) {
|
|
1011
996
|
return v3_length(v.x, v.y, v.z);
|
|
1012
997
|
}
|
|
1013
998
|
|
|
1014
|
-
export function v3_length(x, y, z) {
|
|
1015
|
-
return Math.sqrt(v3_length_sqr(x, y, z));
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
/**
|
|
1019
|
-
*
|
|
1020
|
-
* @param {number} x
|
|
1021
|
-
* @param {number} y
|
|
1022
|
-
* @param {number} z
|
|
1023
|
-
* @return {number}
|
|
1024
|
-
*/
|
|
1025
|
-
export function v3_length_sqr(x, y, z) {
|
|
1026
|
-
return x * x + y * y + z * z;
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
/**
|
|
1031
|
-
*
|
|
1032
|
-
* @param {number} x0
|
|
1033
|
-
* @param {number} y0
|
|
1034
|
-
* @param {number} z0
|
|
1035
|
-
* @param {number} x1
|
|
1036
|
-
* @param {number} y1
|
|
1037
|
-
* @param {number} z1
|
|
1038
|
-
* @returns {number}
|
|
1039
|
-
*/
|
|
1040
|
-
export function v3_angleBetween(x0, y0, z0, x1, y1, z1) {
|
|
1041
|
-
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
1042
|
-
|
|
1043
|
-
const magnitude_0 = v3_length(x0, y0, z0);
|
|
1044
|
-
const magnitude_1 = v3_length(x1, y1, z1);
|
|
1045
|
-
|
|
1046
|
-
const l = magnitude_0 * magnitude_1;
|
|
1047
|
-
|
|
1048
|
-
if (l === 0) {
|
|
1049
|
-
// collective magnitude is 0, provide arbitrary angle
|
|
1050
|
-
return 0;
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
const theta = clamp(d / l, -1, 1);
|
|
1054
|
-
|
|
1055
|
-
return Math.acos(theta);
|
|
1056
|
-
}
|
|
1057
999
|
|
|
1058
1000
|
/**
|
|
1059
1001
|
*
|
|
@@ -1067,70 +1009,4 @@ function v3Lerp(result, a, b, fraction) {
|
|
|
1067
1009
|
v3_lerp(result, a.x, a.y, a.z, b.x, b.y, b.z, fraction);
|
|
1068
1010
|
}
|
|
1069
1011
|
|
|
1070
|
-
/**
|
|
1071
|
-
*
|
|
1072
|
-
* @param {Vector3} result
|
|
1073
|
-
* @param {number} a_x
|
|
1074
|
-
* @param {number} a_y
|
|
1075
|
-
* @param {number} a_z
|
|
1076
|
-
* @param {number} b_x
|
|
1077
|
-
* @param {number} b_y
|
|
1078
|
-
* @param {number} b_z
|
|
1079
|
-
* @param {number} fraction
|
|
1080
|
-
*/
|
|
1081
|
-
function v3_lerp(result, a_x, a_y, a_z, b_x, b_y, b_z, fraction) {
|
|
1082
|
-
|
|
1083
|
-
const x = lerp(a_x, b_x, fraction);
|
|
1084
|
-
const y = lerp(a_y, b_y, fraction);
|
|
1085
|
-
const z = lerp(a_z, b_z, fraction);
|
|
1086
|
-
|
|
1087
|
-
result.set(x, y, z);
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
/**
|
|
1091
|
-
* Spherical linear interpolation
|
|
1092
|
-
* @see https://en.wikipedia.org/wiki/Slerp
|
|
1093
|
-
* @param {Vector3} result
|
|
1094
|
-
* @param {number} a_x
|
|
1095
|
-
* @param {number} a_y
|
|
1096
|
-
* @param {number} a_z
|
|
1097
|
-
* @param {number} b_x
|
|
1098
|
-
* @param {number} b_y
|
|
1099
|
-
* @param {number} b_z
|
|
1100
|
-
* @param {number} fraction
|
|
1101
|
-
*/
|
|
1102
|
-
export function v3_slerp(
|
|
1103
|
-
result,
|
|
1104
|
-
a_x, a_y, a_z,
|
|
1105
|
-
b_x, b_y, b_z,
|
|
1106
|
-
fraction
|
|
1107
|
-
) {
|
|
1108
|
-
const dot = v3_dot(
|
|
1109
|
-
a_x, a_y, a_z,
|
|
1110
|
-
b_x, b_y, b_z
|
|
1111
|
-
);
|
|
1112
|
-
|
|
1113
|
-
if (dot >= 1 || dot <= -1) {
|
|
1114
|
-
// avoid division by 0, both vectors are pointing in the same direction, use lerp instead
|
|
1115
|
-
v3_lerp(result, a_x, a_y, a_z, b_x, b_y, b_z, fraction);
|
|
1116
|
-
return;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
// compute angle between two vectors
|
|
1120
|
-
const theta = Math.acos(dot);
|
|
1121
|
-
|
|
1122
|
-
const sin_theta = Math.sin(theta);
|
|
1123
|
-
|
|
1124
|
-
const inv_sin_theta = 1 / sin_theta;
|
|
1125
|
-
|
|
1126
|
-
const scale_0 = Math.sin((1 - fraction) * theta) * inv_sin_theta;
|
|
1127
|
-
const scale_1 = Math.sin((fraction) * theta) * inv_sin_theta;
|
|
1128
|
-
|
|
1129
|
-
const x = a_x * scale_0 + b_x * scale_1;
|
|
1130
|
-
const y = a_y * scale_0 + b_y * scale_1;
|
|
1131
|
-
const z = a_z * scale_0 + b_z * scale_1;
|
|
1132
|
-
|
|
1133
|
-
result.set(x, y, z);
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
1012
|
export default Vector3;
|
package/core/geom/Vector4.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { assert } from "../assert.js";
|
|
6
6
|
import { Signal } from "../events/signal/Signal.js";
|
|
7
7
|
import { lerp } from "../math/lerp.js";
|
|
8
|
-
import {
|
|
8
|
+
import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
|
|
9
|
+
import { computeHashFloat } from "../math/hash/computeHashFloat.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
*
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @param {function} random
|
|
4
|
-
* @param {
|
|
4
|
+
* @param {number[]} result
|
|
5
|
+
* @param {number} result_offset
|
|
5
6
|
*/
|
|
6
|
-
export function randomPointInBox(random, result) {
|
|
7
|
+
export function randomPointInBox(random, result, result_offset) {
|
|
7
8
|
const x = random() - 0.5;
|
|
8
9
|
const y = random() - 0.5;
|
|
9
10
|
const z = random() - 0.5;
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
//write the result
|
|
13
|
+
result[result_offset] = x;
|
|
14
|
+
result[result_offset + 1] = y;
|
|
15
|
+
result[result_offset + 2] = z;
|
|
12
16
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Volumetric sampling method, since sample volume is a point, it simply sets result to origin
|
|
3
3
|
* @param {function} random
|
|
4
|
-
* @param {
|
|
4
|
+
* @param {number[]} result
|
|
5
|
+
* @param {number} destination_offset
|
|
5
6
|
*/
|
|
6
|
-
export function randomPointInPoint(random, result) {
|
|
7
|
-
result
|
|
7
|
+
export function randomPointInPoint(random, result, destination_offset) {
|
|
8
|
+
result[destination_offset] = 0;
|
|
9
|
+
result[destination_offset + 1] = 0;
|
|
10
|
+
result[destination_offset + 2] = 0;
|
|
8
11
|
}
|