@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
|
@@ -7,9 +7,84 @@ import { QuadTreeNode } from "../../../core/geom/2d/quad-tree/QuadTreeNode.js";
|
|
|
7
7
|
import { Transform } from "../../../engine/ecs/transform/Transform.js";
|
|
8
8
|
import TransformModifyAction from "../../actions/concrete/TransformModifyAction.js";
|
|
9
9
|
import EditorEntity from "../../ecs/EditorEntity.js";
|
|
10
|
+
import { uint82float } from "../../../core/binary/uint82float.js";
|
|
10
11
|
|
|
11
12
|
const LIMIT_VALUE = 1000;
|
|
12
13
|
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {Terrain} terrain
|
|
17
|
+
* @param {number} uv_x0
|
|
18
|
+
* @param {number} uv_y0
|
|
19
|
+
* @param {number} uv_x1
|
|
20
|
+
* @param {number} uv_y1
|
|
21
|
+
* @param {Sampler2D} marker
|
|
22
|
+
* @param {number} value_delta
|
|
23
|
+
* @param {number} limitMin
|
|
24
|
+
* @param {number} limitMax
|
|
25
|
+
* @returns {PatchTerrainHeightAction}
|
|
26
|
+
*/
|
|
27
|
+
function make_mod_action(terrain, uv_x0, uv_y0, uv_x1, uv_y1, marker, value_delta, limitMin, limitMax) {
|
|
28
|
+
|
|
29
|
+
const heightMap = terrain.samplerHeight;
|
|
30
|
+
|
|
31
|
+
const h_x0 = uv_x0 * heightMap.width;
|
|
32
|
+
const h_x1 = uv_x1 * heightMap.width;
|
|
33
|
+
|
|
34
|
+
const h_y0 = uv_y0 * heightMap.height;
|
|
35
|
+
const h_y1 = uv_y1 * heightMap.height;
|
|
36
|
+
|
|
37
|
+
const x0 = Math.ceil(h_x0);
|
|
38
|
+
const x1 = Math.floor(h_x1);
|
|
39
|
+
|
|
40
|
+
const y0 = Math.ceil(h_y0);
|
|
41
|
+
const y1 = Math.floor(h_y1);
|
|
42
|
+
|
|
43
|
+
const action = new PatchTerrainHeightAction(terrain, x0, y0, (x1 - x0), (y1 - y0));
|
|
44
|
+
|
|
45
|
+
const patch_destination_data = action.patch.data;
|
|
46
|
+
|
|
47
|
+
for (let y = y0; y < y1; y++) {
|
|
48
|
+
|
|
49
|
+
const v = inverseLerp(h_y0, h_y1 - 1, y);
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
for (let x = x0; x < x1; x++) {
|
|
53
|
+
|
|
54
|
+
const u = inverseLerp(h_x0, h_x1 - 1, x);
|
|
55
|
+
|
|
56
|
+
//Get alpha
|
|
57
|
+
const markerValue = marker.sampleChannelBilinearUV(u, v, 3);
|
|
58
|
+
|
|
59
|
+
const marker_value_normalized = uint82float(markerValue);
|
|
60
|
+
|
|
61
|
+
const source_address = y * heightMap.width + x;
|
|
62
|
+
|
|
63
|
+
const base = heightMap.data[source_address];
|
|
64
|
+
|
|
65
|
+
const patchAddress = (y - y0) * action.patch.width + (x - x0);
|
|
66
|
+
|
|
67
|
+
const targetValue = clamp(base + value_delta, limitMin, limitMax);
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const value = lerp(base, targetValue, marker_value_normalized);
|
|
71
|
+
|
|
72
|
+
if (Number.isNaN(value)) {
|
|
73
|
+
// console.warn('.');
|
|
74
|
+
|
|
75
|
+
patch_destination_data[patchAddress] = base;
|
|
76
|
+
|
|
77
|
+
} else {
|
|
78
|
+
|
|
79
|
+
patch_destination_data[patchAddress] = value;
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
return action;
|
|
86
|
+
}
|
|
87
|
+
|
|
13
88
|
export class TerrainHeightPaintTool extends TerrainPaintTool {
|
|
14
89
|
|
|
15
90
|
constructor() {
|
|
@@ -57,7 +132,7 @@ export class TerrainHeightPaintTool extends TerrainPaintTool {
|
|
|
57
132
|
const vS = 1 / (this.terrain.size.y * gridScale);
|
|
58
133
|
|
|
59
134
|
dataset.traverseComponents(Transform, (transform, entity) => {
|
|
60
|
-
if(dataset.getComponent(entity, EditorEntity) !== undefined){
|
|
135
|
+
if (dataset.getComponent(entity, EditorEntity) !== undefined) {
|
|
61
136
|
//it's an editor entity
|
|
62
137
|
return;
|
|
63
138
|
}
|
|
@@ -91,7 +166,7 @@ export class TerrainHeightPaintTool extends TerrainPaintTool {
|
|
|
91
166
|
*
|
|
92
167
|
* @param {number} timeDelta
|
|
93
168
|
*/
|
|
94
|
-
paint(timeDelta) {
|
|
169
|
+
async paint(timeDelta) {
|
|
95
170
|
const power = this.settings.brushStrength * timeDelta;
|
|
96
171
|
|
|
97
172
|
/**
|
|
@@ -100,12 +175,6 @@ export class TerrainHeightPaintTool extends TerrainPaintTool {
|
|
|
100
175
|
*/
|
|
101
176
|
const terrain = this.terrain;
|
|
102
177
|
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* @type {Sampler2D}
|
|
106
|
-
*/
|
|
107
|
-
const heightMap = terrain.samplerHeight;
|
|
108
|
-
|
|
109
178
|
const brushPosition = this.__brushPosition;
|
|
110
179
|
const brushSize = this.settings.brushSize;
|
|
111
180
|
|
|
@@ -123,74 +192,17 @@ export class TerrainHeightPaintTool extends TerrainPaintTool {
|
|
|
123
192
|
const uv_y0 = uv_y - uv_h / 2;
|
|
124
193
|
const uv_y1 = uv_y + uv_h / 2;
|
|
125
194
|
|
|
126
|
-
const h_x0 = uv_x0 * heightMap.width;
|
|
127
|
-
const h_x1 = uv_x1 * heightMap.width;
|
|
128
|
-
|
|
129
|
-
const h_y0 = uv_y0 * heightMap.height;
|
|
130
|
-
const h_y1 = uv_y1 * heightMap.height;
|
|
131
|
-
|
|
132
|
-
const x0 = Math.ceil(h_x0);
|
|
133
|
-
const x1 = Math.floor(h_x1);
|
|
134
|
-
|
|
135
|
-
const y0 = Math.ceil(h_y0);
|
|
136
|
-
const y1 = Math.floor(h_y1);
|
|
137
195
|
|
|
138
196
|
const marker = this.settings.marker;
|
|
139
197
|
|
|
140
198
|
const direction = this.modifiers.shift ? -1 : 1;
|
|
141
199
|
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
const action = new PatchTerrainHeightAction(terrain, x0, y0, (x1 - x0), (y1 - y0));
|
|
200
|
+
const value_delta = power * direction;
|
|
145
201
|
|
|
146
202
|
const limitMin = this.settings.limitMin;
|
|
147
203
|
const limitMax = this.settings.limitMax;
|
|
148
204
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const v = inverseLerp(h_y0, h_y1, y);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
for (let x = x0; x < x1; x++) {
|
|
155
|
-
|
|
156
|
-
const u = inverseLerp(h_x0, h_x1, x);
|
|
157
|
-
|
|
158
|
-
//Get alpha
|
|
159
|
-
const markerValue = marker.sampleChannelBilinear(u, v, 3);
|
|
160
|
-
|
|
161
|
-
const p = markerValue / 256;
|
|
162
|
-
|
|
163
|
-
const address = y * heightMap.width + x;
|
|
164
|
-
|
|
165
|
-
const base = heightMap.data[address];
|
|
166
|
-
|
|
167
|
-
const patchAddress = (y - y0) * action.patch.width + (x - x0);
|
|
168
|
-
|
|
169
|
-
const targetValue = clamp(base + speed, limitMin, limitMax);
|
|
170
|
-
|
|
171
|
-
if (markerValue === 0) {
|
|
172
|
-
|
|
173
|
-
action.patch.data[patchAddress] = base;
|
|
174
|
-
|
|
175
|
-
} else {
|
|
176
|
-
|
|
177
|
-
const value = lerp(base, targetValue, p);
|
|
178
|
-
|
|
179
|
-
if (Number.isNaN(value)) {
|
|
180
|
-
console.warn('.');
|
|
181
|
-
|
|
182
|
-
action.patch.data[patchAddress] = base;
|
|
183
|
-
|
|
184
|
-
} else {
|
|
185
|
-
|
|
186
|
-
action.patch.data[patchAddress] = value;
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
205
|
+
const action = make_mod_action(terrain, uv_x0, uv_y0, uv_x1, uv_y1, marker, value_delta, limitMin, limitMax);
|
|
194
206
|
|
|
195
207
|
this.editor.actions.do(action);
|
|
196
208
|
|
|
@@ -252,12 +264,20 @@ export class TerrainHeightPaintTool extends TerrainPaintTool {
|
|
|
252
264
|
const tX = leaf.x0 * heightSampler.width;
|
|
253
265
|
const tY = leaf.y0 * heightSampler.height;
|
|
254
266
|
|
|
255
|
-
const
|
|
267
|
+
const action_value = action.patch.sampleChannelBicubic(tX - action.x, tY - action.y, 0);
|
|
268
|
+
const existing_value = heightSampler.sampleChannelBicubic(tY, tY, 0);
|
|
269
|
+
|
|
270
|
+
const delta = action_value - existing_value;
|
|
256
271
|
|
|
257
272
|
if (delta === 0) {
|
|
258
273
|
continue;
|
|
259
274
|
}
|
|
260
275
|
|
|
276
|
+
if (Number.isNaN(delta)) {
|
|
277
|
+
console.error('Delta is NaN, skipping.', action, tX, tY);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
|
|
261
281
|
const tM = new Transform();
|
|
262
282
|
tM.copy(transform);
|
|
263
283
|
tM.position._add(0, delta, 0);
|
|
@@ -21,7 +21,7 @@ export class TerrainPaintTool extends Tool {
|
|
|
21
21
|
marker.data.fill(255);
|
|
22
22
|
|
|
23
23
|
this.settings.markerColor = new Color(0, 1, 0.8);
|
|
24
|
-
this.settings.markerOpacity = new Vector1(
|
|
24
|
+
this.settings.markerOpacity = new Vector1(1);
|
|
25
25
|
|
|
26
26
|
this.settings.marker = marker;
|
|
27
27
|
this.settings.brushSize = 5;
|
|
@@ -128,6 +128,7 @@ export class TerrainPaintTool extends Tool {
|
|
|
128
128
|
const brushSizeX = brushRadius * dx;
|
|
129
129
|
const brushSizeY = brushRadius * dy;
|
|
130
130
|
|
|
131
|
+
|
|
131
132
|
overlay.paintImage(this.__brushImage, overlayPositionX - brushSizeX, overlayPositionY - brushSizeY, brushSize * dx, brushSize * dy);
|
|
132
133
|
}
|
|
133
134
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { clamp } from "../../../core/math/clamp.js";
|
|
2
2
|
import { inverseLerp } from "../../../core/math/inverseLerp.js";
|
|
3
3
|
import { TerrainPaintTool } from "./TerrainPaintTool.js";
|
|
4
|
-
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
5
|
-
import { PatchTerrainTextureAction } from "../../actions/concrete/PatchTerrainTextureAction.js";
|
|
6
4
|
import { convertSampler2D2DataURL } from "../../../engine/graphics/texture/sampler/convertSampler2D2DataURL.js";
|
|
7
5
|
import { obtainTerrain } from "../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
6
|
+
import { ModifyPatchSampler2DAction } from "../../actions/concrete/ModifyPatchSampler2DAction.js";
|
|
8
7
|
|
|
9
8
|
export class TerrainTexturePaintTool extends TerrainPaintTool {
|
|
10
9
|
constructor() {
|
|
@@ -96,7 +95,6 @@ export class TerrainTexturePaintTool extends TerrainPaintTool {
|
|
|
96
95
|
const brushPosition = this.__brushPosition;
|
|
97
96
|
const brushSize = this.settings.brushSize;
|
|
98
97
|
|
|
99
|
-
|
|
100
98
|
const terrainSize = terrain.size;
|
|
101
99
|
|
|
102
100
|
const terrainHeight = terrainSize.y;
|
|
@@ -126,14 +124,12 @@ export class TerrainTexturePaintTool extends TerrainPaintTool {
|
|
|
126
124
|
*/
|
|
127
125
|
const weightData = this.__splatMapScratch;
|
|
128
126
|
|
|
129
|
-
|
|
130
127
|
/**
|
|
131
128
|
*
|
|
132
129
|
* @type {SplatMapping}
|
|
133
130
|
*/
|
|
134
131
|
const splat = terrain.splat;
|
|
135
132
|
|
|
136
|
-
const splatDepth = splat.depth;
|
|
137
133
|
const splatWidth = splat.size.x;
|
|
138
134
|
const splatHeight = splat.size.y;
|
|
139
135
|
|
|
@@ -153,25 +149,17 @@ export class TerrainTexturePaintTool extends TerrainPaintTool {
|
|
|
153
149
|
|
|
154
150
|
const splatIndex = this.settings.splatIndex;
|
|
155
151
|
|
|
156
|
-
/**
|
|
157
|
-
*
|
|
158
|
-
* @type {Sampler2D}
|
|
159
|
-
*/
|
|
160
|
-
const materialSampler = splat.materialSampler;
|
|
161
|
-
|
|
162
152
|
//create action
|
|
163
153
|
const patchWidth = x1 - x0;
|
|
164
|
-
const patchHeight = y1 - y0;
|
|
165
154
|
|
|
166
155
|
const targetSplatLayerAddress = splatIndex * splatLayerSize;
|
|
167
156
|
|
|
168
|
-
const
|
|
169
|
-
action.patchMaterial.copy_sameItemSize(materialSampler, x0, y0, 0, 0, patchWidth, patchHeight);
|
|
157
|
+
const splat_layer_sampler = splat.getLayerWeightSampler(splatIndex);
|
|
170
158
|
|
|
171
|
-
const
|
|
159
|
+
const m_action = new ModifyPatchSampler2DAction(splat_layer_sampler, [x0, y0, x1, y1]);
|
|
160
|
+
|
|
161
|
+
const patchMaterialData = m_action.patch.data;
|
|
172
162
|
|
|
173
|
-
const a4_weight = new Array(4);
|
|
174
|
-
const a4_material = new Array(4);
|
|
175
163
|
|
|
176
164
|
for (let y = y0; y < y1; y++) {
|
|
177
165
|
|
|
@@ -208,68 +196,15 @@ export class TerrainTexturePaintTool extends TerrainPaintTool {
|
|
|
208
196
|
weightData[targetSplatLayerAddress + splatTexelIndex] = clampedValue;
|
|
209
197
|
|
|
210
198
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (i === splatIndex) {
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const address = i * splatLayerSize + splatTexelIndex;
|
|
218
|
-
|
|
219
|
-
const v = weightData[address];
|
|
220
|
-
|
|
221
|
-
const cV = clamp(v - delta, 0, 255);
|
|
222
|
-
|
|
223
|
-
weightData[address] = cV;
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
a4_weight.fill(-1);
|
|
228
|
-
a4_material.fill(255);
|
|
199
|
+
const patchIndex = ((y - y0) * patchWidth + (x - x0));
|
|
229
200
|
|
|
230
|
-
|
|
231
|
-
for (let i = 0; i < splatDepth; i++) {
|
|
232
|
-
|
|
233
|
-
const address = i * splatLayerSize + splatTexelIndex;
|
|
234
|
-
|
|
235
|
-
const weight = weightData[address];
|
|
236
|
-
|
|
237
|
-
if (weight > a4_weight[3]) {
|
|
238
|
-
a4_weight[3] = weight;
|
|
239
|
-
a4_material[3] = i;
|
|
240
|
-
|
|
241
|
-
for (let j = 3; j >= 0 && weight > a4_weight[j - 1]; j--) {
|
|
242
|
-
const tW = a4_weight[j];
|
|
243
|
-
const tM = a4_material[j];
|
|
244
|
-
|
|
245
|
-
const j1 = j - 1;
|
|
246
|
-
|
|
247
|
-
a4_weight[j] = a4_weight[j1];
|
|
248
|
-
a4_material[j] = a4_material[j1];
|
|
249
|
-
|
|
250
|
-
a4_weight[j1] = tW;
|
|
251
|
-
a4_material[j1] = tM;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const patchIndex4 = ((y - y0) * patchWidth + (x - x0)) * 4;
|
|
260
|
-
|
|
261
|
-
patchMaterialData[patchIndex4] = a4_material[0];
|
|
262
|
-
patchMaterialData[patchIndex4 + 1] = a4_material[1];
|
|
263
|
-
patchMaterialData[patchIndex4 + 2] = a4_material[2];
|
|
264
|
-
patchMaterialData[patchIndex4 + 3] = a4_material[3];
|
|
201
|
+
patchMaterialData[patchIndex] = clampedValue;
|
|
265
202
|
}
|
|
266
203
|
|
|
267
204
|
}
|
|
268
205
|
|
|
269
206
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
this.editor.actions.do(action);
|
|
207
|
+
this.editor.actions.do(m_action);
|
|
273
208
|
}
|
|
274
209
|
|
|
275
210
|
start() {
|
|
@@ -415,7 +415,7 @@ class EditorView extends View {
|
|
|
415
415
|
layout() {
|
|
416
416
|
const size = this.size;
|
|
417
417
|
|
|
418
|
-
this.entityEditor.size.set(
|
|
418
|
+
this.entityEditor.size.set(360, size.y);
|
|
419
419
|
this.entityEditor.position.set(size.x - this.entityEditor.size.x, 0);
|
|
420
420
|
|
|
421
421
|
this.entityListView.size.set(200, size.y);
|
|
@@ -5,7 +5,6 @@ import ObservedBoolean from "../../../core/model/ObservedBoolean.js";
|
|
|
5
5
|
import LabelView from "../../../view/common/LabelView.js";
|
|
6
6
|
import ButtonView from "../../../view/elements/button/ButtonView.js";
|
|
7
7
|
import EmptyView from "../../../view/elements/EmptyView.js";
|
|
8
|
-
import GuiControl from "../../../view/controller/controls/GuiControl.js";
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* @template T
|
|
@@ -16,10 +15,10 @@ export class ComponentControlView extends View {
|
|
|
16
15
|
* @param {number} entity
|
|
17
16
|
* @param {T} component
|
|
18
17
|
* @param {EntityManager} entityManager
|
|
19
|
-
* @param {
|
|
18
|
+
* @param {View} vController
|
|
20
19
|
* @constructor
|
|
21
20
|
*/
|
|
22
|
-
constructor(entity, component, entityManager,
|
|
21
|
+
constructor(entity, component, entityManager, vController ) {
|
|
23
22
|
super();
|
|
24
23
|
|
|
25
24
|
this.signal = {
|
|
@@ -104,33 +103,6 @@ export class ComponentControlView extends View {
|
|
|
104
103
|
|
|
105
104
|
this.addChild(vTitleBar);
|
|
106
105
|
|
|
107
|
-
let vController;
|
|
108
|
-
|
|
109
|
-
function buildPlaceholderController(message) {
|
|
110
|
-
const labelView = new LabelView(message);
|
|
111
|
-
labelView.el.classList.add(GuiControl.CSS_CLASS_NAME);
|
|
112
|
-
return labelView;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
//build controller
|
|
116
|
-
if (!factory.exists(typeName)) {
|
|
117
|
-
//no controller factory for this type
|
|
118
|
-
vController = buildPlaceholderController('No Controller Implemented');
|
|
119
|
-
//fold, not useful to display
|
|
120
|
-
this.folded.set(true);
|
|
121
|
-
} else {
|
|
122
|
-
try {
|
|
123
|
-
vController = factory.create(typeName);
|
|
124
|
-
vController.entity = entity;
|
|
125
|
-
vController.entityManager = entityManager;
|
|
126
|
-
|
|
127
|
-
vController.model.set(component);
|
|
128
|
-
} catch (e) {
|
|
129
|
-
vController = buildPlaceholderController(`Exception thrown during controller build: ${e}`);
|
|
130
|
-
console.error(e);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
106
|
const self = this;
|
|
135
107
|
|
|
136
108
|
folded.process(function (v) {
|