跳转到内容

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 [email protected]

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.

教程

华夏公益教科书