svg3dx-viewer 0.1.0 → 0.1.1

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.
Files changed (75) hide show
  1. package/dist/DisplayModeBar.d.ts +36 -0
  2. package/dist/DisplayModeBar.js +94 -0
  3. package/dist/ModelBar.d.ts +11 -0
  4. package/dist/ModelBar.js +30 -19
  5. package/dist/ParamsBar.d.ts +17 -0
  6. package/dist/ParamsBar.js +42 -24
  7. package/dist/PlaneHelper.d.ts +12 -0
  8. package/dist/PlaneHelper.js +61 -0
  9. package/dist/SettingsBar.d.ts +61 -0
  10. package/dist/SettingsBar.js +268 -0
  11. package/dist/bool.d.ts +6 -1
  12. package/dist/bool.js +114 -40
  13. package/dist/chromeLocale.d.ts +24 -0
  14. package/dist/chromeLocale.js +53 -0
  15. package/dist/chromeStyles.d.ts +2 -0
  16. package/dist/chromeStyles.js +72 -0
  17. package/dist/coords.d.ts +5 -0
  18. package/dist/coords.js +5 -0
  19. package/dist/createViewer.d.ts +194 -1
  20. package/dist/createViewer.js +675 -25
  21. package/dist/documentKind.d.ts +7 -0
  22. package/dist/documentKind.js +25 -0
  23. package/dist/gltf.d.ts +45 -0
  24. package/dist/gltf.js +243 -0
  25. package/dist/highlight.d.ts +25 -5
  26. package/dist/highlight.js +76 -50
  27. package/dist/index.d.ts +14 -2
  28. package/dist/index.js +8 -1
  29. package/dist/pick.js +3 -1
  30. package/dist/primitive.d.ts +2 -1
  31. package/dist/primitive.js +47 -52
  32. package/dist/scene.d.ts +33 -4
  33. package/dist/scene.js +112 -14
  34. package/dist/sceneBuild.d.ts +15 -0
  35. package/dist/sceneBuild.js +1 -0
  36. package/dist/section.d.ts +44 -8
  37. package/dist/section.js +335 -29
  38. package/dist/selectionStyle.d.ts +26 -0
  39. package/dist/selectionStyle.js +54 -0
  40. package/dist/solids.d.ts +6 -11
  41. package/dist/solids.js +42 -121
  42. package/dist/svg2d.js +2 -2
  43. package/dist/sweep.d.ts +20 -10
  44. package/dist/sweep.js +99 -65
  45. package/dist/types.d.ts +5 -0
  46. package/dist/wasm.d.ts +8 -2
  47. package/dist/wasm.js +8 -3
  48. package/package.json +2 -2
  49. package/src/DisplayModeBar.ts +138 -0
  50. package/src/ModelBar.ts +42 -19
  51. package/src/ParamsBar.ts +55 -24
  52. package/src/PlaneHelper.ts +72 -0
  53. package/src/SettingsBar.ts +333 -0
  54. package/src/bool.ts +137 -45
  55. package/src/chromeLocale.ts +79 -0
  56. package/src/chromeStyles.ts +72 -0
  57. package/src/coords.ts +27 -21
  58. package/src/createViewer.ts +1218 -387
  59. package/src/documentKind.ts +28 -0
  60. package/src/gltf.ts +314 -0
  61. package/src/highlight.ts +88 -64
  62. package/src/index.ts +78 -45
  63. package/src/pick.ts +3 -1
  64. package/src/primitive.ts +66 -61
  65. package/src/scene.ts +274 -136
  66. package/src/sceneBuild.ts +16 -0
  67. package/src/section.ts +434 -29
  68. package/src/selectionStyle.ts +64 -0
  69. package/src/solids.ts +55 -141
  70. package/src/svg2d.ts +2 -2
  71. package/src/sweep.ts +164 -70
  72. package/src/types.ts +63 -60
  73. package/src/vendor/ViewHelper.d.ts +4 -0
  74. package/src/vendor/ViewHelper.js +81 -26
  75. package/src/wasm.ts +25 -4
