diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c298edd --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# The real models are plain binaries in git (no LFS): never converted, merged or diffed as text. +assets/built/*.glb binary +*.glb binary diff --git a/.gitignore b/.gitignore index 6bc990e..009c816 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,16 @@ dist/ .DS_Store Thumbs.db release/ + +# real models: the raw downloads are not in git (see scripts/assets and assets/models). The built files are not either, except those of the models a release +# carries (CC0, each pinned by hash in its manifest): they are committed as plain binaries (see .gitattributes), so a fresh clone can build and pack a release. +# A model held back from releases is never listed here. +assets/cache/ +assets/built/* +!assets/built/alarm-clock.glb +!assets/built/bolt-cutters.glb +!assets/built/camera.glb +!assets/built/drill.glb +!assets/built/electric-motor.glb +!assets/built/measuring-tape.glb +!assets/built/mousetrap.glb diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 23cde5b..dcf819f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,6 +32,10 @@ The app works on your real screen: be careful with `--visible-to-capture` and wi The app's windows are hidden from screen capture only for the moment of its own screenshot (`src/main/capture-shield.ts`), so they show in a person's recordings and screen shares the rest of the time. `--visible-to-capture` keeps them in our own screenshots too, which is only for looking at a run. `node_modules/.bin/electron scripts/capture-check.cjs` (needs a visible window, so run it yourself, not in CI) checks that our drawing is absent from our capture and present otherwise, and finds how long the change needs to take effect on your machine. +## Real models + +The 3D models of real things (a heart, a brain) are described by manifests in `assets/models`; their sources are fetched once into an ignored cache, never committed, and the finished files of the models a release carries (the CC0 objects) are committed in `assets/built` as plain binaries; see [docs/real-models.md](docs/real-models.md). Without them the app still runs: a scene that uses one of those models shows the stage without it and says so, and the tests that read a built file skip when it is absent. + ## Testing ``` diff --git a/README.md b/README.md index a8fa8c9..bfc3f38 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Windows is the first platform. Mouse circling and model dragging have reported f ## Contribute -Talkthrough is open source under the [MIT license](LICENSE). The scene language, overlay, and adapters are documented in [CONTRIBUTING.md](CONTRIBUTING.md), [the scene language guide](docs/scene-language.md), and [the overlay notes](docs/overlay.md). Mac and Linux support are planned. +Talkthrough is open source under the [MIT license](LICENSE), which covers its code only: the real 3D models it can show are separate works under their own licences, named in [assets/CREDITS.md](assets/CREDITS.md), and are not part of the MIT grant. The scene language, overlay, and adapters are documented in [CONTRIBUTING.md](CONTRIBUTING.md), [the scene language guide](docs/scene-language.md), and [the overlay notes](docs/overlay.md). Mac and Linux support are planned. For a development checkout, install Node.js 24 or newer, then run: diff --git a/assets/CREDITS.md b/assets/CREDITS.md new file mode 100644 index 0000000..63f1b95 --- /dev/null +++ b/assets/CREDITS.md @@ -0,0 +1,130 @@ +# Credits for the real models + +Talkthrough's own code is MIT licensed. The MIT licence covers that code only: it excludes the models named here, which are separate works under their own licences, listed below with who made them and what was changed. +This file is generated from `assets/models/*.json` (`npm run assets:index`) and is shipped with the app. + +## Alarm clock (`alarm-clock`) + +- Source: Poly Haven, https://polyhaven.com/a/alarm_clock_01 (Alarm Clock 01, 1k glTF, published 2021-08-13) +- Licence: CC0 1.0 Universal, version 1.0: https://creativecommons.org/publicdomain/zero/1.0/ +- As the licence is stated at https://polyhaven.com/license: Our assets are all licensed as CC0. You do not need to give credit. +- Made by: Yann Kervran (rigging), James Ray Cock (modelling and texturing) (no credit is required; named here as a courtesy) +- Fetched on 2026-11-08 from: https://dl.polyhaven.org/file/ph-assets/Models/gltf/8k/alarm_clock_01/alarm_clock_01.bin and 4 more files named in the manifest +- Changes: Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part. +- Built file: alarm-clock.glb, 3017188 bytes, sha256 783a73ee344b333a8a878d2a02254fe47f1622aef8752a0aaa014c00c63a3096 +- Parts (source node): Clock body and glass (alarm_clock_01); Hour hand (houd_hand); Minute hand (minute_hand); Second hand (second_hand) + +## Bolt cutters (`bolt-cutters`) + +- Source: Poly Haven, https://polyhaven.com/a/bolt_cutters_01 (Bolt Cutters 01, 1k glTF, published 2022-12-02) +- Licence: CC0 1.0 Universal, version 1.0: https://creativecommons.org/publicdomain/zero/1.0/ +- As the licence is stated at https://polyhaven.com/license: Our assets are all licensed as CC0. You do not need to give credit. +- Made by: Yann Kervran (rigging), Antanas Kep (modelling and texturing) (no credit is required; named here as a courtesy) +- Fetched on 2026-11-08 from: https://dl.polyhaven.org/file/ph-assets/Models/gltf/4k/bolt_cutters_01/bolt_cutters_01.bin and 4 more files named in the manifest +- Changes: Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part. +- Built file: bolt-cutters.glb, 2496808 bytes, sha256 470c491d351b1bf2831d69511bcdb18a01243a5eaf8881db0de84874f13217a0 +- Parts (source node): Bolt cutters (bolt_cutters_01) +- Limit: A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart. + +## 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)) +- Source archive: https://dbarchive.biosciencedbc.jp/data/bodyparts3d/LATEST/isa_BP3D_4.0_obj_99.zip (142903898 bytes) +- Licence: CC BY 4.0, version 4.0 International: https://dbarchive.biosciencedbc.jp/en/bodyparts3d/lic.html +- Earlier notice, kept on record: the header of every OBJ file in the 2013 archive name CC Attribution-ShareAlike 2.1 Japan; the current grant above is what is relied on. +- Held back from releases: a local prototype only: not published and not packed into a release until it is cleared for one. +- Credit: BodyParts3D, © The Database Center for Life Science licensed under CC Attribution 4.0 International +- 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 licensor's current statement (the database licence page updated 2025-02-27, and the README) is CC BY 4.0 International, and it is what is relied on. The OBJ files in the 2013 archive still carry an older header naming CC Attribution-ShareAlike 2.1 Japan; that is recorded here and kept in the credits, not erased. +- Built file: brain.glb, 8358176 bytes, sha256 0d353d478830dff8e6fac252909c2e236229932336e63eb8a7665179b2f914d1 +- Parts (confidence; source element ids): Frontal lobe (grouped; FJ1833 FJ1834 FJ1787 FJ1788 FJ1744 FJ1745 FJ1800 FJ1801 FJ1793 FJ1794); Parietal lobe (grouped; FJ1797 FJ1798 FJ1841 FJ1842 FJ1732 FJ1733 FJ1835 FJ1836); Temporal lobe (grouped; FJ1746 FJ1747 FJ1789 FJ1790 FJ1783 FJ1784 FJ1785 FJ1786 FJ1837 FJ1838); Occipital lobe (atlas; FJ1791 FJ1792); Insula (atlas; FJ1748 FJ1749); Cingulate gyrus (atlas; FJ1739 FJ1740); Cerebellum (atlas; FJ1781 FJ1830); Pons (atlas; FJ1775 FJ1822); Medulla oblongata (atlas; FJ1769 FJ1831); Midbrain (atlas; FJ1770 FJ1817); Thalamus (atlas; FJ1782 FJ1827); Hypothalamus (atlas; FJ1760 FJ1808); Hippocampus (atlas; FJ1759 FJ1807); Amygdala (atlas; FJ1753 FJ1829); Caudate nucleus (atlas; FJ1754 FJ1802); Globus pallidus (atlas; FJ1757 FJ1805); Corpus callosum (atlas; FJ1742); Cerebral white matter (atlas; FJ1758 FJ1806); Lateral ventricles (atlas; FJ1767 FJ1814); Pituitary gland (atlas; FJ1796) +- 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. + +## Vintage camera (`camera`) + +- Source: Poly Haven, https://polyhaven.com/a/Camera_01 (Camera 01, 1k glTF, published 2020-03-30) +- Licence: CC0 1.0 Universal, version 1.0: https://creativecommons.org/publicdomain/zero/1.0/ +- As the licence is stated at https://polyhaven.com/license: Our assets are all licensed as CC0. You do not need to give credit. +- Made by: Rajil Jose Macatangay (no credit is required; named here as a courtesy) +- Fetched on 2026-11-08 from: https://dl.polyhaven.org/file/ph-assets/Models/gltf/8k/Camera_01/Camera_01.bin and 10 more files named in the manifest +- Changes: Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part. +- Built file: camera.glb, 2436424 bytes, sha256 538e0612753fce31aa31da50426567ed4336853d20afab07d2a033e80de7b31a +- Parts (source node): Strap (Camera_01_strap); Camera body and lens (Camera_01) + +## Power drill (`drill`) + +- Source: Poly Haven, https://polyhaven.com/a/Drill_01 (Drill 01, 1k glTF, published 2020-03-30) +- Licence: CC0 1.0 Universal, version 1.0: https://creativecommons.org/publicdomain/zero/1.0/ +- As the licence is stated at https://polyhaven.com/license: Our assets are all licensed as CC0. You do not need to give credit. +- Made by: Fernando Quinn (no credit is required; named here as a courtesy) +- Fetched on 2026-11-08 from: https://dl.polyhaven.org/file/ph-assets/Models/gltf/4k/Drill_01/Drill_01.bin and 4 more files named in the manifest +- Changes: Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part. +- Built file: drill.glb, 500292 bytes, sha256 a5afd4c33c8d24b4c2f5a0978047654e81835adcf38a4f7de916dfd2cee7683b +- Parts (source node): Power drill (Drill_01) +- Limit: A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart. + +## Davenport electric motor (`electric-motor`) + +- Source: Smithsonian Open Access, https://3d-api.si.edu/voyager/3d_package:a18922b9-a00f-4c9e-988a-f526382b15cc (Davenport electric motor, US patent #132, record edanmdm:nmah_703302) +- Licence: CC0 1.0 Universal, version 1.0: https://creativecommons.org/publicdomain/zero/1.0/ +- As the licence is stated at https://api.si.edu/openaccess/api/v1.0/content/edanmdm:nmah_703302: The 3D media of the record carries usage access "CC0" (read from the Smithsonian Open Access API record on 2026-11-08). +- Made by: Smithsonian National Museum of American History, Digitization Program Office (no credit is required; named here as a courtesy) +- Fetched on 2026-11-08 from: https://3d-api.si.edu/content/document/3d_package:a18922b9-a00f-4c9e-988a-f526382b15cc/resources/Davenport_motor-100k-2048_std.glb +- Changes: Passed through: the geometry, texture coordinates, material and textures are the museum's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on the part. +- Built file: electric-motor.glb, 4335360 bytes, sha256 d26c1f8dbdfca5abc178136004ccc52ec6c6877be03fcfb423e397975fcf8be1 +- Parts (source node): Davenport electric motor (#0) +- Limit: A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart. +- Limit: The source's textures are larger than the page draws them at; they are reduced when loaded, to the size each tier allows. + +## 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)) +- Source archive: https://dbarchive.biosciencedbc.jp/data/bodyparts3d/LATEST/isa_BP3D_4.0_obj_99.zip (142903898 bytes) +- Licence: CC BY 4.0, version 4.0 International: https://dbarchive.biosciencedbc.jp/en/bodyparts3d/lic.html +- Earlier notice, kept on record: the header of every OBJ file in the 2013 archive name CC Attribution-ShareAlike 2.1 Japan; the current grant above is what is relied on. +- Held back from releases: a local prototype only: not published and not packed into a release until it is cleared for one. +- Credit: BodyParts3D, © The Database Center for Life Science licensed under CC Attribution 4.0 International +- 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 licensor's current statement (the database licence page updated 2025-02-27, and the README) is CC BY 4.0 International, and it is what is relied on. The OBJ files in the 2013 archive still carry an older header naming CC Attribution-ShareAlike 2.1 Japan; that is recorded here and kept in the credits, not erased. +- Built file: heart.glb, 2558152 bytes, sha256 309af9886b9388323beb7e9c933c2b1f2a30b05ba93768eda6c8999b7da20ef1 +- Parts (confidence; source element ids): Right atrium (atlas; FJ2424); Wall of the right atrium (atlas; FJ2439); Left atrium (atlas; FJ2425); Wall of the left atrium (atlas; FJ2438); Right ventricle (atlas; FJ2423); Left ventricle (atlas; FJ2422); Mitral valve (grouped; FJ2420 FJ2432); Tricuspid valve (grouped; FJ2421 FJ2433 FJ2436); Aortic valve (grouped; FJ2435 FJ2426 FJ2431); Pulmonary valve (grouped; FJ2417 FJ2427 FJ2434); Papillary muscles (grouped; FJ2418 FJ2419 FJ2429 FJ2430 FJ2437); Ascending aorta (atlas; FJ3413); Arch of the aorta (atlas; FJ3411); Pulmonary trunk (atlas; FJ2966); Superior vena cava (atlas; FJ3645); Left coronary artery and its branches (grouped; 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); Right coronary artery and its branches (grouped; 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); Cardiac veins (grouped; FJ2655 FJ2656 FJ2724 FJ2727 FJ2728 FJ2729 FJ2731) +- 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. + +## Measuring tape (`measuring-tape`) + +- Source: Poly Haven, https://polyhaven.com/a/measuring_tape_01 (Measuring Tape 01, 1k glTF, published 2021-10-15) +- Licence: CC0 1.0 Universal, version 1.0: https://creativecommons.org/publicdomain/zero/1.0/ +- As the licence is stated at https://polyhaven.com/license: Our assets are all licensed as CC0. You do not need to give credit. +- Made by: Kuutti Siitonen (no credit is required; named here as a courtesy) +- Fetched on 2026-11-08 from: https://dl.polyhaven.org/file/ph-assets/Models/gltf/4k/measuring_tape_01/measuring_tape_01.bin and 4 more files named in the manifest +- Changes: Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part. +- Built file: measuring-tape.glb, 445184 bytes, sha256 a947441fd19e3a5b89f27f62510c805e36dd0077120e966729ddd3bec21713e9 +- Parts (source node): Measuring tape (measuring_tape_01) +- Limit: A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart. + +## Mousetrap (`mousetrap`) + +- Source: Poly Haven, https://polyhaven.com/a/mousetrap (Mousetrap, 1k glTF, published 2023-05-19) +- Licence: CC0 1.0 Universal, version 1.0: https://creativecommons.org/publicdomain/zero/1.0/ +- As the licence is stated at https://polyhaven.com/license: Our assets are all licensed as CC0. You do not need to give credit. +- Made by: GreenPixel (no credit is required; named here as a courtesy) +- Fetched on 2026-11-08 from: https://dl.polyhaven.org/file/ph-assets/Models/gltf/4k/mousetrap/mousetrap.bin and 4 more files named in the manifest +- Changes: Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part. +- Built file: mousetrap.glb, 2233796 bytes, sha256 04def5d43d0c40c2b8a905c65115407c6e3623cc0dc17e95c07e9812ac8194c3 +- Parts (source node): Mousetrap (mousetrap) +- Limit: A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart. + +## Morse-Vail telegraph key (`telegraph-key`) + +- Source: Smithsonian Open Access, https://3d-api.si.edu/voyager/3d_package:ed99f44d-3c60-4111-b666-e2908e1b64ef (Morse-Vail Telegraph Key, record edanmdm:nmah_1096762) +- Licence: CC0 1.0 Universal, version 1.0: https://creativecommons.org/publicdomain/zero/1.0/ +- Held back from releases: licence unverified: CC0 seen only in a search snippet, the record itself not read (its page returned 403 and the Open Access API refused the lookup). +- As the licence is stated at https://www.si.edu/object/nmah_1096762: Licence unverified: listed as CC0 on its Smithsonian 3D record (seen in a search result on 2026-11-09; the record page itself would not load for us and the Open Access API refused the lookup, so this one is not read from the record directly). +- Made by: Smithsonian National Museum of American History, Digitization Program Office (no credit is required; named here as a courtesy) +- Fetched on 2026-11-08 from: https://3d-api.si.edu/content/document/3d_package:ed99f44d-3c60-4111-b666-e2908e1b64ef/resources/morse-telegraph-key-150k-4096.glb +- Changes: Passed through: the geometry, texture coordinates, material and textures are the museum's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on the part. +- Built file: telegraph-key.glb, 7582656 bytes, sha256 40aed26cdcb2b5a9b29d6fad85ce3b7ff2309c39ab893320c4f3fc69fc99cc0a +- Parts (source node): Morse-Vail telegraph key (#0) +- Limit: A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart. +- Limit: The source's textures are larger than the page draws them at; they are reduced when loaded, to the size each tier allows. diff --git a/assets/built/alarm-clock.glb b/assets/built/alarm-clock.glb new file mode 100644 index 0000000..a9a7203 Binary files /dev/null and b/assets/built/alarm-clock.glb differ diff --git a/assets/built/bolt-cutters.glb b/assets/built/bolt-cutters.glb new file mode 100644 index 0000000..cec7481 Binary files /dev/null and b/assets/built/bolt-cutters.glb differ diff --git a/assets/built/camera.glb b/assets/built/camera.glb new file mode 100644 index 0000000..d7e7984 Binary files /dev/null and b/assets/built/camera.glb differ diff --git a/assets/built/drill.glb b/assets/built/drill.glb new file mode 100644 index 0000000..d555f49 Binary files /dev/null and b/assets/built/drill.glb differ diff --git a/assets/built/electric-motor.glb b/assets/built/electric-motor.glb new file mode 100644 index 0000000..f9d7b26 Binary files /dev/null and b/assets/built/electric-motor.glb differ diff --git a/assets/built/measuring-tape.glb b/assets/built/measuring-tape.glb new file mode 100644 index 0000000..e70d9ce Binary files /dev/null and b/assets/built/measuring-tape.glb differ diff --git a/assets/built/mousetrap.glb b/assets/built/mousetrap.glb new file mode 100644 index 0000000..f9c32cb Binary files /dev/null and b/assets/built/mousetrap.glb differ diff --git a/assets/models/alarm-clock.json b/assets/models/alarm-clock.json new file mode 100644 index 0000000..f416a73 --- /dev/null +++ b/assets/models/alarm-clock.json @@ -0,0 +1,221 @@ +{ + "id": "alarm-clock", + "name": "Alarm clock", + "description": "A twin-bell alarm clock with its glass, hour, minute and second hands, as a textured model", + "aliases": [ + "alarm clock", + "clock", + "bedside clock" + ], + "format": "gltf", + "licence": { + "id": "CC0-1.0", + "version": "1.0", + "statedOn": "https://polyhaven.com/license", + "statement": "Our assets are all licensed as CC0. You do not need to give credit." + }, + "source": { + "name": "Poly Haven", + "url": "https://polyhaven.com/a/alarm_clock_01", + "version": "Alarm Clock 01, 1k glTF, published 2021-08-13", + "authors": [ + "Yann Kervran (rigging)", + "James Ray Cock (modelling and texturing)" + ], + "cacheFolder": "ph-alarm-clock-01" + }, + "retrieved": "2026-11-08", + "changes": "Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part.", + "orient": { + "up": "y+", + "front": "z+" + }, + "scale": { + "unitsToMetres": 1 + }, + "caveats": [], + "files": [ + { + "entry": "alarm_clock_01.bin", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/8k/alarm_clock_01/alarm_clock_01.bin", + "bytes": 284408, + "sha256": "74b589dc31596fe9350e8ef6d123571955d58cee9955060d831fa0f3055758c6" + }, + { + "entry": "alarm_clock_01_1k.gltf", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/1k/alarm_clock_01/alarm_clock_01_1k.gltf", + "bytes": 10056, + "sha256": "ca16e83e334e28f8eaf2bf1fbf8ce043b7e4fe5d0e171d01a264b12f5f42a78c" + }, + { + "entry": "textures/alarm_clock_01_arm_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/alarm_clock_01/alarm_clock_01_arm_1k.jpg", + "bytes": 538163, + "sha256": "99727eb8908dfea5aac2a2353af7ff60857e40c50b396d7efbe15df685fe4918" + }, + { + "entry": "textures/alarm_clock_01_diff_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/alarm_clock_01/alarm_clock_01_diff_1k.jpg", + "bytes": 404998, + "sha256": "deb82094c2c1aa8cda0a0ce7192b193a81c5376743344503764abbcd2db19ac1" + }, + { + "entry": "textures/alarm_clock_01_nor_gl_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/alarm_clock_01/alarm_clock_01_nor_gl_1k.jpg", + "bytes": 420026, + "sha256": "a0a7b35de5712e23d06832e49516ec0e1170aa159eb60ec9b2af0b0df2102fa4" + } + ], + "parts": [ + { + "key": "body", + "name": "Clock body and glass", + "aliases": [ + "clock body", + "case", + "face" + ], + "confidence": "atlas", + "nodes": [ + "alarm_clock_01" + ] + }, + { + "key": "hour-hand", + "name": "Hour hand", + "aliases": [ + "hour hand", + "short hand" + ], + "confidence": "atlas", + "nodes": [ + "houd_hand" + ], + "hub": "node", + "explode": [ + 0, + 0, + 0.012 + ] + }, + { + "key": "minute-hand", + "name": "Minute hand", + "aliases": [ + "minute hand", + "long hand" + ], + "confidence": "atlas", + "nodes": [ + "minute_hand" + ], + "hub": "node", + "explode": [ + 0, + 0, + 0.024 + ] + }, + { + "key": "second-hand", + "name": "Second hand", + "aliases": [ + "second hand" + ], + "confidence": "atlas", + "nodes": [ + "second_hand" + ], + "hub": "node", + "explode": [ + 0, + 0, + 0.036 + ] + } + ], + "built": { + "file": "alarm-clock.glb", + "bytes": 3017188, + "sha256": "783a73ee344b333a8a878d2a02254fe47f1622aef8752a0aaa014c00c63a3096", + "triangles": 8985, + "size": [ + 0.131651, + 0.174155, + 0.066749 + ], + "parts": { + "body": { + "center": [ + 0, + 0, + 0 + ], + "size": [ + 0.131651, + 0.174155, + 0.066749 + ], + "closed": false, + "triangles": 8560 + }, + "hour-hand": { + "center": [ + 0.00588, + -0.039252, + 0.016068 + ], + "size": [ + 0.02046, + 0.0447, + 0.000593 + ], + "closed": false, + "triangles": 200, + "hub": [ + 0, + -0.021252, + -0.009132 + ] + }, + "minute-hand": { + "center": [ + -0.021117, + -0.010284, + 0.015462 + ], + "size": [ + 0.050875, + 0.030578, + 0.000602 + ], + "closed": false, + "triangles": 152, + "hub": [ + 0, + -0.021252, + -0.009132 + ] + }, + "second-hand": { + "center": [ + 0.009105, + 0.001433, + 0.015015 + ], + "size": [ + 0.024956, + 0.052116, + 0.000158 + ], + "closed": false, + "triangles": 73, + "hub": [ + 0, + -0.021252, + -0.009132 + ] + } + } + } +} diff --git a/assets/models/bolt-cutters.json b/assets/models/bolt-cutters.json new file mode 100644 index 0000000..04d380f --- /dev/null +++ b/assets/models/bolt-cutters.json @@ -0,0 +1,109 @@ +{ + "id": "bolt-cutters", + "name": "Bolt cutters", + "description": "Long-handled bolt cutters, as one textured object", + "aliases": [ + "bolt cutters", + "bolt cutter", + "bolt croppers" + ], + "format": "gltf", + "licence": { + "id": "CC0-1.0", + "version": "1.0", + "statedOn": "https://polyhaven.com/license", + "statement": "Our assets are all licensed as CC0. You do not need to give credit." + }, + "source": { + "name": "Poly Haven", + "url": "https://polyhaven.com/a/bolt_cutters_01", + "version": "Bolt Cutters 01, 1k glTF, published 2022-12-02", + "authors": [ + "Yann Kervran (rigging)", + "Antanas Kep (modelling and texturing)" + ], + "cacheFolder": "ph-bolt-cutters-01" + }, + "retrieved": "2026-11-08", + "changes": "Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part.", + "orient": { + "up": "y+", + "front": "z+" + }, + "scale": { + "unitsToMetres": 1 + }, + "caveats": [ + "A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart." + ], + "files": [ + { + "entry": "bolt_cutters_01.bin", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/4k/bolt_cutters_01/bolt_cutters_01.bin", + "bytes": 94700, + "sha256": "ca59727481d2edca3a3177966d816c2e074f7ee182cef94b7fc4b67d6ded8aa2" + }, + { + "entry": "bolt_cutters_01_1k.gltf", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/1k/bolt_cutters_01/bolt_cutters_01_1k.gltf", + "bytes": 2797, + "sha256": "eedd7c98341e85013c753af0406bac3b58d4e485a2730e611c08dcb4cc2f3a81" + }, + { + "entry": "textures/bolt_cutters_01_arm_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/bolt_cutters_01/bolt_cutters_01_arm_1k.jpg", + "bytes": 810127, + "sha256": "1335d3c5e266be103dcf983c34450213d23796d66b1c7ba0bfc1026ee77041b2" + }, + { + "entry": "textures/bolt_cutters_01_diff_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/bolt_cutters_01/bolt_cutters_01_diff_1k.jpg", + "bytes": 777857, + "sha256": "e525175e4e94d2e7800dd24e8f1005ae0b34b06572cd71ef144b5fabe245fb24" + }, + { + "entry": "textures/bolt_cutters_01_nor_gl_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/bolt_cutters_01/bolt_cutters_01_nor_gl_1k.jpg", + "bytes": 812150, + "sha256": "49228dda2096f76534907f3b93b632a5129eda96d48e4102565fdb84ca74a5f1" + } + ], + "parts": [ + { + "key": "whole", + "name": "Bolt cutters", + "aliases": [], + "confidence": "atlas", + "nodes": [ + "bolt_cutters_01" + ] + } + ], + "built": { + "file": "bolt-cutters.glb", + "bytes": 2496808, + "sha256": "470c491d351b1bf2831d69511bcdb18a01243a5eaf8881db0de84874f13217a0", + "triangles": 3410, + "size": [ + 0.151046, + 0.802581, + 0.036027 + ], + "parts": { + "whole": { + "center": [ + 0, + 0, + 0 + ], + "size": [ + 0.151046, + 0.802581, + 0.036027 + ], + "closed": false, + "triangles": 3410 + } + } + } +} diff --git a/assets/models/brain.json b/assets/models/brain.json new file mode 100644 index 0000000..3e3a1c0 --- /dev/null +++ b/assets/models/brain.json @@ -0,0 +1,1058 @@ +{ + "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 licensor's current statement (the database licence page updated 2025-02-27, and the README) is CC BY 4.0 International, and it is what is relied on. The OBJ files in the 2013 archive still carry an older header naming CC Attribution-ShareAlike 2.1 Japan; that is recorded here and kept in the credits, not erased.", + "earlierNotice": { + "id": "CC-BY-SA-2.1-JP", + "name": "CC Attribution-ShareAlike 2.1 Japan", + "evidence": "the header of every OBJ file in the 2013 archive", + "kept": true + } + }, + "credit": "BodyParts3D, © The Database Center for Life Science licensed under CC Attribution 4.0 International", + "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 + } + } + }, + "release": { + "blocked": true, + "why": "a local prototype only: not published and not packed into a release until it is cleared for one" + } +} diff --git a/assets/models/camera.json b/assets/models/camera.json new file mode 100644 index 0000000..129fd97 --- /dev/null +++ b/assets/models/camera.json @@ -0,0 +1,171 @@ +{ + "id": "camera", + "name": "Vintage camera", + "description": "A vintage bellows-less box camera with its lens and strap, as a textured model", + "aliases": [ + "camera", + "vintage camera", + "film camera", + "old camera" + ], + "format": "gltf", + "licence": { + "id": "CC0-1.0", + "version": "1.0", + "statedOn": "https://polyhaven.com/license", + "statement": "Our assets are all licensed as CC0. You do not need to give credit." + }, + "source": { + "name": "Poly Haven", + "url": "https://polyhaven.com/a/Camera_01", + "version": "Camera 01, 1k glTF, published 2020-03-30", + "authors": [ + "Rajil Jose Macatangay" + ], + "cacheFolder": "ph-camera-01" + }, + "retrieved": "2026-11-08", + "changes": "Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part.", + "orient": { + "up": "y+", + "front": "z+" + }, + "scale": { + "unitsToMetres": 1 + }, + "caveats": [], + "files": [ + { + "entry": "Camera_01.bin", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/8k/Camera_01/Camera_01.bin", + "bytes": 845028, + "sha256": "d3d2c78458a4823bc9821c2ba3994c95d15b044c7a1444ba089b163f74c3fcf2" + }, + { + "entry": "Camera_01_1k.gltf", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/1k/Camera_01/Camera_01_1k.gltf", + "bytes": 9886, + "sha256": "9c5ca3104579c84ffcebdee5c6e5e09821fe8d4a5cd9ce95ed32d81507450ee3" + }, + { + "entry": "textures/Camera_01_body_arm_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Camera_01/Camera_01_body_arm_1k.jpg", + "bytes": 228449, + "sha256": "a3b1928d258fdb23687fb005a3d764b008475abb13b47a2bb87ed81200274635" + }, + { + "entry": "textures/Camera_01_body_diff_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Camera_01/Camera_01_body_diff_1k.jpg", + "bytes": 175778, + "sha256": "89b77ec525e933f9f2702e2ccb0c8ba32ecef31dac241bc034e3eddc9481f4f7" + }, + { + "entry": "textures/Camera_01_body_nor_gl_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Camera_01/Camera_01_body_nor_gl_1k.jpg", + "bytes": 271892, + "sha256": "c7ec0d96ae9b5f16559069f1a4c9a006f3ec1d49a7707269a280fe23786db144" + }, + { + "entry": "textures/Camera_01_lens_body_arm_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Camera_01/Camera_01_lens_body_arm_1k.jpg", + "bytes": 163109, + "sha256": "6fef8a44334428a8f095315fa8043678994abcc671473cf43f7ca63ec10eb98f" + }, + { + "entry": "textures/Camera_01_lens_body_diff_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Camera_01/Camera_01_lens_body_diff_1k.jpg", + "bytes": 106198, + "sha256": "aafa05c5b106b960b21547ef9d4662083dfc7138261cbab1f10e143afe046b68" + }, + { + "entry": "textures/Camera_01_lens_body_nor_gl_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Camera_01/Camera_01_lens_body_nor_gl_1k.jpg", + "bytes": 147816, + "sha256": "3d5e695a57ce38f0e35558f43f30497fff2f8cc844c903c95462d105b58cb333" + }, + { + "entry": "textures/Camera_01_strap_arm_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Camera_01/Camera_01_strap_arm_1k.jpg", + "bytes": 159433, + "sha256": "17beca6e0542a1a28146b52cff06aad2e404541359e452deca83b74d01505c50" + }, + { + "entry": "textures/Camera_01_strap_diff_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Camera_01/Camera_01_strap_diff_1k.jpg", + "bytes": 132449, + "sha256": "3d4c9cb463b330b7ea4fc713f6dc90a0c5e6d9d3ba707b6921fe0a2d1f9ab146" + }, + { + "entry": "textures/Camera_01_strap_nor_gl_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Camera_01/Camera_01_strap_nor_gl_1k.jpg", + "bytes": 199844, + "sha256": "5d4d99d5b1640d5a4d3c2227c264c232279773b5c92e4a6c50d2f34217880202" + } + ], + "parts": [ + { + "key": "strap", + "name": "Strap", + "aliases": [ + "strap" + ], + "confidence": "atlas", + "nodes": [ + "Camera_01_strap" + ] + }, + { + "key": "body", + "name": "Camera body and lens", + "aliases": [ + "camera body", + "lens" + ], + "confidence": "atlas", + "nodes": [ + "Camera_01" + ] + } + ], + "built": { + "file": "camera.glb", + "bytes": 2436424, + "sha256": "538e0612753fce31aa31da50426567ed4336853d20afab07d2a033e80de7b31a", + "triangles": 26987, + "size": [ + 0.213902, + 0.077847, + 0.262824 + ], + "parts": { + "strap": { + "center": [ + 0, + -0.010019, + 0 + ], + "size": [ + 0.213902, + 0.057808, + 0.262824 + ], + "closed": true, + "triangles": 4668 + }, + "body": { + "center": [ + 0.028648, + 0.00014, + -0.045134 + ], + "size": [ + 0.14734, + 0.077567, + 0.088838 + ], + "closed": false, + "triangles": 22319 + } + } + } +} diff --git a/assets/models/drill.json b/assets/models/drill.json new file mode 100644 index 0000000..f77a3f5 --- /dev/null +++ b/assets/models/drill.json @@ -0,0 +1,108 @@ +{ + "id": "drill", + "name": "Power drill", + "description": "A corded power drill with its chuck and trigger, as one textured object", + "aliases": [ + "drill", + "power drill", + "electric drill" + ], + "format": "gltf", + "licence": { + "id": "CC0-1.0", + "version": "1.0", + "statedOn": "https://polyhaven.com/license", + "statement": "Our assets are all licensed as CC0. You do not need to give credit." + }, + "source": { + "name": "Poly Haven", + "url": "https://polyhaven.com/a/Drill_01", + "version": "Drill 01, 1k glTF, published 2020-03-30", + "authors": [ + "Fernando Quinn" + ], + "cacheFolder": "ph-drill-01" + }, + "retrieved": "2026-11-08", + "changes": "Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part.", + "orient": { + "up": "y+", + "front": "z+" + }, + "scale": { + "unitsToMetres": 1 + }, + "caveats": [ + "A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart." + ], + "files": [ + { + "entry": "Drill_01.bin", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/4k/Drill_01/Drill_01.bin", + "bytes": 90100, + "sha256": "0353e743c05051546945fd2d79e9c96bfad7ad387e0d47bc5d408d78ae7b9fe8" + }, + { + "entry": "Drill_01_1k.gltf", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/1k/Drill_01/Drill_01_1k.gltf", + "bytes": 2637, + "sha256": "b162c83a8e35c869aef4f50e2cd80a750be248389e829f6cf9ced73ba094b9db" + }, + { + "entry": "textures/Drill_01_arm_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Drill_01/Drill_01_arm_1k.jpg", + "bytes": 168655, + "sha256": "974670d66a17cceebec08dcee5e4895684b519bcd2e4c8ea748a955fe1e41057" + }, + { + "entry": "textures/Drill_01_diff_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Drill_01/Drill_01_diff_1k.jpg", + "bytes": 106186, + "sha256": "2c1cfdc0d3e65ca490e0bd5cdc28173672bf68f9bb62278cc7094c9c5d6a7dcb" + }, + { + "entry": "textures/Drill_01_nor_gl_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/Drill_01/Drill_01_nor_gl_1k.jpg", + "bytes": 133488, + "sha256": "08d3efc87520243ad9ef031ec0d67369dac5aae2752f8db33988015cbb06e2eb" + } + ], + "parts": [ + { + "key": "whole", + "name": "Power drill", + "aliases": [], + "confidence": "atlas", + "nodes": [ + "Drill_01" + ] + } + ], + "built": { + "file": "drill.glb", + "bytes": 500292, + "sha256": "a5afd4c33c8d24b4c2f5a0978047654e81835adcf38a4f7de916dfd2cee7683b", + "triangles": 2926, + "size": [ + 0.18288, + 0.185062, + 0.052415 + ], + "parts": { + "whole": { + "center": [ + 0, + 0, + 0 + ], + "size": [ + 0.18288, + 0.185062, + 0.052415 + ], + "closed": false, + "triangles": 2926 + } + } + } +} diff --git a/assets/models/electric-motor.json b/assets/models/electric-motor.json new file mode 100644 index 0000000..cdbe97e --- /dev/null +++ b/assets/models/electric-motor.json @@ -0,0 +1,86 @@ +{ + "id": "electric-motor", + "name": "Davenport electric motor", + "description": "Thomas Davenport's 1837 patent model of the first US electric motor, a scan of the museum object", + "aliases": [ + "electric motor", + "davenport motor", + "early electric motor", + "motor" + ], + "format": "gltf", + "licence": { + "id": "CC0-1.0", + "version": "1.0", + "statedOn": "https://api.si.edu/openaccess/api/v1.0/content/edanmdm:nmah_703302", + "statement": "The 3D media of the record carries usage access \"CC0\" (read from the Smithsonian Open Access API record on 2026-11-08)." + }, + "source": { + "name": "Smithsonian Open Access", + "url": "https://3d-api.si.edu/voyager/3d_package:a18922b9-a00f-4c9e-988a-f526382b15cc", + "version": "Davenport electric motor, US patent #132, record edanmdm:nmah_703302", + "authors": [ + "Smithsonian National Museum of American History, Digitization Program Office" + ], + "cacheFolder": "si-davenport-motor" + }, + "retrieved": "2026-11-08", + "changes": "Passed through: the geometry, texture coordinates, material and textures are the museum's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on the part.", + "orient": { + "up": "y+", + "front": "z+" + }, + "scale": { + "unitsToMetres": 1 + }, + "caveats": [ + "A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart.", + "The source's textures are larger than the page draws them at; they are reduced when loaded, to the size each tier allows." + ], + "files": [ + { + "entry": "Davenport_motor-100k-2048_std.glb", + "url": "https://3d-api.si.edu/content/document/3d_package:a18922b9-a00f-4c9e-988a-f526382b15cc/resources/Davenport_motor-100k-2048_std.glb", + "bytes": 4335160, + "sha256": "f87170331d924e5b73a64383bb9b0d86cbdee595c25e632949af11008e7a7f15" + } + ], + "parts": [ + { + "key": "whole", + "name": "Davenport electric motor", + "aliases": [], + "confidence": "atlas", + "nodes": [ + "#0" + ] + } + ], + "built": { + "file": "electric-motor.glb", + "bytes": 4335360, + "sha256": "d26c1f8dbdfca5abc178136004ccc52ec6c6877be03fcfb423e397975fcf8be1", + "triangles": 100002, + "size": [ + 0.262645, + 0.370017, + 0.377809 + ], + "parts": { + "whole": { + "center": [ + 0, + 0, + 0 + ], + "size": [ + 0.262645, + 0.370017, + 0.377809 + ], + "closed": false, + "triangles": 100002 + } + } + } +} diff --git a/assets/models/heart.json b/assets/models/heart.json new file mode 100644 index 0000000..74095c7 --- /dev/null +++ b/assets/models/heart.json @@ -0,0 +1,1220 @@ +{ + "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 licensor's current statement (the database licence page updated 2025-02-27, and the README) is CC BY 4.0 International, and it is what is relied on. The OBJ files in the 2013 archive still carry an older header naming CC Attribution-ShareAlike 2.1 Japan; that is recorded here and kept in the credits, not erased.", + "earlierNotice": { + "id": "CC-BY-SA-2.1-JP", + "name": "CC Attribution-ShareAlike 2.1 Japan", + "evidence": "the header of every OBJ file in the 2013 archive", + "kept": true + } + }, + "credit": "BodyParts3D, © The Database Center for Life Science licensed under CC Attribution 4.0 International", + "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 + } + } + }, + "release": { + "blocked": true, + "why": "a local prototype only: not published and not packed into a release until it is cleared for one" + } +} diff --git a/assets/models/measuring-tape.json b/assets/models/measuring-tape.json new file mode 100644 index 0000000..276e08d --- /dev/null +++ b/assets/models/measuring-tape.json @@ -0,0 +1,108 @@ +{ + "id": "measuring-tape", + "name": "Measuring tape", + "description": "A retractable tape measure in its case, as one textured object", + "aliases": [ + "measuring tape", + "tape measure", + "tape" + ], + "format": "gltf", + "licence": { + "id": "CC0-1.0", + "version": "1.0", + "statedOn": "https://polyhaven.com/license", + "statement": "Our assets are all licensed as CC0. You do not need to give credit." + }, + "source": { + "name": "Poly Haven", + "url": "https://polyhaven.com/a/measuring_tape_01", + "version": "Measuring Tape 01, 1k glTF, published 2021-10-15", + "authors": [ + "Kuutti Siitonen" + ], + "cacheFolder": "ph-measuring-tape-01" + }, + "retrieved": "2026-11-08", + "changes": "Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part.", + "orient": { + "up": "y+", + "front": "z+" + }, + "scale": { + "unitsToMetres": 1 + }, + "caveats": [ + "A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart." + ], + "files": [ + { + "entry": "measuring_tape_01.bin", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/4k/measuring_tape_01/measuring_tape_01.bin", + "bytes": 94680, + "sha256": "9255ba5bde1df6dcbfd7103577809c4af44525fed7d2b41d17ff83ead712dfc6" + }, + { + "entry": "measuring_tape_01_1k.gltf", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/1k/measuring_tape_01/measuring_tape_01_1k.gltf", + "bytes": 2720, + "sha256": "f4d36918fcbe3de138fbf7a0c5cc1ab2c7c049db6a5e7ee24673d78d3d9ed74d" + }, + { + "entry": "textures/measuring_tape_01_arm_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/measuring_tape_01/measuring_tape_01_arm_1k.jpg", + "bytes": 143061, + "sha256": "721fa78a93d9727250123b16a8389ed815801f923bc07e6eb2e5568c5aa5f9d0" + }, + { + "entry": "textures/measuring_tape_01_diff_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/measuring_tape_01/measuring_tape_01_diff_1k.jpg", + "bytes": 83801, + "sha256": "7b66c2a9a5e794336d1456dd9de684ea94bf80a0f8b821c36a0fc2cdf0804052" + }, + { + "entry": "textures/measuring_tape_01_nor_gl_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/measuring_tape_01/measuring_tape_01_nor_gl_1k.jpg", + "bytes": 121717, + "sha256": "956bf080bb51987c2d3929e9b68fdea4e36f47c9fbf0b7dfe08260d5410f6c27" + } + ], + "parts": [ + { + "key": "whole", + "name": "Measuring tape", + "aliases": [], + "confidence": "atlas", + "nodes": [ + "measuring_tape_01" + ] + } + ], + "built": { + "file": "measuring-tape.glb", + "bytes": 445184, + "sha256": "a947441fd19e3a5b89f27f62510c805e36dd0077120e966729ddd3bec21713e9", + "triangles": 2868, + "size": [ + 0.040566, + 0.073414, + 0.169419 + ], + "parts": { + "whole": { + "center": [ + 0, + 0, + 0 + ], + "size": [ + 0.040566, + 0.073414, + 0.169419 + ], + "closed": true, + "triangles": 2868 + } + } + } +} diff --git a/assets/models/mousetrap.json b/assets/models/mousetrap.json new file mode 100644 index 0000000..ced26e4 --- /dev/null +++ b/assets/models/mousetrap.json @@ -0,0 +1,108 @@ +{ + "id": "mousetrap", + "name": "Mousetrap", + "description": "A wooden snap mousetrap with its spring bar, as one textured object", + "aliases": [ + "mousetrap", + "mouse trap", + "snap trap" + ], + "format": "gltf", + "licence": { + "id": "CC0-1.0", + "version": "1.0", + "statedOn": "https://polyhaven.com/license", + "statement": "Our assets are all licensed as CC0. You do not need to give credit." + }, + "source": { + "name": "Poly Haven", + "url": "https://polyhaven.com/a/mousetrap", + "version": "Mousetrap, 1k glTF, published 2023-05-19", + "authors": [ + "GreenPixel" + ], + "cacheFolder": "ph-mousetrap" + }, + "retrieved": "2026-11-08", + "changes": "Passed through: geometry, UV coordinates, materials and the 1k textures are the source's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on each named part.", + "orient": { + "up": "y+", + "front": "z+" + }, + "scale": { + "unitsToMetres": 1 + }, + "caveats": [ + "A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart." + ], + "files": [ + { + "entry": "mousetrap.bin", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/4k/mousetrap/mousetrap.bin", + "bytes": 154880, + "sha256": "34cc9c3a8f5ab6efa2b37498231e22bbf9173b687aab95db8173b7dd40fa01b6" + }, + { + "entry": "mousetrap_1k.gltf", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/gltf/1k/mousetrap/mousetrap_1k.gltf", + "bytes": 2738, + "sha256": "711f5aea9a8460d7243655621dd7bc86d2f52dc872b836c24475866b177e76b8" + }, + { + "entry": "textures/mousetrap_arm_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/mousetrap/mousetrap_arm_1k.jpg", + "bytes": 698232, + "sha256": "195d2beb9adf513a804e731035089630eac1b72d786a7ad7ddef75d5700fdeeb" + }, + { + "entry": "textures/mousetrap_diff_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/mousetrap/mousetrap_diff_1k.jpg", + "bytes": 647362, + "sha256": "7cc4e0dc680845b230c57913ecd242f3ac67dcfcdd1ed590f505385f3b7b6c74" + }, + { + "entry": "textures/mousetrap_nor_gl_1k.jpg", + "url": "https://dl.polyhaven.org/file/ph-assets/Models/jpg/1k/mousetrap/mousetrap_nor_gl_1k.jpg", + "bytes": 731402, + "sha256": "775ff8ba3d858b420619225b799bb321cf34c327698f410cf02cfe9b7e421978" + } + ], + "parts": [ + { + "key": "whole", + "name": "Mousetrap", + "aliases": [], + "confidence": "atlas", + "nodes": [ + "mousetrap" + ] + } + ], + "built": { + "file": "mousetrap.glb", + "bytes": 2233796, + "sha256": "04def5d43d0c40c2b8a905c65115407c6e3623cc0dc17e95c07e9812ac8194c3", + "triangles": 5136, + "size": [ + 0.054988, + 0.017934, + 0.100444 + ], + "parts": { + "whole": { + "center": [ + 0, + 0, + 0 + ], + "size": [ + 0.054988, + 0.017934, + 0.100444 + ], + "closed": false, + "triangles": 5136 + } + } + } +} diff --git a/assets/models/telegraph-key.json b/assets/models/telegraph-key.json new file mode 100644 index 0000000..80498b1 --- /dev/null +++ b/assets/models/telegraph-key.json @@ -0,0 +1,90 @@ +{ + "id": "telegraph-key", + "name": "Morse-Vail telegraph key", + "description": "A Morse-Vail telegraph key from about 1844, a scan of the museum object", + "aliases": [ + "telegraph key", + "morse key", + "morse code key", + "telegraph" + ], + "format": "gltf", + "licence": { + "id": "CC0-1.0", + "version": "1.0", + "statedOn": "https://www.si.edu/object/nmah_1096762", + "statement": "Licence unverified: listed as CC0 on its Smithsonian 3D record (seen in a search result on 2026-11-09; the record page itself would not load for us and the Open Access API refused the lookup, so this one is not read from the record directly)." + }, + "release": { + "blocked": true, + "why": "licence unverified: CC0 seen only in a search snippet, the record itself not read (its page returned 403 and the Open Access API refused the lookup)" + }, + "source": { + "name": "Smithsonian Open Access", + "url": "https://3d-api.si.edu/voyager/3d_package:ed99f44d-3c60-4111-b666-e2908e1b64ef", + "version": "Morse-Vail Telegraph Key, record edanmdm:nmah_1096762", + "authors": [ + "Smithsonian National Museum of American History, Digitization Program Office" + ], + "cacheFolder": "si-morse-vail-key" + }, + "retrieved": "2026-11-08", + "changes": "Passed through: the geometry, texture coordinates, material and textures are the museum's own, unchanged. Added: a root that puts the model on the scene's axes, in metres, centred on its own middle, and a tag on the part.", + "orient": { + "up": "y+", + "front": "z+" + }, + "scale": { + "unitsToMetres": 0.001 + }, + "caveats": [ + "A single scanned or modelled object: it can be labelled as a whole, but has no named parts to cut or take apart.", + "The source's textures are larger than the page draws them at; they are reduced when loaded, to the size each tier allows." + ], + "files": [ + { + "entry": "morse-telegraph-key-150k-4096.glb", + "url": "https://3d-api.si.edu/content/document/3d_package:ed99f44d-3c60-4111-b666-e2908e1b64ef/resources/morse-telegraph-key-150k-4096.glb", + "bytes": 7582452, + "sha256": "ece8213900cc8d4d8cd77b245f4c3390b89131a58baa99e1beddc717010e3aca" + } + ], + "parts": [ + { + "key": "whole", + "name": "Morse-Vail telegraph key", + "aliases": [], + "confidence": "atlas", + "nodes": [ + "#0" + ] + } + ], + "built": { + "file": "telegraph-key.glb", + "bytes": 7582656, + "sha256": "40aed26cdcb2b5a9b29d6fad85ce3b7ff2309c39ab893320c4f3fc69fc99cc0a", + "triangles": 150000, + "size": [ + 0.169078, + 0.07655, + 0.050837 + ], + "parts": { + "whole": { + "center": [ + 0, + 0, + 0 + ], + "size": [ + 0.169078, + 0.07655, + 0.050837 + ], + "closed": true, + "triangles": 150000 + } + } + } +} diff --git a/docs/real-models.md b/docs/real-models.md new file mode 100644 index 0000000..bec1420 --- /dev/null +++ b/docs/real-models.md @@ -0,0 +1,37 @@ +# Real models + +Talkthrough's MIT licence covers its code only. The models are separate works under their own licences, named in [assets/CREDITS.md](../assets/CREDITS.md), and are excluded from the MIT grant. + +Talkthrough can draw a thing as it really is (a heart, a brain, and a handful of everyday objects) instead of building it from shapes. A model is a **manifest** in `assets/models/.json` plus its source files, fetched once from the publisher and never stored in git. The finished file of a model that releases carry (CC0, pinned by hash) is committed; a model held back from releases is not. + +## 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/` is ignored by git, and so is `assets/built/` except for the models releases carry: their `.glb` files are committed as plain binaries (`.gitattributes` marks `*.glb` binary; no LFS), listed by name in `.gitignore`, so a fresh clone can build and pack a release without fetching anything. A test checks that exactly the carried models' files are tracked, that the held ones' are ignored, and that nothing of a machine or of ours is in what is committed. `npm run build` copies the built files into `dist/models/` (without them it warns, and a scene that uses one of those models shows the stage without it and says so); `npm run dist` builds a release (`npm run build -- --release`) and refuses to pack without the files of the models it carries. + +## 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. For a model releases carry, also commit its built file (`git add -f` is not needed: add `!assets/built/.glb` to `.gitignore`). A model that is not cleared for a release says so in `release.blocked` and its file stays out of git; releases leave it out of the catalogue, the files and the credits. +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`. + +## Textured objects (glTF) + +A model whose manifest says `"format": "gltf"` is an artist's own glTF or GLB, passed through: its geometry, UV coordinates, materials and images are copied unchanged into one GLB, and the page draws them with their textures. The manifest lists every file with its address (https, on the publisher's own host: Poly Haven or the Smithsonian's 3D server; any other host is a code change, not a manifest edit), its bytes and sha256, the date the files were fetched, the authors, and the licence as the publisher's page states it (`licence.statement`, `licence.statedOn`). `npm run assets` fetches into a folder of the model's own (`source.cacheFolder`), checks each file against its pin and refuses a file the glTF points at that the manifest does not name. The only changes the build makes are a root that puts the model on the scene's axes, in metres and centred (`orient`, `scale.unitsToMetres`) and a `part` tag on the nodes the manifest names as parts (by node name, or `#3` for the node at an index when the source's nodes have no names). A file that needs Draco, meshopt or KTX2, has skins, animations or morph targets, or holds a mesh in no part, is refused. + +Drawing: the colour map on every tier; the normal, roughness, metal and occlusion maps on mid and high; glass (transmission or blended transparency) as the overlay's glass. A texture larger than its tier keeps (1024 px low, 2048 mid and high) is reduced when the model loads. The page's policy allows `blob:` for connections, which is how the loader reads the images inside a model file; a blob is only ever something the page made. + +A model with one part (`parts.length === 1`, key `whole`) is one object, such as a scan: it is labelled as a whole (`pin` or `highlight` its id), part names on it are refused with a note, `explode` and `cut` on it are dropped, and the Explode and Cut buttons are not offered for it alone. A textured model's parts are not watertight solids, so `cut` shows the inside of the shell, not a cap. + +A part that turns (a clock hand) names its **hub** in the manifest: `"hub": "node"` takes the origin of its source node (the boss it is mounted on), or `"hub": [x, y, z]` gives a point in metres from the model's middle. The build records it, and a `spin`, `loop` or hinge on the part that names no pivot of its own turns it about that point, not about the middle of its box (which for a thin hand is somewhere along the hand). A part may also name `"explode": [x, y, z]` (metres): where it goes when the model is exploded, so a hand lifts straight off its face instead of flying outward across the case. + +## Releases + +A manifest can hold its model back (`release: { blocked: true, why }`): the model is for local use. A release build leaves held models out: they are not in the catalogue the app is built with (so the guide, the schema and the validator never offer them and answers use shapes), their files and credits are not shipped, and the build says what it left out. The two anatomy models are held as a prototype until they are cleared for a release; the CC0 objects are carried, except the Morse-Vail key, held as "licence unverified" (its CC0 was seen only in a search snippet, the record page returned 403) until the record is read. Where a source's files still carry an older licence notice than its current grant, the manifest records the older notice (`licence.earlierNotice`) and the credits file keeps it. + +## 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 81a0d15..8907b21 100644 --- a/docs/scene.schema.json +++ b/docs/scene.schema.json @@ -4014,6 +4014,119 @@ "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": [ + "alarm-clock", + "bolt-cutters", + "brain", + "camera", + "drill", + "electric-motor", + "heart", + "measuring-tape", + "mousetrap", + "telegraph-key" + ] + }, + "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 +6590,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 eab928b..e8898c4 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,73 @@ "additionalProperties": false }, "17": { + "type": "object", + "properties": { + "op": { + "enum": [ + "add" + ] + }, + "shape": { + "enum": [ + "model" + ] + }, + "id": { + "type": "string" + }, + "model": { + "enum": [ + "alarm-clock", + "bolt-cutters", + "brain", + "camera", + "drill", + "electric-motor", + "heart", + "measuring-tape", + "mousetrap", + "telegraph-key" + ] + }, + "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 +800,7 @@ ], "additionalProperties": false }, - "18": { + "19": { "type": "object", "properties": { "op": { @@ -789,36 +856,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 +888,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 +944,7 @@ ], "additionalProperties": false }, - "21": { + "22": { "type": "object", "properties": { "op": { @@ -921,7 +982,7 @@ ], "additionalProperties": false }, - "22": { + "23": { "type": "object", "properties": { "op": { @@ -951,7 +1012,7 @@ ], "additionalProperties": false }, - "23": { + "24": { "type": "object", "properties": { "op": { @@ -977,7 +1038,7 @@ ], "additionalProperties": false }, - "24": { + "25": { "type": "object", "properties": { "op": { @@ -1003,7 +1064,7 @@ ], "additionalProperties": false }, - "25": { + "26": { "type": "object", "properties": { "op": { @@ -1039,7 +1100,7 @@ ], "additionalProperties": false }, - "26": { + "27": { "type": "object", "properties": { "op": { @@ -1079,7 +1140,7 @@ ], "additionalProperties": false }, - "27": { + "28": { "type": "object", "properties": { "op": { @@ -1101,7 +1162,7 @@ ], "additionalProperties": false }, - "28": { + "29": { "anyOf": [ { "$ref": "#/$defs/a" @@ -1312,27 +1373,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 +3017,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 +3110,7 @@ ], "additionalProperties": false }, - "1b": { + "1c": { "type": "object", "properties": { "op": { @@ -3049,7 +3142,7 @@ ], "additionalProperties": false }, - "1c": { + "1d": { "type": "object", "properties": { "op": { @@ -3079,7 +3172,7 @@ ], "additionalProperties": false }, - "1d": { + "1e": { "type": "object", "properties": { "op": { @@ -3110,7 +3203,7 @@ ], "additionalProperties": false }, - "1e": { + "1f": { "type": "object", "properties": { "op": { @@ -3136,7 +3229,7 @@ ], "additionalProperties": false }, - "1f": { + "1g": { "type": "object", "properties": { "op": { @@ -3158,7 +3251,7 @@ ], "additionalProperties": false }, - "1g": { + "1h": { "type": "object", "properties": { "op": { @@ -3192,7 +3285,7 @@ ], "additionalProperties": false }, - "1h": { + "1i": { "type": "object", "properties": { "op": { @@ -3222,7 +3315,7 @@ ], "additionalProperties": false }, - "1i": { + "1j": { "type": "object", "properties": { "op": { @@ -3268,7 +3361,7 @@ ], "additionalProperties": false }, - "1j": { + "1k": { "type": "object", "properties": { "op": { @@ -3306,7 +3399,7 @@ ], "additionalProperties": false }, - "1k": { + "1l": { "type": "object", "properties": { "op": { @@ -3348,7 +3441,7 @@ ], "additionalProperties": false }, - "1l": { + "1m": { "type": "object", "properties": { "op": { @@ -3386,7 +3479,7 @@ ], "additionalProperties": false }, - "1m": { + "1n": { "type": "object", "properties": { "op": { @@ -3452,7 +3545,7 @@ ], "additionalProperties": false }, - "1n": { + "1o": { "type": "object", "properties": { "op": { @@ -3516,7 +3609,7 @@ ], "additionalProperties": false }, - "1o": { + "1p": { "type": "object", "properties": { "op": { @@ -3558,7 +3651,7 @@ ], "additionalProperties": false }, - "1p": { + "1q": { "type": "object", "properties": { "op": { @@ -3600,7 +3693,7 @@ ], "additionalProperties": false }, - "1q": { + "1r": { "type": "object", "properties": { "op": { @@ -3638,7 +3731,7 @@ ], "additionalProperties": false }, - "1r": { + "1s": { "type": "object", "properties": { "op": { @@ -3684,7 +3777,7 @@ ], "additionalProperties": false }, - "1s": { + "1t": { "type": "object", "properties": { "op": { @@ -3726,7 +3819,7 @@ ], "additionalProperties": false }, - "1t": { + "1u": { "type": "object", "properties": { "op": { @@ -3772,7 +3865,7 @@ ], "additionalProperties": false }, - "1u": { + "1v": { "type": "object", "properties": { "op": { @@ -3810,7 +3903,7 @@ ], "additionalProperties": false }, - "1v": { + "1w": { "type": "object", "properties": { "op": { @@ -3848,7 +3941,7 @@ ], "additionalProperties": false }, - "1w": { + "1x": { "type": "object", "properties": { "op": { @@ -3882,7 +3975,7 @@ ], "additionalProperties": false }, - "1x": { + "1y": { "type": "object", "properties": { "op": { @@ -3932,7 +4025,7 @@ ], "additionalProperties": false }, - "1y": { + "1z": { "type": "object", "properties": { "op": { @@ -3970,45 +4063,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-lock.json b/package-lock.json index 7954a5f..12ef776 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "talkthrough", - "version": "0.8.0", + "version": "0.9.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "talkthrough", - "version": "0.8.0", + "version": "0.9.0", "license": "MIT", "dependencies": { "get-windows": "10.0.0", diff --git a/package.json b/package.json index 522db81..b21972f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "talkthrough", - "version": "0.8.0", + "version": "0.9.0", "description": "An AI that talks you through anything on your screen, and draws as it talks.", "keywords": [ "screen assistant", @@ -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 0000000..307808c --- /dev/null +++ b/scripts/assets/build.mjs @@ -0,0 +1,79 @@ +// 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 { buildGltfModel } from './gltf-pass.mjs'; +import { BUILT_DIR, cacheFolder, 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) { + if (m.format === 'gltf') return buildGltfModel(m, (f) => Buffer.from(readFile(f, 'bytes'))); + 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 = cacheFolder(m); + const readFile = (f, as = 'text') => { + const path = join(folder, f.entry); + if (!existsSync(path)) throw new Error(`${f.id ?? f.entry} is not in the cache (run assets:fetch)`); + const data = readFileSync(path); + if (f.sha256 && sha256(data) !== f.sha256) throw new Error(`${f.id ?? f.entry} does not match its pinned hash`); + return as === 'bytes' ? data : 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 0000000..93026ba --- /dev/null +++ b/scripts/assets/fetch.mjs @@ -0,0 +1,84 @@ +// 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 { cacheFolder, fetchAddressProblem, 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(cacheFolder(m), f.entry); + +/** A glTF model's file, from the publisher's own address the manifest names (https, an allowed host, and still on one after any redirect). */ +async function fromUrl(f) { + const refused = fetchAddressProblem(f.url); + if (refused) throw new Error(`${refused}; nothing was asked for`); + const res = await fetch(f.url, { redirect: 'follow' }); + if (!res.ok) throw new Error(`${f.url}: HTTP ${res.status}`); + const landed = fetchAddressProblem(res.url); + if (landed) throw new Error(`${f.url} led somewhere it may not go: ${landed}`); + return Buffer.from(await res.arrayBuffer()); +} +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 && m.format === 'gltf') { + // A glTF model lists its files and their addresses by hand; pinning records what they are. + } else 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 ?? f.entry}: the cached file does not match its pinned hash; removed`); rmSync(path); data = undefined; } + if (!data) { + try { data = m.format === 'gltf' ? await fromUrl(f) : await fromArchive(m, f.entry); } catch (e) { console.error(` ${f.id ?? f.entry}: ${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 ?? f.entry}: 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/gltf-pass.mjs b/scripts/assets/gltf-pass.mjs new file mode 100644 index 0000000..57d8e0f --- /dev/null +++ b/scripts/assets/gltf-pass.mjs @@ -0,0 +1,224 @@ +// Turning a glTF or GLB model into the one GLB the app loads, with its materials and textures kept as the artist made them (a pass-through, not a +// re-modelling): the source's geometry, UVs, materials and images are copied byte for byte into one binary chunk, every file the source points at +// must be one the manifest names and pins (so nothing is read that was not reviewed), and the only things added are a root node that puts the model +// on the scene's axes, in metres and centred on its own middle, and a `part` tag on the nodes the manifest names as parts. The build also measures what +// the app needs without reading a mesh: each part's centre, size, triangles and whether it is watertight. Deterministic, like the OBJ path. + +import { bounds, isClosed, orientation, weld } from './obj-glb.mjs'; + +const pad4 = (n) => (n + 3) & ~3; +const round = (v, d = 6) => Math.round(v * 10 ** d) / 10 ** d; + +/** Extensions the page's loader handles with no decoder to fetch; a file that needs another (Draco, meshopt, KTX2) is refused, not half-drawn. */ +export const ALLOWED_EXTENSIONS = new Set([ + 'KHR_materials_transmission', 'KHR_materials_ior', 'KHR_materials_specular', 'KHR_materials_volume', 'KHR_materials_emissive_strength', + 'KHR_materials_clearcoat', 'KHR_materials_sheen', 'KHR_texture_transform', +]); + +const COMPONENT = { 5120: [Int8Array, 1], 5121: [Uint8Array, 1], 5122: [Int16Array, 2], 5123: [Uint16Array, 2], 5125: [Uint32Array, 4], 5126: [Float32Array, 4] }; +const WIDTH = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4 }; + +// 4x4 matrices, column-major as glTF writes them. +const identity = () => [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; +function multiply(a, b) { + const o = new Array(16).fill(0); + for (let c = 0; c < 4; c++) for (let r = 0; r < 4; r++) for (let k = 0; k < 4; k++) o[c * 4 + r] += a[k * 4 + r] * b[c * 4 + k]; + return o; +} +function fromTrs(t = [0, 0, 0], q = [0, 0, 0, 1], s = [1, 1, 1]) { + const [x, y, z, w] = q; + const xx = x * x, yy = y * y, zz = z * z, xy = x * y, xz = x * z, yz = y * z, wx = w * x, wy = w * y, wz = w * z; + return [ + (1 - 2 * (yy + zz)) * s[0], 2 * (xy + wz) * s[0], 2 * (xz - wy) * s[0], 0, + 2 * (xy - wz) * s[1], (1 - 2 * (xx + zz)) * s[1], 2 * (yz + wx) * s[1], 0, + 2 * (xz + wy) * s[2], 2 * (yz - wx) * s[2], (1 - 2 * (xx + yy)) * s[2], 0, + t[0], t[1], t[2], 1, + ]; +} +const local = (n) => (n.matrix ? [...n.matrix] : fromTrs(n.translation, n.rotation, n.scale)); +const apply = (m, x, y, z) => [m[0] * x + m[4] * y + m[8] * z + m[12], m[1] * x + m[5] * y + m[9] * z + m[13], m[2] * x + m[6] * y + m[10] * z + m[14]]; + +/** The JSON and the embedded binary chunk of a GLB. */ +export function readGlb(bytes) { + if (bytes.length < 28 || bytes.readUInt32LE(0) !== 0x46546c67 || bytes.readUInt32LE(4) !== 2) throw new Error('not a GLB 2 file'); + let at = 12, json, bin; + while (at + 8 <= bytes.length) { + const length = bytes.readUInt32LE(at), type = bytes.readUInt32LE(at + 4); + const body = bytes.subarray(at + 8, at + 8 + length); + if (type === 0x4e4f534a) json = JSON.parse(body.toString('utf8')); + else if (type === 0x004e4942 && !bin) bin = body; + at += 8 + length; + } + if (!json) throw new Error('a GLB with no JSON chunk'); + return { json, bin }; +} + +/** The glTF's parts: everything it points at must be a file the manifest lists, by its path next to the model file. */ +function resolveUri(uri, owner, files, what) { + if (/^data:/i.test(uri)) throw new Error(`${what} is a data URI; the source must keep its files separate and pinned`); + if (/^[a-z][a-z0-9+.-]*:/i.test(uri) || uri.startsWith('/') || uri.includes('..')) throw new Error(`${what} points outside the model's folder (${uri})`); + const path = decodeURIComponent(uri); + const dir = owner.includes('/') ? owner.slice(0, owner.lastIndexOf('/') + 1) : ''; + const entry = dir + path; + const file = files.get(entry); + if (!file) throw new Error(`${what} names ${entry}, which the manifest does not list; every file must be named and pinned`); + return file; +} + +/** Reads a vertex attribute or index accessor out of the combined binary. */ +function readAccessor(json, bin, base, index) { + const a = json.accessors[index]; + if (a.sparse) throw new Error('sparse accessors are not supported'); + const view = json.bufferViews[a.bufferView]; + const [Type, size] = COMPONENT[a.componentType] ?? []; + if (!Type) throw new Error(`unknown component type ${a.componentType}`); + const width = WIDTH[a.type]; + const stride = view.byteStride ?? size * width; + const start = base[view.buffer] + (view.byteOffset ?? 0) + (a.byteOffset ?? 0); + const out = new Array(a.count * width); + const dv = new DataView(bin.buffer, bin.byteOffset, bin.byteLength); + const get = { 5120: 'getInt8', 5121: 'getUint8', 5122: 'getInt16', 5123: 'getUint16', 5125: 'getUint32', 5126: 'getFloat32' }[a.componentType]; + for (let i = 0; i < a.count; i++) for (let k = 0; k < width; k++) out[i * width + k] = dv[get](start + i * stride + k * size, true); + return { data: out, count: a.count, width }; +} + +/** The node indices a manifest part names: by the node's name, or `#3` for the node at that index (a source whose nodes have no names). */ +function nodesNamed(json, key) { + if (/^#\d+$/.test(key)) { + const i = Number(key.slice(1)); + if (!json.nodes[i]) throw new Error(`there is no node ${key}`); + return [i]; + } + const found = json.nodes.map((n, i) => (n.name === key ? i : -1)).filter((i) => i >= 0); + if (!found.length) throw new Error(`there is no node named ${key}`); + return found; +} + +/** The built GLB bytes and what was measured while making them (the same shape as the OBJ path's). */ +export function buildGltfModel(m, readBytes) { + const files = new Map(m.files.map((f) => [f.entry, f])); + const primary = m.files.find((f) => /\.(gltf|glb)$/i.test(f.entry)); + if (!primary) throw new Error('the manifest lists no .gltf or .glb file'); + const raw = readBytes(primary); + let json, glbBin; + if (/\.glb$/i.test(primary.entry)) ({ json, bin: glbBin } = readGlb(raw)); + else json = JSON.parse(raw.toString('utf8')); + if (!json.asset || !String(json.asset.version).startsWith('2')) throw new Error('not a glTF 2 file'); + for (const list of [json.extensionsRequired, json.extensionsUsed]) for (const e of list ?? []) if (!ALLOWED_EXTENSIONS.has(e)) throw new Error(`the file uses ${e}, which the page cannot load without a decoder`); + for (const mesh of json.meshes ?? []) for (const p of mesh.primitives) { + if ((p.mode ?? 4) !== 4) throw new Error('only triangle meshes are supported'); + if (p.targets) throw new Error('morph targets are not supported'); + for (const k of Object.keys(p.attributes)) if (!/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d|COLOR_\d)$/.test(k)) throw new Error(`attribute ${k} is not supported`); + } + if ((json.skins ?? []).length || (json.animations ?? []).length) throw new Error('skins and animations are not supported'); + + // One binary chunk: the file's own, then each buffer it pointed at, then each image. + const chunks = []; + let size = 0; + const add = (bytes) => { const at = size; chunks.push(bytes, Buffer.alloc(pad4(bytes.length) - bytes.length)); size += pad4(bytes.length); return at; }; + const base = []; + const buffers = json.buffers ?? []; + buffers.forEach((b, i) => { + if (b.uri === undefined) { + if (!glbBin || i !== 0) throw new Error(`buffer ${i} has no uri and no GLB chunk`); + base.push(add(glbBin.subarray(0, b.byteLength))); + } else base.push(add(readBytes(resolveUri(b.uri, primary.entry, files, `buffer ${i}`)))); + }); + const views = (json.bufferViews ?? []).map((v) => ({ ...v, buffer: 0, byteOffset: base[v.buffer] + (v.byteOffset ?? 0) })); + for (const [i, img] of (json.images ?? []).entries()) { + if (img.uri === undefined) continue; + const file = resolveUri(img.uri, primary.entry, files, `image ${i}`); + const mime = /\.png$/i.test(file.entry) ? 'image/png' : /\.jpe?g$/i.test(file.entry) ? 'image/jpeg' : undefined; + if (!mime) throw new Error(`image ${i} (${file.entry}) is not a PNG or JPEG`); + const bytes = readBytes(file); + views.push({ buffer: 0, byteOffset: add(bytes), byteLength: bytes.length }); + img.bufferView = views.length - 1; + img.mimeType = mime; + delete img.uri; + } + const bin = Buffer.concat(chunks); + json.bufferViews = views; + json.buffers = [{ byteLength: bin.length }]; + // Reading accessors below uses offsets into the combined chunk (the views are already moved). + const flat = [0]; + + // Parts: each names source nodes; everything under them belongs to the part. + const scene = json.scenes[json.scene ?? 0]; + const roots = scene.nodes; + const members = new Map(); + const claim = (i, key) => { + if (members.has(i) && members.get(i) !== key) throw new Error(`node ${json.nodes[i].name ?? '#' + i} belongs to two parts (${members.get(i)} and ${key})`); + members.set(i, key); + for (const c of json.nodes[i].children ?? []) claim(c, key); + }; + for (const p of m.parts) for (const id of p.nodes) for (const i of nodesNamed(json, id)) claim(i, p.key); + const world = new Map(); + const walk = (i, parent) => { + const w = multiply(parent, local(json.nodes[i])); + world.set(i, w); + for (const c of json.nodes[i].children ?? []) walk(c, w); + }; + for (const r of roots) walk(r, identity()); + for (const [i, n] of world) if (json.nodes[i].mesh !== undefined && !members.has(i)) throw new Error(`mesh node ${json.nodes[i].name ?? '#' + i} is in no part; every mesh must belong to one so none is dropped`); + + // The root: the model on the scene's axes, in metres, its own middle at the origin. First pass finds the middle. + const rows = orientation(m.orient.up, m.orient.front); + const s = m.scale.unitsToMetres; + const axes = [[rows.right[0], rows.up[0], rows.front[0]], [rows.right[1], rows.up[1], rows.front[1]], [rows.right[2], rows.up[2], rows.front[2]]].map((c) => c.map((v) => v * s)); + const rootMatrix = (t) => [...axes[0], 0, ...axes[1], 0, ...axes[2], 0, t[0], t[1], t[2], 1]; + const measured = new Map(m.parts.map((p) => [p.key, { positions: [], triangles: 0, closed: true }])); + const raw0 = rootMatrix([0, 0, 0]); + for (const [i, w] of world) { + const node = json.nodes[i]; + if (node.mesh === undefined) continue; + const total = multiply(raw0, w); + const det = total[0] * (total[5] * total[10] - total[9] * total[6]) - total[4] * (total[1] * total[10] - total[9] * total[2]) + total[8] * (total[1] * total[6] - total[5] * total[2]); + if (det < 0) throw new Error(`mesh node ${node.name ?? '#' + i} is mirrored (a negative scale): its faces would be drawn inside out; unmirror it in the source or flip it in the manifest first`); + const into = measured.get(members.get(i)); + for (const prim of json.meshes[node.mesh].primitives) { + const pos = readAccessor(json, bin, flat, prim.attributes.POSITION); + if (pos.width !== 3) throw new Error('POSITION is not a VEC3'); + const out = new Float32Array(pos.count * 3); + for (let v = 0; v < pos.count; v++) { const p = apply(total, pos.data[v * 3], pos.data[v * 3 + 1], pos.data[v * 3 + 2]); out.set(p, v * 3); } + const index = prim.indices !== undefined ? readAccessor(json, bin, flat, prim.indices).data : Array.from({ length: pos.count }, (_, k) => k); + const welded = weld(out, index); + into.closed = into.closed && isClosed(welded.indices); + into.triangles += index.length / 3; + into.positions.push(out); + } + } + const everything = bounds(Float32Array.from(Array.from(measured.values()).flatMap((p) => p.positions.flatMap((a) => Array.from(a))))); + const shift = everything.center.map((v) => -v); + const result = {}; + let triangles = 0; + for (const p of m.parts) { + const got = measured.get(p.key); + if (!got.positions.length) throw new Error(`part ${p.key} holds no mesh`); + const b = bounds(Float32Array.from(got.positions.flatMap((a) => Array.from(a)))); + const center = b.center.map((v, k) => round(v + shift[k])); + // The hub is where the part turns (a clock hand's boss): the origin of its own node, taken through the same axes and middle, or a point the manifest gives. + let hub; + if (p.hub === 'node') { + const [first] = p.nodes.flatMap((id) => nodesNamed(json, id)); + hub = apply(multiply(rootMatrix(shift), world.get(first)), 0, 0, 0).map((v) => round(v)); + } else if (Array.isArray(p.hub)) hub = p.hub.map((v) => round(v)); + result[p.key] = { center, size: b.size.map((v) => round(v)), closed: got.closed, triangles: got.triangles, ...(hub ? { hub } : {}) }; + triangles += got.triangles; + } + // Tag the parts, add the root. + for (const p of m.parts) for (const id of p.nodes) for (const i of nodesNamed(json, id)) json.nodes[i].extras = { ...(json.nodes[i].extras ?? {}), part: p.key }; + json.nodes.push({ name: m.id, matrix: rootMatrix(shift).map((v) => round(v, 9)), children: [...roots] }); + scene.nodes = [json.nodes.length - 1]; + json.asset = { ...json.asset, generator: `${json.asset.generator ?? 'unknown'}; passed through by talkthrough assets:build` }; + delete json.extras; + + 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 glb = Buffer.alloc(total); + glb.writeUInt32LE(0x46546c67, 0); glb.writeUInt32LE(2, 4); glb.writeUInt32LE(total, 8); + glb.writeUInt32LE(js.length, 12); glb.writeUInt32LE(0x4e4f534a, 16); js.copy(glb, 20); + const o = 20 + js.length; + glb.writeUInt32LE(bin.length, o); glb.writeUInt32LE(0x004e4942, o + 4); bin.copy(glb, o + 8); + return { glb, size: everything.size.map((v) => round(v)), triangles, parts: result }; +} diff --git a/scripts/assets/index.mjs b/scripts/assets/index.mjs new file mode 100644 index 0000000..15f23b2 --- /dev/null +++ b/scripts/assets/index.mjs @@ -0,0 +1,119 @@ +// 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 }, + release: { blocked: m.release?.blocked === true, why: m.release?.why }, + credit: LICENCES[m.licence.id].credit ? m.credit : undefined, + format: m.format ?? 'obj', + // One object with no parts of its own (a scan, or a model of one thing): it is labelled whole, never exploded or cut. + single: m.parts.length === 1, + size: m.built.size, realLengthMetres: m.scale.realLengthMetres ?? Math.max(...m.built.size), 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 ?? [255, 255, 255], 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, + ...(m.built.parts[p.key].hub ? { hub: m.built.parts[p.key].hub } : {}), ...(p.explode ? { explode: p.explode } : {}), + })), + })); + 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: those of the models a release carries are committed, the rest are not (see docs/real-models.md). + +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; + /** Where the part turns, in metres from the model's own middle (a clock hand's boss), when it is not its own middle: a spin or loop turns it about this point. */ + hub?: Vec3; + /** Where the part goes in metres when the model is exploded (a hand lifts off its face), from where it sits; without it, outward from the middle. */ + explode?: Vec3; +}; +export type ModelEntry = { + id: string; name: string; description: string; aliases: string[]; + /** obj: parts built from a source's meshes and drawn in a flat colour; gltf: the artist's own textured materials, passed through. */ + format: 'obj' | 'gltf'; + /** One object with no parts of its own: label the whole, never explode or cut it. */ + single: boolean; + licence: { id: string; name: string; version: string; url: string }; + /** A model held back from every release (the installer is not built while one is). */ + release: { blocked: boolean; why?: string }; + /** The credit line the licence asks to be shown (CC BY); none for CC0. */ + credit?: string; + /** 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\'s own code is MIT licensed. The MIT licence covers that code only: it excludes the models named here, which are separate works under their own licences, listed below with who made them and what was changed.', + '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})`); + if (m.source.archive) lines.push(`- Source archive: ${m.source.archive.url} (${m.source.archive.bytes} bytes)`); + lines.push(`- Licence: ${lic.name}, version ${m.licence.version}: ${m.licence.url ?? lic.url}`); + if (m.licence.earlierNotice) lines.push(`- Earlier notice, kept on record: ${m.licence.earlierNotice.evidence} name ${m.licence.earlierNotice.name}; the current grant above is what is relied on.`); + if (m.release?.blocked) lines.push(`- Held back from releases: ${m.release.why}.`); + if (m.credit) lines.push(`- Credit: ${m.credit}`); + if (m.licence.statement) lines.push(`- As the licence is stated at ${m.licence.statedOn}: ${m.licence.statement}`); + if (m.source.authors?.length) lines.push(`- Made by: ${m.source.authors.join(', ')}${m.licence.id === 'CC0-1.0' ? ' (no credit is required; named here as a courtesy)' : ''}`); + if (m.retrieved) lines.push(`- Fetched on ${m.retrieved} from: ${m.files.filter((f) => f.url).map((f) => f.url).slice(0, 1).join('')}${m.files.length > 1 ? ` and ${m.files.length - 1} more files named in the manifest` : ''}`); + 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(m.format === 'gltf' + ? `- Parts (source node): ${m.parts.map((p) => `${p.name} (${(p.nodes ?? []).join(' ')})`).join('; ')}` + : `- Parts (confidence; source element ids): ${m.parts.map((p) => `${p.name} (${p.confidence}; ${(p.nodes ?? []).join(' ')})`).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 0000000..5cf0e56 --- /dev/null +++ b/scripts/assets/manifest.mjs @@ -0,0 +1,108 @@ +// 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']; + +/** The only hosts a glTF model's files may be fetched from: the original publishers'. Another host is a reviewed code change, never a manifest edit. */ +export const FETCH_HOSTS = ['dl.polyhaven.org', '3d-api.si.edu']; + +/** Whether an address may be fetched from: https, on a publisher's own host. Checked before a request and again for where a redirect landed. */ +export function fetchAddressProblem(url) { + let u; + try { u = new URL(url); } catch { return `${url} is not an address`; } + if (u.protocol !== 'https:') return `${url} is not https`; + if (!FETCH_HOSTS.includes(u.hostname)) return `${u.hostname} is not an allowed host (${FETCH_HOSTS.join(', ')})`; + return undefined; +} + +/** Where a model's source files live in the cache: a folder of its own for a glTF model, the source's folder for an archive's. */ +export const cacheFolder = (m) => join(CACHE_DIR, m.format === 'gltf' ? m.source.cacheFolder : m.source.name.toLowerCase().replace(/[^a-z0-9]+/g, '-')); +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'); + // An older notice on the files themselves is kept on record, never erased. + if (m.licence?.earlierNotice) { + const c = m.licence.earlierNotice; + need(typeof c.id === 'string' && typeof c.name === 'string' && typeof c.evidence === 'string' && c.kept === true, 'an earlier licence notice names the licence, where it is found, and that it is kept'); + } + need(m.release === undefined || (typeof m.release.blocked === 'boolean' && (!m.release.blocked || typeof m.release.why === 'string')), 'release is { blocked, why }'); + 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(m.format === undefined || m.format === 'obj' || m.format === 'gltf', 'format is obj or gltf'); + const gltf = m.format === 'gltf'; + 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.entry === 'string' && f.entry.length > 0, 'a file needs an entry'); + need(typeof f.entry !== 'string' || (!/^[/\\]/.test(f.entry) && !/[:\\]/.test(f.entry) && !f.entry.split('/').includes('..')), `file entry "${f.entry}" must stay inside the model's folder (no absolute path, drive, backslash or ..)`); + const id = f.id ?? f.entry; + if (!gltf) need(typeof f.id === 'string', 'a file needs an id and an entry'); + need(!fileIds.has(id), `file ${id} is listed twice`); + fileIds.add(id); + if (gltf) { + need(fetchAddressProblem(f.url) === undefined, `${f.entry}: url must be https on one of ${FETCH_HOSTS.join(', ')}`); + need(Number.isInteger(f.bytes) && f.bytes > 0 && typeof f.sha256 === 'string' && /^[0-9a-f]{64}$/.test(f.sha256), `${f.entry}: bytes and sha256 must be pinned`); + } + } + if (gltf) { + need(m.files.filter((f) => /[.](gltf|glb)$/i.test(f.entry)).length === 1, 'exactly one .gltf or .glb file is the model'); + need(m.source && typeof m.source.cacheFolder === 'string' && /^[a-z0-9][a-z0-9-]*$/.test(m.source.cacheFolder), 'source.cacheFolder is the folder of its own in the cache'); + need(typeof m.retrieved === 'string' && /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.test(m.retrieved), 'retrieved (the date the files were fetched) is missing'); + need(m.licence && typeof m.licence.statement === 'string' && typeof m.licence.statedOn === 'string', 'a glTF model records the licence as its page states it (licence.statement, licence.statedOn)'); + } + 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(p.hub === undefined || (gltf && (p.hub === 'node' || (Array.isArray(p.hub) && p.hub.length === 3 && p.hub.every(Number.isFinite)))), `part ${p.key}: hub must be "node" (the origin of its node) or [x, y, z] metres, on a gltf model`); + need(p.explode === undefined || (Array.isArray(p.explode) && p.explode.length === 3 && p.explode.every(Number.isFinite)), `part ${p.key}: explode must be [x, y, z] metres`); + need(Array.isArray(p.nodes) && p.nodes.length > 0 || p.derive, `part ${p.key} names no ${gltf ? 'node' : 'file'}`); + if (!gltf) 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 0000000..55c92ff --- /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/release.mjs b/scripts/assets/release.mjs new file mode 100644 index 0000000..58595ec --- /dev/null +++ b/scripts/assets/release.mjs @@ -0,0 +1,29 @@ +// What a release build leaves out. A model whose manifest says `release.blocked` is for local use: a release is built with a catalogue that does not +// list it (so the guide, the schema and the validator never offer it and answers use shapes instead), and without its file or its credits. +// `npm run dist` builds this way; the build says what it left out. + +import { catalogueSource } from './index.mjs'; +import { ROOT, readManifests } from './manifest.mjs'; +import { join } from 'node:path'; + +/** The manifests a release carries, and those it leaves out with why. */ +export function releaseSplit() { + const all = readManifests().map((x) => x.manifest); + return { kept: all.filter((m) => m.release?.blocked !== true), dropped: all.filter((m) => m.release?.blocked === true) }; +} + +/** An esbuild plugin that serves src/scene/model-catalogue.ts without the held models. */ +export const releaseCatalogue = { + name: 'release-catalogue', + setup(build) { + const target = join(ROOT, 'src', 'scene', 'model-catalogue.ts').replace(/[\\]/g, '/').toLowerCase(); + build.onLoad({ filter: /model-catalogue\.ts$/ }, (args) => { + if (args.path.replace(/[\\]/g, '/').toLowerCase() !== target) return undefined; + return { contents: catalogueSource(releaseSplit().kept), loader: 'ts', resolveDir: join(ROOT, 'src', 'scene') }; + }); + }, +}; + +export const droppedNote = (dropped) => dropped.length + ? `left out of this release (held back): ${dropped.map((m) => `${m.id} (${m.release.why})`).join('; ')}` + : ''; diff --git a/scripts/assets/ship.mjs b/scripts/assets/ship.mjs new file mode 100644 index 0000000..5ed399a --- /dev/null +++ b/scripts/assets/ship.mjs @@ -0,0 +1,39 @@ +// 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 a scene that asks for such a model shows +// the stage without it and says so; `strict` (the installer) refuses to go on without the files of the models it carries. +// `release` leaves out every model held back (`release.blocked`): its file is not copied (a copy from an earlier build is removed), and the credits +// file lists only what is carried, or is not written when nothing is. + +import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { creditsSource } from './index.mjs'; +import { BUILT_DIR, ROOT, readManifests, sha256 } from './manifest.mjs'; +import { droppedNote } from './release.mjs'; + +export function shipModels({ strict = false, release = false, out = join(ROOT, 'dist') } = {}) { + const all = readManifests().map((x) => x.manifest); + const dropped = release ? all.filter((m) => m.release?.blocked === true) : []; + const carried = all.filter((m) => !dropped.includes(m)); + for (const m of dropped) if (m.built) rmSync(join(out, 'models', m.built.file), { force: true }); + const missing = []; + const shipped = []; + for (const m of carried) { + 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); + } + if (release && carried.length === 0) { + rmSync(join(out, 'models'), { recursive: true, force: true }); + rmSync(join(out, 'CREDITS.md'), { force: true }); + } else if (release) writeFileSync(join(out, 'CREDITS.md'), creditsSource(carried)); + else if (existsSync(join(ROOT, 'assets', 'CREDITS.md'))) copyFileSync(join(ROOT, 'assets', 'CREDITS.md'), join(out, 'CREDITS.md')); + if (dropped.length) console.warn(`talkthrough: ${droppedNote(dropped)}`); + if (missing.length) { + const why = `real models not built (${missing.join(', ')}): run npm run assets to fetch and build them; until then a scene that uses one shows the stage without it and says so`; + if (strict) throw new Error(why); + console.warn(`talkthrough: ${why}`); + } + return { shipped, missing, dropped: dropped.map((m) => m.id) }; +} diff --git a/scripts/assets/zip-range.mjs b/scripts/assets/zip-range.mjs new file mode 100644 index 0000000..af23036 --- /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 54437b5..6a51af5 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -4,6 +4,11 @@ import { copyFileSync, existsSync, mkdirSync } from 'node:fs'; import { dirname } from 'node:path'; import { build } from 'esbuild'; +import { shipModels } from './assets/ship.mjs'; +import { releaseCatalogue } from './assets/release.mjs'; + +// `--release` builds what is shipped: the real models held back are left out of the catalogue the app is built with (see scripts/assets/release.mjs). +const release = process.argv.includes('--release'); const node = { platform: 'node', format: 'cjs' }; const browser = { platform: 'browser', format: 'iife' }; @@ -34,7 +39,7 @@ for (const { entry, out, platform, format, external } of targets) { console.log(`skip ${entry} (not written yet)`); continue; } - await build({ entryPoints: [entry], outfile: out, bundle: true, platform, format, target: 'es2023', external, sourcemap: true, logLevel: 'warning' }); + await build({ entryPoints: [entry], outfile: out, bundle: true, platform, format, target: 'es2023', external, sourcemap: true, logLevel: 'warning', plugins: release ? [releaseCatalogue] : [] }); console.log(`built ${out}`); } for (const [from, to] of pages) { @@ -46,3 +51,5 @@ for (const [from, to] of pages) { copyFileSync(from, to); console.log(`copied ${to}`); } +const models = shipModels({ release }); +if (models.shipped.length) console.log('copied models', models.shipped.join(', ')); diff --git a/scripts/dist.mjs b/scripts/dist.mjs index ce96019..979f79e 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' } }); @@ -14,6 +15,7 @@ if (checkNativeInputs('node_modules') !== 0) { throw new Error('Native debug paths must be sanitized in a disposable packaging copy before building; see docs/setup.md.'); } ensureElectronOrExit(); // electron-builder packs the Electron in node_modules/electron/dist -run(process.execPath, ['scripts/build.mjs']); +run(process.execPath, ['scripts/build.mjs', '--release']); // the models held back are left out, and the build says which +shipModels({ strict: true, release: true }); // the installer carries the real models it lists: 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 3676896..a47d606 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'; @@ -601,6 +601,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 e3afc39..5095c21 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 d86f651..20ea8ab 100644 --- a/src/overlay/index.html +++ b/src/overlay/index.html @@ -3,7 +3,7 @@ Talkthrough overlay - +