<?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 Lachlan Tweedie on Medium]]></title>
        <description><![CDATA[Stories by Lachlan Tweedie on Medium]]></description>
        <link>https://medium.com/@lachlantweedie?source=rss-cc653533278c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*3HNzFuwdx31JCE8AoVeY6w.jpeg</url>
            <title>Stories by Lachlan Tweedie on Medium</title>
            <link>https://medium.com/@lachlantweedie?source=rss-cc653533278c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 12:20:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lachlantweedie/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 setup Selenium, Nightwatch and Appium to work with Safari and iOS 10.3 & Xcode 8.3.3]]></title>
            <link>https://medium.com/@lachlantweedie/how-to-setup-selenium-nightwatch-and-appium-to-work-with-safari-and-ios-10-3-xcode-8-3-3-4f01541ed536?source=rss-cc653533278c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f01541ed536</guid>
            <category><![CDATA[nightwatchjs]]></category>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[automated-testing]]></category>
            <category><![CDATA[selenium-webdriver]]></category>
            <dc:creator><![CDATA[Lachlan Tweedie]]></dc:creator>
            <pubDate>Sun, 23 Jul 2017 00:09:33 GMT</pubDate>
            <atom:updated>2017-07-23T00:09:33.260Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently got up and running with a local automated testing environment using Selenium and Nightwatch but ran into a few issues while trying to get the Xcode simulator working. I thought I’d write this tutorial to hopefully help anyone running into the same problems.</p><p><strong>Prerequisites</strong></p><p>Make sure you have the following installed before continuing:</p><ul><li><a href="https://brew.sh/">Homebrew</a></li><li>Node</li><li>Xcode 8.3.3 (make sure to open at least once and let Xcode make some changes)</li></ul><h3>Safari</h3><p>This is the easy bit.</p><ol><li>Download the WebDriver named “SafariDriver.safariextz” selenium needs to automate tests on Safari. <a href="http://selenium-release.storage.googleapis.com/index.html?path=2.48%2F">http://selenium-release.storage.googleapis.com/index.html?path=2.48%2F</a></li><li>Make sure you have the developer menu enabled in Preferences &gt; Advanced &gt; Show develop in menu bar.</li><li>Enable automation in by clicking Develop (in menu bar) &gt; Allow Remote Automation.</li></ol><p>Done!</p><p>Update your nightwatch.json to include a Safari env like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/521ae3f4f1bb195f2982bfb6bcb39439/href">https://medium.com/media/521ae3f4f1bb195f2982bfb6bcb39439/href</a></iframe><p>And run your tests by passing the new environment:</p><pre>nightwatch -e safari</pre><h3>Appium, Xcode 8.3.3 &amp; iOS 10.3</h3><p>Okay, this is a bit tricker but let’s do it.</p><p><strong>Install appium-doctor</strong></p><p>Appium-doctor tells us what we need installed before we can start using Appium for our tests.</p><pre>npm install -g appium-doctor</pre><p>Let’s have a look and see what we need:</p><pre>appium-doctor -ios</pre><p>You should see a few things to install, don’t worry though, we’ll get there.</p><p>Start off by installing Carthage, a dependency manager for Cocoa.</p><pre>brew install carthage</pre><p>Make sure Xcode is pointing towards the developer directory:</p><pre>sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer</pre><p>Now we need to install and run a little utility called authorize-ios that pre-authorizes Instruments to run UIAutomation scripts against iOS devices.</p><pre>npm install -g authorize-ios<br>sudo authorize-ios</pre><p>Time to install Appium!</p><pre>npm -g install appium</pre><p>At this point if you run appium-doctor everything should be good to go.</p><p>Let’s get Appium up and running:</p><pre>appium &amp;; #start Appium</pre><p>Here’s an example of the ios env I’m using in my nightwatch.json:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/630b253ba046cc1243b189e634debfd9/href">https://medium.com/media/630b253ba046cc1243b189e634debfd9/href</a></iframe><blockquote>Make sure to have “automationName”: “XCUITest” in your config or Xcode 8.3.3 won’t work!</blockquote><p>And run it:</p><pre>nightwatch -e ios</pre><blockquote>It might timeout the first time you run it since the simulator takes a while to load.</blockquote><p>Done! Feel free to change and test different device names and browsers, or even create a different env for each one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f01541ed536" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Animation in Three.js using Tween.js with examples]]></title>
            <link>https://medium.com/@lachlantweedie/animation-in-three-js-using-tween-js-with-examples-c598a19b1263?source=rss-cc653533278c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c598a19b1263</guid>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[webgl]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[threejs]]></category>
            <dc:creator><![CDATA[Lachlan Tweedie]]></dc:creator>
            <pubDate>Sat, 26 Nov 2016 01:56:24 GMT</pubDate>
            <atom:updated>2016-11-26T01:56:24.302Z</atom:updated>
            <content:encoded><![CDATA[<p>There’s not very many articles explaining animation in Three.js and not many examples so I thought I’d give it a go. In this article I’ll help you animate objects position, rotation or scale, fade objects in and out, and tween custom variables in the render loop.</p><h3>Why Tween.js?</h3><p>Tween.js animates within the Three.js render loop. This improves overall performance of your WebGL application and helps keep a high frame rate.</p><p>It’s also good practice to never create new variables outside your init function (or however you initialise your project). Try to create all your target positions/rotations/scales at the start and reference them later on.</p><p>Another thing aim for is to not modify your variables outside the render loop. For example, if the user triggers an event to rotate a mesh 90 degrees, set a variable which the mesh will update to within the render loop. An alternative solution could be to use the below animation function with a duration of 0 seconds.</p><p>To use the examples below you’ll need to include and setup Tween.js in your project which you can find here: <a href="https://github.com/tweenjs/tween.js/">https://github.com/tweenjs/tween.js/</a></p><h3>Examples</h3><h4><strong>Animating a THREE.Vector3</strong></h4><p>Animating a Vector3 isn’t that hard since you can pass the Vector3 to a function and modify the x, y and z values directly. This function works nicely when you want to animate the position, rotation and/or scale of an object.</p><p>To use this function in an existing project just replace the variable “mesh” with your own object/mesh and pass the function the position, rotation or scale property.</p><pre>/* Animates a Vector3 to the target */</pre><pre>function animateVector3(vectorToAnimate, target, options){</pre><pre>    options = options || {};</pre><pre>    // get targets from options or set to defaults<br>    var to = target || THREE.Vector3(),<br>        easing = options.easing || TWEEN.Easing.Quadratic.In,<br>        duration = options.duration || 2000;</pre><pre>    // create the tween<br>    var tweenVector3 = new TWEEN.Tween(vectorToAnimate)<br>        .to({ x: to.x, y: to.y, z: to.z, }, duration)<br>        .easing(easing)<br>        .onUpdate(function(d) {<br>            if(options.update){ <br>                options.update(d);<br>            }<br>         })<br>        .onComplete(function(){<br>          if(options.callback) options.callback();<br>        });</pre><pre>    // start the tween<br>    tweenVector3.start();</pre><pre>    // return the tween in case we want to manipulate it later on<br>    return tweenVector3;</pre><pre>}</pre><pre>/* How to use */</pre><pre>var target = new THREE.Vector3(10, -20, 20); // create on init</pre><pre>animateVector3(mesh.position, target, {<br>    <br>    duration: 5000, <br>    <br>    easing : TWEEN.Easing.Quadratic.InOut,<br>    <br>    update: function(d) {<br>        console.log(&quot;Updating: &quot; + d);<br>    },<br>    <br>    callback : function(){<br>        console.log(&quot;Completed&quot;);<br>    }</pre><pre>});</pre><h4>Fading objects in and out</h4><p>Fading objects in and out is a bit trickier. This requires us to animate the opacity of an object’s material/s.</p><p>We also need to consider that the material’s opacity value might not always be at 1. For example, what if we have a window model that consists of 5 materials but the glass material has an original opacity of .4. For these cases we need to track the original opacities for each object.</p><p>To track the original opacities we’ll use the userData property on our mesh. This a good place to store custom data about our objects that we want to use later on in our project.</p><pre>/* Track original opacities */</pre><pre>function trackOriginalOpacities(mesh) {<br>    <br>    var opacities = [], <br>        materials = mesh.material.materials ? mesh.material.materials : [mesh.material];</pre><pre>    for (var i = 0; i &lt; materials.length; i++) {        </pre><pre>         materials[i].transparent = true;<br>         opacities.push(materials[i].opacity);</pre><pre>    }</pre><pre>    mesh.userData.originalOpacities = opacities;</pre><pre>}</pre><p>Next we want to tween the opacity of our objects material at a percentage between it’s original opacity and zero. The opacity will be applied in the the tween’s update function as a percentage between 0 and it’s original opacity.</p><pre>/* Fade mesh */</pre><pre>function fadeMesh(mesh, direction, options) {</pre><pre>    options = options || {};</pre><pre>    // set and check <br>    var current = { percentage : direction == &quot;in&quot; ? 1 : 0 },</pre><pre>    // this check is used to work with normal and multi materials.<br>    mats = mesh.material.materials ? <br>             mesh.material.materials : [mesh.material],<br> <br>     originals = mesh.userData.originalOpacities,<br>     easing = options.easing || TWEEN.Easing.Linear.None,<br>     duration = options.duration || 2000;</pre><pre>    // check to make sure originals exist<br>    if( !originals ) {<br>         console.error(&quot;Fade error: originalOpacities not defined, use trackOriginalOpacities&quot;);<br>          return;<br>    }</pre><pre>    // tween opacity back to originals<br>    var tweenOpacity = new TWEEN.Tween(current)<br>        .to({ percentage: direction == &quot;in&quot; ? 0 : 1 }, duration)<br>        .easing(easing)<br>        .onUpdate(function() {<br>             for (var i = 0; i &lt; mats.length; i++) {<br>                mats[i].opacity = originals[i] * current.percentage;<br>             }<br>         })<br>         .onComplete(function(){<br>              if(options.callback){<br>                   options.callback();<br>              }<br>         });</pre><pre>    tweenOpacity.start();</pre><pre>    return tweenOpacity;</pre><pre>}</pre><pre>/* How to use */</pre><pre>// fade in <br>fadeMesh(mesh, &quot;in&quot;);</pre><pre>// fade out <br>fadeMesh(mesh, &quot;out&quot;);</pre><pre>// fade with options<br>fadeMesh(mesh, &quot;in&quot;, {<br>    <br>    duration: 11000,<br>    <br>    easing: TWEEN.Easing.Quintic.InOut,<br>    <br>    callback : function (){<br>        console.log(&quot;Fade complete&quot;);<br>    }</pre><pre>});</pre><h4>Tweening custom variables</h4><p>You might find yourself in some cases where you need to animate something out of the ordinary but don’t want to write a custom animation function for it every time. In these situations we’ll pass the object and the variable that we want to manipulate.</p><pre>/* Tweening a custom variable */</pre><pre>function tweenCustomVar(obj, target, options) {</pre><pre>    options = options || {};</pre><pre>    var easing = options.easing || TWEEN.Easing.Linear.None,<br>        duration = options.duration || 2000,<br>        variable = options.variable || &#39;opacity&#39;,<br>        tweenTo = {};</pre><pre>    tweenTo[variable] = target; // set the custom variable to the target</pre><pre>    var tween = new TWEEN.Tween(obj)<br>        .to(tweenTo, duration)<br>        .easing(easing)<br>        .onUpdate(function(d) { <br>            if(options.update){ <br>                options.update(d);<br>            }<br>        })<br>        .onComplete(function(){<br>             if(options.callback) { <br>                 options.callback();<br>             }<br>        });</pre><pre>    tween.start();</pre><pre>    return tween;</pre><pre>}</pre><pre>/* How to use */</pre><pre>tweenCustomVar(obj, 100, {</pre><pre>    variable : &#39;loadingPercentage&#39;, // the variable we want to tween</pre><pre>    duration: 1000, </pre><pre>    easing : TWEEN.Easing.Exponential.In,</pre><pre>    update: function(d) {<br>        console.log(&quot;Updating: &quot; + d);<br>    },<br>    <br>    callback : function(){<br>        console.log(&quot;Completed&quot;);<br>    }</pre><pre>});</pre><h4>Where can you see these examples in action?</h4><p>I learned all of these by working on the <a href="http://dreamliner.qantas.com/">Qantas Dreamliner</a> website and thought I’d pass on some knowledge. Check it out and let me know what you think!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c598a19b1263" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>