Skip to content

Commit

Permalink
set resolution and a few other settings properly
Browse files Browse the repository at this point in the history
  • Loading branch information
frasercl committed Oct 10, 2024
1 parent 5528961 commit 3923a42
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
25 changes: 18 additions & 7 deletions src/visGeometry/VolumeModel.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Euler, Object3D, Vector3 } from "three";

import {
HasThreeJsContext,

Check failure on line 4 in src/visGeometry/VolumeModel.ts

View workflow job for this annotation

GitHub Actions / Type Check

Module '"@aics/volume-viewer"' has no exported member 'HasThreeJsContext'.
Lut,
Volume,
VolumeDrawable,
HasThreeJsContext,
} from "@aics/volume-viewer";

import { AgentData } from "../simularium/types";
Expand Down Expand Up @@ -40,6 +40,10 @@ export default class VolumeModel {
this.volume = volumeObject;
this.drawable = new VolumeDrawable(this.volume, {});
this.volume.addVolumeDataObserver(this);
this.drawable.setBrightness(0.7);
this.drawable.setGamma(0.15, 0.9, 1.0);
this.drawable.setDensity(0.7);
this.drawable.setMaxProjectMode(true);
}

public setAgentData(data: AgentData): void {
Expand Down Expand Up @@ -79,7 +83,6 @@ export default class VolumeModel {

public onChannelLoaded(vol: Volume, channelIndex: number): void {
if (this.drawable) {
console.log("load", channelIndex);
const isEnabled = this.channelsEnabled[channelIndex];
this.drawable.setVolumeChannelEnabled(channelIndex, isEnabled);
this.drawable.updateScale();
Expand All @@ -93,14 +96,22 @@ export default class VolumeModel {
}
this.drawable.updateLuts();
this.drawable.fuse();
if (this.drawable && channelIndex === 0) {
console.log(this.drawable);
}
}
}

public onBeforeRender(context: HasThreeJsContext): void {
this.drawable?.onAnimate(context);
public onBeforeRender(
context: HasThreeJsContext,
width: number,
height: number
): void {
if (this.drawable) {
this.drawable.setResolution(width, height);

Check failure on line 108 in src/visGeometry/VolumeModel.ts

View workflow job for this annotation

GitHub Actions / Type Check

Expected 1 arguments, but got 2.
this.drawable.onAnimate(context);
}
}

public setSize(width: number, height: number): void {
this.drawable?.setResolution(width, height);

Check failure on line 114 in src/visGeometry/VolumeModel.ts

View workflow job for this annotation

GitHub Actions / Type Check

Expected 1 arguments, but got 2.
}

// METHODS FROM `VolumeDataObserver` in volume-viewer
Expand Down
9 changes: 8 additions & 1 deletion src/visGeometry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,9 @@ class VisGeometry {
orthoScale: this.controls.zoomO,
};

const canvasWidth = this.threejsrenderer.domElement.width;
const canvasHeight = this.threejsrenderer.domElement.height;

// re-add fibers immediately
this.instancedMeshGroup.add(this.fibers.getGroup());

Expand Down Expand Up @@ -1037,7 +1040,11 @@ class VisGeometry {
} else if (displayType === GeometryDisplayType.VOLUME) {
const volObj = entry.geometry.getObject3D();
if (volObj) {
entry.geometry.onBeforeRender(volRenderContext);
entry.geometry.onBeforeRender(
volRenderContext,
canvasWidth,
canvasHeight
);
this.tempVolumeGroup.add(volObj);
}
} else {
Expand Down

0 comments on commit 3923a42

Please sign in to comment.