@@ -0,0 +1,36 @@
1
+ import { type ViewerLocale } from "./chromeLocale.js";
2
+ export interface DisplayModeState {
3
+ /** Browser-native SVG rendering. */
4
+ kernel: boolean;
5
+ /** Three.js svg3dx / svg2d canvas. */
6
+ svg3dx: boolean;
7
+ }
8
+ export interface DisplayModeBarOptions {
9
+ /** Initial mode flags (default both on). */
10
+ initial?: Partial<DisplayModeState>;
11
+ locale?: ViewerLocale;
12
+ onChange?: (state: DisplayModeState) => void;
13
+ }
14
+ /**
15
+ * Top-left display-mode toggles for plain (non-svg3dx) SVG documents.
16
+ * Labels: Kernel / 内核 = browser native SVG; svg3dx = Three.js view.
17
+ */
18
+ export declare class DisplayModeBar {
19
+ readonly el: HTMLElement;
20
+ private titleEl;
21
+ private kernelLabel;
22
+ private svg3dxLabel;
23
+ private kernelInput;
24
+ private svg3dxInput;
25
+ private onChange?;
26
+ private suppress;
27
+ private locale;
28
+ constructor(parent: HTMLElement, options?: DisplayModeBarOptions);
29
+ getState(): DisplayModeState;
30
+ setState(state: Partial<DisplayModeState>): void;
31
+ setLocale(locale: ViewerLocale): void;
32
+ setVisible(visible: boolean): void;
33
+ dispose(): void;
34
+ private applyLocale;
35
+ private makeToggle;
36
+ }
@@ -0,0 +1,94 @@
1
+ import { ensureChromeStyles } from "./chromeStyles.js";
2
+ import { chromeStrings, detectViewerLocale, } from "./chromeLocale.js";
3
+ /**
4
+ * Top-left display-mode toggles for plain (non-svg3dx) SVG documents.
5
+ * Labels: Kernel / 内核 = browser native SVG; svg3dx = Three.js view.
6
+ */
7
+ export class DisplayModeBar {
8
+ constructor(parent, options = {}) {
9
+ this.suppress = false;
10
+ this.onChange = options.onChange;
11
+ this.locale = options.locale ?? detectViewerLocale();
12
+ ensureChromeStyles();
13
+ const initial = {
14
+ kernel: options.initial?.kernel !== false,
15
+ svg3dx: options.initial?.svg3dx !== false,
16
+ };
17
+ this.el = document.createElement("div");
18
+ this.el.className = "svg3dx-display-mode-bar";
19
+ this.el.style.cssText = [
20
+ "display:none",
21
+ "align-items:center",
22
+ "flex-wrap:wrap",
23
+ "gap:10px",
24
+ "padding:4px 8px",
25
+ "pointer-events:auto",
26
+ "user-select:none",
27
+ "align-self:flex-start",
28
+ ].join(";");
29
+ this.titleEl = document.createElement("span");
30
+ this.titleEl.style.cssText = "font-weight:600;white-space:nowrap;";
31
+ const kernel = this.makeToggle(initial.kernel);
32
+ this.kernelInput = kernel.input;
33
+ this.kernelLabel = kernel.labelSpan;
34
+ const svg3dx = this.makeToggle(initial.svg3dx);
35
+ this.svg3dxInput = svg3dx.input;
36
+ this.svg3dxLabel = svg3dx.labelSpan;
37
+ for (const type of ["pointerdown", "pointerup", "wheel", "click"]) {
38
+ this.el.addEventListener(type, (e) => e.stopPropagation());
39
+ }
40
+ this.el.append(this.titleEl, kernel.row, svg3dx.row);
41
+ parent.appendChild(this.el);
42
+ this.applyLocale();
43
+ }
44
+ getState() {
45
+ return {
46
+ kernel: this.kernelInput.checked,
47
+ svg3dx: this.svg3dxInput.checked,
48
+ };
49
+ }
50
+ setState(state) {
51
+ this.suppress = true;
52
+ try {
53
+ if (state.kernel !== undefined)
54
+ this.kernelInput.checked = state.kernel;
55
+ if (state.svg3dx !== undefined)
56
+ this.svg3dxInput.checked = state.svg3dx;
57
+ }
58
+ finally {
59
+ this.suppress = false;
60
+ }
61
+ }
62
+ setLocale(locale) {
63
+ this.locale = locale;
64
+ this.applyLocale();
65
+ }
66
+ setVisible(visible) {
67
+ this.el.style.display = visible ? "flex" : "none";
68
+ }
69
+ dispose() {
70
+ this.el.remove();
71
+ }
72
+ applyLocale() {
73
+ const s = chromeStrings(this.locale);
74
+ this.titleEl.textContent = s.display;
75
+ this.kernelLabel.textContent = s.kernel;
76
+ this.svg3dxLabel.textContent = s.svg3dx;
77
+ }
78
+ makeToggle(checked) {
79
+ const row = document.createElement("label");
80
+ row.style.cssText =
81
+ "display:inline-flex;align-items:center;gap:4px;cursor:pointer;white-space:nowrap;";
82
+ const input = document.createElement("input");
83
+ input.type = "checkbox";
84
+ input.checked = checked;
85
+ input.addEventListener("change", () => {
86
+ if (this.suppress)
87
+ return;
88
+ this.onChange?.(this.getState());
89
+ });
90
+ const labelSpan = document.createElement("span");
91
+ row.append(input, labelSpan);
92
+ return { row, input, labelSpan };
93
+ }
94
+ }
@@ -1,13 +1,21 @@
1
+ import { type ViewerLocale } from "./chromeLocale.js";
1
2
  export interface ModelBarOptions {
3
+ locale?: ViewerLocale;
2
4
  onChange?: (modelId: string) => void;
3
5
  }
