中文(繁体)
<!-- http://www.downcodes.com/js --> <!-- bbs http://www.downcodes.com/bbs--> <head> <style> .point{ 位置:絕對;寬度:10;高度:10;背景顏色:#AAAAAA;溢出:隱藏} </style> <script> speed=4;點=新數組();角度=速度; rotXok=真; rotYok=真; rotZok=假;函數 Obj(div){return this;} objpro=Obj.prototype; objpro.moveTo=函數(x,y,z){this.x=(x);這個.y=(y);這個.z=z; } 點=新數組();函數 movemat(){ /* 2 - 1 1=1,2 2,3,7,6 // 2=3,4 1,5,8,4 3 - 4 3=5,6 4=7,8 6 - 5 5=9,10 // 6=11,12 7 - 8 7=13,14 8=15,16 */ pt1=Math.round(points[1].x); pt2=Math.floor(points[1].y); pt3=Math.floor(points[2].x); pt4=Math.floor(points[2].y); pt5=Math.floor(points[3].x); pt6=Math.floor(points[3].y); pt7=Math.floor(points[4].x); pt8=Math.floor(points[4].y); pt9=Math.floor(points[5].x); pt10=Math.floor(points[5].y); pt11=Math.floor(points[6].x); pt12=Math.floor(points[6].y); pt13=Math.floor(points[7].x); pt14=Math.floor(points[7].y); pt15=Math.floor(points[8].x); pt16=Math.floor(points[8].y); sq1="m "+pt1+","+pt2+" l "+pt3+","+pt4+" "+pt5+", "+pt6+" "+pt7+", "+pt8+" xe"; sq2="m "+pt9+","+pt10+" l "+pt11+","+pt12+" "+pt13+","+pt14+" "+pt15+","+pt16+" xe"; sq3="m "+pt3+","+pt4+" l "+pt5+","+pt6+" "+pt13+","+pt14+" "+pt11+","+pt12+" xe"; sq4="m "+pt1+","+pt2+" l "+pt9+","+pt10+" "+pt15+","+pt16+" "+pt7+","+pt8+" xe"; v1.path=sq1; v2.path=sq2; v3.path=sq3; v4.path=sq4} 函數 init(){ for(i=1; i <=8; i++){ 點[i]=new Obj('v'+i);} 點[1].x=45;點[1].y=15;點[1].z=60;點[2].x=15;點[2].y=15;點[2].z=60;點[3].x=15;點[3].y=15;點[3].z=90;點[4].x=45;點[4].y=15;點[4].z=90;點[5].x=45;點[5].y=45;點[5].z=60;點[6].x=15;點[6].y=45;點[6].z=60;點[7].x=15;點[7].y=45;點[7].z=90;點[8].x=45;點[8].y=45;點[8].z=90; for(i=1; i <=8; i++){ 點[i].moveTo(點[i].x,點[i].y,點[i].z)} } 函數 rot(){ a =degToRad(角度); a2=degToRad(角度); for(i=1; i <= 8; i++){ mat=[points[i].x,points[i].y,points[i].z-75,1]; rotX=[[1,0,0,0],[0,Math.cos(a),-Math.sin(a),0],[0,Math.sin(a),Math.cos(a) ,0],[0,0,0,1]]; rotY=[[Math.cos(a2),0,Math.sin(a2),0],[0,1,0,0],[-Math.sin(a2),0,Math.cos(a2) ,0],[0,0,0,1]]; rotZ=[[數學.cos(a),-數學.sin(a),0,0],[數學.sin(a),數學.cos(a),0,0],[0,0,1 ,0],[0,0,0,1]]; if(rotXok){mat=matrixMultiply(mat,rotX)}; if(rotYok){mat=matrixMultiply(mat,rotY)}; if(rotZok){mat=matrixMultiply(mat,rotZ)};點[i].x=mat[0];點[i].y=mat[1];點[i].z=mat[2] + 75;點[i].moveTo(點[i].x,點[i].y,點[i].z);移動墊(); setTimeout('rot()',50); } 函數矩陣乘法(A,B) { var retVal=[0,0,0]; for(var i=0;i<4;i++) { retVal[i]=0; for(var s=0;s<4;s++) retVal[i] += A[s] * B[i][s] } return retVal;圓周率=3.14159;函數 degToRad(x) { return (( x/(360/(2*pi)) )); } function rotok(oked){ Xok=document.getElementById('rotateX').checked; if(Xok){rotXok=true}else{rotXok=false} Yok=document.getElementById('rotateY').checked; if(Yok){rotYok=true}else{rotYok=false} Zok=document.getElementById('rotateZ').checked; if(Zok){rotZok=true}else{rotZok=false} } </script> <style type="text/css"> v:*{behavior:url(#default#VML);} </style> </head> <body bgcolor="black" text="darkblue"> <script> for(i=1; i <= 4; i++){ document.write('<v:shape id="v'+i+ '" 填滿= "假" 筆畫顏色= "黃色" 樣式= "位置:絕對;左:50;頂部:50;寬度:200;高度:200" coordorigin = "0, 0" coordsize = "60,60" > ' +'<v:path v="m 0,0 l 100,0 100,100 0,100 0,100 xe"/></v:shape>'); }init();rot()</script> <br><br><br> <p><font color=red>//休閒請佛教出處:建站學院。