Skip to content

Commit eecd8b7

Browse files
committed
restore
1 parent 6136cde commit eecd8b7

File tree

3 files changed

+26
-123
lines changed

3 files changed

+26
-123
lines changed

internal_stores/model/surfaces.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ export function useModelSurfacesStyle() {
88
const dataStyleStore = useDataStyleStore()
99
const dataBaseStore = useDataBaseStore()
1010

11-
function modelSurfacesStyle(id) {
12-
return dataStyleStore.getStyle(id).surfaces
13-
}
1411
function modelSurfaceStyle(id, surface_id) {
15-
if (!modelSurfacesStyle(id)[surface_id]) {
16-
modelSurfacesStyle(id)[surface_id] = {}
12+
if (!dataStyleStore.getStyle(id).surfaces[surface_id]) {
13+
dataStyleStore.getStyle(id).surfaces[surface_id] = {}
1714
}
18-
return modelSurfacesStyle(id)[surface_id]
15+
return dataStyleStore.getStyle(id).surfaces[surface_id]
1916
}
2017

2118
function modelSurfaceVisibility(id, surface_id) {
@@ -77,7 +74,7 @@ export function useModelSurfacesStyle() {
7774
}
7875

7976
function applyModelSurfacesStyle(id) {
80-
const style = modelSurfacesStyle(id)
77+
const style = dataStyleStore.getStyle(id).surfaces
8178
const surface_ids = dataBaseStore.getSurfacesUuids(id)
8279

8380
if (!surface_ids || surface_ids.length === 0) {

stores/data_style.js

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,37 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
1414
dataStyleState.styles[id] = getDefaultStyle(geode_object)
1515
}
1616

17-
// useDataStyleStore: setVisibility
18-
function setVisibility(payloadOrId, visibility) {
19-
const id =
20-
typeof payloadOrId === "string"
21-
? payloadOrId
22-
: (payloadOrId?.id ?? payloadOrId?.data_id ?? payloadOrId?.model_id)
23-
if (!id) return Promise.resolve([])
24-
25-
const visible =
26-
typeof visibility === "boolean"
27-
? visibility
28-
: payloadOrId?.visible != null
29-
? !!payloadOrId.visible
30-
: true
31-
17+
function setVisibility(id, visibility) {
3218
const meta = dataBaseStore.itemMetaDatas(id)
33-
const object_type = meta?.object_type
34-
if (!object_type) return Promise.resolve([])
35-
19+
if (!meta) {
20+
console.warn("[DataStyle] setVisibility skipped: unknown id", id)
21+
return Promise.resolve([])
22+
}
23+
const object_type = meta.object_type
3624
if (object_type === "mesh") {
3725
return Promise.all([meshStyleStore.setMeshVisibility(id, visibility)])
3826
} else if (object_type === "model") {
3927
return Promise.all([modelStyleStore.setModelVisibility(id, visibility)])
4028
}
29+
throw new Error("Unknown object_type")
30+
}
31+
32+
function applyDefaultStyle(id) {
33+
const { object_type } = dataBaseStore.itemMetaDatas(id)
34+
if (object_type === "mesh") {
35+
return meshStyleStore.applyMeshStyle(id)
36+
} else if (object_type === "model") {
37+
return modelStyleStore.applyModelStyle(id)
38+
}
4139
return Promise.resolve([])
4240
}
4341

4442
function setModelEdgesVisibility(id, visibility) {
45-
modelStyleStore.setModelMeshComponentVisibility(
46-
id,
47-
"Edge",
48-
null,
49-
visibility,
50-
)
43+
return modelStyleStore.setModelEdgesVisibility(id, visibility)
5144
}
5245

5346
function modelEdgesVisibility(id) {
54-
return modelStyleStore.modelMeshComponentVisibility(id, "Edge", null)
47+
return modelStyleStore.modelEdgesVisibility(id)
5548
}
5649

5750
function exportStores() {
@@ -84,17 +77,15 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
8477

8578
return {
8679
...dataStyleState,
80+
...meshStyleStore,
81+
...modelStyleStore,
8782
addDataStyle,
8883
applyDefaultStyle,
8984
setVisibility,
9085
setModelEdgesVisibility,
9186
modelEdgesVisibility,
9287
exportStores,
9388
importStores,
94-
...meshStyleStore,
95-
...modelStyleStore,
96-
addDataStyle,
97-
applyDefaultStyle,
98-
setVisibility,
89+
applyAllStylesFromState,
9990
}
10091
})

stores/hybrid_viewer.js

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -199,99 +199,14 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
199199
}
200200

201201
function exportStores() {
202-
const cam =
203-
Object.keys(camera_options).length > 0
204-
? { ...camera_options }
205-
: (() => {
206-
if (!genericRenderWindow.value || status.value !== Status.CREATED) {
207-
return undefined
208-
}
209-
const renderer = genericRenderWindow.value.getRenderer()
210-
const camera = renderer.getActiveCamera()
211-
return {
212-
focal_point: camera.getFocalPoint(),
213-
view_up: camera.getViewUp(),
214-
position: camera.getPosition(),
215-
view_angle: camera.getViewAngle(),
216-
clipping_range: camera.getClippingRange(),
217-
distance: camera.getDistance(),
218-
// Ajouts pour style et zoom corrects
219-
parallel_projection:
220-
typeof camera.getParallelProjection === "function"
221-
? camera.getParallelProjection()
222-
: undefined,
223-
parallel_scale:
224-
typeof camera.getParallelScale === "function"
225-
? camera.getParallelScale()
226-
: undefined,
227-
roll:
228-
typeof camera.getRoll === "function"
229-
? camera.getRoll()
230-
: undefined,
231-
}
232-
})()
233-
return { zScale: zScale.value, camera_options: cam }
202+
return { zScale: zScale.value }
234203
}
235204

236205
async function importStores(snapshot) {
237206
const z_scale = snapshot?.zScale
238207
if (z_scale != null) {
239208
await setZScaling(z_scale)
240209
}
241-
242-
const cam = snapshot?.camera_options
243-
if (cam && genericRenderWindow.value && status.value === Status.CREATED) {
244-
const renderer = genericRenderWindow.value.getRenderer()
245-
const camera = renderer.getActiveCamera()
246-
247-
// Appliquer après que la scène soit prête (évite les reset ultérieurs)
248-
await new Promise((resolve) => requestAnimationFrame(resolve))
249-
250-
// Mode de projection et zoom
251-
if (
252-
cam.parallel_projection !== undefined &&
253-
typeof camera.setParallelProjection === "function"
254-
) {
255-
camera.setParallelProjection(!!cam.parallel_projection)
256-
}
257-
258-
// Pose / orientation
259-
if (cam.focal_point) camera.setFocalPoint(...cam.focal_point)
260-
if (cam.view_up) camera.setViewUp(...cam.view_up)
261-
if (cam.position) camera.setPosition(...cam.position)
262-
263-
// Zoom selon le mode
264-
if (
265-
typeof camera.getParallelProjection === "function" &&
266-
camera.getParallelProjection() &&
267-
cam.parallel_scale !== undefined &&
268-
typeof camera.setParallelScale === "function"
269-
) {
270-
camera.setParallelScale(cam.parallel_scale)
271-
} else if (cam.view_angle != null) {
272-
camera.setViewAngle(cam.view_angle)
273-
}
274-
275-
// Roll (si dispo)
276-
if (cam.roll != null && typeof camera.setRoll === "function") {
277-
camera.setRoll(cam.roll)
278-
}
279-
280-
// Clipping et rendu
281-
if (cam.clipping_range) camera.setClippingRange(...cam.clipping_range)
282-
if (typeof camera.modified === "function") camera.modified()
283-
renderer.resetCameraClippingRange()
284-
genericRenderWindow.value.getRenderWindow().render()
285-
286-
// Sync côté viewer distant (si schéma présent)
287-
const schema = viewer_schemas?.opengeodeweb_viewer?.viewer?.update_camera
288-
if (schema) {
289-
await viewer_call({
290-
schema,
291-
params: { camera_options: cam },
292-
})
293-
}
294-
}
295210
}
296211

297212
return {

0 commit comments

Comments
 (0)