Skip to content

Commit 050bd30

Browse files
committed
Merge branch 'main' into feature/rename-package
2 parents 10d8744 + f1b507f commit 050bd30

20 files changed

+174
-73
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+36-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
1-
**Pull request recommendations:**
1+
# Problem
22

3-
- [ ] Name your pull request _your-development-type/short-description_. Ex: _feature/read-tiff-files_
4-
- [ ] Link to any relevant issue in the PR description. Ex: _Resolves [gh-##], adds tiff file format support_
5-
- [ ] Provide description and context of changes.
6-
- [ ] Provide relevant tests for your feature or bug fix.
7-
- [ ] Provide or update documentation for any feature added by your pull request.
3+
What is the problem this work solves, including
4+
[Link to story or ticket](https://my-tracking-system.url/ticket-number)
5+
6+
# Solution
7+
8+
What I/we did to solve this problem
9+
10+
with @pairperson1
11+
12+
## Type of change
13+
14+
Please delete options that are not relevant.
15+
16+
- Bug fix (non-breaking change which fixes an issue)
17+
- New feature (non-breaking change which adds functionality)
18+
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
19+
- This change requires a documentation update
20+
- This change requires updated or new tests
21+
22+
## Steps to Verify:
23+
24+
1. A setup step / beginning state
25+
1. What to do next
26+
1. Any other instructions
27+
1. Expected behavior
28+
1. Suggestions for testing
29+
30+
## Screenshots (optional):
31+
32+
Show-n-tell images/animations here
33+
34+
## Keyfiles (delete if not relevant):
35+
36+
1. main file/entry point
37+
2. other important file
838

939
Thanks for contributing!

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
name: Node.js CI
55
env:
6-
NODE_VERSION: "18"
6+
NODE_VERSION: "20"
77

88
on: [push]
99

.github/workflows/nightly.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: github pages
22

33
env:
4-
NODE_VERSION: "18"
4+
NODE_VERSION: "20"
55

66
on:
77
schedule:
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: Cache dependencies
2121

22-
uses: actions/cache@v1
22+
uses: actions/cache@v4
2323
with:
2424
path: ~/.npm
2525
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
name: NPM Package
55
env:
6-
NODE_VERSION: "18"
6+
NODE_VERSION: "20"
77
on:
88
push:
99
# Sequence of patterns matched against refs/tags

package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aics/vole-core",
3-
"version": "3.12.0",
3+
"version": "3.12.3",
44
"description": "volume renderer for 3d, 4d, or 5d imaging data with OME-Zarr support",
55
"main": "es/index.js",
66
"type": "module",
@@ -36,7 +36,7 @@
3636
"@babel/runtime": "^7.25.6",
3737
"geotiff": "^2.0.5",
3838
"serialize-error": "^11.0.3",
39-
"three": "^0.162.0",
39+
"three": "^0.171.0",
4040
"throttled-queue": "^2.1.4",
4141
"tweakpane": "^3.1.9",
4242
"zarrita": "^0.3.2"

src/Atlas2DSlice.ts

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export default class Atlas2DSlice implements VolumeRenderImpl {
9696
public updateVolumeDimensions(): void {
9797
const volumeScale = this.volume.normPhysicalSize.clone().multiply(this.settings.scale);
9898
const regionScale = volumeScale.clone().multiply(this.volume.normRegionSize);
99-
console.log(regionScale);
10099
const volumeOffset = this.volume.getContentCenter().clone().multiply(this.settings.scale);
101100
this.geometryMesh.position.copy(volumeOffset);
102101
// set scale

src/Histogram.ts

+20-5
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@ type HistogramData = {
1717
export default class Histogram {
1818
// no more than 2^32 pixels of any one intensity in the data!?!?!
1919
private bins: Uint32Array;
20+
/** Min value in the original raw data. */
2021
private min: number;
22+
/** Max value in the original raw data. */
2123
private max: number;
24+
/** Size of each histogram bin in the scale of the original data. */
2225
private binSize: number;
26+
/** Index of the first bin (other than 0) with at least 1 value. */
2327
private dataMinBin: number;
28+
/** Index of the last bin (other than 0) with at least 1 value. */
2429
private dataMaxBin: number;
2530
private pixelCount: number;
2631
public maxBin: number;
@@ -41,14 +46,15 @@ export default class Histogram {
4146
this.max = hinfo.max;
4247
this.binSize = hinfo.binSize;
4348

44-
// track the first and last nonzero bins with at least 1 sample
45-
for (let i = 1; i < this.bins.length; i++) {
49+
// TODO: These should always return 0 and NBINS - 1, respectively. Test if these
50+
// can be removed.
51+
for (let i = 0; i < this.bins.length; i++) {
4652
if (this.bins[i] > 0) {
4753
this.dataMinBin = i;
4854
break;
4955
}
5056
}
51-
for (let i = this.bins.length - 1; i >= 1; i--) {
57+
for (let i = this.bins.length - 1; i >= 0; i--) {
5258
if (this.bins[i] > 0) {
5359
this.dataMaxBin = i;
5460
break;
@@ -83,27 +89,36 @@ export default class Histogram {
8389
return Histogram.findBin(value, this.min, this.binSize, NBINS);
8490
}
8591

92+
/**
93+
* Return the min data value
94+
* @return {number}
95+
*/
8696
getDataMin(): number {
8797
return this.min;
8898
}
8999

100+
/**
101+
* Return the max data value
102+
* @return {number}
103+
*/
90104
getDataMax(): number {
91105
return this.max;
92106
}
93107

94108
/**
95-
* Return the min data value
109+
* Returns the first bin index with at least 1 value, other than the 0th bin.
96110
* @return {number}
97111
*/
98112
getMin(): number {
99113
return this.dataMinBin;
100114
}
101115

102116
/**
103-
* Return the max data value
117+
* Returns the last bin index with at least 1 value, other than the 0th bin.
104118
* @return {number}
105119
*/
106120
getMax(): number {
121+
// Note that this will always return `NBINS - 1`.
107122
return this.dataMaxBin;
108123
}
109124

src/RayMarchedAtlasVolume.ts

+9-19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
BufferAttribute,
66
BufferGeometry,
77
Color,
8+
DataTexture,
89
DepthTexture,
910
Group,
1011
LineBasicMaterial,
@@ -16,10 +17,10 @@ import {
1617
PerspectiveCamera,
1718
ShaderMaterial,
1819
ShapeGeometry,
20+
Texture,
1921
Vector2,
2022
Vector3,
2123
WebGLRenderer,
22-
WebGLRenderTarget,
2324
} from "three";
2425

2526
import FusedChannelData from "./FusedChannelData.js";
@@ -37,17 +38,6 @@ import { VolumeRenderSettings, SettingsFlags } from "./VolumeRenderSettings.js";
3738

3839
const BOUNDING_BOX_DEFAULT_COLOR = new Color(0xffff00);
3940

40-
function createEmptyDepthTexture(renderer: WebGLRenderer): DepthTexture {
41-
const depthTexture = new DepthTexture(2, 2);
42-
const target = new WebGLRenderTarget(2, 2);
43-
target.depthTexture = depthTexture;
44-
renderer.setRenderTarget(target);
45-
// Don't clear color, do clear depth, don't clear stencil
46-
renderer.clear(false, true, false);
47-
renderer.setRenderTarget(null);
48-
return depthTexture;
49-
}
50-
5141
export default class RayMarchedAtlasVolume implements VolumeRenderImpl {
5242
private settings: VolumeRenderSettings;
5343
public volume: Volume;
@@ -59,7 +49,7 @@ export default class RayMarchedAtlasVolume implements VolumeRenderImpl {
5949
private geometryTransformNode: Group;
6050
private uniforms: ReturnType<typeof rayMarchingShaderUniforms>;
6151
private channelData!: FusedChannelData;
62-
private emptyDepthTex?: DepthTexture;
52+
private emptyPositionTex: DataTexture;
6353

6454
/**
6555
* Creates a new RayMarchedAtlasVolume.
@@ -89,6 +79,8 @@ export default class RayMarchedAtlasVolume implements VolumeRenderImpl {
8979

9080
this.geometryTransformNode.add(this.boxHelper, this.tickMarksMesh, this.geometryMesh);
9181

82+
this.emptyPositionTex = new DataTexture(new Uint8Array(Array(16).fill(0)), 2, 2);
83+
9284
this.settings = settings;
9385
this.updateSettings(settings, SettingsFlags.ALL);
9486
// TODO this is doing *more* redundant work! Fix?
@@ -325,17 +317,15 @@ export default class RayMarchedAtlasVolume implements VolumeRenderImpl {
325317
public doRender(
326318
renderer: WebGLRenderer,
327319
camera: PerspectiveCamera | OrthographicCamera,
328-
depthTexture?: DepthTexture
320+
depthTexture?: DepthTexture | Texture
329321
): void {
330322
if (!this.geometryMesh.visible) {
331323
return;
332324
}
333325

334-
if (!this.emptyDepthTex) {
335-
this.emptyDepthTex = createEmptyDepthTexture(renderer);
336-
}
337-
338-
this.setUniform("textureDepth", depthTexture ?? this.emptyDepthTex);
326+
const depthTex = depthTexture ?? this.emptyPositionTex;
327+
this.setUniform("textureDepth", depthTex);
328+
this.setUniform("usingPositionTexture", (depthTex as DepthTexture).isDepthTexture ? 0 : 1);
339329
this.setUniform("CLIP_NEAR", camera.near);
340330
this.setUniform("CLIP_FAR", camera.far);
341331

src/View3d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ export class View3d {
226226
if (this.image) {
227227
this.removeVolume(this.image.volume);
228228
}
229+
this.image = undefined;
229230
}
230231

231232
/**

src/VolumeDrawable.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
OrthographicCamera,
99
PerspectiveCamera,
1010
WebGLRenderer,
11+
Texture,
1112
} from "three";
1213
import { Pane } from "tweakpane";
1314

@@ -117,22 +118,23 @@ export default class VolumeDrawable {
117118
}
118119

119120
/**
120-
* Updates whether a channel's data must be loaded for rendering, based on if its volume or isosurface is enabled.
121+
* Updates whether a channel's data must be loaded for rendering,
122+
* based on if its volume or isosurface is enabled, or whether it is needed for masking.
121123
* Calls `Volume.updateRequiredData` to update the list of required channels if necessary.
122124
*/
123125
private updateChannelDataRequired(channelIndex: number): void {
124126
const { enabled, isosurfaceEnabled } = this.channelOptions[channelIndex];
125-
const channelIsRequired = enabled || isosurfaceEnabled;
127+
const channelIsRequired = enabled || isosurfaceEnabled || channelIndex === this.settings.maskChannelIndex;
126128
const requiredChannels = this.volume.loadSpecRequired.channels;
127129

128130
if (requiredChannels.includes(channelIndex)) {
129131
if (!channelIsRequired) {
130-
// This channel is currently marked required, but both its volume and isosurface are off. Remove it!
132+
// This channel is currently marked required, but both its volume and isosurface are off, and it's not a mask. Remove it!
131133
this.volume.updateRequiredData({ channels: requiredChannels.filter((i) => i !== channelIndex) });
132134
}
133135
} else {
134136
if (channelIsRequired) {
135-
// This channel is not marked required, but either its volume or isosurface is on. Add it!
137+
// This channel is not marked required, but either its volume or isosurface is on, or it is a mask. Add it!
136138
this.volume.updateRequiredData({ channels: [...requiredChannels, channelIndex] });
137139
}
138140
}
@@ -386,7 +388,7 @@ export default class VolumeDrawable {
386388
onAnimate(
387389
renderer: WebGLRenderer,
388390
camera: PerspectiveCamera | OrthographicCamera,
389-
depthTexture?: DepthTexture
391+
depthTexture?: DepthTexture | Texture
390392
): void {
391393
// TODO: this is inefficient, as this work is duplicated by threejs.
392394
// we need camera matrix up to date before giving the 3d objects a chance to use it.
@@ -596,6 +598,7 @@ export default class VolumeDrawable {
596598
return;
597599
}
598600
this.settings.maskChannelIndex = channelIndex;
601+
this.updateChannelDataRequired(channelIndex);
599602
this.volumeRendering.updateSettings(this.settings, SettingsFlags.MASK_DATA);
600603
}
601604

src/VolumeRenderImpl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DepthTexture, Object3D, OrthographicCamera, PerspectiveCamera, WebGLRenderer } from "three";
1+
import { DepthTexture, Object3D, OrthographicCamera, PerspectiveCamera, Texture, WebGLRenderer } from "three";
22

33
import { SettingsFlags, VolumeRenderSettings } from "./VolumeRenderSettings.js";
44
import type { FuseChannel } from "./types.js";
@@ -19,7 +19,7 @@ export interface VolumeRenderImpl {
1919
doRender: (
2020
renderer: WebGLRenderer,
2121
camera: PerspectiveCamera | OrthographicCamera,
22-
depthTexture?: DepthTexture
22+
depthTexture?: DepthTexture | Texture
2323
) => void;
2424
updateVolumeDimensions: () => void;
2525
cleanup: () => void;

0 commit comments

Comments
 (0)