Compare commits
14 Commits
greenkeepe
...
greenkeepe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96f50b29ee | ||
|
|
75772989ea | ||
|
|
cf5aafc12f | ||
|
|
a5f852fcc2 | ||
|
|
07544595fd | ||
|
|
e616ab5d35 | ||
|
|
6e072ea026 | ||
|
|
230a68d564 | ||
|
|
a0ce9e3dca | ||
|
|
0676e0f54a | ||
|
|
ba93f21795 | ||
|
|
5be561133d | ||
|
|
bfa90a07cc | ||
|
|
5f38cd1ee1 |
@@ -41,7 +41,7 @@
|
||||
"tap": "^11.0.0",
|
||||
"travis-after-all": "^1.4.4",
|
||||
"uglifyjs-webpack-plugin": "^1.2.5",
|
||||
"webpack": "^4.8.0",
|
||||
"webpack": "^4.28.4",
|
||||
"webpack-cli": "^3.1.0",
|
||||
"webpack-dev-server": "^3.1.4"
|
||||
},
|
||||
@@ -53,7 +53,7 @@
|
||||
"minilog": "3.1.0",
|
||||
"raw-loader": "^0.5.1",
|
||||
"scratch-storage": "^1.0.0",
|
||||
"scratch-svg-renderer": "0.2.0-prerelease.20181220183040",
|
||||
"scratch-svg-renderer": "0.2.0-prerelease.20190109201344",
|
||||
"twgl.js": "4.4.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,16 +426,16 @@ class Drawable {
|
||||
* Should the drawable use NEAREST NEIGHBOR or LINEAR INTERPOLATION mode
|
||||
*/
|
||||
get useNearest () {
|
||||
// We can't use nearest neighbor unless we are a multiple of 90 rotation
|
||||
if (this._direction % 90 !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Raster skins (bitmaps) should always prefer nearest neighbor
|
||||
if (this.skin.isRaster) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We can't use nearest neighbor unless we are a multiple of 90 rotation
|
||||
if (this._direction % 90 !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the scale of the skin is very close to 100 (0.99999 variance is okay I guess)
|
||||
if (Math.abs(this.scale[0]) > 99 && Math.abs(this.scale[0]) < 101 &&
|
||||
Math.abs(this.scale[1]) > 99 && Math.abs(this.scale[1]) < 101) {
|
||||
|
||||
@@ -931,7 +931,11 @@ class RenderWebGL extends EventEmitter {
|
||||
const worldPos = twgl.v3.create();
|
||||
|
||||
drawable.updateMatrix();
|
||||
drawable.skin.updateSilhouette();
|
||||
if (drawable.skin) {
|
||||
drawable.skin.updateSilhouette();
|
||||
} else {
|
||||
log.warn(`Could not find skin for drawable with id: ${drawableID}`);
|
||||
}
|
||||
|
||||
for (worldPos[1] = bounds.bottom; worldPos[1] <= bounds.top; worldPos[1]++) {
|
||||
for (worldPos[0] = bounds.left; worldPos[0] <= bounds.right; worldPos[0]++) {
|
||||
@@ -963,7 +967,11 @@ class RenderWebGL extends EventEmitter {
|
||||
// default pick list ignores visible and ghosted sprites.
|
||||
if (drawable.getVisible() && drawable.getUniforms().u_ghost !== 0) {
|
||||
drawable.updateMatrix();
|
||||
drawable.skin.updateSilhouette();
|
||||
if (drawable.skin) {
|
||||
drawable.skin.updateSilhouette();
|
||||
} else {
|
||||
log.warn(`Could not find skin for drawable with id: ${id}`);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -101,7 +101,6 @@ class SVGSkin extends Skin {
|
||||
if (this._texture) {
|
||||
gl.bindTexture(gl.TEXTURE_2D, this._texture);
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._svgRenderer.canvas);
|
||||
this._silhouette.update(this._svgRenderer.canvas);
|
||||
} else {
|
||||
// TODO: mipmaps?
|
||||
const textureOptions = {
|
||||
@@ -111,8 +110,8 @@ class SVGSkin extends Skin {
|
||||
};
|
||||
|
||||
this._texture = twgl.createTexture(gl, textureOptions);
|
||||
this._silhouette.update(this._svgRenderer.canvas);
|
||||
}
|
||||
this._silhouetteDirty = true;
|
||||
|
||||
const maxDimension = Math.max(this._svgRenderer.canvas.width, this._svgRenderer.canvas.height);
|
||||
let testScale = 2;
|
||||
@@ -126,6 +125,12 @@ class SVGSkin extends Skin {
|
||||
});
|
||||
}
|
||||
|
||||
updateSilhouette () {
|
||||
if (this._silhouetteDirty) {
|
||||
this._silhouette.update(this._svgRenderer.canvas);
|
||||
this._silhouetteDirty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SVGSkin;
|
||||
|
||||
Reference in New Issue
Block a user