mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-03-03 19:27:07 +08:00
fix: 光照缩放问题
This commit is contained in:
parent
763ff0f3e7
commit
518f5a5815
@ -32,7 +32,7 @@ main.floors.MT50=
|
||||
],
|
||||
"9,13": [
|
||||
"在你刚进入苍蓝之殿时,你只能先前往左下角部分(本地图的左面),右下角暂时不能前往。注意往上走往左依然可以进入左下角,不要只盯着这个地图的左边不放。",
|
||||
"注意火炬可通行,而且跳跃时会跳过火炬,不会跳到火炬上"
|
||||
"注意火炬可通行,而且跳跃时会跳过火炬,不会跳到火炬上。以及由于不可抗力,修改游戏缩放后需要刷新页面才能使光照正常。"
|
||||
],
|
||||
"9,1": [
|
||||
"建议优先点出学习技能,对于特定场景将会非常有帮助",
|
||||
|
@ -15,7 +15,7 @@ const MAX_LIGHT_NUM = 5;
|
||||
/** 阴影层的Z值 */
|
||||
const Z_INDEX = 55;
|
||||
// 我也不知道这个数怎么来的,试出来是这个,别动就行
|
||||
const FOVY = Math.PI / 1.86;
|
||||
const FOVY = Math.PI / 2;
|
||||
const ignore: Set<AllNumbers> = new Set([660]);
|
||||
|
||||
interface LightConfig {
|
||||
@ -70,7 +70,7 @@ function addLightFromBlock(floors: FloorIds[], block: number, config: LightConfi
|
||||
})
|
||||
}
|
||||
|
||||
Mota.require('var', 'loading').once('coreInit', () => {
|
||||
Mota.require('var', 'hook').once('reset', () => {
|
||||
Shadow.init();
|
||||
addLightFromBlock(
|
||||
core.floorIds.slice(61),
|
||||
@ -412,7 +412,7 @@ export class Shadow {
|
||||
const polygons = calMapPolygons(this.floorId, this.immerse, nocache);
|
||||
|
||||
const res: number[] = [];
|
||||
const ratio = core.domStyle.scale * devicePixelRatio;
|
||||
const ratio = devicePixelRatio * core.domStyle.scale;
|
||||
const m = core._PX_ * ratio * 2;
|
||||
|
||||
polygons.forEach(v => {
|
||||
@ -768,7 +768,7 @@ export class Shadow {
|
||||
const gl = Shadow.gl;
|
||||
const ratio = core.domStyle.scale * devicePixelRatio;
|
||||
const cameraMatrix = mat4.create();
|
||||
mat4.lookAt(cameraMatrix, [light.x * ratio, light.y * ratio, core._PX_ * 2], [light.x * ratio, light.y * ratio, 0], [0, 1, 0]);
|
||||
mat4.lookAt(cameraMatrix, [light.x * ratio, light.y * ratio, core._PX_ * 2 * ratio], [light.x * ratio, light.y * ratio, 0], [0, 1, 0]);
|
||||
|
||||
const size = core._PX_ * ratio * 2;
|
||||
gl.viewport(0, 0, size, size);
|
||||
@ -887,6 +887,7 @@ export class Shadow {
|
||||
const gl = this.gl;
|
||||
if (!isWebGL2Supported()) return;
|
||||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
||||
const ratio = core.domStyle.scale * devicePixelRatio;
|
||||
|
||||
// program
|
||||
const depth = createProgram(gl, depthVertex, depthFragment);
|
||||
@ -938,7 +939,7 @@ export class Shadow {
|
||||
|
||||
// Matrix
|
||||
const lightProjection = mat4.create();
|
||||
mat4.perspective(lightProjection, FOVY, 1, 1, core._PX_ * 2);
|
||||
mat4.perspective(lightProjection, FOVY, 1, 1, core._PX_ * ratio);
|
||||
this.martix = {
|
||||
projection: lightProjection
|
||||
}
|
||||
@ -978,6 +979,17 @@ export class Shadow {
|
||||
}
|
||||
}
|
||||
|
||||
static resize() {
|
||||
if (this.martix) {
|
||||
const ratio = core.domStyle.scale * devicePixelRatio;
|
||||
const lightProjection = mat4.create();
|
||||
mat4.perspective(lightProjection, FOVY, 1, 1, core._PX_ * ratio);
|
||||
this.martix = {
|
||||
projection: lightProjection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除一些关键缓冲区的内容,当且仅当图块变化或者切换地图时调用
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user