4
6
  /** Top-left model label + select overlay for the embed viewer. */
5
7
  export declare class ModelBar {
6
8
  readonly el: HTMLElement;
9
+ private labelEl;
7
10
  private select;
8
11
  private onChange?;
9
12
  private suppress;
13
+ private locale;
14
+ private userVisible;
15
+ private hasModels;
10
16
  constructor(parent: HTMLElement, options?: ModelBarOptions);
17
+ setLocale(locale: ViewerLocale): void;
18
+ private applyLocale;
11
19
  /**
12
20
  * Refresh options from evaluation models.
13
21
  * Hidden when there are no models.
@@ -16,5 +24,8 @@ export declare class ModelBar {
16
24
  id: string;
17
25
  }[], activeId: string | null | undefined): void;
18
26
  getValue(): string | null;
27
+ /** User/host visibility preference (still hidden when there are no models). */
28
+ setVisible(visible: boolean): void;
19
29
  dispose(): void;
30
+ private applyVisibility;
20
31
  }
package/dist/ModelBar.js CHANGED
@@ -1,40 +1,34 @@
1
+ import { ensureChromeStyles } from "./chromeStyles.js";
2
+ import { chromeStrings, detectViewerLocale, } from "./chromeLocale.js";
1
3
  /** Top-left model label + select overlay for the embed viewer. */
