Browse Source

Synced with mrdoob's branch.

Also fixed scene loader example to match new cylinder parameters (centered).
alteredq 14 years ago
parent
commit
59071e75b3

File diff suppressed because it is too large
+ 157 - 157
build/Three.js


File diff suppressed because it is too large
+ 13 - 13
build/custom/ThreeExtras.js


+ 10 - 9
build/custom/ThreeWebGL.js

@@ -129,22 +129,23 @@ map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D(
 lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
-color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif",
-morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
+color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif",
+morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif",
+default_vertex:"#ifndef USE_MORPHTARGETS || USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
 THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)},morphTargetInfluences:{type:"f",
 value:0}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",
 value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
 THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",
 value:1}},fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,
 THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,
-THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",
-THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",
-THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",
-THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",
+THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),
+fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,
+THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
+THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",
 THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),
-vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,
-THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,
-THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
+vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
+THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",
+THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
 THREE.WebGLRenderer=function(a){function b(e,j,k){var h,i,r,n=e.vertices,q=n.length,x=e.colors,C=x.length,p=e.__vertexArray,F=e.__colorArray,N=e.__sortArray,K=e.__dirtyVertices,J=e.__dirtyColors;if(k.sortParticles){Ma.multiplySelf(k.matrixWorld);for(h=0;h<q;h++){i=n[h].position;Ga.copy(i);Ma.multiplyVector3(Ga);N[h]=[Ga.z,h]}N.sort(function(G,P){return P[0]-G[0]});for(h=0;h<q;h++){i=n[N[h][1]].position;r=h*3;p[r]=i.x;p[r+1]=i.y;p[r+2]=i.z}for(h=0;h<C;h++){r=h*3;color=x[N[h][1]];F[r]=color.r;F[r+1]=
 color.g;F[r+2]=color.b}}else{if(K)for(h=0;h<q;h++){i=n[h].position;r=h*3;p[r]=i.x;p[r+1]=i.y;p[r+2]=i.z}if(J)for(h=0;h<C;h++){color=x[h];r=h*3;F[r]=color.r;F[r+1]=color.g;F[r+2]=color.b}}if(K||k.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,e.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,p,j)}if(J||k.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,e.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,F,j)}}function d(e,j){e.fragmentShader=j.fragmentShader;e.vertexShader=j.vertexShader;e.uniforms=Uniforms.clone(j.uniforms)}
 function f(e,j,k,h,i){h.program||ya.initMaterial(h,j,k,i);var r=h.program,n=r.uniforms,q=h.uniforms;if(r!=ra){c.useProgram(r);ra=r}c.uniformMatrix4fv(n.projectionMatrix,!1,Xa);if(k&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){q.fogColor.value.setHex(k.color.hex);if(k instanceof THREE.Fog){q.fogNear.value=k.near;q.fogFar.value=k.far}else if(k instanceof

+ 2 - 2
examples/scenes/test_scene.js

@@ -69,7 +69,7 @@ var scene = {
 	"cone" : {
 		"geometry" : "cone",
 		"materials": [ "lambert_blue" ],
-		"position" : [ -50, 40, -50 ],
+		"position" : [ -50, 15, -50 ],
 		"rotation" : [ 1.57, 0, 0 ],
 		"scale"	   : [ 1, 1, 1 ],
 		"visible"  : true
@@ -78,7 +78,7 @@ var scene = {
 	"cylinder" : {
 		"geometry" : "cylinder",
 		"materials": [ "lambert_blue" ],
-		"position" : [ 50, 40, -50 ],
+		"position" : [ 50, 15, -50 ],
 		"rotation" : [ 1.57, 0, 0 ],
 		"scale"	   : [ 1, 1, 1 ],
 		"visible"  : true

+ 141 - 0
examples/webgl_geometries.html

@@ -0,0 +1,141 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js webgl - geometries</title>
+		<meta charset="utf-8">
+		<style type="text/css">
+			body {
+				font-family: Monospace;
+				background-color: #000;
+				margin: 0px;
+				overflow: hidden;
+			}
+			#log { color:#fff; position:absolute; top:50px; text-align:left; display:block; z-index:100; pointer-events:none; }
+		</style>
+	</head>
+	<body>
+
+		<pre id="log"></pre>
+
+		<script type="text/javascript" src="../build/Three.js"></script>
+
+		<script type="text/javascript" src="js/Detector.js"></script>
+		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
+		<script type="text/javascript" src="js/Stats.js"></script>
+
+		<script type="text/javascript">
+
+			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
+
+			var container, stats;
+
+			var camera, scene, renderer;
+
+			init();
+			animate();
+
+			function init() {
+
+				container = document.createElement('div');
+				document.body.appendChild(container);
+
+				camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
+				camera.position.y = 200;
+				camera.position.z = 800;
+
+				scene = new THREE.Scene();
+
+				var light, object, material;
+
+				light = new THREE.DirectionalLight( 0x00aaff, 2.0 );
+				light.position.z = 1;
+				scene.addLight( light );
+
+				light = new THREE.DirectionalLight( 0x000040, 0.5 );
+				light.position.z = - 1;
+				scene.addLight( light );
+
+
+				material = [
+						new THREE.MeshLambertMaterial( { color: 0xffffff } ),
+						new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true, opacity: 0.1 } )
+				];
+
+				object = new THREE.Mesh( new Cube( 100, 100, 100, 4, 4, 4 ), material );
+				object.position.x = - 200;
+				object.position.z = 200;
+				scene.addObject( object );
+
+				object = new THREE.Mesh( new Cylinder( 50, 75, 75, 100 ), material );
+				object.position.z = 200;
+				scene.addObject( object );
+
+				object = new THREE.Mesh( new Icosahedron( 2 ), material );
+				object.position.x = 200;
+				object.position.z = 200;
+				object.scale.x = object.scale.y = object.scale.z = 75;
+				scene.addObject( object );
+
+				object = new THREE.Mesh( new Plane( 100, 100, 4, 4 ), material );
+				object.position.x = - 200;
+				scene.addObject( object );
+
+				object = new THREE.Mesh( new Sphere( 75, 20, 10 ), material );
+				scene.addObject( object );
+
+				object = new THREE.Mesh( new Torus( 50, 20, 20, 20 ), material );
+				object.position.x = 200;
+				scene.addObject( object );
+
+				object = new THREE.Mesh( new TorusKnot( 50, 10, 50, 20 ), material );
+				object.position.z = - 200;
+				scene.addObject( object );
+
+
+				renderer = new THREE.WebGLRenderer();
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+				container.appendChild( renderer.domElement );
+
+				stats = new Stats();
+				stats.domElement.style.position = 'absolute';
+				stats.domElement.style.top = '0px';
+				container.appendChild( stats.domElement );
+
+			}
+
+			//
+
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+				stats.update();
+
+			}
+
+			function render() {
+
+				var timer = new Date().getTime() * 0.0001;
+
+				camera.position.x = Math.cos( timer ) * 800;
+				camera.position.z = Math.sin( timer ) * 800;
+
+				for ( var i = 0, l = scene.objects.length; i < l; i++ ) {
+
+					var object = scene.objects[ i ];
+
+					object.rotation.x += 0.01;
+					object.rotation.y += 0.005;
+
+				}
+
+				renderer.render( scene, camera );
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 3 - 21
examples/webgl_materials.html

@@ -65,6 +65,8 @@
 				var line = new THREE.Line( geometry, line_material, THREE.LinePieces );
 				scene.addObject( line );
 
+				// Materials
+
 				var generatedTexture = new THREE.Texture( generateTexture() );
 				generatedTexture.needsUpdate = true;
 
@@ -147,23 +149,10 @@
 
 				container.appendChild( renderer.domElement );
 
-				var debugCanvas = document.createElement( 'canvas' );
-				debugCanvas.width = 512;
-				debugCanvas.height = 512;
-				debugCanvas.style.position = 'absolute';
-				debugCanvas.style.top = '0px';
-				debugCanvas.style.left = '0px';
-
-				container.appendChild( debugCanvas );
-
-				debugContext = debugCanvas.getContext( '2d' );
-				debugContext.setTransform( 1, 0, 0, 1, 256, 256 );
-				debugContext.strokeStyle = '#000000';
-
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
 				stats.domElement.style.top = '0px';
-				container.appendChild(stats.domElement);
+				container.appendChild( stats.domElement );
 
 			}
 
@@ -233,13 +222,6 @@
 
 			}
 
-			function log( text ) {
-
-				var e = document.getElementById("log");
-				e.innerHTML = text + "<br/>" + e.innerHTML;
-
-			}
-
 		</script>
 
 	</body>

+ 0 - 0
src/extras/primitives/Cube.js → src/extras/geometries/Cube.js


+ 14 - 27
src/extras/primitives/Cylinder.js → src/extras/geometries/Cylinder.js

@@ -1,21 +1,19 @@
 /**
  * @author kile / http://kile.stravaganza.org/
+ * @author mr.doob / http://mrdoob.com/ 
  */
 
-var Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset ) {
+var Cylinder = function ( numSegs, topRad, botRad, height ) {
 
 	THREE.Geometry.call( this );
 
-	var scope = this,
-	pi = Math.PI, i;
-
-	// VERTICES
+	var scope = this, i, pi = Math.PI, halfHeight = height / 2;
 
 	// Top circle vertices
 
 	for ( i = 0; i < numSegs; i ++ ) {
 
-		v( Math.sin( 2 * pi * i / numSegs ) * topRad, Math.cos( 2 * pi * i / numSegs ) * topRad, 0 );
+		v( Math.sin( 2 * pi * i / numSegs ) * topRad, Math.cos( 2 * pi * i / numSegs ) * topRad, - halfHeight );
 
 	}
 
@@ -23,14 +21,11 @@ var Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset
 
 	for ( i = 0; i < numSegs; i ++ ) {
 
-		v( Math.sin( 2 * pi * i / numSegs ) * botRad, Math.cos( 2 * pi * i / numSegs ) * botRad, height );
+		v( Math.sin( 2 * pi * i / numSegs ) * botRad, Math.cos( 2 * pi * i / numSegs ) * botRad, halfHeight );
 
 	}
 
-
-	// FACES
-
-	// Body
+	// Body faces
 
 	for ( i = 0; i < numSegs; i++ ) {
 
@@ -38,31 +33,23 @@ var Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset
 
 	}
 
-	// Bottom circle
-
-	if ( botRad != 0 ) {
+	// Bottom circle faces
 
-		v( 0, 0, - topOffset );
+	v( 0, 0, - halfHeight );
 
-		for ( i = numSegs; i < numSegs + ( numSegs / 2 ); i++ ) {
+	for ( i = numSegs; i < numSegs + ( numSegs / 2 ); i++ ) {
 
-			f4( 2 * numSegs, ( 2 * i - 2 * numSegs ) % numSegs, ( 2 * i - 2 * numSegs + 1 ) % numSegs, ( 2 * i - 2 * numSegs + 2 ) % numSegs );
-
-		}
+		f4( 2 * numSegs, ( 2 * i - 2 * numSegs ) % numSegs, ( 2 * i - 2 * numSegs + 1 ) % numSegs, ( 2 * i - 2 * numSegs + 2 ) % numSegs );
 
 	}
 
-	// Top circle
-
-	if ( topRad != 0 ) {
-
-		v( 0, 0, height + topOffset );
+	// Top circle faces
 
-		for ( i = numSegs + ( numSegs / 2 ); i < 2 * numSegs; i ++ ) {
+	v( 0, 0, halfHeight );
 
-			f4( ( 2 * i - 2 * numSegs + 2 ) % numSegs + numSegs, ( 2 * i - 2 * numSegs + 1 ) % numSegs + numSegs, ( 2 * i - 2 * numSegs ) % numSegs+numSegs, 2 * numSegs + 1 );
+	for ( i = numSegs + ( numSegs / 2 ); i < 2 * numSegs; i ++ ) {
 
-		}
+		f4( ( 2 * i - 2 * numSegs + 2 ) % numSegs + numSegs, ( 2 * i - 2 * numSegs + 1 ) % numSegs + numSegs, ( 2 * i - 2 * numSegs ) % numSegs+numSegs, 2 * numSegs + 1 );
 
 	}
 

+ 7 - 7
src/extras/primitives/Icosahedron.js → src/extras/geometries/Icosahedron.js

@@ -1,6 +1,6 @@
 /**
  * @author oosmoxiecode
- 
+
  * uvs are messed up in this one, and commented away for now. There is an ugly "seam" by the shared vertices
  * when it "wraps" around, that needs to be fixed. It´s because they share the first and the last vertices
  * so it draws the entire texture on the seam-faces, I think...
@@ -16,7 +16,7 @@ var Icosahedron = function ( subdivisions ) {
 	//var temp_uv = [];
 
 	THREE.Geometry.call(this);
-	
+
 	// create 12 vertices of a Icosahedron
 	var t = (1 + Math.sqrt(5)) / 2;
 
@@ -103,7 +103,7 @@ var Icosahedron = function ( subdivisions ) {
 
 	function f3( a, b, c, inscope ) {
 		inscope.faces.push( new THREE.Face3( a, b, c ) );
-		
+
 		/*inscope.uvs.push( [new THREE.UV( temp_uv[a].u, temp_uv[a].v ),
 						   new THREE.UV( temp_uv[b].u, temp_uv[b].v ),
 						   new THREE.UV( temp_uv[c].u, temp_uv[c].v )
@@ -118,18 +118,18 @@ var Icosahedron = function ( subdivisions ) {
 		var x = (pos1.x + pos2.x) / 2;
 		var y = (pos1.y + pos2.y) / 2;
 		var z = (pos1.z + pos2.z) / 2;
-		
+
 		var i = v(x, y, z);
 		return i;
 	}
 
 	/*function getUv(x,y,z) {
-		
+
 		var u,v;
 		var px,py,pz,d;
-			
+
 		d = Math.sqrt( x*x+y*y+z*z );
-			
+
 		px = x/d;
 		py = y/d;
 		pz = z/d;

+ 71 - 0
src/extras/geometries/Lathe.js

@@ -0,0 +1,71 @@
+/**
+ * @author astrodud / http://astrodud.isgreat.org/
+ */
+
+function Lathe( vertices, steps, angle ) {
+
+	THREE.Geometry.call( this );
+
+	this.steps = steps || 12;
+	this.angle = angle || 2 * Math.PI;
+
+	var stepSize = this.angle / this.steps;
+
+	var newV = [], oldInds = [], newInds = [], startInds = [];
+
+	for ( var j = 0; j < vertices.length; j ++ ) {
+
+		this.vertices.push( new THREE.Vertex( vertices[ j ] ) );
+		oldInds[ j ] = this.vertices.length - 1;
+		newV[ j ] = new THREE.Vector3( vertices[ j ].x, vertices[ j ].y, vertices[ j ].z );
+
+	}
+
+	var matrix = new THREE.Matrix4().setRotationZ( this.stepSize );
+
+	for ( var r = 0; r <= this.angle + 0.001; r += this.stepSize ) { // need the +0.001 for it go up to angle
+
+		for ( var j = 0; j < newV.length; j ++ ) {
+
+			if ( r < angle ) {
+
+				newV[ j ] = matrix.multiplyVector3( newV[ j ].clone() );
+				this.vertices.push( new THREE.Vertex( newV[ j ] ) );
+				newInds[ j ] = this.vertices.length - 1;
+
+			} else {
+
+				newInds = startInds; // wrap it up!
+
+			}
+
+		}
+
+		if ( r == 0 ) startInds = oldInds;
+
+		for ( var j = 0; j < oldInds.length - 1; j ++ ) {
+
+			this.faces.push( new THREE.Face4( newInds[ j ], newInds[ j + 1 ], oldInds[ j + 1 ], oldInds[ j ] ) );
+			this.uvs.push( [
+
+				new THREE.UV( r / angle, j / vertices.length ),
+				new THREE.UV( r / angle, ( j + 1 ) / vertices.length ),
+				new THREE.UV( ( r - stepSize ) / angle, ( j + 1 ) / vertices.length ),
+				new THREE.UV( ( r - stepSize ) / angle, j / vertices.length )
+
+			] );
+
+		}
+
+		oldInds = newInds;
+		newInds = [];
+	}
+
+	this.computeCentroids();
+	this.computeFaceNormals();
+	this.computeVertexNormals();
+
+};
+
+Lathe.prototype = new THREE.Geometry();
+Lathe.prototype.constructor = Lathe;

+ 0 - 0
src/extras/primitives/Plane.js → src/extras/geometries/Plane.js


+ 0 - 0
src/extras/primitives/Sphere.js → src/extras/geometries/Sphere.js


+ 4 - 4
src/extras/primitives/Torus.js → src/extras/geometries/Torus.js

@@ -23,21 +23,21 @@ var Torus = function ( radius, tube, segmentsR, segmentsT ) {
 			var x = (this.radius + this.tube*Math.cos(v))*Math.cos(u);
 			var y = (this.radius + this.tube*Math.cos(v))*Math.sin(u);
 			var z = this.tube*Math.sin(v);
-			
+
 			vert(x, y, z);
-			
+
 			temp_uv.push([i/this.segmentsT, 1 - j/this.segmentsR]);
 		}
 	}
 
-	
+
 	for (var j = 1; j <= this.segmentsR; ++j) {
 		for (var i = 1; i <= this.segmentsT; ++i) {
 			var a = (this.segmentsT + 1)*j + i;
 			var b = (this.segmentsT + 1)*j + i - 1;
 			var c = (this.segmentsT + 1)*(j - 1) + i - 1;
 			var d = (this.segmentsT + 1)*(j - 1) + i;
-			
+
 			f4(a,b,c,d);
 
 			this.uvs.push( [new THREE.UV( temp_uv[a][0], temp_uv[a][1] ),

+ 112 - 0
src/extras/geometries/TorusKnot.js

@@ -0,0 +1,112 @@
+/**
+ * @author oosmoxiecode
+ * based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
+ */
+
+var TorusKnot = function ( radius, tube, segmentsR, segmentsT, p, q, heightScale ) {
+
+	var scope = this;
+	THREE.Geometry.call( this );
+
+	this.radius = radius || 200;
+	this.tube = tube || 40;
+	this.segmentsR = segmentsR || 64;
+	this.segmentsT = segmentsT || 8;
+	this.p = p || 2;
+	this.q = q || 3;
+	this.heightScale = heightScale || 1;
+	this.grid = new Array(this.segmentsR);
+
+	var tang = new THREE.Vector3();
+	var n = new THREE.Vector3();
+	var bitan = new THREE.Vector3();
+
+	for ( var i = 0; i < this.segmentsR; ++ i ) {
+
+		this.grid[ i ] = new Array( this.segmentsT );
+
+		for ( var j = 0; j < this.segmentsT; ++ j ) {
+			var u = i / this.segmentsR * 2 * this.p * Math.PI;
+			var v = j / this.segmentsT * 2 * Math.PI;
+			var p = getPos( u, v, this.q, this.p, this.radius, this.heightScale );
+			var p2 = getPos( u + 0.01, v, this.q, this.p, this.radius, this.heightScale );
+			var cx, cy;
+
+			tang.x = p2.x - p.x; tang.y = p2.y - p.y; tang.z = p2.z - p.z;
+			n.x = p2.x + p.x; n.y = p2.y + p.y; n.z = p2.z + p.z; 
+			bitan.cross( tang, n );
+			n.cross( bitan, tang );
+			bitan.normalize();
+			n.normalize();
+
+			cx = this.tube * Math.cos( v ); cy = this.tube * Math.sin( v );
+			p.x += cx * n.x + cy * bitan.x;
+			p.y += cx * n.y + cy * bitan.y;
+			p.z += cx * n.z + cy * bitan.z;
+
+			this.grid[ i ][ j ] = vert( p.x, p.y, p.z );
+
+		}
+
+	}
+
+	for ( var i = 0; i < this.segmentsR; ++ i ) {
+
+		for ( var j = 0; j < this.segmentsT; ++ j ) {
+
+			var ip = ( i + 1 ) % this.segmentsR;
+			var jp = ( j + 1 ) % this.segmentsT;
+			var a = this.grid[ i ][ j ]; 
+			var b = this.grid[ ip ][ j ];
+			var c = this.grid[ i ][ jp ]; 
+			var d = this.grid[ ip ][ jp ];
+
+			var uva = new THREE.UV( i / this.segmentsR, j / this.segmentsT );
+			var uvb = new THREE.UV( ( i + 1 ) / this.segmentsR, j / this.segmentsT );
+			var uvc = new THREE.UV( i / this.segmentsR, ( j + 1 ) / this.segmentsT );
+			var uvd = new THREE.UV( ( i + 1 ) / this.segmentsR, ( j + 1 ) / this.segmentsT );
+
+			f3(a, b, c);
+			this.uvs.push( [ uva,uvb,uvc ] );
+			f3(d, c, b);
+			this.uvs.push( [ uvd,uvc,uvb ] );
+		}
+	}
+
+	this.computeCentroids();
+	this.computeFaceNormals();
+	this.computeVertexNormals();
+
+	function vert( x, y, z ) {
+
+		var i = scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
+		return i - 1;
+
+	}
+
+	function f3( a, b, c ) {
+
+		scope.faces.push( new THREE.Face3( a, b, c ) );
+
+	}
+
+	function getPos( u, v, in_q, in_p, radius, heightScale ) {
+
+		var cu = Math.cos( u );
+		var cv = Math.cos( v );
+		var su = Math.sin( u );
+		var quOverP = in_q / in_p * u;
+		var cs = Math.cos( quOverP );
+
+		var tx = radius * ( 2 + cs ) * 0.5 * cu;
+		var ty = radius * ( 2 + cs ) * su * 0.5;
+		var tz = heightScale * radius * Math.sin( quOverP ) * 0.5;
+
+		return new THREE.Vector3( tx, ty, tz );
+
+	}
+
+}
+
+TorusKnot.prototype = new THREE.Geometry();
+TorusKnot.prototype.constructor = TorusKnot;

+ 0 - 67
src/extras/primitives/LathedObject.js

@@ -1,67 +0,0 @@
-/**
- * @author astrodud / http://astrodud.isgreat.org/
- */
-
-function LathedObject( verts, nsteps, latheAngle ) {
-
-	THREE.Geometry.call( this );
-
-	this.nsteps = nsteps || 12;
-	this.latheAngle = latheAngle || 2 * Math.PI;
-	
-	var stepSize = this.latheAngle / this.nsteps;
-	
-	var newV = [], oldInds = [], newInds = [], startInds = [];
-	
-	for ( var j = 0; j < verts.length; j ++ ) {
-      
-		this.vertices.push( new THREE.Vertex( verts[ j ] ) );
-		oldInds[ j ] = this.vertices.length - 1;
-		newV[ j ] = new THREE.Vector3( verts[ j ].x, verts[ j ].y, verts[ j ].z );
-
-	}
-	
-	var m = THREE.Matrix4.rotationZMatrix( this.stepSize );
-	
-	for ( var r = 0; r <= this.latheAngle + 0.001; r += this.stepSize ) { // need the +0.001 for it go up to latheAngle
-	
-		for ( var j = 0; j < newV.length; j ++ ) {
-			
-			if ( r < latheAngle ) {
-				
-				newV[ j ] = m.multiplyVector3( newV[ j ].clone() );
-				this.vertices.push( new THREE.Vertex( newV[ j ] ) );
-				newInds[ j ] = this.vertices.length - 1;
-
-			} else {
-			
-				newInds = startInds; // wrap it up!
-
-			}
-
-		}
-		
-		if ( r == 0 ) startInds = oldInds;
-      
-		for ( var j = 0; j < oldInds.length - 1; j ++ ) {
-			
-			this.faces.push( new THREE.Face4( newInds[ j ], newInds[ j + 1 ], oldInds[ j + 1 ], oldInds[ j ] ) );
-			this.uvs.push( [ new THREE.UV( r / latheAngle, j / verts.length ),
-							 new THREE.UV( r / latheAngle, ( j + 1 ) / verts.length ),
-							 new THREE.UV( ( r - stepSize ) / latheAngle, ( j + 1 ) / verts.length ),
-							 new THREE.UV( ( r - stepSize ) / latheAngle, j / verts.length ) ] );
-			
-		}
-		
-		oldInds = newInds;
-		newInds = [];
-	}
-	
-	this.computeCentroids();
-	this.computeFaceNormals();
-	this.computeVertexNormals();
-
-};
-
-LathedObject.prototype = new THREE.Geometry();
-LathedObject.prototype.constructor = LathedObject;

+ 0 - 99
src/extras/primitives/Torusknot.js

@@ -1,99 +0,0 @@
-/**
- * @author oosmoxiecode
- * based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
- */
-
-var Torusknot = function (radius, tube, segmentsR, segmentsT, p, q, heightScale) {
-	var scope = this;
-	THREE.Geometry.call(this);
-
-	this.radius = radius || 200;
-	this.tube = tube || 40;
-	this.segmentsR = segmentsR || 64;
-	this.segmentsT = segmentsT || 8;
-	this.p = p || 2;
-    this.q = q || 3;
-	this.heightScale = heightScale || 1;
-	this.grid = new Array(this.segmentsR);
-
-	var tang = new THREE.Vector3();
-	var n = new THREE.Vector3();
-	var bitan = new THREE.Vector3();
-
-	for (var i=0; i<this.segmentsR; ++i) {
-		this.grid[i] = new Array(this.segmentsT);
-		for (var j=0; j<this.segmentsT; ++j) {
-			var u = i / this.segmentsR * 2 * this.p * Math.PI;
-			var v = j / this.segmentsT * 2 * Math.PI;
-			var p = getPos(u, v, this.q, this.p, this.radius, this.heightScale);
-			var p2 = getPos(u+.01, v, this.q, this.p, this.radius, this.heightScale);
-			var cx, cy;
-
-			tang.x = p2.x - p.x; tang.y = p2.y - p.y; tang.z = p2.z - p.z;
-			n.x = p2.x + p.x; n.y = p2.y + p.y; n.z = p2.z + p.z; 
-			bitan.cross(tang, n);
-			n.cross(bitan, tang);
-			bitan.normalize();
-			n.normalize();
-
-			cx = this.tube*Math.cos(v); cy = this.tube*Math.sin(v);
-			p.x += cx * n.x + cy * bitan.x;
-			p.y += cx * n.y + cy * bitan.y;
-			p.z += cx * n.z + cy * bitan.z;
-
-			this.grid[i][j] = vert(p.x, p.y, p.z);
-		}
-	}
-
-	for (var i=0; i<this.segmentsR; ++i) {
-		for (var j=0; j<this.segmentsT; ++j) {
-			var ip = (i+1) % this.segmentsR;
-			var jp = (j+1) % this.segmentsT;
-			var a = this.grid[i][j]; 
-			var b = this.grid[ip][j];
-			var c = this.grid[i][jp]; 
-			var d = this.grid[ip][jp];
-
-			var uva = new THREE.UV(i     / this.segmentsR, j     / this.segmentsT);
-			var uvb = new THREE.UV((i+1) / this.segmentsR, j     / this.segmentsT);
-			var uvc = new THREE.UV(i     / this.segmentsR, (j+1) / this.segmentsT);
-			var uvd = new THREE.UV((i+1) / this.segmentsR, (j+1) / this.segmentsT);
-
-			f3(a, b, c);
-			this.uvs.push( [uva,uvb,uvc] );
-			f3(d, c, b);
-			this.uvs.push( [uvd,uvc,uvb] );
-		}
-	}
-
-	this.computeCentroids();
-	this.computeFaceNormals();
-	this.computeVertexNormals();
-
-	function vert( x, y, z ) {
-		var i = scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
-		return i-1;
-	}
-
-	function f3( a, b, c ) {
-		scope.faces.push( new THREE.Face3( a, b, c ) );
-	}
-
-	function getPos(u, v, in_q, in_p, radius, heightScale ) {
-		var cu = Math.cos(u);
-		var cv = Math.cos(v);
-		var su = Math.sin(u);
-		var quOverP = in_q/in_p*u;
-		var cs = Math.cos(quOverP);
-
-		var tx = radius*(2+cs)*.5 * cu;
-		var ty = radius*(2+cs)*su*.5;
-		var tz = heightScale*radius*Math.sin(quOverP)*.5;
-		
-		return new THREE.Vector3(tx,ty,tz);
-	}
-
-}
-
-Torusknot.prototype = new THREE.Geometry();
-Torusknot.prototype.constructor = Torusknot;

+ 9 - 8
utils/build.py

@@ -84,15 +84,16 @@ EXTRAS_FILES = [
 'extras/ShaderUtils.js',
 'extras/cameras/QuakeCamera.js',
 'extras/cameras/PathCamera.js',
+'extras/geometries/Cube.js',
+'extras/geometries/Cylinder.js',
+'extras/geometries/Icosahedron.js',
+'extras/geometries/Lathe.js',
+'extras/geometries/Plane.js',
+'extras/geometries/Sphere.js',
+'extras/geometries/Torus.js',
+'extras/geometries/TorusKnot.js',
 'extras/io/Loader.js',
-'extras/objects/MarchingCubes.js',
-'extras/primitives/Cube.js',
-'extras/primitives/Cylinder.js',
-'extras/primitives/Plane.js',
-'extras/primitives/Sphere.js',
-'extras/primitives/Torus.js',
-'extras/primitives/Icosahedron.js',
-'extras/primitives/LathedObject.js'
+'extras/objects/MarchingCubes.js'
 ]
 
 CANVAS_FILES = [

Some files were not shown because too many files changed in this diff