@aics/vole-core 3.12.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.
Files changed (141) hide show
  1. package/LICENSE.txt +26 -0
  2. package/README.md +119 -0
  3. package/es/Atlas2DSlice.js +224 -0
  4. package/es/Channel.js +264 -0
  5. package/es/FileSaver.js +31 -0
  6. package/es/FusedChannelData.js +192 -0
  7. package/es/Histogram.js +250 -0
  8. package/es/ImageInfo.js +127 -0
  9. package/es/Light.js +74 -0
  10. package/es/Lut.js +500 -0
  11. package/es/MarchingCubes.js +507 -0
  12. package/es/MeshVolume.js +334 -0
  13. package/es/NaiveSurfaceNets.js +251 -0
  14. package/es/PathTracedVolume.js +482 -0
  15. package/es/RayMarchedAtlasVolume.js +250 -0
  16. package/es/RenderToBuffer.js +31 -0
  17. package/es/ThreeJsPanel.js +633 -0
  18. package/es/Timing.js +28 -0
  19. package/es/TrackballControls.js +538 -0
  20. package/es/View3d.js +848 -0
  21. package/es/Volume.js +352 -0
  22. package/es/VolumeCache.js +161 -0
  23. package/es/VolumeDims.js +16 -0
  24. package/es/VolumeDrawable.js +702 -0
  25. package/es/VolumeMaker.js +101 -0
  26. package/es/VolumeRenderImpl.js +1 -0
  27. package/es/VolumeRenderSettings.js +203 -0
  28. package/es/constants/basicShaders.js +29 -0
  29. package/es/constants/colors.js +59 -0
  30. package/es/constants/denoiseShader.js +43 -0
  31. package/es/constants/lights.js +42 -0
  32. package/es/constants/materials.js +85 -0
  33. package/es/constants/pathtraceOutputShader.js +13 -0
  34. package/es/constants/scaleBarSVG.js +21 -0
  35. package/es/constants/time.js +34 -0
  36. package/es/constants/volumePTshader.js +153 -0
  37. package/es/constants/volumeRayMarchShader.js +123 -0
  38. package/es/constants/volumeSliceShader.js +115 -0
  39. package/es/index.js +21 -0
  40. package/es/loaders/IVolumeLoader.js +131 -0
  41. package/es/loaders/JsonImageInfoLoader.js +255 -0
  42. package/es/loaders/OmeZarrLoader.js +495 -0
  43. package/es/loaders/OpenCellLoader.js +65 -0
  44. package/es/loaders/RawArrayLoader.js +89 -0
  45. package/es/loaders/TiffLoader.js +219 -0
  46. package/es/loaders/VolumeLoadError.js +44 -0
  47. package/es/loaders/VolumeLoaderUtils.js +221 -0
  48. package/es/loaders/index.js +40 -0
  49. package/es/loaders/zarr_utils/ChunkPrefetchIterator.js +143 -0
  50. package/es/loaders/zarr_utils/WrappedStore.js +51 -0
  51. package/es/loaders/zarr_utils/types.js +24 -0
  52. package/es/loaders/zarr_utils/utils.js +225 -0
  53. package/es/loaders/zarr_utils/validation.js +49 -0
  54. package/es/test/ChunkPrefetchIterator.test.js +208 -0
  55. package/es/test/RequestQueue.test.js +442 -0
  56. package/es/test/SubscribableRequestQueue.test.js +244 -0
  57. package/es/test/VolumeCache.test.js +118 -0
  58. package/es/test/VolumeRenderSettings.test.js +71 -0
  59. package/es/test/lut.test.js +671 -0
  60. package/es/test/num_utils.test.js +140 -0
  61. package/es/test/volume.test.js +98 -0
  62. package/es/test/zarr_utils.test.js +358 -0
  63. package/es/types/Atlas2DSlice.d.ts +41 -0
  64. package/es/types/Channel.d.ts +44 -0
  65. package/es/types/FileSaver.d.ts +6 -0
  66. package/es/types/FusedChannelData.d.ts +26 -0
  67. package/es/types/Histogram.d.ts +57 -0
  68. package/es/types/ImageInfo.d.ts +87 -0
  69. package/es/types/Light.d.ts +27 -0
  70. package/es/types/Lut.d.ts +67 -0
  71. package/es/types/MarchingCubes.d.ts +53 -0
  72. package/es/types/MeshVolume.d.ts +40 -0
  73. package/es/types/NaiveSurfaceNets.d.ts +11 -0
  74. package/es/types/PathTracedVolume.d.ts +65 -0
  75. package/es/types/RayMarchedAtlasVolume.d.ts +41 -0
  76. package/es/types/RenderToBuffer.d.ts +17 -0
  77. package/es/types/ThreeJsPanel.d.ts +107 -0
  78. package/es/types/Timing.d.ts +11 -0
  79. package/es/types/TrackballControls.d.ts +51 -0
  80. package/es/types/View3d.d.ts +357 -0
  81. package/es/types/Volume.d.ts +152 -0
  82. package/es/types/VolumeCache.d.ts +43 -0
  83. package/es/types/VolumeDims.d.ts +28 -0
  84. package/es/types/VolumeDrawable.d.ts +108 -0
  85. package/es/types/VolumeMaker.d.ts +49 -0
  86. package/es/types/VolumeRenderImpl.d.ts +22 -0
  87. package/es/types/VolumeRenderSettings.d.ts +98 -0
  88. package/es/types/constants/basicShaders.d.ts +4 -0
  89. package/es/types/constants/colors.d.ts +2 -0
  90. package/es/types/constants/denoiseShader.d.ts +40 -0
  91. package/es/types/constants/lights.d.ts +38 -0
  92. package/es/types/constants/materials.d.ts +20 -0
  93. package/es/types/constants/pathtraceOutputShader.d.ts +11 -0
  94. package/es/types/constants/scaleBarSVG.d.ts +2 -0
  95. package/es/types/constants/time.d.ts +19 -0
  96. package/es/types/constants/volumePTshader.d.ts +137 -0
  97. package/es/types/constants/volumeRayMarchShader.d.ts +117 -0
  98. package/es/types/constants/volumeSliceShader.d.ts +109 -0
  99. package/es/types/glsl.d.js +0 -0
  100. package/es/types/index.d.ts +28 -0
  101. package/es/types/loaders/IVolumeLoader.d.ts +113 -0
  102. package/es/types/loaders/JsonImageInfoLoader.d.ts +80 -0
  103. package/es/types/loaders/OmeZarrLoader.d.ts +87 -0
  104. package/es/types/loaders/OpenCellLoader.d.ts +9 -0
  105. package/es/types/loaders/RawArrayLoader.d.ts +33 -0
  106. package/es/types/loaders/TiffLoader.d.ts +45 -0
  107. package/es/types/loaders/VolumeLoadError.d.ts +18 -0
  108. package/es/types/loaders/VolumeLoaderUtils.d.ts +38 -0
  109. package/es/types/loaders/index.d.ts +22 -0
  110. package/es/types/loaders/zarr_utils/ChunkPrefetchIterator.d.ts +22 -0
  111. package/es/types/loaders/zarr_utils/WrappedStore.d.ts +24 -0
  112. package/es/types/loaders/zarr_utils/types.d.ts +94 -0
  113. package/es/types/loaders/zarr_utils/utils.d.ts +23 -0
  114. package/es/types/loaders/zarr_utils/validation.d.ts +7 -0
  115. package/es/types/test/ChunkPrefetchIterator.test.d.ts +1 -0
  116. package/es/types/test/RequestQueue.test.d.ts +1 -0
  117. package/es/types/test/SubscribableRequestQueue.test.d.ts +1 -0
  118. package/es/types/test/VolumeCache.test.d.ts +1 -0
  119. package/es/types/test/VolumeRenderSettings.test.d.ts +1 -0
  120. package/es/types/test/lut.test.d.ts +1 -0
  121. package/es/types/test/num_utils.test.d.ts +1 -0
  122. package/es/types/test/volume.test.d.ts +1 -0
  123. package/es/types/test/zarr_utils.test.d.ts +1 -0
  124. package/es/types/types.d.ts +115 -0
  125. package/es/types/utils/RequestQueue.d.ts +112 -0
  126. package/es/types/utils/SubscribableRequestQueue.d.ts +52 -0
  127. package/es/types/utils/num_utils.d.ts +43 -0
  128. package/es/types/workers/VolumeLoaderContext.d.ts +106 -0
  129. package/es/types/workers/types.d.ts +101 -0
  130. package/es/types/workers/util.d.ts +3 -0
  131. package/es/types.js +75 -0
  132. package/es/typings.d.js +0 -0
  133. package/es/utils/RequestQueue.js +267 -0
  134. package/es/utils/SubscribableRequestQueue.js +187 -0
  135. package/es/utils/num_utils.js +231 -0
  136. package/es/workers/FetchTiffWorker.js +153 -0
  137. package/es/workers/VolumeLoadWorker.js +129 -0
  138. package/es/workers/VolumeLoaderContext.js +271 -0
  139. package/es/workers/types.js +41 -0
  140. package/es/workers/util.js +8 -0
  141. package/package.json +83 -0
