@woosh/meep-engine 2.50.3 → 2.52.0
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/editor/actions/concrete/WriteGridValueAction.js +13 -18
- package/editor/ecs/component/editors/Sampler2DEditor.js +2 -2
- package/editor/process/SymbolicDisplayProcess.js +1 -1
- package/editor/process/symbolic/buildThreeJSHelperEntity.js +1 -1
- package/editor/process/symbolic/makeCameraSymbolicDisplay.js +1 -1
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +1 -1
- package/editor/process/symbolic/makeLightSymbolicDisplay.js +1 -1
- package/editor/process/symbolic/makePathSymbolicDisplay.js +1 -1
- package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +1 -1
- package/editor/view/ecs/components/GridObstacleController.js +2 -2
- package/editor/view/ecs/components/TerrainController.js +2 -2
- package/package.json +1 -1
- package/samples/terrain/editor.js +2 -2
- package/src/core/NumberFormat.js +0 -71
- package/src/core/UUID.spec.js +8 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.d.ts +4 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +58 -55
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.spec.js +54 -0
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +3 -3
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.spec.js +60 -0
- package/src/core/bvh2/bvh3/query/BVHQueryAny.js +16 -0
- package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +5 -5
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +2 -3
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.spec.js +22 -0
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.spec.js +64 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +2 -3
- package/src/core/bvh2/visual/convert_bvh_to_dot_format_string.js +2 -2
- package/src/core/cache/Cache.js +3 -5
- package/src/core/cache/CacheElement.js +1 -0
- package/src/core/geom/2d/quad-tree/PointQuadTree.js +10 -0
- package/src/core/geom/3d/aabb/aabb3_array_combine.js +3 -3
- package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.js +41 -0
- package/src/core/geom/3d/topology/struct/TopoMesh.js +3 -2
- package/src/core/geom/3d/topology/struct/prototypeBinaryTopology.js +4 -4
- package/src/core/geom/Vector2.d.ts +9 -0
- package/src/core/geom/Vector2.js +8 -22
- package/src/core/geom/Vector2.spec.js +153 -0
- package/src/core/graph/{convertGraphToDotString.js → convert_graph_to_dot_string.js} +1 -1
- package/src/core/graph/convert_graph_to_dot_string.spec.js +28 -0
- package/src/core/math/noise/sdnoise.js +5 -7
- package/src/core/math/noise/sdnoise.spec.js +87 -0
- package/src/core/model/ModuleRegistry.js +2 -4
- package/src/core/model/ModuleRegistry.spec.js +31 -0
- package/src/core/model/reactive/js/compileReactiveToJS.spec.js +14 -0
- package/src/core/model/reactive/model/logic/ReactiveAnd.spec.js +31 -1
- package/src/core/model/reactive/model/logic/ReactiveOr.spec.js +53 -0
- package/src/core/model/stat/LinearModifier.js +2 -2
- package/src/core/model/stat/LinearModifier.spec.js +62 -0
- package/src/core/model/stat/Stat.js +12 -0
- package/src/core/model/stat/Stat.spec.js +36 -0
- package/src/core/primitives/array/computeStridedIntegerArrayHash.spec.js +28 -0
- package/src/core/primitives/numbers/number_format_by_thousands.js +14 -0
- package/src/core/primitives/numbers/number_pretty_print.js +49 -0
- package/src/core/primitives/strings/computeStringHash.spec.js +12 -5
- package/src/core/process/BaseProcess.js +8 -8
- package/src/engine/Clock.js +30 -29
- package/src/engine/Clock.spec.js +26 -0
- package/src/engine/{Platform.js → browserInfo.js} +1 -5
- package/src/engine/ecs/EntityBuilder.js +3 -1
- package/src/engine/ecs/EntityBuilder.spec.js +21 -0
- package/src/engine/ecs/fow/FogOfWar.js +48 -54
- package/src/engine/ecs/gui/GUIElement.js +1 -1
- package/src/engine/ecs/gui/position/ViewportPosition.js +3 -3
- package/src/engine/ecs/{systems → renderable}/RenderSystem.d.ts +1 -1
- package/src/engine/ecs/{systems → renderable}/RenderSystem.js +10 -38
- package/src/engine/ecs/renderable/Renderable.d.ts +25 -0
- package/src/engine/ecs/{components → renderable}/Renderable.js +18 -83
- package/src/engine/ecs/renderable/Renderable.spec.js +10 -0
- package/src/engine/ecs/speaker/VoiceSystem.js +15 -9
- package/src/engine/ecs/terrain/ecs/TerrainClassifier.js +1 -1
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +3 -3
- package/src/engine/ecs/terrain/ecs/splat/SplatMapOptimizerDebugger.js +3 -3
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +2 -2
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +2 -2
- package/src/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +2 -2
- package/src/engine/ecs/transform/Transform.js +1 -0
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +0 -4
- package/src/engine/graphics/copy_transform_to_threejs_object.js +12 -0
- package/src/engine/graphics/debug/VisualSymbolLine.js +1 -1
- package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraph.spec.js +5 -0
- package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +24 -25
- package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.spec.js +5 -0
- package/src/engine/graphics/ecs/decal/DecalSystem.js +3 -21
- package/src/engine/graphics/ecs/decal/v2/Decal.js +32 -32
- package/src/engine/graphics/ecs/decal/v2/Decal.spec.js +5 -0
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +4 -2
- package/src/engine/graphics/ecs/highlight/renderer/makeGaussianBlurShader.js +1 -4
- package/src/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.d.ts +1 -1
- package/src/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.js +2 -2
- package/src/engine/graphics/ecs/mesh/applyTransformToThreeObject.js +2 -5
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +4 -33
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +8 -4
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.spec.js +5 -0
- package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +0 -12
- package/src/engine/graphics/ecs/path/ribbon/RibbonPathBuilder.js +2 -2
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +0 -4
- package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +0 -2
- package/src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js +1 -1
- package/src/engine/graphics/geometry/optimization/merge/prototypeGeometryMerge.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -3
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -4
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -5
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -6
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +2 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +6 -1
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +4 -4
- package/src/engine/graphics/shaders/SoftOutlineShader.js +2 -4
- package/src/engine/graphics/shadows/testShadowMapRendering.js +0 -2
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.spec.js +24 -0
- package/src/engine/graphics/texture/atlas/TextureAtlas.spec.js +46 -0
- package/src/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
- package/src/engine/graphics/texture/sampler/bicubic.spec.js +13 -0
- package/src/engine/graphics/texture/sampler/differenceSampler.js +1 -1
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js +5 -1
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.spec.js +183 -0
- package/src/engine/graphics/texture/sampler/filter/filter_lanczos3.js +20 -0
- package/src/engine/graphics/texture/sampler/filter/mitchell.js +0 -21
- package/src/engine/graphics/texture/sampler/filter/mitchell_v1.js +21 -0
- package/src/engine/graphics/texture/sampler/filter/sampler2d_scale_down_generic.js +17 -16
- package/src/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +11 -9
- package/src/engine/graphics/texture/sampler/{scaleSampler2D.js → resize/sampler2d_scale.js} +8 -8
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale.spec.js +73 -0
- package/src/engine/graphics/texture/sampler/{sampler2_d_scale_down_lanczos.js → resize/sampler2d_scale_down_lanczos.js} +3 -24
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.spec.js +29 -0
- package/src/engine/graphics/texture/sampler/{sampler2d_scale_down_linear.js → resize/sampler2d_scale_down_linear.js} +5 -5
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_linear.spec.js +44 -0
- package/src/engine/graphics/texture/sampler/resize/{sampler2d_downsample_mipmap.js → sampler2d_scale_down_mipmap.js} +2 -2
- package/src/engine/graphics/texture/sampler/resize/{sampler2d_downsample_mipmap.spec.js → sampler2d_scale_down_mipmap.spec.js} +2 -2
- package/src/engine/graphics/texture/sampler/{genericResampleSampler2D.js → resize/sampler2d_scale_generic.js} +16 -12
- package/src/engine/graphics/texture/sampler/{upsampleSampler2D.js → resize/sampler2d_scale_up_linear.js} +5 -2
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_up_linear.spec.js +14 -0
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.js +4 -2
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.spec.js +15 -0
- package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.js +2 -2
- package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +46 -0
- package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.spec.js +108 -0
- package/src/engine/graphics/trail/TemporalPath.js +83 -78
- package/src/engine/graphics/trail/TemporalPath.spec.js +5 -0
- package/src/engine/graphics/trail/x/RibbonX.spec.js +5 -0
- package/src/engine/grid/components/GridObstacle.js +45 -25
- package/src/engine/grid/components/GridObstacle.spec.js +130 -1
- package/src/engine/grid/components/GridPosition.js +5 -17
- package/src/engine/grid/components/GridPosition2Transform.js +1 -70
- package/src/engine/grid/components/GridPosition2TransformSerializationAdapter.js +70 -0
- package/src/engine/input/devices/InputDeviceSwitch.spec.js +5 -0
- package/src/engine/input/ecs/{InputBinding.js → components/InputBinding.js} +1 -1
- package/src/engine/input/ecs/components/InputController.js +2 -2
- package/src/engine/input/ecs/ism/InputBinding.js +2 -2
- package/src/engine/input/ecs/util/TerrainCameraTargetSampler.js +1 -1
- package/src/engine/input/ecs/util/TopDownCameraControllerHelper.js +1 -1
- package/src/engine/intelligence/behavior/behavior_to_dot.spec.js +25 -0
- package/src/engine/intelligence/behavior/util/DelayBehavior.js +6 -4
- package/src/engine/intelligence/blackboard/Blackboard.d.ts +2 -0
- package/src/engine/intelligence/blackboard/Blackboard.js +36 -2
- package/src/engine/intelligence/blackboard/Blackboard.spec.js +49 -0
- package/src/engine/intelligence/blackboard/BlackboardSerializationAdapter.spec.js +2 -0
- package/src/engine/navigation/grid/{AStar.js → find_path_on_grid_astar.js} +21 -18
- package/src/engine/navigation/grid/find_path_on_grid_astar.spec.js +7 -0
- package/src/engine/plugin/EnginePlugin.js +12 -14
- package/src/engine/plugin/EnginePlugin.spec.js +5 -0
- package/src/engine/plugin/EnginePluginManager.js +18 -22
- package/src/engine/scene/transitionToScene.js +12 -1
- package/src/engine/simulation/Ticker.js +1 -1
- package/src/engine/sound/ecs/SoundListenerSystem.js +1 -1
- package/src/generation/markers/debug/visualizeMarkers.js +1 -1
- package/src/generation/theme/TerrainLayerDescription.js +1 -1
- package/src/view/common/LabelView.js +3 -3
- package/src/engine/MeepSettings.js +0 -9
- package/src/engine/User.js +0 -28
- package/src/engine/UserController.js +0 -273
- package/src/engine/ecs/components/AABB.js +0 -33
- package/src/engine/ecs/components/AABBCollider.js +0 -15
- package/src/engine/ecs/components/AimController.js +0 -18
- package/src/engine/ecs/components/Attacker.js +0 -13
- package/src/engine/ecs/components/MeshCollider.js +0 -15
- package/src/engine/ecs/components/RangedAttack.js +0 -12
- package/src/engine/ecs/components/Renderable.d.ts +0 -14
- package/src/engine/ecs/components/TargetAI.js +0 -11
- package/src/engine/ecs/components/ViewportMeshProjection.js +0 -18
- package/src/engine/ecs/grid/Sampler2DDecoder.js +0 -57
- package/src/engine/ecs/grid/makeTerrainGeometry.js +0 -110
- package/src/engine/ecs/systems/AABBColliderSystem.js +0 -61
- package/src/engine/ecs/systems/AABBSystem.js +0 -89
- package/src/engine/ecs/systems/AimControllerSystem.js +0 -63
- package/src/engine/ecs/systems/AttackerSystem.js +0 -67
- package/src/engine/ecs/systems/MeshColliderSystem.js +0 -47
- package/src/engine/ecs/systems/MonsterAISystem.js +0 -163
- package/src/engine/ecs/systems/MortalitySystem.js +0 -46
- package/src/engine/ecs/systems/RangedAttackSystem.js +0 -132
- package/src/engine/ecs/systems/SerializationMetadataSystem.js +0 -10
- package/src/engine/ecs/systems/TargetAISystem.js +0 -107
- package/src/engine/ecs/systems/ViewportMeshProjectionSystem.js +0 -68
- package/src/engine/graphics/particles/ParticleEmitterLibrary.js +0 -87
- package/src/engine/graphics/texture/sampler/sampler2d_make_array_filler_function.js +0 -65
- package/src/engine/graphics/texture/sampler/sampler2d_scale_down_linear.spec.js +0 -17
- package/src/engine/graphics/trail/x/simulator/RibbonState.js +0 -10
- package/src/engine/grid/Grid.js +0 -131
- package/src/engine/grid/components/ViewportGridProjection.js +0 -20
- package/src/engine/grid/systems/GridObstacleSystem.js +0 -58
- package/src/engine/grid/systems/ViewportGridProjectionSystem.js +0 -105
- package/src/engine/navigation/grid/GridField.js +0 -328
- /package/src/{engine → core/primitives/array}/computeStridedIntegerArrayHash.js +0 -0
- /package/src/engine/ecs/{components → renderable}/RenderableFlags.js +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ExplicitBinaryBoundingVolumeHierarchy } from "../ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
2
|
+
import { bvh_query_leaves_generic } from "./bvh_query_leaves_generic.js";
|
|
3
|
+
import { BVHQueryAny } from "./BVHQueryAny.js";
|
|
4
|
+
|
|
5
|
+
test("all-accepting query", () => {
|
|
6
|
+
const bvh = new ExplicitBinaryBoundingVolumeHierarchy();
|
|
7
|
+
|
|
8
|
+
const leaf_a = bvh.allocate_node();
|
|
9
|
+
const leaf_b = bvh.allocate_node();
|
|
10
|
+
|
|
11
|
+
bvh.insert_leaf(leaf_a);
|
|
12
|
+
bvh.insert_leaf(leaf_b);
|
|
13
|
+
|
|
14
|
+
const result = [];
|
|
15
|
+
|
|
16
|
+
const count = bvh_query_leaves_generic(result, 1, bvh, bvh.root, BVHQueryAny.INSTANCE);
|
|
17
|
+
|
|
18
|
+
expect(count).toBe(2);
|
|
19
|
+
expect(result).toContain(leaf_a);
|
|
20
|
+
expect(result).toContain(leaf_b);
|
|
21
|
+
|
|
22
|
+
});
|
|
@@ -13,6 +13,7 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
* @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
|
|
16
|
+
* @param {number} root
|
|
16
17
|
* @param {number[]} result
|
|
17
18
|
* @param {number} result_offset
|
|
18
19
|
* @param {number} origin_x
|
|
@@ -24,12 +25,11 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
|
24
25
|
* @returns {number}
|
|
25
26
|
*/
|
|
26
27
|
export function bvh_query_leaves_ray(
|
|
27
|
-
bvh,
|
|
28
|
+
bvh, root,
|
|
28
29
|
result, result_offset,
|
|
29
30
|
origin_x, origin_y, origin_z,
|
|
30
31
|
direction_x, direction_y, direction_z
|
|
31
32
|
) {
|
|
32
|
-
const root = bvh.root;
|
|
33
33
|
|
|
34
34
|
if (root === NULL_NODE) {
|
|
35
35
|
return 0;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ExplicitBinaryBoundingVolumeHierarchy } from "../ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
2
|
+
import { bvh_query_leaves_ray } from "./bvh_query_leaves_ray.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {number[]} leaves
|
|
7
|
+
*/
|
|
8
|
+
function makeBVH(...leaves) {
|
|
9
|
+
|
|
10
|
+
const bvh = new ExplicitBinaryBoundingVolumeHierarchy();
|
|
11
|
+
|
|
12
|
+
for (let i = 0; i < leaves.length; i++) {
|
|
13
|
+
|
|
14
|
+
const node = bvh.allocate_node();
|
|
15
|
+
|
|
16
|
+
bvh.node_set_aabb(node, leaves[i]);
|
|
17
|
+
bvh.node_set_user_data(node, i);
|
|
18
|
+
|
|
19
|
+
bvh.insert_leaf(node);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return bvh;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
test("cast positive -X to +X, 1 node", () => {
|
|
26
|
+
|
|
27
|
+
const bvh = makeBVH(
|
|
28
|
+
[1, 3, 5, 7, 11, 13]
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const result = [];
|
|
32
|
+
|
|
33
|
+
const match_count = bvh_query_leaves_ray(
|
|
34
|
+
bvh, bvh.root,
|
|
35
|
+
result, 0,
|
|
36
|
+
-1, 4, 6,
|
|
37
|
+
1, 0, 0
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(match_count).toBe(1);
|
|
41
|
+
|
|
42
|
+
expect(result[0]).toEqual(0);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("cast positive -X to +X, 1/2 nodes", () => {
|
|
46
|
+
|
|
47
|
+
const bvh = makeBVH(
|
|
48
|
+
[-4, 3, 5, -2, 11, 13],
|
|
49
|
+
[1, 3, 5, 7, 11, 13]
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const result = [];
|
|
53
|
+
|
|
54
|
+
const match_count = bvh_query_leaves_ray(
|
|
55
|
+
bvh, bvh.root,
|
|
56
|
+
result, 0,
|
|
57
|
+
-1, 4, 6,
|
|
58
|
+
1, 0, 0
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
expect(match_count).toBe(1);
|
|
62
|
+
|
|
63
|
+
expect(result[0]).toEqual(1);
|
|
64
|
+
});
|
|
@@ -9,16 +9,15 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
|
9
9
|
* @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
|
|
10
10
|
* @param {number[]} result
|
|
11
11
|
* @param {number} result_offset
|
|
12
|
+
* @param {number} root
|
|
12
13
|
* @param {BVHQuery} query
|
|
13
14
|
* @returns {number}
|
|
14
15
|
*/
|
|
15
16
|
export function bvh_query_user_data_generic(
|
|
16
17
|
result, result_offset,
|
|
17
|
-
bvh, query
|
|
18
|
+
bvh,root, query
|
|
18
19
|
) {
|
|
19
20
|
|
|
20
|
-
const root = bvh.root;
|
|
21
|
-
|
|
22
21
|
if (root === NULL_NODE) {
|
|
23
22
|
return 0;
|
|
24
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { convert_graph_to_dot_string } from "../../graph/convert_graph_to_dot_string.js";
|
|
2
2
|
import { bvh_traverse_pre_order_using_stack } from "../traversal/bvh_traverse_pre_order_using_stack.js";
|
|
3
3
|
import { Graph } from "../../graph/v2/Graph.js";
|
|
4
4
|
import { Edge, EdgeDirectionType } from "../../graph/Edge.js";
|
|
@@ -46,5 +46,5 @@ export function bvh_to_graph(bvh) {
|
|
|
46
46
|
*/
|
|
47
47
|
export function convert_bvh_to_dot_format_string(bvh) {
|
|
48
48
|
const graph = bvh_to_graph(bvh);
|
|
49
|
-
return
|
|
49
|
+
return convert_graph_to_dot_string({ graph: graph });
|
|
50
50
|
}
|
package/src/core/cache/Cache.js
CHANGED
|
@@ -5,9 +5,10 @@ import { returnOne, returnZero, strictEquals } from "../function/Functions.js";
|
|
|
5
5
|
import { CacheElement } from "./CacheElement.js";
|
|
6
6
|
import { collectIteratorValueToArray } from "../collection/collectIteratorValueToArray.js";
|
|
7
7
|
|
|
8
|
+
// TODO validate hashes of held elements to keep them up to date. Keys are assumed to be immutable, but this assumption may be broken by users
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* Hash-based cache, uses LRU (least-recently-used) eviction policy
|
|
10
|
-
* TODO validate hashes of held elements to keep them up to date. Keys are assumed to be immutable, but this assumption may be broken by users
|
|
11
12
|
* @template Key, Value
|
|
12
13
|
* @extends Map<Key,Value>
|
|
13
14
|
*/
|
|
@@ -403,7 +404,7 @@ export class Cache {
|
|
|
403
404
|
}
|
|
404
405
|
|
|
405
406
|
/**
|
|
406
|
-
* Remove without triggering {@link #
|
|
407
|
+
* Remove without triggering {@link #onRemoved}
|
|
407
408
|
* NOTE: please be sure you understand what you're doing when you use this method
|
|
408
409
|
* @param {Key} key
|
|
409
410
|
* @returns {boolean} true if element was removed, false otherwise
|
|
@@ -469,20 +470,17 @@ export class Cache {
|
|
|
469
470
|
/**
|
|
470
471
|
* Shortcut for "Map" class spec compliance
|
|
471
472
|
* @readonly
|
|
472
|
-
* @type {Cache.put}
|
|
473
473
|
*/
|
|
474
474
|
Cache.prototype.set = Cache.prototype.put;
|
|
475
475
|
|
|
476
476
|
/**
|
|
477
477
|
* Shortcut for "Map" class spec compliance
|
|
478
478
|
* @readonly
|
|
479
|
-
* @type {Cache.remove}
|
|
480
479
|
*/
|
|
481
480
|
Cache.prototype.delete = Cache.prototype.remove;
|
|
482
481
|
|
|
483
482
|
/**
|
|
484
483
|
* Shortcut for "Map" class spec compliance
|
|
485
484
|
* @readonly
|
|
486
|
-
* @type {Cache.contains}
|
|
487
485
|
*/
|
|
488
486
|
Cache.prototype.has = Cache.prototype.contains;
|
|
@@ -170,7 +170,17 @@ class PointQuadTree {
|
|
|
170
170
|
this.br = undefined;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
*
|
|
175
|
+
* @param {T} p
|
|
176
|
+
* @param {number} x
|
|
177
|
+
* @param {number} y
|
|
178
|
+
* @return {Element}
|
|
179
|
+
*/
|
|
173
180
|
insert(p, x, y) {
|
|
181
|
+
assert.isNumber(x, 'x');
|
|
182
|
+
assert.isNumber(y, 'y');
|
|
183
|
+
|
|
174
184
|
const element = new Element(p, x, y);
|
|
175
185
|
|
|
176
186
|
this.resizeToFit(x, y); //adjust size if needed
|
|
@@ -5,9 +5,9 @@ import { max2 } from "../../../math/max2.js";
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Merge bounds of two axis-aligned bounding boxes, the result is a box that tightly bounds inputs
|
|
8
|
-
* @param {ArrayLike<number>|number[]} result where resulting value is written to
|
|
9
|
-
* @param {ArrayLike<number>|number[]} a
|
|
10
|
-
* @param {ArrayLike<number>|number[]} b
|
|
8
|
+
* @param {ArrayLike<number>|number[]|Float32Array} result where resulting value is written to
|
|
9
|
+
* @param {ArrayLike<number>|number[]|Float32Array} a
|
|
10
|
+
* @param {ArrayLike<number>|number[]|Float32Array} b
|
|
11
11
|
*/
|
|
12
12
|
export function aabb3_array_combine(result, a, b) {
|
|
13
13
|
result[0] = min2(a[0], b[0]);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { assert } from "../../../assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number[]|ArrayLike<number>|Float32Array} result
|
|
6
|
+
* @param {BufferGeometry} geometry
|
|
7
|
+
*/
|
|
8
|
+
export function aabb3_from_threejs_geometry(result, geometry) {
|
|
9
|
+
const gbb = geometry.boundingBox;
|
|
10
|
+
|
|
11
|
+
assert.notNull(gbb, 'boundingBox');
|
|
12
|
+
|
|
13
|
+
const min = gbb.min;
|
|
14
|
+
const max = gbb.max;
|
|
15
|
+
|
|
16
|
+
const x0 = min.x;
|
|
17
|
+
const y0 = min.y;
|
|
18
|
+
const z0 = min.z;
|
|
19
|
+
|
|
20
|
+
const x1 = max.x;
|
|
21
|
+
const y1 = max.y;
|
|
22
|
+
const z1 = max.z;
|
|
23
|
+
|
|
24
|
+
// validate bounds
|
|
25
|
+
assert.notNaN(x0, 'x0');
|
|
26
|
+
assert.notNaN(y0, 'y0');
|
|
27
|
+
assert.notNaN(z0, 'z0');
|
|
28
|
+
|
|
29
|
+
assert.notNaN(x1, 'x1');
|
|
30
|
+
assert.notNaN(y1, 'y1');
|
|
31
|
+
assert.notNaN(z1, 'z1');
|
|
32
|
+
|
|
33
|
+
// marshal into transform-accepted format
|
|
34
|
+
result[0] = x0;
|
|
35
|
+
result[1] = y0;
|
|
36
|
+
result[2] = z0;
|
|
37
|
+
|
|
38
|
+
result[3] = x1;
|
|
39
|
+
result[4] = y1;
|
|
40
|
+
result[5] = z1;
|
|
41
|
+
}
|
|
@@ -8,7 +8,8 @@ import { tm_kill_only_vert } from "../tm_kill_only_vert.js";
|
|
|
8
8
|
import { tm_kill_only_edge } from "../tm_kill_only_edge.js";
|
|
9
9
|
import { tm_kill_only_face } from "../tm_kill_only_face.js";
|
|
10
10
|
import { query_edge_other_vertex } from "../query/query_edge_other_vertex.js";
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
import { number_format_by_thousands } from "../../../../primitives/numbers/number_format_by_thousands.js";
|
|
12
13
|
|
|
13
14
|
export class TopoMesh {
|
|
14
15
|
constructor() {
|
|
@@ -643,7 +644,7 @@ export class TopoMesh {
|
|
|
643
644
|
}
|
|
644
645
|
|
|
645
646
|
toString() {
|
|
646
|
-
return `TopoMesh{ vertices: ${
|
|
647
|
+
return `TopoMesh{ vertices: ${number_format_by_thousands(this.vertices.length)}, edges: ${number_format_by_thousands(this.getEdges().size)}, faces: ${number_format_by_thousands(this.getFaces().size)} }`;
|
|
647
648
|
}
|
|
648
649
|
}
|
|
649
650
|
|
|
@@ -5,8 +5,8 @@ import { BinaryTopology } from "./binary/BinaryTopology.js";
|
|
|
5
5
|
import {
|
|
6
6
|
compute_buffer_geometry_byte_size
|
|
7
7
|
} from "../../../../../engine/graphics/geometry/buffered/compute_buffer_geometry_byte_size.js";
|
|
8
|
-
import { prettyPrint } from "../../../../NumberFormat.js";
|
|
9
8
|
import { TopoMesh } from "./TopoMesh.js";
|
|
9
|
+
import { number_pretty_print } from "../../../../primitives/numbers/number_pretty_print.js";
|
|
10
10
|
|
|
11
11
|
function promise_ply(url) {
|
|
12
12
|
|
|
@@ -44,9 +44,9 @@ async function main() {
|
|
|
44
44
|
|
|
45
45
|
console.log(mesh, lucy_geom);
|
|
46
46
|
|
|
47
|
-
console.log(`source mesh size: ${
|
|
48
|
-
console.log(`binary topology size: ${
|
|
49
|
-
console.log(`object topology size: ${
|
|
47
|
+
console.log(`source mesh size: ${number_pretty_print(compute_buffer_geometry_byte_size(lucy_geom))} bytes`);
|
|
48
|
+
console.log(`binary topology size: ${number_pretty_print(mesh.byteSize)} bytes`);
|
|
49
|
+
console.log(`object topology size: ${number_pretty_print(topoMesh.byteSize)} bytes`);
|
|
50
50
|
|
|
51
51
|
window.topo_obj = topoMesh;
|
|
52
52
|
}
|
|
@@ -23,6 +23,8 @@ export default class Vector2 {
|
|
|
23
23
|
|
|
24
24
|
_sub(x: number, y: number): void
|
|
25
25
|
|
|
26
|
+
lerpVectors(a: Vector2, b: Vector2, f: number): void
|
|
27
|
+
|
|
26
28
|
abs(): void
|
|
27
29
|
|
|
28
30
|
round(): void
|
|
@@ -31,6 +33,8 @@ export default class Vector2 {
|
|
|
31
33
|
|
|
32
34
|
ceil(): void
|
|
33
35
|
|
|
36
|
+
rotate(angle: number): void
|
|
37
|
+
|
|
34
38
|
copy(other: Vector2): void
|
|
35
39
|
|
|
36
40
|
clone(): Vector2
|
|
@@ -39,8 +43,13 @@ export default class Vector2 {
|
|
|
39
43
|
|
|
40
44
|
roughlyEquals(other: Vector2, tolerance?: number): boolean
|
|
41
45
|
|
|
46
|
+
hash(): number
|
|
47
|
+
|
|
42
48
|
distanceTo(other: Vector2): number
|
|
43
49
|
|
|
50
|
+
manhattanDistanceTo(other: Vector2): number
|
|
51
|
+
|
|
52
|
+
|
|
44
53
|
isZero(): boolean
|
|
45
54
|
|
|
46
55
|
readFromArray(array: ArrayLike<number>, offset?: number): void
|
package/src/core/geom/Vector2.js
CHANGED
|
@@ -450,7 +450,10 @@ class Vector2 {
|
|
|
450
450
|
* @param {number} fraction
|
|
451
451
|
*/
|
|
452
452
|
lerpVectors(a, b, fraction) {
|
|
453
|
-
|
|
453
|
+
const x = lerp(a.x, b.x, fraction);
|
|
454
|
+
const y = lerp(a.y, b.y, fraction);
|
|
455
|
+
|
|
456
|
+
this.set(x, y);
|
|
454
457
|
}
|
|
455
458
|
|
|
456
459
|
/**
|
|
@@ -538,7 +541,7 @@ class Vector2 {
|
|
|
538
541
|
*
|
|
539
542
|
* @returns {number}
|
|
540
543
|
*/
|
|
541
|
-
|
|
544
|
+
hash() {
|
|
542
545
|
const x = Math.sin(this.x) * 1367130550;
|
|
543
546
|
const y = Math.sin(this.y) * 1367130550;
|
|
544
547
|
|
|
@@ -550,7 +553,7 @@ class Vector2 {
|
|
|
550
553
|
}
|
|
551
554
|
|
|
552
555
|
/**
|
|
553
|
-
*
|
|
556
|
+
* Rotation is counter-clockwise
|
|
554
557
|
* @param {number} angle in radians
|
|
555
558
|
*/
|
|
556
559
|
rotate(angle) {
|
|
@@ -558,7 +561,7 @@ class Vector2 {
|
|
|
558
561
|
const cos = Math.cos(angle);
|
|
559
562
|
|
|
560
563
|
const x = this.x * cos - this.y * sin
|
|
561
|
-
const y = this.x * sin
|
|
564
|
+
const y = this.x * sin + this.y * cos;
|
|
562
565
|
|
|
563
566
|
this.set(x, y);
|
|
564
567
|
}
|
|
@@ -597,7 +600,7 @@ class Vector2 {
|
|
|
597
600
|
* @return {boolean}
|
|
598
601
|
*/
|
|
599
602
|
roughlyEquals(other, tolerance) {
|
|
600
|
-
return this._roughlyEquals(other.x, other.y,
|
|
603
|
+
return this._roughlyEquals(other.x, other.y, tolerance);
|
|
601
604
|
}
|
|
602
605
|
|
|
603
606
|
/**
|
|
@@ -677,23 +680,6 @@ Vector2.one = Object.freeze(new Vector2(1, 1));
|
|
|
677
680
|
* @type {boolean}
|
|
678
681
|
*/
|
|
679
682
|
Vector2.prototype.isVector2 = true;
|
|
680
|
-
|
|
681
|
-
/**
|
|
682
|
-
*
|
|
683
|
-
* @param {Vector2} result
|
|
684
|
-
* @param {Vector2} a
|
|
685
|
-
* @param {Vector2} b
|
|
686
|
-
* @param {number} fraction
|
|
687
|
-
*/
|
|
688
|
-
function v2Lerp(result, a, b, fraction) {
|
|
689
|
-
|
|
690
|
-
const x = lerp(a.x, b.x, fraction);
|
|
691
|
-
const y = lerp(a.y, b.y, fraction);
|
|
692
|
-
|
|
693
|
-
result.set(x, y);
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
|
|
697
683
|
/**
|
|
698
684
|
*
|
|
699
685
|
* @param {number} x0
|
|
@@ -8,6 +8,21 @@ test("setting x and y via constructor", () => {
|
|
|
8
8
|
expect(v.y).toBe(13);
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
+
test("array-style accessors", () => {
|
|
12
|
+
|
|
13
|
+
const v = new Vector2();
|
|
14
|
+
|
|
15
|
+
v[0] = 3;
|
|
16
|
+
v[1] = -7;
|
|
17
|
+
|
|
18
|
+
expect(v[0]).toEqual(3);
|
|
19
|
+
expect(v.x).toEqual(3);
|
|
20
|
+
|
|
21
|
+
expect(v[1]).toEqual(-7);
|
|
22
|
+
expect(v.y).toEqual(-7);
|
|
23
|
+
|
|
24
|
+
});
|
|
25
|
+
|
|
11
26
|
test('add works', () => {
|
|
12
27
|
const a = new Vector2(1, 3);
|
|
13
28
|
const b = new Vector2(5, 7);
|
|
@@ -140,3 +155,141 @@ test("onChange is dispatched when y changes via set", () => {
|
|
|
140
155
|
|
|
141
156
|
expect(changeHandler).toHaveBeenLastCalledWith(2, 3, 1, 3);
|
|
142
157
|
});
|
|
158
|
+
|
|
159
|
+
test("rotate", () => {
|
|
160
|
+
|
|
161
|
+
const v = new Vector2(0, 0);
|
|
162
|
+
|
|
163
|
+
v.rotate(0);
|
|
164
|
+
|
|
165
|
+
expect(v.x).toBeCloseTo(0);
|
|
166
|
+
expect(v.y).toBeCloseTo(0);
|
|
167
|
+
|
|
168
|
+
v.set(1, 0);
|
|
169
|
+
|
|
170
|
+
v.rotate(0);
|
|
171
|
+
|
|
172
|
+
expect(v.x).toBeCloseTo(1);
|
|
173
|
+
expect(v.y).toBeCloseTo(0);
|
|
174
|
+
|
|
175
|
+
v.set(0, 1);
|
|
176
|
+
|
|
177
|
+
v.rotate(0);
|
|
178
|
+
|
|
179
|
+
expect(v.x).toBeCloseTo(0);
|
|
180
|
+
expect(v.y).toBeCloseTo(1);
|
|
181
|
+
|
|
182
|
+
v.set(1, 0);
|
|
183
|
+
|
|
184
|
+
v.rotate(Math.PI);
|
|
185
|
+
|
|
186
|
+
expect(v.x).toBeCloseTo(-1);
|
|
187
|
+
expect(v.y).toBeCloseTo(0);
|
|
188
|
+
|
|
189
|
+
v.set(-1, 0);
|
|
190
|
+
|
|
191
|
+
v.rotate(Math.PI);
|
|
192
|
+
|
|
193
|
+
expect(v.x).toBeCloseTo(1);
|
|
194
|
+
expect(v.y).toBeCloseTo(0);
|
|
195
|
+
|
|
196
|
+
v.set(0, 1);
|
|
197
|
+
|
|
198
|
+
v.rotate(Math.PI);
|
|
199
|
+
|
|
200
|
+
expect(v.x).toBeCloseTo(0);
|
|
201
|
+
expect(v.y).toBeCloseTo(-1);
|
|
202
|
+
|
|
203
|
+
v.set(0, -1);
|
|
204
|
+
|
|
205
|
+
v.rotate(Math.PI);
|
|
206
|
+
|
|
207
|
+
expect(v.x).toBeCloseTo(0);
|
|
208
|
+
expect(v.y).toBeCloseTo(1);
|
|
209
|
+
|
|
210
|
+
v.set(1, 1);
|
|
211
|
+
|
|
212
|
+
v.rotate(Math.PI * 0.5);
|
|
213
|
+
|
|
214
|
+
expect(v.x).toBeCloseTo(-1);
|
|
215
|
+
expect(v.y).toBeCloseTo(1);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test("hash", () => {
|
|
219
|
+
|
|
220
|
+
function validate(x, y) {
|
|
221
|
+
|
|
222
|
+
const v = new Vector2(x, y);
|
|
223
|
+
|
|
224
|
+
const hash = v.hash();
|
|
225
|
+
|
|
226
|
+
expect(hash).toEqual(v.hash()); // stability
|
|
227
|
+
expect(typeof hash).toBe("number");
|
|
228
|
+
expect(Number.isInteger(hash)).toBe(true);
|
|
229
|
+
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
validate(0, 0);
|
|
233
|
+
validate(0, 1);
|
|
234
|
+
validate(1, 0);
|
|
235
|
+
validate(1, 1);
|
|
236
|
+
|
|
237
|
+
validate(0, -1);
|
|
238
|
+
validate(-1, 0);
|
|
239
|
+
validate(-1, -1);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
test("normalize", () => {
|
|
243
|
+
|
|
244
|
+
const v = new Vector2(1, 1);
|
|
245
|
+
|
|
246
|
+
v.normalize();
|
|
247
|
+
|
|
248
|
+
const s = 1 / Math.SQRT2;
|
|
249
|
+
|
|
250
|
+
expect(v.x).toBeCloseTo(s);
|
|
251
|
+
expect(v.y).toBeCloseTo(s);
|
|
252
|
+
|
|
253
|
+
v.set(-1, -1);
|
|
254
|
+
|
|
255
|
+
v.normalize();
|
|
256
|
+
|
|
257
|
+
expect(v.x).toBeCloseTo(-s);
|
|
258
|
+
expect(v.y).toBeCloseTo(-s);
|
|
259
|
+
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test("length", () => {
|
|
263
|
+
|
|
264
|
+
expect(new Vector2(1, 0).length()).toBeCloseTo(1);
|
|
265
|
+
expect(new Vector2(0, 1).length()).toBeCloseTo(1);
|
|
266
|
+
|
|
267
|
+
expect(new Vector2(1, 1).length()).toBeCloseTo(Math.SQRT2);
|
|
268
|
+
|
|
269
|
+
expect(new Vector2(-1, 1).length()).toBeCloseTo(Math.SQRT2);
|
|
270
|
+
|
|
271
|
+
expect(new Vector2(1, -1).length()).toBeCloseTo(Math.SQRT2);
|
|
272
|
+
|
|
273
|
+
expect(new Vector2(-1, -1).length()).toBeCloseTo(Math.SQRT2);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
test("manhattanDistanceTo", () => {
|
|
278
|
+
const a = new Vector2(1, 3);
|
|
279
|
+
const b = new Vector2(5, 11);
|
|
280
|
+
|
|
281
|
+
expect(a.manhattanDistanceTo(b)).toEqual(12)
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test("lerpVectors", () => {
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
const a = new Vector2(-1, 3);
|
|
288
|
+
const b = new Vector2(5, -11);
|
|
289
|
+
|
|
290
|
+
a.lerpVectors(a, b, 0.1);
|
|
291
|
+
|
|
292
|
+
expect(a.x).toBeCloseTo(-1 * 0.9 + 5 * 0.1);
|
|
293
|
+
expect(a.y).toBeCloseTo(3 * 0.9 - 11 * 0.1);
|
|
294
|
+
|
|
295
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { convert_graph_to_dot_string } from "./convert_graph_to_dot_string.js";
|
|
2
|
+
import { Graph } from "./v2/Graph.js";
|
|
3
|
+
import { EdgeDirectionType } from "./Edge.js";
|
|
4
|
+
|
|
5
|
+
test("empty graph should produce valid string", () => {
|
|
6
|
+
const dot = convert_graph_to_dot_string({
|
|
7
|
+
graph: new Graph()
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
expect(typeof dot).toEqual("string");
|
|
11
|
+
expect(dot.trim().length).toBeGreaterThan(0);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("graph with 2 nodes and an edge should produce valid string", () => {
|
|
15
|
+
const graph = new Graph();
|
|
16
|
+
|
|
17
|
+
graph.addNode(1);
|
|
18
|
+
graph.addNode(2);
|
|
19
|
+
|
|
20
|
+
graph.createEdge(1, 2, EdgeDirectionType.Forward);
|
|
21
|
+
|
|
22
|
+
const dot = convert_graph_to_dot_string({
|
|
23
|
+
graph: graph
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
expect(typeof dot).toEqual("string");
|
|
27
|
+
expect(dot.trim().length).toBeGreaterThan(0);
|
|
28
|
+
});
|
|
@@ -195,7 +195,7 @@ function grad4(result, hash) {
|
|
|
195
195
|
* @param {number[]} derivatives
|
|
196
196
|
* @returns {number}
|
|
197
197
|
*/
|
|
198
|
-
function sdnoise1(derivatives, x) {
|
|
198
|
+
export function sdnoise1(derivatives, x) {
|
|
199
199
|
const i0 = x | 0;
|
|
200
200
|
const i1 = i0 + 1;
|
|
201
201
|
|
|
@@ -207,8 +207,7 @@ function sdnoise1(derivatives, x) {
|
|
|
207
207
|
let t1, t20, t40, t21, t41, x21;
|
|
208
208
|
|
|
209
209
|
const x20 = x0 * x0;
|
|
210
|
-
const t0 = 1.0
|
|
211
|
-
f - x20;
|
|
210
|
+
const t0 = 1.0 - x20;
|
|
212
211
|
// if(t0 < 0.0f) t0 = 0.0f; // Never happens for 1D: x0<=1 always
|
|
213
212
|
t20 = t0 * t0;
|
|
214
213
|
t40 = t20 * t20;
|
|
@@ -218,8 +217,7 @@ function sdnoise1(derivatives, x) {
|
|
|
218
217
|
n0 = t40 * gx0 * x0;
|
|
219
218
|
|
|
220
219
|
x21 = x1 * x1;
|
|
221
|
-
t1 = 1.0
|
|
222
|
-
f - x21;
|
|
220
|
+
t1 = 1.0 - x21;
|
|
223
221
|
// if(t1 < 0.0f) t1 = 0.0f; // Never happens for 1D: |x1|<=1 always
|
|
224
222
|
t21 = t1 * t1;
|
|
225
223
|
t41 = t21 * t21;
|
|
@@ -265,7 +263,7 @@ const G2 = 0.21132486540518713;
|
|
|
265
263
|
* @param {number[]} derivatives
|
|
266
264
|
* @returns {number}
|
|
267
265
|
*/
|
|
268
|
-
function sdnoise2(derivatives, x, y) {
|
|
266
|
+
export function sdnoise2(derivatives, x, y) {
|
|
269
267
|
let n0, n1, n2; /* Noise contributions from the three simplex corners */
|
|
270
268
|
let gx0, gy0, gx1, gy1, gx2, gy2; /* Gradients at simplex corners */
|
|
271
269
|
let t0, t1, t2, x1, x2, y1, y2;
|
|
@@ -280,7 +278,7 @@ function sdnoise2(derivatives, x, y) {
|
|
|
280
278
|
let ii, i = xs | 0;
|
|
281
279
|
let jj, j = ys | 0;
|
|
282
280
|
|
|
283
|
-
const t = (
|
|
281
|
+
const t = (i + j) * G2;
|
|
284
282
|
const X0 = i - t; /* Unskew the cell origin back to (x,y) space */
|
|
285
283
|
const Y0 = j - t;
|
|
286
284
|
const x0 = x - X0; /* The x,y distances from the cell origin */
|