Post

Replies

Boosts

Views

Activity

Transparency breaks when updating meshes in Realitykit
import RealityKit let newModel = ModelEntity( mesh: .generatePlane(width: 1, height: 1) ) var mat = SimpleMaterial( color: UIColor.blue.withAlphaComponent(0.5), isMetallic: true ) newModel.model?.materials = [mat] /* next line breaks transluency */ newModel.model?.mesh = .generatePlane(width: 1, height: 1) /* next line fixes it */ newModel.model = ModelComponent( mesh: .generatePlane(width: 1, height: 1), materials: [mat]) In my code I was doing this every time a plane anchor updated:   self.model?.mesh = MeshResource.generatePlane(      width: planeAnchor.extent.x,      depth: planeAnchor.extent.z + 10     ) This resulted in a mesh updating its size, but the transparency completely breaking. When switching to this, transparency worked correctly, but now I have to fully recreate the model whenever I want to update the size  var material = SimpleMaterial(color: MaterialColorParameter.texture(resource!), isMetallic: true)    material.tintColor = .init(white: 1, alpha: 0.5)    self.model = ModelComponent(     mesh: .generatePlane(      width: planeAnchor.extent.x,      depth: planeAnchor.extent.z     ),     materials: [material]    )   Can we get some bug fixes in realitykit this year? So that we don't have to set isMetallic: true, and tintColor just to use a color with opacity? Or have to fully recreate the model just to update the mesh size? Thanks :)
1
0
753
Feb ’21
Filter out vertex buffer by classification?
I have some code that was mostly taken from an open source project on github. I am trying to export an ARkit mesh into a 3d usd file, and this is currently working great. However I want to remove all the vertices that are not on walls or windows, giving me a 3d usd file with ONLY walls and windows.  // Transform the vertex buffer into an array of points   func transformedVertexBuffer(_ transform: simd_float4x4) -> ([Float], Int) {     var bytes = [Float]()     for index in 0..<vertices.count {       let vertexPointer = vertices.buffer.contents().advanced(by: vertices.offset + vertices.stride * index)       let vertex = vertexPointer.assumingMemoryBound(to: (Float, Float, Float).self).pointee       var vertextTransform = matrix_identity_float4x4       vertextTransform.columns.3 = SIMD4<Float>(vertex.0, vertex.1, vertex.2, 1)       let position = (transform * vertextTransform).position         //       let classification = classificationOf(faceWithIndex: index) // //      if(classification == .wall || classification == .window) { //        print("this is a wall") // //      } else { //        print("not a wall") //        continue // //      }               bytes.append(position.x)       bytes.append(position.y)       bytes.append(position.z)     }     return (bytes, bytes.count / 3)   } } You will see I have some commented code, I tried to use the classificationOf extension from the developer docs, but I can't quite figure out how to classify individual points and remove them. Any help would be appreciated.
2
0
556
Oct ’20