VR ĺ AR (WebXR)
ćŻćç莞ĺ¤
Needle Engine ćŻćĺŽć´ç WebXR specificationďźĺ ćŹ AR ĺ VRăWebXR ćŻä¸ä¸ŞĺŽćšç˝çťć ĺďźĺŽĺ°ć˛ćľ¸ĺźä˝éŞĺ¸Śĺ°ç˝çťä¸ďźĺšśĺ ˇĺ¤ç˝çťçĺ ¨é¨äźĺżďźć éĺŽčŁ ăć éĺşç¨ĺĺşăć é SDKsă
ćć希ććľč§ĺ¨ç莞ĺ¤é˝ĺŻäťĽčżčĄä˝żç¨ Needle ćĺťşçĺşç¨ăĺŚććľč§ĺ¨ćŻć WebXRďźć¨çĺşç¨äšĺ°čŞĺ¨ä˝żç¨ć䝏ĺ 罎ç components ĺ¨ XR ä¸ĺˇĽä˝ăčżĺ ćŹćĄé˘ćľč§ĺ¨ăç§ťĺ¨ćľč§ĺ¨ăčŽ¸ĺ¤ AR/VR headsets ä¸çćľč§ĺ¨ďźäťĽĺĺ śäťć°ĺ ´ććŻďźĺŚ Looking Glass ćžç¤şĺ¨ăćşč˝çźéçă
:::tip éčż USDZ/QuickLook ĺ¨ iOS ä¸ćäžć é App ç AR ćŻć č˝çś iOS 莞ĺ¤çŽĺĺ°ćŞĺŽćšćŻć WebXRďźä˝ Needle ćŻćä˝żç¨ Everywhere Actions ĺ¨ iOS ä¸ĺĺťş AR ä˝éŞă诡ĺé iOS é¨ĺäşč§Łć´ĺ¤čŻŚć ăć¨ĺŻäťĽĺ坺丰ĺŻăinteractive çä˝éŞďźĺłä˝żĺ¨ Apple 莞ĺŽçéĺśä¸ďźčżäşä˝éŞäšč˝ĺ¨ iOS 莞ĺ¤ä¸ seamlessĺ°ĺ¨ AR ä¸ĺˇĽä˝ă
ĺ˝ć¨ĺ¨ iOS ä¸čżĺ Ľ AR mode ćśďźNeedle äźčŞĺ¨ĺ°ć¨ç scene 轏ć˘ä¸şä¸ä¸Ş USDZ fileďźçśĺä˝żç¨ Apple ç QuickLook ĺ¨ AR ä¸ćžç¤şăObjects, materials, audio, animation ĺ Everywhere Actions ĺ°č˘Ť preservedă :::
ä¸čĄ¨ĺĺşäşä¸äşć䝏éŞčŻčżä¸ Needle Engine ĺ źĺŽšç莞ĺ¤ă ĺ˝ćŻć WebXR çć°čŽžĺ¤éŽä¸ćśďźĺŽĺ° out of the boxä¸ć¨çĺşç¨ĺ źĺŽšăčżćŻ building with the browser as a platform çä¸ĺ¤§äźĺżââcompatibility ä¸ĺçšĺŽčŽžĺ¤éć SDKs çéĺśă
Apple Vision Pro
âď¸ Safari
hand tracking, support for transient pointer
Meta Quest 3
âď¸ Meta Browser
hand tracking, support for sessiongranted1, passthrough, depth sensing, mesh tracking
Meta Quest 3S
âď¸ Meta Browser
hand tracking, support for sessiongranted1, passthrough, depth sensing, mesh tracking
Meta Quest 2
âď¸ Meta Browser
hand tracking, support for sessiongranted1, passthrough (black and white)
Meta Quest 1
âď¸ Meta Browser
hand tracking, support for sessiongranted1
Meta Quest Pro
âď¸ Meta Browser
hand tracking, support for sessiongranted1, passthrough
Pico Neo 4
âď¸ Pico Browser
passthrough, hand tracking2
Pico Neo 3
âď¸ Pico Browser
no hand tracking, inverted controller thumbsticks
Oculus Rift 1/2
âď¸ Chrome
Valve Index
âď¸ Chrome
HTC Vive
âď¸ Chrome
Hololens 2
âď¸ Edge
hand tracking, support for AR and VR (in VR mode, background is rendered as well)
Android 10+
âď¸ Chrome
Android 10+
âď¸ Firefox
iOS 15+
(âď¸)3 Safari (âď¸)3 Chrome
No full code support, but Needle Everywhere Actions are supported for creating dynamic, interactive USDZ files.
iOS 15+
âď¸ WebXR Viewer
browser is somewhat dated by now
Hololens 2
âď¸ Edge
Hololens 1
â
no WebXR support
Magic Leap 2
âď¸
Magic Leap 1
âď¸
deprecated device
Looking Glass Holographic Display
âď¸ Chrome
requires Looking Glass bridge and some custom code, see our sample
1: Requires enabling a browser flag: chrome://flags/#webxr-navigation-permission
2: Requires enabling a toggle in the Developer settings
3: Uses Everywhere Actions or other approaches
VR, AR ĺ QuickLook 示äž
莿éŽć䝏ç Needle Engine Samples çŤĺłĺ°čŻčŽ¸ĺ¤ interactive examplesăćč ďźçšĺťä¸ćšç QR Codeďźç¨äşććşďźć Open on Questďźç¨äş Meta Quest headsetsďźćéŽďźĺ¨ć¨ç莞ĺ¤ä¸ĺŽćśĺ°čŻă
为ĺşćŻćˇťĺ VR ĺ AR ĺč˝
Needle Engine ä¸ç AR, VR ĺ networking capabilites 袍莞莥为樥ĺĺçăć¨ĺŻäťĽéćŠä¸ćŻćĺ śä¸äťťä˝ä¸ä¸Şďźćč ĺŞćˇťĺ specific featuresă
ĺşćŹĺč˝
ĺŻç¨ AR ĺ VR 桝ĺ ä¸ä¸Ş
WebXR
componentăOptional: ć¨ĺŻäťĽéčż referencing ä¸ä¸Ş Avatar Prefab ćĽčŽžç˝Ž custom avatară By default, ĺé äşä¸ä¸Ş basicDefaultAvatar
ăĺŻç¨ Teleportation 为 object hierarchies ä¸ĺŻäťĽ teleport ç寚蹥桝ĺ ä¸ä¸Ş
TeleportTarget
componentă To exclude specific objects, 莞罎ĺŽäťŹç layer 为IgnoreRaycasting
ă
ĺ¤äşşć¨Ąĺź
ĺŻç¨ Networking 桝ĺ ä¸ä¸Ş
SyncedRoom
componentăĺŻç¨ Desktop Viewer Sync 桝ĺ ä¸ä¸Ş
SyncedCamera
componentăĺŻç¨ Voice Chat 桝ĺ ä¸ä¸Ş
VoIP
componentă
:::tip Scene structure These components can be anywhere inside your hierarchyăĺŽäťŹäšĺŻäťĽ all be on the same GameObjectďźwhich is a common patternă :::
Castle Builder 使ç¨ä¸čż° all of the above for a cross-platform multiplayer sandbox experienceă â #madebyneedle đ
çšćŽ AR çťäťś
Define the AR Session root and scale 为ć¨ç root object 桝ĺ ä¸ä¸Ş
WebARSessionRoot
componentăFor AR experiences, often you want to scale the scene to fit the real worldăDefine the user scale to shrink (< 1) or enlarge (> 1) the user in relation to the scene when entering ARă
ć§ĺś XR ä¸ĺŻščąĄçćžç¤ş
Define whether an object is visible in Browser, AR, VR, First Person, Third Person 为ć¨čŚć§ĺśç寚蹥桝ĺ ä¸ä¸Ş
XR Flag
componentăChange options on the dropdown as neededă Common usecases are
hiding floors when entering AR
hiding Avatar parts in First or Third Person viewsăäžĺŚďźin first-person view a person shouldn't be able to see their own head modelă
ĺ¨ VR ä¸çäšé´çŠżć˘
Needle Engine supports the sessiongranted
stateăčżĺ
莸 users to seamlessly traverse between WebXR applications without leaving an immersive session â they stay in VR or ARă
Currently, this is only supported on Oculus Quest 1, 2 and 3 in the Oculus BrowserăOn other platforms, users will be kicked out of their current immersive session and have to enter VR again on the new pageă
Requires enabling a browser flag: chrome://flags/#webxr-navigation-permission
çšĺťĺŻščąĄćĺźéžćĽ 桝ĺ
OpenURL
componentďźä˝żĺžćĺťş connected worlds ĺĺžé常厚ćă
Scripting
Read more about scripting for XR at the scripting XR documentation
Avatars
While we don't currently provide an out-of-the-box integration external avatar systems,ć¨ĺŻäťĽĺĺťş application-specific avatars or custom systemsă
Create a custom Avatar
ĺĺťşä¸ä¸Ş empty GameObject as avatar root
Add an object named
Head
and add aXRFlag
that's set to Third PersonAdd objects named
HandLeft
andHandRight
ĺ¨čżäş objects ä¸ćšćˇťĺ ć¨ç graphicsă
Experimental Avatar Components
ćä¸äş experimental components to build more expressive AvatarsăAt this point we recommended duplicating them to make your own variants, since they might be changed or removed at a later pointă
Example Avatar Rig with basic neck model and limb constraints
Random Player Colors As an example for avatar customization,ć¨ĺŻäťĽä¸şć¨ç renderers 桝ĺ ä¸ä¸Ş
PlayerColor
componentă This randomized color is synchronized between playersăEye Rotation
AvatarEyeLook_Rotation
rotates GameObjects (eyes) to follow other avatars and a random targetăThis component is synchronized between playersăEye Blinking
AvatarBlink_Simple
randomly hides GameObjects (eyes) every few seconds, emulating a blinkă
Example Avatar Prefab hierarchy
Offset Constraint
OffsetConstraint
allows to shift an object in relation to another one in Avatar spaceăčżĺ 莸ďźäžĺŚďźto have a Body follow the Head but keep rotation levelledăĺŽäš allows to construct simple neck modelsăLimb Constraint
BasicIKConstraint
is a very minimalistic constraint that takes two transforms and a hintăThis is useful to construct simple arm or leg chainsăAs rotation is currently not properly implemented, arms and legs may need to be rotationally symmetric to "look right"ăĺŽäšć䝼袍称为âBasicâćŻćĺĺ çďź
AR ä¸ç HTML ĺ
厚ĺ ĺ
ĺŚćć¨ćłć šćŽĺŽ˘ćˇçŤŻä˝żç¨çćŻ regular browser čżćŻ using AR or VR ćĽćžç¤şä¸ĺç html contentďźć¨ĺŞé use a set of html classesă
čżćŻéčż HTML element classes ć§ĺśçăäžĺŚďźto make content appear on desktop and in AR add a <div class="desktop ar"> ... </div>
inside the <needle-engine>
tag:
<needle-engine>
<div class="desktop ar" style="pointer-events:none;">
<div class="positioning-container">
<p>your content for AR and desktop goes here</p>
<p class="only-in-ar">This will only be visible in AR</p>
<div>
</div>
</needle-engine>
Content Overlays are implemented using the optional dom-overlay
feature which is usually supported on screen-based AR devices (phones, tablets)ă
Use the .ar-session-active
class to show/hide specific content while in ARă:xr-overlay
pseudo class shouldn't be used at this point because using it breaks Mozilla's WebXR Vieweră
.only-in-ar {
display: none;
}
.ar-session-active .only-in-ar {
display:initial;
}
It's worth noting that the overlay element will be always displayed fullscreen while in XR, independent of styling that has been appliedăIf you want to align items differently, you should make a container inside the class="ar"
elementă
iOS ä¸çĺ˘ĺźşç°ĺŽĺ WebXR
Augmented Reality experiences on iOS are somewhat limited, çąäş Apple çŽĺä¸ćŻćĺ¨ iOS devices ä¸ä˝żç¨ WebXRă
Needle Engine ç Everywhere Actions are designed to fill that gap, bringing automatic interactive capabilities to iOS devices for scenes composed of specific componentsăĺŽäťŹćŻć WebXR ä¸ available çä¸é¨ĺĺč˝ďźäžĺŚ spatial audio, image tracking, animations, and moreăSee the docs for more informationă
:::tip QuickLook ä¸ĺŻščŞĺŽäšäťŁç çćŻććé Apple has strong limitations in place what kind of content can be used in QuickLookăThus, custom script components can not automatically be converted for use in AR on iOSăYou can add support for some sorts of custom code using our Everywhere Actions APIă :::
äšĺ¨ â WebXR ĺ QuickLook ćŻć
Here's an example for a musical instrument that uses Everywhere Actions and thus works in browsers and in AR on iOS devicesă ĺŽä˝żç¨ spatial audio, animation, and tap interactionsă
Everywhere Actions ĺ iOS AR çĺ
śäťé饚
čżćĺ śäť options for guiding iOS users to even more capable interactive AR experiences:
Exporting content on-the-fly as USDZ filesă These files can be displayed on iOS devices in ARăWhen exported from scenes with Everywhere Actions the interactivity is the same, more than sufficient for product configurators, narrative experiences and similară An example is Castle Builder where creations (not the live session) can be viewed in ARă
Encryption in Space uses this approachăPlayers can collaboratively place text into the scene on their screens and then view the results in AR on iOSăOn Android, they can also interact right in WebXRă â #madewithneedle by Katja Rempel đ
Guiding users towards WebXR-compatible browsers on iOSă Depending on your target audience, ć¨ĺŻäťĽĺźĺŻź iOS ä¸çç¨ćˇäžĺŚä˝żç¨ Mozilla ç WebXR Viewer ĺ¨ iOS ä¸ä˝éŞ ARă
Using camera access and custom algorithms on iOS devicesă ĺŻäťĽčŻˇćą camera image access and run custom algorithms to determine device poseă While we currently don't provide built-in components for this, čżéćä¸äşć䝏ĺ°ćĽćłĺ°čŻç libraries and frameworks reference:
AR.js (open source)
Experimental AR.js integration by FireDragonGameStudio
Mind AR (open source)
8th Wall (commercial)
ĺžĺ追踪
Needle Engine supports WebXR Image Tracking (Live Demo) on Android and QuickLook Image Tracking on iOSă
ć¨ĺŻäťĽĺ¨ Everywhere Actions é¨ĺćžĺ° additional documentationă
:::warning WebXR Image Tracking is still in a "draft" phase and not generally available So far, browser vendors haven't been able to agree on the final image tracking API for WebXRăAs long as the specification is in "draft" phase (Marker Tracking Explainer)ďź ć¨ĺć¨çĺşç¨ç users éčŚéľĺžŞ these steps to enable WebXR ImageTracking on Android devices:
ĺ¨ć¨ç Android Chrome browser ä¸čŽżéŽ
chrome://flags
ćžĺ°ĺšśĺŻç¨
WebXR Incubations
é饚 :::
Without that spec, one can still request camera image access and run custom algorithms to determine device poseăThe downside is that users will have to accept additional permissions like camera access, and the tracking will not be as accurate as with the native capabilities of the deviceă
Here are some libraries to add image tracking based on camera access and local computer vision algorithms:
AR.js with Needle Engine çĺŽéŞć§éć by FireDragonGameStudio
AR.js (open source)
Mind AR (open source)
ĺččľć
WebXR Device APIcaniuse: WebXRApple's Preliminary USD Behaviours
饾é˘çą AI čŞĺ¨çżťčŻ
Last updated