@leverege/tpi-viz-renderer
v0.2.5
Published
Mutable three.js scene-graph renderer + product-asset loader for TPI blade visualization (the reusable JS half of tpi-viz).
Readme
@leverege/tpi-viz-renderer
The reusable JS half of tpi-viz: a mutable three.js scene-graph renderer
plus a product-asset loader, extracted so any app (the bundled tpi-viz
viewer, the Imaginarium visualizer) can drive a TPI blade scene at runtime.
Entries
// Renderer — imperative, mutable scene graph (no baked scene.json required)
import { createSceneRenderer, SceneModel, computeKinematics } from '@leverege/tpi-viz-renderer'
const scene = createSceneRenderer( containerEl ) // sets up THREE + controls + render loop
scene.setMold( stlMesh )
const camId = scene.addCamera( cam, { ptz, label } )
scene.addContours( lpdContours, { side : 'PS' } )
scene.addFlow( { name, cameraId, steps, useCase } )
scene.setView( savedView )
scene.applyScene( sceneJson ) // hydrate from a Python-emitted scene.json
const recipe = scene.toRecipe(); scene.applyRecipe( recipe ) // refs + views + toggles (no geometry)
// Loader — product id + side → { lpdContours, calPoints, stlMesh } in canonical frame.
// The resource fetcher is injectable (browser → backend signed URLs, or local files in tests).
import { loadProductAssets, createApiFetcher } from '@leverege/tpi-viz-renderer/loader'Layout
src/renderer/sceneModel.js— pure scene model + kinematics (no WebGL; node-testable).src/renderer/SceneRenderer.js— the THREE renderer over the model.src/loader/productAssets.js— parse + compose LPD/CAL/STL into a scene (uses@leverege/tpi-parsers; binary STL via an injected threeSTLLoader).
Tests
yarn install
yarn test # node test/sceneGraph.test.mjs + test/productAssets.test.mjsthree resolves to a single copy in bundlers via resolve.dedupe: ['three'].
