function init3d(n,t,i,r,u){var e,f;totalSize=u;Object.keys(THREE.ShaderLib).forEach(function(n){THREE.ShaderLib[n].fragmentShader=THREE.ShaderLib[n].fragmentShader.replace("#extension GL_EXT_frag_depth : enable","")});setContainerSize();camera=new THREE.PerspectiveCamera(45,aspect,near,1e4);e=new THREE.Vector3(0,0,0);camera.lookAt(e);scene=new THREE.Scene;scene.add(camera);setLight();progressElement&&(progressElement.style.display="block");THREE.Loader.Handlers.add(/\.dds$/i,new THREE.DDSLoader);f=new THREE.MTLLoader;f.setPath(t);f.load(r,function(t){t.preload();var r=new THREE.OBJLoader;r.setMaterials(t);r.setPath(n);r.load(i,function(n){callbackFinished(n)},function(n){callbackProgress(n)})});renderer=Detector.webgl?new THREE.WebGLRenderer({alpha:!0,antialias:!0}):new THREE.CanvasRenderer;container=document.getElementById("container3D");renderer.setClearColor(16777215,1);renderer.setSize(containerWidth,containerHeight);renderer.shadowMap.enabled=!0;renderer.domElement.style.position="relative";setControls()}function bestViewObject(n){var i,r,t,u;(globalObject=n,i=boundingBox(n),undefined==i||i.isEmpty())||(r=i.getSize().length(),t=1,r<near&&(t=near/r,r=1.2*near,n.scale.set(t,t,t)),n.position.x=-i.getCenter().x*t,n.position.y=-i.getCenter().y*t,n.position.z=-i.getCenter().z*t,u=r/(2*near*Math.tan(camera.fov/2*Math.PI/180)*(aspect>1?1:aspect)),camera.position.set(0,-u,u/4))}function callbackFinished(n){bestViewObject(n);progressElement&&(progressElement.style.display="none");n.name="3Dpreview";scene.add(n);animate()}function callbackProgress(n){n.loaded/totalSize*100>=90&&(progressMessageElement.innerHTML=progressMessageElement.getAttribute("data-rendering"));progressElement&&(progressElement.style.display="block")}function callbackError(){console.log("An error happened when load.")}function setControls(){container&&(container.appendChild(renderer.domElement),controls=new THREE.TrackballControls(camera,container),controls.rotateSpeed=1,controls.zoomSpeed=.4,controls.panSpeed=.8,controls.noZoom=!1,controls.noRotate=!1,controls.noPan=!0,controls.staticMoving=!0,controls.dynamicDampingFactor=.3,controls.addEventListener("change",render));window.addEventListener("resize",onWindowResize,!1)}function setLight(){var f=new THREE.AmbientLight(16777215),n,t,i,r,u;f.intensity=.7;scene.add(f);n=new THREE.DirectionalLight(16777215);n.position.set(1e3,1e3,0);n.intensity=.2;scene.add(n);t=new THREE.DirectionalLight(16777215);t.position.set(-1e3,0,0);t.intensity=.2;scene.add(t);i=new THREE.DirectionalLight(16777215);i.position.set(0,-1e3,0);i.intensity=.2;scene.add(i);r=new THREE.DirectionalLight(16777215);r.position.set(0,0,1e3);r.intensity=.2;scene.add(r);u=new THREE.DirectionalLight(16777215);u.position.set(0,0,-1e3);u.intensity=.2;scene.add(u)}function setContainerSize(){window.innerWidth<modalSmall?(containerWidth=window.innerWidth/1.12,containerHeight=window.innerHeight/1.26):window.innerWidth<modalNormal?(containerWidth=598,containerHeight=598):(containerWidth=260,containerHeight=260);aspect=containerWidth/containerHeight}function onWindowResize(){setContainerSize();camera.aspect=aspect;camera.updateProjectionMatrix();renderer.setSize(containerWidth,containerHeight);controls.handleResize();render()}function onDocumentMouseMove(n){mouseX=(n.clientX-windowHalfX)/2;mouseY=(n.clientY-windowHalfY)/2}function onDocumentTouchStart(n){n.touches.length===1&&(n.preventDefault(),window.mouseXOnMouseDown=n.touches[0].pageX-windowHalfX,window.targetRotationOnMouseDown=targetRotation)}function onDocumentTouchMove(n){n.touches.length===1&&(n.preventDefault(),mouseX=n.touches[0].pageX-windowHalfX,window.targetRotation=targetRotationOnMouseDown+(mouseX-mouseXOnMouseDown)*.05)}function boundingBox(n){var u=this,i,r,t;if(n instanceof THREE.Mesh)return i=n.geometry,i.computeBoundingBox(),i.boundingBox;if(n instanceof THREE.Object3D){for(r=new THREE.Box3,t=0;t<n.children.length;t++)r.union(u.boundingBox(n.children[t]));return r}}function clearScene(){scene.remove("3Dpreview")}function animate(){requestAnimationFrame(animate);camera.lookAt(scene.position);render();controls.update()}function render(){renderer.render(scene,camera)}var Detector,Mc;THREE.DDSLoader=function(){this._parser=THREE.DDSLoader.parse};THREE.DDSLoader.prototype=Object.create(THREE.CompressedTextureLoader.prototype);THREE.DDSLoader.prototype.constructor=THREE.DDSLoader;THREE.DDSLoader.parse=function(n,t){function s(n){return n.charCodeAt(0)+(n.charCodeAt(1)<<8)+(n.charCodeAt(2)<<16)+(n.charCodeAt(3)<<24)}function k(n){return String.fromCharCode(n&255,n>>8&255,n>>16&255,n>>24&255)}function d(n,t,i,r){for(var s,l,a,v,y,h=i*r*4,o=new Uint8Array(n,t,h),e=new Uint8Array(h),u=0,f=0,c=0;c<r;c++)for(s=0;s<i;s++)l=o[f],f++,a=o[f],f++,v=o[f],f++,y=o[f],f++,e[u]=v,u++,e[u]=a,u++,e[u]=l,u++,e[u]=y,u++;return e}var i={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},g=s("DXT1"),nt=s("DXT3"),tt=s("DXT5"),it=s("ETC1"),r=new Int32Array(n,0,31),f,a,v,u,h,w,y,e,o,p,l,c,b;if(r[0]!==542327876)return console.error("THREE.DDSLoader.parse: Invalid magic number in DDS header."),i;if(!r[20]&4)return console.error("THREE.DDSLoader.parse: Unsupported format, must contain a FourCC code."),i;a=r[21];v=!1;switch(a){case g:f=8;i.format=THREE.RGB_S3TC_DXT1_Format;break;case nt:f=16;i.format=THREE.RGBA_S3TC_DXT3_Format;break;case tt:f=16;i.format=THREE.RGBA_S3TC_DXT5_Format;break;case it:f=8;i.format=THREE.RGB_ETC1_Format;break;default:if(r[22]===32&&r[23]&16711680&&r[24]&65280&&r[25]&255&&r[26]&4278190080)v=!0,f=64,i.format=THREE.RGBAFormat;else return console.error("THREE.DDSLoader.parse: Unsupported FourCC code ",k(a)),i}if(i.mipmapCount=1,r[2]&131072&&t!==!1&&(i.mipmapCount=Math.max(1,r[7])),u=r[28],i.isCubemap=u&512?!0:!1,i.isCubemap&&(!(u&1024)||!(u&2048)||!(u&4096)||!(u&8192)||!(u&16384)||!(u&32768)))return console.error("THREE.DDSLoader.parse: Incomplete cubemap faces"),i;for(i.width=r[4],i.height=r[3],h=r[1]+4,w=i.isCubemap?6:1,y=0;y<w;y++)for(e=i.width,o=i.height,p=0;p<i.mipmapCount;p++)v?(c=d(n,h,e,o),l=c.length):(l=Math.max(4,e)/4*Math.max(4,o)/4*f,c=new Uint8Array(n,h,l)),b={data:c,width:e,height:o},i.mipmaps.push(b),h+=l,e=Math.max(e>>1,1),o=Math.max(o>>1,1);return i};THREE.MTLLoader=function(n){this.manager=n!==undefined?n:THREE.DefaultLoadingManager};Object.assign(THREE.MTLLoader.prototype,THREE.EventDispatcher.prototype,{load:function(n,t,i,r){var f=this,u=new THREE.XHRLoader(this.manager);u.setPath(this.path);u.load(n,function(n){t(f.parse(n))},i,r)},setPath:function(n){this.path=n},setTexturePath:function(n){this.texturePath=n},setBaseUrl:function(n){console.warn("THREE.MTLLoader: .setBaseUrl() is deprecated. Use .setTexturePath( path ) for texture path or .setPath( path ) for general base path instead.");this.setTexturePath(n)},setCrossOrigin:function(n){this.crossOrigin=n},setMaterialOptions:function(n){this.materialOptions=n},parse:function(n){for(var t,f,i,r,o,e,h=n.split("\n"),u={},c={},s=0;s<h.length;s++)(t=h[s],t=t.trim(),t.length!==0&&t.charAt(0)!=="#")&&(f=t.indexOf(" "),i=f>=0?t.substring(0,f):t,i=i.toLowerCase(),r=f>=0?t.substring(f+1):"",r=r.trim(),i==="newmtl"?(u={name:r},c[r]=u):u&&(i==="ka"||i==="kd"||i==="ks"?(o=r.split(/\s+/,3),u[i]=[parseFloat(o[0]),parseFloat(o[1]),parseFloat(o[2])]):u[i]=r));return e=new THREE.MTLLoader.MaterialCreator(this.texturePath||this.path,this.materialOptions),e.setCrossOrigin(this.crossOrigin),e.setManager(this.manager),e.setMaterials(c),e}});THREE.MTLLoader.MaterialCreator=function(n,t){this.baseUrl=n||"";this.options=t;this.materialsInfo={};this.materials={};this.materialsArray=[];this.nameLookup={};this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide;this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping};THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,setCrossOrigin:function(n){this.crossOrigin=n},setManager:function(n){this.manager=n},setMaterials:function(n){this.materialsInfo=this.convert(n);this.materials={};this.materialsArray=[];this.nameLookup={}},convert:function(n){var i,r,u,f,e;if(!this.options)return n;i={};for(r in n){u=n[r];f={};i[r]=f;for(e in u){var o=!0,t=u[e],s=e.toLowerCase();switch(s){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(t=[t[0]/255,t[1]/255,t[2]/255]);this.options&&this.options.ignoreZeroRGBs&&t[0]===0&&t[1]===0&&t[2]===0&&(o=!1)}o&&(f[s]=t)}}return i},preload:function(){for(var n in this.materialsInfo)this.create(n)},getIndex:function(n){return this.nameLookup[n]},getAsArray:function(){var n=0;for(var t in this.materialsInfo)this.materialsArray[n]=this.create(t),this.nameLookup[t]=n,n++;return this.materialsArray},create:function(n){return this.materials[n]===undefined&&this.createMaterial_(n),this.materials[n]},createMaterial_:function(n){function u(n,t){if(!i[n]){var f=r.getTextureParams(t,i),u=r.loadTexture(o(r.baseUrl,f.url));u.repeat.copy(f.scale);u.offset.copy(f.offset);u.wrapS=r.wrap;u.wrapT=r.wrap;i[n]=u}}var r=this,e=this.materialsInfo[n],i={name:n,side:this.side},o=function(n,t){return typeof t!="string"||t===""?"":/^https?:\/\//i.test(t)?t:n+t},f,t;for(f in e)if(t=e[f],t!=="")switch(f.toLowerCase()){case"kd":i.color=(new THREE.Color).fromArray(t);break;case"ks":i.specular=(new THREE.Color).fromArray(t);break;case"map_kd":u("map",t);break;case"map_ks":u("specularMap",t);break;case"map_bump":case"bump":u("bumpMap",t);break;case"ns":i.shininess=parseFloat(t);break;case"d":t<1&&(i.opacity=t,i.transparent=!0);break;case"Tr":t>0&&(i.opacity=1-t,i.transparent=!0)}return this.materials[n]=new THREE.MeshPhongMaterial(i),this.materials[n]},getTextureParams:function(n,t){var u={scale:new THREE.Vector2(1,1),offset:new THREE.Vector2(0,0)},r=n.split(/\s+/),i;return i=r.indexOf("-bm"),i>=0&&(t.bumpScale=parseFloat(r[i+1]),r.splice(i,2)),i=r.indexOf("-s"),i>=0&&(u.scale.set(parseFloat(r[i+1]),parseFloat(r[i+2])),r.splice(i,4)),i=r.indexOf("-o"),i>=0&&(u.offset.set(parseFloat(r[i+1]),parseFloat(r[i+2])),r.splice(i,4)),u.url=r.join(" ").trim(),u},loadTexture:function(n,t,i,r,u){var e,f=THREE.Loader.Handlers.get(n),o=this.manager!==undefined?this.manager:THREE.DefaultLoadingManager;return f===null&&(f=new THREE.TextureLoader(o)),f.setCrossOrigin&&f.setCrossOrigin(this.crossOrigin),e=f.load(n,i,r,u),t!==undefined&&(e.mapping=t),e}};THREE.OBJLoader=function(n){this.manager=n!==undefined?n:THREE.DefaultLoadingManager;this.materials=null;this.regexp={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}};THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(n,t,i,r){var u=this,f=new THREE.XHRLoader(u.manager);f.setPath(this.path);f.load(n,function(n){t(u.parse(n))},i,r)},setPath:function(n){this.path=n},setMaterials:function(n){this.materials=n},_createParserState:function(){var n={objects:[],object:{},vertices:[],normals:[],uvs:[],materialLibraries:[],startObject:function(n,t){var i,r;if(this.object&&this.object.fromDeclaration===!1){this.object.name=n;this.object.fromDeclaration=t!==!1;return}i=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():undefined;this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0);this.object={name:n||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],uvs:[]},materials:[],smooth:!0,startMaterial:function(n,t){var i=this._finalize(!1),r;return i&&(i.inherited||i.groupCount<=0)&&this.materials.splice(i.index,1),r={index:this.materials.length,name:n||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:i!==undefined?i.smooth:this.smooth,groupStart:i!==undefined?i.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(n){var t={index:typeof n=="number"?n:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}},this.materials.push(r),r},currentMaterial:function(){return this.materials.length>0?this.materials[this.materials.length-1]:undefined},_finalize:function(n){var t=this.currentMaterial(),i;if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),n&&this.materials.length>1)for(i=this.materials.length-1;i>=0;i--)this.materials[i].groupCount<=0&&this.materials.splice(i,1);return n&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),t}};i&&i.name&&typeof i.clone=="function"&&(r=i.clone(0),r.inherited=!0,this.object.materials.push(r));this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(n,t){var i=parseInt(n,10);return(i>=0?i-1:i+t/3)*3},parseNormalIndex:function(n,t){var i=parseInt(n,10);return(i>=0?i-1:i+t/3)*3},parseUVIndex:function(n,t){var i=parseInt(n,10);return(i>=0?i-1:i+t/2)*2},addVertex:function(n,t,i){var r=this.vertices,u=this.object.geometry.vertices;u.push(r[n+0]);u.push(r[n+1]);u.push(r[n+2]);u.push(r[t+0]);u.push(r[t+1]);u.push(r[t+2]);u.push(r[i+0]);u.push(r[i+1]);u.push(r[i+2])},addVertexLine:function(n){var t=this.vertices,i=this.object.geometry.vertices;i.push(t[n+0]);i.push(t[n+1]);i.push(t[n+2])},addNormal:function(n,t,i){var r=this.normals,u=this.object.geometry.normals;u.push(r[n+0]);u.push(r[n+1]);u.push(r[n+2]);u.push(r[t+0]);u.push(r[t+1]);u.push(r[t+2]);u.push(r[i+0]);u.push(r[i+1]);u.push(r[i+2])},addUV:function(n,t,i){var r=this.uvs,u=this.object.geometry.uvs;u.push(r[n+0]);u.push(r[n+1]);u.push(r[t+0]);u.push(r[t+1]);u.push(r[i+0]);u.push(r[i+1])},addUVLine:function(n){var t=this.uvs,i=this.object.geometry.uvs;i.push(t[n+0]);i.push(t[n+1])},addFace:function(n,t,i,r,u,f,e,o,s,h,c,l){var k=this.vertices.length,v=this.parseVertexIndex(n,k),a=this.parseVertexIndex(t,k),p=this.parseVertexIndex(i,k),y,w,b;r===undefined?this.addVertex(v,a,p):(y=this.parseVertexIndex(r,k),this.addVertex(v,a,y),this.addVertex(a,p,y));u!==undefined&&(w=this.uvs.length,v=this.parseUVIndex(u,w),a=this.parseUVIndex(f,w),p=this.parseUVIndex(e,w),r===undefined?this.addUV(v,a,p):(y=this.parseUVIndex(o,w),this.addUV(v,a,y),this.addUV(a,p,y)));s!==undefined&&(b=this.normals.length,v=this.parseNormalIndex(s,b),a=s===h?v:this.parseNormalIndex(h,b),p=s===c?v:this.parseNormalIndex(c,b),r===undefined?this.addNormal(v,a,p):(y=this.parseNormalIndex(l,b),this.addNormal(v,a,y),this.addNormal(a,p,y)))},addLineGeometry:function(n,t){var f,e,i,u,r;for(this.object.geometry.type="Line",f=this.vertices.length,e=this.uvs.length,i=0,r=n.length;i<r;i++)this.addVertexLine(this.parseVertexIndex(n[i],f));for(u=0,r=t.length;u<r;u++)this.addUVLine(this.parseUVIndex(t[u],e))}};return n.startObject("",!1),n},parse:function(n){var r,p,ht,a,ct,it,w,o,y,f,c,u,ut,g,e,d,h,ft;console.time("OBJLoader");r=this._createParserState();n.indexOf("\r\n")!==-1&&(n=n.replace(/\r\n/g,"\n"));n.indexOf("\\\n")!==-1&&(n=n.replace(/\\\n/g,""));var et=n.split("\n"),i="",l="",v="",ot=0,t=[],lt=typeof"".trimLeft=="function";for(o=0,y=et.length;o<y;o++)if((i=et[o],i=lt?i.trimLeft():i.trim(),ot=i.length,ot!==0)&&(l=i.charAt(0),l!=="#"))if(l==="v")if(v=i.charAt(1),v===" "&&(t=this.regexp.vertex_pattern.exec(i))!==null)r.vertices.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]));else if(v==="n"&&(t=this.regexp.normal_pattern.exec(i))!==null)r.normals.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]));else if(v==="t"&&(t=this.regexp.uv_pattern.exec(i))!==null)r.uvs.push(parseFloat(t[1]),parseFloat(t[2]));else throw new Error("Unexpected vertex/normal/uv line: '"+i+"'");else if(l==="f")if((t=this.regexp.face_vertex_uv_normal.exec(i))!==null)r.addFace(t[1],t[4],t[7],t[10],t[2],t[5],t[8],t[11],t[3],t[6],t[9],t[12]);else if((t=this.regexp.face_vertex_uv.exec(i))!==null)r.addFace(t[1],t[3],t[5],t[7],t[2],t[4],t[6],t[8]);else if((t=this.regexp.face_vertex_normal.exec(i))!==null)r.addFace(t[1],t[3],t[5],t[7],undefined,undefined,undefined,undefined,t[2],t[4],t[6],t[8]);else if((t=this.regexp.face_vertex.exec(i))!==null)r.addFace(t[1],t[2],t[3],t[4]);else throw new Error("Unexpected face line: '"+i+"'");else if(l==="l"){var nt=i.substring(1).trim().split(" "),tt=[],st=[];if(i.indexOf("/")===-1)tt=nt;else for(p=0,ht=nt.length;p<ht;p++)a=nt[p].split("/"),a[0]!==""&&tt.push(a[0]),a[1]!==""&&st.push(a[1]);r.addLineGeometry(tt,st)}else if((t=this.regexp.object_pattern.exec(i))!==null)ct=(" "+t[0].substr(1).trim()).substr(1),r.startObject(ct);else if(this.regexp.material_use_pattern.test(i))r.object.startMaterial(i.substring(7).trim(),r.materialLibraries);else if(this.regexp.material_library_pattern.test(i))r.materialLibraries.push(i.substring(7).trim());else if((t=this.regexp.smoothing_pattern.exec(i))!==null)it=t[1].trim().toLowerCase(),r.object.smooth=it==="1"||it==="on",u=r.object.currentMaterial(),u&&(u.smooth=r.object.smooth);else{if(i==='\0')continue;throw new Error("Unexpected line: '"+i+"'");}for(r.finalize(),w=new THREE.Group,w.materialLibraries=[].concat(r.materialLibraries),o=0,y=r.objects.length;o<y;o++){var rt=r.objects[o],s=rt.geometry,b=rt.materials,k=s.type==="Line";if(s.vertices.length!==0){for(f=new THREE.BufferGeometry,f.addAttribute("position",new THREE.BufferAttribute(new Float32Array(s.vertices),3)),s.normals.length>0?f.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(s.normals),3)):f.computeVertexNormals(),s.uvs.length>0&&f.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(s.uvs),2)),c=[],e=0,d=b.length;e<d;e++)h=b[e],u=undefined,this.materials!==null&&(u=this.materials.create(h.name),!k||!u||u instanceof THREE.LineBasicMaterial||(ut=new THREE.LineBasicMaterial,ut.copy(u),u=ut)),u||(u=k?new THREE.LineBasicMaterial:new THREE.MeshPhongMaterial,u.name=h.name),u.shading=h.smooth?THREE.SmoothShading:THREE.FlatShading,c.push(u);if(c.length>1){for(e=0,d=b.length;e<d;e++)h=b[e],f.addGroup(h.groupStart,h.groupCount,e);ft=new THREE.MultiMaterial(c);g=k?new THREE.LineSegments(f,ft):new THREE.Mesh(f,ft)}else g=k?new THREE.LineSegments(f,c[0]):new THREE.Mesh(f,c[0]);g.name=rt.name;w.add(g)}}return console.timeEnd("OBJLoader"),w}};THREE.TrackballControls=function(n,t){function w(n){i.enabled!==!1&&(window.removeEventListener("keydown",w),k=u,u===r.NONE)&&(n.keyCode!==i.keys[r.ROTATE]||i.noRotate?n.keyCode!==i.keys[r.ZOOM]||i.noZoom?n.keyCode!==i.keys[r.PAN]||i.noPan||(u=r.PAN):u=r.ZOOM:u=r.ROTATE)}function ft(){i.enabled!==!1&&(u=k,window.addEventListener("keydown",w,!1))}function et(n){i.enabled!==!1&&(n.preventDefault(),n.stopPropagation(),u===r.NONE&&(u=n.button),u!==r.ROTATE||i.noRotate?u!==r.ZOOM||i.noZoom?u!==r.PAN||i.noPan||(h.copy(a(n.pageX,n.pageY)),l.copy(h)):(s.copy(a(n.pageX,n.pageY)),c.copy(s)):(e.copy(v(n.pageX,n.pageY)),o.copy(e)),document.addEventListener("mousemove",tt,!1),document.addEventListener("mouseup",it,!1),i.dispatchEvent(g))}function tt(n){i.enabled!==!1&&(n.preventDefault(),n.stopPropagation(),u!==r.ROTATE||i.noRotate?u!==r.ZOOM||i.noZoom?u!==r.PAN||i.noPan||l.copy(a(n.pageX,n.pageY)):c.copy(a(n.pageX,n.pageY)):(o.copy(e),e.copy(v(n.pageX,n.pageY))))}function it(n){i.enabled!==!1&&(n.preventDefault(),n.stopPropagation(),u=r.NONE,document.removeEventListener("mousemove",tt),document.removeEventListener("mouseup",it),i.dispatchEvent(nt))}function ot(n){i.enabled!==!1&&(n.preventDefault(),n.stopPropagation(),s.y-=n.deltaY*.01,i.dispatchEvent(g),i.dispatchEvent(nt))}function st(n){var t,f,s,c;if(i.enabled!==!1){switch(n.touches.length){case 1:u=r.TOUCH_ROTATE;e.copy(v(n.touches[0].pageX,n.touches[0].pageY));o.copy(e);break;default:u=r.TOUCH_ZOOM_PAN;t=n.touches[0].pageX-n.touches[1].pageX;f=n.touches[0].pageY-n.touches[1].pageY;p=d=Math.sqrt(t*t+f*f);s=(n.touches[0].pageX+n.touches[1].pageX)/2;c=(n.touches[0].pageY+n.touches[1].pageY)/2;h.copy(a(s,c));l.copy(h)}i.dispatchEvent(g)}}function ht(n){var t,r,u,f;if(i.enabled!==!1){n.preventDefault();n.stopPropagation();switch(n.touches.length){case 1:o.copy(e);e.copy(v(n.touches[0].pageX,n.touches[0].pageY));break;default:t=n.touches[0].pageX-n.touches[1].pageX;r=n.touches[0].pageY-n.touches[1].pageY;p=Math.sqrt(t*t+r*r);u=(n.touches[0].pageX+n.touches[1].pageX)/2;f=(n.touches[0].pageY+n.touches[1].pageY)/2;l.copy(a(u,f))}}}function ct(n){if(i.enabled!==!1){switch(n.touches.length){case 0:u=r.NONE;break;case 1:u=r.TOUCH_ROTATE;e.copy(v(n.touches[0].pageX,n.touches[0].pageY));o.copy(e)}i.dispatchEvent(nt)}}function lt(n){n.preventDefault()}var i=this,r={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},a,v;this.object=n;this.domElement=t!==undefined?t:document;this.enabled=!0;this.screen={left:0,top:0,width:0,height:0};this.rotateSpeed=1;this.zoomSpeed=1.2;this.panSpeed=.3;this.noRotate=!1;this.noZoom=!1;this.noPan=!1;this.staticMoving=!1;this.dynamicDampingFactor=.2;this.minDistance=0;this.maxDistance=Infinity;this.keys=[65,83,68];this.target=new THREE.Vector3;var at=1e-6,b=new THREE.Vector3,u=r.NONE,k=r.NONE,f=new THREE.Vector3,o=new THREE.Vector2,e=new THREE.Vector2,rt=new THREE.Vector3,y=0,s=new THREE.Vector2,c=new THREE.Vector2,d=0,p=0,h=new THREE.Vector2,l=new THREE.Vector2;this.target0=this.target.clone();this.position0=this.object.position.clone();this.up0=this.object.up.clone();var ut={type:"change"},g={type:"start"},nt={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var n=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=n.left+window.pageXOffset-t.clientLeft;this.screen.top=n.top+window.pageYOffset-t.clientTop;this.screen.width=n.width;this.screen.height=n.height}};this.handleEvent=function(n){typeof this[n.type]=="function"&&this[n.type](n)};a=function(){var n=new THREE.Vector2;return function(t,r){return n.set((t-i.screen.left)/i.screen.width,(r-i.screen.top)/i.screen.height),n}}();v=function(){var n=new THREE.Vector2;return function(t,r){return n.set((t-i.screen.width*.5-i.screen.left)/(i.screen.width*.5),(i.screen.height+2*(i.screen.top-r))/i.screen.width),n}}();this.rotateCamera=function(){var s=new THREE.Vector3,n=new THREE.Quaternion,c=new THREE.Vector3,r=new THREE.Vector3,h=new THREE.Vector3,u=new THREE.Vector3,t;return function(){u.set(e.x-o.x,e.y-o.y,0);t=u.length();t?(f.copy(i.object.position).sub(i.target),c.copy(f).normalize(),r.copy(i.object.up).normalize(),h.crossVectors(r,c).normalize(),r.setLength(e.y-o.y),h.setLength(e.x-o.x),u.copy(r.add(h)),s.crossVectors(u,f).normalize(),t*=i.rotateSpeed,n.setFromAxisAngle(s,t),f.applyQuaternion(n),i.object.up.applyQuaternion(n),rt.copy(s),y=t):!i.staticMoving&&y&&(y*=Math.sqrt(1-i.dynamicDampingFactor),f.copy(i.object.position).sub(i.target),n.setFromAxisAngle(rt,y),f.applyQuaternion(n),i.object.up.applyQuaternion(n));o.copy(e)}}();this.zoomCamera=function(){var n;u===r.TOUCH_ZOOM_PAN?(n=d/p,d=p,f.multiplyScalar(n)):(n=1+(c.y-s.y)*i.zoomSpeed,n!==1&&n>0&&(f.multiplyScalar(n),i.staticMoving?s.copy(c):s.y+=(c.y-s.y)*this.dynamicDampingFactor))};this.panCamera=function(){var n=new THREE.Vector2,r=new THREE.Vector3,t=new THREE.Vector3;return function(){n.copy(l).sub(h);n.lengthSq()&&(n.multiplyScalar(f.length()*i.panSpeed),t.copy(f).cross(i.object.up).setLength(n.x),t.add(r.copy(i.object.up).setLength(n.y)),i.object.position.add(t),i.target.add(t),i.staticMoving?h.copy(l):h.add(n.subVectors(l,h).multiplyScalar(i.dynamicDampingFactor)))}}();this.checkDistances=function(){i.noZoom&&i.noPan||(f.lengthSq()>i.maxDistance*i.maxDistance&&(i.object.position.addVectors(i.target,f.setLength(i.maxDistance)),s.copy(c)),f.lengthSq()<i.minDistance*i.minDistance&&(i.object.position.addVectors(i.target,f.setLength(i.minDistance)),s.copy(c)))};this.update=function(){f.subVectors(i.object.position,i.target);i.noRotate||i.rotateCamera();i.noZoom||i.zoomCamera();i.noPan||i.panCamera();i.object.position.addVectors(i.target,f);i.checkDistances();i.object.lookAt(i.target);b.distanceToSquared(i.object.position)>at&&(i.dispatchEvent(ut),b.copy(i.object.position))};this.reset=function(){u=r.NONE;k=r.NONE;i.target.copy(i.target0);i.object.position.copy(i.position0);i.object.up.copy(i.up0);f.subVectors(i.object.position,i.target);i.object.lookAt(i.target);i.dispatchEvent(ut);b.copy(i.object.position)};this.dispose=function(){this.domElement.removeEventListener("contextmenu",lt,!1);this.domElement.removeEventListener("mousedown",et,!1);this.domElement.removeEventListener("wheel",ot,!1);this.domElement.removeEventListener("touchstart",st,!1);this.domElement.removeEventListener("touchend",ct,!1);this.domElement.removeEventListener("touchmove",ht,!1);document.removeEventListener("mousemove",tt,!1);document.removeEventListener("mouseup",it,!1);window.removeEventListener("keydown",w,!1);window.removeEventListener("keyup",ft,!1)};this.domElement.addEventListener("contextmenu",lt,!1);this.domElement.addEventListener("mousedown",et,!1);this.domElement.addEventListener("wheel",ot,!1);this.domElement.addEventListener("touchstart",st,!1);this.domElement.addEventListener("touchend",ct,!1);this.domElement.addEventListener("touchmove",ht,!1);window.addEventListener("keydown",w,!1);window.addEventListener("keyup",ft,!1);this.handleResize();this.update()};THREE.TrackballControls.prototype=Object.create(THREE.EventDispatcher.prototype);THREE.TrackballControls.prototype.constructor=THREE.TrackballControls;Detector={canvas:!!window.CanvasRenderingContext2D,webgl:function(){try{var n=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(n.getContext("webgl")||n.getContext("experimental-webgl")))}catch(t){return!1}}(),workers:!!window.Worker,fileapi:window.File&&window.FileReader&&window.FileList&&window.Blob,getWebGLErrorMessage:function(){var n=document.createElement("div");return n.id="webgl-error-message",n.style.fontFamily="monospace",n.style.fontSize="13px",n.style.fontWeight="normal",n.style.textAlign="center",n.style.background="#fff",n.style.color="#000",n.style.padding="1.5em",n.style.width="400px",n.style.margin="5em auto 0",this.webgl||(n.innerHTML=window.WebGLRenderingContext?'Your graphics card does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL<\/a>.<br />\nFind out how to get it <a href="http://get.webgl.org/" style="color:#000">here<\/a>.':'Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL<\/a>.<br/>\nFind out how to get it <a href="http://get.webgl.org/" style="color:#000">here<\/a>.'),n},addGetWebGLMessage:function(n){var i,r,t;n=n||{};i=n.parent!==undefined?n.parent:document.body;r=n.id!==undefined?n.id:"oldie";t=Detector.getWebGLErrorMessage();t.id=r;i.appendChild(t)}};typeof module=="object"&&(module.exports=Detector);var container,stats,object,globalObject,private_bgScene,private_bgCam,camera,controls,scene,renderer,aspect,containerWidth,containerHeight,totalSize,mouseX=0,mouseY=0,windowHalfX=window.innerWidth/2,windowHalfY=window.innerHeight/2,near=1,modalSmall=768,modalNormal=992,progressElement=document.getElementById("progress"),progressMessageElement=document.getElementById("message");Mc=Mc||{};Mc.Preview3D=function(){function n(){try{t()}catch(n){console.log(n)}}function t(){$("#pill-2").on("hidden.bs.tab",function(){i()});$('a[data-toggle="tab"]').on("shown.bs.tab",function(n){r(n)})}function i(){controls&&(controls.enabled=!1);clearScene()}function r(n){if($(n.target).attr("href")==="#pill-2"){var t=$("#preview3Ddetail"),i=t.data("obj-url"),f=t.data("obj-name"),r=t.data("mtl-url"),e=t.data("mtl-name"),u=t.data("size");controls?(controls.enabled=!0,controls.handleResize()):i!==undefined&&r!==undefined&&u!==undefined&&init3d(i,r,f,e,u)}}return{Init:n}}($);$(function(){"use strict";Mc.Preview3D.Init()})