Skip to content

Commit b178f96

Browse files
committed
Finally got everything glued together
1 parent 89c2722 commit b178f96

8 files changed

Lines changed: 128 additions & 522 deletions

File tree

RawVis.html

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

test.js renamed to homepage.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ let buffer;
1818
let buffer2;
1919
let gain2 = sfx.createGain();
2020
let animationId;
21+
document.body.insertAdjacentHTML("beforeend", `
22+
<div class="smooth-wrapper disposable">
23+
<div class="smooth-content">
24+
<section class="smooth-visualzer" style="height:180vh;"></section>
25+
<section class="last-visualzer" style="height:180vh;"></section>
26+
</div>
27+
</div>
28+
<h2 id="description" class="disposable"></h2>
29+
<h1 id="statue" class="disposable"></h1>
30+
`);
2131
window.addEventListener('DOMContentLoaded',()=>{
2232
window.scrollTo(0,0)
2333
})
@@ -1461,7 +1471,6 @@ gsap.to(scrollProgress, {
14611471
},
14621472

14631473
})
1464-
14651474
gsap.to(activecamera.position, {
14661475
z: 5.57642003011228,
14671476
y:192.335393361824,

index.html

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,6 @@
222222
</form>
223223
-->
224224

225-
<canvas id="mai">
226-
<!-- <div id="main">
227-
</div> -->
228-
</canvas>
229225

230226
<input
231227
type="file"
@@ -428,26 +424,23 @@
428424
}
429425

430426
</script>
431-
<nav class="nav" style="flex-direction: row;display: flex;position: relative;justify-content: space-between;width:100%;align-items: center;position: absolute;padding:40px;">
427+
<nav class="nav" style="flex-direction: row;display: flex;justify-content: space-between;width:100%;position: absolute;padding:40px;">
432428
<a href="https://subsussp.github.io/THE/" id="head" target="_blank" data-has-parsed="true">
433429
<div id="htext" class="sfxbtn" style="color: white;width: 100%;">
434430
THE
435431
</div>
436432
</a>
437-
<ul>
433+
<ul style="
434+
align-self: center;
435+
">
438436
<li>
439437
<div class="disposable">
440438
<canvas id="wave" style="cursor: pointer;height: 100%;" class="sfxbtn"></canvas>
441439
</div>
442440
</li>
443441
</ul>
444442
</nav>
445-
<div class="smooth-wrapper disposable">
446-
<div class="smooth-content">
447-
<section class="smooth-visualzer" style="height:180vh;"></section>
448-
<section class="last-visualzer" style="height:180vh;"></section>
449-
</div>
450-
</div>
443+
451444
<div id="main">
452445
</div>
453446
<audio id="audio" src="music/Far_From_Any_Road_-_Handsome_Family_(mp3.pm).mp3" style="display:none"></audio>
@@ -470,11 +463,8 @@
470463
</textPath>
471464
</text>
472465
</svg>
473-
<h2 id="description" class="disposable"></h2>
474-
<h1 id="statue" class="disposable"></h1>
475466
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.1/dist/gsap.min.js"></script>
476-
<!-- <script type="module" src="./src/js/scripts.js"></script> -->
477-
<script type="module" src="./test.js"></script>
467+
<script type="module" src="./homepage.js"></script>
478468
<!-- <script type="module">
479469
import { initThreeScene, destroyThreeScene } from './src/js/three.js';
480470
import { load2DPage } from './src/js/back.js';

src/js/scripts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ if(!window.localStorage.path || window.localStorage.path == null || window.local
77
window.localStorage.path = 'home'
88
loadwhat();
99
}
10+

src/js/three.js

Lines changed: 110 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ const sceneController = {
8787
else if (name === 'Specturm') switchScene(SpectrumScene);
8888
else if (name === 'V4') switchScene(SparticleScene);
8989
else if (name === 'Vlow') switchScene(PlaneScene);
90+
else if (name === 'Oscilloscope') switchScene(RawVisual);
9091
}}
9192

9293

9394

