visgl / loaders.gl

Loaders for big data visualization. Website:

Home Page:https://loaders.gl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] GLTF: TypedArray for BufferView

Krassnig opened this issue · comments

Hi,

this tileset of the city of Poznan fails when trying to call the constructor for a UInt8Array.

image

I tried to debug the error. In @loaders.gl/gltf/src/lib/gltf-utils/get-typed-array.ts in the function getTypedArrayForBufferView() (link) the binChunk.arrayBuffer is empty but the bufferView.byteLength is some larger number.

Here is a minimal script to reproduce the error:

import { Tiles3DLoader } from "@loaders.gl/3d-tiles";
import { load } from "@loaders.gl/core";
import { Tileset3D } from "@loaders.gl/tiles";
import { WebMercatorViewport } from "@deck.gl/core/typed";

main();
async function main() {
	// tilset of Poznan
	const tilesetJson = await load('http://sip.poznan.pl/model3d/dane/94e73271-85ad-4ef5-8383-ea60a764aa25/tileset.json', Tiles3DLoader);
	const tileset3d = new Tileset3D(tilesetJson, {
		onTileLoad: tile => {
			console.log('tile loaded: ', tile.content.type, tile);
		},
		onTileError: error => {
			console.info('tile erred: ', error);
		}
	});
	
	// Poznan Town Hall
	tileset3d.selectTiles(new WebMercatorViewport({
		width: 2000,
		height: 2000,
		latitude: 52.40857470479989,
		longitude: 16.93402119865525,
		zoom: 18
	}));

	await delay(2000);

	// Arena Sports hall
	tileset3d.selectTiles(new WebMercatorViewport({
		width: 2000,
		height: 2000,
		latitude: 52.397712588813555,
		longitude: 16.891957810801795,
		zoom: 18
	}));

	await delay(2000);

	tileset3d.selectTiles(new WebMercatorViewport({
		width: 2000,
		height: 2000,
		latitude: 52.407871838998496,
		longitude: 16.917021075095796,
		zoom: 18
	}));
}

function delay(milliseconds: number) {
	return new Promise<void>(resolve => setTimeout(() => resolve(), milliseconds));
}

Sorry for opening three issues all at once 😅 and thanks for developing this library :)