3Dの球とパーリン・ノイズ|HTML5

3Dの球とペルリン・ノイズ|HTML5

3Dの球とペルリン・ノイズ|HTML5(HTML5, JavaScript, CSS3) : デモ

3Dの球とペルリン・ノイズ|HTML5(HTML5, JavaScript, CSS3) : ZIPファイル(24kb)

1.HTML

<!DOCTYPE html>
<html lang="jp">
    <head>
        <meta charset="UTF-8" />
        <title>3Dの球とペルリン・ノイズ|3d sphere and Perlin Noise</title>
        <link href="css/base.css" rel="stylesheet" type="text/css">
        <script src="js/devicecheck.js"></script>
        <script src="js/Perlin.js"></script>
        <script src="js/base.js"></script>
    </head>
    <body>
        <div id="contents">
            <canvas id="canvas" width="275" height="275"></canvas>
        </div>
    </body>
</html>

2.CSS

@charset "utf-8";
 
body
{
    margin:0;
    padding:0;
    background-color: #fff;
}
 
#contents
{
    position: absolute;
    top: 0;
    left: 0;
    width: 275px;
    height:275px;
    border: 1px solid #000;
    overflow:hidden;
}
 
#canvas
{
    position: absolute;
    top: 0;
    left: 0;
    width: 275px;
    height:275px;
}

#txt
{
	position: absolute;
    top: 5px;
    left: 5px;
    width: 120px;
    height:12px;
    font-size: 12px;
}

3.JavaScript

Perlin.js

// Perlin  1.0
// Ported from java (http://mrl.nyu.edu/~perlin/noise/) by Ron Valstar (http://www.sjeiti.com/)
// and some help from http://freespace.virgin.net/hugo.elias/models/m_perlin.htm
// AS3 optimizations by Mario Klingemann http://www.quasimondo.com
// then ported to js by Ron Valstar
if (!this.Perlin) {
	var Perlin = function() {

		var oRng = Math;

		var p = [151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];

		var iOctaves = 1;
		var fPersistence = 0.5;
		
		var aOctFreq; // frequency per octave
		var aOctPers; // persistence per octave
		var fPersMax; // 1 / max persistence

		var iXoffset;
		var iYoffset;
		var iZoffset;

		// octFreqPers
		var octFreqPers = function octFreqPers() {
			var fFreq, fPers;
			aOctFreq = [];
			aOctPers = [];
			fPersMax = 0;
			for (var i=0;i<iOctaves;i++) {
				fFreq = Math.pow(2,i);
				fPers = Math.pow(fPersistence,i);
				fPersMax += fPers;
				aOctFreq.push( fFreq );
				aOctPers.push( fPers );
			}
			fPersMax = 1 / fPersMax;
		};
		// setOffset
		var setOffset = function setOffset(n) {
			iXoffset = Math.floor(oRng.random()*256);
			iYoffset = Math.floor(oRng.random()*256);
			iZoffset = Math.floor(oRng.random()*256);
		};
		// init
		setOffset();
		octFreqPers();
		//
		// return
		return {
			 noise: function(x,y,z) {

				x = x||0;
				y = y||0;
				z = z||0;

				var fResult = 0;
				var fFreq, fPers;
				var xf, yf, zf, u, v, w, xx, yy, zz;
				var x1, y1, z1;
				var X, Y, Z, A, B, AA, AB, BA, BB, hash;
				var g1, g2, g3, g4, g5, g6, g7, g8;

				x += iXoffset;
				y += iYoffset;
				z += iZoffset;

				for (var i=0;i<iOctaves;i++) {
					fFreq = aOctFreq[i];
					fPers = aOctPers[i];

					xx = x * fFreq;
					yy = y * fFreq;
					zz = z * fFreq;

					xf = Math.floor(xx);
					yf = Math.floor(yy);
					zf = Math.floor(zz);

					X = Math.floor(xf & 255);
					Y = Math.floor(yf & 255);
					Z = Math.floor(zf & 255);

					xx -= xf;
					yy -= yf;
					zz -= zf;

					u = xx * xx * xx * (xx * (xx*6 - 15) + 10);
					v = yy * yy * yy * (yy * (yy*6 - 15) + 10);
					w = zz * zz * zz * (zz * (zz*6 - 15) + 10);

					A  = Math.round(p[X]) + Y;
					AA = Math.round(p[A]) + Z;
					AB = Math.round(p[Math.round(A+1)]) + Z;
					B  = Math.round(p[Math.round(X+1)]) + Y;
					BA = Math.round(p[B]) + Z;
					BB = Math.round(p[Math.round(B+1)]) + Z;

					x1 = xx-1;
					y1 = yy-1;
					z1 = zz-1;

					hash = Math.round(p[Math.round(BB+1)]) & 15;
					g1 = ((hash&1) === 0 ? (hash<8 ? x1 : y1) : (hash<8 ? -x1 : -y1)) + ((hash&2) === 0 ? hash<4 ? y1 : ( hash===12 ? x1 : z1 ) : hash<4 ? -y1 : ( hash===14 ? -x1 : -z1 ));

					hash = Math.round(p[Math.round(AB+1)]) & 15;
					g2 = ((hash&1) === 0 ? (hash<8 ? xx : y1) : (hash<8 ? -xx : -y1)) + ((hash&2) === 0 ? hash<4 ? y1 : ( hash===12 ? xx : z1 ) : hash<4 ? -y1 : ( hash===14 ? -xx : -z1 ));

					hash = Math.round(p[Math.round(BA+1)]) & 15;
					g3 = ((hash&1) === 0 ? (hash<8 ? x1 : yy) : (hash<8 ? -x1 : -yy)) + ((hash&2) === 0 ? hash<4 ? yy : ( hash===12 ? x1 : z1 ) : hash<4 ? -yy : ( hash===14 ? -x1 : -z1 ));

					hash = Math.round(p[Math.round(AA+1)]) & 15;
					g4 = ((hash&1) === 0 ? (hash<8 ? xx : yy) : (hash<8 ? -xx : -yy)) + ((hash&2) === 0 ? hash<4 ? yy : ( hash===12 ? xx : z1 ) : hash<4 ? -yy : ( hash===14 ? -xx : -z1 ));

					hash = Math.round(p[BB]) & 15;
					g5 = ((hash&1) === 0 ? (hash<8 ? x1 : y1) : (hash<8 ? -x1 : -y1)) + ((hash&2) === 0 ? hash<4 ? y1 : ( hash===12 ? x1 : zz ) : hash<4 ? -y1 : ( hash===14 ? -x1 : -zz ));

					hash = Math.round(p[AB]) & 15;
					g6 = ((hash&1) === 0 ? (hash<8 ? xx : y1) : (hash<8 ? -xx : -y1)) + ((hash&2) === 0 ? hash<4 ? y1 : ( hash===12 ? xx : zz ) : hash<4 ? -y1 : ( hash===14 ? -xx : -zz ));

					hash = Math.round(p[BA]) & 15;
					g7 = ((hash&1) === 0 ? (hash<8 ? x1 : yy) : (hash<8 ? -x1 : -yy)) + ((hash&2) === 0 ? hash<4 ? yy : ( hash===12 ? x1 : zz ) : hash<4 ? -yy : ( hash===14 ? -x1 : -zz ));

					hash = Math.round(p[AA]) & 15;
					g8 = ((hash&1) === 0 ? (hash<8 ? xx : yy) : (hash<8 ? -xx : -yy)) + ((hash&2) === 0 ? hash<4 ? yy : ( hash===12 ? xx : zz ) : hash<4 ? -yy : ( hash===14 ? -xx : -zz ));

					g2 += u * (g1 - g2);
					g4 += u * (g3 - g4);
					g6 += u * (g5 - g6);
					g8 += u * (g7 - g8);

					g4 += v * (g2 - g4);
					g8 += v * (g6 - g8);

					fResult += ( (g8 + w * (g4 - g8))) * fPers;
				}

				return ( fResult * fPersMax + 1 ) * 0.5;
			},noiseDetail: function(octaves,falloff) {
				iOctaves = octaves||iOctaves;
				fPersistence = falloff||fPersistence;
				octFreqPers();
			},setRng: function(r) {
				oRng = r;
				setOffset();
				octFreqPers();
			},toString: function() {
				return "[object Perlin "+iOctaves+" "+fPersistence+"]";
			}
		};
	}();
}

devicecheck.js

var g_mobiledevice = false;	//iPhone、iPad、Androidのときtrue
var g_browsername = 'unknown';
var g_browserver = -1;

if(checkUserAgent() == false)
{
	window.alert('このブラウザは対象外です');
}

function checkUserAgent()
{
	var ua = navigator.userAgent;

	//iPhoneか?	
	var mstr = ua.match(/iPhone OS \d+/);
	if(mstr != null){
		var vstr = mstr[0].match(/\d+/);
		if(parseInt(vstr[0]) >= 3) 
		{
			g_mobiledevice = true;
			g_browsername = 'iPhone';
			//alert('major-version ' + vstr);
			return true;
		}
	}
	//iPadか?
	if(ua.indexOf('iPad') > -1)
	{
		mstr = ua.match(/CPU OS \d+/);
		if(mstr != null)
		{
			var vstr = mstr[0].match(/\d+/);
			if(parseInt(vstr[0]) >= 3) {
				g_mobiledevice = true;
				g_browsername = 'iPad';
				//alert('major-version ' + vstr);
				return true;
			}		
		}		
	}	
	//Androidか?	
	var mstr = ua.match(/Android \d+\.\d+/);
	if(mstr != null)
	{
		g_browsername = 'Android';
		var vstr = mstr[0].match(/\d+\.\d+/);
		g_browserver = parseFloat(vstr[0]);
		g_mobiledevice = true;
		if(pg_browserver > 2.1) 
		{
			//alert('version ' + vstr);
			return true;
		}
	}
	//Chromeか?
	mstr = ua.match(/Chrome\/\d+/);
	if(mstr != null)
	{
		g_browsername = 'Chrome';
		var vstr = mstr[0].match(/\d+/);
		g_browserver = parseInt(vstr[0]);
		if(g_browserver >= 9) 
		{
			//alert('major-version ' + vstr);
			
			return true;
		}		
	}
	//Safariか?
	if(ua.indexOf('Safari') > -1)
	{
		mstr = ua.match(/Version\/\d+/);
		if(mstr != null){
			var vstr = mstr[0].match(/\d+/);
			if(parseInt(vstr[0]) >= 5) 
			{
				g_browsername = 'Safari';
				//alert('major-version ' + vstr);
				return true;
			}		
		}		
	}
	//Internet Explorerか?
	mstr = ua.match(/MSIE \d+/);
	if(mstr != null)
	{
		var vstr = mstr[0].match(/\d+/);
		if(parseInt(vstr[0]) >= 9) 
		{
			g_browsername = 'MSIE';
			//alert('major-version ' + vstr);
			return true;
		}		
	}
	//Firefoxか?
	mstr = ua.match(/Firefox\/\d+/);
	if(mstr != null){
		var vstr = mstr[0].match(/\d+/);
		if(parseInt(vstr[0]) >= 4) 
		{
			g_browsername = 'Firefox';
			//alert('major-version ' + vstr);
			return true;
		}		
	}
	//Operaか?
	if(ua.indexOf('Opera') > -1)
	{
		mstr = ua.match(/Version\/\d+/);
		if(mstr != null){
			var vstr = mstr[0].match(/\d+/);
			if(parseInt(vstr[0]) >= 11) 
			{
				g_browsername = 'Opera';
				//alert('major-version ' + vstr);
				return true;
			}		
		}		
	}
	
	return false;
}

