Skip to content

Commit

Permalink
Use an iso camera
Browse files Browse the repository at this point in the history
  • Loading branch information
stasm committed Mar 6, 2024
1 parent ea341e2 commit a5d49c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
10 changes: 7 additions & 3 deletions src/blueprints/blu_camera_follow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {perspective} from "../../lib/projection.js";
import {orthographic} from "../../lib/projection.js";
import {camera_canvas} from "../components/com_camera.js";
import {children} from "../components/com_children.js";
import {mimic} from "../components/com_mimic.js";
Expand All @@ -11,8 +11,12 @@ export function blueprint_camera_follow(game: Game) {
transform(),
mimic(first_named(game.World, "camera anchor")),
children([
transform([0, 1, -6], [0, 1, 0, 0]),
camera_canvas(perspective(1, 0.1, 1000), [0.1, 0.5, 0.8, 1]),
transform(
[50, 50, 50],
// Isometric projection: Y 45°, X -35.264°, Z 0°
[-0.28, 0.364, 0.116, 0.88],
),
camera_canvas(orthographic([7, 7], 1, 200), [0.1, 0.5, 0.8, 1]),
]),
];
}
7 changes: 1 addition & 6 deletions src/blueprints/blu_player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ export function blueprint_player(game: Game) {
}),
],
// Camera rig anchor.
[
transform(),
named("camera anchor"),
move(0, 3),
control_player(false, 0, 0.2, -10, 80),
],
[transform(undefined, undefined, undefined, true), named("camera anchor")],
// Overhead light.
[transform([0, 2, 0]), light_point([1, 1, 1], 5)],
),
Expand Down
8 changes: 2 additions & 6 deletions src/scenes/sce_stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@ export function scene_stage(game: Game) {
instantiate(game, [transform(), set_rotation(-30, 30, 0), light_directional([1, 1, 1], 0.1)]);

// Player.
instantiate(game, [...blueprint_player(game), set_position(0, 1, 0), set_rotation(0, 180, 0)]);
instantiate(game, [...blueprint_player(game), set_position(0, 1, 0)]);

// Camera.
instantiate(game, [
...blueprint_camera_follow(game),
set_position(0, 1000, 1000),
set_rotation(0, 180, 0),
]);
instantiate(game, [...blueprint_camera_follow(game), set_position(-100, 0, -100)]);

// Item spawner.
instantiate(game, [
Expand Down

0 comments on commit a5d49c0

Please sign in to comment.