initial commit uwu
This commit is contained in:
commit
ccd31710ae
7 changed files with 6351 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules/
|
||||||
|
dist/bundle.js
|
30
dist/index.html
vendored
Normal file
30
dist/index.html
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>wfc</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
#render {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="render"></canvas>
|
||||||
|
<script type="text/javascript" src="bundle.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
6209
package-lock.json
generated
Normal file
6209
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
29
package.json
Normal file
29
package.json
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"name": "wfcjs",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "wave function collapse in typescript",
|
||||||
|
"private": true,
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "webpack",
|
||||||
|
"start": "NODE_ENV=development webpack-dev-server --open"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.bsd.gay/fef/wfcjs.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"grahics",
|
||||||
|
"wfc"
|
||||||
|
],
|
||||||
|
"author": "fef",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"devDependencies": {
|
||||||
|
"ts-loader": "^9.4.1",
|
||||||
|
"typescript": "^4.8.4",
|
||||||
|
"webpack": "^5.74.0",
|
||||||
|
"webpack-cli": "^4.10.0",
|
||||||
|
"webpack-dev-server": "^4.11.1",
|
||||||
|
"webpack-merge": "^5.8.0"
|
||||||
|
}
|
||||||
|
}
|
38
src/app.ts
Normal file
38
src/app.ts
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
export class App {
|
||||||
|
private canvas: HTMLCanvasElement;
|
||||||
|
private lastTime: DOMHighResTimeStamp = 0;
|
||||||
|
private isRunning: boolean = false;
|
||||||
|
|
||||||
|
public constructor(canvas: HTMLCanvasElement) {
|
||||||
|
this.canvas = canvas;
|
||||||
|
this.updateSize(window.innerWidth, window.innerHeight);
|
||||||
|
|
||||||
|
document.onresize = () => this.updateSize(window.innerWidth, window.innerHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
public run() {
|
||||||
|
this.isRunning = true;
|
||||||
|
this.draw(this.lastTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public stop() {
|
||||||
|
this.isRunning = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private draw(time: DOMHighResTimeStamp) {
|
||||||
|
// TODO: actually draw stuff
|
||||||
|
|
||||||
|
this.lastTime = time;
|
||||||
|
if (this.isRunning) {
|
||||||
|
window.requestAnimationFrame(t => this.draw(t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateSize(width: number, height: number) {
|
||||||
|
this.canvas.width = width;
|
||||||
|
this.canvas.height = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const app = new App(document.getElementById("render") as HTMLCanvasElement);
|
||||||
|
app.run();
|
15
tsconfig.json
Normal file
15
tsconfig.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"strict": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/app.ts"
|
||||||
|
]
|
||||||
|
}
|
28
webpack.config.js
Normal file
28
webpack.config.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: "./src/app.ts",
|
||||||
|
mode: process.env.NODE_ENV || "production",
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.ts$/,
|
||||||
|
loader: "ts-loader",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
devtool: "inline-source-map",
|
||||||
|
devServer: {
|
||||||
|
static: "./dist",
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
filename: "bundle.js",
|
||||||
|
path: path.resolve(__dirname, "dist"),
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: [ ".ts", ".js", ".json" ],
|
||||||
|
},
|
||||||
|
experiments: {
|
||||||
|
topLevelAwait: true,
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in a new issue