claygl/example/app_basic.html
2018-01-04 19:00:17 +08:00

48 lines
1.4 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="../dist/claygl.js"></script>
<title>Basic Cube</title>
</head>
<body>
<style>
html, body, #main {
height: 100%;
margin: 0;
}
</style>
<div id="main"></div>
<script>
var app = clay.application.create('#main', {
init: function (renderer, scene, timeline) {
// Create camera
var camera = new clay.camera.Perspective();
camera.position.set(0, 2, 5);
camera.lookAt(clay.math.Vector3.ZERO);
scene.add(camera);
// Create cube
this._cube = clay.application.createCube();
scene.add(this._cube);
// Create light
var light = new clay.light.Directional();
light.position.set(1, 1, 1);
light.lookAt(this._cube.position);
scene.add(light);
},
loop: function (renderer, scene, timeline) {
this._cube.rotation.rotateY(this.frameTime / 1000);
}
});
window.onresize = function () {
app.resize()
};
</script>
</body>
</html>