Skip to content

Commit 00e1c90

Browse files
committed
v 0.1
1 parent 5a9bc20 commit 00e1c90

19 files changed

+2795
-249
lines changed

Diff for: Three.js

+568
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: axis.js

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
function yAxisSprite() {
2+
3+
var canvas = document.createElement( 'canvas' );
4+
canvas.width = 500;
5+
canvas.height = 2000;
6+
7+
var context = canvas.getContext( '2d' );
8+
9+
context.save();
10+
context.translate(250,1000)
11+
context.rotate(Math.PI/2);
12+
context.font = "60pt Calibri";
13+
context.textAlign = "center";
14+
context.textBaseline = "bottom";
15+
context.fillText("Charm", 0, 0);
16+
context.restore();
17+
18+
context.lineWidth = 3;
19+
20+
for (var i = 0 ; i < 100 ; i++) {
21+
context.moveTo(250, i*20);
22+
if (i % 10 == 0) {
23+
context.lineTo(200, i*20);
24+
} else if (i % 5 == 0) {
25+
context.lineTo(225, i*20);
26+
} else {
27+
context.lineTo(235, i*20);
28+
}
29+
}
30+
context.stroke();
31+
return canvas;
32+
}
33+
34+
function drawAxes(scene) {
35+
36+
// Y Axis Sprite
37+
38+
var material = new THREE.ParticleBasicMaterial( { map: new THREE.Texture( yAxisSprite() ), blending: THREE.AdditiveBlending } );
39+
textYAxis = new THREE.Particle( material );
40+
textYAxis.position.y = 200;
41+
textYAxis.scale.x = textYAxis.scale.y = 0.2;
42+
scene.addObject( textYAxis );
43+
44+
// Y Axis
45+
46+
var yAxisGeo = new THREE.Geometry();
47+
yAxisGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( 0, 0, 0 ) ) );
48+
yAxisGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( 0, 400, 0 ) ) );
49+
50+
var yAxis = new THREE.Line( yAxisGeo, new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.8 } ) );
51+
scene.addObject( yAxis );
52+
53+
// Circle Geometry
54+
55+
var circleGeo = new THREE.Geometry();
56+
for (var i = 0 ; i <= 100 ; i++) {
57+
var angle = i*2*Math.PI / 100;
58+
var radius = 300;
59+
circleGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( radius * Math.cos(angle), 0, radius * Math.sin(angle) ) ) );
60+
}
61+
62+
// External Circle
63+
64+
var circle = new THREE.Line( circleGeo, new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.8 } ) );
65+
scene.addObject( circle );
66+
67+
// Internal Circles
68+
69+
for ( var i = 0.1 ; i < 1 ; i += 0.1) {
70+
var circle = new THREE.Line( circleGeo, new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.1 } ) );
71+
circle.scale.x = circle.scale.z = i;
72+
scene.addObject( circle );
73+
}
74+
75+
//
76+
77+
var graduationGeo = new THREE.Geometry();
78+
graduationGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( 0, 0, 0 ) ) );
79+
graduationGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( 2, 0, 0 ) ) );
80+
81+
for (var i = 0 ; i < 360 ; i++) {
82+
83+
var graduation = new THREE.Line( graduationGeo, new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.5 } ) );
84+
if (i % 6 == 0) {
85+
graduation.scale.x = 2;
86+
}
87+
if (i % 30 == 0) {
88+
graduation.scale.x = 4;
89+
}
90+
graduation.rotation.y = -i/360 * 2 * Math.PI;
91+
graduation.position.x = 300 * Math.cos(i/360 * 2*Math.PI);
92+
graduation.position.z = 300 * Math.sin(i/360 * 2*Math.PI);
93+
scene.addObject( graduation );
94+
}
95+
}

Diff for: glMatrix-0.9.5.min.js

-32
This file was deleted.

