@damienmortini/three 0.1.180 → 0.1.182
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.
|
@@ -62,6 +62,7 @@ import {
|
|
|
62
62
|
VectorKeyframeTrack,
|
|
63
63
|
sRGBEncoding
|
|
64
64
|
} from '../../../../three/src/Three.js';
|
|
65
|
+
import { toTrianglesDrawMode } from '../utils/BufferGeometryUtils.js';
|
|
65
66
|
|
|
66
67
|
class GLTFLoader extends Loader {
|
|
67
68
|
|
|
@@ -286,6 +287,7 @@ class GLTFLoader extends Loader {
|
|
|
286
287
|
let json;
|
|
287
288
|
const extensions = {};
|
|
288
289
|
const plugins = {};
|
|
290
|
+
const textDecoder = new TextDecoder();
|
|
289
291
|
|
|
290
292
|
if ( typeof data === 'string' ) {
|
|
291
293
|
|
|
@@ -293,7 +295,7 @@ class GLTFLoader extends Loader {
|
|
|
293
295
|
|
|
294
296
|
} else if ( data instanceof ArrayBuffer ) {
|
|
295
297
|
|
|
296
|
-
const magic =
|
|
298
|
+
const magic = textDecoder.decode( new Uint8Array( data, 0, 4 ) );
|
|
297
299
|
|
|
298
300
|
if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) {
|
|
299
301
|
|
|
@@ -312,7 +314,7 @@ class GLTFLoader extends Loader {
|
|
|
312
314
|
|
|
313
315
|
} else {
|
|
314
316
|
|
|
315
|
-
json = JSON.parse(
|
|
317
|
+
json = JSON.parse( textDecoder.decode( data ) );
|
|
316
318
|
|
|
317
319
|
}
|
|
318
320
|
|
|
@@ -584,7 +586,7 @@ class GLTFLightsExtension {
|
|
|
584
586
|
|
|
585
587
|
}
|
|
586
588
|
|
|
587
|
-
getDependency( type, index ) {
|
|
589
|
+
getDependency( type, index ) {
|
|
588
590
|
|
|
589
591
|
if ( type !== 'light' ) return;
|
|
590
592
|
|
|
@@ -1566,9 +1568,10 @@ class GLTFBinaryExtension {
|
|
|
1566
1568
|
this.body = null;
|
|
1567
1569
|
|
|
1568
1570
|
const headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH );
|
|
1571
|
+
const textDecoder = new TextDecoder();
|
|
1569
1572
|
|
|
1570
1573
|
this.header = {
|
|
1571
|
-
magic:
|
|
1574
|
+
magic: textDecoder.decode( new Uint8Array( data.slice( 0, 4 ) ) ),
|
|
1572
1575
|
version: headerView.getUint32( 4, true ),
|
|
1573
1576
|
length: headerView.getUint32( 8, true )
|
|
1574
1577
|
};
|
|
@@ -1598,7 +1601,7 @@ class GLTFBinaryExtension {
|
|
|
1598
1601
|
if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON ) {
|
|
1599
1602
|
|
|
1600
1603
|
const contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength );
|
|
1601
|
-
this.content =
|
|
1604
|
+
this.content = textDecoder.decode( contentArray );
|
|
1602
1605
|
|
|
1603
1606
|
} else if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN ) {
|
|
1604
1607
|
|
|
@@ -2264,7 +2267,7 @@ class GLTFParser {
|
|
|
2264
2267
|
|
|
2265
2268
|
// Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
|
|
2266
2269
|
// expensive work of uploading a texture to the GPU off the main thread.
|
|
2267
|
-
|
|
2270
|
+
|
|
2268
2271
|
let isSafari = false;
|
|
2269
2272
|
let isFirefox = false;
|
|
2270
2273
|
let firefoxVersion = - 1;
|
|
@@ -4305,98 +4308,4 @@ function addPrimitiveAttributes( geometry, primitiveDef, parser ) {
|
|
|
4305
4308
|
|
|
4306
4309
|
}
|
|
4307
4310
|
|
|
4308
|
-
/**
|
|
4309
|
-
* @param {BufferGeometry} geometry
|
|
4310
|
-
* @param {Number} drawMode
|
|
4311
|
-
* @return {BufferGeometry}
|
|
4312
|
-
*/
|
|
4313
|
-
function toTrianglesDrawMode( geometry, drawMode ) {
|
|
4314
|
-
|
|
4315
|
-
let index = geometry.getIndex();
|
|
4316
|
-
|
|
4317
|
-
// generate index if not present
|
|
4318
|
-
|
|
4319
|
-
if ( index === null ) {
|
|
4320
|
-
|
|
4321
|
-
const indices = [];
|
|
4322
|
-
|
|
4323
|
-
const position = geometry.getAttribute( 'position' );
|
|
4324
|
-
|
|
4325
|
-
if ( position !== undefined ) {
|
|
4326
|
-
|
|
4327
|
-
for ( let i = 0; i < position.count; i ++ ) {
|
|
4328
|
-
|
|
4329
|
-
indices.push( i );
|
|
4330
|
-
|
|
4331
|
-
}
|
|
4332
|
-
|
|
4333
|
-
geometry.setIndex( indices );
|
|
4334
|
-
index = geometry.getIndex();
|
|
4335
|
-
|
|
4336
|
-
} else {
|
|
4337
|
-
|
|
4338
|
-
console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' );
|
|
4339
|
-
return geometry;
|
|
4340
|
-
|
|
4341
|
-
}
|
|
4342
|
-
|
|
4343
|
-
}
|
|
4344
|
-
|
|
4345
|
-
//
|
|
4346
|
-
|
|
4347
|
-
const numberOfTriangles = index.count - 2;
|
|
4348
|
-
const newIndices = [];
|
|
4349
|
-
|
|
4350
|
-
if ( drawMode === TriangleFanDrawMode ) {
|
|
4351
|
-
|
|
4352
|
-
// gl.TRIANGLE_FAN
|
|
4353
|
-
|
|
4354
|
-
for ( let i = 1; i <= numberOfTriangles; i ++ ) {
|
|
4355
|
-
|
|
4356
|
-
newIndices.push( index.getX( 0 ) );
|
|
4357
|
-
newIndices.push( index.getX( i ) );
|
|
4358
|
-
newIndices.push( index.getX( i + 1 ) );
|
|
4359
|
-
|
|
4360
|
-
}
|
|
4361
|
-
|
|
4362
|
-
} else {
|
|
4363
|
-
|
|
4364
|
-
// gl.TRIANGLE_STRIP
|
|
4365
|
-
|
|
4366
|
-
for ( let i = 0; i < numberOfTriangles; i ++ ) {
|
|
4367
|
-
|
|
4368
|
-
if ( i % 2 === 0 ) {
|
|
4369
|
-
|
|
4370
|
-
newIndices.push( index.getX( i ) );
|
|
4371
|
-
newIndices.push( index.getX( i + 1 ) );
|
|
4372
|
-
newIndices.push( index.getX( i + 2 ) );
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
} else {
|
|
4376
|
-
|
|
4377
|
-
newIndices.push( index.getX( i + 2 ) );
|
|
4378
|
-
newIndices.push( index.getX( i + 1 ) );
|
|
4379
|
-
newIndices.push( index.getX( i ) );
|
|
4380
|
-
|
|
4381
|
-
}
|
|
4382
|
-
|
|
4383
|
-
}
|
|
4384
|
-
|
|
4385
|
-
}
|
|
4386
|
-
|
|
4387
|
-
if ( ( newIndices.length / 3 ) !== numberOfTriangles ) {
|
|
4388
|
-
|
|
4389
|
-
console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' );
|
|
4390
|
-
|
|
4391
|
-
}
|
|
4392
|
-
|
|
4393
|
-
// build final geometry
|
|
4394
|
-
|
|
4395
|
-
const newGeometry = geometry.clone();
|
|
4396
|
-
newGeometry.setIndex( newIndices );
|
|
4397
|
-
|
|
4398
|
-
return newGeometry;
|
|
4399
|
-
|
|
4400
|
-
}
|
|
4401
|
-
|
|
4402
4311
|
export { GLTFLoader };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@damienmortini/three",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.182",
|
|
4
4
|
"description": "Three.js helpers",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"install": "npm run copyexamples",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"bugs": "https://github.com/damienmortini/lib/issues",
|
|
29
29
|
"homepage": "https://github.com/damienmortini/lib/tree/main/packages/three",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@damienmortini/core": "^0.2.
|
|
31
|
+
"@damienmortini/core": "^0.2.143",
|
|
32
32
|
"fs-extra": "^11.1.0",
|
|
33
|
-
"three": "0.
|
|
33
|
+
"three": "0.149.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "9c39ac87a4d53c7be6b0c9cf128b892e4fd3abc3"
|
|
36
36
|
}
|