Browse Source

Merged zz85's experimental branch.

alteredq 14 years ago
parent
commit
fb6d579d35

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


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


+ 13 - 12
build/custom/ThreeWebGL.js

@@ -218,18 +218,19 @@ b=="vertex"&&(d=f.createShader(f.VERTEX_SHADER));f.shaderSource(d,c);f.compileSh
 case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;
 case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var L=this,f,ua=[],Aa=null,ta=null,va=!0,Y=null,pa=null,D=null,W=null,P=null,S=null,fa=null,K=0,Ba=0,Ea=0,wa=0,ha=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
 new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Z=new THREE.Matrix4,Fa=new Float32Array(16),Da=new Float32Array(16),Ha=new THREE.Vector4,Ta={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ia=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Ya=b.stencil!==void 0?b.stencil:!0,Za=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,$a=b.antialias!==void 0?b.antialias:!1,xa=b.clearColor!==void 0?new THREE.Color(b.clearColor):
-new THREE.Color(0),Ja=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=Ia;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ma,Qa=[],b=THREE.ShaderLib.depthRGBA,Wa=THREE.UniformsUtils.clone(b.uniforms),Ra=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,
-vertexShader:b.vertexShader,uniforms:Wa}),Ua=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Wa,morphTargets:!0});Ra._shadowPass=!0;Ua._shadowPass=!0;try{if(!(f=Ia.getContext("experimental-webgl",{antialias:$a,stencil:Ya,preserveDrawingBuffer:Za})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+f.getParameter(f.VERSION)+" | "+f.getParameter(f.VENDOR)+" | "+f.getParameter(f.RENDERER)+" | "+f.getParameter(f.SHADING_LANGUAGE_VERSION))}catch(ab){console.error(ab)}f.clearColor(0,
-0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);f.clearColor(xa.r,xa.g,xa.b,Ja);this.context=f;var Xa=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,t={};t.vertices=new Float32Array(16);t.faces=new Uint16Array(6);i=0;t.vertices[i++]=-1;t.vertices[i++]=-1;t.vertices[i++]=0;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=
--1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=0;t.vertices[i++]=-1;t.vertices[i++]=1;t.vertices[i++]=0;i=t.vertices[i++]=0;t.faces[i++]=0;t.faces[i++]=1;t.faces[i++]=2;t.faces[i++]=0;t.faces[i++]=2;t.faces[i++]=3;t.vertexBuffer=f.createBuffer();t.elementBuffer=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,t.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,t.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,t.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,
-t.faces,f.STATIC_DRAW);t.program=f.createProgram();f.attachShader(t.program,U("fragment",THREE.ShaderLib.sprite.fragmentShader));f.attachShader(t.program,U("vertex",THREE.ShaderLib.sprite.vertexShader));f.linkProgram(t.program);t.attributes={};t.uniforms={};t.attributes.position=f.getAttribLocation(t.program,"position");t.attributes.uv=f.getAttribLocation(t.program,"uv");t.uniforms.uvOffset=f.getUniformLocation(t.program,"uvOffset");t.uniforms.uvScale=f.getUniformLocation(t.program,"uvScale");t.uniforms.rotation=
-f.getUniformLocation(t.program,"rotation");t.uniforms.scale=f.getUniformLocation(t.program,"scale");t.uniforms.alignment=f.getUniformLocation(t.program,"alignment");t.uniforms.map=f.getUniformLocation(t.program,"map");t.uniforms.opacity=f.getUniformLocation(t.program,"opacity");t.uniforms.useScreenCoordinates=f.getUniformLocation(t.program,"useScreenCoordinates");t.uniforms.affectedByDistance=f.getUniformLocation(t.program,"affectedByDistance");t.uniforms.screenPosition=f.getUniformLocation(t.program,
-"screenPosition");t.uniforms.modelViewMatrix=f.getUniformLocation(t.program,"modelViewMatrix");t.uniforms.projectionMatrix=f.getUniformLocation(t.program,"projectionMatrix");var Va=!1;this.setSize=function(b,c){Ia.width=b;Ia.height=c;this.setViewport(0,0,Ia.width,Ia.height)};this.setViewport=function(b,c,d,e){K=b;Ba=c;Ea=d;wa=e;f.viewport(K,Ba,Ea,wa)};this.setScissor=function(b,c,d,e){f.scissor(b,c,d,e)};this.enableScissorTest=function(b){b?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.enableDepthBufferWrite=
-function(b){va=b;f.depthMask(b)};this.setClearColorHex=function(b,c){xa.setHex(b);Ja=c;f.clearColor(xa.r,xa.g,xa.b,Ja)};this.setClearColor=function(b,c){xa.copy(b);Ja=c;f.clearColor(xa.r,xa.g,xa.b,Ja)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT|f.STENCIL_BUFFER_BIT)};this.getContext=function(){return f};this.initMaterial=function(b,c,d,e){var g,h,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial?
-j="basic":b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial?j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var k=THREE.ShaderLib[j];b.uniforms=THREE.UniformsUtils.clone(k.uniforms);b.vertexShader=k.vertexShader;b.fragmentShader=k.fragmentShader}var m,p,q;m=q=k=0;for(p=c.length;m<p;m++)h=c[m],h instanceof THREE.SpotLight&&q++,h instanceof THREE.DirectionalLight&&q++,h instanceof THREE.PointLight&&
-k++;k+q<=4?m=q:(m=Math.ceil(4*q/(k+q)),k=4-m);h={directional:m,point:k};k=q=0;for(m=c.length;k<m;k++)p=c[k],p instanceof THREE.SpotLight&&p.castShadow&&q++;var o=50;if(e!==void 0&&e instanceof THREE.SkinnedMesh)o=e.bones.length;var r;a:{m=b.fragmentShader;p=b.vertexShader;var k=b.uniforms,c=b.attributes,d={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:d,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,
-maxDirLights:h.directional,maxPointLights:h.point,maxBones:o,shadowMapEnabled:this.shadowMapEnabled&&e.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:q,alphaTest:b.alphaTest},u,e=[];j?e.push(j):(e.push(m),e.push(p));for(u in d)e.push(u),e.push(d[u]);j=e.join();u=0;for(e=ua.length;u<e;u++)if(ua[u].code==j){r=ua[u].program;break a}u=f.createProgram();e=[Xa?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+d.maxDirLights,
-"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,"#define MAX_BONES "+d.maxBones,d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.skinning?"#define USE_SKINNING":"",d.morphTargets?"#define USE_MORPHTARGETS":"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?"#define SHADOWMAP_SOFT":"",d.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+new THREE.Color(0),Ja=b.clearAlpha!==void 0?b.clearAlpha:0;_maxLights=b.maxLights!==void 0?b.maxLights:4;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=Ia;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ma,Qa=[],b=THREE.ShaderLib.depthRGBA,
+Wa=THREE.UniformsUtils.clone(b.uniforms),Ra=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Wa}),Ua=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Wa,morphTargets:!0});Ra._shadowPass=!0;Ua._shadowPass=!0;try{if(!(f=Ia.getContext("experimental-webgl",{antialias:$a,stencil:Ya,preserveDrawingBuffer:Za})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+f.getParameter(f.VERSION)+
+" | "+f.getParameter(f.VENDOR)+" | "+f.getParameter(f.RENDERER)+" | "+f.getParameter(f.SHADING_LANGUAGE_VERSION))}catch(ab){console.error(ab)}f.clearColor(0,0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);f.clearColor(xa.r,xa.g,xa.b,Ja);this.context=f;var Xa=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,t={};t.vertices=new Float32Array(16);
+t.faces=new Uint16Array(6);i=0;t.vertices[i++]=-1;t.vertices[i++]=-1;t.vertices[i++]=0;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=-1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=1;t.vertices[i++]=0;t.vertices[i++]=-1;t.vertices[i++]=1;t.vertices[i++]=0;i=t.vertices[i++]=0;t.faces[i++]=0;t.faces[i++]=1;t.faces[i++]=2;t.faces[i++]=0;t.faces[i++]=2;t.faces[i++]=3;t.vertexBuffer=f.createBuffer();t.elementBuffer=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,
+t.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,t.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,t.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,t.faces,f.STATIC_DRAW);t.program=f.createProgram();f.attachShader(t.program,U("fragment",THREE.ShaderLib.sprite.fragmentShader));f.attachShader(t.program,U("vertex",THREE.ShaderLib.sprite.vertexShader));f.linkProgram(t.program);t.attributes={};t.uniforms={};t.attributes.position=f.getAttribLocation(t.program,"position");t.attributes.uv=f.getAttribLocation(t.program,
+"uv");t.uniforms.uvOffset=f.getUniformLocation(t.program,"uvOffset");t.uniforms.uvScale=f.getUniformLocation(t.program,"uvScale");t.uniforms.rotation=f.getUniformLocation(t.program,"rotation");t.uniforms.scale=f.getUniformLocation(t.program,"scale");t.uniforms.alignment=f.getUniformLocation(t.program,"alignment");t.uniforms.map=f.getUniformLocation(t.program,"map");t.uniforms.opacity=f.getUniformLocation(t.program,"opacity");t.uniforms.useScreenCoordinates=f.getUniformLocation(t.program,"useScreenCoordinates");
+t.uniforms.affectedByDistance=f.getUniformLocation(t.program,"affectedByDistance");t.uniforms.screenPosition=f.getUniformLocation(t.program,"screenPosition");t.uniforms.modelViewMatrix=f.getUniformLocation(t.program,"modelViewMatrix");t.uniforms.projectionMatrix=f.getUniformLocation(t.program,"projectionMatrix");var Va=!1;this.setSize=function(b,c){Ia.width=b;Ia.height=c;this.setViewport(0,0,Ia.width,Ia.height)};this.setViewport=function(b,c,d,e){K=b;Ba=c;Ea=d;wa=e;f.viewport(K,Ba,Ea,wa)};this.setScissor=
+function(b,c,d,e){f.scissor(b,c,d,e)};this.enableScissorTest=function(b){b?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){va=b;f.depthMask(b)};this.setClearColorHex=function(b,c){xa.setHex(b);Ja=c;f.clearColor(xa.r,xa.g,xa.b,Ja)};this.setClearColor=function(b,c){xa.copy(b);Ja=c;f.clearColor(xa.r,xa.g,xa.b,Ja)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT|f.STENCIL_BUFFER_BIT)};this.getContext=function(){return f};this.initMaterial=
+function(b,c,d,e){var g,h,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial?j="basic":b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial?j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var k=THREE.ShaderLib[j];b.uniforms=THREE.UniformsUtils.clone(k.uniforms);b.vertexShader=k.vertexShader;b.fragmentShader=
+k.fragmentShader}var m,p,q;m=q=k=0;for(p=c.length;m<p;m++)h=c[m],h instanceof THREE.SpotLight&&q++,h instanceof THREE.DirectionalLight&&q++,h instanceof THREE.PointLight&&k++;k+q<=_maxLights?m=q:(m=Math.ceil(_maxLights*q/(k+q)),k=_maxLights-m);h={directional:m,point:k};k=q=0;for(m=c.length;k<m;k++)p=c[k],p instanceof THREE.SpotLight&&p.castShadow&&q++;var o=50;if(e!==void 0&&e instanceof THREE.SkinnedMesh)o=e.bones.length;var r;a:{m=b.fragmentShader;p=b.vertexShader;var k=b.uniforms,c=b.attributes,
+d={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:d,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:h.directional,maxPointLights:h.point,maxBones:o,shadowMapEnabled:this.shadowMapEnabled&&e.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:q,alphaTest:b.alphaTest},u,e=[];j?e.push(j):(e.push(m),e.push(p));
+for(u in d)e.push(u),e.push(d[u]);j=e.join();u=0;for(e=ua.length;u<e;u++)if(ua[u].code==j){r=ua[u].program;break a}u=f.createProgram();e=[Xa?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,"#define MAX_BONES "+d.maxBones,d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.skinning?"#define USE_SKINNING":"",d.morphTargets?
+"#define USE_MORPHTARGETS":"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?"#define SHADOWMAP_SOFT":"",d.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
 h=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,d.alphaTest?"#define ALPHATEST "+d.alphaTest:"",d.fog?"#define USE_FOG":"",d.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?"#define SHADOWMAP_SOFT":
 "",d.shadowMapSoft?"#define SHADOWMAP_WIDTH "+d.shadowMapWidth.toFixed(1):"",d.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+d.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");f.attachShader(u,U("fragment",h+m));f.attachShader(u,U("vertex",e+p));f.linkProgram(u);f.getProgramParameter(u,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(u,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");u.uniforms=
 {};u.attributes={};var t,e=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(t in k)e.push(t);t=e;e=0;for(k=t.length;e<k;e++)m=t[e],u.uniforms[m]=f.getUniformLocation(u,m);e=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(t=0;t<d.maxMorphTargets;t++)e.push("morphTarget"+t);for(r in c)e.push(r);r=e;t=0;for(c=r.length;t<c;t++)d=

+ 87 - 21
src/extras/geometries/ExtrudeGeometry.js

@@ -4,9 +4,11 @@
  * Creates extruded geometry from a path shape.
  *
  * parameters = {
+ *
  *  size: 			<float>, 	// size of the text
  *  height: 		<float>, 	// thickness to extrude text
  *  curveSegments: 	<int>,		// number of points on the curves
+ *  steps: 			<int>,		// number of points for z-side extrusions
  *
  *  font: 			<string>,		// font name
  *  weight: 		<string>,		// font weight (normal, bold)
@@ -19,6 +21,10 @@
  *
  *  extrudePath:	<THREE.CurvePath>	// path to extrude shape along
  *  bendPath:		<THREE.CurvePath> 	// path to bend the geometry around
+ *
+ *  material:		 <THREE.Material>	// material for front and back faces
+ *  extrudeMaterial: <THREE.Material>	// material for extrusion and beveled faces
+ *
  *  }
   **/
 
@@ -37,6 +43,8 @@ THREE.ExtrudeGeometry = function( shapes, options ) {
 
 	var s, sl = shapes.length, shape;
 
+	this.shapebb = shapes[ sl - 1 ].getBoundingBox();
+
 	for ( s = 0; s < sl; s ++ ) {
 
 		shape = shapes[ s ];
@@ -45,6 +53,21 @@ THREE.ExtrudeGeometry = function( shapes, options ) {
 
 	}
 
+
+	// UVs to be added
+	// How can we create UVs on this?
+
+	this.computeCentroids();
+	this.computeFaceNormals();
+
+	// can't really use automatic vertex normals
+	// as then front and back sides get smoothed too
+	// should do separate smoothing just for sides
+
+	//this.computeVertexNormals();
+
+	//console.log( "took", ( Date.now() - startTime ) );
+
 };
 
 THREE.ExtrudeGeometry.prototype = new THREE.Geometry();
@@ -53,8 +76,6 @@ THREE.ExtrudeGeometry.prototype.constructor = THREE.ExtrudeGeometry;
 
 THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 
-	//var startTime = Date.now();
-
 	var amount = options.amount !== undefined ? options.amount : 100;
 
 	var bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 6; // 10
@@ -74,6 +95,13 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 
 	var useSpacedPoints = options.useSpacedPoints !== undefined ? options.useSpacedPoints : false;
 
+	var material = options.material;
+	var extrudeMaterial = options.extrudeMaterial;
+
+	var shapebb = this.shapebb;
+	//shapebb = shape.getBoundingBox();
+
+
 	if ( extrudePath ) {
 
 		extrudePts = extrudePath.getPoints( curveSegments );
@@ -109,8 +137,6 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 
 		shape.addWrapPath( bendPath );
 
-		//shapePoints = shape.extractAllPointsWithBend( curveSegments, bendPath );
-
 	}
 
 	var shapePoints;
@@ -310,7 +336,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 		if ( s < 0 ) {
 
 			// in case of emergecy, revert to algorithm 1.
-	
+
 			return getBevelVec1( pt_i, pt_j, pt_k );
 
 		}
@@ -502,9 +528,6 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 	///   Handle Faces
 	////
 
-	// not used anywhere
-	// var layers = ( steps + bevelSegments * 2 ) * vlen;
-
 	// Bottom faces
 
 	if ( bevelEnabled ) {
@@ -588,14 +611,39 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 
 			//console.log('b', i,j, i-1, k,vertices.length);
 
-			var s = 0;
+			var s = 0, sl = steps  + bevelSegments * 2;
 
-			for ( s = 0; s < ( steps  + bevelSegments * 2 ); s ++ ) {
+			for ( s = 0; s < sl; s ++ ) {
 
 				var slen1 = vlen * s;
 				var slen2 = vlen * ( s + 1 );
+				var a = layeroffset + j + slen1,
+					b = layeroffset + k + slen1,
+					c = layeroffset + k + slen2,
+					d = layeroffset + j + slen2;
+
+				f4( a, b, c, d );
+
+				if ( extrudeMaterial ) {
+
+					var v1 = s / sl;
+					var v2 = ( s + 1 ) / sl;
+
+					var ztol = ( amount + bevelThickness * 2 );
+
+					var u1 = ( scope.vertices[ a ].position.z + bevelThickness ) / ztol;
+					var u2 = ( scope.vertices[ d ].position.z + bevelThickness ) / ztol;
+
+					//console.log(vy1, vy2);
+
+					scope.faceVertexUvs[ 0 ].push( [
+						new THREE.UV( u1, v1 ),
+						new THREE.UV( u2, v1 ),
+						new THREE.UV( u2, v2 ),
+						new THREE.UV( u1, v2 )
+					] );
+				}
 
-				f4( layeroffset + j + slen1, layeroffset + k + slen1, layeroffset + k + slen2, layeroffset + j + slen2 );
 
 			}
 
@@ -603,14 +651,6 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 
 	}
 
-	// UVs to be added
-	// How can we create UVs on this?
-
-	this.computeCentroids();
-	this.computeFaceNormals();
-	//this.computeVertexNormals();
-
-	//console.log( "took", ( Date.now() - startTime ) );
 
 	function v( x, y, z ) {
 
@@ -624,7 +664,33 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 		b += shapesOffset;
 		c += shapesOffset;
 
-		scope.faces.push( new THREE.Face3( a, b, c ) );
+		scope.faces.push( new THREE.Face3( a, b, c, null, null, material ) );
+		//normal, color, materials
+
+		if ( material ) {
+
+			var mx = shapebb.minX, my = shapebb.minY;
+
+			var uy = shapebb.maxY; // - shapebb.minY;
+			var ux = shapebb.maxX; // - shapebb.minX;
+
+			var ax = scope.vertices[ a ].position.x,
+				ay = scope.vertices[ a ].position.y,
+
+				bx = scope.vertices[ b ].position.x,
+				by = scope.vertices[ b ].position.y,
+
+				cx = scope.vertices[ c ].position.x,
+				cy = scope.vertices[ c ].position.y;
+
+			scope.faceVertexUvs[ 0 ].push( [
+
+				new THREE.UV( ax / ux, ay / uy ),
+				new THREE.UV( bx / ux, by / uy ),
+				new THREE.UV( cx / ux, cy / uy ),
+
+			] );
+		}
 
 	}
 
@@ -635,7 +701,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 		c += shapesOffset;
 		d += shapesOffset;
 
- 		scope.faces.push( new THREE.Face4( a, b, c, d ) );
+ 		scope.faces.push( new THREE.Face4( a, b, c, d, null, null, extrudeMaterial ) );
 
 	}
 

+ 2 - 2
src/extras/geometries/TextGeometry.js

@@ -88,10 +88,10 @@ THREE.TextGeometry = function ( text, parameters ) {
 	// 	path.add(new THREE.LineCurve( 250, 150,  400, 50));
 	// path.add(new THREE.LineCurve( 400, 50,  0, 50));
 	// 	parameters.bendPath = path;
-	
+
 	// var path = new THREE.ArcCurve(0, 0, 200, Math.PI * 0, Math.PI * 2, true);
 	// 		parameters.bendPath = path;
-	
+
 	// var path = new THREE.SplineCurve([
 	// 		new THREE.Vector2(0, 0),
 	// 		new THREE.Vector2(100, 40),

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