zincjs 2.4.1-beta.3 → 2.4.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -70
- package/build/zinc.js +5 -5
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/controls.js +71 -49
- package/src/loaders/GLTFToZincJSLoader.js +4 -1
- package/src/loaders/JSONLoader.js +2 -2
- package/src/loaders/primitivesLoader.js +60 -17
- package/src/minimap.js +48 -13
- package/src/primitives/geometry.js +2 -0
- package/src/primitives/glyph.js +11 -1
- package/src/primitives/glyphset.js +33 -7
- package/src/primitives/label.js +39 -24
- package/src/primitives/lines.js +2 -0
- package/src/primitives/lines2.js +76 -24
- package/src/primitives/lod.js +18 -4
- package/src/primitives/marker.js +6 -1
- package/src/primitives/markerCluster.js +5 -1
- package/src/primitives/pointset.js +33 -28
- package/src/primitives/texturePrimitive.js +12 -0
- package/src/primitives/textureSlides.js +24 -3
- package/src/primitives/textureVolume.js +2 -0
- package/src/primitives/tubeLines.js +4 -0
- package/src/primitives/zincObject.js +80 -10
- package/src/region.js +92 -37
- package/src/renderRequests.js +20 -0
- package/src/renderer.js +81 -9
- package/src/scene.js +133 -23
- package/src/sceneExporter.js +4 -0
- package/src/sceneLoader.js +114 -18
- package/src/textSprite.js +211 -0
- package/src/texture/texture.js +10 -0
- package/src/texture/textureArray.js +9 -0
- package/src/utilities.js +147 -47
package/README.md
CHANGED
|
@@ -1,110 +1,126 @@
|
|
|
1
|
-
ZincJS
|
|
2
|
-
|
|
1
|
+
ZincJS
|
|
2
|
+
======
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
ZincJS is a JavaScript library for displaying anatomical and physiological models in the web browser. It is the web counterpart of [OpenCMISS-Zinc](https://github.com/OpenCMISS/zinc): scenes built with PyZinc, Scaffold Maker or the Mapping Tools can be exported and shown interactively on a web page, keeping their region hierarchy, named anatomical groups, graphics settings and time-varying data.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
------------------------------
|
|
6
|
+
It is built on [three.js](https://threejs.org/) and renders with WebGPU, falling back to WebGL 2 where WebGPU is unavailable.
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
Why ZincJS?
|
|
9
|
+
-----------
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
General-purpose 3D libraries can draw meshes, but they know nothing about Zinc models. ZincJS adds the pieces needed for biomedical scaffolds:
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
* **Direct pipeline from Zinc** – load scenes exported from PyZinc / the Argon scene exporter through a single metadata file, with no custom loader code.
|
|
14
|
+
* **Region hierarchy and named groups** – objects are organised in a Zinc-like region tree and identified by anatomical group names, which makes it straightforward to link a 3D structure to search, highlighting and ontology terms.
|
|
15
|
+
* **Time-varying models** – morph-target animation of geometry and field colours (for example a beating heart or gut motility), with scene-wide playback control.
|
|
16
|
+
* **Primitives for scaffolds and fields** – surfaces, lines, tube lines, point sets, glyph sets for vector/tensor fields, labels, markers with clustering and level-of-detail switching.
|
|
17
|
+
* **Imaging alongside models** – volume rendering and texture slices from NIfTI images in the same scene as the scaffold.
|
|
18
|
+
* **Application features** – multiple scenes per renderer, picking, smooth camera transitions, auto-tumble, stereo, minimap, video synchronisation and glTF import/export.
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
Applications built with ZincJS:
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
* [SPARC Portal](https://sparc.science/maps?type=wholebody)
|
|
23
|
+
* [ScaffoldVuer](https://mapcore-demo.org/current/scaffoldvuer)
|
|
24
|
+
* [Scaffold Maker](https://mapcore-demo.org/2019/colon/scaffold.html)
|
|
25
|
+
* [Fitzlet](https://sites.bioeng.auckland.ac.nz/mwu035/fitzlet/)
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
Installation
|
|
28
|
+
------------
|
|
29
|
+
|
|
30
|
+
Install from npm:
|
|
21
31
|
|
|
22
32
|
```Shell
|
|
23
|
-
$ npm install
|
|
24
|
-
$ npm run build-bundle
|
|
33
|
+
$ npm install zincjs
|
|
25
34
|
```
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Useful links:
|
|
30
|
-
-------------
|
|
31
|
-
|
|
32
|
-
[Examples](https://github.com/alan-wu/ZincJS-Examples/)
|
|
36
|
+
Pre-releases are published under the `beta` tag (`npm install zincjs@beta`).
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
Quick start
|
|
39
|
+
-----------
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
```javascript
|
|
42
|
+
import Zinc from 'zincjs';
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
const container = document.getElementById('zinc-container');
|
|
45
|
+
const renderer = new Zinc.Renderer(container);
|
|
46
|
+
await renderer.initialiseVisualisation();
|
|
40
47
|
|
|
41
|
-
|
|
48
|
+
const scene = renderer.getCurrentScene();
|
|
49
|
+
scene.loadMetadataURL('models/metadata.json', undefined, () => {
|
|
50
|
+
scene.viewAll();
|
|
51
|
+
});
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
renderer.animate();
|
|
54
|
+
```
|
|
45
55
|
|
|
46
|
-
|
|
56
|
+
`initialiseVisualisation` is asynchronous and must finish before any scene is used. Other formats can be loaded with `scene.loadGLTF`, `scene.loadOBJ` and `scene.loadSTL`, and NIfTI images with `Zinc.createPrimitivesFromNIFTI`.
|
|
47
57
|
|
|
48
|
-
|
|
49
|
-
-----------------
|
|
58
|
+
### Render on demand
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
By default the renderer draws every animation frame. To only draw when something has changed, which saves GPU time and battery on idle pages, enable render on demand:
|
|
52
61
|
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
```javascript
|
|
63
|
+
renderer.setRenderOnDemand(true);
|
|
64
|
+
```
|
|
55
65
|
|
|
56
|
-
|
|
66
|
+
Camera movement, playback, loading, changes made through the ZincJS APIs and changes to scene properties such as `displayMinimap`, `displayMiniAxes` or `displayMarkers` request a frame automatically. Call `renderer.invalidate()` after changing three.js objects directly, or after changing the three.js renderer from `getThreeJSRenderer()`, e.g. `setClearColor`. Pre-render callbacks still run every frame and can call `invalidate()`; post-render callbacks only run when a frame is drawn.
|
|
57
67
|
|
|
58
|
-
|
|
68
|
+
Useful links:
|
|
59
69
|
|
|
60
|
-
|
|
70
|
+
* [Examples](https://github.com/alan-wu/ZincJS-Examples/)
|
|
71
|
+
* [Tutorials](https://github.com/alan-wu/ZincJS-Tutorials/)
|
|
72
|
+
* [API documentation](https://abi-software.github.io/ZincJS/)
|
|
61
73
|
|
|
62
|
-
|
|
74
|
+
Exporting models to ZincJS
|
|
75
|
+
--------------------------
|
|
63
76
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
upVector: [0.0, 1.0, 0.0]
|
|
67
|
-
interest point: [9.704483032226562, 6.385875701904297, -5.001008987426758]
|
|
68
|
-
eye point: [9.704483032226562, 6.385875701904297, 291.1961093658496]}
|
|
77
|
+
* **Mapping Tools users** – use the [Argon scene exporter](https://abi-mapping-tools.readthedocs.io/en/v1.2.1/mapclientplugins.argonsceneexporterstep/docs/index.html) step.
|
|
78
|
+
* **PyZinc users** – see [PyZinc2ZincJS](https://github.com/alan-wu/PyZinc2ZincJS/).
|
|
69
79
|
|
|
70
|
-
|
|
80
|
+
Both produce a metadata JSON file plus the files it references. Keep them in the same folder and pass the metadata file's URL to `scene.loadMetadataURL`.
|
|
71
81
|
|
|
72
|
-
|
|
82
|
+
<details>
|
|
83
|
+
<summary>Legacy: exporting from CMGUI</summary>
|
|
73
84
|
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
1. Read in your files in CMGUI and set up the graphics and viewing window.
|
|
86
|
+
2. Export with `gfx export threejs` (run `gfx export threejs ?` for options) and note the `filename_prefix` you choose.
|
|
87
|
+
3. Adjust the view, then run `gfx list win 1` and copy the eye point, interest point, up vector, near plane and far plane into a view file:
|
|
76
88
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
```json
|
|
90
|
+
{"farPlane": 601.12, "nearPlane": 14.81, "upVector": [0.0, 1.0, 0.0],
|
|
91
|
+
"targetPosition": [9.70, 6.39, -5.00], "eyePosition": [9.70, 6.39, 291.20]}
|
|
92
|
+
```
|
|
81
93
|
|
|
82
|
-
|
|
83
|
-
Make sure all the json files are located in the same folder and now we should have all files required and we are ready to view them.
|
|
94
|
+
4. The first exported file (`[filename_prefix]_1.json`) is the metadata file. Add an entry for the view file to it:
|
|
84
95
|
|
|
85
|
-
|
|
96
|
+
```json
|
|
97
|
+
{ "Type": "View", "URL": "new_models_view.json" }
|
|
98
|
+
```
|
|
86
99
|
|
|
87
|
-
|
|
88
|
-
----------------
|
|
100
|
+
</details>
|
|
89
101
|
|
|
90
|
-
|
|
102
|
+
Controls
|
|
103
|
+
--------
|
|
91
104
|
|
|
92
|
-
|
|
93
|
-
|
|
105
|
+
| Action | Mouse | Touch |
|
|
106
|
+
|-----------|---------------------|------------------------|
|
|
107
|
+
| Rotate | Left button drag | One-finger drag |
|
|
108
|
+
| Zoom | Middle button drag / scroll wheel | Two-finger pinch |
|
|
109
|
+
| Pan | Right button drag | Three-finger drag |
|
|
94
110
|
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
Building from source
|
|
112
|
+
--------------------
|
|
97
113
|
|
|
98
|
-
|
|
99
|
-
----------------
|
|
114
|
+
Requires Node.js 24.
|
|
100
115
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
116
|
+
```Shell
|
|
117
|
+
$ npm install
|
|
118
|
+
$ npm run build-bundle # outputs build/zinc.js and its source map
|
|
119
|
+
$ npm run test-standard # run the test suite
|
|
120
|
+
$ npm run jsdoc # regenerate the API documentation in docs/
|
|
121
|
+
```
|
|
106
122
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
* Right click/two finger pinch: Zoom
|
|
123
|
+
License
|
|
124
|
+
-------
|
|
110
125
|
|
|
126
|
+
[MIT](LICENSE)
|