-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSphereProjection.html
54 lines (52 loc) · 1.45 KB
/
SphereProjection.html
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.dom.js"></script>
<style>
*{
margin:0;
padding:0;
}
body{
display:flex;
align-items:center;
justify-content:center;
min-height:100vh;
flex-direction: column;
background-color:rgb(50,50,50);
}
</style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/gh/freshfork/[email protected]/p5.easycam.min.js"></script>
<script>
let detail=10;
let slider;
let radius=130;
let easycam;
function setup(){
createCanvas(350,350,WEBGL);
slider=createSlider(5,50,20,1);
createEasyCam({distance:300,rotation:[0.1913417, 0.4619398, -0.1913417, 0.8446232]});
}
function draw(){
background(50);
stroke(255);
strokeWeight(2);
//this is a comment
detail=slider.value();
for(let i=0;i<detail;i++){
let lat=map(i,0,detail,0,PI);
for(let j=0;j<detail;j++){
let lon=map(j,0,detail,0,TWO_PI);
let x=radius*sin(lat)*cos(lon);
let y=radius*sin(lat)*sin(lon);
let z=radius*cos(lat);
point(x,y,z);
}
}
}
</script>
</body>
</html>