提交 28b6b214 编写于 作者: D Don McCurdy

GLTFLoader: Clean up.

上级 fffe49db
......@@ -1346,34 +1346,21 @@ THREE.GLTFLoader = ( function () {
if ( hasMorphPosition ) {
// TODO: Error-prone use of a callback inside a loop.
var accessor = target.POSITION !== undefined
var pendingAccessor = target.POSITION !== undefined
? parser.getDependency( 'accessor', target.POSITION )
.then( function ( accessor ) {
// Cloning not to pollute original accessor below
return cloneBufferAttribute( accessor );
} )
: geometry.attributes.position;
pendingPositionAccessors.push( accessor );
pendingPositionAccessors.push( pendingAccessor );
}
if ( hasMorphNormal ) {
// TODO: Error-prone use of a callback inside a loop.
var accessor = target.NORMAL !== undefined
var pendingAccessor = target.NORMAL !== undefined
? parser.getDependency( 'accessor', target.NORMAL )
.then( function ( accessor ) {
return cloneBufferAttribute( accessor );
} )
: geometry.attributes.normal;
pendingNormalAccessors.push( accessor );
pendingNormalAccessors.push( pendingAccessor );
}
......@@ -1387,6 +1374,24 @@ THREE.GLTFLoader = ( function () {
var morphPositions = accessors[ 0 ];
var morphNormals = accessors[ 1 ];
// Clone morph target accessors before modifying them.
for ( var i = 0, il = morphPositions.length; i < il; i ++ ) {
if ( geometry.attributes.position === morphPositions[ i ] ) continue;
morphPositions[ i ] = cloneBufferAttribute( morphPositions[ i ] );
}
for ( var i = 0, il = morphNormals.length; i < il; i ++ ) {
if ( geometry.attributes.normal === morphNormals[ i ] ) continue;
morphNormals[ i ] = cloneBufferAttribute( morphNormals[ i ] );
}
for ( var i = 0, il = targets.length; i < il; i ++ ) {
var target = targets[ i ];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册