UNPKG

@i3yun/editor

Version:

修复字符串的一个问题

1,242 lines (1,224 loc) 894 kB
/******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ "./src/AppSetting.ts": /*!***************************!*\ !*** ./src/AppSetting.ts ***! \***************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.UserSetting = exports.AppSetting = void 0; const Common_1 = __webpack_require__(/*! ./Services/Common */ "./src/Services/Common.ts"); class AppSetting { constructor() { this.GuiScriptBaseUrl = "https://unpkg.com/"; this.GuiDefaultVisible = false; this.ViewerScriptBaseUrl = "https://unpkg.com/"; this.ViewerDataBaseUrl = "https://www.aisanwei.cn/api/ViewData/"; this.ViewerElementId = 'viewer-element'; this.ViewerEnableDebug = false; this.ViewerEnableGL2 = false; this.ViewerEnableEdit = false; this.ViewerEnableGui = "0"; this.StartSceneUrl = ""; } UseQuery() { let v = Common_1.HelperTool.FromQuery(); let ds = this; for (let key of Object.keys(ds)) { if (v[key.toLowerCase()] != undefined) { ds[key] = v[key.toLowerCase()]; } } return this; } Init() { return this.UseQuery(); } } exports.AppSetting = AppSetting; AppSetting.Version = "2022.4.1.1"; class UserSetting { Save() { let ds = this; for (let key of Object.keys(ds)) { window.localStorage.setItem(key, ds[key]); } } Load() { let ds = this; for (let key of Object.keys(ds)) { let value = window.localStorage.getItem(key); if (value != null) { ds[key] = value; } } return this; } } exports.UserSetting = UserSetting; /***/ }), /***/ "./src/Container.ts": /*!**************************!*\ !*** ./src/Container.ts ***! \**************************/ /***/ ((__unused_webpack_module, exports) => { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.ContainerHost = exports.Container = void 0; class Container { static defineProperty(type) { return new ServiceProxy(type); } constructor() { } Clear() { throw "Not implemented"; } Get(type) { throw "Not implemented"; } Set(type, build) { throw "Not implemented"; } GetInstances() { throw "Not implemented"; } initDefineProperty(t) { for (let key in t) { if (t[key] instanceof ServiceProxy) { t[key] = this.Get(t[key].type); } } } } exports.Container = Container; ; class ServiceProxy { constructor(type) { this.type = type; } } class ContainerHost { static get Current() { if (!this._Current) this._Current = new _Container(); return this._Current; } static CreateContainer() { this._Current = new _Container(); return this._Current; } } exports.ContainerHost = ContainerHost; class _Container extends Container { constructor() { super(); this.TypeInfos = new Map(); this.Set(Container, () => this); } Clear() { this.TypeInfos.forEach((value, key) => { if (value.Value && value.Value.Uninit) { value.Value.Uninit(); } value.Value = undefined; }); } GetInstances() { return Array.from(this.TypeInfos.values()); } Get(type) { if (!this.TypeInfos.has(type)) { this.Set(type); } let typeInfo = this.TypeInfos.get(type); if (!typeInfo.Value) { if (typeInfo.Build) typeInfo.Value = typeInfo.Build(); else typeInfo.Value = new typeInfo.Type(); this.initDefineProperty(typeInfo.Value); if (typeInfo.Value.Init) typeInfo.Value.Init(); } return typeInfo.Value; } Set(type, build) { this.TypeInfos.set(type, { //typeName: type.name, Type: type, Build: build }); } Run(...types) { for (let i = 0; i < types.length; i++) this.Get(types[i]); } } /***/ }), /***/ "./src/Guis/ProjectGui.ts": /*!********************************!*\ !*** ./src/Guis/ProjectGui.ts ***! \********************************/ /***/ (function(__unused_webpack_module, exports, __webpack_require__) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.ProjectGui = void 0; const AppSetting_1 = __webpack_require__(/*! ../AppSetting */ "./src/AppSetting.ts"); const Container_1 = __webpack_require__(/*! ../Container */ "./src/Container.ts"); const BaseGui_1 = __webpack_require__(/*! ../Services/BaseGui */ "./src/Services/BaseGui.ts"); const Common_1 = __webpack_require__(/*! ../Services/Common */ "./src/Services/Common.ts"); const DataService_1 = __webpack_require__(/*! ../Services/DataService */ "./src/Services/DataService.ts"); class ProjectGui extends BaseGui_1.BaseGui { constructor() { super(...arguments); this.title = `项目文件[${ProjectGui.name}]`; this.DataService = Container_1.Container.defineProperty(DataService_1.DataService); this.AppSetting = Container_1.Container.defineProperty(AppSetting_1.AppSetting); this.defaultFileName = "newProject.json"; } UpdateGui() { return __awaiter(this, void 0, void 0, function* () { let fun = { newProject: () => { if (!window.confirm("确实要新建项目吗?")) return; this.defaultFileName = "newProject.json"; this.DataService.Data = {}; this.DataService.OnDataChanged.dispatchEvent(); }, loadProject: () => { this.OpenFile((name, data) => { this.defaultFileName = name; this.DataService.Data = data; this.DataService.OnDataChanged.dispatchEvent(); }); }, loadProjectFromUrl: () => { this.OpenFromUrl((name, data) => { this.defaultFileName = name; this.DataService.Data = data; this.DataService.OnDataChanged.dispatchEvent(); }); }, saveProject: () => { this.SaveFile(this.DataService.Data, this.defaultFileName); } }; let gui = this.gui; let updateGUI = () => { Array.from(gui.__controllers).forEach(_ => { gui.remove(_); }); this.guiService.buildGUIByObject(this.gui, fun); }; updateGUI(); }); } Init() { if (this.AppSetting.StartSceneUrl) { setTimeout(() => { Common_1.HelperTool.httpGet(this.AppSetting.StartSceneUrl).then((data) => { this.defaultFileName = this.AppSetting.StartSceneUrl; this.DataService.Data = data; this.DataService.OnDataChanged.dispatchEvent(); }); }, 500); } } OpenFile(callback) { //@ts-ignore let temp = window.showOpenFilePicker ? this.OpenFileByWindow() : this.OpenFileByDocument(); temp.then((file) => { const reader = new FileReader(); reader.onload = () => { const data = JSON.parse(reader.result); callback(file.name, data); }; reader.readAsText(file); }); } OpenFromUrl(callback) { let fileName = window.prompt("OpenFromUrl", this.defaultFileName); if (!fileName) { return; } Common_1.HelperTool.httpGet(fileName).then((data) => { callback(fileName, data); }); } SaveFile(data, name) { //@ts-ignore window.showSaveFilePicker ? this.SaveFileByWindow(data, name) : this.SaveFileByDocument(data, name); } OpenFileByWindow() { return __awaiter(this, void 0, void 0, function* () { const pickerOpts = { // types: [ // { // description: 'Images', // accept: { // 'image/*': ['.png', '.gif', '.jpeg', '.jpg'] // } // }, // ], //excludeAcceptAllOption: true, multiple: false }; //@ts-ignore let arrFileHandle = yield window.showOpenFilePicker(pickerOpts); let file = yield arrFileHandle[0].getFile(); return file; }); } OpenFileByDocument() { return __awaiter(this, void 0, void 0, function* () { return new Promise((s, f) => { const i = document.createElement("input"); i.type = "file"; i.addEventListener("change", () => { if (i.files) { let file = i.files[0]; s(file); } }); i.click(); }); }); } SaveFileByWindow(data, name) { return __awaiter(this, void 0, void 0, function* () { const opts = { // types: [{ // description: 'Text file', // accept: { 'text/plain': ['.txt'] }, // }], suggestedName: name }; //@ts-ignore let fileHandle = yield window.showSaveFilePicker(opts); //const fileData = await fileHandle.getFile(); const writable = yield fileHandle.createWritable(); yield writable.write(JSON.stringify(data)); yield writable.close(); }); } SaveFileByDocument(data, name) { return __awaiter(this, void 0, void 0, function* () { let fileName = window.prompt("saveProject", name); if (!fileName) { return; } const urlObject = window.URL || window.webkitURL || window; //const exportBlob = new Blob([JSON.stringify(data, null, 4)]); const exportBlob = new Blob([JSON.stringify(data)]); const saveLink = document.createElement("a"); saveLink.href = urlObject.createObjectURL(exportBlob); saveLink.download = fileName; saveLink.click(); }); } } exports.ProjectGui = ProjectGui; /***/ }), /***/ "./src/Guis/editorGui/EditorNodeListGui.ts": /*!*************************************************!*\ !*** ./src/Guis/editorGui/EditorNodeListGui.ts ***! \*************************************************/ /***/ (function(__unused_webpack_module, exports, __webpack_require__) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.EditorPickPointGui = exports.EditorCameraCtrlGui = exports.EditorTimeActionLineGui = exports.EditorTimeActionGui = exports.EditorViewPointAnimationGui = exports.EditorParameterGui = exports.EditorAnimationGui = exports.EditorMarkPanelGui = exports.EditorRotateAnimationGui = exports.EditorPathAnimationGui = exports.EditorModelPartRenderGui = exports.EditorModelRenderGui = exports.EditorNodeEditGui = exports.EditorNodeListGui = void 0; const Container_1 = __webpack_require__(/*! ../../Container */ "./src/Container.ts"); const BaseGui_1 = __webpack_require__(/*! ../../Services/BaseGui */ "./src/Services/BaseGui.ts"); const Common_1 = __webpack_require__(/*! ../../Services/Common */ "./src/Services/Common.ts"); const EditorService_1 = __webpack_require__(/*! ../../Services/EditorService */ "./src/Services/EditorService.ts"); class EditorNodeListGui extends BaseGui_1.BaseGui { constructor() { super(...arguments); this.title = `节点管理[${EditorNodeListGui.name}]`; this.editorService = Container_1.Container.defineProperty(EditorService_1.EditorService); this.data = null; this.moveData = null; } Init() { this.editorService.events.sceneChanged.addEventListener((data) => { this.UpdateGui(); }); this.editorService.events.nodeChanged.addEventListener((data) => { this.UpdateGui(); }); this.editorService.events.nodeSelected.addEventListener((data) => { this.data = data; this.UpdateGui(); }); this.editorService.events.nodeSelected.addEventListener((data) => { if (this.moveData == undefined) return; let moveData = this.moveData; this.moveData = undefined; this.editorService.moveNode(moveData, data); }); } updateData() { let nodes = []; let options = {}; let scene = this.editorService.getScene(); if (scene) { let i = 0; Common_1.HelperTool.SelectTree([scene.scene], (item) => { var _a; return (_a = item.children) === null || _a === void 0 ? void 0 : _a.filter(_ => _.state != EditorService_1.ObjectState.delete); }, (item, level) => { nodes.push(item); let per = Common_1.HelperTool.SelectRange(0, level).map(() => "--").join(""); const name = `${per}${i++}${item.name}`; options[name] = nodes.length - 1; }, 1); } let fun = { addNext: () => { let parent = this.editorService.findParent(nodes[fun.data]); if (!parent) { parent = this.editorService.getScene().scene; } if (!parent.children) parent.children = []; let node = { uuid: Common_1.HelperTool.uuid(), name: `new Node ${parent.children.length}`, state: EditorService_1.ObjectState.change, position: [0, 0, 0], rotation: [0, 0, 0], scale: [1, 1, 1] }; parent.children.push(node); this.editorService.events.nodeChanged.dispatchEvent(node); this.editorService.events.nodeSelected.dispatchEvent(node); }, addChild: () => { let parent = fun.data >= 0 ? nodes[fun.data] : this.editorService.getScene().scene; if (!parent.children) parent.children = []; let node = { uuid: Common_1.HelperTool.uuid(), name: `new Node ${parent.children.length}`, state: EditorService_1.ObjectState.change, position: [0, 0, 0], rotation: [0, 0, 0], scale: [1, 1, 1] }; parent.children.push(node); this.editorService.events.nodeChanged.dispatchEvent(node); this.editorService.events.nodeSelected.dispatchEvent(node); }, remove: () => { let node = nodes[fun.data]; this.data = nodes[fun.data - 1]; this.editorService.setNodeState(node, EditorService_1.ObjectState.delete); this.editorService.events.nodeChanged.dispatchEvent(node); }, move: () => { this.moveData = nodes[fun.data]; alert("请选择父级"); }, copy: () => { let oldNode = nodes[fun.data]; let newNode = this.editorService.copyNode(oldNode); let parent = this.editorService.findParent(oldNode); parent.children.push(newNode); this.editorService.events.nodeChanged.dispatchEvent(newNode); this.editorService.events.nodeSelected.dispatchEvent(newNode); }, focus: () => { this.editorService.events.nodeFocused.dispatchEvent(nodes[fun.data]); }, data: nodes.indexOf(this.data), _moveNode: null, _dataOptions: () => { return options; }, _dataChange: () => { //this.editorService.events.nodeFocused.dispatchEvent(nodes[fun.data]); this.editorService.events.nodeSelected.dispatchEvent(nodes[fun.data]); }, }; return fun; } UpdateGui() { let fun = this.updateData(); let gui = this.gui; let updateGUI = () => { Array.from(gui.__controllers).forEach(_ => { gui.remove(_); }); this.guiService.buildGUIByObject(gui, fun); }; updateGUI(); } } exports.EditorNodeListGui = EditorNodeListGui; class EditorNodeEditGui extends BaseGui_1.BaseGui { constructor() { super(...arguments); this.title = `节点编辑[${EditorNodeEditGui.name}]`; this.editorService = Container_1.Container.defineProperty(EditorService_1.EditorService); this.data = null; } Init() { this.editorService.events.nodeSelected.addEventListener((data) => { this.data = data; this.UpdateGui(); }); this.editorService.events.nodeChanged.addEventListener((data) => { if (data == this.data) this.UpdateGui(); }); } initData() { let data = this.data; let fun = { uuid: data.uuid, name: data.name, position: JSON.stringify(data.position), rotation: JSON.stringify(data.rotation), scale: JSON.stringify(data.scale), _Changed: () => { data.name = fun.name; data.position = JSON.parse(fun.position); data.rotation = JSON.parse(fun.rotation); data.scale = JSON.parse(fun.scale); data.state = EditorService_1.ObjectState.change; this.editorService.events.nodeChanged.dispatchEvent(data); } }; return fun; } UpdateGui() { if (!this.data) return; let fun = this.initData(); let gui = this.gui; let updateGUI = () => { Array.from(gui.__controllers).forEach(_ => { gui.remove(_); }); this.guiService.buildGUIByObject(gui, fun); }; updateGUI(); } } exports.EditorNodeEditGui = EditorNodeEditGui; class EditorModelRenderGui extends BaseGui_1.BaseGui { constructor() { super(...arguments); this.title = `模型组件[${EditorModelRenderGui.name}]`; this.editorService = Container_1.Container.defineProperty(EditorService_1.EditorService); this.data = null; } Init() { this.editorService.events.nodeSelected.addEventListener((data) => { this.data = data; this.UpdateGui(); }); } initData() { var _a; let data = this.data; let c = (_a = data.components) === null || _a === void 0 ? void 0 : _a.find(_ => _.type == "ModelRender"); let fun = { created: c != undefined, active: c ? c.active : false, transparent: c && c.transparent ? c.transparent : false, url: c ? c.url : "", offset: c && c.offset ? JSON.stringify(c.offset) : "", _createdChanged: () => { if (fun.created) { if (!data.components) data.components = []; let c1 = { uuid: Common_1.HelperTool.uuid(), type: "ModelRender", state: EditorService_1.ObjectState.change, active: true, url: "bdd54f13-803b-43d6-bde7-322e00fa38b6", }; data.components.push(c1); // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c1); } else { c.state = EditorService_1.ObjectState.delete; this.editorService.events.componentChanged.dispatchEvent(c); c = null; // this.editorService.events.nodeChanged.dispatchEvent(data); } this.UpdateGui(); }, _activeChanged: () => { if (c) { c.active = fun.active; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _transparentChanged: () => { if (c) { c.transparent = fun.transparent; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _urlChanged: () => { if (c) { c.url = fun.url; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _offsetChanged: () => { if (c) { c.offset = fun.offset == "" ? undefined : JSON.parse(fun.offset); c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } } }; return fun; } UpdateGui() { if (!this.data) return; let fun = this.initData(); let gui = this.gui; let updateGUI = () => { Array.from(gui.__controllers).forEach(_ => { gui.remove(_); }); this.guiService.buildGUIByObject(gui, fun); }; updateGUI(); } } exports.EditorModelRenderGui = EditorModelRenderGui; class EditorModelPartRenderGui extends BaseGui_1.BaseGui { constructor() { super(...arguments); this.title = `模型局部组件[${EditorModelPartRenderGui.name}]`; this.editorService = Container_1.Container.defineProperty(EditorService_1.EditorService); this.data = null; } Init() { this.editorService.events.nodeSelected.addEventListener((data) => { this.data = data; this.UpdateGui(); }); } initData() { var _a; let data = this.data; let c = (_a = data.components) === null || _a === void 0 ? void 0 : _a.find(_ => _.type == "ModelPartRender"); let fun = { created: c != undefined, active: c ? c.active : false, transparent: c && c.transparent ? c.transparent : false, part: c ? c.part : "", offset: c && c.offset ? JSON.stringify(c.offset) : "", _createdChanged: () => { if (fun.created) { if (!data.components) data.components = []; let c1 = { uuid: Common_1.HelperTool.uuid(), type: "ModelRender", state: EditorService_1.ObjectState.change, active: true, url: "bdd54f13-803b-43d6-bde7-322e00fa38b6", }; data.components.push(c1); // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c1); } else { c.state = EditorService_1.ObjectState.delete; this.editorService.events.componentChanged.dispatchEvent(c); c = null; // this.editorService.events.nodeChanged.dispatchEvent(data); } this.UpdateGui(); }, _activeChanged: () => { if (c) { c.active = fun.active; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _transparentChanged: () => { if (c) { c.transparent = fun.transparent; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _partChanged: () => { if (c) { c.part = fun.part; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _offsetChanged: () => { if (c) { c.offset = fun.offset == "" ? undefined : JSON.parse(fun.offset); c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } } }; return fun; } UpdateGui() { if (!this.data) return; let fun = this.initData(); let gui = this.gui; let updateGUI = () => { Array.from(gui.__controllers).forEach(_ => { gui.remove(_); }); this.guiService.buildGUIByObject(gui, fun); }; updateGUI(); } } exports.EditorModelPartRenderGui = EditorModelPartRenderGui; class EditorPathAnimationGui extends BaseGui_1.BaseGui { constructor() { super(...arguments); this.title = `路径组件[${EditorPathAnimationGui.name}]`; this.editorService = Container_1.Container.defineProperty(EditorService_1.EditorService); this.data = null; } Init() { this.editorService.events.nodeSelected.addEventListener((data) => { this.data = data; this.UpdateGui(); }); } initData() { var _a, _b; let data = this.data; let c = (_a = data.components) === null || _a === void 0 ? void 0 : _a.find(_ => _.type == "PathAnimation"); let fun = { created: c != undefined, active: c ? c.active : false, time: c ? c.time : 0, pathNode: c ? (_b = c.pathNode) !== null && _b !== void 0 ? _b : "no pathNode" : "", _createdChanged: () => { if (fun.created) { if (!data.components) data.components = []; let c1 = { uuid: Common_1.HelperTool.uuid(), type: "PathAnimation", state: EditorService_1.ObjectState.change, active: true, time: 1000, pathNode: "", }; data.components.push(c1); // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c1); } else { c.state = EditorService_1.ObjectState.delete; this.editorService.events.componentChanged.dispatchEvent(c); c = null; // this.editorService.events.nodeChanged.dispatchEvent(data); } this.UpdateGui(); }, _activeChanged: () => { if (c) { c.active = fun.active; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _timeChanged: () => { if (c) { c.time = fun.time; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _pathNodeChanged: () => { if (c && c.pathNode) { c.pathNode = fun.pathNode; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } } }; return fun; } UpdateGui() { if (!this.data) return; let fun = this.initData(); let gui = this.gui; let updateGUI = () => { Array.from(gui.__controllers).forEach(_ => { gui.remove(_); }); this.guiService.buildGUIByObject(gui, fun); }; updateGUI(); } } exports.EditorPathAnimationGui = EditorPathAnimationGui; class EditorRotateAnimationGui extends BaseGui_1.BaseGui { constructor() { super(...arguments); this.title = `旋转组件[${EditorRotateAnimationGui.name}]`; this.editorService = Container_1.Container.defineProperty(EditorService_1.EditorService); this.data = null; } Init() { this.editorService.events.nodeSelected.addEventListener((data) => { this.data = data; this.UpdateGui(); }); } initData() { var _a; let data = this.data; let c = (_a = data.components) === null || _a === void 0 ? void 0 : _a.find(_ => _.type == "RotateAnimation"); let fun = { created: c != undefined, active: c ? c.active : false, time: c ? c.time : 0, directionNode: c ? c.directionNode : "", _createdChanged: () => { if (fun.created) { if (!data.components) data.components = []; let c1 = { uuid: Common_1.HelperTool.uuid(), type: "RotateAnimation", state: EditorService_1.ObjectState.change, active: true, time: 1000, directionNode: "", }; data.components.push(c1); // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c1); } else { c.state = EditorService_1.ObjectState.delete; this.editorService.events.componentChanged.dispatchEvent(c); c = null; // this.editorService.events.nodeChanged.dispatchEvent(data); } this.UpdateGui(); }, _activeChanged: () => { if (c) { c.active = fun.active; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _timeChanged: () => { if (c) { c.time = fun.time; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _directionChanged: () => { if (c) { c.directionNode = fun.directionNode; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } } }; return fun; } UpdateGui() { if (!this.data) return; let fun = this.initData(); let gui = this.gui; let updateGUI = () => { Array.from(gui.__controllers).forEach(_ => { gui.remove(_); }); this.guiService.buildGUIByObject(gui, fun); }; updateGUI(); } } exports.EditorRotateAnimationGui = EditorRotateAnimationGui; class EditorMarkPanelGui extends BaseGui_1.BaseGui { constructor() { super(...arguments); this.title = `标记组件[${EditorMarkPanelGui.name}]`; this.editorService = Container_1.Container.defineProperty(EditorService_1.EditorService); this.data = null; this.contentTemp = `<div style="background-color:rgba(255,255,255, 0.8);border: 1px solid black;"> <img src="https://www.aisanwei.cn/apps/dev/logo4.svg" style="width: 32px;">信息面板 </div>`; } Init() { this.editorService.events.nodeSelected.addEventListener((data) => { this.data = data; this.UpdateGui(); }); } initData() { var _a; let data = this.data; let c = (_a = data.components) === null || _a === void 0 ? void 0 : _a.find(_ => _.type == "MarkPanel"); let fun = { created: c != undefined, active: c ? c.active : false, content: c ? c.content : "", _createdChanged: () => { if (fun.created) { if (!data.components) data.components = []; let c1 = { uuid: Common_1.HelperTool.uuid(), type: "MarkPanel", state: EditorService_1.ObjectState.change, active: true, content: this.contentTemp, }; data.components.push(c1); // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c1); } else { c.state = EditorService_1.ObjectState.delete; this.editorService.events.componentChanged.dispatchEvent(c); c = null; // this.editorService.events.nodeChanged.dispatchEvent(data); } this.UpdateGui(); }, _activeChanged: () => { if (c) { c.active = fun.active; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _contentChanged: () => { if (c) { c.content = fun.content; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } } }; return fun; } UpdateGui() { if (!this.data) return; let fun = this.initData(); let gui = this.gui; let updateGUI = () => { Array.from(gui.__controllers).forEach(_ => { gui.remove(_); }); this.guiService.buildGUIByObject(gui, fun); }; updateGUI(); } } exports.EditorMarkPanelGui = EditorMarkPanelGui; class EditorAnimationGui extends BaseGui_1.BaseGui { constructor() { super(...arguments); this.title = `动画组件[${EditorAnimationGui.name}]`; this.editorService = Container_1.Container.defineProperty(EditorService_1.EditorService); this.data = null; } Init() { this.editorService.events.nodeSelected.addEventListener((data) => { this.data = data; this.UpdateGui(); }); } initData() { var _a; let data = this.data; let c = (_a = data.components) === null || _a === void 0 ? void 0 : _a.find(_ => _.type == "Animation"); let fun = { created: c != undefined, active: c ? c.active : false, //content: c ? c.content : "", _createdChanged: () => { if (fun.created) { if (!data.components) data.components = []; let c1 = { uuid: Common_1.HelperTool.uuid(), type: "Animation", state: EditorService_1.ObjectState.change, active: true, frames: [{ state: this.editorService.getAnimationState(data), time: 0, }], }; data.components.push(c1); // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c1); } else { c.state = EditorService_1.ObjectState.delete; this.editorService.events.componentChanged.dispatchEvent(c); c = null; // this.editorService.events.nodeChanged.dispatchEvent(data); } this.UpdateGui(); }, _activeChanged: () => { if (c) { c.active = fun.active; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, addFrame: () => { let time = 1000; time = parseInt(window.prompt("请输入时间", time.toString())); c.frames.push({ state: this.editorService.getAnimationState(data), time: c.frames[c.frames.length - 1].time + time }); c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }; return fun; } UpdateGui() { if (!this.data) return; let fun = this.initData(); let gui = this.gui; let updateGUI = () => { Array.from(gui.__controllers).forEach(_ => { gui.remove(_); }); this.guiService.buildGUIByObject(gui, fun); }; updateGUI(); } } exports.EditorAnimationGui = EditorAnimationGui; class EditorParameterGui extends BaseGui_1.BaseGui { constructor() { super(...arguments); this.title = `参数组件[${EditorParameterGui.name}]`; this.editorService = Container_1.Container.defineProperty(EditorService_1.EditorService); this.data = null; } Init() { this.editorService.events.nodeSelected.addEventListener((data) => { this.data = data; this.UpdateGui(); }); } initData() { var _a; let data = this.data; let c = (_a = data.components) === null || _a === void 0 ? void 0 : _a.find(_ => _.type == "Parameter"); let fun = { created: c != undefined, active: c ? c.active : false, formula: c ? c.formula : "", _createdChanged: () => { if (fun.created) { if (!data.components) data.components = []; let c1 = { uuid: Common_1.HelperTool.uuid(), type: "Parameter", state: EditorService_1.ObjectState.change, active: true, formula: "", frames: [{ state: this.editorService.getAnimationState(data), time: 0, }], }; data.components.push(c1); // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c1); } else { c.state = EditorService_1.ObjectState.delete; this.editorService.events.componentChanged.dispatchEvent(c); c = null; // this.editorService.events.nodeChanged.dispatchEvent(data); } this.UpdateGui(); }, _activeChanged: () => { if (c) { c.active = fun.active; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _formulaChanged: () => { if (c) { c.formula = fun.formula; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, addFrame: () => { let time = 1000; time = parseInt(window.prompt("请输入时间", time.toString())); c.frames.push({ state: this.editorService.getAnimationState(data), time: c.frames[c.frames.length - 1].time + time }); c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }; return fun; } UpdateGui() { if (!this.data) return; let fun = this.initData(); let gui = this.gui; let updateGUI = () => { Array.from(gui.__controllers).forEach(_ => { gui.remove(_); }); this.guiService.buildGUIByObject(gui, fun); }; updateGUI(); } } exports.EditorParameterGui = EditorParameterGui; class EditorViewPointAnimationGui extends BaseGui_1.BaseGui { constructor() { super(...arguments); this.title = `视点动画组件[${EditorViewPointAnimationGui.name}]`; this.editorService = Container_1.Container.defineProperty(EditorService_1.EditorService); this.data = null; } Init() { this.editorService.events.nodeSelected.addEventListener((data) => { this.data = data; this.UpdateGui(); }); } initData() { var _a; let data = this.data; let c = (_a = data.components) === null || _a === void 0 ? void 0 : _a.find(_ => _.type == "ViewPointAnimation"); let fun = { created: c != undefined, active: c ? c.active : false, play: c ? c.play : false, _createdChanged: () => { if (fun.created) { if (!data.components) data.components = []; let c1 = { uuid: Common_1.HelperTool.uuid(), type: "ViewPointAnimation", state: EditorService_1.ObjectState.change, active: true, play: false, frames: [{ state: this.editorService.getViewPointState(), time: 0, }], }; data.components.push(c1); // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } else { c.state = EditorService_1.ObjectState.delete; c = null; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } this.UpdateGui(); }, _activeChanged: () => { if (c) { c.active = fun.active; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, _playChanged: () => { if (c) { c.play = fun.play; c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }, addFrame: () => { let time = 1000; time = parseInt(window.prompt("请输入时间", time.toString())); c.frames.push({ state: this.editorService.getViewPointState(), time: c.frames[c.frames.length - 1].time + time }); c.state = EditorService_1.ObjectState.change; // this.editorService.events.nodeChanged.dispatchEvent(data); this.editorService.events.componentChanged.dispatchEvent(c); } }; return fun; } UpdateGui() { if (!this.data) return; let fun = thi