diff --git a/package.json b/package.json index dbf7f92..c900836 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "pinia": "^3.0.1", "sortablejs": "1.15.6", "split.js": "^1.6.4", - "three": "^0.176.0", "vue": "^3.5.13", "vue-i18n": "9.2.2", "vue-router": "^4.5.0", @@ -55,6 +54,8 @@ "typescript": "~5.8.0", "vite": "^6.2.4", "vite-plugin-vue-devtools": "^7.7.2", - "vue-tsc": "^2.2.8" + "vue-tsc": "^2.2.8", + "three": "^0.176.0", + "camera-controls": "2.10.1" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d65f3a1..59fabd5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,9 +62,6 @@ importers: split.js: specifier: ^1.6.4 version: 1.6.5 - three: - specifier: ^0.176.0 - version: 0.176.0 vue: specifier: ^3.5.13 version: 3.5.14(typescript@5.8.3) @@ -114,6 +111,9 @@ importers: '@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) npm-run-all2: specifier: ^7.0.2 version: 7.0.2 @@ -123,6 +123,9 @@ importers: rimraf: specifier: ^6.0.1 version: 6.0.1 + three: + specifier: ^0.176.0 + version: 0.176.0 typescript: specifier: ~5.8.0 version: 5.8.3 @@ -543,67 +546,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==} @@ -866,6 +858,11 @@ packages: resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} engines: {node: '>= 0.4'} + camera-controls@2.10.1: + resolution: {integrity: sha512-KnaKdcvkBJ1Irbrzl8XD6WtZltkRjp869Jx8c0ujs9K+9WD+1D7ryBsCiVqJYUqt6i/HR5FxT7RLASieUD+Q5w==} + peerDependencies: + three: '>=0.126.1' + caniuse-lite@1.0.30001718: resolution: {integrity: sha512-AflseV1ahcSunK53NfEs9gFWgOEmzr0f+kaMFA4xiLZlr9Hzt7HxcSpIFcnNCUkz6R6dWKa54rUz3HUmI3nVcw==} @@ -2384,6 +2381,10 @@ snapshots: es-errors: 1.3.0 function-bind: 1.1.2 + camera-controls@2.10.1(three@0.176.0): + dependencies: + three: 0.176.0 + caniuse-lite@1.0.30001718: {} codemirror@5.65.19: {} diff --git a/src/designer/Designer.ts b/src/designer/Designer.ts deleted file mode 100644 index 58c78f7..0000000 --- a/src/designer/Designer.ts +++ /dev/null @@ -1,35 +0,0 @@ -import Example1 from './example1' -import { markRaw, reactive } from 'vue' - -/** - * 全局设计器 - */ -export default class Designer { - - data: any = null - allLevels: any = null - currentFloor: string = null - - editorState = reactive({ - ready: false, - camera: { - position: { x: 0, y: 0, z: 0 }, - rotation: { x: 0, y: 0, z: 0 } - } - }) - - constructor() { - this.init() - this.open() - } - - init() { - window['designer'] = this - } - - open() { - system.msg('打开成功') - this.data = markRaw(Example1) - this.allLevels = reactive(this.data.allLevels) - } -} \ No newline at end of file diff --git a/src/designer/model2DEditor/ThreeJsEditor.vue b/src/designer/model2DEditor/ThreeJsEditor.vue index b5d7589..b6a62c5 100644 --- a/src/designer/model2DEditor/ThreeJsEditor.vue +++ b/src/designer/model2DEditor/ThreeJsEditor.vue @@ -2,333 +2,48 @@
\ No newline at end of file diff --git a/src/designer/model2DEditor/tools/MouseMoveInspect.ts b/src/designer/model2DEditor/tools/MouseMoveInspect.ts new file mode 100644 index 0000000..54349b5 --- /dev/null +++ b/src/designer/model2DEditor/tools/MouseMoveInspect.ts @@ -0,0 +1,16 @@ +import Editor from '@/designer/Editor.js' +import type Viewport from '@/designer/Viewport.ts' + +/** + * 鼠标移动时,将鼠标位置的坐标转换为设计图上的坐标,并设置到 designer.mousePos 属性中 + */ +export default class MouseMoveInspect { + viewport: Viewport + + constructor(viewport: Viewport) { + this.viewport = viewport + } + + mouseMove(event) { + } +} \ No newline at end of file diff --git a/src/designer/model3DView/Model3DView.vue b/src/designer/model3DView/Model3DView.vue index 39c74a1..728d3f9 100644 --- a/src/designer/model3DView/Model3DView.vue +++ b/src/designer/model3DView/Model3DView.vue @@ -322,11 +322,9 @@ function initMode3DCamera() { const viewerDom = canvasContainer.value - // 渲染相机 + // ============================ 创建透视相机 const cameraNew = new THREE.PerspectiveCamera(25, viewerDom.clientWidth / viewerDom.clientHeight, 0.1, 2000) - //设置相机位置 cameraNew.position.set(5, 5, 5) - //设置相机方向 cameraNew.lookAt(0, 0, 0) camera = cameraNew diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 7eadb54..7dac369 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -1,11 +1,12 @@ import _ from 'lodash' import $ from 'jquery' import type System from '@/runtime/System' -import type Designer from '@/designer/Designer' +import type WorldModel from '@/designer/WorldModel' declare global { const $: $ const _: _ const system: System - const designer: Designer + + const worldModel: WorldModel } \ No newline at end of file