-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathTinyUSDZLoader.js
71 lines (50 loc) · 1.26 KB
/
TinyUSDZLoader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// W.I.P.
// Based on GLTFLoader and USDZLoader
// https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/USDZLoader.js
// https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/GLTFLoader.js
import {
BufferAttribute,
BufferGeometry,
ClampToEdgeWrapping,
FileLoader,
Group,
Loader,
Mesh,
MeshStandardMaterial,
MirroredRepeatWrapping,
RepeatWrapping,
sRGBEncoding,
TextureLoader,
Object3D,
} from 'three';
///
/// Currently USDZ only.
/// Both USDC and USDA are supported as a USD content in USDZ.
/// TODO: Add feature to directly load USDC and USDA
///
class TinyUSDZLoader extends Loader {
constructor( manager ) {
super( manager );
}
load(url, onLoad, onProgress, onError) {
const scope = this;
const loader = new FileLoader( scope.manager );
loader.setPath( scope.path );
loader.setResponseType( 'arraybuffer' );
loader.setRequestHeader( scope.requestHeader );
loader.setWithCredentials( scope.withCredentials );
loader.load( url, function ( text ) {
try {
onLoad( scope.parse( text ) );
} catch ( e ) {
if ( onError ) {
onError( e );
} else {
console.error( e );
}
scope.manager.itemError( url );
}
}, onProgress, onError );
}
}
export { TinyUSDZLoader };