跳轉到內容

K3D JavaScript 畫布庫/介紹

來自華夏公益教科書,開放的書籍,開放的世界

CanvasK3D 是一個簡單的 3D 2D 投影和動畫系統,完全使用 JavaScript 編寫,使用 HTML5 畫布進行渲染。它可以顯示從一組 3D 向量生成的 3D 物件,並以簡單的 JavaScript 物件結構描述為多邊形。多個物件可以顯示為單個點、線框(線)、實心填充多邊形或紋理化(影像對映)多邊形,然後使用純色、深度提示(z 順序)或光源使用線性疊加照明模型進行陰影,使用任意數量的有色光源。物件可以圍繞一個點自動動畫,並移動以進行簡單的演示。

K3D 不支援“相機”。它不會生成具有可移動“觀察者”或“檢視”向量的完整 3D 場景。相反,使用非常簡單的 2D 透視投影 - 固定觀察者沿 Z 軸向下看向原點。另請參見 A2k0n 的“甜甜圈數學”,瞭解 3D 透視渲染的基本數學原理的描述。

CanvasK3D 可以在任何現代相容 HTML5 的瀏覽器上執行。它不使用 Web-GL,因此也可以在 Android 手機和 Apple iOS 裝置上執行。建議使用 Chrome、Firefox、Safari、Opera 或 IE9 瀏覽器。

更多背景

[編輯 | 編輯原始碼]

簡單但快速的 K3D 引擎的程式碼(“Kevs 3D”,與同名 k-3d C/C++ 庫無關)最初是在 1996 年的編碼黑暗時代用 C/C++ 編寫,在 1998 年轉換為非常棒的 Java 1.0 小程式(Java 中的第一個 3D? - 遠在 Java3D API 存在之前),最近轉換為現代 JavaScript 和 HTML5 畫布。引擎的最初靈感(以及部分程式碼!)來自一本書:Andrew Tyler 的《Atari ST 的即時 3D 圖形:68000 彙編程式設計實用指南》。

許可證

[編輯 | 編輯原始碼]
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.

教程

華夏公益教科書