@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
package/editor/Editor.js
CHANGED
|
@@ -23,7 +23,9 @@ import EditorEntitySystem from "./ecs/EditorEntitySystem.js";
|
|
|
23
23
|
import EditorEntity from "./ecs/EditorEntity.js";
|
|
24
24
|
import TopDownCameraController from "../engine/graphics/ecs/camera/topdown/TopDownCameraController.js";
|
|
25
25
|
import { Transform } from "../engine/ecs/transform/Transform.js";
|
|
26
|
-
import TopDownCameraControllerSystem, {
|
|
26
|
+
import TopDownCameraControllerSystem, {
|
|
27
|
+
setCameraControllerFromTransform
|
|
28
|
+
} from "../engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
|
|
27
29
|
import { downloadAsFile } from "../core/binary/ByteArrayTools.js";
|
|
28
30
|
import BinaryBufferSerializer from "../engine/ecs/storage/BinaryBufferSerializer.js";
|
|
29
31
|
import { EncodingBinaryBuffer } from "../core/binary/EncodingBinaryBuffer.js";
|
|
@@ -31,6 +33,41 @@ import { EntityComponentDataset } from "../engine/ecs/EntityComponentDataset.js"
|
|
|
31
33
|
import InputControllerSystem from "../engine/input/ecs/systems/InputControllerSystem.js";
|
|
32
34
|
import { assert } from "../core/assert.js";
|
|
33
35
|
import { resetSoundEmitterTracks } from "../../model/game/options/resetSoundEmitterTracks.js";
|
|
36
|
+
import { NumberEditor } from "./ecs/component/editors/primitive/NumberEditor.js";
|
|
37
|
+
import { BooleanEditor } from "./ecs/component/editors/primitive/BooleanEditor.js";
|
|
38
|
+
import { StringEditor } from "./ecs/component/editors/primitive/StringEditor.js";
|
|
39
|
+
import { FunctionEditor } from "./ecs/component/editors/primitive/FunctionEditor.js";
|
|
40
|
+
import { ArrayEditor } from "./ecs/component/editors/primitive/ArrayEditor.js";
|
|
41
|
+
import { ObjectEditor } from "./ecs/component/editors/primitive/ObjectEditor.js";
|
|
42
|
+
import { NumericInterval } from "../core/math/interval/NumericInterval.js";
|
|
43
|
+
import { NumericIntervalEditor } from "./ecs/component/editors/NumericIntervalEditor.js";
|
|
44
|
+
import { ListEditor } from "./ecs/component/editors/collection/ListEditor.js";
|
|
45
|
+
import ObservedBoolean from "../core/model/ObservedBoolean.js";
|
|
46
|
+
import { ObservedBooleanEditor } from "./ecs/component/editors/ObservedBooleanEditor.js";
|
|
47
|
+
import ObservedEnum from "../core/model/ObservedEnum.js";
|
|
48
|
+
import { ObservedEnumEditor } from "./ecs/component/editors/ObservedEnumEditor.js";
|
|
49
|
+
import { Color } from "../core/color/Color.js";
|
|
50
|
+
import { ColorEditor } from "./ecs/component/editors/ColorEditor.js";
|
|
51
|
+
import Vector4 from "../core/geom/Vector4.js";
|
|
52
|
+
import { Vector4Editor } from "./ecs/component/editors/geom/Vector4Editor.js";
|
|
53
|
+
import Vector3 from "../core/geom/Vector3.js";
|
|
54
|
+
import { Vector3Editor } from "./ecs/component/editors/geom/Vector3Editor.js";
|
|
55
|
+
import Vector2 from "../core/geom/Vector2.js";
|
|
56
|
+
import { Vector2Editor } from "./ecs/component/editors/geom/Vector2Editor.js";
|
|
57
|
+
import Vector1 from "../core/geom/Vector1.js";
|
|
58
|
+
import { Vector1Editor } from "./ecs/component/editors/geom/Vector1Editor.js";
|
|
59
|
+
import ObservedString from "../core/model/ObservedString.js";
|
|
60
|
+
import { ObservedStringEditor } from "./ecs/component/editors/ObservedStringEditor.js";
|
|
61
|
+
import Quaternion from "../core/geom/Quaternion.js";
|
|
62
|
+
import { QuaternionEditor } from "./ecs/component/editors/geom/QuaternionEditor.js";
|
|
63
|
+
import { Sampler2D } from "../engine/graphics/texture/sampler/Sampler2D.js";
|
|
64
|
+
import { Sampler2DEditor } from "./ecs/component/editors/Sampler2DEditor.js";
|
|
65
|
+
import { HTMLElementEditor } from "./ecs/component/editors/HTMLElementEditor.js";
|
|
66
|
+
import WorkerProxy from "../core/process/worker/WorkerProxy.js";
|
|
67
|
+
import { noEditor } from "./ecs/component/editors/common/noEditor.js";
|
|
68
|
+
import Signal from "../core/events/signal/Signal.js";
|
|
69
|
+
import ObservedInteger from "../core/model/ObservedInteger.js";
|
|
70
|
+
import { ObservedIntegerEditor } from "./ecs/component/editors/ObservedIntegerEditor.js";
|
|
34
71
|
|
|
35
72
|
|
|
36
73
|
/**
|
|
@@ -301,6 +338,57 @@ function activateEditorCamera(cameraEntity, dataset, editor) {
|
|
|
301
338
|
camera.active.set(true);
|
|
302
339
|
}
|
|
303
340
|
|
|
341
|
+
/**
|
|
342
|
+
*
|
|
343
|
+
* @param {Map<any, TypeEditor>} registry
|
|
344
|
+
*/
|
|
345
|
+
function initialize_basic_registry(registry) {
|
|
346
|
+
|
|
347
|
+
registry.set(Number, new NumberEditor());
|
|
348
|
+
registry.set(Boolean, new BooleanEditor());
|
|
349
|
+
registry.set(String, new StringEditor());
|
|
350
|
+
registry.set(Function, new FunctionEditor());
|
|
351
|
+
registry.set(Array, new ArrayEditor());
|
|
352
|
+
registry.set(Object, new ObjectEditor());
|
|
353
|
+
|
|
354
|
+
registry.set(ObservedInteger, new ObservedIntegerEditor());
|
|
355
|
+
registry.set(ObservedBoolean, new ObservedBooleanEditor());
|
|
356
|
+
registry.set(ObservedEnum, new ObservedEnumEditor());
|
|
357
|
+
registry.set(ObservedString, new ObservedStringEditor());
|
|
358
|
+
|
|
359
|
+
registry.set(NumericInterval, new NumericIntervalEditor());
|
|
360
|
+
registry.set(List, new ListEditor());
|
|
361
|
+
registry.set(Color, new ColorEditor());
|
|
362
|
+
|
|
363
|
+
registry.set(Vector4, new Vector4Editor());
|
|
364
|
+
registry.set(Vector3, new Vector3Editor());
|
|
365
|
+
registry.set(Vector2, new Vector2Editor());
|
|
366
|
+
registry.set(Vector1, new Vector1Editor());
|
|
367
|
+
registry.set(Quaternion, new QuaternionEditor());
|
|
368
|
+
|
|
369
|
+
registry.set(Sampler2D, new Sampler2DEditor());
|
|
370
|
+
|
|
371
|
+
registry.set(HTMLElement, new HTMLElementEditor());
|
|
372
|
+
registry.set(HTMLCanvasElement, new HTMLElementEditor());
|
|
373
|
+
|
|
374
|
+
registry.set(WorkerProxy, noEditor());
|
|
375
|
+
registry.set(Signal, noEditor());
|
|
376
|
+
|
|
377
|
+
registry.set(Uint8Array, noEditor());
|
|
378
|
+
registry.set(Uint16Array, noEditor());
|
|
379
|
+
registry.set(Uint32Array, noEditor());
|
|
380
|
+
|
|
381
|
+
registry.set(Int8Array, noEditor());
|
|
382
|
+
registry.set(Int16Array, noEditor());
|
|
383
|
+
registry.set(Int32Array, noEditor());
|
|
384
|
+
|
|
385
|
+
registry.set(Float32Array, noEditor());
|
|
386
|
+
registry.set(Float64Array, noEditor());
|
|
387
|
+
|
|
388
|
+
registry.set(CanvasRenderingContext2D, noEditor());
|
|
389
|
+
|
|
390
|
+
}
|
|
391
|
+
|
|
304
392
|
/**
|
|
305
393
|
*
|
|
306
394
|
* @constructor
|
|
@@ -315,6 +403,14 @@ function Editor() {
|
|
|
315
403
|
this.selectionVistualizer = new SelectionVisualizer(this);
|
|
316
404
|
this.meshLibrary = new MeshLibrary();
|
|
317
405
|
|
|
406
|
+
/**
|
|
407
|
+
*
|
|
408
|
+
* @type {Map<any, TypeEditor>}
|
|
409
|
+
*/
|
|
410
|
+
this.type_editor_registry = new Map();
|
|
411
|
+
|
|
412
|
+
initialize_basic_registry(this.type_editor_registry);
|
|
413
|
+
|
|
318
414
|
this.cameraEntity = buildEditorCamera();
|
|
319
415
|
|
|
320
416
|
this.editorEntitySystem = new EditorEntitySystem();
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Action } from "../../../core/process/undo/Action.js";
|
|
2
|
+
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
3
|
+
|
|
4
|
+
export class ModifyPatchSampler2DAction extends Action {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {Sampler2D} sampler
|
|
8
|
+
* @param {number[]} bounds
|
|
9
|
+
*/
|
|
10
|
+
constructor(sampler, bounds) {
|
|
11
|
+
super();
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @type {Sampler2D}
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
this.__sampler = sampler;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @type {number[]}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
this.__bounds = bounds;
|
|
26
|
+
|
|
27
|
+
const width = this.__bounds[2] - this.__bounds[0];
|
|
28
|
+
const height = this.__bounds[3] - this.__bounds[1];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @type {Sampler2D}
|
|
33
|
+
*/
|
|
34
|
+
this.__patch_new = Sampler2D.float32(sampler.itemSize, width, height);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @type {Sampler2D}
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
this.__patch_old = Sampler2D.float32(sampler.itemSize, width, height);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get patch() {
|
|
45
|
+
return this.__patch_new;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get x() {
|
|
49
|
+
return this.__bounds[0];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get y() {
|
|
53
|
+
return this.__bounds[1];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param {number} x coordinate in global space
|
|
59
|
+
* @param {number} y coordinate in global space
|
|
60
|
+
* @param {number} [channel]
|
|
61
|
+
* @returns {number} delta between original value and the new one after the change
|
|
62
|
+
*/
|
|
63
|
+
computeDelta(x, y, channel = 0) {
|
|
64
|
+
const _x = x - this.x;
|
|
65
|
+
|
|
66
|
+
if (_x < 0 || _x > this.__patch_new.width - 1) {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const _y = y - this.y;
|
|
71
|
+
|
|
72
|
+
if (_y < 0 || _y > this.__patch_new.height - 1) {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const value_old = this.__patch_old.sampleChannelBilinear(_x, _y, channel);
|
|
77
|
+
const value_new = this.__patch_new.sampleChannelBilinear(_x, _y, channel);
|
|
78
|
+
|
|
79
|
+
return value_new - value_old;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
computeByteSize() {
|
|
83
|
+
return this.__patch_new.computeByteSize() + this.__patch_old.computeByteSize() + 280;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
async apply(context) {
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @type {Sampler2D}
|
|
92
|
+
*/
|
|
93
|
+
const source = this.__sampler;
|
|
94
|
+
|
|
95
|
+
//store old data from the patch
|
|
96
|
+
const patch_old = this.__patch_old;
|
|
97
|
+
|
|
98
|
+
patch_old.copy_sameItemSize(source, this.x, this.y, 0, 0, patch_old.width, patch_old.height);
|
|
99
|
+
|
|
100
|
+
const patch_new = this.__patch_new;
|
|
101
|
+
|
|
102
|
+
//apply the patch
|
|
103
|
+
source.copy_sameItemSize(patch_new, 0, 0, this.x, this.y, patch_new.width, patch_new.height);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async revert(context) {
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
* @type {Sampler2D}
|
|
110
|
+
*/
|
|
111
|
+
const source = this.__sampler;
|
|
112
|
+
|
|
113
|
+
const patch_old = this.__patch_old;
|
|
114
|
+
|
|
115
|
+
//apply the patch
|
|
116
|
+
source.copy_sameItemSize(patch_old, 0, 0, this.x, this.y, patch_old.width, patch_old.height);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ModifyPatchSampler2DAction } from "./ModifyPatchSampler2DAction.js";
|
|
2
|
+
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
3
|
+
|
|
4
|
+
test("apply patch size 0", async () => {
|
|
5
|
+
const sampler = Sampler2D.uint8(1, 1, 1);
|
|
6
|
+
sampler.data[0] = 123;
|
|
7
|
+
|
|
8
|
+
const action = new ModifyPatchSampler2DAction(sampler, [0, 0, 0, 0]);
|
|
9
|
+
|
|
10
|
+
await action.apply();
|
|
11
|
+
|
|
12
|
+
expect([...sampler.data]).toEqual([123]);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("apply patch size 1, fill entire", async () => {
|
|
16
|
+
const sampler = Sampler2D.uint8(1, 1, 1);
|
|
17
|
+
sampler.data[0] = 123;
|
|
18
|
+
|
|
19
|
+
const action = new ModifyPatchSampler2DAction(sampler, [0, 0, 1, 1]);
|
|
20
|
+
|
|
21
|
+
action.patch.data[0] = 42;
|
|
22
|
+
|
|
23
|
+
await action.apply();
|
|
24
|
+
|
|
25
|
+
expect([...sampler.data]).toEqual([42]);
|
|
26
|
+
|
|
27
|
+
await action.revert();
|
|
28
|
+
|
|
29
|
+
expect([...sampler.data]).toEqual([123]);
|
|
30
|
+
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
1
|
+
import { ModifyPatchSampler2DAction } from "./ModifyPatchSampler2DAction.js";
|
|
3
2
|
|
|
4
|
-
export class PatchTerrainHeightAction extends
|
|
3
|
+
export class PatchTerrainHeightAction extends ModifyPatchSampler2DAction {
|
|
5
4
|
/**
|
|
6
5
|
*
|
|
7
6
|
* @param {Terrain} terrain
|
|
@@ -11,64 +10,25 @@ export class PatchTerrainHeightAction extends Action {
|
|
|
11
10
|
* @param {number} height
|
|
12
11
|
*/
|
|
13
12
|
constructor(terrain, x, y, width, height) {
|
|
14
|
-
super();
|
|
13
|
+
super(terrain.samplerHeight, [x, y, x + width, y + height]);
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
*
|
|
18
17
|
* @type {Terrain}
|
|
19
18
|
*/
|
|
20
19
|
this.terrain = terrain;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @type {Sampler2D}
|
|
25
|
-
*/
|
|
26
|
-
this.patch = Sampler2D.float32(1, width, height);
|
|
27
|
-
|
|
28
|
-
this.x = x;
|
|
29
|
-
this.y = y;
|
|
30
|
-
|
|
31
|
-
this.__oldPatch = Sampler2D.float32(1, width, height);
|
|
32
20
|
}
|
|
33
21
|
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
* @param {number} x
|
|
37
|
-
* @param {number} y
|
|
38
|
-
* @returns {number}
|
|
39
|
-
*/
|
|
40
|
-
computeDelta(x, y) {
|
|
41
|
-
|
|
42
|
-
const _x = x - this.x;
|
|
43
|
-
|
|
44
|
-
if (_x < 0 || _x > this.patch.width - 1) {
|
|
45
|
-
return 0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const _y = y - this.y;
|
|
49
|
-
|
|
50
|
-
if (_y < 0 || _y > this.patch.height - 1) {
|
|
51
|
-
return 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const sourceValue = this.__oldPatch.sampleChannelBilinear(_x, _y, 0);
|
|
55
|
-
const targetValue = this.patch.sampleChannelBilinear(_x, _y, 0);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return targetValue - sourceValue;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
computeByteSize() {
|
|
62
|
-
return this.patch.computeByteSize() + this.__oldPatch.computeByteSize() + 280;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
updateTerrain() {
|
|
22
|
+
async updateTerrain() {
|
|
66
23
|
/**
|
|
67
24
|
*
|
|
68
25
|
* @type {Terrain}
|
|
69
26
|
*/
|
|
70
27
|
const terrain = this.terrain;
|
|
71
28
|
|
|
29
|
+
terrain.updateHeightTexture();
|
|
30
|
+
terrain.updateWorkerHeights();
|
|
31
|
+
|
|
72
32
|
/**
|
|
73
33
|
*
|
|
74
34
|
* @type {Sampler2D}
|
|
@@ -79,11 +39,7 @@ export class PatchTerrainHeightAction extends Action {
|
|
|
79
39
|
*
|
|
80
40
|
* @type {TerrainTileManager}
|
|
81
41
|
*/
|
|
82
|
-
const tiles = terrain.
|
|
83
|
-
|
|
84
|
-
tiles.buildWorker.setHeightSampler(heightMap.data, heightMap.itemSize, heightMap.width, heightMap.height);
|
|
85
|
-
|
|
86
|
-
const terrainSize = terrain.size;
|
|
42
|
+
const tiles = terrain.__tiles;
|
|
87
43
|
|
|
88
44
|
const x = this.x;
|
|
89
45
|
const y = this.y;
|
|
@@ -94,66 +50,18 @@ export class PatchTerrainHeightAction extends Action {
|
|
|
94
50
|
const v0 = y / heightMap.height;
|
|
95
51
|
const v1 = (y + this.patch.height) / heightMap.height;
|
|
96
52
|
|
|
97
|
-
|
|
98
|
-
const tx1 = u1 * terrainSize.x;
|
|
99
|
-
|
|
100
|
-
const ty0 = v0 * terrainSize.y;
|
|
101
|
-
const ty1 = v1 * terrainSize.y;
|
|
102
|
-
|
|
103
|
-
const dirtyTiles = tiles.getRawTilesOverlappingRectangle(tx0 - 1, ty0 - 1, tx1 + 1, ty1 + 1);
|
|
104
|
-
|
|
105
|
-
dirtyTiles.forEach(tile => {
|
|
106
|
-
tile.isBuilt = false;
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
terrain.heightTexture.needsUpdate = true;
|
|
53
|
+
tiles.rebuildTilesByUV(u0, v0, u1, v1);
|
|
110
54
|
}
|
|
111
55
|
|
|
112
56
|
async apply(context) {
|
|
57
|
+
await super.apply(context);
|
|
113
58
|
|
|
114
|
-
|
|
115
|
-
*
|
|
116
|
-
* @type {Terrain}
|
|
117
|
-
*/
|
|
118
|
-
const terrain = this.terrain;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
*
|
|
122
|
-
* @type {Sampler2D}
|
|
123
|
-
*/
|
|
124
|
-
const heightMap = terrain.heightMap;
|
|
125
|
-
|
|
126
|
-
//store old data from the patch
|
|
127
|
-
const oldPatch = this.__oldPatch;
|
|
128
|
-
|
|
129
|
-
oldPatch.copy_sameItemSize(heightMap, this.x, this.y, 0, 0, oldPatch.width, oldPatch.height);
|
|
130
|
-
|
|
131
|
-
const patch = this.patch;
|
|
132
|
-
//apply the patch
|
|
133
|
-
heightMap.copy_sameItemSize(patch, 0, 0, this.x, this.y, patch.width, patch.height);
|
|
134
|
-
|
|
135
|
-
this.updateTerrain();
|
|
59
|
+
await this.updateTerrain();
|
|
136
60
|
}
|
|
137
61
|
|
|
138
62
|
async revert(context) {
|
|
63
|
+
await super.revert(context);
|
|
139
64
|
|
|
140
|
-
|
|
141
|
-
*
|
|
142
|
-
* @type {Terrain}
|
|
143
|
-
*/
|
|
144
|
-
const terrain = this.terrain;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
*
|
|
148
|
-
* @type {Sampler2D}
|
|
149
|
-
*/
|
|
150
|
-
const heightMap = terrain.heightMap;
|
|
151
|
-
|
|
152
|
-
const patch = this.__oldPatch;
|
|
153
|
-
|
|
154
|
-
//apply the patch
|
|
155
|
-
heightMap.copy_sameItemSize(patch, 0, 0, this.x, this.y, patch.width, patch.height);
|
|
156
|
-
|
|
157
|
-
this.updateTerrain();
|
|
65
|
+
await this.updateTerrain();
|
|
158
66
|
}
|
|
159
67
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
*/
|
|
4
|
+
export class FieldDescriptor {
|
|
5
|
+
constructor() {
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @type {string}
|
|
9
|
+
*/
|
|
10
|
+
this.name = "";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* typeof field
|
|
14
|
+
* @type {Class<T>}
|
|
15
|
+
*/
|
|
16
|
+
this.type = null;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {FieldValueAdapter|null}
|
|
21
|
+
*/
|
|
22
|
+
this.adapter = null;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {{}|undefined}
|
|
27
|
+
*/
|
|
28
|
+
this.schema = undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
toString() {
|
|
32
|
+
return `FieldDescriptor[name='${this.name}']`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { assert } from "../../../core/assert.js";
|
|
2
|
+
|
|
3
|
+
export class FieldValueAdapter {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.writable = true;
|
|
6
|
+
this.readable = true;
|
|
7
|
+
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
read(object, field_name) {
|
|
11
|
+
assert.isString(field_name, 'field_name');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
return object[field_name];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
write(object, field_name, value) {
|
|
18
|
+
object[field_name] = value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class
|
|
3
|
+
* @template T
|
|
4
|
+
*/
|
|
5
|
+
export class TypeEditor {
|
|
6
|
+
inline = true;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Class is hidden and editor should not be displayed
|
|
10
|
+
* @returns {boolean}
|
|
11
|
+
*/
|
|
12
|
+
get hidden() {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @returns {TypeSchema|undefined}
|
|
19
|
+
*/
|
|
20
|
+
get schema() {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {*} parent
|
|
26
|
+
* @param {FieldDescriptor} field
|
|
27
|
+
* @param {Map<*, TypeEditor>} registry
|
|
28
|
+
* @returns {View|void}
|
|
29
|
+
*/
|
|
30
|
+
build(parent, field, registry) {
|
|
31
|
+
throw new Error('Not Implemented');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {DataType} from "../../../core/parser/simple/DataType";
|
|
2
|
+
|
|
3
|
+
interface Type<T> extends Function {
|
|
4
|
+
new(...args: any[]): T;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface PropertiesSchema {
|
|
8
|
+
[key: string]: FieldSchema<any>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface TypeSchema {
|
|
12
|
+
additionalProperties?: boolean
|
|
13
|
+
properties: PropertiesSchema
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface TypeEditor {
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface FieldSchema<T> {
|
|
21
|
+
type: Type<T>
|
|
22
|
+
type_parameters?: any[]
|
|
23
|
+
transient?: boolean
|
|
24
|
+
description?: string,
|
|
25
|
+
editor?: TypeEditor
|
|
26
|
+
deprecated?: boolean,
|
|
27
|
+
enum?: T[],
|
|
28
|
+
numeric_type: DataType,
|
|
29
|
+
/**
|
|
30
|
+
* Small image to be displayed next to field name
|
|
31
|
+
*/
|
|
32
|
+
thumbnail: string,
|
|
33
|
+
/**
|
|
34
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-6.2.2
|
|
35
|
+
*/
|
|
36
|
+
maximum?: number,
|
|
37
|
+
minimum?: number
|
|
38
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import EmptyView from "../../../view/elements/EmptyView.js";
|
|
2
|
+
import LabelView from "../../../view/common/LabelView.js";
|
|
3
|
+
|
|
4
|
+
function format_field_name(name) {
|
|
5
|
+
return name
|
|
6
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2') // break up camel case
|
|
7
|
+
.replace(/([^.])_([^.])/g, '$1 $2') // break up underscore case
|
|
8
|
+
.replace(/(^\w{1})|(\s+\w{1})/g, letter => letter.toUpperCase()); // capitalize every word
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @template CTX
|
|
13
|
+
* @param {Object} object
|
|
14
|
+
* @param {FieldDescriptor} field
|
|
15
|
+
* @param {Map<*, TypeEditor>} registry
|
|
16
|
+
*/
|
|
17
|
+
export function createFieldEditor(object, field, registry) {
|
|
18
|
+
|
|
19
|
+
const field_schema = field.schema;
|
|
20
|
+
|
|
21
|
+
let vValue;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @type {TypeEditor}
|
|
25
|
+
*/
|
|
26
|
+
let factory;
|
|
27
|
+
if (field_schema !== undefined) {
|
|
28
|
+
const specific_field_editor = field_schema.editor;
|
|
29
|
+
|
|
30
|
+
if (specific_field_editor !== undefined) {
|
|
31
|
+
// field has a dedicated editor
|
|
32
|
+
factory = specific_field_editor;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (factory === undefined) {
|
|
37
|
+
factory = registry.get(field.type);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let orientation_inline = true;
|
|
41
|
+
|
|
42
|
+
if (factory !== undefined) {
|
|
43
|
+
if (factory.hidden) {
|
|
44
|
+
// hidden class
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
vValue = factory.build(object, field, registry);
|
|
49
|
+
|
|
50
|
+
if (vValue) {
|
|
51
|
+
orientation_inline = factory.inline;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (vValue === null || vValue === undefined) {
|
|
56
|
+
// no view
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const vResult = new EmptyView({
|
|
61
|
+
classList: ['auto-field-editor']
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (orientation_inline) {
|
|
65
|
+
vResult.addClass('orientation-inline');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const field_formatted_name = format_field_name(field.name);
|
|
69
|
+
|
|
70
|
+
const vLabel = new LabelView(field_formatted_name, { classList: ['field-name'] });
|
|
71
|
+
|
|
72
|
+
vResult.addChild(vLabel);
|
|
73
|
+
vResult.addChild(vValue);
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
if (field_schema !== undefined) {
|
|
77
|
+
if (field_schema.description !== undefined && field_schema.description.length > 0) {
|
|
78
|
+
// add tooltip
|
|
79
|
+
vLabel.attr({
|
|
80
|
+
title: field_schema.description
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (field_schema.deprecated) {
|
|
85
|
+
vResult.addClass('field-deprecated');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return vResult;
|
|
90
|
+
}
|