@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
|
@@ -28,7 +28,6 @@ import ViewportPositionSystem from "../../../../ecs/gui/position/ViewportPositio
|
|
|
28
28
|
import { GridPosition2TransformSystem } from "../../../../grid/systems/GridPosition2TransformSystem.js";
|
|
29
29
|
import { Transform2GridPositionSystem } from "../../../../grid/transform2grid/Transform2GridPositionSystem.js";
|
|
30
30
|
import SynchronizePositionSystem from "../../../../ecs/systems/SynchronizePositionSystem.js";
|
|
31
|
-
import GridObstacleSystem from "../../../../grid/systems/GridObstacleSystem.js";
|
|
32
31
|
import GridPositionSystem from "../../../../grid/systems/GridPositionSystem.js";
|
|
33
32
|
import InputControllerSystem from "../../../../input/ecs/systems/InputControllerSystem.js";
|
|
34
33
|
import { InputSystem } from "../../../../input/ecs/systems/InputSystem.js";
|
|
@@ -39,7 +38,6 @@ import { AnimationGraphSystem } from "../../../ecs/animation/animator/AnimationG
|
|
|
39
38
|
import { FogOfWarSystem } from "../../../../ecs/fow/FogOfWarSystem.js";
|
|
40
39
|
import { FogOfWarRevealerSystem } from "../../../../ecs/fow/FogOfWarRevealerSystem.js";
|
|
41
40
|
import { BehaviorSystem } from "../../../../intelligence/behavior/ecs/BehaviorSystem.js";
|
|
42
|
-
import { SerializationMetadataSystem } from "../../../../ecs/systems/SerializationMetadataSystem.js";
|
|
43
41
|
import { InverseKinematicsSystem } from "../../../../ecs/ik/InverseKinematicsSystem.js";
|
|
44
42
|
import { PathDisplaySystem } from "../../../ecs/path/PathDisplaySystem.js";
|
|
45
43
|
import {
|
|
@@ -65,7 +63,7 @@ import { BehaviorComponent } from "../../../../intelligence/behavior/ecs/Behavio
|
|
|
65
63
|
import { Light } from "../../../ecs/light/Light.js";
|
|
66
64
|
import { LightType } from "../../../ecs/light/LightType.js";
|
|
67
65
|
import { parseColor } from "../../../../../core/color/parseColor.js";
|
|
68
|
-
import Renderable from "../../../../ecs/
|
|
66
|
+
import Renderable from "../../../../ecs/renderable/Renderable.js";
|
|
69
67
|
import { makeHelperSphereGeometry } from "../../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
|
|
70
68
|
import TopDownCameraController from "../../../ecs/camera/topdown/TopDownCameraController.js";
|
|
71
69
|
import ThreeFactory from "../../../three/ThreeFactory.js";
|
|
@@ -139,7 +137,6 @@ function makeConfig(engine) {
|
|
|
139
137
|
new GridPosition2TransformSystem(),
|
|
140
138
|
new Transform2GridPositionSystem(),
|
|
141
139
|
new SynchronizePositionSystem(),
|
|
142
|
-
new GridObstacleSystem(),
|
|
143
140
|
new GridPositionSystem(),
|
|
144
141
|
new InputControllerSystem(devices),
|
|
145
142
|
new InputSystem(devices),
|
|
@@ -154,7 +151,6 @@ function makeConfig(engine) {
|
|
|
154
151
|
new FogOfWarSystem(graphics),
|
|
155
152
|
new FogOfWarRevealerSystem(0),
|
|
156
153
|
new BehaviorSystem(engine),
|
|
157
|
-
new SerializationMetadataSystem(),
|
|
158
154
|
new InverseKinematicsSystem(),
|
|
159
155
|
new PathDisplaySystem(engine),
|
|
160
156
|
new ShadedGeometrySystem(engine)
|
|
@@ -24,7 +24,6 @@ import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
|
24
24
|
import { MouseEvents } from "../../../../input/devices/events/MouseEvents.js";
|
|
25
25
|
import { RingBuffer } from "../../../../../core/collection/RingBuffer.js";
|
|
26
26
|
import { query_bvh_frustum_from_objects } from "../query/query_bvh_frustum_from_objects.js";
|
|
27
|
-
import { prettyPrint } from "../../../../../core/NumberFormat.js";
|
|
28
27
|
import { FPlusDebugMaterial } from "../materials/FPlusDebugMaterial.js";
|
|
29
28
|
import { parseColor } from "../../../../../core/color/parseColor.js";
|
|
30
29
|
import { buildLightClusterWidget } from "../debug/buildLightClusterWidget.js";
|
|
@@ -66,6 +65,7 @@ import { Localization } from "../../../../../core/localization/Localization.js";
|
|
|
66
65
|
import '../../../../../../../../../css/game.scss'
|
|
67
66
|
import { randomFromArray } from "../../../../../core/math/random/randomFromArray.js";
|
|
68
67
|
import { debugAtlas } from "../../../particles/particular/engine/shader/debugAtlas.js";
|
|
68
|
+
import { number_pretty_print } from "../../../../../core/primitives/numbers/number_pretty_print.js";
|
|
69
69
|
|
|
70
70
|
document.body.style.margin = 0;
|
|
71
71
|
|
|
@@ -1523,7 +1523,7 @@ function print_perf_stats() {
|
|
|
1523
1523
|
|
|
1524
1524
|
metric.computeStats(stats);
|
|
1525
1525
|
|
|
1526
|
-
values.push(`${m}: ${
|
|
1526
|
+
values.push(`${m}: ${number_pretty_print(stats.mean)}`);
|
|
1527
1527
|
});
|
|
1528
1528
|
|
|
1529
1529
|
console.log(values.join(", "));
|
|
@@ -27,7 +27,6 @@ import ViewportPositionSystem from "../../../../ecs/gui/position/ViewportPositio
|
|
|
27
27
|
import { GridPosition2TransformSystem } from "../../../../grid/systems/GridPosition2TransformSystem.js";
|
|
28
28
|
import { Transform2GridPositionSystem } from "../../../../grid/transform2grid/Transform2GridPositionSystem.js";
|
|
29
29
|
import SynchronizePositionSystem from "../../../../ecs/systems/SynchronizePositionSystem.js";
|
|
30
|
-
import GridObstacleSystem from "../../../../grid/systems/GridObstacleSystem.js";
|
|
31
30
|
import GridPositionSystem from "../../../../grid/systems/GridPositionSystem.js";
|
|
32
31
|
import InputControllerSystem from "../../../../input/ecs/systems/InputControllerSystem.js";
|
|
33
32
|
import { InputSystem } from "../../../../input/ecs/systems/InputSystem.js";
|
|
@@ -38,7 +37,6 @@ import { AnimationGraphSystem } from "../../../ecs/animation/animator/AnimationG
|
|
|
38
37
|
import { FogOfWarSystem } from "../../../../ecs/fow/FogOfWarSystem.js";
|
|
39
38
|
import { FogOfWarRevealerSystem } from "../../../../ecs/fow/FogOfWarRevealerSystem.js";
|
|
40
39
|
import { BehaviorSystem } from "../../../../intelligence/behavior/ecs/BehaviorSystem.js";
|
|
41
|
-
import { SerializationMetadataSystem } from "../../../../ecs/systems/SerializationMetadataSystem.js";
|
|
42
40
|
import { InverseKinematicsSystem } from "../../../../ecs/ik/InverseKinematicsSystem.js";
|
|
43
41
|
import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
44
42
|
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
@@ -55,7 +53,6 @@ import ViewportPosition from "../../../../ecs/gui/position/ViewportPosition.js";
|
|
|
55
53
|
import GUIElement from "../../../../ecs/gui/GUIElement.js";
|
|
56
54
|
import { MetricCollection } from "../../../../development/performance/MetricCollection.js";
|
|
57
55
|
import { MetricStatistics } from "../../../../development/performance/MetricStatistics.js";
|
|
58
|
-
import { prettyPrint } from "../../../../../core/NumberFormat.js";
|
|
59
56
|
import { buildCanvasViewFromTexture } from "./buildCanvasViewFromTexture.js";
|
|
60
57
|
import { BatchOcclusionQuery } from "./query/BatchOcclusionQuery.js";
|
|
61
58
|
import HeadsUpDisplay from "../../../../ecs/gui/hud/HeadsUpDisplay.js";
|
|
@@ -69,6 +66,7 @@ import { min2 } from "../../../../../core/math/min2.js";
|
|
|
69
66
|
import { mat4 } from "gl-matrix";
|
|
70
67
|
import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
|
|
71
68
|
import { load_and_set_cubemap_v0 } from "../../../load_and_set_cubemap_v0.js";
|
|
69
|
+
import { number_pretty_print } from "../../../../../core/primitives/numbers/number_pretty_print.js";
|
|
72
70
|
|
|
73
71
|
const engineHarness = new EngineHarness();
|
|
74
72
|
|
|
@@ -115,7 +113,6 @@ function makeConfig(engine) {
|
|
|
115
113
|
new GridPosition2TransformSystem(),
|
|
116
114
|
new Transform2GridPositionSystem(),
|
|
117
115
|
new SynchronizePositionSystem(),
|
|
118
|
-
new GridObstacleSystem(),
|
|
119
116
|
new GridPositionSystem(),
|
|
120
117
|
new InputControllerSystem(devices),
|
|
121
118
|
new InputSystem(devices),
|
|
@@ -129,7 +126,6 @@ function makeConfig(engine) {
|
|
|
129
126
|
new FogOfWarSystem(graphics),
|
|
130
127
|
new FogOfWarRevealerSystem(0),
|
|
131
128
|
new BehaviorSystem(engine),
|
|
132
|
-
new SerializationMetadataSystem(),
|
|
133
129
|
new InverseKinematicsSystem(),
|
|
134
130
|
new PathDisplaySystem(engine),
|
|
135
131
|
);
|
|
@@ -186,7 +182,7 @@ function print_perf_stats() {
|
|
|
186
182
|
|
|
187
183
|
metric.computeStats(stats);
|
|
188
184
|
|
|
189
|
-
values.push(`${m}: ${
|
|
185
|
+
values.push(`${m}: ${number_pretty_print(stats.mean)}`);
|
|
190
186
|
});
|
|
191
187
|
|
|
192
188
|
console.log(values.join(", "));
|
|
@@ -179,7 +179,8 @@ export class GeometryBVHBatched {
|
|
|
179
179
|
|
|
180
180
|
// TODO we can unify BVH traversal with ray checks to reduce number of checks
|
|
181
181
|
const count = bvh_query_leaves_ray(
|
|
182
|
-
bvh,
|
|
182
|
+
bvh, bvh.root,
|
|
183
|
+
leaf_buffer, 0,
|
|
183
184
|
origin_x, origin_y, origin_z,
|
|
184
185
|
direction_x, direction_y, direction_z
|
|
185
186
|
);
|
|
@@ -378,7 +378,12 @@ export class PathTracer {
|
|
|
378
378
|
*/
|
|
379
379
|
trace(out, ray, min_distance, max_distance) {
|
|
380
380
|
const bvh = this.bvh_top_level;
|
|
381
|
-
|
|
381
|
+
|
|
382
|
+
const hit_count = bvh_query_leaves_ray(
|
|
383
|
+
bvh, bvh.root,
|
|
384
|
+
temp_ray_results, 0,
|
|
385
|
+
ray[0], ray[1], ray[2], ray[3], ray[4], ray[5]
|
|
386
|
+
);
|
|
382
387
|
|
|
383
388
|
let nearest_hit_distance = max_distance;
|
|
384
389
|
let nearest_mesh = null;
|
|
@@ -13,12 +13,11 @@ import { Sampler2D } from "../../texture/sampler/Sampler2D.js";
|
|
|
13
13
|
import sampler2D2Canvas from "../../texture/sampler/Sampler2D2Canvas.js";
|
|
14
14
|
import { ray3_array_compose } from "../../../../core/geom/3d/ray/ray3_array_compose.js";
|
|
15
15
|
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
16
|
-
import { prettyPrint } from "../../../../core/NumberFormat.js";
|
|
17
16
|
import { float2uint8 } from "../../../../core/binary/float2uint8.js";
|
|
18
17
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
19
18
|
import { Camera } from "../../ecs/camera/Camera.js";
|
|
20
19
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
21
|
-
import {
|
|
20
|
+
import { sampler2d_scale } from "../../texture/sampler/resize/sampler2d_scale.js";
|
|
22
21
|
import { seededRandom } from "../../../../core/math/random/seededRandom.js";
|
|
23
22
|
import { mat4, vec3 } from "gl-matrix";
|
|
24
23
|
import { v3_distance } from "../../../../core/geom/v3_distance.js";
|
|
@@ -38,6 +37,7 @@ import { min2 } from "../../../../core/math/min2.js";
|
|
|
38
37
|
import { makeGeometryIndexed } from "../../geometry/buffered/makeGeometryIndexed.js";
|
|
39
38
|
import { DirectionalLight } from "../../render/forward_plus/model/DirectionalLight.js";
|
|
40
39
|
import { kelvin_to_rgb } from "../../../../core/color/kelvin_to_rgb.js";
|
|
40
|
+
import { number_pretty_print } from "../../../../core/primitives/numbers/number_pretty_print.js";
|
|
41
41
|
|
|
42
42
|
document.body.style.margin = 0;
|
|
43
43
|
document.body.style.overflow = "hidden";
|
|
@@ -500,7 +500,7 @@ function* render(target, pt, camera, progress = { current: 0, total: 0 }) {
|
|
|
500
500
|
|
|
501
501
|
const total_time = performance.now() - t0;
|
|
502
502
|
|
|
503
|
-
console.log(`Trace finished in ${
|
|
503
|
+
console.log(`Trace finished in ${number_pretty_print(total_time)}ms. Total of ${number_pretty_print(sample_count)} samples, ${number_pretty_print(sample_count * 1000 / total_time)} samples per second`);
|
|
504
504
|
|
|
505
505
|
}
|
|
506
506
|
|
|
@@ -595,7 +595,7 @@ async function start_renderer(camera) {
|
|
|
595
595
|
vContainer.removeChild(vProgress);
|
|
596
596
|
|
|
597
597
|
if (scaled_rt !== rt) {
|
|
598
|
-
|
|
598
|
+
sampler2d_scale(scaled_rt, rt);
|
|
599
599
|
}
|
|
600
600
|
|
|
601
601
|
sampler2D2Canvas(rt, 1, 0, vCanvas.el);
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* Created by Alex on 02/10/2015.
|
|
3
3
|
*/
|
|
4
4
|
import * as THREE from 'three';
|
|
5
|
+
import { gaussian } from "../../../core/math/gaussian.js";
|
|
5
6
|
|
|
6
7
|
let SoftOutlineShader = function (edge, sigma, hardPixels) {
|
|
7
|
-
function gaussian(s, v) {
|
|
8
|
-
return Math.exp(-(v * v) / (2.0 * s * s));
|
|
9
|
-
}
|
|
10
8
|
|
|
11
9
|
function makeFragmentBody() {
|
|
12
10
|
const kernel = [];
|
|
@@ -110,4 +108,4 @@ let SoftOutlineShader = function (edge, sigma, hardPixels) {
|
|
|
110
108
|
}
|
|
111
109
|
};
|
|
112
110
|
|
|
113
|
-
export default GaussianGlowShader;
|
|
111
|
+
export default GaussianGlowShader;
|
|
@@ -23,7 +23,6 @@ import { InputSystem } from "../../input/ecs/systems/InputSystem.js";
|
|
|
23
23
|
import MeshHighlightSystem from "../ecs/highlight/system/MeshHighlightSystem.js";
|
|
24
24
|
import LightSystem from "../ecs/light/LightSystem.js";
|
|
25
25
|
import { BehaviorSystem } from "../../intelligence/behavior/ecs/BehaviorSystem.js";
|
|
26
|
-
import { SerializationMetadataSystem } from "../../ecs/systems/SerializationMetadataSystem.js";
|
|
27
26
|
import { PathDisplaySystem } from "../ecs/path/PathDisplaySystem.js";
|
|
28
27
|
import { ParticleEmitterSystem } from "../particles/ecs/ParticleEmitterSystem.js";
|
|
29
28
|
import { ShadedGeometrySystem } from "../ecs/mesh-v2/ShadedGeometrySystem.js";
|
|
@@ -96,7 +95,6 @@ function makeConfig(engine) {
|
|
|
96
95
|
}),
|
|
97
96
|
headsUpDisplaySystem,
|
|
98
97
|
new BehaviorSystem(engine),
|
|
99
|
-
new SerializationMetadataSystem(),
|
|
100
98
|
new PathDisplaySystem(engine),
|
|
101
99
|
new ParticleEmitterSystem(engine),
|
|
102
100
|
new ShadedGeometrySystem(engine),
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TextureAtlas } from "./TextureAtlas.js";
|
|
2
|
+
import { CachingTextureAtlas } from "./CachingTextureAtlas.js";
|
|
3
|
+
import { Sampler2D } from "../sampler/Sampler2D.js";
|
|
4
|
+
|
|
5
|
+
test("constructor does not throw", () => {
|
|
6
|
+
|
|
7
|
+
const atlas = new TextureAtlas();
|
|
8
|
+
|
|
9
|
+
expect(() => new CachingTextureAtlas({ atlas })).not.toThrow();
|
|
10
|
+
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("add one", () => {
|
|
14
|
+
|
|
15
|
+
const atlas = new TextureAtlas();
|
|
16
|
+
const cached = new CachingTextureAtlas({ atlas });
|
|
17
|
+
|
|
18
|
+
const s = Sampler2D.uint8(4, 1, 1);
|
|
19
|
+
|
|
20
|
+
const patch = cached.add(s, 0);
|
|
21
|
+
|
|
22
|
+
expect(atlas.contains(patch)).toBe(true);
|
|
23
|
+
|
|
24
|
+
});
|
|
@@ -122,6 +122,52 @@ test("contains method works correctly", () => {
|
|
|
122
122
|
expect(atlas.contains(patch)).toBe(false);
|
|
123
123
|
});
|
|
124
124
|
|
|
125
|
+
test("remove method", () => {
|
|
126
|
+
|
|
127
|
+
const atlas = new TextureAtlas();
|
|
128
|
+
|
|
129
|
+
const s = Sampler2D.uint8(4, 1, 1);
|
|
130
|
+
|
|
131
|
+
s.writeChannel(0, 0, 0, 1);
|
|
132
|
+
s.writeChannel(0, 0, 1, 2);
|
|
133
|
+
s.writeChannel(0, 0, 2, 3);
|
|
134
|
+
s.writeChannel(0, 0, 3, 5);
|
|
135
|
+
|
|
136
|
+
const patch_a = atlas.add(s, 0);
|
|
137
|
+
|
|
138
|
+
expect(atlas.remove(patch_a)).toBe(true);
|
|
139
|
+
|
|
140
|
+
expect(atlas.remove(patch_a)).toBe(false);
|
|
141
|
+
|
|
142
|
+
// removed patch is erased
|
|
143
|
+
const patch_b = atlas.add(s, 0);
|
|
144
|
+
|
|
145
|
+
atlas.update();
|
|
146
|
+
|
|
147
|
+
atlas.remove(patch_b);
|
|
148
|
+
|
|
149
|
+
const p = patch_b.position;
|
|
150
|
+
|
|
151
|
+
expect(atlas.sampler.readChannel(p.x, p.y, 0)).toEqual(0);
|
|
152
|
+
expect(atlas.sampler.readChannel(p.x, p.y, 1)).toEqual(0);
|
|
153
|
+
expect(atlas.sampler.readChannel(p.x, p.y, 2)).toEqual(0);
|
|
154
|
+
expect(atlas.sampler.readChannel(p.x, p.y, 3)).toEqual(0);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("reset", () => {
|
|
158
|
+
const atlas = new TextureAtlas();
|
|
159
|
+
|
|
160
|
+
expect(() => atlas.reset()).not.toThrow();
|
|
161
|
+
|
|
162
|
+
const s = Sampler2D.uint8(4, 1, 1);
|
|
163
|
+
|
|
164
|
+
const patch = atlas.add(s, 0);
|
|
165
|
+
|
|
166
|
+
atlas.reset();
|
|
167
|
+
|
|
168
|
+
expect(atlas.contains(patch)).toBe(false);
|
|
169
|
+
});
|
|
170
|
+
|
|
125
171
|
/**
|
|
126
172
|
*
|
|
127
173
|
* @param {AtlasPatch} patch
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Created by Alex on 30/10/2014.
|
|
3
3
|
*/
|
|
4
4
|
import QuadTree from '../../../../core/geom/2d/quad-tree/PointQuadTree.js';
|
|
5
|
-
import AABB2 from '../../../../core/geom/AABB2.js';
|
|
5
|
+
import AABB2 from '../../../../core/geom/2d/aabb/AABB2.js';
|
|
6
6
|
import { seededRandom } from "../../../../core/math/random/seededRandom.js";
|
|
7
7
|
import { makeRangedRandom } from "../../../../core/math/random/makeRangedRandom.js";
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
compute_typed_array_constructor_from_data_type
|
|
16
16
|
} from "../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
|
|
17
17
|
import { Base64 } from "../../../../core/binary/Base64.js";
|
|
18
|
-
import { computeStridedIntegerArrayHash } from "
|
|
18
|
+
import { computeStridedIntegerArrayHash } from "../../../../core/primitives/array/computeStridedIntegerArrayHash.js";
|
|
19
19
|
import { is_typed_array_equals } from "../../../../core/collection/array/typed/is_typed_array_equals.js";
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -3,7 +3,7 @@ import { vector_nd_normalize } from "../../../../core/math/vector_nd_normalize.j
|
|
|
3
3
|
import { vector_nd_dot } from "../../../../core/math/vector_nd_dot.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* NOTE: treats samplers as normal maps
|
|
7
7
|
* @param {Sampler2D} sampler0
|
|
8
8
|
* @param {Sampler2D} sampler1
|
|
9
9
|
* @returns {Sampler2D}
|
package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js
CHANGED
|
@@ -8,7 +8,11 @@ import { BitSet } from "../../../../../core/binary/BitSet.js";
|
|
|
8
8
|
* @param {Sampler2D} destination
|
|
9
9
|
* @param {number} emptyValue
|
|
10
10
|
*/
|
|
11
|
-
export function computeSignedDistanceField_NaiveFlood(
|
|
11
|
+
export function computeSignedDistanceField_NaiveFlood(
|
|
12
|
+
source,
|
|
13
|
+
destination,
|
|
14
|
+
emptyValue
|
|
15
|
+
) {
|
|
12
16
|
assert.equal(source.itemSize, 1, `unsupported source.itemSize, expected 1, got '${source.itemSize}'`);
|
|
13
17
|
assert.typeOf(emptyValue, 'number', 'emptyValue');
|
|
14
18
|
|
package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.spec.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { Sampler2D } from "../Sampler2D.js";
|
|
2
|
+
import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
|
|
3
|
+
import { randomIntegerBetween } from "../../../../../core/math/random/randomIntegerBetween.js";
|
|
4
|
+
import { computeSignedDistanceField_NaiveFlood } from "./computeSignedDistanceField_NaiveFlood.js";
|
|
5
|
+
|
|
6
|
+
test('empty', () => {
|
|
7
|
+
const source = Sampler2D.uint8(1, 0, 0);
|
|
8
|
+
const target = Sampler2D.uint8(1, 0, 0);
|
|
9
|
+
|
|
10
|
+
computeSignedDistanceField_NaiveFlood(source, target, 0);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('1 pixel empty source', () => {
|
|
14
|
+
const source = Sampler2D.uint8(1, 1, 1);
|
|
15
|
+
const target = Sampler2D.uint8(1, 1, 1);
|
|
16
|
+
|
|
17
|
+
computeSignedDistanceField_NaiveFlood(source, target, 0);
|
|
18
|
+
|
|
19
|
+
expect(target.readChannel(0, 0, 0)).toBe(255);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('1 pixel filled source', () => {
|
|
23
|
+
const source = Sampler2D.uint8(1, 1, 1);
|
|
24
|
+
source.set(0, 0, [255]);
|
|
25
|
+
|
|
26
|
+
const target = Sampler2D.uint8(1, 1, 1);
|
|
27
|
+
|
|
28
|
+
computeSignedDistanceField_NaiveFlood(source, target, 0);
|
|
29
|
+
|
|
30
|
+
expect(target.readChannel(0, 0, 0)).toBe(0);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('3x3 pixel source with filled middle', () => {
|
|
34
|
+
const source = Sampler2D.uint8(1, 3, 3);
|
|
35
|
+
source.set(1, 1, [255]);
|
|
36
|
+
|
|
37
|
+
const target = Sampler2D.uint8(1, 3, 3);
|
|
38
|
+
|
|
39
|
+
computeSignedDistanceField_NaiveFlood(source, target, 0);
|
|
40
|
+
|
|
41
|
+
expect(target.readChannel(0, 0, 0)).toBe(1);
|
|
42
|
+
expect(target.readChannel(1, 0, 0)).toBe(1);
|
|
43
|
+
expect(target.readChannel(2, 0, 0)).toBe(1);
|
|
44
|
+
|
|
45
|
+
expect(target.readChannel(0, 1, 0)).toBe(1);
|
|
46
|
+
expect(target.readChannel(1, 1, 0)).toBe(0);
|
|
47
|
+
expect(target.readChannel(2, 1, 0)).toBe(1);
|
|
48
|
+
|
|
49
|
+
expect(target.readChannel(0, 2, 0)).toBe(1);
|
|
50
|
+
expect(target.readChannel(1, 2, 0)).toBe(1);
|
|
51
|
+
expect(target.readChannel(2, 2, 0)).toBe(1);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('3x3 pixel source with empty middle', () => {
|
|
55
|
+
const source = Sampler2D.uint8(1, 3, 3);
|
|
56
|
+
source.data.fill(255);
|
|
57
|
+
source.set(1, 1, [0]);
|
|
58
|
+
|
|
59
|
+
const target = Sampler2D.uint8(1, 3, 3);
|
|
60
|
+
|
|
61
|
+
computeSignedDistanceField_NaiveFlood(source, target, 0);
|
|
62
|
+
|
|
63
|
+
expect(target.readChannel(0, 0, 0)).toBe(0);
|
|
64
|
+
expect(target.readChannel(1, 0, 0)).toBe(0);
|
|
65
|
+
expect(target.readChannel(2, 0, 0)).toBe(0);
|
|
66
|
+
|
|
67
|
+
expect(target.readChannel(0, 1, 0)).toBe(0);
|
|
68
|
+
expect(target.readChannel(1, 1, 0)).toBe(1);
|
|
69
|
+
expect(target.readChannel(2, 1, 0)).toBe(0);
|
|
70
|
+
|
|
71
|
+
expect(target.readChannel(0, 2, 0)).toBe(0);
|
|
72
|
+
expect(target.readChannel(1, 2, 0)).toBe(0);
|
|
73
|
+
expect(target.readChannel(2, 2, 0)).toBe(0);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('3x3 pixel source with empty corners', () => {
|
|
77
|
+
const source = Sampler2D.uint8(1, 3, 3);
|
|
78
|
+
source.data.fill(255);
|
|
79
|
+
source.set(0, 0, [0]);
|
|
80
|
+
source.set(2, 0, [0]);
|
|
81
|
+
source.set(0, 2, [0]);
|
|
82
|
+
source.set(2, 2, [0]);
|
|
83
|
+
|
|
84
|
+
const target = Sampler2D.uint8(1, 3, 3);
|
|
85
|
+
|
|
86
|
+
computeSignedDistanceField_NaiveFlood(source, target, 0);
|
|
87
|
+
|
|
88
|
+
expect(target.readChannel(0, 0, 0)).toBe(1);
|
|
89
|
+
expect(target.readChannel(1, 0, 0)).toBe(0);
|
|
90
|
+
expect(target.readChannel(2, 0, 0)).toBe(1);
|
|
91
|
+
|
|
92
|
+
expect(target.readChannel(0, 1, 0)).toBe(0);
|
|
93
|
+
expect(target.readChannel(1, 1, 0)).toBe(0);
|
|
94
|
+
expect(target.readChannel(2, 1, 0)).toBe(0);
|
|
95
|
+
|
|
96
|
+
expect(target.readChannel(0, 2, 0)).toBe(1);
|
|
97
|
+
expect(target.readChannel(1, 2, 0)).toBe(0);
|
|
98
|
+
expect(target.readChannel(2, 2, 0)).toBe(1);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('3x3 pixel source with filled corners', () => {
|
|
102
|
+
const source = Sampler2D.uint8(1, 3, 3);
|
|
103
|
+
source.data.fill(0);
|
|
104
|
+
source.set(0, 0, [255]);
|
|
105
|
+
source.set(2, 0, [255]);
|
|
106
|
+
source.set(0, 2, [255]);
|
|
107
|
+
source.set(2, 2, [255]);
|
|
108
|
+
|
|
109
|
+
const target = Sampler2D.uint8(1, 3, 3);
|
|
110
|
+
|
|
111
|
+
computeSignedDistanceField_NaiveFlood(source, target, 0);
|
|
112
|
+
|
|
113
|
+
expect(target.readChannel(0, 0, 0)).toBe(0);
|
|
114
|
+
expect(target.readChannel(1, 0, 0)).toBe(1);
|
|
115
|
+
expect(target.readChannel(2, 0, 0)).toBe(0);
|
|
116
|
+
|
|
117
|
+
expect(target.readChannel(0, 1, 0)).toBe(1);
|
|
118
|
+
expect(target.readChannel(1, 1, 0)).toBe(1);
|
|
119
|
+
expect(target.readChannel(2, 1, 0)).toBe(1);
|
|
120
|
+
|
|
121
|
+
expect(target.readChannel(0, 2, 0)).toBe(0);
|
|
122
|
+
expect(target.readChannel(1, 2, 0)).toBe(1);
|
|
123
|
+
expect(target.readChannel(2, 2, 0)).toBe(0);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('3x1 pixel source with 1 filled corner', () => {
|
|
127
|
+
const source = Sampler2D.uint8(1, 3, 1);
|
|
128
|
+
source.data.fill(0);
|
|
129
|
+
source.set(0, 0, [255]);
|
|
130
|
+
|
|
131
|
+
const target = Sampler2D.uint8(1, 3, 1);
|
|
132
|
+
|
|
133
|
+
computeSignedDistanceField_NaiveFlood(source, target, 0);
|
|
134
|
+
|
|
135
|
+
expect(target.readChannel(0, 0, 0)).toBe(0);
|
|
136
|
+
expect(target.readChannel(1, 0, 0)).toBe(1);
|
|
137
|
+
expect(target.readChannel(2, 0, 0)).toBe(2);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('3x3 pixel source with 1 filled corner', () => {
|
|
141
|
+
const source = Sampler2D.uint8(1, 3, 3);
|
|
142
|
+
source.data.fill(0);
|
|
143
|
+
source.set(0, 0, [255]);
|
|
144
|
+
|
|
145
|
+
const target = Sampler2D.uint8(1, 3, 3);
|
|
146
|
+
|
|
147
|
+
computeSignedDistanceField_NaiveFlood(source, target, 0);
|
|
148
|
+
|
|
149
|
+
expect(target.readChannel(0, 0, 0)).toBe(0);
|
|
150
|
+
expect(target.readChannel(1, 0, 0)).toBe(1);
|
|
151
|
+
expect(target.readChannel(2, 0, 0)).toBe(2);
|
|
152
|
+
|
|
153
|
+
expect(target.readChannel(0, 1, 0)).toBe(1);
|
|
154
|
+
expect(target.readChannel(1, 1, 0)).toBe(1);
|
|
155
|
+
expect(target.readChannel(2, 1, 0)).toBe(2);
|
|
156
|
+
|
|
157
|
+
expect(target.readChannel(0, 2, 0)).toBe(2);
|
|
158
|
+
expect(target.readChannel(1, 2, 0)).toBe(2);
|
|
159
|
+
expect(target.readChannel(2, 2, 0)).toBe(2);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test.skip('performance', () => {
|
|
163
|
+
|
|
164
|
+
const sizeX = 100;
|
|
165
|
+
const sizeY = 100;
|
|
166
|
+
|
|
167
|
+
const source = Sampler2D.uint8(1, sizeX, sizeY);
|
|
168
|
+
|
|
169
|
+
const random = seededRandom(42);
|
|
170
|
+
source.data.fill(0);
|
|
171
|
+
for (let i = 0; i < source.data.length * 0.1; i++) {
|
|
172
|
+
const x = randomIntegerBetween(random, 0, sizeX);
|
|
173
|
+
const y = randomIntegerBetween(random, 0, sizeY);
|
|
174
|
+
source.set(x, y, [255]);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const target = Sampler2D.uint8(1, sizeX, sizeY);
|
|
178
|
+
|
|
179
|
+
console.time('p');
|
|
180
|
+
computeSignedDistanceField_NaiveFlood(source, target, 0);
|
|
181
|
+
console.timeEnd('p');
|
|
182
|
+
|
|
183
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function filter_lanczos3(x) {
|
|
2
|
+
// assume the input is positive
|
|
3
|
+
|
|
4
|
+
// if (x < 0) {
|
|
5
|
+
// x = -x;
|
|
6
|
+
// }
|
|
7
|
+
|
|
8
|
+
if (x > 3) {
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (x < 1.1920929e-7) {
|
|
13
|
+
return 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (3 * Math.sin(Math.PI * x) * Math.sin(Math.PI * x / 3)) / (Math.PI * Math.PI * x * x);
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
filter_lanczos3.support = 3;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { assert } from "../../../../../core/assert.js";
|
|
2
|
-
|
|
3
1
|
const b = 1.0 / 3.0;
|
|
4
2
|
const c = 1.0 / 3.0;
|
|
5
3
|
|
|
@@ -38,22 +36,3 @@ export function mitchell(x) {
|
|
|
38
36
|
|
|
39
37
|
mitchell.support = 2;
|
|
40
38
|
|
|
41
|
-
/**
|
|
42
|
-
* Hand-optimized mitchell function with c = 0.3333333 and b = 0.3333333
|
|
43
|
-
* NOTE: assumes non-negative values only
|
|
44
|
-
* @param {number} x
|
|
45
|
-
* @returns {number}
|
|
46
|
-
*/
|
|
47
|
-
export function mitchell_v1(x) {
|
|
48
|
-
assert.greaterThanOrEqual(x, 0);
|
|
49
|
-
|
|
50
|
-
if (x < 1.0) {
|
|
51
|
-
return 0.8888888888888888 + x * x * (-2 + x * 1.1666666666666667);
|
|
52
|
-
}
|
|
53
|
-
if (x < 2.0) {
|
|
54
|
-
return 1.7777777777777777 + x * (-3.3333333333333335 + x * (2 + x * -0.3888888888888889));
|
|
55
|
-
}
|
|
56
|
-
return 0.0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
mitchell_v1.support = 2;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { assert } from "../../../../../core/assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hand-optimized mitchell function with c = 0.3333333 and b = 0.3333333
|
|
5
|
+
* NOTE: assumes non-negative values only
|
|
6
|
+
* @param {number} x
|
|
7
|
+
* @returns {number}
|
|
8
|
+
*/
|
|
9
|
+
export function mitchell_v1(x) {
|
|
10
|
+
assert.greaterThanOrEqual(x, 0);
|
|
11
|
+
|
|
12
|
+
if (x < 1.0) {
|
|
13
|
+
return 0.8888888888888888 + x * x * (-2 + x * 1.1666666666666667);
|
|
14
|
+
}
|
|
15
|
+
if (x < 2.0) {
|
|
16
|
+
return 1.7777777777777777 + x * (-3.3333333333333335 + x * (2 + x * -0.3888888888888889));
|
|
17
|
+
}
|
|
18
|
+
return 0.0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
mitchell_v1.support = 2;
|