Extract Reality Composer scene for ARQuickLook
From Apple's Creating 3D Content with Reality Composer
document:
You can also save your composition to a .reality file for use as a
lightweight AR Quick Look experience in your app or on the web. This
allows users to place and preview content in the real world to get a
quick sense of what it’s like.To create a Reality file, choose File > Export > Export Project in the
Reality Composer menu, and provide a name for the file. You use the
Reality file that gets stored to disk just like you would use a USDZ
file, as described in Previewing a Model with AR Quick Look.
RealityKit – Load another Scene from the same Reality Composer project
The simplest approach in RealityKit to switch two or more scenes coming from Reality Composer is to use removeAll()
instance method, allowing you to delete all the anchors from array.
You can switch two scenes using asyncAfter(deadline:execute:)
method:
let boxAnchor = try! Experience.loadBox()
arView.scene.anchors.append(boxAnchor)
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
self.arView.scene.anchors.removeAll()
let sphereAnchor = try! Experience.loadSphere()
self.arView.scene.anchors.append(sphereAnchor)
}
Or you can switch two different RC scenes using a regular UIButton
:
@IBAction func loadNewSceneAndDeletePrevious(_ sender: UIButton) {
self.arView.scene.anchors.removeAll()
let sphereAnchor = try! Experience.loadSphere()
self.arView.scene.anchors.append(sphereAnchor)
}
Move the centre of the force within Reality Composer scene
Physics forces are applied to the model's pivot position. At the moment, neither RealityKit nor Reality Composer has the ability to change the location of an object's pivot point.
In addition to the above, you've applied Add Force
behavior that pushes an object along a specific vector with the definite velocity, however, user's taps occur along the local -Z axis of the screen. Do these vectors match?
And one more note: within the Reality-family, only rigid body dynamics is possible, not soft body.
Reality Composer Tap Trigger issue
i found the issue that the ArView was added to a scannerView which was a normal UIImageView deleting that image and adding the ArVIew to the main View make it work
class ViewController: UIViewController {
let arVi = ARView()
override func viewDidLoad() {
super.viewDidLoad()
let ar = try! orbits.loadScene()
arVi.scene.anchors.append(ar)
self.view.addSubview(arVi)
arVi.translatesAutoresizingMaskIntoConstraints = false
arVi.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width).isActive = true
arVi.heightAnchor.constraint(equalToConstant: UIScreen.main.bounds.height).isActive = true
arVi.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
arVi.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
}
}
File from Reality Composer not switching scenes on iPhone 7
It's not a bug. Seemingly you do not append anchor holding B scene to an array of anchors, while removing previous anchor containing A scene.
You can read this post (a second approach) to find out how to implement a desired methodology.
@IBAction func tappedButton(_ sender: UITapGestureRecognizer) {
if (counter % 2) == 0 {
arView.scene.anchors.removeAll()
arView.scene.anchors.append(firstSceneAnchor!)
} else {
arView.scene.anchors.removeAll()
arView.scene.anchors.append(secondSceneAnchor!)
}
counter += 1
}
Related Topics
On Demand Resources "0 Asset Packs"
Actions Assigned to Nsmenuitem Dont Seem to Work
Extension for Average to Return Double from Numeric Generic
Testing a Class Which Preserves Its State in Private Variables
List Is Not Conforming to Encodable
Is There a Simple Way to Test If You Match One of a Set of Enumerations
Access Each Header and Controls in The Tableview in Swift
Loading Image from Remote Url Asynchronously in Swiftui Image Using Combine's Publisher
Swiftui New App Lifecycle How to Connect The Facebook Sdk
Urlcomponents Queryitems Losing Percent Encoding When Mutated
Swift Loaditem Closure Not Running
Update UIapplicationshortcutitem from Extension
How to Get a Full List of Running Processes