<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ramona Harrison on Medium]]></title>
        <description><![CDATA[Stories by Ramona Harrison on Medium]]></description>
        <link>https://medium.com/@ramona.harrison?source=rss-1675ccfce61d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pHxDBo20s0PFbQUA.</url>
            <title>Stories by Ramona Harrison on Medium</title>
            <link>https://medium.com/@ramona.harrison?source=rss-1675ccfce61d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 00:51:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ramona.harrison/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Supporting AR Experiences in the New York Times Android App]]></title>
            <link>https://open.nytimes.com/supporting-ar-experiences-in-new-york-times-mobile-apps-48c3731a4dbf?source=rss-1675ccfce61d------2</link>
            <guid isPermaLink="false">https://medium.com/p/48c3731a4dbf</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[ar]]></category>
            <dc:creator><![CDATA[Ramona Harrison]]></dc:creator>
            <pubDate>Thu, 13 Sep 2018 17:00:40 GMT</pubDate>
            <atom:updated>2018-09-13T17:05:10.432Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BxAc-2yTFkq3raDkGTLDtw.jpeg" /><figcaption>Illustration by Jeremy Leung</figcaption></figure><p>Earlier this year, The New York Times introduced augmented reality (AR) experiences within interactive articles. This new digital storytelling medium allows readers to bring three-dimensional objects captured by our newsroom into their own space. From catching<a href="https://www.nytimes.com/interactive/2018/02/05/sports/olympics/ar-augmented-reality-olympic-athletes-ul.html"> Olympic athletes mid-jump</a>, to closely examining the intricate textures of<a href="https://www.nytimes.com/interactive/2018/03/20/arts/design/bowie-costumes-ar-3d-ul.html"> David Bowie’s costumes</a>, to exploring<a href="https://www.nytimes.com/interactive/2018/05/01/science/mars-nasa-insight-ar-3d-ul.html"> NASA’s latest mission to Mars</a> — augmented reality brings a new and interactive dimension to our stories.</p><p>These experiences have been enabled on the native app side by new technologies that were released in the past year: <a href="https://developer.apple.com/arkit/">ARKit</a> became available on iOS in late 2017 and <a href="https://developers.google.com/ar/">ARCore</a> became available on Android in February 2018. Fundamentally, these software development kits, or SDKs, allow an app to understand the environment around a user’s device and to place objects and information within it.</p><p>To parse the user’s environment, ARCore and ARKit use the device’s camera to identify distinct feature points in areas of high contrast, such as the corners of a table, and keep track of those points as the user moves their device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*JaGUcj7BX0IJNVvjZkm6JA.png" /></figure><p>As the device is moved, the feature points reposition within the camera frame and the change is used by the SDKs to infer how much the user has moved their device. This visual information is combined with motion data from the device’s sensors to estimate the<strong> </strong>position and orientation of the device camera over time — this is called pose.</p><p>Developers can use this information to align the pose of the real device camera with the pose of a virtual camera that renders 3D content. Because the rendered virtual content is aligned on top of the real camera image in each frame, it appears as if it is part of the real world around the user.</p><h3>Three Goals that Guided Our AR Development</h3><p>When we first started to explore how we wanted to support AR in our Android and iOS news apps, we identified three key goals:</p><ol><li>We wanted to support these experiences in our existing news application — we did not want to require our readers to install a companion app. This also meant that any dependencies we added would need to be minimal in order to keep the download size of our core app lightweight.</li><li>We wanted to be able to publish new experiences separate from the app release cycle, which happens every two weeks. We also wanted to make the app as agnostic to the content and flow of these experiences as possible, so that our colleagues in the newsroom would be able to craft unique and varied interactions across stories.</li><li>We wanted our colleagues in the newsroom to be able to author each story just once and have this same version run seamlessly on both Android and iOS platforms.</li></ol><p>These goals really came to define our options and as a result, we built the framework that we’re using today.</p><p>Our first goal to support AR experiences in our existing news application meant that we could not rely on common cross-platform rendering solutions like Unity or Unreal Engine since these frameworks could not be integrated into our existing native apps. We also had to turn down any solution that involved a large dependency which would add excessive bloat to our app download size.</p><p>In order to satisfy all three of these goals, we considered a number of different approaches before settling on one that worked.</p><h4>Native approach</h4><p>The first approach we considered is what I’ll call “the native approach.” In this approach, the complete AR experience — including all rendering and user interactions — is controlled by the native application.</p><p>Because the rendering is handled on the native side and there is no back and forth communication with the web side, the experience is synchronous, performant and responsive. However, we very quickly ran into some serious limitations to this approach.</p><p>The main the AR experience had to be baked in at build time. This meant that it failed to meet our second goal: to be able to publish new experiences with the news cycle, and independently of our app release cycle. It also failed to meet our third goal — to produce once and have it work across Android and iOS — since interactions would need to be pre-scripted and implemented separately for both platforms.</p><h4>Web rendering approach</h4><p>The second approach we looked at is what I’ll call “the web rendering approach” — WebAROnARCore and WebAROnARKit. In this approach,<a href="https://github.com/google-ar/three.ar.js/blob/master/webvr_ar_extension.md"> which is built as an extension to the existing WebVR browser API</a>, the device exposes AR data to the web page via a browser interface.</p><p>The native app is responsible for rendering the camera image, as well as sending important AR data to the web page, such as the current camera pose. The web page then uses WebGL to render all of the virtual content on top of the camera image, and it renders any of the virtual content that should be visible in the experience.</p><p>There are two advantages to this approach we really loved.</p><p>First, iOS and Android versions of the WebAROnARCore and WebAROnARKit projects adhere to the same interface. This means that our colleagues in the newsroom would be able to author each AR experience just once and it should behave the same on both platforms.</p><p>Second, since all of the virtual content rendering is handled by the web page, the newsroom can craft unique and varied AR experiences by simply creating a new web page rather than waiting on an app release. Each new experience does not need to adhere to a standard formula when it comes to how a scene will be rendered or how a user might interact with the virtual content.</p><p>However, we ultimately steered away from this approach for a couple of reasons.</p><p>Because the camera image is rendered by the native application on the GL rendering thread and the virtual content is rendered by the web page in its own thread, there is a mismatch in synchronicity between frames. This means that when the device moves around quickly it appears as if there is a slight drift between the real world camera image and the virtual content.</p><p>The Android implementation relies on an experimental Chromium fork that would need to be packaged with the APK in our app release. The dependency is quite large, meaning this would not meet our first goal to provide the AR experiences in our existing app without bloating the APK size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F30-gatwwGohe_cM-WDiGQ.jpeg" /><figcaption>Illustration by Jeremy Leung</figcaption></figure><h4>Hybrid approach</h4><p>The third, and final, approach we looked at is an approach I’ll call “the hybrid approach.”</p><p>In this approach, all of the rendering related to the AR experience — including rendering the camera image and the virtual 3D content — is handled by the native app while the content of the experience is delivered and controlled by a web page.</p><p>The visual experience is composed of two layers on the screen. The top layer is a web view that renders the web page that presents 2D content, such as text, and user controls. It has a transparent background, allowing the user to see through to a native layer below where the camera image and 3D virtual content are rendered.</p><p>The web page acts as a controller for the AR experience. It has a JavaScript interface that it uses to call through to the native layer, sending instructions about what virtual content to load, how to position it and how it should react to the user’s interactions. This means that the native app remains as agnostic as possible to the content and flow of each experience. It doesn’t care which or how many virtual models are being rendered, at what time they are placed or how they are positioned relative to the user.</p><p>Because the web page can be authored and delivered at any time, we can meet our goal of publishing new experiences along with the news cycle rather than the app release cycle. Since the JavaScript interface is implemented to control ARKit on iOS devices and ARCore on Android devices, the web page only needs to be authored once and will work similarly on both platforms.</p><h4>Scene graph</h4><p>Before I can talk about the hybrid interface between the web page and the native app, I need to do a quick detour to talk about scene graphs.</p><p>A scene graph is a common approach to managing data in a graphics engine. A scene graph is a tree made up of nodes that can each have as many children as they want — we call this an n-tree.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/0*aTWMxIfHevHYU68e" /><figcaption>A scene graph made up of nodes attached to a scene anchor.</figcaption></figure><p>All of the nodes in our scene descend from a single root node, which itself is attached to a scene anchor. This anchor tracks a real-world position across time, meaning that the virtual content rendered by the scene will appear fixed to a real-world point in the user’s space.</p><p>Each node has some information associated with it. In our case, it has:</p><ul><li>A unique identifier used to find or reference the node.</li><li>A position and rotation in three-dimensional space, i.e. a pose.</li><li>Information about what, if anything, to render.</li></ul><p>The native app uses the scene graph to understand how the 3D virtual content should be rendered. In our hybrid approach, we enable the web page to control details of the scene graph in order to create unique AR experiences across stories. We also enable the web page to perform managerial tasks like starting and stopping an AR session or loading and unloading the file resources required to render an experience.</p><h4>Commands and results</h4><p>To enable the web page to control the AR experience, we’ve created a command and result loop. Commands are created and issued by the web page. They’re passed to the native app through a Javascript interface on the containing web view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Al52hlyVxfXmuQGH" /><figcaption><em>Command and result loop between the web page and native app.</em></figcaption></figure><p>Any action that the web page wants to perform on the AR session or the scene graph is encoded as a command. Each command has a unique identifier, a type indicating the action to be performed and an optional map of values to configure the action. Commands are serialized to a JSON string that looks something like this:</p><pre>{<br>    “id”: 1011,<br>    “type”: “setNodeVisibility”,<br>    “options”: {<br>        “nodeId”: 25,<br>        “visible”: true<br>    }<br>}</pre><p>When a command is issued by the web page, it is added to a queue on the native app side. The app then processes the command and sends an asynchronous result message with the same identifier back to the web page. The result indicates whether or not the command was executed successfully and delivers an optional map of return values.</p><pre>{<br>    “id”: 1011,<br>    “success”: true,<br>    “values”: {}<br>}</pre><h4>Event listeners</h4><p>The command and result loop provides a mechanism for the web page to direct the flow of an AR experience, but how does the web page learn about events that happen spontaneously during the AR experience? This technology has to contend with constantly changing and potentially disruptive visual input. If a device’s camera is recording in a room with a table, the web page would want to know that the table is there so that virtual objects appear as if they were on top of it.</p><p>To notify the web page of events that occur during an AR experience, we added an event listener interface. Event listeners give the web page a way to listen for things that happen spontaneously within the experience. This saves the web page from constantly polling for certain events, such as when a table becomes visible and a new plane is detected on its surface where objects can be placed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QszstuciSu6DlN-b" /><figcaption><em>An event listener is added by the web page via a command and the app notifies the web page of subsequent relevant events.</em></figcaption></figure><p>Instead, it can set a <em>planeDetected</em> listener and be notified by the native app whenever a new plane is discovered.</p><p>Event listeners can be set by the web page on the native side with the addEventListener command. This command takes an option specifying the type of event it should listen for, and returns an ID as the result so that events from this listener can be identified in the future.</p><p>After the event listener has been added, it will notify the web page anytime the specified event has happened via the onEvent function on the web interface.</p><h4>Event structure</h4><p>Here’s an example of an event message. It indicates the type of event, the listener ID that it was sent from, and any additional data related to the event that the web page might care about.</p><pre>{<br>    “id”: 1,<br>    “data”: { <br>        “type”: “planeDetected”,<br>        “center”: {“x”: 20.1, “y”: 3.0, “z”: 1.5}, <br>        “extent”: {“x”: 1.0, “y”: 0.0, “z”: 1.0}<br>    }<br>}</pre><p>In this case, the event lets the web page know that a new plane of the specified extent has been detected at that center position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z84groI12DZ1MAHEZhIIvg.png" /></figure><p>By putting these components together, we’ve been able to deliver immersive, unique stories with AR content outside of our app release cycle.</p><p>These stories enable readers to interact with the news in new ways, like <a href="https://www.nytimes.com/interactive/2018/07/21/world/asia/thai-cave-rescue-ar-ul.html">stepping inside a Thai cave</a> to experience the real-world scale of the obstacles that rescuers faced in retrieving a soccer team and their coach earlier this summer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48c3731a4dbf" width="1" height="1" alt=""><hr><p><a href="https://open.nytimes.com/supporting-ar-experiences-in-new-york-times-mobile-apps-48c3731a4dbf">Supporting AR Experiences in the New York Times Android App</a> was originally published in <a href="https://open.nytimes.com/">NYT Open</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>