diff --git a/package.json b/package.json index ee3efc7..2795d4b 100644 --- a/package.json +++ b/package.json @@ -12,28 +12,7 @@ "format": "prettier --write src/" }, "dependencies": { - "@vueuse/core": "^13.2.0", - "ag-grid-community": "^28.2.1", - "ag-grid-enterprise": "^28.2.1", - "ag-grid-vue3": "^28.2.1", - "axios": "^1.9.0", - "codemirror": "^5.65.19", - "dat.gui": "^0.7.9", - "decimal.js": "^10.5.0", - "element-plus": "^2.9.10", - "hotkeys-js": "^3.13.10", - "jquery": "^3.6.0", - "json5": "^2.2.3", - "less": "^4.2.1", - "localforage": "^1.10.0", - "lodash": "^4.17.21", - "pinia": "^3.0.1", - "sortablejs": "1.15.6", - "split.js": "^1.6.4", - "vue": "^3.5.13", - "vue-i18n": "9.2.2", - "vue-router": "^4.5.0", - "vue3-menus": "^1.1.2" + "@vueuse/core": "^13.2.0" }, "devDependencies": { "@element-plus/icons-vue": "^2.3.1", @@ -60,6 +39,27 @@ "vue-tsc": "^2.2.8", "three": "^0.176.0", "camera-controls": "2.10.1", - "three-mesh-bvh": "^0.9.0" + "three-mesh-bvh": "^0.9.0", + "ag-grid-community": "^28.2.1", + "ag-grid-enterprise": "^28.2.1", + "ag-grid-vue3": "^28.2.1", + "axios": "^1.9.0", + "codemirror": "^5.65.19", + "dat.gui": "^0.7.9", + "decimal.js": "^10.5.0", + "element-plus": "^2.9.10", + "hotkeys-js": "^3.13.10", + "jquery": "^3.6.0", + "json5": "^2.2.3", + "less": "^4.2.1", + "localforage": "^1.10.0", + "lodash": "^4.17.21", + "pinia": "^3.0.1", + "sortablejs": "1.15.6", + "split.js": "^1.6.4", + "vue": "^3.5.13", + "vue-i18n": "9.2.2", + "vue-router": "^4.5.0", + "vue3-menus": "^1.1.2" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f684e79..69c7e7b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,43 @@ importers: '@vueuse/core': specifier: ^13.2.0 version: 13.2.0(vue@3.5.14(typescript@5.8.3)) + devDependencies: + '@element-plus/icons-vue': + specifier: ^2.3.1 + version: 2.3.1(vue@3.5.14(typescript@5.8.3)) + '@rolldown/pluginutils': + specifier: 1.0.0-beta.8-commit.56abf23 + version: 1.0.0-beta.8-commit.56abf23 + '@tsconfig/node22': + specifier: ^22.0.1 + version: 22.0.2 + '@types/jquery': + specifier: ^3.3.31 + version: 3.5.32 + '@types/lodash': + specifier: ^4.17.7 + version: 4.17.17 + '@types/node': + specifier: ^22.14.0 + version: 22.15.21 + '@types/three': + specifier: ^0.176.0 + version: 0.176.0 + '@vicons/antd': + specifier: ^0.13.0 + version: 0.13.0 + '@vicons/fa': + specifier: ^0.12.0 + version: 0.12.0 + '@vitejs/plugin-vue': + specifier: ^5.2.3 + version: 5.2.4(vite@6.3.5(@types/node@22.15.21)(less@4.3.0))(vue@3.5.14(typescript@5.8.3)) + '@vitejs/plugin-vue-jsx': + specifier: ^4.2.0 + version: 4.2.0(vite@6.3.5(@types/node@22.15.21)(less@4.3.0))(vue@3.5.14(typescript@5.8.3)) + '@vue/tsconfig': + specifier: ^0.7.0 + version: 0.7.0(typescript@5.8.3)(vue@3.5.14(typescript@5.8.3)) ag-grid-community: specifier: ^28.2.1 version: 28.2.1 @@ -23,6 +60,9 @@ importers: axios: specifier: ^1.9.0 version: 1.9.0 + camera-controls: + specifier: 2.10.1 + version: 2.10.1(three@0.176.0) codemirror: specifier: ^5.65.19 version: 5.65.19 @@ -53,79 +93,27 @@ importers: lodash: specifier: ^4.17.21 version: 4.17.21 - pinia: - specifier: ^3.0.1 - version: 3.0.2(typescript@5.8.3)(vue@3.5.14(typescript@5.8.3)) - sortablejs: - specifier: 1.15.6 - version: 1.15.6 - split.js: - specifier: ^1.6.4 - version: 1.6.5 - vue: - specifier: ^3.5.13 - version: 3.5.14(typescript@5.8.3) - vue-i18n: - specifier: 9.2.2 - version: 9.2.2(vue@3.5.14(typescript@5.8.3)) - vue-router: - specifier: ^4.5.0 - version: 4.5.1(vue@3.5.14(typescript@5.8.3)) - vue3-menus: - specifier: ^1.1.2 - version: 1.1.2 - devDependencies: - '@element-plus/icons-vue': - specifier: ^2.3.1 - version: 2.3.1(vue@3.5.14(typescript@5.8.3)) - '@rolldown/pluginutils': - specifier: 1.0.0-beta.8-commit.56abf23 - version: 1.0.0-beta.8-commit.56abf23 - '@tsconfig/node22': - specifier: ^22.0.1 - version: 22.0.2 - '@types/jquery': - specifier: ^3.3.31 - version: 3.5.32 - '@types/lodash': - specifier: ^4.17.7 - version: 4.17.17 - '@types/node': - specifier: ^22.14.0 - version: 22.15.21 - '@types/three': - specifier: ^0.176.0 - version: 0.176.0 - '@vicons/antd': - specifier: ^0.13.0 - version: 0.13.0 - '@vicons/fa': - specifier: ^0.12.0 - version: 0.12.0 - '@vitejs/plugin-vue': - specifier: ^5.2.3 - version: 5.2.4(vite@6.3.5(@types/node@22.15.21)(less@4.3.0))(vue@3.5.14(typescript@5.8.3)) - '@vitejs/plugin-vue-jsx': - specifier: ^4.2.0 - version: 4.2.0(vite@6.3.5(@types/node@22.15.21)(less@4.3.0))(vue@3.5.14(typescript@5.8.3)) - '@vue/tsconfig': - specifier: ^0.7.0 - version: 0.7.0(typescript@5.8.3)(vue@3.5.14(typescript@5.8.3)) - camera-controls: - specifier: 2.10.1 - version: 2.10.1(three@0.176.0) mitt: specifier: ^3.0.1 version: 3.0.1 npm-run-all2: specifier: ^7.0.2 version: 7.0.2 + pinia: + specifier: ^3.0.1 + version: 3.0.2(typescript@5.8.3)(vue@3.5.14(typescript@5.8.3)) prettier: specifier: 3.5.3 version: 3.5.3 rimraf: specifier: ^6.0.1 version: 6.0.1 + sortablejs: + specifier: 1.15.6 + version: 1.15.6 + split.js: + specifier: ^1.6.4 + version: 1.6.5 three: specifier: ^0.176.0 version: 0.176.0 @@ -147,9 +135,21 @@ importers: vite-plugin-vue-devtools: specifier: ^7.7.2 version: 7.7.6(rollup@4.41.0)(vite@6.3.5(@types/node@22.15.21)(less@4.3.0))(vue@3.5.14(typescript@5.8.3)) + vue: + specifier: ^3.5.13 + version: 3.5.14(typescript@5.8.3) + vue-i18n: + specifier: 9.2.2 + version: 9.2.2(vue@3.5.14(typescript@5.8.3)) + vue-router: + specifier: ^4.5.0 + version: 4.5.1(vue@3.5.14(typescript@5.8.3)) vue-tsc: specifier: ^2.2.8 version: 2.2.10(typescript@5.8.3) + vue3-menus: + specifier: ^1.1.2 + version: 1.1.2 packages: @@ -558,67 +558,56 @@ packages: resolution: {integrity: sha512-46OzWeqEVQyX3N2/QdiU/CMXYDH/lSHpgfBkuhl3igpZiaB3ZIfSjKuOnybFVBQzjsLwkus2mjaESy8H41SzvA==} cpu: [arm] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.41.0': resolution: {integrity: sha512-lfgW3KtQP4YauqdPpcUZHPcqQXmTmH4nYU0cplNeW583CMkAGjtImw4PKli09NFi2iQgChk4e9erkwlfYem6Lg==} cpu: [arm] os: [linux] - libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.41.0': resolution: {integrity: sha512-nn8mEyzMbdEJzT7cwxgObuwviMx6kPRxzYiOl6o/o+ChQq23gfdlZcUNnt89lPhhz3BYsZ72rp0rxNqBSfqlqw==} cpu: [arm64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.41.0': resolution: {integrity: sha512-l+QK99je2zUKGd31Gh+45c4pGDAqZSuWQiuRFCdHYC2CSiO47qUWsCcenrI6p22hvHZrDje9QjwSMAFL3iwXwQ==} cpu: [arm64] os: [linux] - libc: [musl] '@rollup/rollup-linux-loongarch64-gnu@4.41.0': resolution: {integrity: sha512-WbnJaxPv1gPIm6S8O/Wg+wfE/OzGSXlBMbOe4ie+zMyykMOeqmgD1BhPxZQuDqwUN+0T/xOFtL2RUWBspnZj3w==} cpu: [loong64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-powerpc64le-gnu@4.41.0': resolution: {integrity: sha512-eRDWR5t67/b2g8Q/S8XPi0YdbKcCs4WQ8vklNnUYLaSWF+Cbv2axZsp4jni6/j7eKvMLYCYdcsv8dcU+a6QNFg==} cpu: [ppc64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.41.0': resolution: {integrity: sha512-TWrZb6GF5jsEKG7T1IHwlLMDRy2f3DPqYldmIhnA2DVqvvhY2Ai184vZGgahRrg8k9UBWoSlHv+suRfTN7Ua4A==} cpu: [riscv64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-riscv64-musl@4.41.0': resolution: {integrity: sha512-ieQljaZKuJpmWvd8gW87ZmSFwid6AxMDk5bhONJ57U8zT77zpZ/TPKkU9HpnnFrM4zsgr4kiGuzbIbZTGi7u9A==} cpu: [riscv64] os: [linux] - libc: [musl] '@rollup/rollup-linux-s390x-gnu@4.41.0': resolution: {integrity: sha512-/L3pW48SxrWAlVsKCN0dGLB2bi8Nv8pr5S5ocSM+S0XCn5RCVCXqi8GVtHFsOBBCSeR+u9brV2zno5+mg3S4Aw==} cpu: [s390x] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.41.0': resolution: {integrity: sha512-XMLeKjyH8NsEDCRptf6LO8lJk23o9wvB+dJwcXMaH6ZQbbkHu2dbGIUindbMtRN6ux1xKi16iXWu6q9mu7gDhQ==} cpu: [x64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-musl@4.41.0': resolution: {integrity: sha512-m/P7LycHZTvSQeXhFmgmdqEiTqSV80zn6xHaQ1JSqwCtD1YGtwEK515Qmy9DcB2HK4dOUVypQxvhVSy06cJPEg==} cpu: [x64] os: [linux] - libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.41.0': resolution: {integrity: sha512-4yodtcOrFHpbomJGVEqZ8fzD4kfBeCbpsUy5Pqk4RluXOdsWdjLnjhiKy2w3qzcASWd04fp52Xz7JKarVJ5BTg==} diff --git a/src/assets/fonts/simsunb.ttf b/src/assets/fonts/simsunb.ttf new file mode 100644 index 0000000..0739783 Binary files /dev/null and b/src/assets/fonts/simsunb.ttf differ diff --git a/src/core/ModelUtils.ts b/src/core/ModelUtils.ts index 146c474..2d452b9 100644 --- a/src/core/ModelUtils.ts +++ b/src/core/ModelUtils.ts @@ -217,7 +217,6 @@ export function quickCopyByMouse() { if (items[0]) { // 找到一个有效点,执行复制操作 viewport.interactionManager.startInteraction(items[0].t, { startPoint: items[0].id }) - system.msg('连线成功') return } @@ -242,8 +241,8 @@ export function quickCopyByMouse() { // return false // }) - if (!r || r.length === 0) { - system.msg('鼠标所在位置,没有可复制的对象') + if (!items || items.length === 0) { + system.msg('鼠标所在位置,没有可复制的对象', 'error') return } } diff --git a/src/core/base/BaseRenderer.ts b/src/core/base/BaseRenderer.ts index 0cdf819..1533c89 100644 --- a/src/core/base/BaseRenderer.ts +++ b/src/core/base/BaseRenderer.ts @@ -23,6 +23,10 @@ export default abstract class BaseRenderer { this.itemTypeName = itemTypeName } + async init(): Promise { + return Promise.resolve() + } + /** * 开始更新 * @param viewport 当前视口 diff --git a/src/core/manager/InteractionManager.ts b/src/core/manager/InteractionManager.ts index 422f599..82d07b9 100644 --- a/src/core/manager/InteractionManager.ts +++ b/src/core/manager/InteractionManager.ts @@ -56,7 +56,7 @@ export default class InteractionManager implements IControls { this.viewport.dragControl.dragControls.enabled = true this.viewport.viewerDom.style.cursor = '' - system.msg('退出新建模式') + // system.msg('退出新建模式') } private _setActiveInteraction(mode: string, option?: InteractionOption): void { @@ -98,7 +98,7 @@ export default class InteractionManager implements IControls { // 更新 UI 状态 this.viewport.viewerDom.style.cursor = 'crosshair' this.viewport.state.cursorMode = mode - system.msg(`enter [${mode}] interaction`) + // system.msg(`enter [${mode}] interaction`) } dispose(): void { diff --git a/src/core/manager/ModuleManager.ts b/src/core/manager/ModuleManager.ts index cc3f523..09437b4 100644 --- a/src/core/manager/ModuleManager.ts +++ b/src/core/manager/ModuleManager.ts @@ -28,6 +28,7 @@ export function defineModule(option: ModuleDefineOption): void { throw new Error(`Module with name "${option.name}" is already defined.`) } modules.set(option.name, option) + option.renderer.init().finally() } /** diff --git a/src/modules/measure/MeasureRenderer.ts b/src/modules/measure/MeasureRenderer.ts index 32c05ba..3e5135e 100644 --- a/src/modules/measure/MeasureRenderer.ts +++ b/src/modules/measure/MeasureRenderer.ts @@ -7,6 +7,7 @@ import { Line2 } from 'three/examples/jsm/lines/Line2.js' import { numberToString } from '@/utils/webutils.ts' import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer' import { Text } from 'troika-three-text' +import SimSunTTF from '@/assets/fonts/simsunb.ttf' /** * 辅助测量工具渲染器 @@ -24,15 +25,8 @@ export default class MeasureRenderer extends BaseRenderer { public useHtmlLabel = false - readonly pointMaterial = new THREE.MeshBasicMaterial({ color: 0x303133, transparent: true, opacity: 0.9 }) - - readonly lineMaterial = new LineMaterial({ - color: 0xE63C17, // 主颜色 - linewidth: 2, // 实际可用的线宽 - vertexColors: true, // 启用顶点颜色 - dashed: false, - alphaToCoverage: true - }) + pointMaterial: THREE.MeshBasicMaterial + lineMaterial: LineMaterial readonly defaultScale: THREE.Vector3 = new THREE.Vector3(0.25, 0.1, 0.25) readonly defaultRotation: THREE.Vector3 = new THREE.Vector3(0, 0, 0) @@ -41,6 +35,25 @@ export default class MeasureRenderer extends BaseRenderer { super(itemTypeName) } + async init() { + this.pointMaterial = new THREE.MeshBasicMaterial({ color: 0x303133, transparent: true, opacity: 0.9 }) + this.lineMaterial = new LineMaterial({ + color: 0xE63C17, // 主颜色 + linewidth: 2, // 实际可用的线宽 + vertexColors: true, // 启用顶点颜色 + dashed: false, + alphaToCoverage: true + }) + return Promise.all([ + super.init(), + this.loadFont() + ]) + } + + async loadFont() { + return Promise.resolve() + } + createLineBasic(start: ItemJson, end: ItemJson, type: LinkType): THREE.Object3D[] { const geom = new LineGeometry() const obj = new Line2(geom, this.lineMaterial) @@ -99,7 +112,7 @@ export default class MeasureRenderer extends BaseRenderer { objects[0].userData.labelObj = labelObj } - labelObj.position.set(position.x, position.y, position.z - 0.2) + labelObj.position.set(position.x, position.y + 0.3, position.z - 0.2) if (this.useHtmlLabel) { labelObj.element.innerHTML = label @@ -146,6 +159,7 @@ export default class MeasureRenderer extends BaseRenderer { } else { const label = new Text() label.text = text + label.font = SimSunTTF label.fontSize = 0.4 label.color = '#ff0000' label.opacity = 0.8 diff --git a/src/runtime/System.ts b/src/runtime/System.ts index e061b58..2b158b5 100644 --- a/src/runtime/System.ts +++ b/src/runtime/System.ts @@ -52,40 +52,41 @@ export default class System { /** * 轻量级提示信息 * @param message 消息内容 + * @param type 消息类型,默认为 'info' */ - msg(message: string) { - // ElMessage(cc) + msg(message: string, type: 'success' | 'warning' | 'info' | 'error' = 'info'): void { console.trace(message) - - const $body = $('body') - - $body.find('[xtype=tooltip]').remove() - const $w = $( - '
' + - '
' + - _.escape(message) + - '
' - ) - $body.append($w) - - const iframeWidth = $w.parent().width() as number - const iframeHeight = $w.parent().height() as number - - const windowWidth = $w.width() as number - const windowHeight = $w.height() as number - - let setWidth = (iframeWidth - windowWidth) / 2 - let setHeight = (iframeHeight - windowHeight) / 2 - if (iframeHeight < windowHeight || setHeight < 0) { - setHeight = 0 - } - if (iframeWidth < windowWidth || setWidth < 0) { - setWidth = 0 - } - $w.css({ left: setWidth, top: setHeight }) - setTimeout(() => { - $w.remove() - }, 3000) + ElMessage({ message, type }) + + // const $body = $('body') + // + // $body.find('[xtype=tooltip]').remove() + // const $w = $( + // '
' + + // '
' + + // _.escape(message) + + // '
' + // ) + // $body.append($w) + // + // const iframeWidth = $w.parent().width() as number + // const iframeHeight = $w.parent().height() as number + // + // const windowWidth = $w.width() as number + // const windowHeight = $w.height() as number + // + // let setWidth = (iframeWidth - windowWidth) / 2 + // let setHeight = (iframeHeight - windowHeight) / 2 + // if (iframeHeight < windowHeight || setHeight < 0) { + // setHeight = 0 + // } + // if (iframeWidth < windowWidth || setWidth < 0) { + // setWidth = 0 + // } + // $w.css({ left: setWidth, top: setHeight }) + // setTimeout(() => { + // $w.remove() + // }, 3000) } /**