2
4
  export class ModelBar {
3
5
  constructor(parent, options = {}) {
4
6
  this.suppress = false;
7
+ this.userVisible = true;
8
+ this.hasModels = false;
5
9
  this.onChange = options.onChange;
10
+ this.locale = options.locale ?? detectViewerLocale();
11
+ ensureChromeStyles();
6
12
  this.el = document.createElement("div");
7
13
  this.el.className = "svg3dx-model-bar";
8
14
  this.el.style.cssText = [
9
15
  "display:none",
10
16
  "align-items:center",
11
17
  "gap:6px",
12
- "padding:4px 8px",
13
- "background:rgba(255,255,255,0.92)",
14
- "border:1px solid #c5ced8",
15
- "border-radius:6px",
16
- "box-shadow:0 1px 2px rgba(15,23,42,0.06)",
17
- "font:12px/1.3 system-ui,sans-serif",
18
- "color:#1f2937",
18
+ "padding:0",
19
19
  "pointer-events:auto",
20
20
  "user-select:none",
21
21
  "align-self:flex-start",
22
22
  ].join(";");
23
- const label = document.createElement("label");
24
- label.textContent = "Model";
25
- label.style.cssText = "font-weight:600;white-space:nowrap;";
26
- label.htmlFor = "svg3dx-model-select";
23
+ this.labelEl = document.createElement("label");
24
+ this.labelEl.style.cssText = "font-weight:600;white-space:nowrap;";
25
+ this.labelEl.htmlFor = "svg3dx-model-select";
27
26
  this.select = document.createElement("select");
28
27
  this.select.id = "svg3dx-model-select";
29
28
  this.select.style.cssText = [
30
29
  "min-width:7rem",
31
30
  "max-width:14rem",
32
31
  "padding:2px 6px",
33
- "border:1px solid #c5ced8",
34
- "border-radius:4px",
35
- "background:#fff",
36
- "font:inherit",
37
- "color:inherit",
38
32
  ].join(";");
39
33
  this.select.addEventListener("change", () => {
40
34
  if (this.suppress)
@@ -47,8 +41,16 @@ export class ModelBar {
47
41
  for (const type of ["pointerdown", "pointerup", "wheel", "click"]) {
48
42
  this.el.addEventListener(type, (e) => e.stopPropagation());
49
43
  }
50
- this.el.append(label, this.select);
44
+ this.el.append(this.labelEl, this.select);
51
45
  parent.appendChild(this.el);
46
+ this.applyLocale();
47
+ }
48
+ setLocale(locale) {
49
+ this.locale = locale;
50
+ this.applyLocale();
51
+ }
52
+ applyLocale() {
53
+ this.labelEl.textContent = chromeStrings(this.locale).model;
52
54
  }
53
55
  /**
54
56
  * Refresh options from evaluation models.
@@ -58,8 +60,9 @@ export class ModelBar {
58
60
  this.suppress = true;
59
61
  try {
60
62
  this.select.replaceChildren();
63
+ this.hasModels = models.length > 0;
61
64
  if (!models.length) {
62
- this.el.style.display = "none";
65
+ this.applyVisibility();
63
66
  return;
64
67
  }
65
68
  for (const m of models) {
@@ -71,7 +74,7 @@ export class ModelBar {
71
74
  const ids = new Set(models.map((m) => m.id));
72
75
  const next = activeId && ids.has(activeId) ? activeId : models[0].id;
73
76
  this.select.value = next;
74
- this.el.style.display = "flex";
77
+ this.applyVisibility();
75
78
  }
76
79
  finally {
77
80
  this.suppress = false;
@@ -80,7 +83,15 @@ export class ModelBar {
80
83
  getValue() {
81
84
  return this.select.value || null;
82
85
  }
86
+ /** User/host visibility preference (still hidden when there are no models). */
87
+ setVisible(visible) {
88
+ this.userVisible = visible;
89
+ this.applyVisibility();
90
+ }
83
91
  dispose() {
84
92
  this.el.remove();
85
93
  }
94
+ applyVisibility() {
95
+ this.el.style.display = this.userVisible && this.hasModels ? "flex" : "none";
96
+ }
86
97
  }
@@ -1,6 +1,8 @@
1
1
  import type { ParamDesc } from "./params.js";
2
2
  import type { ParamMap } from "./wasm.js";
3
+ import { type ViewerLocale } from "./chromeLocale.js";
3
4
  export interface ParamsBarOptions {
5
+ locale?: ViewerLocale;
4
6
  onChange?: (params: ParamMap) => void;
5
7
  /** Start expanded (default false). */
6
8
  expanded?: boolean;
@@ -12,16 +14,31 @@ export interface ParamsBarOptions {
12
14
  export declare class ParamsBar {
13
15
  readonly el: HTMLElement;
14
16
  private headerBtn;
17
+ private titleEl;
15
18
  private chevron;
16
19
  private body;
17
20
  private params;
21
+ private lastDescs;
18
22
  private onChange?;
19
23
  private expanded;
20
24
  private hasParams;
25
+ private locale;
26
+ private userVisible;
27
+ private documentAllowed;
21
28
  constructor(parent: HTMLElement, options?: ParamsBarOptions);
29
+ setLocale(locale: ViewerLocale): void;
22
30
  setExpanded(expanded: boolean): void;
23
31
  isExpanded(): boolean;
32
+ /**
33
+ * User/host visibility preference.
34
+ * Document sync may still hide the bar for plain SVG.
35
+ */
36
+ setVisible(visible: boolean): void;
37
+ /** Called by EmbedViewer when the document allows / forbids the bar. */
38
+ setDocumentAllowed(allowed: boolean): void;
39
+ private applyVisibility;
24
40
  setParams(params: ParamMap, descs?: ParamDesc[]): void;
41
+ private applyLocale;
25
42
  getParams(): ParamMap;
26
43
  dispose(): void;
27
44
  private makeRow;
package/dist/ParamsBar.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { ensureChromeStyles } from "./chromeStyles.js";
2
+ import { chromeStrings, detectViewerLocale, } from "./chromeLocale.js";
1
3
  /**
2
4
  * Collapsible Params overlay for the embed viewer — sits under the Model bar.
3
5
  * Lists `:root` external params; edits trigger `onChange` for live re-eval.
@@ -6,8 +8,12 @@ export class ParamsBar {
6
8
  constructor(parent, options = {}) {
7
9
  this.params = {};
8
10
  this.hasParams = false;
11
+ this.userVisible = true;
12
+ this.documentAllowed = true;
9
13
  this.onChange = options.onChange;
10
14
  this.expanded = options.expanded === true;
15
+ this.locale = options.locale ?? detectViewerLocale();
16
+ ensureChromeStyles();
11
17
  this.el = document.createElement("div");
12
18
  this.el.className = "svg3dx-params-bar";
13
19
  this.el.style.cssText = [
@@ -15,12 +21,6 @@ export class ParamsBar {
15
21
  "flex-direction:column",
16
22
  "min-width:11rem",
17
23
  "max-width:16rem",
18
- "background:rgba(255,255,255,0.92)",
19
- "border:1px solid #c5ced8",
20
- "border-radius:6px",
21
- "box-shadow:0 1px 2px rgba(15,23,42,0.06)",
22
- "font:12px/1.3 system-ui,sans-serif",
23
- "color:#1f2937",
24
24
  "pointer-events:auto",
25
25
  "user-select:none",
26
26
  "overflow:hidden",
@@ -42,14 +42,13 @@ export class ParamsBar {
42
42
  "cursor:pointer",
43
43
  "text-align:left",
44
44
  ].join(";");
45
- const title = document.createElement("span");
46
- title.textContent = "Params";
47
- title.style.cssText = "font-weight:600;white-space:nowrap;";
45
+ this.titleEl = document.createElement("span");
46
+ this.titleEl.style.cssText = "font-weight:600;white-space:nowrap;";
48
47
  this.chevron = document.createElement("span");
49
48
  this.chevron.setAttribute("aria-hidden", "true");
50
49
  this.chevron.style.cssText =
51
50
  "font-size:10px;opacity:0.65;transition:transform 0.12s ease;";
52
- this.headerBtn.append(title, this.chevron);
51
+ this.headerBtn.append(this.titleEl, this.chevron);
53
52
  this.headerBtn.addEventListener("click", () => {
54
53
  this.setExpanded(!this.expanded);
55
54
  });
@@ -60,7 +59,6 @@ export class ParamsBar {
60
59
  "flex-direction:column",
61
60
  "gap:6px",
62
61
  "padding:0 8px 8px",
63
- "border-top:1px solid #e5eaf0",
64
62
  "max-height:min(40vh, 280px)",
65
63
  "overflow:auto",
66
64
  ].join(";");
@@ -69,8 +67,15 @@ export class ParamsBar {
69
67
  }
70
68
  this.el.append(this.headerBtn, this.body);
71
69
  parent.appendChild(this.el);
70
+ this.applyLocale();
72
71
  this.syncExpandedUi();
73
72
  }
73
+ setLocale(locale) {
74
+ this.locale = locale;
75
+ this.applyLocale();
76
+ // Refresh empty-state / tooltip copy for the new locale.
77
+ this.setParams(this.params, this.lastDescs);
78
+ }
74
79
  setExpanded(expanded) {
75
80
  this.expanded = expanded;
76
81
  this.syncExpandedUi();
@@ -78,8 +83,27 @@ export class ParamsBar {
78
83
  isExpanded() {
79
84
  return this.expanded;
80
85
  }
86
+ /**
87
+ * User/host visibility preference.
88
+ * Document sync may still hide the bar for plain SVG.
89
+ */
90
+ setVisible(visible) {
91
+ this.userVisible = visible;
92
+ this.applyVisibility();
93
+ }
94
+ /** Called by EmbedViewer when the document allows / forbids the bar. */
95
+ setDocumentAllowed(allowed) {
96
+ this.documentAllowed = allowed;
97
+ this.applyVisibility();
98
+ }
99
+ applyVisibility() {
100
+ this.el.style.display =
101
+ this.userVisible && this.documentAllowed ? "flex" : "none";
102
+ }
81
103
  setParams(params, descs) {
82
104
  this.params = { ...params };
105
+ this.lastDescs = descs;
106
+ const s = chromeStrings(this.locale);
83
107
  const list = descs ??
84
108
  Object.keys(this.params)
85
109
  .sort()
@@ -96,7 +120,7 @@ export class ParamsBar {
96
120
  this.body.replaceChildren();
97
121
  if (!list.length) {
98
122
  const empty = document.createElement("div");
99
- empty.textContent = "No editable params";
123
+ empty.textContent = s.noEditableParams;
100
124
  empty.style.cssText = "opacity:0.6;padding-top:6px;";
101
125
  this.body.appendChild(empty);
102
126
  }
@@ -106,8 +130,11 @@ export class ParamsBar {
106
130
  }
107
131
  }
108
132
  this.headerBtn.title = this.hasParams
109
- ? `${list.length} param${list.length === 1 ? "" : "s"}`
110
- : "No editable params";
133
+ ? s.paramsCount(list.length)
134
+ : s.noEditableParams;
135
+ }
136
+ applyLocale() {
137
+ this.titleEl.textContent = chromeStrings(this.locale).params;
111
138
  }
112
139
  getParams() {
113
140
  return { ...this.params };
@@ -139,16 +166,7 @@ export class ParamsBar {
139
166
  const input = document.createElement("input");
140
167
  input.type = d.kind === "number" ? "number" : "text";
141
168
  input.value = String(this.params[d.name] ?? d.value ?? "");
142
- input.style.cssText = [
143
- "width:100%",
144
- "min-width:0",
145
- "padding:2px 6px",
146
- "border:1px solid #c5ced8",
147
- "border-radius:4px",
148
- "background:#fff",
149
- "font:inherit",
150
- "color:inherit",
151
- ].join(";");
169
+ input.style.cssText = "width:100%;min-width:0;padding:2px 6px;";
152
170
  const commit = () => {
153
171
  const raw = input.value;
154
172
  this.params[d.name] =
@@ -0,0 +1,12 @@
1
+ import * as THREE from "three";
2
+ /**
3
+ * World XY reference plane (svg3dx Z-up): outer rectangle + semi-transparent fill.
4
+ * No interior grid lines — AxesHelper owns the RGB frame.
5
+ */
6
+ export declare class PlaneHelper extends THREE.Group {
7
+ readonly isSvg3dxPlaneHelper = true;
8
+ private readonly border;
9
+ private readonly fill;
10
+ constructor(size?: number, color?: THREE.ColorRepresentation);
11
+ dispose(): void;
12
+ }
@@ -0,0 +1,61 @@
1
+ import * as THREE from "three";
2
+ /**
3
+ * World XY reference plane (svg3dx Z-up): outer rectangle + semi-transparent fill.
4
+ * No interior grid lines — AxesHelper owns the RGB frame.
5
+ */
6
+ export class PlaneHelper extends THREE.Group {
7
+ constructor(size = 10, color = 0x7eb6e8) {
8
+ super();
9
+ this.isSvg3dxPlaneHelper = true;
10
+ this.name = "svg3dx-world-plane";
11
+ const half = size / 2;
12
+ const c = new THREE.Color(color);
13
+ const borderGeom = new THREE.BufferGeometry().setFromPoints([
14
+ new THREE.Vector3(-half, -half, 0),
15
+ new THREE.Vector3(half, -half, 0),
16
+ new THREE.Vector3(half, half, 0),
17
+ new THREE.Vector3(-half, half, 0),
18
+ ]);
19
+ // Priority: AxesHelper > PlaneHelper > other scene solids (see createViewer).
20
+ const planeRenderOrder = 1;
21
+ const borderMat = new THREE.LineBasicMaterial({
22
+ color: c,
23
+ toneMapped: false,
24
+ transparent: true,
25
+ opacity: 0.95,
26
+ depthWrite: false,
27
+ // Bias toward camera so coplanar entity edges lose to the frame.
28
+ polygonOffset: true,
29
+ polygonOffsetFactor: -1,
30
+ polygonOffsetUnits: -1,
31
+ });
32
+ this.border = new THREE.LineLoop(borderGeom, borderMat);
33
+ this.border.name = "svg3dx-world-plane-border";
34
+ this.border.renderOrder = planeRenderOrder;
35
+ const fillGeom = new THREE.PlaneGeometry(size, size);
36
+ const fillMat = new THREE.MeshBasicMaterial({
37
+ color: c,
38
+ transparent: true,
39
+ opacity: 0.14,
40
+ depthWrite: false,
41
+ side: THREE.DoubleSide,
42
+ toneMapped: false,
43
+ // Win z-fighting against coplanar entity faces; still occluded when behind.
44
+ polygonOffset: true,
45
+ polygonOffsetFactor: -1,
46
+ polygonOffsetUnits: -1,
47
+ });
48
+ this.fill = new THREE.Mesh(fillGeom, fillMat);
49
+ this.fill.name = "svg3dx-world-plane-fill";
50
+ this.fill.renderOrder = planeRenderOrder;
51
+ this.add(this.fill);
52
+ this.add(this.border);
53
+ this.renderOrder = planeRenderOrder;
54
+ }
55
+ dispose() {
56
+ this.border.geometry.dispose();
57
+ this.border.material.dispose();
58
+ this.fill.geometry.dispose();
59
+ this.fill.material.dispose();
60
+ }
61
+ }
@@ -0,0 +1,61 @@
1
+ import { type ViewerLocale } from "./chromeLocale.js";
2
+ /** MSAA sample count for EffectComposer render targets. */
3
+ export type AntialiasLevel = 0 | 2 | 4 | 8;
4
+ export interface ViewerUiState {
5
+ settingsButton: boolean;
6
+ modelBar: boolean;
7
+ paramsBar: boolean;
8
+ viewHelper: boolean;
9
+ axesHelper: boolean;
10
+ planeHelper: boolean;
11
+ antialias: AntialiasLevel;
12
+ /** Browser-native SVG pane (plain SVG only). */
13
+ kernel: boolean;
14
+ /** Three.js canvas (plain SVG only). */
15
+ svg3dx: boolean;
16
+ }
17
+ export interface SettingsBarOptions {
18
+ initial: ViewerUiState;
19
+ locale?: ViewerLocale;
20
+ /** Show Kernel / svg3dx rows (plain SVG documents). */
21
+ showDisplayModes?: boolean;
22
+ onChange?: (state: ViewerUiState) => void;
23
+ }
24
+ /**
25
+ * Top-left gear menu for overlay / helper / antialias visibility.
26
+ * The settings-button toggle can hide this control itself.
27
+ */
28
+ export declare class SettingsBar {
29
+ readonly el: HTMLElement;
30
+ private btn;
31
+ private panel;
32
+ private locale;
33
+ private state;
34
+ private showDisplayModes;
35
+ private onChange?;
36
+ private open;
37
+ private suppress;
38
+ private rows;
39
+ private displayModeSection;
40
+ private onDocPointerDown;
41
+ constructor(parent: HTMLElement, options: SettingsBarOptions);
42
+ getState(): ViewerUiState;
43
+ setState(partial: Partial<ViewerUiState>): void;
44
+ setLocale(locale: ViewerLocale): void;
45
+ setShowDisplayModes(show: boolean): void;
46
+ setOpen(open: boolean): void;
47
+ /** Host can force the gear visible again after the user hid it. */
48
+ setButtonVisible(visible: boolean): void;
49
+ dispose(): void;
50
+ private syncButtonVisibility;
51
+ private emit;
52
+ private syncInputsFromState;
53
+ private applyLocale;
54
+ private labelFor;
55
+ private appendToggle;
56
+ private appendAntialias;
57
+ private appendSeparator;
58
+ private makeSeparator;
59
+ private bindDocClose;
60
+ private unbindDocClose;
61
+ }