← Commit history
package.json+43−6@@ -3,7 +3,48 @@ "version": "0.12.3", "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",+ "module": "./dist/index.js",+ "types": "./dist/index.d.ts",+ "exports": {+ ".": {+ "import": "./dist/index.js",+ "types": "./dist/index.d.ts"+ }+ },+ "files": [+ "dist",+ "dist-standalone",+ "src",+ "standalone.ts"+ ],+ "scripts": {+ "build": "vite build",+ "build:standalone": "vite build --config vite.standalone.config.mts",+ "dev": "vite build --watch",+ "prepare": "npm run build",+ "test:sandbox": "node test/wiki-sandbox.test.mjs",+ "test:orbit": "node test/orbit.test.mjs",+ "test": "node test/wiki-sandbox.test.mjs && node test/orbit.test.mjs && node test/viewcube.test.mjs && node test/help.test.mjs && node test/lights.test.mjs && node test/replace.test.mjs && node test/layers.test.mjs && node test/bundle.test.mjs && node test/home-target.test.mjs",+ "test:viewcube": "node test/viewcube.test.mjs",+ "test:help": "node test/help.test.mjs",+ "test:lights": "node test/lights.test.mjs",+ "test:replace": "node test/replace.test.mjs",+ "test:layers": "node test/layers.test.mjs",+ "test:bundle": "node test/bundle.test.mjs",+ "test:home": "node test/home-target.test.mjs"+ }, "dependencies": {},+ "devDependencies": {+ "@sveltejs/vite-plugin-svelte": "^3.1.2",+ "svelte-check": "^3.8.6",+ "terser": "^5.46.2",+ "typescript": "^5.5.4",+ "vite": "^5.4.1"+ },+ "peerDependencies": {+ "svelte": "^4.0.0 || ^5.0.0"+ }, "slug": "adom-3d-viewer", "license": "MIT", "tags": [@@ -37,9 +78,5 @@ "prompt": "Download the 0.4.3 viewer bundle so my tool vendors a fixed build" } ],- "title": "Adom 3D Viewer",- "scripts": {- "install": "./install.sh",- "uninstall": "./uninstall.sh"- }-}+ "title": "Adom 3D Viewer"+}
src/ThreeDViewer.svelte+12−4@@ -1356,13 +1356,19 @@ // 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;+ // `target` (adom/wiki#237) is the point the view orbits, in the scene's+ // frame: a GLB's own coordinates, Z up, as the viewer shows them. Without+ // it Home aims at the model's bounding-box center, which for a scene (a+ // workcell pulled up by an arm, sideways by a rail) can float in the air.+ let homeView: { alpha: number; beta: number; radiusScale: number; target: Vector3 | null } | 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 {+ /** Set (or clear with null) the view Home returns to: { alpha, beta, radiusScale?, target? } (radians; target [x, y, z] in the model's frame), the ?camera= contract. */+ export function setHomeView(view: { alpha: number; beta: number; radiusScale?: number; target?: [number, number, number] | null } | 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 };+ const t = Array.isArray(view.target) && view.target.length === 3 && view.target.every((v) => Number.isFinite(Number(v)))+ ? new Vector3(Number(view.target[0]), Number(view.target[1]), Number(view.target[2])) : null;+ homeView = { alpha: Number(view.alpha), beta: Number(view.beta), radiusScale: Number.isFinite(r) && r > 0 ? r : 1, target: t }; } else { homeView = null; }@@ -1374,6 +1380,8 @@ if (!cam) return; if (homeView) { frameModel();+ // The framing's distance and bounds stay; only the orbit point moves.+ if (homeView.target) cam.setTarget(homeView.target.clone(), false, false, true); cam.alpha = homeView.alpha; cam.beta = homeView.beta; cam.radius = cam.radius * homeView.radiusScale;
standalone.ts+2−1@@ -74,7 +74,8 @@ interface ViewerInstance { 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;+ /** The view Home returns to; target [x, y, z] (the model's frame, Z up) is the point it orbits, default the bounding-box center. */+ setHomeView: (view: { alpha: number; beta: number; radiusScale?: number; target?: [number, number, number] | null } | null) => void; /** Open or close the controls card (the ? button); showHelp: false at init hides the button. */ showHelp: () => void; hideHelp: () => void;