-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageLoader.js
More file actions
58 lines (34 loc) · 981 Bytes
/
ImageLoader.js
File metadata and controls
58 lines (34 loc) · 981 Bytes
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
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.ImageLoader = function ( manager ) {
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
};
Object.assign( THREE.ImageLoader.prototype, {
load: function ( url, onLoad, onProgress, onError ) {
var image = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'img' );
image.onload = function () {
URL.revokeObjectURL( image.src );
if ( onLoad ) onLoad( image );
};
if ( url.indexOf( 'data:' ) === 0 ) {
image.src = url;
} else {
var loader = new THREE.XHRLoader( this.manager );
loader.setPath( this.path );
loader.setResponseType( 'blob' );
loader.load( url, function ( blob ) {
image.src = URL.createObjectURL( blob );
}, onProgress, onError );
}
return image;
},
setCrossOrigin: function ( value ) {
this.crossOrigin = value;
return this;
},
setPath: function ( value ) {
this.path = value;
return this;
}
} );