@woosh/meep-engine 2.33.21 → 2.33.25
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/ThreeClippingPlaneComputingBVHVisitor.js +5 -1
- package/core/bvh2/traversal/__detailed_box_volume_intersection.js +31 -11
- package/core/collection/ArrayUtils.js +1 -1
- package/core/collection/array/arrayQuickSort.js +9 -6
- package/core/collection/array/array_swap.js +22 -0
- package/core/collection/array/binarySearchHighIndex.js +1 -1
- package/core/collection/array/computeHashArray.js +22 -0
- package/core/collection/array/computeHashIntegerArray.js +15 -0
- package/core/collection/array/copyArray.js +2 -2
- package/core/collection/table/DataType2TypedArrayConstructorMapping.js +15 -0
- package/core/color/Color.js +2 -1
- package/core/function/FunctionCompiler.js +2 -1
- package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
- package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +10 -2
- package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +41 -0
- package/core/geom/3d/morton/mortonEncode_magicbits.js +2 -1
- package/core/geom/3d/morton/reinterpret_float32_as_int32.js +13 -0
- package/core/geom/3d/morton/v3_morton_encode_transformed.js +33 -0
- package/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
- package/core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js +13 -14
- package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
- package/core/geom/3d/shape/AbstractShape3D.js +38 -0
- package/core/geom/3d/shape/CompositeShape.js +240 -0
- package/core/geom/3d/shape/TransformedShape3D.js +126 -0
- package/core/geom/3d/shape/UnitCubeShape3D.js +24 -0
- package/core/geom/3d/shape/UnitSphereShape3D.js +24 -0
- package/core/geom/3d/shape/util/shape_to_visual_entity.js +159 -0
- 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 +0 -78
- package/core/geom/Matrix4.js +7 -8
- package/core/geom/Plane.js +14 -9
- package/core/geom/Rectangle.js +2 -1
- package/core/geom/Vector1.js +1 -1
- package/core/geom/Vector3.js +2 -1
- package/core/geom/Vector4.js +2 -1
- package/core/geom/random/randomPointInBox.js +7 -3
- package/core/geom/random/randomPointInPoint.js +6 -3
- package/core/geom/random/randomPointInSphere.js +9 -5
- package/core/geom/random/randomPointOnBox.js +7 -3
- package/core/geom/random/randomPointOnSphere.js +6 -3
- package/core/geom/v3_length.js +8 -3
- package/core/graph/graph_k_means_cluster.js +1 -1
- package/core/json/resolvePathByArray.js +2 -2
- package/core/math/MathUtils.js +0 -354
- package/core/math/MathUtils.spec.js +7 -1
- package/core/math/gaussian.js +9 -0
- package/core/math/hash/computeHashFloat.js +17 -0
- package/core/math/hash/computeHashFloatArray.js +34 -0
- package/core/math/hash/computeObjectHash.js +54 -0
- package/core/math/intersects1D.js +19 -0
- package/core/math/interval/NumericInterval.js +2 -2
- package/core/math/isValueBetween.js +10 -0
- package/core/math/isValueBetweenInclusive.js +10 -0
- package/core/math/noise/curl_noise_3dt.js +1 -1
- package/core/math/noise/sdnoise.js +10 -10
- package/core/math/overlap1D.js +19 -0
- package/core/math/pingpong.js +17 -0
- package/core/math/random/makeRangedRandom.js +19 -0
- package/core/math/random/randomFloatBetween.js +14 -0
- package/core/math/random/randomFromArray.js +19 -0
- package/core/math/random/randomGaussian.js +15 -0
- package/core/math/random/randomIntegerBetween.js +14 -0
- package/core/math/random/roundFair.js +15 -0
- package/core/math/separation1D.js +21 -0
- package/core/math/solveQuadratic.js +25 -0
- package/core/model/BoundedValue.js +1 -1
- package/core/model/node-graph/node/NodeInstancePortReference.js +1 -1
- package/core/model/node-graph/node/Port.js +1 -1
- package/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +3 -1
- package/core/model/reactive/model/ReactiveBinaryExpression.js +1 -1
- package/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +1 -1
- package/core/model/reactive/model/terminal/ReactiveReference.js +1 -1
- package/core/model/reactive/model/util/createRandomReactiveExpression.js +1 -1
- package/core/model/stat/LinearModifier.js +1 -1
- package/core/primitives/array/computeIntegerArrayHash.js +1 -1
- package/{engine/graphics/render/forward_plus/materials → core/primitives/strings}/insert_after.js +3 -0
- package/core/primitives/strings/insert_after_or_replace.js +27 -0
- package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
- package/editor/view/ecs/EntityEditor.js +2 -2
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +2 -2
- package/engine/EngineHarness.js +1 -0
- package/engine/animation/AnimationUtils.js +5 -5
- package/engine/animation/curve/AnimationCurve.js +72 -0
- package/engine/animation/curve/Keyframe.js +27 -0
- package/engine/animation/keyed2/AnimationTrack.js +27 -3
- package/engine/asset/Asset.js +1 -1
- package/engine/asset/loaders/GLTFAssetLoader.d.ts +1 -1
- package/engine/asset/loaders/GLTFAssetLoader.js +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 +3 -1
- package/engine/asset/loaders/material/computeTextureHash.js +2 -1
- package/engine/ecs/EntityBuilder.js +25 -5
- package/engine/ecs/animation/Animation.js +2 -1
- package/engine/ecs/animation/InverseKinematics.js +2 -1
- package/engine/ecs/attachment/AttachmentBinding.js +8 -0
- package/engine/ecs/attachment/AttachmentSystem.js +4 -0
- package/engine/ecs/attachment/TransformAttachmentBinding.js +14 -44
- package/engine/ecs/components/Tag.js +27 -6
- package/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
- package/engine/ecs/dynamic_actions/DynamicRuleDescriptionTable.spec.js +3 -5
- package/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +1 -1
- package/engine/ecs/evaluation/complex/PointFitnessGaussianBlur.js +1 -1
- package/engine/ecs/foliage/ecs/Foliage2.js +1 -1
- package/engine/ecs/fow/FogOfWar.js +4 -0
- package/engine/ecs/fow/FogOfWarSystem.js +2 -0
- package/engine/ecs/fow/shader/FogOfWarRenderer.js +1 -1
- package/engine/ecs/gui/GUIElement.js +1 -1
- package/engine/ecs/gui/hud/HeadsUpDisplay.js +1 -1
- package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -0
- package/engine/ecs/gui/position/ViewportPosition.js +2 -1
- package/engine/ecs/system/AbstractContextSystem.js +1 -1
- package/engine/ecs/systems/RangedAttackSystem.js +1 -1
- package/engine/ecs/systems/SteeringSystem.js +1 -1
- package/engine/ecs/systems/TagSystem.js +17 -0
- package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
- package/engine/ecs/tooltip/TooltipComponent.js +15 -0
- package/engine/ecs/transform/Transform.js +19 -6
- package/engine/ecs/util/hideEntityGracefully.js +18 -0
- package/engine/graphics/GraphicsEngine.js +11 -23
- package/engine/graphics/camera/testClippingPlaneComputation.js +2 -2
- package/engine/graphics/composit/CompositLayer.js +17 -4
- package/engine/graphics/composit/CompositingStages.js +8 -0
- package/engine/graphics/composit/LayerCompositer.js +35 -6
- package/engine/graphics/ecs/animation/animator/AnimationClip.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -1
- package/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +1 -1
- package/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +2 -1
- package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
- package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
- package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +11 -7
- package/engine/graphics/ecs/light/Light.d.ts +1 -1
- package/engine/graphics/ecs/light/Light.js +5 -0
- package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +5 -1
- package/engine/graphics/ecs/mesh/Mesh.js +2 -1
- package/engine/graphics/ecs/mesh-v2/DrawMode.js +5 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +32 -18
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
- package/engine/graphics/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/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
- package/engine/graphics/micron/buildPatchwork.js +1 -1
- package/engine/graphics/micron/format/MicronGeometry.js +3 -3
- package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +2 -2
- package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
- package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
- package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +5 -5
- package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
- package/engine/graphics/particles/ParticleEmitterLibrary.js +3 -0
- package/engine/graphics/particles/ecs/{ParticleEmitterSystem2.js → ParticleEmitterSystem.js} +17 -9
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +12 -4
- package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +84 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +106 -169
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +14 -3
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +141 -14
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +8 -7
- package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +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 +24 -0
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +262 -71
- package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +80 -46
- package/engine/graphics/particles/particular/engine/shader/debugAtlas.js +14 -0
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepApplyForce.js +2 -5
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseAcceleration.js +2 -6
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.js +2 -7
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +2 -5
- package/engine/graphics/particles/particular/engine/simulator/update_parameters.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +141 -0
- package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +478 -0
- package/engine/graphics/particles/particular/engine/utils/volume/lut_to_sampler.js +27 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +935 -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 +13 -7
- 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 +14 -32
- package/engine/graphics/render/forward_plus/materials/FP_INJECTION_POINT_ACCUMULATION.js +1 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +32 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_DECODE_PARS.js +51 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +25 -0
- package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +31 -120
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_lighting_shared.js +35 -0
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_shader.js +4 -5
- package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
- package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +10 -3
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +595 -60
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +256 -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 +7 -4
- package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -2
- package/engine/graphics/shaders/TerrainShader.js +4 -5
- package/engine/graphics/texture/atlas/AtlasPatch.js +7 -2
- package/engine/graphics/texture/atlas/TextureAtlas.js +2 -2
- 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/composeMatrix4.js +33 -23
- package/engine/graphics/util/decompose_matrix_4_array.js +61 -0
- package/engine/grid/components/GridObstacle.js +3 -10
- package/engine/intelligence/behavior/ecs/BehaviorComponent.js +30 -14
- package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
- package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
- package/engine/knowledge/database/StaticKnowledgeDataTable.js +6 -1
- package/engine/navigation/ecs/components/Path.js +1 -6
- package/engine/navigation/grid/FastBinaryHeap.spec.js +1 -1
- package/engine/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/CellFilterGaussianBlur.js +1 -1
- package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
- package/generation/markers/actions/MarkerNodeActionSelectRandom.js +1 -1
- package/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +1 -1
- package/generation/placement/action/random/CellActionSelectRandom.js +1 -1
- package/generation/theme/ThemeEngine.js +2 -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 +6 -100
- 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,159 @@
|
|
|
1
|
+
import { CompositeShape3D } from "../CompositeShape.js";
|
|
2
|
+
import { UnitCubeShape3D } from "../UnitCubeShape3D.js";
|
|
3
|
+
import { UnitSphereShape3D } from "../UnitSphereShape3D.js";
|
|
4
|
+
import { TransformedShape3D } from "../TransformedShape3D.js";
|
|
5
|
+
import EntityBuilder from "../../../../../engine/ecs/EntityBuilder.js";
|
|
6
|
+
import { Transform } from "../../../../../engine/ecs/transform/Transform.js";
|
|
7
|
+
import { AttachmentSockets } from "../../../../../engine/ecs/sockets/AttachmentSockets.js";
|
|
8
|
+
import { Attachment } from "../../../../../engine/ecs/attachment/Attachment.js";
|
|
9
|
+
import { ShadedGeometry } from "../../../../../engine/graphics/ecs/mesh-v2/ShadedGeometry.js";
|
|
10
|
+
import { LineBasicMaterial } from "three";
|
|
11
|
+
import { makeHelperSphereGeometry } from "../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
|
|
12
|
+
import { DrawMode } from "../../../../../engine/graphics/ecs/mesh-v2/DrawMode.js";
|
|
13
|
+
import { makeHelperBoxGeometry } from "../../../../../editor/process/symbolic/makeHelperBoxGeometry.js";
|
|
14
|
+
import Tag from "../../../../../engine/ecs/components/Tag.js";
|
|
15
|
+
|
|
16
|
+
const g_unit_sphere = makeHelperSphereGeometry(0.5, 32);
|
|
17
|
+
const g_unit_cube = makeHelperBoxGeometry(1, 1, 1);
|
|
18
|
+
|
|
19
|
+
const lineMaterial = new LineBasicMaterial({
|
|
20
|
+
depthTest: true,
|
|
21
|
+
depthWrite: false,
|
|
22
|
+
transparent: true,
|
|
23
|
+
linewidth: 1,
|
|
24
|
+
fog: false,
|
|
25
|
+
color: '#FFFFFF',
|
|
26
|
+
opacity: 1
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const SHAPE_VISUAL_ENTITY_TAG = 'util/vis/Shape3D';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param {CompositeShape3D} shape
|
|
34
|
+
* @param {EntityComponentDataset} ecd
|
|
35
|
+
* @returns {EntityBuilder}
|
|
36
|
+
*/
|
|
37
|
+
function composite_shape_to_entity(shape, ecd) {
|
|
38
|
+
|
|
39
|
+
const parent = new EntityBuilder();
|
|
40
|
+
parent
|
|
41
|
+
.add(new Transform())
|
|
42
|
+
.add(AttachmentSockets.fromJSON({
|
|
43
|
+
elements: [
|
|
44
|
+
{
|
|
45
|
+
type: 0,
|
|
46
|
+
id: 0
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}))
|
|
50
|
+
.build(ecd);
|
|
51
|
+
|
|
52
|
+
shape.children.forEach(c => {
|
|
53
|
+
|
|
54
|
+
const child_entity = shape_to_visual_entity(c, ecd);
|
|
55
|
+
|
|
56
|
+
child_entity.add(Attachment.fromJSON({
|
|
57
|
+
socket: 0,
|
|
58
|
+
parent: parent.entity,
|
|
59
|
+
immediate: true
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
return parent;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param {UnitCubeShape3D} shape
|
|
71
|
+
* @param {EntityComponentDataset} ecd
|
|
72
|
+
* @returns {EntityBuilder}
|
|
73
|
+
*/
|
|
74
|
+
function cube_shape_to_entity(shape, ecd) {
|
|
75
|
+
const eb = new EntityBuilder();
|
|
76
|
+
|
|
77
|
+
eb.add(new Transform());
|
|
78
|
+
eb.add(Tag.fromOne(SHAPE_VISUAL_ENTITY_TAG));
|
|
79
|
+
eb.add(ShadedGeometry.from(g_unit_cube, lineMaterial, DrawMode.LineSegments));
|
|
80
|
+
|
|
81
|
+
eb.build(ecd);
|
|
82
|
+
|
|
83
|
+
return eb;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
* @param {UnitSphereShape3D} shape
|
|
90
|
+
* @param {EntityComponentDataset} ecd
|
|
91
|
+
* @returns {EntityBuilder}
|
|
92
|
+
*/
|
|
93
|
+
function sphere_shape_to_entity(shape, ecd) {
|
|
94
|
+
const eb = new EntityBuilder();
|
|
95
|
+
|
|
96
|
+
eb.add(new Transform());
|
|
97
|
+
eb.add(Tag.fromOne(SHAPE_VISUAL_ENTITY_TAG));
|
|
98
|
+
eb.add(ShadedGeometry.from(g_unit_sphere, lineMaterial, DrawMode.Lines));
|
|
99
|
+
|
|
100
|
+
eb.build(ecd);
|
|
101
|
+
|
|
102
|
+
return eb;
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
* @param {TransformedShape3D} shape
|
|
109
|
+
* @param {EntityComponentDataset} ecd
|
|
110
|
+
* @returns {EntityBuilder}
|
|
111
|
+
*/
|
|
112
|
+
function transformed_shape_to_entity(shape, ecd) {
|
|
113
|
+
const subject = shape_to_visual_entity(shape.subject, ecd);
|
|
114
|
+
|
|
115
|
+
const parent = new EntityBuilder();
|
|
116
|
+
parent
|
|
117
|
+
.add(new Transform())
|
|
118
|
+
.add(AttachmentSockets.fromJSON({
|
|
119
|
+
elements: [
|
|
120
|
+
{
|
|
121
|
+
type: 0,
|
|
122
|
+
id: 0
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}))
|
|
126
|
+
.build(ecd);
|
|
127
|
+
|
|
128
|
+
const attachment = Attachment.fromJSON({
|
|
129
|
+
socket: 0,
|
|
130
|
+
parent: parent.entity,
|
|
131
|
+
immediate: true
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
attachment.transform.fromMatrix4(shape.transform);
|
|
135
|
+
|
|
136
|
+
subject.add(attachment);
|
|
137
|
+
|
|
138
|
+
return parent;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
* @param {AbstractShape3D} shape
|
|
144
|
+
* @param {EntityComponentDataset} ecd
|
|
145
|
+
* @returns {EntityBuilder}
|
|
146
|
+
*/
|
|
147
|
+
export function shape_to_visual_entity(shape, ecd) {
|
|
148
|
+
if (shape instanceof CompositeShape3D) {
|
|
149
|
+
return composite_shape_to_entity(shape, ecd);
|
|
150
|
+
} else if (shape instanceof UnitCubeShape3D) {
|
|
151
|
+
return cube_shape_to_entity(shape, ecd);
|
|
152
|
+
} else if (shape instanceof UnitSphereShape3D) {
|
|
153
|
+
return sphere_shape_to_entity(shape, ecd);
|
|
154
|
+
} else if (shape instanceof TransformedShape3D) {
|
|
155
|
+
return transformed_shape_to_entity(shape, ecd);
|
|
156
|
+
} else {
|
|
157
|
+
throw new Error('Unsupported shape type');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -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
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { clamp } from "../math/clamp.js";
|
|
5
5
|
import Vector3 from "./Vector3.js";
|
|
6
|
-
import { v3_dot } from "./v3_dot.js";
|
|
7
|
-
import { v3_distance_sqr } from "./v3_distance_sqr.js";
|
|
8
6
|
|
|
9
7
|
|
|
10
8
|
const SMALL_NUM = 1e-9;
|
|
@@ -19,82 +17,6 @@ const LineSegment = function (first, second) {
|
|
|
19
17
|
|
|
20
18
|
};
|
|
21
19
|
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {Vector3} result
|
|
25
|
-
* @param {number} origin_x
|
|
26
|
-
* @param {number} origin_y
|
|
27
|
-
* @param {number} origin_z
|
|
28
|
-
* @param {number} direction_x
|
|
29
|
-
* @param {number} direction_y
|
|
30
|
-
* @param {number} direction_z
|
|
31
|
-
* @param {number} px
|
|
32
|
-
* @param {number} py
|
|
33
|
-
* @param {number} pz
|
|
34
|
-
* @returns {number} distance from origin, negative means that the point lies behind the origin in the direction opposite to the ray's own
|
|
35
|
-
*/
|
|
36
|
-
export function ray_computeNearestPointToPoint(result, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, px, py, pz) {
|
|
37
|
-
// find closest point
|
|
38
|
-
const sp0_x = px - origin_x;
|
|
39
|
-
const sp0_y = py - origin_y;
|
|
40
|
-
const sp0_z = pz - origin_z;
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
const d2 = v3_dot(direction_x, direction_y, direction_z, direction_x, direction_y, direction_z);
|
|
44
|
-
const d3 = v3_dot(direction_x, direction_y, direction_z, sp0_x, sp0_y, sp0_z);
|
|
45
|
-
|
|
46
|
-
const t = d3 / d2;
|
|
47
|
-
|
|
48
|
-
// compute point on the ray
|
|
49
|
-
const lp_x = direction_x * t + origin_x;
|
|
50
|
-
const lp_y = direction_y * t + origin_y;
|
|
51
|
-
const lp_z = direction_z * t + origin_z;
|
|
52
|
-
|
|
53
|
-
result.set(lp_x, lp_y, lp_z);
|
|
54
|
-
|
|
55
|
-
return t;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Computes shortest distance between a line segment(defined by 2 points) and a point
|
|
60
|
-
* @param {number} x0
|
|
61
|
-
* @param {number} y0
|
|
62
|
-
* @param {number} z0
|
|
63
|
-
* @param {number} x1
|
|
64
|
-
* @param {number} y1
|
|
65
|
-
* @param {number} z1
|
|
66
|
-
* @param {number} px
|
|
67
|
-
* @param {number} py
|
|
68
|
-
* @param {number} pz
|
|
69
|
-
*/
|
|
70
|
-
export function line3_computeSegmentPointDistance_sqr(x0, y0, z0, x1, y1, z1, px, py, pz) {
|
|
71
|
-
// find closest point
|
|
72
|
-
const sp0_x = px - x0;
|
|
73
|
-
const sp0_y = py - y0;
|
|
74
|
-
const sp0_z = pz - z0;
|
|
75
|
-
|
|
76
|
-
// get line delta
|
|
77
|
-
const line_delta_x = x1 - x0;
|
|
78
|
-
const line_delta_y = y1 - y0;
|
|
79
|
-
const line_delta_z = z1 - z0;
|
|
80
|
-
|
|
81
|
-
//
|
|
82
|
-
const d2 = line_delta_x * line_delta_x + line_delta_y * line_delta_y + line_delta_z * line_delta_z;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const d3 = line_delta_x * sp0_x + line_delta_y * sp0_y + line_delta_z * sp0_z;
|
|
86
|
-
|
|
87
|
-
const t = clamp(d3 / d2, 0, 1);
|
|
88
|
-
|
|
89
|
-
// compute point on the line
|
|
90
|
-
const lp_x = line_delta_x * t + x0;
|
|
91
|
-
const lp_y = line_delta_y * t + y0;
|
|
92
|
-
const lp_z = line_delta_z * t + z0;
|
|
93
|
-
|
|
94
|
-
// compute distance from the point in question to the point on the line
|
|
95
|
-
return v3_distance_sqr(px, py, pz, lp_x, lp_y, lp_z);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
20
|
LineSegment.prototype.closestPointToPointParameter = function (point, clampToLine) {
|
|
99
21
|
|
|
100
22
|
|
package/core/geom/Matrix4.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Vector3 from "./Vector3.js";
|
|
2
|
-
import { v3_length } from "./v3_length.js";
|
|
3
2
|
|
|
4
3
|
const _z = new Vector3();
|
|
5
4
|
const _x = new Vector3();
|
|
@@ -193,12 +192,12 @@ export class Matrix4 {
|
|
|
193
192
|
decompose(position, rotation, scale) {
|
|
194
193
|
|
|
195
194
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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);
|
|
199
198
|
|
|
200
199
|
// if determine is negative, we need to invert one scale
|
|
201
|
-
|
|
200
|
+
const det = this.determinant();
|
|
202
201
|
if (det < 0) sx = -sx;
|
|
203
202
|
|
|
204
203
|
position.set(
|
|
@@ -208,9 +207,9 @@ export class Matrix4 {
|
|
|
208
207
|
);
|
|
209
208
|
|
|
210
209
|
// scale the rotation part
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
const invSX = 1 / sx;
|
|
211
|
+
const invSY = 1 / sy;
|
|
212
|
+
const invSZ = 1 / sz;
|
|
214
213
|
|
|
215
214
|
const i_a0 = this.a0 * invSX;
|
|
216
215
|
const i_a1 = this.a1 * invSX;
|
package/core/geom/Plane.js
CHANGED
|
@@ -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/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.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 { lerp } from "../math/lerp.js";
|
|
9
|
-
import {
|
|
9
|
+
import { EPSILON, epsilonEquals } from "../math/MathUtils.js";
|
|
10
10
|
import { sign } from "../math/sign.js";
|
|
11
11
|
import { v3_dot } from "./v3_dot.js";
|
|
12
12
|
import { v3_length_sqr } from "./v3_length_sqr.js";
|
|
@@ -14,6 +14,7 @@ import { v3_length } from "./v3_length.js";
|
|
|
14
14
|
import { v3_angle_between } from "./v3_angle_between.js";
|
|
15
15
|
import { v3_lerp } from "./v3_lerp.js";
|
|
16
16
|
import { v3_slerp } from "./v3_slerp.js";
|
|
17
|
+
import { computeHashFloat } from "../math/hash/computeHashFloat.js";
|
|
17
18
|
|
|
18
19
|
class Vector3 {
|
|
19
20
|
/**
|
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
|
}
|
|
@@ -4,18 +4,20 @@ import { PI2 } from "../../math/MathUtils.js";
|
|
|
4
4
|
*
|
|
5
5
|
* @see based on python code suggested here: https://stackoverflow.com/questions/5408276/sampling-uniformly-distributed-random-points-inside-a-spherical-volume
|
|
6
6
|
* @param {function} random
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {number[]} result
|
|
8
|
+
* @param {number} result_offset
|
|
8
9
|
*/
|
|
9
|
-
export function randomPointInSphere(random, result) {
|
|
10
|
+
export function randomPointInSphere(random, result, result_offset) {
|
|
10
11
|
const phi = PI2 * random();
|
|
11
12
|
|
|
12
13
|
const cosTheta = random() * 2 - 1;
|
|
13
14
|
|
|
14
|
-
const u = random()
|
|
15
|
+
const u = random();
|
|
15
16
|
|
|
16
17
|
const theta = Math.acos(cosTheta);
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
// compute radius
|
|
20
|
+
const r = Math.cbrt(u) * 0.5;
|
|
19
21
|
|
|
20
22
|
const sinTheta = Math.sin(theta);
|
|
21
23
|
|
|
@@ -27,5 +29,7 @@ export function randomPointInSphere(random, result) {
|
|
|
27
29
|
const z = r * cosTheta;
|
|
28
30
|
|
|
29
31
|
//write the result
|
|
30
|
-
result
|
|
32
|
+
result[result_offset] = x;
|
|
33
|
+
result[result_offset + 1] = y;
|
|
34
|
+
result[result_offset + 2] = z;
|
|
31
35
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
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 randomPointOnBox(random, result) {
|
|
7
|
+
export function randomPointOnBox(random, result, result_offset) {
|
|
7
8
|
//pick a side
|
|
8
9
|
const side = random();
|
|
9
10
|
|
|
@@ -29,5 +30,8 @@ export function randomPointOnBox(random, result) {
|
|
|
29
30
|
z = fixedAxis;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
//write the result
|
|
34
|
+
result[result_offset] = x;
|
|
35
|
+
result[result_offset + 1] = y;
|
|
36
|
+
result[result_offset + 2] = z;
|
|
33
37
|
}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
*
|
|
3
3
|
* @see based on python code suggested here: https://stackoverflow.com/questions/5408276/sampling-uniformly-distributed-random-points-inside-a-spherical-volume
|
|
4
4
|
* @param {function} random
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {number[]} result
|
|
6
|
+
* @param {number} result_offset
|
|
6
7
|
*/
|
|
7
|
-
export function randomPointOnSphere(random, result) {
|
|
8
|
+
export function randomPointOnSphere(random, result, result_offset) {
|
|
8
9
|
const phi = Math.PI * 2 * random();
|
|
9
10
|
|
|
10
11
|
const cosTheta = random() * 2 - 1;
|
|
@@ -23,5 +24,7 @@ export function randomPointOnSphere(random, result) {
|
|
|
23
24
|
const z = r * cosTheta;
|
|
24
25
|
|
|
25
26
|
//write the result
|
|
26
|
-
result
|
|
27
|
+
result[result_offset] = x;
|
|
28
|
+
result[result_offset + 1] = y;
|
|
29
|
+
result[result_offset + 2] = z;
|
|
27
30
|
}
|
package/core/geom/v3_length.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number} x
|
|
4
|
+
* @param {number} y
|
|
5
|
+
* @param {number} z
|
|
6
|
+
* @returns {number}
|
|
7
|
+
*/
|
|
3
8
|
export function v3_length(x, y, z) {
|
|
4
|
-
return Math.
|
|
9
|
+
return Math.hypot(x, y, z);
|
|
5
10
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//
|
|
2
2
|
import { seededRandom } from "../math/random/seededRandom.js";
|
|
3
|
-
import { randomIntegerBetween } from "../math/MathUtils.js";
|
|
4
3
|
import { SquareMatrix } from "./SquareMatrix.js";
|
|
5
4
|
import { DataType } from "../collection/table/DataType.js";
|
|
6
5
|
import { BitSet } from "../binary/BitSet.js";
|
|
7
6
|
import FastBinaryHeap from "../../engine/navigation/grid/FastBinaryHeap.js";
|
|
7
|
+
import { randomIntegerBetween } from "../math/random/randomIntegerBetween.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @template N
|