base.js

window.addEventListener("load", init, false);
  
function init()
{
    var offsetX = 0,
    offsetY = 0,
    ctx,
    points = [],
    radii = [],
    triangles = [],
    fl = 250,
    vpX = 0,
    vpY = 0,
    mouseX = 0,
    mouseY = 0,
    buttonDown,
    buttonMove,
    buttonUp,
    light,
    len = 1,
    theContents;
     
    theContents = document.getElementById("contents");
    offsetX = (theContents.currentStyle || document.defaultView.getComputedStyle(theContents,'')).width;
    offsetX = Number(offsetX.replace('px', ''));
  
    offsetY = (theContents.currentStyle || document.defaultView.getComputedStyle(theContents,'')).height;
    offsetY = Number(offsetY.replace('px', ''));
     
    vpX = offsetX / 2;
    vpY = offsetY / 2;
    
    ctx = document.getElementById('canvas').getContext("2d");
     
    //ボタンタイプ
    if(g_mobiledevice === true)
    {
        buttonDown = 'touchstart';
        buttonMove = 'touchmove';
        buttonUp = 'touchend';
    }
    else
    {
        buttonDown = 'mousedown';
        buttonMove = 'mousemove';
        buttonUp = 'mouseup';
    }
     
    document.getElementById('canvas').addEventListener('touchstart', function() 
    {
        event.preventDefault();
    });
    document.getElementById('canvas').addEventListener('touchmove', function() 
    {
        event.preventDefault();
    });
    document.getElementById('canvas').addEventListener('touchend', function() 
    {
        event.preventDefault();
    });
     
    document.getElementById('canvas').addEventListener(buttonMove, mouseMoveHandler, false);
    
    var pg_0 = [];
    pg_0.push({x:-1.836909530733566e-16, y:-1, z:0});
	pg_0.push({x:0.1950903220161283, y:-0.9807852804032305, z:0});
	pg_0.push({x:0.38268343236508995, y:-0.9238795325112866, z:0});
	pg_0.push({x:0.5555702330196018, y:-0.8314696123025455, z:0});
	pg_0.push({x:0.7071067811865475, y:-0.7071067811865477, z:0});
	pg_0.push({x:0.8314696123025452, y:-0.5555702330196022, z:0});
	pg_0.push({x:0.9238795325112867, y:-0.38268343236508956, z:0});
	pg_0.push({x:0.9807852804032303, y:-0.19509032201612872, z:0});
	pg_0.push({x:1, y:-2.4492127076447545e-16, z:0});
	pg_0.push({x:0.9807852804032305, y:0.19509032201612825, z:0});
	pg_0.push({x:0.9238795325112871, y:0.3826834323650891, z:0});
	pg_0.push({x:0.8314696123025455, y:0.5555702330196018, z:0});
	pg_0.push({x:0.7071067811865483, y:0.7071067811865467, z:0});
	pg_0.push({x:0.5555702330196023, y:0.8314696123025452, z:0});
	pg_0.push({x:0.3826834323650896, y:0.9238795325112867, z:0});
	pg_0.push({x:0.19509032201612878, y:0.9807852804032303, z:0});
	pg_0.push({x:3.061515884555943e-16, y:1, z:0}); 
	
    var pg_1 = [];
    pg_1.push({x:-1.8016138291758867e-16, y:-1, z:-3.583632718653064e-17});
	pg_1.push({x:0.19134171618254492, y:-0.9807852804032305, z:0.038060233744356624});
	pg_1.push({x:0.3753302775178654, y:-0.9238795325112866, z:0.07465783405034264});
	pg_1.push({x:0.5448951067758183, y:-0.8314696123025455, z:0.10838637566236953});
	pg_1.push({x:0.6935199226610735, y:-0.7071067811865477, z:0.13794968964147147});
	pg_1.push({x:0.8154931568489171, y:-0.5555702330196022, z:0.16221167441072887});
	pg_1.push({x:0.9061274463528879, y:-0.38268343236508956, z:0.180239955501737});
	pg_1.push({x:0.9619397662556434, y:-0.19509032201612872, z:0.19134171618254484});
	pg_1.push({x:0.9807852804032305, y:-2.4492127076447545e-16, z:0.19509032201612825});
	pg_1.push({x:0.9619397662556435, y:0.19509032201612825, z:0.1913417161825449});
	pg_1.push({x:0.9061274463528882, y:0.3826834323650891, z:0.18023995550173702});
	pg_1.push({x:0.8154931568489174, y:0.5555702330196018, z:0.1622116744107289});
	pg_1.push({x:0.6935199226610745, y:0.7071067811865467, z:0.13794968964147167});
	pg_1.push({x:0.5448951067758186, y:0.8314696123025452, z:0.10838637566236961});
	pg_1.push({x:0.3753302775178651, y:0.9238795325112867, z:0.07465783405034257});
	pg_1.push({x:0.19134171618254536, y:0.9807852804032303, z:0.03806023374435672});
	pg_1.push({x:3.002689715293145e-16, y:1, z:5.972721197755106e-17});
    
    var pg_2 = [];
    pg_2.push({x:-1.697083118519654e-16, y:-1, z:-7.029548441652674e-17});
	pg_2.push({x:0.180239955501737, y:-0.9807852804032305, z:0.07465783405034261});
	pg_2.push({x:0.3535533905932739, y:-0.9238795325112866, z:0.14644660940672632});
	pg_2.push({x:0.5132799671593364, y:-0.8314696123025455, z:0.21260752369181396});
	pg_2.push({x:0.6532814824381882, y:-0.7071067811865477, z:0.27059805007309845});
	pg_2.push({x:0.7681777567114163, y:-0.5555702330196022, z:0.31818964514320847});
	pg_2.push({x:0.8535533905932737, y:-0.38268343236508956, z:0.3535533905932738});
	pg_2.push({x:0.9061274463528878, y:-0.19509032201612872, z:0.3753302775178652});
	pg_2.push({x:0.9238795325112867, y:-2.4492127076447545e-16, z:0.3826834323650898});
	pg_2.push({x:0.9061274463528879, y:0.19509032201612825, z:0.3753302775178653});
	pg_2.push({x:0.8535533905932741, y:0.3826834323650891, z:0.3535533905932739});
	pg_2.push({x:0.7681777567114166, y:0.5555702330196018, z:0.3181896451432086});
	pg_2.push({x:0.6532814824381891, y:0.7071067811865467, z:0.27059805007309884});
	pg_2.push({x:0.5132799671593368, y:0.8314696123025452, z:0.21260752369181415});
	pg_2.push({x:0.3535533905932736, y:0.9238795325112867, z:0.14644660940672619});
	pg_2.push({x:0.18023995550173744, y:0.9807852804032303, z:0.0746578340503428});
	pg_2.push({x:2.8284718641994235e-16, y:1, z:1.1715914069421123e-16}); 
	
    var pg_3 = [];
    pg_3.push({x:-1.5273344553538884e-16, y:-1, z:-1.0205322560255752e-16});
	pg_3.push({x:0.1622116744107289, y:-0.9807852804032305, z:0.10838637566236961});
	pg_3.push({x:0.31818964514320863, y:-0.9238795325112866, z:0.2126075236918142});
	pg_3.push({x:0.4619397662556431, y:-0.8314696123025455, z:0.30865828381745486});
	pg_3.push({x:0.5879378012096792, y:-0.7071067811865477, z:0.392847479193551});
	pg_3.push({x:0.6913417161825448, y:-0.5555702330196022, z:0.4619397662556433});
	pg_3.push({x:0.7681777567114163, y:-0.38268343236508956, z:0.5132799671593368});
	pg_3.push({x:0.8154931568489171, y:-0.19509032201612872, z:0.5448951067758185});
	pg_3.push({x:0.8314696123025452, y:-2.4492127076447545e-16, z:0.5555702330196022});
	pg_3.push({x:0.8154931568489172, y:0.19509032201612825, z:0.5448951067758186});
	pg_3.push({x:0.7681777567114166, y:0.3826834323650891, z:0.5132799671593369});
	pg_3.push({x:0.6913417161825451, y:0.5555702330196018, z:0.4619397662556435});
	pg_3.push({x:0.5879378012096801, y:0.7071067811865467, z:0.39284747919355156});
	pg_3.push({x:0.46193976625564337, y:0.8314696123025452, z:0.30865828381745514});
	pg_3.push({x:0.31818964514320836, y:0.9238795325112867, z:0.21260752369181402});
	pg_3.push({x:0.1622116744107293, y:0.9807852804032303, z:0.1083863756623699});
	pg_3.push({x:2.5455574255898137e-16, y:1, z:1.700887093375959e-16}); 
	
    var pg_4 = [];
    pg_4.push({x:-1.2988911856079034e-16, y:-1, z:-1.2988911856079032e-16});
	pg_4.push({x:0.13794968964147153, y:-0.9807852804032305, z:0.1379496896414715});
	pg_4.push({x:0.2705980500730987, y:-0.9238795325112866, z:0.2705980500730986});
	pg_4.push({x:0.39284747919355084, y:-0.8314696123025455, z:0.3928474791935508});
	pg_4.push({x:0.49999999999999994, y:-0.7071067811865477, z:0.49999999999999983});
	pg_4.push({x:0.5879378012096794, y:-0.5555702330196022, z:0.5879378012096792});
	pg_4.push({x:0.6532814824381883, y:-0.38268343236508956, z:0.6532814824381882});
	pg_4.push({x:0.6935199226610738, y:-0.19509032201612872, z:0.6935199226610735});
	pg_4.push({x:0.7071067811865476, y:-2.4492127076447545e-16, z:0.7071067811865475});
	pg_4.push({x:0.6935199226610739, y:0.19509032201612825, z:0.6935199226610738});
	pg_4.push({x:0.6532814824381886, y:0.3826834323650891, z:0.6532814824381884});
	pg_4.push({x:0.5879378012096796, y:0.5555702330196018, z:0.5879378012096794});
	pg_4.push({x:0.5000000000000007, y:0.7071067811865467, z:0.5000000000000006});
	pg_4.push({x:0.3928474791935512, y:0.8314696123025452, z:0.3928474791935511});
	pg_4.push({x:0.2705980500730984, y:0.9238795325112867, z:0.2705980500730984});
	pg_4.push({x:0.1379496896414719, y:0.9807852804032303, z:0.13794968964147186});
	pg_4.push({x:2.164818642679839e-16, y:1, z:2.1648186426798387e-16});
    
    var pg_5 = [];
    pg_5.push({x:-1.0205322560255755e-16, y:-1, z:-1.5273344553538884e-16});
	pg_5.push({x:0.10838637566236964, y:-0.9807852804032305, z:0.1622116744107289});
	pg_5.push({x:0.21260752369181424, y:-0.9238795325112866, z:0.31818964514320863});
	pg_5.push({x:0.30865828381745497, y:-0.8314696123025455, z:0.4619397662556431});
	pg_5.push({x:0.39284747919355106, y:-0.7071067811865477, z:0.5879378012096792});
	pg_5.push({x:0.46193976625564337, y:-0.5555702330196022, z:0.6913417161825448});
	pg_5.push({x:0.5132799671593368, y:-0.38268343236508956, z:0.7681777567114163});
	pg_5.push({x:0.5448951067758186, y:-0.19509032201612872, z:0.8154931568489171});
	pg_5.push({x:0.5555702330196023, y:-2.4492127076447545e-16, z:0.8314696123025452});
	pg_5.push({x:0.5448951067758188, y:0.19509032201612825, z:0.8154931568489172});
	pg_5.push({x:0.513279967159337, y:0.3826834323650891, z:0.7681777567114166});
	pg_5.push({x:0.46193976625564354, y:0.5555702330196018, z:0.6913417161825451});
	pg_5.push({x:0.3928474791935516, y:0.7071067811865467, z:0.5879378012096801});
	pg_5.push({x:0.3086582838174552, y:0.8314696123025452, z:0.46193976625564337});
	pg_5.push({x:0.21260752369181404, y:0.9238795325112867, z:0.31818964514320836});
	pg_5.push({x:0.10838637566236992, y:0.9807852804032303, z:0.1622116744107293});
	pg_5.push({x:1.7008870933759592e-16, y:1, z:2.5455574255898137e-16}); 
    
    var pg_6 = [];
    pg_6.push({x:-7.029548441652675e-17, y:-1, z:-1.697083118519654e-16});
	pg_6.push({x:0.07465783405034263, y:-0.9807852804032305, z:0.180239955501737});
	pg_6.push({x:0.14644660940672632, y:-0.9238795325112866, z:0.3535533905932739});
	pg_6.push({x:0.21260752369181402, y:-0.8314696123025455, z:0.5132799671593364});
	pg_6.push({x:0.27059805007309845, y:-0.7071067811865477, z:0.6532814824381882});
	pg_6.push({x:0.3181896451432085, y:-0.5555702330196022, z:0.7681777567114163});
	pg_6.push({x:0.35355339059327384, y:-0.38268343236508956, z:0.8535533905932737});
	pg_6.push({x:0.3753302775178653, y:-0.19509032201612872, z:0.9061274463528878});
	pg_6.push({x:0.38268343236508984, y:-2.4492127076447545e-16, z:0.9238795325112867});
	pg_6.push({x:0.37533027751786535, y:0.19509032201612825, z:0.9061274463528879});
	pg_6.push({x:0.3535533905932739, y:0.3826834323650891, z:0.8535533905932741});
	pg_6.push({x:0.31818964514320863, y:0.5555702330196018, z:0.7681777567114166});
	pg_6.push({x:0.2705980500730989, y:0.7071067811865467, z:0.6532814824381891});
	pg_6.push({x:0.21260752369181418, y:0.8314696123025452, z:0.5132799671593368});
	pg_6.push({x:0.1464466094067262, y:0.9238795325112867, z:0.3535533905932736});
	pg_6.push({x:0.07465783405034282, y:0.9807852804032303, z:0.18023995550173744});
	pg_6.push({x:1.1715914069421125e-16, y:1, z:2.8284718641994235e-16});
    
    var pg_7 = [];
    pg_7.push({x:-3.583632718653065e-17, y:-1, z:-1.8016138291758867e-16});
	pg_7.push({x:0.03806023374435664, y:-0.9807852804032305, z:0.19134171618254492});
	pg_7.push({x:0.07465783405034267, y:-0.9238795325112866, z:0.3753302775178654});
	pg_7.push({x:0.10838637566236958, y:-0.8314696123025455, z:0.5448951067758183});
	pg_7.push({x:0.13794968964147153, y:-0.7071067811865477, z:0.6935199226610735});
	pg_7.push({x:0.16221167441072892, y:-0.5555702330196022, z:0.8154931568489171});
	pg_7.push({x:0.18023995550173705, y:-0.38268343236508956, z:0.9061274463528879});
	pg_7.push({x:0.19134171618254492, y:-0.19509032201612872, z:0.9619397662556434});
	pg_7.push({x:0.19509032201612833, y:-2.4492127076447545e-16, z:0.9807852804032305});
	pg_7.push({x:0.19134171618254495, y:0.19509032201612825, z:0.9619397662556435});
	pg_7.push({x:0.18023995550173708, y:0.3826834323650891, z:0.9061274463528882});
	pg_7.push({x:0.16221167441072898, y:0.5555702330196018, z:0.8154931568489174});
	pg_7.push({x:0.13794968964147172, y:0.7071067811865467, z:0.6935199226610745});
	pg_7.push({x:0.10838637566236967, y:0.8314696123025452, z:0.5448951067758186});
	pg_7.push({x:0.0746578340503426, y:0.9238795325112867, z:0.3753302775178651});
	pg_7.push({x:0.038060233744356735, y:0.9807852804032303, z:0.19134171618254536});
	pg_7.push({x:5.972721197755109e-17, y:1, z:3.002689715293145e-16});
    
    var pg_8 = [];
    pg_8.push({x:-1.1247455413666031e-32, y:-1, z:-1.836909530733566e-16});
	pg_8.push({x:1.1945442395510214e-17, y:-0.9807852804032305, z:0.1950903220161283});
	pg_8.push({x:2.343182813884226e-17, y:-0.9238795325112866, z:0.38268343236508995});
	pg_8.push({x:3.401774186751916e-17, y:-0.8314696123025455, z:0.5555702330196018});
	pg_8.push({x:4.3296372853596765e-17, y:-0.7071067811865477, z:0.7071067811865475});
	pg_8.push({x:5.0911148511796277e-17, y:-0.5555702330196022, z:0.8314696123025452});
	pg_8.push({x:5.656943728398846e-17, y:-0.38268343236508956, z:0.9238795325112867});
	pg_8.push({x:6.005379430586289e-17, y:-0.19509032201612872, z:0.9807852804032303});
	pg_8.push({x:6.123031769111886e-17, y:-2.4492127076447545e-16, z:1});
	pg_8.push({x:6.00537943058629e-17, y:0.19509032201612825, z:0.9807852804032305});
	pg_8.push({x:5.656943728398849e-17, y:0.3826834323650891, z:0.9238795325112871});
	pg_8.push({x:5.0911148511796295e-17, y:0.5555702330196018, z:0.8314696123025455});
	pg_8.push({x:4.329637285359683e-17, y:0.7071067811865467, z:0.7071067811865483});
	pg_8.push({x:3.401774186751918e-17, y:0.8314696123025452, z:0.5555702330196023});
	pg_8.push({x:2.3431828138842235e-17, y:0.9238795325112867, z:0.3826834323650896});
	pg_8.push({x:1.1945442395510247e-17, y:0.9807852804032303, z:0.19509032201612878});
	pg_8.push({x:1.8745759022776718e-32, y:1, z:3.061515884555943e-16});
    
    var pg_9 = [];
    pg_9.push({x:3.583632718653059e-17, y:-1, z:-1.801613829175887e-16});
	pg_9.push({x:-0.03806023374435657, y:-0.9807852804032305, z:0.19134171618254492});
	pg_9.push({x:-0.07465783405034253, y:-0.9238795325112866, z:0.37533027751786546});
	pg_9.push({x:-0.10838637566236939, y:-0.8314696123025455, z:0.5448951067758183});
	pg_9.push({x:-0.13794968964147128, y:-0.7071067811865477, z:0.6935199226610738});
	pg_9.push({x:-0.16221167441072862, y:-0.5555702330196022, z:0.8154931568489172});
	pg_9.push({x:-0.1802399555017367, y:-0.38268343236508956, z:0.9061274463528879});
	pg_9.push({x:-0.19134171618254459, y:-0.19509032201612872, z:0.9619397662556434});
	pg_9.push({x:-0.19509032201612797, y:-2.4492127076447545e-16, z:0.9807852804032305});
	pg_9.push({x:-0.19134171618254459, y:0.19509032201612825, z:0.9619397662556435});
	pg_9.push({x:-0.18023995550173677, y:0.3826834323650891, z:0.9061274463528882});
	pg_9.push({x:-0.16221167441072867, y:0.5555702330196018, z:0.8154931568489174});
	pg_9.push({x:-0.13794968964147147, y:0.7071067811865467, z:0.6935199226610745});
	pg_9.push({x:-0.10838637566236946, y:0.8314696123025452, z:0.5448951067758188});
	pg_9.push({x:-0.07465783405034246, y:0.9238795325112867, z:0.37533027751786513});
	pg_9.push({x:-0.038060233744356665, y:0.9807852804032303, z:0.19134171618254542});
	pg_9.push({x:-5.972721197755098e-17, y:1, z:3.002689715293145e-16}); 
    
    var pg_10 = [];
    pg_10.push({x:7.029548441652673e-17, y:-1, z:-1.697083118519654e-16});
	pg_10.push({x:-0.0746578340503426, y:-0.9807852804032305, z:0.180239955501737});
	pg_10.push({x:-0.1464466094067263, y:-0.9238795325112866, z:0.3535533905932739});
	pg_10.push({x:-0.21260752369181393, y:-0.8314696123025455, z:0.5132799671593364});
	pg_10.push({x:-0.2705980500730984, y:-0.7071067811865477, z:0.6532814824381882});
	pg_10.push({x:-0.3181896451432084, y:-0.5555702330196022, z:0.7681777567114163});
	pg_10.push({x:-0.35355339059327373, y:-0.38268343236508956, z:0.8535533905932737});
	pg_10.push({x:-0.3753302775178652, y:-0.19509032201612872, z:0.9061274463528878});
	pg_10.push({x:-0.3826834323650898, y:-2.4492127076447545e-16, z:0.9238795325112867});
	pg_10.push({x:-0.3753302775178652, y:0.19509032201612825, z:0.9061274463528879});
	pg_10.push({x:-0.35355339059327384, y:0.3826834323650891, z:0.8535533905932741});
	pg_10.push({x:-0.3181896451432085, y:0.5555702330196018, z:0.7681777567114166});
	pg_10.push({x:-0.2705980500730988, y:0.7071067811865467, z:0.6532814824381891});
	pg_10.push({x:-0.2126075236918141, y:0.8314696123025452, z:0.5132799671593368});
	pg_10.push({x:-0.14644660940672616, y:0.9238795325112867, z:0.3535533905932736});
	pg_10.push({x:-0.0746578340503428, y:0.9807852804032303, z:0.18023995550173744});
	pg_10.push({x:-1.171591406942112e-16, y:1, z:2.8284718641994235e-16});
    
    var pg_11 = [];
    pg_11.push({x:1.0205322560255755e-16, y:-1, z:-1.527334455353888e-16});
	pg_11.push({x:-0.10838637566236964, y:-0.9807852804032305, z:0.16221167441072887});
	pg_11.push({x:-0.21260752369181424, y:-0.9238795325112866, z:0.31818964514320863});
	pg_11.push({x:-0.30865828381745497, y:-0.8314696123025455, z:0.46193976625564304});
	pg_11.push({x:-0.39284747919355106, y:-0.7071067811865477, z:0.5879378012096792});
	pg_11.push({x:-0.46193976625564337, y:-0.5555702330196022, z:0.6913417161825447});
	pg_11.push({x:-0.5132799671593368, y:-0.38268343236508956, z:0.7681777567114163});
	pg_11.push({x:-0.5448951067758186, y:-0.19509032201612872, z:0.815493156848917});
	pg_11.push({x:-0.5555702330196023, y:-2.4492127076447545e-16, z:0.8314696123025452});
	pg_11.push({x:-0.5448951067758188, y:0.19509032201612825, z:0.8154931568489171});
	pg_11.push({x:-0.513279967159337, y:0.3826834323650891, z:0.7681777567114164});
	pg_11.push({x:-0.46193976625564354, y:0.5555702330196018, z:0.691341716182545});
	pg_11.push({x:-0.3928474791935516, y:0.7071067811865467, z:0.58793780120968});
	pg_11.push({x:-0.3086582838174552, y:0.8314696123025452, z:0.46193976625564337});
	pg_11.push({x:-0.21260752369181404, y:0.9238795325112867, z:0.3181896451432083});
	pg_11.push({x:-0.10838637566236992, y:0.9807852804032303, z:0.16221167441072928});
	pg_11.push({x:-1.7008870933759592e-16, y:1, z:2.5455574255898137e-16});
    
    var pg_12 = [];
    pg_12.push({x:1.2988911856079032e-16, y:-1, z:-1.2988911856079034e-16});
	pg_12.push({x:-0.1379496896414715, y:-0.9807852804032305, z:0.13794968964147153});
	pg_12.push({x:-0.2705980500730986, y:-0.9238795325112866, z:0.2705980500730987});
	pg_12.push({x:-0.3928474791935508, y:-0.8314696123025455, z:0.39284747919355084});
	pg_12.push({x:-0.49999999999999983, y:-0.7071067811865477, z:0.49999999999999994});
	pg_12.push({x:-0.5879378012096792, y:-0.5555702330196022, z:0.5879378012096794});
	pg_12.push({x:-0.6532814824381882, y:-0.38268343236508956, z:0.6532814824381883});
	pg_12.push({x:-0.6935199226610735, y:-0.19509032201612872, z:0.6935199226610738});
	pg_12.push({x:-0.7071067811865475, y:-2.4492127076447545e-16, z:0.7071067811865476});
	pg_12.push({x:-0.6935199226610738, y:0.19509032201612825, z:0.6935199226610739});
	pg_12.push({x:-0.6532814824381884, y:0.3826834323650891, z:0.6532814824381886});
	pg_12.push({x:-0.5879378012096794, y:0.5555702330196018, z:0.5879378012096796});
	pg_12.push({x:-0.5000000000000006, y:0.7071067811865467, z:0.5000000000000007});
	pg_12.push({x:-0.3928474791935511, y:0.8314696123025452, z:0.3928474791935512});
	pg_12.push({x:-0.2705980500730984, y:0.9238795325112867, z:0.2705980500730984});
	pg_12.push({x:-0.13794968964147186, y:0.9807852804032303, z:0.1379496896414719});
	pg_12.push({x:-2.1648186426798387e-16, y:1, z:2.164818642679839e-16}); 

    var pg_13 = [];
    pg_13.push({x:1.5273344553538887e-16, y:-1, z:-1.0205322560255752e-16});
	pg_13.push({x:-0.16221167441072892, y:-0.9807852804032305, z:0.10838637566236961});
	pg_13.push({x:-0.3181896451432087, y:-0.9238795325112866, z:0.2126075236918142});
	pg_13.push({x:-0.4619397662556431, y:-0.8314696123025455, z:0.30865828381745486});
	pg_13.push({x:-0.5879378012096793, y:-0.7071067811865477, z:0.392847479193551});
	pg_13.push({x:-0.691341716182545, y:-0.5555702330196022, z:0.4619397662556433});
	pg_13.push({x:-0.7681777567114164, y:-0.38268343236508956, z:0.5132799671593368});
	pg_13.push({x:-0.8154931568489172, y:-0.19509032201612872, z:0.5448951067758185});
	pg_13.push({x:-0.8314696123025453, y:-2.4492127076447545e-16, z:0.5555702330196022});
	pg_13.push({x:-0.8154931568489172, y:0.19509032201612825, z:0.5448951067758186});
	pg_13.push({x:-0.7681777567114167, y:0.3826834323650891, z:0.5132799671593369});
	pg_13.push({x:-0.6913417161825451, y:0.5555702330196018, z:0.4619397662556435});
	pg_13.push({x:-0.5879378012096802, y:0.7071067811865467, z:0.39284747919355156});
	pg_13.push({x:-0.4619397662556435, y:0.8314696123025452, z:0.30865828381745514});
	pg_13.push({x:-0.3181896451432084, y:0.9238795325112867, z:0.21260752369181402});
	pg_13.push({x:-0.1622116744107293, y:0.9807852804032303, z:0.1083863756623699});
	pg_13.push({x:-2.545557425589814e-16, y:1, z:1.700887093375959e-16}); 
    
    var pg_14 = [];
    pg_14.push({x:1.697083118519654e-16, y:-1, z:-7.029548441652676e-17});
	pg_14.push({x:-0.180239955501737, y:-0.9807852804032305, z:0.07465783405034264});
	pg_14.push({x:-0.3535533905932739, y:-0.9238795325112866, z:0.14644660940672638});
	pg_14.push({x:-0.5132799671593364, y:-0.8314696123025455, z:0.21260752369181404});
	pg_14.push({x:-0.6532814824381882, y:-0.7071067811865477, z:0.27059805007309856});
	pg_14.push({x:-0.7681777567114163, y:-0.5555702330196022, z:0.3181896451432086});
	pg_14.push({x:-0.8535533905932737, y:-0.38268343236508956, z:0.3535533905932739});
	pg_14.push({x:-0.9061274463528878, y:-0.19509032201612872, z:0.37533027751786535});
	pg_14.push({x:-0.9238795325112867, y:-2.4492127076447545e-16, z:0.3826834323650899});
	pg_14.push({x:-0.9061274463528879, y:0.19509032201612825, z:0.3753302775178654});
	pg_14.push({x:-0.8535533905932741, y:0.3826834323650891, z:0.353553390593274});
	pg_14.push({x:-0.7681777567114166, y:0.5555702330196018, z:0.3181896451432087});
	pg_14.push({x:-0.6532814824381891, y:0.7071067811865467, z:0.2705980500730989});
	pg_14.push({x:-0.5132799671593368, y:0.8314696123025452, z:0.2126075236918142});
	pg_14.push({x:-0.3535533905932736, y:0.9238795325112867, z:0.1464466094067262});
	pg_14.push({x:-0.18023995550173744, y:0.9807852804032303, z:0.07465783405034282});
	pg_14.push({x:-2.8284718641994235e-16, y:1, z:1.1715914069421125e-16});
    
    var pg_15 = [];
    pg_15.push({x:1.8016138291758867e-16, y:-1, z:-3.583632718653062e-17});
	pg_15.push({x:-0.19134171618254492, y:-0.9807852804032305, z:0.0380602337443566});
	pg_15.push({x:-0.3753302775178654, y:-0.9238795325112866, z:0.0746578340503426});
	pg_15.push({x:-0.5448951067758183, y:-0.8314696123025455, z:0.10838637566236949});
	pg_15.push({x:-0.6935199226610735, y:-0.7071067811865477, z:0.13794968964147142});
	pg_15.push({x:-0.8154931568489171, y:-0.5555702330196022, z:0.16221167441072878});
	pg_15.push({x:-0.9061274463528879, y:-0.38268343236508956, z:0.18023995550173688});
	pg_15.push({x:-0.9619397662556434, y:-0.19509032201612872, z:0.19134171618254478});
	pg_15.push({x:-0.9807852804032305, y:-2.4492127076447545e-16, z:0.19509032201612814});
	pg_15.push({x:-0.9619397662556435, y:0.19509032201612825, z:0.1913417161825448});
	pg_15.push({x:-0.9061274463528882, y:0.3826834323650891, z:0.18023995550173694});
	pg_15.push({x:-0.8154931568489174, y:0.5555702330196018, z:0.1622116744107288});
	pg_15.push({x:-0.6935199226610745, y:0.7071067811865467, z:0.1379496896414716});
	pg_15.push({x:-0.5448951067758186, y:0.8314696123025452, z:0.10838637566236957});
	pg_15.push({x:-0.3753302775178651, y:0.9238795325112867, z:0.07465783405034253});
	pg_15.push({x:-0.19134171618254536, y:0.9807852804032303, z:0.0380602337443567});
	pg_15.push({x:-3.002689715293145e-16, y:1, z:5.972721197755104e-17}); 
    
    var pg_16 = [];
    pg_16.push({x:1.836909530733566e-16, y:-1, z:-2.2494910827332062e-32});
	pg_16.push({x:-0.1950903220161283, y:-0.9807852804032305, z:2.389088479102043e-17});
	pg_16.push({x:-0.38268343236508995, y:-0.9238795325112866, z:4.686365627768452e-17});
	pg_16.push({x:-0.5555702330196018, y:-0.8314696123025455, z:6.803548373503832e-17});
	pg_16.push({x:-0.7071067811865475, y:-0.7071067811865477, z:8.659274570719353e-17});
	pg_16.push({x:-0.8314696123025452, y:-0.5555702330196022, z:1.0182229702359255e-16});
	pg_16.push({x:-0.9238795325112867, y:-0.38268343236508956, z:1.1313887456797693e-16});
	pg_16.push({x:-0.9807852804032303, y:-0.19509032201612872, z:1.2010758861172578e-16});
	pg_16.push({x:-1, y:-2.4492127076447545e-16, z:1.2246063538223773e-16});
	pg_16.push({x:-0.9807852804032305, y:0.19509032201612825, z:1.201075886117258e-16});
	pg_16.push({x:-0.9238795325112871, y:0.3826834323650891, z:1.1313887456797698e-16});
	pg_16.push({x:-0.8314696123025455, y:0.5555702330196018, z:1.0182229702359259e-16});
	pg_16.push({x:-0.7071067811865483, y:0.7071067811865467, z:8.659274570719367e-17});
	pg_16.push({x:-0.5555702330196023, y:0.8314696123025452, z:6.803548373503836e-17});
	pg_16.push({x:-0.3826834323650896, y:0.9238795325112867, z:4.686365627768447e-17});
	pg_16.push({x:-0.19509032201612878, y:0.9807852804032303, z:2.3890884791020493e-17});
	pg_16.push({x:-3.061515884555943e-16, y:1, z:3.7491518045553436e-32}); 
    
    var pg_17 = [];
    pg_17.push({x:1.801613829175887e-16, y:-1, z:3.583632718653058e-17});
	pg_17.push({x:-0.19134171618254492, y:-0.9807852804032305, z:-0.038060233744356554});
	pg_17.push({x:-0.37533027751786546, y:-0.9238795325112866, z:-0.0746578340503425});
	pg_17.push({x:-0.5448951067758183, y:-0.8314696123025455, z:-0.10838637566236935});
	pg_17.push({x:-0.6935199226610738, y:-0.7071067811865477, z:-0.13794968964147125});
	pg_17.push({x:-0.8154931568489172, y:-0.5555702330196022, z:-0.1622116744107286});
	pg_17.push({x:-0.9061274463528879, y:-0.38268343236508956, z:-0.18023995550173666});
	pg_17.push({x:-0.9619397662556434, y:-0.19509032201612872, z:-0.19134171618254453});
	pg_17.push({x:-0.9807852804032305, y:-2.4492127076447545e-16, z:-0.1950903220161279});
	pg_17.push({x:-0.9619397662556435, y:0.19509032201612825, z:-0.19134171618254456});
	pg_17.push({x:-0.9061274463528882, y:0.3826834323650891, z:-0.18023995550173674});
	pg_17.push({x:-0.8154931568489174, y:0.5555702330196018, z:-0.16221167441072862});
	pg_17.push({x:-0.6935199226610745, y:0.7071067811865467, z:-0.13794968964147145});
	pg_17.push({x:-0.5448951067758188, y:0.8314696123025452, z:-0.10838637566236944});
	pg_17.push({x:-0.37533027751786513, y:0.9238795325112867, z:-0.07465783405034244});
	pg_17.push({x:-0.19134171618254542, y:0.9807852804032303, z:-0.03806023374435665});
	pg_17.push({x:-3.002689715293145e-16, y:1, z:-5.972721197755096e-17}); 
    
    var pg_18 = [];
    pg_18.push({x:1.6970831185196544e-16, y:-1, z:7.029548441652664e-17});
	pg_18.push({x:-0.18023995550173705, y:-0.9807852804032305, z:-0.0746578340503425});
	pg_18.push({x:-0.35355339059327406, y:-0.9238795325112866, z:-0.1464466094067261});
	pg_18.push({x:-0.5132799671593365, y:-0.8314696123025455, z:-0.21260752369181368});
	pg_18.push({x:-0.6532814824381883, y:-0.7071067811865477, z:-0.27059805007309806});
	pg_18.push({x:-0.7681777567114164, y:-0.5555702330196022, z:-0.318189645143208});
	pg_18.push({x:-0.853553390593274, y:-0.38268343236508956, z:-0.3535533905932733});
	pg_18.push({x:-0.9061274463528879, y:-0.19509032201612872, z:-0.3753302775178647});
	pg_18.push({x:-0.923879532511287, y:-2.4492127076447545e-16, z:-0.3826834323650893});
	pg_18.push({x:-0.9061274463528881, y:0.19509032201612825, z:-0.3753302775178647});
	pg_18.push({x:-0.8535533905932742, y:0.3826834323650891, z:-0.35355339059327334});
	pg_18.push({x:-0.7681777567114167, y:0.5555702330196018, z:-0.31818964514320813});
	pg_18.push({x:-0.6532814824381892, y:0.7071067811865467, z:-0.27059805007309845});
	pg_18.push({x:-0.5132799671593369, y:0.8314696123025452, z:-0.21260752369181382});
	pg_18.push({x:-0.35355339059327373, y:0.9238795325112867, z:-0.14644660940672596});
	pg_18.push({x:-0.18023995550173752, y:0.9807852804032303, z:-0.07465783405034271});
	pg_18.push({x:-2.828471864199424e-16, y:1, z:-1.1715914069421105e-16});
    
    var pg_19 = [];
    pg_19.push({x:1.5273344553538884e-16, y:-1, z:1.0205322560255755e-16});
	pg_19.push({x:-0.1622116744107289, y:-0.9807852804032305, z:-0.10838637566236964});
	pg_19.push({x:-0.31818964514320863, y:-0.9238795325112866, z:-0.21260752369181424});
	pg_19.push({x:-0.4619397662556431, y:-0.8314696123025455, z:-0.30865828381745497});
	pg_19.push({x:-0.5879378012096792, y:-0.7071067811865477, z:-0.39284747919355106});
	pg_19.push({x:-0.6913417161825448, y:-0.5555702330196022, z:-0.46193976625564337});
	pg_19.push({x:-0.7681777567114163, y:-0.38268343236508956, z:-0.5132799671593368});
	pg_19.push({x:-0.8154931568489171, y:-0.19509032201612872, z:-0.5448951067758186});
	pg_19.push({x:-0.8314696123025452, y:-2.4492127076447545e-16, z:-0.5555702330196023});
	pg_19.push({x:-0.8154931568489172, y:0.19509032201612825, z:-0.5448951067758188});
	pg_19.push({x:-0.7681777567114166, y:0.3826834323650891, z:-0.513279967159337});
	pg_19.push({x:-0.6913417161825451, y:0.5555702330196018, z:-0.46193976625564354});
	pg_19.push({x:-0.5879378012096801, y:0.7071067811865467, z:-0.3928474791935516});
	pg_19.push({x:-0.46193976625564337, y:0.8314696123025452, z:-0.3086582838174552});
	pg_19.push({x:-0.31818964514320836, y:0.9238795325112867, z:-0.21260752369181404});
	pg_19.push({x:-0.1622116744107293, y:0.9807852804032303, z:-0.10838637566236992});
	pg_19.push({x:-2.5455574255898137e-16, y:1, z:-1.7008870933759592e-16});
    
    var pg_20 = [];
    pg_20.push({x:1.2988911856079034e-16, y:-1, z:1.2988911856079032e-16});
	pg_20.push({x:-0.13794968964147156, y:-0.9807852804032305, z:-0.1379496896414715});
	pg_20.push({x:-0.2705980500730987, y:-0.9238795325112866, z:-0.2705980500730986});
	pg_20.push({x:-0.3928474791935509, y:-0.8314696123025455, z:-0.3928474791935508});
	pg_20.push({x:-0.5, y:-0.7071067811865477, z:-0.49999999999999983});
	pg_20.push({x:-0.5879378012096794, y:-0.5555702330196022, z:-0.5879378012096792});
	pg_20.push({x:-0.6532814824381884, y:-0.38268343236508956, z:-0.6532814824381882});
	pg_20.push({x:-0.6935199226610739, y:-0.19509032201612872, z:-0.6935199226610735});
	pg_20.push({x:-0.7071067811865477, y:-2.4492127076447545e-16, z:-0.7071067811865475});
	pg_20.push({x:-0.6935199226610739, y:0.19509032201612825, z:-0.6935199226610738});
	pg_20.push({x:-0.6532814824381886, y:0.3826834323650891, z:-0.6532814824381884});
	pg_20.push({x:-0.5879378012096796, y:0.5555702330196018, z:-0.5879378012096794});
	pg_20.push({x:-0.5000000000000007, y:0.7071067811865467, z:-0.5000000000000006});
	pg_20.push({x:-0.3928474791935512, y:0.8314696123025452, z:-0.3928474791935511});
	pg_20.push({x:-0.27059805007309845, y:0.9238795325112867, z:-0.2705980500730984});
	pg_20.push({x:-0.13794968964147192, y:0.9807852804032303, z:-0.13794968964147186});
	pg_20.push({x:-2.1648186426798392e-16, y:1, z:-2.1648186426798387e-16});
    
    var pg_21 = [];
    pg_21.push({x:1.0205322560255767e-16, y:-1, z:1.5273344553538874e-16});
	pg_21.push({x:-0.10838637566236978, y:-0.9807852804032305, z:-0.1622116744107288});
	pg_21.push({x:-0.2126075236918145, y:-0.9238795325112866, z:-0.31818964514320847});
	pg_21.push({x:-0.3086582838174553, y:-0.8314696123025455, z:-0.4619397662556428});
	pg_21.push({x:-0.39284747919355156, y:-0.7071067811865477, z:-0.587937801209679});
	pg_21.push({x:-0.461939766255644, y:-0.5555702330196022, z:-0.6913417161825444});
	pg_21.push({x:-0.5132799671593374, y:-0.38268343236508956, z:-0.7681777567114159});
	pg_21.push({x:-0.5448951067758193, y:-0.19509032201612872, z:-0.8154931568489167});
	pg_21.push({x:-0.555570233019603, y:-2.4492127076447545e-16, z:-0.8314696123025448});
	pg_21.push({x:-0.5448951067758194, y:0.19509032201612825, z:-0.8154931568489168});
	pg_21.push({x:-0.5132799671593375, y:0.3826834323650891, z:-0.7681777567114162});
	pg_21.push({x:-0.4619397662556441, y:0.5555702330196018, z:-0.6913417161825447});
	pg_21.push({x:-0.3928474791935521, y:0.7071067811865467, z:-0.5879378012096798});
	pg_21.push({x:-0.3086582838174555, y:0.8314696123025452, z:-0.4619397662556432});
	pg_21.push({x:-0.21260752369181432, y:0.9238795325112867, z:-0.3181896451432082});
	pg_21.push({x:-0.10838637566237004, y:0.9807852804032303, z:-0.16221167441072923});
	pg_21.push({x:-1.7008870933759612e-16, y:1, z:-2.5455574255898127e-16}); 
    
    var pg_22 = [];
    pg_22.push({x:7.029548441652669e-17, y:-1, z:1.697083118519654e-16});
	pg_22.push({x:-0.07465783405034256, y:-0.9807852804032305, z:-0.18023995550173702});
	pg_22.push({x:-0.1464466094067262, y:-0.9238795325112866, z:-0.353553390593274});
	pg_22.push({x:-0.21260752369181382, y:-0.8314696123025455, z:-0.5132799671593364});
	pg_22.push({x:-0.2705980500730983, y:-0.7071067811865477, z:-0.6532814824381882});
	pg_22.push({x:-0.31818964514320824, y:-0.5555702330196022, z:-0.7681777567114163});
	pg_22.push({x:-0.3535533905932735, y:-0.38268343236508956, z:-0.853553390593274});
	pg_22.push({x:-0.3753302775178649, y:-0.19509032201612872, z:-0.9061274463528879});
	pg_22.push({x:-0.38268343236508945, y:-2.4492127076447545e-16, z:-0.9238795325112867});
	pg_22.push({x:-0.37533027751786496, y:0.19509032201612825, z:-0.9061274463528879});
	pg_22.push({x:-0.3535533905932736, y:0.3826834323650891, z:-0.8535533905932742});
	pg_22.push({x:-0.31818964514320836, y:0.5555702330196018, z:-0.7681777567114166});
	pg_22.push({x:-0.2705980500730987, y:0.7071067811865467, z:-0.6532814824381892});
	pg_22.push({x:-0.21260752369181402, y:0.8314696123025452, z:-0.5132799671593369});
	pg_22.push({x:-0.14644660940672607, y:0.9238795325112867, z:-0.3535533905932736});
	pg_22.push({x:-0.07465783405034275, y:0.9807852804032303, z:-0.18023995550173746});
	pg_22.push({x:-1.1715914069421115e-16, y:1, z:-2.8284718641994235e-16}); 
    
    var pg_23 = [];
    pg_23.push({x:3.583632718653072e-17, y:-1, z:1.8016138291758867e-16});
	pg_23.push({x:-0.0380602337443567, y:-0.9807852804032305, z:-0.1913417161825449});
	pg_23.push({x:-0.0746578340503428, y:-0.9238795325112866, z:-0.3753302775178654});
	pg_23.push({x:-0.10838637566236976, y:-0.8314696123025455, z:-0.5448951067758182});
	pg_23.push({x:-0.13794968964147178, y:-0.7071067811865477, z:-0.6935199226610735});
	pg_23.push({x:-0.16221167441072917, y:-0.5555702330196022, z:-0.815493156848917});
	pg_23.push({x:-0.18023995550173733, y:-0.38268343236508956, z:-0.9061274463528878});
	pg_23.push({x:-0.19134171618254528, y:-0.19509032201612872, z:-0.9619397662556431});
	pg_23.push({x:-0.1950903220161287, y:-2.4492127076447545e-16, z:-0.9807852804032303});
	pg_23.push({x:-0.19134171618254528, y:0.19509032201612825, z:-0.9619397662556434});
	pg_23.push({x:-0.1802399555017374, y:0.3826834323650891, z:-0.9061274463528881});
	pg_23.push({x:-0.16221167441072926, y:0.5555702330196018, z:-0.8154931568489172});
	pg_23.push({x:-0.13794968964147197, y:0.7071067811865467, z:-0.6935199226610744});
	pg_23.push({x:-0.10838637566236985, y:0.8314696123025452, z:-0.5448951067758186});
	pg_23.push({x:-0.07465783405034272, y:0.9238795325112867, z:-0.3753302775178651});
	pg_23.push({x:-0.0380602337443568, y:0.9807852804032303, z:-0.19134171618254536});
	pg_23.push({x:-5.972721197755119e-17, y:1, z:-3.0026897152931443e-16}); 
    
    var pg_24 = [];
    pg_24.push({x:3.374236624099809e-32, y:-1, z:1.836909530733566e-16});
	pg_24.push({x:-3.5836327186530646e-17, y:-0.9807852804032305, z:-0.1950903220161283});
	pg_24.push({x:-7.029548441652677e-17, y:-0.9238795325112866, z:-0.38268343236508995});
	pg_24.push({x:-1.0205322560255746e-16, y:-0.8314696123025455, z:-0.5555702330196018});
	pg_24.push({x:-1.298891185607903e-16, y:-0.7071067811865477, z:-0.7071067811865475});
	pg_24.push({x:-1.5273344553538884e-16, y:-0.5555702330196022, z:-0.8314696123025452});
	pg_24.push({x:-1.697083118519654e-16, y:-0.38268343236508956, z:-0.9238795325112867});
	pg_24.push({x:-1.8016138291758867e-16, y:-0.19509032201612872, z:-0.9807852804032303});
	pg_24.push({x:-1.836909530733566e-16, y:-2.4492127076447545e-16, z:-1});
	pg_24.push({x:-1.801613829175887e-16, y:0.19509032201612825, z:-0.9807852804032305});
	pg_24.push({x:-1.6970831185196547e-16, y:0.3826834323650891, z:-0.9238795325112871});
	pg_24.push({x:-1.5273344553538887e-16, y:0.5555702330196018, z:-0.8314696123025455});
	pg_24.push({x:-1.298891185607905e-16, y:0.7071067811865467, z:-0.7071067811865483});
	pg_24.push({x:-1.0205322560255755e-16, y:0.8314696123025452, z:-0.5555702330196023});
	pg_24.push({x:-7.029548441652671e-17, y:0.9238795325112867, z:-0.3826834323650896});
	pg_24.push({x:-3.583632718653074e-17, y:0.9807852804032303, z:-0.19509032201612878});
	pg_24.push({x:-5.623727706833015e-32, y:1, z:-3.061515884555943e-16}); 
    
    var pg_25 = [];
    pg_25.push({x:-3.5836327186530646e-17, y:-1, z:1.8016138291758867e-16});
	pg_25.push({x:0.03806023374435664, y:-0.9807852804032305, z:-0.19134171618254492});
	pg_25.push({x:0.07465783405034265, y:-0.9238795325112866, z:-0.3753302775178654});
	pg_25.push({x:0.10838637566236957, y:-0.8314696123025455, z:-0.5448951067758183});
	pg_25.push({x:0.1379496896414715, y:-0.7071067811865477, z:-0.6935199226610735});
	pg_25.push({x:0.1622116744107289, y:-0.5555702330196022, z:-0.8154931568489171});
	pg_25.push({x:0.18023995550173702, y:-0.38268343236508956, z:-0.9061274463528879});
	pg_25.push({x:0.19134171618254492, y:-0.19509032201612872, z:-0.9619397662556434});
	pg_25.push({x:0.1950903220161283, y:-2.4492127076447545e-16, z:-0.9807852804032305});
	pg_25.push({x:0.19134171618254492, y:0.19509032201612825, z:-0.9619397662556435});
	pg_25.push({x:0.18023995550173708, y:0.3826834323650891, z:-0.9061274463528882});
	pg_25.push({x:0.16221167441072898, y:0.5555702330196018, z:-0.8154931568489174});
	pg_25.push({x:0.1379496896414717, y:0.7071067811865467, z:-0.6935199226610745});
	pg_25.push({x:0.10838637566236965, y:0.8314696123025452, z:-0.5448951067758186});
	pg_25.push({x:0.07465783405034258, y:0.9238795325112867, z:-0.3753302775178651});
	pg_25.push({x:0.03806023374435673, y:0.9807852804032303, z:-0.19134171618254536});
	pg_25.push({x:5.972721197755107e-17, y:1, z:-3.002689715293145e-16});
    
    var pg_26 = [];
    pg_26.push({x:-7.029548441652677e-17, y:-1, z:1.6970831185196537e-16});
	pg_26.push({x:0.07465783405034265, y:-0.9807852804032305, z:-0.180239955501737});
	pg_26.push({x:0.1464466094067264, y:-0.9238795325112866, z:-0.3535533905932739});
	pg_26.push({x:0.2126075236918141, y:-0.8314696123025455, z:-0.5132799671593363});
	pg_26.push({x:0.2705980500730986, y:-0.7071067811865477, z:-0.6532814824381881});
	pg_26.push({x:0.31818964514320863, y:-0.5555702330196022, z:-0.7681777567114162});
	pg_26.push({x:0.353553390593274, y:-0.38268343236508956, z:-0.8535533905932736});
	pg_26.push({x:0.3753302775178654, y:-0.19509032201612872, z:-0.9061274463528877});
	pg_26.push({x:0.38268343236508995, y:-2.4492127076447545e-16, z:-0.9238795325112866});
	pg_26.push({x:0.37533027751786546, y:0.19509032201612825, z:-0.9061274463528878});
	pg_26.push({x:0.3535533905932741, y:0.3826834323650891, z:-0.853553390593274});
	pg_26.push({x:0.31818964514320874, y:0.5555702330196018, z:-0.7681777567114164});
	pg_26.push({x:0.270598050073099, y:0.7071067811865467, z:-0.6532814824381891});
	pg_26.push({x:0.21260752369181424, y:0.8314696123025452, z:-0.5132799671593368});
	pg_26.push({x:0.14644660940672627, y:0.9238795325112867, z:-0.35355339059327356});
	pg_26.push({x:0.07465783405034285, y:0.9807852804032303, z:-0.18023995550173744});
	pg_26.push({x:1.171591406942113e-16, y:1, z:-2.828471864199423e-16}); 
    
    var pg_27 = [];
    pg_27.push({x:-1.0205322560255746e-16, y:-1, z:1.5273344553538887e-16});
	pg_27.push({x:0.10838637566236957, y:-0.9807852804032305, z:-0.16221167441072892});
	pg_27.push({x:0.21260752369181407, y:-0.9238795325112866, z:-0.31818964514320874});
	pg_27.push({x:0.3086582838174547, y:-0.8314696123025455, z:-0.4619397662556432});
	pg_27.push({x:0.3928474791935508, y:-0.7071067811865477, z:-0.5879378012096794});
	pg_27.push({x:0.46193976625564304, y:-0.5555702330196022, z:-0.691341716182545});
	pg_27.push({x:0.5132799671593364, y:-0.38268343236508956, z:-0.7681777567114166});
	pg_27.push({x:0.5448951067758182, y:-0.19509032201612872, z:-0.8154931568489172});
	pg_27.push({x:0.5555702330196018, y:-2.4492127076447545e-16, z:-0.8314696123025455});
	pg_27.push({x:0.5448951067758183, y:0.19509032201612825, z:-0.8154931568489174});
	pg_27.push({x:0.5132799671593365, y:0.3826834323650891, z:-0.7681777567114167});
	pg_27.push({x:0.4619397662556432, y:0.5555702330196018, z:-0.6913417161825453});
	pg_27.push({x:0.39284747919355134, y:0.7071067811865467, z:-0.5879378012096802});
	pg_27.push({x:0.30865828381745497, y:0.8314696123025452, z:-0.46193976625564354});
	pg_27.push({x:0.2126075236918139, y:0.9238795325112867, z:-0.3181896451432084});
	pg_27.push({x:0.10838637566236983, y:0.9807852804032303, z:-0.16221167441072937});
	pg_27.push({x:1.7008870933759577e-16, y:1, z:-2.5455574255898147e-16});
    
    var pg_28 = [];
    pg_28.push({x:-1.298891185607903e-16, y:-1, z:1.2988911856079034e-16});
	pg_28.push({x:0.13794968964147147, y:-0.9807852804032305, z:-0.13794968964147156});
	pg_28.push({x:0.27059805007309856, y:-0.9238795325112866, z:-0.2705980500730987});
	pg_28.push({x:0.3928474791935508, y:-0.8314696123025455, z:-0.3928474791935509});
	pg_28.push({x:0.4999999999999998, y:-0.7071067811865477, z:-0.5});
	pg_28.push({x:0.5879378012096792, y:-0.5555702330196022, z:-0.5879378012096794});
	pg_28.push({x:0.6532814824381882, y:-0.38268343236508956, z:-0.6532814824381884});
	pg_28.push({x:0.6935199226610734, y:-0.19509032201612872, z:-0.6935199226610739});
	pg_28.push({x:0.7071067811865475, y:-2.4492127076447545e-16, z:-0.7071067811865477});
	pg_28.push({x:0.6935199226610735, y:0.19509032201612825, z:-0.6935199226610739});
	pg_28.push({x:0.6532814824381883, y:0.3826834323650891, z:-0.6532814824381886});
	pg_28.push({x:0.5879378012096794, y:0.5555702330196018, z:-0.5879378012096796});
	pg_28.push({x:0.5000000000000004, y:0.7071067811865467, z:-0.5000000000000007});
	pg_28.push({x:0.39284747919355106, y:0.8314696123025452, z:-0.3928474791935512});
	pg_28.push({x:0.2705980500730983, y:0.9238795325112867, z:-0.27059805007309845});
	pg_28.push({x:0.13794968964147183, y:0.9807852804032303, z:-0.13794968964147192});
	pg_28.push({x:2.1648186426798385e-16, y:1, z:-2.1648186426798392e-16}); 
    
    var pg_29 = [];
    pg_29.push({x:-1.5273344553538884e-16, y:-1, z:1.0205322560255752e-16});
	pg_29.push({x:0.1622116744107289, y:-0.9807852804032305, z:-0.10838637566236961});
	pg_29.push({x:0.31818964514320863, y:-0.9238795325112866, z:-0.2126075236918142});
	pg_29.push({x:0.4619397662556431, y:-0.8314696123025455, z:-0.30865828381745486});
	pg_29.push({x:0.5879378012096792, y:-0.7071067811865477, z:-0.392847479193551});
	pg_29.push({x:0.6913417161825448, y:-0.5555702330196022, z:-0.4619397662556433});
	pg_29.push({x:0.7681777567114163, y:-0.38268343236508956, z:-0.5132799671593368});
	pg_29.push({x:0.8154931568489171, y:-0.19509032201612872, z:-0.5448951067758185});
	pg_29.push({x:0.8314696123025452, y:-2.4492127076447545e-16, z:-0.5555702330196022});
	pg_29.push({x:0.8154931568489172, y:0.19509032201612825, z:-0.5448951067758186});
	pg_29.push({x:0.7681777567114166, y:0.3826834323650891, z:-0.5132799671593369});
	pg_29.push({x:0.6913417161825451, y:0.5555702330196018, z:-0.4619397662556435});
	pg_29.push({x:0.5879378012096801, y:0.7071067811865467, z:-0.39284747919355156});
	pg_29.push({x:0.46193976625564337, y:0.8314696123025452, z:-0.30865828381745514});
	pg_29.push({x:0.31818964514320836, y:0.9238795325112867, z:-0.21260752369181402});
	pg_29.push({x:0.1622116744107293, y:0.9807852804032303, z:-0.1083863756623699});
	pg_29.push({x:2.5455574255898137e-16, y:1, z:-1.700887093375959e-16}); 
    
    var pg_30 = [];
    pg_30.push({x:-1.697083118519654e-16, y:-1, z:7.029548441652669e-17});
	pg_30.push({x:0.18023995550173702, y:-0.9807852804032305, z:-0.07465783405034258});
	pg_30.push({x:0.353553390593274, y:-0.9238795325112866, z:-0.1464466094067262});
	pg_30.push({x:0.5132799671593364, y:-0.8314696123025455, z:-0.21260752369181385});
	pg_30.push({x:0.6532814824381882, y:-0.7071067811865477, z:-0.2705980500730983});
	pg_30.push({x:0.7681777567114163, y:-0.5555702330196022, z:-0.3181896451432083});
	pg_30.push({x:0.853553390593274, y:-0.38268343236508956, z:-0.35355339059327356});
	pg_30.push({x:0.9061274463528879, y:-0.19509032201612872, z:-0.37533027751786496});
	pg_30.push({x:0.9238795325112867, y:-2.4492127076447545e-16, z:-0.38268343236508956});
	pg_30.push({x:0.9061274463528879, y:0.19509032201612825, z:-0.3753302775178651});
	pg_30.push({x:0.8535533905932742, y:0.3826834323650891, z:-0.35355339059327373});
	pg_30.push({x:0.7681777567114166, y:0.5555702330196018, z:-0.3181896451432084});
	pg_30.push({x:0.6532814824381892, y:0.7071067811865467, z:-0.2705980500730987});
	pg_30.push({x:0.5132799671593369, y:0.8314696123025452, z:-0.21260752369181402});
	pg_30.push({x:0.3535533905932736, y:0.9238795325112867, z:-0.1464466094067261});
	pg_30.push({x:0.18023995550173746, y:0.9807852804032303, z:-0.07465783405034276});
	pg_30.push({x:2.8284718641994235e-16, y:1, z:-1.1715914069421118e-16});
    
    var pg_31 = [];
    pg_31.push({x:-1.8016138291758867e-16, y:-1, z:3.5836327186530726e-17});
	pg_31.push({x:0.1913417161825449, y:-0.9807852804032305, z:-0.038060233744356714});
	pg_31.push({x:0.3753302775178654, y:-0.9238795325112866, z:-0.07465783405034282});
	pg_31.push({x:0.5448951067758182, y:-0.8314696123025455, z:-0.10838637566236979});
	pg_31.push({x:0.6935199226610735, y:-0.7071067811865477, z:-0.1379496896414718});
	pg_31.push({x:0.815493156848917, y:-0.5555702330196022, z:-0.16221167441072926});
	pg_31.push({x:0.9061274463528878, y:-0.38268343236508956, z:-0.1802399555017374});
	pg_31.push({x:0.9619397662556431, y:-0.19509032201612872, z:-0.1913417161825453});
	pg_31.push({x:0.9807852804032303, y:-2.4492127076447545e-16, z:-0.19509032201612872});
	pg_31.push({x:0.9619397662556434, y:0.19509032201612825, z:-0.19134171618254533});
	pg_31.push({x:0.9061274463528881, y:0.3826834323650891, z:-0.18023995550173744});
	pg_31.push({x:0.8154931568489172, y:0.5555702330196018, z:-0.16221167441072928});
	pg_31.push({x:0.6935199226610744, y:0.7071067811865467, z:-0.137949689641472});
	pg_31.push({x:0.5448951067758186, y:0.8314696123025452, z:-0.10838637566236989});
	pg_31.push({x:0.3753302775178651, y:0.9238795325112867, z:-0.07465783405034275});
	pg_31.push({x:0.19134171618254536, y:0.9807852804032303, z:-0.03806023374435681});
	pg_31.push({x:3.0026897152931443e-16, y:1, z:-5.972721197755121e-17}); 
    
    /*
     * x, y, z, vpX, vpY, cX, cY, cZ, index
     */
    for(var i = 0; i < 17; i++)
    {
    	point3D(pg_0[i].x * len, pg_0[i].y * len, pg_0[i].z * len, vpX, vpY, 0, 0, 0, i);
    }
    var index = 16;
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_1[i].x * len, pg_1[i].y * len, pg_1[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_2[i].x * len, pg_2[i].y * len, pg_2[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_3[i].x * len, pg_3[i].y * len, pg_3[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
   	for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_4[i].x * len, pg_4[i].y * len, pg_4[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_5[i].x * len, pg_5[i].y * len, pg_5[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_6[i].x * len, pg_6[i].y * len, pg_6[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_7[i].x * len, pg_7[i].y * len, pg_7[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_8[i].x * len, pg_8[i].y * len, pg_8[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_9[i].x * len, pg_9[i].y * len, pg_9[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_10[i].x * len, pg_10[i].y * len, pg_10[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_11[i].x * len, pg_11[i].y * len, pg_11[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_12[i].x * len, pg_12[i].y * len, pg_12[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_13[i].x * len, pg_13[i].y * len, pg_13[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_14[i].x * len, pg_14[i].y * len, pg_14[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_15[i].x * len, pg_15[i].y * len, pg_15[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_16[i].x * len, pg_16[i].y * len, pg_16[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_17[i].x * len, pg_17[i].y * len, pg_17[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_18[i].x * len, pg_18[i].y * len, pg_18[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_19[i].x * len, pg_19[i].y * len, pg_19[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_20[i].x * len, pg_20[i].y * len, pg_20[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_21[i].x * len, pg_21[i].y * len, pg_21[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_22[i].x * len, pg_22[i].y * len, pg_22[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_23[i].x * len, pg_23[i].y * len, pg_23[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_24[i].x * len, pg_24[i].y * len, pg_24[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_25[i].x * len, pg_25[i].y * len, pg_25[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_26[i].x * len, pg_26[i].y * len, pg_26[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_27[i].x * len, pg_27[i].y * len, pg_27[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_28[i].x * len, pg_28[i].y * len, pg_28[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_29[i].x * len, pg_29[i].y * len, pg_29[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_30[i].x * len, pg_30[i].y * len, pg_30[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    for(var i = 0; i < 17; i++)
    {
    	index++;
    	point3D(pg_31[i].x * len, pg_31[i].y * len, pg_31[i].z * len, vpX, vpY, 0, 0, 0, index);
    }
    
	/*
	 * pointA, pointB, pointC, color R, color G, color B, index
	 */
	var r = 124,
	g = 124,
	b = 124,
	a = 1,
	index = 0;
	
	for(var i = 0; i < 17; i++)
	{
		if(i != 16)
		{
			//Triangle(points[i], points[i+17], points[i+18], r, g, b, a, index);
			//Triangle(points[i], points[i+18], points[i+1], r, g, b, a, index+1);
			Triangle(radii[i], radii[i+17], radii[i+18], r, g, b, a, index);
			Triangle(radii[i], radii[i+18], radii[i+1], r, g, b, a, index+1);
		}
		index += 2;
	}
	
	var j = 2;
	var startCount = 17;
	var endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	
	j = 3;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 4;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 5;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 6;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 7;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 8;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 9;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 10;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 11;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 12;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 13;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 14;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	//console.log(index);
	j = 15;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	//console.log(endCount);
	j = 16;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 17;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 18;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 19;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 20;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 21;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 22;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 23;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 24;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 25;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 26;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 27;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 28;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 29;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 30;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	j = 31;
	startCount = startCount + 17;
	endCount = startCount + 17;
	index -= 2;
	poligonCreate();
	
	index -= 2;
	for(var i = 527; i < 544; i++)
	{
		if(i != 543)
		{
			Triangle(radii[i], radii[i - 527], radii[i - 526], r, g, b, a, index);
			Triangle(radii[i], radii[i - 526], radii[i + 1], r, g, b, a,index + 1);
			index += 2;
		}
		
	}
	
	function poligonCreate()
	{
		for(var i = startCount; i < endCount; i++)
		{
			if(i != endCount - 1)
			{
				Triangle(radii[i], radii[i + 17], radii[i + 18], r, g, b, a, index);
				Triangle(radii[i], radii[i + 18], radii[i + 1], r, g, b, a, index + 1);
			}
			index += 2;
		}
	}
	var sphereSize = 0;
	var xstartNoise = 0;
    var ystartNoise = 0;
    var zstartNoise = 0;
    var xstart = Math.random() * 10;
    var ystart = Math.random() * 10;
    var zstart = Math.random() * 10;
	Light();
	setAnimation();
	
	function setAnimation()
    {
        animation();
        requestAnimationFrame(setAnimation);
    }
    
    function animation()
    {
        var angleX = (mouseY - vpY) * 0.001;
       	var angleY = (mouseX - vpX) * 0.001;
       	
       	//var angleX = 0;
       	//var angleY = 0;
        
        noise();
        for(var i = 0; i < radii.length; i++)
        {
        	//var point = points[i];
        	var point = radii[i];
        	var point2 = points[i];
			setRotateX(point, point2, angleX);
			setRotateY(point, point2, angleY);
			setScreenX(point);
			setScreenY(point);
        }

       	ctx.clearRect(0, 0, 300, 300);
       	ctx.beginPath();
    	ctx.fillStyle = "rgba(" + 0 + "," + 0 + "," + 0 + "," + 1 + ")";
    	ctx.rect(0, 0, 275, 275);
    	ctx.fill();
        for(i = 0; i < triangles.length; i++)
		{
			triangles[i].zpos = depth(triangles[i].pointA, triangles[i].pointB, triangles[i].pointC);
			draw(triangles[i].pointA, triangles[i].pointB, triangles[i].pointC, triangles[i].r, triangles[i].g, triangles[i].b, triangles[i].a);
		}
		sortZ();
		return;
    }
    
    function noise()
    {
    	xstart += 0.01;
    	ystart += 0.01;
    	zstart += 0.01;
    	
    	var xnoise = xstart;
    	var ynoise = ystart;
    	var znoise = zstart;
		
		var x = 0;
		var y = 0;
		var z = 0;
		ynoise += 0.1;
    	//xnoise = xstart;
    	xnoise += 0.1;
    	znoise += 0.1;
    	drawPoint(x, y, z, Perlin.noise(xnoise, 0, 0), Perlin.noise(0, ynoise, 0), Perlin.noise(0, 0, znoise) );
    }
    
    function drawPoint(x, y, z, noiseFactor, noiseFactor2, noiseFactor3)
    {
    	//var points = points1;
    	var sphereSize = noiseFactor * 150;
    	var greyR = 0 + Math.round(noiseFactor * 255);
    	var greyG = 0 + Math.round(noiseFactor * 255);
    	var greyB = 0 + Math.round(noiseFactor * 255);
    	var alpha = 0 + (noiseFactor * 1);
    	//alpha = 1;
    	//x = x + noiseFactor2 * 200 - 100;
    	y = y + noiseFactor3 * 200 - 100;
    	//z = z + noiseFactor3 * 100;
    	
		for(i = 0; i < triangles.length; i++)
		{
			triangles[i].r = greyR;
			triangles[i].g = greyG;
			triangles[i].b = greyB;
			triangles[i].a = alpha;
		}
		
		for(var i = 0; i < points.length; i++)
		{
			radii[i].cX = x;
			radii[i].cY = y;
			radii[i].cZ = z;
			radii[i].x = points[i].x * sphereSize;
			radii[i].y = points[i].y * sphereSize;
			radii[i].z = points[i].z * sphereSize;
		}
    }
    
    function point3D(x, y, z, vpX, vpY, cX, cY, cZ, i)
    {
    	points[i] = 
		{
			x:x, y:y, z:z/*, 
			vpX:vpX, vpY:vpY, 
			cX:cX, cY:cY, cZ:cZ, 
			angleX:0, angleY:0, angleZ:0,
			screenX:0,screenY:0*/
		};
		
		radii[i] =
		{
			x:points[i].x * 100, 
			y:points[i].y * 100, 
			z:points[i].z * 100,
			vpX:vpX, vpY:vpY, 
			cX:cX, cY:cY, cZ:cZ, 
			angleX:0, angleY:0, angleZ:0,
			screenX:0,screenY:0
		};
    }
    
    function Triangle(pointA, pointB, pointC, r, g, b, a, i)
	{
		var zpos = depth(pointA, pointB, pointC);
		triangles[i] = {pointA:pointA, pointB:pointB, pointC:pointC, r:r, g:g, b:b, a:a, zpos:zpos};
	}
	
	function draw(pointA, pointB, pointC, r, g, b, a)
	{
		if (isBackFace(pointA, pointB, pointC))
		{
			return;
		}
		
		var colorR = getAdjustedColor(pointA, pointB, pointC, r, g, b).red;
		var colorG = getAdjustedColor(pointA, pointB, pointC, r, g, b).green;
		var colorB = getAdjustedColor(pointA, pointB, pointC, r, g, b).blue;
		
		ctx.lineWidth = 0.01;
		ctx.fillStyle = "rgba(" + colorR + "," + colorG + "," + colorB + "," + a + ")";  
		ctx.strokeStyle = "rgba(" + colorR + "," + colorG + "," + colorB + "," + a + ")";
		//ctx.strokeStyle = "transparent";
        
        ctx.beginPath();
		ctx.moveTo(pointA.screenX, pointA.screenY);
		ctx.lineTo(pointB.screenX, pointB.screenY);
		ctx.lineTo(pointC.screenX, pointC.screenY);
		ctx.lineTo(pointA.screenX, pointA.screenY);
		ctx.closePath();
		ctx.fill();
		ctx.stroke();
	}
    
    /*
     * 光源設定
     */
    function Light()
	{
		light = {};
		light.x = -100,
		light.y = -100,
		light.z = -100,
		light.brightness = 1;
	}
    
    /*
	 * 面の照明調整
	 */
    function getAdjustedColor(pointA, pointB, pointC, r, g, b)
	{
		var red = r;
		var green = g;
		var blue = b;
		
		var lightFactor = getLightFactor(pointA, pointB, pointC);
		
		red *= lightFactor;
		green *= lightFactor;
		blue *= lightFactor;
		
		red = Math.round(red);
		green = Math.round(green);
		blue = Math.round(blue);
		
		return {red:red, green:green, blue:blue};
	}
	
	/*
	 * 光線の角度
	 */
	function getLightFactor(pointA, pointB, pointC)
	{
		var ab = {};
		ab.x = pointA.x - pointB.x;
		ab.y = pointA.y - pointB.y;
		ab.z = pointA.z - pointB.z;
		
		var bc = {};
		bc.x = pointB.x - pointC.x;
		bc.y = pointB.y - pointC.y;
		bc.z = pointB.z - pointC.z;
		
		var norm = {};
		norm.x = (ab.y * bc.z) - (ab.z * bc.y);
		norm.y = -((ab.x * bc.z) - (ab.z * bc.x));
		norm.z = (ab.x * bc.y) - (ab.y * bc.x);
		
		var dotProd = norm.x * light.x +
		norm.y * light.y +
		norm.z * light.z;
		
		var normMag = Math.sqrt(norm.x * norm.x +
		norm.y * norm.y + norm.z * norm.z);
		
		var lightMag = Math.sqrt(light.x * light.x +
		light.y * light.y +
		light.z * light.z);
		
		return (Math.acos(dotProd/(normMag*lightMag))/Math.PI) * light.brightness;
	}
	
	/*
	 * 隠面消去
	 */
	function isBackFace(pointA, pointB, pointC)
	{
		var cax = pointC.screenX - pointA.screenX;
		var cay = pointC.screenY - pointA.screenY;
		var bcx = pointB.screenX - pointC.screenX;
		var bcy = pointB.screenY - pointC.screenY;
		return cax * bcy > cay * bcx;
	}
	
    function setScreenX(point)
    {
    	var scale = fl / (fl + point.z + point.cZ);
		point.screenX = point.vpX + (point.cX + point.x) * scale;
    }
    
    function setScreenY(point)
    {
		var scale = fl / (fl + point.z + point.cZ);
		point.screenY = point.vpY + (point.cY + point.y) * scale;
    }
    
    function setRotateX(point, point2, angleX)
    {
		point.angleX = angleX;
		
		var cosX = Math.cos(point.angleX);
		var sinX = Math.sin(point.angleX);
		
		var y1 = point.y * cosX - point.z * sinX;
		var z1 = point.z * cosX + point.y * sinX;
		
		point.y = y1;
		point.z = z1;
		//
		point2.angleX = angleX;
		
		var cosX = Math.cos(point2.angleX);
		var sinX = Math.sin(point2.angleX);
		
		var y1 = point2.y * cosX - point2.z * sinX;
		var z1 = point2.z * cosX + point2.y * sinX;
		
		point2.y = y1;
		point2.z = z1;
    }
    
    function setRotateY(point, point2, angleY)
    {
		point.angleY = angleY;
		
		var cosY = Math.cos(point.angleY);
		var sinY = Math.sin(point.angleY);
		
		var x1 = point.x * cosY - point.z * sinY;
		var z1 = point.z * cosY + point.x * sinY;
		
		point.x = x1;
		point.z = z1;
		
		//
		point2.angleY = angleY;
		
		var cosY = Math.cos(point2.angleY);
		var sinY = Math.sin(point2.angleY);
		
		var x1 = point2.x * cosY - point2.z * sinY;
		var z1 = point2.z * cosY + point2.x * sinY;
		
		point2.x = x1;
		point2.z = z1;
    }
    
    function setRotateZ(point, angleZ)
    {
    	var cosZ = Math.cos(point.angleZ);
		var sinZ = Math.sin(point.angleZ);
		
		var x1 = point.x * cosZ - point.y * sinZ;
		var y1 = point.y * cosZ + point.x * sinZ;
		
		point.x = x1;
		point.y = y1;
    }
    
    
    /*
	 * 配列の並べ替え: 降順
	 */
	function depth(pointA, pointB, pointC)
	{
		var zpos = Math.min(pointA.z, pointB.z);
		zpos = Math.min(zpos, pointC.z);
		return zpos;
	}
	
	function sortZ()
	{
		triangles.sort(function(a, b) 
		{
			if(a["zpos"] < b["zpos"])
			{
				var v = 1;
			}
			else
			{
				v = -1;
			}
			return v;
		});
	}
	
    function mouseMoveHandler(e)
    {
        if(g_mobiledevice)
        {
            var rect = event.currentTarget.getBoundingClientRect();
            mouseX = event.touches[0].pageX - rect.left;
            mouseY = event.touches[0].pageY - rect.top;
        }
        else
        if(g_browsername == 'MSIE'||g_browsername == 'Opera')
        {
            rect = document.getElementById("canvas").getBoundingClientRect();
            mouseX = event.clientX - rect.left;
            mouseY = event.clientY - rect.top;
        }
        else
        if(g_browsername == 'Firefox')
        {
            rect = document.getElementById("canvas").getBoundingClientRect();
            mouseX = e.clientX - rect.left;
            mouseY = e.clientY - rect.top;
        }
        else
        {
            rect = event.currentTarget.getBoundingClientRect();
            mouseX = event.clientX - rect.left;
            mouseY = event.clientY - rect.top;
        }
    }
}
 
// 各ブラウザ対応
window.requestAnimationFrame = (function()
{
    return window.requestAnimationFrame ||
    window.webkitRequestAnimationFrame ||
    window.mozRequestAnimationFrame ||
    window.oRequestAnimationFrame ||
    window.msRequestAnimationFrame ||
    function(callback)
    {
        window.setTimeout(callback, 1000/60);
    };
}());

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です