Skip to content

Commit

Permalink
Fix allignment issue with asset overlays for power of 2 image downsam…
Browse files Browse the repository at this point in the history
…ples
  • Loading branch information
XanthosXanthopoulos committed Sep 25, 2024
1 parent 2f8c38c commit 652ed2e
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 18 deletions.
4 changes: 3 additions & 1 deletion packages/common/src/types/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ export type AssetConfig = {
features?: Feature[];
};

export type ImageConfig = AssetConfig;
export type ImageConfig = AssetConfig & {
isRegularPyramidalImage?: boolean;
};

export type GeometryConfig = AssetConfig & {
/**
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/tile/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ export const HIGHLIGHTED_STATE = 1;
export const SELECTED_STATE = 2;
export const COLOR_GROUPS = 32;
export const MAX_CATEGORIES = 192;

export const WIDTH_ALIASES = ['X', 'WIDTH', '_X'];
export const HEIGHT_ALIASES = ['Y', 'HEIGHT', '_Y'];
export const CHANNEL_ALIASES = ['C', 'BANDS'];
6 changes: 2 additions & 4 deletions packages/core/src/tile/model/image/imageContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,8 @@ export class ImageContent extends TileContent {
return;
}

if (this.texture) {
// The tile is already visible so we need to clear textures to update
this.texture.dispose();
}
this.texture?.dispose();
this.material?.dispose(true, true);

this.material = this.scene.getEngine().isWebGPU
? ImageShaderMaterialWebGPU(
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/tile/model/point/pointContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class PointTileContent

this.meshes[0]._thinInstanceDataStorage.instancesCount = this.pointCount;
this.meshes[0].layerMask = this.tile.mask;
this.meshes[0].renderingGroupId = 3;
this.meshes[0].setVerticesBuffer(
new VertexBuffer(this.scene.getEngine(), data.position, 'loc', {
size: 3,
Expand Down Expand Up @@ -114,6 +115,7 @@ export class PointTileContent
this.meshes[0].setBoundingInfo(this.tile.boundingInfo);
this.meshes[0].material = this.material;
this.meshes[0].layerMask = this.tile.mask;
this.meshes[0].renderingGroupId = 3;
}

const vertexData = new VertexData();
Expand Down
17 changes: 10 additions & 7 deletions packages/core/src/tile/tileImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,16 @@ export class TileDBTileImageVisualization extends TileDBVisualization {
}

this.updateLoadingScreen('Loading image asset metadata', true);
this.imageMetadata = await getImageMetadata({
token: this.options.token,
tiledbEnv: this.options.tiledbEnv,
namespace: imageNamespace,
arrayID: imageArrayID,
groupID: imageGroupID
});
this.imageMetadata = await getImageMetadata(
{
token: this.options.token,
tiledbEnv: this.options.tiledbEnv,
namespace: imageNamespace,
arrayID: imageArrayID,
groupID: imageGroupID
},
this.options.sceneConfig?.imageConfigs?.[0]
);

if (this.options.defaultChannels) {
const defaultAttribute = this.imageMetadata.attributes.filter(
Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/tile/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ export interface LevelRecord {
axesMapping: Map<string, Array<string>>;
}

export interface SOMAMultiscaleImageAssetMetadataRaw extends AssetMetadata {
soma_coordinate_space: string;
soma_encoding_version: number;
soma_multiscale_image_schema: string;
}

export interface SOMAMultiscaleImageAssetMetadata {
soma_coordinate_space: { name: string; units: string; scale?: number }[];
soma_encoding_version: number;
soma_multiscale_image_schema: {
name: string;
image_type: string;
shape: number[];
datatype: string;
axis_names: string[];
};
}

export interface BiomedicalAssetMetadata extends AssetMetadata {
fmt_version: number;
metadata?: string;
Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/tile/utils/picking-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ export class PickingTool {
for (const tile of manager.visibleTiles.values()) {
if (pickingRay.intersectsBox(tile.boundingInfo.boundingBox)) {
tiles.push(tile);

console.log(tile.id);

const result = tile.data?.intersector?.intersectRay(pickingRay);

if (!result) {
Expand Down
14 changes: 11 additions & 3 deletions packages/core/src/tile/worker/loaders/imageLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ export async function imageRequest(
return 'C';
}
});
if (metadata.implicitChannel) {
if (metadata.implicitChannel && !metadata.isWebPCompressed) {
sourceAxes.unshift('C');
}

const axes = new Axes(sourceAxes, ['C', 'Y', 'X']);
const width = payload.region[0].max - payload.region[0].min;
const height = payload.region[1].max - payload.region[1].min;
Expand Down Expand Up @@ -202,17 +203,24 @@ export async function imageRequest(
} catch (e) {
console.log(e);
throw new Error('Request cancelled by the user');
return;
}

const shape: number[] = [];

for (const axis of sourceAxes) {
switch (axis) {
case 'X':
shape.push(
calculatedRanges.get(payload.region[0].dimension)![1] -

Check warning on line 214 in packages/core/src/tile/worker/loaders/imageLoader.ts

View workflow job for this annotation

GitHub Actions / Test and lint

Forbidden non-null assertion

Check warning on line 214 in packages/core/src/tile/worker/loaders/imageLoader.ts

View workflow job for this annotation

GitHub Actions / Test and lint

Forbidden non-null assertion
calculatedRanges.get(payload.region[0].dimension)![0] +
1
);
break;
case 'Y':
shape.push(
calculatedRanges.get(axis)![1] - calculatedRanges.get(axis)![0] + 1
calculatedRanges.get(payload.region[1].dimension)![1] -
calculatedRanges.get(payload.region[1].dimension)![0] +
1
);
break;
case 'C':
Expand Down

0 comments on commit 652ed2e

Please sign in to comment.