Skip to content

Commit

Permalink
Set boom length to be better
Browse files Browse the repository at this point in the history
  • Loading branch information
surrsurus committed May 29, 2024
1 parent 1fe72e6 commit 0fb0570
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions assets/js/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ function animate() {
const b = camera_rig.boom.position.clone();

const dir = a.clone().sub(b).normalize();
const dis = a.distanceTo(b) - camera_rig.coronaSafetyDistance;
const dis = a.distanceTo(b) - camera_rig.boomLength;

camera_rig.boom.position.addScaledVector(dir, dis);
camera_rig.controls.target.copy(me.position)
camera_rig.camera.lookAt(me.position);
}

// Send updates if we are getting updates from the player
if (Object.values(keys).some(v => v === true)) {
if (Object.values(keys).some(key => key === true)) {
channel.push("update_position", {
id: my_id,
x: me.position.x,
Expand Down
7 changes: 4 additions & 3 deletions assets/js/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ export class Light extends Drawable {

export class CameraRig {
constructor() {
this.coronaSafetyDistance = 0.3;

// sets how long the camera boom is. the camera will be allowed to go below this, but won't go above it
this.boomLength = 0.15;

this.camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.01, 10);
this.camera.position.set(0, 0.3, -1);
this.camera.lookAt(scene.position);

this.boom = new THREE.Object3D;
this.boom.position.z = -this.coronaSafetyDistance;
this.boom.position.z = -this.boomLength;
this.boom.add(this.camera);

this.controls = new OrbitControls(this.camera, renderer.domElement);
Expand Down

0 comments on commit 0fb0570

Please sign in to comment.