|
@@ -51,6 +51,10 @@ class USDZExporter {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ } else if ( object.isCamera ) {
|
|
|
+
|
|
|
+ output += buildCamera( object );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
} );
|
|
@@ -555,4 +559,49 @@ function buildVector2( vector ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+function buildCamera( camera ) {
|
|
|
+
|
|
|
+ const name = camera.name ? camera.name : 'Camera_' + camera.id;
|
|
|
+
|
|
|
+ const transform = buildMatrix( camera.matrixWorld );
|
|
|
+
|
|
|
+ if ( camera.matrixWorld.determinant() < 0 ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.USDZExporter: USDZ does not support negative scales', camera );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (camera.isOrthographicCamera) {
|
|
|
+ return `def Camera "${name}"
|
|
|
+ {
|
|
|
+ matrix4d xformOp:transform = ${ transform }
|
|
|
+ uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
|
+
|
|
|
+ float2 clippingRange = (${camera.near}, ${camera.far})
|
|
|
+ float horizontalAperture = ${(Math.abs(camera.left) + Math.abs(camera.right)) * 10}
|
|
|
+ float verticalAperture = ${(Math.abs(camera.top) + Math.abs(camera.bottom)) * 10}
|
|
|
+ token projection = "orthographic"
|
|
|
+ }
|
|
|
+
|
|
|
+ `;
|
|
|
+ } else {
|
|
|
+ return `def Camera "${name}"
|
|
|
+ {
|
|
|
+ matrix4d xformOp:transform = ${ transform }
|
|
|
+ uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
|
+
|
|
|
+ float2 clippingRange = (${camera.near}, ${camera.far})
|
|
|
+ float focalLength = ${camera.getFocalLength()}
|
|
|
+ float focusDistance = ${camera.focus}
|
|
|
+ float horizontalAperture = ${camera.getFilmWidth()}
|
|
|
+ token projection = "perspective"
|
|
|
+ float verticalAperture = ${camera.getFilmHeight()}
|
|
|
+ }
|
|
|
+
|
|
|
+ `;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
export { USDZExporter };
|