优化点光源

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

View File

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