Diff for: js/Detector.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* @author alteredq / http://alteredqualia.com/
3+
* @author mr.doob / http://mrdoob.com/
4+
*/
5+
6+
Detector = {
7+
8+
canvas : !! window.CanvasRenderingContext2D,
9+
webgl : ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )(),
10+
workers : !! window.Worker,
11+
fileapi : window.File && window.FileReader && window.FileList && window.Blob,
12+
13+
getWebGLErrorMessage : function () {
14+
15+
var domElement = document.createElement( 'div' );
16+
17+
domElement.style.fontFamily = 'monospace';
18+
domElement.style.fontSize = '13px';
19+
domElement.style.textAlign = 'center';
20+
domElement.style.background = '#eee';
21+
domElement.style.color = '#000';
22+
domElement.style.padding = '1em';
23+
domElement.style.width = '475px';
24+
domElement.style.margin = '5em auto 0';
25+
26+
if ( ! this.webgl ) {
27+
28+
domElement.innerHTML = window.WebGLRenderingContext ? [
29+
'Your graphics card does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a>.<br />',
30+
'Find out how to get it <a href="http://get.webgl.org/">here</a>.'
31+
].join( '\n' ) : [
32+
'Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a>.<br/>',
33+
'Find out how to get it <a href="http://get.webgl.org/">here</a>.'
34+
].join( '\n' );
35+
36+
}
37+
38+
return domElement;
39+
40+
},
41+
42+
addGetWebGLMessage : function ( parameters ) {
43+
44+
var parent, id, domElement;
45+
46+
parameters = parameters || {};
47+
48+
parent = parameters.parent !== undefined ? parameters.parent : document.body;
49+
id = parameters.id !== undefined ? parameters.id : 'oldie';
50+
51+
domElement = Detector.getWebGLErrorMessage();
52+
domElement.id = id;
53+
54+
parent.appendChild( domElement );
55+
56+
}
57+
58+
};

Diff for: js/ImprovedNoise.js

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// http://mrl.nyu.edu/~perlin/noise/
2+
3+
var ImprovedNoise = function () {
4+
5+
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,
6+
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,
7+
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,
8+
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,
9+
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,
10+
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,
11+
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,
12+
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,
13+
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,
14+
93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];
15+
16+
for (var i=0; i < 256 ; i++) {
17+
18+
p[256+i] = p[i];
19+
20+
}
21+
22+
function fade(t) {
23+
24+
return t * t * t * (t * (t * 6 - 15) + 10);
25+
26+
}
27+
28+
function lerp(t, a, b) {
29+
30+
return a + t * (b - a);
31+
32+
}
33+
34+
function grad(hash, x, y, z) {
35+
36+
var h = hash & 15;
37+
var u = h < 8 ? x : y, v = h < 4 ? y : h == 12 || h == 14 ? x : z;
38+
return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v);
39+
40+
}
41+
42+
return {
43+
44+
noise: function (x, y, z) {
45+
46+
var floorX = ~~x, floorY = ~~y, floorZ = ~~z;
47+
48+
var X = floorX & 255, Y = floorY & 255, Z = floorZ & 255;
49+
50+
x -= floorX;
51+
y -= floorY;
52+
z -= floorZ;
53+
54+
var xMinus1 = x -1, yMinus1 = y - 1, zMinus1 = z - 1;
55+
56+
var u = fade(x), v = fade(y), w = fade(z);
57+
58+
var A = p[X]+Y, AA = p[A]+Z, AB = p[A+1]+Z, B = p[X+1]+Y, BA = p[B]+Z, BB = p[B+1]+Z;
59+
60+
return lerp(w, lerp(v, lerp(u, grad(p[AA], x, y, z),
61+
grad(p[BA], xMinus1, y, z)),
62+
lerp(u, grad(p[AB], x, yMinus1, z),
63+
grad(p[BB], xMinus1, yMinus1, z))),
64+
lerp(v, lerp(u, grad(p[AA+1], x, y, zMinus1),
65+
grad(p[BA+1], xMinus1, y, z-1)),
66+
lerp(u, grad(p[AB+1], x, yMinus1, zMinus1),
67+
grad(p[BB+1], xMinus1, yMinus1, zMinus1))));
68+
69+
}
70+
}
71+
}

Diff for: js/PRNG.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Park-Miller-Carta Pseudo-Random Number Generator
2+
// https://github.com/pnitsch/BitmapData.js/blob/master/js/BitmapData.js
3+
4+
var PRNG = function () {
5+
6+
this.seed = 1;
7+
this.next = function() { return (this.gen() / 2147483647); };
8+
this.nextRange = function(min, max) { return min + ((max - min) * this.next()) };
9+
this.gen = function() { return this.seed = (this.seed * 16807) % 2147483647; };
10+
11+
};

0 commit comments

Comments
 (0)