<?xml version="1.0" encoding="utf-8"?>
<rss version="0.91">
<channel>
<title>mr.doob</title>
<link>http://www.mrdoob.com</link>
<description>Online design+dev projects</description>
<language>en-uk</language>
<copyright>copyright 2013 mr.doob</copyright>
<item><title>Real-time Rendering</title><link>http://ricardocabello.com/blog/post/722</link><description>Almost forgot about this one. I feel like maybe I'm repeating myself too much on these interviews...&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://www.realtimerendering.com/blog/interview-with-three-js-creator/&quot; target=&quot;_blank&quot;&gt;http://www.realtimerendering.com/blog/interview-with-three-js-creator/&lt;/a&gt;</description><pubDate>Sat, 16 Mar 2013 23:06:00 +0000</pubDate></item><item><title>Mosaic</title><link>http://ricardocabello.com/blog/post/721</link><description>And yet another interview... this one is in spanish though.&lt;br /&gt;
&lt;a href=&quot;http://mosaic.uoc.edu/2013/02/27/ricardo-cabello/&quot; target=&quot;_blank&quot;&gt;http://mosaic.uoc.edu/2013/02/27/ricardo-cabello/&lt;/a&gt;</description><pubDate>Tue, 12 Mar 2013 13:03:00 +0000</pubDate></item><item><title>WebGL Podcast - Episode 3</title><link>http://ricardocabello.com/blog/post/720</link><description>Got interviewed on the 3rd episode of the WebGL Podcast.&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://thewebglpodcast.com/3/&quot;&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/webglpodcast_e3.jpg&quot; width=&quot;350&quot; /&gt;&lt;/a&gt;</description><pubDate>Tue, 12 Mar 2013 10:23:00 +0000</pubDate></item><item><title>Time to build tools.</title><link>http://ricardocabello.com/blog/post/719</link><description>And here's a talk I did one month later at &lt;a href=&quot;http://www.dotjs.eu/&quot; target=&quot;_blank&quot;&gt;dotJS&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;

For this one I only had 20 minutes and I had to be sharp. So rehearsing was required again.&lt;br /&gt;&lt;br /&gt;

&lt;iframe width=&quot;350&quot; height=&quot;250&quot; src=&quot;http://www.youtube.com/embed/NLORWry8F5Y&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;br /&gt;

Oh, and no... that's not my laptop. Not really a fan of stickers on laptops :P</description><pubDate>Tue, 15 Jan 2013 15:18:00 +0000</pubDate></item><item><title>What's next for three.js?</title><link>http://ricardocabello.com/blog/post/718</link><description>Here's a quick talk I did some months ago with &lt;a href=&quot;http://alteredqualia.com/&quot; target=&quot;_blank&quot;&gt;Branislav&lt;/a&gt; at &lt;a href=&quot;http://2012.jsconf.eu/&quot; target=&quot;_blank&quot;&gt;JSConf EU&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;

&lt;iframe width=&quot;350&quot; height=&quot;228&quot; src=&quot;http://www.youtube.com/embed/qx40CRwwkS8&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;br /&gt;

This was the first time I rehearsed a talk. Not sure if that makes things better or worse.</description><pubDate>Mon, 14 Jan 2013 12:19:00 +0000</pubDate></item><item><title>Making of ROME</title><link>http://ricardocabello.com/blog/post/717</link><description>This time around, the now traditional making of blog post is a video instead..&lt;br /&gt;&lt;br /&gt;

I didn't go much into detail but hopefully there are some interesting bits:&lt;br /&gt;&lt;br /&gt;

&lt;iframe width=&quot;350&quot; height=&quot;235&quot; src=&quot;http://www.youtube.com/embed/D8mOtkuN864&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;br /&gt;

Thanks to &lt;a href=&quot;http://www.mozilla.org/&quot; target=&quot;_blank&quot;&gt;Mozilla&lt;/a&gt; for sponsoring!</description><pubDate>Mon, 08 Aug 2011 02:22:00 +0000</pubDate></item><item><title>Clean up</title><link>http://ricardocabello.com/blog/post/715</link><description>&lt;strong&gt;Don't include in your portfolio projects you wouldn't enjoy doing again.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;

That's something I learnt right when I started &lt;a href=&quot;http://www.mrdoob.com&quot;&gt;mrdoob.com&lt;/a&gt;. The aim there was just to share some experimentation and have fun, wasn't meant to be my portfolio but people started contacting me proposing interesting projects. At that point I took down my old (and boring) portfolio here and kept doing experiments over there.&lt;br /&gt;&lt;br /&gt;

So now it's time to apply that again... At this point I've no interest on doing Flash projects any more, hence I've removed all the Flash projects and experiments (files are still there, just not linked).</description><pubDate>Fri, 08 Apr 2011 12:30:00 +0000</pubDate></item><item><title>GLSL Sandbox</title><link>http://ricardocabello.com/blog/post/714</link><description>One of the things WebGL will bring us is Fragment Shaders. If you're familiar with &lt;a href=&quot;http://www.adobe.com/devnet/pixelbender.html&quot;&gt;Pixel Bender&lt;/a&gt; you know how Fragment Shaders work.&lt;br /&gt;&lt;br /&gt;

