优化点光源

This commit is contained in:
unanmed 2023-04-15 21:00:17 +08:00
parent c39dd87556
commit d56e54135a
2 changed files with 26 additions and 15 deletions

View File

@ -236,7 +236,7 @@ packages:
'@babel/helper-plugin-utils': 7.20.2 '@babel/helper-plugin-utils': 7.20.2
debug: 4.3.4 debug: 4.3.4
lodash.debounce: 4.0.8 lodash.debounce: 4.0.8
resolve: 1.22.2 resolve: 1.22.3
semver: 6.3.0 semver: 6.3.0
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -2134,7 +2134,7 @@ packages:
hasBin: true hasBin: true
dependencies: dependencies:
caniuse-lite: 1.0.30001478 caniuse-lite: 1.0.30001478
electron-to-chromium: 1.4.363 electron-to-chromium: 1.4.365
node-releases: 2.0.10 node-releases: 2.0.10
update-browserslist-db: 1.0.10_browserslist@4.21.5 update-browserslist-db: 1.0.10_browserslist@4.21.5
dev: true dev: true
@ -2513,8 +2513,8 @@ packages:
stream-shift: 1.0.1 stream-shift: 1.0.1
dev: true dev: true
/electron-to-chromium/1.4.363: /electron-to-chromium/1.4.365:
resolution: {integrity: sha512-ReX5qgmSU7ybhzMuMdlJAdYnRhT90UB3k9M05O5nF5WH3wR5wgdJjXw0uDeFyKNhmglmQiOxkAbzrP0hMKM59g==} resolution: {integrity: sha512-FRHZO+1tUNO4TOPXmlxetkoaIY8uwHzd1kKopK/Gx2SKn1L47wJXWD44wxP5CGRyyP98z/c8e1eBzJrgPeiBOg==}
dev: true dev: true
/emoji-regex/8.0.0: /emoji-regex/8.0.0:
@ -3936,8 +3936,8 @@ packages:
value-or-function: 3.0.0 value-or-function: 3.0.0
dev: true dev: true
/resolve/1.22.2: /resolve/1.22.3:
resolution: {integrity: sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==} resolution: {integrity: sha512-P8ur/gp/AmbEzjr729bZnLjXK5Z+4P0zhIJgBgzqRih7hL7BOukHGtSTA3ACMY467GRFz3duQsi0bDZdR7DKdw==}
hasBin: true hasBin: true
dependencies: dependencies:
is-core-module: 2.12.0 is-core-module: 2.12.0
@ -4417,7 +4417,7 @@ packages:
local-pkg: 0.4.3 local-pkg: 0.4.3
magic-string: 0.27.0 magic-string: 0.27.0
minimatch: 5.1.6 minimatch: 5.1.6
resolve: 1.22.2 resolve: 1.22.3
unplugin: 1.3.1 unplugin: 1.3.1
vue: 3.2.47 vue: 3.2.47
transitivePeerDependencies: transitivePeerDependencies:
@ -4556,7 +4556,7 @@ packages:
esbuild: 0.17.16 esbuild: 0.17.16
less: 4.1.3 less: 4.1.3
postcss: 8.4.21 postcss: 8.4.21
resolve: 1.22.2 resolve: 1.22.3
rollup: 3.20.2 rollup: 3.20.2
terser: 5.16.9 terser: 5.16.9
optionalDependencies: optionalDependencies:

View File

@ -1,7 +1,9 @@
import { power } from 'mutate-animate';
import { Polygon } from './polygon'; import { Polygon } from './polygon';
import { import {
Light, Light,
getAllLights, getAllLights,
moveLight,
refreshLight, refreshLight,
removeAllLights, removeAllLights,
setBackground, setBackground,
@ -25,7 +27,7 @@ export default function init() {
} }
}; };
return { updateShadow, clearShadowCache, setCalShadow }; return { updateShadow, clearShadowCache, setCalShadow, testLight: test };
} }
const shadowInfo: Partial<Record<FloorIds, Light[]>> = { const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
@ -34,8 +36,8 @@ const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
id: 'mt48_1', id: 'mt48_1',
x: 0, x: 0,
y: 0, y: 0,
decay: 1000, decay: 0,
r: 2000, r: 300,
color: '#0000', color: '#0000',
followHero: true followHero: true
} }
@ -95,16 +97,21 @@ export function updateShadow(nocache: boolean = false) {
const t: LocString = `${x},${y - 1}`; const t: LocString = `${x},${y - 1}`;
const b: LocString = `${x},${y + 1}`; const b: LocString = `${x},${y + 1}`;
if (x === 0 || (blocks[l] && blocks[l].event.noPass)) { if (x === 0) left -= immerse * 2;
if (x + 1 === w) right += immerse * 2;
if (y === 0) top -= immerse * 2;
if (y + 1 === h) bottom += immerse * 2;
if (blocks[l] && blocks[l].event.noPass) {
left -= immerse; left -= immerse;
} }
if (x + 1 === w || (blocks[r] && blocks[r].event.noPass)) { if (blocks[r] && blocks[r].event.noPass) {
right += immerse; right += immerse;
} }
if (y === 0 || (blocks[t] && blocks[t].event.noPass)) { if (blocks[t] && blocks[t].event.noPass) {
top -= immerse; top -= immerse;
} }
if (y + 1 === h || (blocks[b] && blocks[b].event.noPass)) { if (blocks[b] && blocks[b].event.noPass) {
bottom += immerse; bottom += immerse;
} }
nodes.push( nodes.push(
@ -146,3 +153,7 @@ export function setCalShadow(n: boolean) {
calMapShadow = n; calMapShadow = n;
updateShadow(); updateShadow();
} }
function test() {
moveLight('mt48_1', 480, 48, 2000, power(4, 'in-out'));
}