提交 72c5799a 编写于 作者: M Mr.doob

Merge remote-tracking branch 'alteredq/dev' into dev

因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -225,8 +225,8 @@ for(var c=c||1,d=d||0,i=this,j=0,l=b.length;j<l;j++)e(new THREE.Vector3(b[j][0],
THREE.IcosahedronGeometry=function(b,a){var c=(1+Math.sqrt(5))/2;THREE.PolyhedronGeometry.call(this,[[-1,c,0],[1,c,0],[-1,-c,0],[1,-c,0],[0,-1,c],[0,1,c],[0,-1,-c],[0,1,-c],[c,0,-1],[c,0,1],[-c,0,-1],[-c,0,1]],[[0,11,5],[0,5,1],[0,1,7],[0,7,10],[0,10,11],[1,5,9],[5,11,4],[11,10,2],[10,7,6],[7,1,8],[3,9,4],[3,4,2],[3,2,6],[3,6,8],[3,8,9],[4,9,5],[2,4,11],[6,2,10],[8,6,7],[9,8,1]],b,a)};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
THREE.OctahedronGeometry=function(b,a){THREE.PolyhedronGeometry.call(this,[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],[[0,2,4],[0,4,3],[0,3,5],[0,5,2],[1,2,5],[1,5,3],[1,3,4],[1,4,2]],b,a)};THREE.OctahedronGeometry.prototype=new THREE.Geometry;THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry;THREE.TetrahedronGeometry=function(b,a){THREE.PolyhedronGeometry.call(this,[[1,1,1],[-1,-1,1],[-1,1,-1],[1,-1,-1]],[[2,1,0],[0,3,2],[1,3,0],[2,3,1]],b,a)};
THREE.TetrahedronGeometry.prototype=new THREE.Geometry;THREE.TetrahedronGeometry.prototype.constructor=THREE.TetrahedronGeometry;
THREE.ParametricGeometry=function(b,a,c,d){THREE.Geometry.call(this);var e=this.vertices,f=this.faces,g=this.faceVertexUvs[0],d=d===void 0?false:d,h,i,j,l,n=a+1;for(h=0;h<=c;h++){l=h/c;for(i=0;i<=a;i++){j=i/a;j=b(j,l);e.push(j)}}var k,m,o,q;for(h=0;h<c;h++)for(i=0;i<a;i++){b=h*n+i;e=h*n+i+1;l=(h+1)*n+i;j=(h+1)*n+i+1;k=new THREE.UV(h/a,i/c);m=new THREE.UV(h/a,(i+1)/c);o=new THREE.UV((h+1)/a,i/c);q=new THREE.UV((h+1)/a,(i+1)/c);if(d){f.push(new THREE.Face3(b,e,l));f.push(new THREE.Face3(e,j,l));g.push([k,
m,o]);g.push([m,q,o])}else{f.push(new THREE.Face4(b,e,j,l));g.push([k,m,o,q])}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.ParametricGeometry.prototype=new THREE.Geometry;THREE.ParametricGeometry.prototype.constructor=THREE.ParametricGeometry;
THREE.ParametricGeometry=function(b,a,c,d){THREE.Geometry.call(this);var e=this.vertices,f=this.faces,g=this.faceVertexUvs[0],d=d===void 0?false:d,h,i,j,l,n=a+1;for(h=0;h<=c;h++){l=h/c;for(i=0;i<=a;i++){j=i/a;j=b(j,l);e.push(j)}}var k,m,o,q;for(h=0;h<c;h++)for(i=0;i<a;i++){b=h*n+i;e=h*n+i+1;l=(h+1)*n+i;j=(h+1)*n+i+1;k=new THREE.UV(i/a,h/c);m=new THREE.UV((i+1)/a,h/c);o=new THREE.UV(i/a,(h+1)/c);q=new THREE.UV((i+1)/a,(h+1)/c);if(d){f.push(new THREE.Face3(b,e,l));f.push(new THREE.Face3(e,j,l));g.push([k,
m,o]);g.push([m,q,o])}else{f.push(new THREE.Face4(b,e,j,l));g.push([k,m,q,o])}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.ParametricGeometry.prototype=new THREE.Geometry;THREE.ParametricGeometry.prototype.constructor=THREE.ParametricGeometry;
THREE.AxisHelper=function(){THREE.Object3D.call(this);var b=new THREE.Geometry;b.vertices.push(new THREE.Vector3);b.vertices.push(new THREE.Vector3(0,100,0));var a=new THREE.CylinderGeometry(0,5,25,5,1),c;c=new THREE.Line(b,new THREE.LineBasicMaterial({color:16711680}));c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Mesh(a,new THREE.MeshBasicMaterial({color:16711680}));c.position.x=100;c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Line(b,new THREE.LineBasicMaterial({color:65280}));this.add(c);
c=new THREE.Mesh(a,new THREE.MeshBasicMaterial({color:65280}));c.position.y=100;this.add(c);c=new THREE.Line(b,new THREE.LineBasicMaterial({color:255}));c.rotation.x=Math.PI/2;this.add(c);c=new THREE.Mesh(a,new THREE.MeshBasicMaterial({color:255}));c.position.z=100;c.rotation.x=Math.PI/2;this.add(c)};THREE.AxisHelper.prototype=new THREE.Object3D;THREE.AxisHelper.prototype.constructor=THREE.AxisHelper;
THREE.ArrowHelper=function(b,a,c,d){THREE.Object3D.call(this);d===void 0&&(d=16776960);c===void 0&&(c=20);var e=new THREE.Geometry;e.vertices.push(new THREE.Vector3(0,0,0));e.vertices.push(new THREE.Vector3(0,1,0));this.line=new THREE.Line(e,new THREE.LineBasicMaterial({color:d}));this.add(this.line);e=new THREE.CylinderGeometry(0,0.05,0.25,5,1);this.cone=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:d}));this.cone.position.set(0,1,0);this.add(this.cone);if(a instanceof THREE.Vector3)this.position=
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -104,6 +104,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_gl,
_programs = [],
_programs_counter = 0,
// internal state cache
......@@ -369,6 +370,69 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.deallocateMaterial = function ( material ) {
var program = material.program;
if ( ! program ) return;
material.program = undefined;
// only deallocate GL program if this was the last use of shared program
// assumed there is only single copy of any program in the _programs list
// (that's how it's constructed)
var i, il, programInfo;
var deleteProgram = false;
for ( i = 0, il = _programs.length; i < il; i ++ ) {
programInfo = _programs[ i ];
if ( programInfo.program === program ) {
programInfo.usedTimes --;
if ( programInfo.usedTimes === 0 ) {
deleteProgram = true;
}
break;
}
}
if ( deleteProgram ) {
// avoid using array.splice, this is costlier than creating new array from scratch
var newPrograms = [];
for ( i = 0, il = _programs.length; i < il; i ++ ) {
programInfo = _programs[ i ];
if ( programInfo.program !== program ) {
newPrograms.push( programInfo );
}
}
_programs = newPrograms;
_gl.deleteProgram( program );
_this.info.memory.programs --;
}
};
// Rendering
this.updateShadowMap = function ( scene, camera ) {
......@@ -5463,11 +5527,15 @@ THREE.WebGLRenderer = function ( parameters ) {
for ( p = 0, pl = _programs.length; p < pl; p ++ ) {
if ( _programs[ p ].code === code ) {
var programInfo = _programs[ p ];
if ( programInfo.code === code ) {
// console.log( "Code already compiled." /*: \n\n" + code*/ );
return _programs[ p ].program;
programInfo.usedTimes ++;
return programInfo.program;
}
......@@ -5611,8 +5679,11 @@ THREE.WebGLRenderer = function ( parameters ) {
].join("\n");
_gl.attachShader( program, getShader( "fragment", prefix_fragment + fragmentShader ) );
_gl.attachShader( program, getShader( "vertex", prefix_vertex + vertexShader ) );
var glFragmentShader = getShader( "fragment", prefix_fragment + fragmentShader );
var glVertexShader = getShader( "vertex", prefix_vertex + vertexShader );
_gl.attachShader( program, glVertexShader );
_gl.attachShader( program, glFragmentShader );
_gl.linkProgram( program );
......@@ -5622,6 +5693,11 @@ THREE.WebGLRenderer = function ( parameters ) {
}
// clean up
_gl.deleteShader( glFragmentShader );
_gl.deleteShader( glVertexShader );
//console.log( prefix_fragment + fragmentShader );
//console.log( prefix_vertex + vertexShader );
......@@ -5676,9 +5752,9 @@ THREE.WebGLRenderer = function ( parameters ) {
cacheAttributeLocations( program, identifiers );
program.id = _programs.length;
program.id = _programs_counter ++;
_programs.push( { program: program, code: code } );
_programs.push( { program: program, code: code, usedTimes: 1 } );
_this.info.memory.programs = _programs.length;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册