From 853fc75f871cb3d0370422a2495a3b638afe953a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Duhen?= Date: Thu, 23 Jan 2025 19:09:30 +0100 Subject: [PATCH] fix: remove unnecessary optional --- src/Core/Prefab/TileBuilder.ts | 18 +++++++++++++----- src/Core/Prefab/computeBufferTileGeometry.ts | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Core/Prefab/TileBuilder.ts b/src/Core/Prefab/TileBuilder.ts index 5e0b35afc9..b7b48efdf0 100644 --- a/src/Core/Prefab/TileBuilder.ts +++ b/src/Core/Prefab/TileBuilder.ts @@ -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); } diff --git a/src/Core/Prefab/computeBufferTileGeometry.ts b/src/Core/Prefab/computeBufferTileGeometry.ts index ff387e0470..bffb7fe84d 100644 --- a/src/Core/Prefab/computeBufferTileGeometry.ts +++ b/src/Core/Prefab/computeBufferTileGeometry.ts @@ -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); @@ -89,7 +89,7 @@ function allocateBuffers( const { index, skirt, - } = allocateIndexBuffer(nVertex, nSeg, params, cache?.index) ?? {}; + } = allocateIndexBuffer(nVertex, nSeg, params, cache?.index); return { index,