a
This commit is contained in:
parent
d163ceb291
commit
f6d7412744
94 changed files with 3836 additions and 1226 deletions
|
|
@ -339,13 +339,22 @@
|
|||
const oldH = this.h || height;
|
||||
this.viewportW = Math.max(1, width || this.viewportW || 1000);
|
||||
this.viewportH = Math.max(1, height || this.viewportH || 720);
|
||||
const requestedScale = fieldWorldScale(this);
|
||||
const scale = Math.max(requestedScale, 220 / this.viewportW, 180 / this.viewportH);
|
||||
this.w = this.viewportW * scale;
|
||||
this.h = this.viewportH * scale;
|
||||
|
||||
// The playable world follows the CSS canvas size. Callers can opt out for
|
||||
// presentation-only measurements, but normal viewport resizes keep the two
|
||||
// dimensions linked and may scale existing contents to preserve layout.
|
||||
const resizeWorld = opts.resizeWorld !== false || !this._worldSizeInitialized;
|
||||
if (resizeWorld) {
|
||||
const requestedScale = fieldWorldScale(this);
|
||||
const scale = Math.max(requestedScale, 220 / this.viewportW, 180 / this.viewportH);
|
||||
this.w = this.viewportW * scale;
|
||||
this.h = this.viewportH * scale;
|
||||
this._worldSizeInitialized = true;
|
||||
}
|
||||
|
||||
this.fieldZoom = this.normalizedFieldZoom(this.fieldZoom);
|
||||
this.clampCamera();
|
||||
if (opts.scaleContents && oldW > 0 && oldH > 0) {
|
||||
if (resizeWorld && opts.scaleContents && oldW > 0 && oldH > 0) {
|
||||
const sx = this.w / oldW;
|
||||
const sy = this.h / oldH;
|
||||
const scalePoint = (p) => {
|
||||
|
|
@ -355,6 +364,8 @@
|
|||
};
|
||||
for (const t of this.tarinai || []) scalePoint(t);
|
||||
for (const it of this.items || []) scalePoint(it);
|
||||
for (const residue of this.residues || []) scalePoint(residue);
|
||||
this.rebuildResidueIndex?.();
|
||||
for (const ef of this.effects || []) scalePoint(ef);
|
||||
scalePoint(this.pointer);
|
||||
this.cameraX *= sx;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue