@woosh/meep-engine 2.37.18 → 2.38.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/core/assert.js +1 -1
- package/core/binary/float2uint8.js +8 -0
- package/core/binary/uint82float.js +8 -0
- package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +6 -4
- package/core/collection/array/array_get_index_in_range.js +16 -0
- package/core/collection/array/typed/isTypedArray.js +20 -0
- package/core/collection/array/typedArrayToDataType.js +1 -0
- package/{engine/navigation/grid → core/collection/heap}/BinaryHeap.js +6 -1
- package/{engine/navigation/grid → core/collection/heap}/FastBinaryHeap.js +3 -2
- package/{engine/navigation/grid → core/collection/heap}/FastBinaryHeap.spec.js +3 -3
- package/core/collection/heap/Uin32Heap.spec.js +59 -0
- package/core/collection/heap/Uint32Heap.js +385 -0
- package/core/collection/list/List.d.ts +1 -1
- package/core/collection/table/RowFirstTable.js +34 -0
- package/core/collection/table/RowFirstTable.spec.js +59 -1
- package/core/color/Color.js +83 -1
- package/core/color/YCbCr_to_rgb_uint24.js +3 -4
- package/core/color/hsv2rgb.js +4 -3
- package/core/color/linear_to_sRGB.js +4 -5
- package/core/color/rgb2hex.js +1 -1
- package/core/color/rgb2uint24.js +6 -4
- package/core/color/rgb_to_YCbCr_uint24.js +11 -13
- package/core/events/signal/Signal.d.ts +11 -9
- package/core/events/signal/Signal.spec.js +16 -0
- package/core/geom/2d/quad-tree/qt_collect_by_circle.js +67 -0
- package/core/geom/3d/topology/computeTopoMeshVertexDuplicates.js +9 -6
- package/core/geom/3d/topology/expandConnectivityByLocality.js +5 -5
- package/core/geom/3d/topology/query/query_edge_is_boundary.js +7 -0
- package/core/geom/3d/topology/query/query_edge_is_manifold.js +13 -0
- package/core/geom/3d/topology/query/query_edge_is_manifold_or_boundary.js +11 -0
- package/core/geom/3d/topology/query/query_edge_is_wire.js +13 -0
- package/core/geom/3d/topology/query/query_edge_other_vertex.js +20 -0
- package/core/geom/3d/topology/query/query_edge_share_vert.js +9 -0
- package/core/geom/3d/topology/query/query_face_get_other_edges.js +39 -0
- package/core/geom/3d/topology/query/query_face_next_vertex.js +19 -0
- package/core/geom/3d/topology/query/query_face_prev_vertex.js +18 -0
- package/core/geom/3d/topology/query/query_vertex_in_edge.js +14 -0
- package/core/geom/3d/topology/query/query_vertex_pair_share_face.js +24 -0
- package/core/geom/3d/topology/query/query_vertices_in_edge.js +19 -0
- package/core/geom/3d/topology/simplify/collapseEdge.spec.js +3 -5
- package/core/geom/3d/topology/simplify/collapse_all_degenerate_edges.js +8 -10
- package/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +12 -2
- package/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.js +277 -0
- package/core/geom/3d/topology/simplify/edge_collapse_quadratic.js +126 -0
- package/core/geom/3d/topology/simplify/prototypeMeshSimplification.js +502 -0
- package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +37 -5
- package/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js +86 -1
- package/core/geom/3d/topology/simplify/simplifyTopoMesh.js +4 -4
- package/core/geom/3d/topology/simplify/simplifyTopoMesh2.js +119 -0
- package/core/geom/3d/topology/simplify/tm_edge_collapse_is_degenerate_flip.js +81 -0
- package/core/geom/3d/topology/{TopoEdge.js → struct/TopoEdge.js} +47 -20
- package/core/geom/3d/topology/{TopoEdge.spec.js → struct/TopoEdge.spec.js} +0 -0
- package/core/geom/3d/topology/{TopoMesh.js → struct/TopoMesh.js} +20 -41
- package/core/geom/3d/topology/{TopoTriangle.js → struct/TopoTriangle.js} +15 -25
- package/core/geom/3d/topology/{TopoVertex.js → struct/TopoVertex.js} +21 -4
- package/core/geom/3d/topology/{TopoVertex.spec.js → struct/TopoVertex.spec.js} +0 -0
- package/core/geom/3d/topology/tm_edge_kill.js +24 -0
- package/core/geom/3d/topology/tm_edge_splice.js +42 -0
- package/core/geom/3d/topology/tm_face_area.js +18 -0
- package/core/geom/3d/topology/tm_face_kill.js +12 -0
- package/core/geom/3d/topology/tm_face_normal.js +14 -0
- package/core/geom/3d/topology/tm_kill_only_edge.js +35 -0
- package/core/geom/3d/topology/tm_kill_only_face.js +12 -0
- package/core/geom/3d/topology/tm_kill_only_vert.js +14 -0
- package/core/geom/3d/topology/tm_vert_kill.js +19 -0
- package/core/geom/3d/topology/tm_vert_splice.js +64 -0
- package/core/geom/3d/topology/tm_vertex_compute_normal.js +42 -0
- package/core/geom/3d/topology/topoMeshToBufferGeometry.js +18 -4
- package/core/geom/3d/topology/weld_duplicate_vertices.js +63 -0
- package/core/geom/Quaternion.d.ts +21 -1
- package/core/geom/Quaternion.js +279 -200
- package/core/geom/Quaternion.spec.js +71 -2
- package/core/geom/Vector2.js +3 -3
- package/core/geom/Vector3.d.ts +2 -0
- package/core/geom/Vector3.js +31 -7
- package/core/geom/Vector3.schema.json +16 -0
- package/core/geom/Vector4.js +16 -0
- package/core/geom/packing/MaxRectangles.js +1 -1
- package/core/graph/cluster_mesh_metis.js +16 -0
- package/core/graph/coarsen_graph.js +1 -1
- package/core/graph/graph_k_means_cluster.js +1 -1
- package/core/json/JsonUtils.js +2 -20
- package/core/math/bell_membership_function.js +19 -0
- package/core/math/exp2.js +8 -0
- package/core/math/interval/NumericInterval.js +17 -0
- package/core/math/physics/brdf/brdf_burley.js +25 -0
- package/core/math/physics/bsdf/bsdf_schlick.js +22 -0
- package/core/math/physics/irradiance/interpolate_irradiance_linear.js +18 -0
- package/{engine/sound/ecs/emitter/attenuate/attenuateSoundLogarithmic.js → core/math/physics/irradiance/interpolate_irradiance_lograrithmic.js} +2 -2
- package/{engine/sound/ecs/emitter/attenuate/attenuateSoundSmith.js → core/math/physics/irradiance/interpolate_irradiance_smith.js} +1 -1
- package/core/math/random/seededRandom.js +2 -31
- package/core/math/random/seededRandom_Mulberry32.js +31 -0
- package/core/math/random/seededRandom_sine.js +33 -0
- package/core/model/ObservedEnum.js +8 -0
- package/editor/Editor.js +97 -1
- package/editor/actions/concrete/ModifyPatchSampler2DAction.js +118 -0
- package/editor/actions/concrete/ModifyPatchSampler2DAction.spec.js +30 -0
- package/editor/actions/concrete/PatchTerrainHeightAction.js +13 -105
- package/editor/ecs/component/FieldDescriptor.js +34 -0
- package/editor/ecs/component/FieldValueAdapter.js +20 -0
- package/editor/ecs/component/TypeEditor.js +33 -0
- package/editor/ecs/component/TypeSchema.d.ts +38 -0
- package/editor/ecs/component/createFieldEditor.js +90 -0
- package/editor/ecs/component/createObjectEditor.js +266 -60
- package/editor/ecs/component/editors/ColorEditor.js +39 -0
- package/editor/ecs/component/editors/HTMLElementEditor.js +17 -0
- package/editor/ecs/component/editors/ImagePathEditor.js +50 -0
- package/editor/ecs/component/editors/NumericIntervalEditor.js +86 -0
- package/editor/ecs/component/editors/ObservedBooleanEditor.js +13 -0
- package/editor/ecs/component/editors/ObservedEnumEditor.js +32 -0
- package/editor/ecs/component/editors/ObservedIntegerEditor.js +43 -0
- package/editor/ecs/component/editors/ObservedStringEditor.js +51 -0
- package/editor/ecs/component/editors/Sampler2DEditor.js +107 -0
- package/editor/ecs/component/editors/collection/ListEditor.js +83 -0
- package/editor/ecs/component/editors/common/BitFlagsEditor.js +80 -0
- package/editor/ecs/component/editors/common/EnumEditor.js +41 -0
- package/editor/ecs/component/editors/common/makeV3_editor.js +85 -0
- package/editor/ecs/component/editors/common/noEditor.js +9 -0
- package/editor/ecs/component/editors/ecs/GridObstacleEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.js +16 -0
- package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +44 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +54 -0
- package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/Trail2DEditor.js +33 -0
- package/editor/ecs/component/editors/ecs/TransformEditor.js +23 -0
- package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +89 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.js +18 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.js +22 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.js +20 -0
- package/editor/ecs/component/editors/geom/QuaternionEditor.js +56 -0
- package/editor/ecs/component/editors/geom/Vector1Editor.js +57 -0
- package/editor/ecs/component/editors/geom/Vector2Editor.js +11 -0
- package/editor/ecs/component/editors/geom/Vector3Editor.js +13 -0
- package/editor/ecs/component/editors/geom/Vector4Editor.js +12 -0
- package/editor/ecs/component/editors/primitive/ArrayEditor.js +46 -0
- package/editor/ecs/component/editors/primitive/BooleanEditor.js +27 -0
- package/editor/ecs/component/editors/primitive/FunctionEditor.js +29 -0
- package/editor/ecs/component/editors/primitive/NumberEditor.js +60 -0
- package/editor/ecs/component/editors/primitive/ObjectEditor.js +12 -0
- package/editor/ecs/component/editors/primitive/StringEditor.js +31 -0
- package/editor/ecs/component/editors/three/BufferGeometryEditor.js +28 -0
- package/editor/ecs/component/editors/three/MaterialEditor.js +27 -0
- package/editor/ecs/component/editors/three/MeshEditor.js +35 -0
- package/editor/ecs/component/editors/three/TextureEditor.js +32 -0
- package/editor/ecs/component/findNearestRegisteredType.js +59 -0
- package/editor/ecs/component/prototypeObjectEditor.js +379 -0
- package/editor/tools/SelectionTool.js +1 -1
- package/editor/tools/paint/TerrainHeightPaintTool.js +88 -68
- package/editor/tools/paint/TerrainPaintTool.js +2 -1
- package/editor/tools/paint/TerrainTexturePaintTool.js +8 -73
- package/editor/view/EditorView.js +1 -1
- package/editor/view/ecs/ComponentControlView.js +2 -30
- package/editor/view/ecs/EntityEditor.js +61 -139
- package/editor/view/ecs/components/GridObstacleController.js +4 -4
- package/editor/view/ecs/components/TerrainController.js +1 -1
- package/editor/view/ecs/components/common/NumberController.js +19 -7
- package/editor/view/node-graph/NodeGraphView.js +2 -2
- package/editor/view/node-graph/NodeView.js +7 -9
- package/engine/animation/keyed2/AnimationTrack.js +1 -1
- package/engine/asset/AssetManager.d.ts +1 -1
- package/engine/asset/AssetManager.js +390 -388
- package/engine/asset/loaders/gltf/extensions/MSFT_texture_dds.js +14 -2
- package/engine/ecs/components/TagEditor.js +15 -0
- package/engine/ecs/fow/FogOfWarEditor.js +13 -0
- package/engine/ecs/parent/ParentEntitySystem.js +57 -0
- package/engine/ecs/terrain/ecs/OffsetScaleTransform2D.d.ts +6 -0
- package/engine/ecs/terrain/ecs/Terrain.js +44 -43
- package/engine/ecs/terrain/ecs/TerrainSystem.js +2 -2
- package/engine/ecs/terrain/ecs/layers/TerrainLayer.js +1 -1
- package/engine/ecs/terrain/ecs/splat/SplatMapping.js +26 -28
- package/engine/ecs/terrain/overlay/TerrainOverlay.js +71 -66
- package/engine/ecs/terrain/tiles/TerrainTileManager.js +23 -0
- package/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +1 -1
- package/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +13 -7
- package/engine/ecs/terrain/util/tensionOptimizeUV.js +1 -1
- package/engine/ecs/transform/Transform.d.ts +2 -0
- package/engine/ecs/transform/Transform.editor.schema.json +16 -0
- package/engine/ecs/transform/Transform.js +3 -0
- package/engine/graphics/ecs/highlight/HighlightEditor.js +17 -0
- package/engine/graphics/ecs/light/Light.js +0 -47
- package/engine/graphics/ecs/light/LightSerializationAdapter.js +50 -0
- package/engine/graphics/ecs/mesh/MeshEditor.js +28 -0
- package/engine/graphics/ecs/mesh-v2/DrawMode.js +2 -1
- package/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +3 -3
- package/engine/graphics/ecs/mesh-v2/build_three_object.js +3 -1
- package/engine/graphics/ecs/mesh-v2/sg_compute_hierarchy_bounding_box_by_parent_entity.js +31 -0
- package/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.d.ts +4 -0
- package/engine/graphics/ecs/sprite/Sprite.js +11 -0
- package/engine/graphics/ecs/sprite/SpriteSystemPE.js +133 -0
- package/engine/graphics/ecs/sprite/prototypeSpriteSystem.js +1570 -0
- package/engine/graphics/micron/build/PatchRepresentation.js +7 -3
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +18 -8
- package/engine/graphics/micron/build/clustering/build_clustering_2.js +1 -1
- package/engine/graphics/micron/build/clustering/build_leaf_patches.js +2 -2
- package/engine/graphics/micron/build/clustering/build_leaf_patches_metis.js +1 -1
- package/engine/graphics/micron/build/hierarchy/buildAbstractPatchHierarchy.js +21 -3
- package/engine/graphics/micron/build/hierarchy/merge_patches.js +96 -43
- package/engine/graphics/micron/build/hierarchy/qvdr_build_simplified_clusters.js +11 -5
- package/engine/graphics/micron/format/VirtualGeometry.js +46 -3
- package/engine/graphics/micron/format/micron_build_proxy_geometry.js +4 -2
- package/engine/graphics/micron/prototypeVirtualGeometry.js +47 -10
- package/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +17 -17
- package/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +15 -3
- package/engine/graphics/micron/simplifyGeometry.js +1 -1
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +5 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +17 -9
- package/engine/graphics/particles/particular/engine/renderers/ParticleRenderer.js +12 -10
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +7 -2
- package/engine/graphics/particles/particular/engine/renderers/billboard/SoftBillboardParticlePool.js +27 -0
- package/engine/graphics/particles/particular/engine/renderers/billboard/SoftBillboardParticleRenderer.js +80 -0
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +16 -4
- package/engine/graphics/shaders/TerrainShader.js +8 -8
- package/engine/graphics/texture/atlas/TextureAtlasDebugger.js +2 -1
- package/engine/graphics/texture/sampler/Sampler2D.js +206 -201
- package/engine/graphics/texture/sampler/Sampler2D.spec.js +34 -35
- package/engine/graphics/texture/sampler/bicubic.js +59 -0
- package/engine/graphics/texture/sampler/downsampleSample2D.spec.js +2 -2
- package/engine/graphics/texture/sampler/genericResampleSampler2D.js +0 -2
- package/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +146 -0
- package/engine/graphics/texture/sampler/{downsampleSampler2D.js → sampler2D_scale_down_linear.js} +8 -4
- package/engine/graphics/texture/sampler/sampler2_d_scale_down_lanczos.js +140 -0
- package/engine/graphics/texture/sampler/scaleSampler2D.js +3 -3
- package/engine/graphics/texture/sampler/writeSampler2DDataToDataTexture.js +1 -1
- package/engine/graphics/util/ScaleObject3ToBox.js +14 -1
- package/engine/graphics/util/makeMeshPreviewScene.js +2 -1
- package/engine/grid/components/GridObstacle.js +0 -44
- package/engine/grid/components/GridObstacleSerializationAdapter.js +46 -0
- package/engine/input/devices/PointerDevice.d.ts +1 -1
- package/engine/input/devices/PointerDevice.js +17 -2
- package/engine/input/ecs/util/TerrainCameraTargetSampler.js +2 -2
- package/engine/navigation/ecs/components/Path.d.ts +2 -0
- package/engine/navigation/ecs/components/Path.js +6 -1
- package/engine/navigation/ecs/components/computeNonuniformCatmullRomSplineSample.js +117 -0
- package/engine/navigation/grid/AStar.js +1 -1
- package/engine/navigation/grid/GridField.js +3 -2
- package/engine/platform/GetURLHash.js +27 -0
- package/engine/platform/WebEnginePlatform.js +1 -22
- package/engine/sound/ecs/emitter/SoundEmitter.js +10 -6
- package/engine/ui/DraggableAspect.js +2 -2
- package/generation/GridGenerator.js +7 -6
- package/generation/example/SampleGenerator0.js +39 -35
- package/generation/example/filters/SampleGroundMoistureFilter.js +58 -17
- package/generation/example/generators/interactive/mir_generator_place_buff_objects.js +7 -6
- package/generation/example/generators/mir_generator_place_bases.js +7 -3
- package/generation/example/generators/mir_generator_place_road_decorators.js +3 -3
- package/generation/example/generators/mir_generator_place_starting_point.js +3 -2
- package/generation/example/themes/SampleTheme0.js +11 -7
- package/generation/filtering/numeric/CellFilterLiteralFloat.js +5 -0
- package/generation/filtering/numeric/complex/CellFilterDilate.js +36 -0
- package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +15 -5
- package/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +53 -1
- package/generation/filtering/numeric/math/CellFilterMax2.js +3 -0
- package/generation/filtering/numeric/math/CellFilterMembershipGeneralizedBell.js +55 -0
- package/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.js +42 -0
- package/generation/filtering/numeric/sampling/CellFilterSampleLayerCubic.js +36 -0
- package/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js +41 -0
- package/generation/grid/GridData.d.ts +5 -1
- package/generation/grid/GridData.js +35 -36
- package/generation/grid/MarkerMatchCounter.js +5 -3
- package/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
- package/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +1 -1
- package/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +1 -1
- package/generation/grid/generation/road/GridTaskGenerateRoads.js +1 -1
- package/generation/markers/GridActionRuleSet.js +15 -32
- package/generation/markers/GridCellActionPlaceMarker.js +12 -8
- package/generation/markers/debug/visualizeMarkers.js +56 -36
- package/generation/markers/emitter/MarkerNodeEmitterFromAction.js +8 -8
- package/generation/markers/prototypeGridCellActionPlaceMarker.js +209 -0
- package/generation/markers/transform/MarkerNodeTransformerOffsetPosition.js +1 -5
- package/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.spec.js +2 -2
- package/generation/placement/GridCellPlacementRule.js +31 -25
- package/generation/theme/ThemeEngine.js +1 -1
- package/package.json +1 -1
- package/samples/terrain/from_image.js +7 -3
- package/samples/terrain/main.js +1 -1
- package/view/View.js +23 -1
- package/view/common/LabelView.js +1 -1
- package/view/compose3x3transform.js +32 -8
- package/view/controller/dat/DatGuiUtils.js +1 -1
- package/view/elements/DropDownSelectionView.js +11 -3
- package/view/elements/image/ImageView.js +3 -1
- package/core/model/ObservedReal.js +0 -55
- package/editor/ecs/component/ObjectEditor.js +0 -0
- package/engine/graphics/particles/particular/engine/renderers/SoftBillboardParticleRenderer.js +0 -7
- package/engine/sound/ecs/emitter/attenuate/attenuateSoundLinear.js +0 -11
- package/generation/filtering/numeric/CellFilterReadGridLayer.js +0 -73
|
@@ -1,32 +1,73 @@
|
|
|
1
|
-
import { CellFilterAdd } from "../../filtering/numeric/math/algebra/CellFilterAdd.js";
|
|
2
1
|
import { CellFilterMultiply } from "../../filtering/numeric/math/algebra/CellFilterMultiply.js";
|
|
3
2
|
import { CellFilterSimplexNoise } from "../../filtering/numeric/complex/CellFilterSimplexNoise.js";
|
|
4
3
|
import { CellFilterLiteralFloat } from "../../filtering/numeric/CellFilterLiteralFloat.js";
|
|
5
4
|
import { CellFilterGaussianBlur } from "../../filtering/numeric/complex/CellFilterGaussianBlur.js";
|
|
6
|
-
import { CellFilterOneMinus } from "../../filtering/numeric/math/CellFilterOneMinus.js";
|
|
7
5
|
import { CellFilterStep } from "../../filtering/numeric/math/CellFilterStep.js";
|
|
8
|
-
import {
|
|
6
|
+
import { CellFilterSampleLayerLinear } from "../../filtering/numeric/sampling/CellFilterSampleLayerLinear.js";
|
|
9
7
|
import { MirGridLayers } from "../grid/MirGridLayers.js";
|
|
8
|
+
import { CellFilterMax2 } from "../../filtering/numeric/math/CellFilterMax2.js";
|
|
9
|
+
import { CellFilterSmoothStep } from "../../filtering/numeric/math/CellFilterSmoothStep.js";
|
|
10
|
+
import { MohGridLayers } from "../../../../../generator/MohGridLayers.js";
|
|
11
|
+
import { CellFilterDilate } from "../../filtering/numeric/complex/CellFilterDilate.js";
|
|
12
|
+
import { DEG2RAD } from "three/src/math/MathUtils.js";
|
|
13
|
+
import { CellFilterCache } from "../../filtering/numeric/CellFilterCache.js";
|
|
10
14
|
|
|
11
|
-
const fReadHeight =
|
|
15
|
+
const fReadHeight = CellFilterSampleLayerLinear.from(MirGridLayers.Heights);
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
const WATER_MASK = CellFilterStep.from(fReadHeight, CellFilterLiteralFloat.from(-0.05));
|
|
18
|
+
const CURVATURE = CellFilterSampleLayerLinear.from(MohGridLayers.Curvature);
|
|
19
|
+
const SLOPE = CellFilterSampleLayerLinear.from(MohGridLayers.Slope);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export const SampleGroundMoistureFilter = CellFilterMax2.from(
|
|
14
23
|
// add regional variation in relative moisture
|
|
15
24
|
CellFilterMultiply.from(
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
CellFilterMultiply.from(
|
|
26
|
+
CellFilterSimplexNoise.fractal(2, 100, 1263),
|
|
27
|
+
CellFilterMax2.from(
|
|
28
|
+
// flat areas are more likely to be keep moisture
|
|
29
|
+
CellFilterSmoothStep.from(
|
|
30
|
+
CellFilterLiteralFloat.from(40 * DEG2RAD),
|
|
31
|
+
CellFilterLiteralFloat.from(10 * DEG2RAD),
|
|
32
|
+
SLOPE
|
|
33
|
+
),
|
|
34
|
+
// water accumulates in crevices
|
|
35
|
+
CellFilterSmoothStep.from(
|
|
36
|
+
CellFilterLiteralFloat.from(0.0),
|
|
37
|
+
CellFilterLiteralFloat.from(0.1),
|
|
38
|
+
CURVATURE
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
),
|
|
42
|
+
|
|
43
|
+
CellFilterLiteralFloat.from(0.5)
|
|
18
44
|
),
|
|
19
45
|
|
|
20
|
-
//simulate water
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
//simulate water diffusion from lakes/rivers/sees into the nearby ground
|
|
47
|
+
CellFilterGaussianBlur.from(
|
|
48
|
+
CellFilterCache.from(
|
|
49
|
+
CellFilterMax2.from(
|
|
50
|
+
WATER_MASK,
|
|
51
|
+
CellFilterMultiply.from(
|
|
52
|
+
CellFilterGaussianBlur.from(
|
|
53
|
+
CellFilterCache.from(CellFilterDilate.from(WATER_MASK)),
|
|
54
|
+
5,
|
|
55
|
+
5,
|
|
56
|
+
1
|
|
57
|
+
),
|
|
58
|
+
/*
|
|
59
|
+
Diffuse more along surfaces with low slope (flat)
|
|
60
|
+
NOTE: we don't have to worry about directly of the slope, as water always starts at 0, so any slope will be positive in effect
|
|
61
|
+
*/
|
|
62
|
+
CellFilterSmoothStep.from(
|
|
63
|
+
CellFilterLiteralFloat.from(35 * DEG2RAD),
|
|
64
|
+
CellFilterLiteralFloat.from(10 * DEG2RAD),
|
|
65
|
+
SLOPE
|
|
66
|
+
),
|
|
67
|
+
)
|
|
68
|
+
)
|
|
29
69
|
),
|
|
30
|
-
|
|
70
|
+
3, 3, 1
|
|
31
71
|
)
|
|
32
72
|
);
|
|
73
|
+
|
|
@@ -23,6 +23,7 @@ import { MirMarkerTypes } from "../../../../../generator/MirMarkerTypes.js";
|
|
|
23
23
|
import { GridPatternMatcherCell } from "../../../rules/cell/GridPatternMatcherCell.js";
|
|
24
24
|
import { BuffObjectTypes } from "../../../../../../generator/BuffObjectTypes.js";
|
|
25
25
|
import { UnlockableElementsManager } from "../../../../../../model/unlocks/UnlockableElementsManager.js";
|
|
26
|
+
import { GridCellActionSequence } from "../../../placement/action/util/GridCellActionSequence.js";
|
|
26
27
|
|
|
27
28
|
const TAG_MAJOR = 'Major Buff';
|
|
28
29
|
const TAG_MINOR = 'Minor Buff';
|
|
@@ -112,7 +113,7 @@ function makeMajorRule(tag) {
|
|
|
112
113
|
)
|
|
113
114
|
)
|
|
114
115
|
),
|
|
115
|
-
|
|
116
|
+
action: GridCellActionSequence.from([
|
|
116
117
|
placeTags,
|
|
117
118
|
clearTags,
|
|
118
119
|
GridCellActionPlaceMarker.from({
|
|
@@ -121,7 +122,7 @@ function makeMajorRule(tag) {
|
|
|
121
122
|
tags: [MirMarkerTypes.BuffObject, TAG_MAJOR]
|
|
122
123
|
}),
|
|
123
124
|
placeRoadMarkers
|
|
124
|
-
],
|
|
125
|
+
]),
|
|
125
126
|
probability: CellFilterLiteralFloat.from(0.1)
|
|
126
127
|
});
|
|
127
128
|
}
|
|
@@ -151,7 +152,7 @@ function makeMinorRule(tag) {
|
|
|
151
152
|
)
|
|
152
153
|
)
|
|
153
154
|
),
|
|
154
|
-
|
|
155
|
+
action: GridCellActionSequence.from([
|
|
155
156
|
placeTags,
|
|
156
157
|
clearTags,
|
|
157
158
|
GridCellActionPlaceMarker.from({
|
|
@@ -159,7 +160,7 @@ function makeMinorRule(tag) {
|
|
|
159
160
|
size: 0.52,
|
|
160
161
|
tags: [MirMarkerTypes.BuffObject, TAG_MINOR]
|
|
161
162
|
})
|
|
162
|
-
],
|
|
163
|
+
]),
|
|
163
164
|
probability: CellFilterLiteralFloat.from(0.1)
|
|
164
165
|
});
|
|
165
166
|
}
|
|
@@ -185,7 +186,7 @@ function makeUtilityRule(tag, frequency = 17) {
|
|
|
185
186
|
)
|
|
186
187
|
)
|
|
187
188
|
),
|
|
188
|
-
|
|
189
|
+
action: GridCellActionSequence.from([
|
|
189
190
|
placeTags,
|
|
190
191
|
clearTags,
|
|
191
192
|
GridCellActionPlaceMarker.from({
|
|
@@ -193,7 +194,7 @@ function makeUtilityRule(tag, frequency = 17) {
|
|
|
193
194
|
size: 0.52,
|
|
194
195
|
tags: [MirMarkerTypes.BuffObject, TAG_UTILITY]
|
|
195
196
|
})
|
|
196
|
-
],
|
|
197
|
+
]),
|
|
197
198
|
probability: CellFilterLiteralFloat.from(0.1)
|
|
198
199
|
});
|
|
199
200
|
}
|
|
@@ -21,9 +21,12 @@ import { MarkerNodeMatcherAny } from "../../markers/matcher/MarkerNodeMatcherAny
|
|
|
21
21
|
import { MarkerNodeEmitterFromAction } from "../../markers/emitter/MarkerNodeEmitterFromAction.js";
|
|
22
22
|
import { Transform } from "../../../engine/ecs/transform/Transform.js";
|
|
23
23
|
import { MarkerNodeTransformerOffsetPosition } from "../../markers/transform/MarkerNodeTransformerOffsetPosition.js";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
MarkerNodeTransformerRecordUniqueRandomEnum
|
|
26
|
+
} from "../../markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js";
|
|
25
27
|
import { MirMarkerTypes } from "../../../../generator/MirMarkerTypes.js";
|
|
26
28
|
import { MirMarkerTags } from "../../../../generator/MirMarkerTags.js";
|
|
29
|
+
import { GridCellActionSequence } from "../../placement/action/util/GridCellActionSequence.js";
|
|
27
30
|
|
|
28
31
|
const pMatcher = new CellMatcherGridPattern();
|
|
29
32
|
|
|
@@ -79,7 +82,7 @@ for (let i = 0; i < 100; i++) {
|
|
|
79
82
|
|
|
80
83
|
const rule = GridCellPlacementRule.from({
|
|
81
84
|
matcher: pMatcher,
|
|
82
|
-
|
|
85
|
+
action: GridCellActionSequence.from([
|
|
83
86
|
placeTags,
|
|
84
87
|
clearTags,
|
|
85
88
|
MarkerNodeEmitterGridCellAction.from(
|
|
@@ -134,7 +137,8 @@ const rule = GridCellPlacementRule.from({
|
|
|
134
137
|
})
|
|
135
138
|
),
|
|
136
139
|
placeRoadConnectors
|
|
137
|
-
],
|
|
140
|
+
]),
|
|
141
|
+
probability: CellFilterLiteralFloat.from(0.1)
|
|
138
142
|
});
|
|
139
143
|
|
|
140
144
|
rule.allowRotation = false;
|
|
@@ -46,9 +46,9 @@ const placeMarker = GridCellActionPlaceMarker.from({ type: 'Road Junction Decora
|
|
|
46
46
|
placeMarker.addTag(TAG_ROAD_DECORATOR);
|
|
47
47
|
|
|
48
48
|
const ruleBend90 = GridCellPlacementRule.from({
|
|
49
|
-
matcher: matchBend90,
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
matcher: matchBend90,
|
|
50
|
+
action:placeMarker,
|
|
51
|
+
probability: CellFilterLiteralFloat.from(0.1)
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
|
|
@@ -16,6 +16,7 @@ import { MirMarkerTypes } from "../../../../generator/MirMarkerTypes.js";
|
|
|
16
16
|
import { MarkerNodeTransformerRemoveTag } from "../../markers/transform/MarkerNodeTransformerRemoveTag.js";
|
|
17
17
|
import { MirMarkerTags } from "../../../../generator/MirMarkerTags.js";
|
|
18
18
|
import { MarkerNodeTransformerSequence } from "../../markers/transform/MarkerNodeTransformerSequence.js";
|
|
19
|
+
import { GridCellActionSequence } from "../../placement/action/util/GridCellActionSequence.js";
|
|
19
20
|
|
|
20
21
|
const MATCH_STARTING_POINT = CellMatcherLayerBitMaskTest.from(GridTags.StartingPoint, MirGridLayers.Tags);
|
|
21
22
|
|
|
@@ -30,7 +31,7 @@ pattern.addRule(0, -1, CellMatcherLayerBitMaskTest.from(GridTags.Base, MirGridLa
|
|
|
30
31
|
const rule = GridCellPlacementRule.from(
|
|
31
32
|
{
|
|
32
33
|
matcher: pattern,
|
|
33
|
-
|
|
34
|
+
action: GridCellActionSequence.from([
|
|
34
35
|
GridCellActionPlaceTags.from(GridTags.StartingPoint | GridTags.Occupied, MirGridLayers.Tags),
|
|
35
36
|
GridCellActionPlaceMarker.from({ type: MirMarkerTypes.StartingPoint }),
|
|
36
37
|
// transfer ownership of any base within some distance to the player
|
|
@@ -42,7 +43,7 @@ const rule = GridCellPlacementRule.from(
|
|
|
42
43
|
MarkerNodeTransformerRemoveTag.from(MirMarkerTags.Encounter)
|
|
43
44
|
])
|
|
44
45
|
)
|
|
45
|
-
]
|
|
46
|
+
])
|
|
46
47
|
}
|
|
47
48
|
);
|
|
48
49
|
|
|
@@ -21,13 +21,17 @@ import Tag from "../../../engine/ecs/components/Tag.js";
|
|
|
21
21
|
import HeadsUpDisplay from "../../../engine/ecs/gui/hud/HeadsUpDisplay.js";
|
|
22
22
|
import ViewportPosition from "../../../engine/ecs/gui/position/ViewportPosition.js";
|
|
23
23
|
import GUIElement from "../../../engine/ecs/gui/GUIElement.js";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
MarkerNodeTransformerYRotateByFilterGradient
|
|
26
|
+
} from "../../markers/transform/MarkerNodeTransformerYRotateByFilterGradient.js";
|
|
25
27
|
import { PI_HALF } from "../../../core/math/MathUtils.js";
|
|
26
28
|
import { CellFilterGaussianBlur } from "../../filtering/numeric/complex/CellFilterGaussianBlur.js";
|
|
27
29
|
import { CellProcessingRule } from "../../theme/cell/CellProcessingRule.js";
|
|
28
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
ContinuousGridCellActionSetTerrainHeight
|
|
32
|
+
} from "../../grid/actions/ContinuousGridCellActionSetTerrainHeight.js";
|
|
29
33
|
import { MirGridLayers } from "../grid/MirGridLayers.js";
|
|
30
|
-
import {
|
|
34
|
+
import { CellFilterSampleLayerLinear } from "../../filtering/numeric/sampling/CellFilterSampleLayerLinear.js";
|
|
31
35
|
import ClingToTerrain from "../../../engine/ecs/terrain/ecs/ClingToTerrain.js";
|
|
32
36
|
import { MarkerNodeTransformerYRotateByFilter } from "../../markers/transform/MarkerNodeTransformerYRotateByFilter.js";
|
|
33
37
|
import { CellFilterAngleToNormal } from "../../filtering/numeric/complex/CellFilterAngleToNormal.js";
|
|
@@ -55,14 +59,14 @@ const terrainTheme = new TerrainTheme();
|
|
|
55
59
|
|
|
56
60
|
const matcher_tag_road = CellMatcherLayerBitMaskTest.from(GridTags.Road, MirGridLayers.Tags);
|
|
57
61
|
|
|
58
|
-
const filterMoisture =
|
|
62
|
+
const filterMoisture = CellFilterSampleLayerLinear.from(MirGridLayers.Moisture);
|
|
59
63
|
|
|
60
64
|
const filterRock = CellFilterClamp.from(
|
|
61
65
|
CellFilterSmoothStep.from(
|
|
62
66
|
CellFilterLiteralFloat.from(Math.PI / 5),
|
|
63
67
|
CellFilterLiteralFloat.from(Math.PI / 3.5),
|
|
64
68
|
CellFilterAngleToNormal.from(
|
|
65
|
-
|
|
69
|
+
CellFilterSampleLayerLinear.from(MirGridLayers.Heights),
|
|
66
70
|
Vector3.forward
|
|
67
71
|
)
|
|
68
72
|
),
|
|
@@ -101,7 +105,7 @@ const filterSand = CellFilterMultiply.from(
|
|
|
101
105
|
CellFilterLiteralFloat.from(0),
|
|
102
106
|
CellFilterLiteralFloat.from(0.2),
|
|
103
107
|
CellFilterNegate.from(
|
|
104
|
-
|
|
108
|
+
CellFilterSampleLayerLinear.from(MirGridLayers.Heights)
|
|
105
109
|
)
|
|
106
110
|
),
|
|
107
111
|
3,
|
|
@@ -1562,7 +1566,7 @@ SampleTheme0.nodes.add(MarkerProcessingRule.from({
|
|
|
1562
1566
|
|
|
1563
1567
|
const aHeight = new ContinuousGridCellActionSetTerrainHeight();
|
|
1564
1568
|
|
|
1565
|
-
aHeight.target =
|
|
1569
|
+
aHeight.target = CellFilterSampleLayerLinear.from(MirGridLayers.Heights);
|
|
1566
1570
|
|
|
1567
1571
|
SampleTheme0.cells.add(CellProcessingRule.from(
|
|
1568
1572
|
CellFilterLiteralFloat.from(1),
|
|
@@ -37,3 +37,8 @@ export class CellFilterLiteralFloat extends CellFilter {
|
|
|
37
37
|
* @type {CellFilterLiteralFloat}
|
|
38
38
|
*/
|
|
39
39
|
CellFilterLiteralFloat.ONE = CellFilterLiteralFloat.from(1);
|
|
40
|
+
/**
|
|
41
|
+
* @readonly
|
|
42
|
+
* @type {CellFilterLiteralFloat}
|
|
43
|
+
*/
|
|
44
|
+
CellFilterLiteralFloat.ZERO = CellFilterLiteralFloat.from(0);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CellFilter } from "../../CellFilter.js";
|
|
2
|
+
import { max2 } from "../../../../core/math/max2.js";
|
|
3
|
+
import { CellFilterUnaryOperation } from "../../core/CellFilterUnaryOperation.js";
|
|
4
|
+
import { assert } from "../../../../core/assert.js";
|
|
5
|
+
|
|
6
|
+
export class CellFilterDilate extends CellFilterUnaryOperation {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {CellFilter} source
|
|
10
|
+
* @returns {CellFilterDilate}
|
|
11
|
+
*/
|
|
12
|
+
static from(source) {
|
|
13
|
+
const r = new CellFilterDilate();
|
|
14
|
+
assert.equal(source.isCellFilter, true, 'source.isCellFilter !== true');
|
|
15
|
+
|
|
16
|
+
r.source = source;
|
|
17
|
+
|
|
18
|
+
return r;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
execute(grid, x, y, rotation) {
|
|
22
|
+
const filter = this.source;
|
|
23
|
+
|
|
24
|
+
let result = Number.NEGATIVE_INFINITY;
|
|
25
|
+
|
|
26
|
+
for (let _y = -1; _y <= 1; _y++) {
|
|
27
|
+
for (let _x = -1; _x <= 1; _x++) {
|
|
28
|
+
const v = filter.execute(grid, x + _x, y + _y, 0);
|
|
29
|
+
|
|
30
|
+
result = max2(result, v);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -81,14 +81,20 @@ export class CellFilterGaussianBlur extends CellFilter {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
initialize(grid, seed) {
|
|
84
|
+
if (this.initialized) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
84
88
|
if (!this.source.initialized) {
|
|
85
89
|
this.source.initialize(grid, seed);
|
|
90
|
+
}
|
|
86
91
|
|
|
87
|
-
|
|
92
|
+
this.__kernel = new Float32Array(this.samples_x * this.samples_y);
|
|
88
93
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
// initialize kernel
|
|
95
|
+
this.__kernel_total_power = buildKernel(this.__kernel, this.samples_x, this.samples_y, this.sigma_x, this.sigma_y);
|
|
96
|
+
|
|
97
|
+
super.initialize(grid, seed);
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
|
|
@@ -115,6 +121,8 @@ export class CellFilterGaussianBlur extends CellFilter {
|
|
|
115
121
|
}
|
|
116
122
|
|
|
117
123
|
execute(grid, x, y, rotation) {
|
|
124
|
+
assert.ok(this.__initialized, 'not initialized');
|
|
125
|
+
|
|
118
126
|
const samplesX = this.samples_x;
|
|
119
127
|
const samplesY = this.samples_y;
|
|
120
128
|
|
|
@@ -156,7 +164,9 @@ export class CellFilterGaussianBlur extends CellFilter {
|
|
|
156
164
|
|
|
157
165
|
const sourceValue = source.execute(grid, x + offset_x, y + offset_y, 0);
|
|
158
166
|
|
|
159
|
-
|
|
167
|
+
const sample_contribution = sourceValue * power;
|
|
168
|
+
|
|
169
|
+
sum += sample_contribution;
|
|
160
170
|
|
|
161
171
|
}
|
|
162
172
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { seededRandom } from "../../../../core/math/random/seededRandom.js";
|
|
2
2
|
import { CellFilter } from "../../CellFilter.js";
|
|
3
3
|
import SimplexNoise from "simplex-noise";
|
|
4
|
+
import { CellFilterAdd } from "../math/algebra/CellFilterAdd.js";
|
|
5
|
+
import { CellFilterMultiply } from "../math/algebra/CellFilterMultiply.js";
|
|
6
|
+
import { CellFilterLiteralFloat } from "../CellFilterLiteralFloat.js";
|
|
7
|
+
import { CellFilterDivide } from "../math/algebra/CellFilterDivide.js";
|
|
4
8
|
|
|
5
9
|
export class CellFilterSimplexNoise extends CellFilter {
|
|
6
10
|
constructor() {
|
|
@@ -14,7 +18,7 @@ export class CellFilterSimplexNoise extends CellFilter {
|
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
20
|
* @private
|
|
17
|
-
* @type {
|
|
21
|
+
* @type {function}
|
|
18
22
|
*/
|
|
19
23
|
this.random = seededRandom(0);
|
|
20
24
|
|
|
@@ -29,6 +33,54 @@ export class CellFilterSimplexNoise extends CellFilter {
|
|
|
29
33
|
this.__seed = 0;
|
|
30
34
|
}
|
|
31
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Build a fractal noise filter with a given number of octaves
|
|
38
|
+
* @param {number} octaves
|
|
39
|
+
* @param {number} scale
|
|
40
|
+
* @param {number} persistence
|
|
41
|
+
* @param {number} lacunarity
|
|
42
|
+
* @param {number} seed
|
|
43
|
+
* @returns {CellFilter}
|
|
44
|
+
*/
|
|
45
|
+
static fractal(octaves, scale, seed = 0, persistence = 0.5, lacunarity = 2) {
|
|
46
|
+
let s = seed;
|
|
47
|
+
let r;
|
|
48
|
+
|
|
49
|
+
let frequency = 1;
|
|
50
|
+
let amplitude = 1;
|
|
51
|
+
let totalAmplitude = 0;
|
|
52
|
+
|
|
53
|
+
for (let i = 0; i < octaves; i++) {
|
|
54
|
+
const noise = CellFilterSimplexNoise.from(scale * frequency, scale * frequency, s);
|
|
55
|
+
|
|
56
|
+
if (r === undefined) {
|
|
57
|
+
r = noise;
|
|
58
|
+
} else {
|
|
59
|
+
r = CellFilterAdd.from(
|
|
60
|
+
CellFilterMultiply.from(noise, CellFilterLiteralFloat.from(amplitude)),
|
|
61
|
+
r
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
totalAmplitude += amplitude;
|
|
66
|
+
amplitude *= persistence;
|
|
67
|
+
frequency *= lacunarity;
|
|
68
|
+
|
|
69
|
+
s = (s + 1) * 31;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (totalAmplitude === 1) {
|
|
73
|
+
return r;
|
|
74
|
+
} else {
|
|
75
|
+
|
|
76
|
+
return CellFilterDivide.from(
|
|
77
|
+
r,
|
|
78
|
+
CellFilterLiteralFloat.from(totalAmplitude)
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
32
84
|
/**
|
|
33
85
|
*
|
|
34
86
|
* @param {number} scale_x
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CellFilterUnaryOperation } from "../../core/CellFilterUnaryOperation.js";
|
|
2
|
+
import { assert } from "../../../../core/assert.js";
|
|
3
|
+
import { bell_membership_function } from "../../../../core/math/bell_membership_function.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @see "dbellmf" function from Matlab
|
|
7
|
+
* @see https://codecrucks.com/what-is-fuzzy-membership-function-complete-guide/
|
|
8
|
+
* @see https://researchhubs.com/post/maths/fundamentals/bell-shaped-function.html
|
|
9
|
+
*/
|
|
10
|
+
export class CellFilterMembershipGeneralizedBell extends CellFilterUnaryOperation {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Controls window, larger value = larger window. Function will return exactly 0.5 at this distance away from center
|
|
17
|
+
* @type {number}
|
|
18
|
+
*/
|
|
19
|
+
this.a = 0;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Slope, larger slope makes function's tails sharper, meaning that values fall off faster away from center
|
|
23
|
+
* @type {number}
|
|
24
|
+
*/
|
|
25
|
+
this.b = 0;
|
|
26
|
+
/**
|
|
27
|
+
* Controls center of the bell
|
|
28
|
+
* @type {number}
|
|
29
|
+
*/
|
|
30
|
+
this.c = 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static from(source, a = 1, b = 1, c = 0) {
|
|
34
|
+
assert.equal(source.isCellFilter, true, 'source.isCellFilter !== true');
|
|
35
|
+
|
|
36
|
+
assert.isNumber(a, 'a');
|
|
37
|
+
assert.isNumber(b, 'b');
|
|
38
|
+
assert.isNumber(c, 'c');
|
|
39
|
+
|
|
40
|
+
const r = new CellFilterMembershipGeneralizedBell();
|
|
41
|
+
|
|
42
|
+
r.a = a;
|
|
43
|
+
r.b = b;
|
|
44
|
+
r.c = c;
|
|
45
|
+
|
|
46
|
+
r.source = source;
|
|
47
|
+
|
|
48
|
+
return r;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
operation(v) {
|
|
52
|
+
return bell_membership_function(v, this.a, this.b, this.c);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CellFilter } from "../../CellFilter.js";
|
|
2
|
+
|
|
3
|
+
export class AbstractCellFilterSampleGridLayer extends CellFilter {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @type {string}
|
|
10
|
+
*/
|
|
11
|
+
this.layerId = null;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @type {GridDataLayer}
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
this.__layer = null;
|
|
19
|
+
|
|
20
|
+
this.__u_scale = 0;
|
|
21
|
+
this.__v_scale = 0;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @type {Sampler2D}
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
this.__sampler = null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
initialize(grid, seed) {
|
|
31
|
+
super.initialize(grid, seed);
|
|
32
|
+
|
|
33
|
+
this.__layer = grid.getLayerById(this.layerId);
|
|
34
|
+
|
|
35
|
+
// cache required values
|
|
36
|
+
this.__sampler = this.__layer.sampler;
|
|
37
|
+
|
|
38
|
+
this.__u_scale = this.__sampler.width / grid.width;
|
|
39
|
+
this.__v_scale = this.__sampler.height / grid.height;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AbstractCellFilterSampleGridLayer } from "./AbstractCellFilterSampleGridLayer.js";
|
|
2
|
+
import { assert } from "../../../../core/assert.js";
|
|
3
|
+
|
|
4
|
+
export class CellFilterSampleLayerCubic extends AbstractCellFilterSampleGridLayer {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {string} layer
|
|
9
|
+
* @returns {CellFilterSampleLayerCubic}
|
|
10
|
+
*/
|
|
11
|
+
static from(layer) {
|
|
12
|
+
assert.typeOf(layer, 'string', 'layer');
|
|
13
|
+
|
|
14
|
+
const r = new CellFilterSampleLayerCubic();
|
|
15
|
+
|
|
16
|
+
r.layerId = layer;
|
|
17
|
+
|
|
18
|
+
return r;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
execute(grid, x, y, rotation) {
|
|
22
|
+
|
|
23
|
+
//convert to UV
|
|
24
|
+
const sampler_x = x * this.__u_scale;
|
|
25
|
+
const sampler_y = y * this.__v_scale;
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @type {Sampler2D}
|
|
31
|
+
*/
|
|
32
|
+
const sampler = this.__sampler;
|
|
33
|
+
|
|
34
|
+
return sampler.sampleChannelBicubic(sampler_x, sampler_y, 0);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { AbstractCellFilterSampleGridLayer } from "./AbstractCellFilterSampleGridLayer.js";
|
|
3
|
+
|
|
4
|
+
export class CellFilterSampleLayerLinear extends AbstractCellFilterSampleGridLayer {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {string} layer
|
|
9
|
+
* @returns {CellFilterSampleLayerLinear}
|
|
10
|
+
*/
|
|
11
|
+
static from(layer) {
|
|
12
|
+
assert.typeOf(layer, 'string', 'layer');
|
|
13
|
+
|
|
14
|
+
const r = new CellFilterSampleLayerLinear();
|
|
15
|
+
|
|
16
|
+
r.layerId = layer;
|
|
17
|
+
|
|
18
|
+
return r;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
execute(grid, x, y, rotation) {
|
|
22
|
+
|
|
23
|
+
//convert to UV
|
|
24
|
+
const sampler_x = x * this.__u_scale;
|
|
25
|
+
const sampler_y = y * this.__v_scale;
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @type {Sampler2D}
|
|
31
|
+
*/
|
|
32
|
+
const sampler = this.__sampler;
|
|
33
|
+
|
|
34
|
+
const channel_value = sampler.sampleChannelBilinear(sampler_x, sampler_y, 0);
|
|
35
|
+
|
|
36
|
+
assert.notNaN(channel_value, 'channel_value');
|
|
37
|
+
|
|
38
|
+
return channel_value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|