未验证 提交 34f9b0eb 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #18647 from kinolaev/patch-1

GLTFExporter: Fix mesh cache key
......@@ -1131,10 +1131,25 @@ THREE.GLTFExporter.prototype = {
*/
function processMesh( mesh ) {
var cacheKey = mesh.geometry.uuid + ':' + mesh.material.uuid;
if ( cachedData.meshes.has( cacheKey ) ) {
var meshCacheKeyParts = [ mesh.geometry.uuid ];
if ( Array.isArray( mesh.material ) ) {
return cachedData.meshes.get( cacheKey );
for ( var i = 0, l = mesh.material.length; i < l; i++ ) {
meshCacheKeyParts.push( mesh.material[ i ].uuid );
}
} else {
meshCacheKeyParts.push( mesh.material.uuid );
}
var meshCacheKey = meshCacheKeyParts.join( ':' );
if ( cachedData.meshes.has( meshCacheKey ) ) {
return cachedData.meshes.get( meshCacheKey );
}
......@@ -1459,7 +1474,7 @@ THREE.GLTFExporter.prototype = {
outputJSON.meshes.push( gltfMesh );
var index = outputJSON.meshes.length - 1;
cachedData.meshes.set( cacheKey, index );
cachedData.meshes.set( meshCacheKey, index );
return index;
......
......@@ -1153,10 +1153,25 @@ GLTFExporter.prototype = {
*/
function processMesh( mesh ) {
var cacheKey = mesh.geometry.uuid + ':' + mesh.material.uuid;
if ( cachedData.meshes.has( cacheKey ) ) {
var meshCacheKeyParts = [ mesh.geometry.uuid ];
if ( Array.isArray( mesh.material ) ) {
return cachedData.meshes.get( cacheKey );
for ( var i = 0, l = mesh.material.length; i < l; i++ ) {
meshCacheKeyParts.push( mesh.material[ i ].uuid );
}
} else {
meshCacheKeyParts.push( mesh.material.uuid );
}
var meshCacheKey = meshCacheKeyParts.join( ':' );
if ( cachedData.meshes.has( meshCacheKey ) ) {
return cachedData.meshes.get( meshCacheKey );
}
......@@ -1481,7 +1496,7 @@ GLTFExporter.prototype = {
outputJSON.meshes.push( gltfMesh );
var index = outputJSON.meshes.length - 1;
cachedData.meshes.set( cacheKey, index );
cachedData.meshes.set( meshCacheKey, index );
return index;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册