Compare commits

...

14 Commits

Author SHA1 Message Date
greenkeeper[bot]
96f50b29ee chore(package): update webpack to version 4.28.4 2019-01-10 19:41:00 +00:00
Paul Kaplan
75772989ea Merge pull request #395 from LLK/greenkeeper/scratch-svg-renderer-0.2.0-prerelease.20190109201344
Update scratch-svg-renderer to the latest version 🚀
2019-01-09 15:16:30 -05:00
greenkeeper[bot]
cf5aafc12f fix(package): update scratch-svg-renderer to version 0.2.0-prerelease.20190109201344 2019-01-09 20:15:01 +00:00
Paul Kaplan
a5f852fcc2 Merge pull request #394 from paulkaplan/defer-silhouette-updates
Implement updateSilhouette to allow updates to happen when needed
2019-01-09 14:59:56 -05:00
Paul Kaplan
07544595fd Implement updateSilhouette to allow updates to happen when needed 2019-01-09 14:22:08 -05:00
Paul Kaplan
e616ab5d35 Merge pull request #393 from LLK/revert-391-blurrybg
Revert "Increase maximum texture size and back it off if GL fails to render"
2019-01-08 16:00:30 -05:00
Paul Kaplan
6e072ea026 Revert "Increase maximum texture size and back it off if GL fails to render" 2019-01-08 15:59:09 -05:00
DD Liu
230a68d564 Merge pull request #391 from LLK/blurrybg
Increase maximum texture size and back it off if GL fails to render
2019-01-08 12:41:49 -05:00
Karishma Chadha
a0ce9e3dca Merge pull request #392 from kchadha/fix-uncaught-type-error
Fix uncaught error `cannot find property updateSilhouette of null`
2019-01-07 11:19:49 -05:00
DD Liu
0676e0f54a Use callback for loop, and update maxTextureScale during callback 2019-01-07 10:00:31 -05:00
Karishma Chadha
ba93f21795 Fix uncaught error when drawable.skin does not exist. Log a warning in this case instead. 2019-01-06 18:02:33 -05:00
DD Liu
5be561133d Increase maximum texture size and back it off if GL fails to render 2019-01-05 00:43:55 -05:00
Chris Willis-Ford
bfa90a07cc Merge pull request #385 from fsih/fixBlurry
Always use nearest for raster textures
2019-01-03 14:00:29 -05:00
DD
5f38cd1ee1 Always use nearest for raster textures 2019-01-03 12:00:28 -05:00
4 changed files with 24 additions and 11 deletions

View File

@@ -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"
}
}

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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;