软件简介

ClayGL 是一个 WebGL 图形库,用于构建可伸缩的 Web3D 应用程序。

ClayGL 易于使用,可针对高质量图形进行配置。得益于模块化和 tree shaking,对于基本的3D应用程序,它可以缩小到22k(压缩)。

示例

创建旋转立方体示例

<!DOCTYPE html>
<html lang="en">
<head>
  <script src="lib/claygl.js"></script>
</head>
<body>
  <canvas id="main"></canvas>
  <script>
    clay.application.create('#main', {

      width: window.innerWidth,
      height: window.innerHeight,

      init(app) {
        // Create camera
        this._camera = app.createCamera([0, 2, 5], [0, 0, 0]);

        // Create a RED cube
        this._cube = app.createCube({
            color: '#f00'
        });

        // Create light
        this._mainLight = app.createDirectionalLight([-1, -1, -1]);
      },
      loop(app) {
        this._cube.rotation.rotateY(app.frameTime / 1000);
      }
    });
  </script>
</body>
</html>

 

转载自: https://www.oschina.net/p/claygl