How you can convert and compress OBJ fashions to GLTF to be used with AWS IoT TwinMaker

[ad_1]

Making an attempt to get began with AWS IoT TwinMaker and have to convert your OBJ file to glTF? Maybe you could have carried out a degree cloud scan of your atmosphere 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 occasions in AWS IoT TwinMaker.

Overview

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

  • OBJ – Object file, an ordinary 3D picture format that may be exported and opened by varied 3D picture modifying applications.
  • 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, an ordinary file format for three-dimensional scenes and fashions. A glTF file makes use of one in every of two attainable 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 scale 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, might be transformed to glTF utilizing AWS Associate options, reminiscent of these from Pixyz. On this weblog, you’ll discover an alternate server-less method to mannequin conversion of Matterpak bundles to glTF utilizing open supply libraries reminiscent of 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. This can set off the conversion to glTF inside an extended working Lambda execution. The zipped file could comprise OBJ, MTL, and JPG recordsdata.

Inside a Matterpak bundle, there are a number of recordsdata together with an OBJ, MTL, level cloud scan (xyz), and probably many JPG recordsdata. Matterport on this instance has transformed the purpose cloud scan to an object mesh format, OBJ. The MTL and JPG recordsdata collectively offers 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 reminiscent of 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 perform on this weblog will first compress all JPG photos previous to changing to glTF. In consequence, the conversion will produce a a lot smaller GLB or glTF file as seen on this AWS IoT TwinMaker Scene beneath. Be aware, a glTF file makes use of one in every of two attainable file extensions: .gltf or .glb. GLB will probably be used on this weblog as this can be a binary format versus JSON leading to a smaller mannequin file.

Instance Matterport Scan in AWS IoT TwinMaker

Stipulations

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 Operate, IAM roles, and Amazon S3 bucket. It is strongly recommended that you simply work within the Virginia area (us-east-1). You could incur value on among the following providers:

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

Steps

Obtain Matterpak Pattern Bundle

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

Set up Mannequin Convert Lambda Operate

  1. Obtain the pattern Lambda Mannequin Convert deployment package deal. The perform 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 recordsdata to GLB
    – Add GLB again to the S3 Bucket.
  2. Log into the Amazon S3 console
  3. Create an S3 bucket or select an current one the place you’ll add the Lambda perform you downloaded. Go away the file zipped as is.
  4. As soon as the Lambda perform 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 perform to
  6. Change the S3BucketName parameter worth to the identify of a brand new bucket that may host your mannequin recordsdata. This will probably be created for you. Remember to choose a reputation that’s globally distinctive as it’s going to fail throughout 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 might 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. Remember to maintain it zipped because the Lambda perform 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, test Amazon CloudWatch for any logs from the Lambda perform.

Add Mannequin to Scene (Elective)

To recap, you could have efficiently compressed and transformed a virtually 180MB level cloud scan by Matterport to a 18MB GLB file. With the mannequin transformed, you may attempt to load this in your IoT TwinMaker workspace. Be aware that any Mattertags you could have created in Matterport should not 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. Should 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. Should you want steerage on this course of, the documentation is obtainable right here. Don’t overlook to set environmental lighting because the mannequin will seem all black.

Clear Up

Remember to clear up the work on this weblog to keep away from expenses. Delete the next assets when completed on this order

  1. Delete the item recordsdata within the Lambda and Mannequin S3 Buckets. Be aware, this isn’t the IoT TwinMaker Workspace bucket however fairly the buckets created for this weblog
  2. Delete the CloudFormation Stack
  3. Delete the mannequin out of your TwinMaker workspace

Conclusion

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 methods as nicely. With this pipeline, it is possible for you to to cut back Scene load occasions and streamline 3D mannequin updates on to your IoT TwinMaker workspace.

Listed below are different mannequin conversion blogs accessible, with extra to return:
How you can convert CAD belongings to glTF to be used with AWS IoT TwinMaker

Concerning the writer

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

 

[ad_2]

Leave a Reply