|
@@ -8,69 +8,18 @@ THREE.PDBLoader.prototype = {
|
|
|
|
|
|
constructor: THREE.OBJLoader,
|
|
|
|
|
|
- load: function ( url, callback ) {
|
|
|
+ load: function ( url, onLoad ) {
|
|
|
|
|
|
- var worker, scope = this;
|
|
|
+ var scope = this;
|
|
|
|
|
|
- this.loadAjaxPDB( this, url, callback );
|
|
|
+ var loader = new THREE.XHRLoader( scope.manager );
|
|
|
+ loader.setCrossOrigin( this.crossOrigin );
|
|
|
+ loader.load( url, function ( text ) {
|
|
|
|
|
|
- },
|
|
|
-
|
|
|
- loadAjaxPDB: function ( context, url, callback, callbackProgress ) {
|
|
|
-
|
|
|
- var xhr = new XMLHttpRequest();
|
|
|
-
|
|
|
- var length = 0;
|
|
|
-
|
|
|
- xhr.onreadystatechange = function () {
|
|
|
-
|
|
|
- if ( xhr.readyState === xhr.DONE ) {
|
|
|
-
|
|
|
- if ( xhr.status === 200 || xhr.status === 0 ) {
|
|
|
-
|
|
|
- if ( xhr.responseText ) {
|
|
|
-
|
|
|
- var json = context.parsePDB( xhr.responseText );
|
|
|
- context.createModel( json, callback );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- console.warn( "THREE.PDBLoader: [" + url + "] seems to be unreachable or file there is empty" );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- console.error( "THREE.PDBLoader: Couldn't load [" + url + "] [" + xhr.status + "]" );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else if ( xhr.readyState === xhr.LOADING ) {
|
|
|
-
|
|
|
- if ( callbackProgress ) {
|
|
|
-
|
|
|
- if ( length === 0 ) {
|
|
|
-
|
|
|
- length = xhr.getResponseHeader( "Content-Length" );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- callbackProgress( { total: length, loaded: xhr.responseText.length } );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else if ( xhr.readyState === xhr.HEADERS_RECEIVED ) {
|
|
|
-
|
|
|
- length = xhr.getResponseHeader( "Content-Length" );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
+ var json = scope.parsePDB( text );
|
|
|
+ scope.createModel( json, onLoad );
|
|
|
|
|
|
- xhr.open( "GET", url, true );
|
|
|
- if ( xhr.overrideMimeType ) xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
|
|
|
- xhr.setRequestHeader( "Content-Type", "text/plain" );
|
|
|
- xhr.send( null );
|
|
|
+ } );
|
|
|
|
|
|
},
|
|
|
|