@needle-tools/three 0.146.5 → 0.146.6
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.
- package/build/three.cjs +32605 -32587
- package/build/three.js +32619 -32601
- package/build/three.min.js +6 -7
- package/build/three.module.js +871 -842
- package/examples/jsm/exporters/USDZExporter.js +16 -7
- package/package.json +1 -1
- package/src/renderers/webxr/WebXRManager.js +43 -12
|
@@ -375,8 +375,6 @@ class USDZExporter {
|
|
|
375
375
|
|
|
376
376
|
context.output += buildMaterials( materials, textures );
|
|
377
377
|
|
|
378
|
-
invokeAll( context, 'onAfterHierarchy' );
|
|
379
|
-
|
|
380
378
|
const header = context.document.buildHeader();
|
|
381
379
|
const final = header + '\n' + context.output;
|
|
382
380
|
|
|
@@ -393,7 +391,6 @@ class USDZExporter {
|
|
|
393
391
|
for ( const id in textures ) {
|
|
394
392
|
|
|
395
393
|
let texture = textures[ id ];
|
|
396
|
-
const color = id.split( '_' )[ 1 ];
|
|
397
394
|
const isRGBA = texture.format === 1023;
|
|
398
395
|
if ( texture.isCompressedTexture ) {
|
|
399
396
|
|
|
@@ -401,10 +398,20 @@ class USDZExporter {
|
|
|
401
398
|
|
|
402
399
|
}
|
|
403
400
|
|
|
401
|
+
// TODO add readback options for textures that don't have texture.image
|
|
404
402
|
const canvas = await imageToCanvas( texture.image );
|
|
405
|
-
const blob = await new Promise( resolve => canvas.toBlob( resolve, isRGBA ? 'image/png' : 'image/jpeg', 1 ) );
|
|
406
403
|
|
|
407
|
-
|
|
404
|
+
if ( canvas ) {
|
|
405
|
+
|
|
406
|
+
const blob = await new Promise( resolve => canvas.toBlob( resolve, isRGBA ? 'image/png' : 'image/jpeg', 1 ) );
|
|
407
|
+
files[ `textures/Texture_${id}.${isRGBA ? 'png' : 'jpg'}` ] = new Uint8Array( await blob.arrayBuffer() );
|
|
408
|
+
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
|
|
412
|
+
console.warn( 'Can`t export texture: ', texture );
|
|
413
|
+
|
|
414
|
+
}
|
|
408
415
|
|
|
409
416
|
}
|
|
410
417
|
|
|
@@ -542,6 +549,8 @@ function parseDocument( context ) {
|
|
|
542
549
|
|
|
543
550
|
}
|
|
544
551
|
|
|
552
|
+
invokeAll( context, 'onAfterHierarchy', writer );
|
|
553
|
+
|
|
545
554
|
writer.closeBlock();
|
|
546
555
|
writer.closeBlock();
|
|
547
556
|
writer.closeBlock();
|
|
@@ -590,14 +599,14 @@ function addResources( object, context ) {
|
|
|
590
599
|
|
|
591
600
|
}
|
|
592
601
|
|
|
593
|
-
function invokeAll( context, name ) {
|
|
602
|
+
function invokeAll( context, name, writer = null ) {
|
|
594
603
|
|
|
595
604
|
if ( context.extensions ) {
|
|
596
605
|
|
|
597
606
|
for ( const ext of context.extensions ) {
|
|
598
607
|
|
|
599
608
|
if ( typeof ext[ name ] === 'function' )
|
|
600
|
-
ext[ name ]( context );
|
|
609
|
+
ext[ name ]( context, writer );
|
|
601
610
|
|
|
602
611
|
}
|
|
603
612
|
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import { EventDispatcher } from '../../core/EventDispatcher.js';
|
|
|
3
3
|
import { PerspectiveCamera } from '../../cameras/PerspectiveCamera.js';
|
|
4
4
|
import { Vector3 } from '../../math/Vector3.js';
|
|
5
5
|
import { Vector4 } from '../../math/Vector4.js';
|
|
6
|
+
import { RAD2DEG } from '../../math/MathUtils.js';
|
|
6
7
|
import { WebGLAnimation } from '../webgl/WebGLAnimation.js';
|
|
7
8
|
import { WebGLRenderTarget } from '../WebGLRenderTarget.js';
|
|
8
9
|
import { WebXRController } from './WebXRController.js';
|
|
@@ -492,6 +493,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
492
493
|
const bottom2 = bottomFov * far / far2 * near2;
|
|
493
494
|
|
|
494
495
|
camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
|
|
496
|
+
camera.projectionMatrixInverse.copy( camera.projectionMatrix ).invert();
|
|
495
497
|
|
|
496
498
|
}
|
|
497
499
|
|
|
@@ -543,12 +545,42 @@ class WebXRManager extends EventDispatcher {
|
|
|
543
545
|
|
|
544
546
|
}
|
|
545
547
|
|
|
546
|
-
|
|
548
|
+
// update projection matrix for proper view frustum culling
|
|
549
|
+
|
|
550
|
+
if ( cameras.length === 2 ) {
|
|
551
|
+
|
|
552
|
+
setProjectionFromUnion( cameraVR, cameraL, cameraR );
|
|
553
|
+
|
|
554
|
+
} else {
|
|
555
|
+
|
|
556
|
+
// assume single camera setup (AR)
|
|
557
|
+
|
|
558
|
+
cameraVR.projectionMatrix.copy( cameraL.projectionMatrix );
|
|
559
|
+
|
|
560
|
+
}
|
|
547
561
|
|
|
548
562
|
// update user camera and its children
|
|
549
563
|
|
|
550
|
-
|
|
564
|
+
updateUserCamera( camera, cameraVR, parent );
|
|
565
|
+
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
function updateUserCamera( camera, cameraVR, parent ) {
|
|
569
|
+
|
|
570
|
+
if ( parent === null ) {
|
|
571
|
+
|
|
572
|
+
camera.matrix.copy( cameraVR.matrixWorld );
|
|
573
|
+
|
|
574
|
+
} else {
|
|
575
|
+
|
|
576
|
+
camera.matrix.copy( parent.matrixWorld );
|
|
577
|
+
camera.matrix.invert();
|
|
578
|
+
camera.matrix.multiply( cameraVR.matrixWorld );
|
|
579
|
+
|
|
580
|
+
}
|
|
581
|
+
|
|
551
582
|
camera.matrix.decompose( camera.position, camera.quaternion, camera.scale );
|
|
583
|
+
camera.updateMatrixWorld( true );
|
|
552
584
|
|
|
553
585
|
const children = camera.children;
|
|
554
586
|
|
|
@@ -558,21 +590,17 @@ class WebXRManager extends EventDispatcher {
|
|
|
558
590
|
|
|
559
591
|
}
|
|
560
592
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
if ( cameras.length === 2 ) {
|
|
593
|
+
camera.projectionMatrix.copy( cameraVR.projectionMatrix );
|
|
594
|
+
camera.projectionMatrixInverse.copy( cameraVR.projectionMatrixInverse );
|
|
564
595
|
|
|
565
|
-
|
|
596
|
+
if ( camera.isPerspectiveCamera ) {
|
|
566
597
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
// assume single camera setup (AR)
|
|
570
|
-
|
|
571
|
-
cameraVR.projectionMatrix.copy( cameraL.projectionMatrix );
|
|
598
|
+
camera.fov = RAD2DEG * 2 * Math.atan( 1 / camera.projectionMatrix.elements[ 5 ] );
|
|
599
|
+
camera.zoom = 1;
|
|
572
600
|
|
|
573
601
|
}
|
|
574
602
|
|
|
575
|
-
}
|
|
603
|
+
}
|
|
576
604
|
|
|
577
605
|
this.getCamera = function () {
|
|
578
606
|
|
|
@@ -695,12 +723,15 @@ class WebXRManager extends EventDispatcher {
|
|
|
695
723
|
}
|
|
696
724
|
|
|
697
725
|
camera.matrix.fromArray( view.transform.matrix );
|
|
726
|
+
camera.matrix.decompose( camera.position, camera.quaternion, camera.scale );
|
|
698
727
|
camera.projectionMatrix.fromArray( view.projectionMatrix );
|
|
728
|
+
camera.projectionMatrixInverse.copy( camera.projectionMatrix ).invert();
|
|
699
729
|
camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );
|
|
700
730
|
|
|
701
731
|
if ( i === 0 ) {
|
|
702
732
|
|
|
703
733
|
cameraVR.matrix.copy( camera.matrix );
|
|
734
|
+
cameraVR.matrix.decompose( cameraVR.position, cameraVR.quaternion, cameraVR.scale );
|
|
704
735
|
|
|
705
736
|
}
|
|
706
737
|
|