← Commit history
0.9.2: setHomeView, so Home goes to the host's authored view (#9)
5 files changed
+33−7
README.md+1−1@@ -85,7 +85,7 @@ window.Adom3DViewerBabylon9 = { - `getScene()` / `getEngine()` / `getCamera()` / `getShadowGenerator()` - `addContentRoot(node, opts?)` / `removeContentRoot(node)` - `toggleDebugLayer()` / `showDebugLayer()` / `hideDebugLayer()`-- `setGroundVisible(visible)` / `goHome()`+- `setGroundVisible(visible)` / `goHome()` / `setHomeView({ alpha, beta, radiusScale? } | null)`: Home (the view cube and `goHome()`) goes to the host's view when one is set, else the top-front-right corner (0.9.2, adom/adom-3d-viewer#9) - `setBottomLight(on)` / `getBottomLightState()`: underside fill light, default off - `setProjectionMode(ortho)` / `getProjectionMode()` - `toggleAxes("world" | "mesh-local", force?)` / `getAxesState()`
VERSION+1−1@@ -1 +1 @@-0.9.1+0.9.2
package.json+1−1@@ -1,6 +1,6 @@ { "name": "adom-3d-viewer-babylon9",- "version": "0.9.1",+ "version": "0.9.2", "description": "The Babylon 9.5 engine behind every component page's 3D tab on wiki.adom.inc. Versioned ESM bundle with GLB loading, view cube, layers toolbar, ground shadows, and Z-up CAD framing.", "type": "app", "main": "./dist/index.js",
src/ThreeDViewer.svelte+27−4@@ -665,7 +665,7 @@ return true; } - /** Lights the content brought with it, as authored (candela, metres). */+ /** Lights the content brought with it, as authored (candela, meters). */ export function getContentLights(): ContentLightRow[] { return contentLights ? contentLights.rows() : []; }@@ -945,7 +945,7 @@ /** * Take the GLB's own lights under the viewer's budget, and say something- * when the content puts one under a scaled node: glTF range is metres and+ * when the content puts one under a scaled node: glTF range is meters and * intensity candela, and neither follows a node matrix, so a light inside * a 1000x group throws 1000x too short for the geometry around it. The * viewer does not "fix" that by rewriting the light; the file is wrong and@@ -1077,7 +1077,7 @@ /** * Pin the shadow map refresh rate, or pass null to restore automatic- * behaviour (adom/wiki#60 item 7). Setting refreshRate straight on the+ * behavior (adom/wiki#60 item 7). Setting refreshRate straight on the * shadow map does not survive, because refreshShadows() runs on every * load, frame and layer toggle and reasserts its own choice. Auto only * looks at scene.animationGroups, so content a consumer animates from@@ -1172,10 +1172,33 @@ return !!(bl && bl.intensity > 0); } - /** Jump camera to the home view (front-top-right, like the view cube corner) and re-frame the model. No animation. */+ // The host's own home view (adom/adom-3d-viewer#9): a page that knows its+ // canonical presentation (a part whose marking reads the right way up+ // from one side) sets it once, and Home (the cube's button, goHome()) goes+ // there instead of the generic top-front-right corner. Null = the corner.+ let homeView: { alpha: number; beta: number; radiusScale: number } | null = null;++ /** Set (or clear with null) the view Home returns to: { alpha, beta, radiusScale? } in radians, the ?camera= contract. */+ export function setHomeView(view: { alpha: number; beta: number; radiusScale?: number } | null): void {+ if (view && Number.isFinite(view.alpha) && Number.isFinite(view.beta)) {+ const r = view.radiusScale == null ? 1 : Number(view.radiusScale);+ homeView = { alpha: Number(view.alpha), beta: Number(view.beta), radiusScale: Number.isFinite(r) && r > 0 ? r : 1 };+ } else {+ homeView = null;+ }+ }++ /** Jump camera to the home view (the host's, else front-top-right like the view cube corner) and re-frame the model. No animation. */ export function goHome(): void { const cam = AdomStatics.camera; if (!cam) return;+ if (homeView) {+ frameModel();+ cam.alpha = homeView.alpha;+ cam.beta = homeView.beta;+ cam.radius = cam.radius * homeView.radiusScale;+ return;+ } cam.rotateToCubeTopFrontRight(0); frameModel(); }
standalone.ts+3@@ -61,6 +61,8 @@ interface ViewerInstance { setBottomLight: (on: boolean) => void; getBottomLightState: () => boolean; goHome: () => void;+ /** Set the view Home returns to ({ alpha, beta, radiusScale? } in radians), or null for the cube corner. */+ setHomeView: (view: { alpha: number; beta: number; radiusScale?: number } | null) => void; /** Open or close the controls card (the ? button); showHelp: false at init hides the button. */ showHelp: () => void; hideHelp: () => void;@@ -186,6 +188,7 @@ function init(container: HTMLElement, options?: { setBottomLight: (on: boolean) => component.setBottomLight(on), getBottomLightState: () => component.getBottomLightState(), goHome: () => component.goHome(),+ setHomeView: (view) => component.setHomeView(view), setProjectionMode: (ortho: boolean) => component.setProjectionMode(ortho), getProjectionMode: () => component.getProjectionMode(), toggleAxes: (target: 'world' | 'mesh-local', enabled?: boolean) => component.toggleAxes(target, enabled),