Skip to content

Commit b656d4a

Browse files
committed
fix(tests): undefined is returned instead of an empty arraybuffer
1 parent 62a9f65 commit b656d4a

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

fission/src/mirabuf/MirabufLoader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ class MirabufCachingService {
386386

387387
try {
388388
// Get buffer from hashMap. If not in hashMap, check OPFS. Otherwise, buff is undefined
389-
const getOPFSBuffer = async () => {
389+
const getOPFSBuffer = async (): Promise<ArrayBuffer | undefined> => {
390390
const dirHandle = dirHandleMap[miraType]
391391
if (!canOPFS) return
392392

@@ -396,7 +396,7 @@ class MirabufCachingService {
396396
return await fileHandle.getFile().then(x => x.arrayBuffer())
397397
}
398398

399-
const buff = ((cache[id]?.buffer ?? new Uint8Array()).buffer as ArrayBuffer) ?? (await getOPFSBuffer())
399+
const buff = (cache[id]?.buffer?.buffer as ArrayBuffer | undefined) ?? (await getOPFSBuffer())
400400
if (!buff) {
401401
console.error(`Failed to find arrayBuffer for id: ${id}`)
402402
return undefined

fission/src/mirabuf/MirabufParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class MirabufParser {
9393
this._globalTransforms = new Map()
9494
this._gamePieces = undefined
9595
this._isGamePiece = isGamePiece
96-
if (assembly.transform && isGamePiece)
96+
if (isGamePiece && assembly.transform)
9797
this._gamePieceTransform = convertMirabufTransformToThreeMatrix(assembly.transform)
9898

9999
progressHandle?.update("Parsing assembly...", 0.3)

fission/src/test/MirabufParser.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ describe("Mirabuf Parser Tests", () => {
88
const spikeMira = await MirabufCachingService.cacheRemote(
99
"/api/mira/robots/Dozer_v9.mira",
1010
MiraType.ROBOT
11-
).then(x => MirabufCachingService.get(x!.id, MiraType.ROBOT))
11+
).then(x => {
12+
expect(x).toBeDefined()
13+
return MirabufCachingService.get(x!.id, MiraType.ROBOT)
14+
})
1215

1316
const t = new MirabufParser(spikeMira!)
1417
const rn = [...t.rigidNodes.values()]

fission/src/test/physics/PhysicsSystemRobotSpawning.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ describe("Mirabuf Physics Loading", () => {
1111
return MirabufCachingService.get(x!.id, MiraType.ROBOT)
1212
}
1313
)
14+
1415
const parser = new MirabufParser(assembly!)
1516
const physSystem = new PhysicsSystem()
1617
const mapping = physSystem.createBodiesFromParser(parser, new LayerReserve())

0 commit comments

Comments
 (0)