Fixed bundle bug.
This commit is contained in:
@ -18,11 +18,8 @@ const outputFix = (output, dir) => {
|
|||||||
const matches = out.matchAll(reg);
|
const matches = out.matchAll(reg);
|
||||||
let match;
|
let match;
|
||||||
while(!(match = matches.next()).done) {
|
while(!(match = matches.next()).done) {
|
||||||
const exp = new RegExp(`${match.value[1]}\.`);
|
const exp = new RegExp(`${match.value[1]}\.`, 'gm');
|
||||||
exp.multiline = true;
|
|
||||||
|
|
||||||
scanFile(path.join(dir, match.value[2]), dir);
|
scanFile(path.join(dir, match.value[2]), dir);
|
||||||
|
|
||||||
out = out.replace(match.value[0], '').replace(exp, 'exports.');
|
out = out.replace(match.value[0], '').replace(exp, 'exports.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
0
ts/asset/AssetManager.ts
Normal file
0
ts/asset/AssetManager.ts
Normal file
40
ts/game/Game.ts
Normal file
40
ts/game/Game.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
export abstract class Game {
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
print("init");
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
print("update");
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose() {
|
||||||
|
print("Disposed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let GAME_MAIN:Game|null = null;
|
||||||
|
|
||||||
|
export const gameSetMain = (game:Game) => {
|
||||||
|
print("setting", game);
|
||||||
|
GAME_MAIN = game;
|
||||||
|
}
|
||||||
|
|
||||||
|
const init = () => {
|
||||||
|
if(!GAME_MAIN) return;
|
||||||
|
GAME_MAIN.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
const update = () => {
|
||||||
|
if(!GAME_MAIN) return;
|
||||||
|
GAME_MAIN.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
const dispose = () => {
|
||||||
|
if(!GAME_MAIN) return;
|
||||||
|
GAME_MAIN.dispose();
|
||||||
|
}
|
46
ts/main.ts
46
ts/main.ts
@ -1,47 +1,7 @@
|
|||||||
let cube:Primitive;
|
import { Game, gameSetMain } from "./game/Game";
|
||||||
let shader:Shader;
|
|
||||||
let camera:Camera;
|
|
||||||
let texture:Texture;
|
|
||||||
let n:number;
|
|
||||||
|
|
||||||
const init = () => {
|
class MainGame extends Game {
|
||||||
print('Main invoked');
|
|
||||||
|
|
||||||
n = 0;
|
|
||||||
|
|
||||||
// Create Quad
|
|
||||||
cube = primitiveCreate();
|
|
||||||
quadInit(cube, 0, -1, -1, 0, 0, 1, 1, 1, 1);
|
|
||||||
|
|
||||||
// Create Camera
|
|
||||||
camera = cameraCreate();
|
|
||||||
|
|
||||||
// Load Shader
|
|
||||||
shader = shaderCreate();
|
|
||||||
assetShaderLoad(shader, "shaders/textured.vert", "shaders/textured.frag");
|
|
||||||
|
|
||||||
// Texture load
|
|
||||||
texture = textureCreate();
|
|
||||||
assetTextureLoad(texture, "test_texture.png");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const update = () => {
|
gameSetMain(new MainGame());
|
||||||
shaderUse(shader);
|
|
||||||
shaderUseTexture(shader, texture);
|
|
||||||
|
|
||||||
n += epochGetDelta();
|
|
||||||
|
|
||||||
|
|
||||||
cameraLookAt(camera, 3,3,3, 0,0,0);
|
|
||||||
cameraPerspective(camera, 45, 16/9, 0.01, 100);
|
|
||||||
|
|
||||||
|
|
||||||
shaderUseCamera(shader, camera);
|
|
||||||
shaderUsePosition(shader, 0,0,0, 0,n,0);
|
|
||||||
primitiveDraw(cube, 0, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const dispose = () => {
|
|
||||||
cameraDispose(camera);
|
|
||||||
shaderDispose(shader);
|
|
||||||
}
|
|
Reference in New Issue
Block a user