Compare commits
2 Commits
renovate/d
...
0.1.0-prer
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d019ad8ed | ||
|
|
0ec6f4f6f0 |
@@ -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.20200610220938",
|
||||
"scratch-svg-renderer": "0.2.0-prerelease.20201014105708",
|
||||
"twgl.js": "4.4.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,12 +350,13 @@ class RenderWebGL extends EventEmitter {
|
||||
* @param {!string} svgData - new SVG to use.
|
||||
* @param {?Array<number>} rotationCenter Optional: rotation center of the skin. If not supplied, the center of the
|
||||
* skin will be used
|
||||
* @param {function} [onSkinReady] - Optional: if present, will be called after the skin loads
|
||||
* @returns {!int} the ID for the new skin.
|
||||
*/
|
||||
createSVGSkin (svgData, rotationCenter) {
|
||||
createSVGSkin (svgData, rotationCenter, onSkinReady) {
|
||||
const skinId = this._nextSkinId++;
|
||||
const newSkin = new SVGSkin(skinId, this);
|
||||
newSkin.setSVG(svgData, rotationCenter);
|
||||
newSkin.setSVG(svgData, rotationCenter, onSkinReady);
|
||||
this._allSkins[skinId] = newSkin;
|
||||
return skinId;
|
||||
}
|
||||
@@ -393,6 +394,7 @@ class RenderWebGL extends EventEmitter {
|
||||
* @param {!string} svgData - new SVG to use.
|
||||
* @param {?Array<number>} rotationCenter Optional: rotation center of the skin. If not supplied, the center of the
|
||||
* skin will be used
|
||||
* @returns {Promise} - a promise which resolves after the skin has updated
|
||||
*/
|
||||
updateSVGSkin (skinId, svgData, rotationCenter) {
|
||||
if (this._allSkins[skinId] instanceof SVGSkin) {
|
||||
@@ -401,8 +403,9 @@ class RenderWebGL extends EventEmitter {
|
||||
}
|
||||
|
||||
const newSkin = new SVGSkin(skinId, this);
|
||||
newSkin.setSVG(svgData, rotationCenter);
|
||||
this._reskin(skinId, newSkin);
|
||||
return newSkin.setSVG(svgData, rotationCenter).then(() => {
|
||||
this._reskin(skinId, newSkin);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,9 +140,11 @@ class SVGSkin extends Skin {
|
||||
* Set the contents of this skin to a snapshot of the provided SVG data.
|
||||
* @param {string} svgData - new SVG to use.
|
||||
* @param {Array<number>} [rotationCenter] - Optional rotation center for the SVG.
|
||||
* @param {function} [onSkinReady] - Optional: if present, will be called after the skin loads
|
||||
* @returns {Promise} - a promise which resolves after the SVG is loaded and ready
|
||||
*/
|
||||
setSVG (svgData, rotationCenter) {
|
||||
this._svgRenderer.loadSVG(svgData, false, () => {
|
||||
setSVG (svgData, rotationCenter, onSkinReady) {
|
||||
return this._svgRenderer.loadSVG(svgData, false, () => {
|
||||
const svgSize = this._svgRenderer.size;
|
||||
if (svgSize[0] === 0 || svgSize[1] === 0) {
|
||||
super.setEmptyImageData();
|
||||
@@ -163,6 +165,9 @@ class SVGSkin extends Skin {
|
||||
this._rotationCenter[1] = rotationCenter[1] - viewOffset[1];
|
||||
|
||||
this.emit(Skin.Events.WasAltered);
|
||||
if (onSkinReady) {
|
||||
onSkinReady();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user