Skip to content

Commit

Permalink
update tap gesture action
Browse files Browse the repository at this point in the history
  • Loading branch information
OneeMe committed Oct 26, 2023
1 parent 8d4821d commit 5b302be
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,58 @@ def Xform "Root"
uint group = 1
uniform token info:id = "RealityKit.Collider"
uint mask = 4294967295
token type = "Default"
token type = "Trigger"

def RealityKitStruct "Shape"
{
float3 extent = (0.20000006, 0.2, 0.20000008)
token shapeType = "Box"
}
}

def RealityKitComponent "HierarchicalFade"
{
uniform token info:id = "RealityKit.HierarchicalFade"
}
}

def "Sun" (
active = false
prepend references = @../Models/Sun.usdz@
)
{
float3 xformOp:scale = (1, 1, 1)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:orient", "xformOp:scale"]

def RealityKitComponent "HierarchicalFade"
{
uniform token info:id = "RealityKit.HierarchicalFade"
float opacity = 0
}

def RealityKitComponent "InputTarget"
{
uniform token info:id = "RealityKit.InputTarget"
}

def RealityKitComponent "Collider"
{
uint group = 1
uniform token info:id = "RealityKit.Collider"
uint mask = 4294967295
token type = "Trigger"

def RealityKitStruct "Shape"
{
float3 extent = (0.2, 0.2, 0.19999999)
float radius = 0.1
token shapeType = "Sphere"

def RealityKitStruct "pose"
{
float3 position = (3.7252903e-8, 0, 4.8428774e-8)
}
}
}
}
}

11 changes: 10 additions & 1 deletion WhatVisionOSCanDo/ShowCase/Gesture/GestureView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ enum GestureToggles {

struct GestureView: View {
@State private var enabledGesture: GestureToggles = .tap
@State private var isNight: Bool = true


var body: some View {
VStack {
Expand All @@ -25,9 +27,16 @@ struct GestureView: View {
} catch {
print("load entity error, error is \(error)")
}
} update: { content in
let root = content.entities.first
let moon = root?.findEntity(named: "Moon")
let sun = root?.findEntity(named: "Sun")
moon?.components[OpacityComponent.self]?.opacity = isNight ? 1.0 : 0.0
sun?.components[OpacityComponent.self]?.opacity = isNight ? 0.0 : 1.0
}
.gesture(enabledGesture == .tap ? TapGesture().targetedToAnyEntity().onEnded { _ in
.gesture(enabledGesture == .tap ? TapGesture().targetedToAnyEntity().onEnded { event in
print("TapGesture ended")
isNight = !isNight
} : nil)
.gesture(enabledGesture == .drag ? DragGesture().targetedToAnyEntity().onChanged { value in
let location = value.convert(value.gestureValue.location3D, from: .global, to: value.entity.parent!)
Expand Down

0 comments on commit 5b302be

Please sign in to comment.