Skip to content

Commit

Permalink
use loader worker
Browse files Browse the repository at this point in the history
  • Loading branch information
frasercl committed Jan 23, 2024
1 parent 25d5c07 commit 93e7781
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/aics-image-viewer/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@
import React, { useCallback, useEffect, useRef, useState } from "react";
import { Layout } from "antd";
import { debounce } from "lodash";
import {
createVolumeLoader,
LoadSpec,
RENDERMODE_PATHTRACE,
RENDERMODE_RAYMARCH,
View3d,
Volume,
VolumeCache,
} from "@aics/volume-viewer";
import { LoadSpec, LoadWorker, RENDERMODE_PATHTRACE, RENDERMODE_RAYMARCH, View3d, Volume } from "@aics/volume-viewer";

import {
AppProps,
Expand Down Expand Up @@ -161,9 +153,8 @@ const App: React.FC<AppProps> = (props) => {

// State management /////////////////////////////////////////////////////////

// TODO is there a better API for values that never change?
const view3d = useConstructor(() => new View3d());
const volumeCache = useConstructor(() => new VolumeCache(250_000_000 * 4));
const loadWorker = useConstructor(() => new LoadWorker(250_000_000 * 4, 8, 3));
const [image, setImage] = useState<Volume | null>(null);
const imageUrlRef = useRef<string>("");

Expand Down Expand Up @@ -429,7 +420,8 @@ const App: React.FC<AppProps> = (props) => {

// if this does NOT end with tif or json,
// then we assume it's zarr.
const loader = await createVolumeLoader(fullUrl, { cache: volumeCache });
await loadWorker.onOpen();
const loader = await loadWorker.createLoader(fullUrl);

const aimg = await loader.createVolume(loadSpec, (v, channelIndex) => {
// NOTE: this callback runs *after* `onNewVolumeCreated` below, for every loaded channel
Expand Down

0 comments on commit 93e7781

Please sign in to comment.