@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.
- package/LICENSE.txt +26 -0
- package/README.md +119 -0
- package/es/Atlas2DSlice.js +224 -0
- package/es/Channel.js +264 -0
- package/es/FileSaver.js +31 -0
- package/es/FusedChannelData.js +192 -0
- package/es/Histogram.js +250 -0
- package/es/ImageInfo.js +127 -0
- package/es/Light.js +74 -0
- package/es/Lut.js +500 -0
- package/es/MarchingCubes.js +507 -0
- package/es/MeshVolume.js +334 -0
- package/es/NaiveSurfaceNets.js +251 -0
- package/es/PathTracedVolume.js +482 -0
- package/es/RayMarchedAtlasVolume.js +250 -0
- package/es/RenderToBuffer.js +31 -0
- package/es/ThreeJsPanel.js +633 -0
- package/es/Timing.js +28 -0
- package/es/TrackballControls.js +538 -0
- package/es/View3d.js +848 -0
- package/es/Volume.js +352 -0
- package/es/VolumeCache.js +161 -0
- package/es/VolumeDims.js +16 -0
- package/es/VolumeDrawable.js +702 -0
- package/es/VolumeMaker.js +101 -0
- package/es/VolumeRenderImpl.js +1 -0
- package/es/VolumeRenderSettings.js +203 -0
- package/es/constants/basicShaders.js +29 -0
- package/es/constants/colors.js +59 -0
- package/es/constants/denoiseShader.js +43 -0
- package/es/constants/lights.js +42 -0
- package/es/constants/materials.js +85 -0
- package/es/constants/pathtraceOutputShader.js +13 -0
- package/es/constants/scaleBarSVG.js +21 -0
- package/es/constants/time.js +34 -0
- package/es/constants/volumePTshader.js +153 -0
- package/es/constants/volumeRayMarchShader.js +123 -0
- package/es/constants/volumeSliceShader.js +115 -0
- package/es/index.js +21 -0
- package/es/loaders/IVolumeLoader.js +131 -0
- package/es/loaders/JsonImageInfoLoader.js +255 -0
- package/es/loaders/OmeZarrLoader.js +495 -0
- package/es/loaders/OpenCellLoader.js +65 -0
- package/es/loaders/RawArrayLoader.js +89 -0
- package/es/loaders/TiffLoader.js +219 -0
- package/es/loaders/VolumeLoadError.js +44 -0
- package/es/loaders/VolumeLoaderUtils.js +221 -0
- package/es/loaders/index.js +40 -0
- package/es/loaders/zarr_utils/ChunkPrefetchIterator.js +143 -0
- package/es/loaders/zarr_utils/WrappedStore.js +51 -0
- package/es/loaders/zarr_utils/types.js +24 -0
- package/es/loaders/zarr_utils/utils.js +225 -0
- package/es/loaders/zarr_utils/validation.js +49 -0
- package/es/test/ChunkPrefetchIterator.test.js +208 -0
- package/es/test/RequestQueue.test.js +442 -0
- package/es/test/SubscribableRequestQueue.test.js +244 -0
- package/es/test/VolumeCache.test.js +118 -0
- package/es/test/VolumeRenderSettings.test.js +71 -0
- package/es/test/lut.test.js +671 -0
- package/es/test/num_utils.test.js +140 -0
- package/es/test/volume.test.js +98 -0
- package/es/test/zarr_utils.test.js +358 -0
- package/es/types/Atlas2DSlice.d.ts +41 -0
- package/es/types/Channel.d.ts +44 -0
- package/es/types/FileSaver.d.ts +6 -0
- package/es/types/FusedChannelData.d.ts +26 -0
- package/es/types/Histogram.d.ts +57 -0
- package/es/types/ImageInfo.d.ts +87 -0
- package/es/types/Light.d.ts +27 -0
- package/es/types/Lut.d.ts +67 -0
- package/es/types/MarchingCubes.d.ts +53 -0
- package/es/types/MeshVolume.d.ts +40 -0
- package/es/types/NaiveSurfaceNets.d.ts +11 -0
- package/es/types/PathTracedVolume.d.ts +65 -0
- package/es/types/RayMarchedAtlasVolume.d.ts +41 -0
- package/es/types/RenderToBuffer.d.ts +17 -0
- package/es/types/ThreeJsPanel.d.ts +107 -0
- package/es/types/Timing.d.ts +11 -0
- package/es/types/TrackballControls.d.ts +51 -0
- package/es/types/View3d.d.ts +357 -0
- package/es/types/Volume.d.ts +152 -0
- package/es/types/VolumeCache.d.ts +43 -0
- package/es/types/VolumeDims.d.ts +28 -0
- package/es/types/VolumeDrawable.d.ts +108 -0
- package/es/types/VolumeMaker.d.ts +49 -0
- package/es/types/VolumeRenderImpl.d.ts +22 -0
- package/es/types/VolumeRenderSettings.d.ts +98 -0
- package/es/types/constants/basicShaders.d.ts +4 -0
- package/es/types/constants/colors.d.ts +2 -0
- package/es/types/constants/denoiseShader.d.ts +40 -0
- package/es/types/constants/lights.d.ts +38 -0
- package/es/types/constants/materials.d.ts +20 -0
- package/es/types/constants/pathtraceOutputShader.d.ts +11 -0
- package/es/types/constants/scaleBarSVG.d.ts +2 -0
- package/es/types/constants/time.d.ts +19 -0
- package/es/types/constants/volumePTshader.d.ts +137 -0
- package/es/types/constants/volumeRayMarchShader.d.ts +117 -0
- package/es/types/constants/volumeSliceShader.d.ts +109 -0
- package/es/types/glsl.d.js +0 -0
- package/es/types/index.d.ts +28 -0
- package/es/types/loaders/IVolumeLoader.d.ts +113 -0
- package/es/types/loaders/JsonImageInfoLoader.d.ts +80 -0
- package/es/types/loaders/OmeZarrLoader.d.ts +87 -0
- package/es/types/loaders/OpenCellLoader.d.ts +9 -0
- package/es/types/loaders/RawArrayLoader.d.ts +33 -0
- package/es/types/loaders/TiffLoader.d.ts +45 -0
- package/es/types/loaders/VolumeLoadError.d.ts +18 -0
- package/es/types/loaders/VolumeLoaderUtils.d.ts +38 -0
- package/es/types/loaders/index.d.ts +22 -0
- package/es/types/loaders/zarr_utils/ChunkPrefetchIterator.d.ts +22 -0
- package/es/types/loaders/zarr_utils/WrappedStore.d.ts +24 -0
- package/es/types/loaders/zarr_utils/types.d.ts +94 -0
- package/es/types/loaders/zarr_utils/utils.d.ts +23 -0
- package/es/types/loaders/zarr_utils/validation.d.ts +7 -0
- package/es/types/test/ChunkPrefetchIterator.test.d.ts +1 -0
- package/es/types/test/RequestQueue.test.d.ts +1 -0
- package/es/types/test/SubscribableRequestQueue.test.d.ts +1 -0
- package/es/types/test/VolumeCache.test.d.ts +1 -0
- package/es/types/test/VolumeRenderSettings.test.d.ts +1 -0
- package/es/types/test/lut.test.d.ts +1 -0
- package/es/types/test/num_utils.test.d.ts +1 -0
- package/es/types/test/volume.test.d.ts +1 -0
- package/es/types/test/zarr_utils.test.d.ts +1 -0
- package/es/types/types.d.ts +115 -0
- package/es/types/utils/RequestQueue.d.ts +112 -0
- package/es/types/utils/SubscribableRequestQueue.d.ts +52 -0
- package/es/types/utils/num_utils.d.ts +43 -0
- package/es/types/workers/VolumeLoaderContext.d.ts +106 -0
- package/es/types/workers/types.d.ts +101 -0
- package/es/types/workers/util.d.ts +3 -0
- package/es/types.js +75 -0
- package/es/typings.d.js +0 -0
- package/es/utils/RequestQueue.js +267 -0
- package/es/utils/SubscribableRequestQueue.js +187 -0
- package/es/utils/num_utils.js +231 -0
- package/es/workers/FetchTiffWorker.js +153 -0
- package/es/workers/VolumeLoadWorker.js +129 -0
- package/es/workers/VolumeLoaderContext.js +271 -0
- package/es/workers/types.js +41 -0
- package/es/workers/util.js +8 -0
- package/package.json +83 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { deserializeError } from "serialize-error";
|
|
2
|
+
import throttledQueue from "throttled-queue";
|
|
3
|
+
import { VolumeFileFormat, pathToFileType } from "../loaders/index.js";
|
|
4
|
+
import { ThreadableVolumeLoader } from "../loaders/IVolumeLoader.js";
|
|
5
|
+
import { RawArrayLoader } from "../loaders/RawArrayLoader.js";
|
|
6
|
+
import { TiffLoader } from "../loaders/TiffLoader.js";
|
|
7
|
+
import { WorkerMsgType, WorkerResponseResult, WorkerEventType } from "./types.js";
|
|
8
|
+
import { rebuildLoadSpec } from "./util.js";
|
|
9
|
+
const throttle = throttledQueue(1, 16);
|
|
10
|
+
/**
|
|
11
|
+
* A handle that holds the worker and manages requests and messages to/from it.
|
|
12
|
+
*
|
|
13
|
+
* `VolumeLoaderContext` and every `LoaderWorker` it creates all hold references to one `SharedLoadWorkerHandle`.
|
|
14
|
+
* They use it to interact with the worker via `sendMessage`, which speaks the protocol defined in ./types.ts and
|
|
15
|
+
* converts messages received from the worker into resolved `Promise`s and called callbacks.
|
|
16
|
+
*
|
|
17
|
+
* This class exists to represent that access to the worker is shared between `VolumeLoaderContext` and any
|
|
18
|
+
* `LoaderWorker`s. This is as opposed to implementing `sendMessage` directly on `VolumeLoaderContext`, where making
|
|
19
|
+
* the method public to `LoaderWorker`s would require also allowing access to users of the class.
|
|
20
|
+
*/
|
|
21
|
+
class SharedLoadWorkerHandle {
|
|
22
|
+
pendingRequests = [];
|
|
23
|
+
workerOpen = true;
|
|
24
|
+
throttleChannelData = false;
|
|
25
|
+
onChannelData = undefined;
|
|
26
|
+
onUpdateMetadata = undefined;
|
|
27
|
+
constructor() {
|
|
28
|
+
this.worker = new Worker(new URL("./VolumeLoadWorker", import.meta.url));
|
|
29
|
+
this.worker.onmessage = this.receiveMessage.bind(this);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Given a handle for settling a promise when a response is received from the worker, store it and return its ID */
|
|
33
|
+
registerMessagePromise(prom) {
|
|
34
|
+
for (const [i, pendingPromise] of this.pendingRequests.entries()) {
|
|
35
|
+
if (pendingPromise === undefined) {
|
|
36
|
+
this.pendingRequests[i] = prom;
|
|
37
|
+
return i;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return this.pendingRequests.push(prom) - 1;
|
|
41
|
+
}
|
|
42
|
+
get isOpen() {
|
|
43
|
+
return this.workerOpen;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Close the worker. */
|
|
47
|
+
close() {
|
|
48
|
+
this.worker.terminate();
|
|
49
|
+
this.workerOpen = false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Send a message of type `T` to the worker.
|
|
54
|
+
* Returns a `Promise` that resolves with the worker's response, or rejects with an error message.
|
|
55
|
+
*/
|
|
56
|
+
sendMessage(type, payload) {
|
|
57
|
+
let msgId = -1;
|
|
58
|
+
const promise = new Promise((resolve, reject) => {
|
|
59
|
+
msgId = this.registerMessagePromise({
|
|
60
|
+
type,
|
|
61
|
+
resolve,
|
|
62
|
+
reject
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
const msg = {
|
|
66
|
+
msgId,
|
|
67
|
+
type,
|
|
68
|
+
payload
|
|
69
|
+
};
|
|
70
|
+
this.worker.postMessage(msg);
|
|
71
|
+
return promise;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Receive a message from the worker. If it's an event, call a callback; otherwise, resolve/reject a promise. */
|
|
75
|
+
receiveMessage({
|
|
76
|
+
data
|
|
77
|
+
}) {
|
|
78
|
+
if (data.responseResult === WorkerResponseResult.EVENT) {
|
|
79
|
+
if (data.eventType === WorkerEventType.CHANNEL_LOAD) {
|
|
80
|
+
if (this.onChannelData) {
|
|
81
|
+
if (this.throttleChannelData) {
|
|
82
|
+
throttle(() => this.onChannelData ? this.onChannelData(data) : {});
|
|
83
|
+
} else {
|
|
84
|
+
this.onChannelData ? this.onChannelData(data) : {};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
} else if (data.eventType === WorkerEventType.METADATA_UPDATE) {
|
|
88
|
+
this.onUpdateMetadata?.(data);
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
const prom = this.pendingRequests[data.msgId];
|
|
92
|
+
if (prom === undefined) {
|
|
93
|
+
throw new Error(`Received response for unknown message ID ${data.msgId}`);
|
|
94
|
+
}
|
|
95
|
+
if (prom.type !== data.type) {
|
|
96
|
+
throw new Error(`Received response of type ${data.type} for message of type ${prom.type}`);
|
|
97
|
+
}
|
|
98
|
+
if (data.responseResult === WorkerResponseResult.ERROR) {
|
|
99
|
+
prom.reject(deserializeError(data.payload));
|
|
100
|
+
} else {
|
|
101
|
+
prom.resolve(data.payload);
|
|
102
|
+
}
|
|
103
|
+
this.pendingRequests[data.msgId] = undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
setThrottleChannelData(throttle) {
|
|
107
|
+
this.throttleChannelData = throttle;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A context in which volume loaders can be run, which allows loading to run on a WebWorker (where it won't block
|
|
113
|
+
* rendering or UI updates) and loaders to share a single `VolumeCache` and `RequestQueue`.
|
|
114
|
+
*
|
|
115
|
+
* ### To use:
|
|
116
|
+
* 1. Create a `VolumeLoaderContext` with the desired cache and queue configuration.
|
|
117
|
+
* 2. Before creating a loader, await `onOpen` to ensure the worker is ready.
|
|
118
|
+
* 3. Create a loader with `createLoader`. This accepts nearly the same arguments as `createVolumeLoader`, but without
|
|
119
|
+
* options to directly link to a cache or queue (the loader will always be linked to the context's shared instances
|
|
120
|
+
* of these if possible).
|
|
121
|
+
*
|
|
122
|
+
* The returned `WorkerLoader` can be used like any other `IVolumeLoader` and acts as a handle to the actual loader
|
|
123
|
+
* running on the worker.
|
|
124
|
+
*/
|
|
125
|
+
class VolumeLoaderContext {
|
|
126
|
+
activeLoader = undefined;
|
|
127
|
+
activeLoaderId = -1;
|
|
128
|
+
constructor(maxCacheSize, maxActiveRequests, maxLowPriorityRequests) {
|
|
129
|
+
this.workerHandle = new SharedLoadWorkerHandle();
|
|
130
|
+
this.openPromise = this.workerHandle.sendMessage(WorkerMsgType.INIT, {
|
|
131
|
+
maxCacheSize,
|
|
132
|
+
maxActiveRequests,
|
|
133
|
+
maxLowPriorityRequests
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Returns a `Promise` that resolves when the worker is ready. `await` it before trying to create a loader. */
|
|
138
|
+
onOpen() {
|
|
139
|
+
if (!this.workerHandle.isOpen) {
|
|
140
|
+
return Promise.reject("Worker is closed");
|
|
141
|
+
}
|
|
142
|
+
return this.openPromise;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Close this context, its worker, and any active loaders. */
|
|
146
|
+
close() {
|
|
147
|
+
this.workerHandle.close();
|
|
148
|
+
this.activeLoader?.close();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Create a new loader within this context. This loader will share the context's `VolumeCache` and `RequestQueue`.
|
|
153
|
+
*
|
|
154
|
+
* This works just like `createVolumeLoader`. A file format may be provided, or it may be inferred from the URL.
|
|
155
|
+
*/
|
|
156
|
+
async createLoader(path, options) {
|
|
157
|
+
// Special case: TIFF loader doesn't work on a worker, has its own workers anyways, and doesn't use cache or queue.
|
|
158
|
+
const pathString = Array.isArray(path) ? path[0] : path;
|
|
159
|
+
const fileType = options?.fileType || pathToFileType(pathString);
|
|
160
|
+
if (fileType === VolumeFileFormat.TIFF) {
|
|
161
|
+
return new TiffLoader(pathString);
|
|
162
|
+
} else if (fileType === VolumeFileFormat.DATA) {
|
|
163
|
+
if (!options?.rawArrayOptions) {
|
|
164
|
+
throw new Error("Failed to create loader: Must provide RawArrayOptions for RawArrayLoader");
|
|
165
|
+
}
|
|
166
|
+
return new RawArrayLoader(options.rawArrayOptions.data, options.rawArrayOptions.metadata);
|
|
167
|
+
}
|
|
168
|
+
const success = await this.workerHandle.sendMessage(WorkerMsgType.CREATE_LOADER, {
|
|
169
|
+
path,
|
|
170
|
+
options
|
|
171
|
+
});
|
|
172
|
+
if (!success) {
|
|
173
|
+
throw new Error("Failed to create loader");
|
|
174
|
+
}
|
|
175
|
+
this.activeLoader?.close();
|
|
176
|
+
this.activeLoaderId += 1;
|
|
177
|
+
this.activeLoader = new WorkerLoader(this.activeLoaderId, this.workerHandle);
|
|
178
|
+
return this.activeLoader;
|
|
179
|
+
}
|
|
180
|
+
setThrottleChannelData(throttle) {
|
|
181
|
+
this.workerHandle.setThrottleChannelData(throttle);
|
|
182
|
+
}
|
|
183
|
+
getActiveLoader() {
|
|
184
|
+
return this.activeLoader;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* A handle to an instance of `IVolumeLoader` (technically, a `ThreadableVolumeLoader`) running on a WebWorker.
|
|
190
|
+
*
|
|
191
|
+
* Created with `VolumeLoaderContext.createLoader`. See its documentation for more.
|
|
192
|
+
*/
|
|
193
|
+
class WorkerLoader extends ThreadableVolumeLoader {
|
|
194
|
+
isOpen = true;
|
|
195
|
+
currentLoadId = -1;
|
|
196
|
+
currentLoadCallback = undefined;
|
|
197
|
+
currentMetadataUpdateCallback = undefined;
|
|
198
|
+
constructor(loaderId, workerHandle) {
|
|
199
|
+
super();
|
|
200
|
+
this.loaderId = loaderId;
|
|
201
|
+
this.workerHandle = workerHandle;
|
|
202
|
+
workerHandle.onChannelData = this.onChannelData.bind(this);
|
|
203
|
+
workerHandle.onUpdateMetadata = this.onUpdateMetadata.bind(this);
|
|
204
|
+
}
|
|
205
|
+
checkIsOpen() {
|
|
206
|
+
if (!this.isOpen || !this.workerHandle.isOpen) {
|
|
207
|
+
throw new Error("Tried to use a closed loader");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Close and permanently invalidate this loader. */
|
|
212
|
+
close() {
|
|
213
|
+
this.isOpen = false;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Change which directions to prioritize when prefetching. All chunks will be prefetched in these directions before
|
|
218
|
+
* any chunks are prefetched in any other directions. Has no effect if this loader doesn't support prefetching.
|
|
219
|
+
*/
|
|
220
|
+
setPrefetchPriority(directions) {
|
|
221
|
+
return this.workerHandle.sendMessage(WorkerMsgType.SET_PREFETCH_PRIORITY_DIRECTIONS, directions);
|
|
222
|
+
}
|
|
223
|
+
updateFetchOptions(fetchOptions) {
|
|
224
|
+
return this.workerHandle.sendMessage(WorkerMsgType.UPDATE_FETCH_OPTIONS, fetchOptions);
|
|
225
|
+
}
|
|
226
|
+
syncMultichannelLoading(sync) {
|
|
227
|
+
return this.workerHandle.sendMessage(WorkerMsgType.SYNCHRONIZE_MULTICHANNEL_LOADING, sync);
|
|
228
|
+
}
|
|
229
|
+
loadDims(loadSpec) {
|
|
230
|
+
this.checkIsOpen();
|
|
231
|
+
return this.workerHandle.sendMessage(WorkerMsgType.LOAD_DIMS, loadSpec);
|
|
232
|
+
}
|
|
233
|
+
async createImageInfo(loadSpec) {
|
|
234
|
+
this.checkIsOpen();
|
|
235
|
+
const {
|
|
236
|
+
imageInfo,
|
|
237
|
+
loadSpec: adjustedLoadSpec
|
|
238
|
+
} = await this.workerHandle.sendMessage(WorkerMsgType.CREATE_VOLUME, loadSpec);
|
|
239
|
+
return {
|
|
240
|
+
imageInfo,
|
|
241
|
+
loadSpec: rebuildLoadSpec(adjustedLoadSpec)
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
loadRawChannelData(imageInfo, loadSpec, onUpdateMetadata, onData) {
|
|
245
|
+
this.checkIsOpen();
|
|
246
|
+
this.currentLoadCallback = onData;
|
|
247
|
+
this.currentMetadataUpdateCallback = onUpdateMetadata;
|
|
248
|
+
this.currentLoadId += 1;
|
|
249
|
+
return this.workerHandle.sendMessage(WorkerMsgType.LOAD_VOLUME_DATA, {
|
|
250
|
+
imageInfo,
|
|
251
|
+
loadSpec,
|
|
252
|
+
loaderId: this.loaderId,
|
|
253
|
+
loadId: this.currentLoadId
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
onChannelData(e) {
|
|
257
|
+
if (e.loaderId !== this.loaderId || e.loadId !== this.currentLoadId) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
this.currentLoadCallback?.(e.channelIndex, e.dtype, e.data, e.ranges, e.atlasDims);
|
|
261
|
+
}
|
|
262
|
+
onUpdateMetadata(e) {
|
|
263
|
+
if (e.loaderId !== this.loaderId || e.loadId !== this.currentLoadId) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const imageInfo = e.imageInfo;
|
|
267
|
+
const loadSpec = e.loadSpec && rebuildLoadSpec(e.loadSpec);
|
|
268
|
+
this.currentMetadataUpdateCallback?.(imageInfo, loadSpec);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
export default VolumeLoaderContext;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** The types of requests that can be made to the worker. Mostly corresponds to methods on `IVolumeLoader`. */
|
|
2
|
+
export let WorkerMsgType = /*#__PURE__*/function (WorkerMsgType) {
|
|
3
|
+
WorkerMsgType[WorkerMsgType["INIT"] = 0] = "INIT";
|
|
4
|
+
WorkerMsgType[WorkerMsgType["CREATE_LOADER"] = 1] = "CREATE_LOADER";
|
|
5
|
+
WorkerMsgType[WorkerMsgType["CREATE_VOLUME"] = 2] = "CREATE_VOLUME";
|
|
6
|
+
WorkerMsgType[WorkerMsgType["LOAD_DIMS"] = 3] = "LOAD_DIMS";
|
|
7
|
+
WorkerMsgType[WorkerMsgType["LOAD_VOLUME_DATA"] = 4] = "LOAD_VOLUME_DATA";
|
|
8
|
+
WorkerMsgType[WorkerMsgType["SET_PREFETCH_PRIORITY_DIRECTIONS"] = 5] = "SET_PREFETCH_PRIORITY_DIRECTIONS";
|
|
9
|
+
WorkerMsgType[WorkerMsgType["SYNCHRONIZE_MULTICHANNEL_LOADING"] = 6] = "SYNCHRONIZE_MULTICHANNEL_LOADING";
|
|
10
|
+
WorkerMsgType[WorkerMsgType["UPDATE_FETCH_OPTIONS"] = 7] = "UPDATE_FETCH_OPTIONS";
|
|
11
|
+
return WorkerMsgType;
|
|
12
|
+
}({});
|
|
13
|
+
|
|
14
|
+
/** The kind of response a worker can return - `SUCCESS`, `ERROR`, or `EVENT`. */
|
|
15
|
+
export let WorkerResponseResult = /*#__PURE__*/function (WorkerResponseResult) {
|
|
16
|
+
WorkerResponseResult[WorkerResponseResult["SUCCESS"] = 0] = "SUCCESS";
|
|
17
|
+
WorkerResponseResult[WorkerResponseResult["ERROR"] = 1] = "ERROR";
|
|
18
|
+
WorkerResponseResult[WorkerResponseResult["EVENT"] = 2] = "EVENT";
|
|
19
|
+
return WorkerResponseResult;
|
|
20
|
+
}({});
|
|
21
|
+
|
|
22
|
+
/** The kind of events that can occur when loading */
|
|
23
|
+
export let WorkerEventType = /*#__PURE__*/function (WorkerEventType) {
|
|
24
|
+
WorkerEventType[WorkerEventType["METADATA_UPDATE"] = 0] = "METADATA_UPDATE";
|
|
25
|
+
WorkerEventType[WorkerEventType["CHANNEL_LOAD"] = 1] = "CHANNEL_LOAD";
|
|
26
|
+
return WorkerEventType;
|
|
27
|
+
}({});
|
|
28
|
+
|
|
29
|
+
/** All messages to/from a worker carry a `msgId`, a `type`, and a `payload` (whose type is determined by `type`). */
|
|
30
|
+
|
|
31
|
+
/** Maps each `WorkerMsgType` to the type of the payload of requests of that type. */
|
|
32
|
+
|
|
33
|
+
/** Maps each `WorkerMsgType` to the type of the payload of responses of that type. */
|
|
34
|
+
|
|
35
|
+
/** Event for when a batch of channel data loads. */
|
|
36
|
+
|
|
37
|
+
/** Event for when metadata updates. */
|
|
38
|
+
|
|
39
|
+
/** All valid types of worker requests, with some `WorkerMsgType` and a matching payload type. */
|
|
40
|
+
|
|
41
|
+
/** All valid types of worker responses: `SUCCESS` with a matching payload, `ERROR` with a message, or an `EVENT`. */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Box3, Vector3 } from "three";
|
|
2
|
+
/** Recreates a `LoadSpec` that has just been sent to/from a worker to restore three.js object prototypes */
|
|
3
|
+
export function rebuildLoadSpec(spec) {
|
|
4
|
+
return {
|
|
5
|
+
...spec,
|
|
6
|
+
subregion: new Box3(new Vector3().copy(spec.subregion.min), new Vector3().copy(spec.subregion.max))
|
|
7
|
+
};
|
|
8
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aics/vole-core",
|
|
3
|
+
"version": "3.12.4",
|
|
4
|
+
"description": "volume renderer for 3d, 4d, or 5d imaging data with OME-Zarr support",
|
|
5
|
+
"main": "es/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"module": "es/index.js",
|
|
8
|
+
"types": "es/types/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"es",
|
|
11
|
+
"README.md",
|
|
12
|
+
"package.json"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"prepare": "npm run build",
|
|
16
|
+
"build-docs": "node node_modules/documentation/bin/documentation.js build src/Histogram.ts src/View3d.ts src/Volume.ts src/VolumeMaker.ts src/VolumeLoader.ts -f html -o docs --shallow",
|
|
17
|
+
"build": "npm run transpileES && npm run build-types",
|
|
18
|
+
"build-types": "tsc -p tsconfig.types.json",
|
|
19
|
+
"build-demo": "webpack --config webpack.demo.js",
|
|
20
|
+
"clean": "rimraf es/",
|
|
21
|
+
"format": "prettier --write src/**/*.js",
|
|
22
|
+
"gh-build": "webpack --config webpack.dev.js",
|
|
23
|
+
"dev": "webpack serve --config webpack.dev.js",
|
|
24
|
+
"start": "webpack serve --config webpack.dev.js",
|
|
25
|
+
"lint": "eslint --config ./.eslintrc.json --ignore-path ./.eslintignore --ext .js --ext .ts ./src",
|
|
26
|
+
"test": "cross-env NODE_OPTIONS=\"--loader ts-node/esm\" mocha --require ts-node/register --es-module-specifier-resolution=node src/**/test/*.[jt]s",
|
|
27
|
+
"transpileES": "babel src --out-dir es --extensions .js,.ts --ignore **/*.test.js",
|
|
28
|
+
"typeCheck": "tsc -p tsconfig.json --noEmit"
|
|
29
|
+
},
|
|
30
|
+
"author": "Daniel Toloudis",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@babel/runtime": "^7.25.6",
|
|
37
|
+
"geotiff": "^2.0.5",
|
|
38
|
+
"serialize-error": "^11.0.3",
|
|
39
|
+
"three": "^0.171.0",
|
|
40
|
+
"throttled-queue": "^2.1.4",
|
|
41
|
+
"tweakpane": "^3.1.9",
|
|
42
|
+
"zarrita": "^0.3.2"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@babel/cli": "^7.25.6",
|
|
46
|
+
"@babel/core": "^7.25.2",
|
|
47
|
+
"@babel/plugin-transform-runtime": "^7.25.4",
|
|
48
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
49
|
+
"@babel/register": "^7.24.6",
|
|
50
|
+
"@tweakpane/core": "^1.1.9",
|
|
51
|
+
"@types/chai": "^4.3.12",
|
|
52
|
+
"@types/mocha": "^9.1.1",
|
|
53
|
+
"@types/three": "^0.144.0",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
|
55
|
+
"@typescript-eslint/parser": "^5.30.5",
|
|
56
|
+
"acorn": "^8.7.0",
|
|
57
|
+
"babel-loader": "^8.2.2",
|
|
58
|
+
"babel-plugin-inline-import": "^3.0.0",
|
|
59
|
+
"babel-plugin-inline-import-data-uri": "^1.0.1",
|
|
60
|
+
"chai": "^5.1.0",
|
|
61
|
+
"clean-webpack-plugin": "^4.0.0-alpha.0",
|
|
62
|
+
"copy-webpack-plugin": "^9.0.1",
|
|
63
|
+
"cross-env": "^7.0.3",
|
|
64
|
+
"documentation": "^14.0.0",
|
|
65
|
+
"eslint": "^8.19.0",
|
|
66
|
+
"eslint-config-prettier": "^8.5.0",
|
|
67
|
+
"file-loader": "^6.2.0",
|
|
68
|
+
"html-webpack-plugin": "^5.3.2",
|
|
69
|
+
"husky": "^7.0.1",
|
|
70
|
+
"lil-gui": "^0.19.2",
|
|
71
|
+
"lint-staged": "^13.2.1",
|
|
72
|
+
"mocha": "^10.3.0",
|
|
73
|
+
"prettier": "^2.3.2",
|
|
74
|
+
"raw-loader": "^4.0.2",
|
|
75
|
+
"rimraf": "^3.0.2",
|
|
76
|
+
"ts-node": "^10.9.2",
|
|
77
|
+
"typescript": "^4.3.5",
|
|
78
|
+
"url-loader": "^4.1.1",
|
|
79
|
+
"webpack": "^5.69.1",
|
|
80
|
+
"webpack-cli": "^4.9.2",
|
|
81
|
+
"webpack-dev-server": "^4.7.4"
|
|
82
|
+
}
|
|
83
|
+
}
|