From e1eebadcfde5e7b95a54f6ec2639f9d54fc5ff06 Mon Sep 17 00:00:00 2001 From: Zach Fox <3409031+zfox23@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:02:56 -0500 Subject: [PATCH 1/7] Update some WebVR docs to relate to the more modern WebXR --- files/en-us/_redirects.txt | 1 + files/en-us/_wikihistory.json | 2 +- .../index.md | 2 +- .../games/techniques/3d_on_the_web/index.md | 4 +- .../techniques/3d_on_the_web/webvr/hmds.jpg | Bin 9548 -> 0 bytes .../techniques/3d_on_the_web/webvr/index.md | 113 ------------------ .../techniques/3d_on_the_web/webxr/hmds.jpg | Bin 0 -> 17262 bytes .../techniques/3d_on_the_web/webxr/index.md | 57 +++++++++ .../{webvr => webxr}/sechelt.jpg | Bin files/jsondata/GroupData.json | 9 +- 10 files changed, 70 insertions(+), 118 deletions(-) delete mode 100644 files/en-us/games/techniques/3d_on_the_web/webvr/hmds.jpg delete mode 100644 files/en-us/games/techniques/3d_on_the_web/webvr/index.md create mode 100644 files/en-us/games/techniques/3d_on_the_web/webxr/hmds.jpg create mode 100644 files/en-us/games/techniques/3d_on_the_web/webxr/index.md rename files/en-us/games/techniques/3d_on_the_web/{webvr => webxr}/sechelt.jpg (100%) diff --git a/files/en-us/_redirects.txt b/files/en-us/_redirects.txt index 128eff465f1d3b4..cee68f1d12854b4 100644 --- a/files/en-us/_redirects.txt +++ b/files/en-us/_redirects.txt @@ -3511,6 +3511,7 @@ /en-US/docs/Games/Introduction_to_HTML5_Game_Development_(summary) /en-US/docs/Games/Introduction_to_HTML5_Game_Development /en-US/docs/Games/Introduction_to_HTML5_Game_Gevelopment_(summary) /en-US/docs/Games/Introduction_to_HTML5_Game_Development /en-US/docs/Games/Techniques/3D_collision_detection/Bounding_boxes_with_THREE.js /en-US/docs/Games/Techniques/3D_collision_detection/Bounding_volume_collision_detection_with_THREE.js +/en-US/docs/Games/Techniques/3D_on_the_web/WebVR /en-US/docs/Games/Techniques/3D_on_the_web/WebXR /en-US/docs/Games/Techniques/Crisp,_pixel_art_look_with_image-rendering /en-US/docs/Games/Techniques/Crisp_pixel_art_look /en-US/docs/Games/Techniques/Efficient_animation_for_web_games /en-US/docs/Games/Techniques /en-US/docs/Games/Techniques/Fridge_Gamepad_API /en-US/docs/Games/Techniques/Controls_Gamepad_API diff --git a/files/en-us/_wikihistory.json b/files/en-us/_wikihistory.json index 583ef325de52896..e0c0c15a9ffc3be 100644 --- a/files/en-us/_wikihistory.json +++ b/files/en-us/_wikihistory.json @@ -313,7 +313,7 @@ "PushpitaPikuDey" ] }, - "Games/Techniques/3D_on_the_web/WebVR": { + "Games/Techniques/3D_on_the_web/WebXR": { "modified": "2020-10-30T12:56:29.452Z", "contributors": [ "Wind1808", diff --git a/files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md b/files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md index fcd7bb48728d3db..039d6c263d4cf31 100644 --- a/files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md +++ b/files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md @@ -6,7 +6,7 @@ page-type: guide {{GamesSidebar}} -The [WebVR](/en-US/docs/Games/Techniques/3D_on_the_web/WebVR) and [WebGL](/en-US/docs/Web/API/WebGL_API) APIs already enable us to start creating virtual reality (VR) experiences inside web browsers, but the community is still waiting for tools and libraries to appear, to make this easier. Mozilla's [A-Frame](https://aframe.io/) framework provides a markup language allowing us to build 3D VR landscapes using a system familiar to web developers, which follows game development coding principles; this is useful for quickly and successfully building prototypes and demos, without having to write a lot of JavaScript or GLSL. This article explains how to get up and running with A-Frame, and how to use it to build up a simple demo. +The [WebXR](/en-US/docs/Games/Techniques/3D_on_the_web/WebXR) and [WebGL](/en-US/docs/Web/API/WebGL_API) APIs already enable us to start creating virtual reality (VR) and augmented reality (AR) experiences inside web browsers, but the community is still waiting for tools and libraries to appear, to make this easier. Mozilla's [A-Frame](https://aframe.io/) framework provides a markup language allowing us to build 3D VR landscapes using a system familiar to web developers, which follows game development coding principles; this is useful for quickly and successfully building prototypes and demos, without having to write a lot of JavaScript or GLSL. This article explains how to get up and running with A-Frame, and how to use it to build up a simple demo. ## High level overview diff --git a/files/en-us/games/techniques/3d_on_the_web/index.md b/files/en-us/games/techniques/3d_on_the_web/index.md index c538d41fa1edc85..7b5c26aac080207 100644 --- a/files/en-us/games/techniques/3d_on_the_web/index.md +++ b/files/en-us/games/techniques/3d_on_the_web/index.md @@ -33,9 +33,9 @@ It's hard to imagine a game without collision detection — we always need to wo - [2D collision detection](/en-US/docs/Games/Techniques/2D_collision_detection) - [3D collision detection](/en-US/docs/Games/Techniques/3D_collision_detection) -### WebVR +### WebXR -The concept of virtual reality is not new, but it's storming onto the web thanks to hardware advancements such as the [Oculus Rift](https://www.oculus.com/rift/), and the (currently experimental) [WebVR API](/en-US/docs/Web/API/WebVR_API) for capturing information from VR hardware and making it available for use in JavaScript applications. For more, read [WebVR — Virtual Reality for the Web](/en-US/docs/Games/Techniques/3D_on_the_web/WebVR). +The concept of virtual reality is not new, but it's storming onto the web thanks to hardware advancements such as the [Meta Quest](https://www.meta.com/quest/), and the (currently experimental) [WebXR API](/en-US/docs/Web/API/WebXR_Device_API) for capturing information from XR hardware and making it available for use in JavaScript applications. For more, read [WebXR — Virtual and Augmented Reality for the Web](/en-US/docs/Games/Techniques/3D_on_the_web/WebXR). There's also the [Building up a basic demo with A-Frame](/en-US/docs/Games/Techniques/3D_on_the_web/Building_up_a_basic_demo_with_A-Frame) article showing you how easy it is to build 3D environments for virtual reality using the [A-Frame](https://aframe.io/) framework. diff --git a/files/en-us/games/techniques/3d_on_the_web/webvr/hmds.jpg b/files/en-us/games/techniques/3d_on_the_web/webvr/hmds.jpg deleted file mode 100644 index 5ce29503f3bbbfe8a8687f03543c945f52434cb5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9548 zcmb7qWmFv9vUU&d4#C}h1_pO`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j6A-BN3&uj)~ wiudLb{cYipnBkYvo>kGsA* **Note:** WebVR API is replaced by [WebXR Device API](/en-US/docs/Web/API/WebXR_Device_API). WebVR was never ratified as a standard, was implemented and enabled by default in very few browsers and supported a small number of devices. - -## VR devices - -With the popularity of Oculus Rift and a lot of other devices in production coming soon to the market, the future looks bright — we already have sufficient technology to make the VR experience "good enough" for playing games. There are many devices to chose from: desktop ones like Oculus Rift or HTC Vive, through consoles with Playstation VR (which admittedly doesn't support WebVR at this time), to mobile experiences like Gear VR or Google Cardboard. - -![Five different VR devices, ranging from cardboard to high-end.](hmds.jpg) - -> **Note:** For more information, read our [WebVR Concepts](/en-US/docs/Web/API/WebVR_API/Concepts) article. - -## The WebVR API - -The [WebVR API](/en-US/docs/Web/API/WebVR_API) is the central API for capturing information on VR Devices connected to a computer and headset position/orientation/velocity/acceleration information, and converting that into useful data you can use in your games and other applications. - -> **Note:** There are of course other APIs useful for creating games, for example [The Gamepad API](/en-US/docs/Web/API/Gamepad_API) for control inputs, and the [Device Orientation API](/en-US/docs/Web/API/Device_orientation_events/Detecting_device_orientation) for handling display orientation on mobile. - -### Browser support and spec status - -The [WebVR spec](https://mozvr.github.io/webvr-spec/webvr.html), led by [Vladimir Vukicevic](https://twitter.com/vvuk) from Mozilla and [Brandon Jones](https://twitter.com/tojiro) from Google, is being replaced by the [WebXR Device API](/en-US/docs/Web/API/WebXR_Device_API). WebVR may still be available in some browsers while WebXR is finalized. -For more info, see the and [WebVR.info](https://webvr.info/) websites. - -### Using the WebVR API - -The WebVR API is based on two concepts — sending [stereoscopic images](/en-US/docs/Web/API/WebVR_API/Concepts#stereoscopic_vision) to both lenses in your headset and receiving positional data for your head from the sensor, and those two are handled by {{domxref("HMDVRDevice")}} (head-mounted display virtual reality device) and {{domxref("PositionSensorVRDevice")}}. - -### Get the devices - -To get information about devices connected to your computer, you can use the {{domxref("Navigator/getVRDisplays")}} method: - -```js -navigator.getVRDevices().then((devices) => { - for (let i = 0; i < devices.length; ++i) { - if (devices[i] instanceof HMDVRDevice) { - gHMD = devices[i]; - break; - } - } - if (gHMD) { - for (let i = 0; i < devices.length; ++i) { - if ( - devices[i] instanceof PositionSensorVRDevice && - devices[i].hardwareUnitId === gHMD.hardwareUnitId - ) { - gPositionSensor = devices[i]; - break; - } - } - } -}); -``` - -This code will loop through the available devices and assign proper sensors to the headsets — the first `devices` array contains the connected devices, and a check is done to find the {{domxref("HMDVRDevice")}}, and assign it to the `gHMD` variable — using this you can set up the scene, getting the eye parameters, setting the field of view, etc. For example: - -```js -function setCustomFOV(up, right, down, left) { - const testFOV = new VRFieldOfView(up, right, down, left); - - gHMD.setFieldOfView(testFOV, testFOV, 0.01, 10000.0); -} -``` - -The `gPositionSensor` variable holds the {{domxref("PositionSensorVRDevice")}} — using this you can get the current position or orientation state (for example to update the scene view on every frame), or reset the sensor. For example, the below code outputs position information on the screen: - -```js -function setView() { - const posState = gPositionSensor.getState(); - - if (posState.hasPosition) { - const format = (axis) => `${axis}${roundToTwo(posState.position[axis])}`; - posPara.textContent = `Position: ${axis("x")} ${axis("y")} ${axis("x")}`; - xPos = -posState.position.x * WIDTH * 2; - yPos = posState.position.y * HEIGHT * 2; - zPos = -posState.position.z > 0.01 ? -posState.position.z : 0.01; - } - - // … -} -``` - -For a full explanation and more details of the demo this is taken from, see [Using the WebVR API](/en-US/docs/Web/API/WebVR_API/Using_the_WebVR_API). - -## Tools and techniques - -The first WebVR experiments and demos used Three.js as it's probably the most popular 3D engine for the web. See the [VREffect](https://github.com/mrdoob/three.js/blob/ca521eb4af7554e760f14d8fe8b451c8ff34deb8/examples/js/effects/VREffect.js) and [VRControls](https://github.com/mrdoob/three.js/blob/abdd1713c606135bc35028c6021698b52f27872b/examples/js/controls/VRControls.js) functions available on the Three.js GitHub to help you implement and handle WebVR with Three.js. - -![A 3D representation of a landscape: it's a pinkish sunset, with a blue mountainous land in the background surrounded by a mirror sea and a darker blue island in the second plan.](sechelt.jpg) - -Boris Smus has written about the concept of [Responsive WebVR](https://smus.com/responsive-vr/), where a single web game can be played on various devices like laptops without VR hardware, PCs with Oculus Rift, or smartphones inside Google Cardboard and still deliver a unique and valuable experience across all of them. It's like responsive design but applied to the VR world — write once and run in any VR headset, or without it. You can check the [WebVR Boilerplate](https://github.com/borismus/webvr-boilerplate) sources — it's a good example to start learning WebVR from, and a starting point for any web-based VR experience. - -There's also a markup framework called [A-Frame](https://aframe.io/) that offers simple building blocks for WebVR, so you can rapidly build and experiment with VR websites and games: read the [Building up a basic demo with A-Frame](/en-US/docs/Games/Techniques/3D_on_the_web/Building_up_a_basic_demo_with_A-Frame) tutorial for more details. - -Immersion is more important than gameplay or graphics - you have to feel you're "inside" the experience. It's not easy to achieve, but it doesn't require realistic images. Quite the contrary as having a basic shapes flying around in high frame rate can make a lot. Remember: experimenting is key - see what works for your game in particular. - -## The future of WebVR - -It's happening — consumer devices are reaching the market right now, and we already have JavaScript APIs to support them on the Web. All we need now is a stable specification, good UX and UI, better hardware and more tools and libraries — and all of that is on the horizon. It's the perfect time to dive in and experiment with WebVR. - -## See also - -- [WebVR API](/en-US/docs/Web/API/WebVR_API) -- [WebVR concepts](/en-US/docs/Web/API/WebVR_API/Concepts) -- [Using the WebVR API](/en-US/docs/Web/API/WebVR_API/Using_the_WebVR_API) -- [Building up a basic demo with A-Frame](/en-US/docs/Games/Techniques/3D_on_the_web/Building_up_a_basic_demo_with_A-Frame) diff --git a/files/en-us/games/techniques/3d_on_the_web/webxr/hmds.jpg b/files/en-us/games/techniques/3d_on_the_web/webxr/hmds.jpg new file mode 100644 index 0000000000000000000000000000000000000000..345d5a96978747936e90f381683d54106a1ff053 GIT binary patch literal 17262 zcmeHvXIN89*XRx%q)1aldXXk2p$F+8AiYaf2qBb^gpdHDGz$tU2qFp=RC@1CMMRON zsC4NHC{2_Og2J~G$~otK&sXlf&;4gYenl)w5teLR&aqAPX|HN^l;{XH# z01)sG*!oPjr626=2>_<1fFu9_bO0@c4WI;5WIBW!peCmQz#VdUFYN;n-{G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~^1Rpsz`grhc`^P;Thhl?BErfi7s>{Xha<<$OTAE@MOq zuY+Q@@e{i)CYgi|g*(%)5e!PpiKVGp(Ap_iE2G9f2Akv zlt>W1Q1_vxC~@D5x9~fxPad})Wr>{YztS=(nVZx>Catv$v^H#}1fG@j_3 zz3$J^-rQNNl|iGedHu-MtI2$$t_hzjZ5u9Ii+JaXsfYM%9=@~x0*8elzt0U3-+BXs z$cexkWpk0hTJZ#OxFxA`Jvxqa!K{S-)O*K6%-3a!cHRW@o|PL3|0l2 zt6KA{3zPQBxO3@Rzcos%S~%jBnLa0W?LP%s%Ah_q%g`4TpE~3$b@sKBpJ6H>+j1_SXL(myaV@O1uVl5><)kwrK6>;Qk^AHA_f%Pi4?6VY zA$d&c$E+%CXHqdl&eB=w+8p}C?r){blr{F%R_q9${-J>jb)vjHIw!wy648)P-0*UT zG__^zq&%ZY9_P$MUL3v)@?h6PWM!Ai^382BP0iq0+7mxbpYb zS677HxUVs2TV=5-k@r)yX+Jf3vID#J7PbYji6n_}c@U}i=Iy?A=(bAs$MJ{Q4c>eS zuc@hRqSA;^q{3-)y*z#aAbikkm=~o+Z(z0nCCQhAV)9=b*ZX=#0wp`BX9TImDYMVb z;9~m?G#Gq0Ef3Ee0v)J9o~@S4Ih>O}pBmnzETJ_5m+r#k-{n(MZ~v5zv~&m8?yQvi z*#rgTpjz7OFpF(}GX(ti1JgzBG2dVEU_yi}v!*jbN($e)d3Hs;k?l6Ni`8p<@~P0s zr>UJU_(!^if-C$k>l^OLrj30@2;U@w!>Q*jvrHcFmJC|52rmwsJd)9Sqo0PC)z4VU zGWqGHH$I--Bt~PTswNiS%0SbB`-Q9evQB?}g`MjeVXUPpO5)MD@#KP`1An`j>}2V2 zO_Lg)k&5tEP=8*M{uJO9#=QVx1@;SQ3CdY)JC7+znlJLd&9$i **Note:** You may see references to the older WebVR (with a V) API across the Internet. WebVR was replaced by [WebXR Device API](/en-US/docs/Web/API/WebXR_Device_API). WebVR was never ratified as a standard, was implemented and enabled by default in very few browsers, and supported only a small number of devices. + +## VR devices + +With the popularity of existing VR headsets such as Meta Quest, Valve Index, and PlayStation VR, the future looks bright — we already have sufficient technology to create meaningful VR gaming experiences. + +![Three different VR devices: the Meta Quest 3, the Valve Index, and the Sony PSVR2.](hmds.jpg) + +### History of the WebVR spec + +The [WebVR spec](https://mozvr.github.io/webvr-spec/webvr.html), led by [Vladimir Vukicevic](https://twitter.com/vvuk) from Mozilla and [Brandon Jones](https://twitter.com/tojiro) from Google, is being replaced by the [WebXR Device API](/en-US/docs/Web/API/WebXR_Device_API). WebVR may still be available in some browsers while WebXR is finalized. +For more info, see the and [WebVR.info](https://webvr.info/) websites. + +## The WebXR API + +The core of any WebXR experience is built on top of two foundational concepts: + +1. The application must receive real-time data about your headset's position and your controllers' positions in three-dimensional space +2. The application must render a real-time, stereoscopic view to the headset's display(s) according to that positional data + +The [WebXR API](/en-US/docs/Web/API/WebXR_Device_API) is the central API for capturing information about XR devices connected to a computer. The API can capture headset and controller position, orientation, velocity, acceleration, and other information that you can use in your games. + +There are other APIs useful for creating games such as [the Gamepad API](/en-US/docs/Web/API/Gamepad_API) for non-XR controller inputs and the [Device Orientation API](/en-US/docs/Web/API/Device_orientation_events/Detecting_device_orientation) for handling display orientation. + +### Using the WebXR API + +The best place to start with the WebXR API is with our [Fundamentals of WebXR](/en-US/docs/Web/API/WebXR_Device_API/Fundamentals) guide. After that, see [Starting up and shutting down a WebXR session](/en-US/docs/Web/API/WebXR_Device_API/Startup_and_shutdown). + +## Tools and techniques + +The first WebVR experiments and demos used Three.js as it's probably the most popular 3D engine for the web. Its popularity continues today, and it can be used for WebXR games. Check out Three.js' [How to create VR content](https://threejs.org/docs/#manual/en/introduction/How-to-create-VR-content) documentation to help you make WebXR games with Three.js. + +![A 3D representation of a landscape: it's a pinkish sunset, with a blue mountainous land in the background surrounded by a mirror sea and a darker blue island in the second plan.](sechelt.jpg) + +There's also a markup framework called [A-Frame](https://aframe.io/) that offers simple building blocks for WebXR, so you can rapidly build and experiment with VR websites and games: read the [Building up a basic demo with A-Frame](/en-US/docs/Games/Techniques/3D_on_the_web/Building_up_a_basic_demo_with_A-Frame) tutorial for more details. + +Immersion is more important than gameplay or graphics - you have to feel you're "inside" the experience. It's not easy to achieve, but it doesn't require realistic images. Quite the contrary, as having a basic shapes flying around with a high frame rate can make for a compelling experience. Remember: experimenting is key - see what works for your game in particular. + +## The future of WebXR + +It's happening — consumer devices are on the market right now, and we already have JavaScript APIs to support them on the web. All we need now is a widely-adopted, stable specification, good UX and UI, better hardware, and more tools and libraries — and all of that is on the horizon. It's the perfect time to dive in and experiment with WebXR. + +## See also + +- [WebVR Device API](/en-US/docs/Web/API/WebXR_Device_API) +- [Fundamentals of WebXR](/en-US/docs/Web/API/WebXR_Device_API/Fundamentals) +- [Building up a basic demo with A-Frame](/en-US/docs/Games/Techniques/3D_on_the_web/Building_up_a_basic_demo_with_A-Frame) diff --git a/files/en-us/games/techniques/3d_on_the_web/webvr/sechelt.jpg b/files/en-us/games/techniques/3d_on_the_web/webxr/sechelt.jpg similarity index 100% rename from files/en-us/games/techniques/3d_on_the_web/webvr/sechelt.jpg rename to files/en-us/games/techniques/3d_on_the_web/webxr/sechelt.jpg diff --git a/files/jsondata/GroupData.json b/files/jsondata/GroupData.json index d03c03864818589..89d5ddd51bf2b74 100644 --- a/files/jsondata/GroupData.json +++ b/files/jsondata/GroupData.json @@ -2301,7 +2301,14 @@ }, "WebXR Device API": { "overview": ["WebXR Device API"], - "guides": ["/docs/Web/API/WebXR_Device_API/Fundamentals"], + "guides": [ + "/docs/Web/API/WebXR_Device_API/Fundamentals", + "/docs/Web/API/WebXR_Device_API/Lifecycle", + "/docs/Web/API/WebXR_Device_API/Startup_and_shutdown", + "/docs/Web/API/WebXR_Device_API/Cameras", + "/docs/Web/API/WebXR_Device_API/Geometry", + "/docs/Web/API/WebXR_Device_API/Spatial_tracking" + ], "interfaces": [ "XRAnchor", "XRBoundedReferenceSpace", From d4408d29b291be85c83cacbe4be49f492509eb03 Mon Sep 17 00:00:00 2001 From: Zach Fox <3409031+zfox23@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:50:12 -0500 Subject: [PATCH 2/7] Update files/en-us/games/techniques/3d_on_the_web/webxr/index.md Co-authored-by: Brian Thomas Smith --- files/en-us/games/techniques/3d_on_the_web/webxr/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md index aee14896aebf5af..a5964a8f60a007c 100644 --- a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md +++ b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md @@ -8,7 +8,7 @@ page-type: guide The concepts of virtual reality (VR) and augmented reality (AR) aren't new, but the technology is more accessible than ever. We can also use a JavaScript API to make use of it in web applications. This article introduces WebXR from the perspective of its use in games. -> **Note:** You may see references to the older WebVR (with a V) API across the Internet. WebVR was replaced by [WebXR Device API](/en-US/docs/Web/API/WebXR_Device_API). WebVR was never ratified as a standard, was implemented and enabled by default in very few browsers, and supported only a small number of devices. +> **Note:** You may see references to the non-standard WebVR API. WebVR was never ratified as a standard, was implemented and enabled by default in very few browsers, and supported only a few devices. The **WebVR** API is replaced by the [**WebXR** Device API](/en-US/docs/Web/API/WebXR_Device_API). ## VR devices From f536a54773e4cf4315cee39cca531898e96c0c5c Mon Sep 17 00:00:00 2001 From: Zach Fox <3409031+zfox23@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:51:32 -0500 Subject: [PATCH 3/7] Update files/en-us/games/techniques/3d_on_the_web/webxr/index.md Co-authored-by: Brian Thomas Smith --- files/en-us/games/techniques/3d_on_the_web/webxr/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md index a5964a8f60a007c..d2b6b4135d1ddf4 100644 --- a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md +++ b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md @@ -16,7 +16,7 @@ With the popularity of existing VR headsets such as Meta Quest, Valve Index, and ![Three different VR devices: the Meta Quest 3, the Valve Index, and the Sony PSVR2.](hmds.jpg) -### History of the WebVR spec +### Development of WebVR The [WebVR spec](https://mozvr.github.io/webvr-spec/webvr.html), led by [Vladimir Vukicevic](https://twitter.com/vvuk) from Mozilla and [Brandon Jones](https://twitter.com/tojiro) from Google, is being replaced by the [WebXR Device API](/en-US/docs/Web/API/WebXR_Device_API). WebVR may still be available in some browsers while WebXR is finalized. For more info, see the and [WebVR.info](https://webvr.info/) websites. From b7586afaa25a170e3ecbe39512d5db6f09f27f0b Mon Sep 17 00:00:00 2001 From: Zach Fox <3409031+zfox23@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:55:52 -0500 Subject: [PATCH 4/7] Update files/en-us/games/techniques/3d_on_the_web/webxr/index.md Co-authored-by: Brian Thomas Smith --- files/en-us/games/techniques/3d_on_the_web/webxr/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md index d2b6b4135d1ddf4..0c5e27ed14255a4 100644 --- a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md +++ b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md @@ -38,7 +38,7 @@ The best place to start with the WebXR API is with our [Fundamentals of WebXR](/ ## Tools and techniques -The first WebVR experiments and demos used Three.js as it's probably the most popular 3D engine for the web. Its popularity continues today, and it can be used for WebXR games. Check out Three.js' [How to create VR content](https://threejs.org/docs/#manual/en/introduction/How-to-create-VR-content) documentation to help you make WebXR games with Three.js. +Three.js is one of the most popular 3D engines for the web, and it can be used for WebXR games. Check out Three.js' [How to create VR content](https://threejs.org/docs/#manual/en/introduction/How-to-create-VR-content) documentation to help you make WebXR games with Three.js. ![A 3D representation of a landscape: it's a pinkish sunset, with a blue mountainous land in the background surrounded by a mirror sea and a darker blue island in the second plan.](sechelt.jpg) From cb27ef945968398b0d6beee5daa0b71796f9b3f8 Mon Sep 17 00:00:00 2001 From: Zach Fox <3409031+zfox23@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:16:31 -0500 Subject: [PATCH 5/7] Update files/en-us/games/techniques/3d_on_the_web/webxr/index.md Co-authored-by: Brian Thomas Smith --- files/en-us/games/techniques/3d_on_the_web/webxr/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md index 0c5e27ed14255a4..659bc916f6f348c 100644 --- a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md +++ b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md @@ -44,7 +44,7 @@ Three.js is one of the most popular 3D engines for the web, and it can be used f There's also a markup framework called [A-Frame](https://aframe.io/) that offers simple building blocks for WebXR, so you can rapidly build and experiment with VR websites and games: read the [Building up a basic demo with A-Frame](/en-US/docs/Games/Techniques/3D_on_the_web/Building_up_a_basic_demo_with_A-Frame) tutorial for more details. -Immersion is more important than gameplay or graphics - you have to feel you're "inside" the experience. It's not easy to achieve, but it doesn't require realistic images. Quite the contrary, as having a basic shapes flying around with a high frame rate can make for a compelling experience. Remember: experimenting is key - see what works for your game in particular. +Immersion takes priority over gameplay and graphics - you must feel part of the experience. It's not easy to achieve, but it doesn't require realistic images. On the contrary, even basic shapes soaring past at high frame rates can be thrilling if the experience is immersive. Remember: experimenting is key - feel free to go with what works well for your project. ## The future of WebXR From 7ad4bbf71ba086be656ce3c91ca73ee4b491cb9f Mon Sep 17 00:00:00 2001 From: Zach Fox <3409031+zfox23@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:22:44 -0500 Subject: [PATCH 6/7] Update files/en-us/games/techniques/3d_on_the_web/webxr/index.md Co-authored-by: Brian Thomas Smith --- files/en-us/games/techniques/3d_on_the_web/webxr/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md index 659bc916f6f348c..eaa8b859ec0fbb9 100644 --- a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md +++ b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md @@ -48,7 +48,7 @@ Immersion takes priority over gameplay and graphics - you must feel part of the ## The future of WebXR -It's happening — consumer devices are on the market right now, and we already have JavaScript APIs to support them on the web. All we need now is a widely-adopted, stable specification, good UX and UI, better hardware, and more tools and libraries — and all of that is on the horizon. It's the perfect time to dive in and experiment with WebXR. +Consumer devices are available on the market, and we have JavaScript APIs to support them on the web. As hardware becomes more affordable and the ecosystem matures, developers can focus on building experiences through good UX and UI. It's the perfect time to dive in and experiment with WebXR. ## See also From 4d4991b4cfd7a08ae3c36237103bf1db3293425b Mon Sep 17 00:00:00 2001 From: Zach Fox <3409031+zfox23@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:25:49 -0500 Subject: [PATCH 7/7] Reorder --- files/en-us/games/techniques/3d_on_the_web/webxr/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md index eaa8b859ec0fbb9..8ab07c5c8ba2070 100644 --- a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md +++ b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md @@ -38,11 +38,11 @@ The best place to start with the WebXR API is with our [Fundamentals of WebXR](/ ## Tools and techniques -Three.js is one of the most popular 3D engines for the web, and it can be used for WebXR games. Check out Three.js' [How to create VR content](https://threejs.org/docs/#manual/en/introduction/How-to-create-VR-content) documentation to help you make WebXR games with Three.js. +[A-Frame](https://aframe.io/) is a web framework that offers simple building blocks for WebXR, so you can rapidly build and experiment with VR websites and games. You can read MDN's [Building up a basic demo with A-Frame](/en-US/docs/Games/Techniques/3D_on_the_web/Building_up_a_basic_demo_with_A-Frame) tutorial for more details. -![A 3D representation of a landscape: it's a pinkish sunset, with a blue mountainous land in the background surrounded by a mirror sea and a darker blue island in the second plan.](sechelt.jpg) +Separately, Three.js is one of the most popular 3D engines for the web, and it can be used for WebXR games. Check out Three.js' [How to create VR content](https://threejs.org/docs/#manual/en/introduction/How-to-create-VR-content) documentation to help you make WebXR games with Three.js. -There's also a markup framework called [A-Frame](https://aframe.io/) that offers simple building blocks for WebXR, so you can rapidly build and experiment with VR websites and games: read the [Building up a basic demo with A-Frame](/en-US/docs/Games/Techniques/3D_on_the_web/Building_up_a_basic_demo_with_A-Frame) tutorial for more details. +![A 3D representation of a landscape: it's a pinkish sunset, with a blue mountainous land in the background surrounded by a mirror sea and a darker blue island in the second plan.](sechelt.jpg) Immersion takes priority over gameplay and graphics - you must feel part of the experience. It's not easy to achieve, but it doesn't require realistic images. On the contrary, even basic shapes soaring past at high frame rates can be thrilling if the experience is immersive. Remember: experimenting is key - feel free to go with what works well for your project.