I have developed a code that initiates the Timeline in the Reality Composer Pro scene every 12.93 seconds.
RealityView { … }
.onAppear {
startTimer()
}
.onDisappear {
stopTimer()
}
func startTimer() {
timer = Timer.scheduledTimer(withTimeInterval: 12.93, repeats: true) { _ in
action()
}
}
func stopTimer() {
timer?.invalidate()
}
func action() {
print(“SunUpDown”)
NotificationCenter.default.post(
name: NSNotification.Name(“RealityKit.NotificationTrigger”),
object: nil,
userInfo: [
“RealityKit.NotificationTrigger.Scene”: scene as Any,
“RealityKit.NotificationTrigger.Identifier”: “SunUpDown”
]
)
}
Upon receiving the “SunUpDown” command, Timeline will be executed.
However, everything was functioning normally when I was running the scene, and I could continue looping until I attempted to zoom in on the window and discovered that it ceased looping. Could you please provide an explanation for this behavior?
Note: The window type is volumetric, and the parameter of the defaultWorldScaling modifier is dynamic.
Post
Replies
Boosts
Views
Activity
In a scenario involving one of the entities in a Reality Composer Pro environment, I intend for this entity to display a blue material when viewed by the user. To achieve this, I have added the following Shader Graphs to the materials associated with this entity:
Additionally, I have included the HoverEffectComponent component to the Reality View in the code:
RealityView { content in
if let model = try? await Entity(named: “WorldScene”, in: realityKitContentBundle) {
let hoverEffect = HoverEffectComponent(.shader(.default))
model.components.set(hoverEffect)
content.add(model)
}
}
However, hover this entity, I am unable to observe any visual reaction. Could you please provide guidance on how to resolve this issue?
I was making a gesture to let the goose (character) walk, but I had two problems.
1: I added collision and physical body components to the goose and the collided entity, but I found that those physical formations could not completely block the way of the goose. For example, a tree is in front of it. After the goose is blocked, it will cross the tree or run to the top of the tree as long as it is a little faster.
2: Because the knowledge I have accumulated is not very complete, I can control the movement of the goose on the z-axis. I hope that the user's gestures can be realized by dragging back and forth (z-axis), but I can only realize the user's gestures by dragging up and down (y-axis). I hope you can give me some guidance:
GooseOriginalPosition.z + Float(translation.height / 10000)
This is the complete code:
@State var goose: Entity?
@State var isDraggingGoose = false
@State var gooseOriginalPosition = SIMD3<Float>(repeating: 0)
RealityView { content in
if let model = try? await Entity(named: "WorldScene", in: realityKitContentBundle) {
content.add(model)
}
if let gooseEntity = try? await Entity(named: "Goose", in: realityKitContentBundle) {
gooseEntity.scale = SIMD3<Float>(repeating: 0.3)
content.add(gooseEntity)
goose = gooseEntity
}
}
.simultaneousGesture(DragGesture()
.targetedToAnyEntity()
.onChanged { value in
handleDrag(value)
}
.onEnded { _ in
isDraggingGoose = false
gooseTimer?.invalidate()
})
func handleDrag(_ value: EntityTargetValue<DragGesture.Value>) {
guard let goose = goose else { return }
if !isDraggingGoose {
isDraggingGoose = true
gooseOriginalPosition = goose.position(relativeTo: nil)
}
let translation = value.gestureValue.translation
let newPosition = SIMD3<Float>(
gooseOriginalPosition.x + Float(translation.width / 10000),
gooseOriginalPosition.y,
gooseOriginalPosition.z + Float(translation.height / 10000)//I hope the gesture here should be z-axis drag.
)
goose.setPosition(newPosition, relativeTo: nil)
}
How to realize that a string of descriptions of a view will appear after looking at a view for a long time in the diagram
I used such a gesture under a reality view.
DragGesture().targetedToAnyEntity()
.onChanged { value in
print("DragGesture")
self.dragOffset = value.translation
self.startTimer()
}
.onEnded { _ in
self.dragOffset = .zero
self.direction = "None"
self.stopTimer()
}
However, due to the special nature of Reality View, it is impossible to detect gestures normally, so I think some modifiers should be added after value.translation, but I don't know what modifiers are. Can you give me some? Do you know? Thank you.
In a listing program in WWDC24, it shows that users can control the robot to walk by pinching and sliding. However, I haven't found any documents or videos related to this function. If you know, please let me know. Thank you!
When I run my visionOS App, RealityKitContent Report an error:
Tool terminated by signal 'Segmentation fault: 11'
And it points to a USDZ model I imported, but in the scene, my model can be displayed normally and there is no damage. Why does an error occur? How can I check and repair it?
In Xcode16Beta4, it contains Predictive Code Completion, and Predictive Code Completion is also with other SDKs in the page opened by Xcode for the first time. Waiting for download.
However, I want to know: 1. What is Predictive Code Completion? 2. I didn't download Predictive Code Completion on the SDK download page when I first opened Xcode. Where should I download it later?
In the apple map of some areas, there will be a very realistic real-life 3D map. And now I want to call it through 3d in visionOS (like model3d). How can I call it?
Note: What I ask for is not to have an effect similar to 3d on a flat screen like in iOS, but to display the USDZ model in visionOS.
This is a visionOS App. I added contextMenu under a combination view, but when I pressed the view for a long time, there was no response. I tried to use this contextMenu in other views, which can be used normally, so I think there is something wrong with this combination view, but I don't know what the problem is. I hope you can remind me. Thank you!
Views with problems:
struct NAMEView: View {
@StateObject private var placeStore = PlaceStore()
var body: some View {
ZStack {
Group {
HStack(spacing: 2) {
Image(systemName: "mappin.circle.fill")
.font(.system(size: 50))
.symbolRenderingMode(.multicolor)
.accessibilityLabel("your location")
.accessibilityAddTraits([.isHeader])
.padding(.leading, 5.5)
VStack {
Text("\(placeStore.locationName)")
.font(.title3)
.accessibilityLabel(placeStore.locationName)
Text("You are here in App")
.font(.system(size: 13))
.foregroundColor(.secondary)
.accessibilityLabel("You are here in App")
}
.hoverEffect { effect, isActive, _ in
effect.opacity(isActive ? 1 : 0)
}
.padding()
}
}
.onAppear {
placeStore.updateLocationName()
}
.glassBackgroundEffect()
.hoverEffect { effect, isActive, proxy in
effect.clipShape(.capsule.size(
width: isActive ? proxy.size.width : proxy.size.height,
height: proxy.size.height,
anchor: .leading
))
.scaleEffect(isActive ? 1.05 : 1.0)
}
}
}
}
In vision OS, the tab bar of TabView is outside the window by default.
If I switch a page without TabView to a page that needs TabView in my program, the tab bar will suddenly appear on the left side of the screen without any animation. I hope it has an animation when it appears (such as easeIn, move). I tried it in Tab. Other animation-related modifiers such as animation are added under View, but there is no animation in the tab bar. Only the view in the tab has an animation effect, but this is not what I want. What I want is that the tab bar outside the window can have animation. What should I do?
In the AudioServicesPlaySystemSound function of AudioToolbox, you can enter the corresponding SystemSoundID to play some sound effects that come with the system. However, I can't be sure what sound effect each number corresponds to, so I want to know all the sound effects in visionOS and its corresponding SystemSoundID.
Since my question exceeds 700 words, please check it in the attachment. Thank you!
Question
My App needs to send and receive messages to the server, but my server does not have SSL, so I can only disable ATS in the development stage. But if I want to put the app on the shelf, then I still disable ATS when I put it on the shelf, and the server still does not have SSL. Will it be packaged? Is pp warned and terminated by Xcode? Will it be rejected by the Apple audit department? Can it be put on the App Store normally and provided to all users?
Note: My server is completely safe without any security risks. I didn't apply for SSL just because I didn't have enough funds.
We can add many models in the Reality Composer Pro scene, but when I use RealityView to display and add modifiers in SwiftUI, the modifiers will have Effect, and I don't want to do this. I hope this modifier will be valid for a single model in the Reality Composer Pro scenario.
May I ask how to add modifiers to a single model in the Reality Composer Pro scene?