three-cad-viewer 4.3.5 → 4.3.7

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 (58) hide show
  1. package/dist/three-cad-viewer.esm.js +8 -5
  2. package/dist/three-cad-viewer.esm.js.map +1 -1
  3. package/dist/three-cad-viewer.esm.min.js +1 -1
  4. package/dist/three-cad-viewer.js +8 -5
  5. package/dist/three-cad-viewer.min.js +1 -1
  6. package/package.json +2 -3
  7. package/src/_version.ts +0 -1
  8. package/src/camera/camera.ts +0 -445
  9. package/src/camera/controls/CADOrbitControls.ts +0 -241
  10. package/src/camera/controls/CADTrackballControls.ts +0 -598
  11. package/src/camera/controls.ts +0 -380
  12. package/src/core/patches.ts +0 -16
  13. package/src/core/studio-manager.ts +0 -652
  14. package/src/core/types.ts +0 -892
  15. package/src/core/viewer-state.ts +0 -784
  16. package/src/core/viewer.ts +0 -4821
  17. package/src/index.ts +0 -151
  18. package/src/rendering/environment.ts +0 -840
  19. package/src/rendering/light-detection.ts +0 -327
  20. package/src/rendering/material-factory.ts +0 -735
  21. package/src/rendering/material-presets.ts +0 -289
  22. package/src/rendering/raycast.ts +0 -291
  23. package/src/rendering/room-environment.ts +0 -192
  24. package/src/rendering/studio-composer.ts +0 -577
  25. package/src/rendering/studio-floor.ts +0 -108
  26. package/src/rendering/texture-cache.ts +0 -324
  27. package/src/rendering/tree-model.ts +0 -542
  28. package/src/rendering/triplanar.ts +0 -329
  29. package/src/scene/animation.ts +0 -343
  30. package/src/scene/axes.ts +0 -108
  31. package/src/scene/bbox.ts +0 -223
  32. package/src/scene/clipping.ts +0 -650
  33. package/src/scene/grid.ts +0 -864
  34. package/src/scene/nestedgroup.ts +0 -1448
  35. package/src/scene/objectgroup.ts +0 -866
  36. package/src/scene/orientation.ts +0 -259
  37. package/src/scene/render-shape.ts +0 -634
  38. package/src/tools/cad_tools/measure.ts +0 -811
  39. package/src/tools/cad_tools/select.ts +0 -100
  40. package/src/tools/cad_tools/tools.ts +0 -231
  41. package/src/tools/cad_tools/ui.ts +0 -454
  42. package/src/tools/cad_tools/zebra.ts +0 -369
  43. package/src/types/html.d.ts +0 -5
  44. package/src/types/n8ao.d.ts +0 -28
  45. package/src/types/three-augmentation.d.ts +0 -60
  46. package/src/ui/display.ts +0 -3295
  47. package/src/ui/index.html +0 -505
  48. package/src/ui/info.ts +0 -177
  49. package/src/ui/slider.ts +0 -206
  50. package/src/ui/toolbar.ts +0 -347
  51. package/src/ui/treeview.ts +0 -945
  52. package/src/utils/decode-instances.ts +0 -233
  53. package/src/utils/font.ts +0 -60
  54. package/src/utils/gpu-tracker.ts +0 -265
  55. package/src/utils/logger.ts +0 -92
  56. package/src/utils/sizeof.ts +0 -116
  57. package/src/utils/timer.ts +0 -69
  58. package/src/utils/utils.ts +0 -446
