Find out how to convert and compress OBJ fashions to GLTF to be used with AWS IoT TwinMaker

Attempting to get began with AWS IoT TwinMaker and have to convert your OBJ file to glTF? Maybe you could have carried out some extent cloud scan of your surroundings with Matterport and it’s not clear how one can import the Matterpak bundle into AWS IoT TwinMaker. On this weblog, you’ll apply a mannequin conversion pipeline to compress and convert a Matterpak bundle into glTF format. This method will present updated 3D fashions and improved scene load instances in AWS IoT TwinMaker.


On this weblog submit, a number of file extensions and mannequin codecs are referenced. Earlier than getting began, it’s good to know the next:

  • OBJ – Object file, a normal 3D picture format that may be exported and opened by numerous 3D picture enhancing packages.
  • MTL – Materials library file, incorporates a number of materials definitions, every of which incorporates the colour, texture, and reflection map of particular person supplies for objects in an OBJ mannequin
  • glTF – Graphics Language Transmission Format, a normal file format for three-dimensional scenes and fashions. A glTF file makes use of one in every of two potential file extensions: .gltf or .glb
  • Level Cloud Scans – A big assortment of particular person factors (x, y, z coordinates) inside a 3D area, captured utilizing a 3D laser scanner and saved in ASCII (.xyz) or binary format.

AWS IoT TwinMaker helps 3D belongings within the glTF format, which is a 3D file format that shops 3D mannequin data in JSON format or binary and permits environment friendly transmission and loading of 3D fashions in purposes. The glTF format minimizes the dimensions of 3D belongings and the runtime processing wanted to unpack and use them. The 3D fashions from conventional CAD purposes, in addition to level cloud scans, will be transformed to glTF utilizing AWS Companion options, corresponding to these from Pixyz. On this weblog, you’ll discover another server-less method to mannequin conversion of Matterpak bundles to glTF utilizing open supply libraries corresponding to Cesium obj2gltf.

Within the structure beneath, you will notice how AWS Lambda can be utilized to detect a Matterpak zip bundle uploaded to an Amazon S3 bucket. It will set off the conversion to glTF inside a protracted operating Lambda execution. The zipped file could include OBJ, MTL, and JPG information.

Inside a Matterpak bundle, there are a number of information together with an OBJ, MTL, level cloud scan (xyz), and presumably many JPG information. Matterport on this instance has transformed the purpose cloud scan to an object mesh format, OBJ. The MTL and JPG information collectively supplies coloured texturing over the objects throughout the OBJ mannequin. The xyz file won’t be used on this conversion course of as this has already been transformed to OBJ within the Matterpak.

Mannequin Conversion Pipeline Structure

When working with level cloud scans corresponding to Matterport, excessive decision JPG textures are captured all through the scan. Doing a easy conversion of the OBJ to glTF will nonetheless be fairly massive. To enhance this, the Lambda operate on this weblog will first compress all JPG photos previous to changing to glTF. Consequently, the conversion will produce a a lot smaller GLB or glTF file as seen on this AWS IoT TwinMaker Scene beneath. Observe, a glTF file makes use of one in every of two potential file extensions: .gltf or .glb. GLB will probably be used on this weblog as it is a binary format versus JSON leading to a smaller mannequin file.

Instance Matterport Scan in AWS IoT TwinMaker


An AWS account will probably be required to setup and execute the steps on this weblog. An AWS Cloudformation template will configure and set up the required AWS Lambda Perform, IAM roles, and Amazon S3 bucket. It’s endorsed that you just work within the Virginia area (us-east-1). You could incur price on among the following providers:

  • Amazon Easy Storage Service (S3) Storage prices
  • AWS Lambda Mannequin Convert Perform


Obtain Matterpak Pattern Bundle

Obtain one of many Matterpak Bundles. Choose one of many bundles, corresponding to Pro2. This out there checklist of bundles could change. The approximate file dimension for the Pro2 pattern bundle is 178MB.

Set up Mannequin Convert Lambda Perform

  1. Obtain the pattern Lambda Mannequin Convert deployment package deal. The operate code inside this package deal will carry out the next:
    – Obtain Matterpak bundle from S3
    – Extract to the Lambda /tmp listing
    – Compress all JPG photos
    – Convert OBJ information to GLB
    – Add GLB again to the S3 Bucket.
  2. Log into the Amazon S3 console
  3. Create an S3 bucket or select an present one the place you’ll add the Lambda operate you downloaded. Depart the file zipped as is.
  4. As soon as the Lambda operate has been positioned in S3, launch this CloudFormation template
  5. Change the LambdaArtifactBucketName parameter worth to the identify of the bucket you uploaded the Lambda operate to
  6. Change the S3BucketName parameter worth to the identify of a brand new bucket that can host your mannequin information. This will probably be created for you. Be sure you choose a reputation that’s globally distinctive as it is going to fail in the course of the creation of the stack in any other case.
  7. Click on on Create Stack to arrange the mannequin conversion pipeline
  8. As soon as full, navigate to the brand new S3 bucket. A hyperlink will be discovered below the Assets tab
  9. Create a folder on this bucket and identify it paks
  10. Add the Matterpak bundle that was downloaded in step 1 to the paks folder. Be sure you hold it zipped because the Lambda operate will unzip it throughout processing. The conversion course of will start routinely and will take a couple of minutes.
  11. If the mannequin is transformed efficiently, you will notice a GLB file within the root of the S3 Bucket. If not, examine Amazon CloudWatch for any logs from the Lambda operate.

Add Mannequin to Scene (Non-compulsory)

To recap, you could have efficiently compressed and transformed an almost 180MB level cloud scan by Matterport to a 18MB GLB file. With the mannequin transformed, you’ll be able to attempt to load this in your IoT TwinMaker workspace. Observe that any Mattertags you could have created in Matterport will not be transferrable on this course of. This have to be recreated utilizing IoT TwinMaker Tags within the Scene composer.

  1. In your IoT TwinMaker Workspace, add the GLB mannequin within the Assets part. In case you haven’t already created a workspace, please comply with the steps at Getting Began with AWS IoT TwinMaker.
  2. Add this mannequin to your scene or create one if it doesn’t exist already. In case you want steerage on this course of, the documentation is obtainable right here. Don’t neglect to set environmental lighting because the mannequin will seem all black.

Clear Up

Be sure you clear up the work on this weblog to keep away from prices. Delete the next sources when completed on this order

  1. Delete the article information within the Lambda and Mannequin S3 Buckets. Observe, this isn’t the IoT TwinMaker Workspace bucket however slightly the buckets created for this weblog
  2. Delete the CloudFormation Stack
  3. Delete the mannequin out of your TwinMaker workspace


On this weblog, you created a mannequin conversion pipeline to compress and convert a Matterpak bundle into glTF format.  This consists of generic conversion of OBJ from different techniques as properly. With this pipeline, it is possible for you to to cut back Scene load instances and streamline 3D mannequin updates on to your IoT TwinMaker workspace.

Listed below are different mannequin conversion blogs out there, with extra to come back:
Find out how to convert CAD belongings to glTF to be used with AWS IoT TwinMaker

In regards to the writer

Chris Azer is a Senior IoT Specialist Architect serving to prospects with their digital twin initiatives. Chris has labored in numerous roles at AWS since 2017 supporting companions and prospects with architecting IoT options. This features a broad set of use circumstances overlaying the DoD, Manufacturing, State and Native Authorities, Federal and Civilian, Sensible Cities, Companions, and others. His profession in Industrial Automation dates again to 2004 the place he continues to help enterprises at this time with their sensible manufacturing journey.


Leave a Reply

Your email address will not be published.