ClayGL構(gòu)建 Web3D 應(yīng)用的 WebGL 圖形庫
ClayGL 是一個 WebGL 圖形庫,用于構(gòu)建可伸縮的 Web3D 應(yīng)用程序。
ClayGL 易于使用,可針對高質(zhì)量圖形進(jìn)行配置。得益于模塊化和 tree shaking,對于基本的3D應(yīng)用程序,它可以縮小到22k(壓縮)。
示例
創(chuàng)建旋轉(zhuǎn)立方體示例
<!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>
評論
圖片
表情
