Skip to content

Commit 514c9cd

Browse files
b2rengertherewasaguy
authored andcommitted
adding listener 3D with positionX
1 parent 4ae1859 commit 514c9cd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

examples/spatial_panning_listener/sketch.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function setup() {
3636
cameraControls = QuickSettings.create(5, 5, "Camera Controls");
3737
cameraControls.addRange("camera x rotation", -TWO_PI, TWO_PI, 0, 0.1, camXChange);
3838
cameraControls.addRange("camera y rotation", -PI, PI, -PI/2, 0.1, camYChange);
39-
cameraControls.addRange("camera z position", -1500, 1500, -500, 1, camZChange);
39+
cameraControls.addRange("camera z position", -15000, 1500, -500, 1, camZChange);
4040
cameraControls.addButton("camera reset", resetCam);
4141

4242
simulationParameters = QuickSettings.create(255, 5, "Simulation Parameters");
@@ -52,12 +52,13 @@ function setup() {
5252
//disconnect sound file and send it to output via Panner3D
5353
soundFile.disconnect();
5454
panner3d = new p5.Panner3D();
55+
listener3d = new p5.Listener3D();
56+
//listener3d.connect(panner3d);
5557
soundFile.connect(panner3d);
5658
soundFile.loop();
5759

5860

59-
listener3d = new p5.Listener3D();
60-
61+
6162

6263
}
6364

@@ -86,6 +87,11 @@ function draw() {
8687
panner3d.position( flock.boids[0].position.x,
8788
flock.boids[0].position.y,
8889
flock.boids[0].position.z);
90+
91+
listener3d.spatializer.setPosition(0,0,cam_z_pos)
92+
//listener3d.orientX(cam_y_rot)
93+
//listener3d.spatializer.orientY(cam_x_rot)
94+
// listener3d.spatializer.setOrientation(cam_x_rot,cam_y_rot,0)
8995

9096
}
9197

@@ -104,6 +110,7 @@ function resetFlock(){
104110
flock = new Flock();
105111
for (var i = 0; i < nb; i++) {
106112
var b = new Boid(1,1,-400);
113+
b.acceleration = createVector(random(1,10)*cos(random(TWO_PI)),random(1,10)*sin(random(TWO_PI)),0 )
107114
flock.addBoid(b);
108115
}
109116
}

0 commit comments

Comments
 (0)