symbiote-ui 0.3.0-alpha.4
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/CHANGELOG.md +46 -0
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/canvas/AutoLayout.js +731 -0
- package/canvas/Breadcrumb/Breadcrumb.css.js +75 -0
- package/canvas/Breadcrumb/Breadcrumb.js +96 -0
- package/canvas/Breadcrumb/Breadcrumb.tpl.js +7 -0
- package/canvas/CanvasConnectionRenderer.js +971 -0
- package/canvas/CanvasGraph/CanvasGraph.css.js +29 -0
- package/canvas/CanvasGraph/CanvasGraph.js +1697 -0
- package/canvas/CanvasGraph/CanvasGraphDrawState.js +280 -0
- package/canvas/CanvasGraph/CanvasGraphGeometry.js +194 -0
- package/canvas/CanvasViewport.js +550 -0
- package/canvas/ConnectionRenderer.js +1283 -0
- package/canvas/FlowSimulator.js +326 -0
- package/canvas/ForceLayout.js +226 -0
- package/canvas/ForceWorker.js +1303 -0
- package/canvas/FrameManager.js +223 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.css.js +136 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.js +129 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.tpl.js +12 -0
- package/canvas/GraphTabs/GraphTabs.css.js +101 -0
- package/canvas/GraphTabs/GraphTabs.js +189 -0
- package/canvas/GraphTabs/GraphTabs.tpl.js +12 -0
- package/canvas/LODManager.js +88 -0
- package/canvas/Minimap/Minimap.css.js +73 -0
- package/canvas/Minimap/Minimap.js +210 -0
- package/canvas/Minimap/Minimap.tpl.js +7 -0
- package/canvas/NodeCanvas/NodeCanvas.css.js +398 -0
- package/canvas/NodeCanvas/NodeCanvas.js +1499 -0
- package/canvas/NodeCanvas/NodeCanvas.tpl.js +22 -0
- package/canvas/NodeSearch/NodeSearch.css.js +97 -0
- package/canvas/NodeSearch/NodeSearch.js +140 -0
- package/canvas/NodeSearch/NodeSearch.tpl.js +25 -0
- package/canvas/NodeViewManager.js +748 -0
- package/canvas/PcbRouteDiagnostics.js +463 -0
- package/canvas/PcbRouter.js +1127 -0
- package/canvas/PinExpansion.js +134 -0
- package/canvas/PseudoConnection.js +84 -0
- package/canvas/SelectionSync.js +163 -0
- package/canvas/SubgraphManager.js +203 -0
- package/canvas/SubgraphRouter.js +452 -0
- package/canvas/ViewportActions.js +473 -0
- package/canvas/graph-explorer.js +339 -0
- package/canvas/graph-layout.js +148 -0
- package/canvas/graph-model.js +68 -0
- package/canvas/html-in-canvas.js +202 -0
- package/canvas/project-graph-builder.js +440 -0
- package/canvas/project-graph-model.js +183 -0
- package/chat/ChatComposer/ChatComposer.css.js +652 -0
- package/chat/ChatComposer/ChatComposer.js +304 -0
- package/chat/ChatList/ChatList.css.js +102 -0
- package/chat/ChatList/ChatList.js +99 -0
- package/chat/ChatList/ChatList.tpl.js +20 -0
- package/chat/ChatListItem/ChatListItem.css.js +117 -0
- package/chat/ChatListItem/ChatListItem.js +32 -0
- package/chat/ChatListItem/ChatListItem.tpl.js +17 -0
- package/chat/ChatMessageItem/ChatMessageItem.css.js +628 -0
- package/chat/ChatMessageItem/ChatMessageItem.js +156 -0
- package/chat/ChatSidebar/ChatSidebar.css.js +150 -0
- package/chat/ChatSidebar/ChatSidebar.js +230 -0
- package/chat/ChatSidebar/ChatSidebar.tpl.js +18 -0
- package/chat/ChatSidebar/constants.js +11 -0
- package/chat/ChatSidebarItem/ChatSidebarItem.css.js +445 -0
- package/chat/ChatSidebarItem/ChatSidebarItem.js +304 -0
- package/chat/ChatTranscript/ChatTranscript.css.js +90 -0
- package/chat/ChatTranscript/ChatTranscript.js +244 -0
- package/chat/chat-context.js +123 -0
- package/chat/message-model.js +156 -0
- package/cli.js +20 -0
- package/control/Button/Button.css.js +93 -0
- package/control/Button/Button.js +78 -0
- package/control/Button/Button.tpl.js +3 -0
- package/control/Field/Field.css.js +91 -0
- package/control/Field/Field.js +17 -0
- package/control/Field/Field.tpl.js +3 -0
- package/core/Connection.js +47 -0
- package/core/Editor.js +449 -0
- package/core/Frame.js +33 -0
- package/core/GraphMermaid.js +348 -0
- package/core/GraphText.js +228 -0
- package/core/Node.js +145 -0
- package/core/Portal.js +106 -0
- package/core/Socket.js +187 -0
- package/core/SubgraphNode.js +121 -0
- package/core/base-path.js +55 -0
- package/core/dom-utils.js +14 -0
- package/core/index.js +18 -0
- package/core/local-cache.js +26 -0
- package/core/state-sync.js +227 -0
- package/custom-elements.json +6380 -0
- package/discover.js +240 -0
- package/display/Badge/Badge.css.js +44 -0
- package/display/Badge/Badge.js +17 -0
- package/display/Badge/Badge.tpl.js +3 -0
- package/display/Banner/Banner.css.js +61 -0
- package/display/Banner/Banner.js +17 -0
- package/display/Banner/Banner.tpl.js +3 -0
- package/display/CodeBlock/CodeBlock.css.js +194 -0
- package/display/CodeBlock/CodeBlock.js +220 -0
- package/display/CodeBlock/CodeBlock.tpl.js +11 -0
- package/display/DataTable/DataTable.css.js +101 -0
- package/display/DataTable/DataTable.js +136 -0
- package/display/DataTable/DataTable.tpl.js +13 -0
- package/display/EmptyState/EmptyState.css.js +33 -0
- package/display/EmptyState/EmptyState.js +17 -0
- package/display/EmptyState/EmptyState.tpl.js +3 -0
- package/display/EventFeed/EventFeed.css.js +145 -0
- package/display/EventFeed/EventFeed.js +64 -0
- package/display/EventFeed/EventFeed.tpl.js +14 -0
- package/display/EventFeed/EventFeedItem.js +116 -0
- package/display/EventFeed/EventFeedItem.tpl.js +22 -0
- package/display/LoadingOverlay/LoadingOverlay.css.js +91 -0
- package/display/LoadingOverlay/LoadingOverlay.js +48 -0
- package/display/LoadingOverlay/LoadingOverlay.tpl.js +12 -0
- package/display/Metric/Metric.css.js +60 -0
- package/display/Metric/Metric.js +17 -0
- package/display/Metric/Metric.tpl.js +6 -0
- package/display/OutputGraphPreview/OutputGraphPreview.css.js +122 -0
- package/display/OutputGraphPreview/OutputGraphPreview.js +89 -0
- package/display/OutputGraphPreview/OutputGraphPreview.tpl.js +13 -0
- package/display/OutputListPreview/OutputListPreview.css.js +109 -0
- package/display/OutputListPreview/OutputListPreview.js +77 -0
- package/display/OutputListPreview/OutputListPreview.tpl.js +13 -0
- package/display/SourceEditor/SourceEditor.css.js +39 -0
- package/display/SourceEditor/SourceEditor.js +129 -0
- package/display/SourceEditor/SourceEditor.tpl.js +10 -0
- package/display/SourceViewer/SourceViewer.css.js +80 -0
- package/display/SourceViewer/SourceViewer.js +418 -0
- package/display/SourceViewer/SourceViewer.tpl.js +17 -0
- package/display/StatusRibbon/StatusRibbon.css.js +73 -0
- package/display/StatusRibbon/StatusRibbon.js +87 -0
- package/display/StatusRibbon/StatusRibbon.tpl.js +7 -0
- package/display/event-feed-adapter.js +72 -0
- package/display/format-utils.js +29 -0
- package/display/highlight.js +659 -0
- package/display/icons.js +37 -0
- package/display/markdown-formatter.js +60 -0
- package/display/network-approval-page.js +487 -0
- package/display/output-preview.js +261 -0
- package/effects/CellBg/CellBg.css.js +33 -0
- package/effects/CellBg/CellBg.js +410 -0
- package/effects/CellBg/CellBg.tpl.js +5 -0
- package/graph/canvas-adapter.js +223 -0
- package/graph/graph-algorithms.js +31 -0
- package/graph/index.js +46 -0
- package/graph/model.js +176 -0
- package/graph/project-graph-build.js +66 -0
- package/graph/project-graph-metadata.js +253 -0
- package/graph/project-package.js +128 -0
- package/graph/project-runtime.js +116 -0
- package/graph/project-transaction.js +284 -0
- package/graph/skeleton-utils.js +84 -0
- package/graph/theme-contract.js +36 -0
- package/graph/transaction-parser.js +56 -0
- package/icons/MaterialSymbols.js +69 -0
- package/icons/material-symbols-outlined-400.ttf +0 -0
- package/icons/material-symbols.css +24 -0
- package/index.js +95 -0
- package/inspector/InspectorPanel/InspectorPanel.css.js +375 -0
- package/inspector/InspectorPanel/InspectorPanel.js +368 -0
- package/inspector/InspectorPanel/InspectorPanel.tpl.js +96 -0
- package/inspector/TemplatePreview/TemplatePreview.css.js +104 -0
- package/inspector/TemplatePreview/TemplatePreview.js +145 -0
- package/inspector/TemplatePreview/TemplatePreview.tpl.js +33 -0
- package/interactions/ConnectFlow.js +304 -0
- package/interactions/Drag.js +104 -0
- package/interactions/Selector.js +133 -0
- package/interactions/SnapGrid.js +66 -0
- package/interactions/Zoom.js +139 -0
- package/layout/ActionZone/ActionZone.css.js +88 -0
- package/layout/ActionZone/ActionZone.js +261 -0
- package/layout/ActionZone/ActionZone.tpl.js +11 -0
- package/layout/CrossLayoutPortalBridge/CrossLayoutPortalBridge.js +255 -0
- package/layout/Layout/Layout.css.js +91 -0
- package/layout/Layout/Layout.js +637 -0
- package/layout/Layout/Layout.tpl.js +27 -0
- package/layout/LayoutNode/LayoutNode.css.js +302 -0
- package/layout/LayoutNode/LayoutNode.js +509 -0
- package/layout/LayoutNode/LayoutNode.tpl.js +39 -0
- package/layout/LayoutPreview/LayoutPreview.css.js +46 -0
- package/layout/LayoutPreview/LayoutPreview.js +102 -0
- package/layout/LayoutPreview/LayoutPreview.tpl.js +6 -0
- package/layout/LayoutRouter/LayoutRouter.js +274 -0
- package/layout/LayoutRouter/SectionRegistry.js +135 -0
- package/layout/LayoutRouter/routerSync.js +250 -0
- package/layout/LayoutSidebar/LayoutSidebar.css.js +411 -0
- package/layout/LayoutSidebar/LayoutSidebar.js +368 -0
- package/layout/LayoutSidebar/LayoutSidebar.tpl.js +26 -0
- package/layout/LayoutSidebar/SidebarSection.css.js +20 -0
- package/layout/LayoutSidebar/SidebarSection.js +184 -0
- package/layout/LayoutSidebar/SidebarSection.tpl.js +22 -0
- package/layout/LayoutTree.js +373 -0
- package/layout/PanelMenu/PanelMenu.css.js +43 -0
- package/layout/PanelMenu/PanelMenu.js +95 -0
- package/layout/PanelMenu/PanelMenu.tpl.js +17 -0
- package/layout/ProjectTabs/ProjectTabs.css.js +188 -0
- package/layout/ProjectTabs/ProjectTabs.js +77 -0
- package/layout/ProjectTabs/ProjectTabs.tpl.js +15 -0
- package/layout/index.js +40 -0
- package/list/ListDetailShell/ListDetailShell.css.js +128 -0
- package/list/ListDetailShell/ListDetailShell.js +72 -0
- package/list/ListDetailShell/ListDetailShell.tpl.js +36 -0
- package/list/ListItem/ListItem.css.js +111 -0
- package/list/ListItem/ListItem.js +66 -0
- package/list/ListItem/ListItem.tpl.js +18 -0
- package/locale/index.js +503 -0
- package/manifest/component-registry.js +2446 -0
- package/manifest/graph-schema.js +285 -0
- package/manifest/index.js +6 -0
- package/manifest/project-schema-catalog.js +246 -0
- package/manifest/rule-catalog.js +201 -0
- package/manifest/theme-catalog.js +2149 -0
- package/manifest/ui-schema-catalog.js +334 -0
- package/menu/ContextMenu/ContextMenu.css.js +61 -0
- package/menu/ContextMenu/ContextMenu.js +82 -0
- package/menu/ContextMenu/ContextMenu.tpl.js +19 -0
- package/navigation/QuickOpen/QuickOpen.css.js +92 -0
- package/navigation/QuickOpen/QuickOpen.js +185 -0
- package/navigation/QuickOpen/QuickOpen.tpl.js +15 -0
- package/navigation/quick-open-utils.js +101 -0
- package/node/CtrlItem/CtrlItem.css.js +41 -0
- package/node/CtrlItem/CtrlItem.js +24 -0
- package/node/CtrlItem/CtrlItem.tpl.js +17 -0
- package/node/GraphFrame/GraphFrame.css.js +66 -0
- package/node/GraphFrame/GraphFrame.js +32 -0
- package/node/GraphFrame/GraphFrame.tpl.js +13 -0
- package/node/GraphNode/GraphNode.css.js +815 -0
- package/node/GraphNode/GraphNode.js +173 -0
- package/node/GraphNode/GraphNode.tpl.js +33 -0
- package/node/NodeCallout/NodeCallout.css.js +91 -0
- package/node/NodeCallout/NodeCallout.js +281 -0
- package/node/NodeCallout/NodeCallout.tpl.js +8 -0
- package/node/NodeSocket/NodeSocket.css.js +68 -0
- package/node/NodeSocket/NodeSocket.js +26 -0
- package/node/NodeSocket/NodeSocket.tpl.js +7 -0
- package/node/PortItem/PortItem.css.js +93 -0
- package/node/PortItem/PortItem.js +87 -0
- package/node/PortItem/PortItem.tpl.js +10 -0
- package/package.json +165 -0
- package/palette/PaletteBrowser/PaletteBrowser.css.js +143 -0
- package/palette/PaletteBrowser/PaletteBrowser.js +152 -0
- package/palette/PaletteBrowser/PaletteBrowser.tpl.js +23 -0
- package/plugins/History.js +408 -0
- package/plugins/Readonly.js +60 -0
- package/rules/symbiote-3x.json +170 -0
- package/schemas/component-descriptor-v1.json +91 -0
- package/schemas/component-descriptor-v2.json +145 -0
- package/schemas/graph-model-v1.json +179 -0
- package/schemas/graph-v1.json +91 -0
- package/schemas/project-package-v1.json +102 -0
- package/schemas/project-transaction-v1.json +114 -0
- package/schemas/runtime-ui-v1.json +80 -0
- package/schemas/theme-rule-block-v1.json +73 -0
- package/shapes/CircleShape.js +79 -0
- package/shapes/CommentShape.js +35 -0
- package/shapes/DiamondShape.js +130 -0
- package/shapes/NodeShape.js +79 -0
- package/shapes/PillShape.js +91 -0
- package/shapes/RectShape.js +84 -0
- package/shapes/SVGShape.js +525 -0
- package/shapes/index.js +63 -0
- package/surface/Card/Card.css.js +57 -0
- package/surface/Card/Card.js +17 -0
- package/surface/Card/Card.tpl.js +3 -0
- package/themes/Palette.js +30 -0
- package/themes/Skin.js +113 -0
- package/themes/Theme.js +82 -0
- package/themes/carbon.js +135 -0
- package/themes/dark.js +140 -0
- package/themes/default-dark.js +714 -0
- package/themes/default-provider.css +635 -0
- package/themes/default-provider.js +718 -0
- package/themes/ebook.js +136 -0
- package/themes/grey.js +137 -0
- package/themes/light.js +139 -0
- package/themes/neon.js +138 -0
- package/themes/pcb.js +273 -0
- package/themes/synthwave.js +138 -0
- package/tokens/base.json +29 -0
- package/tokens/themes/carbon.json +11 -0
- package/tokens/themes/dark.json +12 -0
- package/tokens/themes/default-dark.json +1543 -0
- package/tokens/themes/default-provider.json +1543 -0
- package/tokens/themes/ebook.json +11 -0
- package/tokens/themes/grey.json +11 -0
- package/tokens/themes/light.json +12 -0
- package/tokens/themes/neon.json +11 -0
- package/tokens/themes/pcb.json +11 -0
- package/tokens/themes/synthwave.json +11 -0
- package/toolbar/QuickToolbar/QuickToolbar.css.js +152 -0
- package/toolbar/QuickToolbar/QuickToolbar.js +529 -0
- package/toolbar/QuickToolbar/QuickToolbar.tpl.js +34 -0
- package/tree/TreePanel/TreePanel.css.js +112 -0
- package/tree/TreePanel/TreePanel.js +147 -0
- package/tree/TreePanel/TreePanel.tpl.js +18 -0
- package/tree/TreeView/TreeView.css.js +122 -0
- package/tree/TreeView/TreeView.js +365 -0
- package/tree/TreeView/TreeView.tpl.js +10 -0
- package/ui/dialogs.js +221 -0
- package/ui/host-adapters.js +114 -0
- package/ui/index.js +660 -0
- package/ui/locale.js +50 -0
- package/ui/overlay-stack.js +89 -0
- package/ui/shared-styles.js +26 -0
- package/webmcp.js +37 -0
- package/xr/deep-graph.js +646 -0
- package/xr/emulation.js +198 -0
- package/xr/gesture.js +228 -0
- package/xr/html-canvas-renderer.js +472 -0
- package/xr/index.js +15 -0
- package/xr/layout-projection.js +1046 -0
- package/xr/panel-frame.js +128 -0
- package/xr/panel-host.js +267 -0
- package/xr/pointer.js +258 -0
- package/xr/scene-controller.js +242 -0
- package/xr/spatial-scene.js +212 -0
- package/xr/theme-bridge.js +105 -0
- package/xr/three-webxr-adapter.js +3439 -0
- package/xr/webgl-layer-renderer.js +419 -0
- package/xr/webxr.js +679 -0
- package/xr/workbench.js +516 -0
|
@@ -0,0 +1,1046 @@
|
|
|
1
|
+
import { collectPanels } from '../layout/LayoutTree.js';
|
|
2
|
+
|
|
3
|
+
export const XR_LAYOUT_PRESETS = Object.freeze({
|
|
4
|
+
front: Object.freeze({ position: [0, 1.35, -1.8], rotation: [0, 0, 0], size: [0.9, 0.62] }),
|
|
5
|
+
left: Object.freeze({ position: [-0.86, 1.32, -1.62], rotation: [0, 24, 0], size: [0.58, 0.78] }),
|
|
6
|
+
right: Object.freeze({ position: [0.86, 1.32, -1.62], rotation: [0, -24, 0], size: [0.58, 0.78] }),
|
|
7
|
+
lower: Object.freeze({ position: [0, 0.86, -1.35], rotation: [-14, 0, 0], size: [0.98, 0.28] }),
|
|
8
|
+
upperRight: Object.freeze({ position: [0.58, 1.74, -1.42], rotation: [8, -18, 0], size: [0.42, 0.24] }),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const AREA_PRESET = Object.freeze({
|
|
12
|
+
left: 'left',
|
|
13
|
+
sidebar: 'left',
|
|
14
|
+
nav: 'left',
|
|
15
|
+
menu: 'left',
|
|
16
|
+
right: 'right',
|
|
17
|
+
inspector: 'right',
|
|
18
|
+
details: 'right',
|
|
19
|
+
bottom: 'lower',
|
|
20
|
+
lower: 'lower',
|
|
21
|
+
tray: 'lower',
|
|
22
|
+
status: 'upperRight',
|
|
23
|
+
toast: 'upperRight',
|
|
24
|
+
center: 'front',
|
|
25
|
+
main: 'front',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const DEFAULT_RELATIVE_SIZE = Object.freeze({
|
|
29
|
+
width: 1.22,
|
|
30
|
+
height: 0.82,
|
|
31
|
+
minWidth: 0.32,
|
|
32
|
+
minHeight: 0.22,
|
|
33
|
+
maxWidth: 1.28,
|
|
34
|
+
maxHeight: 0.92,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const DEFAULT_CONTENT_VIEWPORT = Object.freeze({
|
|
38
|
+
minWidth: 1280,
|
|
39
|
+
minHeight: 720,
|
|
40
|
+
maxWidth: 2048,
|
|
41
|
+
maxHeight: 1536,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const DEFAULT_TEXTURE_QUALITY = Object.freeze({
|
|
45
|
+
minPixelsPerMeter: 900,
|
|
46
|
+
targetPixelsPerMeter: 1200,
|
|
47
|
+
texturePixelRatio: 1,
|
|
48
|
+
maxTexturePixelRatio: 2,
|
|
49
|
+
maxTextureSize: 4096,
|
|
50
|
+
redrawMode: 'dirty',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const DEFAULT_POSE_COMFORT = Object.freeze({
|
|
54
|
+
eyeHeight: 1.55,
|
|
55
|
+
minDistance: 1,
|
|
56
|
+
targetDistance: 1.45,
|
|
57
|
+
maxDistance: 2.2,
|
|
58
|
+
maxHorizontalAngle: 42,
|
|
59
|
+
minVerticalAngle: -28,
|
|
60
|
+
maxVerticalAngle: 16,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const DEFAULT_FACING = Object.freeze({
|
|
64
|
+
maxYawError: 6,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
function numberOr(value, fallback) {
|
|
68
|
+
let number = Number(value);
|
|
69
|
+
return Number.isFinite(number) ? number : fallback;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function clamp(value, min, max) {
|
|
73
|
+
return Math.max(min, Math.min(max, value));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function roundMetric(value) {
|
|
77
|
+
return Math.round(value * 1_000_000) / 1_000_000;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function asVector(value, fallback) {
|
|
81
|
+
if (!Array.isArray(value)) return [...fallback];
|
|
82
|
+
return fallback.map((item, index) => numberOr(value[index], item));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function inferPreset(panel, index, total) {
|
|
86
|
+
let area = panel?.xr?.anchor || panel?.layout?.area || panel?.area || panel?.panelState?.area || '';
|
|
87
|
+
if (AREA_PRESET[area]) return AREA_PRESET[area];
|
|
88
|
+
if (total === 1) return 'front';
|
|
89
|
+
if (index === 0) return 'front';
|
|
90
|
+
if (index % 4 === 1) return 'left';
|
|
91
|
+
if (index % 4 === 2) return 'right';
|
|
92
|
+
if (index % 4 === 3) return 'lower';
|
|
93
|
+
return 'upperRight';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function isRuntimeUiNode(node) {
|
|
97
|
+
return !!node && typeof node === 'object' && typeof node.component === 'string';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function collectRuntimePanels(root) {
|
|
101
|
+
let panels = [];
|
|
102
|
+
|
|
103
|
+
function walk(node) {
|
|
104
|
+
if (!node) return;
|
|
105
|
+
if (Array.isArray(node)) {
|
|
106
|
+
node.forEach(walk);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!isRuntimeUiNode(node)) return;
|
|
110
|
+
if (node.component === 'panel-layout' && Array.isArray(node.children) && node.children.length) {
|
|
111
|
+
node.children.forEach(walk);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
panels.push(node);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
walk(root);
|
|
118
|
+
return panels;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function normalizeRect(rect) {
|
|
122
|
+
if (!rect) return null;
|
|
123
|
+
return {
|
|
124
|
+
x: clamp(numberOr(rect.x, 0), 0, 1),
|
|
125
|
+
y: clamp(numberOr(rect.y, 0), 0, 1),
|
|
126
|
+
width: clamp(numberOr(rect.width, 1), 0, 1),
|
|
127
|
+
height: clamp(numberOr(rect.height, 1), 0, 1),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function collectLayoutRects(root) {
|
|
132
|
+
let rects = new Map();
|
|
133
|
+
|
|
134
|
+
function walk(node, rect) {
|
|
135
|
+
if (!node) return;
|
|
136
|
+
if (node.type === 'panel') {
|
|
137
|
+
rects.set(node, normalizeRect(node.layout?.rect || rect));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (node.type !== 'split') return;
|
|
141
|
+
let ratio = clamp(numberOr(node.ratio, 0.5), 0, 1);
|
|
142
|
+
if (node.direction === 'vertical') {
|
|
143
|
+
walk(node.first, { ...rect, height: rect.height * ratio });
|
|
144
|
+
walk(node.second, {
|
|
145
|
+
x: rect.x,
|
|
146
|
+
y: rect.y + rect.height * ratio,
|
|
147
|
+
width: rect.width,
|
|
148
|
+
height: rect.height * (1 - ratio),
|
|
149
|
+
});
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
walk(node.first, { ...rect, width: rect.width * ratio });
|
|
153
|
+
walk(node.second, {
|
|
154
|
+
x: rect.x + rect.width * ratio,
|
|
155
|
+
y: rect.y,
|
|
156
|
+
width: rect.width * (1 - ratio),
|
|
157
|
+
height: rect.height,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
walk(root, { x: 0, y: 0, width: 1, height: 1 });
|
|
162
|
+
return rects;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function runtimeLayoutDirection(node) {
|
|
166
|
+
return node.layout?.direction || node.props?.layoutDirection || 'horizontal';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function runtimeLayoutWeight(node) {
|
|
170
|
+
return Math.max(0, numberOr(node.layout?.weight ?? node.props?.layoutWeight, 1));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function collectRuntimeRects(root) {
|
|
174
|
+
let rects = new Map();
|
|
175
|
+
|
|
176
|
+
function walk(node, rect) {
|
|
177
|
+
if (!isRuntimeUiNode(node)) return;
|
|
178
|
+
let normalizedRect = normalizeRect(node.layout?.rect || rect);
|
|
179
|
+
if (node.component !== 'panel-layout' || !Array.isArray(node.children) || !node.children.length) {
|
|
180
|
+
rects.set(node, normalizedRect);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
let direction = runtimeLayoutDirection(node);
|
|
185
|
+
let weights = node.children.map(runtimeLayoutWeight);
|
|
186
|
+
let total = weights.reduce((sum, weight) => sum + weight, 0) || node.children.length || 1;
|
|
187
|
+
let cursor = direction === 'vertical' ? normalizedRect.y : normalizedRect.x;
|
|
188
|
+
|
|
189
|
+
node.children.forEach((child, index) => {
|
|
190
|
+
let ratio = (weights[index] || 1) / total;
|
|
191
|
+
let childRect = direction === 'vertical'
|
|
192
|
+
? {
|
|
193
|
+
x: normalizedRect.x,
|
|
194
|
+
y: cursor,
|
|
195
|
+
width: normalizedRect.width,
|
|
196
|
+
height: normalizedRect.height * ratio,
|
|
197
|
+
}
|
|
198
|
+
: {
|
|
199
|
+
x: cursor,
|
|
200
|
+
y: normalizedRect.y,
|
|
201
|
+
width: normalizedRect.width * ratio,
|
|
202
|
+
height: normalizedRect.height,
|
|
203
|
+
};
|
|
204
|
+
cursor += direction === 'vertical' ? childRect.height : childRect.width;
|
|
205
|
+
walk(child, child.layout?.rect || childRect);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
walk(root, { x: 0, y: 0, width: 1, height: 1 });
|
|
210
|
+
return rects;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function createRelativeSize(rect, preset, options = {}) {
|
|
214
|
+
if (!rect) {
|
|
215
|
+
return {
|
|
216
|
+
size: [...preset.size],
|
|
217
|
+
source: 'preset',
|
|
218
|
+
relativeRect: null,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
let size = options.relativeSize || DEFAULT_RELATIVE_SIZE;
|
|
222
|
+
return {
|
|
223
|
+
size: [
|
|
224
|
+
roundMetric(clamp(
|
|
225
|
+
rect.width * numberOr(size.width, DEFAULT_RELATIVE_SIZE.width),
|
|
226
|
+
numberOr(size.minWidth, DEFAULT_RELATIVE_SIZE.minWidth),
|
|
227
|
+
numberOr(size.maxWidth, DEFAULT_RELATIVE_SIZE.maxWidth)
|
|
228
|
+
)),
|
|
229
|
+
roundMetric(clamp(
|
|
230
|
+
rect.height * numberOr(size.height, DEFAULT_RELATIVE_SIZE.height),
|
|
231
|
+
numberOr(size.minHeight, DEFAULT_RELATIVE_SIZE.minHeight),
|
|
232
|
+
numberOr(size.maxHeight, DEFAULT_RELATIVE_SIZE.maxHeight)
|
|
233
|
+
)),
|
|
234
|
+
],
|
|
235
|
+
source: 'relative-layout',
|
|
236
|
+
relativeRect: rect,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function normalizeXRPanel(panel = {}, options = {}) {
|
|
241
|
+
let xr = panel.xr || panel.props?.xr || {};
|
|
242
|
+
let presetName = xr.preset ||
|
|
243
|
+
(XR_LAYOUT_PRESETS[xr.anchor] ? xr.anchor : inferPreset({ ...panel, xr }, options.index || 0, options.total || 1));
|
|
244
|
+
let preset = XR_LAYOUT_PRESETS[presetName] || XR_LAYOUT_PRESETS.front;
|
|
245
|
+
let relative = createRelativeSize(normalizeRect(options.relativeRect), preset, options);
|
|
246
|
+
let explicitSize = Array.isArray(xr.size);
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
id: String(panel.id || `xr-panel-${options.index || 0}`),
|
|
250
|
+
panelType: panel.panelType || panel.component || 'panel',
|
|
251
|
+
component: panel.component || panel.panelState?.component || panel.panelType || 'panel',
|
|
252
|
+
layoutNode: panel,
|
|
253
|
+
anchor: xr.anchor || presetName,
|
|
254
|
+
position: asVector(xr.position, preset.position),
|
|
255
|
+
rotation: asVector(xr.rotation, preset.rotation),
|
|
256
|
+
size: explicitSize ? asVector(xr.size, preset.size) : relative.size,
|
|
257
|
+
sizeSource: explicitSize ? 'explicit' : relative.source,
|
|
258
|
+
relativeRect: relative.relativeRect,
|
|
259
|
+
curve: numberOr(xr.curve, options.curve ?? 0),
|
|
260
|
+
opacity: numberOr(xr.opacity, options.opacity ?? 1),
|
|
261
|
+
priority: numberOr(xr.priority ?? panel.priority, options.index || 0),
|
|
262
|
+
state: panel.panelState || {},
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function projectLayoutToXR(root, options = {}) {
|
|
267
|
+
let panels = Array.isArray(root?.panels)
|
|
268
|
+
? root.panels
|
|
269
|
+
: collectPanels(root, { includeGlobal: options.includeGlobal !== false });
|
|
270
|
+
let rects = Array.isArray(root?.panels) ? new Map() : collectLayoutRects(root);
|
|
271
|
+
if (!panels.length && isRuntimeUiNode(root)) {
|
|
272
|
+
panels = collectRuntimePanels(root);
|
|
273
|
+
rects = collectRuntimeRects(root);
|
|
274
|
+
}
|
|
275
|
+
let projectedPanels = panels
|
|
276
|
+
.map((panel, index) => normalizeXRPanel(panel, {
|
|
277
|
+
...options,
|
|
278
|
+
index,
|
|
279
|
+
total: panels.length,
|
|
280
|
+
relativeRect: rects.get(panel),
|
|
281
|
+
}))
|
|
282
|
+
.sort((a, b) => a.priority - b.priority || a.id.localeCompare(b.id));
|
|
283
|
+
|
|
284
|
+
return {
|
|
285
|
+
version: 'xr-layout-v1',
|
|
286
|
+
unit: 'meter',
|
|
287
|
+
coordinateSystem: 'webxr-local-floor',
|
|
288
|
+
panels: projectedPanels,
|
|
289
|
+
focusPanelId: options.focusPanelId || projectedPanels[0]?.id || null,
|
|
290
|
+
themeScope: options.themeScope || 'xr',
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export function createXRPanelPose(panel, frame = null, referenceSpace = null) {
|
|
295
|
+
return {
|
|
296
|
+
panelId: panel.id,
|
|
297
|
+
position: [...panel.position],
|
|
298
|
+
rotation: [...panel.rotation],
|
|
299
|
+
size: [...panel.size],
|
|
300
|
+
frame,
|
|
301
|
+
referenceSpace,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function rectSummary(rect) {
|
|
306
|
+
if (!rect) return null;
|
|
307
|
+
return {
|
|
308
|
+
x: roundMetric(numberOr(rect.x, 0)),
|
|
309
|
+
y: roundMetric(numberOr(rect.y, 0)),
|
|
310
|
+
width: roundMetric(numberOr(rect.width, 0)),
|
|
311
|
+
height: roundMetric(numberOr(rect.height, 0)),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function previewSummary(preview) {
|
|
316
|
+
if (!preview) return null;
|
|
317
|
+
return {
|
|
318
|
+
left: roundMetric(numberOr(preview.left, 0)),
|
|
319
|
+
top: roundMetric(numberOr(preview.top, 0)),
|
|
320
|
+
width: roundMetric(numberOr(preview.width, 0)),
|
|
321
|
+
height: roundMetric(numberOr(preview.height, 0)),
|
|
322
|
+
depth: roundMetric(numberOr(preview.depth, 0)),
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function panelWorldRect(panel) {
|
|
327
|
+
let position = asVector(panel.position, [0, 0, 0]);
|
|
328
|
+
let size = asVector(panel.size, [0, 0]);
|
|
329
|
+
return {
|
|
330
|
+
panelId: String(panel.id || ''),
|
|
331
|
+
left: roundMetric(position[0] - size[0] / 2),
|
|
332
|
+
right: roundMetric(position[0] + size[0] / 2),
|
|
333
|
+
bottom: roundMetric(position[1] - size[1] / 2),
|
|
334
|
+
top: roundMetric(position[1] + size[1] / 2),
|
|
335
|
+
z: roundMetric(position[2]),
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function rectOverlap(first, second) {
|
|
340
|
+
let width = Math.max(0, Math.min(first.right, second.right) - Math.max(first.left, second.left));
|
|
341
|
+
let height = Math.max(0, Math.min(first.top, second.top) - Math.max(first.bottom, second.bottom));
|
|
342
|
+
return roundMetric(width * height);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function normalizeVisualTelemetry(input = {}) {
|
|
346
|
+
let telemetry = input.telemetry || input.session || {};
|
|
347
|
+
let adapter = input.adapter || input.adapterState || {};
|
|
348
|
+
return {
|
|
349
|
+
active: Boolean(telemetry.active ?? input.active),
|
|
350
|
+
panelFrameVisuals: Number(telemetry.panelFrameVisuals ?? adapter.panelFrameVisualCount ?? 0),
|
|
351
|
+
controllerRayVisuals: Number(telemetry.controllerRayVisuals ?? input.controllerRayVisuals ?? 0),
|
|
352
|
+
hitReticleVisuals: Number(telemetry.hitReticleVisuals ?? input.hitReticleVisuals ?? 0),
|
|
353
|
+
interactionEvents: Number(telemetry.interactionEvents ?? input.interactionEvents ?? 0),
|
|
354
|
+
hoverPanelId: telemetry.hover?.panelId || input.hover?.panelId || null,
|
|
355
|
+
selectedPanelId: telemetry.selectedPanelId || input.selectedPanelId || null,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function visualCheck(id, status, details = {}) {
|
|
360
|
+
return {
|
|
361
|
+
id,
|
|
362
|
+
status,
|
|
363
|
+
...details,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function roundPixel(value) {
|
|
368
|
+
return Math.round(numberOr(value, 0));
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function normalizeDegrees(value) {
|
|
372
|
+
let normalized = ((numberOr(value, 0) + 180) % 360 + 360) % 360 - 180;
|
|
373
|
+
return roundMetric(normalized);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function yawToViewer(position) {
|
|
377
|
+
return normalizeDegrees(Math.atan2(-position[0], Math.max(Math.abs(position[2]), 0.000001)) * 180 / Math.PI);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function normalizeViewportOptions(options = {}) {
|
|
381
|
+
return {
|
|
382
|
+
minWidth: numberOr(options.minWidth, DEFAULT_CONTENT_VIEWPORT.minWidth),
|
|
383
|
+
minHeight: numberOr(options.minHeight, DEFAULT_CONTENT_VIEWPORT.minHeight),
|
|
384
|
+
maxWidth: numberOr(options.maxWidth, DEFAULT_CONTENT_VIEWPORT.maxWidth),
|
|
385
|
+
maxHeight: numberOr(options.maxHeight, DEFAULT_CONTENT_VIEWPORT.maxHeight),
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function fitViewportToAspect(aspectRatio, options) {
|
|
390
|
+
let width = Math.max(options.minWidth, options.minHeight * aspectRatio);
|
|
391
|
+
let height = width / aspectRatio;
|
|
392
|
+
if (height < options.minHeight) {
|
|
393
|
+
height = options.minHeight;
|
|
394
|
+
width = height * aspectRatio;
|
|
395
|
+
}
|
|
396
|
+
if (width > options.maxWidth) {
|
|
397
|
+
width = options.maxWidth;
|
|
398
|
+
height = width / aspectRatio;
|
|
399
|
+
}
|
|
400
|
+
if (height > options.maxHeight) {
|
|
401
|
+
height = options.maxHeight;
|
|
402
|
+
width = height * aspectRatio;
|
|
403
|
+
}
|
|
404
|
+
if (width < options.minWidth) {
|
|
405
|
+
width = options.minWidth;
|
|
406
|
+
}
|
|
407
|
+
if (height < options.minHeight) {
|
|
408
|
+
height = options.minHeight;
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
width: roundPixel(width),
|
|
412
|
+
height: roundPixel(height),
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function scaleForPreview(viewport, preview) {
|
|
417
|
+
if (!preview) return 1;
|
|
418
|
+
let widthScale = numberOr(preview.width, 0) / viewport.width;
|
|
419
|
+
let heightScale = numberOr(preview.height, 0) / viewport.height;
|
|
420
|
+
let scale = Math.min(widthScale, heightScale);
|
|
421
|
+
return roundMetric(scale > 0 ? scale : 1);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export function createXRPanelContentViewport(panel = {}, options = {}) {
|
|
425
|
+
let size = asVector(panel.size, [1, 0.5625]);
|
|
426
|
+
let aspectRatio = roundMetric(clamp(size[0] / Math.max(size[1], 0.000001), 0.35, 2.4));
|
|
427
|
+
let viewport = fitViewportToAspect(aspectRatio, normalizeViewportOptions(options));
|
|
428
|
+
let preview = options.previewPixels || options.preview || null;
|
|
429
|
+
let scale = scaleForPreview(viewport, preview);
|
|
430
|
+
return {
|
|
431
|
+
width: viewport.width,
|
|
432
|
+
height: viewport.height,
|
|
433
|
+
aspectRatio,
|
|
434
|
+
scale,
|
|
435
|
+
density: roundMetric(clamp(scale * 6, 0.72, 1)),
|
|
436
|
+
source: preview ? 'preview-fit' : 'panel-aspect',
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export function createXRPanelTextureQualitySummary(panel = {}, options = {}) {
|
|
441
|
+
let policy = createXRTextureQualityPolicy(panel, options);
|
|
442
|
+
let size = asVector(panel.size, [1, 0.5625]);
|
|
443
|
+
let pixelsPerMeterX = roundMetric(policy.texturePixels.width / Math.max(size[0], 0.000001));
|
|
444
|
+
let pixelsPerMeterY = roundMetric(policy.texturePixels.height / Math.max(size[1], 0.000001));
|
|
445
|
+
let minAxisPixelsPerMeter = roundMetric(Math.min(pixelsPerMeterX, pixelsPerMeterY));
|
|
446
|
+
let requiredPixels = {
|
|
447
|
+
min: {
|
|
448
|
+
width: roundPixel(size[0] * policy.thresholds.minPixelsPerMeter),
|
|
449
|
+
height: roundPixel(size[1] * policy.thresholds.minPixelsPerMeter),
|
|
450
|
+
},
|
|
451
|
+
target: {
|
|
452
|
+
width: roundPixel(size[0] * policy.thresholds.targetPixelsPerMeter),
|
|
453
|
+
height: roundPixel(size[1] * policy.thresholds.targetPixelsPerMeter),
|
|
454
|
+
},
|
|
455
|
+
};
|
|
456
|
+
let status = minAxisPixelsPerMeter >= policy.thresholds.targetPixelsPerMeter
|
|
457
|
+
? 'target'
|
|
458
|
+
: minAxisPixelsPerMeter >= policy.thresholds.minPixelsPerMeter ? 'readable' : 'low';
|
|
459
|
+
let warnings = [];
|
|
460
|
+
if (status === 'low') warnings.push('texture-density-low');
|
|
461
|
+
if (!policy.texturePixels.width || !policy.texturePixels.height) warnings.push('missing-texture-size');
|
|
462
|
+
if (policy.capped) warnings.push('texture-size-capped');
|
|
463
|
+
let recommendations = [];
|
|
464
|
+
if (warnings.includes('missing-texture-size')) {
|
|
465
|
+
recommendations.push('provide-texture-size');
|
|
466
|
+
}
|
|
467
|
+
if (status === 'low') {
|
|
468
|
+
recommendations.push('increase-texture-resolution');
|
|
469
|
+
}
|
|
470
|
+
if (status !== 'target') {
|
|
471
|
+
recommendations.push('increase-texture-density-to-target');
|
|
472
|
+
}
|
|
473
|
+
if (status !== 'target' && policy.texturePixelRatio < policy.maxTexturePixelRatio) {
|
|
474
|
+
recommendations.push('increase-texture-pixel-ratio');
|
|
475
|
+
}
|
|
476
|
+
if (policy.capped || requiredPixels.target.width > policy.maxTextureSize || requiredPixels.target.height > policy.maxTextureSize) {
|
|
477
|
+
recommendations.push('increase-max-texture-size');
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
panelId: String(panel.id || ''),
|
|
481
|
+
status,
|
|
482
|
+
texturePixels: policy.texturePixels,
|
|
483
|
+
requiredPixels,
|
|
484
|
+
meters: {
|
|
485
|
+
width: roundMetric(size[0]),
|
|
486
|
+
height: roundMetric(size[1]),
|
|
487
|
+
},
|
|
488
|
+
pixelsPerMeter: {
|
|
489
|
+
x: pixelsPerMeterX,
|
|
490
|
+
y: pixelsPerMeterY,
|
|
491
|
+
min: minAxisPixelsPerMeter,
|
|
492
|
+
},
|
|
493
|
+
contentViewport: {
|
|
494
|
+
width: policy.contentViewport.width,
|
|
495
|
+
height: policy.contentViewport.height,
|
|
496
|
+
scale: policy.contentViewport.scale,
|
|
497
|
+
density: policy.contentViewport.density,
|
|
498
|
+
},
|
|
499
|
+
thresholds: policy.thresholds,
|
|
500
|
+
policy,
|
|
501
|
+
warnings,
|
|
502
|
+
recommendations: [...new Set(recommendations)],
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export function createXRTextureQualityPolicy(panel = {}, options = {}) {
|
|
507
|
+
let size = asVector(panel.size, [1, 0.5625]);
|
|
508
|
+
let viewport = panel.contentViewport || createXRPanelContentViewport(panel, {
|
|
509
|
+
previewPixels: options.previewPixels || options.preview || null,
|
|
510
|
+
});
|
|
511
|
+
let maxTexturePixelRatio = numberOr(options.maxTexturePixelRatio, DEFAULT_TEXTURE_QUALITY.maxTexturePixelRatio);
|
|
512
|
+
let texturePixelRatio = clamp(
|
|
513
|
+
numberOr(options.texturePixelRatio ?? options.pixelRatio, DEFAULT_TEXTURE_QUALITY.texturePixelRatio),
|
|
514
|
+
0.5,
|
|
515
|
+
maxTexturePixelRatio
|
|
516
|
+
);
|
|
517
|
+
let maxTextureSize = Math.max(256, numberOr(options.maxTextureSize, DEFAULT_TEXTURE_QUALITY.maxTextureSize));
|
|
518
|
+
let minPixelsPerMeter = numberOr(options.minPixelsPerMeter, DEFAULT_TEXTURE_QUALITY.minPixelsPerMeter);
|
|
519
|
+
let targetPixelsPerMeter = numberOr(options.targetPixelsPerMeter, DEFAULT_TEXTURE_QUALITY.targetPixelsPerMeter);
|
|
520
|
+
let desiredWidth = Math.max(viewport.width * texturePixelRatio, size[0] * minPixelsPerMeter);
|
|
521
|
+
let desiredHeight = Math.max(viewport.height * texturePixelRatio, size[1] * minPixelsPerMeter);
|
|
522
|
+
if (options.preferTargetDensity) {
|
|
523
|
+
desiredWidth = Math.max(desiredWidth, size[0] * targetPixelsPerMeter);
|
|
524
|
+
desiredHeight = Math.max(desiredHeight, size[1] * targetPixelsPerMeter);
|
|
525
|
+
}
|
|
526
|
+
let textureWidth = roundPixel(options.textureWidth ?? Math.min(desiredWidth, maxTextureSize));
|
|
527
|
+
let textureHeight = roundPixel(options.textureHeight ?? Math.min(desiredHeight, maxTextureSize));
|
|
528
|
+
return {
|
|
529
|
+
version: 'xr-texture-quality-policy-v1',
|
|
530
|
+
panelId: String(panel.id || ''),
|
|
531
|
+
redrawMode: options.redrawMode || DEFAULT_TEXTURE_QUALITY.redrawMode,
|
|
532
|
+
texturePixelRatio,
|
|
533
|
+
maxTexturePixelRatio,
|
|
534
|
+
maxTextureSize,
|
|
535
|
+
texturePixels: { width: textureWidth, height: textureHeight },
|
|
536
|
+
contentViewport: {
|
|
537
|
+
width: viewport.width,
|
|
538
|
+
height: viewport.height,
|
|
539
|
+
scale: viewport.scale,
|
|
540
|
+
density: viewport.density,
|
|
541
|
+
},
|
|
542
|
+
thresholds: {
|
|
543
|
+
minPixelsPerMeter,
|
|
544
|
+
targetPixelsPerMeter,
|
|
545
|
+
},
|
|
546
|
+
capped: textureWidth >= maxTextureSize || textureHeight >= maxTextureSize,
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
export function createXRPanelPoseComfortSummary(panel = {}, options = {}) {
|
|
551
|
+
let position = asVector(panel.position, [0, DEFAULT_POSE_COMFORT.eyeHeight, -DEFAULT_POSE_COMFORT.targetDistance]);
|
|
552
|
+
let size = asVector(panel.size, [1, 0.5625]);
|
|
553
|
+
let eyeHeight = numberOr(options.eyeHeight ?? options.userSpace?.eyeHeight, DEFAULT_POSE_COMFORT.eyeHeight);
|
|
554
|
+
let minDistance = numberOr(options.minDistance, DEFAULT_POSE_COMFORT.minDistance);
|
|
555
|
+
let targetDistance = numberOr(options.targetDistance, DEFAULT_POSE_COMFORT.targetDistance);
|
|
556
|
+
let maxDistance = numberOr(options.maxDistance, DEFAULT_POSE_COMFORT.maxDistance);
|
|
557
|
+
let maxHorizontalAngle = numberOr(options.maxHorizontalAngle, DEFAULT_POSE_COMFORT.maxHorizontalAngle);
|
|
558
|
+
let minVerticalAngle = numberOr(options.minVerticalAngle, DEFAULT_POSE_COMFORT.minVerticalAngle);
|
|
559
|
+
let maxVerticalAngle = numberOr(options.maxVerticalAngle, DEFAULT_POSE_COMFORT.maxVerticalAngle);
|
|
560
|
+
let horizontalDistance = Math.sqrt((position[0] ** 2) + (position[2] ** 2));
|
|
561
|
+
let distance = Math.sqrt((position[0] ** 2) + ((position[1] - eyeHeight) ** 2) + (position[2] ** 2));
|
|
562
|
+
let horizontalAngle = Math.atan2(position[0], Math.max(Math.abs(position[2]), 0.000001)) * 180 / Math.PI;
|
|
563
|
+
let verticalAngle = Math.atan2(position[1] - eyeHeight, Math.max(horizontalDistance, 0.000001)) * 180 / Math.PI;
|
|
564
|
+
let warnings = [];
|
|
565
|
+
|
|
566
|
+
if (distance < minDistance) warnings.push('panel-too-close');
|
|
567
|
+
if (distance > maxDistance) warnings.push('panel-too-far');
|
|
568
|
+
if (Math.abs(horizontalAngle) > maxHorizontalAngle) warnings.push('panel-horizontal-angle-high');
|
|
569
|
+
if (verticalAngle < minVerticalAngle) warnings.push('panel-too-low');
|
|
570
|
+
if (verticalAngle > maxVerticalAngle) warnings.push('panel-too-high');
|
|
571
|
+
|
|
572
|
+
return {
|
|
573
|
+
panelId: String(panel.id || ''),
|
|
574
|
+
status: warnings.length ? 'warning' : 'comfortable',
|
|
575
|
+
distance: roundMetric(distance),
|
|
576
|
+
targetDistance: roundMetric(targetDistance),
|
|
577
|
+
eyeHeight: roundMetric(eyeHeight),
|
|
578
|
+
heightOffset: roundMetric(position[1] - eyeHeight),
|
|
579
|
+
angles: {
|
|
580
|
+
horizontal: roundMetric(horizontalAngle),
|
|
581
|
+
vertical: roundMetric(verticalAngle),
|
|
582
|
+
},
|
|
583
|
+
position: position.map(roundMetric),
|
|
584
|
+
size: {
|
|
585
|
+
width: roundMetric(size[0]),
|
|
586
|
+
height: roundMetric(size[1]),
|
|
587
|
+
},
|
|
588
|
+
thresholds: {
|
|
589
|
+
minDistance,
|
|
590
|
+
maxDistance,
|
|
591
|
+
maxHorizontalAngle,
|
|
592
|
+
minVerticalAngle,
|
|
593
|
+
maxVerticalAngle,
|
|
594
|
+
},
|
|
595
|
+
warnings,
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export function adjustXRPanelPoseForComfort(panel = {}, options = {}) {
|
|
600
|
+
let summary = createXRPanelPoseComfortSummary(panel, options);
|
|
601
|
+
if (summary.status === 'comfortable') {
|
|
602
|
+
return { ...panel };
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
let position = asVector(panel.position, [0, summary.eyeHeight, -summary.targetDistance]);
|
|
606
|
+
let adjustedPosition = [...position];
|
|
607
|
+
let horizontalDistance = Math.sqrt((position[0] ** 2) + (position[2] ** 2));
|
|
608
|
+
let changed = false;
|
|
609
|
+
let reasons = [];
|
|
610
|
+
|
|
611
|
+
if (summary.warnings.includes('panel-too-low')) {
|
|
612
|
+
adjustedPosition[1] = summary.eyeHeight + Math.tan((summary.thresholds.minVerticalAngle + 2) * Math.PI / 180) * horizontalDistance;
|
|
613
|
+
reasons.push('vertical-angle-raised');
|
|
614
|
+
changed = true;
|
|
615
|
+
}
|
|
616
|
+
if (summary.warnings.includes('panel-too-high')) {
|
|
617
|
+
adjustedPosition[1] = summary.eyeHeight + Math.tan((summary.thresholds.maxVerticalAngle - 2) * Math.PI / 180) * horizontalDistance;
|
|
618
|
+
reasons.push('vertical-angle-lowered');
|
|
619
|
+
changed = true;
|
|
620
|
+
}
|
|
621
|
+
if (summary.warnings.includes('panel-too-close')) {
|
|
622
|
+
let zSign = adjustedPosition[2] <= 0 ? -1 : 1;
|
|
623
|
+
adjustedPosition[2] = zSign * Math.max(Math.abs(adjustedPosition[2]), summary.thresholds.minDistance);
|
|
624
|
+
reasons.push('distance-pushed');
|
|
625
|
+
changed = true;
|
|
626
|
+
}
|
|
627
|
+
if (summary.warnings.includes('panel-too-far')) {
|
|
628
|
+
let zSign = adjustedPosition[2] <= 0 ? -1 : 1;
|
|
629
|
+
adjustedPosition[2] = zSign * Math.min(Math.abs(adjustedPosition[2]), summary.thresholds.maxDistance);
|
|
630
|
+
reasons.push('distance-pulled');
|
|
631
|
+
changed = true;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
let adjustedPanel = {
|
|
635
|
+
...panel,
|
|
636
|
+
position: adjustedPosition.map(roundMetric),
|
|
637
|
+
};
|
|
638
|
+
let after = createXRPanelPoseComfortSummary(adjustedPanel, options);
|
|
639
|
+
return {
|
|
640
|
+
...adjustedPanel,
|
|
641
|
+
poseAdjustment: {
|
|
642
|
+
adjusted: changed,
|
|
643
|
+
reason: reasons.join(',') || null,
|
|
644
|
+
before: summary,
|
|
645
|
+
after,
|
|
646
|
+
},
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export function createXRPanelFacingSummary(panel = {}, options = {}) {
|
|
651
|
+
let position = asVector(panel.position, [0, DEFAULT_POSE_COMFORT.eyeHeight, -DEFAULT_POSE_COMFORT.targetDistance]);
|
|
652
|
+
let rotation = asVector(panel.rotation, [0, 0, 0]);
|
|
653
|
+
let maxYawError = numberOr(options.maxYawError, DEFAULT_FACING.maxYawError);
|
|
654
|
+
let targetYaw = yawToViewer(position);
|
|
655
|
+
let yawDelta = normalizeDegrees(rotation[1] - targetYaw);
|
|
656
|
+
let warnings = [];
|
|
657
|
+
|
|
658
|
+
if (Math.abs(yawDelta) > maxYawError) warnings.push('panel-yaw-off-axis');
|
|
659
|
+
|
|
660
|
+
return {
|
|
661
|
+
panelId: String(panel.id || ''),
|
|
662
|
+
status: warnings.length ? 'warning' : 'aligned',
|
|
663
|
+
rotation: rotation.map(roundMetric),
|
|
664
|
+
targetRotation: [roundMetric(rotation[0]), targetYaw, roundMetric(rotation[2])],
|
|
665
|
+
delta: {
|
|
666
|
+
yaw: yawDelta,
|
|
667
|
+
},
|
|
668
|
+
thresholds: {
|
|
669
|
+
maxYawError,
|
|
670
|
+
},
|
|
671
|
+
warnings,
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
export function adjustXRPanelRotationForViewer(panel = {}, options = {}) {
|
|
676
|
+
let summary = createXRPanelFacingSummary(panel, options);
|
|
677
|
+
if (summary.status === 'aligned') {
|
|
678
|
+
return { ...panel };
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
let rotation = asVector(panel.rotation, [0, 0, 0]);
|
|
682
|
+
let adjustedPanel = {
|
|
683
|
+
...panel,
|
|
684
|
+
rotation: [roundMetric(rotation[0]), summary.targetRotation[1], roundMetric(rotation[2])],
|
|
685
|
+
};
|
|
686
|
+
let after = createXRPanelFacingSummary(adjustedPanel, options);
|
|
687
|
+
|
|
688
|
+
return {
|
|
689
|
+
...adjustedPanel,
|
|
690
|
+
rotationAdjustment: {
|
|
691
|
+
adjusted: true,
|
|
692
|
+
reason: summary.warnings.join(',') || null,
|
|
693
|
+
before: summary,
|
|
694
|
+
after,
|
|
695
|
+
},
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
export function createXRPanelGeometrySummary(panel = {}, preview = null, options = {}) {
|
|
700
|
+
let size = asVector(panel.size, [0, 0]);
|
|
701
|
+
let contentViewport = panel.contentViewport || createXRPanelContentViewport(panel, {
|
|
702
|
+
previewPixels: previewSummary(preview),
|
|
703
|
+
});
|
|
704
|
+
return {
|
|
705
|
+
panelId: String(panel.id || ''),
|
|
706
|
+
component: panel.component || panel.panelType || 'panel',
|
|
707
|
+
anchor: panel.anchor || '',
|
|
708
|
+
sizeSource: panel.sizeSource || 'preset',
|
|
709
|
+
relativeRect: rectSummary(panel.relativeRect),
|
|
710
|
+
meters: {
|
|
711
|
+
width: roundMetric(size[0]),
|
|
712
|
+
height: roundMetric(size[1]),
|
|
713
|
+
},
|
|
714
|
+
previewPixels: previewSummary(preview),
|
|
715
|
+
contentViewport,
|
|
716
|
+
textureQuality: createXRPanelTextureQualitySummary(panel, {
|
|
717
|
+
...options,
|
|
718
|
+
previewPixels: previewSummary(preview),
|
|
719
|
+
}),
|
|
720
|
+
poseComfort: createXRPanelPoseComfortSummary(panel, options),
|
|
721
|
+
poseAdjustment: panel.poseAdjustment || null,
|
|
722
|
+
facing: createXRPanelFacingSummary(panel, options),
|
|
723
|
+
rotationAdjustment: panel.rotationAdjustment || null,
|
|
724
|
+
position: asVector(panel.position, [0, 0, 0]).map(roundMetric),
|
|
725
|
+
rotation: asVector(panel.rotation, [0, 0, 0]).map(roundMetric),
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
export function createXRSceneQualitySummary(sceneOrPanels = {}, options = {}) {
|
|
730
|
+
let panels = Array.isArray(sceneOrPanels)
|
|
731
|
+
? sceneOrPanels
|
|
732
|
+
: Array.isArray(sceneOrPanels.panels) ? sceneOrPanels.panels : [];
|
|
733
|
+
let panelSummaries = panels.map((panel) => {
|
|
734
|
+
let textureQuality = createXRPanelTextureQualitySummary(panel, options);
|
|
735
|
+
let poseComfort = createXRPanelPoseComfortSummary(panel, options);
|
|
736
|
+
let facing = createXRPanelFacingSummary(panel, options);
|
|
737
|
+
return {
|
|
738
|
+
panelId: String(panel.id || ''),
|
|
739
|
+
textureStatus: textureQuality.status,
|
|
740
|
+
comfortStatus: poseComfort.status,
|
|
741
|
+
facingStatus: facing.status,
|
|
742
|
+
pixelsPerMeter: textureQuality.pixelsPerMeter.min,
|
|
743
|
+
distance: poseComfort.distance,
|
|
744
|
+
position: asVector(panel.position, [0, 0, 0]).map(roundMetric),
|
|
745
|
+
rotation: asVector(panel.rotation, [0, 0, 0]).map(roundMetric),
|
|
746
|
+
warnings: [
|
|
747
|
+
...textureQuality.warnings,
|
|
748
|
+
...poseComfort.warnings,
|
|
749
|
+
...facing.warnings,
|
|
750
|
+
],
|
|
751
|
+
};
|
|
752
|
+
});
|
|
753
|
+
let lowQualityCount = panelSummaries.filter((panel) => panel.textureStatus === 'low').length;
|
|
754
|
+
let comfortWarningCount = panelSummaries.filter((panel) => panel.comfortStatus === 'warning').length;
|
|
755
|
+
let facingWarningCount = panelSummaries.filter((panel) => panel.facingStatus === 'warning').length;
|
|
756
|
+
return {
|
|
757
|
+
version: 'xr-scene-quality-summary-v1',
|
|
758
|
+
status: lowQualityCount || comfortWarningCount || facingWarningCount ? 'warning' : 'ok',
|
|
759
|
+
total: panelSummaries.length,
|
|
760
|
+
lowQualityCount,
|
|
761
|
+
comfortWarningCount,
|
|
762
|
+
facingWarningCount,
|
|
763
|
+
panels: panelSummaries,
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
export function createXRSceneGeometrySummary(sceneOrPanels = {}, options = {}) {
|
|
768
|
+
let panels = Array.isArray(sceneOrPanels)
|
|
769
|
+
? sceneOrPanels
|
|
770
|
+
: Array.isArray(sceneOrPanels.panels) ? sceneOrPanels.panels : [];
|
|
771
|
+
let panelSummaries = panels.map((panel) => createXRPanelGeometrySummary(
|
|
772
|
+
panel,
|
|
773
|
+
options.previewByPanel?.[panel.id] || options.preview || null,
|
|
774
|
+
options
|
|
775
|
+
));
|
|
776
|
+
let pixelsPerMeter = panelSummaries
|
|
777
|
+
.map((panel) => panel.textureQuality?.pixelsPerMeter?.min)
|
|
778
|
+
.filter((value) => Number.isFinite(value));
|
|
779
|
+
let lowQualityCount = panelSummaries
|
|
780
|
+
.filter((panel) => panel.textureQuality?.status === 'low').length;
|
|
781
|
+
let comfortWarningCount = panelSummaries
|
|
782
|
+
.filter((panel) => panel.poseComfort?.status === 'warning').length;
|
|
783
|
+
let poseAdjustedCount = panelSummaries
|
|
784
|
+
.filter((panel) => panel.poseAdjustment?.adjusted).length;
|
|
785
|
+
let facingWarningCount = panelSummaries
|
|
786
|
+
.filter((panel) => panel.facing?.status === 'warning').length;
|
|
787
|
+
let rotationAdjustedCount = panelSummaries
|
|
788
|
+
.filter((panel) => panel.rotationAdjustment?.adjusted).length;
|
|
789
|
+
|
|
790
|
+
return {
|
|
791
|
+
version: 'xr-scene-geometry-summary-v1',
|
|
792
|
+
total: panelSummaries.length,
|
|
793
|
+
status: lowQualityCount || comfortWarningCount || facingWarningCount ? 'warning' : 'ok',
|
|
794
|
+
lowQualityCount,
|
|
795
|
+
comfortWarningCount,
|
|
796
|
+
poseAdjustedCount,
|
|
797
|
+
facingWarningCount,
|
|
798
|
+
rotationAdjustedCount,
|
|
799
|
+
minPixelsPerMeter: pixelsPerMeter.length ? roundMetric(Math.min(...pixelsPerMeter)) : null,
|
|
800
|
+
firstPanel: panelSummaries[0] || null,
|
|
801
|
+
panels: panelSummaries,
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
export function createXRVisualTestSummary(sceneOrPanels = {}, options = {}) {
|
|
806
|
+
let panels = Array.isArray(sceneOrPanels)
|
|
807
|
+
? sceneOrPanels
|
|
808
|
+
: Array.isArray(sceneOrPanels.panels) ? sceneOrPanels.panels : [];
|
|
809
|
+
let geometry = options.geometry || createXRSceneGeometrySummary(sceneOrPanels, options);
|
|
810
|
+
let telemetry = normalizeVisualTelemetry(options);
|
|
811
|
+
let checks = [];
|
|
812
|
+
let issues = [];
|
|
813
|
+
let panelIds = panels.map((panel) => String(panel.id || ''));
|
|
814
|
+
let uniquePanelIds = new Set(panelIds.filter(Boolean));
|
|
815
|
+
let panelMap = geometry.panels.map((panel) => {
|
|
816
|
+
let rect = panelWorldRect(panels.find((item) => String(item.id || '') === panel.panelId) || panel);
|
|
817
|
+
return {
|
|
818
|
+
panelId: panel.panelId,
|
|
819
|
+
component: panel.component,
|
|
820
|
+
anchor: panel.anchor,
|
|
821
|
+
relativeRect: panel.relativeRect,
|
|
822
|
+
position: panel.position,
|
|
823
|
+
rotation: panel.rotation,
|
|
824
|
+
meters: panel.meters,
|
|
825
|
+
contentViewport: panel.contentViewport,
|
|
826
|
+
pixelsPerMeter: panel.textureQuality?.pixelsPerMeter?.min ?? null,
|
|
827
|
+
distance: panel.poseComfort?.distance ?? null,
|
|
828
|
+
facingStatus: panel.facing?.status || null,
|
|
829
|
+
comfortStatus: panel.poseComfort?.status || null,
|
|
830
|
+
worldRect: rect,
|
|
831
|
+
};
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
function addCheck(id, status, details = {}) {
|
|
835
|
+
let check = visualCheck(id, status, details);
|
|
836
|
+
checks.push(check);
|
|
837
|
+
if (status !== 'pass') {
|
|
838
|
+
issues.push({
|
|
839
|
+
id,
|
|
840
|
+
severity: status === 'fail' ? 'error' : 'warning',
|
|
841
|
+
...details,
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
addCheck('panels-present', panels.length ? 'pass' : 'fail', {
|
|
847
|
+
count: panels.length,
|
|
848
|
+
});
|
|
849
|
+
addCheck('panel-ids-unique', uniquePanelIds.size === panelIds.length ? 'pass' : 'fail', {
|
|
850
|
+
count: panelIds.length,
|
|
851
|
+
unique: uniquePanelIds.size,
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
let invalidTransforms = panelMap.filter((panel) => (
|
|
855
|
+
!panel.position.every((value) => Number.isFinite(value)) ||
|
|
856
|
+
!panel.rotation.every((value) => Number.isFinite(value)) ||
|
|
857
|
+
!Number.isFinite(panel.meters.width) ||
|
|
858
|
+
!Number.isFinite(panel.meters.height) ||
|
|
859
|
+
panel.meters.width <= 0 ||
|
|
860
|
+
panel.meters.height <= 0
|
|
861
|
+
));
|
|
862
|
+
addCheck('panel-transforms-finite', invalidTransforms.length ? 'fail' : 'pass', {
|
|
863
|
+
panelIds: invalidTransforms.map((panel) => panel.panelId),
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
let viewportMinWidth = numberOr(options.minContentViewportWidth, DEFAULT_CONTENT_VIEWPORT.minWidth);
|
|
867
|
+
let viewportMinHeight = numberOr(options.minContentViewportHeight, DEFAULT_CONTENT_VIEWPORT.minHeight);
|
|
868
|
+
let smallViewports = panelMap.filter((panel) => (
|
|
869
|
+
Number(panel.contentViewport?.width || 0) < viewportMinWidth ||
|
|
870
|
+
Number(panel.contentViewport?.height || 0) < viewportMinHeight
|
|
871
|
+
));
|
|
872
|
+
addCheck('content-viewports-usable', smallViewports.length ? 'warn' : 'pass', {
|
|
873
|
+
minWidth: viewportMinWidth,
|
|
874
|
+
minHeight: viewportMinHeight,
|
|
875
|
+
panelIds: smallViewports.map((panel) => panel.panelId),
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
addCheck('texture-density-readable', geometry.lowQualityCount ? 'warn' : 'pass', {
|
|
879
|
+
lowQualityCount: geometry.lowQualityCount,
|
|
880
|
+
minPixelsPerMeter: geometry.minPixelsPerMeter,
|
|
881
|
+
});
|
|
882
|
+
addCheck('pose-comfort', geometry.comfortWarningCount ? 'warn' : 'pass', {
|
|
883
|
+
warningCount: geometry.comfortWarningCount,
|
|
884
|
+
});
|
|
885
|
+
addCheck('viewer-facing', geometry.facingWarningCount ? 'warn' : 'pass', {
|
|
886
|
+
warningCount: geometry.facingWarningCount,
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
let maxDepthDelta = numberOr(options.maxOverlapDepthDelta, 0.35);
|
|
890
|
+
let maxOverlapArea = numberOr(options.maxOverlapArea, 0.02);
|
|
891
|
+
let overlaps = [];
|
|
892
|
+
for (let index = 0; index < panelMap.length; index += 1) {
|
|
893
|
+
for (let next = index + 1; next < panelMap.length; next += 1) {
|
|
894
|
+
let first = panelMap[index].worldRect;
|
|
895
|
+
let second = panelMap[next].worldRect;
|
|
896
|
+
let depthDelta = Math.abs(first.z - second.z);
|
|
897
|
+
let area = rectOverlap(first, second);
|
|
898
|
+
if (depthDelta <= maxDepthDelta && area > maxOverlapArea) {
|
|
899
|
+
overlaps.push({
|
|
900
|
+
panelIds: [first.panelId, second.panelId],
|
|
901
|
+
area,
|
|
902
|
+
depthDelta: roundMetric(depthDelta),
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
addCheck('panel-world-overlap', overlaps.length ? 'warn' : 'pass', {
|
|
908
|
+
overlaps,
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
let expectedFrameVisuals = Number(options.expectedFrameVisuals ?? panels.length);
|
|
912
|
+
if (options.expectInteraction !== false && (telemetry.active || options.expectInteraction === true)) {
|
|
913
|
+
addCheck('frame-visuals-present', telemetry.panelFrameVisuals >= expectedFrameVisuals ? 'pass' : 'warn', {
|
|
914
|
+
count: telemetry.panelFrameVisuals,
|
|
915
|
+
expected: expectedFrameVisuals,
|
|
916
|
+
});
|
|
917
|
+
addCheck('controller-rays-visible', telemetry.controllerRayVisuals > 0 ? 'pass' : 'warn', {
|
|
918
|
+
count: telemetry.controllerRayVisuals,
|
|
919
|
+
});
|
|
920
|
+
addCheck('hit-reticle-visible', telemetry.hitReticleVisuals > 0 ? 'pass' : 'warn', {
|
|
921
|
+
count: telemetry.hitReticleVisuals,
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
let failCount = checks.filter((check) => check.status === 'fail').length;
|
|
926
|
+
let warnCount = checks.filter((check) => check.status === 'warn').length;
|
|
927
|
+
return {
|
|
928
|
+
version: 'xr-visual-test-summary-v1',
|
|
929
|
+
status: failCount ? 'fail' : warnCount ? 'warning' : 'pass',
|
|
930
|
+
panelCount: panels.length,
|
|
931
|
+
checkCount: checks.length,
|
|
932
|
+
failCount,
|
|
933
|
+
warnCount,
|
|
934
|
+
passCount: checks.filter((check) => check.status === 'pass').length,
|
|
935
|
+
panelMap,
|
|
936
|
+
checks,
|
|
937
|
+
issues,
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
function idsFromVisualSummary(visual = {}) {
|
|
942
|
+
let ids = new Set();
|
|
943
|
+
for (let issue of Array.isArray(visual.issues) ? visual.issues : []) {
|
|
944
|
+
if (issue?.id) ids.add(String(issue.id));
|
|
945
|
+
}
|
|
946
|
+
for (let issueId of Array.isArray(visual.issueIds) ? visual.issueIds : []) {
|
|
947
|
+
if (issueId) ids.add(String(issueId));
|
|
948
|
+
}
|
|
949
|
+
return [...ids];
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
function countOr(value) {
|
|
953
|
+
let count = Number(value);
|
|
954
|
+
return Number.isFinite(count) ? count : 0;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
export function createXRVisualAgentReadinessSummary(input = {}) {
|
|
958
|
+
let visual = input.visual || input.summary || {};
|
|
959
|
+
let expectedIssueIds = [...new Set(Array.isArray(input.expectedIssueIds) ? input.expectedIssueIds.map(String) : [])];
|
|
960
|
+
let actualIssueIds = idsFromVisualSummary(visual);
|
|
961
|
+
let actualIssueSet = new Set(actualIssueIds);
|
|
962
|
+
let expectedIssueSet = new Set(expectedIssueIds);
|
|
963
|
+
let expectedStatus = input.expectedStatus || (expectedIssueIds.length ? 'warning' : 'pass');
|
|
964
|
+
let panelCount = countOr(visual.panelCount ?? input.panelCount);
|
|
965
|
+
let svg = input.svg || input.visualMaps || {};
|
|
966
|
+
let outputs = input.outputs || {};
|
|
967
|
+
let screenshots = Array.isArray(input.screenshots)
|
|
968
|
+
? input.screenshots
|
|
969
|
+
: input.screenshot ? [input.screenshot] : [];
|
|
970
|
+
let pageErrors = Array.isArray(input.pageErrors) ? input.pageErrors : [];
|
|
971
|
+
let requireBrowserArtifacts = input.requireBrowserArtifacts !== false;
|
|
972
|
+
let missingIssues = expectedIssueIds.filter((id) => !actualIssueSet.has(id));
|
|
973
|
+
let unexpectedIssues = input.allowUnexpectedIssues
|
|
974
|
+
? []
|
|
975
|
+
: actualIssueIds.filter((id) => !expectedIssueSet.has(id));
|
|
976
|
+
let mapCounts = {
|
|
977
|
+
topPanelShapes: countOr(svg.topPanelShapes),
|
|
978
|
+
frontPanelShapes: countOr(svg.frontPanelShapes),
|
|
979
|
+
topLabels: countOr(svg.topLabels),
|
|
980
|
+
frontLabels: countOr(svg.frontLabels),
|
|
981
|
+
};
|
|
982
|
+
let outputSizes = {
|
|
983
|
+
statusRows: countOr(outputs.statusRows),
|
|
984
|
+
checksBytes: countOr(outputs.checksBytes),
|
|
985
|
+
panelMapBytes: countOr(outputs.panelMapBytes),
|
|
986
|
+
};
|
|
987
|
+
let invalidScreenshots = screenshots.filter((screenshot) => (
|
|
988
|
+
!screenshot ||
|
|
989
|
+
countOr(screenshot.bytes) <= 0 ||
|
|
990
|
+
countOr(screenshot.width) <= 0 ||
|
|
991
|
+
countOr(screenshot.height) <= 0 ||
|
|
992
|
+
screenshot.invalid === true ||
|
|
993
|
+
screenshot.screenshotInvalid === true
|
|
994
|
+
));
|
|
995
|
+
let checks = [
|
|
996
|
+
visualCheck('visual-status', visual.status === expectedStatus ? 'pass' : 'fail', {
|
|
997
|
+
expected: expectedStatus,
|
|
998
|
+
actual: visual.status || null,
|
|
999
|
+
}),
|
|
1000
|
+
visualCheck('expected-issues', missingIssues.length ? 'fail' : 'pass', {
|
|
1001
|
+
expectedIssueIds,
|
|
1002
|
+
missingIssueIds: missingIssues,
|
|
1003
|
+
}),
|
|
1004
|
+
visualCheck('unexpected-issues', unexpectedIssues.length ? 'warn' : 'pass', {
|
|
1005
|
+
issueIds: unexpectedIssues,
|
|
1006
|
+
}),
|
|
1007
|
+
visualCheck('visual-maps-present', !requireBrowserArtifacts || (
|
|
1008
|
+
mapCounts.topPanelShapes >= panelCount &&
|
|
1009
|
+
mapCounts.frontPanelShapes >= panelCount &&
|
|
1010
|
+
mapCounts.topLabels >= panelCount &&
|
|
1011
|
+
mapCounts.frontLabels >= panelCount
|
|
1012
|
+
) ? 'pass' : 'fail', {
|
|
1013
|
+
panelCount,
|
|
1014
|
+
...mapCounts,
|
|
1015
|
+
}),
|
|
1016
|
+
visualCheck('agent-output-sizes', !requireBrowserArtifacts || (
|
|
1017
|
+
outputSizes.statusRows > 0 &&
|
|
1018
|
+
outputSizes.checksBytes > 0 &&
|
|
1019
|
+
outputSizes.panelMapBytes > 0
|
|
1020
|
+
) ? 'pass' : 'fail', outputSizes),
|
|
1021
|
+
visualCheck('page-errors-empty', pageErrors.length ? 'fail' : 'pass', {
|
|
1022
|
+
count: pageErrors.length,
|
|
1023
|
+
}),
|
|
1024
|
+
visualCheck('screenshots-valid', invalidScreenshots.length ? 'fail' : 'pass', {
|
|
1025
|
+
total: screenshots.length,
|
|
1026
|
+
invalid: invalidScreenshots.length,
|
|
1027
|
+
}),
|
|
1028
|
+
];
|
|
1029
|
+
let failCount = checks.filter((check) => check.status === 'fail').length;
|
|
1030
|
+
let warnCount = checks.filter((check) => check.status === 'warn').length;
|
|
1031
|
+
|
|
1032
|
+
return {
|
|
1033
|
+
version: 'xr-visual-agent-readiness-v1',
|
|
1034
|
+
ready: failCount === 0,
|
|
1035
|
+
status: failCount ? 'fail' : warnCount ? 'warning' : 'pass',
|
|
1036
|
+
reason: checks.find((check) => check.status === 'fail')?.id || checks.find((check) => check.status === 'warn')?.id || 'ready',
|
|
1037
|
+
expectedStatus,
|
|
1038
|
+
issueIds: actualIssueIds,
|
|
1039
|
+
expectedIssueIds,
|
|
1040
|
+
missingIssueIds: missingIssues,
|
|
1041
|
+
unexpectedIssueIds: unexpectedIssues,
|
|
1042
|
+
failCount,
|
|
1043
|
+
warnCount,
|
|
1044
|
+
checks,
|
|
1045
|
+
};
|
|
1046
|
+
}
|