html
html
1
2
3
4
5
6
7
8
9
10
<!doctype html>
<html>
<head>
<title>Our Planets</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r120/three.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
</head>
<body>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
body {
background-color: black;
margin:0;
position:fixed;
margin: auto;
width: 100em;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
let W, H;
let canvas, scene, camera, renderer, light, e;
let mouse = {x: 0, y: 0};
let move = false;
let cubes = [];
let textures = [];
const NBR_CUBE = 100;
const random = (max=1, min=0) => Math.random() * (max - min) + min;
const eventsListener = ()=> {
document.body.addEventListener("touchstart",function(e){
touchx = e.touches[0].pageX;
touchy = e.touches[0].pageY;
});
document.body.addEventListener("touchmove",function(e){
camera.position.x += 0.1*(e.touches[0].pageX-touchx);
touchx = e.touches[0].pageX;
camera.position.y += 0.1*(e.touches[0].pageY-touchy);
touchy = e.touches[0].pageY;
});
document.body.addEventListener("mousemove", function(e){
if(move){
camera.position.x += 0.1*(e.clientX-mouse.x);
camera.position.y += 0.1*(e.clientY-mouse.y);
mouse.x = e.clientX;
mouse.y = e.clientY;
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run