@leverege/tpi-viz 0.2.0

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/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @leverege/tpi-viz
2
+
3
+ 3D scene viewer for TPI manufacturing data. Renders blade geometry, PTZ
4
+ cameras, defects, ply layers, and flows from JSON scene files written by
5
+ `tpi-scripts-py` (Python).
6
+
7
+ This is a sibling package inside the `tpi-scripts-py` repo. The Python
8
+ side writes scene data + image assets into `work_dir/scenes/<name>/`. This
9
+ package's dev server mounts that directory at `/scenes/*` so the viewer
10
+ can fetch any scene by name.
11
+
12
+ ## Dev loop (the normal flow)
13
+
14
+ ```bash
15
+ cd packages/tpi-scripts-py/tpi-viz
16
+ yarn install
17
+ yarn dev # vite dev server on http://localhost:5173
18
+ ```
19
+
20
+ Leave that running. In another terminal generate a scene:
21
+
22
+ ```bash
23
+ cd packages/tpi-scripts-py
24
+ python -m scripts.visualize.defects <SA_JOB_ID>
25
+ python -m scripts.visualize.plylayers <SA_JOB_ID>
26
+ python -m scripts.visualize.ptz_camera <CAMERA_ID>
27
+ python -m scripts.flow.viewer --shell <SHELL_ID>
28
+ ```
29
+
30
+ Each writes `work_dir/scenes/<name>/scene.json` (plus sibling image dirs
31
+ when relevant) and prints the URL to open:
32
+
33
+ ```
34
+ http://localhost:5173/?scene=<name>
35
+ ```
36
+
37
+ Refresh the page after re-running the script to see new data — no Python
38
+ re-render, no rebuild.
39
+
40
+ Hitting `http://localhost:5173/` with no `?scene=` shows a list of
41
+ available scenes scraped from the dev server's directory listing.
42
+
43
+ ## How it works
44
+
45
+ - `vite.config.js` mounts `<repo>/work_dir/scenes/` at `/scenes/*` via a
46
+ `sirv` middleware.
47
+ - `src/main.js` reads `?scene=<name>` from the URL, sets
48
+ `<base href="/scenes/<name>/">` so relative paths in `scene.json`
49
+ (`images/foo.jpg`, `overlays/bar.png`) resolve under the scene's dir,
50
+ then fetches `/scenes/<name>/scene.json` and renders.
51
+ - The viewer is a single-page app built with Three.js +
52
+ `@leverege/ptz-camera`.
53
+
54
+ ## Production build
55
+
56
+ ```bash
57
+ yarn build # writes dist/index.html (single self-contained file)
58
+ ```
59
+
60
+ Useful for shipping the viewer somewhere. The dev-server scene loading
61
+ still works against the built artifact if it's hosted with `/scenes/*`
62
+ mapped the same way.
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@leverege/tpi-viz",
3
+ "version": "0.2.0",
4
+ "description": "3D scene viewer for TPI manufacturing data — renders blade geometry, PTZ cameras, defects, ply layers, and flows. Exports mountViewer()/destroy() for embedding (e.g. an Imaginarium React route); also runs standalone.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./src/main.js"
8
+ },
9
+ "files": [
10
+ "src"
11
+ ],
12
+ "scripts": {
13
+ "build": "vite build",
14
+ "dev": "vite",
15
+ "preview": "vite preview"
16
+ },
17
+ "dependencies": {
18
+ "@leverege/ptz-camera": "^0.3.0",
19
+ "@leverege/tpi-camera-modeling": "^0.3.1",
20
+ "@leverege/tpi-parsers": "^0.3.2",
21
+ "@leverege/tpi-viz-renderer": "^0.2.3",
22
+ "three": "^0.160.0"
23
+ },
24
+ "devDependencies": {
25
+ "sirv": "^2.0.4",
26
+ "vite": "^5.0.0",
27
+ "vite-plugin-singlefile": "^2.0.0"
28
+ },
29
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
30
+ }