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.
docs/media.md +17−6
| @@ -2,7 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | 3 | A repository holds more than source text. Vole shows a picture or a 3D model on | |
| 4 | 4 | the surfaces that read a file: the code browser, a commit or compare diff, and | |
| 5 | the Files tab of a change request. Markdown files use the same image support. | ||
| 5 | the Files tab of a change request. Markdown files use the same image and model | ||
| 6 | support. | ||
| 6 | 7 | ||
| 7 | 8 | Nothing has to be rendered. A format with no useful source view (a PNG, a binary | |
| 8 | 9 | STL) is shown in place of the source table. A text format that is also a model or | |
| @@ -44,10 +45,17 @@ An image larger than 32 MiB is a download rather than an inline preview. | |||
| 44 | 45 | | `.glb` | glTF (binary) | | |
| 45 | 46 | | `.3mf` | 3D Manufacturing Format | | |
| 46 | 47 | ||
| 47 | The viewer runs in the browser and needs only the file: drag to orbit, scroll or | ||
| 48 | pinch to zoom, and use the buttons to reset the view or toggle a wireframe. It is | ||
| 49 | loaded on demand, so a page without a model downloads none of it. Without | ||
| 50 | JavaScript or WebGL, the file's download link stays visible. | ||
| 48 | The viewer runs in the browser and needs only the file. Drag to orbit; scroll, | ||
| 49 | pinch, or use the + and − buttons to zoom; use the buttons to reset the view or | ||
| 50 | toggle a wireframe. It is loaded on demand, so a page without a model downloads | ||
| 51 | none of it. Without JavaScript or WebGL, the file's download link stays visible. | ||
| 52 | |||
| 53 | A Markdown document names a model the same way it names a picture: a relative | ||
| 54 | image path whose extension is on the list above. A README can therefore show an | ||
| 55 | assembly beside the prose. The image's alt text labels the preview, and the | ||
| 56 | file's name is what the fallback offers to download. A path in a document that | ||
| 57 | has no place in a tree — an issue body, the instance introduction — stays an | ||
| 58 | image, because there is no raw route behind it for the viewer to fetch. | ||
| 51 | 59 | ||
| 52 | 60 | A `.gltf` may name buffers and textures beside it; they are fetched through the | |
| 53 | 61 | same raw path. A companion `.mtl` for an `.obj` is not loaded, so an OBJ arrives | |
| @@ -56,4 +64,7 @@ as geometry with a plain material. | |||
| 56 | 64 | Compressed glTF assets are not supported. A model that uses Draco, KTX2, or | |
| 57 | 65 | meshopt reports that it could not be loaded and keeps its download link. | |
| 58 | 66 | ||
| 59 | A model larger than 64 MiB is a download rather than an inline preview. | ||
| 67 | A model larger than 64 MiB is a download rather than an inline preview in the | ||
| 68 | code browser, which reads the file's size before rendering. A Markdown document | ||
| 69 | is rendered from its text alone, so the path is all that decides there: a | ||
| 70 | README's model is offered to the viewer whatever its size. | ||