-
Notifications
You must be signed in to change notification settings - Fork 3
/
TGmin00Ar.js
1 lines (1 loc) · 56.8 KB
/
TGmin00Ar.js
1
window.File&&window.FileReader&&window.FileList&&window.Blob?console.log("method YESSSSSSSSSSSSS"):console.log("The File APIs are not fully supported in this browser.");var mouseX=0,mouseY=0,windowHalfX=window.innerWidth/2,windowHalfY=window.innerHeight/2;function toggleDiv(e){"none"==document.getElementById(e).style.display?document.getElementById(e).style.display="":document.getElementById(e).style.display="none"}function onDocumentKeyDown(e){keyCode=e.which}function onDocumentKeyUp(e){keyCodeUp=e.which}function nextTetra(){addTetraFlag+=1,camera.remove(objects[1]),addTetraF()}function prevTetra(){addTetraFlag-=1,addTetraFlag<1&&(addTetraFlag=42),camera.remove(objects[1]),addTetraF()}function LoadUserFile(e){scene.remove(octa),console.log(scene.children.length+"children scene Empty");e=e;var o=localStorage.getItem(e);retrievedObjectA=JSON.parse(o),cii=retrievedObjectA[0].NormalT,TColour=retrievedObjectA[0].TColour,rotX=retrievedObjectA[0].rotX,rotY=retrievedObjectA[0].rotY,rotZ,retrievedObjectA[0].rotZ,possiX=retrievedObjectA[0].possiX,possiY=retrievedObjectA[0].possiY,possiZ=retrievedObjectA[0].possiZ,TFlagNum=retrievedObjectA[0].TFlagNum,TFlagNum[cii+1]=1,vv0x=retrievedObjectA[0].vv0x,vv0y=retrievedObjectA[0].vv0y,vv0z=retrievedObjectA[0].vv0z,vv1x=retrievedObjectA[0].vv1x,vv1y=retrievedObjectA[0].vv1y,vv1z=retrievedObjectA[0].vv1z,vv2x=retrievedObjectA[0].vv2x,vv2y=retrievedObjectA[0].vv2y,vv2z=retrievedObjectA[0].vv2z,vv3x=retrievedObjectA[0].vv3x,vv3y=retrievedObjectA[0].vv3y,vv3z=retrievedObjectA[0].vv3z,mirX=retrievedObjectA[0].mirX,mirY=retrievedObjectA[0].mirY,mirXY=retrievedObjectA[0].mirXY,ciiL=retrievedObjectA[0].NormalT,console.log("ciiL: ",ciiL),cii=0,i=2,iiL=-11111;for(var t=loadingF=1;t<=ciiL;t+=1)cii+=1,addTetraFlag=retrievedObjectA[0].TFlagNum[cii],console.log(cii),addTetraLC(cii,e),render();ciiB=scene.children.length,cii=0,i=2,iiL=-11111,console.log(scene.children.length+"children scene Clickables"),ciiB=scene.children.length;for(t=1;t<=ciiL;t+=1)cii+=1,addTetraFlag=retrievedObjectA[0].TFlagNum[cii],addTetraL(cii),render();cii=ciiL,iiL=0}function LoadUserFileC(e,t){localStorage?console.log("LocalStorage is supported!"):console.log("No support. Use a fallback such as browser cookies or store on the server.");var o=e,a=localStorage.getItem(o);retrievedObjectA=JSON.parse(a),ciiL=retrievedObjectA[0].NormalT;console.log(t.length+"obj length"),console.log(t[1].position.x+"obj x pos"),console.log(retrievedObjectA[0].TColour[2]+"outloop obj color"),console.log(scene.children.length+"children scene 8"),ciiA=scene.children.length;scene.traverse(function(e){if(e instanceof THREE.Object3D&&e.userData<990){materials[e.userData]=material15;var o=retrievedObjectA[0].TColour[e.userData];materials[e.userData].color.setHex("0x"+o),lambert=new THREE.MeshLambertMaterial({color:materials[e.userData].color,map:texture2}),t[e.userData].traverse(function(e){e.material=lambert}),1==mirX[e.userData]&.8<Math.abs(possiX[e.userData])&&t[e.userData+1e3].traverse(function(e){e.material=lambert}),1==mirY[e.userData]&.8<Math.abs(possiY[e.userData])&&t[e.userData+2e3].traverse(function(e){e.material=lambert}),1==mirXY[e.userData]&.8<Math.abs(possiX[e.userData])&.8<Math.abs(possiY[e.userData])&&t[e.userData+3e3].traverse(function(e){e.material=lambert})}}),ciiL=retrievedObjectA[0].NormalT-1,cii=ciiL,iiL=0}function download(e,o,t){var a=new Blob([e],{type:t});if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(a,o);else{var i=document.createElement("a"),r=URL.createObjectURL(a);i.href=r,i.download=o,document.body.appendChild(i),i.click(),setTimeout(function(){document.body.removeChild(i),window.URL.revokeObjectURL(r)},0)}}function exportToObj(e,o,t,a,i){localStorage?console.log("LocalStorage is supported!"):console.log("No support. Use a fallback such as browser cookies or store on the server."),localStorage.clear(),parameters.Load2=activeFiles,parameters.LoadC=activeFiles,parameters.DelFile=activeFiles,parameters.uLocalName=userLocalName;for(var r=0;r<Object.keys(gui.__folders).length;r++)for(var s=Object.keys(gui.__folders)[r],n=0;n<gui.__folders[s].__controllers.length;n++)gui.__folders[s].__controllers[n].updateDisplay();var c=[{current:current,userLocalName:userLocalName,numUsers:a,savedFiles:savedFiles}];userObject=JSON.stringify(c,null,100);localStorage.setItem("USERS",userObject),sentObjectA=[{NormalT:cii,TColour:TColour,rotX:rotX,rotY:rotY,rotZ:rotZ,possiX:possiX,possiY:possiY,possiZ:possiZ,TFlagNum:TFlagNum,vv0x:vv0x,vv0y:vv0y,vv0z:vv0z,vv1x:vv1x,vv1y:vv1y,vv1z:vv1z,vv2x:vv2x,vv2y:vv2y,vv2z:vv2z,vv3x:vv3x,vv3y:vv3y,vv3z:vv3z,mirX:mirX,mirY:mirY,mirXY:mirXY}],sampleObject=JSON.stringify(sentObjectA,null,100);var l=new Blob([cii,", cii,","\r\n",TColour,", TColour,","\r\n",rotX,", rotX,","\r\n",rotY,", rotY ","\r\n",rotZ,", rotZ ","\r\n",possiX,", possiX ","\r\n",possiY,", possiY ","\r\n",possiZ,", possiZ ","\r\n",TFlagNum,", TFlagNum ","\r\n",ciiX,", ciiX, ","\r\n",TColourX,", TColourX, ","\r\n",rotXX,", rotX_Xsym, ","\r\n",rotYX,", rotYX ","\r\n",rotZX,", rotZX ","\r\n",possiXX,", possiXX ","\r\n",possiYX,", possiYX ","\r\n",possiZX,", possiZX ","\r\n",TFlagNumX,", TFlagNumX ","\r\n",ciiY,", ciiY, ","\r\n",TColourY,", TColourY, ","\r\n",rotXY,", rotX_Ysym, ","\r\n",rotYY,", rotYY ","\r\n",rotZY,", rotZY ","\r\n",possiXY,", possiXY ","\r\n",possiYY,", possiYY ","\r\n",possiZY,", possiZY ","\r\n",TFlagNumY,", TFlagNumY ",ciiXY,", ciiXandY, ","\r\n",TColourXY,", TColourXandY, ","\r\n",rotXXY,", rotX_XandYsym, ","\r\n",rotYXY,", rotYXY ","\r\n",rotZXY,", rotZXY ","\r\n",possiXXY,", possiXXY ","\r\n",possiYXY,", possiYXY ","\r\n",possiZXY,", possiZXY ","\r\n",TFlagNumXY,", TFlagNumXY "],{type:"text/plain;charset=utf-8"}),d=t;localStorage.setItem(d,sampleObject);for(var m=rotX,v=rotY,b=rotZ,g=1;g<=cii;g+=1)m[g]=180*rotX[g]/Math.PI-90,v[g]=180*rotY[g]/Math.PI,b[g]=180*rotZ[g]/Math.PI;var u="NormalT ="+cii+";TColour =["+TColour.toString().substring(8)+"];rotX =["+m.toString().substring(5)+"];rotY =["+v.toString().substring(5)+"];rotZ =["+b.toString().substring(5)+"];possiX =["+possiX.toString().substring(2)+"];possiY =["+possiY.toString().substring(2)+"];possiZ =["+possiZ.toString().substring(2)+"];TFlagNum =["+TFlagNum.toString().substring(2)+"];vv0x =["+vv0x.toString().substring(2)+"];vv0y =["+vv0y.toString().substring(2)+"];vv0z =["+vv0z.toString().substring(2)+"];vv1x =["+vv1x.toString().substring(2)+"];vv1y =["+vv1y.toString().substring(2)+"];vv1z =["+vv1z.toString().substring(2)+"];vv2x =["+vv2x.toString().substring(2)+"];vv2y =["+vv2y.toString().substring(2)+"];vv2z =["+vv2z.toString().substring(2)+"];vv3x =["+vv3x.toString().substring(2)+"];vv3y =["+vv3y.toString().substring(2)+"];vv3z =["+vv3z.toString().substring(2)+"];mirX =["+mirX+"];mirY =["+mirY+"];mirXY =["+mirXY+"];";sampleObject=JSON.stringify(u,null,100);var E=sampleObject.toString().replace(['"'],[""]);download(E=E.slice(0,-1),d,"text/csv"),console.log("savedxxxxxx"+d),camera.remove(objects[1]),camera.remove(objects[999]),scene.remove(objects[1]),scene.remove(objects[999]);var p="",x=0;for(r=2;r<cii+1;r++){var T;if(p+="newmtl Material."+(r-1+x)+"\n",p+="Ns 96.0000\n",p+="Ni 1.5000\n",p+="d 1.0000\n",p+="Tr 0.0000\n",p+="Tf 1.0000 1.0000 1.0000\n",p+="illum 2\n",p+="Ka 1.0000 1.0000 1.0000\n",p+="Kd "+((T="0x"+TColour[r])>>16)/255*.8+" "+(T>>8&255)/255*.8+" "+(255&T)/255*.8+" \n",p+="Ks 0.0000 0.0000 0.0000\n",p+="Ke 0.2000 0.2000 0.2000\n",void 0===objects[r+1e3]);else p+="newmtl Material."+(r-1+(x+=1))+"\n",p+="Ns 96.0000\n",p+="Ni 1.5000\n",p+="d 1.0000\n",p+="Tr 0.0000\n",p+="Tf 1.0000 1.0000 1.0000\n",p+="illum 2\n",p+="Ka 1.0000 1.0000 1.0000\n",p+="Kd "+((T="0x"+TColour[r])>>16)/255*.8+" "+(T>>8&255)/255*.8+" "+(255&T)/255*.8+" \n",p+="Ks 0.0000 0.0000 0.0000\n",p+="Ke 0.2000 0.2000 0.2000\n";if(void 0===objects[r+2e3]);else p+="newmtl Material."+(r-1+(x+=1))+"\n",p+="Ns 96.0000\n",p+="Ni 1.5000\n",p+="d 1.0000\n",p+="Tr 0.0000\n",p+="Tf 1.0000 1.0000 1.0000\n",p+="illum 2\n",p+="Ka 1.0000 1.0000 1.0000\n",p+="Kd "+((T="0x"+TColour[r])>>16)/255*.8+" "+(T>>8&255)/255*.8+" "+(255&T)/255*.8+" \n",p+="Ks 0.0000 0.0000 0.0000\n",p+="Ke 0.2000 0.2000 0.2000\n";if(void 0===objects[r+3e3]);else p+="newmtl Material."+(r-1+(x+=1))+"\n",p+="Ns 96.0000\n",p+="Ni 1.5000\n",p+="d 1.0000\n",p+="Tr 0.0000\n",p+="Tf 1.0000 1.0000 1.0000\n",p+="illum 2\n",p+="Ka 1.0000 1.0000 1.0000\n",p+="Kd "+((T="0x"+TColour[r])>>16)/255*.8+" "+(T>>8&255)/255*.8+" "+(255&T)/255*.8+" \n",p+="Ks 0.0000 0.0000 0.0000\n",p+="Ke 0.2000 0.2000 0.2000\n"}var y=new THREE.OBJExporter;count=0;var f=y.parse(scene,count);f="mtllib "+d+".mtl\n"+f,TColour.toString().substring(8),l=new Blob([f],{type:"text/plain"});saveAs(l,d+".obj");l=new Blob([p],{type:"text/plain"});saveAs(l,d+".mtl"),camera.add(objects[1]),camera.add(objects[999])}function loadALL(){if(null===localStorage.getItem("USERS")){numUsers=1,numUserL=0,userLocalName[0]="NONE",savedFiles=[". ","No file"],numSavedFiles=2,current=["NONE","No file",0],console.log(numSavedFiles," HoWWW1111111111111111111 ",userLocalName[0]);var e=[{current:current,userLocalName:["NONE"],numUsers:numUsers,savedFiles:savedFiles}];userObject=JSON.stringify(e,null,100);localStorage.setItem("USERS",userObject),uLocalName=current[0]}console.log(numSavedFiles," HoWWWW00000000000000 ",savedFiles[1])}function init(){if(null===localStorage.getItem("USERS"))loadALL();else{var e=localStorage.getItem("USERS"),o=JSON.parse(e);numSavedFiles=o[0].savedFiles.length,numUsers=o[0].userLocalName.length,userLocalName=o[0].userLocalName,current=o[0].current,numUserL=current[2],console.log(numSavedFiles," HoWWWW2222222222222222222"),uLocalName=current[0],savedFiles=o[0].savedFiles,currentFile=current[1],console.log(currentFile," ",uLocalName," ",numUserL)}console.log(numSavedFiles," HoWWWW00000000000000 ",savedFiles[1]),material11.side=THREE.DoubleSide,console.log(designs[0]+": "+designs[1]+": "+designs[2]+": "+designs[3]+": "+designs[4]+": "+designs[5]),floatingDiv=document.createElement("div"),floatingDiv.className="floating",document.body.appendChild(floatingDiv),projector=new THREE.Projector,scene=new THREE.Scene,scene2=new THREE.Scene;var t,a=window.innerWidth,i=window.innerHeight,r=a/i;(t=(new THREE.CubeTextureLoader).setPath("textures/cube/Archi/").load(["px.png","nx.png","py.png","ny.png","pz.png","nz.png"])).format=THREE.RGBFormat,camera=new THREE.PerspectiveCamera(45,r,.01,2e4),camera.up=new THREE.Vector3(0,1,0);var s=new THREE.AudioListener;camera.add(s);var n,c=new THREE.Audio(s);scene.add(c),(n=new THREE.AudioLoader).load("sounds/1.mp3",function(e){c.setBuffer(e),c.setLoop(!0),c.play()},function(e){console.log(e.loaded/e.total*100+"% loaded")},function(e){console.log("An error happened")}),cameraLeft=new THREE.PerspectiveCamera(45,r,.01,2e4),cameraLeft.position.set(0,0,3),cameraLeft.position.set(.1,-2.5,-30.195),cameraLeft.lookAt(scene.position),scene.add(cameraLeft),cameraRight=new THREE.PerspectiveCamera(45,r,.01,2e4),cameraRight.position.set(0,0,3),cameraRight.position.set(-.1,-2.5,-30.195),cameraRight.lookAt(scene.position),scene.add(cameraRight),scene.add(camera),console.log("Texture cube9 loaded"),scene.background=t,console.log("Texture cube10 loaded"),camera.position.set(0,-2.5,-30.195),camera.lookAt(scene.position),Detector.webgl||Detector.addGetWebGLMessage(),Detector.webgl?renderer=new THREE.WebGLRenderer({antialias:!0}):renderer=new THREE.CanvasRenderer,renderer.setClearColor(0),renderer.setSize(a,i),container=document.getElementById("ThreeJS"),renderer.gammaInput=!0,renderer.gammaOutput=!0,container.appendChild(renderer.domElement),document.addEventListener("mousedown",onDocumentMouseDown,!1),document.addEventListener("mousemove",onDocumentMouseMove,!1),document.addEventListener("keydown",onDocumentKeyDown,!1),document.addEventListener("keyup",onDocumentKeyUp,!1),document.addEventListener("keyup",function(e){audio.play()}),THREEx.WindowResize(renderer,camera),THREEx.FullScreen.bindKey({charCode:"m".charCodeAt(0)}),controls=new THREE.TrackballControls(camera,renderer.domElement),renderer.domElement.addEventListener("mousedown",onDocumentMouseDown,!1),renderer.domElement.addEventListener("mousemove",onDocumentMouseMove,!1),document.addEventListener("keydown",onDocumentKeyDown,!1),document.addEventListener("keyup",onDocumentKeyUp,!1),anaglyphRenderer=new THREE.AnaglyphEffect(renderer,a,i),stereoRenderer=new THREE.StereoEffect(renderer,a,i);new THREE.AmbientLight(12303291);lightsP[0]=new THREE.AmbientLight(16777215),lightsP[0].intensity=3,lightsP[1]=new THREE.PointLight(16777215,1,0),lightsP[2]=new THREE.PointLight(16777215,1,0),lightsP[1].intensity=3,lightsP[2].intensity=3,lightsP[0].position.set(0,200,0),lightsP[1].position.set(100,200,100),lightsP[2].position.set(-100,-200,-100),scene.add(lightsP[0]),scene.add(lightsP[1]),scene.add(lightsP[2]);var l=new THREE.DirectionalLight(16777215,1);l.position.set(1,551,1).normalize(),scene.add(l);new THREE.PointLight(16777215,2,800);var d=new THREE.SphereGeometry(.5,.5,.5),m=new THREE.Color("skyblue"),v=new THREE.Mesh(d,m);v.position.x=0,v.position.y=200,v.position.z=500,console.log("flag1"),ci=1,cii=1,materials[cii]=material15,gui=new dat.GUI,parameters={x:0,y:30,z:0,color:"#1133aa",opacity:3,REMOVE_DESIGN:"",Xsym:"OFF",Ysym:"OFF",Zsym:1,BTab:"XZ Table",Doption:"OFF",Rainbow:"Random",addTetraName:"Original",addTetraName2R:" ",addTetraName2:" ",addTetraName3:" ",addTetraName4:" ",addTextureName:" ",Load2:". ",LoadC:". ",DelFile:". ",saveOBJ2:" ",visible:"1"},text={Save_filename:"MyDesign",C_filename:"",Load_filename:"",D_filename:""},Xsym="OFF",Ysym="OFF",Zsym=1,lightsP[0].intensity=Zsym,lightsP[1].intensity=Zsym,lightsP[2].intensity=Zsym,l.intensity=Zsym,cubeColor=gui.addColor(parameters,"color").name("Color").listen();var b=uLocalName.length;folder1=gui.addFolder(" USER SETTINGS ");var g=folder1.add(parameters,"REMOVE_DESIGN",["Restart!","Design","Game Levels","Sfere's only"]).name("MODE").listen(),u=folder1.add(parameters,"Xsym",["OFF","ON"]).name("Xsymmetry").listen(),E=folder1.add(parameters,"Ysym",["OFF","ON"]).name("Ysymmetry").listen(),p=folder1.add(parameters,"Zsym",[.1,.5,.8,1,1.5,2,2.5,3]).name("Light Intensity").listen(),x=folder1.add(parameters,"BTab",["None","XZ Table"]).name("Build Table").listen(),T=folder1.add(parameters,"Doption",["OFF","Anaglyph","Side-by-Side"]).name("3 D view").listen(),y=folder1.add(parameters,"Rainbow",["OFF","Random","Greens","Reds","Blues","Greys","Yellow/Blue"]).name("Random Colors").listen(),f=folder1.add(parameters,"addTetraName",tNames).name("Solid Designs"),j=folder1.add(parameters,"addTetraName2R",tNames2).name("Frame Designs"),h=folder1.add(parameters,"addTetraName2",tNames3).name("Shapes and pipes"),w=folder1.add(parameters,"addTetraName3",tNames4).name("Art Designs"),R=folder1.add(parameters,"addTetraName4",tNames5).name("Spheres"),N=folder1.add(parameters,"addTextureName",texNames).name("Textures").listen(),O=folder1.add(parameters,"visible",["Silence","1","2","3","4","5","6","7","8","9","10"]).name("Listen to music").listen(),F=0;console.log(numSavedFiles," Ho1",b," userL ",savedFiles[1].slice(0,b));for(var H=1;H<numSavedFiles;H++){if(savedFiles[H].slice(0,b)==uLocalName){var z=savedFiles[H].length;F++,activeFiles[F-1]=savedFiles[H].slice(b-z),console.log(savedFiles[H]," YEA",H," userL ",savedFiles[1].slice(0,4))}"No file"==savedFiles[1]&&(activeFiles=[". ","No file"])}userLocalName[numUserL]=uLocalName,console.log(F," Ho2",b," activeFiles ",activeFiles[0]," uln ",uLocalName),console.log(F," Ho2",b," activeFiles ",activeFiles[1]," uln ",uLocalName);var S=gui.addFolder("Save Design");S.add(text,"Save_filename");var C=S.add(parameters,"saveOBJ2",[" "," Save... "]).name("Save").listen();console.log(numSavedFiles," Ho3",b," userL ",savedFiles[1]);var X=gui.addFolder("Load Design");X.add(text,"Load_filename");var L=X.add(parameters,"Load2",activeFiles).name("Load Designs").listen(),Y=gui.addFolder("Load Colours");Y.add(text,"C_filename");var M=Y.add(parameters,"LoadC",activeFiles).name("Load Colours").listen(),_=gui.addFolder("Delete Saved Design");_.add(text,"D_filename");var D=_.add(parameters,"DelFile",activeFiles).name("Delete Saved Design").listen();g.onChange(function(e){"Restart!"==e&&window.location.reload(!1),"Design"==e&&window.location.replace("file:////home/theunsdirkse-vanschalkwyk/Documents/TetraGenius/examples/TetraGeniusV008.Load.html"),"Game Levels"==e&&window.location.replace("file:////home/theunsdirkse-vanschalkwyk/Documents/TetraGenius/examples/TetraGeniusV008.Game.html"),"Sfere's only"==e&&window.location.replace("file:////home/theunsdirkse-vanschalkwyk/Documents/TetraGenius/examples/compact.html")}),u.onChange(function(e){Xsym=e}),E.onChange(function(e){Ysym=e}),p.onChange(function(e){Zsym=e,lightsP[0].intensity=Zsym,lightsP[1].intensity=Zsym,lightsP[2].intensity=Zsym,l.intensity=Zsym}),x.onChange(function(e){if("XZ Table"==(BTab=e)){scene.remove(objectT),scene.remove(objectT1);var o=new THREE.OBJLoader;o.load("models/obj/tableB.obj",function(e){e.material=lambert,e.traverse(function(e){e.material=new THREE.MeshLambertMaterial({color:material11.color})}),objectT1=e.clone(),objectT1.material=e.material.clone();var o=camera.position.x,t=camera.position.y,a=camera.position.z;objectT1.rotation.x=Math.PI,objectT1.position.y=-7.8,scene.add(objectT1),camera.position.set(o,t+8,a),camera.up=new THREE.Vector3(0,1,0)}),o.load("models/obj/grass.obj",function(e){e.material=lambert,e.traverse(function(e){e.material=new THREE.MeshLambertMaterial({color:material11.color,map:texture3})}),objectT=e.clone(),objectT.material=e.material.clone();var o=camera.position.x,t=camera.position.y,a=camera.position.z;objectT.position.y=.55,objectT.rotation.y=Math.PI,scene.add(objectT),camera.position.set(o,t+8,a),camera.up=new THREE.Vector3(0,1,0)})}"None"==e&&(scene.remove(objectT),scene.remove(objectT1),console.log("Table removed"))}),T.onChange(function(e){Doption=e}),y.onChange(function(e){Rainbow=e}),f.onChange(function(e){addTetraName=e,j.onChange=!1,h.onChange=!1,w.onChange=!1,R.onChange=!1,2!=xxx&&3!=xxx&&4!=xxx&&5!=xxx&&(xxx=1," "!=folder1.__controllers[8]&&folder1.__controllers[8].setValue(" "),j.onChange=!1," "!=folder1.__controllers[9]&&folder1.__controllers[9].setValue(" "),h.onChange=!1," "!=folder1.__controllers[10]&&folder1.__controllers[10].setValue(" "),w.onChange=!1," "!=folder1.__controllers[11]&&folder1.__controllers[11].setValue(" "),R.onChange=!1,addTetraFlag=tNames.indexOf(addTetraName),camera.remove(objects[1]),lightsP[0].color.setHex(5592405),console.log(addTetraName+" addTetraName "+addTetraFlag),addTetraF())}),j.onChange(function(e){addTetraName2R=e,f.onChange=!1,h.onChange=!1,w.onChange=!1,R.onChange=!1,1!=xxx&&3!=xxx&&4!=xxx&&5!=xxx&&(xxx=2," "!=folder1.__controllers[7]&&folder1.__controllers[7].setValue(" "),f.onChange=!1," "!=folder1.__controllers[9]&&folder1.__controllers[9].setValue(" "),h.onChange=!1," "!=folder1.__controllers[10]&&folder1.__controllers[10].setValue(" "),w.onChange=!1," "!=folder1.__controllers[11]&&folder1.__controllers[11].setValue(" "),R.onChange=!1,addTetraFlag=tetNames.indexOf(addTetraName2R),camera.remove(objects[1]),lightsP[0].color.setHex(5592405),console.log(addTetraName2R+" addTetraName2R "+addTetraFlag),addTetraF())}),h.onChange(function(e){addTetraName2=e,f.onChange=!1,j.onChange=!1,w.onChange=!1,R.onChange=!1,1!=xxx&&2!=xxx&&4!=xxx&&5!=xxx&&(xxx=3," "!=folder1.__controllers[7]&&folder1.__controllers[7].setValue(" "),f.onChange=!1," "!=folder1.__controllers[8]&&folder1.__controllers[8].setValue(" "),j.onChange=!1," "!=folder1.__controllers[10]&&folder1.__controllers[10].setValue(" "),w.onChange=!1," "!=folder1.__controllers[11]&&folder1.__controllers[11].setValue(" "),R.onChange=!1,addTetraFlag=tetNames.indexOf(addTetraName2),camera.remove(objects[1]),lightsP[0].color.setHex(5592405),console.log(addTetraName2+" addTetraName2 "+addTetraFlag),addTetraF())}),w.onChange(function(e){addTetraName3=e,f.onChange=!1,j.onChange=!1,h.onChange=!1,R.onChange=!1,1!=xxx&&2!=xxx&&3!=xxx&&5!=xxx&&(xxx=4," "!=folder1.__controllers[7]&&folder1.__controllers[7].setValue(" "),f.onChange=!1," "!=folder1.__controllers[8]&&folder1.__controllers[8].setValue(" "),j.onChange=!1," "!=folder1.__controllers[9]&&folder1.__controllers[9].setValue(" "),h.onChange=!1," "!=folder1.__controllers[11]&&folder1.__controllers[11].setValue(" "),R.onChange=!1,addTetraFlag=tetNames.indexOf(addTetraName3),camera.remove(objects[1]),lightsP[0].color.setHex(5592405),console.log(addTetraName3+" addTetraName3 "+addTetraFlag),addTetraF())}),R.onChange(function(e){addTetraName4=e,f.onChange=!1,j.onChange=!1,h.onChange=!1,w.onChange=!1,1!=xxx&&2!=xxx&&3!=xxx&&4!=xxx&&(xxx=5," "!=folder1.__controllers[7]&&folder1.__controllers[7].setValue(" "),f.onChange=!1," "!=folder1.__controllers[8]&&folder1.__controllers[8].setValue(" "),j.onChange=!1," "!=folder1.__controllers[9]&&folder1.__controllers[9].setValue(" "),h.onChange=!1," "!=folder1.__controllers[10]&&folder1.__controllers[10].setValue(" "),w.onChange=!1,addTetraFlag=tetNames.indexOf(addTetraName4),camera.remove(objects[1]),lightsP[0].color.setHex(5592405),addTetraF())}),N.onChange(function(e){addTextureName=e,"Central Africa"==addTextureName&&(texFlag=1),"Antartica"==addTextureName&&(texFlag=2),"Eurasia"==addTextureName&&(texFlag=3),"Australia"==addTextureName&&(texFlag=4),"Canada"==addTextureName&&(texFlag=5),"Americas"==addTextureName&&(texFlag=6),"EsherStair"==addTextureName&&(texFlag=7),"GoldCopper"==addTextureName&&(texFlag=8),"BlueIce"==addTextureName&&(texFlag=9),"Silver"==addTextureName&&(texFlag=10),"Glass"==addTextureName&&(texFlag=11),"Green"==addTextureName&&(texFlag=12),"Sandstone"==addTextureName&&(texFlag=14),"Leaf"==addTextureName&&(texFlag=14),"Heart"==addTextureName&&(texFlag=15),"Flowers"==addTextureName&&(texFlag=16)," "==addTextureName&&(texFlag=0),camera.remove(objects[1]),lightsP[0].color.setHex(5592405),addTetraF()}),L.onChange(function(e){if(". "==e||"No file"==e);else{var o=e;text.Load_filename=o,Load2=userLocalName[numUserL]+text.Load_filename;for(var t=0;t<Object.keys(gui.__folders).length;t++)for(var a=Object.keys(gui.__folders)[t],i=0;i<gui.__folders[a].__controllers.length;i++)gui.__folders[a].__controllers[i].updateDisplay();parameters.Load2=" Loaded",console.log("loadingQQQz............."+Load2),loaded=LoadUserFile(Load2),console.log("loadingQQQ............."+Load2),gui.close(),gui.open()}}),M.onChange(function(e){if(". "==e||"No file"==e);else{var o;LoadC=e,text.C_filename=e,o=userLocalName[numUserL]+text.Load_filename;for(var t=0;t<Object.keys(gui.__folders).length;t++)for(var a=Object.keys(gui.__folders)[t],i=0;i<gui.__folders[a].__controllers.length;i++)gui.__folders[a].__controllers[i].updateDisplay();parameters.CLoad2=" Loaded",console.log("loadingQQQ............."+o),loaded=LoadUserFileC(o,objects),console.log("loadingQQQ............."+e),gui.close(),gui.open()}}),O.onChange(function(e){visible=e,c.stop(),visible,"1"==visible&&(playingNow=musicC[1]),"2"==visible&&(playingNow=musicC[2]),"3"==visible&&(playingNow=musicC[3]),"4"==visible&&(playingNow=musicC[4]),"5"==visible&&(playingNow=musicC[5]),"6"==visible&&(playingNow=musicC[6]),"7"==visible&&(playingNow=musicC[7]),"8"==visible&&(playingNow=musicC[8]),"9"==visible&&(playingNow=musicC[9]),"10"==visible&&(playingNow=musicC[10]),n.load(playingNow,function(e){c.setBuffer(e),c.play()},function(e){console.log(e.loaded/e.total*100+"% loaded"),console.log(playingNow+" loaded")},function(e){console.log("An error happened")})}),C.onChange(function(e){var o=localStorage.getItem("USERS"),t=JSON.parse(o);if(savedFiles=t[0].savedFiles,numSavedFiles=t[0].savedFiles.length,"No file"==savedFiles[1]){var a=text.Save_filename,i=userLocalName[numUserL]+a;savedFiles[1]=i}else{console.log(numSavedFiles," HoWWWWWWWWW5555555555555555555555");a=text.Save_filename;console.log("saving............."),text.Save_filename=a;i=userLocalName[numUserL]+a;savedFiles[numSavedFiles]=i,console.log(userLocalName[numUserL]+" Saving users file: "+numUserL);var r=i;console.log(i+"ddddddddddddddddddddddddddd")}a=text.Save_filename,r=i=userLocalName[numUserL]+a;exportToObj(userLocalName[numUserL],a,r,numUsers,numUserL),console.log(i+"vvvvvvvvvvvvvvvvvvvvvvvvvvvv"),numSavedFiles+=1,parameters.Load2=savedFiles,parameters.LoadC=savedFiles,parameters.DelFile=savedFiles,parameters.uLocalName=userLocalName;for(var s=0;s<Object.keys(gui.__folders).length;s++)for(var n=Object.keys(gui.__folders)[s],c=0;c<gui.__folders[n].__controllers.length;c++)gui.__folders[n].__controllers[c].updateDisplay();parameters.saveOBJ2=[" "," Save... "],parameters.Load2=savedFiles,parameters.LoadC=savedFiles,parameters.DelFile=savedFiles,parameters.uLocalName=userLocalName,M.updateDisplay(),console.log(".........",savedFiles[1],"........",savedFiles[2])}),D.onChange(function(e){gui.close();var o=e;console.log("saving............."),text.D_filename=o;var t=savedFiles.indexOf(o);console.log(t+" delete this locally"),localStorage.removeItem(userLocalName[numUserL]+o),savedFiles.splice(t,1),console.log(savedFiles[0]," ",savedFiles[1]),numSavedFiles-=1;var a=[{Rainbow:Rainbow,savedFiles:savedFiles,tetraName:tetraName}];userObject=JSON.stringify(a,null,100);localStorage.setItem("USERS",userObject),parameters.Load2=savedFiles,parameters.LoadC=savedFiles,parameters.DelFile=savedFiles,parameters.uLocalSelect=userLocalName;for(var i=0;i<Object.keys(gui.__folders).length;i++)for(var r=Object.keys(gui.__folders)[i],s=0;s<gui.__folders[r].__controllers.length;s++)gui.__folders[r].__controllers[s].updateDisplay();gui.open(),localStorage.removeItem(userLocalName[numUserL]+o),window.location.reload(!1)}),cubeColor.onChange(function(e){materials[cii]=material15,materials[cii].color.setHex(e.replace("#","0x"))}),gui.open(),console.log(Rainbow),parameters.Rainbow=Rainbow,parameters.Load2=savedFiles,parameters.LoadC=savedFiles,parameters.DelFile=savedFiles,parameters.uLocalName=userLocalName[numUserL];for(H=0;H<Object.keys(gui.__folders).length;H++)for(var A=Object.keys(gui.__folders)[H],I=0;I<gui.__folders[A].__controllers.length;I++)gui.__folders[A].__controllers[I].updateDisplay();addTetra();for(H=0;H<Object.keys(gui.__folders).length;H++)for(A=Object.keys(gui.__folders)[H],I=0;I<gui.__folders[A].__controllers.length;I++)gui.__folders[A].__controllers[I].updateDisplay();d=new THREE.SphereGeometry(.35,.35,.35);var k=new THREE.Mesh(d,new THREE.MeshBasicMaterial({color:15658734}));scene.add(k),mouseSphere.push(k),renderer.autoClear=!1}function updateGuiT(){parameters.Rainbow=Rainbow,parameters.Load2=savedFiles,parameters.LoadC=savedFiles,parameters.DelFile=savedFiles,parameters.uLocalName=[" ","Create_User"],parameters.uLocalSelect=userLocalName;for(var e=0;e<Object.keys(gui.__folders).length;e++)for(var o=Object.keys(gui.__folders)[e],t=0;t<gui.__folders[o].__controllers.length;t++)gui.__folders[o].__controllers[t].updateDisplay();console.log("should update the gui????")}function addTetra(){var e=new THREE.LoadingManager;e.onProgress=function(e,o,t){},texture2=(new THREE.TextureLoader).load(textures[texFlag]),texture3=(new THREE.TextureLoader).load("textures/grass.jpg"),console.log(texFlag," texFlag");(i=new THREE.ImageLoader(e)).load(textures[texFlag],function(e){}),lambert=new THREE.MeshLambertMaterial({color:material15.color,map:texture2}),lambert=new THREE.MeshLambertMaterial({color:1127338,overdraw:.5,map:texture2});var o=new THREE.TextureLoader,t=o.load("roughness_map.jpg"),a=o.load("textures/envmap.png");a.mapping=THREE.SphericalReflectionMapping;var s=[new THREE.MeshBasicMaterial({color:65535,wireframe:!0,side:THREE.DoubleSide}),new THREE.MeshBasicMaterial({color:16711680,blending:THREE.AdditiveBlending}),new THREE.MeshLambertMaterial({color:16777215,overdraw:.5}),new THREE.MeshLambertMaterial({color:16777215,overdraw:.5}),new THREE.MeshNormalMaterial({overdraw:.5}),new THREE.MeshBasicMaterial({envMap:t,overdraw:.5,side:THREE.DoubleSide}),new THREE.MeshBasicMaterial({envMap:a,overdraw:.5})];0==addTetraFlag&&(console.log("flag1111"),(i=new THREE.OBJLoader(e)).load("models/obj/arrows.obj",function(e){e.material=lambert,e.traverse(function(e){e.material=s[3]}),e.scale.x=.99,e.scale.y=.99,e.scale.z=.99,objects[999]=e.clone(),objects[999].material=e.material.clone();Math.PI;var o=Math.floor(window.innerWidth/60);console.log(o);var t=window.innerHeight/80,a=camera.position.x,i=camera.position.y,r=camera.position.z;objects[999].scale.x=.8,objects[999].scale.y=.8,objects[999].scale.z=.8,objects[999].position.x=0,objects[999].position.y=0,objects[999].position.z=0,objects[999].position.applyMatrix4(camera.matrixWorld),objects[999].position.x=objects[999].position.x-o/1.3,objects[999].position.z=objects[999].position.z-16,objects[999].position.y=objects[999].position.y+t,camera.position.set(a,i,r)}),i.load("models/obj/TextLess.obj",function(e){e.material=lambert,e.traverse(function(e){e.material=new THREE.MeshLambertMaterial({color:13243,overdraw:.5,map:texture2})}),e.scale.x=.99,e.scale.y=.99,e.scale.z=.99,objects[3]=e.clone(),objects[3].material=e.material.clone();Math.PI;var o=Math.floor(window.innerWidth/60);console.log(o);window.innerHeight,objects[3].position.x,objects[3].position.y,objects[3].position.z;objects[3].position.x=0,objects[3].position.y=0,objects[3].position.z=0,objects[3].position.applyMatrix4(camera.matrixWorld),objects[3].position.x=objects[3].position.x,objects[3].position.z=objects[3].position.z-3,objects[3].position.y=objects[3].position.y+4,camera.add(objects[3])}),(i=new THREE.OBJLoader(e)).load(designs[0],function(e){e.traverse(function(e){e.material=new THREE.MeshLambertMaterial({color:1127338,overdraw:.5,map:texture2})}),e.scale.x=.99,e.scale.y=.99,e.scale.z=.99,objects[2]=e.clone(),objects[2].material=e.material.clone(),objects[1]=e.clone(),objects[1].material=e.material.clone(),object2=e.clone(),object2.material=e.material.clone();Math.PI;var o=Math.floor(window.innerWidth/60);console.log(o);var t=window.innerHeight/80,a=camera.position.x,i=camera.position.y,r=camera.position.z;camera.position.set(0,-2.5,-30.195),objects[1].scale.x=.9,objects[1].scale.y=.9,objects[1].scale.z=.9,objects[1].position.x=0,objects[1].position.y=0,objects[1].position.z=0,objects[1].position.applyMatrix4(camera.matrixWorld),objects[1].position.x=objects[1].position.x-o/1.3,objects[1].position.z=objects[1].position.z-8,objects[1].position.y=objects[1].position.y+t/1.3,camera.add(objects[1]),camera.position.set(a,i,r),console.log(cii+" numbr"),targetOBJ.push(objects[1]),targetOBJ.push(objects[2]),cii=1;(new THREE.TextureLoader).load("textures/sprite.png"),new THREE.MeshLambertMaterial({color:16711680,vertexColors:THREE.FaceColors,shading:THREE.FlatShading,polygonOffset:!0,polygonOffsetUnits:1,polygonOffsetFactor:1});var s=new THREE.Geometry;s.vertices=[new THREE.Vector3(-2,0,1),new THREE.Vector3(2,0,1),new THREE.Vector3(0,-2,-1),new THREE.Vector3(0,2,-1)],s.faces=[new THREE.Face3(2,1,0),new THREE.Face3(1,2,3),new THREE.Face3(0,3,2),new THREE.Face3(3,0,1)],s.computeFaceNormals(),octa=new THREE.Mesh(s,material11);var n=new THREE.Mesh(s,new THREE.MeshBasicMaterial({color:3342387,wireframe:!0,transparent:!0,opacity:1}));octa.add(n),scene.add(octa),targetList.push(octa),console.log(("000000"+material11.color.getHex().toString(16)).slice(-6)+"gethexcol"),TColour[cii]=("000000"+material11.color.getHex().toString(16)).slice(-6)},function(e){if(e.lengthComputable)e.loaded,e.total},function(e){}));var i=new THREE.OBJLoader;material111=new THREE.MeshLambertMaterial({color:3355443,transparent:!0,opacity:0}),i.load("models/obj/tableB.obj",function(e){e.material=lambert,e.traverse(function(e){e.material=new THREE.MeshLambertMaterial({color:material11.color})}),objectT1=e.clone(),objectT1.material=e.material.clone();var o=camera.position.x,t=camera.position.y,a=camera.position.z;objectT1.rotation.x=Math.PI,objectT1.position.y=-7.8,scene.add(objectT1),camera.position.set(o,t+8,a),camera.up=new THREE.Vector3(0,1,0)}),i.load("models/obj/grass.obj",function(e){e.material=lambert,e.traverse(function(e){e.material=new THREE.MeshLambertMaterial({color:material15.color,map:texture3})}),objectT=e.clone(),objectT.material=e.material.clone();var o=camera.position.x,t=camera.position.y,a=camera.position.z;objectT.position.y=.55,objectT.rotation.y=Math.PI,scene.add(objectT),camera.position.set(o,t+8,a),camera.up=new THREE.Vector3(0,1,0)})}function addTetraLC(e,o){var t=localStorage.getItem(o);retrievedObjectA=JSON.parse(t);retrievedObjectA[0].possiX[e],retrievedObjectA[0].possiY[e],retrievedObjectA[0].possiZ[e],retrievedObjectA[0].rotX[e],retrievedObjectA[0].rotY[e],retrievedObjectA[0].rotZ[e];1==mirX[e]&&(Xsym="ON"),"ON"==Xsym&&(console.log("YayMirX!"),mirX[e]=1),1==mirY[e]&&(Ysym="ON"),"ON"==Ysym&&(mirY[e]=1),1==mirXY[e]&&(Xsym="ON",Ysym="ON"),"ON"==Ysym&"ON"==Xsym&&(mirXY[e]=1),(new THREE.LoadingManager).onProgress=function(e,o,t){};console.log(retrievedObjectA[0].possiX[e]," possi "),vv0x[e]=retrievedObjectA[0].vv0x[e],vv0y[e]=retrievedObjectA[0].vv0y[e],vv0z[e]=retrievedObjectA[0].vv0z[e],vv1x[e]=retrievedObjectA[0].vv1x[e],vv1y[e]=retrievedObjectA[0].vv1y[e],vv1z[e]=retrievedObjectA[0].vv1z[e],vv2x[e]=retrievedObjectA[0].vv2x[e],vv2y[e]=retrievedObjectA[0].vv2y[e],vv2z[e]=retrievedObjectA[0].vv2z[e],vv3x[e]=retrievedObjectA[0].vv3x[e],vv3y[e]=retrievedObjectA[0].vv3y[e],vv3z[e]=retrievedObjectA[0].vv3z[e],console.log(vv0x[e]," x ",vv3z," z ",vv2y," y ");var a=new THREE.Geometry,i=vv0y+vv1y+vv2y+vv3y,r=vv0x+vv1x+vv2x+vv3x;if(a.vertices=[new THREE.Vector3(vv0x[e],vv0y[e],vv0z[e]),new THREE.Vector3(vv1x[e],vv1y[e],vv1z[e]),new THREE.Vector3(vv2x[e],vv2y[e],vv2z[e]),new THREE.Vector3(vv3x[e],vv3y[e],vv3z[e])],a.faces=[new THREE.Face3(2,1,0),new THREE.Face3(1,2,3),new THREE.Face3(0,3,2),new THREE.Face3(3,0,1)],a.computeFaceNormals(),octa=new THREE.Mesh(a,material11),console.log(e+"octa------------cii"),octa.name=e,octa.userData="NONO",scene.add(octa),targetList.push(octa),.8<Math.abs(xi)&"ON"==Xsym){a=new THREE.Geometry,r=vv0x+vv1x+vv2x+vv3x;a.vertices=[new THREE.Vector3(-vv0x,vv0y,vv0z),new THREE.Vector3(-vv1x,vv1y,vv1z),new THREE.Vector3(-vv2x,vv2y,vv2z),new THREE.Vector3(-vv3x,vv3y,vv3z)],a.faces=[new THREE.Face3(0,1,2),new THREE.Face3(3,2,1),new THREE.Face3(2,3,0),new THREE.Face3(1,0,3)],octaX=new THREE.Mesh(a,material11),octaX.name=e+1e3,octaX.userData="NONO",scene.add(octaX),targetList.push(octaX)}if(.8<Math.abs(yi)&"ON"==Ysym){a=new THREE.Geometry,i=vv0y+vv1y+vv2y+vv3y;a.vertices=[new THREE.Vector3(vv0x,-vv0y,vv0z),new THREE.Vector3(vv1x,-vv1y,vv1z),new THREE.Vector3(vv2x,-vv2y,vv2z),new THREE.Vector3(vv3x,-vv3y,vv3z)],a.faces=[new THREE.Face3(0,1,2),new THREE.Face3(3,2,1),new THREE.Face3(2,3,0),new THREE.Face3(1,0,3)],octaY=new THREE.Mesh(a,material11),octaY.name=e+2e3,scene.add(octaY),octaY.userData="NONO",targetList.push(octaY)}if("ON"==Xsym&"ON"==Ysym){a=new THREE.Geometry,i=vv0y+vv1y+vv2y+vv3y,r=vv0x+vv1x+vv2x+vv3x;a.vertices=[new THREE.Vector3(-vv0x,-vv0y,vv0z),new THREE.Vector3(-vv1x,-vv1y,vv1z),new THREE.Vector3(-vv2x,-vv2y,vv2z),new THREE.Vector3(-vv3x,-vv3y,vv3z)],a.faces=[new THREE.Face3(2,1,0),new THREE.Face3(1,2,3),new THREE.Face3(0,3,2),new THREE.Face3(3,0,1)],.1<r&i<-.1&&(a.faces=[new THREE.Face3(0,1,2),new THREE.Face3(3,2,1),new THREE.Face3(2,3,0),new THREE.Face3(1,0,3)]),r<-.1&.1<i&&(a.faces=[new THREE.Face3(0,1,2),new THREE.Face3(3,2,1),new THREE.Face3(2,3,0),new THREE.Face3(1,0,3)]),r<-.1&i<-.1&&(a.faces=[new THREE.Face3(2,1,0),new THREE.Face3(1,2,3),new THREE.Face3(0,3,2),new THREE.Face3(3,0,1)]),a.computeFaceNormals(),octaXY=new THREE.Mesh(a,material11),octaXY.name=e+3e3,octaXY.userData="NONO",scene.add(octaXY),targetList.push(octaXY)}scene.traverse(function(e){e instanceof THREE.Object3D&&(e.userData="NONO")}),scene2.traverse(function(e){e instanceof THREE.Object3D&&(e.userData="NONO")})}function addTetraL(o){var t=retrievedObjectA[0].possiX[o],a=retrievedObjectA[0].possiY[o],i=retrievedObjectA[0].possiZ[o],r=retrievedObjectA[0].rotX[o],s=retrievedObjectA[0].rotY[o],n=retrievedObjectA[0].rotZ[o],e=new THREE.LoadingManager;e.onProgress=function(e,o,t){};console.log(retrievedObjectA[0].possiX[o]," possi "),42<addTetraFlag&&(addTetraFlag=0),-1!=addTetraFlag&&new THREE.OBJLoader(e).load(designs[addTetraFlag],function(e){e.traverse(function(e){}),e.scale.x=.99,e.scale.y=.99,e.scale.z=.99,objects[o]=e.clone(),console.log(o,"objectsload"),xi=retrievedObjectA[0].possiX[o],yi=retrievedObjectA[0].possiY[o],zi=retrievedObjectA[0].possiZ[o],angleObx=retrievedObjectA[0].rotX[o],angleOby=retrievedObjectA[0].rotY[o],angleObz=retrievedObjectA[0].rotZ[o];Math.PI,Math.floor(window.innerWidth/1910),window.innerHeight;objects[o].position.applyMatrix4(camera.matrixWorld),objects[o].position.x=t,objects[o].position.z=i,objects[o].position.y=a,objects[o].rotation.x=r,objects[o].rotation.y=s,objects[o].rotation.z=n,objects[o].position.y=yi,objects[o].position.z=zi,objects[o].position.x=xi,objects[o].rotation.x=angleObx,objects[o].rotation.y=angleOby,objects[o].rotation.z=angleObz,objects[o].name=o,objects[o].userData=o,objects[o].userSTL="Y",objects[o].userCol=TColour[o],scene2.add(objects[o]),scene.add(objects[o]),1==mirX[o]&&(Xsym="ON"),"ON"==Xsym&&(console.log("YayMirX!"),mirX[o]=1),1==mirY[o]&&(Ysym="ON"),"ON"==Ysym&&(mirY[o]=1),1==mirXY[o]&&(Xsym="ON",Ysym="ON"),"ON"==Ysym&"ON"==Xsym&&(mirXY[o]=1),console.log(o+"numbr"+objects[o].nameX+"Yay"),console.log(o+"numbr"+objects[o].name+"Nay"),targetOBJ.push(objects[o].name),TColour[o]=("000000"+material15.color.getHex().toString(16)).slice(-6),console.log(Xsym),.8<Math.abs(xi)&"ON"==Xsym&&(objects[o+1e3]=e.clone(),lambert=new THREE.MeshLambertMaterial({color:TColour[o].color,map:texture2}),objects[o+1e3].traverse(function(e){}),objects[o+1e3].position.y=yi,objects[o+1e3].position.z=zi,objects[o+1e3].position.x=-xi,objects[o+1e3].rotation.x=angleObx,objects[o+1e3].rotation.y=-angleOby,objects[o+1e3].rotation.z=angleObz,objects[o+1e3].name=o+1e3,objects[o+1e3].userData=o+1e3,scene2.add(objects[o+1e3]),scene.add(objects[o+1e3]),objects[o+1e3].userCol=TColour[o],console.log(o+"numbr"+objects[o+1e3].name),targetOBJ.push(objects[o+1e3])),.8<Math.abs(yi)&"ON"==Ysym&&(objects[o+2e3]=e.clone(),lambert=new THREE.MeshLambertMaterial({color:TColour[o].color,map:texture2}),objects[o+2e3].traverse(function(e){}),objects[o+2e3].position.y=-yi,objects[o+2e3].position.z=zi,objects[o+2e3].position.x=xi,objects[o+2e3].rotation.x=-angleObx,objects[o+2e3].rotation.y=angleOby,objects[o+2e3].rotation.z=angleObz,objects[o+2e3].name=o+2e3,objects[o+2e3].userData=o+2e3,scene2.add(objects[o+2e3]),scene.add(objects[o+2e3]),objects[o+2e3].userCol=TColour[o],console.log(o+"numbr"+objects[o+2e3].name),targetOBJ.push(objects[o+2e3])),.8<Math.abs(yi)&.8<Math.abs(xi)&"ON"==Xsym&"ON"==Ysym&&(objects[o+3e3]=e.clone(),lambert=new THREE.MeshLambertMaterial({color:TColour[o].color,map:texture2}),objects[o+3e3].traverse(function(e){}),objects[o+3e3].position.y=-yi,objects[o+3e3].position.z=zi,objects[o+3e3].position.x=-xi,objects[o+3e3].rotation.x=-angleObx,objects[o+3e3].rotation.y=-angleOby,objects[o+3e3].rotation.z=angleObz,objects[o+3e3].name=o+3e3,objects[o+3e3].userData=o+3e3,objects[o+3e3].userCol=TColour[o],scene.add(objects[o+3e3]),scene3.add(objects[o+3e3]),console.log(o+"numbr"+objects[o+3e3].name),targetOBJ.push(objects[o+3e3])),objects[o].name=o,targetOBJ.push(objects[o].name)},function(e){if(e.lengthComputable)e.loaded,e.total},function(e){})}function addTetraF(){texture2=(new THREE.TextureLoader).load(textures[texFlag]),new THREE.ImageLoader(e).load(textures[texFlag],function(e){});var e=new THREE.LoadingManager;e.onProgress=function(e,o,t){};new THREE.TextureLoader;var o=objects[1].position.x,t=objects[1].position.y,a=objects[1].position.z;camera.remove(objects[1]);camera.position.x,camera.position.y,camera.position.z;42<addTetraFlag&&(addTetraFlag=0),-1!=addTetraFlag&&new THREE.OBJLoader(e).load(designs[addTetraFlag],function(e){e.material=lambert,e.traverse(function(e){e.material=new THREE.MeshLambertMaterial({color:material15.color,transparent:!0,opacity:.9})}),e.scale.x=.99,e.scale.y=.99,e.scale.z=.99,camera.remove(objects[1]),scene.remove(objects[1]),objects[1]=e.clone(),objects[1].material=e.material.clone(),object2=e.clone(),object2.material=e.material.clone();Math.PI,Math.floor(window.innerWidth/1910),window.innerHeight;objects[1].scale.x=.9,objects[1].scale.y=.9,objects[1].scale.z=.9,objects[1].position.applyMatrix4(camera.matrixWorld),objects[1].position.x=o,objects[1].position.z=a,objects[1].position.y=t,scene.add(objects[1]),camera.add(objects[1]),console.log(" numbrx Design "+designs[addTetraFlag]),targetOBJ.push(objects[1]);new THREE.MeshLambertMaterial({color:16711680,vertexColors:THREE.FaceColors,shading:THREE.FlatShading,polygonOffset:!0,polygonOffsetUnits:1,polygonOffsetFactor:1});scene.add(octa),targetList.push(octa),TColour[cii]=("000000"+material15.color.getHex().toString(16)).slice(-6)},function(e){if(e.lengthComputable)e.loaded,e.total},function(e){})}function isOdd(e){return e%2}function onWindowResize(){windowHalfX=window.innerWidth/2,windowHalfY=window.innerHeight/2,camera.aspect=window.innerWidth/window.innerHeight,camera.updateProjectionMatrix(),renderer.setSize(window.innerWidth,window.innerHeight)}function onDocumentMouseMove(e){mouse.x=e.clientX/window.innerWidth*2-1,mouse.y=-e.clientY/window.innerHeight*2+1,mouseX=mouse.x,mouseY=mouse.y}function onDocumentMouseDown(e){switch(console.log("Click."),e.button){case 0:Tadd=1;case 1:break;case 2:Tadd=0}mouse.x=e.clientX/window.innerWidth*2-1,mouse.y=-e.clientY/window.innerHeight*2+1,checkSelection()}function checkSelection(){var e=new THREE.Vector3(mouse.x,mouse.y,.999);e.unproject(camera);var o=new THREE.Raycaster(camera.position,e.sub(camera.position).normalize()).intersectObjects(targetList);if(0<o.length&1==Tadd){console.log("function checkSelection(){"+cii);var t=INTERSECTED.object.geometry,a=INTERSECTED.face,i=(a.normal.x,a.normal.y,a.normal.z,t.vertices),r=i[0],s=i[1],n=i[2],c=i[3];if(a.a+a.b+a.c==6){var l=s,d=new THREE.Vector3((n.x+c.x)/2+((n.x+c.x)/2-r.x),(n.y+c.y)/2+((n.y+c.y)/2-r.y),(n.z+c.z)/2+(n.z+c.z)/2-r.z),m=n,v=c;console.log("Face 6 @ "+v.x)}if(a.a+a.b+a.c==5){l=new THREE.Vector3((c.x+n.x)/2+((c.x+n.x)/2-s.x),(c.y+n.y)/2+((c.y+n.y)/2-s.y),(c.z+n.z)/2+(c.z+n.z)/2-s.z),d=r,m=n,v=c;console.log("Face 5 @ "+l.x+" "+d.x)}if(a.a+a.b+a.c==4){l=r,d=s,m=c,v=new THREE.Vector3((r.x+s.x)/2+((r.x+s.x)/2-n.x),(r.y+s.y)/2+((r.y+s.y)/2-n.y),(r.z+s.z)/2+(r.z+s.z)/2-n.z);console.log("Face 4 @ "+l.x)}if(a.a+a.b+a.c==3){l=r,d=s,m=new THREE.Vector3((r.x+s.x)/2+((r.x+s.x)/2-c.x),(r.y+s.y)/2+((r.y+s.y)/2-c.y),(r.z+s.z)/2+(r.z+s.z)/2-c.z),v=n;console.log("Face 3 @ "+l.x)}sx=r.x+s.x+n.x+c.x,sy=r.y+s.y+n.y+c.y,sz=r.z+s.z+n.z+c.z,xi=(l.x+d.x+m.x+v.x)/4,yi=(l.y+d.y+m.y+v.y)/4,zi=(l.z+d.z+m.z+v.z)/4,angleObx=0,angleOby=0,angleObz=0;var b=Math.PI;if(xi/4==Math.floor(xi/4)&(yi-1)/4==Math.floor((yi-1)/4)&(zi-3)/4==Math.floor((zi-3)/4)&&(angleObx=b/2,console.log("gggggggggg66666666666666")),(xi+2)/4==Math.floor((xi+2)/4)&(yi-2)/4==Math.floor((yi-2)/4)&zi/4==Math.floor(zi/4)&&(angleObx=b,console.log("gggggggggg4444444444444444")),(xi-2)/4==Math.floor((xi-2)/4)&(yi-3)/4==Math.floor((yi-3)/4)&(zi-3)/4==Math.floor((zi-3)/4)&&(angleObx=b/2,console.log("ggggggggggg1111111111111111111")),(xi-2)/4==Math.floor((xi-2)/4)&(yi-1)/4==Math.floor((yi-1)/4)&(zi-3)/4==Math.floor((zi-3)/4)&&(angleObx=b/2,angleObz=b/2,console.log("ffffffff888888888888888888")),xi/4==Math.floor(xi/4)&yi/4==Math.floor(yi/4)&(zi-2)/4==Math.floor((zi-2)/4)&&(angleObz=b,console.log("ffffffff7777777777777777777")),(xi-3)/4==Math.floor((xi-3)/4)&yi/4==Math.floor(yi/4)&(zi-3)/4==Math.floor((zi-3)/4)&&(angleOby=-b/2,console.log("fffffffffff555555555555555")),(xi-3)/4==Math.floor((xi-3)/4)&(yi-2)/4==Math.floor((yi-2)/4)&(zi-1)/4==Math.floor((zi-1)/4)&&(angleObx=b/2,angleOby=-b/2,console.log("fffffffffff444444444444")),(xi-1)/4==Math.floor((xi-1)/4)&(yi-2)/4==Math.floor((yi-2)/4)&(zi-1)/4==Math.floor((zi-1)/4)&&(angleOby=-b/2,console.log("ffffffffff666666666666666666")),(xi-1)/4==Math.floor((xi-1)/4)&yi/4==Math.floor(yi/4)&(zi-3)/4==Math.floor((zi-3)/4)&&(angleOby=b/2,console.log("ffffffffff666666666666666666")),xi/4==Math.floor(xi/4)&(yi-3)/4==Math.floor((yi-3)/4)&(zi-1)/4==Math.floor((zi-1)/4)&&(angleObx=b/2,angleOby=b,console.log("ffffffff3333333333333")),xi/4==Math.floor(xi/4)&yi/4==Math.floor(yi/4)&(zi+2)/4==Math.floor((zi+2)/4)&&(angleObx=b),xi/4==Math.floor(xi/4)&(yi-1)/4==Math.floor((yi-1)/4)&(zi-1)/4==Math.floor((zi-1)/4)&&(angleObx=b/2,console.log("fff000000000000000000000000")),1==cii){o[0],o[1];INTERSECTED.object.geometry.computeBoundingSphere();var g=INTERSECTED.object.geometry.boundingSphere.center;INTERSECTED.object.name;scene.remove(INTERSECTED.object),scene.remove(objects[INTERSECTED.object.name]),camera.remove(objects[3]),targetList.splice(targetList.indexOf(INTERSECTED.object),1)}console.log(l," vvo etc ",d," vv1",m," vv2 ",v),cii+=1,addTNew(l,d,m,v)}if(0<o.length&0==Tadd){o[0];INTERSECTED.object.geometry.computeBoundingSphere();g=INTERSECTED.object.geometry.boundingSphere.center;if(.8<Math.abs(g.x)&&(console.log(INTERSECTED.object.name+"---A-------delete this"+mirX[5]),1==mirX[INTERSECTED.object.name])){console.log(INTERSECTED.object.name+" B "+g.x+"-xxxx---------delete this");var u=INTERSECTED.object.name+1e3;rotXX[u-1e3]="NA",scene.remove(objects[u])}if(.2<Math.abs(g.y)&&1==mirY[INTERSECTED.object.name]){console.log(INTERSECTED.object.name+" B "+g.x+"-xxxxSS---------delete this");var E=INTERSECTED.object.name+2e3;rotYY[E-2e3]="NA",scene.remove(objects[E])}if(.2<Math.abs(g.y)&.8<Math.abs(g.x)&&1==mirY[INTERSECTED.object.name]&1==mirX[INTERSECTED.object.name]){console.log(INTERSECTED.object.name+" B "+g.x+"-xxxxSS---------delete this");var p=INTERSECTED.object.name+3e3;rotXY[p-3e3]="NA",scene.remove(objects[p])}rotX[INTERSECTED.object.name]="NA",scene.remove(objects[INTERSECTED.object.name]),targetList.splice(targetList.indexOf(INTERSECTED.object),1),console.log(INTERSECTED.object.name+" "+g.x+"-xxxx-----G----delete this")}}function addTNew(e,o,t,a){if(materials[cii]=material15,objects[cii]=object2.clone(),objects[cii].material=object2.material.clone(),"Random"==Rainbow){("000000"+materials[cii].color.getHex().toString(16)).slice(-6);var i=Math.floor(98.9*Math.random()+1)+100*Math.floor(98.9*Math.random()+1)+1e4*Math.floor(98.9*Math.random()+1);console.log("nextcolour "+i),materials[cii].color.setHex("0x"+i)}if("Greys"==Rainbow){var r=Math.min(Math.floor(4*Math.random()+59),60).toString(16);i="88";materials[cii].color.setHex("0x"+r+r+i)}if("Greens"==Rainbow){r=Math.floor(80*Math.random()+17).toString(16),i="ff";materials[cii].color.setHex("0x"+r+i+r)}if("Reds"==Rainbow){r=Math.floor(80*Math.random()+17).toString(16),i="ff";materials[cii].color.setHex("0x"+i+r+r)}if("Blues"==Rainbow){r=Math.floor(80*Math.random()+17).toString(16),i="ff";materials[cii].color.setHex("0x"+r+r+i)}"Yellow/Blue"==Rainbow&&(materials[cii].color.setHex(colcol),"0x2222cc"==colcol?colcol="0x555500":colcol="0x2222cc",materials[cii].color.setHex(colcol)),lambert=new THREE.MeshLambertMaterial({color:materials[cii].color,map:texture2}),objects[cii].traverse(function(e){e.material=lambert}),1==loadingF&&(xi=retrievedObjectA[0].possiX[cii],yi=retrievedObjectA[0].possiY[cii],zi=retrievedObjectA[0].possiZ[cii],angleObx=retrievedObjectA[0].rotX[cii],angleOby=retrievedObjectA[0].rotY[cii],angleObz=retrievedObjectA[0].rotZ[cii],loadingF=0),objects[cii].position.y=yi,objects[cii].position.z=zi,objects[cii].position.x=xi,possiX[cii]=xi,possiY[cii]=yi,possiZ[cii]=zi,TFlagNum[cii]=addTetraFlag,objects[cii].rotation.x=angleObx,objects[cii].rotation.y=angleOby,objects[cii].rotation.z=angleObz,rotX[cii]=angleObx,rotY[cii]=angleOby,rotZ[cii]=angleObz,scene2.add(objects[cii]),scene.add(objects[cii]),1==mirX[cii]&&(Xsym="ON"),"ON"==Xsym&&(console.log("YayMirX!"),mirX[cii]=1),1==mirY[cii]&&(Ysym="ON"),"ON"==Ysym&&(mirY[cii]=1),1==mirXY[cii]&&(Xsym="ON",Ysym="ON"),"ON"==Ysym&"ON"==Xsym&&(mirXY[cii]=1),objects[cii].userData="P",objects[cii].userSTL="Y",objects[cii].userCol=TColour[cii],console.log(cii+"numbr"+objects[cii].nameX+"Yay"),console.log(cii+"numbr"+objects[cii].name+"Nay"),targetOBJ.push(objects[cii].name),TColour[cii]=("000000"+material15.color.getHex().toString(16)).slice(-6),console.log(Xsym),.8<Math.abs(xi)&"ON"==Xsym?(objects[cii+1e3]=object2.clone(),objects[cii+1e3].material=object2.material.clone(),lambert=new THREE.MeshLambertMaterial({color:materials[cii].color,map:texture2}),objects[cii+1e3].traverse(function(e){e.material=lambert}),objects[cii+1e3].position.y=yi,objects[cii+1e3].position.z=zi,objects[cii+1e3].position.x=-xi,objects[cii+1e3].rotation.x=angleObx,objects[cii+1e3].rotation.y=-angleOby,objects[cii+1e3].rotation.z=angleObz,possiYX[cii]=yi,possiZX[cii]=zi,possiXX[cii]=-xi,TFlagNumX[cii]=addTetraFlag,TColourX[cii]=("000000"+lambert.color.getHex().toString(16)).slice(-6),rotXX[cii]=angleObx,rotYX[cii]=-angleOby,rotZX[cii]=angleObz,scene2.add(objects[cii+1e3]),scene.add(objects[cii+1e3]),objects[cii+1e3].name=cii+1e3,objects[cii+1e3].userData="P",console.log(cii+"numbr"+objects[cii+1e3].name),targetOBJ.push(objects[cii+1e3])):(possiYX[cii]="NA",possiZX[cii]="NA",possiXX[cii]="NA",TFlagNumX[cii]="NA",TColourX[cii]="NA",rotXX[cii]="NA",rotYX[cii]="NA",rotZX[cii]="NA"),.8<Math.abs(yi)&"ON"==Ysym?(objects[cii+2e3]=object2.clone(),objects[cii+2e3].material=object2.material.clone(),lambert=new THREE.MeshLambertMaterial({color:materials[cii].color,map:texture2}),objects[cii+2e3].traverse(function(e){e.material=lambert}),objects[cii+2e3].position.y=-yi,objects[cii+2e3].position.z=zi,objects[cii+2e3].position.x=xi,objects[cii+2e3].rotation.x=-angleObx,objects[cii+2e3].rotation.y=angleOby,objects[cii+2e3].rotation.z=angleObz,possiYY[cii]=-yi,possiZY[cii]=zi,possiXY[cii]=xi,TFlagNumY[cii]=addTetraFlag,TColourY[cii]=("000000"+lambert.color.getHex().toString(16)).slice(-6),rotXY[cii]=-angleObx,rotYY[cii]=angleOby,rotZY[cii]=angleObz,scene2.add(objects[cii+2e3]),scene.add(objects[cii+2e3]),objects[cii+2e3].name=cii+2e3,objects[cii+2e3].userData="P",console.log(cii+"numbr"+objects[cii+2e3].name),targetOBJ.push(objects[cii+2e3])):(possiYY[cii]="NA",possiZY[cii]="NA",possiXY[cii]="NA",TFlagNumY[cii]="NA",TColourY[cii]="NA",rotXY[cii]="NA",rotYY[cii]="NA",rotZY[cii]="NA"),.8<Math.abs(yi)&.8<Math.abs(xi)&"ON"==Xsym&"ON"==Ysym?(objects[cii+3e3]=object2.clone(),objects[cii+3e3].material=object2.material.clone(),lambert=new THREE.MeshLambertMaterial({color:materials[cii].color,map:texture2}),objects[cii+3e3].traverse(function(e){e.material=lambert}),objects[cii+3e3].position.y=-yi,objects[cii+3e3].position.z=zi,objects[cii+3e3].position.x=-xi,objects[cii+3e3].rotation.x=-angleObx,objects[cii+3e3].rotation.y=-angleOby,objects[cii+3e3].rotation.z=angleObz,possiYXY[cii]=-yi,possiZXY[cii]=zi,possiXXY[cii]=-xi,TFlagNumXY[cii]=addTetraFlag,TColourXY[cii]=("000000"+lambert.color.getHex().toString(16)).slice(-6),rotXXY[cii]=-angleObx,rotYXY[cii]=-angleOby,rotZXY[cii]=angleObz,scene2.add(objects[cii+3e3]),scene.add(objects[cii+3e3]),objects[cii+3e3].name=cii+3e3,objects[cii+3e3].userData="P",console.log(cii+"numbr"+objects[cii+3e3].name),targetOBJ.push(objects[cii+3e3])):(possiYXY[cii]="NA",possiZXY[cii]="NA",possiXXY[cii]="NA",TFlagNumXY[cii]="NA",TColourXY[cii]="NA",rotXXY[cii]="NA",rotYXY[cii]="NA",rotZXY[cii]="NA"),console.log(cii+"numbr and xvalue ="+xi);var s=new THREE.Geometry,n=e.y+o.y+t.y+a.y,c=e.x+o.x+t.x+a.x;if(vv0x[cii]=e.x,console.log(cii+"vv0x ="+e.x),vv0y[cii]=e.y,vv0z[cii]=e.z,vv1x[cii]=o.x,vv1y[cii]=o.y,vv1z[cii]=o.z,vv2x[cii]=t.x,vv2y[cii]=t.y,vv2z[cii]=t.z,vv3x[cii]=a.x,vv3y[cii]=a.y,vv3z[cii]=a.z,s.vertices=[new THREE.Vector3(e.x,e.y,e.z),new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(a.x,a.y,a.z)],s.faces=[new THREE.Face3(2,1,0),new THREE.Face3(1,2,3),new THREE.Face3(0,3,2),new THREE.Face3(3,0,1)],s.computeFaceNormals(),octa=new THREE.Mesh(s,material11),console.log(cii+"octa------------cii"),octa.name=cii,scene.add(octa),targetList.push(octa),.8<Math.abs(xi)&"ON"==Xsym){s=new THREE.Geometry,c=e.x+o.x+t.x+a.x;s.vertices=[new THREE.Vector3(-e.x,e.y,e.z),new THREE.Vector3(-o.x,o.y,o.z),new THREE.Vector3(-t.x,t.y,t.z),new THREE.Vector3(-a.x,a.y,a.z)],s.faces=[new THREE.Face3(0,1,2),new THREE.Face3(3,2,1),new THREE.Face3(2,3,0),new THREE.Face3(1,0,3)],octaX=new THREE.Mesh(s,material11),octaX.name=cii+1e3,scene.add(octaX),targetList.push(octaX)}if(.8<Math.abs(yi)&"ON"==Ysym){s=new THREE.Geometry,n=e.y+o.y+t.y+a.y;s.vertices=[new THREE.Vector3(e.x,-e.y,e.z),new THREE.Vector3(o.x,-o.y,o.z),new THREE.Vector3(t.x,-t.y,t.z),new THREE.Vector3(a.x,-a.y,a.z)],s.faces=[new THREE.Face3(0,1,2),new THREE.Face3(3,2,1),new THREE.Face3(2,3,0),new THREE.Face3(1,0,3)],octaY=new THREE.Mesh(s,material11),octaY.name=cii+2e3,scene.add(octaY),targetList.push(octaY)}if("ON"==Xsym&"ON"==Ysym){s=new THREE.Geometry,n=e.y+o.y+t.y+a.y,c=e.x+o.x+t.x+a.x;s.vertices=[new THREE.Vector3(-e.x,-e.y,e.z),new THREE.Vector3(-o.x,-o.y,o.z),new THREE.Vector3(-t.x,-t.y,t.z),new THREE.Vector3(-a.x,-a.y,a.z)],s.faces=[new THREE.Face3(2,1,0),new THREE.Face3(1,2,3),new THREE.Face3(0,3,2),new THREE.Face3(3,0,1)],.1<c&n<-.1&&(s.faces=[new THREE.Face3(0,1,2),new THREE.Face3(3,2,1),new THREE.Face3(2,3,0),new THREE.Face3(1,0,3)]),c<-.1&.1<n&&(s.faces=[new THREE.Face3(0,1,2),new THREE.Face3(3,2,1),new THREE.Face3(2,3,0),new THREE.Face3(1,0,3)]),c<-.1&n<-.1&&(s.faces=[new THREE.Face3(2,1,0),new THREE.Face3(1,2,3),new THREE.Face3(0,3,2),new THREE.Face3(3,0,1)]),s.computeFaceNormals(),octaXY=new THREE.Mesh(s,material11),octaXY.name=cii+3e3,scene.add(octaXY),targetList.push(octaXY)}}function onDocumentKeyDown(e){switch(e.keyCode){case 16:isShiftDown=!0}}function onDocumentKeyUp(e){switch(e.keyCode){case 16:isShiftDown=!1}}function animate(){requestAnimationFrame(animate),render(),update()}function flyTrack(){var e=camera,o=window.innerWidth/window.innerHeight;camera=new THREE.PerspectiveCamera(45,o,.01,2e4),camera.position.copy(e.position),camera.rotation.copy(e.rotation);var t=0,a=1;switch(mode){case a:controls=new THREE.TrackballControls(camera),mode=t;break;case t:controls=new THREE.FlyControls(camera),mode=a}}function update(){keyboard.update();var e=Math.PI;keyboard.pressed("A")&&(objects[1].traverse(function(e){e.material=lambert}),objects[cii].traverse(function(e){e.material=lambert}),console.log("APressed")),keyboard.pressed("left")&&(objects[1].position.x=objects[1].position.x-.5,objects[999].position.x=objects[999].position.x-.5,console.log("leftPressed")),keyboard.pressed("right")&&(objects[1].position.x=objects[1].position.x+.5,objects[999].position.x=objects[999].position.x+.5,console.log("rightPressed")),keyboard.pressed("down")&&(objects[1].position.y=objects[1].position.y-.5,objects[999].position.y=objects[999].position.y-.5,console.log("downPressed")),keyboard.pressed("up")&&(objects[1].position.y=objects[1].position.y+.5,objects[999].position.y=objects[999].position.y+.5,console.log("upPressed"));if(keyboard.pressed("X")){var o=objects[cii].rotation.x;console.log("upPressed"),setTimeout(function(){objects[cii].rotation.x=o+e/2},300)}if(keyboard.pressed("Y")){o=objects[cii].rotation.y;setTimeout(function(){objects[cii].rotation.y=o+e/2},300)}if(keyboard.pressed("Z")){o=objects[cii].rotation.z;setTimeout(function(){objects[cii].rotation.z=o+e/2},300)}if(keyboard.pressed("F")){for(o=0;o<=10;o+=1)var t=o;addTetraFlag=addTetraFlag+1+t,addTetraFlag-=t,camera.remove(objects[1]),addTetraF()}keyboard.pressed("B")&&(separation+=.1),keyboard.pressed("B")&&(separation-=.1),objects[1].rotation.z=objects[1].rotation.z+.01,objects[1].rotation.x=objects[1].rotation.x+.005,objects[1].rotation.x>2*Math.PI&&(objects[1].rotation.x=.005),objects[1].rotation.z>2*Math.PI&&(objects[1].rotation.z=.01),objects[1].traverse(function(e){e.material=lambert}),controls.update(),checkHighlight(),CheckMouseSphere()}function checkHighlight(){var e=new THREE.Vector3(mouse.x,mouse.y,.999);e.unproject(camera);var o=new THREE.Raycaster(camera.position,e.sub(camera.position).normalize()).intersectObjects(targetList);0<o.length?(null==INTERSECTED||(INTERSECTED.face.color=baseColor,INTERSECTED.object.geometry.colorsNeedUpdate=!0),INTERSECTED=o[0],INTERSECTED.face.color=cubeColor,mouseSphereCoords=[INTERSECTED.point.x,INTERSECTED.point.y,INTERSECTED.point.z],INTERSECTED.object.geometry.colorsNeedUpdate=!0):(INTERSECTED&&(INTERSECTED.face.color=baseColor,INTERSECTED.object.geometry.colorsNeedUpdate=!0),INTERSECTED=null,mouseSphereCoords=null)}function checkRotation(){var e=camera.position.x,o=(camera.position.y,camera.position.z);keyboard.pressed("left")?(camera.position.x=e*Math.cos(rotSpeed)+o*Math.sin(rotSpeed),camera.position.z=o*Math.cos(rotSpeed)-e*Math.sin(rotSpeed)):keyboard.pressed("right")&&(camera.position.x=e*Math.cos(rotSpeed)-o*Math.sin(rotSpeed),camera.position.z=o*Math.cos(rotSpeed)+e*Math.sin(rotSpeed)),camera.lookAt(scene.position)}function CheckMouseSphere(){null!=mouseSphereCoords?(mouseSphere[0].position.set(mouseSphereCoords[0],mouseSphereCoords[1],mouseSphereCoords[2]),mouseSphere[0].visible=!0):(mouseSphere[0].visible=!1,xxx=0)}function render(){keyboard.update();var e=Math.PI;if(keyboard.pressed("C")&&(iR=0),iR<360){var o=camera.position.x,t=(camera.position.y,camera.position.z);console.log(iR),camera.position.x=o*Math.cos(iR/e/3270)+t*Math.sin(iR/e/3270),camera.position.z=t*Math.cos(iR/e/3270)-o*Math.sin(iR/e/3270),camera.lookAt(scene.position)}iR+=1,1e6<iR&&(iR=4e3),"OFF"==Doption&&(renderer.clear(),"XZ Table"==BTab&&(camera.up=new THREE.Vector3(0,1,0)),"YZ Table"==BTab&&(camera.up=new THREE.Vector3(0,1,0)),renderer.render(scene,camera)),"Anaglyph"==Doption&&anaglyphRenderer.render(scene,camera),"Side-by-Side"==Doption&&OcRenderer.render(scene,camera)}console.log("starting"),savedFiles[0]=". ",userLocalName[0]="NONE",init(),animate(),objects1.on("click",function(){exportToObj()});