zincjs 2.4.1-beta.2 → 2.4.1-beta.4

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 CHANGED
@@ -1,110 +1,116 @@
1
- ZincJS (Web-based-Zinc-Visualisation)
2
- =====================================
1
+ ZincJS
2
+ ======
3
3
 
4
- Some of the following documentations are currerntly out-of-date .
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
- Webapp developed using ZincJS:
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
- [SPARC Portal](https://sparc.science/maps?type=wholebody)
8
+ Why ZincJS?
9
+ -----------
10
10
 
11
- [Fitzlet](https://sites.bioeng.auckland.ac.nz/mwu035/fitzlet/)
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
- [Scaffold Maker](https://mapcore-demo.org/2019/colon/scaffold.html)
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
- [ScaffoldVuer](https://mapcore-demo.org/current/scaffoldvuer)
20
+ Applications built with ZincJS:
16
21
 
17
- Installation:
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
- You need NPM to build the ZincJS library. Once NPM has been installed, follow the instructions below:
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
- If everything works accordingly, a 'build' folder along with two files zinc.js and zinc.min.js in it should be created. The zinc.js and zinc.min.js can now be consumed in your preferred envirnoment.
28
-
29
- Useful links:
30
- -------------
31
-
32
- [Examples](https://github.com/alan-wu/ZincJS-Examples/)
33
-
34
- [Tutorials](https://github.com/alan-wu/ZincJS-Tutorials/)
35
-
36
- [API Documentation](https://abi-software.github.io/ZincJS/)
36
+ Pre-releases are published under the `beta` tag (`npm install zincjs@beta`).
37
37
 
38
- How to export models to ZincJS:
39
- -------------------------------
38
+ Quick start
39
+ -----------
40
40
 
41
- Here is a short instruction on how to get simple models from CMGUI/Zinc showing on web brwoser quickly.
41
+ ```javascript
42
+ import Zinc from 'zincjs';
42
43
 
43
- For Mapping Tool users:
44
- -----------------------
44
+ const container = document.getElementById('zinc-container');
45
+ const renderer = new Zinc.Renderer(container);
46
+ await renderer.initialiseVisualisation();
45
47
 
46
- [Argon scene exporter](https://abi-mapping-tools.readthedocs.io/en/v1.2.1/mapclientplugins.argonsceneexporterstep/docs/index.html)
48
+ const scene = renderer.getCurrentScene();
49
+ scene.loadMetadataURL('models/metadata.json', undefined, () => {
50
+ scene.viewAll();
51
+ });
47
52
 
48
- For PyZinc users:
49
- -----------------
50
-
51
- [PyZinc2ZincJS](https://github.com/alan-wu/PyZinc2ZincJS/)
52
-
53
- For Cmgui users:
54
- ----------------
53
+ renderer.animate();
54
+ ```
55
55
 
56
- 1. Download the latest cmgui from http://physiomeproject.org/software/opencmiss/cmgui/download/developer
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`.
57
57
 
58
- 2. Read in your files, set up the graphics and viewing windows.
58
+ Useful links:
59
59
 
60
- 3. Export the json files using the following command gfx expore threejs, there are few different options regarding the export, make sure you read the instruction using "gfx export threejs ?" command. Please note down the filename_prefix you have chosen here. The number of files output may vary depending on the type of graphics.
60
+ * [Examples](https://github.com/alan-wu/ZincJS-Examples/)
61
+ * [Tutorials](https://github.com/alan-wu/ZincJS-Tutorials/)
62
+ * [API documentation](https://abi-software.github.io/ZincJS/)
61
63
 
62
- 4. A file containing information of the viewport is also required. After adjusting the viewport on Cmgui to the desired setting then note down the values of eye point, interest point, upvector, near plane and far plane from the output of the "gfx list win 1" command. For example with the following output:
64
+ Exporting models to ZincJS
65
+ --------------------------
63
66
 
64
- farPlane: 601.1211762872496
65
- nearPlane: 14.809855917663832
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]}
67
+ * **Mapping Tools users** – use the [Argon scene exporter](https://abi-mapping-tools.readthedocs.io/en/v1.2.1/mapclientplugins.argonsceneexporterstep/docs/index.html) step.
68
+ * **PyZinc users** – see [PyZinc2ZincJS](https://github.com/alan-wu/PyZinc2ZincJS/).
69
69
 
70
- The viewport file will look like this:
70
+ 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
71
 
72
- {"farPlane": 601.1211762872496, "nearPlane": 14.809855917663832, "upVector": [0.0, 1.0, 0.0], "targetPosition": [9.704483032226562, 6.385875701904297, -5.001008987426758], "eyePosition": [9.704483032226562, 6.385875701904297, 291.1961093658496]}
72
+ <details>
73
+ <summary>Legacy: exporting from CMGUI</summary>
73
74
 
74
- 5. The first exported file -[filename]_1.json is the metadata file and contains
75
- informations of other required files including primitives type, url and etc. It also contains information of the viewport file (as mentioned above) but as the parameters are not known to the exporters. Users have to add it to the metadata file themselves and it looks something like:
75
+ 1. Read in your files in CMGUI and set up the graphics and viewing window.
76
+ 2. Export with `gfx export threejs` (run `gfx export threejs ?` for options) and note the `filename_prefix` you choose.
77
+ 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
78
 
77
- {
78
- "Type" : "View",
79
- "URL" : "new_models_view.json"
80
- }
79
+ ```json
80
+ {"farPlane": 601.12, "nearPlane": 14.81, "upVector": [0.0, 1.0, 0.0],
81
+ "targetPosition": [9.70, 6.39, -5.00], "eyePosition": [9.70, 6.39, 291.20]}
82
+ ```
81
83
 
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.
84
+ 4. The first exported file (`[filename_prefix]_1.json`) is the metadata file. Add an entry for the view file to it:
84
85
 
85
- *please not that only surfaces are supported at this moment.
86
+ ```json
87
+ { "Type": "View", "URL": "new_models_view.json" }
88
+ ```
86
89
 
87
- For PyZinc users:
88
- ----------------
90
+ </details>
89
91
 
90
- Take a look at the following page: https://github.com/alan-wu/PyZinc2ZincJS
92
+ Controls
93
+ --------
91
94
 
92
- Using the sample page:
93
- ----------------------
95
+ | Action | Mouse | Touch |
96
+ |-----------|---------------------|------------------------|
97
+ | Rotate | Left button drag | One-finger drag |
98
+ | Zoom | Middle button drag / scroll wheel | Two-finger pinch |
99
+ | Pan | Right button drag | Three-finger drag |
94
100
 
95
- I have included a simple html page - multiscenes_example.html which will display simple models.
96
- You can also view the following page to see mroe WebGL based Zinc in action: http://sites.bioeng.auckland.ac.nz/webgl_zinc_collections/
101
+ Building from source
102
+ --------------------
97
103
 
98
- Use of ThreeJS:
99
- ----------------
104
+ Requires Node.js 24.
100
105
 
101
- This library wraps the ThreeJS library and provides a more Zinc-like experience to users.
102
- I have modified the ThreeJS backend slightly to fit my usage here, you can find the github repository of my ThreeJS fork here: https://github.com/alan-wu/three.js
103
-
104
- Basic controls:
105
- ---------------
106
+ ```Shell
107
+ $ npm install
108
+ $ npm run build-bundle # outputs build/zinc.js and its source map
109
+ $ npm run test-standard # run the test suite
110
+ $ npm run jsdoc # regenerate the API documentation in docs/
111
+ ```
106
112
 
107
- * Left click/single finger touch move: Rotate
108
- * Middle click/three finger touch move: Translate
109
- * Right click/two finger pinch: Zoom
113
+ License
114
+ -------
110
115
 
116
+ [MIT](LICENSE)