提交 23269242 编写于 作者: M Mugen87

JSM: Update modules.

上级 b163e54d
......@@ -1940,13 +1940,15 @@ var GLTFLoader = ( function () {
// The buffer is not interleaved if the stride is the item size in bytes.
if ( byteStride && byteStride !== itemBytes ) {
var ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType;
// Each "slice" of the buffer, as defined by 'count' elements of 'byteStride' bytes, gets its own InterleavedBuffer
// This makes sure that IBA.count reflects accessor.count properly
var ibSlice = Math.floor( byteOffset / byteStride );
var ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType + ':' + ibSlice + ':' + accessorDef.count;
var ib = parser.cache.get( ibCacheKey );
if ( ! ib ) {
// Use the full buffer if it's interleaved.
array = new TypedArray( bufferView );
array = new TypedArray( bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes );
// Integer parameters to IB/IBA are in array elements, not bytes.
ib = new InterleavedBuffer( array, byteStride / elementBytes );
......@@ -1955,7 +1957,7 @@ var GLTFLoader = ( function () {
}
bufferAttribute = new InterleavedBufferAttribute( ib, itemSize, byteOffset / elementBytes, normalized );
bufferAttribute = new InterleavedBufferAttribute( ib, itemSize, (byteOffset % byteStride) / elementBytes, normalized );
} else {
......@@ -2977,14 +2979,11 @@ var GLTFLoader = ( function () {
return ( function () {
// .isBone isn't in glTF spec. See .markDefs
if ( nodeDef.isBone === true ) {
return Promise.resolve( new Bone() );
var pending = [];
} else if ( nodeDef.mesh !== undefined ) {
if ( nodeDef.mesh !== undefined ) {
return parser.getDependency( 'mesh', nodeDef.mesh ).then( function ( mesh ) {
pending.push( parser.getDependency( 'mesh', nodeDef.mesh ).then( function ( mesh ) {
var node;
......@@ -3030,25 +3029,58 @@ var GLTFLoader = ( function () {
return node;
} );
} ) );
}
} else if ( nodeDef.camera !== undefined ) {
if ( nodeDef.camera !== undefined ) {
return parser.getDependency( 'camera', nodeDef.camera );
pending.push( parser.getDependency( 'camera', nodeDef.camera ) );
} else if ( nodeDef.extensions
}
if ( nodeDef.extensions
&& nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ]
&& nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].light !== undefined ) {
return parser.getDependency( 'light', nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].light );
pending.push( parser.getDependency( 'light', nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].light ) );
}
return Promise.all( pending );
}() ).then( function ( objects ) {
var node;
// .isBone isn't in glTF spec. See .markDefs
if ( nodeDef.isBone === true ) {
node = new Bone();
} else if ( objects.length > 1 ) {
node = new Group();
} else if ( objects.length === 1 ) {
node = objects[ 0 ];
} else {
return Promise.resolve( new Object3D() );
node = new Object3D();
}
}() ).then( function ( node ) {
if ( node !== objects[ 0 ] ) {
for ( var i = 0, il = objects.length; i < il; i ++ ) {
node.add( objects[ i ] );
}
}
if ( nodeDef.name !== undefined ) {
......@@ -3132,11 +3164,9 @@ var GLTFLoader = ( function () {
} ).then( function ( jointNodes ) {
var meshes = node.isGroup === true ? node.children : [ node ];
for ( var i = 0, il = meshes.length; i < il; i ++ ) {
node.traverse( function ( mesh ) {
var mesh = meshes[ i ];
if ( ! mesh.isMesh ) return;
var bones = [];
var boneInverses = [];
......@@ -3169,7 +3199,7 @@ var GLTFLoader = ( function () {
mesh.bind( new Skeleton( bones, boneInverses ), mesh.matrixWorld );
}
} );
return node;
......
......@@ -54,7 +54,7 @@ TTFLoader.prototype = {
var glyphs = {};
var scale = ( 100000 ) / ( ( font.unitsPerEm || 2048 ) * 72 );
var glyphIndexMap = font.encoding.cmap.glyphIndexMap;
var unicodes = Object.keys( glyphIndexMap );
......@@ -108,7 +108,7 @@ TTFLoader.prototype = {
} );
glyphs[ String.fromCodePoint( unicode ) ] = token;
glyphs[ String.fromCodePoint( glyph.unicode ) ] = token;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册