three-cad-viewer 4.3.4 → 4.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/scene/clipping.d.ts +6 -0
  2. package/dist/three-cad-viewer.esm.js +20 -5
  3. package/dist/three-cad-viewer.esm.js.map +1 -1
  4. package/dist/three-cad-viewer.esm.min.js +1 -1
  5. package/dist/three-cad-viewer.js +20 -5
  6. package/dist/three-cad-viewer.min.js +1 -1
  7. package/package.json +2 -3
  8. package/src/_version.ts +0 -1
  9. package/src/camera/camera.ts +0 -445
  10. package/src/camera/controls/CADOrbitControls.ts +0 -241
  11. package/src/camera/controls/CADTrackballControls.ts +0 -598
  12. package/src/camera/controls.ts +0 -380
  13. package/src/core/patches.ts +0 -16
  14. package/src/core/studio-manager.ts +0 -652
  15. package/src/core/types.ts +0 -892
  16. package/src/core/viewer-state.ts +0 -784
  17. package/src/core/viewer.ts +0 -4821
  18. package/src/index.ts +0 -151
  19. package/src/rendering/environment.ts +0 -840
  20. package/src/rendering/light-detection.ts +0 -327
  21. package/src/rendering/material-factory.ts +0 -735
  22. package/src/rendering/material-presets.ts +0 -289
  23. package/src/rendering/raycast.ts +0 -291
  24. package/src/rendering/room-environment.ts +0 -192
  25. package/src/rendering/studio-composer.ts +0 -577
  26. package/src/rendering/studio-floor.ts +0 -108
  27. package/src/rendering/texture-cache.ts +0 -324
  28. package/src/rendering/tree-model.ts +0 -542
  29. package/src/rendering/triplanar.ts +0 -329
  30. package/src/scene/animation.ts +0 -343
  31. package/src/scene/axes.ts +0 -108
  32. package/src/scene/bbox.ts +0 -223
  33. package/src/scene/clipping.ts +0 -640
  34. package/src/scene/grid.ts +0 -864
  35. package/src/scene/nestedgroup.ts +0 -1444
  36. package/src/scene/objectgroup.ts +0 -866
  37. package/src/scene/orientation.ts +0 -259
  38. package/src/scene/render-shape.ts +0 -634
  39. package/src/tools/cad_tools/measure.ts +0 -811
  40. package/src/tools/cad_tools/select.ts +0 -100
  41. package/src/tools/cad_tools/tools.ts +0 -231
  42. package/src/tools/cad_tools/ui.ts +0 -454
  43. package/src/tools/cad_tools/zebra.ts +0 -369
  44. package/src/types/html.d.ts +0 -5
  45. package/src/types/n8ao.d.ts +0 -28
  46. package/src/types/three-augmentation.d.ts +0 -60
  47. package/src/ui/display.ts +0 -3295
  48. package/src/ui/index.html +0 -505
  49. package/src/ui/info.ts +0 -177
  50. package/src/ui/slider.ts +0 -206
  51. package/src/ui/toolbar.ts +0 -347
  52. package/src/ui/treeview.ts +0 -945
  53. package/src/utils/decode-instances.ts +0 -233
  54. package/src/utils/font.ts +0 -60
  55. package/src/utils/gpu-tracker.ts +0 -265
  56. package/src/utils/logger.ts +0 -92
  57. package/src/utils/sizeof.ts +0 -116
  58. package/src/utils/timer.ts +0 -69
  59. package/src/utils/utils.ts +0 -446
