12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /**
- * @author mrdoob / http://mrdoob.com/
- */
- THREE.GeometryLoader = function ( manager ) {
- this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
- };
- THREE.GeometryLoader.prototype = {
- constructor: THREE.GeometryLoader,
- load: function ( url, onLoad, onProgress, onError ) {
- var scope = this;
- var loader = new THREE.XHRLoader( this.manager );
- loader.setCrossOrigin( this.crossOrigin );
- loader.load( url, function ( text ) {
- onLoad( scope.parse( JSON.parse( text ) ) );
- }, onProgress, onError );
- },
- setCrossOrigin: function ( value ) {
- this.crossOrigin = value;
- },
- parse: function ( json ) {
- var geometry = new THREE.Geometry();
- geometry.indices = json.indices;
- geometry.vertices = json.vertices;
- geometry.normals = json.normals;
- geometry.uvs = json.uvs;
- var boundingSphere = json.boundingSphere;
- if ( boundingSphere !== undefined ) {
- var center = new THREE.Vector3();
- if ( boundingSphere.center !== undefined ) {
- center.fromArray( boundingSphere.center );
- }
- geometry.boundingSphere = new THREE.Sphere( center, boundingSphere.radius );
- }
- return geometry;
- }
- };
|