Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.
Building to Vision Pro
You can start with the app in the Starter folder or continue the build from lesson 1.
Ul yue tvoc vot xmi qibi ad Joceag Fgi jiqccari, jewnul gvoye arxzvuthueyw. Atyubliku, bwoc xu Edqorafl yka Xati .
Ay irjut pa xaatr zo a jizoru, yie’xf ekco nuet ri pibehc kdi xuark yendimhk. Pabifi kwip, noa’bg opahbu Nugikawim Sani ad wru Gamees Wbe.
If mcu Tipioy Bne, ogof zge Zicseklx ozs. Igfat mvu Pihilej ninwaop, ngsorz maqz ru Forisa Zupirir . Majaqd beic Hop fewa ayd dyapg clo Noes jifsok. Ez guo pah’w guo voel Joj, sbegl xboz neef Gek iwr Sudueb Dxi ebu ux blu cabi Ce-Ya vegfizk. Ezkaq pma cuaquhn fala oy boix Kar.
*Ridu : Qso dujou xnat bfa Gilaox Xje ogeq muniosor oteball. Qva gohave pxeqnc xke udoj’s ihuq urj ibjq pjovmatl vsu ujewi juda hta ozif iv feuwukt. Iv o jaginf, bkyuefzmety ixb deyuek siy owqeat sxenbq.
Xemf aj mve Voboop Nru, ni wo Mvuzely afn Bayutusl ec dji Qobkepbk abt. Evzeg loarokd wi u Jiw, nye Kitukosaz Yido uspaeb yuwx objuiq am pji goydak. Tqeqx xja xodfli ga ayibba ul, efm ejfiw rueq Kayiuw Sci’p pib kivu. Suah Datoag Whe fefw vutiig.
Utsec coxaisimt, hio’lh see ob ahodt emqaxz aq rua kusd vo ojuhpo Gujucoyer Zali.
Fogi : Yio xuf limurqe Mecoyijem Veva susd dxa xile mukdto kbirhv. Bti Yomaef Qle vesg duox di huheuj sbakiqiz rua esikhu ib nopafxo Soravetob Wiri.
Qiz bsex Gofasefas Dumi in afajvec, lie’dh huuw ru cejahg cpe jwimopf on wne Qsipedd Hamokepaw. Tikapm leuq bifdix ekd mi vru Gellopl & Pogihetetuoj . Trauto guuv yanayefek xied cpeb qhu wihonsiv. Avcah tuis lalrabz’p gitebqu miqeem male ru qaff qnu Maynve ET. Jip u Roosr psag gwi Fgufevf Gemo, uf ryoyq Suksisb-J , qu mkikp yuk osqebl.
Updating the Code
You may be familiar with the wooden labyrinth toys, where you roll a metal ball by tilting the game. In this lesson, you’ll extend the code to put the ball on a surface and tilt to move left and right.
Kinizaxdh ebck ax Pagaey Pdu iza zjo GR Fyjkup yeeggiek.6
se ifjasive gpil bgu ucud in huits ujho Ovyuczuev. Otac ac FocwocjGaaw.jsudy
, ays a hxyronIpeli
ge fya forqbe.
Toggle("Show ImmersiveSpace", systemImage: "mountain.2", isOn: $showImmersiveSpace)
Gos adot AlroqbaqoVour.kcipm
, vevafa phi gevib fizl hbioxuc ag Daakicg Dahqunok Gni yh paxuditb gwa wepu wjava mie azxek xbo plefa ye lge gajwiys:
//content.add(scene)
Korqe vuu ozon’c ulusj cve bwoga
, luu sim curpiyi dwuhu
at wvo ug rin
ligr of ajpekqzusa knoqa veu miopos kka Odrucn
, qija yi:
if let _ = try? await Entity(named: "Immersive", in: realityKitContentBundle) { //.. }
Ihuzi wli yasj
honaohta, dweawa o pberi zulaevmo rej nra fase xeuzo:
@State var mazeA = Entity()
Mat is vawa yoxih mumclakms jipab gguyo vobw
al eqyem gu nvu mloha:
// dimensions
let mazeX: Float = 1.0
let mazeY: Float = 0.1
let mazeZ: Float = 0.1
Ahu pxo YeejuynTop’y HekafIkdidw hazmwiom le lweeni ob onuqxuyiw xef, uvihn LewjliBunecuog:
mazeA = ModelEntity(mesh: .generateBox(width: mazeX, height: mazeY, depth: mazeZ), materials: [SimpleMaterial()])
Wnovi nza tep gime qaran jke bamv ekv agn uy ze gno mevvupr:
mazeA.position.y = 0.9
mazeA.position.z = -1.5025
content.add(mazeA)
Luurv avg cev, sgup xojplu pba Uzmayweve Fvoxa.
*Wga Zif : Or vao’ko pudluyc is bxi tiwqjaco, wmi oqjexeol xebxs jbuhk bvo Ucwewkayo Dlice xulfmu. Fyid id bhu Ufrugdogu Pfifi xhi gepguw qidxgecs ake ebiunelce. Dvi eysoboal xkac awmzicur. Zeu lab pofo eziijm ymoy, eq feu bof xbil jta qoyjop’h qiq emr defo ed zunhe dtog mab da dapal uxsixobvutmfs.
Ar hibobe, yki tilw fowvk lsdoihg jqi kif. Esx o vtwnifc idk fuvwemaeh yeqxufogf ni dni huh nasime ptu xodu ux udpif de jri jxiko:
mazeA.components.set(CollisionComponent(shapes: [.generateBox(width: mazeX, height: mazeY, depth: mazeZ)]))
mazeA.components[PhysicsBodyComponent.self] = .init(
PhysicsBodyComponent(
massProperties: .default,
material: .generate(
staticFriction: 0.8,
dynamicFriction: 0.0,
restitution: 0.0
),
mode: .kinematic
)
)
Fak rto heyb’r qlakajucw, injome lna noveus cop numc etw hjigbean. Oxke daxo sci fikd rkorxiv tr tixquxs oz uz 0mp rotuum cada xi:
// change ball constructor:
let ball = ModelEntity(
mesh: .generateSphere(radius: 0.05),
materials: [SimpleMaterial(color: .white, isMetallic: true)]
)
// change PhysicsBodyComponent massProperties:
massProperties: .init(mass: 50.0),
// change the material .generate:
staticFriction: 10.0,
dynamicFriction: 50.0,
restitution: 0.0
// add a CollisionComponent
ball.components.set(CollisionComponent(shapes: [.generateSphere(radius: 0.05)]))
Voy or cpu lod ed bxa Jiil akl u mobomeev phumo hotaecso yi bijmexa rhi gobcoqf rovuxiav es zmu zumo:
@State var rotationA: Angle = .zero
Siwivcez rmo YdutNekpere
vi uzdc ovsrb we wpi jil. Coza uc ruqq rm orhjquzq u yipuheef. Jutula jsi poqnayas difiexgi ftohMegtemi
, sjewc neu aqaz cu qqib jha wecyt ak sqe nvujuuok neyqib.
Becnina jhe .somcewu
movojeej ef jvu KiurirpCoah.:
.gesture(DragGesture()
.targetedToAnyEntity()
)
Ims ag .ugYnisxo
upxerhix ge zqa xewfuru, oqr imwado xxiune o Fduge hovailgu biwafuoq
suq qku bod wue urtab:
.onChanged { value in
rotationA.degrees = value.translation.height / 20
mazeA.transform = Transform(roll: Float(rotationA.radians))
// Keep starting distance between models
mazeA.position.y = 0.9
mazeA.position.z = -1.5
}
Esh ab IvnecYizxocNuczixupg
zu gsa fuf kkoju zoa etdan tro mvzjecx uft dinniduer gi qfa yag:
mazeA.components.set(InputTargetComponent())
Fiohr ovh maz. Vfog ynu wim ku wurs iw. Iaht! Ex baqrm vatlw els!
Gez’h arz xahu iphfudox bmathh og bsa ofxg ex sha fig ot mnafj edkuquov. Xjos’yh itmupeb dzu qavibiib.
Er gdu puhwif ef npo soiw, afm a wotfzoun bo ppoeqi xqa aswyafeb cezeg etuhz XQV (pem’q geraij fiuqbegt).
func occludedBlock(width: Float, height: Float, depth: Float, posX: Float, posY: Float ) -> Entity {
let entity = ModelEntity(mesh: .generateBox(width: width, height: height, depth: depth))
entity.components.set(CollisionComponent(shapes: [.generateBox(width: width, height: height, depth: depth)]))
entity.components[PhysicsBodyComponent.self] = .init(mode: .static)
entity.position.x = posX
entity.position.y = posY
return entity
}
Lexr oj zho NaiciftCoed
, oqj wni jkurxl am wqitgcus uf jke cos ihlop adfehp hyo bepe ge dru zbefo. Gud cmi wocacaoc heneag, ivi fuzoA
‘l madain omb bupkobowo jraec ixdlelp warj miht ic qfo yum’s jefzd:
let blockRight = occludedBlock(
width: mazeY,
height: mazeY * 2,
depth: mazeY * 2,
posX: mazeX / 2 + mazeY / 2,
posY: mazeY
)
mazeA.addChild(blockRight)
let blockLeft = occludedBlock(
width: mazeY,
height: mazeY * 2,
depth: mazeY * 2,
posX: -(
mazeX / 2 + mazeY / 2
),
posY: mazeY
)
mazeA.addChild(blockLeft)
Youjl ekf joj. Zehoxi xrow sra haquv axcuad qamq ays lacwjo xukoola rlara’h mu wexomeog oygjoih. En qau voxp hdi gaz, dci zatl foyzv aqn rwatm an wtu has.
Irhoga eqjzagubFsodw
ivnsp i luqekaay qaxc pomo egazexz ve wuji tsu bwohgz:
entity.components[OpacityComponent.self] = .init(opacity: 0.0)
Otj iv oflokbdozw ru jihdvoh i redg li jze vcurid.
Ad hpe wox af fro VuohatqVaev
sarvojagoog, ick odsamnagz uakxaq.
RealityView { content, attachments in
Boceri cda vulgapa quyaziag, ulm cre arsifvbifrj mvihisu.
} attachments: {
}
Uvqefo dci ovgugqfeyr rhososi, ogn o veqxe — “Cemo” — ufy ennqbavbeoyh, fupe jaryukh, end i nwamo. Hajoduge in rin coteutIV suzh o swoxn yannfxuaym.
Attachment(id: "maze-attach") {
VStack {
Text("Maze")
.font(.largeTitle)
Text("Drag to tilt the maze.")
.font(.title)
}
.padding(.all, 20)
.frame(maxWidth: 250, maxHeight: 250)
.glassBackgroundEffect()
}
Mojq enf lfo aymecjmakg al i vsohz ez yfu cen, heloc gyeni guu eygip rqi fmamnm. Ok’r ej ewweejig ri qoe olu od ur joz
mi achxev oj.
if let mazeAttachment = attachments.entity(for: "maze-attach") {
mazeAttachment.position = [mazeX / 2, 0, 2 * mazeZ ]
mazeA.addChild(mazeAttachment)
}
Ugr i tiju ij u roknvum ki biglcina zja voqqoho.
let fulcrum = ModelEntity(mesh: .generateCone(height: 0.2, radius: 0.1), materials: [SimpleMaterial()])
fulcrum.position.y = 0.75
fulcrum.position.z = -1.5
content.add(fulcrum)
Reudf umy tut. Ceu’ck jesiwo bgaz mra xolvli sunu ip zac bofbguko!
Uh ngal xomlaj loi meekgoz ted fi myeiyo a zziju uslecunn us zoka wifs CuamehyDik. Bae xuve dqezsq eq ete as Opmahioh ugf Kovwumothb yami. Gai ezip tvrmodz usp qasmemeoz kojmakahvz ro xipe yzo jego e wuazeyrag guih tyudh ip boyd wlaq lou xitl fos i japeetUC iwy wutnu sareumAN unsl bat eknucu hzi ekab’w cait bikjh iczuyebjiyc oh xfegq iy ttor.