Merge origin/master
This commit is contained in:
42 files changed
+2950
-83
No files matched your search
+11
-6
@@ -9,9 +9,9 @@
|
||||
//
|
||||
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import { generateTerrainFromContours } from "../model/terrain";
|
||||
import { generateTerrainFromContours, type TerrainOptions } from "../model/terrain";
|
||||
import type { ContextObject, Project } from "../model/types";
|
||||
import { addItems, fieldOps, removeItems } from "../core/opsBuild";
|
||||
import { addItems, fieldOps, patchItem, removeItems } from "../core/opsBuild";
|
||||
import type { CoreOp } from "../core/ops";
|
||||
import { ensureContextCategories } from "../model/contextCategories";
|
||||
import type { StoreApi } from "./store";
|
||||
@@ -32,7 +32,9 @@ export interface SiteSlice {
|
||||
* weiteres Kontext-Objekt hinzu. Liefert die ID des neuen TerrainMesh, oder
|
||||
* null, wenn der ContourSet nicht existiert / kein Mesh entsteht.
|
||||
*/
|
||||
generateTerrain: (contourSetId: string) => string | null;
|
||||
generateTerrain: (contourSetId: string, opts?: TerrainOptions) => string | null;
|
||||
/** [T6]/[68] Ändert Felder eines Kontext-Objekts (Gelände, Baugrube) in einem Schritt; `coalesceKey` für Tippen. */
|
||||
patchContextObject: (id: string, patch: Record<string, unknown>, coalesceKey?: string) => void;
|
||||
/** Leert die gesamte Kontext-Schicht. */
|
||||
clearContext: () => void;
|
||||
}
|
||||
@@ -44,7 +46,7 @@ export interface SiteSlice {
|
||||
*/
|
||||
type SiteSliceDeps = {
|
||||
project: Project;
|
||||
applyChange: (ops: readonly CoreOp[] | ((p: Project) => readonly CoreOp[])) => void;
|
||||
applyChange: (ops: readonly CoreOp[] | ((p: Project) => readonly CoreOp[]), coalesceKey?: string) => void;
|
||||
};
|
||||
|
||||
export function createSiteSlice(
|
||||
@@ -81,13 +83,16 @@ export function createSiteSlice(
|
||||
get().applyChange((p) => removeItems(p, "context", ids));
|
||||
},
|
||||
|
||||
generateTerrain: (contourSetId) => {
|
||||
patchContextObject: (id, patch, coalesceKey) =>
|
||||
get().applyChange((p) => patchItem(p, "context", id, (o) => ({ ...o, ...patch }) as ContextObject), coalesceKey),
|
||||
|
||||
generateTerrain: (contourSetId, opts) => {
|
||||
const ctx = get().project.context ?? [];
|
||||
const set = ctx.find(
|
||||
(o) => o.id === contourSetId && o.type === "contourSet",
|
||||
);
|
||||
if (!set || set.type !== "contourSet") return null;
|
||||
const terrain = generateTerrainFromContours(set.contours);
|
||||
const terrain = generateTerrainFromContours(set.contours, opts);
|
||||
if (terrain.indices.length === 0) return null; // kein sinnvolles TIN
|
||||
addToContext([terrain]);
|
||||
return terrain.id;
|
||||
|
||||
@@ -169,6 +169,7 @@ export function usePanelHostBase(opts: {
|
||||
| "removeContextObject"
|
||||
| "removeContextObjects"
|
||||
| "generateTerrain"
|
||||
| "patchContextObject"
|
||||
| "commitTransformOn"
|
||||
| "setElementColor"
|
||||
| "setElementWeight"
|
||||
@@ -293,6 +294,7 @@ export function usePanelHostBase(opts: {
|
||||
removeContextObject,
|
||||
removeContextObjects,
|
||||
generateTerrain,
|
||||
patchContextObject,
|
||||
commitTransformOn,
|
||||
setElementColor,
|
||||
setElementWeight,
|
||||
@@ -1087,6 +1089,8 @@ export function usePanelHostBase(opts: {
|
||||
onRemoveContextObject: removeContextObject,
|
||||
onRemoveContextObjects: removeContextObjects,
|
||||
onGenerateTerrain: generateTerrain,
|
||||
onPatchContextObject: patchContextObject,
|
||||
onStartExcavation: () => onRunCommand("excavation"),
|
||||
onSetGeoAnchor: (anchor) => {
|
||||
applyChange((p) => setFieldIfChanged(p, "geoAnchor", anchor));
|
||||
},
|
||||
|
||||
@@ -48,6 +48,8 @@ function contextObjectsBounds(objs: ContextObject[]): Vec2[] | null {
|
||||
} else if (obj.type === "image") {
|
||||
acc(obj.min.x, obj.min.y);
|
||||
acc(obj.max.x, obj.max.y);
|
||||
} else if (obj.type === "excavation") {
|
||||
for (const p of obj.outline) acc(p.x, p.y);
|
||||
} else {
|
||||
// importedMesh / terrainMesh: flaches (x,y,z…)-Array, Stride 3.
|
||||
const pos = obj.positions;
|
||||
@@ -351,6 +353,7 @@ export function useProjectActions(
|
||||
const removeContextObject = useStore((s) => s.removeContextObject);
|
||||
const removeContextObjects = useStore((s) => s.removeContextObjects);
|
||||
const generateTerrain = useStore((s) => s.generateTerrain);
|
||||
const patchContextObject = useStore((s) => s.patchContextObject);
|
||||
const moveGripOf = useStore((s) => s.moveGripOf);
|
||||
const moveElementByOf = useStore((s) => s.moveElementByOf);
|
||||
const moveEdgeOf = useStore((s) => s.moveEdgeOf);
|
||||
@@ -465,6 +468,7 @@ export function useProjectActions(
|
||||
removeContextObject,
|
||||
removeContextObjects,
|
||||
generateTerrain,
|
||||
patchContextObject,
|
||||
moveGripOf,
|
||||
moveElementByOf,
|
||||
moveEdgeOf,
|
||||
|
||||
Reference in new issue
Block a user