Browse Source

Merge remote-tracking branch 'remotes/mrdoob/dev' into dev

alteredq 12 years ago
parent
commit
aaeb1740fd

+ 18 - 5
docs/api/core/Color.html

@@ -100,17 +100,22 @@
 		Based on MochiKit implementation by Bob Ippolito.
 		</div>
 
-		<h3>.setHex( [page:Integer hex] ) [page:this]</h3>
+		<h3>.getHex() [page:Integer]</h3>
 		<div>
-		hex — Color in hexadecimal.<br />
+		Returns the hexadecimal value of this color.
 		</div>
+
+		<h3>.getHexString() [page:String]</h3>
 		<div>
-		Sets this color from a hexadecimal value.
+		Returns the string formated hexadecimal value of this color.
 		</div>
 
-		<h3>.getHex() [page:Integer]</h3>
+		<h3>.setHex( [page:Integer hex] ) [page:this]</h3>
+		<div>
+		hex — Color in hexadecimal.<br />
+		</div>
 		<div>
-		Returns the value of this color in hexadecimal.
+		Sets this color from a hexadecimal value.
 		</div>
 
 		<h3>.getContextStyle() [page:String]</h3>
@@ -119,6 +124,14 @@
 		Example: rgb(r, g, b)
 		</div>
 
+		<h3>.setContextStyle( [page:String contextStyle] ) [page:this]</h3>
+		<div>
+		contextStyle — Color in CSS context style format.<br />
+		</div>
+		<div>
+		Sets this color from a CSS context style string.
+		</div>
+
 		<h3>.clone() [page:Color]</h3>
 		<div>
 		Clones this color.

+ 5 - 1
examples/js/controls/PointerLockControls.js

@@ -1,4 +1,8 @@
-var PointerLockControls = function ( camera ) {
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+THREE.PointerLockControls = function ( camera ) {
 
 	var scope = this;
 

+ 60 - 0
examples/js/shaders/KaleidoShader.js

@@ -0,0 +1,60 @@
+/**
+ * @author felixturner / http://airtight.cc/
+ *
+ * Kaleidoscope Shader
+ * Radial reflection around center point
+ * Ported from: http://pixelshaders.com/editor/
+ * by Toby Schachman / http://tobyschachman.com/
+ *
+ * sides: number of reflections
+ * angle: initial angle in radians
+ */
+
+THREE.KaleidoShader = {
+
+	uniforms: {
+
+		"tDiffuse": { type: "t", value: null },
+		"sides":    { type: "f", value: 6.0 },
+		"angle":    { type: "f", value: 0.0 }
+
+	},
+
+	vertexShader: [
+
+		"varying vec2 vUv;",
+
+		"void main() {",
+
+			"vUv = uv;",
+			"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+		"}"
+
+	].join("\n"),
+
+	fragmentShader: [
+
+		"uniform sampler2D tDiffuse;",
+		"uniform float sides;",
+		"uniform float angle;",
+		
+		"varying vec2 vUv;",
+
+		"void main() {",
+
+			"vec2 p = vUv - 0.5;",
+			"float r = length(p);",
+			"float a = atan(p.y, p.x) + angle;",
+			"float tau = 2. * 3.1416 ;",
+			"a = mod(a, tau/sides);",
+			"a = abs(a - tau/sides/2.) ;",
+			"p = r * vec2(cos(a), sin(a));",
+			"vec4 color = texture2D(tDiffuse, p + 0.5);",
+			"gl_FragColor = color;",
+
+		"}"
+
+	].join("\n")
+
+};

+ 58 - 0
examples/js/shaders/MirrorShader.js

@@ -0,0 +1,58 @@
+/**
+ * @author felixturner / http://airtight.cc/
+ *
+ * Mirror Shader
+ * Copies half the input to the other half
+ *
+ * side: side of input to mirror (0 = left, 1 = right, 2 = top, 3 = bottom)
+ */
+
+THREE.MirrorShader = {
+
+	uniforms: {
+
+		"tDiffuse": { type: "t", value: null },
+		"side":     { type: "i", value: 1 }
+
+	},
+
+	vertexShader: [
+
+		"varying vec2 vUv;",
+
+		"void main() {",
+
+			"vUv = uv;",
+			"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+		"}"
+
+	].join("\n"),
+
+	fragmentShader: [
+
+		"uniform sampler2D tDiffuse;",
+		"uniform int side;",
+		
+		"varying vec2 vUv;",
+
+		"void main() {",
+
+			"vec2 p = vUv;",
+			"if (side == 0){",
+				"if (p.x > 0.5) p.x = 1.0 - p.x;",
+			"}else if (side == 1){",
+				"if (p.x < 0.5) p.x = 1.0 - p.x;",
+			"}else if (side == 2){",
+				"if (p.y < 0.5) p.y = 1.0 - p.y;",
+			"}else if (side == 3){",
+				"if (p.y > 0.5) p.y = 1.0 - p.y;",
+			"} ",
+			"vec4 color = texture2D(tDiffuse, p);",
+			"gl_FragColor = color;",
+
+		"}"
+
+	].join("\n")
+
+};

