Hello,
I'm trying to load a video on immersive space.
Actually using VideoMaterial and applying it on a plane surface I'm able to load video that I have locally.
If I want to load something from an external link like youtube or other service how can I do that?
Remembering obv that I'm loading it in an immersive space.
Thanks ;)
visionOS
RSS for tagDiscuss developing for spatial computing and Apple Vision Pro.
Posts under visionOS tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I have three basic elements in this UI page: View, Alert, Toolbar. I put Toolbar and Alert along with the View, when I click a button on Toolbar, my alert window shows up. Below could be a simple version of my code:
@State private var showAlert = false
HStack {
// ...
}
.alert(Text("Quit the game?"), isPresented: $showAlert) {
MyAlertWindow()
} message: {
Text("Description text about this alert")
}
.toolbar {
ToolbarItem(placement: .bottomOrnament) {
MyToolBarButton(showAlert: $showAlert)
}
}
And in MyToolBarButton I just toggle the binded showAlert variable to try to open/close the alert window.
When running on either simulator or device, the bahavior is quite strange. Where when toggle MyToolBarButton the alert window takes like 2-3 seconds to show-up, and all the elements on the alert window is grayed out, behaving like the whole window is losing focus. I have to click the moving control bar below (by dragging gesture) to make the whole window back to focus.
And this is not the only issue, I also find MyToolBarButton cannot be pressed to close the alert window (even thogh when I try to click the button on my alert window it closes itself).
Oh btw I don't know if this may affect but I open the window with my immersive view opened (though I tested it won't affect anything here)
Any idea of what's going on here?
XCode 16.1 / visionOS 2 beta 6
The following RealityView ModelEntity animated text works in visionOS 1.0. In visionOS 2.0, when running the same piece of code, the model entity move duration does not seem to work. Are there changes to the way it works that I am missing? Thank you in advance.
RealityView { content in
let textEntity = generateMovingText()
content.add(textEntity)
_ = try? await arkitSession.run([worldTrackingProvider])
} update: { content in
guard let entity = content.entities.first(where: { $0.name == .textEntityName}) else { return }
if let pose = worldTrackingProvider.queryDeviceAnchor(atTimestamp: CACurrentMediaTime()) {
entity.position = .init(
x: pose.originFromAnchorTransform.columns.3.x,
y: pose.originFromAnchorTransform.columns.3.y,
z: pose.originFromAnchorTransform.columns.3.z
)
}
if let modelEntity = entity as? ModelEntity {
let rotation = Transform(rotation: simd_quatf(angle: -.pi / 6, axis: [1, 0, 0])) // Adjust angle as needed
modelEntity.transform = Transform(matrix: rotation.matrix * modelEntity.transform.matrix)
let animationDuration: Float = 60.0 // Adjust the duration as needed
let moveUp = Transform(scale: .one, translation: [0, 2, 0])
modelEntity.move(to: moveUp, relativeTo: modelEntity, duration: TimeInterval(animationDuration), timingFunction: .linear)
}
}
The source is available at the following:
https://github.com/Sebulec/crawling-text
In RealityView I have two entities that contain tracking components and collision components, which are used to follow the hand and detect collisions. In the Behaviors component of one of the entities, there is an instruction to execute action through onCollision. However, when I test, they cannot execute action after collisions. Why is this?
com.apple.Vision Code=9 "Could not build inference plan - ANECF error: failed to load ANE model file:///System/Library/Frameworks/ Vision.framework/anodv4_drop6_fp16.H14G.espresso.hwx
Code rise this error:
func imageToHeadBox(image: CVPixelBuffer) async throws -> [CGRect] {
let request:DetectFaceRectanglesRequest = DetectFaceRectanglesRequest()
let faceResult:[FaceObservation] = try await request.perform(on: image)
let faceBoxs:[CGRect] = faceResult.map { face in
let faceBoundingBox:CGRect = face.boundingBox.cgRect
return faceBoundingBox
}
return faceBoxs
}
Hello there,
I'm currently working on a Hand Tracking System. I've already placed some spheres on some joint points on the left and right hand. Now I want to access the translation/position value of these entities in the update(context: Scene) function. Now my question is, is it possible to access them via .handAnchors(), or which types of .handSkeleton.joint(name) are referencing the same entity? (E.g. is AnchorEntity(.hand(.right, location: .indexFingerTip)) the same as handSkeleton.joint(.indexFingerTip). The goal would be to access the translation of the joints where a sphere has been placed per hand and to be able to update the data every frame through the update(context) function.
I would very much appreciate any help!
See code example down below:
ImmersiveView.swift
import SwiftUI
import RealityKit
import ARKit
struct ImmersiveView: View {
public var body: some View {
RealityView { content in
/* HEAD */
let headEntity = AnchorEntity(.head)
content.add(headEntity)
/* LEFT HAND */
let leftHandWristEntity = AnchorEntity(.hand(.left, location: .wrist))
let leftHandIndexFingerEntity = AnchorEntity(.hand(.left, location: .indexFingerTip))
let leftHandWristSphere = ModelEntity(mesh: .generateSphere(radius: 0.02), materials: [SimpleMaterial(color: .red, isMetallic: false)])
let leftHandIndexFingerSphere = ModelEntity(mesh: .generateSphere(radius: 0.01), materials: [SimpleMaterial(color: .orange, isMetallic: false)])
leftHandWristEntity.addChild(leftHandWristSphere)
content.add(leftHandWristEntity)
leftHandIndexFingerEntity.addChild(leftHandIndexFingerSphere)
content.add(leftHandIndexFingerEntity)
}
}
}
TrackingSystem.swift
import SwiftUI
import simd
import ARKit
import RealityKit
public class TrackingSystem: System {
static let query = EntityQuery(where: .has(AnchoringComponent.self))
private let arKitSession = ARKitSession()
private let worldTrackingProvider = WorldTrackingProvider()
private let handTrackingProvider = HandTrackingProvider()
public required init(scene: RealityKit.Scene) {
setUpSession()
}
private func setUpSession() {
Task {
do {
try await arKitSession.run([worldTrackingProvider, handTrackingProvider])
} catch {
print("Error: \(error)")
}
}
}
public func update(context: SceneUpdateContext) {
guard worldTrackingProvider.state == .running && handTrackingProvider.state == .running else { return }
let _ = context.entities(matching: Self.query, updatingSystemWhen: .rendering)
if let avp = worldTrackingProvider.queryDeviceAnchor(atTimestamp: currentTime) {
let hands = handTrackingProvider.handAnchors(at: currentTime)
...
}
}
}
Is it possible to get the location of where a user uses the tap gesture on the screen? Like an x/y coordinate that can be used within my app.
I know there is spatialTapGesture but from what I can tell that is only linked to content entities like a cube or something. Does this mean I can only get the x/y coordinate data by opening an immersive space and using the tap gesture in relation to some entity?
TLDR: Can I get the location of a tap gesture in Vision OS in a regular app, without opening an immersive space?
I have a model entity (from Reality Composer Pro) I want to change the material of the model entity inside swift. The material is also imported in reality composer pro. I am copying the USDZ file of the material in the same directory as the script.
This is the code I am using to reference the Material.
do {
// Load the file data
if let materialURL = Bundle.main.url(forResource: "BlackABSPlastic", withExtension: "usdz") {
let materialData = try Data(contentsOf: materialURL)
// Check the first few bytes of the data to see if it matches expected types
let headerBytes = materialData.prefix(4)
let headerString = String(decoding: headerBytes, as: UTF8.self)
// Print out the header information for debugging
print("File header: \(headerString)")
// Attempt to load the ShaderGraphMaterial
let ScratchedMetallicPaint = try await ShaderGraphMaterial(
named: "BlackABSPlastic",
from: materialData
)
print(ScratchedMetallicPaint)
} else {
print("BlackABSPlastic.usdz file not found.")
}
} catch {
// Catch the error and print it
print("BlackABSPlastic load failed: \(error)")
// Attempt to infer file type based on the error or file content
if let error = error as? DecodingError {
switch error {
case .typeMismatch(let type, _):
print("Type mismatch: Expected \(type)")
case .dataCorrupted(let context):
print("Data corrupted: \(context.debugDescription)")
default:
print("Decoding error: \(error)")
}
} else {
print("Unexpected error: \(error)")
}
}
I am receiving these errors:
File header: PK
TBB Global TLS count is not == 1, instead it is: 2
Unable to create stage from in-memory buffer.
BlackABSPlastic load failed: internalImportError
Unexpected error: internalImportError
am I doing anything wrong? I am able to access the materials of the model entity easily but this seems to something different. How can this be resolved?
Thanks.
The sample code project RealityKit-Stereo-Rendering found at the article Rendering a windowed game in stereo here fails to compile with the following errors in Xcode 16 beta 6.
The sample code project Tabletopkit Sample found at the article Creating tabletop games here fails to compile with the following errors in Xcode 16 beta 6.
error: [xrsimulator] Component Compatibility: Billboard not available for 'xros 1.0', please update 'platforms' array in Package.swift
error: [xrsimulator] Exception thrown during compile: compileFailedBecause(reason: "compatibility faults")
error: Tool exited with code 1
The sample code project PencilKitCustomToolPicker found at this article Configuring the PencilKit tool picker here fails to compile with the following errors in Xcode 16 beta 6
Compilation of the project for the WWDC 2024 session title Compose interactive 3D content in Reality Composer Pro fails.
After applying the fix mentioned here (https://developer.apple.com/forums/thread/762030?login=true), the project still won't compile.
Using Xcode 16 beta 7, I get these errors:
error: [xrsimulator] Component Compatibility: EnvironmentLightingConfiguration not available for 'xros 1.0', please update 'platforms' array in Package.swift
error: [xrsimulator] Component Compatibility: AudioLibrary not available for 'xros 1.0', please update 'platforms' array in Package.swift
error: [xrsimulator] Component Compatibility: BlendShapeWeights not available for 'xros 1.0', please update 'platforms' array in Package.swift
error: [xrsimulator] Exception thrown during compile: compileFailedBecause(reason: "compatibility faults")
error: Tool exited with code 1
Is it possible to show a SafariWebView in an ImmersiveSpace with hand tracking enabled?
I have an app with an initialView that launches an immersive space and opens a SafariView. I noticed that hand tracking stops working when I open the SafariView, but not when I open the TestView (which is just an empty window).
Here's the Scene:
var body: some Scene {
WindowGroup(id: "control") {
InitialView()
}.windowResizability(.contentSize)
WindowGroup(id: "test") {
TestView()
}.windowResizability(.contentSize)
WindowGroup(id: "safari") {
SafariView(url: URL(string: "some URL")!)
}
ImmersiveSpace(id: "immersiveSpace") {
ImmersiveView()
}
}
I’m developing an app for Vision Pro and have encountered an issue related to the UI layout and model display. Here's a summary of the problem:
I created an anchor window to display text and models in the hand menu UI.
While testing on my Vision Pro, everything works as expected; the text and models do not overlap and appear correctly.
However, after pushing the changes to GitHub and having my client test it, the text and models are overlapping.
Details:
I’m using Reality Composer Pro to load models and set them in the hand menu UI.
All pins are attached to attachmentHandManu, and attachmentHandManu is set to track the hand and show the elements in the hand menu.
I ensure that the attachmentHandManu tracks the hand properly and displays the UI components correctly in my local tests.
Question:
What could be causing the text and models to overlap in the client’s environment but not in mine? Are there any specific settings or configurations I should verify to ensure consistent behavior across different environments? Additionally, what troubleshooting steps can I take to resolve this issue?
hello guys
as u know, full immersive boundary range is 3m * 3m, for safe the users.
but i need the full immersive space by more extended range.
bcuz i got the quite large area and to play more fun.
is the any problem?
thank you!
when I use openwindow to show a volume window,I want to hide the old
window ,keep it stays where it is, when I close the volume window, the old window appears again.the logic is simple, I tried to use opaque to hide the old window, but the window bar is still there, which is very annoying. how could I solve this?
I am working on a project for a university which wants to alter the passthrough camera feed more so than the standard filters (saturation/contract/etc) that some of the headsets provide.
I don't have access to the headset or enterprise SDK yet, as I'd like to nail down whether or not this is feasible before we purchase the hardware. In the API I see I can use CameraFrameProvider to access a CameraFrame and then grab a sample. The sample has a CVPixelBuffer. I have 2 questions regarding the pixelBuffer:
I see that the buffer itself is read only but can I alter the bytes within this pixel buffer? Lets say change all green pixels to red (not my actual use case but just an example)
Will the updated pixel buffer then be used in the passthrough screen?
If not, then is there any way to have control over the video feed that is being displayed as passthrough? Our ideal setup would be to have access to a frame, alter it however we want, and then have the frame displayed in passthrough. I realize I could take the feed and copy it into a floating window and alter that, but that breaks the immersion we are shooting to create here.
Thanks in advance!
Can we get the raw sensor data from the apple vision pro?
Is there any action that can clone the entity in RealityView to the number I want? If there is, please let me know. Thank you!
I created a simple Timeline animation with only a "Play Audio" action in RCP. Also a Behaviors Component setting an "OnTap" trigger to fire this Timeline animation.
In my code, I simply run Entity.applyTapForBehaviors() when something happened. The audio can be normally played on the simulator but cannot be played on the device.
Any potential bug leads this behavior?
Env below:
Simulator Version: visionOS 2.0 (22N5286g)
XCode Version: Version 16.0 beta 4 (16A5211f)
Device Version: visionOS 2.0 beta (latest)