Post

Replies

Boosts

Views

Activity

Reply to Arkit gps alike funcationality
The only ways I know of getting a more accurate positioning is using tracking images which are placed in specific locations, using a visual search system like Google Maps uses, or by using WiFi data. Google has not opened their API for developers unfortunately, and the only company I know that uses WiFi for positioning is called Dent Reality. But again, not accessible to other developers.
Jun ’20
Reply to How to initialize .nonAR mode properly?
In the SwiftUI example they use `.zero` for the frame, might be best to just use the same as it will take it to full screen either way.For the box, in order to avoid any issues, just create and add a box manually instead, also the SwiftUI Preview will basically use the simulator, and the initialiser I mentioned is actually not available for the simulator, you'll need to put in a targetEnvironment check:struct ARViewContainer: UIViewRepresentable { func makeUIView(context: Context) -> ARView { #if targetEnvironment(simulator) let arView = ARView(frame: .zero) #else let arView = ARView(frame: .zero, cameraMode: .nonAR, automaticallyConfigureSession: false) #endif let newAnchor = AnchorEntity(world: [0, 0, -1]) let newBox = ModelEntity(mesh: .generateBox(size: 0.3)) newAnchor.addChild(newBox) arView.scene.anchors.append(newAnchor) return arView } func updateUIView(_ uiView: ARView, context: Context) {} }The simulator automatically uses cameraMode .nonAR, as it has no other choice and cannot be changed to `.ar`.
Jun ’20
Reply to How to initialize .nonAR mode properly?
Your scene may be empty, in which case it would be normal to see nothing. Add a cube to the position [0, 0, -1], it should appear in the middle of your view, since the default camera should be looking at [0,0,-1] from [0,0,0].If you're changing the camera mode from .ar to .nonAR, and don't plan on actually using the session for anything, then it might be best to run arView.session.pause() after, instead of leaving it.A better (IMO) way to initialize a nonAR ARView would be using this initializer, but if you're using storyboards then just changing the camera mode should work just as well. Also, if you want to change the background color, set this parameter:self.arView.environment.background = .color(.blue)
Jun ’20
Reply to Initiate ARView with the specified dimensions, camera mode, and session configuration state.
As mentioned, if your target is simulator or not iOS you can not specify the cameraMode, it will go straight to nonAR. The only initialiser will just take the frame I believe.Only if you are building for an iOS device (not simulator) can you use the initialiser with cameraMode.#if os(iOS) && !targetEnvironment(simulator) arView.cameraMode = .nonAR #endifNo need to recreate the ARView, just changing the camera mode should be fine.If you are still stuck it'd be useful to know what your build target is.
Jun ’20
Reply to Move, Rotate, Scale By
It might be helpful if you post your code, so someone may be able to spot where the 0.1cm error is coming from.I'm expecting that your second animation is starting just before the first has ended.Try using the AnimationEvents.PlaybackCompleted Event before firing the second animation if you're not already. Otherwise if you're calculating based on `entity.position`, then adding or subtracting 2, instead you could save the starting position so the entity moves back to there instead.PS I'm assuming you're using move(to: Transform), rather than anything else, as move(by:) doesn't exist in RealityKit.
Apr ’20
Reply to Change Material base color
I saw your question on twitter, but I'll respond here with more details…Once you've loaded your ModelEntity from a USDZ, find the model.materials list and replace the material you want to replace with a SimpleMaterial or UnlitMaterial.To find which material you need to replace, depending on how your USDZ is structured it could look like this:https://imgur.com/a/bWyjVlGIn which case you can see that if you want to replace the sail it'll be model.materials[0], model.materials[4] for the handrails.If you cannot view all the materials like this, for example if you have multiple geometries in your USDZ, then you can try deduce based on the order of the geometries in your usdz file, or loop through some colours, replacing each material in the material array like this:let myColors: [UIColor] = [.red, .orange, .blue, .yellow, ...] model.materials = myColors.map { SimpleMaterial(color: $0, isMetallic: false) }Also make sure sure that your array of colors is the same size as your original model.materials array, not sure what a ModelComponent does if you give it too many materials. (it likely just ignores them)And then just see what color the mesh shows up on to deduce the index.
Apr ’20