Three Blocks

Murmuration / source

Open preview
helpers/bunnyVolume.jsPlain text ↗
import { FBXLoader } from 'three/addons/loaders/FBXLoader.js';
import { withAssetLoader } from './LoadingManager.js';

// Stanford Computer Graphics Laboratory scan, distributed under the Stanford
// 3D Scanning Repository terms: https://graphics.stanford.edu/data/3Dscanrep/
const modelUrl = 'https://raw.githubusercontent.com/mrdoob/three.js/r187/examples/models/fbx/stanford-bunny.fbx';

export async function loadBunnyVolume( container, scale ) {

	const model = await withAssetLoader( container, [ 'Stanford bunny' ], manager => (
		manager.load( 'Stanford bunny', onProgress => new FBXLoader().loadAsync( modelUrl, onProgress ) )
	) );
	const mesh = model.getObjectByProperty( 'isMesh', true );
	if ( ! mesh ) throw new Error( 'The Stanford bunny file contains no mesh.' );
	mesh.material.dispose();
	return mesh.geometry.center().scale( scale, scale, scale );

}