Skip to content

Commit

Permalink
fix: remove unnecessary optional
Browse files Browse the repository at this point in the history
  • Loading branch information
HoloTheDrunk committed Jan 23, 2025
1 parent a9b5ac8 commit 853fc75
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions src/Core/Prefab/TileBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,19 @@ export function newTileGeometry(

let buffers;
try {
buffers = computeBuffers(builder, params,
cachedBuffers !== undefined ? {
index: cachedBuffers.index.array as Uint32Array,
uv: cachedBuffers.uv.array as Float32Array,
} : undefined);
buffers = computeBuffers(
builder,
params,
// @ts-expect-error: can't sync index type right now
cachedBuffers !== undefined
? {
// We lost type information along the way with the
// storage as THREE.BufferAttribute.
index: cachedBuffers.index.array,
uv: cachedBuffers.uv.array as Float32Array,
}
: undefined,
);
} catch (e) {
return Promise.reject(e);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Prefab/computeBufferTileGeometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function allocateIndexBuffer(
nSeg: number,
params: TileBuilderParams,
cache?: BufferCache['index'],
): Option<{ index: IndexArray, skirt: IndexArray }> {
): { index: IndexArray, skirt: IndexArray } {
const indexBufferSize = getBufferIndexSize(nSeg, params.disableSkirt);
const indexConstructor = getUintArrayConstructor(nVertex);

Expand Down Expand Up @@ -89,7 +89,7 @@ function allocateBuffers(
const {
index,
skirt,
} = allocateIndexBuffer(nVertex, nSeg, params, cache?.index) ?? {};
} = allocateIndexBuffer(nVertex, nSeg, params, cache?.index);

return {
index,
Expand Down

0 comments on commit 853fc75

Please sign in to comment.