@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
|
@@ -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
|
-
import { plane_three_computeConvex3PlaneIntersection } from "../plane_computeConvex3PlaneIntersection.js";
|
|
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
|
*
|
|
@@ -14,6 +14,12 @@ const scratch_v3_0 = new Vector3();
|
|
|
14
14
|
|
|
15
15
|
const scratch_v3_1 = new Vector3();
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @type {number[]}
|
|
20
|
+
*/
|
|
21
|
+
const scratch_v3_array = [];
|
|
22
|
+
|
|
17
23
|
/**
|
|
18
24
|
*
|
|
19
25
|
* @param {Vector3} result
|
|
@@ -94,7 +100,9 @@ export function frustum3_computeNearestPointToPoint(result, planes, target_x, ta
|
|
|
94
100
|
const plane_1 = planes[plane_1_index];
|
|
95
101
|
const plane_2 = planes[plane_2_index];
|
|
96
102
|
|
|
97
|
-
plane_three_computeConvex3PlaneIntersection(
|
|
103
|
+
plane_three_computeConvex3PlaneIntersection(scratch_v3_array, 0, plane_0, plane_1, plane_2);
|
|
104
|
+
|
|
105
|
+
result.readFromArray(scratch_v3_array, 0)
|
|
98
106
|
}
|
|
99
107
|
|
|
100
108
|
return false;
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { mortonEncode_magicbits } from "./mortonEncode_magicbits.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Assumes that coordinates will be mapped to -1..1 range after transform
|
|
5
|
+
* @param {number} x
|
|
6
|
+
* @param {number} y
|
|
7
|
+
* @param {number} z
|
|
8
|
+
* @param {number[]} matrix matrix to transform supplied coordinates to Normalized Device Coordinates
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
export function v3_morton_encode_transformed(x, y, z, matrix) {
|
|
12
|
+
|
|
13
|
+
// apply matrix transform
|
|
14
|
+
const _x = matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12];
|
|
15
|
+
const _y = matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13];
|
|
16
|
+
const _z = matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14];
|
|
17
|
+
const _w = matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15];
|
|
18
|
+
|
|
19
|
+
const d = 1 / _w;
|
|
20
|
+
|
|
21
|
+
// apply perspective divide, values are now in Normalized Coordinate system (-1,1)
|
|
22
|
+
const px = _x * d;
|
|
23
|
+
const py = _y * d;
|
|
24
|
+
const pz = _z * d;
|
|
25
|
+
|
|
26
|
+
// scale each value up to 10 bits (for 10 bits, the multiplier = 1024. As we have -1,1 range, we do (v+1)/2. 1024/2 = 512)
|
|
27
|
+
|
|
28
|
+
const cx = ((px + 1) * 512) | 0;
|
|
29
|
+
const cy = ((py + 1) * 512) | 0;
|
|
30
|
+
const cz = ((pz + 1) * 512) | 0;
|
|
31
|
+
|
|
32
|
+
return mortonEncode_magicbits(cx, cy, cz);
|
|
33
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { v2_dot } from "../../../Vector2.js";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
@source https://aras-p.info/texts/CompactNormalStorage.html
|
|
5
|
+
@source https://en.wikipedia.org/wiki/Lambert_azimuthal_equal-area_projection
|
|
6
|
+
|
|
7
|
+
half2 encode (half3 n, float3 view)
|
|
8
|
+
{
|
|
9
|
+
half f = sqrt(8*n.z+8);
|
|
10
|
+
return n.xy / f + 0.5;
|
|
11
|
+
}
|
|
12
|
+
half3 decode (half4 enc, float3 view)
|
|
13
|
+
{
|
|
14
|
+
half2 fenc = enc*4-2;
|
|
15
|
+
half f = dot(fenc,fenc);
|
|
16
|
+
half g = sqrt(1-f/4);
|
|
17
|
+
half3 n;
|
|
18
|
+
n.xy = fenc*g;
|
|
19
|
+
n.z = 1-f/2;
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {number[]} output
|
|
27
|
+
* @param {number} output_offset
|
|
28
|
+
* @param {number} x
|
|
29
|
+
* @param {number} y
|
|
30
|
+
* @param {number} z
|
|
31
|
+
*/
|
|
32
|
+
export function encode_unit_to_azimuth(output, output_offset, x, y, z) {
|
|
33
|
+
const f = Math.sqrt(8 * z + 8);
|
|
34
|
+
|
|
35
|
+
output[output_offset] = x / f + 0.5;
|
|
36
|
+
output[output_offset + 1] = y / f + 0.5;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param {number[]} output
|
|
42
|
+
* @param {number} output_offset
|
|
43
|
+
* @param {number} x range [-1,1]
|
|
44
|
+
* @param {number} y range [-1,1]
|
|
45
|
+
*/
|
|
46
|
+
export function decode_azimuth_to_unit(output, output_offset, x, y) {
|
|
47
|
+
const fenc_x = x * 4 - 2;
|
|
48
|
+
const fenc_y = y * 4 - 2;
|
|
49
|
+
|
|
50
|
+
const f = v2_dot(fenc_x, fenc_y, fenc_x, fenc_y);
|
|
51
|
+
|
|
52
|
+
const g = Math.sqrt(1 - f / 4);
|
|
53
|
+
|
|
54
|
+
const n_x = fenc_x * g;
|
|
55
|
+
const n_y = fenc_y * g;
|
|
56
|
+
const n_z = 1 - f / 2;
|
|
57
|
+
|
|
58
|
+
output[output_offset] = n_x;
|
|
59
|
+
output[output_offset + 1] = n_y;
|
|
60
|
+
output[output_offset + 2] = n_z;
|
|
61
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { v2_magnitude } from "../../../Vector2.js";
|
|
2
|
+
import { v3_dot } from "../../../v3_dot.js";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
@source https://aras-p.info/texts/CompactNormalStorage.html#method04spheremap
|
|
6
|
+
@source Siggraph 99
|
|
7
|
+
@source Cry Engine 3, presented by Martin Mittring in "A bit more Deferred"
|
|
8
|
+
|
|
9
|
+
half2 encode (half3 n, float3 view)
|
|
10
|
+
{
|
|
11
|
+
half2 enc = normalize(n.xy) * (sqrt(-n.z*0.5+0.5));
|
|
12
|
+
enc = enc*0.5+0.5;
|
|
13
|
+
return enc;
|
|
14
|
+
}
|
|
15
|
+
half3 decode (half4 enc, float3 view)
|
|
16
|
+
{
|
|
17
|
+
half4 nn = enc*half4(2,2,0,0) + half4(-1,-1,1,-1);
|
|
18
|
+
half l = dot(nn.xyz,-nn.xyw);
|
|
19
|
+
nn.z = l;
|
|
20
|
+
nn.xy *= sqrt(l);
|
|
21
|
+
return nn.xyz * 2 + half3(0,0,-1);
|
|
22
|
+
}
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Encode v3 to v2
|
|
28
|
+
* @param {number[]} output
|
|
29
|
+
* @param {number} output_offset
|
|
30
|
+
* @param {number} x
|
|
31
|
+
* @param {number} y
|
|
32
|
+
* @param {number} z
|
|
33
|
+
*/
|
|
34
|
+
export function encode_unit_to_spheremap(output, output_offset, x, y, z) {
|
|
35
|
+
const length_xy = v2_magnitude(x, y);
|
|
36
|
+
|
|
37
|
+
const norm_xy_x = x / length_xy;
|
|
38
|
+
const norm_xy_y = y / length_xy;
|
|
39
|
+
|
|
40
|
+
const z_factor = Math.sqrt(-z * 0.5 - 0.5) * 0.5;
|
|
41
|
+
|
|
42
|
+
const enc_x = norm_xy_x * z_factor + 0.5;
|
|
43
|
+
const enc_y = norm_xy_y * z_factor + 0.5;
|
|
44
|
+
|
|
45
|
+
output[output_offset] = enc_x;
|
|
46
|
+
output[output_offset + 1] = enc_y;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {number[]} output
|
|
51
|
+
* @param {number} output_offset
|
|
52
|
+
* @param {number} x range [-1,1]
|
|
53
|
+
* @param {number} y range [-1,1]
|
|
54
|
+
*/
|
|
55
|
+
function decode_spheremap_to_unit(output, output_offset, x, y) {
|
|
56
|
+
const nn4_x = x * 2 - 1;
|
|
57
|
+
const nn4_y = y * 2 - 1;
|
|
58
|
+
const nn4_z = 1;
|
|
59
|
+
const nn4_w = -1;
|
|
60
|
+
|
|
61
|
+
const l = v3_dot(nn4_x, nn4_y, nn4_z, -nn4_x, -nn4_y, -nn4_w);
|
|
62
|
+
|
|
63
|
+
const nn_z = l;
|
|
64
|
+
|
|
65
|
+
const l_sqrt = Math.sqrt(l);
|
|
66
|
+
|
|
67
|
+
const nn_x = nn4_x * l_sqrt;
|
|
68
|
+
const nn_y = nn4_y * l_sqrt;
|
|
69
|
+
|
|
70
|
+
const _x = nn_x * 2;
|
|
71
|
+
const _y = nn_y * 2;
|
|
72
|
+
const _z = nn_z * 2 - 1;
|
|
73
|
+
|
|
74
|
+
output[output_offset] = _x;
|
|
75
|
+
output[output_offset + 1] = _y;
|
|
76
|
+
output[output_offset + 2] = _z;
|
|
77
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { lerp } from "../../../math/lerp.js";
|
|
2
|
-
import Vector3
|
|
2
|
+
import Vector3 from "../../Vector3.js";
|
|
3
3
|
import { plane3_intersect_plane } from "./plane3_intersect_plane.js";
|
|
4
|
+
import { v3_dot } from "../../v3_dot.js";
|
|
5
|
+
import { v3_length } from "../../v3_length.js";
|
|
4
6
|
|
|
5
7
|
const v0 = new Vector3();
|
|
6
8
|
const v1 = new Vector3();
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { lerp } from "../../../math/lerp.js";
|
|
2
2
|
import { EPSILON } from "../../../math/MathUtils.js";
|
|
3
|
-
import Vector3
|
|
3
|
+
import Vector3 from "../../Vector3.js";
|
|
4
|
+
import { v3_dot } from "../../v3_dot.js";
|
|
5
|
+
import { v3_length_sqr } from "../../v3_length_sqr.js";
|
|
6
|
+
import { v3_slerp } from "../../v3_slerp.js";
|
|
4
7
|
|
|
5
8
|
const e = new Vector3();
|
|
6
9
|
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { v3_dot } from "
|
|
2
|
-
|
|
1
|
+
import { v3_dot } from "../../v3_dot.js";
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
*
|
|
6
|
-
* @param {
|
|
5
|
+
* @param {number[]} result
|
|
6
|
+
* @param {number} result_offset
|
|
7
7
|
* @param {Plane} a
|
|
8
8
|
* @param {Plane} b
|
|
9
9
|
* @param {Plane} c
|
|
10
10
|
* @returns {boolean}
|
|
11
11
|
*/
|
|
12
|
-
export function plane_three_computeConvex3PlaneIntersection(result, a, b, c) {
|
|
12
|
+
export function plane_three_computeConvex3PlaneIntersection(result, result_offset, a, b, c) {
|
|
13
13
|
const a_normal = a.normal;
|
|
14
14
|
const b_normal = b.normal;
|
|
15
15
|
const c_normal = c.normal;
|
|
16
16
|
|
|
17
17
|
return plane_computeConvex3PlaneIntersection(
|
|
18
18
|
result,
|
|
19
|
+
result_offset,
|
|
19
20
|
a_normal.x, a_normal.y, a_normal.z, a.constant,
|
|
20
21
|
b_normal.x, b_normal.y, b_normal.z, b.constant,
|
|
21
22
|
c_normal.x, c_normal.y, c_normal.z, c.constant,
|
|
@@ -24,7 +25,8 @@ export function plane_three_computeConvex3PlaneIntersection(result, a, b, c) {
|
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* NOTE: Based on Intersection of 3 planes, Graphics Gems 1 pg 305
|
|
27
|
-
* @param {
|
|
28
|
+
* @param {Float32Array|number[]|vec3} result
|
|
29
|
+
* @param {number} result_offset
|
|
28
30
|
* @param {number} a_normal_x
|
|
29
31
|
* @param {number} a_normal_y
|
|
30
32
|
* @param {number} a_normal_z
|
|
@@ -40,7 +42,7 @@ export function plane_three_computeConvex3PlaneIntersection(result, a, b, c) {
|
|
|
40
42
|
* @returns {boolean} true if planes intersect, false otherwise
|
|
41
43
|
*/
|
|
42
44
|
export function plane_computeConvex3PlaneIntersection(
|
|
43
|
-
result,
|
|
45
|
+
result, result_offset,
|
|
44
46
|
a_normal_x, a_normal_y, a_normal_z, a_constant,
|
|
45
47
|
b_normal_x, b_normal_y, b_normal_z, b_constant,
|
|
46
48
|
c_normal_x, c_normal_y, c_normal_z, c_constant
|
|
@@ -75,18 +77,14 @@ export function plane_computeConvex3PlaneIntersection(
|
|
|
75
77
|
const d = 1 / determinant;
|
|
76
78
|
|
|
77
79
|
const neg_a_constant = -a_constant;
|
|
78
|
-
const neg_b_constant = -b_constant;
|
|
79
|
-
const neg_c_constant = -c_constant;
|
|
80
80
|
|
|
81
|
-
const x = (bxc_x * neg_a_constant
|
|
82
|
-
const y = (bxc_y * neg_a_constant
|
|
83
|
-
const z = (bxc_z * neg_a_constant
|
|
81
|
+
const x = (bxc_x * neg_a_constant - cxa_x * b_constant - axb_x * c_constant) * d;
|
|
82
|
+
const y = (bxc_y * neg_a_constant - cxa_y * b_constant - axb_y * c_constant) * d;
|
|
83
|
+
const z = (bxc_z * neg_a_constant - cxa_z * b_constant - axb_z * c_constant) * d;
|
|
84
84
|
|
|
85
|
-
result
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
z
|
|
89
|
-
);
|
|
85
|
+
result[result_offset] = x;
|
|
86
|
+
result[result_offset + 1] = y;
|
|
87
|
+
result[result_offset + 2] = z;
|
|
90
88
|
|
|
91
89
|
return true;
|
|
92
90
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { v3_dot } from "../../v3_dot.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {Vector3} result
|
|
6
|
+
* @param {number} origin_x
|
|
7
|
+
* @param {number} origin_y
|
|
8
|
+
* @param {number} origin_z
|
|
9
|
+
* @param {number} direction_x
|
|
10
|
+
* @param {number} direction_y
|
|
11
|
+
* @param {number} direction_z
|
|
12
|
+
* @param {number} px
|
|
13
|
+
* @param {number} py
|
|
14
|
+
* @param {number} pz
|
|
15
|
+
* @returns {number} distance from origin, negative means that the point lies behind the origin in the direction opposite to the ray's own
|
|
16
|
+
*/
|
|
17
|
+
export function ray_computeNearestPointToPoint(result, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, px, py, pz) {
|
|
18
|
+
// find closest point
|
|
19
|
+
const sp0_x = px - origin_x;
|
|
20
|
+
const sp0_y = py - origin_y;
|
|
21
|
+
const sp0_z = pz - origin_z;
|
|
22
|
+
|
|
23
|
+
//
|
|
24
|
+
const d2 = v3_dot(direction_x, direction_y, direction_z, direction_x, direction_y, direction_z);
|
|
25
|
+
const d3 = v3_dot(direction_x, direction_y, direction_z, sp0_x, sp0_y, sp0_z);
|
|
26
|
+
|
|
27
|
+
const t = d3 / d2;
|
|
28
|
+
|
|
29
|
+
// compute point on the ray
|
|
30
|
+
const lp_x = direction_x * t + origin_x;
|
|
31
|
+
const lp_y = direction_y * t + origin_y;
|
|
32
|
+
const lp_z = direction_z * t + origin_z;
|
|
33
|
+
|
|
34
|
+
result.set(lp_x, lp_y, lp_z);
|
|
35
|
+
|
|
36
|
+
return t;
|
|
37
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class AbstractShape3D {
|
|
2
|
+
constructor() {
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {number[]} result
|
|
8
|
+
* @param {number} result_offset
|
|
9
|
+
* @param {function} random
|
|
10
|
+
*/
|
|
11
|
+
sample_random_point_in_volume(result, result_offset, random) {
|
|
12
|
+
throw new Error('Not Implemented');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Total volume of the shape
|
|
17
|
+
* @returns {number}
|
|
18
|
+
*/
|
|
19
|
+
get volume() {
|
|
20
|
+
throw new Error('Not Implemented');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @returns {number}
|
|
25
|
+
*/
|
|
26
|
+
get surface_area() {
|
|
27
|
+
throw new Error('Not Implemented');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AbstractShape3D } from "./AbstractShape3D.js";
|
|
2
|
+
import { weightedRandomFromArray } from "../../../collection/array/weightedRandomFromArray.js";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const scratch_array = [];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {AbstractShape3D} shape
|
|
10
|
+
* @return {number}
|
|
11
|
+
*/
|
|
12
|
+
function getVolume(shape) {
|
|
13
|
+
return shape.volume;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class CompositeShape extends AbstractShape3D {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @type {AbstractShape3D[]}
|
|
23
|
+
*/
|
|
24
|
+
this.children = [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get volume() {
|
|
28
|
+
let r = 0;
|
|
29
|
+
|
|
30
|
+
const children = this.children;
|
|
31
|
+
const child_count = children.length;
|
|
32
|
+
for (let i = 0; i < child_count; i++) {
|
|
33
|
+
const child = children[i];
|
|
34
|
+
|
|
35
|
+
r += child.volume;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return r;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get surface_area(){
|
|
42
|
+
let r = 0;
|
|
43
|
+
|
|
44
|
+
const children = this.children;
|
|
45
|
+
const child_count = children.length;
|
|
46
|
+
for (let i = 0; i < child_count; i++) {
|
|
47
|
+
const child = children[i];
|
|
48
|
+
|
|
49
|
+
r += child.surface_area;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return r;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
sample_random_point_in_volume(result, result_offset, random) {
|
|
56
|
+
const child = weightedRandomFromArray(this.children, random, getVolume);
|
|
57
|
+
|
|
58
|
+
return child.sample_random_point_in_volume(result, result_offset, random);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { mat4, vec3 } from "gl-matrix";
|
|
2
|
+
import { AbstractShape3D } from "./AbstractShape3D.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @type {number[]|Float32Array|vec3}
|
|
7
|
+
*/
|
|
8
|
+
const scratch_v3 = [];
|
|
9
|
+
|
|
10
|
+
export class TransformedShape3D extends AbstractShape3D {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @type {number[]|Float32Array|mat4}
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
this.__matrix = new Float32Array(16);
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @type {AbstractShape3D|null}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
this.__subject = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param {number[]|Float32Array} m4
|
|
31
|
+
* @param {AbstractShape3D} subject
|
|
32
|
+
* @returns {TransformedShape3D}
|
|
33
|
+
*/
|
|
34
|
+
static from_m4(subject, m4) {
|
|
35
|
+
const r = new TransformedShape3D();
|
|
36
|
+
|
|
37
|
+
r.__subject = subject;
|
|
38
|
+
r.__matrix = m4;
|
|
39
|
+
|
|
40
|
+
return r;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param {number[]|Float32Array} m
|
|
46
|
+
*/
|
|
47
|
+
set transform(m) {
|
|
48
|
+
this.__matrix.set(m);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get volume() {
|
|
52
|
+
mat4.getScaling(scratch_v3, this.__matrix);
|
|
53
|
+
|
|
54
|
+
const scale_modifier = scratch_v3[0] * scratch_v3[1] * scratch_v3[2];
|
|
55
|
+
|
|
56
|
+
return this.__subject.volume * scale_modifier;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
sample_random_point_in_volume(result, result_offset, random) {
|
|
60
|
+
this.__subject.sample_random_point_in_volume(scratch_v3, 0, random);
|
|
61
|
+
|
|
62
|
+
// apply transform
|
|
63
|
+
vec3.transformMat4(scratch_v3, scratch_v3, this.__matrix);
|
|
64
|
+
|
|
65
|
+
// write out
|
|
66
|
+
result[0] = scratch_v3[0];
|
|
67
|
+
result[1] = scratch_v3[1];
|
|
68
|
+
result[2] = scratch_v3[2];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AbstractShape3D } from "./AbstractShape3D.js";
|
|
2
|
+
import { randomPointInBox } from "../../random/randomPointInBox.js";
|
|
3
|
+
|
|
4
|
+
export class UnitCubeShape3D extends AbstractShape3D {
|
|
5
|
+
|
|
6
|
+
get volume() {
|
|
7
|
+
return 1;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
sample_random_point_in_volume(result, result_offset, random) {
|
|
11
|
+
randomPointInBox(random, result, result_offset);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AbstractShape3D } from "./AbstractShape3D.js";
|
|
2
|
+
import { randomPointInSphere } from "../../random/randomPointInSphere.js";
|
|
3
|
+
|
|
4
|
+
export class UnitSphereShape3D extends AbstractShape3D {
|
|
5
|
+
get volume() {
|
|
6
|
+
return 0.523598776;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
get surface_area() {
|
|
10
|
+
return 3.14159265;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
sample_random_point_in_volume(result, result_offset, random) {
|
|
14
|
+
randomPointInSphere(random, result, result_offset);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { v3_length } from "../../Vector3.js";
|
|
2
1
|
import { array_replace_all } from "../../../collection/array/array_replace_all.js";
|
|
3
2
|
import { array_push_if_unique } from "../../../collection/array/array_push_if_unique.js";
|
|
4
3
|
import { assert } from "../../../assert.js";
|
|
5
4
|
import { array_remove_first } from "../../../collection/array/array_remove_first.js";
|
|
6
5
|
import { vec3 } from "gl-matrix";
|
|
6
|
+
import { v3_length } from "../../v3_length.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { v3_distance } from "../../Vector3.js";
|
|
2
1
|
import { assert } from "../../../assert.js";
|
|
3
2
|
import { array_push_if_unique } from "../../../collection/array/array_push_if_unique.js";
|
|
4
3
|
import { array_remove_first } from "../../../collection/array/array_remove_first.js";
|
|
4
|
+
import { v3_distance } from "../../v3_distance.js";
|
|
5
5
|
|
|
6
6
|
export class TopoVertex {
|
|
7
7
|
constructor() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Miniball } from "../../../packing/miniball/Miniball.js";
|
|
2
2
|
import { PointSet } from "../../../packing/miniball/PointSet.js";
|
|
3
3
|
import { ConicRay } from "../../../ConicRay.js";
|
|
4
|
-
import { v3_angleBetween } from "../../../Vector3.js";
|
|
5
4
|
import { array_copy } from "../../../../collection/array/copyArray.js";
|
|
6
5
|
import { min2 } from "../../../../math/min2.js";
|
|
6
|
+
import { v3_angle_between } from "../../../v3_angle_between.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Using Shirman and Abi-Ezzi method, compute bounding sphere of points, then build a cone from that
|
|
@@ -66,7 +66,7 @@ export function computeTraingleClusterNormalBoundingCone(result, faces) {
|
|
|
66
66
|
const normal_y = normal_data[i3];
|
|
67
67
|
const normal_z = normal_data[i3];
|
|
68
68
|
|
|
69
|
-
const angle =
|
|
69
|
+
const angle = v3_angle_between(
|
|
70
70
|
normal_x, normal_y, normal_z,
|
|
71
71
|
result_direction.x, result_direction.y, result_direction.z
|
|
72
72
|
);
|