1
0
mirror of https://github.com/Foltik/Shimapan synced 2025-01-09 09:17:14 -05:00
shimapan/public/js/index.min.js

1 line
48 KiB
JavaScript
Raw Normal View History

2017-10-20 16:46:14 -04:00
var camera={focus:600,self:{x:0,y:0,z:0},rotate:{x:0,y:0,z:0},up:{x:0,y:1,z:0},zoom:1,display:{x:window.innerWidth/2,y:.8125*window.innerHeight,z:0}},affine={world:{size:function(A,e){return{x:A.x*e.x,y:A.y*e.y,z:A.z*e.z}},rotate:{x:function(A,e){return{x:A.x,y:A.y*Math.cos(dtr(e.x))-A.z*Math.sin(dtr(e.x)),z:A.y*Math.sin(dtr(e.x))+A.z*Math.cos(dtr(e.x))}},y:function(A,e){return{x:A.x*Math.cos(dtr(e.y))+A.z*Math.sin(dtr(e.y)),y:A.y,z:-A.x*Math.sin(dtr(e.y))+A.z*Math.cos(dtr(e.y))}},z:function(A,e){return{x:A.x*Math.cos(dtr(e.z))-A.y*Math.sin(dtr(e.z)),y:A.x*Math.sin(dtr(e.z))+A.y*Math.cos(dtr(e.z)),z:A.z}}},position:function(A,e){return{x:A.x+e.x,y:A.y+e.y,z:A.z+e.z}}},view:{point:function(A){return{x:A.x-camera.self.x,y:A.y-camera.self.y,z:A.z-camera.self.z}},x:function(A){return{x:A.x,y:A.y*Math.cos(dtr(camera.rotate.x))-A.z*Math.sin(dtr(camera.rotate.x)),z:A.y*Math.sin(dtr(camera.rotate.x))+A.z*Math.cos(dtr(camera.rotate.x))}},y:function(A){return{x:A.x*Math.cos(dtr(camera.rotate.y))+A.z*Math.sin(dtr(camera.rotate.y)),y:A.y,z:A.x*-Math.sin(dtr(camera.rotate.y))+A.z*Math.cos(dtr(camera.rotate.y))}},viewReset:function(A){return{x:A.x-camera.self.x,y:A.y-camera.self.y,z:A.z-camera.self.z}},righthandedReversal:function(A){return{x:A.x,y:-A.y,z:A.z}}},perspective:function(A){return{x:A.x*((camera.focus-camera.self.z)/(camera.focus-camera.self.z-A.z))*camera.zoom,y:A.y*((camera.focus-camera.self.z)/(camera.focus-camera.self.z-A.z))*camera.zoom,z:A.z*((camera.focus-camera.self.z)/(camera.focus-camera.self.z-A.z))*camera.zoom,p:(camera.focus-camera.self.z)/(camera.focus-camera.self.z-A.z)*camera.zoom}},display:function(A,e){return{x:A.x+e.x,y:A.y+e.y,z:A.z+e.z,p:A.p}},process:function(A,e,s,t,i){var a=affine.world.size(A,e);return a=affine.world.rotate.x(a,s),a=affine.world.rotate.y(a,s),a=affine.world.rotate.z(a,s),a=affine.world.position(a,t),a=affine.view.point(a),a=affine.view.x(a),a=affine.view.y(a),a=affine.view.viewReset(a),a=affine.view.righthandedReversal(a),a=affine.perspective(a),a=affine.display(a,i)}},vertex3d=function(A){this.affineIn={},this.affineOut={},void 0!==A.vertex?this.affineIn.vertex=A.vertex:this.affineIn.vertex={x:0,y:0,z:0},void 0!==A.size?this.affineIn.size=A.size:this.affineIn.size={x:1,y:1,z:1},void 0!==A.rotate?this.affineIn.rotate=A.rotate:this.affineIn.rotate={x:0,y:0,z:0},void 0!==A.position?this.affineIn.position=A.position:this.affineIn.position={x:0,y:0,z:0}};vertex3d.prototype={vertexUpdate:function(){this.affineOut=affine.process(this.affineIn.vertex,this.affineIn.size,this.affineIn.rotate,this.affineIn.position,camera.display)}};var dtr=function(A){return A*Math.PI/180},polarToRectangle=function(A,e,s){var t=Math.sin(dtr(A))*Math.cos(dtr(e))*s;return{x:Math.sin(dtr(A))*Math.sin(dtr(e))*s,y:Math.cos(dtr(A))*s,z:t}},rectangleToPolar=function(A,e,s){var t,i,a;t=0===A?.001:A,i=0===e?.001:e,a=0===s?.001:s;var r=Math.sqrt(t*t+i*i+a*a),g=Math.atan(a/Math.sqrt(t*t+i*i)),B=Math.atan(i/t);return{x:g*(180/Math.PI),y:B*(180/Math.PI),r:r}},closeValue=function(A,e){this.flag=0,this.progress=0,this.startTime=0,this.durationTime=0,this.fromValue=0,this.toValue=0,this.minValue=0,this.maxValue=1,this.minDuration=A,this.maxDuration=e};closeValue.prototype={init:function(){return this.durationTime=this.minDuration+(this.maxDuration-this.minDuration)*Math.random(),this.startTime=Date.now(),this.progress=Math.min(1,(Date.now()-this.startTime)/this.durationTime),this.fromValue=this.toValue,this.toValue=this.minValue+this.maxValue*Math.random(),this.flag=1,this.fromValue+(this.toValue-this.fromValue)*this.progress},update:function(){return this.progress=Math.min(1,(Date.now()-this.startTime)/this.durationTime),1===this.progress&&(this.flag=0),this.fromValue+(this.toValue-this.fromValue)*this.progress},execution:function(){return 0===this.flag?this.init():1===this.flag?this.update():void 0}};var strokeColor="rgba(255,255,255,0.1)",backgroundColor="rgba(0,0,0,0)",vibrateFlag=!1,canvas=document.getElementById("canvas"),canvasWidth=window.innerWidth,canvasHeight=window.innerHeight;canvas.width=canvasWidth,canvas.h