@geode/opengeodeweb-front 12.2.0-rc.5 → 12.2.0-rc.6
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/app/components/CameraOrientation.vue +85 -68
- package/app/components/CameraOrientationDial.vue +195 -0
- package/app/components/Viewer/OrientationCompass.vue +11 -34
- package/app/components/Viewer/OrientationGlobe.vue +2 -2
- package/app/composables/compass_dial.ts +40 -0
- package/app/utils/brand_colors.ts +9 -0
- package/app/utils/camera_orientations.ts +136 -0
- package/app/utils/orientation_compass.ts +15 -0
- package/app/utils/orientation_cube_style.ts +70 -0
- package/package.json +1 -1
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
type CameraOrientation,
|
|
4
|
+
cameraOrientations,
|
|
5
|
+
isNorth,
|
|
6
|
+
} from "@ogw_front/utils/camera_orientations";
|
|
7
|
+
import { BRAND_ORANGE } from "@ogw_front/utils/brand_colors";
|
|
2
8
|
import type { CameraOptions } from "@ogw_internal/stores/hybrid_viewer/vtk_types.js";
|
|
9
|
+
import CameraOrientationDial from "@ogw_front/components/CameraOrientationDial.vue";
|
|
3
10
|
import ToolPanel from "@ogw_front/components/ToolPanel.vue";
|
|
4
11
|
import { applyCameraOptions } from "@ogw_internal/stores/hybrid_viewer/camera";
|
|
12
|
+
import { orientationCubeStyle } from "@ogw_front/utils/orientation_cube_style";
|
|
13
|
+
import { useChromeTheme } from "@ogw_front/composables/chrome_theme";
|
|
14
|
+
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
5
15
|
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
16
|
+
import { useTheme } from "vuetify";
|
|
6
17
|
import { newInstance as vtkAnnotatedCubeActor } from "@kitware/vtk.js/Rendering/Core/AnnotatedCubeActor";
|
|
7
18
|
import { newInstance as vtkGenericRenderWindow } from "@kitware/vtk.js/Rendering/Misc/GenericRenderWindow";
|
|
8
19
|
|
|
@@ -28,56 +39,22 @@ const emit = defineEmits<Emits>();
|
|
|
28
39
|
|
|
29
40
|
const show = defineModel<boolean>("show", { default: false });
|
|
30
41
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
label: "Y+",
|
|
50
|
-
value: "yplus",
|
|
51
|
-
face: "front",
|
|
52
|
-
vtkKey: "YPlus",
|
|
53
|
-
rotation: 180,
|
|
54
|
-
position: { top: "35%", left: "22%" },
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
label: "Y-",
|
|
58
|
-
value: "yminus",
|
|
59
|
-
face: "back",
|
|
60
|
-
vtkKey: "YMinus",
|
|
61
|
-
rotation: 0,
|
|
62
|
-
position: { top: "65%", left: "78%" },
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
label: "X+",
|
|
66
|
-
value: "xplus",
|
|
67
|
-
face: "right",
|
|
68
|
-
vtkKey: "XPlus",
|
|
69
|
-
rotation: 90,
|
|
70
|
-
position: { top: "35%", left: "78%" },
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
label: "X-",
|
|
74
|
-
value: "xminus",
|
|
75
|
-
face: "left",
|
|
76
|
-
vtkKey: "XMinus",
|
|
77
|
-
rotation: -90,
|
|
78
|
-
position: { top: "65%", left: "22%" },
|
|
79
|
-
},
|
|
80
|
-
];
|
|
42
|
+
// With the compass marker, the orientations read north, east, south, west, up and down
|
|
43
|
+
const dataStyleStore = useDataStyleStore();
|
|
44
|
+
const isCompass = computed(() => dataStyleStore.sceneStyle.orientation_widget === "compass");
|
|
45
|
+
const orientations = computed(() =>
|
|
46
|
+
cameraOrientations(dataStyleStore.sceneStyle.orientation_widget),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// The cube follows the theme it is shown in: the chrome theme of the panel (GlassCard), the app
|
|
50
|
+
// Theme for the menu
|
|
51
|
+
const theme = useTheme();
|
|
52
|
+
const chromeTheme = useChromeTheme();
|
|
53
|
+
const cubeStyle = computed(() => {
|
|
54
|
+
const name = panel ? chromeTheme.value : theme.global.name.value;
|
|
55
|
+
const colors = theme.computedThemes.value[name]?.colors;
|
|
56
|
+
return orientationCubeStyle({ surface: colors?.surface, "on-surface": colors?.["on-surface"] });
|
|
57
|
+
});
|
|
81
58
|
|
|
82
59
|
const hoveredFace = ref<string | undefined>(undefined);
|
|
83
60
|
const hybridViewerStore = useHybridViewerStore();
|
|
@@ -87,6 +64,43 @@ let genericRenderWindow: unknown = undefined;
|
|
|
87
64
|
let cubeActor: unknown = undefined;
|
|
88
65
|
let isInteracting = false;
|
|
89
66
|
|
|
67
|
+
function faceStyle(
|
|
68
|
+
orientation: CameraOrientation,
|
|
69
|
+
hovered: boolean,
|
|
70
|
+
): { faceColor: string; fontColor: string } {
|
|
71
|
+
const style = cubeStyle.value;
|
|
72
|
+
if (hovered) {
|
|
73
|
+
return { faceColor: style.hoveredFaceColor, fontColor: style.hoveredFontColor };
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
faceColor: style.faceColor,
|
|
77
|
+
fontColor: isNorth(orientation) ? BRAND_ORANGE : style.fontColor,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function labelFaces(): void {
|
|
82
|
+
for (const orientation of orientations.value) {
|
|
83
|
+
cubeActor[`set${orientation.vtkKey}FaceProperty`]({
|
|
84
|
+
text: orientation.label,
|
|
85
|
+
faceRotation: orientation.rotation,
|
|
86
|
+
...faceStyle(orientation, orientation.face === hoveredFace.value),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function edgeStyle(): { edgeColor: string } {
|
|
92
|
+
return { edgeColor: cubeStyle.value.edgeColor };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
watch([orientations, cubeStyle], () => {
|
|
96
|
+
if (!cubeActor) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
cubeActor.setDefaultStyle(edgeStyle());
|
|
100
|
+
labelFaces();
|
|
101
|
+
genericRenderWindow.getRenderWindow().render();
|
|
102
|
+
});
|
|
103
|
+
|
|
90
104
|
function initVTK(): void {
|
|
91
105
|
if (genericRenderWindow) {
|
|
92
106
|
return;
|
|
@@ -109,21 +123,13 @@ function initVTK(): void {
|
|
|
109
123
|
cubeActor.setDefaultStyle({
|
|
110
124
|
fontFamily: "sans-serif",
|
|
111
125
|
fontStyle: "bold",
|
|
112
|
-
|
|
113
|
-
fontColor: "white",
|
|
114
|
-
edgeColor: "rgba(255, 255, 255, 0.4)",
|
|
126
|
+
...edgeStyle(),
|
|
115
127
|
edgeThickness: 0.1,
|
|
116
128
|
resolution: 400,
|
|
117
129
|
fontSizeScale: (resolution: number) => resolution / 4,
|
|
118
130
|
});
|
|
119
131
|
|
|
120
|
-
|
|
121
|
-
cubeActor[`set${orientation.vtkKey}FaceProperty`]({
|
|
122
|
-
text: orientation.label,
|
|
123
|
-
faceRotation: orientation.rotation,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
132
|
+
labelFaces();
|
|
127
133
|
cubeActor.getProperty().setBackfaceCulling(true);
|
|
128
134
|
|
|
129
135
|
const renderer = genericRenderWindow.getRenderer();
|
|
@@ -166,12 +172,9 @@ watch(hoveredFace, (newFace, oldFace) => {
|
|
|
166
172
|
return;
|
|
167
173
|
}
|
|
168
174
|
function updateFace(face: string | undefined, active: boolean): void {
|
|
169
|
-
const config = orientations.find((orientation) => orientation.face === face);
|
|
175
|
+
const config = orientations.value.find((orientation) => orientation.face === face);
|
|
170
176
|
if (config) {
|
|
171
|
-
cubeActor[`set${config.vtkKey}FaceProperty`](
|
|
172
|
-
faceColor: active ? "rgba(255, 255, 255, 0.95)" : "rgba(60, 60, 60, 1)",
|
|
173
|
-
fontColor: active ? "black" : "white",
|
|
174
|
-
});
|
|
177
|
+
cubeActor[`set${config.vtkKey}FaceProperty`](faceStyle(config, active));
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
|
|
@@ -189,7 +192,16 @@ watch(hoveredFace, (newFace, oldFace) => {
|
|
|
189
192
|
:width="width"
|
|
190
193
|
:escapeFunction="escapeFunction"
|
|
191
194
|
>
|
|
195
|
+
<CameraOrientationDial
|
|
196
|
+
v-if="isCompass"
|
|
197
|
+
v-model:hoveredFace="hoveredFace"
|
|
198
|
+
:orientations="orientations"
|
|
199
|
+
@select="(value) => emit('select', value)"
|
|
200
|
+
>
|
|
201
|
+
<div ref="cubeContainer" style="width: 70px; height: 70px; pointer-events: none" />
|
|
202
|
+
</CameraOrientationDial>
|
|
192
203
|
<div
|
|
204
|
+
v-else
|
|
193
205
|
class="pa-0 overflow-hidden position-relative"
|
|
194
206
|
style="
|
|
195
207
|
height: 220px;
|
|
@@ -236,7 +248,7 @@ watch(hoveredFace, (newFace, oldFace) => {
|
|
|
236
248
|
@mouseleave="hoveredFace = undefined"
|
|
237
249
|
@click.stop="emit('select', orientation.value)"
|
|
238
250
|
>
|
|
239
|
-
<v-tooltip activator="parent" location="top">{{ orientation.
|
|
251
|
+
<v-tooltip activator="parent" location="top">{{ orientation.tooltip }}</v-tooltip>
|
|
240
252
|
<span class="text-caption font-weight-black" style="font-size: 0.7rem !important">{{
|
|
241
253
|
orientation.label
|
|
242
254
|
}}</span>
|
|
@@ -266,8 +278,10 @@ watch(hoveredFace, (newFace, oldFace) => {
|
|
|
266
278
|
@mouseleave="hoveredFace = undefined"
|
|
267
279
|
@click.stop="emit('select', orientation.value)"
|
|
268
280
|
>
|
|
269
|
-
<v-tooltip activator="parent" location="top">{{ orientation.
|
|
270
|
-
<span class="text-caption font-weight-black"
|
|
281
|
+
<v-tooltip activator="parent" location="top">{{ orientation.tooltip }}</v-tooltip>
|
|
282
|
+
<span class="text-caption font-weight-black" :class="{ north: isNorth(orientation) }">{{
|
|
283
|
+
orientation.label
|
|
284
|
+
}}</span>
|
|
271
285
|
</v-btn>
|
|
272
286
|
</div>
|
|
273
287
|
</div>
|
|
@@ -290,6 +304,9 @@ watch(hoveredFace, (newFace, oldFace) => {
|
|
|
290
304
|
.transition-all {
|
|
291
305
|
transition: all 0.4s ease;
|
|
292
306
|
}
|
|
307
|
+
.north {
|
|
308
|
+
color: v-bind(BRAND_ORANGE);
|
|
309
|
+
}
|
|
293
310
|
.orientation-menu {
|
|
294
311
|
min-width: 180px;
|
|
295
312
|
background: rgb(var(--v-theme-surface)) !important;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { BRAND_ORANGE, BRAND_ORANGE_BORDER } from "@ogw_front/utils/brand_colors";
|
|
3
|
+
import {
|
|
4
|
+
COMPASS_TICK_ANGLES,
|
|
5
|
+
compassDialPoint,
|
|
6
|
+
isCardinalAngle,
|
|
7
|
+
} from "@ogw_front/utils/orientation_compass";
|
|
8
|
+
import { type CameraOrientation, isNorth } from "@ogw_front/utils/camera_orientations";
|
|
9
|
+
import { useCompassDial } from "@ogw_front/composables/compass_dial";
|
|
10
|
+
|
|
11
|
+
// Compass layout of the orientation panel, in the look of the scene compass (Viewer/OrientationCompass.vue):
|
|
12
|
+
// The cardinal buttons sit on a dial turned with the camera heading and flattened with its elevation,
|
|
13
|
+
// So each one stays on its side of the cube drawn in the middle (slot). Up and down sit apart.
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
orientations: CameraOrientation[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { orientations } = defineProps<Props>();
|
|
20
|
+
|
|
21
|
+
interface Emits {
|
|
22
|
+
select: [value: string];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const emit = defineEmits<Emits>();
|
|
26
|
+
|
|
27
|
+
const hoveredFace = defineModel<string | undefined>("hoveredFace");
|
|
28
|
+
|
|
29
|
+
const BUTTON_RADIUS = 82;
|
|
30
|
+
const TICK_OUTER_RADIUS = 62;
|
|
31
|
+
const TICK_INNER_RADIUS = 57;
|
|
32
|
+
const CARDINAL_TICK_INNER_RADIUS = 51;
|
|
33
|
+
// Up and down, in pixels from the panel center
|
|
34
|
+
const VERTICAL_X = 98;
|
|
35
|
+
const VERTICAL_Y = 80;
|
|
36
|
+
|
|
37
|
+
const { heading, tilt } = useCompassDial();
|
|
38
|
+
|
|
39
|
+
const dialTransform = computed(() => `scale(1 ${tilt.value}) rotate(${-heading.value})`);
|
|
40
|
+
|
|
41
|
+
interface PlacedOrientation {
|
|
42
|
+
orientation: CameraOrientation;
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const placed = computed<PlacedOrientation[]>(() =>
|
|
48
|
+
orientations.map((orientation) => {
|
|
49
|
+
if (orientation.vertical !== undefined) {
|
|
50
|
+
const sign = orientation.vertical === "up" ? -1 : 1;
|
|
51
|
+
return { orientation, x: VERTICAL_X, y: sign * VERTICAL_Y };
|
|
52
|
+
}
|
|
53
|
+
const { x, y } = compassDialPoint(
|
|
54
|
+
orientation.heading ?? 0,
|
|
55
|
+
BUTTON_RADIUS,
|
|
56
|
+
heading.value,
|
|
57
|
+
tilt.value,
|
|
58
|
+
);
|
|
59
|
+
return { orientation, x, y };
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const hoveredHeading = computed(
|
|
64
|
+
() => orientations.find((orientation) => orientation.face === hoveredFace.value)?.heading,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
function tickInnerRadius(angle: number): number {
|
|
68
|
+
return isCardinalAngle(angle) ? CARDINAL_TICK_INNER_RADIUS : TICK_INNER_RADIUS;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function nodeStyle({ x, y }: PlacedOrientation): Record<string, string> {
|
|
72
|
+
return { top: `calc(50% + ${y}px)`, left: `calc(50% + ${x}px)` };
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
77
|
+
<div class="compass-dial position-relative" data-testid="cameraOrientationDial">
|
|
78
|
+
<svg class="position-absolute w-100 h-100" aria-hidden="true">
|
|
79
|
+
<svg x="50%" y="50%" overflow="visible">
|
|
80
|
+
<g :transform="dialTransform">
|
|
81
|
+
<ellipse class="ring" :rx="TICK_OUTER_RADIUS" :ry="TICK_OUTER_RADIUS" />
|
|
82
|
+
<line
|
|
83
|
+
v-for="angle in COMPASS_TICK_ANGLES"
|
|
84
|
+
:key="angle"
|
|
85
|
+
class="tick"
|
|
86
|
+
:class="{ north: angle === 0, hovered: angle === hoveredHeading }"
|
|
87
|
+
:y1="-tickInnerRadius(angle)"
|
|
88
|
+
:y2="-TICK_OUTER_RADIUS"
|
|
89
|
+
:transform="`rotate(${angle})`"
|
|
90
|
+
/>
|
|
91
|
+
</g>
|
|
92
|
+
</svg>
|
|
93
|
+
</svg>
|
|
94
|
+
|
|
95
|
+
<div class="cube position-absolute">
|
|
96
|
+
<slot />
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<v-btn
|
|
100
|
+
v-for="item in placed"
|
|
101
|
+
:key="item.orientation.value"
|
|
102
|
+
icon
|
|
103
|
+
variant="text"
|
|
104
|
+
size="32"
|
|
105
|
+
class="compass-node position-absolute"
|
|
106
|
+
:class="{
|
|
107
|
+
north: isNorth(item.orientation),
|
|
108
|
+
vertical: item.orientation.vertical !== undefined,
|
|
109
|
+
}"
|
|
110
|
+
:style="nodeStyle(item)"
|
|
111
|
+
:data-testid="`cameraOrientation${item.orientation.vtkKey}Button`"
|
|
112
|
+
@mouseenter="hoveredFace = item.orientation.face"
|
|
113
|
+
@mouseleave="hoveredFace = undefined"
|
|
114
|
+
@click.stop="emit('select', item.orientation.value)"
|
|
115
|
+
>
|
|
116
|
+
<v-tooltip activator="parent" location="top">{{ item.orientation.tooltip }}</v-tooltip>
|
|
117
|
+
<span class="compass-letter">{{ item.orientation.label }}</span>
|
|
118
|
+
</v-btn>
|
|
119
|
+
</div>
|
|
120
|
+
</template>
|
|
121
|
+
|
|
122
|
+
<style scoped>
|
|
123
|
+
.compass-dial {
|
|
124
|
+
height: 220px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.cube {
|
|
128
|
+
top: 50%;
|
|
129
|
+
left: 50%;
|
|
130
|
+
transform: translate(-50%, -50%);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.ring {
|
|
134
|
+
fill: rgba(var(--v-theme-surface), 0.72);
|
|
135
|
+
stroke: rgba(var(--v-border-color), var(--v-border-opacity));
|
|
136
|
+
stroke-width: 1px;
|
|
137
|
+
vector-effect: non-scaling-stroke;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.tick {
|
|
141
|
+
stroke: rgba(var(--v-theme-on-surface), 0.35);
|
|
142
|
+
stroke-width: 1px;
|
|
143
|
+
vector-effect: non-scaling-stroke;
|
|
144
|
+
transition: stroke 0.2s ease;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.tick.north,
|
|
148
|
+
.tick.north.hovered {
|
|
149
|
+
stroke: v-bind(BRAND_ORANGE);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.tick.hovered {
|
|
153
|
+
stroke: rgb(var(--v-theme-on-surface));
|
|
154
|
+
stroke-width: 2px;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* Round targets of the scene compass: translucent surface, thin border, brighter on hover */
|
|
158
|
+
.compass-node {
|
|
159
|
+
transform: translate(-50%, -50%);
|
|
160
|
+
border: 1px solid rgba(var(--v-border-color), var(--v-border-opacity));
|
|
161
|
+
background: rgba(var(--v-theme-surface), 0.72) !important;
|
|
162
|
+
backdrop-filter: blur(6px);
|
|
163
|
+
transition:
|
|
164
|
+
background-color 0.2s ease,
|
|
165
|
+
border-color 0.2s ease;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.compass-node:hover,
|
|
169
|
+
.compass-node:focus-visible {
|
|
170
|
+
border-color: rgba(var(--v-theme-on-surface), 0.35);
|
|
171
|
+
background: rgba(var(--v-theme-surface), 0.86) !important;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.compass-node.north,
|
|
175
|
+
.compass-node.north:hover {
|
|
176
|
+
border-color: v-bind(BRAND_ORANGE_BORDER);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.compass-letter {
|
|
180
|
+
color: rgb(var(--v-theme-on-surface));
|
|
181
|
+
font-size: 11px;
|
|
182
|
+
font-weight: 500;
|
|
183
|
+
letter-spacing: 0;
|
|
184
|
+
text-transform: none;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.compass-node.north .compass-letter {
|
|
188
|
+
color: v-bind(BRAND_ORANGE);
|
|
189
|
+
font-weight: 600;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.compass-node.vertical .compass-letter {
|
|
193
|
+
font-size: 10px;
|
|
194
|
+
}
|
|
195
|
+
</style>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { cameraViewBasis, toCameraPose } from "@ogw_front/utils/orientation_gizmo";
|
|
3
2
|
import {
|
|
3
|
+
COMPASS_TICK_ANGLES,
|
|
4
|
+
QUARTER_TURN,
|
|
4
5
|
compassDialPoint,
|
|
5
|
-
compassHeading,
|
|
6
|
-
compassTilt,
|
|
7
6
|
facingCameraPose,
|
|
7
|
+
isCardinalAngle,
|
|
8
8
|
isFacing,
|
|
9
9
|
} from "@ogw_front/utils/orientation_compass";
|
|
10
|
+
import { BRAND_ORANGE } from "@ogw_front/utils/brand_colors";
|
|
10
11
|
import type { CameraOptions } from "@ogw_internal/stores/hybrid_viewer/vtk_types";
|
|
12
|
+
import { toCameraPose } from "@ogw_front/utils/orientation_gizmo";
|
|
13
|
+
import { useCompassDial } from "@ogw_front/composables/compass_dial";
|
|
11
14
|
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
12
15
|
|
|
13
16
|
// Compass in the app theme: the dial turns with the camera heading (north = world +Y) and flattens
|
|
@@ -26,13 +29,6 @@ const LETTER_HIT_RADIUS = 9;
|
|
|
26
29
|
const NEEDLE_LENGTH = 18;
|
|
27
30
|
const NEEDLE_HALF_WIDTH = 3.5;
|
|
28
31
|
const HUB_RADIUS = 2.5;
|
|
29
|
-
const TICK_STEP = 30;
|
|
30
|
-
const QUARTER_TURN = 90;
|
|
31
|
-
const FULL_TURN = 360;
|
|
32
|
-
const TICK_ANGLES = Array.from(
|
|
33
|
-
{ length: FULL_TURN / TICK_STEP },
|
|
34
|
-
(_item, index) => index * TICK_STEP,
|
|
35
|
-
);
|
|
36
32
|
const NORTH = 0;
|
|
37
33
|
const LETTERS = [
|
|
38
34
|
{ label: "N", name: "north", angle: NORTH },
|
|
@@ -44,26 +40,7 @@ const NORTH_NEEDLE = `M0 ${-NEEDLE_LENGTH} L${NEEDLE_HALF_WIDTH} 0 L${-NEEDLE_HA
|
|
|
44
40
|
const SOUTH_NEEDLE = `M0 ${NEEDLE_LENGTH} L${NEEDLE_HALF_WIDTH} 0 L${-NEEDLE_HALF_WIDTH} 0 Z`;
|
|
45
41
|
|
|
46
42
|
const hybridViewerStore = useHybridViewerStore();
|
|
47
|
-
|
|
48
|
-
const basis = computed(() => {
|
|
49
|
-
const pose = toCameraPose(hybridViewerStore.camera_options);
|
|
50
|
-
return pose && cameraViewBasis(pose);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// The last readable heading is kept while the camera is rolled until no heading can be read
|
|
54
|
-
const heading = ref(0);
|
|
55
|
-
const tilt = ref(1);
|
|
56
|
-
watch(
|
|
57
|
-
basis,
|
|
58
|
-
(value) => {
|
|
59
|
-
if (!value) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
heading.value = compassHeading(value) ?? heading.value;
|
|
63
|
-
tilt.value = compassTilt(value);
|
|
64
|
-
},
|
|
65
|
-
{ immediate: true },
|
|
66
|
-
);
|
|
43
|
+
const { basis, heading, tilt } = useCompassDial();
|
|
67
44
|
|
|
68
45
|
const dialTransform = computed(() => `scale(1 ${tilt.value}) rotate(${-heading.value})`);
|
|
69
46
|
const letters = computed(() =>
|
|
@@ -74,7 +51,7 @@ const letters = computed(() =>
|
|
|
74
51
|
);
|
|
75
52
|
|
|
76
53
|
function tickInnerRadius(angle: number): number {
|
|
77
|
-
return angle
|
|
54
|
+
return isCardinalAngle(angle) ? CARDINAL_TICK_INNER_RADIUS : TICK_INNER_RADIUS;
|
|
78
55
|
}
|
|
79
56
|
|
|
80
57
|
function face(targetHeading: number): void {
|
|
@@ -116,7 +93,7 @@ function face(targetHeading: number): void {
|
|
|
116
93
|
>
|
|
117
94
|
<g :transform="dialTransform">
|
|
118
95
|
<line
|
|
119
|
-
v-for="angle in
|
|
96
|
+
v-for="angle in COMPASS_TICK_ANGLES"
|
|
120
97
|
:key="angle"
|
|
121
98
|
class="tick"
|
|
122
99
|
:y1="-tickInnerRadius(angle)"
|
|
@@ -182,7 +159,7 @@ function face(targetHeading: number): void {
|
|
|
182
159
|
}
|
|
183
160
|
|
|
184
161
|
.needle-north {
|
|
185
|
-
fill:
|
|
162
|
+
fill: v-bind(BRAND_ORANGE);
|
|
186
163
|
}
|
|
187
164
|
|
|
188
165
|
.needle-south {
|
|
@@ -217,7 +194,7 @@ function face(targetHeading: number): void {
|
|
|
217
194
|
}
|
|
218
195
|
|
|
219
196
|
.letter.north {
|
|
220
|
-
fill:
|
|
197
|
+
fill: v-bind(BRAND_ORANGE);
|
|
221
198
|
font-weight: 600;
|
|
222
199
|
}
|
|
223
200
|
</style>
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
strataRings,
|
|
9
9
|
} from "@ogw_front/utils/orientation_globe";
|
|
10
10
|
import { cameraViewBasis, toCameraPose } from "@ogw_front/utils/orientation_gizmo";
|
|
11
|
+
import { BRAND_ORANGE } from "@ogw_front/utils/brand_colors";
|
|
11
12
|
import { compassHeading } from "@ogw_front/utils/orientation_compass";
|
|
12
13
|
import { strataPixels } from "@ogw_front/utils/orientation_strata";
|
|
13
14
|
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
@@ -35,7 +36,6 @@ const LIGHT_INK_LUMINANCE = 0.5;
|
|
|
35
36
|
const LUMINANCE_WEIGHTS = { red: 0.2126, green: 0.7152, blue: 0.0722 } as const;
|
|
36
37
|
const MAX_CHANNEL = 255;
|
|
37
38
|
const AXIS_COLORS = { x: "#D9553B", y: "#3F8F63", z: "#3567B5" } as const;
|
|
38
|
-
const ORANGE = "#F48830";
|
|
39
39
|
|
|
40
40
|
const hybridViewerStore = useHybridViewerStore();
|
|
41
41
|
const dataStyleStore = useDataStyleStore();
|
|
@@ -320,7 +320,7 @@ svg {
|
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
.north {
|
|
323
|
-
fill: v-bind(
|
|
323
|
+
fill: v-bind(BRAND_ORANGE);
|
|
324
324
|
stroke: #e8eef0;
|
|
325
325
|
stroke-width: 1.5px;
|
|
326
326
|
pointer-events: none;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ComputedRef, Ref } from "vue";
|
|
2
|
+
import { type ViewBasis, cameraViewBasis, toCameraPose } from "@ogw_front/utils/orientation_gizmo";
|
|
3
|
+
import { compassHeading, compassTilt } from "@ogw_front/utils/orientation_compass";
|
|
4
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
5
|
+
|
|
6
|
+
interface CompassDial {
|
|
7
|
+
basis: ComputedRef<ViewBasis | undefined>;
|
|
8
|
+
// Clockwise angle in degrees from north to the direction the camera looks at
|
|
9
|
+
heading: Ref<number>;
|
|
10
|
+
// Vertical scale of the dial with the camera elevation
|
|
11
|
+
tilt: Ref<number>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Dial of a compass following the viewer camera: the scene compass (Viewer/OrientationCompass.vue)
|
|
15
|
+
// And the compass layout of the orientation panel (CameraOrientationDial.vue) turn the same way.
|
|
16
|
+
// The last readable heading is kept while the camera is rolled until no heading can be read.
|
|
17
|
+
function useCompassDial(): CompassDial {
|
|
18
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
19
|
+
const basis = computed(() => {
|
|
20
|
+
const pose = toCameraPose(hybridViewerStore.camera_options);
|
|
21
|
+
return pose && cameraViewBasis(pose);
|
|
22
|
+
});
|
|
23
|
+
const heading = ref(0);
|
|
24
|
+
const tilt = ref(1);
|
|
25
|
+
watch(
|
|
26
|
+
basis,
|
|
27
|
+
(value) => {
|
|
28
|
+
if (!value) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
heading.value = compassHeading(value) ?? heading.value;
|
|
32
|
+
tilt.value = compassTilt(value);
|
|
33
|
+
},
|
|
34
|
+
{ immediate: true },
|
|
35
|
+
);
|
|
36
|
+
return { basis, heading, tilt };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { useCompassDial };
|
|
40
|
+
export type { CompassDial };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Brand colors drawn by the front itself (orientation markers, camera orientation panel). Components bind
|
|
2
|
+
// Them in their styles with v-bind() so the value lives here only.
|
|
3
|
+
|
|
4
|
+
// Geode Solutions orange: the north of the compasses and of the axes globe
|
|
5
|
+
const BRAND_ORANGE = "#F48830";
|
|
6
|
+
// The north border of the round targets: the orange, a bit transparent
|
|
7
|
+
const BRAND_ORANGE_BORDER = `color-mix(in srgb, ${BRAND_ORANGE} 60%, transparent)`;
|
|
8
|
+
|
|
9
|
+
export { BRAND_ORANGE, BRAND_ORANGE_BORDER };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Camera orientations of the orientation panel (CameraOrientation.vue). Each one looks from a world
|
|
2
|
+
// Axis; with the compass marker, the labels follow the scene compass (north = world +Y, east = +X,
|
|
3
|
+
// Up = +Z, see utils/orientation_compass.ts) instead of the axis names.
|
|
4
|
+
import type { SceneOrientationWidget } from "@ogw_internal/stores/data_style/types";
|
|
5
|
+
|
|
6
|
+
const QUARTER_TURN = 90;
|
|
7
|
+
const HALF_TURN = 180;
|
|
8
|
+
|
|
9
|
+
// A type alias, not an interface: it is bound to the style of a button, whose CSS properties take an
|
|
10
|
+
// Index signature (custom properties) that interfaces do not satisfy
|
|
11
|
+
type PanelPosition = Record<"top" | "left", string>;
|
|
12
|
+
|
|
13
|
+
interface CameraOrientation {
|
|
14
|
+
// Key of hybridViewerStore.setCameraOrientation
|
|
15
|
+
value: string;
|
|
16
|
+
face: string;
|
|
17
|
+
vtkKey: string;
|
|
18
|
+
// Rotation of the label on its cube face
|
|
19
|
+
rotation: number;
|
|
20
|
+
// Place around the cube in the panel with the axes marker
|
|
21
|
+
position: PanelPosition;
|
|
22
|
+
label: string;
|
|
23
|
+
tooltip: string;
|
|
24
|
+
// Clockwise angle in degrees from north of the side it looks from, with the compass marker
|
|
25
|
+
heading?: number;
|
|
26
|
+
// Looks from above or below, with the compass marker
|
|
27
|
+
vertical?: Vertical;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type Vertical = "up" | "down";
|
|
31
|
+
|
|
32
|
+
interface OrientationEntry {
|
|
33
|
+
value: string;
|
|
34
|
+
face: string;
|
|
35
|
+
vtkKey: string;
|
|
36
|
+
rotation: number;
|
|
37
|
+
position: PanelPosition;
|
|
38
|
+
axisLabel: string;
|
|
39
|
+
compassLabel: string;
|
|
40
|
+
// Side it looks from, as read in "View from ..."
|
|
41
|
+
compassName: string;
|
|
42
|
+
heading?: number;
|
|
43
|
+
vertical?: Vertical;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const ORIENTATIONS: readonly OrientationEntry[] = [
|
|
47
|
+
{
|
|
48
|
+
value: "zplus",
|
|
49
|
+
face: "top",
|
|
50
|
+
vtkKey: "ZPlus",
|
|
51
|
+
rotation: 0,
|
|
52
|
+
position: { top: "15%", left: "50%" },
|
|
53
|
+
axisLabel: "Z+",
|
|
54
|
+
compassLabel: "Up",
|
|
55
|
+
compassName: "above",
|
|
56
|
+
vertical: "up",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: "zminus",
|
|
60
|
+
face: "bottom",
|
|
61
|
+
vtkKey: "ZMinus",
|
|
62
|
+
rotation: 0,
|
|
63
|
+
position: { top: "85%", left: "50%" },
|
|
64
|
+
axisLabel: "Z-",
|
|
65
|
+
compassLabel: "Down",
|
|
66
|
+
compassName: "below",
|
|
67
|
+
vertical: "down",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
value: "yplus",
|
|
71
|
+
face: "front",
|
|
72
|
+
vtkKey: "YPlus",
|
|
73
|
+
rotation: HALF_TURN,
|
|
74
|
+
position: { top: "35%", left: "22%" },
|
|
75
|
+
axisLabel: "Y+",
|
|
76
|
+
compassLabel: "N",
|
|
77
|
+
compassName: "north",
|
|
78
|
+
heading: 0,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
value: "yminus",
|
|
82
|
+
face: "back",
|
|
83
|
+
vtkKey: "YMinus",
|
|
84
|
+
rotation: 0,
|
|
85
|
+
position: { top: "65%", left: "78%" },
|
|
86
|
+
axisLabel: "Y-",
|
|
87
|
+
compassLabel: "S",
|
|
88
|
+
compassName: "south",
|
|
89
|
+
heading: HALF_TURN,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
value: "xplus",
|
|
93
|
+
face: "right",
|
|
94
|
+
vtkKey: "XPlus",
|
|
95
|
+
rotation: QUARTER_TURN,
|
|
96
|
+
position: { top: "35%", left: "78%" },
|
|
97
|
+
axisLabel: "X+",
|
|
98
|
+
compassLabel: "E",
|
|
99
|
+
compassName: "east",
|
|
100
|
+
heading: QUARTER_TURN,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
value: "xminus",
|
|
104
|
+
face: "left",
|
|
105
|
+
vtkKey: "XMinus",
|
|
106
|
+
rotation: -QUARTER_TURN,
|
|
107
|
+
position: { top: "65%", left: "22%" },
|
|
108
|
+
axisLabel: "X-",
|
|
109
|
+
compassLabel: "W",
|
|
110
|
+
compassName: "west",
|
|
111
|
+
heading: 3 * QUARTER_TURN,
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
function cameraOrientations(marker: SceneOrientationWidget): CameraOrientation[] {
|
|
116
|
+
const isCompass = marker === "compass";
|
|
117
|
+
return ORIENTATIONS.map((entry) => ({
|
|
118
|
+
value: entry.value,
|
|
119
|
+
face: entry.face,
|
|
120
|
+
vtkKey: entry.vtkKey,
|
|
121
|
+
rotation: entry.rotation,
|
|
122
|
+
position: entry.position,
|
|
123
|
+
label: isCompass ? entry.compassLabel : entry.axisLabel,
|
|
124
|
+
tooltip: isCompass ? `View from ${entry.compassName}` : `${entry.value} View`,
|
|
125
|
+
heading: isCompass ? entry.heading : undefined,
|
|
126
|
+
vertical: isCompass ? entry.vertical : undefined,
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// The north is the brand orange, as on the scene compass
|
|
131
|
+
function isNorth(orientation: CameraOrientation): boolean {
|
|
132
|
+
return orientation.heading === 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { cameraOrientations, isNorth };
|
|
136
|
+
export type { CameraOrientation, Vertical };
|
|
@@ -11,6 +11,13 @@ const MIN_COMPASS_TILT = 0.6;
|
|
|
11
11
|
// Under this heading gap in degrees, the camera already faces the direction: nothing to turn
|
|
12
12
|
const FACING_TOLERANCE = 0.5;
|
|
13
13
|
const FULL_TURN = 360;
|
|
14
|
+
const QUARTER_TURN = 90;
|
|
15
|
+
// The dials are graduated every 30 degrees, the cardinal ticks longer
|
|
16
|
+
const TICK_STEP = 30;
|
|
17
|
+
const COMPASS_TICK_ANGLES: readonly number[] = Array.from(
|
|
18
|
+
{ length: FULL_TURN / TICK_STEP },
|
|
19
|
+
(_item, index) => index * TICK_STEP,
|
|
20
|
+
);
|
|
14
21
|
|
|
15
22
|
interface DialPoint {
|
|
16
23
|
x: number;
|
|
@@ -87,16 +94,24 @@ function facingCameraPose(
|
|
|
87
94
|
};
|
|
88
95
|
}
|
|
89
96
|
|
|
97
|
+
// Whether the dial angle, clockwise in degrees from north, is a cardinal direction (N, E, S or W)
|
|
98
|
+
function isCardinalAngle(angle: number): boolean {
|
|
99
|
+
return angle % QUARTER_TURN === 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
90
102
|
function northUpCameraPose(pose: CameraPose, basis: ViewBasis): CameraPose | undefined {
|
|
91
103
|
return facingCameraPose(pose, basis, 0);
|
|
92
104
|
}
|
|
93
105
|
|
|
94
106
|
export {
|
|
107
|
+
COMPASS_TICK_ANGLES,
|
|
95
108
|
MIN_COMPASS_TILT,
|
|
109
|
+
QUARTER_TURN,
|
|
96
110
|
compassDialPoint,
|
|
97
111
|
compassHeading,
|
|
98
112
|
compassTilt,
|
|
99
113
|
facingCameraPose,
|
|
114
|
+
isCardinalAngle,
|
|
100
115
|
isFacing,
|
|
101
116
|
northUpCameraPose,
|
|
102
117
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Colors of the orientation cube of the camera orientation panel (CameraOrientation.vue), from the
|
|
2
|
+
// Vuetify theme it is shown in: faces a bit off the surface, labels and edges in the surface ink,
|
|
3
|
+
// The hovered face inverted. The cube is drawn by vtk.js on canvases, so it takes CSS color strings.
|
|
4
|
+
import type { ColorRGB } from "@geode/opengeodeweb-viewer/schema_types";
|
|
5
|
+
|
|
6
|
+
const HEX_BASE = 16;
|
|
7
|
+
const CHANNEL_LENGTH = 2;
|
|
8
|
+
const HEX_COLOR = /^#?(?<hex>[\da-f]{6})/iu;
|
|
9
|
+
// Part of the ink in the face color: the faces stand out of the panel without competing with labels
|
|
10
|
+
const FACE_INK_RATIO = 0.15;
|
|
11
|
+
const EDGE_OPACITY = 0.4;
|
|
12
|
+
const HOVERED_FACE_OPACITY = 0.95;
|
|
13
|
+
|
|
14
|
+
// The cube of the dark theme, when the theme has no usable surface colors
|
|
15
|
+
const DARK_SURFACE_CHANNEL = 33;
|
|
16
|
+
const MAX_CHANNEL = 255;
|
|
17
|
+
const FALLBACK_SURFACE: ColorRGB = {
|
|
18
|
+
red: DARK_SURFACE_CHANNEL,
|
|
19
|
+
green: DARK_SURFACE_CHANNEL,
|
|
20
|
+
blue: DARK_SURFACE_CHANNEL,
|
|
21
|
+
};
|
|
22
|
+
const FALLBACK_INK: ColorRGB = { red: MAX_CHANNEL, green: MAX_CHANNEL, blue: MAX_CHANNEL };
|
|
23
|
+
|
|
24
|
+
interface CubeStyle {
|
|
25
|
+
faceColor: string;
|
|
26
|
+
fontColor: string;
|
|
27
|
+
edgeColor: string;
|
|
28
|
+
hoveredFaceColor: string;
|
|
29
|
+
hoveredFontColor: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function hexChannel(hex: string, index: number): number {
|
|
33
|
+
return Number.parseInt(hex.slice(index * CHANNEL_LENGTH, (index + 1) * CHANNEL_LENGTH), HEX_BASE);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Vuetify resolves its theme colors to #RRGGBB strings
|
|
37
|
+
function parseHex(color: unknown): ColorRGB | undefined {
|
|
38
|
+
const hex = typeof color === "string" ? HEX_COLOR.exec(color)?.groups?.hex : undefined;
|
|
39
|
+
if (hex === undefined) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return { red: hexChannel(hex, 0), green: hexChannel(hex, 1), blue: hexChannel(hex, 2) };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function rgba({ red, green, blue }: ColorRGB, alpha = 1): string {
|
|
46
|
+
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function mix(base: ColorRGB, ink: ColorRGB, ratio: number): ColorRGB {
|
|
50
|
+
function channel(key: keyof ColorRGB): number {
|
|
51
|
+
return Math.round(base[key] * (1 - ratio) + ink[key] * ratio);
|
|
52
|
+
}
|
|
53
|
+
return { red: channel("red"), green: channel("green"), blue: channel("blue") };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Cube colors for the theme colors (Vuetify `theme.themes[name].colors`)
|
|
57
|
+
function orientationCubeStyle(colors: Record<"surface" | "on-surface", unknown>): CubeStyle {
|
|
58
|
+
const surface = parseHex(colors.surface) ?? FALLBACK_SURFACE;
|
|
59
|
+
const ink = parseHex(colors["on-surface"]) ?? FALLBACK_INK;
|
|
60
|
+
return {
|
|
61
|
+
faceColor: rgba(mix(surface, ink, FACE_INK_RATIO)),
|
|
62
|
+
fontColor: rgba(ink),
|
|
63
|
+
edgeColor: rgba(ink, EDGE_OPACITY),
|
|
64
|
+
hoveredFaceColor: rgba(ink, HOVERED_FACE_OPACITY),
|
|
65
|
+
hoveredFontColor: rgba(surface),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { orientationCubeStyle };
|
|
70
|
+
export type { CubeStyle };
|
package/package.json
CHANGED