@woosh/meep-engine 2.50.3 → 2.51.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/UUID.spec.js +8 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.d.ts +4 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +57 -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/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/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/engine/{Platform.js → browserInfo.js} +1 -5
- package/src/engine/ecs/fow/FogOfWar.js +48 -54
- 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/systems/MeshColliderSystem.js +1 -1
- package/src/engine/ecs/systems/RangedAttackSystem.js +1 -1
- package/src/engine/ecs/systems/ViewportMeshProjectionSystem.js +1 -1
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +2 -2
- 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/graphics/copy_transform_to_threejs_object.js +12 -0
- package/src/engine/graphics/debug/VisualSymbolLine.js +1 -1
- package/src/engine/graphics/ecs/decal/DecalSystem.js +1 -1
- 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/path/ribbon/RibbonPathBuilder.js +2 -2
- package/src/engine/graphics/geometry/optimization/merge/prototypeGeometryMerge.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -2
- package/src/engine/graphics/shaders/SoftOutlineShader.js +2 -4
- 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/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 +66 -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/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/sound/ecs/SoundListenerSystem.js +1 -1
- package/src/generation/markers/debug/visualizeMarkers.js +1 -1
- 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/Renderable.d.ts +0 -14
- 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/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/navigation/grid/GridField.js +0 -328
- /package/src/engine/ecs/{components → renderable}/RenderableFlags.js +0 -0
|
@@ -4,7 +4,7 @@ import { max2 } from "../../../../../core/math/max2.js";
|
|
|
4
4
|
import { min2 } from "../../../../../core/math/min2.js";
|
|
5
5
|
import { Sampler2D } from "../../../../graphics/texture/sampler/Sampler2D.js";
|
|
6
6
|
import { assert } from "../../../../../core/assert.js";
|
|
7
|
-
import {
|
|
7
|
+
import { sampler2d_scale } from "../../../../graphics/texture/sampler/resize/sampler2d_scale.js";
|
|
8
8
|
import { array_copy } from "../../../../../core/collection/array/array_copy.js";
|
|
9
9
|
import { typed_array_copy } from "../../../../../core/collection/array/typed/typed_array_copy.js";
|
|
10
10
|
import { Base64 } from "../../../../../core/binary/Base64.js";
|
|
@@ -520,7 +520,7 @@ export class SplatMapping {
|
|
|
520
520
|
const source = new Sampler2D(oldWeightData.subarray(d * oldLayerSize, (d + 1) * oldLayerSize), 1, oldWidth, oldHeight);
|
|
521
521
|
const target = new Sampler2D(weightImage.data.subarray(d * newLayerSize, (d + 1) * newLayerSize), 1, width, height);
|
|
522
522
|
|
|
523
|
-
|
|
523
|
+
sampler2d_scale(source, target);
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
526
|
|
|
@@ -11,7 +11,7 @@ import { assert } from "../../../../core/assert.js";
|
|
|
11
11
|
import ObservedString from "../../../../core/model/ObservedString.js";
|
|
12
12
|
import { ClampToEdgeWrapping, DataTexture, NearestFilter } from "three";
|
|
13
13
|
import { Sampler2D } from "../../../graphics/texture/sampler/Sampler2D.js";
|
|
14
|
-
import {
|
|
14
|
+
import { sampler2d_scale } from "../../../graphics/texture/sampler/resize/sampler2d_scale.js";
|
|
15
15
|
import { uint82float } from "../../../../core/binary/uint82float.js";
|
|
16
16
|
import { float2uint8 } from "../../../../core/binary/float2uint8.js";
|
|
17
17
|
import { isTypedArray } from "../../../../core/collection/array/typed/isTypedArray.js";
|
|
@@ -314,7 +314,7 @@ export class TerrainOverlay {
|
|
|
314
314
|
|
|
315
315
|
// rescale source if needed
|
|
316
316
|
const scaled_source = Sampler2D.uint8(4, dWidth, dHeight);
|
|
317
|
-
|
|
317
|
+
sampler2d_scale(source, scaled_source);
|
|
318
318
|
|
|
319
319
|
this.sampler.paint(scaled_source, 0, 0, dx, dy, dWidth, dHeight);
|
|
320
320
|
|
|
@@ -2,7 +2,7 @@ import { Sampler2D } from "../../../graphics/texture/sampler/Sampler2D.js";
|
|
|
2
2
|
import { ParameterLookupTable } from "../../../graphics/particles/particular/engine/parameter/ParameterLookupTable.js";
|
|
3
3
|
import { passThrough } from "../../../../core/function/Functions.js";
|
|
4
4
|
import { clamp01 } from "../../../../core/math/clamp01.js";
|
|
5
|
-
import {
|
|
5
|
+
import { sampler2d_scale } from "../../../graphics/texture/sampler/resize/sampler2d_scale.js";
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
const heatmap_lut = new ParameterLookupTable(4);
|
|
@@ -43,7 +43,7 @@ export function paintTerrainOverlayViaLookupTable({
|
|
|
43
43
|
// rescale source
|
|
44
44
|
const scaled_sampler = sampler.clone();
|
|
45
45
|
scaled_sampler.resize(w, h);
|
|
46
|
-
|
|
46
|
+
sampler2d_scale(sampler, scaled_sampler);
|
|
47
47
|
|
|
48
48
|
for (j = 0; j < h; j++) {
|
|
49
49
|
|
|
@@ -5,7 +5,7 @@ import { System } from '../../../ecs/System.js';
|
|
|
5
5
|
import { Euler as ThreeEuler, MaterialLoader, Mesh as ThreeMesh, Vector3 as ThreeVector3 } from 'three';
|
|
6
6
|
import { Transform } from '../../../ecs/transform/Transform.js';
|
|
7
7
|
import Mesh from '../mesh/Mesh.js';
|
|
8
|
-
import Renderable from '../../../ecs/
|
|
8
|
+
import Renderable from '../../../ecs/renderable/Renderable.js';
|
|
9
9
|
import LoadMaterial from "../../material/LoadMaterial.js";
|
|
10
10
|
|
|
11
11
|
import Decal from "./Decal.js";
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import LineBuilder from "../../../../../core/codegen/LineBuilder.js";
|
|
2
|
-
|
|
3
|
-
function gaussian(s, v) {
|
|
4
|
-
return Math.exp(-(v * v) / (2.0 * s * s));
|
|
5
|
-
}
|
|
2
|
+
import { gaussian } from "../../../../../core/math/gaussian.js";
|
|
6
3
|
|
|
7
4
|
/**
|
|
8
5
|
* Pre-build kernel internally, no branches in convolution code, everything is inlined
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {System} from "../../../../ecs/System";
|
|
2
2
|
import Engine from "../../../../Engine";
|
|
3
3
|
import Highlight from "../Highlight";
|
|
4
|
-
import Renderable from "../../../../ecs/
|
|
4
|
+
import Renderable from "../../../../ecs/renderable/Renderable";
|
|
5
5
|
|
|
6
6
|
export class RenderableHighlightSystem extends System<Highlight, Renderable> {
|
|
7
7
|
constructor(engine: Engine)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { System } from "../../../../ecs/System.js";
|
|
2
2
|
import { HighlightRenderElementSource } from "../plugin/HighlightRenderElementSource.js";
|
|
3
|
-
import Renderable from "../../../../ecs/
|
|
4
|
-
import { RenderableFlags } from "../../../../ecs/
|
|
3
|
+
import Renderable from "../../../../ecs/renderable/Renderable.js";
|
|
4
|
+
import { RenderableFlags } from "../../../../ecs/renderable/RenderableFlags.js";
|
|
5
5
|
import Highlight from "../Highlight.js";
|
|
6
6
|
import { OutlineRenderPlugin } from "../plugin/OutlineRenderPlugin.js";
|
|
7
7
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { rootObject3DFastMatrixUpdate } from "./rootObject3DFastMatrixUpdate.js";
|
|
2
|
+
import { copy_transform_to_threejs_object } from "../../copy_transform_to_threejs_object.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
@@ -6,11 +7,7 @@ import { rootObject3DFastMatrixUpdate } from "./rootObject3DFastMatrixUpdate.js"
|
|
|
6
7
|
* @param {Transform} t
|
|
7
8
|
*/
|
|
8
9
|
export function applyTransformToThreeObject(m, t) {
|
|
9
|
-
m
|
|
10
|
-
|
|
11
|
-
t.rotation.toEulerAnglesXYZ(m.rotation);
|
|
12
|
-
|
|
13
|
-
m.scale.copy(t.scale);
|
|
10
|
+
copy_transform_to_threejs_object(m, t);
|
|
14
11
|
|
|
15
12
|
rootObject3DFastMatrixUpdate(m);
|
|
16
13
|
}
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
RIBBON_ATTRIBUTE_ADDRESS_UV_OFFSET
|
|
5
5
|
} from "../../../trail/x/ribbon_attributes_spec.js";
|
|
6
6
|
import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
7
|
-
import Renderable from "../../../../ecs/
|
|
8
|
-
import { RenderableFlags } from "../../../../ecs/
|
|
7
|
+
import Renderable from "../../../../ecs/renderable/Renderable.js";
|
|
8
|
+
import { RenderableFlags } from "../../../../ecs/renderable/RenderableFlags.js";
|
|
9
9
|
import { Transform } from "../../../../ecs/transform/Transform.js";
|
|
10
10
|
import EntityBuilder from "../../../../ecs/EntityBuilder.js";
|
|
11
11
|
import ThreeFactory from "../../../three/ThreeFactory.js";
|
|
@@ -8,7 +8,7 @@ import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
|
8
8
|
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
9
9
|
import { GLTFAssetLoader } from "../../../../asset/loaders/GLTFAssetLoader.js";
|
|
10
10
|
import EntityBuilder from "../../../../ecs/EntityBuilder.js";
|
|
11
|
-
import Renderable from "../../../../ecs/
|
|
11
|
+
import Renderable from "../../../../ecs/renderable/Renderable.js";
|
|
12
12
|
import { Transform } from "../../../../ecs/transform/Transform.js";
|
|
13
13
|
import { merge_geometry_hierarchy } from "./merge_geometry_hierarchy.js";
|
|
14
14
|
import {
|
package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js
CHANGED
|
@@ -65,7 +65,7 @@ import { ShadedGeometry } from "../../../../../ecs/mesh-v2/ShadedGeometry.js";
|
|
|
65
65
|
import { DrawMode } from "../../../../../ecs/mesh-v2/DrawMode.js";
|
|
66
66
|
import { makeHelperBoxGeometry } from "../../../../../../../../editor/process/symbolic/makeHelperBoxGeometry.js";
|
|
67
67
|
import { LineBasicMaterial } from "three";
|
|
68
|
-
import Renderable from "../../../../../../ecs/
|
|
68
|
+
import Renderable from "../../../../../../ecs/renderable/Renderable.js";
|
|
69
69
|
import { TransformControls } from "three/examples/jsm/controls/TransformControls.js";
|
|
70
70
|
import { threeUpdateTransform } from "../../../../../util/threeUpdateTransform.js";
|
|
71
71
|
import InputController from "../../../../../../input/ecs/components/InputController.js";
|
|
@@ -65,7 +65,7 @@ import { BehaviorComponent } from "../../../../intelligence/behavior/ecs/Behavio
|
|
|
65
65
|
import { Light } from "../../../ecs/light/Light.js";
|
|
66
66
|
import { LightType } from "../../../ecs/light/LightType.js";
|
|
67
67
|
import { parseColor } from "../../../../../core/color/parseColor.js";
|
|
68
|
-
import Renderable from "../../../../ecs/
|
|
68
|
+
import Renderable from "../../../../ecs/renderable/Renderable.js";
|
|
69
69
|
import { makeHelperSphereGeometry } from "../../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
|
|
70
70
|
import TopDownCameraController from "../../../ecs/camera/topdown/TopDownCameraController.js";
|
|
71
71
|
import ThreeFactory from "../../../three/ThreeFactory.js";
|
|
@@ -18,7 +18,7 @@ import { float2uint8 } from "../../../../core/binary/float2uint8.js";
|
|
|
18
18
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
19
19
|
import { Camera } from "../../ecs/camera/Camera.js";
|
|
20
20
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
21
|
-
import {
|
|
21
|
+
import { sampler2d_scale } from "../../texture/sampler/resize/sampler2d_scale.js";
|
|
22
22
|
import { seededRandom } from "../../../../core/math/random/seededRandom.js";
|
|
23
23
|
import { mat4, vec3 } from "gl-matrix";
|
|
24
24
|
import { v3_distance } from "../../../../core/geom/v3_distance.js";
|
|
@@ -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;
|
|
@@ -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
|
|
|
@@ -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;
|