partforge 0.5.1 → 0.5.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "partforge",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Turn a declarative part definition into a parametric-CAD web app (three.js + Manifold/Replicad). Requires a Vite-based consumer.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -36,8 +36,10 @@ export function createViewer(container, part) {
36
36
  const key = new THREE.DirectionalLight(0xffffff, 1.4);
37
37
  key.position.set(8, 14, 10);
38
38
  scene.add(key);
39
- // 1 cm grid (mm units): 200 mm wide, 20 divisions -> 10 mm squares.
40
- let grid = new THREE.GridHelper(200, 20, THEME.dark.grid[0], THEME.dark.grid[1]);
39
+ // 1 cm grid (mm units): 300 mm wide, 30 divisions -> 10 mm (1 cm) squares.
40
+ const GRID_SIZE = 300, GRID_DIVS = 30;
41
+ let floorY = 0; // world Y of the grid plane; set to the part's bbox bottom in frameTo
42
+ let grid = new THREE.GridHelper(GRID_SIZE, GRID_DIVS, THEME.dark.grid[0], THEME.dark.grid[1]);
41
43
  scene.add(grid);
42
44
 
43
45
  // --- material + part groups -----------------------------------------------
@@ -146,6 +148,10 @@ export function createViewer(container, part) {
146
148
  const center = _box.getCenter(new THREE.Vector3());
147
149
  partsGroup.position.copy(center).multiplyScalar(-1); // centre assembly on the pivot
148
150
  const size = _box.getSize(new THREE.Vector3());
151
+ // Drop the grid to the bottom of the bounding box (model Z -> world Y), so it reads
152
+ // as a floor the part sits on rather than a plane through its middle.
153
+ floorY = -size.z / 2;
154
+ grid.position.y = floorY;
149
155
  const r = Math.max(size.x, size.y, size.z) || 12;
150
156
  camera.position.setLength(r * 2.6 + 6);
151
157
  controls.target.set(0, 0, 0);
@@ -179,7 +185,8 @@ export function createViewer(container, part) {
179
185
  const t = THEME[mode] ?? THEME.dark;
180
186
  scene.background = new THREE.Color(t.bg);
181
187
  scene.remove(grid);
182
- grid = new THREE.GridHelper(200, 20, t.grid[0], t.grid[1]);
188
+ grid = new THREE.GridHelper(GRID_SIZE, GRID_DIVS, t.grid[0], t.grid[1]);
189
+ grid.position.y = floorY; // keep the floor at the bbox bottom across theme swaps
183
190
  scene.add(grid);
184
191
  lineMaterial.color.set(t.line);
185
192
  }