mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-05 11:34:31 +08:00
优化阴影,布局初步
This commit is contained in:
1 parent
9d995567bd
commit
565dcab6dd
6 files changed
+544
-65
No files matched your search
@@ -13,11 +13,11 @@ export default function init() {
|
||||
}
|
||||
|
||||
const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
|
||||
MT46: [
|
||||
MT43: [
|
||||
{
|
||||
id: 'mt42_1',
|
||||
x: 85,
|
||||
y: 85,
|
||||
x: 280,
|
||||
y: 220,
|
||||
decay: 100,
|
||||
r: 300,
|
||||
color: '#0000'
|
||||
@@ -25,13 +25,13 @@ const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
|
||||
]
|
||||
};
|
||||
const backgroundInfo: Partial<Record<FloorIds, Color>> = {
|
||||
MT46: '#0008'
|
||||
MT43: '#0008'
|
||||
};
|
||||
const blurInfo: Partial<Record<FloorIds, number>> = {
|
||||
MT46: 4
|
||||
MT43: 4
|
||||
};
|
||||
const immersionInfo: Partial<Record<FloorIds, number>> = {
|
||||
MT46: 8
|
||||
MT43: 8
|
||||
};
|
||||
const shadowCache: Partial<Record<FloorIds, Polygon[]>> = {};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ export class Polygon {
|
||||
if (nodes.length < 3) {
|
||||
throw new Error(`Nodes number delivered is less than 3!`);
|
||||
}
|
||||
this.nodes = nodes;
|
||||
this.nodes = nodes.map(v => [v[0] + 32, v[1] + 32]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -24,12 +24,14 @@ export class Polygon {
|
||||
const id = `${x},${y}`;
|
||||
if (this.cache[id]) return this.cache[id];
|
||||
const res: LocArr[][] = [];
|
||||
const w = core._PX_ ?? core.__PIXELS__;
|
||||
const h = core._PY_ ?? core.__PIXELS__;
|
||||
const w = (core._PX_ ?? core.__PIXELS__) + 64;
|
||||
const h = (core._PY_ ?? core.__PIXELS__) + 64;
|
||||
|
||||
const aspect = h / w;
|
||||
|
||||
const intersect = (nx: number, ny: number): LocArr => {
|
||||
const k = (ny - y) / (nx - x);
|
||||
if (k > 1 || k < -1) {
|
||||
if (k > aspect || k < -aspect) {
|
||||
if (ny < y) {
|
||||
const ix = x + y / k;
|
||||
return [2 * x - ix, 0];
|
||||
|
||||
+10
-10
@@ -76,15 +76,15 @@ const transitionList: Record<string, Transition> = {};
|
||||
export function initShadowCanvas() {
|
||||
const w = core._PX_ ?? core.__PIXELS__;
|
||||
const h = core._PY_ ?? core.__PIXELS__;
|
||||
ctx = core.createCanvas('shadow', 0, 0, w, h, 55);
|
||||
ctx = core.createCanvas('shadow', -32, -32, w + 64, h + 64, 55);
|
||||
canvas = ctx.canvas;
|
||||
const s = core.domStyle.scale * devicePixelRatio;
|
||||
temp1.width = w * s;
|
||||
temp1.height = h * s;
|
||||
temp2.width = w * s;
|
||||
temp2.height = h * s;
|
||||
temp3.width = w * s;
|
||||
temp3.height = h * s;
|
||||
temp1.width = (w + 64) * s;
|
||||
temp1.height = (h + 64) * s;
|
||||
temp2.width = (w + 64) * s;
|
||||
temp2.height = (h + 64) * s;
|
||||
temp3.width = (w + 64) * s;
|
||||
temp3.height = (h + 64) * s;
|
||||
ct1.scale(s, s);
|
||||
ct2.scale(s, s);
|
||||
ct3.scale(s, s);
|
||||
@@ -401,8 +401,8 @@ export function setBlur(n: number) {
|
||||
* 绘制阴影
|
||||
*/
|
||||
export function drawShadow() {
|
||||
const w = core._PX_ ?? core.__PIXELS__;
|
||||
const h = core._PY_ ?? core.__PIXELS__;
|
||||
const w = (core._PX_ ?? core.__PIXELS__) + 64;
|
||||
const h = (core._PY_ ?? core.__PIXELS__) + 64;
|
||||
needRefresh = false;
|
||||
ctx.clearRect(0, 0, w, h);
|
||||
ct1.clearRect(0, 0, w, h);
|
||||
@@ -421,7 +421,7 @@ export function drawShadow() {
|
||||
ct2.clearRect(0, 0, w, h);
|
||||
if (!noShelter) {
|
||||
for (const polygon of shadowNodes) {
|
||||
const area = polygon.shadowArea(x, y, r);
|
||||
const area = polygon.shadowArea(x + 32, y + 32, r);
|
||||
area.forEach(v => {
|
||||
ct1.beginPath();
|
||||
ct1.moveTo(v[0][0], v[0][1]);
|
||||
|
||||
Reference in new issue
Block a user