天道酬勤,学无止境

arkit

Change a colour of an object

I am currently looking into options on how to transform objects colour from Swift. The object has been added to the scene from Reality Composer. I found in the documentation that I can change position, rotation, scale, however, I am unable to find a way how to change colour.

2022-05-03 06:19:14    分类:问答    swift   augmented-reality   arkit   realitykit   reality-composer

ARKit – Getting "Unexpectedly found nil" when using SCN file > 300 MB

I am loading a 300mb 3d model of extension .dae, converted into .scn, with 4.4 million vertices, 1.5 million polygons, which is a 3d model of a building, created in 3DS MAX by an artist, like so: let sceneToLoad = SCNScene(named: "art.scnassets/building1.scn")! (It is loaded in a SCNView default viewer in the app so that the user can view, rotate it etc., by SCNView.allowsCameraControl = true) Xcode will immediately crash when it reads that line, with only compiler info "unexpectedly found nil while unwrapping an optional value". The memory does not go up at all when it runs to that line -

2022-05-03 05:19:34    分类:问答    swift   augmented-reality   scenekit   arkit   realitykit

Reset ARView and run coaching overlay again

I have an ARView which will be populated as soon as the coachingOverlay has finished successfully. How can I call a function to reset this ARView from another view (Navbar) and run coachingOverlay to initialize AR again? struct ContentView : View { var body: some View { ZStack { ARViewContainer().edgesIgnoringSafeArea(.all) VStack { Spacer() Navbar() } .padding() } } } struct ARViewContainer: UIViewRepresentable { func makeUIView(context: Context) -> ARView { let arView = ARView(frame: .zero) arView.addCoaching() let config = ARWorldTrackingConfiguration() config.planeDetection = .horizontal

2022-05-02 20:11:28    分类:问答    ios   swift   swiftui   augmented-reality   arkit

Is it possible to use Reality Composer for detecting 3D assets in the real world?

I'm trying to find a way to create .arobject for detecting 3D assets in real world. The only solution I've found is to use Apple scanning application. But I wonder maybe there is a way to use Reality Composer to achieve this? Since Reality Composer can detect Images and Anchors maybe this is possible.

2022-05-02 10:23:22    分类:问答    arkit   realitykit   reality-composer

Best way to obtain ARKit or RealityKit camera rotation?

I am writing in Swift and trying to obtain the RealityKit camera's rotation. I've successfully gotten the position using: xsettings.xcam = arView.session.currentFrame?.camera.transform.columns.3.x ?? 0); xsettings.ycam = arView.session.currentFrame?.camera.transform.columns.3.y ?? 0); xsettings.zcam = arView.session.currentFrame?.camera.transform.columns.3.z ?? 0); this works excellently, but I haven't found a rotation solution that seems to work as well. Currently I am doing this: xsettings.xcamrot = arView.session.currentFrame?.camera.eulerAngles[0] ?? 0; xsettings.ycamrot = arView.session

2022-05-02 07:35:57    分类:问答    swift   augmented-reality   arkit   realitykit

RealityKit – transform.rotate() makes object bigger in scale

I'm trying to rotate the steel box given in the starter code for RealityKit, and I use this code steelBox.transform.rotation += simd_quatf(angle: radians, axis: SIMD3<Float>(0, 1, 0)) to attempt to rotate the object. When the object rotates, however, it grows bigger in one dimension as well. Why is that?

2022-05-02 07:19:20    分类:问答    swift   augmented-reality   arkit   simd   realitykit

What is the difference between arView.session.currentFrame.camera.transform and arview.cameraTransform?

I stumbled upon this while applying rotation from the camera onto an entity in RealityKit. I thought I have to do some matrix math to gain the euler angles from arView.session.currentFrame.camera.transform matrix, but retrieving the rotation from arview.cameraTransform.rotation did the trick (found here). So: What is the difference of both matrices and when should be used which?

2022-05-02 07:17:07    分类:问答    swift   arkit   realitykit

RealityKit – How to create shadow catcher for natural lighting?

I'd like to create a plane: func getShadowPlane(_ width: Float, _ height: Float) -> ModelEntity { let sphereResource = MeshResource.generatePlane(width: width, depth: height) let myMaterial = ShadowMataerial . ???? return ModelEntity(mesh: sphereResource, materials: [myMaterial]) } & add it to my anchor at specific position. I'd like to get shadow data from the "lighting" I get from my camera that RealityKit is able to capture/generate. I don't want to use AnchorEntity(plane: AnchoringComponent.Target.Alignment.horizontal) Any idea how can this be accomplished? I can not find shadowCatcher

2022-05-02 07:15:16    分类:问答    swift   augmented-reality   arkit   realitykit

RealityKit – Keep object always in front of screen

I am using the below code to keep the object in front of a screen and to move it with the camera. On didUpdate frame: ARFrame delegate I call getCameraPosition(). All is working perfect, Now I need an efficient solution to improve processing time. In the current solution, I feel that the phone hangs sometimes. And what if existingPlaneInfinite & estimatedPlane are not available? Here is the video link of what I have done. extension ARView { func getCameraPosition(from: CGPoint? = nil) -> Position { let from = from ?? self.center var result: ARRaycastResult? if let raycast = self.raycast(from

2022-05-02 03:41:27    分类:问答    swift   augmented-reality   arkit   realitykit

importing 3d model into Flutter app and textures not showing up

Problem: I am using the ARKIT package for flutter. I have been having a hard time figuring out how to import the 3d model for my project with the textures included. The package has an example that has textures included (located in the IOS Runner folder) which demonstrates that this is possible with their custom 3d object example (eevee.dae). What is the best way to import a model into a flutter app and maintain its textures/materials?

2022-05-01 22:19:54    分类:问答    flutter   augmented-reality   arkit   blender