@fi4f/hg 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/dist/asset.d.ts +46 -0
- package/dist/asset.d.ts.map +1 -0
- package/dist/{core/asset.js → asset.js} +5 -30
- package/dist/asset.js.map +1 -0
- package/dist/{core/cache.d.ts → cache.d.ts} +17 -19
- package/dist/cache.d.ts.map +1 -0
- package/dist/{core/cache.js → cache.js} +5 -43
- package/dist/cache.js.map +1 -0
- package/dist/canvas.d.ts +4 -0
- package/dist/canvas.d.ts.map +1 -0
- package/dist/canvas.js +12 -0
- package/dist/canvas.js.map +1 -0
- package/dist/el.d.ts +6 -0
- package/dist/el.d.ts.map +1 -0
- package/dist/el.js +7 -0
- package/dist/el.js.map +1 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js.map +1 -0
- package/dist/hg.d.ts +13 -12
- package/dist/hg.d.ts.map +1 -1
- package/dist/hg.js +14 -13
- package/dist/hg.js.map +1 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/matrix2.d.ts +152 -0
- package/dist/matrix2.d.ts.map +1 -0
- package/dist/matrix2.js +262 -0
- package/dist/matrix2.js.map +1 -0
- package/dist/matrix3.d.ts +196 -0
- package/dist/matrix3.d.ts.map +1 -0
- package/dist/matrix3.js +352 -0
- package/dist/matrix3.js.map +1 -0
- package/dist/matrix4.d.ts +253 -0
- package/dist/matrix4.d.ts.map +1 -0
- package/dist/matrix4.js +465 -0
- package/dist/matrix4.js.map +1 -0
- package/dist/{core/scene.d.ts → scene.d.ts} +2 -3
- package/dist/scene.d.ts.map +1 -0
- package/dist/scene.js.map +1 -0
- package/dist/sprite.d.ts +24 -0
- package/dist/sprite.d.ts.map +1 -0
- package/dist/sprite.js +49 -0
- package/dist/sprite.js.map +1 -0
- package/dist/stage.d.ts +100 -0
- package/dist/stage.d.ts.map +1 -0
- package/dist/stage.js +303 -0
- package/dist/stage.js.map +1 -0
- package/dist/vector2.d.ts +114 -0
- package/dist/vector2.d.ts.map +1 -0
- package/dist/vector2.js +168 -0
- package/dist/vector2.js.map +1 -0
- package/dist/vector3.d.ts +126 -0
- package/dist/vector3.d.ts.map +1 -0
- package/dist/vector3.js +190 -0
- package/dist/vector3.js.map +1 -0
- package/dist/vector4.d.ts +135 -0
- package/dist/vector4.d.ts.map +1 -0
- package/dist/vector4.js +209 -0
- package/dist/vector4.js.map +1 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js.map +1 -0
- package/package.json +1 -1
- package/dist/core/asset.d.ts +0 -71
- package/dist/core/asset.d.ts.map +0 -1
- package/dist/core/asset.js.map +0 -1
- package/dist/core/cache.d.ts.map +0 -1
- package/dist/core/cache.js.map +0 -1
- package/dist/core/event.d.ts.map +0 -1
- package/dist/core/event.js.map +0 -1
- package/dist/core/scene.d.ts.map +0 -1
- package/dist/core/scene.js.map +0 -1
- package/dist/core/stage.d.ts +0 -130
- package/dist/core/stage.d.ts.map +0 -1
- package/dist/core/stage.js +0 -308
- package/dist/core/stage.js.map +0 -1
- package/dist/math/index.d.ts +0 -6
- package/dist/math/index.d.ts.map +0 -1
- package/dist/math/index.js +0 -6
- package/dist/math/index.js.map +0 -1
- package/dist/math/matrix2.d.ts +0 -58
- package/dist/math/matrix2.d.ts.map +0 -1
- package/dist/math/matrix2.js +0 -178
- package/dist/math/matrix2.js.map +0 -1
- package/dist/math/matrix3.d.ts +0 -92
- package/dist/math/matrix3.d.ts.map +0 -1
- package/dist/math/matrix3.js +0 -255
- package/dist/math/matrix3.js.map +0 -1
- package/dist/math/matrix4.d.ts +0 -138
- package/dist/math/matrix4.d.ts.map +0 -1
- package/dist/math/matrix4.js +0 -352
- package/dist/math/matrix4.js.map +0 -1
- package/dist/math/vector2.d.ts +0 -38
- package/dist/math/vector2.d.ts.map +0 -1
- package/dist/math/vector2.js +0 -67
- package/dist/math/vector2.js.map +0 -1
- package/dist/math/vector3.d.ts +0 -34
- package/dist/math/vector3.d.ts.map +0 -1
- package/dist/math/vector3.js +0 -74
- package/dist/math/vector3.js.map +0 -1
- package/dist/math/vector4.d.ts +0 -39
- package/dist/math/vector4.d.ts.map +0 -1
- package/dist/math/vector4.js +0 -81
- package/dist/math/vector4.js.map +0 -1
- package/dist/util/types.d.ts +0 -2
- package/dist/util/types.d.ts.map +0 -1
- package/dist/util/types.js +0 -2
- package/dist/util/types.js.map +0 -1
- package/dist/util/version.d.ts.map +0 -1
- package/dist/util/version.js.map +0 -1
- /package/dist/{core/event.d.ts → event.d.ts} +0 -0
- /package/dist/{core/event.js → event.js} +0 -0
- /package/dist/{core/scene.js → scene.js} +0 -0
- /package/dist/{util/version.d.ts → version.d.ts} +0 -0
- /package/dist/{util/version.js → version.js} +0 -0
package/dist/stage.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Event } from "./event.js";
|
|
2
|
+
import { Scene } from "./scene.js";
|
|
3
|
+
export type Stage = {
|
|
4
|
+
readonly configureDebug: "print" | "paint" | boolean;
|
|
5
|
+
readonly configureW: number;
|
|
6
|
+
readonly configureH: number;
|
|
7
|
+
readonly configureLogicalBackground: string;
|
|
8
|
+
readonly configureVirtualBackground: string;
|
|
9
|
+
readonly configureScaleIncrement: number | undefined;
|
|
10
|
+
readonly configureImageSmoothing: ImageSmoothingQuality | undefined;
|
|
11
|
+
logicalCanvasElement: HTMLCanvasElement;
|
|
12
|
+
virtualCanvasElement: OffscreenCanvas;
|
|
13
|
+
logicalCanvasContext: CanvasRenderingContext2D;
|
|
14
|
+
virtualCanvasContext: OffscreenCanvasRenderingContext2D;
|
|
15
|
+
virtualScale: number;
|
|
16
|
+
event: Event.Tree;
|
|
17
|
+
debug: Map<string, string | undefined>;
|
|
18
|
+
scene: Scene | undefined;
|
|
19
|
+
measuredFramesPerSecond: number;
|
|
20
|
+
measuredAverageFrame: number;
|
|
21
|
+
measuredMinimumFrame: number;
|
|
22
|
+
measuredMaximumFrame: number;
|
|
23
|
+
measuredAverageUpdate: number;
|
|
24
|
+
measuredMinimumUpdate: number;
|
|
25
|
+
measuredMaximumUpdate: number;
|
|
26
|
+
measuredAverageRender: number;
|
|
27
|
+
measuredMinimumRender: number;
|
|
28
|
+
measuredMaximumRender: number;
|
|
29
|
+
};
|
|
30
|
+
export declare namespace Stage {
|
|
31
|
+
type Options = {
|
|
32
|
+
canvas?: HTMLCanvasElement;
|
|
33
|
+
debug?: "print" | "paint" | boolean;
|
|
34
|
+
w?: number;
|
|
35
|
+
h?: number;
|
|
36
|
+
lbg?: string;
|
|
37
|
+
vbg?: string;
|
|
38
|
+
si?: number;
|
|
39
|
+
is?: ImageSmoothingQuality;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A collection of constants and functions for constructing and
|
|
44
|
+
* interacting with Stage objects.
|
|
45
|
+
*/
|
|
46
|
+
export declare const Stage: {
|
|
47
|
+
"new"(o?: Stage.Options): {
|
|
48
|
+
configureDebug: boolean | "print" | "paint";
|
|
49
|
+
configureW: number;
|
|
50
|
+
configureH: number;
|
|
51
|
+
configureLogicalBackground: string;
|
|
52
|
+
configureVirtualBackground: string;
|
|
53
|
+
configureScaleIncrement: number | undefined;
|
|
54
|
+
configureImageSmoothing: ImageSmoothingQuality | undefined;
|
|
55
|
+
logicalCanvasElement: HTMLCanvasElement;
|
|
56
|
+
virtualCanvasElement: OffscreenCanvas;
|
|
57
|
+
logicalCanvasContext: CanvasRenderingContext2D;
|
|
58
|
+
virtualCanvasContext: OffscreenCanvasRenderingContext2D;
|
|
59
|
+
virtualScale: number;
|
|
60
|
+
event: {
|
|
61
|
+
root: {
|
|
62
|
+
children: Map<any, any>;
|
|
63
|
+
listeners: Map<any, any>;
|
|
64
|
+
};
|
|
65
|
+
pending: never[];
|
|
66
|
+
};
|
|
67
|
+
debug: Map<any, any>;
|
|
68
|
+
scene: undefined;
|
|
69
|
+
measuredFramesPerSecond: number;
|
|
70
|
+
measuredAverageFrame: number;
|
|
71
|
+
measuredMinimumFrame: number;
|
|
72
|
+
measuredMaximumFrame: number;
|
|
73
|
+
measuredAverageUpdate: number;
|
|
74
|
+
measuredMinimumUpdate: number;
|
|
75
|
+
measuredMaximumUpdate: number;
|
|
76
|
+
measuredAverageRender: number;
|
|
77
|
+
measuredMinimumRender: number;
|
|
78
|
+
measuredMaximumRender: number;
|
|
79
|
+
};
|
|
80
|
+
getLogicalSize(stage: Stage): [number, number];
|
|
81
|
+
getVirtualSize(stage: Stage): [number, number];
|
|
82
|
+
getVirtualScale(stage: Stage): number;
|
|
83
|
+
use(stage: Stage, scene: Scene | undefined): void;
|
|
84
|
+
listen<T>(stage: Stage, type: string, listener: Event.Listener<T>, o?: {
|
|
85
|
+
path?: string;
|
|
86
|
+
defer?: boolean;
|
|
87
|
+
}): void;
|
|
88
|
+
deafen<T>(stage: Stage, type?: string, listener?: Event.Listener<T>, o?: {
|
|
89
|
+
path?: string;
|
|
90
|
+
defer?: boolean;
|
|
91
|
+
}): void;
|
|
92
|
+
dispatch<T>(stage: Stage, type: string, event: T, o?: {
|
|
93
|
+
path?: string;
|
|
94
|
+
defer?: boolean;
|
|
95
|
+
}): void;
|
|
96
|
+
poll(stage: Stage): void;
|
|
97
|
+
getDebugInfo(stage: Stage, id: string): string | undefined;
|
|
98
|
+
setDebugInfo(stage: Stage, id: string, info: string | undefined): void;
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=stage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage.d.ts","sourceRoot":"","sources":["../src/stage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAI,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,KAAK,EAAI,MAAM,YAAY,CAAA;AAGpC,MAAM,MAAM,KAAK,GAAG;IAElB,QAAQ,CAAC,cAAc,EAAc,OAAO,GAAG,OAAO,GAA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AC,EAAE,MAAM,CAAA;QAChB,GAAO,CAAC,EAAE,MAAM,CAAA;QAChB,EAAO,CAAC,EAAE,MAAM,CAAA;QAChB,EAAO,CAAC,EAAE,qBAAqB,CAAA;KAChC,CAAA;CACF;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK;cACP,KAAK,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BA2FA,KAAK;0BAOL,KAAK;2BAOJ,KAAK;eAIjB,KAAK,SAAS,KAAK,GAAG,SAAS;WAInC,CAAC,SAAS,KAAK,QAAU,MAAM,YAAc,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAO;QAAE,IAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAM,CAAC,EAAE,OAAO,CAAA;KAAE;WAIzG,CAAC,SAAS,KAAK,SAAU,MAAM,aAAc,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAO;QAAE,IAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAM,CAAC,EAAE,OAAO,CAAA;KAAE;aAIvG,CAAC,SAAS,KAAK,QAAQ,MAAM,SAAS,CAAC,MAAO;QAAE,IAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAM,CAAC,EAAE,OAAO,CAAA;KAAE;gBAI/E,KAAK;wBAIG,KAAK,MAAM,MAAM;wBAIjB,KAAK,MAAM,MAAM,QAAQ,MAAM,GAAG,SAAS;CAGhE,CAAA"}
|
package/dist/stage.js
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { Canvas } from "./canvas.js";
|
|
2
|
+
import { Event } from "./event.js";
|
|
3
|
+
import { Scene } from "./scene.js";
|
|
4
|
+
import { Vector2 } from "./vector2.js";
|
|
5
|
+
/**
|
|
6
|
+
* A collection of constants and functions for constructing and
|
|
7
|
+
* interacting with Stage objects.
|
|
8
|
+
*/
|
|
9
|
+
export const Stage = {
|
|
10
|
+
new(o) {
|
|
11
|
+
const configureDebug = o?.debug ?? false;
|
|
12
|
+
const configureW = o?.w ?? 0;
|
|
13
|
+
const configureH = o?.h ?? 0;
|
|
14
|
+
const configureLogicalBackground = o?.lbg ?? "#000";
|
|
15
|
+
const configureVirtualBackground = o?.vbg ?? "#fff";
|
|
16
|
+
const configureScaleIncrement = o?.si;
|
|
17
|
+
const configureImageSmoothing = o?.is;
|
|
18
|
+
const logicalCanvasElement = o?.canvas ?? Canvas.Default();
|
|
19
|
+
const virtualCanvasElement = new OffscreenCanvas(configureW || logicalCanvasElement.width, configureH || logicalCanvasElement.height);
|
|
20
|
+
const logicalCanvasContext = logicalCanvasElement.getContext("2d");
|
|
21
|
+
const virtualCanvasContext = virtualCanvasElement.getContext("2d");
|
|
22
|
+
// configure image smoothing
|
|
23
|
+
logicalCanvasContext.imageSmoothingEnabled = !!configureImageSmoothing;
|
|
24
|
+
virtualCanvasContext.imageSmoothingEnabled = !!configureImageSmoothing;
|
|
25
|
+
if (configureImageSmoothing) {
|
|
26
|
+
logicalCanvasContext.imageSmoothingQuality = configureImageSmoothing;
|
|
27
|
+
virtualCanvasContext.imageSmoothingQuality = configureImageSmoothing;
|
|
28
|
+
}
|
|
29
|
+
// configure virtual scale
|
|
30
|
+
let virtualScale = Math.min(logicalCanvasElement.width / virtualCanvasElement.width, logicalCanvasElement.height / virtualCanvasElement.height);
|
|
31
|
+
if (configureScaleIncrement)
|
|
32
|
+
virtualScale = Math.floor(virtualScale / configureScaleIncrement) * configureScaleIncrement;
|
|
33
|
+
const stage = {
|
|
34
|
+
// configuration
|
|
35
|
+
configureDebug,
|
|
36
|
+
configureW,
|
|
37
|
+
configureH,
|
|
38
|
+
configureLogicalBackground,
|
|
39
|
+
configureVirtualBackground,
|
|
40
|
+
configureScaleIncrement,
|
|
41
|
+
configureImageSmoothing,
|
|
42
|
+
// canvas
|
|
43
|
+
logicalCanvasElement,
|
|
44
|
+
virtualCanvasElement,
|
|
45
|
+
logicalCanvasContext,
|
|
46
|
+
virtualCanvasContext,
|
|
47
|
+
virtualScale,
|
|
48
|
+
// data
|
|
49
|
+
event: Event.Tree.new(),
|
|
50
|
+
debug: new Map(),
|
|
51
|
+
scene: undefined,
|
|
52
|
+
// metrics
|
|
53
|
+
measuredFramesPerSecond: 0,
|
|
54
|
+
measuredAverageFrame: 0,
|
|
55
|
+
measuredMinimumFrame: 0,
|
|
56
|
+
measuredMaximumFrame: 0,
|
|
57
|
+
measuredAverageUpdate: 0,
|
|
58
|
+
measuredMinimumUpdate: 0,
|
|
59
|
+
measuredMaximumUpdate: 0,
|
|
60
|
+
measuredAverageRender: 0,
|
|
61
|
+
measuredMinimumRender: 0,
|
|
62
|
+
measuredMaximumRender: 0,
|
|
63
|
+
};
|
|
64
|
+
Stage.setDebugInfo(stage, "stage:frameInfo", undefined);
|
|
65
|
+
Stage.setDebugInfo(stage, "stage:updateInfo", undefined);
|
|
66
|
+
Stage.setDebugInfo(stage, "stage:renderInfo", undefined);
|
|
67
|
+
Stage.setDebugInfo(stage, "stage:canvasInfo", undefined);
|
|
68
|
+
new ResizeObserver(() => resize(stage)).observe(logicalCanvasElement);
|
|
69
|
+
Stage.listen(stage, "stage:resize", resize => onResize(stage, resize));
|
|
70
|
+
Stage.listen(stage, "stage:change", change => onChange(stage, change));
|
|
71
|
+
requestAnimationFrame(firstFrame => requestAnimationFrame(lastFrame => requestAnimationFrame(thisFrame => animate(stage, firstFrame, lastFrame, thisFrame))));
|
|
72
|
+
return stage;
|
|
73
|
+
},
|
|
74
|
+
getLogicalSize(stage) {
|
|
75
|
+
return Vector2.new(stage.logicalCanvasElement.width, stage.logicalCanvasElement.height);
|
|
76
|
+
},
|
|
77
|
+
getVirtualSize(stage) {
|
|
78
|
+
return Vector2.new(stage.virtualCanvasElement.width, stage.virtualCanvasElement.height);
|
|
79
|
+
},
|
|
80
|
+
getVirtualScale(stage) {
|
|
81
|
+
return stage.virtualScale;
|
|
82
|
+
},
|
|
83
|
+
use(stage, scene) {
|
|
84
|
+
Stage.dispatch(stage, "stage:change", scene);
|
|
85
|
+
},
|
|
86
|
+
listen(stage, type, listener, o) {
|
|
87
|
+
Event.listen(stage.event, type, listener, o);
|
|
88
|
+
},
|
|
89
|
+
deafen(stage, type, listener, o) {
|
|
90
|
+
Event.deafen(stage.event, type, listener, o);
|
|
91
|
+
},
|
|
92
|
+
dispatch(stage, type, event, o) {
|
|
93
|
+
Event.dispatch(stage.event, type, event, o);
|
|
94
|
+
},
|
|
95
|
+
poll(stage) {
|
|
96
|
+
Event.poll(stage.event);
|
|
97
|
+
},
|
|
98
|
+
getDebugInfo(stage, id) {
|
|
99
|
+
return stage.debug.get(id);
|
|
100
|
+
},
|
|
101
|
+
setDebugInfo(stage, id, info) {
|
|
102
|
+
stage.debug.set(id, info);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
function resize(stage) {
|
|
106
|
+
const w = stage.logicalCanvasElement.getBoundingClientRect().width;
|
|
107
|
+
const h = stage.logicalCanvasElement.getBoundingClientRect().height;
|
|
108
|
+
Stage.dispatch(stage, "stage:resize", [w, h]);
|
|
109
|
+
}
|
|
110
|
+
function onResize(stage, [w, h]) {
|
|
111
|
+
// compute new canvas sizes
|
|
112
|
+
stage.logicalCanvasElement.width = w;
|
|
113
|
+
stage.logicalCanvasElement.height = h;
|
|
114
|
+
stage.virtualCanvasElement = new OffscreenCanvas(stage.configureW || stage.logicalCanvasElement.width, stage.configureH || stage.logicalCanvasElement.height);
|
|
115
|
+
// new canvas contexts
|
|
116
|
+
stage.logicalCanvasContext = stage.logicalCanvasElement.getContext("2d");
|
|
117
|
+
stage.virtualCanvasContext = stage.virtualCanvasElement.getContext("2d");
|
|
118
|
+
// configure image smoothing
|
|
119
|
+
stage.logicalCanvasContext.imageSmoothingEnabled = !!stage.configureImageSmoothing;
|
|
120
|
+
stage.virtualCanvasContext.imageSmoothingEnabled = !!stage.configureImageSmoothing;
|
|
121
|
+
if (stage.configureImageSmoothing) {
|
|
122
|
+
stage.logicalCanvasContext.imageSmoothingQuality = stage.configureImageSmoothing;
|
|
123
|
+
stage.virtualCanvasContext.imageSmoothingQuality = stage.configureImageSmoothing;
|
|
124
|
+
}
|
|
125
|
+
// configure virtual scale
|
|
126
|
+
stage.virtualScale = Math.min(stage.logicalCanvasElement.width / stage.virtualCanvasElement.width, stage.logicalCanvasElement.height / stage.virtualCanvasElement.height);
|
|
127
|
+
if (stage.configureScaleIncrement)
|
|
128
|
+
stage.virtualScale = Math.floor(stage.virtualScale / stage.configureScaleIncrement) * stage.configureScaleIncrement;
|
|
129
|
+
Stage.setDebugInfo(stage, "stage:canvasInfo", getCanvasInfo(stage));
|
|
130
|
+
}
|
|
131
|
+
function onChange(stage, scene) {
|
|
132
|
+
if (stage.scene && stage.scene.onDetach)
|
|
133
|
+
stage.scene.onDetach(stage);
|
|
134
|
+
stage.scene = scene;
|
|
135
|
+
if (stage.scene && stage.scene.onAttach)
|
|
136
|
+
stage.scene.onAttach(stage);
|
|
137
|
+
}
|
|
138
|
+
function update(stage, t, dt) {
|
|
139
|
+
Stage.poll(stage);
|
|
140
|
+
if (Scene.doesUpdate(stage.scene))
|
|
141
|
+
stage.scene.onUpdate({ stage, t, dt });
|
|
142
|
+
}
|
|
143
|
+
function render(stage, t, dt) {
|
|
144
|
+
const f = stage.logicalCanvasContext;
|
|
145
|
+
const g = stage.virtualCanvasContext;
|
|
146
|
+
f.resetTransform();
|
|
147
|
+
g.resetTransform();
|
|
148
|
+
f.fillStyle = stage.configureLogicalBackground;
|
|
149
|
+
const [lw, lh] = Stage.getLogicalSize(stage);
|
|
150
|
+
f.fillRect(0, 0, lw, lh);
|
|
151
|
+
g.fillStyle = stage.configureVirtualBackground;
|
|
152
|
+
const [vw, vh] = Stage.getVirtualSize(stage);
|
|
153
|
+
g.fillRect(0, 0, vw, vh);
|
|
154
|
+
const vs = Stage.getVirtualScale(stage);
|
|
155
|
+
f.translate(lw / 2 - vw * vs / 2, lh / 2 - vh * vs / 2);
|
|
156
|
+
f.scale(vs, vs);
|
|
157
|
+
if (Scene.doesRender(stage.scene))
|
|
158
|
+
stage.scene.onRender({ stage, t, dt, g });
|
|
159
|
+
f.drawImage(stage.virtualCanvasElement, 0, 0);
|
|
160
|
+
if (stage.configureDebug && stage.configureDebug !== "print")
|
|
161
|
+
paintDebugInfo(stage);
|
|
162
|
+
}
|
|
163
|
+
const Timing = {
|
|
164
|
+
new() {
|
|
165
|
+
return {
|
|
166
|
+
framesPerSecondAccumulator: 0,
|
|
167
|
+
averageFrameAccumulator: 0,
|
|
168
|
+
minimumFrameAccumulator: Infinity,
|
|
169
|
+
maximumFrameAccumulator: 0,
|
|
170
|
+
averageUpdateAccumulator: 0,
|
|
171
|
+
minimumUpdateAccumulator: Infinity,
|
|
172
|
+
maximumUpdateAccumulator: 0,
|
|
173
|
+
averageRenderAccumulator: 0,
|
|
174
|
+
minimumRenderAccumulator: Infinity,
|
|
175
|
+
maximumRenderAccumulator: 0,
|
|
176
|
+
oneSecondAccumulator: 0,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
function animate(stage, t0, t1, t2, m) {
|
|
181
|
+
m ??= Timing.new();
|
|
182
|
+
const t = (t2 - t0) / 1000;
|
|
183
|
+
const dt = (t2 - t1) / 1000;
|
|
184
|
+
const a = performance.now();
|
|
185
|
+
update(stage, t, dt);
|
|
186
|
+
const b = performance.now();
|
|
187
|
+
render(stage, t, dt);
|
|
188
|
+
const c = performance.now();
|
|
189
|
+
const deltaFrame = c - a;
|
|
190
|
+
const deltaUpdate = b - a;
|
|
191
|
+
const deltaRender = c - b;
|
|
192
|
+
m.framesPerSecondAccumulator += 1;
|
|
193
|
+
m.averageFrameAccumulator += deltaFrame;
|
|
194
|
+
m.minimumFrameAccumulator = Math.min(deltaFrame, m.minimumFrameAccumulator);
|
|
195
|
+
m.maximumFrameAccumulator = Math.max(deltaFrame, m.maximumFrameAccumulator);
|
|
196
|
+
m.averageUpdateAccumulator += deltaUpdate;
|
|
197
|
+
m.minimumUpdateAccumulator = Math.min(deltaUpdate, m.minimumUpdateAccumulator);
|
|
198
|
+
m.maximumUpdateAccumulator = Math.max(deltaUpdate, m.maximumUpdateAccumulator);
|
|
199
|
+
m.averageRenderAccumulator += deltaRender;
|
|
200
|
+
m.minimumRenderAccumulator = Math.min(deltaRender, m.minimumRenderAccumulator);
|
|
201
|
+
m.maximumRenderAccumulator = Math.max(deltaRender, m.maximumRenderAccumulator);
|
|
202
|
+
m.oneSecondAccumulator += dt;
|
|
203
|
+
if (m.oneSecondAccumulator >= 1) {
|
|
204
|
+
stage.measuredFramesPerSecond = m.framesPerSecondAccumulator;
|
|
205
|
+
stage.measuredAverageFrame = m.averageFrameAccumulator / m.framesPerSecondAccumulator;
|
|
206
|
+
stage.measuredMinimumFrame = m.minimumFrameAccumulator;
|
|
207
|
+
stage.measuredMaximumFrame = m.maximumFrameAccumulator;
|
|
208
|
+
stage.measuredAverageUpdate = m.averageUpdateAccumulator / m.framesPerSecondAccumulator;
|
|
209
|
+
stage.measuredMinimumUpdate = m.minimumUpdateAccumulator;
|
|
210
|
+
stage.measuredMaximumUpdate = m.maximumUpdateAccumulator;
|
|
211
|
+
stage.measuredAverageRender = m.averageRenderAccumulator / m.framesPerSecondAccumulator;
|
|
212
|
+
stage.measuredMinimumRender = m.minimumRenderAccumulator;
|
|
213
|
+
stage.measuredMaximumRender = m.maximumRenderAccumulator;
|
|
214
|
+
// reset accumulators
|
|
215
|
+
m.framesPerSecondAccumulator = 0;
|
|
216
|
+
m.averageFrameAccumulator = 0;
|
|
217
|
+
m.minimumFrameAccumulator = Infinity;
|
|
218
|
+
m.maximumFrameAccumulator = 0;
|
|
219
|
+
m.averageUpdateAccumulator = 0;
|
|
220
|
+
m.minimumUpdateAccumulator = Infinity;
|
|
221
|
+
m.maximumUpdateAccumulator = 0;
|
|
222
|
+
m.averageRenderAccumulator = 0;
|
|
223
|
+
m.minimumRenderAccumulator = Infinity;
|
|
224
|
+
m.maximumRenderAccumulator = 0;
|
|
225
|
+
m.oneSecondAccumulator = 0;
|
|
226
|
+
Stage.setDebugInfo(stage, "stage:frameInfo", getFrameInfo(stage));
|
|
227
|
+
Stage.setDebugInfo(stage, "stage:updateInfo", getUpdateInfo(stage));
|
|
228
|
+
Stage.setDebugInfo(stage, "stage:renderInfo", getRenderInfo(stage));
|
|
229
|
+
if (stage.configureDebug && stage.configureDebug !== "print")
|
|
230
|
+
printDebugInfo(stage);
|
|
231
|
+
}
|
|
232
|
+
requestAnimationFrame(t3 => animate(stage, t0, t2, t3));
|
|
233
|
+
}
|
|
234
|
+
function getFrameInfo(stage) {
|
|
235
|
+
return `FRAME ${stage.measuredFramesPerSecond.toFixed(0)} hz @ ${stage.measuredAverageFrame.toFixed(2)} [${stage.measuredMinimumFrame.toFixed(2)} - ${stage.measuredMaximumFrame.toFixed(2)}] ms`;
|
|
236
|
+
}
|
|
237
|
+
function getUpdateInfo(stage) {
|
|
238
|
+
return `UPDATE ${stage.measuredAverageFrame.toFixed(2)} [${stage.measuredMinimumFrame.toFixed(2)} - ${stage.measuredMaximumFrame.toFixed(2)}] ms`;
|
|
239
|
+
}
|
|
240
|
+
function getRenderInfo(stage) {
|
|
241
|
+
return `RENDER ${stage.measuredAverageFrame.toFixed(2)} [${stage.measuredMinimumFrame.toFixed(2)} - ${stage.measuredMaximumFrame.toFixed(2)}] ms`;
|
|
242
|
+
}
|
|
243
|
+
function getCanvasInfo(stage) {
|
|
244
|
+
const [lw, lh] = Stage.getLogicalSize(stage);
|
|
245
|
+
const [vw, vh] = Stage.getVirtualSize(stage);
|
|
246
|
+
const vs = Stage.getVirtualScale(stage);
|
|
247
|
+
return `CANVAS ${lw}x${lh} ${vw}x${vh} ${(100 * vs).toFixed(2)}%`;
|
|
248
|
+
}
|
|
249
|
+
function printDebugInfo(stage) {
|
|
250
|
+
let infos = "*** DEBUG ***\n";
|
|
251
|
+
for (const [id, info] of stage.debug) {
|
|
252
|
+
if (!info)
|
|
253
|
+
continue;
|
|
254
|
+
infos += `${info}\n`;
|
|
255
|
+
}
|
|
256
|
+
console.log(infos);
|
|
257
|
+
}
|
|
258
|
+
const configureDebugInfoBackground = "#000a";
|
|
259
|
+
const configureDebugInfoForeground = "#ffff";
|
|
260
|
+
const configureDebugInfoPaddingL = 10;
|
|
261
|
+
const configureDebugInfoPaddingR = 10;
|
|
262
|
+
const configureDebugInfoPaddingT = 10;
|
|
263
|
+
const configureDebugInfoPaddingB = 10;
|
|
264
|
+
const configureDebugInfoSpacing = 0;
|
|
265
|
+
const configureDebugInfoFont = "16px monospace";
|
|
266
|
+
function paintDebugInfo(stage) {
|
|
267
|
+
const g = stage.logicalCanvasContext;
|
|
268
|
+
g.resetTransform();
|
|
269
|
+
g.font = configureDebugInfoFont;
|
|
270
|
+
let w = 0;
|
|
271
|
+
let h = 0;
|
|
272
|
+
for (const [id, info] of stage.debug) {
|
|
273
|
+
if (!info)
|
|
274
|
+
continue;
|
|
275
|
+
const tm = g.measureText(info);
|
|
276
|
+
w = Math.max(w, tm.width);
|
|
277
|
+
h += (tm.fontBoundingBoxAscent +
|
|
278
|
+
tm.fontBoundingBoxDescent +
|
|
279
|
+
configureDebugInfoSpacing);
|
|
280
|
+
}
|
|
281
|
+
if (h > 0) {
|
|
282
|
+
w += configureDebugInfoPaddingL + configureDebugInfoPaddingR;
|
|
283
|
+
h += configureDebugInfoPaddingT + configureDebugInfoPaddingB;
|
|
284
|
+
h -= configureDebugInfoSpacing;
|
|
285
|
+
}
|
|
286
|
+
// draw background
|
|
287
|
+
g.fillStyle = configureDebugInfoBackground;
|
|
288
|
+
g.fillRect(0, 0, w, h);
|
|
289
|
+
// draw foreground
|
|
290
|
+
g.fillStyle = configureDebugInfoForeground;
|
|
291
|
+
let x = configureDebugInfoPaddingL;
|
|
292
|
+
let y = configureDebugInfoPaddingT;
|
|
293
|
+
for (const [id, info] of stage.debug) {
|
|
294
|
+
if (!info)
|
|
295
|
+
continue;
|
|
296
|
+
const tm = g.measureText(info);
|
|
297
|
+
g.fillText(info, x, y + tm.fontBoundingBoxAscent);
|
|
298
|
+
y += (tm.fontBoundingBoxAscent +
|
|
299
|
+
tm.fontBoundingBoxDescent +
|
|
300
|
+
configureDebugInfoSpacing);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=stage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage.js","sourceRoot":"","sources":["../src/stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAG,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,KAAK,EAAI,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,KAAK,EAAI,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAqDtC;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,GAAG,CAAC,CAAkB;QACpB,MAAM,cAAc,GAAe,CAAC,EAAE,KAAK,IAAI,KAAK,CAAA;QACpD,MAAM,UAAU,GAAmB,CAAC,EAAE,CAAC,IAAQ,CAAC,CAAA;QAChD,MAAM,UAAU,GAAmB,CAAC,EAAE,CAAC,IAAQ,CAAC,CAAA;QAChD,MAAM,0BAA0B,GAAG,CAAC,EAAE,GAAG,IAAM,MAAM,CAAA;QACrD,MAAM,0BAA0B,GAAG,CAAC,EAAE,GAAG,IAAM,MAAM,CAAA;QACrD,MAAM,uBAAuB,GAAM,CAAC,EAAE,EAAE,CAAA;QACxC,MAAM,uBAAuB,GAAM,CAAC,EAAE,EAAE,CAAA;QAExC,MAAM,oBAAoB,GAAG,CAAC,EAAE,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAA;QAC1D,MAAM,oBAAoB,GAAG,IAAI,eAAe,CAC9C,UAAU,IAAI,oBAAoB,CAAC,KAAK,EACxC,UAAU,IAAI,oBAAoB,CAAC,MAAM,CAC1C,CAAA;QACD,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,UAAU,CAAC,IAAI,CAAE,CAAA;QACnE,MAAM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5D,CAAC,IAAI,yBAAyB,CAAA;IAChC,CAAC;IAED,kBAAkB;IAClB,CAAC,CAAC,SAAS,GAAG,4BAA4B,CAAA;IAC1C,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAEtB,kBAAkB;IAClB,CAAC,CAAC,SAAS,GAAG,4BAA4B,CAAA;IAC1C,IAAI,CAAC,GAAG,0BAA0B,CAAA;IAClC,IAAI,CAAC,GAAG,0BAA0B,CAAA;IAClC,KAAK,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI;YAAE,SAAQ;QAEnB,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,CAAA;QACjD,CAAC,IAAI,CACH,EAAE,CAAC,qBAAqB;YACxB,EAAE,CAAC,sBAAsB;YACzB,yBAAyB,CAC1B,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export type Vector2 = [number, number];
|
|
2
|
+
/**
|
|
3
|
+
* A collection of constants and functions for constructing and
|
|
4
|
+
* interacting with Vector2 objects.
|
|
5
|
+
*/
|
|
6
|
+
export declare const Vector2: {
|
|
7
|
+
/** Constant index for the x-component of a Vector2 */
|
|
8
|
+
X: 0;
|
|
9
|
+
/** Constant index for the y-component of a Vector2 */
|
|
10
|
+
Y: 1;
|
|
11
|
+
/** A collection of getters for Vector2 objects */
|
|
12
|
+
Get: {
|
|
13
|
+
/** Get the x-component of a Vector2 */
|
|
14
|
+
x(a: Vector2): number;
|
|
15
|
+
/** Get the y-component of a Vector2 */
|
|
16
|
+
y(a: Vector2): number;
|
|
17
|
+
};
|
|
18
|
+
/** A collection of setters for Vector2 objects */
|
|
19
|
+
Set: {
|
|
20
|
+
/** Set the x-component of a Vector2 */
|
|
21
|
+
x(a: Vector2, x: number): number;
|
|
22
|
+
/** Set the y-component of a Vector2 */
|
|
23
|
+
y(a: Vector2, y: number): number;
|
|
24
|
+
};
|
|
25
|
+
/** Get or set (when `x` is defined) the x-component of a Vector2 */
|
|
26
|
+
x(a: Vector2, x?: number): number;
|
|
27
|
+
/** Get or set (when `y` is defined) the y-component of a Vector2 */
|
|
28
|
+
y(a: Vector2, y?: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* Construct a Vector2 from a variadic array of numbers.
|
|
31
|
+
*
|
|
32
|
+
* Constructs a uniform Vector2 when `a.length === 1`
|
|
33
|
+
* ```js
|
|
34
|
+
* Vector2.new(1) // [1, 1]
|
|
35
|
+
* ```
|
|
36
|
+
* Otherwise constructs a standard zero-padded Vector2
|
|
37
|
+
* ```js
|
|
38
|
+
* Vector2.new( ) // [0, 0]
|
|
39
|
+
* Vector2.new(1, 2) // [1, 2]
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
"new"(...a: Array<number>): [number, number];
|
|
43
|
+
/**
|
|
44
|
+
* Constructs a Vector2 from a number or an array of numbers.
|
|
45
|
+
*
|
|
46
|
+
* Constructs a uniform Vector2 when `a` is a number
|
|
47
|
+
* ```js
|
|
48
|
+
* Vector2.from(1) // [1, 1]
|
|
49
|
+
* ```
|
|
50
|
+
* Otherwise constructs a standard zero-padded Vector2
|
|
51
|
+
* ```js
|
|
52
|
+
* Vector2.from([ ]) // [0, 0]
|
|
53
|
+
* Vector2.from([1 ]) // [1, 0]
|
|
54
|
+
* Vector2.from([1, 2]) // [1, 2]
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
from(a: number | Array<number>): [number, number];
|
|
58
|
+
/**
|
|
59
|
+
* Perform an element-wise operation on two Vector2 objects.
|
|
60
|
+
* Number-like arguments are promoted to uniform Vector2 objects
|
|
61
|
+
* before performing the operation. Constructs a new Vector2 when an
|
|
62
|
+
* output argument is not provided.
|
|
63
|
+
*/
|
|
64
|
+
el(op: (a: number, b: number) => number, a: number | Vector2, b: number | Vector2, out?: Vector2): Vector2;
|
|
65
|
+
/**
|
|
66
|
+
* Compute the sum of two Vector2 objects. Number-like arguments are
|
|
67
|
+
* promoted to uniform Vector2 objects before performing the operation.
|
|
68
|
+
* Constructs a new Vector2 when an output argument is not provided.
|
|
69
|
+
*/
|
|
70
|
+
add(a: number | Vector2, b: number | Vector2, out?: Vector2): Vector2;
|
|
71
|
+
/**
|
|
72
|
+
* Compute the difference of two Vector2 objects. Number-like arguments
|
|
73
|
+
* are promoted to uniform Vector2 objects before performing the
|
|
74
|
+
* operation. Constructs a new Vector2 when an output argument is not
|
|
75
|
+
* provided.
|
|
76
|
+
*/
|
|
77
|
+
sub(a: number | Vector2, b: number | Vector2, out?: Vector2): Vector2;
|
|
78
|
+
/**
|
|
79
|
+
* Compute the hadamard (element-wise) product of two Vector2 objects.
|
|
80
|
+
* Number-like arguments are promoted to uniform Vector2 objects before
|
|
81
|
+
* performing the operation. Constructs a new Vector2 when an output
|
|
82
|
+
* argument is not provided.
|
|
83
|
+
*/
|
|
84
|
+
hmul(a: number | Vector2, b: number | Vector2, out?: Vector2): Vector2;
|
|
85
|
+
/**
|
|
86
|
+
* Compute the hadamard (element-wise) quotient of two Vector2 objects.
|
|
87
|
+
* Number-like arguments are promoted to uniform Vector2 objects before
|
|
88
|
+
* performing the operation. Constructs a new Vector2 when an output
|
|
89
|
+
* argument is not provided.
|
|
90
|
+
*/
|
|
91
|
+
hdiv(a: number | Vector2, b: number | Vector2, out?: Vector2): Vector2;
|
|
92
|
+
/**
|
|
93
|
+
* Compute the hadamard (element-wise) remainder of two Vector2 objects.
|
|
94
|
+
* Number-like arguments are promoted to uniform Vector2 objects before
|
|
95
|
+
* performing the operation. Constructs a new Vector2 when an output
|
|
96
|
+
* argument is not provided.
|
|
97
|
+
*/
|
|
98
|
+
hmod(a: number | Vector2, b: number | Vector2, out?: Vector2): Vector2;
|
|
99
|
+
/**
|
|
100
|
+
* Compute the dot product of two Vector2 objects, or simply the
|
|
101
|
+
* dot product of `a` with itself when `b` is not defined. Number-like
|
|
102
|
+
* arguments are promoted to uniform Vector2 objects before performing
|
|
103
|
+
* the operation.
|
|
104
|
+
*/
|
|
105
|
+
dot(a: number | Vector2, b?: number | Vector2): number;
|
|
106
|
+
/**
|
|
107
|
+
* Convert a Vector2 into its string representation
|
|
108
|
+
* ```js
|
|
109
|
+
* Vector2.toString([1, 2]) // "vec2<1, 2>"
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
toString([x, y]: Vector2): `vec2<${number}, ${number}>`;
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=vector2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector2.d.ts","sourceRoot":"","sources":["../src/vector2.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEtC;;;GAGG;AACH,eAAO,MAAM,OAAO;IAClB,sDAAsD;;IAEtD,sDAAsD;;IAGtD,kDAAkD;;QAEhD,uCAAuC;aAClC,OAAO;QACZ,uCAAuC;aAClC,OAAO;;IAGd,kDAAkD;;QAEhD,uCAAuC;aAClC,OAAO,KAAK,MAAM;QACvB,uCAAuC;aAClC,OAAO,KAAK,MAAM;;IAGzB,oEAAoE;SAC/D,OAAO,MAAO,MAAM;IAKzB,oEAAoE;SAC/D,OAAO,MAAO,MAAM;IAKzB;;;;;;;;;;;;OAYG;gBACO,KAAK,CAAC,MAAM,CAAC;IAWvB;;;;;;;;;;;;;OAaG;YACK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAW9B;;;;;OAKG;WACI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,KAAK,MAAM,GAAG,OAAO,KAAK,MAAM,GAAG,OAAO,QAAO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