+ 56 - 0
examples/js/shaders/RGBShiftShader.js

@@ -0,0 +1,56 @@
+/**
+ * @author felixturner / http://airtight.cc/
+ *
+ * RGB Shift Shader
+ * Shifts red and blue channels from center in opposite directions
+ * Ported from http://kriss.cx/tom/2009/05/rgb-shift/
+ * by Tom Butterworth / http://kriss.cx/tom/
+ *
+ * amount: shift distance (1 is width of input)
+ * angle: shift angle in radians
+ */
+
+THREE.RGBShiftShader = {
+
+	uniforms: {
+
+		"tDiffuse": { type: "t", value: null },
+		"amount":   { type: "f", value: 0.005 },
+		"angle":    { type: "f", value: 0.0 }
+
+	},
+
+	vertexShader: [
+
+		"varying vec2 vUv;",
+
+		"void main() {",
+
+			"vUv = uv;",
+			"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+		"}"
+
+	].join("\n"),
+
+	fragmentShader: [
+
+		"uniform sampler2D tDiffuse;",
+		"uniform float amount;",
+		"uniform float angle;",
+
+		"varying vec2 vUv;",
+
+		"void main() {",
+
+			"vec2 offset = amount * vec2( cos(angle), sin(angle));",
+			"vec4 cr = texture2D(tDiffuse, vUv + offset);",
+			"vec4 cga = texture2D(tDiffuse, vUv);",
+			"vec4 cb = texture2D(tDiffuse, vUv - offset);",
+			"gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);",
+
+		"}"
+
+	].join("\n")
+
+};

+ 1 - 1
examples/misc_controls_pointerlock.html

@@ -189,7 +189,7 @@
 				light.position.set( -1, - 0.5, -1 );
 				scene.add( light );
 
-				controls = new PointerLockControls( camera );
+				controls = new THREE.PointerLockControls( camera );
 				scene.add( controls.getObject() );
 
 				ray = new THREE.Ray();

+ 26 - 15
src/core/Color.js

@@ -141,6 +141,12 @@ THREE.Color.prototype = {
 
 	},
 
+	getHex: function () {
+
+		return ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0;
+
+	},
+
 	setHex: function ( hex ) {
 
 		hex = Math.floor( hex );
@@ -153,35 +159,30 @@ THREE.Color.prototype = {
 
 	},
 
-	lerpSelf: function ( color, alpha ) {
-
-		this.r += ( color.r - this.r ) * alpha;
-		this.g += ( color.g - this.g ) * alpha;
-		this.b += ( color.b - this.b ) * alpha;
+	getHexString: function () {
 
-		return this;
+		return ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 );
 
 	},
 
-	getHex: function () {
+	getContextStyle: function () {
 
-		return ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0;
+		return 'rgb(' + ( ( this.r * 255 ) | 0 )  + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')';
 
 	},
 
-	getHexString: function () {
+	setContextStyle: function ( style ) {
 
-		return ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 );
+		var color = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/i.exec( style );
 
-	},
-
-	getContextStyle: function () {
+		this.r = parseInt( color[ 1 ], 10 ) / 255;
+		this.g = parseInt( color[ 2 ], 10 ) / 255;
+		this.b = parseInt( color[ 3 ], 10 ) / 255;
 
-		return 'rgb(' + ( ( this.r * 255 ) | 0 )  + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')';
+		return this;
 
 	},
 
-
 	getHSV: function ( hsv ) {
 
 		// based on MochiKit implementation by Bob Ippolito
@@ -251,6 +252,16 @@ THREE.Color.prototype = {
 
 	},
 
+	lerpSelf: function ( color, alpha ) {
+
+		this.r += ( color.r - this.r ) * alpha;
+		this.g += ( color.g - this.g ) * alpha;
+		this.b += ( color.b - this.b ) * alpha;
+
+		return this;
+
+	},
+
 	clone: function () {
 
 		return new THREE.Color().setRGB( this.r, this.g, this.b );

+ 1 - 1
src/extras/helpers/SpotLightHelper.js

@@ -35,7 +35,7 @@ THREE.SpotLightHelper = function ( light, sphereSize, arrowLength ) {
 
 	var bulbGeometry = new THREE.SphereGeometry( sphereSize, 16, 8 );
 	var raysGeometry = new THREE.AsteriskGeometry( sphereSize * 1.25, sphereSize * 2.25 );
-	var coneGeometry = new THREE.CylinderGeometry( 0.0001, 1, 1, 32, 1, true );
+	var coneGeometry = new THREE.CylinderGeometry( 0.0001, 1, 1, 8, 1, true );
 
 	var coneMatrix = new THREE.Matrix4();
 	coneMatrix.rotateX( -Math.PI/2 );

+ 1 - 1
src/objects/SkinnedMesh.js

@@ -20,7 +20,7 @@ THREE.SkinnedMesh = function ( geometry, material, useVertexTexture ) {
 
 	var b, bone, gbone, p, q, s;
 
-	if ( this.geometry.bones !== undefined ) {
+	if ( this.geometry && this.geometry.bones !== undefined ) {
 
 		for ( b = 0; b < this.geometry.bones.length; b ++ ) {