Skip to content

Commit 2df88aa

Browse files
committed
Move dev scene into userScene/main.ts
1 parent f191447 commit 2df88aa

File tree

3 files changed

+48
-38
lines changed

3 files changed

+48
-38
lines changed

Diff for: index.html

+3-37
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,15 @@
99
<body>
1010
<canvas id="canvas" style="border: 1px solid black; height: 420px"></canvas>
1111
<script type="module">
12-
import { Geometry, Animation, THREE, SceneController } from "./src/index";
13-
14-
class Scene {
15-
constructor(scene, camera, renderer) {
16-
this.scene = scene;
17-
this.camera = camera;
18-
this.renderer = renderer;
19-
20-
const triangle = new Geometry.Polygon(
21-
[
22-
new THREE.Vector3(-1, -1, 0),
23-
new THREE.Vector3(1, 1, 0),
24-
new THREE.Vector3(1, -1, 0),
25-
],
26-
{
27-
strokeWidth: 4,
28-
fillColor: new THREE.Color("red"),
29-
fillOpacity: 0.5,
30-
strokeColor: new THREE.Color("red"),
31-
},
32-
);
33-
scene.add(triangle);
34-
35-
this.animations = [
36-
new Animation.Wait(),
37-
38-
new Animation.Animation((t, dt) => {
39-
triangle.reshape([
40-
new THREE.Vector3(-1, -1, 0),
41-
new THREE.Vector3(1 + t, 1, 0),
42-
new THREE.Vector3(1, -1, 0),
43-
]);
44-
}),
45-
];
46-
}
47-
}
12+
import { SceneController } from "./src/index";
13+
import UserScene from "./userScene/main.ts";
4814

4915
const canvas = document.querySelector("#canvas");
5016
if (canvas === null) {
5117
throw new Error("canvas is null");
5218
}
5319

54-
const sceneController = new SceneController(Scene, canvas, {
20+
const sceneController = new SceneController(UserScene, canvas, {
5521
aspectRatio: 16 / 9,
5622
pixelHeight: 720,
5723
coordinateHeight: 8,

Diff for: tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
"noImplicitReturns": true,
2727
"noUncheckedIndexedAccess": true
2828
},
29-
"include": ["src"]
29+
"include": ["src", "userScene"]
3030
}

Diff for: userScene/main.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {
2+
Geometry,
3+
Animation,
4+
StudioScene,
5+
AnimationRepresentation,
6+
} from "../src/index.js";
7+
import * as THREE from "three";
8+
9+
export default class Scene implements StudioScene {
10+
animations?: Array<AnimationRepresentation>;
11+
12+
constructor(
13+
public scene: THREE.Scene,
14+
public camera: THREE.OrthographicCamera,
15+
public renderer: THREE.WebGLRenderer,
16+
) {
17+
const triangle = new Geometry.Polygon(
18+
[
19+
new THREE.Vector3(-1, -1, 0),
20+
new THREE.Vector3(1, 1, 0),
21+
new THREE.Vector3(1, -1, 0),
22+
],
23+
{
24+
strokeWidth: 4,
25+
fillColor: new THREE.Color("red"),
26+
fillOpacity: 0.5,
27+
strokeColor: new THREE.Color("red"),
28+
},
29+
);
30+
scene.add(triangle);
31+
32+
this.animations = [
33+
new Animation.Wait(),
34+
35+
new Animation.Animation((t, _) => {
36+
triangle.reshape([
37+
new THREE.Vector3(-1, -1, 0),
38+
new THREE.Vector3(1 + t, 1, 0),
39+
new THREE.Vector3(1, -1, 0),
40+
]);
41+
}),
42+
];
43+
}
44+
}

0 commit comments

Comments
 (0)