Posts

Post marked as Apple Recommended
Thanks to @helpingtiger I could edit my code and make it possible to reverse the animation , and here is the edited working code import SwiftUI import RealityKit struct ImmersiveView: View { @State var entity = Entity() @State var openDoor: Bool = true var body: some View { RealityView { content in if let mainDoor = try? await Entity(named: "Door.usdz") { if let frame = mainDoor.findEntity(named: "DoorFrame") { frame.position = [0, 0, -8] frame.orientation = simd_quatf(angle: (270 * (.pi / 180)), axis: SIMD3(x: 1, y: 0, z: 0)) content.add(frame) entity = frame.findEntity(named: "Door")! entity.components.set(InputTargetComponent(allowedInputTypes: .indirect)) entity.components.set(HoverEffectComponent()) let entityModel = entity.children[0] entityModel.generateCollisionShapes(recursive: true) } } } .gesture( SpatialTapGesture() .targetedToEntity(entity) .onEnded { value in print(value) if openDoor == true { var playerDefinition = entity.availableAnimations[0].definition playerDefinition.speed = 1 playerDefinition.repeatMode = .none playerDefinition.trimDuration = 0 let playerAnimation = try! AnimationResource.generate(with: playerDefinition) entity.playAnimation(playerAnimation) openDoor = false } else { var playerDefinition = entity.availableAnimations[0].definition playerDefinition.speed = -1 playerDefinition.repeatMode = .none playerDefinition.trimDuration = 0 let playerAnimation = try! AnimationResource.generate(with: playerDefinition) entity.playAnimation(playerAnimation) openDoor = true } } ) } }
Post marked as Apple Recommended
As I expected In visionOS 1.1, the AnimationPlaybackController object is still not able to play back a reverse asset animation, as it was in iOS RealityKit. in iOS RealityKit you could reverse the animation by simply give speed negative value like -1 but if you try it in visionOS RealityKit it would stop the animation totally as you give a speed = 0 , the workaround so far is a bi complicated by making 2 animations one forward and the other reverse and apply each when needed. Hopefully Apply would resolve this issue in the next version of visionOS.
Post marked as Apple Recommended
Also here is the link for the USDZ file for the door if you want to check https://www.worldhotelity.com/stack/Door.usdz
Post not yet marked as solved
3 Replies
Put the new animation in a separate USDZ file and load it to the code then apply each when needed on the desired entity, which should be identical to the entity that have the external animation. import SwiftUI import RealityKit struct ImmersiveView: View { @State var entity = Entity() @State var extEntity = Entity() var body: some View { RealityView { content in //Loading Main USDZ With Main Animation And Link it let mainAnim = try! await Entity(named: "main.usdz") if let item = mainAnim.findEntity(named: "SOME ENTITY") { entity = item // The Entity of the object you want to animate content.add(entity) } //Loading External Animation And Link it let extAnim = try! await Entity(named: "external.usdz") if let item = extAnim.findEntity(named: "SOME ENTITY") { externalEntity = item // The Entity Of the Object have the external Animation } Then somewhere in your code when you want to apply the external animation func playExtraAnimation() { entity.playAnimation(extEntity.availableAnimations[0], transitionDuration: duration , startsPaused: true) }
Post marked as solved
1 Replies
I figure it out myself import SwiftUI import RealityKit import GameController struct ImmersiveView: View { @State var entity = ModelEntity() @State var z: Float = -4.0 @State var connected = false @State var controller = GCController() var body: some View { RealityView { content in if let cube = try? await ModelEntity(named: "am.usdz") { entity = cube entity.generateCollisionShapes(recursive: true) entity.name = "Cube" entity.position = [0, 0, -4] entity.components.set(InputTargetComponent(allowedInputTypes: .indirect)) entity.components.set(HoverEffectComponent()) content.add(entity) } } .gesture( SpatialTapGesture() .targetedToEntity(entity) .onEnded { value in print(value) z -= 1.0 entity.position = [0, 0, z] } ) .onAppear(perform: { // Start Using The Game Controller NotificationCenter.default.addObserver(forName: NSNotification.Name.GCControllerDidConnect, object: nil, queue: nil, using: didConnectController) NotificationCenter.default.addObserver(forName: NSNotification.Name.GCControllerDidDisconnect, object: nil, queue: nil, using: didDisconnectController) GCController.startWirelessControllerDiscovery{} }) } func didConnectController(_ notification: Notification) { connected = true controller = notification.object as! GCController print("◦ connected \(controller.productCategory)") controller.extendedGamepad?.buttonA.pressedChangedHandler = { (button, value, pressed) in self.button("X", pressed)} } func didDisconnectController(_ notification: Notification) { connected = false controller = notification.object as! GCController print("◦ disConnected \(controller.productCategory)") } func button(_ button: String, _ pressed: Bool){ if button == "X" && pressed { z -= 1.0 entity.position = [0, 0, z] } } }
Post not yet marked as solved
2 Replies
Sorry I may have not expressed the question well, I'm not asking about this certain code, this codes are just a generic sample and it could be anything else, I'm asking about if this possible or not in Xcode cause so far until Xcode 14.3 it does not seem to happen and it is as simple as fold all Childs under one parent or fold all selected only ,may be apple could notice that and may be like to add it on the next update cause it really helps specially for 3D Physics Collision with different actions.
Post marked as solved
8 Replies
I have same issue with my appleTV tvOS 16.3 and the only solution so far is to test my work using the Xcode 14.3 beta version until they make a final version of it , it do support tvOS 16.4 [https://developer.apple.com/documentation/xcode-release-notes/xcode-14_3-release-notes)
Post not yet marked as solved
3 Replies
After Long time Of many repeated downloads of the simulators and delete the old one from settings I got the right solution According To Apple Xcode 14 Release Notes There was this issue: It Seems If you manually unmount or detach a simulator runtime disk image (such as by using diskutil eject or umount), Simulator and Xcode may not be able to determine whether the runtime is installed or not. Attempts to re-download the runtime results in failure with a duplicate runtime error. (89589210) Workaround: Restarting causes Simulator to re-mount the runtime disk image. But this might not work so I Open Terminal And Remount The Images Manually Using this Command xcrun simctl runtime add Alternately you can use xcrun simctl runtime to locate the affected runtime disk image, delete it, then use Xcode to re-download it.
Post not yet marked as solved
8 Replies
Although this answer may be delayed as I had this problem with Xcode 13.2 but my reason was My DAE file is large that even my M1 Latest Macbook cannot handle it on Xcode but I found the solution by using terminal command scntool xcrun scntool --convert INPUT.dae --format scn --output OUT.scn --asset-catalog-path . here is a complete answer for this problem Convert Large DAE to SCN Using Terminal You need: Xcode To Be Installed On Your Mac Now Open Terminal 1- Set The scntool to be Called From Anywhere  export PATH="/Applications/Xcode.app/Contents/Developer/usr/bin" Note : you can ignore last line is you add xcrun before scntool Example   xcrun scntool --convert INPUT.dae --format scn --output OUT.scn --asset-catalog-path . 2- Change Your Directory To where The DAE and The Resources are My Folder named Export cd THE_LOCATION_OF_YOUR_DAE_FILE Example cd /Users/YOURHOME/Desktop/Export 3- Use scntool to convert it like that (INPUT and OUTPUT is names of the file) The dot at the end of the command line is very important it means you will set resources to same location  scntool --convert INPUT.dae --format scn --output OUT.scn --asset-catalog-path . Or if you do not set scntool default path   xcrun scntool --convert INPUT.dae --format scn --output OUT.scn --asset-catalog-path . Example: scntool --convert ISS.dae --format scn --output ISS.scn --asset-catalog-path . If you don’t set the —asset-catalog-path . You will have no materials  By comparing 2 Output files, one with correct conversion and the other without  You will notice a missing line “path”, this line “path”, tells the SCN file to search the materials in the correct location  Mistaken Out.scn }, { "$class" = :false; NS.keys = ( :false ); NS.objects = ( :false ); }, "AMS02Coil.png", { "$classes" = ( "NSMutableDictionary", "NSDictionary", "NSObject" ); "$classname" = "NSMutableDictionary"; }, Correct Out.scn File }, { "$class" = :false; NS.keys = ( :false ); NS.objects = ( :false ); }, "path", "AMS02Coil.png", { "$classes" = ( "NSMutableDictionary", "NSDictionary", "NSObject" ); "$classname" = "NSMutableDictionary"; }, Here is a List Of scntool Command Options (I Got It From This Location  https://gist.github.com/matux/4a30c4b4b29d636fe6847b6a3234bc4f) $ xcrun scntool --verbose | Current SceneKit version is 4.560000 | Running scntool (compiled on Jul  1 2018 01:01:55) usage: scntool --convert file --format format [--output file] --convert: File to convert. Formats found to be supported: com.apple.scenekit.scene (scn), com.apple.scenekit.scene.zip (scnz), com.apple.scenekit.particlesystem (.scnp), org.khronos.collada.digital-asset-exchange (.dae), c3d, bplist --format: Format to convert to. Formats found to be supported: scn, c3d, dae. --output: Destination path and filename. -c (--compress) -d (--decompress) --uncompress --copy --target-platform= --target-version= --target-build-dir= --asset-catalog-path --resources-path-prefix --resources-folder-path= --force-y-up: Some documents use different up axis. When enabled, objects in a scene are converted to the Y-up orientation. --force-interleaved: Because most geometries use more than one geometry source and the GPU typically uses data from multiple sources together, you can achieve better rendering performance for custom geometries by interleaving the vertex data for multiple semantics in the same array. --prefer-compressed-textures: Use this option to prefer KTX, ASTC and PVRTC to other file formats. When enabled, if an image is referenced by a scene and exists within the asset catalog with the same name and the .astc or .pvrtc file extension, the compressed version will be used by SceneKit. --verbose: Always use verbose to get pretty error messages. With --verbose: scntool: error: No file at path /path/to/model/file.scn Same error, without --verbose:
Post not yet marked as solved
3 Replies
To Convert DAE to SCN Using Terminal You need: Xcode To Be Installed On Your Mac, You Don't Need to Run It we gonna use scntool command line from Xcode app Now Open Terminal 1- Set The scntool to be Called From Anywhere  export PATH="/Applications/Xcode.app/Contents/Developer/usr/bin" 2- Change Your Directory To where The DAE and The Resources are My Folder named Export cd THE_LOCATION_OF_YOUR_DAE_FILE Example cd /Users/YOURHOME/Desktop/Export 3- Use scntool to convert it like that (INPUT and OUTPUT is names of the file) The dot at the end of the command line is very important it means you will set resources to same location  scntool --convert INPUT.dae --format scn --output OUT.scn --asset-catalog-path . Example: scntool --convert ISS.dae --format scn --output ISS.scn --asset-catalog-path . If you don’t set the —asset-catalog-path . You will have no materials  By comparing 2 Output files, one with correct conversion and the other without  You will notice a missing line “path”, this line “path”, tells the SCN file to search the materials in the correct location  Mistaken Out.scn }, { "$class" = :false; NS.keys = ( :false ); NS.objects = ( :false ); }, "AMS02Coil.png", { "$classes" = ( "NSMutableDictionary", "NSDictionary", "NSObject" ); "$classname" = "NSMutableDictionary"; }, Correct Out.scn File }, { "$class" = :false; NS.keys = ( :false ); NS.objects = ( :false ); }, "path", "AMS02Coil.png", { "$classes" = ( "NSMutableDictionary", "NSDictionary", "NSObject" ); "$classname" = "NSMutableDictionary"; }, List Of scntool Command Options (I Got It From This Location  https://gist.github.com/matux/4a30c4b4b29d636fe6847b6a3234bc4f) $ xcrun scntool --verbose | Current SceneKit version is 4.560000 | Running scntool (compiled on Jul  1 2018 01:01:55) usage: scntool --convert file --format format [--output file] --convert: File to convert. Formats found to be supported: com.apple.scenekit.scene (scn), com.apple.scenekit.scene.zip (scnz), com.apple.scenekit.particlesystem (.scnp), org.khronos.collada.digital-asset-exchange (.dae), c3d, bplist --format: Format to convert to. Formats found to be supported: scn, c3d, dae. --output: Destination path and filename. -c (--compress) -d (--decompress) --uncompress --copy --target-platform= --target-version= --target-build-dir= --asset-catalog-path --resources-path-prefix --resources-folder-path= --force-y-up: Some documents use different up axis. When enabled, objects in a scene are converted to the Y-up orientation. --force-interleaved: Because most geometries use more than one geometry source and the GPU typically uses data from multiple sources together, you can achieve better rendering performance for custom geometries by interleaving the vertex data for multiple semantics in the same array. --prefer-compressed-textures: Use this option to prefer KTX, ASTC and PVRTC to other file formats. When enabled, if an image is referenced by a scene and exists within the asset catalog with the same name and the .astc or .pvrtc file extension, the compressed version will be used by SceneKit. --verbose: Always use verbose to get pretty error messages. With --verbose: scntool: error: No file at path /path/to/model/file.scn Same error, without --verbose:
Post not yet marked as solved
11 Replies
Same here, all image events commands are not working anymore since catalina, i'll file a bug and i appreciate if everyone also do so
Post not yet marked as solved
13 Replies
All that issues and more happend to me the moment i downloaded xcode command tools and the worst part is that i have XCode 11.1 and no release for xcode commands tools but only 11.0 and 11.2 beta i wont go for the beta ofcourse anyway i tried to remove the Xcode command tools and it helped me temporarely but then after a short time i have many bugs again, worst thing that it stops the auto complete that was a huge help while writing the codes as it does not recognize most of the codes, note to say that among all those bugs the xcode still make a working builds although the project full of red alerts, it's kinda crazy to find fatel errors and you still can build your project successfully.I hope apple would concentrate this time when issuing the next XCode 11.2.