package/src/ui/info.ts DELETED
@@ -1,177 +0,0 @@
1
- import * as THREE from "three";
2
- import type { Vector3Tuple } from "three";
3
-
4
- /**
5
- * Manages information display panel for the CAD viewer.
6
- * Shows bounding box info, version info, and other contextual information.
7
- */
8
- class Info {
9
- html: HTMLElement;
10
- number: number;
11
- chunks: [number, string][];
12
-
13
- /**
14
- * Create an Info panel instance.
15
- * @param html - The HTML container element for info display.
16
- */
17
- constructor(html: HTMLElement) {
18
- this.html = html;
19
- this.number = 0;
20
- this.chunks = [];
21
- this.clear();
22
- }
23
-
24
- /**
25
- * Clear all displayed information.
26
- */
27
- clear(): void {
28
- this.html.innerHTML = "";
29
- this.number = 0;
30
- this.chunks = [];
31
- }
32
-
33
- /**
34
- * Dispose of resources and clear the container.
35
- */
36
- dispose(): void {
37
- this.clear();
38
- this.html.innerHTML = "";
39
- }
40
-
41
- /**
42
- * Add plain text as a preformatted block.
43
- * @param msg - The text message to display.
44
- */
45
- addText(msg: string): void {
46
- this.addHtml(`<pre style="white-space: nowrap;">${msg}</pre>`);
47
- }
48
-
49
- /**
50
- * Add HTML content to the info panel.
51
- * New content appears at the top of the list.
52
- * @param html - The HTML string to add.
53
- */
54
- addHtml(html: string): void {
55
- this.chunks.unshift([this.number, html]);
56
- this.number += 1;
57
- this.render();
58
- }
59
-
60
- /**
61
- * Render all chunks to the container as a table.
62
- */
63
- private render(): void {
64
- let html = "<table class='tcv_info_table'>";
65
-
66
- for (const chunk of this.chunks) {
67
- html += "<tr class='tcv_info_row'>";
68
- html += `<td><pre class="tcv_info_num">[${chunk[0]}]</pre></td>`;
69
- html += `<td>${chunk[1]}</td>`;
70
- html += "</tr>";
71
- }
72
- html += "</table>";
73
-
74
- this.html.innerHTML = html;
75
- }
76
-
77
- /**
78
- * Display version information for CadQuery and Jupyter CadQuery.
79
- * @param cqVersion - CadQuery version string.
80
- * @param jcqVersion - Jupyter CadQuery version string.
81
- */
82
- versionMsg(cqVersion: string, jcqVersion: string): void {
83
- this.addHtml(
84
- `<b>Versions</b>
85
- <table>
86
- <tr class="tcv_small_table"><td>CadQuery:</td> <td>${cqVersion}</td> </tr>
87
- <tr class="tcv_small_table"><td>Jupyter CadQuery:</td><td>${jcqVersion}</td> </tr>
88
- </table>`,
89
- );
90
- }
91
-
92
- /**
93
- * Display the ready message with viewer version and control mode.
94
- * @param version - Viewer version string.
95
- * @param control - Control mode name (e.g., "orbit", "trackball").
96
- */
97
- readyMsg(version: string, control: string): void {
98
- this.clear();
99
- const html = `<div class="tcv_info_header">Ready</div>
100
- <table class="small_table">
101
- <tr class="tcv_small_table_row" ><td>Version</td><td>${version}</td> </tr>
102
- <tr class="tcv_small_table_row" ><td>Control</td><td>${control}</td></tr>
103
- <tr class="tcv_small_table_row" ><td>Axes</td>
104
- <td>
105
- <span class="tcv_info_red"><b>X</b></span>,
106
- <span class="tcv_info_green"><b>Y</b></span>,
107
- <span class="tcv_info_blue"><b>Z</b></span>
108
- </td>
109
- </tr>
110
- </table>`;
111
- this.addHtml(html);
112
- }
113
-
114
- /**
115
- * Display bounding box information for a selected object.
116
- * @param path - The object's path in the tree.
117
- * @param name - The object's name.
118
- * @param bb - The bounding box to display.
119
- */
120
- bbInfo(path: string, name: string, bb: THREE.Box3): void {
121
- let html = `
122
- <table class="tcv_small_table">
123
- <tr class="tcv_small_table_row">
124
- <td><b>Path:</b></td>
125
- <td>${path}</td>
126
- </tr>
127
- <tr class="tcv_small_table_row">
128
- <td><b>Name:</b></td>
129
- <td>${name}</td>
130
- </tr>
131
- </table>
132
- `;
133
- html += `
134
- <div class="tcv_info_header">Bounding box:</div>
135
- <table class="tcv_small_table">
136
- <tr class="tcv_small_table_row">
137
- <th></th>
138
- <th>min</th>
139
- <th>max</th>
140
- <th>center</th>
141
- </tr>
142
- `;
143
-
144
- const center = new THREE.Vector3();
145
- bb.getCenter(center);
146
-
147
- (["x", "y", "z"] as const).forEach((a) => {
148
- html += `
149
- <tr class="tcv_small_table_row">
150
- <th>${a}</th>
151
- <td align='right'>${bb.min[a].toFixed(3)}</td>
152
- <td align='right'>${bb.max[a].toFixed(3)}</td>
153
- <td align='right'>${center[a].toFixed(3)}</td>
154
- </tr>
155
- `;
156
- });
157
- html += "</table>";
158
- this.addHtml(html);
159
- }
160
-
161
- /**
162
- * Display camera target center information.
163
- * @param center - The center coordinates [x, y, z].
164
- */
165
- centerInfo(center: Vector3Tuple): void {
166
- const html =
167
- "<div>Camera target set to AABB center:</div>" +
168
- "<div class='tcv_info_line'>{ " +
169
- `x: ${center[0].toFixed(2)}, ` +
170
- `y: ${center[1].toFixed(2)}, ` +
171
- `z: ${center[2].toFixed(2)}` +
172
- " }</div>";
173
- this.addHtml(html);
174
- }
175
- }
176
-
177
- export { Info };
package/src/ui/slider.ts DELETED
@@ -1,206 +0,0 @@
1
- /**
2
- * Handler type for slider value changes.
3
- * For plane sliders: (index: number, value: string) => void
4
- * For other sliders: (value: number, notify?: boolean) => void
5
- *
6
- * Note: Using a permissive second parameter type to accommodate both use cases
7
- * while satisfying strictFunctionTypes. The Slider class handles the actual
8
- * argument passing based on slider type.
9
- */
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
- type SliderHandler = (indexOrValue: number, value?: any) => void;
12
-
13
- /**
14
- * Options for configuring a Slider instance.
15
- */
16
- interface SliderOptions {
17
- handler: SliderHandler;
18
- percentage?: boolean;
19
- notifyCallback?: ((change: Record<string, number>, notify: boolean) => void) | null;
20
- isReadyCheck?: (() => boolean) | null;
21
- onSetSlider?: ((index: number, value: string) => void) | null;
22
- }
23
-
24
- /**
25
- * Slider component for controlling numeric values with linked input field.
26
- */
27
- class Slider {
28
- index: number | undefined;
29
- type: string;
30
- handler: SliderHandler;
31
- percentage: boolean;
32
- notifyCallback: ((change: Record<string, number>, notify: boolean) => void) | null;
33
- isReadyCheck: (() => boolean) | null;
34
- onSetSlider: ((index: number, value: string) => void) | null;
35
- slider: HTMLInputElement;
36
- input: HTMLInputElement;
37
-
38
- /**
39
- * Create a Slider instance
40
- * @param index - Slider identifier (e.g., "plane1", "ambientlight")
41
- * @param min - Minimum value
42
- * @param max - Maximum value
43
- * @param container - DOM container to search for slider elements
44
- * @param options - Configuration options
45
- */
46
- constructor(
47
- index: string,
48
- min: number,
49
- max: number,
50
- container: HTMLElement,
51
- options: SliderOptions
52
- ) {
53
- if (index.startsWith("plane")) {
54
- this.index = parseInt(index.substring(5));
55
- this.type = "plane";
56
- } else {
57
- this.index = undefined;
58
- this.type = index;
59
- }
60
-
61
- this.handler = options.handler;
62
- this.percentage = options.percentage || false;
63
- this.notifyCallback = options.notifyCallback || null;
64
- this.isReadyCheck = options.isReadyCheck || null;
65
- this.onSetSlider = options.onSetSlider || null;
66
-
67
- const sliderEl = container.getElementsByClassName(`tcv_sld_value_${index}`)[0];
68
- const inputEl = container.getElementsByClassName(`tcv_inp_value_${index}`)[0];
69
-
70
- if (!(sliderEl instanceof HTMLInputElement) || !(inputEl instanceof HTMLInputElement)) {
71
- throw new Error(
72
- `Slider elements not found for index "${index}" in container`,
73
- );
74
- }
75
-
76
- this.slider = sliderEl;
77
- this.input = inputEl;
78
-
79
- this.slider.min = String(min);
80
- this.slider.max = String(max);
81
- this.input.value = String(max);
82
- this.slider.oninput = this.sliderChange;
83
- this.input.addEventListener("change", this.inputChange);
84
- }
85
-
86
- /**
87
- * Send change notification via callback (for plane-type sliders only)
88
- * @param value - The current slider value
89
- * @param notify - Whether to trigger the notification
90
- */
91
- private _notify = (value: number | string, notify: boolean = true): void => {
92
- if (this.type == "plane" && this.notifyCallback && this.index !== undefined) {
93
- const change: Record<string, number> = {};
94
- change[`clip_slider_${this.index - 1}`] = parseFloat(String(value));
95
- this.notifyCallback(change, notify);
96
- }
97
- };
98
-
99
- /**
100
- * Invoke the value change handler with appropriate value transformation
101
- * @param type - Slider type ("plane" or other identifier)
102
- * @param index - Plane index (for plane-type sliders)
103
- * @param value - The input value as string
104
- */
105
- private _handle(type: string, index: number | undefined, value: string): void {
106
- if (type == "plane" && index !== undefined) {
107
- this.handler(index, value);
108
- } else {
109
- // Check if ready (if check provided), or assume ready
110
- const isReady = this.isReadyCheck ? this.isReadyCheck() : true;
111
- if (isReady) {
112
- const handlerValue = this.percentage
113
- ? parseFloat(value) / 100
114
- : parseFloat(value);
115
- this.handler(handlerValue);
116
- }
117
- }
118
- }
119
-
120
- /**
121
- * Handle slider drag/input events
122
- */
123
- sliderChange = (e: Event): void => {
124
- if (!(e.target instanceof HTMLInputElement)) return;
125
- const value = e.target.value;
126
- this.input.value = String(Math.round(1000 * parseFloat(value)) / 1000);
127
- this._handle(this.type, this.index, this.input.value);
128
- this._notify(value);
129
- };
130
-
131
- /**
132
- * Handle text input change events
133
- */
134
- inputChange = (e: Event): void => {
135
- if (!(e.target instanceof HTMLInputElement)) return;
136
- const clampedValue = Math.max(
137
- Math.min(parseFloat(e.target.value), parseFloat(this.slider.max)),
138
- parseFloat(this.slider.min),
139
- );
140
- this.input.value = String(Math.round(1000 * clampedValue) / 1000);
141
- this.slider.value = String(clampedValue);
142
- this._handle(this.type, this.index, this.input.value);
143
- this._notify(clampedValue);
144
- };
145
-
146
- /**
147
- * Configure slider range for symmetric limits around zero (used for clipping planes).
148
- * Only sets min/max/step - does NOT change the current value.
149
- * Values should be set via state subscriptions.
150
- * @param limit - The absolute limit value for both min (-limit) and max (+limit)
151
- */
152
- setLimits(limit: number): void {
153
- const exp = Math.abs(Math.round(Math.log10(2 * limit)));
154
- this.slider.min = String(-limit);
155
- this.slider.max = String(limit);
156
- this.slider.step = String(Math.pow(10, -(3 - exp)));
157
- }
158
-
159
- /**
160
- * Get the current slider value
161
- * @returns The current value as a float
162
- */
163
- getValue(): number {
164
- return parseFloat(this.input.value);
165
- }
166
-
167
- /**
168
- * Set the slider value programmatically
169
- * @param value - The value to set (will be clamped to min/max range)
170
- * @param notify - Whether to trigger change notifications
171
- */
172
- setValue(value: number, notify: boolean = true): void {
173
- const clampedValue = Math.max(
174
- Math.min(value, parseFloat(this.slider.max)),
175
- parseFloat(this.slider.min),
176
- );
177
- this.input.value = String(Math.round(1000 * clampedValue) / 1000);
178
- this.slider.value = String(clampedValue);
179
- this._handle(this.type, this.index, this.input.value);
180
- this._notify(clampedValue, notify);
181
- }
182
-
183
- /**
184
- * Update slider visual without triggering handler (for state subscription updates).
185
- * Use this when the state has already been updated and you just need to sync the UI.
186
- * @param value - The value to set (will be clamped to min/max range)
187
- */
188
- setValueFromState(value: number): void {
189
- const clampedValue = Math.max(
190
- Math.min(value, parseFloat(this.slider.max)),
191
- parseFloat(this.slider.min),
192
- );
193
- this.input.value = String(Math.round(1000 * clampedValue) / 1000);
194
- this.slider.value = String(clampedValue);
195
- }
196
-
197
- /**
198
- * Clean up event listeners.
199
- */
200
- dispose(): void {
201
- this.slider.oninput = null;
202
- this.input.removeEventListener("change", this.inputChange);
203
- }
204
- }
205
-
206
- export { Slider };