提交 3ade043c 编写于 作者: M Mr.doob

Updated builds.

上级 2af775f7
......@@ -9478,6 +9478,73 @@ THREE.Geometry.prototype = {
},
// Geometry splitting
makeGroups: ( function () {
var geometryGroupCounter = 0;
return function ( usesFaceMaterial ) {
var f, fl, face, materialIndex,
groupHash, hash_map = {};
var numMorphTargets = this.morphTargets.length;
var numMorphNormals = this.morphNormals.length;
this.geometryGroups = {};
for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
face = this.faces[ f ];
materialIndex = usesFaceMaterial ? face.materialIndex : 0;
if ( ! ( materialIndex in hash_map ) ) {
hash_map[ materialIndex ] = { 'hash': materialIndex, 'counter': 0 };
}
groupHash = hash_map[ materialIndex ].hash + '_' + hash_map[ materialIndex ].counter;
if ( ! ( groupHash in this.geometryGroups ) ) {
this.geometryGroups[ groupHash ] = { 'faces3': [], 'materialIndex': materialIndex, 'vertices': 0, 'numMorphTargets': numMorphTargets, 'numMorphNormals': numMorphNormals };
}
if ( this.geometryGroups[ groupHash ].vertices + 3 > 65535 ) {
hash_map[ materialIndex ].counter += 1;
groupHash = hash_map[ materialIndex ].hash + '_' + hash_map[ materialIndex ].counter;
if ( ! ( groupHash in this.geometryGroups ) ) {
this.geometryGroups[ groupHash ] = { 'faces3': [], 'materialIndex': materialIndex, 'vertices': 0, 'numMorphTargets': numMorphTargets, 'numMorphNormals': numMorphNormals };
}
}
this.geometryGroups[ groupHash ].faces3.push( f );
this.geometryGroups[ groupHash ].vertices += 3;
}
this.geometryGroupsList = [];
for ( var g in this.geometryGroups ) {
this.geometryGroups[ g ].id = geometryGroupCounter ++;
this.geometryGroupsList.push( this.geometryGroups[ g ] );
}
};
} )(),
clone: function () {
var geometry = new THREE.Geometry();
......@@ -20413,7 +20480,6 @@ THREE.WebGLRenderer = function ( parameters ) {
_currentMaterialId = -1,
_currentGeometryGroupHash = null,
_currentCamera = null,
_geometryGroupCounter = 0,
_usedTextureUnits = 0,
......@@ -24051,71 +24117,6 @@ THREE.WebGLRenderer = function ( parameters ) {
};
// Geometry splitting
function sortFacesByMaterial ( geometry, material ) {
var f, fl, face, materialIndex, vertices,
groupHash, hash_map = {};
var numMorphTargets = geometry.morphTargets.length;
var numMorphNormals = geometry.morphNormals.length;
var usesFaceMaterial = material instanceof THREE.MeshFaceMaterial;
geometry.geometryGroups = {};
for ( f = 0, fl = geometry.faces.length; f < fl; f ++ ) {
face = geometry.faces[ f ];
materialIndex = usesFaceMaterial ? face.materialIndex : 0;
if ( hash_map[ materialIndex ] === undefined ) {
hash_map[ materialIndex ] = { 'hash': materialIndex, 'counter': 0 };
}
groupHash = hash_map[ materialIndex ].hash + '_' + hash_map[ materialIndex ].counter;
if ( geometry.geometryGroups[ groupHash ] === undefined ) {
geometry.geometryGroups[ groupHash ] = { 'faces3': [], 'materialIndex': materialIndex, 'vertices': 0, 'numMorphTargets': numMorphTargets, 'numMorphNormals': numMorphNormals };
}
vertices = 3;
if ( geometry.geometryGroups[ groupHash ].vertices + vertices > 65535 ) {
hash_map[ materialIndex ].counter += 1;
groupHash = hash_map[ materialIndex ].hash + '_' + hash_map[ materialIndex ].counter;
if ( geometry.geometryGroups[ groupHash ] === undefined ) {
geometry.geometryGroups[ groupHash ] = { 'faces3': [], 'materialIndex': materialIndex, 'vertices': 0, 'numMorphTargets': numMorphTargets, 'numMorphNormals': numMorphNormals };
}
}
geometry.geometryGroups[ groupHash ].faces3.push( f );
geometry.geometryGroups[ groupHash ].vertices += vertices;
}
geometry.geometryGroupsList = [];
for ( var g in geometry.geometryGroups ) {
geometry.geometryGroups[ g ].id = _geometryGroupCounter ++;
geometry.geometryGroupsList.push( geometry.geometryGroups[ g ] );
}
};
// Objects refresh
this.initWebGLObjects = function ( scene ) {
......@@ -24209,7 +24210,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( geometry.geometryGroups === undefined ) {
sortFacesByMaterial( geometry, material );
geometry.makeGroups( material instanceof THREE.MeshFaceMaterial );
}
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册