claygl/example/app_basic.html

46 lines
1.2 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 (app) {
// Create camera
this._camera = app.createCamera([0, 2, 5], [0, 0, 0]);
// Create cube
this._cube = app.createCube(1, {
diffuseMap: 'assets/textures/crate.gif'
});
// Create light
var light = new clay.light.Directional();
light.position.set(1, 1, 1);
light.lookAt(this._cube.position);
app.scene.add(light);
},
loop: function (app) {
this._cube.rotation.rotateY(app.frameTime / 1000);
}
});
window.onresize = function () {
app.resize()
};
</script>
</body>
</html>