@esotericsoftware/spine-webgl 4.2.111 → 4.2.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SceneRenderer.d.ts +3 -0
- package/dist/SceneRenderer.js +17 -2
- package/dist/esm/spine-webgl.min.mjs +3 -3
- package/dist/esm/spine-webgl.mjs +20 -1
- package/dist/esm/spine-webgl.mjs.map +2 -2
- package/dist/iife/spine-webgl.js +20 -1
- package/dist/iife/spine-webgl.js.map +2 -2
- package/dist/iife/spine-webgl.min.js +2 -2
- package/package.json +2 -2
package/dist/esm/spine-webgl.mjs
CHANGED
|
@@ -5678,6 +5678,11 @@ var AssetManagerBase = class {
|
|
|
5678
5678
|
try {
|
|
5679
5679
|
const atlas = this.createTextureAtlas(path, atlasText);
|
|
5680
5680
|
let toLoad = atlas.pages.length, abort = false;
|
|
5681
|
+
if (toLoad === 0) {
|
|
5682
|
+
this.success(success, path, atlas);
|
|
5683
|
+
resolve(atlas);
|
|
5684
|
+
return;
|
|
5685
|
+
}
|
|
5681
5686
|
for (let page of atlas.pages) {
|
|
5682
5687
|
this.loadTexture(
|
|
5683
5688
|
!fileAlias ? parent + page.name : fileAlias[page.name],
|
|
@@ -13352,6 +13357,8 @@ var SceneRenderer = class {
|
|
|
13352
13357
|
shapes;
|
|
13353
13358
|
shapesShader;
|
|
13354
13359
|
activeRenderer = null;
|
|
13360
|
+
maxCanvasWidth = 0;
|
|
13361
|
+
maxCanvasHeight = 0;
|
|
13355
13362
|
skeletonRenderer;
|
|
13356
13363
|
skeletonDebugRenderer;
|
|
13357
13364
|
constructor(canvas, context, twoColorTint = true) {
|
|
@@ -13725,7 +13732,7 @@ var SceneRenderer = class {
|
|
|
13725
13732
|
}
|
|
13726
13733
|
resize(resizeMode) {
|
|
13727
13734
|
let canvas = this.canvas;
|
|
13728
|
-
var dpr =
|
|
13735
|
+
var dpr = this.getSafeDevicePixelRatio(canvas.clientWidth, canvas.clientHeight);
|
|
13729
13736
|
var w = Math.round(canvas.clientWidth * dpr);
|
|
13730
13737
|
var h = Math.round(canvas.clientHeight * dpr);
|
|
13731
13738
|
if (canvas.width != w || canvas.height != h) {
|
|
@@ -13745,6 +13752,18 @@ var SceneRenderer = class {
|
|
|
13745
13752
|
}
|
|
13746
13753
|
this.camera.update();
|
|
13747
13754
|
}
|
|
13755
|
+
getSafeDevicePixelRatio(cssWidth, cssHeight) {
|
|
13756
|
+
const dpr = window.devicePixelRatio || 1;
|
|
13757
|
+
if (cssWidth <= 0 || cssHeight <= 0) return dpr;
|
|
13758
|
+
if (this.maxCanvasWidth === 0 || this.maxCanvasHeight === 0) {
|
|
13759
|
+
const gl = this.context.gl;
|
|
13760
|
+
const maxRenderbufferSize = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE);
|
|
13761
|
+
const maxViewportDims = gl.getParameter(gl.MAX_VIEWPORT_DIMS);
|
|
13762
|
+
this.maxCanvasWidth = Math.min(maxRenderbufferSize, maxViewportDims[0]);
|
|
13763
|
+
this.maxCanvasHeight = Math.min(maxRenderbufferSize, maxViewportDims[1]);
|
|
13764
|
+
}
|
|
13765
|
+
return Math.min(dpr, this.maxCanvasWidth / cssWidth, this.maxCanvasHeight / cssHeight);
|
|
13766
|
+
}
|
|
13748
13767
|
enableRenderer(renderer) {
|
|
13749
13768
|
if (this.activeRenderer === renderer) return;
|
|
13750
13769
|
this.end();
|