-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaframe-extras.loaders.min.js
1 lines (1 loc) · 7.38 KB
/
aframe-extras.loaders.min.js
1
!function e(t,n,r){function i(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(s)return s(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var h=n[a]={exports:{}};t[a][0].call(h.exports,function(e){var n=t[a][1][e];return i(n?n:e)},h,h.exports,e,t,n,r)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,t,n){e("./src/loaders").registerAll()},{"./src/loaders":3}],2:[function(e,t,n){t.exports=THREE.PLYLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.propertyNameMapping={}},THREE.PLYLoader.prototype={constructor:THREE.PLYLoader,load:function(e,t,n,r){var i=this,s=new THREE.XHRLoader(this.manager);s.setResponseType("arraybuffer"),s.load(e,function(e){t(i.parse(e))},n,r)},setPropertyNameMapping:function(e){this.propertyNameMapping=e},bin2str:function(e){for(var t=new Uint8Array(e),n="",r=0;r<e.byteLength;r++)n+=String.fromCharCode(t[r]);return n},isASCII:function(e){var t=this.parseHeader(this.bin2str(e));return"ascii"===t.format},parse:function(e){return e instanceof ArrayBuffer?this.isASCII(e)?this.parseASCII(this.bin2str(e)):this.parseBinary(e):this.parseASCII(e)},parseHeader:function(e){function t(e,t){var n={type:e[0]};return"list"===n.type?(n.name=e[3],n.countType=e[1],n.itemType=e[2]):n.name=e[1],n.name in t&&(n.name=t[n.name]),n}var n=/ply([\s\S]*)end_header\s/,r="",i=0,s=n.exec(e);null!==s&&(r=s[1],i=s[0].length);for(var a,o,l={comments:[],elements:[],headerLength:i},c=r.split("\n"),h=void 0,m=0;m<c.length;m++){var u=c[m];if(u=u.trim(),""!==u)switch(o=u.split(/\s+/),a=o.shift(),u=o.join(" "),a){case"format":l.format=o[0],l.version=o[1];break;case"comment":l.comments.push(u);break;case"element":void 0!==h&&l.elements.push(h),h=Object(),h.name=o[0],h.count=parseInt(o[1]),h.properties=[];break;case"property":h.properties.push(t(o,this.propertyNameMapping));break;default:console.log("unhandled",a,o)}}return void 0!==h&&l.elements.push(h),l},parseASCIINumber:function(e,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(e);case"float":case"double":case"float32":case"float64":return parseFloat(e)}},parseASCIIElement:function(e,t){for(var n=t.split(/\s+/),r=Object(),i=0;i<e.length;i++)if("list"===e[i].type){for(var s=[],a=this.parseASCIINumber(n.shift(),e[i].countType),o=0;o<a;o++)s.push(this.parseASCIINumber(n.shift(),e[i].itemType));r[e[i].name]=s}else r[e[i].name]=this.parseASCIINumber(n.shift(),e[i].type);return r},parseASCII:function(e){var t,n=new THREE.Geometry,r=this.parseHeader(e),i=/end_header\s([\s\S]*)$/,s="";null!==(t=i.exec(e))&&(s=t[1]);var a=s.split("\n"),o=0,l=0;n.useColor=!1;for(var c=0;c<a.length;c++){var h=a[c];if(h=h.trim(),""!==h){l>=r.elements[o].count&&(o++,l=0);var m=this.parseASCIIElement(r.elements[o].properties,h);this.handleElement(n,r.elements[o].name,m),l++}}return this.postProcess(n)},postProcess:function(e){if(e.useColor){for(var t=0;t<e.faces.length;t++)e.faces[t].vertexColors=[e.colors[e.faces[t].a],e.colors[e.faces[t].b],e.colors[e.faces[t].c]];e.elementsNeedUpdate=!0}return e.computeBoundingSphere(),e},handleElement:function(e,t,n){if("vertex"===t){if(e.vertices.push(new THREE.Vector3(n.x,n.y,n.z)),"red"in n&&"green"in n&&"blue"in n){e.useColor=!0;var r=new THREE.Color;r.setRGB(n.red/255,n.green/255,n.blue/255),e.colors.push(r)}}else if("face"===t){var i=n.vertex_indices||n.vertex_index;3===i.length?e.faces.push(new THREE.Face3(i[0],i[1],i[2])):4===i.length&&e.faces.push(new THREE.Face3(i[0],i[1],i[3]),new THREE.Face3(i[1],i[2],i[3]))}},binaryRead:function(e,t,n,r){switch(n){case"int8":case"char":return[e.getInt8(t),1];case"uint8":case"uchar":return[e.getUint8(t),1];case"int16":case"short":return[e.getInt16(t,r),2];case"uint16":case"ushort":return[e.getUint16(t,r),2];case"int32":case"int":return[e.getInt32(t,r),4];case"uint32":case"uint":return[e.getUint32(t,r),4];case"float32":case"float":return[e.getFloat32(t,r),4];case"float64":case"double":return[e.getFloat64(t,r),8]}},binaryReadElement:function(e,t,n,r){for(var i,s=Object(),a=0,o=0;o<n.length;o++)if("list"===n[o].type){var l=[];i=this.binaryRead(e,t+a,n[o].countType,r);var c=i[0];a+=i[1];for(var h=0;h<c;h++)i=this.binaryRead(e,t+a,n[o].itemType,r),l.push(i[0]),a+=i[1];s[n[o].name]=l}else i=this.binaryRead(e,t+a,n[o].type,r),s[n[o].name]=i[0],a+=i[1];return[s,a]},parseBinary:function(e){for(var t,n=new THREE.Geometry,r=this.parseHeader(this.bin2str(e)),i="binary_little_endian"===r.format,s=new DataView(e,r.headerLength),a=0,o=0;o<r.elements.length;o++)for(var l=0;l<r.elements[o].count;l++){t=this.binaryReadElement(s,a,r.elements[o].properties,i),a+=t[1];var c=t[0];this.handleElement(n,r.elements[o].name,c)}return this.postProcess(n)}}},{}],3:[function(e,t,n){t.exports={"ply-model":e("./ply-model"),"three-model":e("./three-model"),registerAll:function(e){this._registered||(e=e||window.AFRAME,e=e.aframeCore||e,e.systems["ply-model"]||e.registerSystem("ply-model",this["ply-model"].System),e.components["ply-model"]||e.registerComponent("ply-model",this["ply-model"].Component),e.components["three-model"]||e.registerComponent("three-model",this["three-model"]),this._registered=!0)}}},{"./ply-model":4,"./three-model":5}],4:[function(e,t,n){function r(e){return new THREE.Mesh(e,new THREE.MeshPhongMaterial({color:16777215,shading:THREE.FlatShading,vertexColors:THREE.VertexColors,shininess:0}))}THREE.PLYLoader=e("../../lib/PLYLoader"),t.exports.System={init:function(){this.cache={}},getOrLoadGeometry:function(e,t){var n=this.cache,r=n[e];return!t&&r?r:(n[e]=new Promise(function(t){var n=new THREE.PLYLoader;n.load(e,function(e){t(e)})}),n[e])}},t.exports.Component={schema:{skipCache:{type:"boolean","default":!1},src:{type:"src"}},init:function(){this.model=null},update:function(){var e=this.data,t=this.el;return e.src?void this.system.getOrLoadGeometry(e.src,e.skipCache).then(function(e){var n=r(e);t.setObject3D("mesh",n),t.emit("model-loaded",{format:"ply",model:n})}):void console.warn("[%s] `src` property is required.",this.name)},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{"../../lib/PLYLoader":2}],5:[function(e,t,n){t.exports={schema:{src:{type:"src"},loader:{"default":"object",oneOf:["object","json"]},animation:{"default":""}},init:function(){this.model=null,this.mixer=null},update:function(e){var t,n=this.data;if(n.src)if(e)n.animation!==e.animation&&this.model.activeAction&&(this.model.activeAction.stop(),this.playAnimation());else if(this.remove(),"object"===n.loader)t=new THREE.ObjectLoader,t.load(n.src,this.load.bind(this));else{if("json"!==n.loader)throw new Error('[three-model] Invalid mode "%s".',n.mode);t=new THREE.JSONLoader,t.load(n.src,function(e,t){this.load(new THREE.Mesh(e,new THREE.MeshFaceMaterial(t)))}.bind(this))}},load:function(e){this.model=e,this.mixer=new THREE.AnimationMixer(this.model),this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"three",model:e}),this.data.animation&&this.playAnimation()},playAnimation:function(){var e=this.data,t=this.model.animations||this.model.geometry.animations,n=THREE.AnimationClip.findByName(t,e.animation);this.model.activeAction=this.mixer.clipAction(n,this.model).play()},remove:function(){this.mixer&&this.mixer.stopAllAction(),this.model&&this.el.removeObject3D("mesh")},tick:function(e,t){this.mixer&&!isNaN(t)&&this.mixer.update(t/1e3)}}},{}]},{},[1]);