Although they usually go with Vertex Shaders, you can set it up for doing just 2D effects with it. &lt;a href=&quot;http://www.iquilezles.org/&quot;&gt;Iq&lt;/a&gt; did exactly this some months ago with &lt;a href=&quot;http://www.iquilezles.org/apps/shadertoy/&quot;&gt;Shader Toy&lt;/a&gt; — a browser based Fragment Shader editor.&lt;br /&gt;&lt;br /&gt;

This week I started experimenting with this. First thing I needed to do was a sandbox with the basic WebGL initialisation code. With that done is just a matter of testing values and refreshing the browser. I tried to have a compile button right in the page so I wouldn't even need to refresh the browser but it was over complicating the code...&lt;br /&gt;&lt;br /&gt;

These are the tests I've done so far:&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://mrdoob.com/lab/javascript/webgl/glsl/01/&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_glsl01.png&quot;/&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://mrdoob.com/lab/javascript/webgl/glsl/02/&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_glsl02.png&quot;/&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://mrdoob.com/lab/javascript/webgl/glsl/03/&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_glsl03.png&quot;/&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://mrdoob.com/lab/javascript/webgl/glsl/04/&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_glsl04.png&quot;/&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;

Next thing on the list is to implement render to texture so I can use the output of the fragment shader as input. That'll allow crazy feedback effects and even crazier drawing tools!&lt;br /&gt;&lt;br /&gt;

Feel free to use the sandbox code for your own experimentation.</description><pubDate>Tue, 04 Jan 2011 04:53:00 +0000</pubDate></item><item><title>WebGL</title><link>http://ricardocabello.com/blog/post/713</link><description>Seems like &lt;a href=&quot;http://en.wikipedia.org/wiki/WebGL&quot;&gt;WebGL&lt;/a&gt; is about to land. &lt;a href=&quot;http://www.google.com/landing/chrome/beta/&quot;&gt;Chrome 9 beta&lt;/a&gt;, &lt;a href=&quot;http://www.mozilla.com/en-GB/firefox/beta/&quot;&gt;Firefox 4 beta 8&lt;/a&gt; and &lt;a href=&quot;http://nightly.webkit.org/&quot;&gt;Safari Nighly Build&lt;/a&gt; have it enabled by default already. It's just a matter of weeks for the final versions to be released.&lt;br /&gt;&lt;br /&gt;

I think we're going to face a funny situation... For web developers OpenGL may be a bit intimidating — at least it was for me! For game developers it's piece of cake, but because some features have been disabled some of them feel like a step back in their careers. So it's an area where there won't be so many people for a while.&lt;br /&gt;&lt;br /&gt;

You may know that, for the last few months, &lt;a href=&quot;http://github.com/mrdoob/three.js/&quot;&gt;I've been busy developing a library&lt;/a&gt; that aims to make this as painless and fun as possible. Hopefully there will be more libraries like this in the near future.&lt;br /&gt;&lt;br /&gt;

If you're a web developer I would suggest you to start tinkering with all this. I have the feeling things are going to move quite fast as soon as it lands. Won't be long until Mobile Safari — iOS and Android browser — also enables this.&lt;br /&gt;&lt;br /&gt;

Exciting times! :)</description><pubDate>Tue, 04 Jan 2011 04:11:00 +0000</pubDate></item><item><title>3 point gradient trick and vertex colors</title><link>http://ricardocabello.com/blog/post/710</link><description>Continuing with the three.js development, after implementing multi lights the flat shading was starting to be quite a limitation.&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://mrdoob.github.com/three.js/examples/lights_pointlights.html
&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_4pointgradient0.png&quot; width=&quot;350&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;

In order to get smooth faces I needed to figure out a way to create what it's called 3 point gradients. I took a look at the usual Flash 3D engines and what was my surprise when I found out that they tend to be limited to just 1 light (correct me if I'm wrong).  This is probably because by supporting 1 light they just needed to create a light map per material. Something like this:&lt;br /&gt;&lt;br /&gt;

&lt;center&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_4pointgradient6.png&quot; /&gt;&lt;/center&gt;&lt;br /&gt;

That's indeed a fast approach, but it limits to just 1 light, and then you need to update the map if the ambient light changes or the color of the material... not really up my street.&lt;br /&gt;&lt;br /&gt;

The old way of doing this with OpenGL is by using Vertex Colors. Basically, I was after this:&lt;br /&gt;&lt;br /&gt;

&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_4pointgradient7.png&quot; width=&quot;350&quot; /&gt;&lt;br /&gt;&lt;br /&gt;

I wondered if there was a way to create this kind of gradient with the Canvas API. I googled a bit to see what people had come up with, but all the approaches seemed quite cpu intensive. Like &lt;a href=&quot;http://en.nicoptere.net/?p=537&quot; target=&quot;_blank&quot;&gt;this one&lt;/a&gt; from nicoptere.&lt;br /&gt;&lt;br /&gt;

