Skip to content

Commit

Permalink
increase alpha values, use teapot in lighting scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
ydcjeff committed Dec 18, 2023
1 parent 37464e9 commit 0ccfc24
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/scenes/axis-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class AxisScene extends Scene {
const cube = this.createObject('cube', {
position: Vector3.zero,
scale: new Vector3(100, 100, 100),
color: new Color(255, 255, 255, 0.1),
color: new Color(0, 0, 255, 0.5),
});
cube.rotate(Vector3.up, DEFAULT_ANGLE);

Expand Down
2 changes: 1 addition & 1 deletion src/scenes/camera-rotating-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class CameraRotatingScene extends Scene {
const cube = this.createObject('cube', {
position: Vector3.zero,
scale: new Vector3(100, 100, 100),
color: new Color(255, 0, 0, 0.3),
color: new Color(0, 0, 255, 0.5),
});
cube.rotate(Vector3.up, DEFAULT_ANGLE);

Expand Down
24 changes: 12 additions & 12 deletions src/scenes/combined-direct-light-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@ const green = () => new Color(0, 255, 0);
const blue = () => new Color(0, 0, 255);

Check failure on line 10 in src/scenes/combined-direct-light-scene.ts

View workflow job for this annotation

GitHub Actions / test

'blue' is assigned a value but never used

export class CombinedDirectLightScene extends Scene {
cube?: Object3D;
teapot?: Object3D;

configureScene(): void {
const camera = (this.mainCamera = new Camera(
{
fov: Math.PI / 2,
},
new Vector3(0, 100, -300),
new Vector3(0, 500, -1000),
));
camera.rotate(Vector3.left, Math.PI / 9);

const DEFAULT_ANGLE = Math.PI / 3;

Check failure on line 24 in src/scenes/combined-direct-light-scene.ts

View workflow job for this annotation

GitHub Actions / test

'DEFAULT_ANGLE' is assigned a value but never used
const cube = (this.cube = this.createObject('cube', {
this.teapot = this.createObject('teapot', {
position: Vector3.zero,
scale: new Vector3(100, 100, 100),
color: new Color(255, 0, 0, 0.5),
}));
cube.rotate(Vector3.up, DEFAULT_ANGLE);
});

// // X axis
// const xCube = this.createObject('cube', {
Expand Down Expand Up @@ -74,12 +72,12 @@ export class CombinedDirectLightScene extends Scene {

this.lights.push(
new DirectLight({
direction: new Vector3(1, -1, 1),
direction: new Vector3(1, -1, 0),
}),
);
this.lights.push(
new DirectLight({
direction: new Vector3(0, 1, 1),
direction: new Vector3(0, -1, 0),
}),
);

Expand Down Expand Up @@ -114,12 +112,14 @@ export class CombinedDirectLightScene extends Scene {
}

onBeforeUpdate(): void {
this.cube?.rotate(Vector3.left, 0.01);
this.cube?.rotate(Vector3.up, 0.01);
this.cube?.rotate(Vector3.forward, 0.01);
this.teapot?.rotate(Vector3.up, 0.01);
}

async prepareResources(): Promise<void> {
await Promise.all([this.resourceLoader.loadObject('cube'), this.resourceLoader.loadObject('pyramid')]);
await Promise.all([
this.resourceLoader.loadObject('teapot'),
this.resourceLoader.loadObject('cube'),
this.resourceLoader.loadObject('pyramid'),
]);
}
}
22 changes: 11 additions & 11 deletions src/scenes/direct-light-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@ const green = () => new Color(0, 255, 0);
const blue = () => new Color(0, 0, 255);

Check failure on line 10 in src/scenes/direct-light-scene.ts

View workflow job for this annotation

GitHub Actions / test

'blue' is assigned a value but never used

export class DirectLightScene extends Scene {
cube?: Object3D;
teapot?: Object3D;

configureScene(): void {
const camera = (this.mainCamera = new Camera(
{
fov: Math.PI / 2,
},
new Vector3(0, 100, -300),
new Vector3(0, 500, -1000),
));
camera.rotate(Vector3.left, Math.PI / 9);

const DEFAULT_ANGLE = Math.PI / 3;

Check failure on line 24 in src/scenes/direct-light-scene.ts

View workflow job for this annotation

GitHub Actions / test

'DEFAULT_ANGLE' is assigned a value but never used
const cube = (this.cube = this.createObject('cube', {
this.teapot = this.createObject('teapot', {
position: Vector3.zero,
scale: new Vector3(100, 100, 100),
color: new Color(255, 0, 0, 0.5),
}));
cube.rotate(Vector3.up, DEFAULT_ANGLE);
});

// // X axis
// const xCube = this.createObject('cube', {
Expand Down Expand Up @@ -74,7 +72,7 @@ export class DirectLightScene extends Scene {

this.lights.push(
new DirectLight({
direction: new Vector3(1, -1, 1),
direction: new Vector3(1, -1, 0),
}),
);

Expand Down Expand Up @@ -109,12 +107,14 @@ export class DirectLightScene extends Scene {
}

onBeforeUpdate(): void {
this.cube?.rotate(Vector3.left, 0.01);
this.cube?.rotate(Vector3.up, 0.01);
this.cube?.rotate(Vector3.forward, 0.01);
this.teapot?.rotate(Vector3.up, 0.01);
}

async prepareResources(): Promise<void> {
await Promise.all([this.resourceLoader.loadObject('cube'), this.resourceLoader.loadObject('pyramid')]);
await Promise.all([
this.resourceLoader.loadObject('teapot'),
this.resourceLoader.loadObject('cube'),
this.resourceLoader.loadObject('pyramid'),
]);
}
}
21 changes: 12 additions & 9 deletions src/scenes/point-light-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@ const green = () => new Color(0, 255, 0);
const blue = () => new Color(0, 0, 255);

export class PointLightScene extends Scene {
cube?: Object3D;
teapot?: Object3D;

configureScene(): void {
const camera = (this.mainCamera = new Camera(
{
fov: Math.PI / 2,
},
new Vector3(0, 100, -400),
new Vector3(0, 500, -1000),
));
camera.rotate(Vector3.left, Math.PI / 9);

const DEFAULT_ANGLE = Math.PI / 3;
const cube = (this.cube = this.createObject('cube', {
this.teapot = this.createObject('teapot', {
position: new Vector3(-200, 0, 0),
scale: new Vector3(100, 100, 100),
color: new Color(255, 0, 0, 0.5),
}));
cube.rotate(Vector3.up, DEFAULT_ANGLE);
});

// // X axis
// const xCube = this.createObject('cube', {
Expand Down Expand Up @@ -74,7 +72,8 @@ export class PointLightScene extends Scene {

this.lights.push(
new SpotLight({
position: new Vector3(0, -1, 0),
position: new Vector3(0, 1, -200),
radius: 1000,
}),
);

Expand Down Expand Up @@ -109,10 +108,14 @@ export class PointLightScene extends Scene {
}

onBeforeUpdate(): void {
this.cube?.rotate(Vector3.up, 0.01, Vector3.zero);
this.teapot?.rotate(Vector3.up, 0.01);
}

async prepareResources(): Promise<void> {
await Promise.all([this.resourceLoader.loadObject('cube'), this.resourceLoader.loadObject('pyramid')]);
await Promise.all([
this.resourceLoader.loadObject('teapot'),
this.resourceLoader.loadObject('cube'),
this.resourceLoader.loadObject('pyramid'),
]);
}
}
4 changes: 2 additions & 2 deletions src/scenes/rotating-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class RotatingScene extends Scene {
this.cube1 = this.createObject('cube', {
position: Vector3.zero,
scale: new Vector3(100, 100, 100),
color: new Color(255, 255, 0, 0.1),
color: new Color(255, 255, 0, 0.5),
});
this.cube1.rotate(Vector3.up, DEFAULT_ANGLE);

Expand Down Expand Up @@ -81,7 +81,7 @@ export class RotatingScene extends Scene {
this.cube2 = this.createObject('cube', {
position: new Vector3(-500, 0, 0),
scale: new Vector3(100, 100, 100),
color: new Color(255, 0, 255, 0.3),
color: new Color(255, 0, 255, 0.5),
});
this.cube2.rotate(Vector3.up, angle);

Expand Down
6 changes: 3 additions & 3 deletions src/scenes/scale-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ScaleScene extends Scene {
this.cube1 = this.createObject('cube', {
position: Vector3.zero,
scale: new Vector3(100, 100, 100),
color: new Color(255, 255, 255, 0.1),
color: new Color(255, 0, 0, 0.5),
});
this.cube1.rotate(Vector3.up, DEFAULT_ANGLE);

Expand Down Expand Up @@ -77,14 +77,14 @@ export class ScaleScene extends Scene {
this.cube2 = this.createObject('cube', {
position: new Vector3(-250, 0, 0),
scale: new Vector3(100, 100, 100),
color: new Color(255, 0, 255, 0.3),
color: new Color(0, 255, 0, 0.5),
});
this.cube2.rotate(Vector3.up, DEFAULT_ANGLE);

this.cube3 = this.createObject('cube', {
position: new Vector3(-500, 0, 0),
scale: new Vector3(100, 100, 100),
color: new Color(255, 0, 255, 0.3),
color: new Color(0, 0, 255, 0.5),
});
this.cube3.rotate(Vector3.up, -DEFAULT_ANGLE);

Expand Down
2 changes: 1 addition & 1 deletion src/scenes/solar-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class SolarScene extends Scene {
{
fov: Math.PI / 2,
},
new Vector3(0, 0, -500),
new Vector3(0, 0, -800),
));

this.sun = this.createObject(OBJ_NAMES[0], {
Expand Down
2 changes: 1 addition & 1 deletion src/scenes/translation-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class TranslationScene extends Scene {
const cube = this.createObject('cube', {
position: Vector3.zero,
scale: new Vector3(100, 100, 100),
color: new Color(255, 255, 255, 0.1),
color: new Color(0, 0, 255, 0.5),
});
cube.rotate(Vector3.up, DEFAULT_ANGLE);

Expand Down

0 comments on commit 0ccfc24

Please sign in to comment.