@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.170 → 2.0.0-next.171
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/bundle/openbridge-webcomponents.bundle.js +870 -441
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +1110 -383
- package/dist/ar/poi/poi-aton.d.ts +1 -0
- package/dist/ar/poi/poi-aton.d.ts.map +1 -1
- package/dist/ar/poi/poi-aton.js +1 -0
- package/dist/ar/poi/poi-aton.js.map +1 -1
- package/dist/ar/poi/poi-base.d.ts +39 -5
- package/dist/ar/poi/poi-base.d.ts.map +1 -1
- package/dist/ar/poi/poi-base.js +108 -37
- package/dist/ar/poi/poi-base.js.map +1 -1
- package/dist/ar/poi/poi-data.d.ts +1 -0
- package/dist/ar/poi/poi-data.d.ts.map +1 -1
- package/dist/ar/poi/poi-data.js +1 -0
- package/dist/ar/poi/poi-data.js.map +1 -1
- package/dist/ar/poi/poi-vessel.d.ts +1 -0
- package/dist/ar/poi/poi-vessel.d.ts.map +1 -1
- package/dist/ar/poi/poi-vessel.js +1 -0
- package/dist/ar/poi/poi-vessel.js.map +1 -1
- package/dist/ar/poi/poi.d.ts +4 -12
- package/dist/ar/poi/poi.d.ts.map +1 -1
- package/dist/ar/poi/poi.js +6 -72
- package/dist/ar/poi/poi.js.map +1 -1
- package/dist/ar/poi-button/poi-button.d.ts +6 -2
- package/dist/ar/poi-button/poi-button.d.ts.map +1 -1
- package/dist/ar/poi-button/poi-button.js +10 -1
- package/dist/ar/poi-button/poi-button.js.map +1 -1
- package/dist/ar/poi-card/poi-card.d.ts +12 -1
- package/dist/ar/poi-card/poi-card.d.ts.map +1 -1
- package/dist/ar/poi-card/poi-card.js +4 -1
- package/dist/ar/poi-card/poi-card.js.map +1 -1
- package/dist/ar/poi-controller/poi-controller.d.ts +45 -1
- package/dist/ar/poi-controller/poi-controller.d.ts.map +1 -1
- package/dist/ar/poi-controller/poi-controller.js +72 -14
- package/dist/ar/poi-controller/poi-controller.js.map +1 -1
- package/dist/ar/poi-group/poi-group.d.ts +28 -5
- package/dist/ar/poi-group/poi-group.d.ts.map +1 -1
- package/dist/ar/poi-group/poi-group.js +50 -7
- package/dist/ar/poi-group/poi-group.js.map +1 -1
- package/dist/ar/poi-layer/poi-layer.css.js +69 -18
- package/dist/ar/poi-layer/poi-layer.css.js.map +1 -1
- package/dist/ar/poi-layer/poi-layer.d.ts +64 -5
- package/dist/ar/poi-layer/poi-layer.d.ts.map +1 -1
- package/dist/ar/poi-layer/poi-layer.js +173 -39
- package/dist/ar/poi-layer/poi-layer.js.map +1 -1
- package/dist/ar/poi-layer-stack/poi-layer-stack.d.ts +82 -7
- package/dist/ar/poi-layer-stack/poi-layer-stack.d.ts.map +1 -1
- package/dist/ar/poi-layer-stack/poi-layer-stack.js +172 -100
- package/dist/ar/poi-layer-stack/poi-layer-stack.js.map +1 -1
- package/dist/ar/poi-projection/poi-projection.d.ts +88 -0
- package/dist/ar/poi-projection/poi-projection.d.ts.map +1 -0
- package/dist/ar/poi-projection/poi-projection.js +90 -0
- package/dist/ar/poi-projection/poi-projection.js.map +1 -0
- package/docs/MigrationGuide.mdx +61 -5
- package/docs/migration-guide/a11y-labels.md +8 -0
- package/docs/migration-guide/api-automation.md +1 -0
- package/package.json +2 -2
- package/src/ar/_test-utils.ts +18 -6
- package/src/ar/poi/poi-aton.ts +2 -0
- package/src/ar/poi/poi-base.ts +159 -70
- package/src/ar/poi/poi-data.ts +2 -0
- package/src/ar/poi/poi-dom-ownership.spec.ts +393 -0
- package/src/ar/poi/poi-vessel.ts +2 -0
- package/src/ar/poi/poi.ts +12 -113
- package/src/ar/poi-button/poi-button.ts +25 -3
- package/src/ar/poi-card/poi-card.ts +16 -2
- package/src/ar/poi-controller/poi-controller.spec.ts +54 -0
- package/src/ar/poi-controller/poi-controller.stories.ts +76 -24
- package/src/ar/poi-controller/poi-controller.ts +111 -41
- package/src/ar/poi-group/poi-group.stories.ts +18 -5
- package/src/ar/poi-group/poi-group.ts +87 -12
- package/src/ar/poi-layer/poi-layer.css +69 -18
- package/src/ar/poi-layer/poi-layer.stories.ts +30 -16
- package/src/ar/poi-layer/poi-layer.ts +289 -64
- package/src/ar/poi-layer-stack/poi-layer-stack.stories.ts +56 -23
- package/src/ar/poi-layer-stack/poi-layer-stack.ts +342 -247
- package/src/ar/poi-projection/poi-projection.stories.ts +100 -0
- package/src/ar/poi-projection/poi-projection.ts +147 -0
|
@@ -60,6 +60,13 @@ export enum PointerDirection {
|
|
|
60
60
|
*
|
|
61
61
|
* ## Events
|
|
62
62
|
* - `card-click`: Fired when the card surface is activated in interactive mode.
|
|
63
|
+
* - `close-click`: Fired when the header close button is pressed (`hasCloseButton` with the detailed header variant).
|
|
64
|
+
*
|
|
65
|
+
* ## CSS Parts
|
|
66
|
+
* - `wrapper`: Outer layout wrapper holding the pointer arrows and the card surface.
|
|
67
|
+
* - `content-box`: Card surface with background, border, and rounded corners.
|
|
68
|
+
* - `header`: The `obc-poi-card-header` element, rendered when `showHeader` is true.
|
|
69
|
+
* - `content`: Body area wrapping the default slot.
|
|
63
70
|
*
|
|
64
71
|
* ## Best Practices
|
|
65
72
|
* - Keep `index` stable so event payloads remain predictable.
|
|
@@ -92,8 +99,12 @@ export enum PointerDirection {
|
|
|
92
99
|
* @slot - Main card body content.
|
|
93
100
|
* @slot leading-icon - Optional icon used by the regular header variant.
|
|
94
101
|
* @slot poi-icon - Optional icon used by the detailed header variant.
|
|
102
|
+
* @csspart wrapper - Outer layout wrapper holding the pointer arrows and the card surface.
|
|
103
|
+
* @csspart content-box - Card surface with background, border, and rounded corners.
|
|
104
|
+
* @csspart header - The `obc-poi-card-header` element, rendered when `showHeader` is true.
|
|
105
|
+
* @csspart content - Body area wrapping the default slot.
|
|
95
106
|
* @fires {CustomEvent<PoiCardClickDetail>} card-click - Fired when the card is activated in interactive mode.
|
|
96
|
-
* @fires {CustomEvent<void>} close-click - Passed on from the header when its close button is pressed (`hasCloseButton`).
|
|
107
|
+
* @fires {CustomEvent<void>} close-click - Passed on from the header when its close button is pressed (`hasCloseButton` with the detailed header variant).
|
|
97
108
|
* @experimental
|
|
98
109
|
*/
|
|
99
110
|
@customElement('obc-poi-card')
|
|
@@ -222,6 +233,7 @@ export class ObcPoiCard extends LitElement {
|
|
|
222
233
|
if (!this.showHeader) return nothing;
|
|
223
234
|
return html`
|
|
224
235
|
<obc-poi-card-header
|
|
236
|
+
part="header"
|
|
225
237
|
variant=${this.headerVariant}
|
|
226
238
|
index=${this.index}
|
|
227
239
|
cardTitle=${this.cardTitle}
|
|
@@ -252,6 +264,7 @@ export class ObcPoiCard extends LitElement {
|
|
|
252
264
|
override render() {
|
|
253
265
|
return html`
|
|
254
266
|
<div
|
|
267
|
+
part="wrapper"
|
|
255
268
|
class=${classMap({
|
|
256
269
|
wrapper: true,
|
|
257
270
|
'hug-content': !this.fixedSize,
|
|
@@ -263,6 +276,7 @@ export class ObcPoiCard extends LitElement {
|
|
|
263
276
|
<div class="center">
|
|
264
277
|
${this.renderLeftPointer()}
|
|
265
278
|
<div
|
|
279
|
+
part="content-box"
|
|
266
280
|
class="content-box"
|
|
267
281
|
role=${this.interactive ? 'button' : nothing}
|
|
268
282
|
tabindex=${this.interactive ? '0' : nothing}
|
|
@@ -272,7 +286,7 @@ export class ObcPoiCard extends LitElement {
|
|
|
272
286
|
@keyup=${this.handleKeyUp}
|
|
273
287
|
>
|
|
274
288
|
${this.renderHeader()}
|
|
275
|
-
<div class="content">
|
|
289
|
+
<div part="content" class="content">
|
|
276
290
|
<slot></slot>
|
|
277
291
|
</div>
|
|
278
292
|
${this.renderAlertLayer()}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {afterEach, describe, expect, it} from 'vitest';
|
|
2
|
+
import './poi-controller.js';
|
|
3
|
+
import type {ObcPoiController} from './poi-controller.js';
|
|
4
|
+
import type {PoiBase} from '../poi/poi-base.js';
|
|
5
|
+
|
|
6
|
+
const MEDIA =
|
|
7
|
+
'data:image/svg+xml,' +
|
|
8
|
+
encodeURIComponent(
|
|
9
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="640" height="360"></svg>'
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const nextFrame = () =>
|
|
13
|
+
new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
document.body.innerHTML = '';
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('obc-poi-controller filter cutoffs', () => {
|
|
20
|
+
it('returns reused targets to their default when an override is cleared', async () => {
|
|
21
|
+
document.body.innerHTML = `
|
|
22
|
+
<obc-poi-controller style="display: block; width: 640px; height: 360px">
|
|
23
|
+
<img slot="media" alt="" src="${MEDIA}" />
|
|
24
|
+
<obc-poi-layer-stack slot="stack">
|
|
25
|
+
<obc-poi-layer data-controller-layer="background"></obc-poi-layer>
|
|
26
|
+
</obc-poi-layer-stack>
|
|
27
|
+
</obc-poi-controller>
|
|
28
|
+
`;
|
|
29
|
+
const controller = document.querySelector(
|
|
30
|
+
'obc-poi-controller'
|
|
31
|
+
) as ObcPoiController;
|
|
32
|
+
await (document.querySelector('img') as HTMLImageElement).decode();
|
|
33
|
+
const defaults = document.createElement('obc-poi-data') as PoiBase;
|
|
34
|
+
|
|
35
|
+
controller.xFilterCutoffHz = 0;
|
|
36
|
+
controller.yFilterCutoffHz = 0;
|
|
37
|
+
controller.detections = [{id: 'a', x: 320, y: 180}];
|
|
38
|
+
await controller.updateComplete;
|
|
39
|
+
await nextFrame();
|
|
40
|
+
const target = controller.querySelector('obc-poi-data') as PoiBase;
|
|
41
|
+
expect(target).not.toBeNull();
|
|
42
|
+
expect(target.xFilterCutoffHz).toBe(0);
|
|
43
|
+
expect(target.yFilterCutoffHz).toBe(0);
|
|
44
|
+
|
|
45
|
+
controller.xFilterCutoffHz = null;
|
|
46
|
+
controller.yFilterCutoffHz = null;
|
|
47
|
+
controller.detections = [{id: 'a', x: 330, y: 180}];
|
|
48
|
+
await controller.updateComplete;
|
|
49
|
+
await nextFrame();
|
|
50
|
+
expect(controller.querySelector('obc-poi-data')).toBe(target);
|
|
51
|
+
expect(target.xFilterCutoffHz).toBe(defaults.xFilterCutoffHz);
|
|
52
|
+
expect(target.yFilterCutoffHz).toBe(defaults.yFilterCutoffHz);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type {Meta, StoryObj} from '@storybook/web-components-vite';
|
|
2
2
|
import {html} from 'lit';
|
|
3
3
|
import './poi-controller.js';
|
|
4
|
-
import {PoiFitMode} from './poi-controller.js';
|
|
4
|
+
import {PoiDetectionVariant, PoiFitMode} from './poi-controller.js';
|
|
5
5
|
import {PoiLayerSelectionMode} from '../poi-layer-stack/poi-layer-stack.js';
|
|
6
6
|
import '../poi/poi-data.js';
|
|
7
7
|
import '../poi/poi-aton.js';
|
|
8
8
|
import '../poi/poi-vessel.js';
|
|
9
9
|
import '../../icons/icon-beacon-general-east.js';
|
|
10
10
|
import '../../icons/icon-vessel-type-psv-outlined.js';
|
|
11
|
+
import {
|
|
12
|
+
isVitestBrowser,
|
|
13
|
+
waitForStorySettle as waitForSharedStorySettle,
|
|
14
|
+
} from '../_test-utils.js';
|
|
11
15
|
import {normalizeAngle, radToDeg} from '../../svghelpers/math.js';
|
|
12
16
|
|
|
13
|
-
const isVitestBrowser = Boolean(
|
|
14
|
-
(globalThis as {__vitest_browser__?: unknown}).__vitest_browser__
|
|
15
|
-
);
|
|
16
|
-
|
|
17
17
|
type PoiControllerArgs = {
|
|
18
18
|
fit: PoiFitMode;
|
|
19
19
|
classFilter: string[];
|
|
@@ -59,22 +59,7 @@ const waitForStorySettle = async (
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
await (document as Document & {fonts?: FontFaceSet}).fonts?.ready;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
await new Promise<void>((resolve) =>
|
|
67
|
-
requestAnimationFrame(() => requestAnimationFrame(() => resolve()))
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
if (options.drainTransitions && isVitestBrowser) {
|
|
71
|
-
await new Promise<void>((resolve) => {
|
|
72
|
-
setTimeout(resolve, 220);
|
|
73
|
-
});
|
|
74
|
-
await new Promise<void>((resolve) =>
|
|
75
|
-
requestAnimationFrame(() => requestAnimationFrame(() => resolve()))
|
|
76
|
-
);
|
|
77
|
-
}
|
|
62
|
+
await waitForSharedStorySettle(options);
|
|
78
63
|
};
|
|
79
64
|
|
|
80
65
|
const meta: Meta<PoiControllerArgs> = {
|
|
@@ -139,7 +124,7 @@ const meta: Meta<PoiControllerArgs> = {
|
|
|
139
124
|
.fit=${args.fit}
|
|
140
125
|
.classFilter=${args.classFilter}
|
|
141
126
|
>
|
|
142
|
-
<img slot="media" src="/assets/AR-test-image.png" />
|
|
127
|
+
<img slot="media" src="/assets/AR-test-image.png" alt="Camera view" />
|
|
143
128
|
<obc-poi-layer-stack
|
|
144
129
|
slot="stack"
|
|
145
130
|
selection-mode=${PoiLayerSelectionMode.Multi}
|
|
@@ -219,7 +204,7 @@ export const SelectionMultiAnimated: Story = {
|
|
|
219
204
|
.fit=${args.fit}
|
|
220
205
|
.classFilter=${args.classFilter}
|
|
221
206
|
>
|
|
222
|
-
<img slot="media" src="/assets/AR-test-image.png" />
|
|
207
|
+
<img slot="media" src="/assets/AR-test-image.png" alt="Camera view" />
|
|
223
208
|
<obc-poi-layer-stack
|
|
224
209
|
slot="stack"
|
|
225
210
|
class="stack-animated"
|
|
@@ -436,7 +421,7 @@ export const BottomLayerWithValues: Story = {
|
|
|
436
421
|
.fit=${args.fit}
|
|
437
422
|
.classFilter=${args.classFilter}
|
|
438
423
|
>
|
|
439
|
-
<img slot="media" src="/assets/AR-test-image.png" />
|
|
424
|
+
<img slot="media" src="/assets/AR-test-image.png" alt="Camera view" />
|
|
440
425
|
<obc-poi-layer-stack
|
|
441
426
|
slot="stack"
|
|
442
427
|
class="stack-values"
|
|
@@ -500,3 +485,70 @@ export const BottomLayerWithValues: Story = {
|
|
|
500
485
|
}
|
|
501
486
|
},
|
|
502
487
|
};
|
|
488
|
+
|
|
489
|
+
export const DetectionVariants: Story = {
|
|
490
|
+
args: {},
|
|
491
|
+
render: (args) => {
|
|
492
|
+
const detections = [
|
|
493
|
+
{
|
|
494
|
+
x: 420,
|
|
495
|
+
y: 1180,
|
|
496
|
+
box_width: 46,
|
|
497
|
+
box_height: 38,
|
|
498
|
+
id: 'vessel-1',
|
|
499
|
+
variant: PoiDetectionVariant.Vessel,
|
|
500
|
+
icon: 'obi-vessel-type-psv-outlined',
|
|
501
|
+
heading: 45,
|
|
502
|
+
data: [{label: 'SPD', value: '9.2', unit: 'kts'}],
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
x: 900,
|
|
506
|
+
y: 1150,
|
|
507
|
+
box_width: 30,
|
|
508
|
+
box_height: 40,
|
|
509
|
+
id: 'aton-1',
|
|
510
|
+
variant: PoiDetectionVariant.Aton,
|
|
511
|
+
icon: 'obi-beacon-general-east',
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
x: 1400,
|
|
515
|
+
y: 1210,
|
|
516
|
+
box_width: 40,
|
|
517
|
+
box_height: 36,
|
|
518
|
+
id: 'data-1',
|
|
519
|
+
},
|
|
520
|
+
];
|
|
521
|
+
|
|
522
|
+
return html`
|
|
523
|
+
<style>
|
|
524
|
+
.variants-stage {
|
|
525
|
+
width: 100%;
|
|
526
|
+
max-width: 1200px;
|
|
527
|
+
aspect-ratio: 16 / 9;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.variants-stage img {
|
|
531
|
+
width: 100%;
|
|
532
|
+
height: 100%;
|
|
533
|
+
object-fit: cover;
|
|
534
|
+
display: block;
|
|
535
|
+
}
|
|
536
|
+
</style>
|
|
537
|
+
<div class="variants-stage">
|
|
538
|
+
<obc-poi-controller .detections=${detections} .fit=${args.fit}>
|
|
539
|
+
<img slot="media" src="/assets/AR-test-image.png" alt="Camera view" />
|
|
540
|
+
<obc-poi-layer-stack
|
|
541
|
+
slot="stack"
|
|
542
|
+
selection-mode=${PoiLayerSelectionMode.Single}
|
|
543
|
+
>
|
|
544
|
+
<obc-poi-layer .isSelected=${true}></obc-poi-layer>
|
|
545
|
+
<obc-poi-layer data-controller-layer="background"></obc-poi-layer>
|
|
546
|
+
</obc-poi-layer-stack>
|
|
547
|
+
</obc-poi-controller>
|
|
548
|
+
</div>
|
|
549
|
+
`;
|
|
550
|
+
},
|
|
551
|
+
play: async ({canvasElement}) => {
|
|
552
|
+
await waitForStorySettle(canvasElement);
|
|
553
|
+
},
|
|
554
|
+
};
|
|
@@ -4,8 +4,37 @@ import {customElement} from '../../decorator.js';
|
|
|
4
4
|
import componentStyle from './poi-controller.css?inline';
|
|
5
5
|
import '../poi-layer-stack/poi-layer-stack.js';
|
|
6
6
|
import {ObcPoiLayer} from '../poi-layer/poi-layer.js';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import '../poi/poi-data.js';
|
|
8
|
+
import '../poi/poi-vessel.js';
|
|
9
|
+
import '../poi/poi-aton.js';
|
|
10
|
+
import {
|
|
11
|
+
PoiBase,
|
|
12
|
+
X_FILTER_CUTOFF_HZ,
|
|
13
|
+
Y_FILTER_CUTOFF_HZ,
|
|
14
|
+
} from '../poi/poi-base.js';
|
|
15
|
+
import {ObcPoiState} from '../poi/poi.js';
|
|
16
|
+
import {
|
|
17
|
+
ObcPoiButtonDataItem,
|
|
18
|
+
resolvePoiButtonTypeFromBoxSize,
|
|
19
|
+
} from '../poi-button/poi-button.js';
|
|
20
|
+
import {
|
|
21
|
+
MediaFit,
|
|
22
|
+
computeMediaProjection,
|
|
23
|
+
type MediaProjection,
|
|
24
|
+
projectPoint,
|
|
25
|
+
} from '../poi-projection/poi-projection.js';
|
|
26
|
+
|
|
27
|
+
export enum PoiDetectionVariant {
|
|
28
|
+
Data = 'data',
|
|
29
|
+
Vessel = 'vessel',
|
|
30
|
+
Aton = 'aton',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const DETECTION_VARIANT_TAGS: Record<PoiDetectionVariant, string> = {
|
|
34
|
+
[PoiDetectionVariant.Data]: 'obc-poi-data',
|
|
35
|
+
[PoiDetectionVariant.Vessel]: 'obc-poi-vessel',
|
|
36
|
+
[PoiDetectionVariant.Aton]: 'obc-poi-aton',
|
|
37
|
+
};
|
|
9
38
|
|
|
10
39
|
export type PoiDetection = {
|
|
11
40
|
x: number;
|
|
@@ -18,6 +47,14 @@ export type PoiDetection = {
|
|
|
18
47
|
class_id?: number;
|
|
19
48
|
heading?: number;
|
|
20
49
|
direction?: number;
|
|
50
|
+
/** POI variant rendered for this detection (default `data`). */
|
|
51
|
+
variant?: PoiDetectionVariant;
|
|
52
|
+
/** Custom-element tag rendered as the POI's icon child (e.g. an `obi-*` icon). */
|
|
53
|
+
icon?: string;
|
|
54
|
+
/** Alert state applied to the target. */
|
|
55
|
+
state?: ObcPoiState;
|
|
56
|
+
/** Data rows shown in the target's expanded button. */
|
|
57
|
+
data?: ObcPoiButtonDataItem[];
|
|
21
58
|
};
|
|
22
59
|
|
|
23
60
|
export type PoiKeyFn = (det: PoiDetection, index: number) => string;
|
|
@@ -33,12 +70,23 @@ export enum PoiFitMode {
|
|
|
33
70
|
Cover = 'cover',
|
|
34
71
|
}
|
|
35
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Attribute consumers set on a child `obc-poi-layer` to tell the
|
|
75
|
+
* controller which layer receives its detection-driven targets.
|
|
76
|
+
*/
|
|
77
|
+
export const POI_CONTROLLER_LAYER_ATTR = 'data-controller-layer';
|
|
78
|
+
|
|
79
|
+
/** `data-controller-layer` value marking the background/target layer. */
|
|
80
|
+
export const POI_CONTROLLER_BACKGROUND_LAYER = 'background';
|
|
81
|
+
|
|
36
82
|
/**
|
|
37
83
|
* `<obc-poi-controller>` — Maps detection data onto POI markers over a video or image.
|
|
38
84
|
*
|
|
39
85
|
* Takes detection coordinates in media pixel space (e.g. x,y in a 1920x1080 frame),
|
|
40
86
|
* projects them to screen space using the media's rendered size and fit mode, and
|
|
41
|
-
* creates/updates
|
|
87
|
+
* creates/updates POI targets inside a layer stack (`obc-poi-data` by default;
|
|
88
|
+
* `obc-poi-vessel`/`obc-poi-aton` via each detection's `variant`, with optional
|
|
89
|
+
* per-detection `icon`, `state`, and `data`).
|
|
42
90
|
*
|
|
43
91
|
* ## Quick Start
|
|
44
92
|
*
|
|
@@ -93,6 +141,16 @@ export enum PoiFitMode {
|
|
|
93
141
|
* <obc-poi-controller detections={detections} fit="cover">
|
|
94
142
|
* ```
|
|
95
143
|
*
|
|
144
|
+
* ## Framework Notes
|
|
145
|
+
*
|
|
146
|
+
* Both paths are safe for declarative renderers (React, Vue, Lit): the
|
|
147
|
+
* `detections` API creates and owns the resulting `obc-poi-data` elements,
|
|
148
|
+
* and manually slotted POI children are never moved, re-parented, or
|
|
149
|
+
* modified structurally by the library — selection is rendered by CSS
|
|
150
|
+
* projection and auto-grouping happens inside the layer's shadow root via
|
|
151
|
+
* slot assignment. Frameworks can manage POI children as ordinary
|
|
152
|
+
* framework-owned elements.
|
|
153
|
+
*
|
|
96
154
|
* ## Coordinate Model
|
|
97
155
|
*
|
|
98
156
|
* Detection `x` and `y` are in **media pixel space** (e.g. 0-1920 for a 1920x1080 video).
|
|
@@ -132,6 +190,8 @@ export enum PoiFitMode {
|
|
|
132
190
|
* - `--obc-poi-controller-stack-height` (default `50%`) — height of the stack
|
|
133
191
|
* - `--obc-poi-controller-stack-gap` (default `8px`) — gap between layers
|
|
134
192
|
*
|
|
193
|
+
* @property xFilterCutoffHz - Forwarded to every controller-owned target's `xFilterCutoffHz`; `null` leaves the targets on their default.
|
|
194
|
+
* @property yFilterCutoffHz - Forwarded to every controller-owned target's `yFilterCutoffHz`; `null` leaves the targets on their default.
|
|
135
195
|
* @slot media - Video or image element. Sets the projection source dimensions.
|
|
136
196
|
* @slot stack - `obc-poi-layer-stack` containing the layers for target placement.
|
|
137
197
|
* @experimental
|
|
@@ -146,6 +206,10 @@ export class ObcPoiController extends LitElement {
|
|
|
146
206
|
@property({type: Array}) classFilter: string[] | null = null;
|
|
147
207
|
@property({attribute: false})
|
|
148
208
|
keyFn: PoiKeyFn | null = null;
|
|
209
|
+
@property({type: Number, attribute: 'x-filter-cutoff-hz'})
|
|
210
|
+
xFilterCutoffHz: number | null = null;
|
|
211
|
+
@property({type: Number, attribute: 'y-filter-cutoff-hz'})
|
|
212
|
+
yFilterCutoffHz: number | null = null;
|
|
149
213
|
|
|
150
214
|
@state() private mediaWidth = 0;
|
|
151
215
|
@state() private mediaHeight = 0;
|
|
@@ -166,7 +230,7 @@ export class ObcPoiController extends LitElement {
|
|
|
166
230
|
this.setupLayerObserver();
|
|
167
231
|
this.scheduleSync();
|
|
168
232
|
};
|
|
169
|
-
private controllerTargets = new Map<string,
|
|
233
|
+
private controllerTargets = new Map<string, PoiBase>();
|
|
170
234
|
private currentMedia: HTMLVideoElement | HTMLImageElement | null = null;
|
|
171
235
|
private currentLayer: ObcPoiLayer | null = null;
|
|
172
236
|
private mediaHandlers = {
|
|
@@ -253,7 +317,7 @@ export class ObcPoiController extends LitElement {
|
|
|
253
317
|
if (!stack) return null;
|
|
254
318
|
|
|
255
319
|
const explicitLayer = stack.querySelector<ObcPoiLayer>(
|
|
256
|
-
|
|
320
|
+
`obc-poi-layer[${POI_CONTROLLER_LAYER_ATTR}="${POI_CONTROLLER_BACKGROUND_LAYER}"]`
|
|
257
321
|
);
|
|
258
322
|
if (explicitLayer) return explicitLayer;
|
|
259
323
|
|
|
@@ -406,43 +470,24 @@ export class ObcPoiController extends LitElement {
|
|
|
406
470
|
return frames[0] ?? null;
|
|
407
471
|
}
|
|
408
472
|
|
|
473
|
+
private computeCurrentProjection(): MediaProjection | null {
|
|
474
|
+
return computeMediaProjection({
|
|
475
|
+
mediaWidth: this.mediaWidth,
|
|
476
|
+
mediaHeight: this.mediaHeight,
|
|
477
|
+
renderWidth: this.renderWidth,
|
|
478
|
+
renderHeight: this.renderHeight,
|
|
479
|
+
fit: this.fit === PoiFitMode.Cover ? MediaFit.Cover : MediaFit.Contain,
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
|
|
409
483
|
private mapDetection(
|
|
410
|
-
det: PoiDetection
|
|
484
|
+
det: PoiDetection,
|
|
485
|
+
projection: MediaProjection | null = this.computeCurrentProjection()
|
|
411
486
|
): {x: number; y: number; scale: number} | null {
|
|
412
|
-
if (
|
|
413
|
-
!Number.isFinite(this.mediaWidth) ||
|
|
414
|
-
!Number.isFinite(this.mediaHeight) ||
|
|
415
|
-
!Number.isFinite(this.renderWidth) ||
|
|
416
|
-
!Number.isFinite(this.renderHeight) ||
|
|
417
|
-
this.mediaWidth === 0 ||
|
|
418
|
-
this.mediaHeight === 0 ||
|
|
419
|
-
this.renderWidth === 0 ||
|
|
420
|
-
this.renderHeight === 0
|
|
421
|
-
) {
|
|
422
|
-
return null;
|
|
423
|
-
}
|
|
487
|
+
if (!projection) return null;
|
|
424
488
|
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
? Math.max(
|
|
428
|
-
this.renderWidth / this.mediaWidth,
|
|
429
|
-
this.renderHeight / this.mediaHeight
|
|
430
|
-
)
|
|
431
|
-
: Math.min(
|
|
432
|
-
this.renderWidth / this.mediaWidth,
|
|
433
|
-
this.renderHeight / this.mediaHeight
|
|
434
|
-
);
|
|
435
|
-
|
|
436
|
-
const contentWidth = this.mediaWidth * scale;
|
|
437
|
-
const contentHeight = this.mediaHeight * scale;
|
|
438
|
-
const offsetX = (this.renderWidth - contentWidth) / 2;
|
|
439
|
-
const offsetY = (this.renderHeight - contentHeight) / 2;
|
|
440
|
-
|
|
441
|
-
return {
|
|
442
|
-
x: offsetX + det.x * scale,
|
|
443
|
-
y: offsetY + det.y * scale,
|
|
444
|
-
scale,
|
|
445
|
-
};
|
|
489
|
+
const point = projectPoint(projection, det.x, det.y);
|
|
490
|
+
return {x: point.x, y: point.y, scale: projection.scale};
|
|
446
491
|
}
|
|
447
492
|
|
|
448
493
|
private syncTargetsToCustomStack() {
|
|
@@ -469,23 +514,43 @@ export class ObcPoiController extends LitElement {
|
|
|
469
514
|
|
|
470
515
|
const active = this.getActiveDetections();
|
|
471
516
|
const activeKeys = new Set<string>();
|
|
517
|
+
const projection = this.computeCurrentProjection();
|
|
472
518
|
|
|
473
519
|
active.forEach((det, index) => {
|
|
474
|
-
const mapped = this.mapDetection(det);
|
|
520
|
+
const mapped = this.mapDetection(det, projection);
|
|
475
521
|
if (!mapped) return;
|
|
476
522
|
const key =
|
|
477
523
|
det.id ?? (this.keyFn ? this.keyFn(det, index) : `index:${index}`);
|
|
478
524
|
activeKeys.add(key);
|
|
479
525
|
|
|
526
|
+
const variant = det.variant ?? PoiDetectionVariant.Data;
|
|
527
|
+
const tag = DETECTION_VARIANT_TAGS[variant];
|
|
528
|
+
|
|
480
529
|
let target = this.controllerTargets.get(key);
|
|
530
|
+
if (target && target.tagName.toLowerCase() !== tag) {
|
|
531
|
+
target.remove();
|
|
532
|
+
this.controllerTargets.delete(key);
|
|
533
|
+
target = undefined;
|
|
534
|
+
}
|
|
481
535
|
if (!target) {
|
|
482
|
-
target = document.createElement(
|
|
536
|
+
target = document.createElement(tag) as PoiBase;
|
|
483
537
|
target.dataset.controller = '1';
|
|
484
538
|
target.dataset.detectionIndex = String(index);
|
|
485
539
|
target.fixedTarget = false;
|
|
486
540
|
this.controllerTargets.set(key, target);
|
|
487
541
|
}
|
|
488
542
|
|
|
543
|
+
const iconTag = det.icon?.toLowerCase() ?? null;
|
|
544
|
+
const currentIcon = target.firstElementChild;
|
|
545
|
+
if (iconTag) {
|
|
546
|
+
if (currentIcon?.tagName.toLowerCase() !== iconTag) {
|
|
547
|
+
currentIcon?.remove();
|
|
548
|
+
target.appendChild(document.createElement(iconTag));
|
|
549
|
+
}
|
|
550
|
+
} else if (currentIcon) {
|
|
551
|
+
currentIcon.remove();
|
|
552
|
+
}
|
|
553
|
+
|
|
489
554
|
// Append to background layer unless layer-stack moved it elsewhere
|
|
490
555
|
if (!target.isConnected || target.parentElement === null) {
|
|
491
556
|
layer.appendChild(target);
|
|
@@ -511,6 +576,11 @@ export class ObcPoiController extends LitElement {
|
|
|
511
576
|
if (typeof heading === 'number' && Number.isFinite(heading)) {
|
|
512
577
|
target.relativeDirection = heading;
|
|
513
578
|
}
|
|
579
|
+
|
|
580
|
+
target.state = det.state ?? ObcPoiState.Enabled;
|
|
581
|
+
target.data = det.data ?? [];
|
|
582
|
+
target.xFilterCutoffHz = this.xFilterCutoffHz ?? X_FILTER_CUTOFF_HZ;
|
|
583
|
+
target.yFilterCutoffHz = this.yFilterCutoffHz ?? Y_FILTER_CUTOFF_HZ;
|
|
514
584
|
});
|
|
515
585
|
|
|
516
586
|
Array.from(this.controllerTargets.entries()).forEach(([key, target]) => {
|
|
@@ -2,6 +2,7 @@ import type {Meta, StoryObj} from '@storybook/web-components-vite';
|
|
|
2
2
|
import {ObcPoiGroup} from './poi-group.js';
|
|
3
3
|
import './poi-group.js';
|
|
4
4
|
import {crossDecorator} from '../../storybook-util.js';
|
|
5
|
+
import {waitForStorySettle} from '../_test-utils.js';
|
|
5
6
|
import {html} from 'lit';
|
|
6
7
|
import {createRef, ref} from 'lit/directives/ref.js';
|
|
7
8
|
import '../poi-button/poi-button-data.js';
|
|
@@ -91,7 +92,7 @@ const meta: Meta<PoiGroupStoryArgs> = {
|
|
|
91
92
|
<obc-poi-group
|
|
92
93
|
style="position: absolute; top: 0; left: 0;"
|
|
93
94
|
.expand=${args.expand}
|
|
94
|
-
|
|
95
|
+
position-vertical="calc(50% - 40px)"
|
|
95
96
|
@expand=${onExpand}
|
|
96
97
|
>
|
|
97
98
|
<obc-poi-data
|
|
@@ -129,12 +130,18 @@ export default meta;
|
|
|
129
130
|
type Story = StoryObj<PoiGroupStoryArgs>;
|
|
130
131
|
|
|
131
132
|
export const Grouped: Story = {
|
|
133
|
+
play: async () => {
|
|
134
|
+
await waitForStorySettle({drainTransitions: true});
|
|
135
|
+
},
|
|
132
136
|
args: {
|
|
133
137
|
expand: false,
|
|
134
138
|
},
|
|
135
139
|
};
|
|
136
140
|
|
|
137
141
|
export const GroupedWithNumbers: Story = {
|
|
142
|
+
play: async () => {
|
|
143
|
+
await waitForStorySettle({drainTransitions: true});
|
|
144
|
+
},
|
|
138
145
|
args: {
|
|
139
146
|
expand: false,
|
|
140
147
|
},
|
|
@@ -173,7 +180,7 @@ export const GroupedWithNumbers: Story = {
|
|
|
173
180
|
<obc-poi-group
|
|
174
181
|
style="position: absolute; top: 0; left: 0;"
|
|
175
182
|
.expand=${args.expand}
|
|
176
|
-
|
|
183
|
+
position-vertical="calc(50% - 40px)"
|
|
177
184
|
@expand=${onExpand}
|
|
178
185
|
>
|
|
179
186
|
<obc-poi-data
|
|
@@ -220,6 +227,9 @@ export const GroupedWithNumbers: Story = {
|
|
|
220
227
|
};
|
|
221
228
|
|
|
222
229
|
export const GroupedWithValues: Story = {
|
|
230
|
+
play: async () => {
|
|
231
|
+
await waitForStorySettle({drainTransitions: true});
|
|
232
|
+
},
|
|
223
233
|
args: {
|
|
224
234
|
expand: false,
|
|
225
235
|
},
|
|
@@ -320,6 +330,9 @@ export const GroupedWithValues: Story = {
|
|
|
320
330
|
};
|
|
321
331
|
|
|
322
332
|
export const GroupedMixedTypes: Story = {
|
|
333
|
+
play: async () => {
|
|
334
|
+
await waitForStorySettle({drainTransitions: true});
|
|
335
|
+
},
|
|
323
336
|
args: {
|
|
324
337
|
expand: false,
|
|
325
338
|
},
|
|
@@ -345,7 +358,7 @@ export const GroupedMixedTypes: Story = {
|
|
|
345
358
|
<obc-poi-group
|
|
346
359
|
style="position: absolute; top: 0; left: 0;"
|
|
347
360
|
.expand=${args.expand}
|
|
348
|
-
|
|
361
|
+
position-vertical="calc(50% - 40px)"
|
|
349
362
|
>
|
|
350
363
|
<obc-poi-aton
|
|
351
364
|
id="target-3"
|
|
@@ -447,7 +460,7 @@ export const Expanded: Story = {
|
|
|
447
460
|
${ref(groupRef)}
|
|
448
461
|
style="position: absolute; top: 0; left: 0;"
|
|
449
462
|
.expand=${false}
|
|
450
|
-
|
|
463
|
+
position-vertical="calc(50% - 40px)"
|
|
451
464
|
@expand=${onExpand}
|
|
452
465
|
>
|
|
453
466
|
<obc-poi-data
|
|
@@ -629,7 +642,7 @@ export const InternalGroupSwapping: Story = {
|
|
|
629
642
|
style="position: absolute; top: 0; left: 0;"
|
|
630
643
|
.expand=${isVitestBrowser ? false : args.expand}
|
|
631
644
|
.internalSwapping=${args.internalSwapping}
|
|
632
|
-
|
|
645
|
+
position-vertical="calc(50% - 40px)"
|
|
633
646
|
@expand=${(event: CustomEvent<{expand: boolean}>) => {
|
|
634
647
|
if (isVitestBrowser) {
|
|
635
648
|
stopAnimation();
|