Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Show a model from a document, and redraw the viewer

0be968244db3882594fa65032ff6b4cf59385bb9 · Keenan Nemetz · 11d ago · parent ffbcb4cc

Show a model from a document, and redraw the viewer

A README that names a 3D model with an image path was emitting an <img> of
a mesh. The raw route serves model/stl, no browser draws that, so the
reader saw a broken image where the rack was supposed to be.

A model image in a document now becomes the same viewer host the code
browser writes, with the image's alt text as its label and the download
link inside it for a reader without JavaScript or WebGL. Only a document
with a place in a tree does this: an issue body has no raw route to fetch.
The sanitiser admits exactly that host's shape, so the one classed element
in a rendered document is the one the renderer wrote.

The viewer also never redrew after OrbitControls moved the camera: it
renders on demand, and only the button handlers called render. A drag or a
wheel zoom changed the camera and left the old frame on screen, which is
why the viewer looked static. Listen for the controls' change event, add
zoom in/out buttons clamped to the wheel's own limits, and give the canvas
a grab cursor.

Docs now say a Markdown path names a model the same way it names a picture,
and that the code browser's size cap cannot apply to a document rendered
from its text alone.

server/web/static/vole.css +17−2

@@ -1202,8 +1202,11 @@ pre code { background: none; border: 0; padding: 0; font-size: inherit; }
1202 1202
1203 1203 /* A 3D preview owns a fixed box, because the canvas is sized from its element.
1204 1204 The server writes a download link inside the box; the viewer removes it once
1205 the mesh is drawn, and leaves it for a reader without JavaScript or WebGL. */
1205 the mesh is drawn, and leaves it for a reader without JavaScript or WebGL.
1206 Markdown writes the host as a span, since an image may sit mid-sentence, so the
1207 box is asked for here rather than inherited from the element. */
1206 1208 .model-viewer {
1209 display: block;
1207 1210 position: relative;
1208 1211 height: min(64vh, 560px);
1209 1212 min-height: 260px;
@@ -1220,7 +1223,10 @@ pre code { background: none; border: 0; padding: 0; font-size: inherit; }
1220 1223 width: 100%;
1221 1224 height: 100%;
1222 1225 touch-action: none;
1226 /* The canvas is draggable, and says so before the first drag. */
1227 cursor: grab;
1223 1228 }
1229 .model-canvas:active { cursor: grabbing; }
1224 1230 .model-fallback {
1225 1231 position: absolute;
1226 1232 inset: 0;
@@ -1242,7 +1248,16 @@ pre code { background: none; border: 0; padding: 0; font-size: inherit; }
1242 1248 font-size: calc(12.65px * var(--font-scale));
1243 1249 pointer-events: none;
1244 1250 }
1245 .model-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
1251 .model-tools {
1252 position: absolute;
1253 top: 8px;
1254 right: 8px;
1255 display: flex;
1256 flex-wrap: wrap;
1257 justify-content: flex-end;
1258 gap: 6px;
1259 max-width: calc(100% - 16px);
1260 }
1246 1261 .model-tool {
1247 1262 font: inherit;
1248 1263 font-size: calc(12.65px * var(--font-scale));