94-
gui.add(sceneController, 'currentScene', ['Sphere', 'Particles','Specturm','V4','Vlow'])
95+
gui.add(sceneController, 'currentScene', ['Sphere', 'Particles','Specturm','V4','Vlow','Oscilloscope'])
9596
.name('Scene')
9697
.onChange(sceneController.swapScene);
9798
camera.position.set(6, 8, 14);
@@ -213,6 +214,8 @@ export function loadwhat(){
213214
if(window.localStorage.scene == 'sc3') return SpectrumScene()
214215
if(window.localStorage.scene == 'sc4') return SparticleScene()
215216
if(window.localStorage.scene == 'sc5') return PlaneScene()
217+
if(window.localStorage.scene == 'sc6') return RawVisual()
218+
216219
}
217220
export function initThreeScene() {
218221
window.localStorage.scene = 'sc1'
@@ -597,7 +600,7 @@ function loadpart(){
597600
}
598601

599602
export function destroyThreeScene() {
600-
cancelAnimationFrame(animationId);
603+
cancelAnimationFrame(animationId);
601604
// 1. Stop animation loop
602605
if(gui){
603606
gui.destroy();
@@ -618,9 +621,7 @@ export function destroyThreeScene() {
618621

619622
});
620623
}
621-
622-
// 5. Optionally dispose audio
623-
624+
document.body.querySelectorAll('.disposable').forEach((node)=>node.remove())
624625
// 6. Optional: dispose renderer
625626
renderer?.dispose();
626627
// 7. Dispose audio and analyser
@@ -662,7 +663,6 @@ export function SpectrumScene() {
662663
scene = new THREE.Scene();
663664
gui = new GUI();
664665
analyser = new THREE.AudioAnalyser(sound, 64);
665-
analyser.fftSize = 1024;
666666

667667
let settings = { pov: 36.0, bloom: true };
668668
camera = new THREE.PerspectiveCamera(settings.pov, aspect, 1, 1000);
@@ -1741,8 +1741,8 @@ void main() {
17411741
const thnote = document.createElement('div');
17421742
// secondnote.innerText = "Double click to lock";
17431743
thnote.innerText = "ESC to unlock";
1744-
thnote.className = "notes";
1745-
note.className = "notes";
1744+
thnote.className = "notes disposable";
1745+
note.className = "notes disposable";
17461746
// secondnote.className = "notes";
17471747
thnote.style.top = '20vh';
17481748
thnote.style.position = 'absolute';
@@ -1953,3 +1953,105 @@ void main() {
19531953
renderer.render( scene, camera );
19541954
}
19551955
}
1956+
1957+
export function RawVisual(){
1958+
window.localStorage.scene = 'sc6'
1959+
scene = new THREE.Scene()
1960+
camera = new THREE.PerspectiveCamera(60,window.innerWidth/ window.innerHeight ,0.1,1000)
1961+
1962+
analyser = new THREE.AudioAnalyser(sound, 256);
1963+
const bufferLength = analyser.analyser.frequencyBinCount;
1964+
let dataArray = new Float32Array(bufferLength)
1965+
1966+
gui = new GUI();
1967+
renderer = new THREE.WebGLRenderer({antialias:true})
1968+
renderer.setSize(window.innerWidth,window.innerHeight)
1969+
main.appendChild(renderer.domElement)
1970+
1971+
initControllers('Oscilloscope')
1972+
1973+
1974+
camera.position.z = 15
1975+
1976+
let buffer = new THREE.BufferGeometry()
1977+
buffer.setAttribute("position", new THREE.BufferAttribute(new Float32Array([
1978+
1.0, 1.0, 0.0,
1979+
1.0, -1.0, 0.0,
1980+
-1.0, -1.0, 0.0,
1981+
-1.0, 1.0, 0.0 ]
1982+
),3))
1983+
buffer.setIndex( new THREE.BufferAttribute(
1984+
new Uint16Array([
1985+
0, 1, 3,
1986+
1, 2, 3
1987+
]),
1988+
1
1989+
)
1990+
)
1991+
1992+
let mat = new THREE.ShaderMaterial({
1993+
uniforms:{
1994+
resolution: {value: new THREE.Vector2(window.innerWidth, window.innerHeight)},
1995+
uAudio: {value: new Float32Array(128)}
1996+
},
1997+
side: THREE.DoubleSide,
1998+
vertexShader: `
1999+
varying vec3 pos;
2000+
void main() {
2001+
pos = position;
2002+
gl_Position = vec4(position,1);
2003+
}
2004+
`,
2005+
fragmentShader: `
2006+
uniform vec2 resolution;
2007+
varying vec3 pos;
2008+
uniform float uAudio[128];
2009+
2010+
float getSample(float x){
2011+
2012+
float index = x * 127.0 / resolution.x;
2013+
2014+
int i0 = int(floor(index));
2015+
int i1 = int(ceil(index));
2016+
2017+
float t = fract(index);
2018+
2019+
return mix(uAudio[i0], uAudio[i1], t);
2020+
}
2021+
void main(){
2022+
2023+
float x = gl_FragCoord.x;
2024+
float y = gl_FragCoord.y / resolution.y;
2025+
2026+
float amp = getSample(x);
2027+
2028+
amp = 0.5 - amp * 0.5;
2029+
2030+
float thickness = 0.0004;
2031+
2032+
float line = abs(thickness / (amp - y));
2033+
2034+
gl_FragColor = vec4(vec3(line),1.0);
2035+
}
2036+
`
2037+
})
2038+
scene.add(new THREE.Mesh(buffer,mat))
2039+
let frame = 0
2040+
function animate(time){
2041+
frame++
2042+
if(analyser && frame % 4 == 0){
2043+
analyser.analyser.getFloatTimeDomainData(dataArray)
2044+
mat.uniforms.uAudio.value = dataArray
2045+
}
2046+
renderer.render(scene,camera)
2047+
requestAnimationFrame(animate)
2048+
}
2049+
animate()
2050+
window.addEventListener('resize',()=> {
2051+
camera.aspect = window.innerWidth/ window.innerHeight;
2052+
camera.updateProjectionMatrix();
2053+
renderer.setSize(window.innerWidth, window.innerHeight);
2054+
renderer.setPixelRatio(window.devicePixelRatio);
2055+
mat.uniforms.resolution.value= new THREE.Vector2(window.innerWidth, window.innerHeight);
2056+
})
2057+
}

tasks.txt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,5 @@ thinking of a way to make the mouse interactive with the scene
77
75.5327255724013
88
95.61752943615642
99
95.61752943615642
10-
chatgpt prompt
11-
`how to make something slowmotion?` (i want to apply it for the background visualizer)
12-
13-
make the mouse drag down transform a scroll trigger animation
14-
15-
something wrong with the wrapper for the website scroll
16-
<<<<<<< HEAD
1710

18-
19-
Audio config with the scroll trigger so it sounds far away
20-
=======
21-
>>>>>>> a86d3cbadc7a58705a218abc845ac842739e3f16
11+
`how to make something slowmotion?` (i want to apply it for the background visualizer)

0 commit comments

Comments
 (0)