Compare commits
3
Commits
9662f41eec
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecd24acf19 | ||
|
|
37e1e58883 | ||
|
|
a8947696af |
Binary file not shown.
@@ -18,7 +18,7 @@ import {onMounted, ref} from "vue";
|
||||
import {Copy} from "@vicons/carbon";
|
||||
import {NIcon, NTooltip} from "naive-ui";
|
||||
import {t} from "@/language";
|
||||
import {App,Hooks,AddObjectCommand} from "@astral3d/engine";
|
||||
import {App,Hooks,Loader,Utils,AddObjectCommand} from "@astral3d/engine";
|
||||
|
||||
const disabled = ref(true);
|
||||
|
||||
@@ -36,6 +36,15 @@ function handleClone() {
|
||||
//避免复制相机或场景
|
||||
if (object === null || object.parent === null) return;
|
||||
|
||||
if (Utils.isHtmlPanelObject(object)) {
|
||||
const _json = object.toJSON() as any;
|
||||
|
||||
Loader.objectLoader.parseAsync(_json).then(newObject3D => {
|
||||
App.execute(new AddObjectCommand(newObject3D));
|
||||
}).catch((e: Error) => window.$message?.error(e.message));
|
||||
return;
|
||||
}
|
||||
|
||||
object = object.clone();
|
||||
|
||||
App.execute(new AddObjectCommand(object));
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
ChoroplethMap
|
||||
} from '@vicons/carbon';
|
||||
import {t} from "@/language";
|
||||
import {App,Hooks, MoveObjectCommand, RemoveObjectCommand, AddObjectCommand} from "@astral3d/engine";
|
||||
import {App,Hooks,Loader,Utils, MoveObjectCommand, RemoveObjectCommand, AddObjectCommand} from "@astral3d/engine";
|
||||
import {escapeHTML, findSiblingsAndIndex} from "@/utils/common/utils";
|
||||
import {getMaterialName} from "@/utils/common/scenes";
|
||||
import EsContextmenu from "@/components/es/EsContextmenu.vue";
|
||||
@@ -367,6 +367,15 @@ function handleContextmenuSelect(key: string) {
|
||||
if (parent !== null) App.execute(new RemoveObjectCommand(object));
|
||||
break;
|
||||
case "clone":
|
||||
if (Utils.isHtmlPanelObject(object)) {
|
||||
const _json = object.toJSON() as any;
|
||||
|
||||
Loader.objectLoader.parseAsync(_json).then(newObject3D => {
|
||||
App.execute(new AddObjectCommand(newObject3D));
|
||||
}).catch((e: Error) => window.$message?.error(e.message));
|
||||
break;
|
||||
}
|
||||
|
||||
const _object = object.clone();
|
||||
|
||||
App.execute(new AddObjectCommand(_object));
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { injectWasm } from "@/utils/wasm/inject";
|
||||
|
||||
export function clearBuffer() {
|
||||
injectWasm({ wasmUrl: "/wasm/Astral3DEditor.wasm" }).then(() => {
|
||||
// 加载完wasm后自动注册了清除缓存的函数调用
|
||||
window.clearBuffer();
|
||||
});
|
||||
}
|
||||
@@ -29,6 +29,22 @@ onBeforeUnmount(() => {
|
||||
Hooks.useRemoveSignal("objectSelected", updateUI);
|
||||
})
|
||||
|
||||
function ensureHtmlPanelOptions(object: any) {
|
||||
const options = object?.options || {};
|
||||
const codes = Array.isArray(options.codes) ? options.codes : [];
|
||||
const isSingleHtml = typeof options.isSingleHtml === 'boolean' ? options.isSingleHtml : true;
|
||||
const isSprite = typeof options.isSprite === 'boolean' ? options.isSprite : !!object?.isHtmlSprite;
|
||||
|
||||
object.options = {
|
||||
...options,
|
||||
codes,
|
||||
isSingleHtml,
|
||||
isSprite
|
||||
};
|
||||
|
||||
return object.options;
|
||||
}
|
||||
|
||||
function updateUI() {
|
||||
const object = App.selected;
|
||||
if(!object) return;
|
||||
@@ -39,7 +55,8 @@ function updateUI() {
|
||||
}
|
||||
|
||||
data.type = object.isHtmlPanel? 'panel' :'sprite';
|
||||
data.codes = object.options.codes;
|
||||
const options = ensureHtmlPanelOptions(object);
|
||||
data.codes = options.codes;
|
||||
}
|
||||
|
||||
function update(method: string){
|
||||
@@ -55,6 +72,7 @@ function update(method: string){
|
||||
|
||||
const _json = object.toJSON() as any;
|
||||
_json.object.type = data.type === 'panel' ? 'HtmlSprite' : 'HtmlPanel';
|
||||
_json.object.options = _json.object.options || {};
|
||||
_json.object.options.isSprite = !_json.object.options.isSprite;
|
||||
|
||||
Loader.objectLoader.parseAsync(_json).then(newObject3D => {
|
||||
@@ -73,9 +91,11 @@ function update(method: string){
|
||||
|
||||
_code.content = editorCode.code;
|
||||
|
||||
const options = ensureHtmlPanelOptions(object);
|
||||
|
||||
const htmlPanelOption = {
|
||||
isSprite: object.options.isSprite,
|
||||
isSingleHtml:object.options.isSingleHtml,
|
||||
isSprite: options.isSprite,
|
||||
isSingleHtml: options.isSingleHtml,
|
||||
codes: data.codes
|
||||
}
|
||||
|
||||
@@ -135,10 +155,12 @@ function updateFileList(fList: UploadFileInfo[]) {
|
||||
isSprite: data.type ==='sprite',
|
||||
fileName: file.name
|
||||
}).then(htmlPlaneObj => {
|
||||
object.options.codes = htmlPlaneObj.options.codes;
|
||||
object.options.isSingleHtml = htmlPlaneObj.options.isSingleHtml;
|
||||
const options = ensureHtmlPanelOptions(object);
|
||||
|
||||
data.codes = object.options.codes;
|
||||
options.codes = htmlPlaneObj.options.codes;
|
||||
options.isSingleHtml = htmlPlaneObj.options.isSingleHtml;
|
||||
|
||||
data.codes = options.codes;
|
||||
|
||||
// Keep object identity (id/uuid) so scene tree and context menu references stay valid.
|
||||
while (object.element.firstChild) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import PathDrawingOverlay from "./PathDrawingOverlay.vue";
|
||||
import {useGlobalConfigStore} from "@/store/modules/globalConfig";
|
||||
import {usePluginStore} from "@/store/modules/plugin";
|
||||
import {installBuiltinPlugin} from "@/plugin";
|
||||
import { clearBuffer } from "@/utils/wasm/optimize";
|
||||
import ViewportInfo from "./ViewportInfo.vue";
|
||||
import IFCProperties from "./IFCProperties.vue";
|
||||
|
||||
@@ -94,9 +93,6 @@ onMounted(async () => {
|
||||
|
||||
// 注册astral editor内置插件
|
||||
installBuiltinPlugin(window.viewer);
|
||||
|
||||
// 清理wasm缓存
|
||||
clearBuffer();
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
Reference in New Issue
Block a user