Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at

A Basic RayCaster

AnnevK: The example here never closes the path and due to a bug in Firefox 1.5 (it automatically closes the path) it runs smoothly there, but not at all in Opera 9... I guess this will make it a lot slower in Firefox 2 or 3 as well.


Hi there...

I've copied your files into the Samples area of the MDC (currently I have to do this manually...we'll sort out a way to allow contributors to do this themselves eventually).

The directory is here:

Right now the example doesn't work properly in Firefox, but it looks fantastic in Safari. I've asked Vlad to take a look at it to see if we can getting it working cross-browser, but if you have any ideas how it could be fixed up, let me know.

This is a very cool bit of code. Thanks for posting it here :)

Also: if you want to update or change the code, just mail a copy of the files to, and I'll make sure updated versions are uploaded ASAP.

-- dria 09:32, 25 September 2005 (PDT)


thanks! i'll see if i can't look into it too. by the way, i really like the format of this developer center! very cool.

--p 10:55, 25 September 2005 (PDT)


ok. new files sent via email. of course, i noticed a minor typo after i sent them, but i don't think it will break anything. in input.js the trace function call in the last line of the release function should refer to the variable code, not charCode.

--p 12:18, 25 September 2005 (PDT)

Ok, I think I made the fix properly. Let me know if there are any other problems :) -- dria 12:36, 25 September 2005 (PDT)
eek, i also got the arrow key codes mixed up. i've sent you the whole input.js file just to be easier. sorry for the slop. --p 12:42, 25 September 2005 (PDT)

Do we really need the wiki pages with the code? Can't we just link to to the files in samples/ ? Otherwise, people might edit the wiki variant, and things will get out of sync.

About the categories used on this page: Category:Examples:Canvas should be HTML:Canvas:Examples, to be consistent with other categories.

Also I don't think we should be creating categories when there are not enough articles to be put there (I'm referring to Category:Examples:Canvas, Category:Examples:Animation, and Category:HTML:Animation).

--Nickolay 14:24, 25 September 2005 (PDT)

well, i can't edit the files in samples/, and it's not very convenient to have to bug someone at MDC to do it for me. as soon as there's some way for me to manage the files myself i agree it makes sense to take down the code listings. for now, if people want to point out improvements to the code, that would be cool.
sorry about the categories, i just figured the more the better, and surely this canvas thing will be pretty popular and there will be a lot more examples coming. so what's the rule for making a new category-- how many articles do you need? and why does it need to be more than one?

--p 06:30, 26 September 2005 (PDT)

The categories wouldn't be very useful, if there were too many of them, and most of them were half-empty. It's more or less okay when they are named consistently (like the (topic):(category) scheme used on devmo), but certainly not for random names, like html:animation
Thanks for posting this sample, by the way. It's pretty cool. --Nickolay 08:18, 26 September 2005 (PDT)

Document Tags and Contributors

 Contributors to this page: AnnevK1, Nickolay, Pgerstmann, Dria
 Last updated by: AnnevK1,