From 2a9102391e4618fded917c7d7530eb8882c85865 Mon Sep 17 00:00:00 2001 From: ProjectIdris <227970220+ProjectIdris@users.noreply.github.com> Date: Sun, 8 Nov 2026 23:44:12 +1300 Subject: [PATCH 01/12] Real models for real things: a heart and a brain from BodyParts3D, with named parts One general mechanism: a per-model manifest (source, exact licence and version, credit, hashes, axes, scale, named parts with confidence), a fetch-once hash-pinned build into ignored folders (no large files in git, no LFS), a GLB loader in the overlay page that checks size, hash and external references and reads files only, and `add {shape:model}` whose named parts are objects of their own, so pin, highlight, style, explode and cut work on them unchanged. A model with no match falls back to shapes with a note. CC BY credit is shown at the foot of the stage and a credits file is shipped and can be saved from the tray. The build copies the pinned files to dist/models; the installer refuses to pack without them. The guide grows by about 1.2 KB (test budgets raised to 44,800 and 33,700). Co-Authored-By: Claude Sonnet 5.5 --- .gitignore | 4 + CONTRIBUTING.md | 4 + assets/CREDITS.md | 27 + assets/models/brain.json | 1048 ++++++++++++++++++++++++++++ assets/models/heart.json | 1210 +++++++++++++++++++++++++++++++++ docs/real-models.md | 21 + docs/scene.schema.json | 108 +++ docs/scene.schema.lean.json | 280 +++++--- package.json | 5 + scripts/assets/build.mjs | 77 +++ scripts/assets/fetch.mjs | 71 ++ scripts/assets/index.mjs | 96 +++ scripts/assets/manifest.mjs | 70 ++ scripts/assets/obj-glb.mjs | 162 +++++ scripts/assets/ship.mjs | 27 + scripts/assets/zip-range.mjs | 50 ++ scripts/build.mjs | 3 + scripts/dist.mjs | 2 + src/main/main.ts | 9 +- src/main/tray.ts | 3 + src/overlay/index.html | 6 +- src/overlay/model-assets.ts | 132 ++++ src/overlay/overlay.ts | 37 + src/overlay/scene3d.ts | 24 +- src/overlay/timeline.ts | 23 + src/scene/anchors.ts | 5 + src/scene/guide.ts | 4 +- src/scene/model-catalogue.ts | 1020 +++++++++++++++++++++++++++ src/scene/models.ts | 44 ++ src/scene/spec.ts | 10 + src/scene/types.ts | 10 +- src/scene/validate.ts | 52 +- test/assets-obj-glb.test.ts | 71 ++ test/assets-zip-range.test.ts | 55 ++ test/guide-pass.test.ts | 4 +- test/real-models.test.ts | 220 ++++++ test/scene-models.test.ts | 97 +++ 37 files changed, 4971 insertions(+), 120 deletions(-) create mode 100644 assets/CREDITS.md create mode 100644 assets/models/brain.json create mode 100644 assets/models/heart.json create mode 100644 docs/real-models.md create mode 100644 scripts/assets/build.mjs create mode 100644 scripts/assets/fetch.mjs create mode 100644 scripts/assets/index.mjs create mode 100644 scripts/assets/manifest.mjs create mode 100644 scripts/assets/obj-glb.mjs create mode 100644 scripts/assets/ship.mjs create mode 100644 scripts/assets/zip-range.mjs create mode 100644 src/overlay/model-assets.ts create mode 100644 src/scene/model-catalogue.ts create mode 100644 src/scene/models.ts create mode 100644 test/assets-obj-glb.test.ts create mode 100644 test/assets-zip-range.test.ts create mode 100644 test/real-models.test.ts create mode 100644 test/scene-models.test.ts diff --git a/.gitignore b/.gitignore index 6bc990e3..2f50f779 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ dist/ .DS_Store Thumbs.db release/ + +# real models: the raw downloads and the built files are not in git (see scripts/assets and assets/models) +assets/cache/ +assets/built/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4dcde74a..37f4acb9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,6 +30,10 @@ Setup (a speech recogniser, a model) is in [docs/setup.md](docs/setup.md); commo The app works on your real screen: be careful with `--visible-to-capture` and with anything that takes screenshots while a private window is open. +## Real models + +The 3D models of real things (a heart, a brain) are described by manifests in `assets/models` and fetched once into an ignored cache, never committed; see [docs/real-models.md](docs/real-models.md). Without them the app still runs and those models are drawn from shapes, and the two tests that read the built files skip. + ## Testing ``` diff --git a/assets/CREDITS.md b/assets/CREDITS.md new file mode 100644 index 00000000..2eb6e474 --- /dev/null +++ b/assets/CREDITS.md @@ -0,0 +1,27 @@ +# Credits for the real models + +Talkthrough itself is MIT licensed. The models it can show are separate works under their own licences, listed here, and are not part of the MIT grant. +This file is generated from `assets/models/*.json` (`npm run assets:index`) and is shipped with the app. + +## Human brain (`brain`) + +- Source: BodyParts3D, https://dbarchive.biosciencedbc.jp/en/bodyparts3d/ (4.0, polygon reduction 99 percent (archive of 2013-05-22; README and licence of 2025-02-27)) +- Licence: CC BY 4.0, version 4.0 International: https://dbarchive.biosciencedbc.jp/en/bodyparts3d/lic.html +- Credit: BodyParts3D, © The Database Center for Life Science, licensed under CC Attribution 4.0 International (https://creativecommons.org/licenses/by/4.0/) +- Changes: Files converted from OBJ to glTF, millimetres to metres, axes turned to y up and the front toward the viewer, parts recentred on themselves; left and right meshes and gyri are merged into one named part. Duplicate vertices were welded and smooth normals computed; no shape was edited. +- Note: The database licence page (updated 2025-02-27) and README name CC BY 4.0 International and the credit line given here. The OBJ files in the 2013 archive still carry an older header naming CC Attribution-Share Alike 2.1 Japan; the current statement of the licensor is followed here, and the files are converted without their header. +- Built file: brain.glb, 8358176 bytes, sha256 0d353d478830dff8e6fac252909c2e236229932336e63eb8a7665179b2f914d1 +- Parts: Frontal lobe (grouped); Parietal lobe (grouped); Temporal lobe (grouped); Occipital lobe (atlas); Insula (atlas); Cingulate gyrus (atlas); Cerebellum (atlas); Pons (atlas); Medulla oblongata (atlas); Midbrain (atlas); Thalamus (atlas); Hypothalamus (atlas); Hippocampus (atlas); Amygdala (atlas); Caudate nucleus (atlas); Globus pallidus (atlas); Corpus callosum (atlas); Cerebral white matter (atlas); Lateral ventricles (atlas); Pituitary gland (atlas) +- Limit: The atlas models the main gyri, not every fold: the lobes are made of the named gyri it has, so small regions (the precuneus, the posterior superior temporal gyrus) are not separate and may show as gaps. + +## Human heart (`heart`) + +- Source: BodyParts3D, https://dbarchive.biosciencedbc.jp/en/bodyparts3d/ (4.0, polygon reduction 99 percent (archive of 2013-05-22; README and licence of 2025-02-27)) +- Licence: CC BY 4.0, version 4.0 International: https://dbarchive.biosciencedbc.jp/en/bodyparts3d/lic.html +- Credit: BodyParts3D, © The Database Center for Life Science, licensed under CC Attribution 4.0 International (https://creativecommons.org/licenses/by/4.0/) +- Changes: Files converted from OBJ to glTF, millimetres to metres, axes turned to y up and the front toward the viewer, parts recentred on themselves; a file may be merged with others into one named part. Duplicate vertices were welded and smooth normals computed; no shape was edited. +- Note: The database licence page (updated 2025-02-27) and README name CC BY 4.0 International and the credit line given here. The OBJ files in the 2013 archive still carry an older header naming CC Attribution-Share Alike 2.1 Japan; the current statement of the licensor is followed here, and the files are converted without their header. +- Built file: heart.glb, 2558152 bytes, sha256 309af9886b9388323beb7e9c933c2b1f2a30b05ba93768eda6c8999b7da20ef1 +- Parts: Right atrium (atlas); Wall of the right atrium (atlas); Left atrium (atlas); Wall of the left atrium (atlas); Right ventricle (atlas); Left ventricle (atlas); Mitral valve (grouped); Tricuspid valve (grouped); Aortic valve (grouped); Pulmonary valve (grouped); Papillary muscles (grouped); Ascending aorta (atlas); Arch of the aorta (atlas); Pulmonary trunk (atlas); Superior vena cava (atlas); Left coronary artery and its branches (grouped); Right coronary artery and its branches (grouped); Cardiac veins (grouped) +- Limit: The atlas has no mesh for the ventricular wall or the pericardium: the chambers are drawn as their blood-filled cavities, so a cut shows cavities, valves and vessels, not a wall. +- Limit: The pulmonary veins, the branches of the pulmonary arteries and the inferior vena cava (its mesh runs 24 cm into the abdomen) are not included. diff --git a/assets/models/brain.json b/assets/models/brain.json new file mode 100644 index 00000000..97a2b196 --- /dev/null +++ b/assets/models/brain.json @@ -0,0 +1,1048 @@ +{ + "id": "brain", + "name": "Human brain", + "aliases": [ + "brain", + "human brain", + "cerebrum", + "lobes of the brain", + "cerebral cortex", + "cerebellum" + ], + "description": "An adult human brain: the main cortical gyri grouped into the four lobes, deep structures, cerebellum and brainstem, as named parts.", + "source": { + "name": "BodyParts3D", + "url": "https://dbarchive.biosciencedbc.jp/en/bodyparts3d/", + "archive": { + "url": "https://dbarchive.biosciencedbc.jp/data/bodyparts3d/LATEST/isa_BP3D_4.0_obj_99.zip", + "bytes": 142903898, + "folder": "isa_BP3D_4.0_obj_99" + }, + "version": "4.0, polygon reduction 99 percent (archive of 2013-05-22; README and licence of 2025-02-27)", + "format": "obj" + }, + "licence": { + "id": "CC-BY-4.0", + "version": "4.0 International", + "url": "https://dbarchive.biosciencedbc.jp/en/bodyparts3d/lic.html", + "evidence": { + "page": "https://dbarchive.biosciencedbc.jp/en/bodyparts3d/lic.html", + "updated": "2025-02-27", + "retrieved": "2026-11-08", + "sha256": "6ab56d4702c16d52ec54c7635cef25e7b488771ae9539717afd87327c09ed842" + }, + "note": "The database licence page (updated 2025-02-27) and README name CC BY 4.0 International and the credit line given here. The OBJ files in the 2013 archive still carry an older header naming CC Attribution-Share Alike 2.1 Japan; the current statement of the licensor is followed here, and the files are converted without their header." + }, + "credit": "BodyParts3D, © The Database Center for Life Science, licensed under CC Attribution 4.0 International (https://creativecommons.org/licenses/by/4.0/)", + "changes": "Files converted from OBJ to glTF, millimetres to metres, axes turned to y up and the front toward the viewer, parts recentred on themselves; left and right meshes and gyri are merged into one named part. Duplicate vertices were welded and smooth normals computed; no shape was edited.", + "orient": { + "up": "z+", + "front": "y-", + "note": "source axes: x toward the left of the body, y toward the back, z toward the head (README, coordinate system)" + }, + "scale": { + "unitsToMetres": 0.001, + "realLengthMetres": 0.17, + "realLengthOf": "the brain, front to back (about 17 cm)" + }, + "caveats": [ + "The atlas models the main gyri, not every fold: the lobes are made of the named gyri it has, so small regions (the precuneus, the posterior superior temporal gyrus) are not separate and may show as gaps." + ], + "parts": [ + { + "key": "frontal-lobe", + "name": "Frontal lobe", + "aliases": [ + "frontal cortex" + ], + "nodes": [ + "FJ1833", + "FJ1834", + "FJ1787", + "FJ1788", + "FJ1744", + "FJ1745", + "FJ1800", + "FJ1801", + "FJ1793", + "FJ1794" + ], + "confidence": "grouped", + "color": [ + 226, + 150, + 120 + ], + "note": "superior, middle, inferior frontal, precentral and orbital gyri" + }, + { + "key": "parietal-lobe", + "name": "Parietal lobe", + "aliases": [ + "parietal cortex" + ], + "nodes": [ + "FJ1797", + "FJ1798", + "FJ1841", + "FJ1842", + "FJ1732", + "FJ1733", + "FJ1835", + "FJ1836" + ], + "confidence": "grouped", + "color": [ + 232, + 196, + 110 + ], + "note": "postcentral, supramarginal, angular gyri and superior parietal lobule" + }, + { + "key": "temporal-lobe", + "name": "Temporal lobe", + "aliases": [ + "temporal cortex" + ], + "nodes": [ + "FJ1746", + "FJ1747", + "FJ1789", + "FJ1790", + "FJ1783", + "FJ1784", + "FJ1785", + "FJ1786", + "FJ1837", + "FJ1838" + ], + "confidence": "grouped", + "color": [ + 120, + 190, + 140 + ], + "note": "inferior, middle, fusiform, parahippocampal gyri and the anterior superior temporal gyrus" + }, + { + "key": "occipital-lobe", + "name": "Occipital lobe", + "aliases": [ + "visual cortex" + ], + "nodes": [ + "FJ1791", + "FJ1792" + ], + "confidence": "atlas", + "color": [ + 130, + 150, + 226 + ] + }, + { + "key": "insula", + "name": "Insula", + "aliases": [], + "nodes": [ + "FJ1748", + "FJ1749" + ], + "confidence": "atlas", + "color": [ + 210, + 130, + 170 + ] + }, + { + "key": "cingulate-gyrus", + "name": "Cingulate gyrus", + "aliases": [], + "nodes": [ + "FJ1739", + "FJ1740" + ], + "confidence": "atlas", + "color": [ + 190, + 120, + 200 + ] + }, + { + "key": "cerebellum", + "name": "Cerebellum", + "aliases": [], + "nodes": [ + "FJ1781", + "FJ1830" + ], + "confidence": "atlas", + "color": [ + 150, + 120, + 190 + ] + }, + { + "key": "pons", + "name": "Pons", + "aliases": [], + "nodes": [ + "FJ1775", + "FJ1822" + ], + "confidence": "atlas", + "color": [ + 200, + 160, + 140 + ] + }, + { + "key": "medulla-oblongata", + "name": "Medulla oblongata", + "aliases": [ + "medulla" + ], + "nodes": [ + "FJ1769", + "FJ1831" + ], + "confidence": "atlas", + "color": [ + 214, + 176, + 150 + ] + }, + { + "key": "midbrain", + "name": "Midbrain", + "aliases": [], + "nodes": [ + "FJ1770", + "FJ1817" + ], + "confidence": "atlas", + "color": [ + 184, + 150, + 130 + ] + }, + { + "key": "thalamus", + "name": "Thalamus", + "aliases": [], + "nodes": [ + "FJ1782", + "FJ1827" + ], + "confidence": "atlas", + "color": [ + 226, + 120, + 120 + ] + }, + { + "key": "hypothalamus", + "name": "Hypothalamus", + "aliases": [], + "nodes": [ + "FJ1760", + "FJ1808" + ], + "confidence": "atlas", + "color": [ + 240, + 160, + 100 + ] + }, + { + "key": "hippocampus", + "name": "Hippocampus", + "aliases": [], + "nodes": [ + "FJ1759", + "FJ1807" + ], + "confidence": "atlas", + "color": [ + 100, + 180, + 200 + ] + }, + { + "key": "amygdala", + "name": "Amygdala", + "aliases": [], + "nodes": [ + "FJ1753", + "FJ1829" + ], + "confidence": "atlas", + "color": [ + 240, + 110, + 150 + ] + }, + { + "key": "caudate-nucleus", + "name": "Caudate nucleus", + "aliases": [], + "nodes": [ + "FJ1754", + "FJ1802" + ], + "confidence": "atlas", + "color": [ + 120, + 170, + 230 + ] + }, + { + "key": "globus-pallidus", + "name": "Globus pallidus", + "aliases": [], + "nodes": [ + "FJ1757", + "FJ1805" + ], + "confidence": "atlas", + "color": [ + 150, + 200, + 120 + ] + }, + { + "key": "corpus-callosum", + "name": "Corpus callosum", + "aliases": [], + "nodes": [ + "FJ1742" + ], + "confidence": "atlas", + "color": [ + 240, + 232, + 214 + ] + }, + { + "key": "cerebral-white-matter", + "name": "Cerebral white matter", + "aliases": [ + "white matter" + ], + "nodes": [ + "FJ1758", + "FJ1806" + ], + "confidence": "atlas", + "color": [ + 236, + 226, + 206 + ] + }, + { + "key": "lateral-ventricles", + "name": "Lateral ventricles", + "aliases": [ + "ventricles" + ], + "nodes": [ + "FJ1767", + "FJ1814" + ], + "confidence": "atlas", + "color": [ + 90, + 150, + 240 + ], + "closed": true + }, + { + "key": "pituitary-gland", + "name": "Pituitary gland", + "aliases": [ + "pituitary" + ], + "nodes": [ + "FJ1796" + ], + "confidence": "atlas", + "color": [ + 250, + 200, + 90 + ] + } + ], + "files": [ + { + "id": "FJ1833", + "entry": "isa_BP3D_4.0_obj_99/FJ1833.obj", + "bytes": 432276, + "sha256": "b1705a60646438f5c1bd8d215c738f90e7aed9c9360a8ab94993a1e6b5649851" + }, + { + "id": "FJ1834", + "entry": "isa_BP3D_4.0_obj_99/FJ1834.obj", + "bytes": 437650, + "sha256": "505aff0f5fba6160aa273af517d8ef9f9e4d7bd6ee904e2739ccf41f8d7af441" + }, + { + "id": "FJ1787", + "entry": "isa_BP3D_4.0_obj_99/FJ1787.obj", + "bytes": 226086, + "sha256": "de3c1098d95fc81060b72603e72a4a2a55529b0fb82063dbd0dfc4f3955d720c" + }, + { + "id": "FJ1788", + "entry": "isa_BP3D_4.0_obj_99/FJ1788.obj", + "bytes": 224095, + "sha256": "216015b568cc446ae3e7c2ad256f47a352479a6e36c0df025cde311e913fde0c" + }, + { + "id": "FJ1744", + "entry": "isa_BP3D_4.0_obj_99/FJ1744.obj", + "bytes": 218647, + "sha256": "3de90fe338da50f60859e591089e5882cf8ce2df2d0e4acbfc5dae7364c184a5" + }, + { + "id": "FJ1745", + "entry": "isa_BP3D_4.0_obj_99/FJ1745.obj", + "bytes": 220234, + "sha256": "b3eafbe2d1289be8c24dde82d8a5475f86a13cb6bcc7d5dbc0b4cfcb2d340132" + }, + { + "id": "FJ1800", + "entry": "isa_BP3D_4.0_obj_99/FJ1800.obj", + "bytes": 270175, + "sha256": "9f375219acb0aed075860e5afe3562be19bde6061a007d3096d52f96aa59e944" + }, + { + "id": "FJ1801", + "entry": "isa_BP3D_4.0_obj_99/FJ1801.obj", + "bytes": 274741, + "sha256": "89e9017a488f4854ef4daaa5488bbe0bada8aed4cd81352553305beda8caef85" + }, + { + "id": "FJ1793", + "entry": "isa_BP3D_4.0_obj_99/FJ1793.obj", + "bytes": 179022, + "sha256": "b47d45c7f6a419e69a9c5b6af00b80cc4f1269593a260e34b662b850801e354c" + }, + { + "id": "FJ1794", + "entry": "isa_BP3D_4.0_obj_99/FJ1794.obj", + "bytes": 173187, + "sha256": "8fe535cdf4054a6a395ea2250e1c66719d551818eaf96802a4c7883af00a8170" + }, + { + "id": "FJ1797", + "entry": "isa_BP3D_4.0_obj_99/FJ1797.obj", + "bytes": 236182, + "sha256": "e05f6ec80fa902f5334cc5e8c029359674d39c39a90f86476a6d1d190ca1f30a" + }, + { + "id": "FJ1798", + "entry": "isa_BP3D_4.0_obj_99/FJ1798.obj", + "bytes": 238993, + "sha256": "ce476b98e79e988bbf2efa1b8593019d0cc64114cf455d00347ed6e95ee5f037" + }, + { + "id": "FJ1841", + "entry": "isa_BP3D_4.0_obj_99/FJ1841.obj", + "bytes": 149885, + "sha256": "895a1e9e5eaed7443d9fe9544fefede9db219aaf38d30a4674cde778e1bdfb8e" + }, + { + "id": "FJ1842", + "entry": "isa_BP3D_4.0_obj_99/FJ1842.obj", + "bytes": 152420, + "sha256": "374934ec8c016aec1aae2cad47d80b1d2668354cc890b0227a0b102c9b3b4469" + }, + { + "id": "FJ1732", + "entry": "isa_BP3D_4.0_obj_99/FJ1732.obj", + "bytes": 236788, + "sha256": "d24f6c5647b751706d3f7c4dd4b62518fb3e9cd281ed7d2a2437fafbbcd0e1b3" + }, + { + "id": "FJ1733", + "entry": "isa_BP3D_4.0_obj_99/FJ1733.obj", + "bytes": 239530, + "sha256": "a8e5d63d28890e42861f2b1c4c7b898dba84b169507315d77e9ebeb2433171e9" + }, + { + "id": "FJ1835", + "entry": "isa_BP3D_4.0_obj_99/FJ1835.obj", + "bytes": 366912, + "sha256": "6d1cc1963191120c07eb557c728b4cd00ccf63467b3858a408a6b5ba4564719c" + }, + { + "id": "FJ1836", + "entry": "isa_BP3D_4.0_obj_99/FJ1836.obj", + "bytes": 383555, + "sha256": "e3291cc04dcdc3743d8fe67951d2b1589294062d116873515194e0c6c979c770" + }, + { + "id": "FJ1746", + "entry": "isa_BP3D_4.0_obj_99/FJ1746.obj", + "bytes": 177780, + "sha256": "aefe572e69d8b7687b29644b0a855ced4e64b255f1cb3ca0e6640cab7292d132" + }, + { + "id": "FJ1747", + "entry": "isa_BP3D_4.0_obj_99/FJ1747.obj", + "bytes": 182921, + "sha256": "dd358cac91394ee511250be17f7a0184defecb23a19b921388fb267e23132195" + }, + { + "id": "FJ1789", + "entry": "isa_BP3D_4.0_obj_99/FJ1789.obj", + "bytes": 174631, + "sha256": "52396a1feaedfb7f8f1a334dd02acb35f2897362b0f1a37658edc4e69556db6d" + }, + { + "id": "FJ1790", + "entry": "isa_BP3D_4.0_obj_99/FJ1790.obj", + "bytes": 179357, + "sha256": "f2c8ba988026b991559d5195a702675a0a222e9a03711dcb127a909f18ae0fb4" + }, + { + "id": "FJ1783", + "entry": "isa_BP3D_4.0_obj_99/FJ1783.obj", + "bytes": 96372, + "sha256": "f0cc5fbc23f9846e881e91cb2221e691694895c7584506d560aca48324d079b5" + }, + { + "id": "FJ1784", + "entry": "isa_BP3D_4.0_obj_99/FJ1784.obj", + "bytes": 101913, + "sha256": "ecfd67d495a6f5f3bf391f2455f124edf444122d79299fb8fa0b01493e450f29" + }, + { + "id": "FJ1785", + "entry": "isa_BP3D_4.0_obj_99/FJ1785.obj", + "bytes": 47143, + "sha256": "d328f96770816958f290e2461214dd52c38d3e7395d113eed55ba6065ec76c37" + }, + { + "id": "FJ1786", + "entry": "isa_BP3D_4.0_obj_99/FJ1786.obj", + "bytes": 54449, + "sha256": "2453959db95754c9f3fe6dbe435bbcff98e79f6bbd77c12f1d063c30941fa05f" + }, + { + "id": "FJ1837", + "entry": "isa_BP3D_4.0_obj_99/FJ1837.obj", + "bytes": 114207, + "sha256": "2fb61c24b880e134ff2034558fa6abbfcbcd8506b0aca18ee2cc844fa6783de6" + }, + { + "id": "FJ1838", + "entry": "isa_BP3D_4.0_obj_99/FJ1838.obj", + "bytes": 120477, + "sha256": "342678a0d5a35ca049870e95536c19b9d66915c7f636f0b738162e5db833746b" + }, + { + "id": "FJ1791", + "entry": "isa_BP3D_4.0_obj_99/FJ1791.obj", + "bytes": 293610, + "sha256": "d504be1cf6f085be1b885b31ac3b1fb1a1fc475855aeda56baa142a600911fe5" + }, + { + "id": "FJ1792", + "entry": "isa_BP3D_4.0_obj_99/FJ1792.obj", + "bytes": 307991, + "sha256": "e9e4bb82648576fbe6256992771f0ab0917cfea10d15325c86869283573a64ad" + }, + { + "id": "FJ1748", + "entry": "isa_BP3D_4.0_obj_99/FJ1748.obj", + "bytes": 148027, + "sha256": "b7553aaa8a282d5882d9d2809f5fedd7b35ef50710773ac103cfa82f9f184245" + }, + { + "id": "FJ1749", + "entry": "isa_BP3D_4.0_obj_99/FJ1749.obj", + "bytes": 150490, + "sha256": "0c8e4e39ba935c4f5b24168b46c99782057ba73379844173de56c60210b45c72" + }, + { + "id": "FJ1739", + "entry": "isa_BP3D_4.0_obj_99/FJ1739.obj", + "bytes": 154389, + "sha256": "0926a6839371b0179bbf7d0040b3925f338995be63d18fc1b176721db12c82d3" + }, + { + "id": "FJ1740", + "entry": "isa_BP3D_4.0_obj_99/FJ1740.obj", + "bytes": 151331, + "sha256": "9e8c3b086c0cd15b9f85189b37529c6d044c153cbd3f16c678a5b79d02efb656" + }, + { + "id": "FJ1781", + "entry": "isa_BP3D_4.0_obj_99/FJ1781.obj", + "bytes": 1579646, + "sha256": "47003d37cf123dc10b108bb79a2b12638a56f0f2616d0d1f58b727af88d1ec53" + }, + { + "id": "FJ1830", + "entry": "isa_BP3D_4.0_obj_99/FJ1830.obj", + "bytes": 1598659, + "sha256": "585176d67d072ead00bab6b4d0ca42a151ace76bed1c20c1aeed22b8b4c57ac1" + }, + { + "id": "FJ1775", + "entry": "isa_BP3D_4.0_obj_99/FJ1775.obj", + "bytes": 697135, + "sha256": "d24253c225545078ce9c4420880dc5652e20fb2576a6305a9fadc18f95fba9dd" + }, + { + "id": "FJ1822", + "entry": "isa_BP3D_4.0_obj_99/FJ1822.obj", + "bytes": 727798, + "sha256": "474dffce10e8506b5f8a7aac5d6ccfc7ef6251490b36b5f04a7fa2676b7fb708" + }, + { + "id": "FJ1769", + "entry": "isa_BP3D_4.0_obj_99/FJ1769.obj", + "bytes": 392219, + "sha256": "cc1cd37ef3f58fea9ffe8875efa3a33101ee6945dd13bdb28c973303a9986fbd" + }, + { + "id": "FJ1831", + "entry": "isa_BP3D_4.0_obj_99/FJ1831.obj", + "bytes": 401304, + "sha256": "7c19ec386aadaafdae3dab8aa99c08d5db47fa063f689e99ee7e9cdf0bdbeda9" + }, + { + "id": "FJ1770", + "entry": "isa_BP3D_4.0_obj_99/FJ1770.obj", + "bytes": 468005, + "sha256": "6e7eb027702dc4097aa0b2abe46efcffcd1f5e108b1665a649b45420b98229e9" + }, + { + "id": "FJ1817", + "entry": "isa_BP3D_4.0_obj_99/FJ1817.obj", + "bytes": 461102, + "sha256": "b86a8f1ce035a5ec382122a210f86239c581a5478f2b1b5f377b021542981f2e" + }, + { + "id": "FJ1782", + "entry": "isa_BP3D_4.0_obj_99/FJ1782.obj", + "bytes": 100051, + "sha256": "6e6e87e4feda05756e8748a61febdb2fe61d4ba834fd5a57d805512d9fcd82cc" + }, + { + "id": "FJ1827", + "entry": "isa_BP3D_4.0_obj_99/FJ1827.obj", + "bytes": 44651, + "sha256": "a4b5be59d7cf6dc3ca1b2ae97a83ffd947e39493cc663c2cb7d65a064af91b1d" + }, + { + "id": "FJ1760", + "entry": "isa_BP3D_4.0_obj_99/FJ1760.obj", + "bytes": 132131, + "sha256": "aec134edcffcaea082eaebc3a01fe84700893fcc8cba5868b1ade6a721f530bf" + }, + { + "id": "FJ1808", + "entry": "isa_BP3D_4.0_obj_99/FJ1808.obj", + "bytes": 131989, + "sha256": "122de5cfac67f779f911876ea1faca1fb9546327b1a1654d395f571f711772f7" + }, + { + "id": "FJ1759", + "entry": "isa_BP3D_4.0_obj_99/FJ1759.obj", + "bytes": 57341, + "sha256": "d841b56aabfe6785a3b2892de1af5f2f52d87d13b8928d3d2fdf028b9640994d" + }, + { + "id": "FJ1807", + "entry": "isa_BP3D_4.0_obj_99/FJ1807.obj", + "bytes": 60478, + "sha256": "76ef76851cf014d1e090f63328963dad9041cf10f20066eb1e92e4619f700c30" + }, + { + "id": "FJ1753", + "entry": "isa_BP3D_4.0_obj_99/FJ1753.obj", + "bytes": 22629, + "sha256": "1a557cc879fa71c1e5a5681caf4e7506418c479c29171b48a959a1d5a69e1425" + }, + { + "id": "FJ1829", + "entry": "isa_BP3D_4.0_obj_99/FJ1829.obj", + "bytes": 22898, + "sha256": "f53fab3de8ac6b90a2c956e8ccac9b949d9adc32b843070712f12c9ad1b18e92" + }, + { + "id": "FJ1754", + "entry": "isa_BP3D_4.0_obj_99/FJ1754.obj", + "bytes": 156733, + "sha256": "c94a8fe0da8cd1ddb916a4f871b017a82bf1dbe5a60307cbc36baa9bf23324ec" + }, + { + "id": "FJ1802", + "entry": "isa_BP3D_4.0_obj_99/FJ1802.obj", + "bytes": 159115, + "sha256": "1139f3e7002704a0efcc1c9161ef2b84e60f28c18728e24664454451ae30bb17" + }, + { + "id": "FJ1757", + "entry": "isa_BP3D_4.0_obj_99/FJ1757.obj", + "bytes": 448013, + "sha256": "f1519d79c632403ab669d8ffa8f6c72ce50dc57bc58b3fa54b155f292db20488" + }, + { + "id": "FJ1805", + "entry": "isa_BP3D_4.0_obj_99/FJ1805.obj", + "bytes": 338283, + "sha256": "c89453826d4617211ca58a6ce11bc63904a571d594d3d073cfb3a53c7672a9be" + }, + { + "id": "FJ1742", + "entry": "isa_BP3D_4.0_obj_99/FJ1742.obj", + "bytes": 2128770, + "sha256": "3f46359c2a23499ac130bd27646309f7974d216f9d55320b503e3b0844da9a70" + }, + { + "id": "FJ1758", + "entry": "isa_BP3D_4.0_obj_99/FJ1758.obj", + "bytes": 1837827, + "sha256": "eb5e61b574f6962ad949427b11d97055553d6e1175ac926164f7f5402d43e5bc" + }, + { + "id": "FJ1806", + "entry": "isa_BP3D_4.0_obj_99/FJ1806.obj", + "bytes": 1922977, + "sha256": "89ef94f2f907f9da109e55c1a6a7a59ef7118555fa0d39e02ef37f1f69c26e98" + }, + { + "id": "FJ1767", + "entry": "isa_BP3D_4.0_obj_99/FJ1767.obj", + "bytes": 1158407, + "sha256": "8491961042556b62e2570c8e8dec8fe9269908abb34aa738ba7613489acd7838" + }, + { + "id": "FJ1814", + "entry": "isa_BP3D_4.0_obj_99/FJ1814.obj", + "bytes": 1168390, + "sha256": "5a0c29cf5c573d35f225df3c96c66cc34eb166fde8e54323b3c22b6f2220248b" + }, + { + "id": "FJ1796", + "entry": "isa_BP3D_4.0_obj_99/FJ1796.obj", + "bytes": 70119, + "sha256": "e79b1a41d81d066e798dcda7f73f7ffd58741adfbd709d47baacccb2fabfcce0" + } + ], + "built": { + "file": "brain.glb", + "bytes": 8358176, + "sha256": "0d353d478830dff8e6fac252909c2e236229932336e63eb8a7665179b2f914d1", + "triangles": 347340, + "size": [ + 0.138834, + 0.16596, + 0.180006 + ], + "parts": { + "frontal-lobe": { + "center": [ + -0.000109, + 0.03463, + 0.024801 + ], + "size": [ + 0.127036, + 0.0967, + 0.130404 + ], + "closed": true, + "triangles": 39628 + }, + "parietal-lobe": { + "center": [ + 0.000064, + 0.03401, + -0.038944 + ], + "size": [ + 0.138492, + 0.0844, + 0.094374 + ], + "closed": true, + "triangles": 30012 + }, + "temporal-lobe": { + "center": [ + 0, + -0.004345, + -0.008636 + ], + "size": [ + 0.138834, + 0.05927, + 0.114089 + ], + "closed": true, + "triangles": 19458 + }, + "occipital-lobe": { + "center": [ + -0.000125, + -0.00283, + -0.058363 + ], + "size": [ + 0.088351, + 0.05382, + 0.063281 + ], + "closed": true, + "triangles": 8954 + }, + "insula": { + "center": [ + -0.000132, + 0.015335, + 0.016858 + ], + "size": [ + 0.08987, + 0.03457, + 0.051781 + ], + "closed": true, + "triangles": 4896 + }, + "cingulate-gyrus": { + "center": [ + -0.000119, + 0.016425, + 0.006743 + ], + "size": [ + 0.057946, + 0.06665, + 0.111379 + ], + "closed": true, + "triangles": 4762 + }, + "cerebellum": { + "center": [ + -0.000137, + -0.033605, + -0.039354 + ], + "size": [ + 0.10654, + 0.05327, + 0.056292 + ], + "closed": true, + "triangles": 47700 + }, + "pons": { + "center": [ + -0.000128, + -0.0311, + 0.00011 + ], + "size": [ + 0.042197, + 0.02862, + 0.034406 + ], + "closed": true, + "triangles": 20650 + }, + "medulla-oblongata": { + "center": [ + -0.00013, + -0.06234, + -0.011835 + ], + "size": [ + 0.026734, + 0.04128, + 0.0332 + ], + "closed": true, + "triangles": 12096 + }, + "midbrain": { + "center": [ + -0.000132, + -0.01047, + 0.001592 + ], + "size": [ + 0.029333, + 0.01704, + 0.029371 + ], + "closed": true, + "triangles": 12908 + }, + "thalamus": { + "center": [ + -0.000092, + 0.00643, + 0.000427 + ], + "size": [ + 0.047979, + 0.02368, + 0.036589 + ], + "closed": true, + "triangles": 2460 + }, + "hypothalamus": { + "center": [ + -0.00013, + -0.005315, + 0.021533 + ], + "size": [ + 0.015228, + 0.01987, + 0.017941 + ], + "closed": true, + "triangles": 4078 + }, + "hippocampus": { + "center": [ + -0.000129, + -0.007235, + 0.001233 + ], + "size": [ + 0.074507, + 0.02199, + 0.042922 + ], + "closed": true, + "triangles": 2000 + }, + "amygdala": { + "center": [ + -0.000097, + -0.00912, + 0.018688 + ], + "size": [ + 0.068013, + 0.01286, + 0.018457 + ], + "closed": true, + "triangles": 766 + }, + "caudate-nucleus": { + "center": [ + -0.000139, + 0.011325, + 0.012475 + ], + "size": [ + 0.068694, + 0.03709, + 0.063585 + ], + "closed": true, + "triangles": 5114 + }, + "globus-pallidus": { + "center": [ + -0.000129, + 0.00748, + 0.015189 + ], + "size": [ + 0.059349, + 0.0173, + 0.029279 + ], + "closed": true, + "triangles": 12424 + }, + "corpus-callosum": { + "center": [ + -0.000135, + 0.016355, + 0.005571 + ], + "size": [ + 0.051806, + 0.03885, + 0.091623 + ], + "closed": true, + "triangles": 30232 + }, + "cerebral-white-matter": { + "center": [ + -0.000144, + 0.024975, + 0.001254 + ], + "size": [ + 0.126252, + 0.10109, + 0.163222 + ], + "closed": true, + "triangles": 52054 + }, + "lateral-ventricles": { + "center": [ + -0.000131, + 0.007345, + -0.0074 + ], + "size": [ + 0.077503, + 0.04903, + 0.109333 + ], + "closed": true, + "triangles": 35984 + }, + "pituitary-gland": { + "center": [ + -0.000112, + -0.018425, + 0.02616 + ], + "size": [ + 0.012311, + 0.01297, + 0.009458 + ], + "closed": true, + "triangles": 1164 + } + } + } +} diff --git a/assets/models/heart.json b/assets/models/heart.json new file mode 100644 index 00000000..6ccb0134 --- /dev/null +++ b/assets/models/heart.json @@ -0,0 +1,1210 @@ +{ + "id": "heart", + "name": "Human heart", + "aliases": [ + "heart", + "human heart", + "cardiac", + "cardiovascular", + "chambers of the heart", + "aorta" + ], + "description": "An adult human heart: four chambers, valves, papillary muscles, great vessels and coronary arteries, as separate named parts.", + "source": { + "name": "BodyParts3D", + "url": "https://dbarchive.biosciencedbc.jp/en/bodyparts3d/", + "archive": { + "url": "https://dbarchive.biosciencedbc.jp/data/bodyparts3d/LATEST/isa_BP3D_4.0_obj_99.zip", + "bytes": 142903898, + "folder": "isa_BP3D_4.0_obj_99" + }, + "version": "4.0, polygon reduction 99 percent (archive of 2013-05-22; README and licence of 2025-02-27)", + "format": "obj" + }, + "licence": { + "id": "CC-BY-4.0", + "version": "4.0 International", + "url": "https://dbarchive.biosciencedbc.jp/en/bodyparts3d/lic.html", + "evidence": { + "page": "https://dbarchive.biosciencedbc.jp/en/bodyparts3d/lic.html", + "updated": "2025-02-27", + "retrieved": "2026-11-08", + "sha256": "6ab56d4702c16d52ec54c7635cef25e7b488771ae9539717afd87327c09ed842" + }, + "note": "The database licence page (updated 2025-02-27) and README name CC BY 4.0 International and the credit line given here. The OBJ files in the 2013 archive still carry an older header naming CC Attribution-Share Alike 2.1 Japan; the current statement of the licensor is followed here, and the files are converted without their header." + }, + "credit": "BodyParts3D, © The Database Center for Life Science, licensed under CC Attribution 4.0 International (https://creativecommons.org/licenses/by/4.0/)", + "changes": "Files converted from OBJ to glTF, millimetres to metres, axes turned to y up and the front toward the viewer, parts recentred on themselves; a file may be merged with others into one named part. Duplicate vertices were welded and smooth normals computed; no shape was edited.", + "orient": { + "up": "z+", + "front": "y-", + "note": "source axes: x toward the left of the body, y toward the back, z toward the head (README, coordinate system)" + }, + "scale": { + "unitsToMetres": 0.001, + "realLengthMetres": 0.12, + "realLengthOf": "the heart, apex to base (about 12 cm)" + }, + "caveats": [ + "The atlas has no mesh for the ventricular wall or the pericardium: the chambers are drawn as their blood-filled cavities, so a cut shows cavities, valves and vessels, not a wall.", + "The pulmonary veins, the branches of the pulmonary arteries and the inferior vena cava (its mesh runs 24 cm into the abdomen) are not included." + ], + "parts": [ + { + "key": "right-atrium", + "name": "Right atrium", + "aliases": [ + "atrium right" + ], + "nodes": [ + "FJ2424" + ], + "confidence": "atlas", + "color": [ + 92, + 132, + 230 + ], + "closed": true, + "note": "cavity of the right atrium" + }, + { + "key": "right-atrium-wall", + "name": "Wall of the right atrium", + "aliases": [], + "nodes": [ + "FJ2439" + ], + "confidence": "atlas", + "color": [ + 200, + 120, + 130 + ] + }, + { + "key": "left-atrium", + "name": "Left atrium", + "aliases": [ + "atrium left" + ], + "nodes": [ + "FJ2425" + ], + "confidence": "atlas", + "color": [ + 226, + 86, + 96 + ], + "closed": true, + "note": "cavity of the left atrium" + }, + { + "key": "left-atrium-wall", + "name": "Wall of the left atrium", + "aliases": [], + "nodes": [ + "FJ2438" + ], + "confidence": "atlas", + "color": [ + 200, + 120, + 130 + ] + }, + { + "key": "right-ventricle", + "name": "Right ventricle", + "aliases": [ + "ventricle right" + ], + "nodes": [ + "FJ2423" + ], + "confidence": "atlas", + "color": [ + 86, + 124, + 222 + ], + "closed": true, + "note": "cavity of the right ventricle" + }, + { + "key": "left-ventricle", + "name": "Left ventricle", + "aliases": [ + "ventricle left" + ], + "nodes": [ + "FJ2422" + ], + "confidence": "atlas", + "color": [ + 222, + 76, + 88 + ], + "closed": true, + "note": "cavity of the left ventricle" + }, + { + "key": "mitral-valve", + "name": "Mitral valve", + "aliases": [ + "bicuspid valve" + ], + "nodes": [ + "FJ2420", + "FJ2432" + ], + "confidence": "grouped", + "color": [ + 238, + 226, + 196 + ], + "note": "anterior and posterior leaflets" + }, + { + "key": "tricuspid-valve", + "name": "Tricuspid valve", + "aliases": [], + "nodes": [ + "FJ2421", + "FJ2433", + "FJ2436" + ], + "confidence": "grouped", + "color": [ + 238, + 226, + 196 + ], + "note": "anterior, posterior and septal leaflets" + }, + { + "key": "aortic-valve", + "name": "Aortic valve", + "aliases": [], + "nodes": [ + "FJ2435", + "FJ2426", + "FJ2431" + ], + "confidence": "grouped", + "color": [ + 238, + 226, + 196 + ], + "note": "three cusps" + }, + { + "key": "pulmonary-valve", + "name": "Pulmonary valve", + "aliases": [ + "pulmonic valve" + ], + "nodes": [ + "FJ2417", + "FJ2427", + "FJ2434" + ], + "confidence": "grouped", + "color": [ + 238, + 226, + 196 + ], + "note": "three cusps" + }, + { + "key": "papillary-muscles", + "name": "Papillary muscles", + "aliases": [ + "papillary muscle" + ], + "nodes": [ + "FJ2418", + "FJ2419", + "FJ2429", + "FJ2430", + "FJ2437" + ], + "confidence": "grouped", + "color": [ + 170, + 70, + 80 + ] + }, + { + "key": "ascending-aorta", + "name": "Ascending aorta", + "aliases": [ + "aorta" + ], + "nodes": [ + "FJ3413" + ], + "confidence": "atlas", + "color": [ + 214, + 82, + 82 + ], + "closed": false + }, + { + "key": "aortic-arch", + "name": "Arch of the aorta", + "aliases": [ + "aortic arch" + ], + "nodes": [ + "FJ3411" + ], + "confidence": "atlas", + "color": [ + 214, + 82, + 82 + ], + "closed": false + }, + { + "key": "pulmonary-trunk", + "name": "Pulmonary trunk", + "aliases": [ + "pulmonary artery" + ], + "nodes": [ + "FJ2966" + ], + "confidence": "atlas", + "color": [ + 92, + 128, + 226 + ], + "closed": false + }, + { + "key": "superior-vena-cava", + "name": "Superior vena cava", + "aliases": [ + "vena cava" + ], + "nodes": [ + "FJ3645" + ], + "confidence": "atlas", + "color": [ + 92, + 128, + 226 + ], + "closed": false + }, + { + "key": "left-coronary-artery", + "name": "Left coronary artery and its branches", + "aliases": [ + "coronary artery", + "coronary arteries" + ], + "nodes": [ + "FJ2737", + "FJ2631", + "FJ2632", + "FJ2633", + "FJ2634", + "FJ2635", + "FJ2636", + "FJ2637", + "FJ2638", + "FJ2639", + "FJ2640", + "FJ2641", + "FJ2642", + "FJ2643", + "FJ2644", + "FJ2645", + "FJ2646", + "FJ2647", + "FJ2648", + "FJ2649", + "FJ2650", + "FJ2651", + "FJ2652", + "FJ2653", + "FJ2654" + ], + "confidence": "grouped", + "color": [ + 236, + 150, + 60 + ], + "closed": false + }, + { + "key": "right-coronary-artery", + "name": "Right coronary artery and its branches", + "aliases": [], + "nodes": [ + "FJ2723", + "FJ2667", + "FJ2668", + "FJ2670", + "FJ2671", + "FJ2672", + "FJ2673", + "FJ2674", + "FJ2675", + "FJ2676", + "FJ2677", + "FJ2692", + "FJ2693", + "FJ2694", + "FJ2695", + "FJ2696", + "FJ2697", + "FJ2698", + "FJ2699", + "FJ2700", + "FJ2714", + "FJ2715", + "FJ2716", + "FJ2717", + "FJ2718", + "FJ2719", + "FJ2720", + "FJ2721", + "FJ2722" + ], + "confidence": "grouped", + "color": [ + 236, + 170, + 70 + ], + "closed": false + }, + { + "key": "cardiac-veins", + "name": "Cardiac veins", + "aliases": [ + "coronary sinus" + ], + "nodes": [ + "FJ2655", + "FJ2656", + "FJ2724", + "FJ2727", + "FJ2728", + "FJ2729", + "FJ2731" + ], + "confidence": "grouped", + "color": [ + 110, + 120, + 200 + ], + "closed": false + } + ], + "files": [ + { + "id": "FJ2424", + "entry": "isa_BP3D_4.0_obj_99/FJ2424.obj", + "bytes": 139097, + "sha256": "53739664c1d4a5bb635ca48c216b54deb16bb947d76a4ad75635adf69c8fa11c" + }, + { + "id": "FJ2439", + "entry": "isa_BP3D_4.0_obj_99/FJ2439.obj", + "bytes": 1211683, + "sha256": "6e87510c607541b53b124f8224b6be74cb9b7351e29102246053b30a7260d8dd" + }, + { + "id": "FJ2425", + "entry": "isa_BP3D_4.0_obj_99/FJ2425.obj", + "bytes": 65824, + "sha256": "d93197cc47f47d6d084de017917c88de039a4ab632b421893cede03264f43384" + }, + { + "id": "FJ2438", + "entry": "isa_BP3D_4.0_obj_99/FJ2438.obj", + "bytes": 510077, + "sha256": "ad28c5925374c6648bafb77ac9a89163316c101559cb730906208c96266ae078" + }, + { + "id": "FJ2423", + "entry": "isa_BP3D_4.0_obj_99/FJ2423.obj", + "bytes": 113621, + "sha256": "f0d7cbf9e10c0fcefe96741700605e7080d4a627fe214b4c8d5647d970e085f7" + }, + { + "id": "FJ2422", + "entry": "isa_BP3D_4.0_obj_99/FJ2422.obj", + "bytes": 102171, + "sha256": "8844c5fc464d23fdc785d1d254d666a4d3b70b14b73ec90ca0c77ba4aff3dd37" + }, + { + "id": "FJ2420", + "entry": "isa_BP3D_4.0_obj_99/FJ2420.obj", + "bytes": 495300, + "sha256": "f0294cbbd35096d1df5e8bdc92f17dbed5ebf981e62024a07e7ca18e31eb1a94" + }, + { + "id": "FJ2432", + "entry": "isa_BP3D_4.0_obj_99/FJ2432.obj", + "bytes": 274620, + "sha256": "0b296151ecceff395da5c435bcf65cf6dfca390e72eb0be71d778fee84bc216b" + }, + { + "id": "FJ2421", + "entry": "isa_BP3D_4.0_obj_99/FJ2421.obj", + "bytes": 532771, + "sha256": "7303c55e6d9c2e294759f7f7e01d23fc120eba74bce9ade0a01cc4bdb2bd4200" + }, + { + "id": "FJ2433", + "entry": "isa_BP3D_4.0_obj_99/FJ2433.obj", + "bytes": 325359, + "sha256": "6519afbf9aa2eb3c0dc25d8e332a0208fd2ad68956c1dfe1ef6b010f04984d55" + }, + { + "id": "FJ2436", + "entry": "isa_BP3D_4.0_obj_99/FJ2436.obj", + "bytes": 302591, + "sha256": "f0572079c56ea2a00eff869b07c4910defd624c5bda3fddd2403e4f1831f6be1" + }, + { + "id": "FJ2435", + "entry": "isa_BP3D_4.0_obj_99/FJ2435.obj", + "bytes": 56513, + "sha256": "b498ef286aa1ba0bfeaf2114298f43078007beab66fc81f422ff6017c309bd7a" + }, + { + "id": "FJ2426", + "entry": "isa_BP3D_4.0_obj_99/FJ2426.obj", + "bytes": 57407, + "sha256": "86fa5ef6decf47a91d33f826e1b5579bbecd94795c206b2d797f52c36c3e1020" + }, + { + "id": "FJ2431", + "entry": "isa_BP3D_4.0_obj_99/FJ2431.obj", + "bytes": 21434, + "sha256": "40ae6e23decbb5fe2ea3800d44d517302f219078266abd8dcbc7d86ebc246799" + }, + { + "id": "FJ2417", + "entry": "isa_BP3D_4.0_obj_99/FJ2417.obj", + "bytes": 78664, + "sha256": "12d2dccc78efa7d21f6f4af53ae08603be473613ec4e04b0beb9c0239b96da56" + }, + { + "id": "FJ2427", + "entry": "isa_BP3D_4.0_obj_99/FJ2427.obj", + "bytes": 62530, + "sha256": "eb867fa648f3da04036d925e6a740d4e3a922b893d74a20dec40d8d763a18414" + }, + { + "id": "FJ2434", + "entry": "isa_BP3D_4.0_obj_99/FJ2434.obj", + "bytes": 85105, + "sha256": "ed432a90e8fbfe9742d524044c0bd20c165f2a9a820ee585f00635cc47c5b5c0" + }, + { + "id": "FJ2418", + "entry": "isa_BP3D_4.0_obj_99/FJ2418.obj", + "bytes": 54778, + "sha256": "ad6dbf98d5afb2dd5010c42df9d707bf172b0ecc4f6e22c70716d022660aadc8" + }, + { + "id": "FJ2419", + "entry": "isa_BP3D_4.0_obj_99/FJ2419.obj", + "bytes": 59575, + "sha256": "1169b9b927ff75aac2dc2406a700b962bb9f3c95b860c5271548414d9e1226da" + }, + { + "id": "FJ2429", + "entry": "isa_BP3D_4.0_obj_99/FJ2429.obj", + "bytes": 51282, + "sha256": "2f02411a806eedacfcb662b2dee47ca60f8448eb5243f48fb32083df66541ca4" + }, + { + "id": "FJ2430", + "entry": "isa_BP3D_4.0_obj_99/FJ2430.obj", + "bytes": 48375, + "sha256": "971ab49fff2908862fc230653f5f0980424e2030ae7f29f7f96637e8b636c4e8" + }, + { + "id": "FJ2437", + "entry": "isa_BP3D_4.0_obj_99/FJ2437.obj", + "bytes": 56351, + "sha256": "8ac0c0aa95adc3f41e82f51bbd8e8a74681f4e58af7f7edd4bc9c5aafffa97c7" + }, + { + "id": "FJ3413", + "entry": "isa_BP3D_4.0_obj_99/FJ3413.obj", + "bytes": 24686, + "sha256": "764f23e432a9308e0780c586f9d1638db1fbcc52a5019ae61817b4b1de323870" + }, + { + "id": "FJ3411", + "entry": "isa_BP3D_4.0_obj_99/FJ3411.obj", + "bytes": 41743, + "sha256": "9eeb5e5a627e8145f03961c661c9c66d8fdc55ed1234d04b84212b87a21d902c" + }, + { + "id": "FJ2966", + "entry": "isa_BP3D_4.0_obj_99/FJ2966.obj", + "bytes": 89640, + "sha256": "7d4fbfbeebdb541b4053e62e6ba9e55bdbc8d1354de8192f94d7c6008812ab3f" + }, + { + "id": "FJ3645", + "entry": "isa_BP3D_4.0_obj_99/FJ3645.obj", + "bytes": 36208, + "sha256": "5cc007c2ea51255df641225630e83ddbf3e5c4545dffe4814b098c9199ceb26c" + }, + { + "id": "FJ2737", + "entry": "isa_BP3D_4.0_obj_99/FJ2737.obj", + "bytes": 12641, + "sha256": "22aa075132e33f9a3d3be135515362b03ab84f12a0d641edde35e260fb2cd65b" + }, + { + "id": "FJ2631", + "entry": "isa_BP3D_4.0_obj_99/FJ2631.obj", + "bytes": 187038, + "sha256": "ca7d8c0c82982ef1c838cd2224650c810adc3e52aaf6b345f0cdb77d7b068c5e" + }, + { + "id": "FJ2632", + "entry": "isa_BP3D_4.0_obj_99/FJ2632.obj", + "bytes": 8543, + "sha256": "74d743ebe7ccb06a69244bccb59789cbb094af1f3b279e24be5541b9d01d2f6c" + }, + { + "id": "FJ2633", + "entry": "isa_BP3D_4.0_obj_99/FJ2633.obj", + "bytes": 32810, + "sha256": "ba9e2eca1abc7946b27b8adb9846f1b626c7cc3e942da1a2cd2301e0c02bcf1f" + }, + { + "id": "FJ2634", + "entry": "isa_BP3D_4.0_obj_99/FJ2634.obj", + "bytes": 14842, + "sha256": "575eec8663acbae025b51ad8fa42dc6229f35d6f5d25673912c76cb59f117aec" + }, + { + "id": "FJ2635", + "entry": "isa_BP3D_4.0_obj_99/FJ2635.obj", + "bytes": 51353, + "sha256": "bc02d461ae79073f21f350b3c9751d7ccb973ea3c74f8c58bc9a2aeafc533281" + }, + { + "id": "FJ2636", + "entry": "isa_BP3D_4.0_obj_99/FJ2636.obj", + "bytes": 28744, + "sha256": "119cc81d1816f1db4c3d64add10efa63c9148e3177b74d10184f7a1e579581e5" + }, + { + "id": "FJ2637", + "entry": "isa_BP3D_4.0_obj_99/FJ2637.obj", + "bytes": 13104, + "sha256": "d4fa7aa9a6e224a3c7fea1264f4d81ea076ec7baaa8b1c8b3da8e1053bbf4e4a" + }, + { + "id": "FJ2638", + "entry": "isa_BP3D_4.0_obj_99/FJ2638.obj", + "bytes": 22808, + "sha256": "bad6520fcbcea112ca400ba5328e52f7b2ff680346b5b2591db2e97394f9b6e5" + }, + { + "id": "FJ2639", + "entry": "isa_BP3D_4.0_obj_99/FJ2639.obj", + "bytes": 11513, + "sha256": "a80ec5085d0430fa9ae5b643042742bb9757cfd23d3f0280e162751b91acda5f" + }, + { + "id": "FJ2640", + "entry": "isa_BP3D_4.0_obj_99/FJ2640.obj", + "bytes": 20309, + "sha256": "7391892f7c4a8ab6165bf17e6e5ba1367267f14b2cf845233456cb5945f31e14" + }, + { + "id": "FJ2641", + "entry": "isa_BP3D_4.0_obj_99/FJ2641.obj", + "bytes": 31770, + "sha256": "0a9b2c86202434b7aa66c2499c680c40c5d3ebce6bc3ef73c927018ff2c81718" + }, + { + "id": "FJ2642", + "entry": "isa_BP3D_4.0_obj_99/FJ2642.obj", + "bytes": 58861, + "sha256": "2f6dbb44742cd505762e3f24eb2ed3e9ed929f7a909ac28db4df68393e098888" + }, + { + "id": "FJ2643", + "entry": "isa_BP3D_4.0_obj_99/FJ2643.obj", + "bytes": 29632, + "sha256": "3ee93d012a24f6fb93c92faa6eb35d918a3875b58cb0dd52ca5e3dc010ee55cf" + }, + { + "id": "FJ2644", + "entry": "isa_BP3D_4.0_obj_99/FJ2644.obj", + "bytes": 20055, + "sha256": "91b7c72f9fd221c63dd14932b7e66a0331e96d1b0aff3bfbec21f12187530467" + }, + { + "id": "FJ2645", + "entry": "isa_BP3D_4.0_obj_99/FJ2645.obj", + "bytes": 22289, + "sha256": "d6dcbc3294545f857df903393a6db47b268e3a97e8a0c87a0ab5bef056469eee" + }, + { + "id": "FJ2646", + "entry": "isa_BP3D_4.0_obj_99/FJ2646.obj", + "bytes": 30477, + "sha256": "4549b2c6a0bf1d15057bd6185fdafbec846deecc464b6cbfb19f7cedb68b815c" + }, + { + "id": "FJ2647", + "entry": "isa_BP3D_4.0_obj_99/FJ2647.obj", + "bytes": 21395, + "sha256": "18044f3caa4b23c89e8ce42555df29326c1ff1bdbf4b52559473dfb8368b040a" + }, + { + "id": "FJ2648", + "entry": "isa_BP3D_4.0_obj_99/FJ2648.obj", + "bytes": 20026, + "sha256": "33bdf6f3048e9c940710c1cfc27e59af549f37c14b58ba24bd12f3bd5b284d73" + }, + { + "id": "FJ2649", + "entry": "isa_BP3D_4.0_obj_99/FJ2649.obj", + "bytes": 81031, + "sha256": "d4833bb0b60ee79f526150ad7ba9124e326aba8cd48000711bf3a6b0997b0ce0" + }, + { + "id": "FJ2650", + "entry": "isa_BP3D_4.0_obj_99/FJ2650.obj", + "bytes": 29816, + "sha256": "dd2c38fdc784311c955fb8b0420d70dfbdf16f0ce6e236a086dc5f350faae04c" + }, + { + "id": "FJ2651", + "entry": "isa_BP3D_4.0_obj_99/FJ2651.obj", + "bytes": 37854, + "sha256": "864567c4b15c3add5a8184edb142766538936e2ef17af4efa25acca67f4344d8" + }, + { + "id": "FJ2652", + "entry": "isa_BP3D_4.0_obj_99/FJ2652.obj", + "bytes": 22767, + "sha256": "fd5ee304558da1d1ffebb01ca7f59b374087667e71d473fe5401f355a2ff161f" + }, + { + "id": "FJ2653", + "entry": "isa_BP3D_4.0_obj_99/FJ2653.obj", + "bytes": 20958, + "sha256": "74fc42fbc783857619dccb5a753b06cbfce9abc6403f14e38f55bbb9fafdad80" + }, + { + "id": "FJ2654", + "entry": "isa_BP3D_4.0_obj_99/FJ2654.obj", + "bytes": 13776, + "sha256": "4e8467b12ca3374d25807d5de058cfb8d147ad2decd99f6debe57847a83099a1" + }, + { + "id": "FJ2723", + "entry": "isa_BP3D_4.0_obj_99/FJ2723.obj", + "bytes": 281611, + "sha256": "cd008769cb9d565a75bf6b91b5ad3bd482932e37c4747837f6c9446cd23b73a2" + }, + { + "id": "FJ2667", + "entry": "isa_BP3D_4.0_obj_99/FJ2667.obj", + "bytes": 25908, + "sha256": "4a43aa2911b4b1ee153d8948e5edfa99c078f374603a52c69100ab3ae2ef4362" + }, + { + "id": "FJ2668", + "entry": "isa_BP3D_4.0_obj_99/FJ2668.obj", + "bytes": 16400, + "sha256": "512479cec370a4390d5f2f0555fbdfc7ba3c2e8fb7b78b242cb4382ede30287f" + }, + { + "id": "FJ2670", + "entry": "isa_BP3D_4.0_obj_99/FJ2670.obj", + "bytes": 28943, + "sha256": "e734bab3fcf2ee2bfba0eb6f827f8894fd9ff86e261f4fff0cf1ec37c3f84073" + }, + { + "id": "FJ2671", + "entry": "isa_BP3D_4.0_obj_99/FJ2671.obj", + "bytes": 32032, + "sha256": "9ca85be93a017bc2a8aa7d565b3ec320620e4b22e78936b0d6f52b7cf3015be5" + }, + { + "id": "FJ2672", + "entry": "isa_BP3D_4.0_obj_99/FJ2672.obj", + "bytes": 47950, + "sha256": "032c1562f06b7c960e1524fd8259fa321d59426ba0a9e6df32b42eb2c79e8e11" + }, + { + "id": "FJ2673", + "entry": "isa_BP3D_4.0_obj_99/FJ2673.obj", + "bytes": 23827, + "sha256": "9ffff6952448478f178b3a4debe89cc0cb28035cf392f992c119768406f1cf32" + }, + { + "id": "FJ2674", + "entry": "isa_BP3D_4.0_obj_99/FJ2674.obj", + "bytes": 18806, + "sha256": "e4ff01e6ce03c7f0bfd28d099680623dd2e98829bde7efb9dbd9936029e3961d" + }, + { + "id": "FJ2675", + "entry": "isa_BP3D_4.0_obj_99/FJ2675.obj", + "bytes": 14381, + "sha256": "18496992ff047cc1578789bb356e181e91fd0bc3f59332f392b64ef02a91cc45" + }, + { + "id": "FJ2676", + "entry": "isa_BP3D_4.0_obj_99/FJ2676.obj", + "bytes": 22233, + "sha256": "5455ee32b46013949d56fbdbbe87d08988975d7e3504105b270ed942376a13f8" + }, + { + "id": "FJ2677", + "entry": "isa_BP3D_4.0_obj_99/FJ2677.obj", + "bytes": 18719, + "sha256": "475b16a4d4a365a732fa8dbc1757f57b81ca99847ef2d36dd160656994dae474" + }, + { + "id": "FJ2692", + "entry": "isa_BP3D_4.0_obj_99/FJ2692.obj", + "bytes": 62836, + "sha256": "c38882cfb2a4ff493aece22ced1f23c9e044bf9cc091f14d40c7256179d34ccf" + }, + { + "id": "FJ2693", + "entry": "isa_BP3D_4.0_obj_99/FJ2693.obj", + "bytes": 50460, + "sha256": "2f089666f8301e52400250614677a5c824bfa37fee55bfeb545904c8acffc063" + }, + { + "id": "FJ2694", + "entry": "isa_BP3D_4.0_obj_99/FJ2694.obj", + "bytes": 30018, + "sha256": "8579bbf2af9aa03a93604db0f05283334baf131b26ca17d9bbd9c1ff281ee048" + }, + { + "id": "FJ2695", + "entry": "isa_BP3D_4.0_obj_99/FJ2695.obj", + "bytes": 15952, + "sha256": "8a50ff9ad16191e3fd6cadb480943d212796d9cba391659c186be731b8f68d6a" + }, + { + "id": "FJ2696", + "entry": "isa_BP3D_4.0_obj_99/FJ2696.obj", + "bytes": 26375, + "sha256": "0d90aa40e3ac1a0d4423d19da7c8a9f4446063bdae1b7246f97669c6db3720df" + }, + { + "id": "FJ2697", + "entry": "isa_BP3D_4.0_obj_99/FJ2697.obj", + "bytes": 17355, + "sha256": "da528958c3c9784dc6ed9c04cd0a8d1fe6678c66e3792e0c258b1b51c9a07874" + }, + { + "id": "FJ2698", + "entry": "isa_BP3D_4.0_obj_99/FJ2698.obj", + "bytes": 17208, + "sha256": "d253c0270030d4f2845f99ec3658e0e0ac9a79bda8e6d2e3ec1cae9d1942c9bd" + }, + { + "id": "FJ2699", + "entry": "isa_BP3D_4.0_obj_99/FJ2699.obj", + "bytes": 11081, + "sha256": "4434305060b28d0b294b33cc18cdeb62f7a525f1282500c24dfb558205ec54a5" + }, + { + "id": "FJ2700", + "entry": "isa_BP3D_4.0_obj_99/FJ2700.obj", + "bytes": 19411, + "sha256": "2c4dacf7f7029de9075b4671085accefcf96200b4dbaba8a130ac1c3b177ebc6" + }, + { + "id": "FJ2714", + "entry": "isa_BP3D_4.0_obj_99/FJ2714.obj", + "bytes": 51286, + "sha256": "d7d9ed93cb831b5beb98cdbbb814d2628e38efcc524028a4a291ee6144ea5c03" + }, + { + "id": "FJ2715", + "entry": "isa_BP3D_4.0_obj_99/FJ2715.obj", + "bytes": 17086, + "sha256": "f18dda103cde54e3a21c811c33f2dc3cf25f000eaff460703c696e76cc6a0e3f" + }, + { + "id": "FJ2716", + "entry": "isa_BP3D_4.0_obj_99/FJ2716.obj", + "bytes": 17573, + "sha256": "0efa7807739a27fd0fd8ee6fb043ebdc17c8c824b1d068ddcf8bc305a138ca19" + }, + { + "id": "FJ2717", + "entry": "isa_BP3D_4.0_obj_99/FJ2717.obj", + "bytes": 24857, + "sha256": "3fb3cd79b66f9ec1be89382534eef8b9294328d6e7c17a7b48e87dd879316579" + }, + { + "id": "FJ2718", + "entry": "isa_BP3D_4.0_obj_99/FJ2718.obj", + "bytes": 13359, + "sha256": "f08dbbc4cb90043b874b8483b378c0da44a573a6dccbb17530f8f07e8c32ba0c" + }, + { + "id": "FJ2719", + "entry": "isa_BP3D_4.0_obj_99/FJ2719.obj", + "bytes": 28572, + "sha256": "56493dd7e056b7c7cb462293402c3fa42dbb82c572dc746dfee5685eb4afe94a" + }, + { + "id": "FJ2720", + "entry": "isa_BP3D_4.0_obj_99/FJ2720.obj", + "bytes": 22827, + "sha256": "425ff09df45ea552c0d9a6d3cb57ec55a16ca5ca37e0736bf6ba5dea6cdf03a9" + }, + { + "id": "FJ2721", + "entry": "isa_BP3D_4.0_obj_99/FJ2721.obj", + "bytes": 18826, + "sha256": "36858ad1fc4dd8f39de435eb42715c02b75976da212e9f322723e222d9862922" + }, + { + "id": "FJ2722", + "entry": "isa_BP3D_4.0_obj_99/FJ2722.obj", + "bytes": 23583, + "sha256": "ba9b6f6885b2fa65dd32aa1799dd1d3c77f2a95baac9dcab816704ad74fcd0d3" + }, + { + "id": "FJ2655", + "entry": "isa_BP3D_4.0_obj_99/FJ2655.obj", + "bytes": 37441, + "sha256": "6095f578e12b9a85dcf978692793f775494086ab09b7eb44e6a069049640bd82" + }, + { + "id": "FJ2656", + "entry": "isa_BP3D_4.0_obj_99/FJ2656.obj", + "bytes": 49555, + "sha256": "cb9c6b4e10e43c92c8ea4e2e1a66215d98cf58d72fcc60aeadc8a0f87f6724fc" + }, + { + "id": "FJ2724", + "entry": "isa_BP3D_4.0_obj_99/FJ2724.obj", + "bytes": 33909, + "sha256": "1da253198ab9482187ad49300d2d8cc594a44ed4e805c01e027d1df481f3403c" + }, + { + "id": "FJ2727", + "entry": "isa_BP3D_4.0_obj_99/FJ2727.obj", + "bytes": 65355, + "sha256": "d54aafb93539879b37513605156084a45d9161134ad4c64b16e6ceca2dff77e2" + }, + { + "id": "FJ2728", + "entry": "isa_BP3D_4.0_obj_99/FJ2728.obj", + "bytes": 19145, + "sha256": "601bfbfb4d36b9a044995b8fddaecc8897fe7ff3f8e2d2b03ba8758de9318ba6" + }, + { + "id": "FJ2729", + "entry": "isa_BP3D_4.0_obj_99/FJ2729.obj", + "bytes": 15250, + "sha256": "e69c55079d6a139103feb2117bf5c70599ccb28f0aaae75719b36e772a6cc9d8" + }, + { + "id": "FJ2731", + "entry": "isa_BP3D_4.0_obj_99/FJ2731.obj", + "bytes": 52845, + "sha256": "69c00eaa21cf6e04da2b794ec4d56ec0900f502b59cbe616e129ee8099008296" + } + ], + "built": { + "file": "heart.glb", + "bytes": 2558152, + "sha256": "309af9886b9388323beb7e9c933c2b1f2a30b05ba93768eda6c8999b7da20ef1", + "triangles": 105768, + "size": [ + 0.115695, + 0.14217, + 0.126672 + ], + "parts": { + "right-atrium": { + "center": [ + -0.037052, + -0.014615, + 0.009824 + ], + "size": [ + 0.03739, + 0.09226, + 0.061127 + ], + "closed": true, + "triangles": 2244 + }, + "right-atrium-wall": { + "center": [ + -0.036307, + -0.014715, + 0.016314 + ], + "size": [ + 0.043082, + 0.09642, + 0.0663 + ], + "closed": true, + "triangles": 17784 + }, + "left-atrium": { + "center": [ + -0.007574, + -0.008635, + -0.014305 + ], + "size": [ + 0.068708, + 0.06184, + 0.055771 + ], + "closed": true, + "triangles": 1064 + }, + "left-atrium-wall": { + "center": [ + -0.001364, + -0.01009, + -0.00252 + ], + "size": [ + 0.086119, + 0.07297, + 0.080981 + ], + "closed": true, + "triangles": 7544 + }, + "right-ventricle": { + "center": [ + -0.004635, + -0.02625, + 0.031126 + ], + "size": [ + 0.071509, + 0.08055, + 0.058223 + ], + "closed": true, + "triangles": 1918 + }, + "left-ventricle": { + "center": [ + 0.016813, + -0.028195, + 0.009281 + ], + "size": [ + 0.063779, + 0.06748, + 0.07212 + ], + "closed": true, + "triangles": 1722 + }, + "mitral-valve": { + "center": [ + 0.015744, + -0.028245, + 0.000354 + ], + "size": [ + 0.051133, + 0.03632, + 0.05618 + ], + "closed": true, + "triangles": 11378 + }, + "tricuspid-valve": { + "center": [ + -0.017332, + -0.033445, + 0.021762 + ], + "size": [ + 0.050579, + 0.04784, + 0.04274 + ], + "closed": true, + "triangles": 17612 + }, + "aortic-valve": { + "center": [ + -0.002516, + -0.00176, + 0.005453 + ], + "size": [ + 0.02672, + 0.02167, + 0.027615 + ], + "closed": true, + "triangles": 2150 + }, + "pulmonary-valve": { + "center": [ + 0.003301, + 0.00908, + 0.030411 + ], + "size": [ + 0.032154, + 0.02037, + 0.031978 + ], + "closed": true, + "triangles": 3638 + }, + "papillary-muscles": { + "center": [ + 0.019309, + -0.0367, + 0.025558 + ], + "size": [ + 0.067376, + 0.06173, + 0.067943 + ], + "closed": true, + "triangles": 4014 + }, + "ascending-aorta": { + "center": [ + -0.010483, + 0.011975, + 0.00887 + ], + "size": [ + 0.035765, + 0.04784, + 0.030777 + ], + "closed": true, + "triangles": 396 + }, + "aortic-arch": { + "center": [ + -0.00754, + 0.05349, + -0.019677 + ], + "size": [ + 0.041668, + 0.03519, + 0.087318 + ], + "closed": true, + "triangles": 670 + }, + "pulmonary-trunk": { + "center": [ + 0.005131, + 0.02905, + 0.024509 + ], + "size": [ + 0.0308, + 0.03711, + 0.042348 + ], + "closed": true, + "triangles": 1302 + }, + "superior-vena-cava": { + "center": [ + -0.036916, + 0.046305, + 0.002251 + ], + "size": [ + 0.022525, + 0.035, + 0.023689 + ], + "closed": true, + "triangles": 598 + }, + "left-coronary-artery": { + "center": [ + 0.029846, + -0.02587, + 0.016692 + ], + "size": [ + 0.056002, + 0.08137, + 0.085786 + ], + "closed": true, + "triangles": 12666 + }, + "right-coronary-artery": { + "center": [ + 0.004379, + -0.02801, + 0.019393 + ], + "size": [ + 0.09534, + 0.08615, + 0.087885 + ], + "closed": true, + "triangles": 14682 + }, + "cardiac-veins": { + "center": [ + -0.004547, + -0.029925, + 0.013577 + ], + "size": [ + 0.075674, + 0.07476, + 0.0913 + ], + "closed": true, + "triangles": 4386 + } + } + } +} diff --git a/docs/real-models.md b/docs/real-models.md new file mode 100644 index 00000000..298d577f --- /dev/null +++ b/docs/real-models.md @@ -0,0 +1,21 @@ +# Real models + +Talkthrough can draw a thing as it really is (today a human heart and a brain) instead of building it from shapes. A model is a **manifest** in `assets/models/.json` plus files that are fetched once and never stored in git. + +## Getting the files + +``` +npm run assets # fetch what the manifests name, build assets/built/*.glb, check the generated files +``` + +The fetch reads only the files the manifests name, by byte range out of the source archive, and checks each against the size and sha256 the manifest pins. It is the only time anything is downloaded; the app itself never fetches a model. `assets/cache/` and `assets/built/` are ignored by git. `npm run build` copies the built files into `dist/models/` (without them it warns and the models are drawn from shapes); `npm run dist` refuses to pack without them. + +## Adding a model + +1. Write `assets/models/.json`: the source and its version, the licence (`CC0-1.0` or `CC-BY-4.0` only) with its version and the evidence for it, the credit line (required for CC BY), what was changed, `orient` (which source axis is up and which faces front), `scale.unitsToMetres`, the `files` (archive entries) and the named `parts`, each naming its files and how well the source backs it (`atlas`, `grouped`, `approximate`). +2. `npm run assets:pin` fetches, builds and records the hashes, then writes `src/scene/model-catalogue.ts` and `assets/CREDITS.md`. Commit the manifest and those two generated files; a test fails when they drift from the manifests. +3. A scene uses it with `{ "op": "add", "shape": "model", "id": "h", "model": "heart", "size": 8 }`; its parts are then `h.left-ventricle` and so on, for `pin`, `highlight`, `style`, `explode` and `cut`. + +## Credits + +`assets/CREDITS.md` lists every model, its source, licence, credit and changes; the tray's "Save the 3D model credits…" saves it. A drawing that shows a CC BY model carries its credit line at the foot of the stage. diff --git a/docs/scene.schema.json b/docs/scene.schema.json index 81a0d151..118866f9 100644 --- a/docs/scene.schema.json +++ b/docs/scene.schema.json @@ -4014,6 +4014,111 @@ "additionalProperties": false, "description": "A ready-made part fitted to the box size [x,y,z]. Electronics: chip (variant black or metal), header (n pins per row, two rows), port (variant usb, usb3, ethernet, hdmi, usbc), lens, screen, button, fan (n blades, axis y), wheel (n spokes, axis z). Mechanism, axis y: cylinder-block (variant cutaway or finned; the bore is round in x,z), piston, connecting-rod (small end up), valve (head down), spark-plug (tip down), spring (n coils), pipe, elbow, housing (variant cutaway); axis z: crankshaft (n throws), camshaft (n lobes), gear (n teeth), bearing (n balls). Their anchors and origin work for pins, connectors and parentAnchor/selfAnchor. Attached by a face of its parent (right, top, front...), a part turns to face out of it unless you give rot; faces: port, lens, screen +z, chip, header, button, fan +y." }, + "addModel": { + "type": "object", + "properties": { + "op": { + "enum": [ + "add" + ] + }, + "shape": { + "enum": [ + "model" + ] + }, + "id": { + "type": "string" + }, + "model": { + "enum": [ + "brain", + "heart" + ] + }, + "parent": { + "type": [ + "string", + "null" + ], + "description": "id of a group, part or shape to attach to; create a new parent no later than this child (it carries this along)" + }, + "parentAnchor": { + "type": [ + "string", + "null" + ], + "description": "attach at this named point of the parent (requires parent): a built-in name, a kit part's own, or one named with the anchor action; origin when only selfAnchor is set. The part then stays at that point whatever moves, spins or is dragged, and pos and move are its offset from the point; up to 24 characters" + }, + "selfAnchor": { + "type": [ + "string", + "null" + ], + "description": "the point of this object placed at parentAnchor, default origin; requires parent. Unknown names drop the action with the available ones; up to 24 characters" + }, + "explode": { + "type": [ + "array", + "null" + ], + "items": { + "type": "number" + }, + "description": "where it moves when the model is exploded, [x,y,z] in the units of the group it is in (spread 1); without it, it moves outward from the middle of the parts around it; [x,y,z], each -100 to 100" + }, + "pos": { + "type": [ + "array", + "null" + ], + "items": { + "type": "number" + }, + "description": "[x,y,z], default [0,0,0]; [x,y,z], each -100 to 100" + }, + "rot": { + "type": [ + "array", + "null" + ], + "items": { + "type": "number" + }, + "description": "degrees [x,y,z]; [x,y,z], each -3600 to 3600" + }, + "size": { + "type": [ + "number", + "null" + ], + "description": "0.5 to 60" + }, + "at": { + "type": [ + "number", + "null" + ], + "description": "seconds after the step starts; 0 to 60" + } + }, + "required": [ + "op", + "shape", + "id", + "model", + "parent", + "parentAnchor", + "selfAnchor", + "explode", + "pos", + "rot", + "size", + "at" + ], + "additionalProperties": false, + "description": "A real model of a real thing (the list is in the rules), with its named parts as objects id.part. size is its longest side (default its real size, a heart about 5, a brain about 7); a model turns and attaches like any object." + }, "addArray": { "type": "object", "properties": { @@ -6477,6 +6582,9 @@ { "$ref": "#/$defs/addPart" }, + { + "$ref": "#/$defs/addModel" + }, { "$ref": "#/$defs/addArray" }, diff --git a/docs/scene.schema.lean.json b/docs/scene.schema.lean.json index eab928b1..a41a0484 100644 --- a/docs/scene.schema.lean.json +++ b/docs/scene.schema.lean.json @@ -4,7 +4,7 @@ "steps": { "type": "array", "items": { - "$ref": "#/$defs/29" + "$ref": "#/$defs/2a" } }, "escalate": { @@ -690,6 +690,65 @@ "additionalProperties": false }, "17": { + "type": "object", + "properties": { + "op": { + "enum": [ + "add" + ] + }, + "shape": { + "enum": [ + "model" + ] + }, + "id": { + "type": "string" + }, + "model": { + "enum": [ + "brain", + "heart" + ] + }, + "parent": { + "$ref": "#/$defs/1" + }, + "parentAnchor": { + "$ref": "#/$defs/1" + }, + "selfAnchor": { + "$ref": "#/$defs/1" + }, + "pos": { + "$ref": "#/$defs/2" + }, + "rot": { + "$ref": "#/$defs/2" + }, + "size": { + "$ref": "#/$defs/0" + }, + "at": { + "$ref": "#/$defs/0" + } + }, + "required": [ + "op", + "shape", + "id", + "model", + "parent", + "parentAnchor", + "selfAnchor", + "pos", + "rot", + "size", + "at" + ], + "additionalProperties": false + }, + "18": { "type": "object", "properties": { "op": { @@ -733,7 +792,7 @@ ], "additionalProperties": false }, - "18": { + "19": { "type": "object", "properties": { "op": { @@ -789,36 +848,31 @@ ], "additionalProperties": false }, - "19": { + "20": { "type": "object", "properties": { "op": { "enum": [ - "add" - ] - }, - "shape": { - "enum": [ - "group" + "wedge" ] }, "id": { "type": "string" }, - "parent": { - "$ref": "#/$defs/1" + "drives": { + "type": "string" }, - "parentAnchor": { - "$ref": "#/$defs/1" + "angle": { + "$ref": "#/$defs/0" }, - "selfAnchor": { - "$ref": "#/$defs/1" + "travel": { + "$ref": "#/$defs/0" }, - "pos": { - "$ref": "#/$defs/2" + "period": { + "$ref": "#/$defs/0" }, - "rot": { - "$ref": "#/$defs/2" + "axis": { + "$ref": "#/$defs/6" }, "at": { "$ref": "#/$defs/0" @@ -826,18 +880,17 @@ }, "required": [ "op", - "shape", "id", - "parent", - "parentAnchor", - "selfAnchor", - "pos", - "rot", + "drives", + "angle", + "travel", + "period", + "axis", "at" ], "additionalProperties": false }, - "20": { + "21": { "type": "object", "properties": { "op": { @@ -883,7 +936,7 @@ ], "additionalProperties": false }, - "21": { + "22": { "type": "object", "properties": { "op": { @@ -921,7 +974,7 @@ ], "additionalProperties": false }, - "22": { + "23": { "type": "object", "properties": { "op": { @@ -951,7 +1004,7 @@ ], "additionalProperties": false }, - "23": { + "24": { "type": "object", "properties": { "op": { @@ -977,7 +1030,7 @@ ], "additionalProperties": false }, - "24": { + "25": { "type": "object", "properties": { "op": { @@ -1003,7 +1056,7 @@ ], "additionalProperties": false }, - "25": { + "26": { "type": "object", "properties": { "op": { @@ -1039,7 +1092,7 @@ ], "additionalProperties": false }, - "26": { + "27": { "type": "object", "properties": { "op": { @@ -1079,7 +1132,7 @@ ], "additionalProperties": false }, - "27": { + "28": { "type": "object", "properties": { "op": { @@ -1101,7 +1154,7 @@ ], "additionalProperties": false }, - "28": { + "29": { "anyOf": [ { "$ref": "#/$defs/a" @@ -1312,27 +1365,11 @@ }, { "$ref": "#/$defs/27" - } - ] - }, - "29": { - "type": "object", - "properties": { - "say": { - "type": "string" }, - "actions": { - "type": "array", - "items": { - "$ref": "#/$defs/28" - } + { + "$ref": "#/$defs/28" } - }, - "required": [ - "say", - "actions" - ], - "additionalProperties": false + ] }, "a": { "type": "object", @@ -2972,6 +3009,54 @@ "additionalProperties": false }, "1a": { + "type": "object", + "properties": { + "op": { + "enum": [ + "add" + ] + }, + "shape": { + "enum": [ + "group" + ] + }, + "id": { + "type": "string" + }, + "parent": { + "$ref": "#/$defs/1" + }, + "parentAnchor": { + "$ref": "#/$defs/1" + }, + "selfAnchor": { + "$ref": "#/$defs/1" + }, + "pos": { + "$ref": "#/$defs/2" + }, + "rot": { + "$ref": "#/$defs/2" + }, + "at": { + "$ref": "#/$defs/0" + } + }, + "required": [ + "op", + "shape", + "id", + "parent", + "parentAnchor", + "selfAnchor", + "pos", + "rot", + "at" + ], + "additionalProperties": false + }, + "1b": { "type": "object", "properties": { "op": { @@ -3017,7 +3102,7 @@ ], "additionalProperties": false }, - "1b": { + "1c": { "type": "object", "properties": { "op": { @@ -3049,7 +3134,7 @@ ], "additionalProperties": false }, - "1c": { + "1d": { "type": "object", "properties": { "op": { @@ -3079,7 +3164,7 @@ ], "additionalProperties": false }, - "1d": { + "1e": { "type": "object", "properties": { "op": { @@ -3110,7 +3195,7 @@ ], "additionalProperties": false }, - "1e": { + "1f": { "type": "object", "properties": { "op": { @@ -3136,7 +3221,7 @@ ], "additionalProperties": false }, - "1f": { + "1g": { "type": "object", "properties": { "op": { @@ -3158,7 +3243,7 @@ ], "additionalProperties": false }, - "1g": { + "1h": { "type": "object", "properties": { "op": { @@ -3192,7 +3277,7 @@ ], "additionalProperties": false }, - "1h": { + "1i": { "type": "object", "properties": { "op": { @@ -3222,7 +3307,7 @@ ], "additionalProperties": false }, - "1i": { + "1j": { "type": "object", "properties": { "op": { @@ -3268,7 +3353,7 @@ ], "additionalProperties": false }, - "1j": { + "1k": { "type": "object", "properties": { "op": { @@ -3306,7 +3391,7 @@ ], "additionalProperties": false }, - "1k": { + "1l": { "type": "object", "properties": { "op": { @@ -3348,7 +3433,7 @@ ], "additionalProperties": false }, - "1l": { + "1m": { "type": "object", "properties": { "op": { @@ -3386,7 +3471,7 @@ ], "additionalProperties": false }, - "1m": { + "1n": { "type": "object", "properties": { "op": { @@ -3452,7 +3537,7 @@ ], "additionalProperties": false }, - "1n": { + "1o": { "type": "object", "properties": { "op": { @@ -3516,7 +3601,7 @@ ], "additionalProperties": false }, - "1o": { + "1p": { "type": "object", "properties": { "op": { @@ -3558,7 +3643,7 @@ ], "additionalProperties": false }, - "1p": { + "1q": { "type": "object", "properties": { "op": { @@ -3600,7 +3685,7 @@ ], "additionalProperties": false }, - "1q": { + "1r": { "type": "object", "properties": { "op": { @@ -3638,7 +3723,7 @@ ], "additionalProperties": false }, - "1r": { + "1s": { "type": "object", "properties": { "op": { @@ -3684,7 +3769,7 @@ ], "additionalProperties": false }, - "1s": { + "1t": { "type": "object", "properties": { "op": { @@ -3726,7 +3811,7 @@ ], "additionalProperties": false }, - "1t": { + "1u": { "type": "object", "properties": { "op": { @@ -3772,7 +3857,7 @@ ], "additionalProperties": false }, - "1u": { + "1v": { "type": "object", "properties": { "op": { @@ -3810,7 +3895,7 @@ ], "additionalProperties": false }, - "1v": { + "1w": { "type": "object", "properties": { "op": { @@ -3848,7 +3933,7 @@ ], "additionalProperties": false }, - "1w": { + "1x": { "type": "object", "properties": { "op": { @@ -3882,7 +3967,7 @@ ], "additionalProperties": false }, - "1x": { + "1y": { "type": "object", "properties": { "op": { @@ -3932,7 +4017,7 @@ ], "additionalProperties": false }, - "1y": { + "1z": { "type": "object", "properties": { "op": { @@ -3970,45 +4055,22 @@ ], "additionalProperties": false }, - "1z": { + "2a": { "type": "object", "properties": { - "op": { - "enum": [ - "wedge" - ] - }, - "id": { - "type": "string" - }, - "drives": { + "say": { "type": "string" }, - "angle": { - "$ref": "#/$defs/0" - }, - "travel": { - "$ref": "#/$defs/0" - }, - "period": { - "$ref": "#/$defs/0" - }, - "axis": { - "$ref": "#/$defs/6" - }, - "at": { - "$ref": "#/$defs/0" + "actions": { + "type": "array", + "items": { + "$ref": "#/$defs/29" + } } }, "required": [ - "op", - "id", - "drives", - "angle", - "travel", - "period", - "axis", - "at" + "say", + "actions" ], "additionalProperties": false } diff --git a/package.json b/package.json index 15a33491..981b18a3 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,11 @@ "scripts": { "typecheck": "tsc --noEmit", "build": "node scripts/build.mjs", + "assets:fetch": "node scripts/assets/fetch.mjs", + "assets:build": "node scripts/assets/build.mjs", + "assets:pin": "node scripts/assets/fetch.mjs --pin && node scripts/assets/build.mjs --pin && node scripts/assets/index.mjs", + "assets:index": "node scripts/assets/index.mjs", + "assets": "node scripts/assets/fetch.mjs && node scripts/assets/build.mjs && node scripts/assets/index.mjs --check", "start": "node scripts/start.mjs", "test": "node --test \"test/*.test.ts\"", "dist": "node scripts/dist.mjs" diff --git a/scripts/assets/build.mjs b/scripts/assets/build.mjs new file mode 100644 index 00000000..e90b0abd --- /dev/null +++ b/scripts/assets/build.mjs @@ -0,0 +1,77 @@ +// node scripts/assets/build.mjs [--pin] [model ...] +// Builds one GLB for each manifest from the cached source files: every file checked against its pinned hash, turned to the scene's axes and metres, +// welded, grouped into the named parts, written with the parts as nodes. The result goes in assets/built. --pin records what the build measured +// (the GLB's size and hash, each part's centre, size and whether it is closed) in the manifest; without it, the build must reproduce the pinned +// hash exactly, so a change in the files or in this code cannot go unnoticed. + +import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { bounds, isClosed, merge, orientation, parseObj, transformPositions, weld, writeGlb } from './obj-glb.mjs'; +import { BUILT_DIR, CACHE_DIR, manifestProblems, readManifests, sha256 } from './manifest.mjs'; + +const args = process.argv.slice(2); +const pin = args.includes('--pin'); +const only = args.filter((a) => !a.startsWith('--')); +const round = (v, d = 6) => Math.round(v * 10 ** d) / 10 ** d; + +/** The built GLB bytes and what was measured while making them. */ +export function buildModel(m, readFile) { + const rows = orientation(m.orient.up, m.orient.front); + const files = new Map(m.files.map((f) => [f.id, f])); + const parts = m.parts.map((p) => { + const meshes = p.nodes.map((id) => { + const raw = parseObj(readFile(files.get(id))); + const moved = transformPositions(raw.positions, rows, m.scale.unitsToMetres); + return weld(moved, raw.indices); + }); + const mesh = meshes.length === 1 ? meshes[0] : merge(meshes); + // A part made of several files is closed when each of them is. + const closed = meshes.every((x) => isClosed(x.indices)); + return { key: p.key, files: p.nodes, confidence: p.confidence, color: p.color, mesh, closed }; + }); + // The model's own middle is the origin: its parts are placed around it. + const all = bounds(merge(parts.map((p) => p.mesh)).positions); + const shifted = parts.map((p) => { + const positions = new Float32Array(p.mesh.positions.length); + for (let i = 0; i < positions.length; i += 3) for (let k = 0; k < 3; k++) positions[i + k] = p.mesh.positions[i + k] - all.center[k]; + return { ...p, positions, indices: p.mesh.indices }; + }); + const glb = writeGlb(m.id, shifted); + const measured = {}; + for (const p of shifted) { + const b = bounds(p.positions); + measured[p.key] = { center: b.center.map((v) => round(v)), size: b.size.map((v) => round(v)), closed: p.closed, triangles: p.indices.length / 3 }; + } + return { glb, size: all.size.map((v) => round(v)), triangles: shifted.reduce((n, p) => n + p.indices.length / 3, 0), parts: measured }; +} + +if (import.meta.url === `file:///${process.argv[1].replace(/\\/g, '/')}`) { + let failed = 0; + mkdirSync(BUILT_DIR, { recursive: true }); + for (const { file, manifest: m } of readManifests()) { + if (only.length && !only.includes(m.id)) continue; + const problems = manifestProblems(m); + if (problems.length) { console.error(`${m.id}: manifest is not sound: ${problems.join('; ')}`); failed++; continue; } + const folder = join(CACHE_DIR, m.source.name.toLowerCase().replace(/[^a-z0-9]+/g, '-')); + const readFile = (f) => { + const path = join(folder, f.entry); + if (!existsSync(path)) throw new Error(`${f.id} is not in the cache (run assets:fetch)`); + const data = readFileSync(path); + if (f.sha256 && sha256(data) !== f.sha256) throw new Error(`${f.id} does not match its pinned hash`); + return data.toString('latin1'); + }; + try { + const built = buildModel(m, readFile); + const hash = sha256(built.glb); + if (!pin && m.built && m.built.sha256 !== hash) throw new Error(`the build gives ${hash}, the manifest pins ${m.built.sha256}; check the change, then run with --pin`); + writeFileSync(join(BUILT_DIR, `${m.id}.glb`), built.glb); + if (pin) { + m.built = { file: `${m.id}.glb`, bytes: built.glb.length, sha256: hash, triangles: built.triangles, size: built.size, parts: built.parts }; + writeFileSync(file, JSON.stringify(m, null, 2) + '\n'); + } + const open = Object.entries(built.parts).filter(([key, p]) => m.parts.find((x) => x.key === key)?.closed && !p.closed).map(([key]) => key); + console.log(`${m.id}: ${(built.glb.length / 1048576).toFixed(2)} MB, ${built.triangles} triangles, size ${built.size.map((v) => (v * 100).toFixed(1)).join(' x ')} cm${open.length ? `; NOT closed though the manifest says so: ${open.join(', ')}` : ''}`); + } catch (e) { console.error(`${m.id}: ${e.message}`); failed++; } + } + if (failed) process.exit(1); +} diff --git a/scripts/assets/fetch.mjs b/scripts/assets/fetch.mjs new file mode 100644 index 00000000..22864eaf --- /dev/null +++ b/scripts/assets/fetch.mjs @@ -0,0 +1,71 @@ +// node scripts/assets/fetch.mjs [--pin] [model ...] +// The one place files are fetched: a developer step, never run by the app. For each manifest it makes sure every file it names is in the cache +// (assets/cache, or the folder named by TALKTHROUGH_ASSET_CACHE), downloaded only if missing, and checks each against the size and sha256 the manifest +// pins. A file that does not match is refused and removed, not used. --pin is the maintainer's step: it lists the files a manifest's parts need, +// downloads them and writes their sizes and hashes into the manifest. +// Only what the manifests name is downloaded: from a large archive, just those files, by byte range. + +import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; +import { dirname, join } from 'node:path'; +import { CACHE_DIR, manifestProblems, readManifests, sha256 } from './manifest.mjs'; +import { httpRange, readDirectory, readEntry } from './zip-range.mjs'; + +const args = process.argv.slice(2); +const pin = args.includes('--pin'); +const only = args.filter((a) => !a.startsWith('--')); + +const cachePath = (m, f) => join(CACHE_DIR, m.source.name.toLowerCase().replace(/[^a-z0-9]+/g, '-'), f.entry); +const directories = new Map(); + +/** The archive's directory, checked against the size the manifest recorded (a re-published archive is not the one that was reviewed). */ +async function archiveDirectory(m) { + const { url, bytes } = m.source.archive; + if (!directories.has(url)) { + const head = await fetch(url, { method: 'HEAD' }); + const size = Number(head.headers.get('content-length')); + if (size !== bytes) throw new Error(`${url} is ${size} bytes, the manifest says ${bytes}: it has changed; review it before updating the manifest`); + directories.set(url, await readDirectory(size, httpRange(url))); + } + return directories.get(url); +} + +async function fromArchive(m, entry) { + const dir = await archiveDirectory(m); + const item = dir.find((e) => e.name === entry); + if (!item) throw new Error(`${entry} is not in ${m.source.archive.url}`); + return readEntry(item, httpRange(m.source.archive.url)); +} + +let failed = 0; +for (const { file, manifest: m } of readManifests()) { + if (only.length && !only.includes(m.id)) continue; + console.log(`${m.id}: ${m.parts.length} parts`); + if (pin) { + // The files a part names, in the order they appear; the archive folder is the manifest's. + const ids = [...new Set(m.parts.flatMap((p) => p.nodes ?? []))]; + const known = new Map((m.files ?? []).map((f) => [f.id, f])); + m.files = ids.map((id) => known.get(id) ?? { id, entry: `${m.source.archive.folder}/${id}.obj` }); + } else if (manifestProblems(m).length) { + console.error(` manifest is not sound: ${manifestProblems(m).join('; ')}`); + failed++; + continue; + } + let fetched = 0, bytes = 0; + for (const f of m.files) { + const path = cachePath(m, f); + let data = existsSync(path) ? readFileSync(path) : undefined; + if (data && f.sha256 && sha256(data) !== f.sha256) { console.error(` ${f.id}: the cached file does not match its pinned hash; removed`); rmSync(path); data = undefined; } + if (!data) { + try { data = await fromArchive(m, f.entry); } catch (e) { console.error(` ${f.id}: ${e.message}`); failed++; continue; } + mkdirSync(dirname(path), { recursive: true }); + writeFileSync(path, data); + fetched++; + bytes += data.length; + } + if (pin) { f.bytes = data.length; f.sha256 = sha256(data); } + else if (f.sha256 !== sha256(data) || f.bytes !== data.length) { console.error(` ${f.id}: does not match the manifest (hash or size); refused`); rmSync(path); failed++; } + } + if (pin) writeFileSync(file, JSON.stringify(m, null, 2) + '\n'); + console.log(` ${m.files.length} files, ${fetched} fetched (${(bytes / 1048576).toFixed(1)} MB)`); +} +if (failed) { console.error(`${failed} problem${failed === 1 ? '' : 's'}`); process.exit(1); } diff --git a/scripts/assets/index.mjs b/scripts/assets/index.mjs new file mode 100644 index 00000000..9d263553 --- /dev/null +++ b/scripts/assets/index.mjs @@ -0,0 +1,96 @@ +// node scripts/assets/index.mjs [--check] +// Writes what the app and the guide need to know about the models, from the manifests alone (no mesh needed): src/scene/model-catalogue.ts, and the +// exportable credits file assets/CREDITS.md. Both are committed (a few KB) and a test checks they are what the manifests say; --check does the same here. + +import { readFileSync, writeFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { LICENCES, ROOT, manifestProblems, readManifests } from './manifest.mjs'; + +const PARTS_VERSION = 1; + +export function catalogueSource(manifests) { + const entries = manifests.map((m) => ({ + id: m.id, name: m.name, description: m.description, aliases: m.aliases, + licence: { id: m.licence.id, name: LICENCES[m.licence.id].name, version: m.licence.version, url: LICENCES[m.licence.id].url }, + credit: LICENCES[m.licence.id].credit ? m.credit : undefined, + size: m.built.size, realLengthMetres: m.scale.realLengthMetres, caveats: m.caveats ?? [], + built: { file: m.built.file, bytes: m.built.bytes, sha256: m.built.sha256, triangles: m.built.triangles }, + parts: m.parts.map((p) => ({ + key: p.key, name: p.name, aliases: p.aliases ?? [], confidence: p.confidence, color: p.color, closed: m.built.parts[p.key].closed, + center: m.built.parts[p.key].center, size: m.built.parts[p.key].size, triangles: m.built.parts[p.key].triangles, + })), + })); + return `// The real models the scene language can place: what each is, its licence and credit, and its named parts. Generated from assets/models/*.json by +// \`npm run assets:index\` (scripts/assets/index.mjs); do not edit. The meshes themselves are built files, not in git (see scripts/assets). + +import type { Vec3 } from './types.ts'; + +export type ModelPart = { + key: string; name: string; aliases: string[]; + /** How the source backs the part: atlas (a named mesh of the source), grouped (several of its meshes, grouped by us), approximate (a place, not a structure). */ + confidence: 'atlas' | 'grouped' | 'approximate'; + color: [number, number, number]; + /** Whether the mesh is a watertight solid, so a cut can be capped. */ + closed: boolean; + /** The part's middle and size in metres, from the model's own middle. */ + center: Vec3; size: Vec3; triangles: number; +}; +export type ModelEntry = { + id: string; name: string; description: string; aliases: string[]; + licence: { id: string; name: string; version: string; url: string }; + /** The credit line the licence asks to be shown (CC BY); none for CC0. */ + credit: string | undefined; + /** The whole model's size in metres, and the real length of its subject. */ + size: Vec3; realLengthMetres: number; caveats: string[]; + built: { file: string; bytes: number; sha256: string; triangles: number }; + parts: ModelPart[]; +}; + +export const MODELS: readonly ModelEntry[] = ${JSON.stringify(entries, null, 2)}; +`; +} + +export function creditsSource(manifests) { + const lines = [ + '# Credits for the real models', + '', + 'Talkthrough itself is MIT licensed. The models it can show are separate works under their own licences, listed here, and are not part of the MIT grant.', + 'This file is generated from `assets/models/*.json` (`npm run assets:index`) and is shipped with the app.', + '', + ]; + for (const m of manifests) { + const lic = LICENCES[m.licence.id]; + lines.push(`## ${m.name} (\`${m.id}\`)`, ''); + lines.push(`- Source: ${m.source.name}, ${m.source.url} (${m.source.version})`); + lines.push(`- Licence: ${lic.name}, version ${m.licence.version}: ${m.licence.url ?? lic.url}`); + if (m.credit) lines.push(`- Credit: ${m.credit}`); + lines.push(`- Changes: ${m.changes}`); + if (m.licence.note) lines.push(`- Note: ${m.licence.note}`); + lines.push(`- Built file: ${m.built.file}, ${m.built.bytes} bytes, sha256 ${m.built.sha256}`); + lines.push(`- Parts: ${m.parts.map((p) => `${p.name} (${p.confidence})`).join('; ')}`); + for (const c of m.caveats ?? []) lines.push(`- Limit: ${c}`); + lines.push(''); + } + return lines.join('\n'); +} + +export function generate() { + const manifests = readManifests().map((x) => x.manifest); + for (const m of manifests) { + const problems = manifestProblems(m); + if (problems.length) throw new Error(`${m.id}: ${problems.join('; ')}`); + if (!m.built) throw new Error(`${m.id} has not been built and pinned (run assets:build --pin)`); + } + return { catalogue: catalogueSource(manifests), credits: creditsSource(manifests) }; +} + +if (import.meta.url === `file:///${process.argv[1].replace(/\\/g, '/')}`) { + const out = generate(); + const files = [[join(ROOT, 'src', 'scene', 'model-catalogue.ts'), out.catalogue], [join(ROOT, 'assets', 'CREDITS.md'), out.credits]]; + if (process.argv.includes('--check')) { + for (const [path, text] of files) if (readFileSync(path, 'utf8').replace(/\r\n/g, '\n') !== text) { console.error(`${path} is not what the manifests say: run npm run assets:index`); process.exit(1); } + console.log('catalogue and credits are current'); + } else { + for (const [path, text] of files) { writeFileSync(path, text); console.log('wrote', path); } + } +} diff --git a/scripts/assets/manifest.mjs b/scripts/assets/manifest.mjs new file mode 100644 index 00000000..f6c7edfd --- /dev/null +++ b/scripts/assets/manifest.mjs @@ -0,0 +1,70 @@ +// Reading and checking the per-model manifests (assets/models/*.json), shared by the fetch, build and index scripts. A manifest is the whole claim about +// a model: where it came from, under which licence, which files, how they are turned into the scene's axes and size, and which named parts are which +// files. Nothing is trusted that the manifest does not say. + +import { createHash } from 'node:crypto'; +import { readFileSync, readdirSync } from 'node:fs'; +import { dirname, join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +export const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..'); +export const MODELS_DIR = join(ROOT, 'assets', 'models'); +export const CACHE_DIR = process.env.TALKTHROUGH_ASSET_CACHE ? resolve(process.env.TALKTHROUGH_ASSET_CACHE) : join(ROOT, 'assets', 'cache'); +export const BUILT_DIR = join(ROOT, 'assets', 'built'); + +/** Licences a model may carry: the permissive ones the project can redistribute. Everything else is refused (NC and ND, share-alike, "CC" alone). */ +export const LICENCES = { + 'CC0-1.0': { name: 'CC0 1.0 Universal', url: 'https://creativecommons.org/publicdomain/zero/1.0/', credit: false }, + 'CC-BY-4.0': { name: 'CC BY 4.0', url: 'https://creativecommons.org/licenses/by/4.0/', credit: true }, +}; + +export const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex'); + +const CONFIDENCE = ['atlas', 'grouped', 'approximate']; +const ID = /^[a-z][a-z0-9-]{0,31}$/; + +/** Problems with a manifest, as plain sentences (an empty list means it is sound). */ +export function manifestProblems(m) { + const out = []; + const need = (ok, why) => { if (!ok) out.push(why); }; + need(m && typeof m === 'object', 'the manifest is not an object'); + if (!m || typeof m !== 'object') return out; + need(typeof m.id === 'string' && ID.test(m.id), 'id must be lower-case letters, digits and dashes'); + need(typeof m.name === 'string' && m.name.length > 0, 'name is missing'); + need(typeof m.description === 'string' && m.description.length > 0 && m.description.length <= 160, 'description is missing or longer than 160 characters'); + need(Array.isArray(m.aliases) && m.aliases.every((a) => typeof a === 'string'), 'aliases must be a list of words'); + need(m.licence && Object.hasOwn(LICENCES, m.licence.id), `licence must be one of ${Object.keys(LICENCES).join(', ')}`); + need(m.licence && typeof m.licence.version === 'string', 'the licence needs its version'); + need(m.source && typeof m.source.name === 'string' && typeof m.source.url === 'string', 'source needs a name and a url'); + need(m.credit === undefined || typeof m.credit === 'string', 'credit must be text'); + if (m.licence && LICENCES[m.licence.id]?.credit) need(typeof m.credit === 'string' && m.credit.length > 0, 'this licence requires a credit line'); + need(typeof m.changes === 'string', 'changes (what was done to the files) must be stated'); + need(m.orient && ['x+','x-','y+','y-','z+','z-'].includes(m.orient.up) && ['x+','x-','y+','y-','z+','z-'].includes(m.orient.front), 'orient needs up and front, each one of x+ x- y+ y- z+ z-'); + need(m.scale && Number.isFinite(m.scale.unitsToMetres) && m.scale.unitsToMetres > 0, 'scale.unitsToMetres is missing'); + need(Array.isArray(m.files) && m.files.length > 0, 'files is empty'); + const fileIds = new Set(); + for (const f of m.files ?? []) { + need(typeof f.id === 'string' && typeof f.entry === 'string', 'a file needs an id and an entry'); + need(!fileIds.has(f.id), `file ${f.id} is listed twice`); + fileIds.add(f.id); + } + need(Array.isArray(m.parts) && m.parts.length > 0, 'parts is empty'); + const keys = new Set(); + for (const p of m.parts ?? []) { + need(typeof p.key === 'string' && ID.test(p.key), `part key "${p.key}" is not a valid key`); + need(!keys.has(p.key), `part ${p.key} is listed twice`); + keys.add(p.key); + need(typeof p.name === 'string' && p.name.length > 0, `part ${p.key} has no name`); + need(CONFIDENCE.includes(p.confidence), `part ${p.key} needs a confidence (${CONFIDENCE.join(', ')})`); + need(Array.isArray(p.nodes) && p.nodes.length > 0 || p.derive, `part ${p.key} names no file`); + for (const n of p.nodes ?? []) need(fileIds.has(n), `part ${p.key} names ${n}, which is not in files`); + } + return out; +} + +export function readManifests() { + return readdirSync(MODELS_DIR).filter((f) => f.endsWith('.json')).sort().map((f) => { + const m = JSON.parse(readFileSync(join(MODELS_DIR, f), 'utf8')); + return { file: join(MODELS_DIR, f), manifest: m }; + }); +} diff --git a/scripts/assets/obj-glb.mjs b/scripts/assets/obj-glb.mjs new file mode 100644 index 00000000..55c92ffe --- /dev/null +++ b/scripts/assets/obj-glb.mjs @@ -0,0 +1,162 @@ +// Turning an atlas mesh into a part of a glTF binary, in plain functions (no packages): read an OBJ's vertices and faces, turn its axes and units into the +// scene's (x right, y up, z toward the viewer, metres), weld and smooth it, count whether it is closed, and write a GLB whose nodes are the named +// parts. The output is deterministic (no times, no random), so its hash is a fact about the inputs and this code. + +/** Vertices and triangles of an OBJ (`v x y z`, `f a b c` or `a/b/c`, with fans for faces of more than three corners). Nothing else is read. */ +export function parseObj(text) { + const pos = [], tri = []; + for (const raw of text.split('\n')) { + const line = raw.trim(); + if (line.startsWith('v ')) { + const p = line.split(/\s+/); + const v = [Number(p[1]), Number(p[2]), Number(p[3])]; + if (!v.every(Number.isFinite)) throw new Error(`bad vertex: ${line}`); + pos.push(v[0], v[1], v[2]); + } else if (line.startsWith('f ')) { + const ids = line.split(/\s+/).slice(1).map((t) => { + const i = parseInt(t.split('/')[0], 10); + return i < 0 ? pos.length / 3 + i : i - 1; + }); + for (let k = 1; k + 1 < ids.length; k++) tri.push(ids[0], ids[k], ids[k + 1]); + } + } + const count = pos.length / 3; + for (const i of tri) if (!(i >= 0 && i < count)) throw new Error(`a face names vertex ${i + 1}, which does not exist`); + return { positions: Float32Array.from(pos), indices: tri }; +} + +const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]; +const AXES = { 'x+': [1, 0, 0], 'x-': [-1, 0, 0], 'y+': [0, 1, 0], 'y-': [0, -1, 0], 'z+': [0, 0, 1], 'z-': [0, 0, -1] }; + +/** + * The rows that turn source coordinates into the scene's: the scene's up is the source's up axis, its front (toward the viewer) the source's front + * axis, and its right is up x front. A rotation (never a mirror), so a left stays a left. + */ +export function orientation(up, front) { + const u = AXES[up], f = AXES[front]; + if (!u || !f) throw new Error(`orient axes must be one of ${Object.keys(AXES).join(', ')}`); + if (u[0] * f[0] + u[1] * f[1] + u[2] * f[2] !== 0) throw new Error('up and front must be different axes'); + return { right: cross(u, f), up: u, front: f }; +} + +/** Positions into the scene's axes and metres. */ +export function transformPositions(positions, rows, unitsToMetres) { + const out = new Float32Array(positions.length); + for (let i = 0; i < positions.length; i += 3) { + const x = positions[i], y = positions[i + 1], z = positions[i + 2]; + out[i] = (x * rows.right[0] + y * rows.right[1] + z * rows.right[2]) * unitsToMetres; + out[i + 1] = (x * rows.up[0] + y * rows.up[1] + z * rows.up[2]) * unitsToMetres; + out[i + 2] = (x * rows.front[0] + y * rows.front[1] + z * rows.front[2]) * unitsToMetres; + } + return out; +} + +/** Joins vertices at the same place (the source repeats them), dropping degenerate triangles. */ +export function weld(positions, indices) { + const seen = new Map(), remap = new Int32Array(positions.length / 3), keep = []; + for (let i = 0, n = positions.length / 3; i < n; i++) { + const key = `${positions[i * 3]},${positions[i * 3 + 1]},${positions[i * 3 + 2]}`; + let at = seen.get(key); + if (at === undefined) { at = keep.length / 3; seen.set(key, at); keep.push(positions[i * 3], positions[i * 3 + 1], positions[i * 3 + 2]); } + remap[i] = at; + } + const tri = []; + for (let t = 0; t < indices.length; t += 3) { + const a = remap[indices[t]], b = remap[indices[t + 1]], c = remap[indices[t + 2]]; + if (a !== b && b !== c && a !== c) tri.push(a, b, c); + } + return { positions: Float32Array.from(keep), indices: tri }; +} + +/** Smooth vertex normals, each triangle weighted by its area. */ +export function normals(positions, indices) { + const n = new Float32Array(positions.length); + for (let t = 0; t < indices.length; t += 3) { + const [a, b, c] = [indices[t] * 3, indices[t + 1] * 3, indices[t + 2] * 3]; + const e1 = [positions[b] - positions[a], positions[b + 1] - positions[a + 1], positions[b + 2] - positions[a + 2]]; + const e2 = [positions[c] - positions[a], positions[c + 1] - positions[a + 1], positions[c + 2] - positions[a + 2]]; + const f = cross(e1, e2); + for (const v of [a, b, c]) { n[v] += f[0]; n[v + 1] += f[1]; n[v + 2] += f[2]; } + } + for (let i = 0; i < n.length; i += 3) { + const l = Math.hypot(n[i], n[i + 1], n[i + 2]) || 1; + n[i] /= l; n[i + 1] /= l; n[i + 2] /= l; + } + return n; +} + +/** True when every edge is shared by exactly two triangles (a watertight solid, so a cut can be capped). */ +export function isClosed(indices) { + const edges = new Map(); + for (let t = 0; t < indices.length; t += 3) { + for (let k = 0; k < 3; k++) { + const a = indices[t + k], b = indices[t + (k + 1) % 3]; + const key = a < b ? `${a}|${b}` : `${b}|${a}`; + edges.set(key, (edges.get(key) ?? 0) + 1); + } + } + for (const c of edges.values()) if (c !== 2) return false; + return indices.length > 0; +} + +export function bounds(positions) { + const min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity]; + for (let i = 0; i < positions.length; i += 3) for (let k = 0; k < 3; k++) { min[k] = Math.min(min[k], positions[i + k]); max[k] = Math.max(max[k], positions[i + k]); } + return { min, max, center: min.map((v, k) => (v + max[k]) / 2), size: min.map((v, k) => max[k] - v) }; +} + +/** Joins several meshes into one (indices moved on by the vertices before them). */ +export function merge(meshes) { + let vertices = 0, tris = 0; + for (const m of meshes) { vertices += m.positions.length; tris += m.indices.length; } + const positions = new Float32Array(vertices), indices = []; + let at = 0; + for (const m of meshes) { positions.set(m.positions, at); for (const i of m.indices) indices.push(i + at / 3); at += m.positions.length; } + return { positions, indices }; +} + +const pad4 = (n) => (n + 3) & ~3; + +/** + * A GLB: one scene, a root node (the model), and under it one node for each part with its mesh, centred on itself, and its own translation. Each node + * carries `extras` (the part's key, the atlas files it came from, its confidence). Positions, normals and 32-bit indices, one flat colour as the + * material (the app picks its own surface by name; this is for any other viewer). + */ +export function writeGlb(root, parts) { + const chunks = [], views = [], accessors = [], meshes = [], materials = [], nodes = [{ name: root, children: [] }]; + const push = (bytes, target) => { + const offset = chunks.reduce((n, c) => n + c.length, 0); + const buf = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength); + chunks.push(buf, Buffer.alloc(pad4(buf.length) - buf.length)); + views.push({ buffer: 0, byteOffset: offset, byteLength: buf.length, ...(target ? { target } : {}) }); + return views.length - 1; + }; + for (const part of parts) { + const b = bounds(part.positions); + const local = new Float32Array(part.positions.length); + for (let i = 0; i < local.length; i += 3) for (let k = 0; k < 3; k++) local[i + k] = part.positions[i + k] - b.center[k]; + const nrm = normals(local, part.indices); + const idx = Uint32Array.from(part.indices); + const pv = push(local, 34962), nv = push(nrm, 34962), iv = push(idx, 34963); + const lb = bounds(local); + accessors.push({ bufferView: pv, componentType: 5126, count: local.length / 3, type: 'VEC3', min: lb.min, max: lb.max }); + accessors.push({ bufferView: nv, componentType: 5126, count: nrm.length / 3, type: 'VEC3' }); + accessors.push({ bufferView: iv, componentType: 5125, count: idx.length, type: 'SCALAR' }); + const a = accessors.length - 3; + materials.push({ name: part.key, pbrMetallicRoughness: { baseColorFactor: [...(part.color ?? [200, 200, 200]).map((c) => Math.round((c / 255) * 1000) / 1000), 1], metallicFactor: 0, roughnessFactor: 0.6 } }); + meshes.push({ name: part.key, primitives: [{ attributes: { POSITION: a, NORMAL: a + 1 }, indices: a + 2, material: materials.length - 1 }] }); + nodes.push({ name: part.key, mesh: meshes.length - 1, translation: b.center.map((v) => Math.round(v * 1e7) / 1e7), extras: { key: part.key, files: part.files, confidence: part.confidence } }); + nodes[0].children.push(nodes.length - 1); + } + const bin = Buffer.concat(chunks); + const json = { asset: { version: '2.0', generator: 'talkthrough assets:build' }, scene: 0, scenes: [{ nodes: [0] }], nodes, meshes, materials, accessors, bufferViews: views, buffers: [{ byteLength: bin.length }] }; + let js = Buffer.from(JSON.stringify(json)); + js = Buffer.concat([js, Buffer.alloc(pad4(js.length) - js.length, 0x20)]); + const total = 12 + 8 + js.length + 8 + bin.length; + const out = Buffer.alloc(total); + out.writeUInt32LE(0x46546c67, 0); out.writeUInt32LE(2, 4); out.writeUInt32LE(total, 8); + out.writeUInt32LE(js.length, 12); out.writeUInt32LE(0x4e4f534a, 16); js.copy(out, 20); + const o = 20 + js.length; + out.writeUInt32LE(bin.length, o); out.writeUInt32LE(0x004e4942, o + 4); bin.copy(out, o + 8); + return out; +} diff --git a/scripts/assets/ship.mjs b/scripts/assets/ship.mjs new file mode 100644 index 00000000..48a0b5a4 --- /dev/null +++ b/scripts/assets/ship.mjs @@ -0,0 +1,27 @@ +// Puts the built model files and the credits next to the app: dist/models/*.glb and dist/CREDITS.md. A file is copied only if it is the one the manifest +// pins (by hash). Without the files (a fresh clone that has not run `npm run assets`) the app still builds and the models fall back to shapes; +// `strict` (the installer) refuses to go on without them. + +import { copyFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { BUILT_DIR, ROOT, readManifests, sha256 } from './manifest.mjs'; + +export function shipModels({ strict = false, out = join(ROOT, 'dist') } = {}) { + const missing = []; + const shipped = []; + for (const { manifest: m } of readManifests()) { + const file = join(BUILT_DIR, m.built?.file ?? `${m.id}.glb`); + if (!m.built || !existsSync(file) || sha256(readFileSync(file)) !== m.built.sha256) { missing.push(m.id); continue; } + mkdirSync(join(out, 'models'), { recursive: true }); + copyFileSync(file, join(out, 'models', m.built.file)); + shipped.push(m.id); + } + const credits = join(ROOT, 'assets', 'CREDITS.md'); + if (existsSync(credits)) copyFileSync(credits, join(out, 'CREDITS.md')); + if (missing.length) { + const why = `real models not built (${missing.join(', ')}): run npm run assets to fetch and build them; until then they are drawn from shapes`; + if (strict) throw new Error(why); + console.warn(`talkthrough: ${why}`); + } + return { shipped, missing }; +} diff --git a/scripts/assets/zip-range.mjs b/scripts/assets/zip-range.mjs new file mode 100644 index 00000000..af230362 --- /dev/null +++ b/scripts/assets/zip-range.mjs @@ -0,0 +1,50 @@ +// Reads single files out of a large zip without downloading the whole archive: the end of the zip names where its directory is, the directory names +// every file and where it starts, and each file is then a small byte range. `read(start, end)` is any function that returns those bytes (end is +// exclusive), so the same code runs against an HTTP server that accepts ranges and against a buffer in a test. Plain and deflated entries only, and +// no zip64: an archive that needs it is refused rather than half read. + +import { inflateRawSync } from 'node:zlib'; + +const EOCD_SIG = 0x06054b50, CEN_SIG = 0x02014b50, LOC_SIG = 0x04034b50; + +/** The directory of the archive: one record for each file in it. */ +export async function readDirectory(size, read) { + const tail = Math.min(size, 65557 + 22); + const end = await read(size - tail, size); + let at = -1; + for (let i = end.length - 22; i >= 0; i--) if (end.readUInt32LE(i) === EOCD_SIG) { at = i; break; } + if (at < 0) throw new Error('not a zip (no end record)'); + const count = end.readUInt16LE(at + 10), cdSize = end.readUInt32LE(at + 12), cdStart = end.readUInt32LE(at + 16); + if (count === 0xffff || cdSize === 0xffffffff || cdStart === 0xffffffff) throw new Error('zip64 archives are not supported'); + const cd = await read(cdStart, cdStart + cdSize); + const files = []; + for (let p = 0, n = 0; n < count; n++) { + if (cd.readUInt32LE(p) !== CEN_SIG) throw new Error('bad directory record'); + const method = cd.readUInt16LE(p + 10), crc = cd.readUInt32LE(p + 16), csize = cd.readUInt32LE(p + 20), usize = cd.readUInt32LE(p + 24); + const nameLen = cd.readUInt16LE(p + 28), extraLen = cd.readUInt16LE(p + 30), commentLen = cd.readUInt16LE(p + 32), offset = cd.readUInt32LE(p + 42); + const name = cd.toString('utf8', p + 46, p + 46 + nameLen); + files.push({ name, method, crc, compressedSize: csize, size: usize, offset }); + p += 46 + nameLen + extraLen + commentLen; + } + return files; +} + +/** One file's bytes, checked against its size and its crc. */ +export async function readEntry(entry, read) { + const head = await read(entry.offset, entry.offset + 30); + if (head.readUInt32LE(0) !== LOC_SIG) throw new Error(`bad local header for ${entry.name}`); + const start = entry.offset + 30 + head.readUInt16LE(26) + head.readUInt16LE(28); + const raw = await read(start, start + entry.compressedSize); + const data = entry.method === 0 ? raw : entry.method === 8 ? inflateRawSync(raw) : (() => { throw new Error(`unsupported compression ${entry.method} for ${entry.name}`); })(); + if (data.length !== entry.size) throw new Error(`size of ${entry.name} is ${data.length}, the archive says ${entry.size}`); + return data; +} + +/** A `read` that asks an HTTP server for byte ranges. */ +export function httpRange(url, fetchImpl = fetch) { + return async (start, end) => { + const response = await fetchImpl(url, { headers: { Range: `bytes=${start}-${end - 1}` } }); + if (response.status !== 206) throw new Error(`${url}: the server did not give the range ${start}-${end - 1} (status ${response.status})`); + return Buffer.from(await response.arrayBuffer()); + }; +} diff --git a/scripts/build.mjs b/scripts/build.mjs index 54437b56..a7415e0b 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -4,6 +4,7 @@ import { copyFileSync, existsSync, mkdirSync } from 'node:fs'; import { dirname } from 'node:path'; import { build } from 'esbuild'; +import { shipModels } from './assets/ship.mjs'; const node = { platform: 'node', format: 'cjs' }; const browser = { platform: 'browser', format: 'iife' }; @@ -46,3 +47,5 @@ for (const [from, to] of pages) { copyFileSync(from, to); console.log(`copied ${to}`); } +const models = shipModels(); +if (models.shipped.length) console.log('copied models', models.shipped.join(', ')); diff --git a/scripts/dist.mjs b/scripts/dist.mjs index ce960192..13cf8ed1 100644 --- a/scripts/dist.mjs +++ b/scripts/dist.mjs @@ -4,6 +4,7 @@ import { spawnSync } from 'node:child_process'; import { createRequire } from 'node:module'; import { ensureElectronOrExit } from './ensure-electron.mjs'; import { checkNativeInputs } from './native-packaging.mjs'; +import { shipModels } from './assets/ship.mjs'; const run = (command, args) => { const result = spawnSync(command, args, { stdio: 'inherit', env: { ...process.env, CSC_IDENTITY_AUTO_DISCOVERY: 'false' } }); @@ -15,5 +16,6 @@ if (checkNativeInputs('node_modules') !== 0) { } ensureElectronOrExit(); // electron-builder packs the Electron in node_modules/electron/dist run(process.execPath, ['scripts/build.mjs']); +shipModels({ strict: true }); // the installer carries the real models: refuse to pack one that cannot show them const cli = createRequire(import.meta.url).resolve('electron-builder/cli.js'); run(process.execPath, [cli, '--win', '--x64', '--publish', 'never', ...process.argv.slice(2)]); diff --git a/src/main/main.ts b/src/main/main.ts index b03034ba..5076831e 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -1,5 +1,5 @@ import { app, clipboard, dialog, safeStorage, screen, shell } from 'electron'; -import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; +import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; import { join, sep } from 'node:path'; import { isCheckRun, parseArgs, wantsSoftware } from './args.ts'; import { createHttpBackend } from '../adapters/backend.ts'; @@ -598,6 +598,13 @@ async function main(): Promise { session?.reset(); }, onVisualTour: () => visualTour.open(), + onCredits: () => { + const source = join(__dirname, '..', 'CREDITS.md'); + if (!existsSync(source)) return; + void dialog.showSaveDialog({ title: 'Save the 3D model credits', defaultPath: 'Talkthrough-model-credits.md', filters: [{ name: 'Markdown', extensions: ['md'] }] }).then((r) => { + if (!r.canceled && r.filePath) copyFileSync(source, r.filePath); + }); + }, onPlaySample: () => playSample(screen.getPrimaryDisplay().id), onSettings: () => settingsWindow.open(), hotkeyLabel: chord.label, diff --git a/src/main/tray.ts b/src/main/tray.ts index e3afc39f..5095c219 100644 --- a/src/main/tray.ts +++ b/src/main/tray.ts @@ -30,6 +30,8 @@ export function createTray(handlers: { onPlaySample(): void; /** Browse the offline visual examples. */ onVisualTour?(): void; + /** Save the credits file for the 3D models (their licences and who made them) where the person chooses. */ + onCredits?(): void; onClear(): void; /** Opens the settings window. */ onSettings(): void; @@ -56,6 +58,7 @@ export function createTray(handlers: { { type: 'separator' }, ...(handlers.guideActions ? guideItems(handlers.guideActions) : []), ...(handlers.onVisualTour ? [{ label: 'Explore visual examples…', click: handlers.onVisualTour }] : []), + ...(handlers.onCredits ? [{ label: 'Save the 3D model credits…', click: handlers.onCredits }] : []), { label: 'Play a sample scene', click: handlers.onPlaySample }, { label: 'Clear the overlay', click: handlers.onClear }, { label: 'Settings…', click: handlers.onSettings }, diff --git a/src/overlay/index.html b/src/overlay/index.html index d86f6510..b7798b4d 100644 --- a/src/overlay/index.html +++ b/src/overlay/index.html @@ -3,7 +3,7 @@ Talkthrough overlay - +