mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-03 18:24:30 +08:00
feat: 新的渲染系统
This commit is contained in:
1 parent
af38d2e47e
commit
2f8fbd375c
34 files changed
+1173
-179
No files matched your search
+11
-1
@@ -20,6 +20,8 @@ export class MotaOffscreenCanvas2D extends EventEmitter<OffscreenCanvasEvent> {
|
||||
/** 是否是高清画布 */
|
||||
highResolution: boolean = true;
|
||||
|
||||
scale: number = 1;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -41,6 +43,7 @@ export class MotaOffscreenCanvas2D extends EventEmitter<OffscreenCanvasEvent> {
|
||||
if (this.autoScale && this.highResolution) {
|
||||
ratio *= core.domStyle.scale;
|
||||
}
|
||||
this.scale = ratio;
|
||||
this.canvas.width = width * ratio;
|
||||
this.canvas.height = height * ratio;
|
||||
this.width = width;
|
||||
@@ -82,7 +85,13 @@ export class MotaOffscreenCanvas2D extends EventEmitter<OffscreenCanvasEvent> {
|
||||
newCanvas.setHD(canvas.highResolution);
|
||||
newCanvas.withGameScale(canvas.autoScale);
|
||||
newCanvas.size(canvas.width, canvas.height);
|
||||
newCanvas.ctx.drawImage(canvas.canvas, 0, 0);
|
||||
newCanvas.ctx.drawImage(
|
||||
canvas.canvas,
|
||||
0,
|
||||
0,
|
||||
canvas.width,
|
||||
canvas.height
|
||||
);
|
||||
return newCanvas;
|
||||
}
|
||||
}
|
||||
@@ -144,6 +153,7 @@ export class MotaCanvas2D extends MotaOffscreenCanvas2D {
|
||||
this.canvas.style.width = `${width}px`;
|
||||
this.canvas.style.height = `${height}px`;
|
||||
}
|
||||
this.scale = ratio;
|
||||
this.canvas.width = width * ratio;
|
||||
this.canvas.height = height * ratio;
|
||||
this.width = width;
|
||||
|
||||
@@ -114,18 +114,18 @@ Mota.require('var', 'hook').once('reset', () => {
|
||||
Shadow.update(true);
|
||||
}
|
||||
});
|
||||
Mota.rewrite(core.events, 'changingFloor', 'add', (_, floorId) => {
|
||||
if (!main.replayChecking) {
|
||||
Shadow.clearBuffer();
|
||||
Shadow.update();
|
||||
setCanvasFilterByFloorId(floorId);
|
||||
}
|
||||
});
|
||||
Mota.rewrite(core.control, 'loadData', 'add', () => {
|
||||
if (!main.replayChecking) {
|
||||
Shadow.update(true);
|
||||
}
|
||||
});
|
||||
Mota.require('var', 'hook').on('changingFloor', (floorId) => {
|
||||
if (!main.replayChecking) {
|
||||
Shadow.clearBuffer();
|
||||
Shadow.update();
|
||||
setCanvasFilterByFloorId(floorId);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// 深度测试着色器
|
||||
|
||||
Reference in new issue
Block a user