Then a crazy idea pop into my mind. What about having a 2x2 image, and change the colors of each pixel depending of the vertex color and do that at render time per polygon? The browser will then stretch that image and create all the gradient in between those 3-4 pixels.&lt;br /&gt;&lt;br /&gt;

This is the 2x2 image:&lt;br /&gt;&lt;br /&gt;

&lt;center&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_4pointgradient1.png&quot; /&gt;&lt;/center&gt;&lt;br /&gt;

Can't you see it? Ok, this is the same image scaled to 256x256 with no filtering (using &lt;a href=&quot;http://www.gimp.org/&quot; target=&quot;_blank&quot;&gt;Gimp&lt;/a&gt;):&lt;br /&gt;&lt;br /&gt;

&lt;center&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_4pointgradient15.png&quot; /&gt;&lt;/center&gt;&lt;br /&gt;

However, by default (whether you like it or not) the browsers &lt;a href=&quot;http://en.wikipedia.org/wiki/Bilinear_filtering&quot; target=&quot;_blank&quot;&gt;filter&lt;/a&gt; scaled images. This is what you get within the browsers:&lt;br /&gt;&lt;br /&gt;

&lt;center&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_4pointgradient2.png&quot; /&gt;&lt;/center&gt;&lt;br /&gt;

Each browser gets slightly different results but pretty much that's what you get. This wasn't exactly what I was after, there is too much color on the corners. However, by looking at all the results from all the browsers I realised that the center part of the image was the only part that was always similar.&lt;br /&gt;&lt;br /&gt;

&lt;center&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_4pointgradient3.png&quot; /&gt;&lt;/center&gt;&lt;br /&gt;

Then I realised that that's the actual gradient I was after!&lt;br /&gt;&lt;br /&gt;

&lt;center&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_4pointgradient4.png&quot; /&gt;&lt;/center&gt;&lt;br /&gt;

Here it's the code:&lt;br /&gt;&lt;br /&gt;

&lt;pre&gt;
var QUALITY = 256;

var canvas_colors = document.createElement( 'canvas' );
canvas_colors.width = 2;
canvas_colors.height = 2;

var context_colors = canvas_colors.getContext( '2d' );
context_colors.fillStyle = 'rgba(0,0,0,1)';
context_colors.fillRect( 0, 0, 2, 2 );

var image_colors = context_colors.getImageData( 0, 0, 2, 2 );
var data = image_colors.data;

var canvas_render = document.createElement( 'canvas' );
canvas_render.width = QUALITY;
canvas_render.height = QUALITY;
document.body.appendChild( canvas_render );

var context_render = canvas_render.getContext( '2d' );
context_render.translate( - QUALITY / 2, - QUALITY / 2 );
context_render.scale( QUALITY, QUALITY );

data[ 0 ] = 255; // Top-left, red component
data[ 5 ] = 255; // Top-right, green component
data[ 10 ] = 255; // Bottom-left, blue component

context_colors.putImageData( image_colors, 0, 0 );
context_render.drawImage( canvas_colors, 0, 0 );
&lt;/pre&gt;&lt;br /&gt;

So it was just a matter of changing 3-4 pixels, scaling up and cropping and then use that as a texture for each polygon. Crazy? Yes. But it works! And fast enough! And what's more, it's not just limited to 3 points, but a 4th point comes for free (quads).&lt;br /&gt;&lt;br /&gt;

&lt;center&gt;&lt;a href=&quot;http://twitpic.com/37bjvz/full&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_4pointgradient5.png&quot; width=&quot;350&quot; /&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;

&lt;a href=&quot;http://mrdoob.github.com/three.js/examples/materials_depth.html&quot; target=&quot;_blank&quot;&gt;Here it's an example&lt;/a&gt; of the first material I've applied the technique to (use arrow keys and ASWD to navigate).&lt;br /&gt;&lt;br /&gt;

At this point I was surprised that I didn't see this before. And that I hadn't seen this being done in any of the usual 3d engines. I did another search and I found &lt;a href=&quot;http://actionsnippet.com/?p=2329&quot; target=&quot;_blank&quot;&gt;this snippet&lt;/a&gt; from &lt;a href=&quot;http://pixelero.wordpress.com/&quot; target=&quot;_blank&quot;&gt;Pixelero&lt;/a&gt; that uses the same concept. Good to know I'm not the only one with crazy ideas! :)&lt;br /&gt;&lt;br /&gt;

Thanks to this, now I'm able to do smooth materials (gouraud, phong) that support multiple lights, fog, even &lt;a href=&quot;http://en.wikipedia.org/wiki/Screen_Space_Ambient_Occlusion&quot; target=&quot;_blank&quot;&gt;SAAO&lt;/a&gt; :) We just need the browsers to become faster (which&lt;a href=&quot;http://www.youtube.com/watch?v=VZXjxl5p_0c&quot;&gt; they seem to be on it already&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;

