|
|
@@ -90,6 +90,83 @@ export default QUnit.module( 'Addons', () => {
|
|
|
|
|
|
} );
|
|
|
|
|
|
+ QUnit.test( 'export scene with onlyVisible option', async ( assert ) => {
|
|
|
+
|
|
|
+ const exporter = new USDZExporter( );
|
|
|
+
|
|
|
+ const scene = new Scene();
|
|
|
+
|
|
|
+ const geometry = new BoxGeometry( 1, 1, 1 );
|
|
|
+ const material1 = new MeshStandardMaterial( { color: 0xff0000 } );
|
|
|
+ const material2 = new MeshStandardMaterial( { color: 0x00ff00 } );
|
|
|
+
|
|
|
+ const box1 = new Mesh( geometry, material1 );
|
|
|
+ box1.name = 'box1';
|
|
|
+ box1.position.set( - 1, 0, 0 );
|
|
|
+
|
|
|
+ const box2 = new Mesh( geometry, material2 );
|
|
|
+ box2.name = 'box2';
|
|
|
+ box2.position.set( 1, 0, 0 );
|
|
|
+ box2.visible = false;
|
|
|
+
|
|
|
+ scene.add( box1 );
|
|
|
+ scene.add( box2 );
|
|
|
+
|
|
|
+ // onlyVisible = true
|
|
|
+
|
|
|
+ const options = {
|
|
|
+ onlyVisible: true,
|
|
|
+ };
|
|
|
+ const exportResult = await exporter.parseAsync( scene, options );
|
|
|
+
|
|
|
+ assert.ok(
|
|
|
+ exportResult.buffer instanceof ArrayBuffer,
|
|
|
+ 'Export returns an ArrayBuffer'
|
|
|
+ );
|
|
|
+ assert.ok(
|
|
|
+ exportResult.buffer.byteLength > 0,
|
|
|
+ 'ArrayBuffer has non-zero length'
|
|
|
+ );
|
|
|
+
|
|
|
+ const unzipped = unzipSync( exportResult );
|
|
|
+ const fileNames = Object.keys( unzipped );
|
|
|
+ const modelFileName = 'model.usda';
|
|
|
+
|
|
|
+ assert.ok( fileNames.includes( modelFileName ), `ZIP contains ${modelFileName}` );
|
|
|
+
|
|
|
+ const usdaContent = strFromU8( unzipped[ modelFileName ] );
|
|
|
+ assert.ok( isValidUSDA( usdaContent ), `${modelFileName} is valid USDA` );
|
|
|
+
|
|
|
+ assert.ok( usdaContent.includes( 'box1' ), 'USDA contains box1' );
|
|
|
+ assert.ok( ! usdaContent.includes( 'box2' ), 'USDA does not contain box2' );
|
|
|
+
|
|
|
+ // onlyVisible = false
|
|
|
+
|
|
|
+ options.onlyVisible = false;
|
|
|
+ const exportResult2 = await exporter.parseAsync( scene, options );
|
|
|
+
|
|
|
+ assert.ok(
|
|
|
+ exportResult2.buffer instanceof ArrayBuffer,
|
|
|
+ 'Export returns an ArrayBuffer'
|
|
|
+ );
|
|
|
+ assert.ok(
|
|
|
+ exportResult2.buffer.byteLength > 0,
|
|
|
+ 'ArrayBuffer has non-zero length'
|
|
|
+ );
|
|
|
+
|
|
|
+ const unzipped2 = unzipSync( exportResult2 );
|
|
|
+ const fileNames2 = Object.keys( unzipped2 );
|
|
|
+
|
|
|
+ assert.ok( fileNames2.includes( modelFileName ), `ZIP contains ${modelFileName}` );
|
|
|
+
|
|
|
+ const usdaContent2 = strFromU8( unzipped2[ modelFileName ] );
|
|
|
+ assert.ok( isValidUSDA( usdaContent2 ), `${modelFileName} is valid USDA` );
|
|
|
+
|
|
|
+ assert.ok( usdaContent2.includes( 'box1' ), 'USDA contains box1' );
|
|
|
+ assert.ok( usdaContent2.includes( 'box2' ), 'USDA contains box2' );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
} );
|
|
|
|
|
|
} );
|