@@ -0,0 +1,118 @@
1
+ import { expect } from "chai";
2
+ import VolumeCache from "../VolumeCache";
3
+ describe("VolumeCache", () => {
4
+ it("creates an empty cache with the specified max size", () => {
5
+ const cache = new VolumeCache(10);
6
+ expect(cache.size).to.equal(0);
7
+ expect(cache.maxSize).to.equal(10);
8
+ });
9
+ describe("insert", () => {
10
+ it("adds a new entry to the cache", () => {
11
+ const cache = new VolumeCache();
12
+ expect(cache.get("1")).to.be.undefined;
13
+ const insertionResult = cache.insert("1", new Uint8Array(4));
14
+ expect(insertionResult).to.be.true;
15
+ expect(cache.get("1")).to.deep.equal(new Uint8Array(4));
16
+ });
17
+ it("does not insert an entry if it is too big for the cache", () => {
18
+ const cache = new VolumeCache(6);
19
+ const insertionResult = cache.insert("1", new Uint8Array(8));
20
+ expect(insertionResult).to.be.false;
21
+ expect(cache.get("1")).to.be.undefined;
22
+ });
23
+ it("evicts the least recently used entry when above its size limit", () => {
24
+ const cache = new VolumeCache(12); // max: 12
25
+
26
+ cache.insert("0", new Uint8Array(8)); // 8 < 12
27
+ cache.insert("1", new Uint8Array(2)); // 10 < 12
28
+ cache.insert("2", new Uint8Array(8)); // 18 > 12! evict 1!
29
+
30
+ expect(cache.size).to.equal(10);
31
+ expect(cache.numberOfEntries).to.equal(2);
32
+ expect(cache.get("0")).to.be.undefined;
33
+ expect(cache.get("1")).to.deep.equal(new Uint8Array(2));
34
+ expect(cache.get("2")).to.deep.equal(new Uint8Array(8));
35
+ });
36
+ it("evicts as many entries as it takes to get below max size", () => {
37
+ const cache = new VolumeCache(12);
38
+ cache.insert("0", new Uint8Array(6)); // 6
39
+ cache.insert("1", new Uint8Array(6)); // 12
40
+ cache.insert("2", new Uint8Array(8)); // 20!
41
+
42
+ expect(cache.size).to.equal(8);
43
+ expect(cache.numberOfEntries).to.equal(1);
44
+ expect(cache.get("0")).to.be.undefined;
45
+ expect(cache.get("1")).to.be.undefined;
46
+ expect(cache.get("2")).to.deep.equal(new Uint8Array(8));
47
+ });
48
+ it("reuses any entries that match the provided key", () => {
49
+ const cache = new VolumeCache(12);
50
+ cache.insert("0", new Uint8Array([1, 2, 3, 4])); // 4
51
+ cache.insert("1", new Uint8Array(8)); // 12
52
+ cache.insert("0", new Uint8Array([5, 6, 7, 8])); // still 12
53
+
54
+ expect(cache.size).to.equal(12);
55
+ expect(cache.numberOfEntries).to.equal(2);
56
+ expect(cache.get("1")).to.deep.equal(new Uint8Array(8));
57
+ expect(cache.get("0")).to.deep.equal(new Uint8Array([5, 6, 7, 8]));
58
+ });
59
+ });
60
+ const SLICE_0 = [1, 2, 3, 4];
61
+ const SLICE_1 = [5, 6, 7, 8];
62
+ const SLICE_2 = [2, 4, 6, 8];
63
+ const SLICE_3 = [1, 3, 5, 7];
64
+ function setupGetTest() {
65
+ const cache = new VolumeCache(12);
66
+ cache.insert("0", new Uint8Array(SLICE_0));
67
+ cache.insert("1", new Uint8Array(SLICE_1));
68
+ cache.insert("2", new Uint8Array(SLICE_2));
69
+ return cache;
70
+ }
71
+ describe("get", () => {
72
+ it("gets an entry when provided a key", () => {
73
+ const cache = setupGetTest();
74
+ const result = cache.get("1");
75
+ expect(result).to.deep.equal(new Uint8Array(SLICE_1));
76
+ });
77
+ it("moves returned entries to the front of the LRU queue", () => {
78
+ const cache = setupGetTest(); // size: 12; max: 12
79
+
80
+ cache.get("0"); // SLICE_0 moves from last to first; SLICE_1 is now last
81
+ cache.insert("3", new Uint8Array(SLICE_3)); // 16! evict SLICE_1
82
+
83
+ expect(cache.get("0")).to.deep.equal(new Uint8Array(SLICE_0));
84
+ expect(cache.get("1")).to.be.undefined;
85
+ expect(cache.get("2")).to.deep.equal(new Uint8Array(SLICE_2));
86
+ expect(cache.get("3")).to.deep.equal(new Uint8Array(SLICE_3));
87
+ });
88
+ });
89
+ function setupClearTest() {
90
+ const cache = new VolumeCache(12);
91
+ cache.insert("0/0", new Uint8Array(1));
92
+ cache.insert("0/1", new Uint8Array(2));
93
+ cache.insert("1/0", new Uint8Array(1));
94
+ return cache;
95
+ }
96
+ describe("clearWithPrefix", () => {
97
+ it("clears all entries from the cache whose keys have the specified prefix", () => {
98
+ const cache = setupClearTest();
99
+ cache.clearWithPrefix("0/");
100
+ expect(cache.size).to.equal(1);
101
+ expect(cache.numberOfEntries).to.equal(1);
102
+ expect(cache.get("0/0")).to.be.undefined;
103
+ expect(cache.get("0/1")).to.be.undefined;
104
+ expect(cache.get("1/0")).to.deep.equal(new Uint8Array(1));
105
+ });
106
+ });
107
+ describe("clear", () => {
108
+ it("clears all entries from the cache", () => {
109
+ const cache = setupClearTest();
110
+ cache.clear();
111
+ expect(cache.size).to.equal(0);
112
+ expect(cache.numberOfEntries).to.equal(0);
113
+ expect(cache.get("0/0")).to.be.undefined;
114
+ expect(cache.get("0/1")).to.be.undefined;
115
+ expect(cache.get("1/0")).to.be.undefined;
116
+ });
117
+ });
118
+ });
@@ -0,0 +1,71 @@
1
+ import { expect } from "chai";
2
+ import { Axis, VolumeRenderSettings } from "../VolumeRenderSettings";
3
+ import { Vector3 } from "three";
4
+ describe("VolumeRenderSettingUtils", () => {
5
+ it("deeply-copies bounds", () => {
6
+ const s1 = new VolumeRenderSettings();
7
+ const s1BMax = new Vector3(9.0, 9.0, 9.0);
8
+ s1.bounds.bmax = s1BMax;
9
+ const s2 = s1.clone();
10
+
11
+ // Values should be the same
12
+ expect(s1.bounds.bmax.equals(s1BMax)).to.be.true;
13
+ expect(s2.bounds.bmax.equals(s1BMax)).to.be.true;
14
+ expect(s1.isEqual(s2)).to.be.true;
15
+ const s2BMax = new Vector3(1.0, 2.0, 3.0);
16
+ s2.bounds.bmax = s2BMax;
17
+ expect(s2.bounds.bmax.equals(s2BMax)).to.be.true;
18
+ expect(s1.bounds.bmax.equals(s2BMax)).to.be.false;
19
+ });
20
+ it("deeply-copies arrays", () => {
21
+ const s1 = new VolumeRenderSettings();
22
+ const glossiness = [4.0, 3.0, 1.0];
23
+ s1.glossiness = glossiness;
24
+ const s2 = s1.clone();
25
+ expect(s1.glossiness).to.deep.equal(glossiness);
26
+ expect(s2.glossiness).to.deep.equal(glossiness);
27
+ s2.glossiness[1] = 17.0;
28
+
29
+ // s1 should not change.
30
+ expect(s1.glossiness).to.deep.equal(glossiness);
31
+ expect(s2.glossiness).to.deep.equal([4.0, 17.0, 1.0]);
32
+ expect(s1.glossiness).to.not.deep.equal(s2.glossiness);
33
+ });
34
+ it("can compare against itself", () => {
35
+ const s1 = new VolumeRenderSettings();
36
+ expect(s1.isEqual(s1)).to.be.true;
37
+ });
38
+ it("can compare settings objects", () => {
39
+ const s1 = new VolumeRenderSettings();
40
+ const s2 = new VolumeRenderSettings();
41
+ expect(s1.isEqual(s2)).to.be.true;
42
+ expect(s2.isEqual(s1)).to.be.true;
43
+
44
+ // Change boolean field
45
+ s2.isOrtho = !s2.isOrtho;
46
+ expect(s1.isEqual(s2)).to.be.false;
47
+ expect(s2.isEqual(s1)).to.be.false;
48
+
49
+ // Change array property
50
+ const s3 = new VolumeRenderSettings();
51
+ s3.specular[0][1] = 15;
52
+ expect(s1.isEqual(s3)).to.be.false;
53
+ expect(s3.isEqual(s1)).to.be.false;
54
+
55
+ // Change bounds
56
+ const s4 = new VolumeRenderSettings();
57
+ s4.bounds.bmax = new Vector3(-1, -2, -3);
58
+ expect(s1.isEqual(s4)).to.be.false;
59
+ expect(s4.isEqual(s1)).to.be.false;
60
+ s4.bounds.bmax = s1.bounds.bmax;
61
+ expect(s4.isEqual(s1)).to.be.true;
62
+ expect(s1.isEqual(s4)).to.be.true;
63
+ });
64
+ it("flags string changes", () => {
65
+ const s1 = new VolumeRenderSettings();
66
+ const s2 = new VolumeRenderSettings();
67
+ s1.viewAxis = Axis.NONE;
68
+ s2.viewAxis = Axis.X;
69
+ expect(s1.isEqual(s2)).to.be.false;
70
+ });
71
+ });