Of course, if your browser supports WebGL you should be using that instead, but if it doesn't, at least you'll have something better than a text message.</description><pubDate>Thu, 18 Nov 2010 00:09:00 +0000</pubDate></item><item><title>three.js r28</title><link>http://ricardocabello.com/blog/post/709</link><description>For the last few weeks I've been quite focused on developing &lt;a href=&quot;https://github.com/mrdoob/three.js&quot; target=&quot;_blank&quot;&gt;the engine&lt;/a&gt; and I think the API is starting to get quite stable. I'm still unsure on what parts of the API need to be included in the actual build and what parts should just keep outside.&lt;br /&gt;&lt;br /&gt;

For instance, primitives is something you don't want to have in the compiled .js file. If you need a Cube, Sphere, ... I think it's easier to have it in &lt;em&gt;/js/geometry/primives/*&lt;/em&gt;. Otherwise we end up having a 100kbytes file just for drawing a bunch of particles. I really want to avoid that, right now it's 60kbytes. But that includes all the renderers, if you're only going to use &lt;em&gt;CanvasRenderer&lt;/em&gt;, you can save 20-30kb by removing the &lt;em&gt;SVGRenderer&lt;/em&gt;, &lt;em&gt;WebGLRenderer&lt;/em&gt;, ... logic. &lt;a href=&quot;https://github.com/mrdoob/three.js/tree/master/utils/&quot; target=&quot;_blank&quot;&gt;These scripts&lt;/a&gt; do that automatically.&lt;br /&gt;&lt;br /&gt;

Mr. &lt;a href=&quot;http://alteredqualia.com/&quot; target=&quot;_blank&quot;&gt;AlteredQualia&lt;/a&gt; has been doing an awesome job with the &lt;em&gt;WebGLRenderer&lt;/em&gt; these past weeks. If you have WebGL enabled, &lt;a href=&quot;http://mrdoob.github.com/three.js/examples/geometry_large_mesh.html&quot; target=&quot;_blank&quot;&gt;these 400k polys&lt;/a&gt; are waiting for you.&lt;br /&gt;&lt;br /&gt;

There is still quite a bit of work to do here and there, specially on the materials side (Mapping types, Blending, Gouraud, Phong... ) but it'll all come in good time :)</description><pubDate>Thu, 04 Nov 2010 23:55:00 +0000</pubDate></item><item><title>How do you debug JavaScript?</title><link>http://ricardocabello.com/blog/post/708</link><description>&lt;a href=&quot;http://joeparry.com/blog/&quot; target=&quot;_blank&quot;&gt;Joe Parry&lt;/a&gt; suggested by email to write a follow up to the post about &lt;a href=&quot;http://mrdoob.com/blog/post/706&quot; target=&quot;_blank&quot;&gt;JavaScript IDEs&lt;/a&gt;. That's also one of the common questions and I intended to include it on the first post but I forgot :S&lt;br /&gt;&lt;br /&gt;

I've heard many people referring to &lt;a href=&quot;http://getfirebug.com/&quot; target=&quot;_blank&quot;&gt;Firebug&lt;/a&gt; as the best way to debug when coding JavaScript but I've never got to try it out properly as I started coding directly with/for Chrome. So in my case I mainly use the &lt;a href=&quot;http://webkit.org/blog/197/web-inspector-redesign/&quot; target=&quot;_blank&quot;&gt;Webkit Inspector&lt;/a&gt;/&lt;a href=&quot;http://blog.chromium.org/2009/06/developer-tools-for-google-chrome.html&quot; target=&quot;_blank&quot;&gt;Developer Tools&lt;/a&gt; panel.&lt;br /&gt;&lt;br /&gt;

However, rather than debug the code I usually log stuff instead for which &lt;strong&gt;console.log()&lt;/strong&gt;, &lt;strong&gt;console.log()&lt;/strong&gt;, &lt;strong&gt;console.error()&lt;/strong&gt;, &lt;strong&gt;console.warn()&lt;/strong&gt;, &lt;strong&gt;console.info()&lt;/strong&gt; gives me way more than I need. Specially coming from Flash where the console is so basic that everyone keeps building &lt;a href=&quot;http://code.google.com/p/mrdoob/source/browse/trunk/libs/net/hires/debug/Logger.as&quot; target=&quot;_blank&quot;&gt;their own logging library&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;

At this last &lt;a href=&quot;http://code.google.com/events/io/2010/&quot; target=&quot;_blank&quot;&gt;Google I/O&lt;/a&gt; I saw this presentation about the Developer Tools that left me quite impressed of how much stuff I was missing.&lt;br /&gt;&lt;br /&gt;

&lt;iframe title=&quot;YouTube video player&quot; class=&quot;youtube-player&quot; type=&quot;text/html&quot; width=&quot;350&quot; height=&quot;300&quot; src=&quot;http://www.youtube.com/embed/TH7sJbyXHuk&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;</description><pubDate>Mon, 11 Oct 2010 13:46:00 +0000</pubDate></item><item><title>stats.js bookmarklet</title><link>http://ricardocabello.com/blog/post/707</link><description>Last week &lt;a href=&quot;http://twitter.com/matthewlein&quot; target=&quot;_blank&quot;&gt;Matthew Lein&lt;/a&gt; shared a &lt;a href=&quot;http://twitter.com/matthewlein/status/26675207435&quot; target=&quot;_blank&quot;&gt;very interesting tip&lt;/a&gt; over twitter.&lt;br /&gt;&lt;br /&gt;

Apart from &lt;a href=&quot;http://ffffound.com/&quot; target=&quot;_blank&quot;&gt;FFFOUND!&lt;/a&gt;'s bookmarklet I haven't seen myself using many of these as I've never felt they were that useful. However, this case is different and, once again, the possibilities of JavaScript amaze me.&lt;br /&gt;&lt;br /&gt;

Just drag and drop this link to your bookmarks toolbar:&lt;br /&gt;&lt;br /&gt;

&lt;center&gt;&lt;a href=&quot;javascript:(function(){var script=document.createElement('script');script.src='http://github.com/mrdoob/stats.js/raw/master/build/stats.min.js';document.body.appendChild(script);script=document.createElement('script');script.innerHTML='var interval=setInterval(function(){if(typeof Stats==\'function\'){clearInterval(interval);var stats=new Stats();stats.domElement.style.position=\'fixed\';stats.domElement.style.left=\'0px\';stats.domElement.style.top=\'0px\';stats.domElement.style.zIndex=\'10000\';document.body.appendChild(stats.domElement);setInterval(function(){stats.update();},1000/60);}},100);';document.body.appendChild(script);})();&quot;&gt;Display Stats&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;

By clicking on the saved bookmark you'll be able to insert the &lt;a href=&quot;http://github.com/mrdoob/stats.js&quot;&gt;Stats.js widget&lt;/a&gt; in any website and monitor the FPS/MS/MEM by doing so \:D/.</description><pubDate>Mon, 11 Oct 2010 03:12:00 +0000</pubDate></item><item><title>What IDE do you use for Javascript coding?</title><link>http://ricardocabello.com/blog/post/706</link><description>I've been asked this question a few times for the past week so I thought I would make a &quot;public&quot; answer.&lt;br /&gt;&lt;br /&gt;

At first I tested some &lt;a href=&quot;http://en.wikipedia.org/wiki/Integrated_development_environment&quot; target=&quot;_blank&quot;&gt;IDE&lt;/a&gt;s like &lt;a href=&quot;http://netbeans.org/&quot; target=&quot;_blank&quot;&gt;NetBeans&lt;/a&gt; and &lt;a href=&quot;http://www.aptana.com/&quot; target=&quot;_blank&quot;&gt;Aptana&lt;/a&gt;  but somehow I didn't get to like them. Specially because they tend to add &quot;hidden&quot; folders around.&lt;br /&gt;&lt;br /&gt;

Believe it or not, I simply use &lt;a href=&quot;http://www.ubuntu.com/&quot; target=&quot;_blank&quot;&gt;Ubuntu&lt;/a&gt;'s default text editor &lt;a href=&quot;http://projects.gnome.org/gedit/&quot; target=&quot;_blank&quot;&gt;gedit&lt;/a&gt;. Sometimes the syntax highlighting is not correct and editing 1 line files is incredibly slow but apart from that it doesn't get on the way. Simple and fast.&lt;br /&gt;&lt;br /&gt;

However, auto completion is something I was missing from my &lt;a href=&quot;http://www.fdt.powerflasher.com/&quot; target=&quot;_blank&quot;&gt;FDT&lt;/a&gt;/AS3 days. Turns out &lt;a href=&quot;https://github.com/nagaozen/gedit-plugin-codecompletion/&quot; target=&quot;_blank&quot;&gt;auto completion based on already written text in the loaded files&lt;/a&gt; is all I need.</description><pubDate>Wed, 06 Oct 2010 22:18:00 +0000</pubDate></item><item><title>Making of The Wilderness Downtown</title><link>http://ricardocabello.com/blog/post/705</link><description>&lt;a href=&quot;http://thewildernessdowntown.com/&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_af.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;

I think it was about one year ago, right after the &lt;a href=&quot;&quot; target=&quot;_blank&quot;&gt;Google Sphere experiment&lt;/a&gt;, when &lt;a href=&quot;http://www.aaronkoblin.com/&quot; target=&quot;_blank&quot;&gt;Aaron&lt;/a&gt; started talking about a music video in the browser idea and if I would be up for it. If you consider &lt;a href=&quot;http://vimeo.com/14457835&quot; target=&quot;_blank&quot;&gt;my background&lt;/a&gt;, you'll understand how excited I was with such opportunity. Since then they (the &lt;strong&gt;Google Creative Lab&lt;/strong&gt; guys) started looking for a band to work with and a director. Months later we got busy with &lt;a href=&quot;http://www.thejohnnycashproject.com/&quot; target=&quot;_blank&quot;&gt;The Johnny Cash Project&lt;/a&gt; and seeing how well it worked out they saw clear how &lt;a href=&quot;http://www.chrismilk.com/&quot; target=&quot;_blank&quot;&gt;Chris&lt;/a&gt; could do a great job directing this project too. Chris happened to be friends with &lt;a href=&quot;http://www.arcadefire.com/&quot;&gt;Arcade Fire&lt;/a&gt; whom also seemed to be interested on joining the party.&lt;br /&gt;&lt;br /&gt;

As the project was considerably big we also needed a production company to handle the design and development process and &lt;a href=&quot;http://www.b-reel.com/&quot; target=&quot;_blank&quot;&gt;B-Reel&lt;/a&gt; seemed a good fit. Albeit they had some in-house developers we really needed people with HTML5/Javascript experience. Finding people with these skills turned out to be a hard task as it seems most of the people we knew were stuck with either jQuery-kind-of-Javascript, AS3 or full employed/unavailable... As an act of desperation I &lt;a href=&quot;http://twitter.com/mrdoob/status/17171731990&quot; target=&quot;_blank&quot;&gt;tweeted this&lt;/a&gt;. &lt;a href=&quot;http://twitter.com/thespite&quot; target=&quot;_blank&quot;&gt;An old friend of mine&lt;/a&gt; replied to the call. I knew he had already played around with &amp;lt;canvas&gt; and I knew he would be invaluable for the team for his know-how. At this point, we had a band, a track, Chris+Aaron had the script ready and the team was all set.&lt;br /&gt;&lt;br /&gt;

At first I didn't realised the cleverness of the idea of using Google Maps/Street View data set. It wasn't until we had the first test of the kid running around the neighbourhood that it made an impact on me and made me remember old times. Kudos to Chris and Aaron for envisioning that :)&lt;br /&gt;&lt;br /&gt;

&lt;strong&gt;Production time&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;

By reading the script I realised that how valuable the javascript libraries I had been developing for the past year were going to be. We had a &lt;a href=&quot;http://github.com/mrdoob/xplsv_orsotheysay/blob/master/js/Sequencer.js&quot; target=&quot;_blank&quot;&gt;sequencer&lt;/a&gt; ready to add and remove effects in sync with a tune, a &lt;a href=&quot;http://github.com/mrdoob/three.js/&quot; target=&quot;_blank&quot;&gt;3D renderer&lt;/a&gt; and &lt;a href=&quot;http://mrdoob.com/projects/harmony/&quot; target=&quot;_blank&quot;&gt;Harmony&lt;/a&gt; (as it was referred in the script).&lt;br /&gt;&lt;br /&gt;

I'm sure most of the people will think that the drawing tool is basically what I did... not really. Although it used Harmony as the base code, &lt;a href=&quot;http://www.georgemichaelbrower.com/&quot; target=&quot;_blank&quot;&gt;George&lt;/a&gt; was in charge of that part. He did a great work by creating a new brush out of it, a recorder and repainter and, in the last minute, some keyboard based input with the letter being drawn using that brush.&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://www.jocabola.com/&quot; target=&quot;_blank&quot;&gt;Eduard&lt;/a&gt; was responsible of the whole mainframe and making sure everyone was producing compatible code. The sequencer already provided some basic template for show/hide behaviour of effects but we also needed pre-loading, sharing data between effects and more things I'm probably not aware of. If that wasn't enough, he created a sequencing tool (with javascript) so the Director and Art Director could easily set when each window and effect would appear and where in the screen.&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://twitter.com/thespite&quot; target=&quot;_blank&quot;&gt;Jaime&lt;/a&gt; took the maps beast and geocoding utils. We couldn't just directly use the embeddable Google Maps, the maps were supposed to have some tilting on the camera so a new Maps Data viewer was required. We also had to figure out possible routes for the runner to get to the user's home in sync with the music, the &lt;a href=&quot;http://code.google.com/apis/maps/documentation/javascript/services.html#Routes&quot; target=&quot;_blank&quot;&gt;Direction Route API&lt;/a&gt; provided that but we had to implement it properly. All this takes a lot of time, research and testing.&lt;br /&gt;&lt;br /&gt;

I was going to work on all the Street View scenes and also the cgi version of the runner. However, I didn't have skinning nor any animation code for three.js yet, so as these scenes weren't interactive neither customisable it was quickly decided that B-Reel would create videos for these parts — which ended up really great too! In the end I also added the birds flocking and birds landing on the drawing to my plate.&lt;br /&gt;&lt;br /&gt;

Now... I can't speak much about the challenges that other people faced but you can get the idea with the ones I did.&lt;br /&gt;&lt;br /&gt;

&lt;strong&gt;(Fast) Street View&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;

At first we intended to simply use Google's &lt;a href=&quot;http://code.google.com/apis/maps/documentation/javascript/services.html#StreetView&quot; target=&quot;_blank&quot;&gt;Street View&lt;/a&gt;. I did a test integrating &lt;a href=&quot;http://github.com/mrdoob/three.js/&quot; target=&quot;_blank&quot;&gt;three.js&lt;/a&gt; with it and it seemed to work all fluid. However, what I didn't know was that if you have WebGL enabled Google's Street View would already use it. So what other people would see was considerable slower than what I was seeing. If WebGL is not enabled the Street View uses a three.js-like renderer. That was fine on Windows and Linux but not so much for MacOS. Turns out Google Chrome internally uses a different graphics library in MacOS than in Windows and Linux. &lt;a href=&quot;http://www.cocoadev.com/index.pl?CoreGraphics&quot; target=&quot;_blank&quot;&gt;CoreGraphics&lt;/a&gt; for MacOS and &lt;a href=&quot;http://code.google.com/p/skia/&quot; target=&quot;_blank&quot;&gt;Skia&lt;/a&gt; for Windows and Linux. Each library have their own pros and cons but CoreGraphics is specially slow when transforming and clipping big images. Street View would run at 30fps on Windows/Linux while it would get 1fps on MacOS.&lt;br /&gt;&lt;br /&gt;

Like with the maps, we had to build a custom &lt;a href=&quot;http://code.google.com/apis/maps/documentation/javascript/services.html#StreetViewService&quot; target=&quot;_blank&quot;&gt;Street View Data&lt;/a&gt; viewer. Jaime encountered the same problem while doing the 3d maps using three.js. He then started researching other ways of drawing the Maps Data in a way that would create the same effect. An additional challenge was that with &amp;lt;canvas&gt; you don't have access to the pixel data of images loaded from another domain. Otherwise we could just use &lt;a href=&quot;http://mrdoob.com/lab/javascript/effects/plane_deformations/&quot; target=&quot;_blank&quot;&gt;this technique&lt;/a&gt; and call it a day. However, albeit pixel access is forbidden, &lt;strong&gt;context.drawImage() is allowed for copying areas from images hosted on other domains&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;

By stitching all the tiles the API provides for each panorama we get this image:&lt;br /&gt;&lt;br /&gt;

&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_af_pano.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;

After zooming in to a part of the image we get this:&lt;br /&gt;&lt;br /&gt;

&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_af_fastpano01.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;

Somehow we need to apply this distortion:&lt;br /&gt;&lt;br /&gt;

&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_af_fastpano07.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;

We can do that by cropping columns from the original image and positioning them one after the other horizontally. Each one with some vertical scaling depending of the proximity to the center. We get this:&lt;br /&gt;&lt;br /&gt;

&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_af_fastpano02.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;

Now we just need to wider the columns a bit to hide the gaps:&lt;br /&gt;&lt;br /&gt;

&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_af_fastpano03.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;

The distortion isn't perfect but it's close enough. This approach seemed to be quite fast in all the platforms and all it was left was to apply the good old &lt;a href=&quot;http://gist.github.com/518916&quot; target=&quot;_blank&quot;&gt;Perlin Noise&lt;/a&gt; to the movement to get some human feeling.&lt;br /&gt;&lt;br /&gt;

&lt;strong&gt;The right heading&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;

Or so I thought. We were missing an important bit. For each StreetView we had to place the camera target at specific positions. For instance, the Street View that does the 360 right in front of your house had to start spinning right from your house. But how do you know where to look at? Where is the user's house? The &lt;a href=&quot;http://code.google.com/apis/maps/documentation/javascript/services.html#StreetViewService&quot; target=&quot;_blank&quot;&gt;Street View Service&lt;/a&gt; doesn't give any information about that. After studying all the data the API provided and directly debugging &lt;a href=&quot;http://maps.google.com/&quot; target=&quot;_blank&quot;&gt;Google Maps&lt;/a&gt; I ended up noticing that each panorama has a lat/lng information, plus I also had the lat/lng information of the location of the house. On top of that, the panorama does provide the angle where the north points to.&lt;br /&gt;&lt;br /&gt;

Very long story short... subtract the lat/lng position of the house with the lat/lng position of the panorama. Get the angle of that vector and mix it with the angle of where the north is in the panorama. Voila! :)&lt;br /&gt;&lt;br /&gt;

&lt;strong&gt;Birds&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://mrdoob.github.com/three.js/examples/geometry_birds.html&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_af_birds.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;

Although &lt;a href=&quot;http://www.ductil.org/&quot; target=&quot;_blank&quot;&gt;Guille&lt;/a&gt; and &lt;a href=&quot;http://www.ghost-hack.com/&quot; target=&quot;_blank&quot;&gt;Michael&lt;/a&gt; had done great progress with the birds we felt we could do better. After considering the options, my approach was using a 3 polygons mesh — one polygon for each wing and one for the body. Then animating it by sinusoidally moving up and down the vertices at the end of the wings. Although it didn't look like a crow it gave, once again, a close enough effect. Specially when you have a bunch of them following a &lt;a href=&quot;http://www.openprocessing.org/visuals/?visualID=6910&quot; target=&quot;_blank&quot;&gt;boid simulation&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;

&lt;strong&gt;Tinting&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;

This one is going to be controversial... Street View and Maps footage needed to be colour corrected because the action is supposed to take place in the morning, thus some yellowish tint was needed.&lt;br /&gt;&lt;br /&gt;

&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_af_tint01.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;

Again, we can't access the pixel data of images hosted in another domain, so the only option was to layer a colour on top of the image and play with blend modes. However, take a look at the &lt;a href=&quot;http://www.nihilogic.dk/labs/canvas_sheet/HTML5_Canvas_Cheat_Sheet.png&quot; target=&quot;_blank&quot;&gt;blend modes available&lt;/a&gt;... only &lt;strong&gt;lighten&lt;/strong&gt; could be of some use here. So we first tried drawing a rectangle on top with a yellow colour and &lt;strong&gt;lighten&lt;/strong&gt; blending mode enabled. That kind of worked but it washed the footage out.&lt;br /&gt;&lt;br /&gt;

&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_af_tint02.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;

There is another blending mode though... &lt;strong&gt;darken&lt;/strong&gt;. It was taken out of the specification but it still remains in WebKit and I hope they put it back because this is a good example of why is useful. By drawing that yellow colour using the &lt;strong&gt;darken&lt;/strong&gt; blending mode on top of the image, and then drawing the original image on top using the &lt;strong&gt;lighten&lt;/strong&gt; blending mode we achieved a really nice yellow tint and contrast that worked quite well for simulating the light we get in the morning.&lt;br /&gt;&lt;br /&gt;

&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_af_tint03.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;

Notice how the darks stay dark. Here it's the actual snippet:&lt;br /&gt;&lt;br /&gt;

&lt;pre&gt;
var context = texture_mod.getContext( '2d' );
 
context.drawImage( texture, 0, 0 );
 
context.globalAlpha = 0.5;
context.globalCompositeOperation = 'darker';
context.fillStyle = '#704214';
context.fillRect( 0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT );
 
context.globalCompositeOperation = 'lighter';
context.drawImage( texture, 0, 0 );
&lt;/pre&gt;&lt;br /&gt;

&lt;strong&gt;Tween and Manual Tween&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;

Most of the movements in the video use the well known &lt;a href=&quot;http://robertpenner.com/easing/&quot; target=&quot;_blank&quot;&gt;Penner's Easing equations&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://soledadpenades.com/&quot; target=&quot;_blank&quot;&gt;Sole&lt;/a&gt; had been working on a &lt;a href=&quot;http://github.com/sole/tween.js&quot; target=&quot;_blank&quot;&gt;simplified Javascript Tweening library&lt;/a&gt; some months before this project and it proved really useful. You probably know how Tweening libraries work... you define an animation with its properties to be animated, it's delay and so on... then you start it. However, we needed to be able to go backwards at any point of the video (at least I needed it ;P). So by doing the Manual Tween alternative  we were able to move freely to any point of the virtual timeline.&lt;br /&gt;&lt;br /&gt;

Now that I look back, instead of having 2 different libraries for Tweening, the Manual one should have been part of the &lt;a href=&quot;http://github.com/mrdoob/xplsv_orsotheysay/blob/master/js/Sequencer.js&quot; target=&quot;_blank&quot;&gt;sequencer&lt;/a&gt; code... hmmm... something to consider...&lt;br /&gt;&lt;br /&gt;

&lt;strong&gt;Optimising&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;

Launch day was approaching and the server guys were giving some recommendations on some changes we could do for making the server happier. One of them was the tree animation I was using on the last Street View part. It was something I intended to do but I didn't have time just yet. Instead of having 63 separate images for a growing tree animation is better to mix them up in a single image.&lt;br /&gt;&lt;br /&gt;

&lt;img src=&quot;http://ricardocabello.com/files/blog/mrdoob_af_streetview_trees.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;

We have seen this in previous projects haven't we? ;)&lt;br /&gt;&lt;br /&gt;

The second one was about javascript files.... we had about 40+ javascript files. The more files you have the more server resources each user will consume. There is a defined amount of connections available in a server, if that amount is, for example, 40 and each user needs to open 40 files to be able to see the website, the website would be able to be seen by just 1 user at a time. Mix all those 40 files into 1 file and then 40 users will be able to visit the website at a time. We didn't used the compressed/compiled index by launch time and I believe that was one of the main reasons we suffered some downtimes.&lt;br /&gt;&lt;br /&gt;

&lt;a href=&quot;http://github.com/mrdoob/three.js/blob/master/utils/Builder.py&quot; target=&quot;_blank&quot;&gt;This script&lt;/a&gt; shows pretty much how to combine and minify easily.&lt;br /&gt;&lt;br /&gt;

&lt;strong&gt;Ok, that's enough&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;

I know, that was quite long wasn't it. Hope this is of some use to some one, and hope you liked the actual piece too. Now, let's move to WebGL ;)&lt;br /&gt;&lt;br /&gt;

PS: If you wonder about any other technical details, feel free to use the comments and I'll try to address them.</description><pubDate>Fri, 17 Sep 2010 12:25:00 +0000</pubDate></item>
</channel></rss>
