Skip to content

Commit

Permalink
camera rotating scene
Browse files Browse the repository at this point in the history
  • Loading branch information
ydcjeff committed Dec 19, 2023
1 parent ef273d5 commit d6fab01
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/scenes/camera-rotating-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ export class CameraRotatingScene extends Scene {
new Vector3(0, 100, -500),
));
camera.rotate(Vector3.left, Math.PI / 9);
camera.rotate(Vector3.up, Math.PI / 6);

const DEFAULT_ANGLE = Math.PI / 3;
const cube = this.createObject('cube', {
const shuttle = this.createObject('shuttle', {
position: Vector3.zero,
scale: new Vector3(100, 100, 100),
color: new Color(0, 0, 255, 0.5),
scale: new Vector3(20, 20, 20),
color: new Color(0, 0, 255, 0.6),
});
cube.rotate(Vector3.up, DEFAULT_ANGLE);
shuttle.rotate(Vector3.left, Math.PI / 1.5);

// X axis
const xCube = this.createObject('cube', {
Expand Down Expand Up @@ -105,22 +104,14 @@ export class CameraRotatingScene extends Scene {
}

onBeforeUpdate(): void {
const speed = 0.005;
if (this.count < 200) {
this.mainCamera.fov -= 0.0001;
// this.mainCamera.rotate(Vector3.down, speed);
// this.count++;
} else if (this.count < 400) {
this.mainCamera.fov += 0.0001;
// this.mainCamera.rotate(Vector3.up, speed);
// this.count++;
} else {
this.count = 0;
}
console.log(this.mainCamera.fov);
this.mainCamera.rotate(Vector3.up, 0.02);
}

async prepareResources(): Promise<void> {
await Promise.all([this.resourceLoader.loadObject('cube'), this.resourceLoader.loadObject('pyramid')]);
await Promise.all([
this.resourceLoader.loadObject('shuttle'),
this.resourceLoader.loadObject('cube'),
this.resourceLoader.loadObject('pyramid'),
]);
}
}

0 comments on commit d6fab01

Please sign in to comment.