-
Notifications
You must be signed in to change notification settings - Fork 3
/
00Both.js
1 lines (1 loc) · 73.7 KB
/
00Both.js
1
var container,scene,scene2,backgroundScene,backgroundCamera,camera,cameraLeft,cameraRight,renderer,controls,controls1,uLocalName;var keyboard=new KeyboardState;var WebPath=window.location.pathname.slice(-6);console.log(WebPath+"webpath");if(WebPath=="y.html"){var typeGame=0;var spesGame=1;var setBGPath="textures/cube/Space/";var guiOriginal=1;var tableType="models/obj/tableB.obj";var surfType="models/obj/grass.obj";var BTab="Grid View";var Doption="OFF";var Rainbow="Random";var musicTrue=0;var texture3=(new THREE.TextureLoader).load("textures/grass.jpg");var tetraName="Geometric";var addTetraFlag=0;var loadingF=0;var Xsym="OFF";var Ysym="OFF";var Btable}if(WebPath=="l.html"){var typeGame=0;var spesGame=1;var setBGPath="textures/cube/Space/";var guiOriginal=1;var tableType="models/obj/tableB.obj";var surfType="models/obj/grass.obj";var BTab="Grid View";var Doption="OFF";var Rainbow="Random";var musicTrue=0;var texture3=(new THREE.TextureLoader).load("textures/grass.jpg");var tetraName="Geometric";var addTetraFlag=0;var loadingF=0;var Xsym="OFF";var Ysym="OFF";var Btable}if(WebPath=="S.html"){var typeGame=0;var spesGame=1;var setBGPath="textures/cube/Space/";var guiOriginal=1;var tableType="models/obj/tableB.obj";var surfType="models/obj/grass.obj";var BTab="Grid View";var Doption="OFF";var Rainbow="Random";var musicTrue=0;var texture3=(new THREE.TextureLoader).load("textures/grass.jpg");var tetraName="Geometric";var addTetraFlag=0;var loadingF=0;var Xsym="OFF";var Ysym="OFF";var Btable}if(WebPath=="E.html"){var typeGame=0;var spesGame=0;var setBGPath="textures/cube/Engineering/";var guiOriginal=1;var tableType="models/obj/tableB.obj";var surfType="models/obj/grass.obj";var BTab="Grid View";var Doption="OFF";var Rainbow="Random";var musicTrue=0;var texture3=(new THREE.TextureLoader).load("textures/grass.jpg");var tetraName="SpaceBric";var addTetraFlag=0;var loadingF=0;var Xsym="OFF";var Ysym="OFF";var Btable}if(WebPath=="B.html"){var typeGame=0;var spesGame=1;var setBGPath="textures/cube/Flat/";var guiOriginal=1;var tableType="models/obj/tableB.obj";var surfType="models/obj/grass.obj";var BTab="Grid View";var Doption="OFF";var Rainbow="Random";var musicTrue=0;var texture3=(new THREE.TextureLoader).load("textures/grass.jpg");var tetraName="Geometric";var addTetraFlag=0;var loadingF=0;var Xsym="OFF";var Ysym="OFF";var Btable}if(WebPath=="h.html"){var typeGame=0;var spesGame=0;var setBGPath="textures/cube/Space/";var guiOriginal=1;var tableType="models/obj/tableB.obj";var surfType="models/obj/grass.obj";var BTab="Grid View";var Doption="OFF";var Rainbow="OFF";var musicTrue=0;var texture3=(new THREE.TextureLoader).load("textures/grass.jpg");var tetraName="SpaceBric";var addTetraFlag=0;var loadingF=0;var Xsym="OFF";var Ysym="OFF";var Btable}if(WebPath=="A.html"){var typeGame=0;var spesGame=1;var setBGPath="textures/cube/Art/";var guiOriginal=1;var tableType="models/obj/tableB.obj";var surfType="models/obj/grass.obj";var BTab="Grid View";var Doption="OFF";var Rainbow="Greys";var musicTrue=0;var texture3=(new THREE.TextureLoader).load("textures/grass.jpg");var tetraName="Geometric";var addTetraFlag=0;var loadingF=0;var Xsym="OFF";var Ysym="OFF";var Btable}{var gridHelper,axesHelper;var targetList=[],targetListX=[],targetListY=[],targetListXY=[],savedFiles=[],userLocalName=[],userLocalPass=[];var numSavedFiles=0,current=["NONE",""],currentFile;var activeFiles=[];activeFiles[0]=". ";var numUserL=0;var numUsers=1;var possiX=[],possiY=[],possiZ=[],possiXX=[],possiYX=[],possiZX=[],possiXY=[],possiYY=[],possiZY=[],possiXXY=[],possiYXY=[],possiZXY=[];var TFlagNum=[],TFlagNumX=[],TFlagNumY=[],TFlagNumXY=[],TColour=[],TColourX=[],TColourY=[],TColourXY=[];var rotX=[],rotY=[],rotZ=[],rotXX=[],rotYX=[],rotZX=[],rotXY=[],rotYY=[],rotZY=[],rotXXY=[],rotYXY=[],rotZXY=[],DesT=[];var vv0x=[],vv0y=[],vv0z=[],vv1x=[],vv1y=[],vv1z=[],vv2x=[],vv2y=[],vv2z=[],vv3x=[],vv3y=[],vv3z=[];var count=0;var mirX=[],mirY=[],mirXY=[];var targetOBJ=[];var objects=[];var objectsL=[];var objectXxx=[];var objectX,objectT,objectT1;var lightsP=[];var particleLight;var projector,raycaster,mouse={x:0,y:0},INTERSECTED,isShiftDown=false;var separation=.1;var selectedFaces=[];var floorSide=1e3;var faceColorMaterial,baseColor=new THREE.Color(15654246);var highlightedColor=new THREE.Color(14526976);var selectedColor=new THREE.Color(4482781);var mouseSphereCoords=null;var mouseSphere=[];var material=new THREE.MeshBasicMaterial({vertexColors:THREE.FaceColors});var light1,light2,light3;var iR,li=2,i,iiL,xi,yi,zi,si,sy,sz,ci=1,cii=1,ciiX=0,ciiY=0,ciiXY=0;var materials=[];var shininess=50,specular=3355443,bumpScale=1,shading=THREE.SmoothShading;var keyCode,KeyCodeUp;var xposi1=3.3003030003033005;var yposi1=2.220020202002022;var zposi1=5.500550500505505;var xxpo=xposi1/(Math.PI/3)*Math.floor(xposi1/Math.floor(xposi1)+yposi1+zposi1-Math.floor(yposi1+zposi1))/Math.PI/Math.floor(xposi1/3);var yypo=5*Math.PI*Math.floor(yposi1/Math.floor(yposi1)+xposi1+zposi1-Math.floor(xposi1+zposi1))/Math.PI/Math.floor(yposi1/10);var zzpo=2*Math.PI*Math.floor(zposi1/Math.floor(zposi1)+xposi1+yposi1-Math.floor(yposi1+xposi1))/Math.PI/Math.floor(zposi1/2.5);var object3,object4,object2;var rotSelect2=[];var rotSelect=[];var octa,octa2,octaX,octaY,octaZ;var cubeColor,backgroundMesh;var folder1;var addTetraFlag2=0,Load2=0,addDesignFlag=0;var designs=[];var textures=[];var Tadd,xxx=0;var TaddD=1;var TransparentBlock="False";var saveOBJ1="SavedOBJ";var colcol="0x2222cc";var colcol2="0x2222cc";var musicC=[];var playingNow;var audio;var loaded;var retrievedObjectA=[];var sentObjectA={};var userObject=[];var USERS={};var retrievedObject;var tetrasL=[];var angleObx=0;var angleOby=0;var angleObz=0;var angleOb=Math.PI;var ciiB=0,ciiA=0}{var material111=new THREE.MeshLambertMaterial({color:3355443,transparent:true,opacity:0});var material11=new THREE.MeshLambertMaterial({color:16777215,transparent:true,opacity:0});var material999=new THREE.MeshLambertMaterial({color:65280,transparent:true,opacity:.3});var material12=new THREE.MeshLambertMaterial({color:16776960,transparent:true,opacity:1});var material13=new THREE.MeshLambertMaterial({color:15662848});var material14=new THREE.MeshLambertMaterial({color:15662848});var material15=new THREE.MeshLambertMaterial({color:16777215,transparent:true,opacity:1});var material16=new THREE.MeshLambertMaterial({color:8396869,transparent:true,opacity:1})}{var tetNames=["TetraPline","Platform","SpaceBric","SquareFlat","Slide","Modern","Torus","Clipped","TetraFrame","TetraMag","ThickStar","ThinStar","Flower","Original","Triangles","Magnet Ball","Pipes","Cubic","Lattice","Half-Pipe","Flatpack","Dragon","Heart-shape","Heart-logo","Leaf","DNA segment","Oval","Sphere0","Sphere1","Sphere2","Sphere3","Sphere4","Organic1","Organic2","Organic3","Globe1","Globe2","Globe3","Globe4","Globe5","Globe6"];var tNames=tetNames.slice(0,5);var tNames2=tetNames.slice(5,13);var tNames3=tetNames.slice(13,19);var tNames4=tetNames.slice(19,26);var tNames5=tetNames.slice(26,31);var tNames6=tetNames.slice(31,40)}if(spesGame==1){var texNames=["Oceans","Forests","InquireInspire","Recycle","InspireColor","Support","Stars","Fractals","Wormholes","BlueIce","Silver","Glass","Green","Artsy","Leaves","Rust","Sandstone","Colors"];textures=["textures/ocean.jpg","textures/forest.jpg","textures/IEI.jpg","textures/care.jpg","textures/inspire.jpg","textures/friends.jpg","textures/stars9.jpg","textures/curl.jpg","textures/wormholes.bmp","textures/s1.png","textures/silverMetal.jpg","textures/skyScr4.jpg","textures/greenMetal.jpg","textures/disturb.jpg","textures/leaf09.png","textures/rust.jpg","textures/sandstone2.jpg","textures/color.jpg"];designs=["models/obj/geometric.obj","models/obj/Platform.obj","models/obj/Original.obj","models/obj/tetraplineTex2020.obj","models/obj/solid4.obj","models/obj/modern.obj","models/obj/Tetratorus.obj","models/obj/snake.obj","models/obj/Tetraframe1.obj","models/obj/magnetic1.obj","models/obj/slivers2.obj","models/obj/small.obj","models/obj/press.obj","models/obj/Abstract.obj","models/obj/Triangle.obj","models/obj/Hex.obj","models/obj/pipe2.obj","models/obj/dice.obj","models/obj/geometryBall.obj","models/obj/halfpipe2.obj","models/obj/Flatpacka.obj","models/obj/dragon2.obj","models/obj/Cordedfree.obj","models/obj/PuzzleClip.obj","models/obj/leaf2.obj","models/obj/bamboolasercut.obj","models/obj/pipe2018d.obj","models/obj/spacebrickpline.obj","models/obj/sphere1.obj","models/obj/sphere2.obj","models/obj/Tri2023.obj","models/obj/sphere4.obj","models/obj/cubic.obj","models/obj/organic2.obj","models/obj/organic3.obj","models/obj/leaf3.obj","models/obj/heart.obj","models/obj/spiral.obj"]}if(spesGame==0){var texNames=["N1","N2","N3","N4","N5","N6","N7","N8","E1","E2","E3","E4","E5","E6","E7","E8","S1","S2","S3","S4","S5","S6","S7","S8","None"];textures=["textures/n1.png","textures/n2.png","textures/n3.png","textures/n4.png","textures/n5.png","textures/n6.png","textures/n7.png","textures/n8.png","textures/e1.png","textures/e2.png","textures/e3.png","textures/e4.png","textures/e5.png","textures/e6.png","textures/e7.png","textures/e8.png","textures/s1.png","textures/s2.png","textures/s3.png","textures/s4.png","textures/s5.png","textures/s6.png","textures/s7.png","textures/s8.png","textures/none.png"];designs=["models/obj/Original.obj","models/obj/TetraSquare1.obj","models/obj/solid4.obj","models/obj/modern.obj","models/obj/globe2.obj","models/obj/Platform.obj","models/obj/Tetratorus.obj","models/obj/snake.obj","models/obj/Tetraframe1.obj","models/obj/magnetic1.obj","models/obj/slivers2.obj","models/obj/small.obj","models/obj/press.obj","models/obj/Abstract.obj","models/obj/Triangle.obj","models/obj/Hex.obj","models/obj/pipe2.obj","models/obj/dice.obj","models/obj/geometryBall.obj","models/obj/halfpipe2.obj","models/obj/Flatpacka.obj","models/obj/dragon2.obj","models/obj/Cordedfree.obj","models/obj/PuzzleClip.obj","models/obj/leaf2.obj","models/obj/bamboolasercut.obj","models/obj/pipe2018d.obj","models/obj/spacebrickpline.obj","models/obj/sphere1.obj","models/obj/sphere2.obj","models/obj/Tri2023.obj","models/obj/sphere4.obj","models/obj/cubic.obj","models/obj/organic2.obj","models/obj/organic3.obj","models/obj/leaf3.obj","models/obj/heart.obj","models/obj/spiral.obj"]}var texFlag=0;var texNum=textures.length-1;var tetraNum=designs.length-1;console.log(tetraNum+"TetraNum");var texture2;if(window.File&&window.FileReader&&window.FileList&&window.Blob){}else{}var mouseX=0,mouseY=0;var windowHalfX=window.innerWidth/2;var windowHalfY=window.innerHeight/2;function toggleDiv(el){if(document.getElementById(el).style.display=="none"){document.getElementById(el).style.display=""}else{document.getElementById(el).style.display="none"}}savedFiles[0]=". ";userLocalName[0]="NONE";init();animate();function onDocumentKeyDown(event){keyCode=event.which}function onDocumentKeyUp(event){keyCodeUp=event.which}function nextTetra(){addTetraFlag=addTetraFlag+1;if(addTetraFlag>tetraNum){addTetraFlag=0}camera.remove(objects[1]);addTetraF()}function prevTetra(){addTetraFlag=addTetraFlag-1;if(addTetraFlag<0){addTetraFlag=tetraNum}camera.remove(objects[1]);addTetraF()}function nextTex(){texFlag=texFlag+1;if(texFlag>texNum){texFlag=0}camera.remove(objects[1]);addTetraF()}function prevTex(){texFlag=texFlag-1;if(texFlag<0){texFlag=texNum}camera.remove(objects[1]);addTetraF()}function deleteX(){console.log(TaddD+" TaddD");var temp=TaddD;if(TaddD==0){TaddD=1}if(temp==1){TaddD=0}console.log(TaddD+" TaddD")}var callback=function(){objects[cii].rotation.x=gamma+angleOb/2};var callbacky=function(){objects[cii].rotation.y=gamma+angleOb/2};var callbackz=function(){objects[cii].rotation.z=gamma+angleOb/2};function keyboardX(){var gamma=objects[cii].rotation.x;console.log("XRotate");setTimeout(callback,300);objects[cii].rotation.x=gamma+angleOb/2}function keyboardY(){var gamma=objects[cii].rotation.y;console.log("YRotate");setTimeout(callbacky,300);objects[cii].rotation.y=gamma+angleOb/2}function keyboardZ(){var gamma=objects[cii].rotation.z;console.log("ZRotate");setTimeout(callbackz,300);objects[cii].rotation.z=gamma+angleOb/2}function LoadUserFile(nametoload){scene.remove(octa);var nametoload=nametoload;var retrievedObjectB=localStorage.getItem(nametoload);retrievedObjectA=JSON.parse(retrievedObjectB);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;cii=0;i=2;iiL=-11111;loadingF=1;for(var lim=1;lim<=ciiL;lim+=1){cii+=1;addTetraFlag=retrievedObjectA[0].TFlagNum[cii];addTetraLC(cii,nametoload);render()}ciiB=scene.children.length;cii=0;i=2;iiL=-11111;ciiB=scene.children.length;for(var lim=1;lim<=ciiL;lim+=1){cii+=1;addTetraFlag=retrievedObjectA[0].TFlagNum[cii];addTetraL(cii);render()}cii=ciiL;iiL=0}function LoadUserFileC(CLoad2,objects){if(localStorage){console.log("LocalStorage is supported!")}else{console.log("No support. Use a fallback such as browser cookies or store on the server.")}var nametoload=CLoad2;var retrievedObjectB=localStorage.getItem(nametoload);retrievedObjectA=JSON.parse(retrievedObjectB);ciiL=retrievedObjectA[0].NormalT;var vcii=1;console.log(objects.length+"obj length");console.log(objects[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;var vName=0;scene.traverse(function(node){if(node instanceof THREE.Object3D){if(node.userData<990){materials[node.userData]=material15;var nextColor=retrievedObjectA[0].TColour[node.userData];materials[node.userData].color.setHex("0x"+nextColor);lambert=new THREE.MeshLambertMaterial({color:materials[node.userData].color,map:texture2});objects[node.userData].traverse(function(child){child.material=lambert});if(mirX[node.userData]==1&Math.abs(possiX[node.userData])>.8){objects[node.userData+1e3].traverse(function(child){child.material=lambert})}if(mirY[node.userData]==1&Math.abs(possiY[node.userData])>.8){objects[node.userData+2e3].traverse(function(child){child.material=lambert})}if(mirXY[node.userData]==1&Math.abs(possiX[node.userData])>.8&Math.abs(possiY[node.userData])>.8){objects[node.userData+3e3].traverse(function(child){child.material=lambert})}}}});ciiL=retrievedObjectA[0].NormalT-1;cii=ciiL;iiL=0}function download(data,filename,type){var file=new Blob([data],{type:type});if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(file,filename);else{var a=document.createElement("a"),url=URL.createObjectURL(file);a.href=url;a.download=filename;document.body.appendChild(a);a.click();setTimeout(function(){document.body.removeChild(a);window.URL.revokeObjectURL(url)},0)}}function sendMail(blob){var blobx=blob;var link="mailto:[email protected]"+"[email protected]"+"&subject="+escape("OBJ12321")+"&body="+blobx;window.location.href=link}function exportToObj(userLocalNameX,fileNameTetX,fileUserX,numUsersX,numUserLX){if(localStorage){console.log("LocalStorage is supported!")}else{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 i=0;i<Object.keys(gui.__folders).length;i++){var key=Object.keys(gui.__folders)[i];for(var j=0;j<gui.__folders[key].__controllers.length;j++){gui.__folders[key].__controllers[j].updateDisplay()}}var USERS=[{current:current,userLocalName:userLocalName,numUsers:numUsersX,savedFiles:savedFiles}];userObject=JSON.stringify(USERS,null,100);var fileUser="USERS";localStorage.setItem(fileUser,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 blob=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"});var filenamex=fileUserX;localStorage.setItem(filenamex,sampleObject);var rotXD=rotX;var rotYD=rotY;var rotZD=rotZ;for(var lim=1;lim<=cii;lim+=1){rotXD[lim]=rotX[lim]*180/Math.PI-90;rotYD[lim]=rotY[lim]*180/Math.PI;rotZD[lim]=rotZ[lim]*180/Math.PI}var sentObjectB="NormalT ="+cii+";"+"TColour =["+TColour.toString().substring(8)+"];"+"rotX =["+rotXD.toString().substring(5)+"];"+"rotY =["+rotYD.toString().substring(5)+"];"+"rotZ =["+rotZD.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(sentObjectB,null,100);var find=['"'];var replace=[""];var sampleObjectC=sampleObject.toString().replace(find,replace);sampleObjectC=sampleObjectC.slice(0,-1);download(sampleObjectC,filenamex,"text/csv");console.log("savedxxxxxx"+filenamex);camera.remove(objects[1]);camera.remove(objects[999]);scene.remove(objects[1]);scene.remove(objects[999]);var mtlOutput="";var im=0;for(var i=2;i<cii+1;i++){mtlOutput+="newmtl Material."+(i-1+im)+"\n";var hex="0x"+TColour[i];var r=hex>>16;var g=hex>>8&255;var b=hex&255;r=r/255*.8;g=g/255*.8;b=b/255*.8;mtlOutput+="Ns 96.0000\n";mtlOutput+="Ni 1.5000\n";mtlOutput+="d 1.0000\n";mtlOutput+="Tr 0.0000\n";mtlOutput+="Tf 1.0000 1.0000 1.0000\n";mtlOutput+="illum 2\n";mtlOutput+="Ka 1.0000 1.0000 1.0000\n";mtlOutput+="Kd "+r+" "+g+" "+b+" "+"\n";mtlOutput+="Ks 0.0000 0.0000 0.0000\n";mtlOutput+="Ke 0.2000 0.2000 0.2000\n";if(typeof objects[i+1e3]==="undefined"){}else{im+=1;mtlOutput+="newmtl Material."+(i-1+im)+"\n";var hex="0x"+TColour[i];var r=hex>>16;var g=hex>>8&255;var b=hex&255;r=r/255*.8;g=g/255*.8;b=b/255*.8;mtlOutput+="Ns 96.0000\n";mtlOutput+="Ni 1.5000\n";mtlOutput+="d 1.0000\n";mtlOutput+="Tr 0.0000\n";mtlOutput+="Tf 1.0000 1.0000 1.0000\n";mtlOutput+="illum 2\n";mtlOutput+="Ka 1.0000 1.0000 1.0000\n";mtlOutput+="Kd "+r+" "+g+" "+b+" "+"\n";mtlOutput+="Ks 0.0000 0.0000 0.0000\n";mtlOutput+="Ke 0.2000 0.2000 0.2000\n"}if(typeof objects[i+2e3]==="undefined"){}else{im+=1;mtlOutput+="newmtl Material."+(i-1+im)+"\n";var hex="0x"+TColour[i];var r=hex>>16;var g=hex>>8&255;var b=hex&255;r=r/255*.8;g=g/255*.8;b=b/255*.8;mtlOutput+="Ns 96.0000\n";mtlOutput+="Ni 1.5000\n";mtlOutput+="d 1.0000\n";mtlOutput+="Tr 0.0000\n";mtlOutput+="Tf 1.0000 1.0000 1.0000\n";mtlOutput+="illum 2\n";mtlOutput+="Ka 1.0000 1.0000 1.0000\n";mtlOutput+="Kd "+r+" "+g+" "+b+" "+"\n";mtlOutput+="Ks 0.0000 0.0000 0.0000\n";mtlOutput+="Ke 0.2000 0.2000 0.2000\n"}if(typeof objects[i+3e3]==="undefined"){}else{im+=1;mtlOutput+="newmtl Material."+(i-1+im)+"\n";var hex="0x"+TColour[i];var r=hex>>16;var g=hex>>8&255;var b=hex&255;r=r/255*.8;g=g/255*.8;b=b/255*.8;mtlOutput+="Ns 96.0000\n";mtlOutput+="Ni 1.5000\n";mtlOutput+="d 1.0000\n";mtlOutput+="Tr 0.0000\n";mtlOutput+="Tf 1.0000 1.0000 1.0000\n";mtlOutput+="illum 2\n";mtlOutput+="Ka 1.0000 1.0000 1.0000\n";mtlOutput+="Kd "+r+" "+g+" "+b+" "+"\n";mtlOutput+="Ks 0.0000 0.0000 0.0000\n";mtlOutput+="Ke 0.2000 0.2000 0.2000\n"}}var exporter=new THREE.OBJExporter;count=0;var str=exporter.parse(scene,count);str="mtllib "+filenamex+".mtl\n"+str;var str1=str[0];var str2=TColour.toString().substring(8);var blob=new Blob([str],{type:"text/plain"});var eMailbody1=blob;saveAs(blob,filenamex+".obj");var blob=new Blob([mtlOutput],{type:"text/plain"});saveAs(blob,filenamex+".mtl");camera.add(objects[1]);camera.add(objects[999])}function loadALL(){if(localStorage.getItem("USERS")===null){numUsers=1;numUserL=0;userLocalName[0]="NONE";savedFiles=[". ","No file"];numSavedFiles=2;current=["NONE","No file",0];var USERS=[{current:current,userLocalName:["NONE"],numUsers:numUsers,savedFiles:savedFiles}];userObject=JSON.stringify(USERS,null,100);var fileUser="USERS";localStorage.setItem(fileUser,userObject);uLocalName=current[0]}}function init(){console.log("init 2020");if(localStorage.getItem("USERS")===null){loadALL()}else{var retrievedObjectU=localStorage.getItem("USERS");var USERS=JSON.parse(retrievedObjectU);numSavedFiles=USERS[0].savedFiles.length;numUsers=USERS[0].userLocalName.length;userLocalName=USERS[0].userLocalName;current=USERS[0].current;numUserL=current[2];uLocalName=current[0];savedFiles=USERS[0].savedFiles;currentFile=current[1]}var textureLoader=new THREE.TextureLoader;texFlag=1;texture2=(new THREE.TextureLoader).load(textures[texFlag]);console.log(texFlag+"texFlag");material11.side=THREE.DoubleSide;floatingDiv=document.createElement("div");floatingDiv.className="floating";document.body.appendChild(floatingDiv);projector=new THREE.Projector;scene=new THREE.Scene;scene2=new THREE.Scene;var SCREEN_WIDTH=window.innerWidth,SCREEN_HEIGHT=window.innerHeight;var VIEW_ANGLE=55,ASPECT=SCREEN_WIDTH/SCREEN_HEIGHT,NEAR=.01,FAR=2e4;var reflectionCube=(new THREE.CubeTextureLoader).setPath(setBGPath).load(["0001.jpg","0003.jpg","0005.jpg","0006.jpg","0004.jpg","0002.jpg"]);reflectionCube.format=THREE.RGBFormat;camera=new THREE.PerspectiveCamera(VIEW_ANGLE,ASPECT,NEAR,FAR);camera.up=new THREE.Vector3(0,1,0);var audioListener=new THREE.AudioListener;camera.add(audioListener);if(musicTrue==1){var MusicTG=new THREE.Audio(audioListener);scene.add(MusicTG);var loader=new THREE.AudioLoader;loader.load("sounds/1.mp3",function(audioBuffer){MusicTG.setBuffer(audioBuffer);MusicTG.setLoop(true);MusicTG.play()},function(xhr){},function(xhr){console.log("An error happened")})}cameraLeft=new THREE.PerspectiveCamera(VIEW_ANGLE,ASPECT,NEAR,FAR);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(VIEW_ANGLE,ASPECT,NEAR,FAR);cameraRight.position.set(0,0,3);cameraRight.position.set(-.1,-2.5,-30.195);cameraRight.lookAt(scene.position);scene.add(cameraRight);scene.add(camera);scene.background=reflectionCube;camera.position.set(0,-2.5,-30.195);camera.lookAt(scene.position);if(!Detector.webgl)Detector.addGetWebGLMessage();if(Detector.webgl)renderer=new THREE.WebGLRenderer({antialias:true});else renderer=new THREE.CanvasRenderer;renderer.setClearColor(0);renderer.setSize(SCREEN_WIDTH,SCREEN_HEIGHT);container=document.getElementById("ThreeJS");renderer.gammaInput=true;renderer.gammaOutput=true;container.appendChild(renderer.domElement);document.addEventListener("mousedown",onDocumentMouseDown,false);document.addEventListener("mousemove",onDocumentMouseMove,false);document.addEventListener("keydown",onDocumentKeyDown,false);document.addEventListener("keyup",onDocumentKeyUp,false);document.addEventListener("keyup",function(object){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,false);renderer.domElement.addEventListener("mousemove",onDocumentMouseMove,false);document.addEventListener("keydown",onDocumentKeyDown,false);document.addEventListener("keyup",onDocumentKeyUp,false);anaglyphRenderer=new THREE.AnaglyphEffect(renderer,SCREEN_WIDTH,SCREEN_HEIGHT);stereoRenderer=new THREE.StereoEffect(renderer,SCREEN_WIDTH,SCREEN_HEIGHT);var ambientLight=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 directionalLight=new THREE.DirectionalLight(16777215,1);directionalLight.position.set(1,551,1).normalize();scene.add(directionalLight);var pointLight=new THREE.PointLight(16777215,2,800);var newSphereGeom=new THREE.SphereGeometry(.5,.5,.5);var color1=new THREE.Color("skyblue");var mesh2=new THREE.Mesh(newSphereGeom,color1);mesh2.position.x=0;mesh2.position.y=200;mesh2.position.z=500;ci=1;cii=1;materials[cii]=material15;if(guiOriginal==1){gui=new dat.GUI;parameters={x:30,y:30,z:0,color:"#1133aa",opacity:3,Xsym:Xsym,Ysym:Ysym,Zsym:1,BTab:BTab,Doption:Doption,Rainbow:Rainbow,addTetraName:tetraName,addTetraName2R:" ",addTetraName2:" ",addTetraName3:" ",addTetraName4:" ",addTextureName:" ",Load2:". ",LoadC:". ",DelFile:". ",saveOBJ2:" "};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;directionalLight.intensity=Zsym;cubeColor=gui.addColor(parameters,"color").name("Color").listen();var lth=uLocalName.length;folder1=gui.addFolder(" USER SETTINGS ");var cubeX=folder1.add(parameters,"Xsym",["OFF","ON"]).name("Xsymmetry").listen();var cubeY=folder1.add(parameters,"Ysym",["OFF","ON"]).name("Ysymmetry").listen();var cubeZ=folder1.add(parameters,"Zsym",[.1,.5,.8,1,1.5,2,2.5,3]).name("Light Intensity").listen();var Btable=folder1.add(parameters,"BTab",["None","Grid View"]).name("Grid View").listen();var cubeD=folder1.add(parameters,"Doption",["OFF","Anaglyph","Side-by-Side"]).name("3 D view").listen();var varyColor=folder1.add(parameters,"Rainbow",["OFF","Random","Greens","Reds","Blues","Greys","Yellow/Blue"]).name("Random Colors").listen();var Design=folder1.add(parameters,"addTetraName",tNames).name("Solid Designs");var Design2R=folder1.add(parameters,"addTetraName2R",tNames2).name("Frame Designs");var Design2=folder1.add(parameters,"addTetraName2",tNames3).name("Shapes and pipes");var Design3=folder1.add(parameters,"addTetraName3",tNames4).name("Art Designs");var Design4=folder1.add(parameters,"addTetraName4",tNames5).name("Spheres");var Design5=folder1.add(parameters,"addTextureName",texNames).name("Textures").listen();var yFile=0;for(var i=1;i<numSavedFiles;i++){if(savedFiles[i].slice(0,lth)==uLocalName){var ltx=savedFiles[i].length;yFile++;activeFiles[yFile-1]=savedFiles[i].slice(lth-ltx)}if(savedFiles[1]=="No file"){activeFiles=[". ","No file"]}}userLocalName[numUserL]=uLocalName;var f2=gui.addFolder("Save Design");f2.add(text,"Save_filename");var saveO2=f2.add(parameters,"saveOBJ2",[" "," Save... "]).name("Save").listen();console.log(numSavedFiles," Ho3",lth," userL ",savedFiles[1]);var f3=gui.addFolder("Load Design");f3.add(text,"Load_filename");var DesignLoad2=f3.add(parameters,"Load2",activeFiles).name("Load Designs").listen();var f4=gui.addFolder("Load Colours");f4.add(text,"C_filename");var CLoad2=f4.add(parameters,"LoadC",activeFiles).name("Load Colours").listen();var f5=gui.addFolder("Delete Saved Design");f5.add(text,"D_filename");var delF=f5.add(parameters,"DelFile",activeFiles).name("Delete Saved Design").listen();cubeX.onChange(function(value){Xsym=value});cubeY.onChange(function(value){Ysym=value});cubeZ.onChange(function(value){Zsym=value;lightsP[0].intensity=Zsym;lightsP[1].intensity=Zsym;lightsP[2].intensity=Zsym;directionalLight.intensity=Zsym});Btable.onChange(function(value){BTab=value;if(value=="Grid View"){var size=100;var divisions=20;gridHelper=new THREE.GridHelper(size,divisions,328965,394758);gridHelper.name="GridHelper";gridHelper.position.y=-7.8;scene.add(gridHelper);axesHelper=new THREE.AxesHelper(5);axesHelper.name="AxesHelper";axesHelper.position.y=-7.8;scene.add(axesHelper)}if(value=="None"){scene.remove(scene.getObjectByName("GridHelper"));scene.remove(scene.getObjectByName("AxesHelper"));console.log("Table removed")}});cubeD.onChange(function(value){Doption=value});varyColor.onChange(function(value){Rainbow=value;texFlag=0;console.log("Texture removed "+texFlag);camera.remove(objects[1]);lightsP[0].color.setHex(5592405);addTetraF()});Design.onChange(function(value){addTetraName=value;Design2.onChange=false;Design2R.onChange=false;Design3.onChange=false;Design4.onChange=false;if(xxx!=3&&xxx!=2&&xxx!=4&&xxx!=5){xxx=1;if(folder1.__controllers[7]!=" "){folder1.__controllers[7].setValue(" ")}Design2R.onChange=false;if(folder1.__controllers[8]!=" "){folder1.__controllers[8].setValue(" ")}Design2.onChange=false;if(folder1.__controllers[9]!=" "){folder1.__controllers[9].setValue(" ")}Design3.onChange=false;if(folder1.__controllers[10]!=" "){folder1.__controllers[10].setValue(" ")}Design4.onChange=false;addTetraFlag=tetNames.indexOf(addTetraName);camera.remove(objects[1]);lightsP[0].color.setHex(5592405);console.log(addTetraName+" addTetraName "+addTetraFlag);addTetraF()}});Design2R.onChange(function(value){addTetraName2R=value;Design.onChange=false;Design2.onChange=false;Design3.onChange=false;Design4.onChange=false;if(xxx!=1&&xxx!=3&&xxx!=4&&xxx!=5){xxx=2;if(folder1.__controllers[6]!=" "){folder1.__controllers[6].setValue(" ")}Design.onChange=false;if(folder1.__controllers[8]!=" "){folder1.__controllers[8].setValue(" ")}Design2.onChange=false;if(folder1.__controllers[9]!=" "){folder1.__controllers[9].setValue(" ")}Design3.onChange=false;if(folder1.__controllers[10]!=" "){folder1.__controllers[10].setValue(" ")}Design4.onChange=false;addTetraFlag=tetNames.indexOf(addTetraName2R);camera.remove(objects[1]);lightsP[0].color.setHex(5592405);console.log(addTetraName2+" addTetraName2 "+addTetraFlag);addTetraF()}});Design2.onChange(function(value){addTetraName2=value;Design.onChange=false;Design2R.onChange=false;Design3.onChange=false;Design4.onChange=false;if(xxx!=1&&xxx!=2&&xxx!=4&&xxx!=5){xxx=3;if(folder1.__controllers[6]!=" "){folder1.__controllers[6].setValue(" ")}Design.onChange=false;if(folder1.__controllers[7]!=" "){folder1.__controllers[7].setValue(" ")}Design2R.onChange=false;if(folder1.__controllers[9]!=" "){folder1.__controllers[9].setValue(" ")}Design3.onChange=false;if(folder1.__controllers[10]!=" "){folder1.__controllers[10].setValue(" ")}Design4.onChange=false;addTetraFlag=tetNames.indexOf(addTetraName2);camera.remove(objects[1]);lightsP[0].color.setHex(5592405);console.log(addTetraName2+" addTetraName2 "+addTetraFlag);addTetraF()}});Design3.onChange(function(value){addTetraName3=value;Design.onChange=false;Design2R.onChange=false;Design2.onChange=false;Design4.onChange=false;if(xxx!=1&&xxx!=2&&xxx!=3&&xxx!=5){xxx=4;if(folder1.__controllers[6]!=" "){folder1.__controllers[6].setValue(" ")}Design.onChange=false;if(folder1.__controllers[7]!=" "){folder1.__controllers[7].setValue(" ")}Design2R.onChange=false;if(folder1.__controllers[8]!=" "){folder1.__controllers[8].setValue(" ")}Design2.onChange=false;if(folder1.__controllers[10]!=" "){folder1.__controllers[10].setValue(" ")}Design4.onChange=false;addTetraFlag=tetNames.indexOf(addTetraName3);camera.remove(objects[1]);lightsP[0].color.setHex(5592405);console.log(addTetraName3+" addTetraName3 "+addTetraFlag);addTetraF()}});Design4.onChange(function(value){addTetraName4=value;Design.onChange=false;Design2R.onChange=false;Design2.onChange=false;Design3.onChange=false;if(xxx!=1&&xxx!=2&&xxx!=3&&xxx!=4){xxx=5;if(folder1.__controllers[6]!=" "){folder1.__controllers[6].setValue(" ")}Design.onChange=false;if(folder1.__controllers[7]!=" "){folder1.__controllers[7].setValue(" ")}Design2R.onChange=false;if(folder1.__controllers[8]!=" "){folder1.__controllers[8].setValue(" ")}Design2.onChange=false;if(folder1.__controllers[9]!=" "){folder1.__controllers[9].setValue(" ")}Design3.onChange=false;addTetraFlag=tetNames.indexOf(addTetraName4);camera.remove(objects[1]);lightsP[0].color.setHex(5592405);addTetraF()}});Design5.onChange(function(value){addTextureName=value;if(addTextureName==texNames[0]){texFlag=0}if(addTextureName==texNames[1]){texFlag=1}if(addTextureName==texNames[2]){texFlag=2}if(addTextureName==texNames[3]){texFlag=3}if(addTextureName==texNames[4]){texFlag=4}if(addTextureName==texNames[5]){texFlag=5}if(addTextureName==texNames[6]){texFlag=6}if(addTextureName==texNames[7]){texFlag=7}if(addTextureName==texNames[8]){texFlag=8}if(addTextureName==texNames[9]){texFlag=9}if(addTextureName==texNames[10]){texFlag=10}if(addTextureName==texNames[11]){texFlag=11}if(addTextureName==texNames[12]){texFlag=12}if(addTextureName==texNames[13]){texFlag=13}if(addTextureName==texNames[14]){texFlag=14}if(addTextureName==texNames[15]){texFlag=15}if(addTextureName==texNames[16]){texFlag=16}if(addTextureName==texNames[17]){texFlag=17}if(addTextureName==texNames[18]){texFlag=18}if(addTextureName=="N1"){texFlag=0}if(addTextureName=="N2"){texFlag=1}if(addTextureName=="N3"){texFlag=2}if(addTextureName=="N4"){texFlag=3}if(addTextureName=="N5"){texFlag=4}if(addTextureName=="N6"){texFlag=5}if(addTextureName=="N7"){texFlag=6}if(addTextureName=="N8"){texFlag=7}if(addTextureName=="E1"){texFlag=8}if(addTextureName=="E2"){texFlag=9}if(addTextureName=="E3"){texFlag=10}if(addTextureName=="E4"){texFlag=11}if(addTextureName=="E5"){texFlag=12}if(addTextureName=="E6"){texFlag=13}if(addTextureName=="E7"){texFlag=14}if(addTextureName=="E8"){texFlag=15}if(addTextureName=="S1"){texFlag=16}if(addTextureName=="S2"){texFlag=17}if(addTextureName=="S3"){texFlag=18}if(addTextureName=="S4"){texFlag=19}if(addTextureName=="S5"){texFlag=20}if(addTextureName=="S6"){texFlag=21}if(addTextureName=="S7"){texFlag=22}if(addTextureName=="S8"){texFlag=23}if(addTextureName=="None"){texFlag=24}if(addTextureName==""){texFlag=24}camera.remove(objects[1]);lightsP[0].color.setHex(5592405);addTetraF()});DesignLoad2.onChange(function(value){if(value==". "||value=="No file"){}else{var loadxxx=value;text.Load_filename=loadxxx;Load2=userLocalName[numUserL]+text.Load_filename;for(var i=0;i<Object.keys(gui.__folders).length;i++){var key=Object.keys(gui.__folders)[i];for(var j=0;j<gui.__folders[key].__controllers.length;j++){gui.__folders[key].__controllers[j].updateDisplay()}}parameters.Load2=" Loaded";console.log("loadingQQQz............."+Load2);loaded=LoadUserFile(Load2);console.log("loadingQQQ............."+Load2);gui.close();gui.open()}});CLoad2.onChange(function(value){if(value==". "||value=="No file"){}else{var loadxxxC=value;LoadC=value;text.C_filename=value;loadxxxC=userLocalName[numUserL]+text.Load_filename;for(var i=0;i<Object.keys(gui.__folders).length;i++){var key=Object.keys(gui.__folders)[i];for(var j=0;j<gui.__folders[key].__controllers.length;j++){gui.__folders[key].__controllers[j].updateDisplay()}}parameters.CLoad2=" Loaded";console.log("loadingQQQ............."+loadxxxC);loaded=LoadUserFileC(loadxxxC,objects);console.log("loadingQQQ............."+value);gui.close();gui.open()}});if(musicTrue==1){MLoad2.onChange(function(value){visible=value;MusicTG.stop();if(visible=="Silence"){}if(visible=="1"){playingNow=musicC[1]}if(visible=="2"){playingNow=musicC[2]}if(visible=="3"){playingNow=musicC[3]}if(visible=="4"){playingNow=musicC[4]}if(visible=="5"){playingNow=musicC[5]}if(visible=="6"){playingNow=musicC[6]}if(visible=="7"){playingNow=musicC[7]}if(visible=="8"){playingNow=musicC[8]}if(visible=="9"){playingNow=musicC[9]}if(visible=="10"){playingNow=musicC[10]}loader.load(playingNow,function(audioBuffer){MusicTG.setBuffer(audioBuffer);MusicTG.play()},function(xhr){console.log(xhr.loaded/xhr.total*100+"% loaded");console.log(playingNow+" loaded")},function(xhr){console.log("An error happened")})})}saveO2.onChange(function(value){var retrievedObjectU=localStorage.getItem("USERS");var USERS=JSON.parse(retrievedObjectU);savedFiles=USERS[0].savedFiles;numSavedFiles=USERS[0].savedFiles.length;if(savedFiles[1]=="No file"){var fileNameTet=text.Save_filename;var savename=userLocalName[numUserL]+fileNameTet;savedFiles[1]=savename}else{console.log(numSavedFiles," HoWWWWWWWWW5555555555555555555555");var fileNameTet=text.Save_filename;console.log("saving.............");text.Save_filename=fileNameTet;var savename=userLocalName[numUserL]+fileNameTet;savedFiles[numSavedFiles]=savename;console.log(userLocalName[numUserL]+" Saving users file: "+numUserL);var fileUser=savename;console.log(savename+"ddddddddddddddddddddddddddd")}var fileNameTet=text.Save_filename;var savename=userLocalName[numUserL]+fileNameTet;var fileUser=savename;exportToObj(userLocalName[numUserL],fileNameTet,fileUser,numUsers,numUserL);console.log(savename+"vvvvvvvvvvvvvvvvvvvvvvvvvvvv");numSavedFiles+=1;parameters.Load2=savedFiles;parameters.LoadC=savedFiles;parameters.DelFile=savedFiles;parameters.uLocalName=userLocalName;for(var i=0;i<Object.keys(gui.__folders).length;i++){var key=Object.keys(gui.__folders)[i];for(var j=0;j<gui.__folders[key].__controllers.length;j++){gui.__folders[key].__controllers[j].updateDisplay()}}parameters.saveOBJ2=[" "," Save... "];parameters.Load2=savedFiles;parameters.LoadC=savedFiles;parameters.DelFile=savedFiles;parameters.uLocalName=userLocalName;CLoad2.updateDisplay();console.log(".........",savedFiles[1],"........",savedFiles[2])});delF.onChange(function(value){gui.close();var fileNameTet=value;console.log("saving.............");text.D_filename=fileNameTet;var atP=savedFiles.indexOf(fileNameTet);console.log(atP+" delete this locally");localStorage.removeItem(userLocalName[numUserL]+fileNameTet);savedFiles.splice(atP,1);console.log(savedFiles[0]," ",savedFiles[1]);numSavedFiles-=1;var USERS=[{Rainbow:Rainbow,savedFiles:savedFiles,tetraName:tetraName}];userObject=JSON.stringify(USERS,null,100);var fileUser="USERS";localStorage.setItem(fileUser,userObject);parameters.Load2=savedFiles;parameters.LoadC=savedFiles;parameters.DelFile=savedFiles;parameters.uLocalSelect=userLocalName;for(var i=0;i<Object.keys(gui.__folders).length;i++){var key=Object.keys(gui.__folders)[i];for(var j=0;j<gui.__folders[key].__controllers.length;j++){gui.__folders[key].__controllers[j].updateDisplay()}}gui.open();localStorage.removeItem(userLocalName[numUserL]+fileNameTet);window.location.reload(false)});cubeColor.onChange(function(value){materials[cii]=material15;materials[cii].color.setHex(value.replace("#","0x"));Rainbow="OFF"});gui.open();console.log(Rainbow);parameters.Rainbow=Rainbow;parameters.Load2=savedFiles;parameters.LoadC=savedFiles;parameters.DelFile=savedFiles;parameters.uLocalName=userLocalName[numUserL];for(var i=0;i<Object.keys(gui.__folders).length;i++){var key=Object.keys(gui.__folders)[i];for(var j=0;j<gui.__folders[key].__controllers.length;j++){gui.__folders[key].__controllers[j].updateDisplay()}}addTetra();for(var i=0;i<Object.keys(gui.__folders).length;i++){var key=Object.keys(gui.__folders)[i];for(var j=0;j<gui.__folders[key].__controllers.length;j++){gui.__folders[key].__controllers[j].updateDisplay()}}}var newSphereGeom=new THREE.SphereGeometry(.35,.35,.35);var sphere=new THREE.Mesh(newSphereGeom,new THREE.MeshBasicMaterial({color:15658734}));scene.add(sphere);mouseSphere.push(sphere);renderer.autoClear=false;gui.close()}function updateGuiT(){parameters.Rainbow=Rainbow;parameters.Load2=savedFiles;parameters.LoadC=savedFiles;parameters.DelFile=savedFiles;parameters.uLocalName=[" ","Create_User"];parameters.uLocalSelect=userLocalName;for(var i=0;i<Object.keys(gui.__folders).length;i++){var key=Object.keys(gui.__folders)[i];for(var j=0;j<gui.__folders[key].__controllers.length;j++){gui.__folders[key].__controllers[j].updateDisplay()}}console.log("should update the gui????")}function addTetra(){console.log("addTetra 2020");console.log("addTetra 2020: ",textures[texFlag]);manager=new THREE.LoadingManager;manager.onProgress=function(item,loaded,total){};var onProgress=function(xhr){if(xhr.lengthComputable){var percentComplete=xhr.loaded/xhr.total*100}};var onError=function(xhr){};var loader=new THREE.ImageLoader(manager);loader.load(textures[texFlag],function(image){});lambert=new THREE.MeshLambertMaterial({color:materials[cii].color,map:texture2});var textureLoader=new THREE.TextureLoader;var earthTexture=textureLoader.load("roughness_map.jpg");var envMap=textureLoader.load("textures/envmap.png");envMap.mapping=THREE.SphericalReflectionMapping;var materialsx=[new THREE.MeshBasicMaterial({color:65535,wireframe:true,side:THREE.DoubleSide}),new THREE.MeshBasicMaterial({color:16711680,blending:THREE.AdditiveBlending}),new THREE.MeshLambertMaterial({color:16777215}),new THREE.MeshLambertMaterial({color:16777215}),new THREE.MeshNormalMaterial({}),new THREE.MeshBasicMaterial({envMap:earthTexture,side:THREE.DoubleSide}),new THREE.MeshBasicMaterial({envMap:envMap})];if(addTetraFlag==0){console.log("flag1111");var loader=new THREE.OBJLoader(manager);loader.load("models/obj/TextLess.obj",function(objectX){objectX.material=lambert;objectX.traverse(function(child){child.material=new THREE.MeshLambertMaterial({color:13243,map:texture2})});objectX.scale.x=.99;objectX.scale.y=.99;objectX.scale.z=.99;objects[3]=objectX.clone();objects[3].material=objectX.material.clone();var angleOb=Math.PI;var sSWi=Math.floor(window.innerWidth/60);console.log(sSWi);var sSH=window.innerHeight/80;var cxb=objects[3].position.x;var cyb=objects[3].position.y;var czb=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;objects[3].position.y=objects[3].position.y+2.7;camera.add(objects[3])});var loader=new THREE.OBJLoader(manager);loader.load(designs[0],function(objectX){objectX.traverse(function(child){child.material=new THREE.MeshLambertMaterial({color:1127338,map:texture2,side:THREE.DoubleSide})});objectX.scale.x=.99;objectX.scale.y=.99;objectX.scale.z=.99;objects[2]=objectX.clone();objects[2].material=objectX.material.clone();objects[1]=objectX.clone();objects[1].material=objectX.material.clone();object2=objectX.clone();object2.material=objectX.material.clone();var angleOb=Math.PI;var sSWi=Math.floor(window.innerWidth/60);console.log(sSWi);var sSH=window.innerHeight/80;var cxb=camera.position.x;var cyb=camera.position.y;var czb=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=sSWi/20;objects[1].position.z=objects[1].position.z;objects[1].position.y=sSH;objects[1].rotation.x=Math.PI;camera.add(objects[1]);camera.position.set(cxb,cyb,czb);console.log(cii+" numbr");targetOBJ.push(objects[1]);targetOBJ.push(objects[2]);cii=1;var loader=new THREE.TextureLoader;var map1=loader.load("textures/sprite.png");var faceColorMaterial=new THREE.MeshLambertMaterial({color:16711680,vertexColors:THREE.FaceColors,flatshading:THREE.FlatShading,polygonOffset:true,polygonOffsetUnits:1,polygonOffsetFactor:1});{var TetraGeom=new THREE.Geometry;TetraGeom.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)];TetraGeom.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)];TetraGeom.computeFaceNormals();octa=new THREE.Mesh(TetraGeom,material11);var wireOcta=new THREE.Mesh(TetraGeom,new THREE.MeshBasicMaterial({color:3342387,wireframe:true,transparent:true,opacity:1}));octa.add(wireOcta);scene.add(octa);console.log("000 OCTA added");targetList.push(octa)}console.log(("000000"+material11.color.getHex().toString(16)).slice(-6)+"gethexcol");TColour[cii]=("000000"+material11.color.getHex().toString(16)).slice(-6)},onProgress,onError)}var loader=new THREE.OBJLoader;material111=new THREE.MeshLambertMaterial({color:3355443,transparent:true,opacity:0});var size=100;var divisions=20;gridHelper=new THREE.GridHelper(size,divisions,328965,394758);gridHelper.name="GridHelper";gridHelper.position.y=-7.8;scene.add(gridHelper);axesHelper=new THREE.AxesHelper(5);axesHelper.name="AxesHelper";axesHelper.position.y=-7.8;scene.add(axesHelper)}objects1.on("click",function(){exportToObj()});function addTetraLC(cii,nametoload){var retrievedObjectB=localStorage.getItem(nametoload);retrievedObjectA=JSON.parse(retrievedObjectB);var xxb=retrievedObjectA[0].possiX[cii];var yyb=retrievedObjectA[0].possiY[cii];var zzb=retrievedObjectA[0].possiZ[cii];var xxxrot=retrievedObjectA[0].rotX[cii];var yyyrot=retrievedObjectA[0].rotY[cii];var zzzrot=retrievedObjectA[0].rotZ[cii];if(mirX[cii]==1){Xsym="ON"}if(Xsym=="ON"){console.log("YayMirX!");mirX[cii]=1}if(mirY[cii]==1){Ysym="ON"}if(Ysym=="ON"){mirY[cii]=1}if(mirXY[cii]==1){Xsym="ON";Ysym="ON"}if(Ysym=="ON"&Xsym=="ON"){mirXY[cii]=1}var manager=new THREE.LoadingManager;manager.onProgress=function(item,loaded,total){};var onProgress=function(xhr){if(xhr.lengthComputable){var percentComplete=xhr.loaded/xhr.total*100}};var onError=function(xhr){};console.log(retrievedObjectA[0].possiX[cii]," possi ");vv0x[cii]=retrievedObjectA[0].vv0x[cii];vv0y[cii]=retrievedObjectA[0].vv0y[cii];vv0z[cii]=retrievedObjectA[0].vv0z[cii];vv1x[cii]=retrievedObjectA[0].vv1x[cii];vv1y[cii]=retrievedObjectA[0].vv1y[cii];vv1z[cii]=retrievedObjectA[0].vv1z[cii];vv2x[cii]=retrievedObjectA[0].vv2x[cii];vv2y[cii]=retrievedObjectA[0].vv2y[cii];vv2z[cii]=retrievedObjectA[0].vv2z[cii];vv3x[cii]=retrievedObjectA[0].vv3x[cii];vv3y[cii]=retrievedObjectA[0].vv3y[cii];vv3z[cii]=retrievedObjectA[0].vv3z[cii];console.log(vv0x[cii]," x ",vv3z," z ",vv2y," y ");var TetraGeom=new THREE.Geometry;var ysum=vv0y+vv1y+vv2y+vv3y;var xsum=vv0x+vv1x+vv2x+vv3x;TetraGeom.vertices=[new THREE.Vector3(vv0x[cii],vv0y[cii],vv0z[cii]),new THREE.Vector3(vv1x[cii],vv1y[cii],vv1z[cii]),new THREE.Vector3(vv2x[cii],vv2y[cii],vv2z[cii]),new THREE.Vector3(vv3x[cii],vv3y[cii],vv3z[cii])];TetraGeom.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)];TetraGeom.computeFaceNormals();octa=new THREE.Mesh(TetraGeom,material11);console.log(cii+"octa------------cii");octa.name=cii;octa.userData="NONO";scene.add(octa);targetList.push(octa);if(Math.abs(xi)>.8&Xsym=="ON"){var TetraGeom=new THREE.Geometry;var xsum=vv0x+vv1x+vv2x+vv3x;TetraGeom.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)];TetraGeom.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(TetraGeom,material11);octaX.name=cii+1e3;octaX.userData="NONO";scene.add(octaX);targetList.push(octaX)}if(Math.abs(yi)>.8&Ysym=="ON"){var TetraGeom=new THREE.Geometry;var ysum=vv0y+vv1y+vv2y+vv3y;TetraGeom.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)];TetraGeom.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(TetraGeom,material11);octaY.name=cii+2e3;scene.add(octaY);octaY.userData="NONO";targetList.push(octaY)}if(Xsym=="ON"&Ysym=="ON"){var TetraGeom=new THREE.Geometry;var ysum=vv0y+vv1y+vv2y+vv3y;var xsum=vv0x+vv1x+vv2x+vv3x;TetraGeom.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)];TetraGeom.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)];if(xsum>.1&ysum<-.1){TetraGeom.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)]}if(xsum<-.1&ysum>.1){TetraGeom.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)]}if(xsum<-.1&ysum<-.1){TetraGeom.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)]}TetraGeom.computeFaceNormals();octaXY=new THREE.Mesh(TetraGeom,material11);octaXY.name=cii+3e3;octaXY.userData="NONO";scene.add(octaXY);targetList.push(octaXY)}scene.traverse(function(node){if(node instanceof THREE.Object3D){node.userData="NONO"}});scene2.traverse(function(node){if(node instanceof THREE.Object3D){node.userData="NONO"}})}function addTetraL(cii){var xxb=retrievedObjectA[0].possiX[cii];var yyb=retrievedObjectA[0].possiY[cii];var zzb=retrievedObjectA[0].possiZ[cii];var xxxrot=retrievedObjectA[0].rotX[cii];var yyyrot=retrievedObjectA[0].rotY[cii];var zzzrot=retrievedObjectA[0].rotZ[cii];var manager=new THREE.LoadingManager;manager.onProgress=function(item,loaded,total){};var onProgress=function(xhr){if(xhr.lengthComputable){var percentComplete=xhr.loaded/xhr.total*100}};var onError=function(xhr){};console.log(retrievedObjectA[0].possiX[cii]," possi ");if(addTetraFlag>tetraNum){addTetraFlag=0}if(addTetraFlag!=-1){var loader=new THREE.OBJLoader(manager);loader.load(designs[addTetraFlag],function(objectX){objectX.traverse(function(child){});objectX.scale.x=.99;objectX.scale.y=.99;objectX.scale.z=.99;objects[cii]=objectX.clone();console.log(cii,"objectsload");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];var angleOb=Math.PI;var sSWi=Math.floor(window.innerWidth/1910)*16;var sSH=window.innerHeight/60;objects[cii].position.applyMatrix4(camera.matrixWorld);objects[cii].position.x=xxb;objects[cii].position.z=zzb;objects[cii].position.y=yyb;objects[cii].position.y=yi;objects[cii].position.z=zi;objects[cii].position.x=xi;objects[cii].rotation.x=angleObx+angleOb;objects[cii].rotation.y=angleOby;objects[cii].rotation.z=angleObz;objects[cii].name=cii;objects[cii].userData=cii;objects[cii].userSTL="Y";objects[cii].userCol=TColour[cii];scene2.add(objects[cii]);scene.add(objects[cii]);objects[cii].rotation.z=angleObz;if(mirX[cii]==1){Xsym="ON"}if(Xsym=="ON"){console.log("YayMirX!");mirX[cii]=1}if(mirY[cii]==1){Ysym="ON"}if(Ysym=="ON"){mirY[cii]=1}if(mirXY[cii]==1){Xsym="ON";Ysym="ON"}if(Ysym=="ON"&Xsym=="ON"){mirXY[cii]=1}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);if(Math.abs(xi)>.8&Xsym=="ON"){objects[cii+1e3]=objectX.clone();lambert=new THREE.MeshLambertMaterial({color:TColour[cii].color,map:texture2});objects[cii+1e3].traverse(function(child){});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;objects[cii+1e3].name=cii+1e3;objects[cii+1e3].userData=cii+1e3;scene2.add(objects[cii+1e3]);scene.add(objects[cii+1e3]);objects[cii+1e3].userCol=TColour[cii];console.log(cii+"numbr"+objects[cii+1e3].name);targetOBJ.push(objects[cii+1e3])}if(Math.abs(yi)>.8&Ysym=="ON"){objects[cii+2e3]=objectX.clone();lambert=new THREE.MeshLambertMaterial({color:TColour[cii].color,map:texture2});objects[cii+2e3].traverse(function(child){});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;objects[cii+2e3].name=cii+2e3;objects[cii+2e3].userData=cii+2e3;scene2.add(objects[cii+2e3]);scene.add(objects[cii+2e3]);objects[cii+2e3].userCol=TColour[cii];console.log(cii+"numbr"+objects[cii+2e3].name);targetOBJ.push(objects[cii+2e3])}if(Math.abs(yi)>.8&Math.abs(xi)>.8&Xsym=="ON"&Ysym=="ON"){objects[cii+3e3]=objectX.clone();lambert=new THREE.MeshLambertMaterial({color:TColour[cii].color,map:texture2});objects[cii+3e3].traverse(function(child){});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;objects[cii+3e3].name=cii+3e3;objects[cii+3e3].userData=cii+3e3;objects[cii+3e3].userCol=TColour[cii];scene.add(objects[cii+3e3]);scene3.add(objects[cii+3e3]);console.log(cii+"numbr"+objects[cii+3e3].name);targetOBJ.push(objects[cii+3e3])}objects[cii].name=cii;targetOBJ.push(objects[cii].name)},onProgress,onError)}}function addTetraF(){console.log("addTetra F 2020");console.log("addTetra 2020: ",textures[texFlag]);var textureLoader=new THREE.TextureLoader;texture2=(new THREE.TextureLoader).load(textures[texFlag]);console.log(texFlag+"texFlag2020");lambert=new THREE.MeshLambertMaterial({color:1127338,map:texture2,side:THREE.DoubleSide});var manager=new THREE.LoadingManager;manager.onProgress=function(item,loaded,total){};var onProgress=function(xhr){if(xhr.lengthComputable){var percentComplete=xhr.loaded/xhr.total*100}};var onError=function(xhr){};var textureLoader=new THREE.TextureLoader;var xxb=objects[1].position.x;var yyb=objects[1].position.y;var zzb=objects[1].position.z;camera.remove(objects[1]);var cxb=camera.position.x;var cyb=camera.position.y;var czb=camera.position.z;if(addTetraFlag>tetraNum){addTetraFlag=0}if(addTetraFlag!=-1){console.log("ttt1");var loader=new THREE.OBJLoader(manager);loader.load(designs[addTetraFlag],function(objectX){objectX.material=lambert;objectX.traverse(function(child){child.material=new THREE.MeshLambertMaterial({color:material15.color,transparent:true,opacity:.9})});console.log("ttt2");objectX.scale.x=.99;objectX.scale.y=.99;objectX.scale.z=.99;camera.remove(objects[1]);scene.remove(objects[1]);objects[1]=objectX.clone();objects[1].material=objectX.material.clone();object2=objectX.clone();object2.material=objectX.material.clone();var angleOb=Math.PI;var sSWi=Math.floor(window.innerWidth/1910)*16;var sSH=window.innerHeight/60;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=xxb;objects[1].position.z=zzb;objects[1].position.y=yyb;objects[1].rotation.x=angleOb;scene.add(objects[1]);camera.add(objects[1]);console.log(" numbrx Design "+designs[addTetraFlag]);targetOBJ.push(objects[1]);var faceColorMaterial=new THREE.MeshLambertMaterial({color:16711680,vertexColors:THREE.FaceColors,flatshading:THREE.FlatShading,polygonOffset:true,polygonOffsetUnits:1,polygonOffsetFactor:1});scene.add(octa);targetList.push(octa);TColour[cii]=("000000"+material15.color.getHex().toString(16)).slice(-6)},onProgress,onError)}}function isOdd(num){return num%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(event){mouse.x=event.clientX/window.innerWidth*2-1;mouse.y=-(event.clientY/window.innerHeight)*2+1;mouseX=mouse.x;mouseY=mouse.y}function onDocumentMouseDown(event){console.log("Click.");switch(event.button){case 0:Tadd=1;if(TaddD==0){Tadd=0}console.log(TaddD+" TaddD");case 1:break;case 2:Tadd=0}mouse.x=event.clientX/window.innerWidth*2-1;mouse.y=-(event.clientY/window.innerHeight)*2+1;checkSelection()}function checkSelection(){var vector=new THREE.Vector3(mouse.x,mouse.y,.999);vector.unproject(camera);var ray=new THREE.Raycaster(camera.position,vector.sub(camera.position).normalize());var intersects=ray.intersectObjects(targetList);if(intersects.length>0&Tadd==1){console.log("function checkSelection(){"+cii);var geometry2=INTERSECTED.object.geometry;var face=INTERSECTED.face;var xia=face.normal.x;var yia=face.normal.y;var zia=face.normal.z;var vertices=geometry2.vertices;var v0=vertices[0];var v1=vertices[1];var v2=vertices[2];var v3=vertices[3];if(face.a+face.b+face.c==6){var vv0=v1;var vv1=new THREE.Vector3((v2.x+v3.x)/2+((v2.x+v3.x)/2-v0.x),(v2.y+v3.y)/2+((v2.y+v3.y)/2-v0.y),(v2.z+v3.z)/2+(v2.z+v3.z)/2-v0.z);var vv2=v2;var vv3=v3;console.log("Face 6 @ "+vv3.x)}if(face.a+face.b+face.c==5){var vv0=new THREE.Vector3((v3.x+v2.x)/2+((v3.x+v2.x)/2-v1.x),(v3.y+v2.y)/2+((v3.y+v2.y)/2-v1.y),(v3.z+v2.z)/2+(v3.z+v2.z)/2-v1.z);var vv1=v0;var vv2=v2;var vv3=v3;console.log("Face 5 @ "+vv0.x+" "+vv1.x)}if(face.a+face.b+face.c==4){var vv0=v0;var vv1=v1;var vv2=v3;var vv3=new THREE.Vector3((v0.x+v1.x)/2+((v0.x+v1.x)/2-v2.x),(v0.y+v1.y)/2+((v0.y+v1.y)/2-v2.y),(v0.z+v1.z)/2+(v0.z+v1.z)/2-v2.z);console.log("Face 4 @ "+vv0.x)}if(face.a+face.b+face.c==3){var vv0=v0;var vv1=v1;var vv2=new THREE.Vector3((v0.x+v1.x)/2+((v0.x+v1.x)/2-v3.x),(v0.y+v1.y)/2+((v0.y+v1.y)/2-v3.y),(v0.z+v1.z)/2+(v0.z+v1.z)/2-v3.z);var vv3=v2;console.log("Face 3 @ "+vv0.x)}sx=v0.x+v1.x+v2.x+v3.x;sy=v0.y+v1.y+v2.y+v3.y;sz=v0.z+v1.z+v2.z+v3.z;xi=(vv0.x+vv1.x+vv2.x+vv3.x)/4;yi=(vv0.y+vv1.y+vv2.y+vv3.y)/4;zi=(vv0.z+vv1.z+vv2.z+vv3.z)/4;angleObx=0;angleOby=0;angleObz=0;var angleOb=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=angleOb/2;console.log("gggggggggg66666666666666")}if((xi+2)/4==Math.floor((xi+2)/4)&(yi-2)/4==Math.floor((yi-2)/4)&zi/4==Math.floor(zi/4)){angleObx=angleOb;console.log("gggggggggg4444444444444444")}if((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=angleOb/2;console.log("ggggggggggg1111111111111111111")}if((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=angleOb/2;angleObz=angleOb/2;console.log("ffffffff888888888888888888")}if(xi/4==Math.floor(xi/4)&yi/4==Math.floor(yi/4)&(zi-2)/4==Math.floor((zi-2)/4)){angleObz=angleOb;console.log("ffffffff7777777777777777777")}if((xi-3)/4==Math.floor((xi-3)/4)&yi/4==Math.floor(yi/4)&(zi-3)/4==Math.floor((zi-3)/4)){angleOby=-angleOb/2;console.log("fffffffffff555555555555555")}if((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=angleOb/2;angleOby=-angleOb/2;console.log("fffffffffff444444444444")}if((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=-angleOb/2;console.log("ffffffffff666666666666666666")}if((xi-1)/4==Math.floor((xi-1)/4)&yi/4==Math.floor(yi/4)&(zi-3)/4==Math.floor((zi-3)/4)){angleOby=angleOb/2;console.log("ffffffffff666666666666666666")}if(xi/4==Math.floor(xi/4)&(yi-3)/4==Math.floor((yi-3)/4)&(zi-1)/4==Math.floor((zi-1)/4)){angleObx=angleOb/2;angleOby=angleOb;console.log("ffffffff3333333333333")}if(xi/4==Math.floor(xi/4)&yi/4==Math.floor(yi/4)&(zi+2)/4==Math.floor((zi+2)/4)){angleObx=angleOb}if(xi/4==Math.floor(xi/4)&(yi-1)/4==Math.floor((yi-1)/4)&(zi-1)/4==Math.floor((zi-1)/4)){angleObx=angleOb/2;console.log("fff000000000000000000000000")}if(cii==1){var intersect=intersects[0];var intersect=intersects[1];INTERSECTED.object.geometry.computeBoundingSphere();var vector22=INTERSECTED.object.geometry.boundingSphere.center;var OXX=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(vv0," vvo etc ",vv1," vv1",vv2," vv2 ",vv3);cii+=1;addTNew(vv0,vv1,vv2,vv3)}if(intersects.length>0&Tadd==0){var intersect=intersects[0];INTERSECTED.object.geometry.computeBoundingSphere();var vector22=INTERSECTED.object.geometry.boundingSphere.center;if(Math.abs(vector22.x)>.8){console.log(INTERSECTED.object.name+"---A-------delete this"+mirX[5]);if(mirX[INTERSECTED.object.name]==1){console.log(INTERSECTED.object.name+" B "+vector22.x+"-xxxx---------delete this");var mirrorXX=INTERSECTED.object.name+1e3;rotXX[mirrorXX-1e3]="NA";scene.remove(objects[mirrorXX])}}if(Math.abs(vector22.y)>.2){if(mirY[INTERSECTED.object.name]==1){console.log(INTERSECTED.object.name+" B "+vector22.x+"-xxxxSS---------delete this");var mirrorYY=INTERSECTED.object.name+2e3;rotYY[mirrorYY-2e3]="NA";scene.remove(objects[mirrorYY])}}if(Math.abs(vector22.y)>.2&Math.abs(vector22.x)>.8){if(mirY[INTERSECTED.object.name]==1&mirX[INTERSECTED.object.name]==1){console.log(INTERSECTED.object.name+" B "+vector22.x+"-xxxxSS---------delete this");var mirrorXY=INTERSECTED.object.name+3e3;rotXY[mirrorXY-3e3]="NA";scene.remove(objects[mirrorXY])}}rotX[INTERSECTED.object.name]="NA";scene.remove(objects[INTERSECTED.object.name]);targetList.splice(targetList.indexOf(INTERSECTED.object),1);console.log(INTERSECTED.object.name+" "+vector22.x+"-xxxx-----G----delete this")}}function addTNew(vv0,vv1,vv2,vv3){console.log("addTNew(vv0,vv1,vv2,vv3)");materials[cii]=material15;objects[cii]=object2.clone();objects[cii].material=object2.material.clone();if(Rainbow=="Random"){var tempColor=("000000"+materials[cii].color.getHex().toString(16)).slice(-6);var nextColor=Math.floor(Math.random()*98.9+1)+100*Math.floor(Math.random()*98.9+1)+1e4*Math.floor(Math.random()*98.9+1);console.log("nextcolour "+nextColor);materials[cii].color.setHex("0x"+nextColor)}if(Rainbow=="Greys"){var shade=Math.min(Math.floor(Math.random()*4+59),60);var shadeG=shade.toString(16);var nextColor="88";materials[cii].color.setHex("0x"+shadeG+shadeG+nextColor)}if(Rainbow=="Greens"){var shade=Math.floor(Math.random()*80+17);var shadeG=shade.toString(16);var nextColor="ff";materials[cii].color.setHex("0x"+shadeG+nextColor+shadeG)}if(Rainbow=="Reds"){var shade=Math.floor(Math.random()*80+17);var shadeG=shade.toString(16);var nextColor="ff";materials[cii].color.setHex("0x"+nextColor+shadeG+shadeG)}if(Rainbow=="Blues"){var shade=Math.floor(Math.random()*80+17);var shadeG=shade.toString(16);var nextColor="ff";materials[cii].color.setHex("0x"+shadeG+shadeG+nextColor)}if(Rainbow=="Yellow/Blue"){materials[cii].color.setHex(colcol);if(colcol=="0x2222cc"){colcol="0x555500"}else{colcol="0x2222cc"}materials[cii].color.setHex(colcol)}lambert=new THREE.MeshLambertMaterial({color:materials[cii].color,map:texture2});objects[cii].traverse(function(child){child.material=lambert});if(loadingF==1){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]);if(mirX[cii]==1){Xsym="ON"}if(Xsym=="ON"){console.log("YayMirX!");mirX[cii]=1}if(mirY[cii]==1){Ysym="ON"}if(Ysym=="ON"){mirY[cii]=1}if(mirXY[cii]==1){Xsym="ON";Ysym="ON"}if(Ysym=="ON"&Xsym=="ON"){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);if(Math.abs(xi)>.8&Xsym=="ON"){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(child){child.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])}else{possiYX[cii]="NA";possiZX[cii]="NA";possiXX[cii]="NA";TFlagNumX[cii]="NA";TColourX[cii]="NA";rotXX[cii]="NA";rotYX[cii]="NA";rotZX[cii]="NA"}if(Math.abs(yi)>.8&Ysym=="ON"){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(child){child.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])}else{possiYY[cii]="NA";possiZY[cii]="NA";possiXY[cii]="NA";TFlagNumY[cii]="NA";TColourY[cii]="NA";rotXY[cii]="NA";rotYY[cii]="NA";rotZY[cii]="NA"}if(Math.abs(yi)>.8&Math.abs(xi)>.8&Xsym=="ON"&Ysym=="ON"){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(child){child.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])}else{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 TetraGeom=new THREE.Geometry;var ysum=vv0.y+vv1.y+vv2.y+vv3.y;var xsum=vv0.x+vv1.x+vv2.x+vv3.x;vv0x[cii]=vv0.x;console.log(cii+"vv0x ="+vv0.x);vv0y[cii]=vv0.y;vv0z[cii]=vv0.z;vv1x[cii]=vv1.x;vv1y[cii]=vv1.y;vv1z[cii]=vv1.z;vv2x[cii]=vv2.x;vv2y[cii]=vv2.y;vv2z[cii]=vv2.z;vv3x[cii]=vv3.x;vv3y[cii]=vv3.y;vv3z[cii]=vv3.z;TetraGeom.vertices=[new THREE.Vector3(vv0.x,vv0.y,vv0.z),new THREE.Vector3(vv1.x,vv1.y,vv1.z),new THREE.Vector3(vv2.x,vv2.y,vv2.z),new THREE.Vector3(vv3.x,vv3.y,vv3.z)];TetraGeom.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)];TetraGeom.computeFaceNormals();octa=new THREE.Mesh(TetraGeom,material11);console.log(cii+"octa------------cii");octa.name=cii;scene.add(octa);targetList.push(octa);if(Math.abs(xi)>.8&Xsym=="ON"){var TetraGeom=new THREE.Geometry;var xsum=vv0.x+vv1.x+vv2.x+vv3.x;TetraGeom.vertices=[new THREE.Vector3(-vv0.x,vv0.y,vv0.z),new THREE.Vector3(-vv1.x,vv1.y,vv1.z),new THREE.Vector3(-vv2.x,vv2.y,vv2.z),new THREE.Vector3(-vv3.x,vv3.y,vv3.z)];TetraGeom.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(TetraGeom,material11);octaX.name=cii+1e3;scene.add(octaX);targetList.push(octaX)}if(Math.abs(yi)>.8&Ysym=="ON"){var TetraGeom=new THREE.Geometry;var ysum=vv0.y+vv1.y+vv2.y+vv3.y;TetraGeom.vertices=[new THREE.Vector3(vv0.x,-vv0.y,vv0.z),new THREE.Vector3(vv1.x,-vv1.y,vv1.z),new THREE.Vector3(vv2.x,-vv2.y,vv2.z),new THREE.Vector3(vv3.x,-vv3.y,vv3.z)];TetraGeom.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(TetraGeom,material11);octaY.name=cii+2e3;scene.add(octaY);targetList.push(octaY)}if(Xsym=="ON"&Ysym=="ON"){var TetraGeom=new THREE.Geometry;var ysum=vv0.y+vv1.y+vv2.y+vv3.y;var xsum=vv0.x+vv1.x+vv2.x+vv3.x;TetraGeom.vertices=[new THREE.Vector3(-vv0.x,-vv0.y,vv0.z),new THREE.Vector3(-vv1.x,-vv1.y,vv1.z),new THREE.Vector3(-vv2.x,-vv2.y,vv2.z),new THREE.Vector3(-vv3.x,-vv3.y,vv3.z)];TetraGeom.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)];if(xsum>.1&ysum<-.1){TetraGeom.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)]}if(xsum<-.1&ysum>.1){TetraGeom.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)]}if(xsum<-.1&ysum<-.1){TetraGeom.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)]}TetraGeom.computeFaceNormals();octaXY=new THREE.Mesh(TetraGeom,material11);octaXY.name=cii+3e3;scene.add(octaXY);targetList.push(octaXY)}}function onDocumentKeyDown(event){switch(event.keyCode){case 16:isShiftDown=true;break}}function onDocumentKeyUp(event){switch(event.keyCode){case 16:isShiftDown=false;break}}function animate(){requestAnimationFrame(animate);render();update()}function flyTrack(){var prevCamera=camera;var SCREEN_WIDTH=window.innerWidth,SCREEN_HEIGHT=window.innerHeight;var VIEW_ANGLE=45,ASPECT=SCREEN_WIDTH/SCREEN_HEIGHT,NEAR=.01,FAR=2e4;camera=new THREE.PerspectiveCamera(VIEW_ANGLE,ASPECT,NEAR,FAR);camera.position.copy(prevCamera.position);camera.rotation.copy(prevCamera.rotation);var MODE={TRACKBALL:0,FLY:1};switch(mode){case MODE.FLY:controls=new THREE.TrackballControls(camera);mode=MODE.TRACKBALL;break;case MODE.TRACKBALL:controls=new THREE.FlyControls(camera);mode=MODE.FLY;break}}function update(){keyboard.update();var angleOb=Math.PI;if(keyboard.pressed("A")){objects[1].traverse(function(child){child.material=lambert});objects[cii].traverse(function(child){child.material=lambert});console.log("APressed")}if(keyboard.pressed("left")){objects[1].position.x=objects[1].position.x-.5;objects[999].position.x=objects[999].position.x-.5;console.log("leftPressed")}if(keyboard.pressed("right")){objects[1].position.x=objects[1].position.x+.5;objects[999].position.x=objects[999].position.x+.5;console.log("rightPressed")}if(keyboard.pressed("down")){objects[1].position.y=objects[1].position.y-.5;objects[999].position.y=objects[999].position.y-.5;console.log("downPressed")}if(keyboard.pressed("up")){objects[1].position.y=objects[1].position.y+.5;objects[999].position.y=objects[999].position.y+.5;console.log("upPressed")}var callback=function(){objects[cii].rotation.x=gamma+angleOb/2};var callbacky=function(){objects[cii].rotation.y=gamma+angleOb/2};var callbackz=function(){objects[cii].rotation.z=gamma+angleOb/2};var callbacki=function(){objects[cii].material.opacity=.6;console.log("transparent2")};if(keyboard.pressed("X")){var gamma=objects[cii].rotation.x;console.log("upPressed");setTimeout(callback,300)}if(keyboard.pressed("Y")){var gamma=objects[cii].rotation.y;setTimeout(callbacky,300)}if(keyboard.pressed("Z")){var gamma=objects[cii].rotation.z;setTimeout(callbackz,300)}if(keyboard.pressed("F")){for(var gamma=0;gamma<=10;gamma+=1){var xxxx=gamma}addTetraFlag=addTetraFlag+1+xxxx;addTetraFlag=addTetraFlag-xxxx;camera.remove(objects[1]);addTetraF()}if(keyboard.pressed("B")){separation+=.1}if(keyboard.pressed("B")){separation-=.1}objects[1].rotation.z=objects[1].rotation.z+.01;objects[1].rotation.x=objects[1].rotation.x+0;if(objects[1].rotation.x>Math.PI*2){objects[1].rotation.x=.005}if(objects[1].rotation.z>Math.PI*2){objects[1].rotation.z=.01}objects[1].traverse(function(child){child.material=lambert});controls.update();checkHighlight();CheckMouseSphere()}function checkHighlight(){var vector=new THREE.Vector3(mouse.x,mouse.y,.999);vector.unproject(camera);var ray=new THREE.Raycaster(camera.position,vector.sub(camera.position).normalize());var intersects=ray.intersectObjects(targetList);if(intersects.length>0){if(INTERSECTED==null){INTERSECTED=intersects[0];INTERSECTED.face.color=cubeColor}else{INTERSECTED.face.color=baseColor;INTERSECTED.object.geometry.colorsNeedUpdate=true;INTERSECTED=intersects[0];INTERSECTED.face.color=cubeColor}mouseSphereCoords=[INTERSECTED.point.x,INTERSECTED.point.y,INTERSECTED.point.z];INTERSECTED.object.geometry.colorsNeedUpdate=true}else{if(INTERSECTED){INTERSECTED.face.color=baseColor;INTERSECTED.object.geometry.colorsNeedUpdate=true}INTERSECTED=null;mouseSphereCoords=null}}function checkRotation(){var xR=camera.position.x,yR=camera.position.y,zR=camera.position.z;if(keyboard.pressed("left")){camera.position.x=xR*Math.cos(rotSpeed)+zR*Math.sin(rotSpeed);camera.position.z=zR*Math.cos(rotSpeed)-xR*Math.sin(rotSpeed)}else if(keyboard.pressed("right")){camera.position.x=xR*Math.cos(rotSpeed)-zR*Math.sin(rotSpeed);camera.position.z=zR*Math.cos(rotSpeed)+xR*Math.sin(rotSpeed)}camera.lookAt(scene.position)}function CheckMouseSphere(){if(mouseSphereCoords!=null){mouseSphere[0].position.set(mouseSphereCoords[0],mouseSphereCoords[1],mouseSphereCoords[2]);mouseSphere[0].visible=true}else{mouseSphere[0].visible=false;xxx=0}}function render(){keyboard.update();var angleOb=Math.PI;if(keyboard.pressed("C")){iR=0}if(iR<360){var xR=camera.position.x,yR=camera.position.y,zR=camera.position.z;console.log(iR);camera.position.x=xR*Math.cos(iR/angleOb/3270)+zR*Math.sin(iR/angleOb/3270);camera.position.z=zR*Math.cos(iR/angleOb/3270)-xR*Math.sin(iR/angleOb/3270);camera.lookAt(scene.position)}iR=iR+1;if(iR>1e6){iR=4e3}if(Doption=="OFF"){renderer.clear();renderer.render(scene,camera)}if(Doption=="Anaglyph"){anaglyphRenderer.render(scene,camera)}if(Doption=="Side-by-Side"){OcRenderer.render(scene,camera)}}