Skip to content

Commit cc9213c

Browse files
authored
Merge pull request #2 from nitrous-git/Removing-Vite-Dependancy
Removing vite dependancy
2 parents 1ae1aa9 + 2791b88 commit cc9213c

4 files changed

Lines changed: 42 additions & 39 deletions

File tree

index.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="utf-8">
5-
<title>Chaotic Attractor in Three.js</title>
6-
<style>
7-
body { margin: 0; }
8-
</style>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Chaotic Attractors in Three.js</title>
8+
<link rel="stylesheet" href="./style.css" />
99
</head>
10+
1011
<body>
11-
<script type="module" src="/main.js"></script>
12+
<script type="importmap">
13+
{
14+
"imports": {
15+
"three": "https://cdn.jsdelivr.net/npm/three@0.182.0/build/three.module.js",
16+
"lil-gui": "https://cdn.jsdelivr.net/npm/lil-gui@0.21/+esm"
17+
}
18+
}
19+
</script>
20+
<script type="module" src="/main.js"></script>
1221
</body>
22+
1323
</html>

main.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const ATTRACTORS = {
5656
dt: 0.01,
5757
T: 600,
5858
scale: 3,
59+
maxPointsPerFrame : 13,
5960

6061
cameraPosition: [0, 3, 10],
6162
cameraLookAt: [0, 2, 0],
@@ -91,6 +92,7 @@ const ATTRACTORS = {
9192
dt: 0.001,
9293
T: 200,
9394
scale: 1.8,
95+
maxPointsPerFrame : 50,
9496

9597
cameraPosition: [0, 45, 80],
9698
cameraLookAt: [0, 45, 0],
@@ -118,6 +120,7 @@ const ATTRACTORS = {
118120
dt: 0.01,
119121
T: 1000,
120122
scale: 1.6,
123+
maxPointsPerFrame : 35,
121124

122125
cameraPosition: [0, 15, 45],
123126
cameraLookAt: [0, 8, 0],
@@ -145,6 +148,7 @@ const ATTRACTORS = {
145148
dt: 0.01,
146149
T: 1800,
147150
scale: 12.0,
151+
maxPointsPerFrame : 35,
148152

149153
cameraPosition: [45, 45, 45],
150154
cameraLookAt: [0, 0, 0],
@@ -170,6 +174,7 @@ const ATTRACTORS = {
170174
dt: 0.005,
171175
T: 250,
172176
scale: 5.0,
177+
maxPointsPerFrame : 25,
173178

174179
cameraPosition: [45, 45, 45],
175180
cameraLookAt: [0, 0, 0],
@@ -195,6 +200,7 @@ const ATTRACTORS = {
195200
dt: 0.005,
196201
T: 900,
197202
scale: 2.0,
203+
maxPointsPerFrame : 30,
198204

199205
cameraPosition: [60, 45, 25],
200206
cameraLookAt: [2, 5, 0],
@@ -224,6 +230,7 @@ const ATTRACTORS = {
224230
dt: 0.01,
225231
T: 300,
226232
scale: 3,
233+
maxPointsPerFrame : 30,
227234

228235
cameraPosition: [0, 0, 5],
229236
cameraLookAt: [0, 0, 0],
@@ -260,6 +267,7 @@ const settings = {
260267
scale: 3,
261268

262269
pointsPerSecond: 3.0,
270+
maxPointsPerFrame : 3.0,
263271

264272
trail: 0.7,
265273
band: 0.005,
@@ -475,6 +483,9 @@ function applyPreset(name) {
475483
}
476484

477485
function applyCameraPreset(def) {
486+
487+
settings.maxPointsPerFrame = def.maxPointsPerFrame;
488+
478489
camera.position.set(
479490
def.cameraPosition[0],
480491
def.cameraPosition[1],
@@ -555,14 +566,14 @@ function setupGUI() {
555566

556567
trackController(
557568
simulationFolder
558-
.add(settings, "T", 10, 1000, 1)
569+
.add(settings, "T", 10, 3000, 1)
559570
.name("Total Time")
560571
.onFinishChange(rebuildTrajectory)
561572
);
562573

563574
trackController(
564575
simulationFolder
565-
.add(settings, "scale", 0.05, 10, 0.05)
576+
.add(settings, "scale", 0.05, 18, 0.05)
566577
.name("Scale")
567578
.onFinishChange(rebuildTrajectory)
568579
);
@@ -584,19 +595,10 @@ function setupGUI() {
584595
})
585596
);
586597

587-
trackController(
588-
visualFolder
589-
.add(settings, "band", 0.0005, 0.05, 0.0005)
590-
.name("Glow Band")
591-
.onChange(function (value) {
592-
uniforms.u_band.value = value;
593-
})
594-
);
595-
596598
trackController(
597599
visualFolder
598600
.add(settings, "intensity", 0.1, 5.0, 0.1)
599-
.name("Glow Intensity")
601+
.name("Trail Length")
600602
.onChange(function (value) {
601603
uniforms.u_intensity.value = value;
602604
})
@@ -618,7 +620,10 @@ function animate(t) {
618620

619621
// reveal the line progressively
620622
const elapsed = (t - revealStartTime) * 0.001; // seconds since start
621-
drawCount = Math.min(drawCount + Math.floor(elapsed * settings.pointsPerSecond), trajectory_points.length);
623+
624+
const pointsThisFrame = Math.min(Math.floor(elapsed * settings.pointsPerSecond), settings.maxPointsPerFrame);
625+
626+
drawCount = Math.min(drawCount + pointsThisFrame, trajectory_points.length);
622627
geom.setDrawRange(0, drawCount);
623628

624629
// head index is drawCount-1
@@ -646,4 +651,3 @@ setupGUI();
646651
applyCameraPreset(ATTRACTORS[settings.attractor]);
647652
rebuildTrajectory();
648653
requestAnimationFrame(animate);
649-

package.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
html,
2+
body {
3+
margin: 0;
4+
padding: 0;
5+
width: 100%;
6+
height: 100%;
7+
overflow: hidden;
8+
background: #000;
9+
}

0 commit comments

Comments
 (0)