K3D JavaScript Canvas Library/Introduction
Introduction
[edit | edit source]CanvasK3D is a simple 3D 2D projection and animation system written purely in JavaScript using the HTML5 canvas for rendering. It can display 3D objects generated from a set of 3D vectors and described as polygons in a simple JavaScript object structure. Multiple objects can be displayed as individual points, wireframe (lines), solid filled polygons or textured (image mapped) polygons, then shaded using either plain colour, depth cued (z-ordered) or light-sourced using a linear-additive lighting model with any number of coloured lights. Objects can be automatically animated around a point and moved to make simple demonstrations.
K3D does not support a "camera" as such. It does not generate a full 3D scene with a movable "observer" or "look at" vectors. Instead a very simple 2D perspective projection is used - a fixed observer looking down the Z-axis towards the origin. See also A2k0n's "donut math" for a description of the basic math behind 3D perspective rendering.
CanvasK3D runs on any modern HTML5 compatible browser. It does not use Web-GL so will also run on Android phones and Apple iOS devices. Recommend the use of Chome, Firefox, Safari, Opera or IE9 browsers.
Further background
[edit | edit source]The code for the simple-but-fast K3D engine ("Kevs 3D", no relation to the k-3d C/C++ library of similar name) was originally written in C/C++ back in the coding dark-ages of 1996, converted to a very-nifty-for-the-time-thanks Java 1.0 Applet in 1998 (the first 3D in Java? - well before the Java3D APIs existed) and recently converted to modern JavaScript and HTML5 Canvas. The original inspiration for the engine (and some of the code!) came from a book: Real-time 3D Graphics for the Atari ST: A Practical Guide to 68000 Assembler Programming by Andrew Tyler.
License
[edit | edit source]Copyright (c) 2011 Kevin Roast kevtoast@yahoo.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. A "link back" to the original holding website "www.kev3d.co.uk" or a reference to the original author "Kevin Roast" shall be provided on any copies or substantial portions of the Software. Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.