Exporting to USDZ

< previous page next page

In this tutorial, we are going to use RapidCompact to optimize a 3D model and export it directly to the USD/USDZ format for "app-less" AR display with Quicklook or import into ARKit, RealitKit or Reality Composer. Note that you will be able to convert any currently supported file formats to USDZ using RapidCompact.

Table of Contents

If you have a device with iOS 12, such as a recent iPhone or iPad, you should be able to simply view one of the following assets in AR by tapping on one of the following links (Diesel Engine from CadNav, Shoe and Tutanch models courtesy of CultLab3D; This website checks if your browser supports direct viewing with USDZ):

Preparing the files

 back to top

In the following, we'll see how to create such an embeddable AR experience, using RapidCompact. Let's start by downloading the original mesh file here.

As you can see the downloaded file consists of the scanned mesh file as well as the respective textures. While having all files in the same directory, just execute the following command with the RapidCompact CLI:

      rpdx -i Tutanch_scan.obj -c -e Tutanch_compact.usdz
Tip for exporting with old versions of RapidCompact (4.6.0 and older): Scaling Options

If you are using an older version of rpdx and the 3D model comes from a format which is base on meters (eg. glTF) it is important to note that you have to rescale it in order to get a propper scaled result with USDZ. USD files are all using centimeters as reference scale in older rpdx versions; We will now edit the command to the following:
      rpdx -i Tutanch_scan.glb -c --scale 100 -e Tutanch_compact.usdz
The above command, however, actually scales the asset by transforming its meshes. You can achieve the same by only scaling the asset on export (and even change that flag between multiple exports). This can be achieved using the "export:scaling" parameter:
      rpdx -i Tutanch_scan.glb -c -s export:scaling 100 -e Tutanch_compact.usdz
With RapidCompact version 4.7.0 and higher, units are handled automatically and you do not need to scale the asset yourself when exporting to USDZ.

You now should have a compact version of the scan in the USDZ format. In this case we converted the model into glb as explained in the previous Tutorial and exported it using the -w command for embedding in a Web page, or - if you prefer a graphical, configurable tool - feel free to use our 3D Embed configurator available for free as part of our RapidCompact Cloud Platform offering to create your custom 3D web viewer. In this case we used the 3D embed editor to configurate also the link to the creator of the original 3D scan. Your resulting compact model should now look similar to this version:

What is the USDZ Format and how can it be used?

 back to top

USD, short for Universal Scene Description, is a 3D format by Pixar. The USDZ file format is a format for displaying and sharing USD 3D content natively in iOS and platforms that use the USD runtime. Here is a link refering to the official introduction of the USD format by Pixar.

Currently, a USDZ file can contain a USD file, material specifications and texture images (a list of supported files can be found here). With RapidCompact, USDZ files can be written from inputs with PBR Materials and one or multiple input textures, for example resulting from a 3D scan. RapidCompact will also interpret material properties in form of .mtl files or as a part of an input glTF file and convert them into the proper internal format for USDZ. We recommend to use PBR-based materials or textures for the USDZ format to get the best possible visual result. Especially for AR visualizations with the iOS AR-Viewer or custom apps build with ARKit, PBR materials can be very beneficial to the overall quality with a realistic material behaviour in combination with (real-time updated) environment lighting.

The exported sample usdz file opened directly via an embedded HTML link on an iOS device (in this case an iPad).

Embedding a Link to USDZ Files

 back to top

In addition to the possibility of using USDZ files in ARKit or other software and platforms supporting the format, there is a very simple and easy-to-setup way to directly display USDZ files in AR on an iOS 12 device. In the following we will set up a simple example HTML snippet to directly access your USDZ files through the tap on the link or button on your Web page. USDZ the sample USDZ and image file here. The html code directing to the USDZ file could look similar to this:

            <a href="directory/sample_file.usdz" rel="ar">
                <img src="sample_image_file.png" alt="" width="300" height="300">

The most important part here is in line 5: the rel="ar" attribute indicates that the link attached to the image is refering to content usable with the iOS AR- Viewer and also indicates the usibility with a cube- logo layed on top of the used image file (iOS device only).

When hosted over a Web server, the resulting image embedded to the website should now show the image and, in addition, if displayed on an iOS device, a small badge showing a 3D cube should appear in the top right corner:

More information on how to correctly embed USDZ files can also be found in the Webkit blog.

< previous page next page