Create an Augmented Reality Blackhole in Your Room in 10 Minutes using Apple Reality Kit
Any object can become a blackhole as long as its mass is concentrated enough to bend space to where not even light can escape its gravity. This is defined by Schwarzschild radius. For the Earth to become a blackhole, the whole Earth must be compressed to a little ball with the radius of 9mm or 0.35in.
I figured that I might not have the super power to create a real blackhole so I created one in Augmented Reality using Apple Reality Kit.
Prerequisite
- Have a Macbook and an iOS device(iPhone, iPad).
- Download Xcode on your Macbook from Apple Store.
Process
Step 1) Find free Blackhole 3D model
I usually find free 3D models from Sketchfab. Here is the link to an incredible blackhole 3D model created by rubykamen
— https://sketchfab.com/3d-models/blackhole-74cbeaeae2174a218fe9455d77902b5
When downloading the 3D model, choose Augmented Reality Format (USDZ)
Step 2) Create AR project in Xcode
Open Xcode and choose Create a new Xcode Project
. Then choose Augmented Reality App
Enter project information and we are ready to make an AR blackhole.
We will see some code in Swift that has been written for us. Don’t worry, the code is basically loading the box object and then appending it to the AR view in our phone. We don’t have to change anything in the code.
Step 3) Import blackhole 3D model to AR project.
Click on Experience
on the left directory, and then click on Open in Reality Composer
on the right
Then delete the cube object using right click on your mouse and then click Add
button on the top menu bar.
Then click on Import
button once the popup appears and then locate and select the 3D model file that we downloaded in Step 1.
Step 4) Configure the spin velocity and the position of the blackhole
Click on the blackhole 3D model in our screen after it is imported. Then adjust the Position
, Rotation
, and Scale
same as the right menu in the below image.
All blackholes have angular velocity, so we will add spinning to this blackhole. Click on Behaviours
on the top menu bar, and then +
icon and choose Custom
behaviour.
Once it is added, then choose Scene Start
trigger, and Spin
action.
Within Spin action, choose loop
symbol. Then choose Affected Objects
and click on our blackhole.
Adjust the Duration
to 15 sec. and Iterations
to 10. This determines how fast our blackhole will spin.
Then we are ready to deploy the AR app to our iPhone
Step 5) Build the AR app on your phone.
Connect our phone to the Macbook through USB cable, make sure to choose the device under iOS Device.
and then click on play button to build the project into an app in our iOS device.
and Voilà, we have our AR app that creates blackhole 🕳