Skip to content

Commit

Permalink
added calculation of fragmentKey to do the correct chunk lookup when …
Browse files Browse the repository at this point in the history
…fragmentId != fragmentKey

fixed lint errors
  • Loading branch information
chrisj authored and fcollman committed Feb 25, 2024
1 parent c067351 commit 55c20de
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/mesh/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ export class MeshLayer extends PerspectiveViewRenderLayer<ThreeDimensionalRender
): Float32Array | undefined {
const transform = this.displayState.transform.value;
if (transform.error !== undefined) return undefined;
const chunk = this.source.chunks.get(getObjectKey(id));
const key = getObjectKey(id);
const chunk = this.source.chunks.get(key);
if (chunk === undefined) return undefined;
const { rank } = transform;
const inverseModelToRenderLayerTransform = new Float32Array(
Expand All @@ -611,10 +612,11 @@ export class MeshLayer extends PerspectiveViewRenderLayer<ThreeDimensionalRender
rank,
);
const { fragmentIds } = chunk;
let closestVertex = new Float32Array(rank);
const closestVertex = new Float32Array(rank);
let closestDistanceSq = Number.POSITIVE_INFINITY;
for (let fragmentId of fragmentIds) {
const fragmentChunk = this.source.fragmentSource.chunks.get(fragmentId);
for (const fragmentId of fragmentIds) {
const { key: fragmentKey } = this.source.getFragmentKey(key, fragmentId);
const fragmentChunk = this.source.fragmentSource.chunks.get(fragmentKey);
if (fragmentChunk === undefined) continue;
const { state, meshData } = fragmentChunk;
if (
Expand All @@ -628,10 +630,8 @@ export class MeshLayer extends PerspectiveViewRenderLayer<ThreeDimensionalRender
for (let i = 0; i < vertexPositions.length; i += rank) {
let distanceSq = 0;
for (let j = 0; j < rank; j++) {
distanceSq += Math.pow(
vertexPositions[i + j] - nearestPositionInModal[j],
2,
);
distanceSq +=
(vertexPositions[i + j] - nearestPositionInModal[j]) ** 2;
}
if (distanceSq < closestDistanceSq) {
closestDistanceSq = distanceSq;
Expand Down

0 comments on commit 55c20de

Please sign in to comment.