Browse Source

upload to git

master
c 3 months ago
parent
commit
dcfd3ad91c
  1. 19
      index.html
  2. 96
      p5xr.js
  3. 108
      sketch.js
  4. 8
      style.css

19
index.html

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.min.js"></script>
<!--><script src="https://unpkg.com/p5.xr"></script>
<-->
<script src="p5xr.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="utf-8" />
</head>
<body>
<main>
</main>
<script src="sketch.js"></script>
</body>
</html>

96
p5xr.js

File diff suppressed because one or more lines are too long

108
sketch.js

@ -0,0 +1,108 @@ @@ -0,0 +1,108 @@
let n = 0, randomX = [], randomY = [], randomS = [];
var rn;
let tree
let branchLength = 100
let minimumWeight = 0.03
let iteration = 15
function preload() {
createVRCanvas();
}
function setup() {
setVRBackgroundColor(200, 200, 200);
noStroke();
for(let i=0; i<iteration; ++i) {
randomX[i] = random(-175, 175);
randomY[i] = random(-175, 175);
randomS[i] = random(15, 20);
}
createTree();
angleMode(DEGREES)
rn = random(1,1000)
noLoop()
}
function draw() {
n++;
setViewerPosition(0, 10, 350-n);
if(n>=600){
n=0;
setup();
}
//rotateY(n/2);
noStroke();
rotateX(90);
fill(0, 160, 0);
plane(5000, 5000);
fill(128, 128, 0);
rotateX(-90)
for(let i = 0; i<iteration;i++){
randomSeed(rn+i)
translate(randomX[i],0,randomY[i])
//translate(0,0,0)
branch(randomS[i]);
translate(0,-randomS[i],0)
translate(-randomX[i],0,-randomY[i])
}
}
function drawTree(posX,posY,scale){
}
function createTree() {
}
function branch(len) {
strokeWeight(map(len,10,30,0.5,5))
stroke(70,40,20)
line(0,0,0,0,len,0)
translate(0,len,0)
if(len > 10 ){
for(var i=0;i<3;i++){
rotateY(random(100,140));
push();
rotateZ(random(20,50));
branch(len *0.7);
pop();
}
} else {
var r = 80 + random(-20,20)
var g = 120+ random(-20,20)
var b = 40+ random(-20,20)
fill(r,g,b,200);
noStroke()
translate(5,0,0)
rotateZ(90)
triangle(-5,-5,5,5,-5,5)
}
}

8
style.css

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
html, body {
margin: 0;
padding: 0;
}
canvas {
display: block;
}
Loading…
Cancel
Save