@needle-tools/three 0.162.2 → 0.162.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1290,13 +1290,14 @@ class GLTFWriter {
|
|
|
1290
1290
|
|
|
1291
1291
|
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
|
|
1292
1292
|
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
|
|
1293
|
-
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap )
|
|
1293
|
+
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ||
|
|
1294
|
+
( typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas ) ) {
|
|
1294
1295
|
|
|
1295
1296
|
ctx.drawImage( image, 0, 0, canvas.width, canvas.height );
|
|
1296
1297
|
|
|
1297
1298
|
} else {
|
|
1298
1299
|
|
|
1299
|
-
throw new Error( 'THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement or
|
|
1300
|
+
throw new Error( 'THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.' );
|
|
1300
1301
|
|
|
1301
1302
|
}
|
|
1302
1303
|
|
|
@@ -1388,6 +1389,18 @@ class GLTFWriter {
|
|
|
1388
1389
|
|
|
1389
1390
|
if ( cache.textures.has( map ) ) return cache.textures.get( map );
|
|
1390
1391
|
|
|
1392
|
+
const beforeWriteArgs = { keep: true, newTexture: null };
|
|
1393
|
+
|
|
1394
|
+
this._invokeAll( function ( ext ) {
|
|
1395
|
+
|
|
1396
|
+
ext.beforeWriteTexture && ext.beforeWriteTexture( map, beforeWriteArgs );
|
|
1397
|
+
|
|
1398
|
+
} );
|
|
1399
|
+
|
|
1400
|
+
if ( beforeWriteArgs.keep === false ) return null;
|
|
1401
|
+
|
|
1402
|
+
if ( beforeWriteArgs.newTexture != null ) map = beforeWriteArgs.newTexture;
|
|
1403
|
+
|
|
1391
1404
|
if ( ! json.textures ) json.textures = [];
|
|
1392
1405
|
|
|
1393
1406
|
// make non-readable textures (e.g. CompressedTexture) readable by blitting them into a new texture
|
|
@@ -1605,6 +1618,20 @@ class GLTFWriter {
|
|
|
1605
1618
|
*/
|
|
1606
1619
|
processMesh( mesh ) {
|
|
1607
1620
|
|
|
1621
|
+
const beforeWriteArgs = { keep: true }
|
|
1622
|
+
|
|
1623
|
+
this._invokeAll( function ( ext ) {
|
|
1624
|
+
|
|
1625
|
+
ext.beforeWriteMesh && ext.beforeWriteMesh( mesh, beforeWriteArgs );
|
|
1626
|
+
|
|
1627
|
+
} );
|
|
1628
|
+
|
|
1629
|
+
if ( beforeWriteArgs.keep != true ) {
|
|
1630
|
+
|
|
1631
|
+
return null;
|
|
1632
|
+
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1608
1635
|
const cache = this.cache;
|
|
1609
1636
|
const json = this.json;
|
|
1610
1637
|
|
|
@@ -2204,6 +2231,20 @@ class GLTFWriter {
|
|
|
2204
2231
|
*/
|
|
2205
2232
|
processNode( object ) {
|
|
2206
2233
|
|
|
2234
|
+
const beforeWriteArgs = { keep: true }
|
|
2235
|
+
|
|
2236
|
+
this._invokeAll( function ( ext ) {
|
|
2237
|
+
|
|
2238
|
+
ext.beforeWriteNode && ext.beforeWriteNode( object, beforeWriteArgs );
|
|
2239
|
+
|
|
2240
|
+
} );
|
|
2241
|
+
|
|
2242
|
+
if ( beforeWriteArgs.keep != true ) {
|
|
2243
|
+
|
|
2244
|
+
return null;
|
|
2245
|
+
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2207
2248
|
const json = this.json;
|
|
2208
2249
|
const options = this.options;
|
|
2209
2250
|
const nodeMap = this.nodeMap;
|
package/package.json
CHANGED
|
@@ -217,19 +217,23 @@ class PropertyBinding {
|
|
|
217
217
|
// search into node subtree.
|
|
218
218
|
if ( root.children ) {
|
|
219
219
|
|
|
220
|
-
const searchNodeSubtree = function ( children ) {
|
|
220
|
+
const searchNodeSubtree = function ( children, checkByUserDataName ) {
|
|
221
221
|
|
|
222
222
|
for ( let i = 0; i < children.length; i ++ ) {
|
|
223
223
|
|
|
224
224
|
const childNode = children[ i ];
|
|
225
225
|
|
|
226
|
-
if ( childNode.name === nodeName || childNode.uuid === nodeName ) {
|
|
226
|
+
if ( ! checkByUserDataName && ( childNode.name === nodeName || childNode.uuid === nodeName ) ) {
|
|
227
|
+
|
|
228
|
+
return childNode;
|
|
229
|
+
|
|
230
|
+
} else if ( checkByUserDataName && childNode.userData && childNode.userData.name === nodeName ) {
|
|
227
231
|
|
|
228
232
|
return childNode;
|
|
229
233
|
|
|
230
234
|
}
|
|
231
235
|
|
|
232
|
-
const result = searchNodeSubtree( childNode.children );
|
|
236
|
+
const result = searchNodeSubtree( childNode.children, checkByUserDataName );
|
|
233
237
|
|
|
234
238
|
if ( result ) return result;
|
|
235
239
|
|
|
@@ -245,6 +249,18 @@ class PropertyBinding {
|
|
|
245
249
|
|
|
246
250
|
return subTreeNode;
|
|
247
251
|
|
|
252
|
+
} else {
|
|
253
|
+
|
|
254
|
+
// Search again by userData.name, as set by GLTFLoader.
|
|
255
|
+
// We don't want to do that in a single pass to avoid incorrect matches.
|
|
256
|
+
const subTreeNode = searchNodeSubtree( root.children, true );
|
|
257
|
+
|
|
258
|
+
if ( subTreeNode ) {
|
|
259
|
+
|
|
260
|
+
return subTreeNode;
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
248
264
|
}
|
|
249
265
|
|
|
250
266
|
}
|