Created
July 14, 2019 16:31
-
-
Save brickbones/f4482da4d01857e314f96638e13a6eca to your computer and use it in GitHub Desktop.
Getting started with Zdog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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" /> | |
<title>zzz dog</title> | |
</head> | |
<body> | |
<canvas class="cubes"></canvas> | |
<script src="https://unpkg.com/zdog@1/dist/zdog.dist.min.js"></script> | |
<script> | |
const cubes = new Zdog.Illustration({ | |
element: '.cubes', | |
resize: 'fullscreen', | |
zoom: 2 | |
}) | |
const cubeOne = new Zdog.Box({ | |
addTo: cubes, | |
width: 100, | |
height: 100, | |
depth: 100, | |
stroke: false, | |
leftFace: "#da0", | |
rightFace: "#e62", | |
topFace: '#ed0', | |
bottomFace: '#636' | |
}) | |
const cubeTwo = new Zdog.Box({ | |
addTo: cubes, | |
width: 50, | |
height: 50, | |
depth: 50, | |
stroke: false, | |
leftFace: "#da0", | |
rightFace: "#e62", | |
topFace: '#ed0', | |
bottomFace: '#636', | |
translate: { z: 100 } | |
}) | |
const cubeThree = cubeTwo.copy({ | |
translate: { z: -100 } | |
}) | |
function animateCubes() { | |
cubes.rotate.y += 0.01; | |
cubes.rotate.x += 0.01; | |
cubeTwo.rotate.z += 0.03; | |
cubeThree.rotate.z += 0.03; | |
cubes.updateRenderGraph() | |
requestAnimationFrame(animateCubes) | |
} | |
animateCubes() | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment