<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Labs Blog</title>
	<atom:link href="http://labs.jam3.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.jam3.ca</link>
	<description></description>
	<lastBuildDate>Tue, 06 Mar 2012 15:37:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Extending Air</title>
		<link>http://labs.jam3.ca/extending-air/</link>
		<comments>http://labs.jam3.ca/extending-air/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 06:47:40 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[native extension]]></category>

		<guid isPermaLink="false">http://labs.jam3.ca/?p=1122</guid>
		<description><![CDATA[WHAT IS A NATIVE EXTENSION? One of the great new features of AIR 3.0 is native extensions. These extensions allow you to build hooks into &#8230;</div><div class="clear"><!-- --></div><div class="divider_line_white_s_r"></div><div class="viewfullpost"><a href="http://labs.jam3.ca/extending-air/"><img alt="" src="http://labs.jam3.ca/wp-content/themes/Labs_blog/images/manu_img.jpg">View Full Post</a></div>]]></description>
	
	
		
	
			<content:encoded><![CDATA[  <img src="http://labs.jam3.ca/wp-content/uploads/2012/03/adobe_Air-206x114.jpg" class="post_banner"/>  <p><strong>WHAT IS A NATIVE EXTENSION?</strong></p>
<p>One of the great new features of AIR 3.0 is native extensions. These extensions allow you to build hooks into the native OS that lets you do some things that AIR doesn&#8217;t support on its own. One of the best things about AIR is the fact that it can run on so many platforms, E.G. Android, IOS and the Playbook. However, one drawback to this is that AIR must cater to the lowest common denominator and cannot really focus on device specific features. This is where the native extensions come in. They let you write code native to the device that can tap into the cool features that make each device unique. This means, for iOS you would write the extension in Objective C. For Android you could write it in Java. On Android, this could let you push things to the notification drawer and maybe on a Blackberry you could get access to BBM messages and features. You can find a great tutorial for building your own AIR native extensions for Android at <a href="http://www.adobe.com/devnet/air/articles/developing-native-extensions-air.html">Adobe</a>.</p>
<p><span id="more-1122"></span><br />
<strong>NOT ALL SUNSHINE AND LEMONADE:</strong></p>
<p>The work flow for building your own native extensions isn&#8217;t too bad but there are a few caveats. Right now there aren&#8217;t really tools for packaging your extensions so you need to know a little bit about the command line and building bat files. The other half of this is that the packaging errors can be a little cryptic so be prepared to spend a lot of time googling random phrases and hoping someone else had the same error as you before.</p>
<p>For example, one of the issues I had was with signing my extension. ADT was attempting to generate a time stamp but it kept failing giving me this error: &#8220;Could not generate timestamp: handshake alert: unrecognized_name&#8221;. The solution was to include &#8220;-tsa none&#8221; as a -package option in my package.bat.</p>
<p>A second issue was with adt.bat. This bat file executes \lib\adt.jar however on my computer it was pointing to the wrong path when my package.bat tried to run it. The solution was to hard code the path to the jar file rather than use the aliases.</p>
<p>When you&#8217;re invoking the native code in AIR and there&#8217;s an error, the AIR debugger doesn&#8217;t really know how to deal with that. It can be difficult and downright frustrating to debug something when you&#8217;re not sure where its failing.</p>
<p>Lastly, like I mentioned before, one of the best reasons to use AIR is the fact that its cross platform compatible. By their very nature, native extensions are not. However, there are still use cases where you could build something in AIR but use a native extension if the OS had a better implementation. It was this last case that lead me to create a native extension for accessing the sharing API in Android.</p>
<p><strong>ShareExt: AN EXTENSION FOR NATIVE ANDROID SHARING</strong></p>
<p>There are several Actionscript libraries out there for building in links to Facebook, Twitter, Flickr etc&#8230; in order to share your content but one of the cool features of Android is that it has a standardized API for this. So if I&#8217;m deploying to Android why not use something that the users will already be familiar with? With this in mind, I built a native extension for accessing the share functionality in Android from AIR. I won&#8217;t say that its fully featured and functional but it handles sharing most mime types. You can pass it an image, video, audio or other file and it will do its best to share with the right tools. It also supports sharing straight text. I built a really basic AIR app that you can side load on your Android device to try it out. The app uses the built in AIR API for file browsing to find a file to share but when it launches the list of sharing apps that&#8217;s all Android, baby. Click <a href="http://jam3media.com/blogFiles/ShareApp.apk">here</a> to download. If you visit the link on your device it should download and let you install it pretty easily.</p>
<p>You can find the source code for the native extension and the example app on <a href="https://github.com/Jam3/AndroidShareANE">github</a> if you&#8217;d like to play around with it. The folder &#8216;extension&#8217; houses the two halves of the extension. The folder &#8216;shareAirExt&#8217; has the code for the Actionscript part of the extension while the &#8216;shareJavaExt&#8217; has the Java portion. I&#8217;ve also included my .bat file. Its mainly taken from the tutorial I&#8217;ve linked above but it might be useful to have a working reference.</p>
<p>Once you&#8217;ve built the native extension, using it in Actionscript is a breeze. It acts just like any other object from a SWC or library.</p>
<p><code>/*<br />
Instantiate our Native Extension and share our file with the native extension.<br />
*/<br />
share = new ShareExt();<br />
share.shareMedia(file.name,file.nativePath, mimeType);</code></p>
<p><strong>WHATS OUT THERE NOW:</strong></p>
<p>Native extensions are the hot new thing right now and developers have only just started to scratch the surface of what can be done. At <a href="http://www.gotoandlearn.com/play.php?id=148">gotoAndLearn()</a>, Lee Brimelow talks about building a native extension for pushing to the notification drawer on Android.</p>
<p><a href="http://custardbelly.com/blog/2011/09/21/air-native-extension-example-ibattery-for-ios/">This example</a>, from Todd Anderson, shows how you can build a native extension to get battery information on iOS.</p>
<p>At <a href="http://www.as3nui.com/air-kinect/">as3NUI</a> they have built a native extension for using the Microsoft X-Box Kinect in AIR. This is coolest thing yet and really shows the power of native extensions in AIR. AIR and Actionscript is already a great environment for making games so hopefully, with this great new extension, we can start seeing some Kinect games and installations built in AIR.</p>
<p>Speaking of games <a href="http://www.milkmangames.com">Milkman Games</a> has built a iOS native extension for using <a href="http://www.milkmangames.com/blog/2011/11/20/announcing-native-ios-game-center-for-adobe-air/">Game Center</a> in your AIR apps. This should mean a more unified experience of AIR apps on iOS.</p>
<p>This is only the beginning and I, for one, am excited to see what comes next.</p>
<p><strong>UPDATE ON JAN 5th, 2011:</strong></p>
<p>I committed a packaged version of the ANE file to the github repo. You can find the repo <a href="https://github.com/Jam3/AndroidShareANE">here</a>. Or, if you&#8217;d prefer, you can download the ANE file directly by clicking <a href="http://jam3media.com/blogFiles/ShareANE.ane">here</a>.</p>
]]></content:encoded>
	





		<wfw:commentRss>http://labs.jam3.ca/extending-air/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unity3D Let The Fun Begin</title>
		<link>http://labs.jam3.ca/unity3d-let-the-fun-begin/</link>
		<comments>http://labs.jam3.ca/unity3d-let-the-fun-begin/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 15:28:27 +0000</pubDate>
		<dc:creator>Mikko</dc:creator>
				<category><![CDATA[Unity3D]]></category>

		<guid isPermaLink="false">http://labs.jam3.ca/?p=1057</guid>
		<description><![CDATA[The first time you open up Unity3D it might be SUPER intimidating. You have an entire 3d &#8220;modeler&#8221; in front of you and you think &#8230;</div><div class="clear"><!-- --></div><div class="divider_line_white_s_r"></div><div class="viewfullpost"><a href="http://labs.jam3.ca/unity3d-let-the-fun-begin/"><img alt="" src="http://labs.jam3.ca/wp-content/themes/Labs_blog/images/manu_img.jpg">View Full Post</a></div>]]></description>
	
	
		
	
			<content:encoded><![CDATA[  <img src="http://labs.jam3.ca/wp-content/uploads/2011/10/unity3d1-206x114.jpg" class="post_banner"/>  <p>The first time you open up Unity3D it might be SUPER intimidating. You have an entire 3d &#8220;modeler&#8221; in front of you and you think &#8220;where do I go from here?&#8221;.</p>
<p>So you&#8217;ve watched some <a href="http://unity3d.com/support/documentation/video/" target="_blank">videos on Unity&#8217;s site</a> and you have sort of a grasp on creating scenes.</p>
<p>But now&#8230; It&#8217;s time&#8230; To code! Where do you even begin?<br />
<span id="more-1057"></span><br />
About a half a year ago or so I ended up having to jump into the wonderful world of Unity3D. I literally went through the path of looking at all the <a href="http://unity3d.com/support/" target="_blank">resources</a> and <a href="http://unity3d.com/support/documentation/video/" target="_blank">video tutorials</a> on the Unity site. By looking at the <a href="http://unity3d.com/support/resources/tutorials/">tutorials</a> and <a href="http://unity3d.com/support/resources/example-projects/" target="_blank">example projects</a> you&#8217;ll get a really good grasp of how to make things in Unity.</p>
<p>There&#8217;s one thing that was a bit confusing, even after looking at all those resources I mentioned above, and that was the architecture of the Unity3D libraries.</p>
<p>I think the biggest confusion could be if you&#8217;re coming from a typical Object Oriented work environment the Unity environment can be a bit odd.</p>
<p>Let&#8217;s for instance create an &#8220;animal&#8221; in a regular OOP environment.</p>
<p>You&#8217;d make a base animal class and add functions that represent behaviour of the animal. For instance the functions could be: walk, eat, and poop.</p>
<p><img class="alignnone size-full wp-image-1079" title="Base Animal" src="http://labs.jam3.ca/wp-content/uploads/2011/10/baseAnimal.jpg" alt="" width="537" height="332" /></p>
<p>In unity however it&#8217;s preferred that you create a &#8220;behaviour&#8221; class and add it to the animal. So your behaviour class would have functions like: walk, eat, and poop.</p>
<p>So here&#8217;s where it gets interesting&#8230;</p>
<p>In As3 and other oop languages you would extend animal to create a new animal. For instance if we wanted to create a Dragon object we&#8217;d extend our Animal class which has the functions for walk, eat, and poop. After that we&#8217;d write a new function breatheFire to the dragon class. So we&#8217;re good to go we have a dragon.</p>
<p><img class="alignnone size-full wp-image-1086" title="Extended Dragon" src="http://labs.jam3.ca/wp-content/uploads/2011/10/extendedDragon1.jpg" alt="" width="537" height="495" /></p>
<p>Like I stated above in Unity you&#8217;re encouraged to create behaviours more and add them to objects. So what we&#8217;d do is keep the basic animal behaviour: walk, eat, and poop separate from the breatheFire behaviour. So we&#8217;d have two classes AnimalBehaviour which has the basic animal functions and another class FireBreatheBehaviour which is separate from AnimalBehaviour. When we have those two behaviours we can drop them both onto our dragon object and we have a dragon.</p>
<p><img class="alignnone size-full wp-image-1087" title="unityDragon" src="http://labs.jam3.ca/wp-content/uploads/2011/10/unityDragon1.jpg" alt="" width="537" height="242" /></p>
<p>So you might be saying at this point what&#8217;s the difference? Well let&#8217;s say we had another animal the good ol domestic cow. However we want this cow to be able to breathe fire. Well in As3 what we&#8217;d have to do is recreate the breatheFire function in the cow class and most likely it would be the same as the function in the Dragon class. It&#8217;s a huge waste having to do this type of thing. Why would you code the same thing twice?</p>
<p><img class="alignnone size-full wp-image-1088" title="extendedCow" src="http://labs.jam3.ca/wp-content/uploads/2011/10/extendedCow1.jpg" alt="" width="537" height="495" /></p>
<p>In unity if you want to create a fire breathing cow all you&#8217;d need to do is drop the breatheFire behaviour onto the cow in the same way as the dragon.</p>
<p><img class="alignnone size-full wp-image-1089" title="unityCow" src="http://labs.jam3.ca/wp-content/uploads/2011/10/unityCow1.jpg" alt="" width="537" height="247" /></p>
<p>Of course the way Unity works has some flaws. For instance if you were creating very unique behaviours they can&#8217;t be applied to EVERYTHING. However overall because of this architecture decision it makes coding for Unity very very enjoyable. Not to mention the fact that you can choose which language you will code in. (C#, Javascript, Boo)</p>
]]></content:encoded>
	





		<wfw:commentRss>http://labs.jam3.ca/unity3d-let-the-fun-begin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zip Through The Load</title>
		<link>http://labs.jam3.ca/zip-through-the-load/</link>
		<comments>http://labs.jam3.ca/zip-through-the-load/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 09:00:58 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://labs.jam3.ca/?p=1012</guid>
		<description><![CDATA[Load times are a Flash Developer&#8217;s nemesis. Even today with download speeds measured in megabits per second, a good developer has to be wary of &#8230;</div><div class="clear"><!-- --></div><div class="divider_line_white_s_r"></div><div class="viewfullpost"><a href="http://labs.jam3.ca/zip-through-the-load/"><img alt="" src="http://labs.jam3.ca/wp-content/themes/Labs_blog/images/manu_img.jpg">View Full Post</a></div>]]></description>
	
	
		
	
			<content:encoded><![CDATA[  <img src="http://labs.jam3.ca/wp-content/uploads/2011/10/the_load-206x114.jpg" class="post_banner"/>  <p>Load times are a Flash Developer&#8217;s nemesis. Even today with download speeds measured in megabits per second, a good developer has to be wary of how slow things are loading. A popular way of speeding up load times are to use a CDN like Cachefly or Amazon. However, these services do cost money and often charge by bandwidth used. An alternative way to speed up loading is to compress your files into a zip file.<br />
<span id="more-1012"></span><br />
This can help load times in a variety of ways. Firstly, downloading a compressed file means less data needs to be transmitted. For example, to build the main voxel model for our site (<a href="http://www.jam3.com">www.jam3.com</a>) we download a file that is roughly 2MB uncompressed. If we zip it, we can get it down to 25KB. While 2MB will only take a few seconds to download on a high end connection, it is a lot to download on slow one. Secondly, if you compress multiple files in the same zip file you can limit the amount of requests the client and server have to deal with which adds a lot of overhead. If you are downloading lots of little files these small handshakes can add up to a lot of time and every bit helps.</p>
<p>There are different ways to handle compression for the web but here we&#8217;ll be looking at unzipping using Flash.</p>
<p>Flash doesn&#8217;t handle zip files natively but there are a few libraries available that will add support. The one we&#8217;ll be using here can be found at <a href="http://nochump.com/blog/archives/15">nochump.com</a></p>
<p>First off we need to actually load our zip file:</p>
<pre><code> private function loadZip():void{ var loader:URLLoader = new URLLoader(); //since flash doesn't know what to do with a .zip //we need to make sure it just loads it as a //binary file so it doesn't try to cast it as text. loader.dataFormat = URLLoaderDataFormat.BINARY loader.addEventListener(Event.COMPLETE, onLoadComplete); loader.load(new URLRequest("main.zip")); } private function onLoadComplete(e:Event):void{ //do stuff here } </code></pre>
<p>Once we have our zip file loaded we can begin to manipulate it to get at the delicious compressed data it contains.</p>
<pre><code> private function onLoadComplete(e:Event):void{ // get our data from our loader var loader:URLLoader = URLLoader(e.target); //create a new Zipfile and pass it our data to decode var myzip:ZipFile = new ZipFile(loader.data); } </code></pre>
<p>Each ZipFile has a property called entries which is an array of ZipEntrys. Each file in the zip has a corresponding ZipEntry. A ZipEntry is basically a data object that contains the file name, size, last modified date and a couple of other properties about the file. To trace the first file name we could just do this <code> trace(myzip.entries[0]);</code><br />
To actually get at the data we need to use the method ZipFile.getInput(entry) which returns a bytearray of our file.</p>
<pre><code> var entry:ZipEntry = myzip.entries[0]; var data:ByteArray = myzip.getInput(entry); </code></pre>
<p>Once we have a byte array there a few different ways to decode our data. For this example, my zip contains an xml file. We need to convert our data to an XML object. This is surprisingly easy.</p>
<pre><code> var myXml:XML = XML(myByteArray.toString()); trace(myXml); </code></pre>
<p>If our zip contains images it slightly more complicated. The easiest way is to use a Loader&#8217;s loadBytes method. This loads a bytearray and decodes it into the correct type (<a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html?filter_flash=cs5&amp;filter_flashplayer=10.2&amp;filter_air=2.6#loadBytes%28%29">ASDocs</a>). In this case, jpg.</p>
<pre><code> var myLoader:Loader = new Loader(); myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onBytesComplete); myLoader.loadBytes(myByteArray); private function onBytesComplete(e:Event):void{ var loader:Loader = Loader(e.target.loader); addChild(loader.content); } </code></pre>
<p>One major caveat to loading a zip of images is that its quite CPU intensive. While you do save time on load you can end up waiting for Flash to decode your images for you. Also, zipping a bunch of images doesn&#8217;t save much space. It does however cut down on the amount of requests you are making to the server.</p>
<p>And that&#8217;s all there is too it. Loading compressed files is a great way to compress your load times and make sure your user can zip on through!</p>
]]></content:encoded>
	





		<wfw:commentRss>http://labs.jam3.ca/zip-through-the-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook vs. Developers</title>
		<link>http://labs.jam3.ca/facebook-vs-developers/</link>
		<comments>http://labs.jam3.ca/facebook-vs-developers/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 19:14:58 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[social network]]></category>

		<guid isPermaLink="false">http://labs.jam3.ca/?p=716</guid>
		<description><![CDATA[I hate to keep bringing up Facebook, but when you spend a lot of time working on Facebook applications, its the thing that comes to &#8230;</div><div class="clear"><!-- --></div><div class="divider_line_white_s_r"></div><div class="viewfullpost"><a href="http://labs.jam3.ca/facebook-vs-developers/"><img alt="" src="http://labs.jam3.ca/wp-content/themes/Labs_blog/images/manu_img.jpg">View Full Post</a></div>]]></description>
	
	
		
	
			<content:encoded><![CDATA[  <img src="http://labs.jam3.ca/wp-content/uploads/2011/09/facebook_vs_developers1-206x114.jpg" class="post_banner"/>  <p>I hate to keep bringing up Facebook, but when you spend a lot of time working on Facebook applications, its the thing that comes to mind most often. And it may seem like I&#8217;m continually bashing the platform, but you must agree, a blog post praising Facebook would be much less interesting and much less informative. So here we are.</p>
<p>The <a href="http://mashable.com/2011/09/22/facebook-f8-live-video/">recent F8 conference</a> has brought some new features that will make facebook users happy, such as <a href="http://mashable.com/2011/09/29/facebook-timeline-brands/">the timeline and the ticker</a>, but that also means that there will be more work for developers. It also seems like they are trying to make their api more consistant, with other api&#8217;s, and in general, which should make development life easier. Although we know from past examples, that that will be a long road. The facebook <a href="http://developers.facebook.com/roadmap/">roadmap</a> doesn&#8217;t show much for developing for these new features, but you can bet as time goes on and demand increases, they will be just another roadblock developers are going to have to tackle.<span id="more-716"></span></p>
<p>Developing for Facebook is not the most smooth process out there. I commend them for constantly updating the developer tools and making things more consistent, but when relying on a service for our client work, when things go bad, we notice and our clients notice. This more often than not, involves some form of undocumented Facebook update and subsequent calls from the client telling us about it.</p>
<p>Just recently a fellow developer ran into a bit of a problem with her Facebook application. Its seems like all of the sudden the page was no longer validating like normal and was therefor creating an endless redirection loop of trying to get permissions even though it already had them. It turns out Facebook had just implemented an option in the advanced tab of the application settings called OAuth 2.0 for canvas which was defaulted to disabled. Now if Facebook would have set the default to enabled, there would be no problem and i would not be mentioning it in this post, but it wasn&#8217;t and many of our previously created apps were now broken because of it. Its also not like the solution was found right away, it took testing and research to figure it out (not done by me mind you), and then the solution had to be applied to most of our old applications.</p>
<p>Another situation occurred on a completely unrelated application, and this time, the fix wasn&#8217;t so easy. In fact, there was no fix at all. A few days after the application launched, we get a call from the client saying the application is no longer working. After initial testing, i realized nothing had changed on our end, and nothing seemed to be different in the application, so that led me to believe Facebook had updated the service and in the process added a bug to the system. After hunting down a bug report and informing the client that we have no control over the current situation, our only option was to sit it out and wait until the service wasfixed. Luckily in this case it was no longer than a day or two, but it&#8217;s not easy telling the client we have no control, and heck, it sucks as a developer to have no control over the situation.</p>
<p>When i make a normal website, once it has been tested and pushed live, i generally don&#8217;t have to worry about it anymore. But working with Facebook changes that situation. You have to be constantly ready to tell the client that Facebook has changed something and we will now have to find a work around to make the application work again. Not without getting stern phone calls from clients who think we have somehow broken it. I&#8217;m not going to go into the long list of problems i have encountered while working with Facebook since they can be found all over the internet (ahem: <a href="http://salpy.wordpress.com/2011/04/08/the-wildly-inconsistent-facebook/">http://salpy.wordpress.com/2011/04/08/the-wildly-inconsistent-facebook/</a>). I just post this so others know what to expect when working with Facebook and that hopefully Facebook will see this and do a bit more testing on existing applications when updating the platform.</p>
]]></content:encoded>
	





		<wfw:commentRss>http://labs.jam3.ca/facebook-vs-developers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Vote for Labs panels at SXSW</title>
		<link>http://labs.jam3.ca/vote-for-labs-panels-at-sxsw/</link>
		<comments>http://labs.jam3.ca/vote-for-labs-panels-at-sxsw/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 15:33:23 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Approach]]></category>

		<guid isPermaLink="false">http://labs.jam3.ca/?p=1034</guid>
		<description><![CDATA[Jam3’s looking to invade SXSW Interactive in 2012, and we have more ammo and explosive content than a Michael Bay flick. There’s plenty of methods &#8230;</div><div class="clear"><!-- --></div><div class="divider_line_white_s_r"></div><div class="viewfullpost"><a href="http://labs.jam3.ca/vote-for-labs-panels-at-sxsw/"><img alt="" src="http://labs.jam3.ca/wp-content/themes/Labs_blog/images/manu_img.jpg">View Full Post</a></div>]]></description>
	
	
		
	
			<content:encoded><![CDATA[  <img src="http://labs.jam3.ca/wp-content/uploads/2011/08/sxsw1-206x114.jpg" class="post_banner"/>  <p>Jam3’s looking to invade SXSW Interactive in 2012, and we have more ammo and explosive content than a Michael Bay flick.</p>
<p>There’s plenty of methods to our madness at Jam3 and we want to share some of that with you at the SXSW Interactive conference this coming year. Give them some love and support their initiatives in the talks they aim to present.<br />
<span id="more-1034"></span><br />
The smörgåsbord of topics range from design to tech to production. We’ve got mouthwatering material on creating tools to implement a creative team’s vision, and theories on how “less code is the best kind of code.” We’ve got an in depth look at audio responsive visualizations, and a little digital storytelling production guidance for you broadcast/film folk to cap it all off.</p>
<p><strong>Our People and Talk Titles:</strong><br />
<em>Mikko Haapoja’s “Less Code More Cool”<br />
Aaron Morris’s “Teaching Laziness: Coding Efficiency for Beginners”<br />
Salpy Kelian and Cole Sullivan’s “Audio Visualization: a DIY Guide”<br />
Adrian Belina’s “Producing Digital Narratives for Brands or Film”</em></p>
<p>Come vote the shit out of this and support your fellow digital peeps in Jam3‘s epic takeover of SXSW’s 2012 best Interactive Conference Ever.</p>
<p><strong><a href="http://panelpicker.sxsw.com/ideas/index/10/company:jam3" target="_blank">http://panelpicker.sxsw.com/ideas/index/10/company:jam3</a></strong></p>
]]></content:encoded>
	





		<wfw:commentRss>http://labs.jam3.ca/vote-for-labs-panels-at-sxsw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Taming the Web: 5 cross-compatiblity tips for HTML, CSS and Javascript</title>
		<link>http://labs.jam3.ca/taming-the-web/</link>
		<comments>http://labs.jam3.ca/taming-the-web/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 16:27:23 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://labs.jam3.ca/?p=887</guid>
		<description><![CDATA[When working in the realm of html, css, and javascript, browser consistency can be a major headache, especially if you are still forced to support &#8230;</div><div class="clear"><!-- --></div><div class="divider_line_white_s_r"></div><div class="viewfullpost"><a href="http://labs.jam3.ca/taming-the-web/"><img alt="" src="http://labs.jam3.ca/wp-content/themes/Labs_blog/images/manu_img.jpg">View Full Post</a></div>]]></description>
	
	
		
	
			<content:encoded><![CDATA[  <img src="http://labs.jam3.ca/wp-content/uploads/2011/08/taming_the_web1-206x114.jpg" class="post_banner"/>  <p>When working in the realm of html, css, and javascript, browser consistency can be a major headache, especially if you are still forced to support the evil known as Internet Explorer 6. But there are a few things you can do to make the process a little easier on yourself. Below I&#8217;ll be sharing some of the things that have helped me when building websites for multiple browsers and platforms. Keep in mind though that implementing these are best done before starting a project, they may do more harm than good on an existing website.</p>
<p>First off we will start with CSS. This first one is a bit controversial, some people swear by it, some people hate it, all i know, it helps me out a lot. Using a reset CSS helps make all the base values for things like margin and padding equal across all browsers. Some people claim they end up having to write more code when they have to re-declare bold tags and what not, but the benefits far outweigh the negatives. Starting with a clean slate makes development from that point much easier and removes the need for browser specific hacks. You can also remove some of the reset values to make it more suitable to your development style, all in all, a great way to start off a project. Although, adding this to a preexisting project can cause more problems than it solves. The one i use most is available <a href="http://meyerweb.com/eric/tools/css/reset/">here</a>. </p>
<p>Another tip for using CSS is avoiding the use of floats. Floats i find are rendered differently in most browsers so i find it best to simply not use them whenever possible, instead relying on positioning elements with top and left. I understand sometimes you may have to use floats, i just prefer to limit they&#8217;re use. A tip for using positioning, setting the position to absolute will set the start point of your top and left values at the top left of the browser, but if you set the container div to position relative, the container will still be in the same position, but the absolutely positioned div will have it&#8217;s start point set to the top left of the containing div.</p>
<p>Its also important to note the use of z-index on Internet Explorer 7 and earlier. Each positioned element in IE creates a new stacking order, starting from 0, instead of using a global stacking order like most browsers. This can cause problems when you want one element to appear over another, but it is nested deeper in the page. The best way to solve this problem is to keep z-indexed elements on the same level in the html, or if you wish to have it appear over all the content, simply place it right below the opening body tag.</p>
<p>As for HTML, the only real change i make is setting the doctype. Whenever i generate a new HTML page, i make sure the doctype is strict rather than transitional (sometimes set by default). It forces Internet Explorer to behave more like the other modern browsers and generally just makes development easier, This will also most likely give you some problems if changing it in a preexisting project, so its best to start from scratch with this one. The most common doctypes i use are:</p>
<p><code>HTML: &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;</code></p>
<p><code>XHTML: &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</code></p>
<p>As for Javascript, my best advice is to pick a library and stick with it. Most common Javascript libraries already take into account browser differences so creating functionality for your website becomes a lot easier. From my <a href="http://labs.jam3.ca/2011/06/jquery-vs-mootools/">last post</a> you can probably gather that i am a MooTools guy, but jQuery works just as well in this area, just try not to use both in the same project.</p>
<p>If your starting a project from scratch, take some time to setup a few of the things i have mentioned, and i think you will find you&#8217;ll be spending a lot less time doing the terrible chore that is browser testing. I take no responsibility for any headaches you get from implementing these on an existing project <img src='http://labs.jam3.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you have any other tips for taming the web, please add a comment below.</p>
]]></content:encoded>
	





		<wfw:commentRss>http://labs.jam3.ca/taming-the-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paper.js: Vector meets Canvas</title>
		<link>http://labs.jam3.ca/paper-js-vector-meets-canvas/</link>
		<comments>http://labs.jam3.ca/paper-js-vector-meets-canvas/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 13:41:20 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[paper.js]]></category>

		<guid isPermaLink="false">http://labs.jam3.ca/?p=947</guid>
		<description><![CDATA[I know I&#8217;m not the first to delve into the world of Paper.js, but being such a new technology, i figured it was worth a &#8230;</div><div class="clear"><!-- --></div><div class="divider_line_white_s_r"></div><div class="viewfullpost"><a href="http://labs.jam3.ca/paper-js-vector-meets-canvas/"><img alt="" src="http://labs.jam3.ca/wp-content/themes/Labs_blog/images/manu_img.jpg">View Full Post</a></div>]]></description>
	
	
		
	
			<content:encoded><![CDATA[  <img src="http://labs.jam3.ca/wp-content/uploads/2011/08/paperjs_51-206x114.jpg" class="post_banner"/>  <p>I know I&#8217;m not the first to delve into the world of Paper.js, but being such a new technology, i figured it was worth a look. Not to mention that you can do some pretty neat stuff with it on any canvas enabled browser.</p>
<p>See these quick examples:<br />
<a href="http://labs.jam3.ca/paper/?id=0" target="_blank">cubes</a><br />
<a href="http://labs.jam3.ca/paper/?id=1" target="_blank">lines</a><br />
<a href="http://labs.jam3.ca/paper/?id=2" target="_blank">starfield</a></p>
<p><span id="more-947"></span></p>
<p>First off, if you don&#8217;t know about Paper.js, definitely <a href="http://paperjs.org/">check it out</a>, its a vector graphics framework built on top of Javascript and the HTML 5 Canvas element. It gives you the ability to easily draw some pretty neat things, and performance seems pretty great as well (usually runs about 60fps). It takes a bit getting used to, but its an interesting approach to the normal javascript development process. Here is the basic setup.</p>
<pre><code>
&lt;script src="js/paper.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="js/main.js" type="text/paperscript"&gt;&lt;/script&gt;
&lt;canvas id="draw" width="100%" height="100%" resize="true"&gt;&lt;/canvas&gt;
</code></pre>
<p>As you can see, first you include the Paper.js source file, then you include your code file with the type as text/paperscript. This will setup your basic events and also provide your script with the extra functionality and classes that Paper.js uses. You also pass the id of the canvas element you want to draw to with the canvas parameter. That&#8217;s pretty much all you need to get you started. Paper.js adds a lot of new classes to use for drawing and also hooks up your events for you so you can get right to the creative part. A complete api reference is available <a href="http://paperjs.org/reference/">here</a>. My template file usually starts off with some of the more common events, as seen below.</p>
<pre><code>
function onFrame(e) {
	e.time // Time in seconds since the app started
}
function onResize(e) {
	view.size // The current canvas size, in a Size object.
}
function onMouseMove(e) {
	e.point; // The current mouse position, in a Point object.
}
</code></pre>
<p>I won&#8217;t go into too much detail about the basic javascript code, but i will go over some of the basic drawing techniques I&#8217;ve used. Path is your basic drawing class, allowing you to draw lines and shapes similar to the flash graphics engine. To control the look of your Path you set fillColor and and strokeColor (they accept CSS values or the colour classes provided by Paper.js like RGBColor). Once a path has been created, it is in the display list unless you specifically call remove(). You can also add your paths to a Group which allows you to control them all with a single function call. I&#8217;ll go over how i drew the shapes in each example.</p>
<p><a href="http://labs.jam3.ca/paper/?id=1">Lines</a> / <a href="http://labs.jam3.ca/paper/js/lines.js">Source</a></p>
<p>Lines are one of the easiest things to draw in Paper.js. Simply create a Path, add points to the line by sending a Point object to the add() function. If you would like your line to be curved instead of jagged, simply call smooth() on the Path. To change the thickness and colour, simply set the strokeColor and strokeWidth properties. Note: the smooth() function must be called any time the points change.</p>
<pre><code>
path = new Path();
path.strokeWidth = Math.round(Math.random()*4)+2;
path.strokeColor = STROKE_COLOR;
for (var n=0; n&lt;POINTS; n++) {
	path.add(new Point(width/(POINTS-1)*n,start+i*SPACING));
}
</code></pre>
<p>The animation of this is a simple sin wave with a multiplier based off mouse position.</p>
<p><a href="http://labs.jam3.ca/paper/?id=2">Stars</a> / <a href="http://labs.jam3.ca/paper/js/stars.js">Source</a></p>
<p>Stars is also a simple application.</p>
<pre><code>
new Path.Circle(new Point(0,0),values.size);
initial.fillColor = 'white';

var symbol = new Symbol(initial);
for (var i=0; i&lt;values.stars; i++) {
	var item = symbol.place(Point.random()*view.size);
}
</code></pre>
<p>We create an initial circle using the Path.Circle function passing in the center point and the radius. This time, we create a Symbol out of the circle which basically turns our circle into a stamp. We call the function place() on the Symbol and pass in a Point object to create a copy of the item at that location. Since we do not keep track of each item in this project, we can simply loop through the children of the activeLayer which is a property of the project variable (available by default without having to declare it).</p>
<pre><code>
var layer = project.activeLayer;
for (var i = 0; i &lt; layer.children.length; i++) {
	layer.children[i].x += values.speed*item.data.scale;
}
</code></pre>
<p>The speed of the particles in this example is controlled by mouse position.</p>
<p><a href="http://labs.jam3.ca/paper/?id=0">Cubes</a> / <a href="http://labs.jam3.ca/paper/js/cubes.js">Source</a></p>
<p>The cube creating part of this example was taken from the Paper.js examples, but i&#8217;ll try to explain whats going on:</p>
<pre><code>Path.RegularPolygon(view.center, 6, 30);</code></pre>
<p>This function creates a 6 sided polygon that has a radius of 30, simple enough, but to create the 3d colouring effect, we have to parse each segment (each segment being a triangle for each side of the shape) into its own Path. To do this, we run through the segments array and clone() each segment into a path and colour them appropriately. This only needs to happen once, as we are then able to simply clone() the Cube that we have created and stored when we want to make another.</p>
<p>The animation of this is just a simple spring effect with a mouse based rotation applied to the container.</p>
<p>I hope these examples have given you a good primer to get started with Paper.js. Now that you have the basics, you are good to go, let your creativity fly. Paper.js allows you to easily create shapes, lines, and even work with loaded images. There is still a lot of unexplored terrain left for me to explore, but here are a few of the examples i came up with after taking a look through the examples posted on the Paper.js website. I&#8217;ve also provided the links to the source so you can see how its done.</p>
<p><a href="http://labs.jam3.ca/paper/">View Examples</a></p>
<p>You can check out the official examples <a href="http://paperjs.org/examples/">here</a>.</p>
]]></content:encoded>
	





		<wfw:commentRss>http://labs.jam3.ca/paper-js-vector-meets-canvas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RadioHead WebGL</title>
		<link>http://labs.jam3.ca/radiohead-webgl/</link>
		<comments>http://labs.jam3.ca/radiohead-webgl/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 03:43:30 +0000</pubDate>
		<dc:creator>Mikko</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Radiohead]]></category>
		<category><![CDATA[WebGL]]></category>

		<guid isPermaLink="false">http://labs.jam3.ca/?p=892</guid>
		<description><![CDATA[Seem&#8217;s like I&#8217;ve brought the House Of Cards dataset to almost every platform I work with. So it was only logical to use it with &#8230;</div><div class="clear"><!-- --></div><div class="divider_line_white_s_r"></div><div class="viewfullpost"><a href="http://labs.jam3.ca/radiohead-webgl/"><img alt="" src="http://labs.jam3.ca/wp-content/themes/Labs_blog/images/manu_img.jpg">View Full Post</a></div>]]></description>
	
	
		
	
			<content:encoded><![CDATA[  <img src="http://labs.jam3.ca/wp-content/uploads/2011/08/radiohead-206x114.jpg" class="post_banner"/>  <p>Seem&#8217;s like I&#8217;ve brought the House Of Cards dataset to almost every platform I work with. So it was only logical to use it with my first experiments with WebGL:<br />
Seem&#8217;s like I&#8217;ve brought the House Of Cards dataset to almost every platform I work with. So it was only logical to use it with my first experiments with WebGL:<br />
<iframe src="http://player.vimeo.com/video/26014170?title=0&amp;byline=0&amp;portrait=0" width="580" height="326" frameborder="0"></iframe><br />
<span id="more-892"></span><br />
To see it in action click below (you must have a WebGL enabled browser):<br />
<a href="http://labs.jam3.ca/wp-content/uploads/2011/07/index.html" target="_blank">House Of Cards WebGL</a></p>
<p>Click on the options on the right to change the way the model looks.</p>
<p>The setting for rendering tris for edges will toggle what geometry will be rendering so if you unselect edges it will stop rendering the &#8220;lines&#8221; around the triangles.</p>
<p>The colour setting will change the way the model looks. By selecting <strong>&#8220;Use Model Colours&#8221;</strong> it will use the colour &#8220;intensity&#8221; values from the RadioHead dataset. If you select <strong>&#8220;Use Solid Colour&#8221;</strong> it will shade the entire model with one colour that is lit with a directional light. Selecting <strong>&#8220;Show Normals&#8221;</strong> will render the triangles based on the Normals of the vertices.</p>
<p>Under animation you can turn on and off the wave motion.</p>
<p>This was a fun small experiment but I learned a lot doing it. I&#8217;m not 100% sure the Normals were calculated correctly but it seems like it. Regardless&#8230; I like how it turned out. </p>
<p>I think Google liked it too since they decided to put it on Chrome Experiments:<br />
<a href="http://www.chromeexperiments.com/detail/radiohead-webgl/">http://www.chromeexperiments.com/detail/radiohead-webgl/</a></p>
]]></content:encoded>
	





		<wfw:commentRss>http://labs.jam3.ca/radiohead-webgl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coding for the 90%</title>
		<link>http://labs.jam3.ca/coding-for-the-90/</link>
		<comments>http://labs.jam3.ca/coding-for-the-90/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 18:34:42 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Approach]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[code review]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[interactive developer]]></category>

		<guid isPermaLink="false">http://labs.jam3.ca/?p=861</guid>
		<description><![CDATA[If there’s one thing I’ve learned during my years as a Flash developer its that we’re lazy. Coders are always trying to find ways to &#8230;</div><div class="clear"><!-- --></div><div class="divider_line_white_s_r"></div><div class="viewfullpost"><a href="http://labs.jam3.ca/coding-for-the-90/"><img alt="" src="http://labs.jam3.ca/wp-content/themes/Labs_blog/images/manu_img.jpg">View Full Post</a></div>]]></description>
	
	
		
	
			<content:encoded><![CDATA[  <img src="http://labs.jam3.ca/wp-content/uploads/2011/07/coding_for_901-206x114.jpg" class="post_banner"/>  <p>If there’s one thing I’ve learned during my years as a Flash developer its that we’re lazy. Coders are always trying to find ways to make their work easier and to write less code.  The most interesting thing about coding is that the more experienced you are the less code you probably write on a day to day basis. There are a variety of reasons for this. One reason is that the code they write is simply more efficient than the code written by a less experienced coder. Another reason is that senior coders have been around for so long that they’ve simply written it already.  However, the biggest reason I think is having a mindset of always trying to solve the problem with the least amount of work.<br />
<span id="more-861"></span><br />
A lot of coders want to write code that can be used in 100% of cases. Think about it, you write a function once and you every time you want to accomplish that task you just copy and paste. It&#8217;s perfect. This is the holy grail of coding. If you can accomplish this it leaves you to concentrate on only the unique/fun parts of the project.  The problem with this is that it can trap you.  Imagine a scenario where you need a have a large piece of text that needs a scroll bar. Realizing that a scroll bar is something you will use again and again you decide you want to write a scroll bar class that can be used for any kind of configuration of scrolling. Vertical, horizontal, even 45 degree angles. This way you’ll never have to write another again. A noble idea.</p>
<p>However, when you finish writing it you realize that it took you twice as long as it would have if you didn’t worry about horizontal and angled scrolling. Also, now when you use the scroll bar it now takes twice as much set up time just to get a vertical scroll bar. Let&#8217;s say instead of 10 minutes, it now takes 20 minutes.  This isn’t a huge deal most of the time but in aggregate it is. If you use the scroll bar class 10 times in one year you’ve spent an extra hour and forty minutes on it. A better idea would be to code a vertical scroll bar and extend the class when you do need the rare horizontal scroll bar.</p>
<p>This is what i call coding for the 90%. This should be your guiding principle when writing code. Worry about the 90% of cases, and deal with the other 10% when it comes up.</p>
<p>This principle can also help guide API development. When creating an API its important to think about how a person will use your API in the future. Rather than include a million constructor parameters to handle every use case think about whats the most important.  It may not take much to develop that class but if every time someone uses it they need to configure 10 different options, a lot of time is lost.  Like my previous post on writing <a href="http://labs.jam3.ca/2011/03/reduce-reuse-recycle-tips-for-the-beginner/#more-630">reusable code</a>, following the 90% principle can help you pick your battles when it comes to writing reusable code. Not everything has to be resuable, just the things that you use a lot. </p>
]]></content:encoded>
	





		<wfw:commentRss>http://labs.jam3.ca/coding-for-the-90/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Björk Part2: Inner Workings</title>
		<link>http://labs.jam3.ca/bjork-part2-inner-workings/</link>
		<comments>http://labs.jam3.ca/bjork-part2-inner-workings/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 17:13:12 +0000</pubDate>
		<dc:creator>Mikko</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://labs.jam3.ca/?p=818</guid>
		<description><![CDATA[When I look back on developing Björk I&#8217;m surprised by one thing&#8230; It wasn&#8217;t as painful as I thought it would be. When I first &#8230;</div><div class="clear"><!-- --></div><div class="divider_line_white_s_r"></div><div class="viewfullpost"><a href="http://labs.jam3.ca/bjork-part2-inner-workings/"><img alt="" src="http://labs.jam3.ca/wp-content/themes/Labs_blog/images/manu_img.jpg">View Full Post</a></div>]]></description>
	
	
		
	
			<content:encoded><![CDATA[  <img src="http://labs.jam3.ca/wp-content/uploads/2011/07/bjork2-206x114.jpg" class="post_banner"/>  <p>When I look back on developing Björk I&#8217;m surprised by one thing&#8230; It wasn&#8217;t as painful as I thought it would be.</p>
<p>When I first saw the creative for the site I started thinking &#8220;How will we pull this off in HTML?&#8221;. As the previous post stated we took quite a few test routes before deciding on doing everything using canvas. Once we had decided on the Canvas method I developed Jam3D.js quite quickly. I think the core of the engine was written in two days or so.</p>
<p>You might be asking why didn&#8217;t I just use another 3D engine that&#8217;s out there. Well&#8230; Generally with projects that have a tight timeline or are high profile I&#8217;m scared to use other peoples tools/code. Especially when it needs to be optimized as much as possible. It&#8217;s very hard to optimize someone else&#8217;s code vs your own. Sometimes to optimize code you have to know every nook and cranny of the code. That&#8217;s not to say I don&#8217;t EVER use other people&#8217;s libraries. (I do look forward to playing with <a href="https://github.com/mrdoob/three.js/" target="_blank">ThreeJS</a> though)</p>
<p>When I was writing Jam3D.js I knew we had to optimize as much as possible but still keep it flexible. To do this you have to keep things as simple as possible.<br />
<span id="more-818"></span><br />
If you look at Jam3D.js you&#8217;ll notice that its really just one array of 3D (x, y, z) points that is being transformed by a 3D transformation matrix and an array that represents those 3D points transformed into their 2D form (x, y). You can&#8217;t get more simple then that.<br />
<img src="http://labs.jam3.ca/wp-content/uploads/2011/07/mikko_bjork_Scene3D_cole.jpg" alt="" title="Björk Scene3D" width="537" height="296" class="alignnone size-full wp-image-910" /><br />
I kept these point arrays as one dimensional arrays of numbers because I wasn&#8217;t sure how intensive it would be to do two dimensional lookups on a Javascript array. At every point when developing something that&#8217;s processor intensive you have to think of these small details.</p>
<p>In order to keep our sanity we created four classes to help us modify and render Scene3D&#8217;s point array. These four classes being Vector3D, Line3D, Circle3D , and CurvePath3D.</p>
<p>Vector3D was the class that would never make an appearance on Björk&#8217;s stage, it would never be rendered, but it was used to create all the 3D objects and also used for some calculations in the site. Vector3D is sort of like a 3D point&#8230; It has properties such as x, y, z position but I also added in two properties x2D and y2D. x2D and y2D were getters that &#8220;reached&#8221; into Scene3D&#8217;s transformed 2d point array to grabed the &#8220;2d&#8221; version of a position. Actually the 3d positions also &#8220;grabbed/pushed&#8221; their values from the Scene3D array.</p>
<p><img src="http://labs.jam3.ca/wp-content/uploads/2011/07/mikko_bjork_Vector3D_cole.jpg" alt="" title="Björk Vector3D" width="537" height="296" class="alignnone size-full wp-image-912" /></p>
<p>This simplest shape that we rendered/drew to Canvas I would say was Circle3D. Circle3D really just had two properties one Vector3D and the radius of the circle. Because we were dealing with perfect &#8220;spheres&#8221; in this site we didn&#8217;t have to calculate anything else beside&#8217;s the location of a circle/spere. Actually I think because of this the Circles were the fastest item&#8217;s to render to screen. Really with just a minimal performance hit.</p>
<p><img src="http://labs.jam3.ca/wp-content/uploads/2011/07/mikko_bjork_Circle3D_cole.jpg" alt="" title="Björk Circle3D" width="537" height="296" class="alignnone size-full wp-image-914" /></p>
<p>Line3D you could guess was quite simple too. It really just contains a start and end position vector3d.</p>
<p><img src="http://labs.jam3.ca/wp-content/uploads/2011/07/mikko_bjork_Line3D_cole.jpg" alt="" title="Björk Line3D" width="537" height="296" class="alignnone size-full wp-image-911" /></p>
<p>Curve3D was the most complex 3D object we were rendering to screen and really was the only one I wasn&#8217;t super confident writing. Up until this point I had never written 3D curves. I was a little bit nervous because in actuality it&#8217;s not even often I write code to render 2d curves. HAH&#8230; But after a bit of experimentation I realized we could render Quadratic or Bezier curves in 3D.</p>
<p>Curves in computer graphics are defined by a starting point and end point and a point that &#8220;effects&#8221; how we will curve in-between those<br />
points. </p>
<p><img src="http://labs.jam3.ca/wp-content/uploads/2011/07/mikko_bjork_Quadratic_cole.jpg" alt="" title="Björk Quadratic Curve" width="537" height="296" class="alignnone size-full wp-image-918" /></p>
<p>Well to be honest the above is a Quadratic curve. A bezier curve has two control points or points that &#8220;effect&#8221; the curve.</p>
<p><img src="http://labs.jam3.ca/wp-content/uploads/2011/07/mikko_bjork_Bezier_cole.jpg" alt="" title="Björk Bezier" width="537" height="296" class="alignnone size-full wp-image-919" /></p>
<p>You might&#8217;ve noticed that I speak very vaguely about the control point effecting the curve and really because it&#8217;s actually very hard to distinctly say how it effects it. The equation for a Quadratic curve is quite simple but it&#8217;s hard to judge quickly what a curve will look like by just knowing the the start, end, and control point of a curve. (for you who&#8217;ve used Illustrator will know) And because of this reason I was very scared to start coding 3D curves. But it turns out if we translate the 3D points for the start, end, and control point to 2D it looks just fine. Just the way it&#8217;s supposed to. Who knew???</p>
<p>So to recap how this whole thing works&#8230; We have a Scene3D which contains some arrays defining 3D and 2D positions. Then we have a few classes that hook/reach into those arrays to modify and set those arrays. </p>
<p>But who does the actual rendering? When you write a simple 3D engine like Jam3D.js you have to make the decision will the Scene render objects or will the objects themselves render themselves. If you choose to have the Scene render the items your engine may perform a little bit better but you&#8217;ll always have to define how things are rendered in the scene and it&#8217;s hard to add in new types of items to render. To be honest at this point I was a bit nervous the creative for Bjork would change and we&#8217;d have to start rendering new types of items so I made the decision to have objects render themselves and possibly take a small performance hit. These types of decisions only really happen when dealing with clients but luckily they never wanted new types of items to render.</p>
<p>One nice thing about the creative for Bjork was that all the items are white. You couldn&#8217;t tell if the white circle that was in the distance was actually in front of the white line in the front cause they were both white. This was nice because we could skip Z-Sorting completely. This helped a lot since Z-Sorting can be one of the most processor intensive operations.</p>
<p>I knew that I didn&#8217;t have a lot of time to write out the Björk site and so I decided that I wasn&#8217;t going to write Matrix3D class. Luckily I found a great Matrix class written by <a href="http://www.daijima.jp/blog/" target="_blank">Masayuki Daijima</a> Matrices scare people a bit if you haven&#8217;t worked with them much. But really you probably all learned this stuff in grade 10 math. HEH. Really matrices are just a set of equations to transform points. (<a href="http://en.wikipedia.org/wiki/Rotation_matrix">http://en.wikipedia.org/wiki/Rotation_matrix</a> <a href="http://en.wikipedia.org/wiki/Scaling_(geometry)"></a> <a href="http://en.wikipedia.org/wiki/Transformation_matrix"></a>)</p>
]]></content:encoded>
	





		<wfw:commentRss>http://labs.jam3.ca/bjork-part2-inner-workings/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

































