Closed general

3D viewer: let a page set the camera target (viewer_3d.camera.target and ?camera=a,b,r,tx,ty,tz)

John Lauer · ·closed by Colby Knox

Ask

Let a page set the 3D viewer's camera target, not only its angles and distance:

  • component.viewer_3d.camera.target: [x, y, z] in the GLB's own frame (metres, Z up as the viewer shows it), defaulting to today's bounding-box centre;
  • and the same on the embed query, for example ?camera=alpha,beta,radiusScale,tx,ty,tz.

Why

Today the opening view takes alpha, beta and radiusScale (page.json component.viewer_3d.camera, or ?camera=a,b,r), and it always aims at the GLB's bounding-box centre. That is fine for a chip. For a scene it often is not: a robot workcell's box is pulled upwards by the arm and sideways by long rails or a shelf, so the centre floats in the air behind the cell. The opening view then shows the cell small in the lower part of the frame, with empty space above.

The only workaround is to edit the model so that its box centre lands where the view should aim. Authors do this by moving, trimming or padding geometry purely to steer a camera, which changes the model for a presentation reason.

Example

A project page's hero is a workcell GLB. The author's chosen view (front-left, the whole cell filling the frame, the arm rising out of the top edge) aims at about the middle of the stations, about 0.25 m below and 0.2 m in front of the box centre. No combination of alpha, beta and radiusScale gives that framing, because the target cannot move.

Expected

  • target set: the opening camera orbits that point; Home returns to it.
  • target absent: unchanged behaviour (box centre), so no existing page moves.
  • The sanitizer accepts the key (today unknown keys are dropped with a publish hint), and the query form overrides page.json the way ?camera= does now.

Related, not the same: #374 (component heroes land on a bad camera angle) asks for a posing step for hero images; this asks for one more camera parameter that the hero step could reuse.

2 Replies

Colby Knox ·

Accepted on the wiki side: the page.json component.viewer_3d.camera.target key (sanitizer included), the extra tx,ty,tz on ?camera=, and passing the target through so Home returns to it. The viewer half (setHomeView taking a target) rides on the viewer's camera work in adom-inc/adom-3d-viewer-babylon9#12, so this lands after that merges.

For next time: requests for the viewer library itself (its API, controls, rendering) belong on the 3D viewer's page, https://wiki.adom.inc/adom/adom-3d-viewer/issues. Wiki-side wiring like the page.json keys and the embed query stays here.

Colby Knox ·

Live on wiki.adom.inc. In page.json: component.viewer_3d.camera: { alpha, beta, radiusScale?, target: [x, y, z] }, with the target in the GLB's own frame (meters, Z up, as the viewer shows it). On the embed: ?camera=alpha,beta,radiusScale,tx,ty,tz (all three target numbers or none). The opening view orbits that point and Home returns to it; without a target nothing changes. A malformed target is reported at publish as camera.target and the angles still apply. The viewer side is adom/adom-3d-viewer 0.12.3 (setHomeView takes target), and the wiki-hero-glb skill (skill pack 0.8.51) documents it.

Colby Knox closed this ·

Log in to reply.