feat: 裁剪组裁剪跟随选择组移动
This commit is contained in:
@@ -159,9 +159,7 @@ export class LiquifyRealTimeUpdater {
|
||||
// });
|
||||
// }
|
||||
} else {
|
||||
console.warn(
|
||||
"=================快速更新液化效果时,图像数据未变化,跳过更新"
|
||||
);
|
||||
console.warn("=================快速更新液化效果时,图像数据未变化,跳过更新");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("快速更新液化效果失败:", error);
|
||||
@@ -184,6 +182,8 @@ export class LiquifyRealTimeUpdater {
|
||||
*/
|
||||
async _fullUpdate(imageData) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 临时禁用画布自动渲染
|
||||
const oldRenderOnAddRemove = this.canvas.renderOnAddRemove;
|
||||
try {
|
||||
// 使用高质量canvas进行最终渲染
|
||||
this.highQualityCtx.putImageData(imageData, 0, 0);
|
||||
@@ -233,9 +233,6 @@ export class LiquifyRealTimeUpdater {
|
||||
selected: false,
|
||||
evented: originalObj.evented,
|
||||
});
|
||||
|
||||
// 临时禁用画布自动渲染
|
||||
const oldRenderOnAddRemove = this.canvas.renderOnAddRemove;
|
||||
this.canvas.renderOnAddRemove = false;
|
||||
|
||||
// 智能查找和替换canvas上的对象
|
||||
@@ -244,9 +241,7 @@ export class LiquifyRealTimeUpdater {
|
||||
|
||||
// 如果直接查找失败,尝试通过ID查找
|
||||
if (targetIndex === -1 && originalObjId) {
|
||||
targetIndex = allObjects.findIndex(
|
||||
(obj) => obj.id === originalObjId
|
||||
);
|
||||
targetIndex = allObjects.findIndex((obj) => obj.id === originalObjId);
|
||||
if (targetIndex !== -1) {
|
||||
console.log(`通过ID找到目标对象: ${originalObjId}`);
|
||||
// 更新目标对象引用
|
||||
@@ -256,9 +251,7 @@ export class LiquifyRealTimeUpdater {
|
||||
|
||||
// 如果通过ID查找仍然失败,尝试通过图层ID查找
|
||||
if (targetIndex === -1 && originalObjLayerId) {
|
||||
targetIndex = allObjects.findIndex(
|
||||
(obj) => obj.layerId === originalObjLayerId
|
||||
);
|
||||
targetIndex = allObjects.findIndex((obj) => obj.layerId === originalObjLayerId);
|
||||
if (targetIndex !== -1) {
|
||||
console.log(`通过图层ID找到目标对象: ${originalObjLayerId}`);
|
||||
// 更新目标对象引用
|
||||
@@ -284,9 +277,7 @@ export class LiquifyRealTimeUpdater {
|
||||
resolve(newImg);
|
||||
} else {
|
||||
// 如果在画布中找不到对象,可能对象已被移除或引用已更新
|
||||
console.warn(
|
||||
"在画布中找不到目标对象,可能已被其他操作移除或替换"
|
||||
);
|
||||
console.warn("在画布中找不到目标对象,可能已被其他操作移除或替换");
|
||||
|
||||
// 恢复自动渲染设置
|
||||
this.canvas.renderOnAddRemove = oldRenderOnAddRemove;
|
||||
@@ -333,24 +324,6 @@ export class LiquifyRealTimeUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理资源
|
||||
*/
|
||||
dispose() {
|
||||
this.targetObject = null;
|
||||
this.cachedDataURL = null;
|
||||
this.pendingImageData = null;
|
||||
this.updateQueue.length = 0;
|
||||
|
||||
// 清理临时canvas
|
||||
if (this.tempCanvas) {
|
||||
this.tempCanvas.width = 0;
|
||||
this.tempCanvas.height = 0;
|
||||
this.tempCanvas = null;
|
||||
this.tempCtx = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前目标对象
|
||||
* @returns {Object} 当前的fabric对象
|
||||
@@ -388,13 +361,6 @@ export class LiquifyRealTimeUpdater {
|
||||
console.log("✅ 恢复正常渲染模式");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前目标对象
|
||||
*/
|
||||
getTargetObject() {
|
||||
return this.targetObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图像质量
|
||||
* @param {Number} quality 质量值 (0.1-1.0)
|
||||
@@ -416,6 +382,24 @@ export class LiquifyRealTimeUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 清理资源
|
||||
// */
|
||||
// dispose() {
|
||||
// this.targetObject = null;
|
||||
// this.cachedDataURL = null;
|
||||
// this.pendingImageData = null;
|
||||
// this.updateQueue.length = 0;
|
||||
|
||||
// // 清理临时canvas
|
||||
// if (this.tempCanvas) {
|
||||
// this.tempCanvas.width = 0;
|
||||
// this.tempCanvas.height = 0;
|
||||
// this.tempCanvas = null;
|
||||
// this.tempCtx = null;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 清理资源
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user