<?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 Jan Crisologo on Medium]]></title>
        <description><![CDATA[Stories by Jan Crisologo on Medium]]></description>
        <link>https://medium.com/@rtql8d?source=rss-e7b08db4f060------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xDO3sZQBrFWWqM9y9knGig.jpeg</url>
            <title>Stories by Jan Crisologo on Medium</title>
            <link>https://medium.com/@rtql8d?source=rss-e7b08db4f060------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 21:23:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rtql8d/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[How to Change Textures on a Node in ARKit With Touch Gestures]]></title>
            <link>https://medium.com/better-programming/tutorial-how-to-change-textures-on-a-node-in-arkit-with-touch-gestures-72dba54aa6b1?source=rss-e7b08db4f060------2</link>
            <guid isPermaLink="false">https://medium.com/p/72dba54aa6b1</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[arkit]]></category>
            <category><![CDATA[ar]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Jan Crisologo]]></dc:creator>
            <pubDate>Mon, 03 Feb 2020 16:39:43 GMT</pubDate>
            <atom:updated>2020-02-05T17:23:43.151Z</atom:updated>
            <content:encoded><![CDATA[<h4>Give your new reality a new look</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ED9jz0WmIaxvZjz2" /><figcaption>Photo by <a href="https://unsplash.com/@pawel_czerwinski?utm_source=medium&amp;utm_medium=referral">Paweł Czerwiński</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Why, you ask yourself, would you want to change the texture on a node (a node is any object within a SceneKit scene)?</p><p>There are a variety of reasons. The simplest is you want an indication you’ve interacted with a node. Perhaps you have an AR game, and you want to give players feedback there’s a change in the game’s state. Maybe static textures get boring from time to time.</p><p>Whatever the reason is, I’m here to provide a simple tutorial on how to change the textures on a running ARKit app through touch gestures.</p><h3>Getting Started</h3><p>Start by creating a new project. Instead of implementing the ARSCNView and boilerplate from scratch, select Augmented Reality App as your template and make sure SceneKit is the selected Content Technology.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_8DCu6rfRdR9zlKSfrdhdw.png" /></figure><p>Before you start any code, we need to add some images for our project. For this specific app, I went with a solar system theme and gathered textures for Earth, the moon, and the sun.</p><p>That’s right — we’re going to be creating planetary bodies with our app. Make sure to name them earth, moon, and sun, respectively, and drop them directly into the Assets.xcassets folder.</p><p>In ViewController.swift, start by declaring the following variables just above the viewDidLoad() method:</p><pre>let textures = [&quot;earth&quot;, &quot;moon&quot;, &quot;sun&quot;]<br>var currentIndex = 0<br>var currentTexture = &quot;&quot;</pre><p>Make sure the strings in the textures array have the same exact names as the textures in your assets folder. Inside the viewDidLoad() method, replace where it says SCNScene(named: “art.scnassets/ship.scn”)! with SCNScene(). Underneath this line, initialize currentTexture with the first item in textures using currentTexture = textures[currentIndex].</p><p>After the viewWillDisappear() method, create the following function:</p><pre>func createSphere() -&gt; SCNNode {<br>  let sphere = SCNSphere(radius: 1)     <br>  sphere.firstMaterial?.diffuse.contents = UIImage(named:    <br>  currentTexture)<br>  let sphereNode = SCNNode(geometry: sphere)<br>  sphereNode.name = &quot;sphere&quot;<br>  sphereNode.position = SCNVector3(0, 0, -3)<br>  return sphereNode<br>}</pre><p>It goes without saying this function creates a sphere in our 3D space. We’re giving the sphere a radius of 1 meter (as per ARKit’s default unit of measurement) and assigning it the texture of currentTexture, which should be earth.</p><p>We’re then creating an SCNNode() and assigning its sphere’s geometry — as well as giving it the name sphere, which will be important when we go about changing textures. We’re then positioning it three meters away from the camera when the app starts and returning sphereNode.</p><p>In viewDidLoad(), add the following underneath where we assigned currentTexture:</p><pre>sceneView.scene.rootNode.addChildNode(createSphere())</pre><p>Test the app on your phone, and if all goes well, you should see an augmented reality Earth in front of your eyes.</p><h3>Tough Gestures</h3><p>Now we get to work on changing textures with a touch gesture. Underneath the createSphere() method, implement touchesBegan(_:with:)<em>. </em>Note that there are other ways to implement the touch gesture — this is just one of them. Add the following code inside touchesBegan:</p><pre>let touch = touches.first!</pre><pre>if touch.view == self.sceneView {<br>  let viewTouchLocation:CGPoint = touch.location(in: sceneView)<br>  <br>  guard let result = sceneView.hitTest(viewTouchLocation, options: nil).first else {<br>    return<br>  }</pre><pre>  if result.node.name == &quot;sphere&quot; {<br>    let node = result.node<br>    currentIndex = currentIndex == 0 ? 1 : currentIndex == 1 ? 2 : 0<br>    currentTexture = textures[currentIndex]<br>    node.geometry?.firstMaterial?.diffuse.contents = currentTexture<br>  }<br>}</pre><p>Let’s go over this codeblock.</p><p>First, we’re getting the first instance of a touch being detected.</p><p>Then, we’re making sure the touch is within the sceneView (if you’ve been following along, the sceneView should cover your phone’s entire screen by default because it automatically has zero margins on each side).</p><p>Then, we’re getting the CGPoint coordinates of the touch point relative to the screen.</p><p>Next, we’re making sure we’re triggering sceneView’s hitTest by assigning it to the result; otherwise, we return.</p><p>At this point, the code is free to check if we’re touching the node. If the name of the node that we’re touching is sphere (which we used earlier), then we need to change the texture of the sphere. Because I’ve only got three textures, I’m using a ternary operator to cycle currentIndex from 0 ➡ 1 ➡ 2, then back to 0. I then reassign the currentTexture. And, lastly, Iassign a new material to our node.</p><p>Whew! Run your code, and you should get this result when you touch the sphere:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Pf6yF9Oo9VDmClxM-F2ygg.gif" /><figcaption>The result</figcaption></figure><p>That’s all! I hope this gives you a starting point for changing textures in ARKit. Feel free to check out the full source code <a href="https://github.com/modium/ARKit-texture-tutorial">here</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fx1nysJkwSWs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dx1nysJkwSWs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fx1nysJkwSWs%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/753a53704f30a98c9c022fc0219e5cf0/href">https://medium.com/media/753a53704f30a98c9c022fc0219e5cf0/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72dba54aa6b1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/tutorial-how-to-change-textures-on-a-node-in-arkit-with-touch-gestures-72dba54aa6b1">How to Change Textures on a Node in ARKit With Touch Gestures</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Dynamically Populate a Year Dropdown With JavaScript]]></title>
            <link>https://medium.com/better-programming/how-to-dynamically-populate-a-year-dropdown-with-javascript-bcf4f849bc4f?source=rss-e7b08db4f060------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcf4f849bc4f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Jan Crisologo]]></dc:creator>
            <pubDate>Sun, 19 Jan 2020 23:15:29 GMT</pubDate>
            <atom:updated>2020-01-28T02:07:37.343Z</atom:updated>
            <content:encoded><![CDATA[<h4>Remove hardcoded boilerplate</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P7uw2a0sx5INM-uK" /><figcaption>Photo by <a href="https://unsplash.com/@romanbozhko?utm_source=medium&amp;utm_medium=referral">Roman Bozhko</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Does your web app need a dropdown with selectable years? Instead of hardcoding all of those years, here’s a quick and easy way to dynamically populate it with a range of years (of your own choosing, of course) using JavaScript.</p><p>Because this is a very basic example, we’re going to be using a simple HTML boilerplate as a starting point.</p><p>In fact, I’m using what Emmet automatically outputs when you type an exclamation mark (!). <a href="https://atom.io/packages/emmet">Emmet</a>, by the way, is an awesome, awesome plugin for front-end developers that I highly recommend and is available for most code editors.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9f2d40bf1fb6f2a3ce17040bbae8b83/href">https://medium.com/media/f9f2d40bf1fb6f2a3ce17040bbae8b83/href</a></iframe><p>Next, type out opening and closing select tags within the body tags and give it a descriptive ID. For this example, I’m just using date-dropdown.</p><pre>&lt;select id=&#39;date-dropdown&#39;&gt;<br>&lt;/select&gt;</pre><p>Underneath your select tags, add opening and closing script tags. Within those script tags, add the following code (it’ll be much easier to explain what’s happening when you see it).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8927977031f6d35d18244f130e21f604/href">https://medium.com/media/8927977031f6d35d18244f130e21f604/href</a></iframe><p>First, we’re locating our date dropdown by finding the element we gave the ID of date-dropdown.</p><p>Next, we’re getting the current year (as of this writing, 2020) as well as declaring how far back we want to populate our dropdown, which in this example is 1970.</p><p>Afterward, we’re going to be using a while loop, which, for every iteration, an option tag is being created and assigned the text and value of a year before being added to the select dropdown.</p><p>This will continually add years to the dropdown until currentYear is <em>less than or equal to</em> earliestYear, because we’re decrementing currentYear by 1 after every loop.</p><p>This is what the final example looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yG7op66q0iXg-zYeYmpXCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Vh4OZxYj46W9gOIK_kCaw.png" /></figure><p>There you have it, dynamically populated year drop-downs!</p><p>You can also repurpose the currentYear variable to dynamically set a copyright (©) year on a web page’s footer instead of having to change it every year!</p><p>Here’s the full example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5cf57d50be61c06600df699c1a2142e/href">https://medium.com/media/d5cf57d50be61c06600df699c1a2142e/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcf4f849bc4f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/how-to-dynamically-populate-a-year-dropdown-with-javascript-bcf4f849bc4f">How to Dynamically Populate a Year Dropdown With JavaScript</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Use GIFs with ARKit]]></title>
            <link>https://medium.com/better-programming/how-to-use-gifs-with-arkit-tutorial-610e4c1602da?source=rss-e7b08db4f060------2</link>
            <guid isPermaLink="false">https://medium.com/p/610e4c1602da</guid>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[arkit]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Jan Crisologo]]></dc:creator>
            <pubDate>Sun, 15 Dec 2019 01:14:44 GMT</pubDate>
            <atom:updated>2019-12-17T15:51:27.788Z</atom:updated>
            <content:encoded><![CDATA[<h3>How To Use GIFs With ARKit</h3><h4>3D gets a lot of love, but what about using 2D in ARKit?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CSNPvKtRuH2aF7Yo" /><figcaption>Photo by <a href="https://unsplash.com/@patrick_schneider?utm_source=medium&amp;utm_medium=referral">Patrick Schneider</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve noticed a distinct lack of tutorials for implementing GIFs with Apple’s ARKit platform. I think it’s because people are more interested in the 3D side of AR than the 2D side, but I believe 2D has some interesting use-cases.</p><p>What’s the key to implementing GIFs in ARKit? Unfortunately, it’s not as simple as applying a GIF file as material on a node because the animation won’t play. Luckily, someone’s created an extension for UIImage that you can simply add to your project in order to play GIFs.</p><p>Let’s start by creating a new project in Xcode. Some people prefer starting from a single view app, but here we’ll create an augmented reality app. Make sure Content Technology is set to SceneKit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NWKQlUsIhhUz3izyQzIuRw.png" /></figure><p>If you start from the Augmented Reality template, <strong>info.plist</strong> will automatically have Privacy — Camera Usage Description filled out. This is important because all new ARKit projects require the user’s permission to use the phone’s camera. Now we need that UIImage extension. The folks over at iOS Dev Centers created an awesome <a href="https://github.com/kiritmodi2702/GIF-Swift/blob/master/GIF-Swift/iOSDevCenters%2BGIF.swift">extension that plays well with ARKit</a>. Simply create a new Swift file in your project and drop the code in there:</p><pre>//<br>//  iOSDevCenters+GIF.swift<br>//  GIF-Swift<br>//<br>//  Created by iOSDevCenters on 11/12/15.<br>//  Copyright © 2016 iOSDevCenters. All rights reserved.<br>//<br>import UIKit<br>import ImageIO<br>// FIXME: comparison operators with optionals were removed from the Swift Standard Libary.<br>// Consider refactoring the code to use the non-optional operators.<br>fileprivate func &lt; &lt;T : Comparable&gt;(lhs: T?, rhs: T?) -&gt; Bool {<br>  switch (lhs, rhs) {<br>  case let (l?, r?):<br>    return l &lt; r<br>  case (nil, _?):<br>    return true<br>  default:<br>    return false<br>  }<br>}<br><br><br><br>extension UIImage {<br>    <br>    public class func gifImageWithData(_ data: Data) -&gt; UIImage? {<br>        guard let source = CGImageSourceCreateWithData(data as CFData, nil) else {<br>            print(&quot;image doesn&#39;t exist&quot;)<br>            return nil<br>        }<br>        <br>        return UIImage.animatedImageWithSource(source)<br>    }<br>    <br>    public class func gifImageWithURL(_ gifUrl:String) -&gt; UIImage? {<br>        guard let bundleURL:URL? = URL(string: gifUrl)<br>            else {<br>                print(&quot;image named \&quot;\(gifUrl)\&quot; doesn&#39;t exist&quot;)<br>                return nil<br>        }<br>        guard let imageData = try? Data(contentsOf: bundleURL!) else {<br>            print(&quot;image named \&quot;\(gifUrl)\&quot; into NSData&quot;)<br>            return nil<br>        }<br>        <br>        return gifImageWithData(imageData)<br>    }<br>    <br>    public class func gifImageWithName(_ name: String) -&gt; UIImage? {<br>        guard let bundleURL = Bundle.main<br>            .url(/service/forresource: name, withExtension: &quot;gif&quot;) else {<br>                print(&quot;SwiftGif: This image named \&quot;\(name)\&quot; does not exist&quot;)<br>                return nil<br>        }<br>        guard let imageData = try? Data(contentsOf: bundleURL) else {<br>            print(&quot;SwiftGif: Cannot turn image named \&quot;\(name)\&quot; into NSData&quot;)<br>            return nil<br>        }<br>        <br>        return gifImageWithData(imageData)<br>    }<br>    <br>    class func delayForImageAtIndex(_ index: Int, source: CGImageSource!) -&gt; Double {<br>        var delay = 0.1<br>        <br>        let cfProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil)<br>        let gifProperties: CFDictionary = unsafeBitCast(<br>            CFDictionaryGetValue(cfProperties,<br>                Unmanaged.passUnretained(kCGImagePropertyGIFDictionary).toOpaque()),<br>            to: CFDictionary.self)<br>        <br>        var delayObject: AnyObject = unsafeBitCast(<br>            CFDictionaryGetValue(gifProperties,<br>                Unmanaged.passUnretained(kCGImagePropertyGIFUnclampedDelayTime).toOpaque()),<br>            to: AnyObject.self)<br>        if delayObject.doubleValue == 0 {<br>            delayObject = unsafeBitCast(CFDictionaryGetValue(gifProperties,<br>                Unmanaged.passUnretained(kCGImagePropertyGIFDelayTime).toOpaque()), to: AnyObject.self)<br>        }<br>        <br>        delay = delayObject as! Double<br>        <br>        if delay &lt; 0.1 {<br>            delay = 0.1<br>        }<br>        <br>        return delay<br>    }<br>    <br>    class func gcdForPair(_ a: Int?, _ b: Int?) -&gt; Int {<br>        var a = a<br>        var b = b<br>        if b == nil || a == nil {<br>            if b != nil {<br>                return b!<br>            } else if a != nil {<br>                return a!<br>            } else {<br>                return 0<br>            }<br>        }<br>        <br>        if a &lt; b {<br>            let c = a<br>            a = b<br>            b = c<br>        }<br>        <br>        var rest: Int<br>        while true {<br>            rest = a! % b!<br>            <br>            if rest == 0 {<br>                return b!<br>            } else {<br>                a = b<br>                b = rest<br>            }<br>        }<br>    }<br>    <br>    class func gcdForArray(_ array: Array&lt;Int&gt;) -&gt; Int {<br>        if array.isEmpty {<br>            return 1<br>        }<br>        <br>        var gcd = array[0]<br>        <br>        for val in array {<br>            gcd = UIImage.gcdForPair(val, gcd)<br>        }<br>        <br>        return gcd<br>    }<br>    <br>    class func animatedImageWithSource(_ source: CGImageSource) -&gt; UIImage? {<br>        let count = CGImageSourceGetCount(source)<br>        var images = [CGImage]()<br>        var delays = [Int]()<br>        <br>        for i in 0..&lt;count {<br>            if let image = CGImageSourceCreateImageAtIndex(source, i, nil) {<br>                images.append(image)<br>            }<br>            <br>            let delaySeconds = UIImage.delayForImageAtIndex(Int(i),<br>                source: source)<br>            delays.append(Int(delaySeconds * 1000.0)) // Seconds to ms<br>        }<br>        <br>        let duration: Int = {<br>            var sum = 0<br>            <br>            for val: Int in delays {<br>                sum += val<br>            }<br>            <br>            return sum<br>        }()<br>        <br>        let gcd = gcdForArray(delays)<br>        var frames = [UIImage]()<br>        <br>        var frame: UIImage<br>        var frameCount: Int<br>        for i in 0..&lt;count {<br>            frame = UIImage(cgImage: images[Int(i)])<br>            frameCount = Int(delays[Int(i)] / gcd)<br>            <br>            for _ in 0..&lt;frameCount {<br>                frames.append(frame)<br>            }<br>        }<br>        <br>        let animation = UIImage.animatedImage(with: frames,<br>            duration: Double(duration) / 1000.0)<br>        <br>        return animation<br>    }<br>}</pre><p>Next, find your GIF of choice and drag it into your project (make sure it’s in the root folder and not the Assets.xcassets folder). When prompted, make sure that “Copy items as needed” is checked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d8Nb-DzL3i13ybywydHhVw.png" /></figure><p>Now we’re ready to do some coding. In viewDidLoad(), replace the default scene that all ARKit templates start with (the one called “art.scnassets/ship.scn”) with this:</p><pre>let scene = SCNScene()</pre><p>Next, create a function called addGif() that takes in a string for the name of the GIF you added to your project and will return a SCNNode.</p><pre>func addGIF(name: String) -&gt; SCNNode {<br>  let gifNode = SCNNode()<br> <br>  return gifNode<br>}</pre><p>Because the function is expecting to return a SCNNode, we created a node called gifNode which we return at the end of the function. Now we’ll apply our GIF to it with the help of the UIImage extension we imported earlier:</p><pre>func addGIF(name: String) -&gt; SCNNode {<br>  let gifNode = SCNNode()</pre><pre>  let gifPlane = SCNPlane(width: 1, height: 1)  <br>  let gifImage = UIImage.gifImageWithName(name)<br>  let gifImageView = UIImageView(image: gifImage)    <br>  gifPlane.firstMaterial?.diffuse.contents = gifImageView</pre><pre>  gifNode.geometry = gifPlane<br>  gifNode.position = SCNVector3(0, 0, -1)<br>  <br>  return gifNode<br>}</pre><p>What’s happening here? Firstly, we’re creating a SCNPlane with a width and a height of 1 meter (ARKit uses meters). Next, we’re creating a UIImage with the name of our GIF, which is then supplied to gifImageView. We then apply gifImageView as a material to gifPlane. In turn, we assign gifNode<em>’s </em>geometry to be that of gifPlane. Lastly, we position it -1 on the Z-axis: One meter from where we first open our app. ARKit axes are beyond the scope of this tutorial — I recommend reading <a href="https://www.raywenderlich.com/378-augmented-reality-and-arkit-tutorial">this article</a> for a better idea of how it works.</p><p>We need to do one more thing before we can see our GIF in action: Call it with our viewDidLoad() method.</p><pre>override func viewDidLoad() {<br>  super.viewDidLoad()<br>  . . .<br>  sceneView.scene = scene</pre><pre>  sceneView.scene.rootNode.addChildNode(addGIF(name: &quot;giraffe&quot;))<br>}</pre><p>Compile your code and run your app. Awesome! You’ve just created your first ARKit app with GIFs (hopefully!)</p><p>Feel free to check out the <a href="https://github.com/modium/ARKit-GIF-tutorial">finished code</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fo4cTA-J8RGs%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Do4cTA-J8RGs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fo4cTA-J8RGs%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c079c1830a6dec65780bd3b351a7a367/href">https://medium.com/media/c079c1830a6dec65780bd3b351a7a367/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-rQRW3uETfM%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-rQRW3uETfM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-rQRW3uETfM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/eca9d8335825c5c31c2ad4088be9ef7b/href">https://medium.com/media/eca9d8335825c5c31c2ad4088be9ef7b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=610e4c1602da" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/how-to-use-gifs-with-arkit-tutorial-610e4c1602da">How To Use GIFs with ARKit</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[sneakAR — How AR can boost fashion experiences]]></title>
            <link>https://medium.com/@rtql8d/sneakar-how-ar-can-boost-fashion-experiences-4cab8e72fbe4?source=rss-e7b08db4f060------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cab8e72fbe4</guid>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[future]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[virtual-reality]]></category>
            <dc:creator><![CDATA[Jan Crisologo]]></dc:creator>
            <pubDate>Fri, 25 May 2018 23:54:56 GMT</pubDate>
            <atom:updated>2019-02-15T03:14:13.494Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ynlXPppbXqQZd9Bs1y3q5A.png" /></figure><p>I coded a conceptual augmented reality app for iPhone called sneakAR (it’s really just “sneaker”). It’s the culmination of my newfound obsession with AR. I’ve been making iOS apps on the side for a couple of years now but it was ARKit that really opened my eyes to the potential of augmented reality. I got the idea from an article in a technology magazine talking about practical uses for AR. The crux of the app’s concept is this: what if there was a way for users to visually inspect sneakers and even interact with them, albeit simplistically, in AR before they made their purchase?</p><p>This is how the app works. ARKit first needs a brief moment to detect worldly “feature points”. Once it’s ready, users tap on a surface to place an AR sneaker on it. Users can then change the sizing of the shoes and select other sneakers via the scrollbar. They can also cycle through a shoe’s colorways by tapping on the shoe itself, provided the shoe has other colors. By planting it on a surface, users can compare a virtual shoe with other shoes, see if it works with their wardrobe, etc. Once they’ve found a shoe they’d like to buy, tapping and holding on to the sneaker will take users to an online store for purchase.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F_KZwUYryhiA%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_KZwUYryhiA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F_KZwUYryhiA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb39f1f823dadd8aca5f858796050b0b/href">https://medium.com/media/fb39f1f823dadd8aca5f858796050b0b/href</a></iframe><p>This obviously wouldn’t work without realistic-looking assets. For the sneakers themselves, I either found some 3D models online or used a technique called photogrammetry with my own collection. I avoided perfectly modelled shoes from asset stores and opted for as much a worn-in look as possible. After lots of trial and error (the process is imprecise and finicky) I got some realistic-looking sneakers rendered in 3D. I fixed the sneakers’ meshes with Blender, cleaned/made new textures in Photoshop and imported the shoes into Xcode. I coded the app itself purely in Swift, but I would love to try remaking it in Unity in the future in order to make an Android counterpart.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fx1nysJkwSWs%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dx1nysJkwSWs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fx1nysJkwSWs%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/98782ad65127d648d6089ffcd8496412/href">https://medium.com/media/98782ad65127d648d6089ffcd8496412/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKw0jSzNOj9I%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKw0jSzNOj9I&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKw0jSzNOj9I%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a86f3b636eabcb13ad4bb8818328044/href">https://medium.com/media/6a86f3b636eabcb13ad4bb8818328044/href</a></iframe><p>The next part is a brief technical report so feel free to skip it.</p><p>-Textures are loaded from a Firebase server. Essentially, you can have an unlimited amount of textures because you’re not limited by your phone’s storage, and colorways are automatically updated as they’re released. This is super useful for shoes that are constantly getting new colorways (e.g. Air Jordan 1s, Yeezy Boost 350s). Also, if I split textures based on components, like shoelaces and soles, there’s a potential for users to customize their own footwear.</p><p>-Models, however, are stored within the app. This makes the app heavier in size. The ideal is to “stream” 3D models into the user’s phone the way Netflix streams content in a user-friendly manner. As an experiment I had the app download temporarily hosted models from a server successfully, but found that some models took too long to download (even with a visual indicator it was a bad user experience). I have to find a way to balance decreasing the app size without hindering UX, like reducing model complexity, downloading models in the background, etc.</p><p>-ARKit only accepts .dae (Collada) and .scn files for 3D models. All models had to be converted as such before importing into Xcode. For the model downloading experiment I had to convert them all to .scn files.</p><p>-I might incorporate a way to rotate, transform and even flip shoes with gestures. Currently there’s no way I know of in ARKit to mirror 3D models programmatically and even then the ruse would instantly be over when users see a backwards logo (the solution is to scan the other shoe but if I did this for every shoe the app is now twice its original size).</p><p>-I’m a big analytics fan. It could be useful gathering demographic information like most purchased size, most popular colorway/model, etc. for shoe brands. The extra element of interactivity with this kind of app certainly lends itself to gathering useful data.</p><p>-In the future there would be a dedicated API handling everything; the app itself would essentially just be a vessel for holding user preferences (e.g. foot size, favorite colors) and a UI for interacting with a server — no shoe models or textures stored in the app to make it as lightweight as possible.</p><p>-Next step is to train a neural network to segment feet so that users can “wear” the sneakers!</p><p>That’s all for my very first Medium story! If you have any cool ideas (AR or not) or just want to talk shop, you can find me on Twitter or Instagram @rtql8d (“articulated” 😉) or email me at jan.b.crisologo@gmail.com.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cab8e72fbe4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>