@@ -1,192 +0,0 @@
1
- /**
2
- * Clean room environment for Studio mode PMREM generation.
3
- *
4
- * Based on Three.js RoomEnvironment (which is based on Google model-viewer's
5
- * EnvironmentScene), but with the 6 decorative boxes removed and an infinity
6
- * cove (quarter-cylinder) at all wall-floor junctions for a clean cyclorama.
7
- */
8
- import {
9
- BackSide,
10
- BoxGeometry,
11
- BufferGeometry,
12
- Float32BufferAttribute,
13
- Mesh,
14
- MeshLambertMaterial,
15
- MeshStandardMaterial,
16
- PointLight,
17
- Scene,
18
- } from "three";
19
-
20
- class CleanRoomEnvironment extends Scene {
21
- constructor() {
22
- super();
23
-
24
- this.name = "CleanRoomEnvironment";
25
- this.position.y = -3.5;
26
- // Pre-rotate 45° so the cleanest wall/floor edge faces the default camera
27
- this.rotation.y = (45 * Math.PI) / 180;
28
-
29
- const geometry = new BoxGeometry();
30
- geometry.deleteAttribute("uv");
31
-
32
- const roomMaterial = new MeshStandardMaterial({ side: BackSide });
33
-
34
- const mainLight = new PointLight(0xffffff, 900, 28, 2);
35
- mainLight.position.set(0.418, 16.199, 0.3);
36
- this.add(mainLight);
37
-
38
- const room = new Mesh(geometry, roomMaterial);
39
- room.position.set(-0.757, 13.219, 0.717);
40
- room.scale.set(31.713, 28.305, 28.591);
41
- this.add(room);
42
-
43
- // Infinity cove (quarter-cylinder sweep) at all 4 wall-floor junctions.
44
- // Eliminates the sharp 90° corner visible in reflections.
45
- //
46
- // Room bounds (inner faces of BackSide box):
47
- const cx = -0.757, cy = 13.219, cz = 0.717;
48
- const hx = 31.713 / 2, hy = 28.305 / 2, hz = 28.591 / 2;
49
- const floorY = cy - hy; // ≈ -0.93
50
- const wallMinX = cx - hx; // ≈ -16.61
51
- const wallMinZ = cz - hz; // ≈ -13.58
52
- const R = 6;
53
-
54
- // Single infinity cove on the -z wall (faces default camera after 45° rotation).
55
- const cove = new Mesh(createCove(hx * 2, R, 12, "-z"), roomMaterial);
56
- cove.position.set(wallMinX, floorY, wallMinZ + R);
57
- this.add(cove);
58
-
59
- // Area lights on walls and ceiling
60
-
61
- // -x right
62
- const light1 = new Mesh(geometry, createAreaLightMaterial(50));
63
- light1.position.set(-16.116, 14.37, 8.208);
64
- light1.scale.set(0.1, 2.428, 2.739);
65
- this.add(light1);
66
-
67
- // -x left
68
- const light2 = new Mesh(geometry, createAreaLightMaterial(50));
69
- light2.position.set(-16.109, 18.021, -8.207);
70
- light2.scale.set(0.1, 2.425, 2.751);
71
- this.add(light2);
72
-
73
- // +x
74
- const light3 = new Mesh(geometry, createAreaLightMaterial(17));
75
- light3.position.set(14.904, 12.198, -1.832);
76
- light3.scale.set(0.15, 4.265, 6.331);
77
- this.add(light3);
78
-
79
- // +z
80
- const light4 = new Mesh(geometry, createAreaLightMaterial(43));
81
- light4.position.set(-0.462, 8.89, 14.52);
82
- light4.scale.set(4.38, 5.441, 0.088);
83
- this.add(light4);
84
-
85
- // -z
86
- const light5 = new Mesh(geometry, createAreaLightMaterial(20));
87
- light5.position.set(3.235, 11.486, -12.541);
88
- light5.scale.set(2.5, 2.0, 0.1);
89
- this.add(light5);
90
-
91
- // +y (ceiling)
92
- const light6 = new Mesh(geometry, createAreaLightMaterial(100));
93
- light6.position.set(0.0, 20.0, 0.0);
94
- light6.scale.set(1.0, 0.1, 1.0);
95
- this.add(light6);
96
- }
97
-
98
- dispose(): void {
99
- const resources = new Set<{ dispose(): void }>();
100
- this.traverse((object) => {
101
- if ("isMesh" in object && object.isMesh) {
102
- const mesh = object as Mesh;
103
- resources.add(mesh.geometry);
104
- if (!Array.isArray(mesh.material)) {
105
- resources.add(mesh.material);
106
- }
107
- }
108
- });
109
- for (const resource of resources) {
110
- resource.dispose();
111
- }
112
- }
113
- }
114
-
115
- /**
116
- * Quarter-cylinder for infinity cove — no rotation needed.
117
- *
118
- * @param length Extrusion length along the wall edge
119
- * @param radius Cove radius
120
- * @param segments Arc subdivisions
121
- * @param wall Which wall: "-x"|"+x"|"-z"|"+z"
122
- *
123
- * The arc sweeps from floor-tangent (horizontal) to wall-tangent (vertical).
124
- * Winding is set so BackSide material renders the concave interior.
125
- */
126
- function createCove(
127
- length: number, radius: number, segments: number,
128
- wall: "-x" | "+x" | "-z" | "+z",
129
- ): BufferGeometry {
130
- const positions: number[] = [];
131
- const normals: number[] = [];
132
- const indices: number[] = [];
133
-
134
- // sign: which direction the arc curves toward the wall
135
- // axis: 0 = arc in XY extruded along Z, 1 = arc in ZY extruded along X
136
- const axis = wall === "-x" || wall === "+x" ? 0 : 1;
137
- const sign = wall === "-x" || wall === "-z" ? -1 : 1;
138
-
139
- for (let i = 0; i <= segments; i++) {
140
- const angle = (i / segments) * Math.PI / 2;
141
- const h = sign * radius * Math.sin(angle); // horizontal offset toward wall
142
- const y = radius * (1 - Math.cos(angle)); // vertical offset above floor
143
- const nh = sign * Math.sin(angle); // normal toward wall
144
- const ny = -Math.cos(angle); // normal downward
145
-
146
- if (axis === 0) {
147
- // Arc in XY, extruded along Z (for ±x walls)
148
- positions.push(h, y, 0);
149
- normals.push(nh, ny, 0);
150
- positions.push(h, y, length);
151
- normals.push(nh, ny, 0);
152
- } else {
153
- // Arc in ZY, extruded along X (for ±z walls)
154
- positions.push(0, y, h);
155
- normals.push(0, ny, nh);
156
- positions.push(length, y, h);
157
- normals.push(0, ny, nh);
158
- }
159
- }
160
-
161
- for (let i = 0; i < segments; i++) {
162
- const a = i * 2;
163
- const b = a + 1;
164
- const c = a + 2;
165
- const d = a + 3;
166
- // Winding: front face must point toward corner for BackSide to show
167
- // concave interior. Extruding along X (axis=1) flips the cross product
168
- // vs extruding along Z (axis=0), so we XOR the conditions.
169
- const flip = (sign > 0) !== (axis === 1);
170
- if (flip) {
171
- indices.push(a, c, b, b, c, d);
172
- } else {
173
- indices.push(a, b, c, b, d, c);
174
- }
175
- }
176
-
177
- const geom = new BufferGeometry();
178
- geom.setAttribute("position", new Float32BufferAttribute(positions, 3));
179
- geom.setAttribute("normal", new Float32BufferAttribute(normals, 3));
180
- geom.setIndex(indices);
181
- return geom;
182
- }
183
-
184
- function createAreaLightMaterial(intensity: number): MeshLambertMaterial {
185
- return new MeshLambertMaterial({
186
- color: 0x000000,
187
- emissive: 0xffffff,
188
- emissiveIntensity: intensity,
189
- });
190
- }
191
-
192
- export { CleanRoomEnvironment };