From f4092830a630b373ff2437dfcdeee046931e2621 Mon Sep 17 00:00:00 2001 From: skyun Date: Thu, 19 Oct 2023 04:53:00 +0800 Subject: [PATCH] Thu Oct 19 04:53:00 CST 2023 inscode --- .inscode | 2 +- package.json | 1 + src/assets/base.css | 1 - src/assets/main.css | 39 ++++++++++++-- src/main.js | 7 ++- src/threejs-tools.js | 27 +++++++--- src/views/basic.vue | 118 +++++++++++++++++++++++++++++++++++++------ 7 files changed, 166 insertions(+), 29 deletions(-) diff --git a/.inscode b/.inscode index 9fec957..661e4aa 100644 --- a/.inscode +++ b/.inscode @@ -11,4 +11,4 @@ XDG_CONFIG_HOME = "/root/.config" npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" [debugger] -program = "main.js" +program = "npm run preview" diff --git a/package.json b/package.json index 97f16e6..f1e7954 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "dependencies": { "guess": "^1.0.2", "three": "^0.157.0", + "view-ui-plus": "^1.3.14", "vue": "^3.2.37" }, "devDependencies": { diff --git a/src/assets/base.css b/src/assets/base.css index 71dc55a..ab87f3b 100644 --- a/src/assets/base.css +++ b/src/assets/base.css @@ -60,7 +60,6 @@ } body { - min-height: 100vh; color: var(--color-text); background: var(--color-background); transition: color 0.5s, background-color 0.5s; diff --git a/src/assets/main.css b/src/assets/main.css index 393b942..7c22445 100644 --- a/src/assets/main.css +++ b/src/assets/main.css @@ -1,9 +1,19 @@ @import "./base.css"; - +html { + width: 100%; + height: 100vh; +} +body { + display: flex; + place-items: center; + width: 100%; + height: 100%; +} #app { - max-width: 1280px; margin: 0 auto; font-weight: normal; + width: 100%; + height: 100%; } a, @@ -23,11 +33,32 @@ a, body { display: flex; place-items: center; + width: 100%; + height: 100%; } #app { display: grid; - grid-template-columns: 1fr 1fr; - padding: 0 2rem; + /* grid-template-columns: 1fr 1fr; */ + width: 100%; + height: 100%; } } + +.flex-row { + display: flex; + flex-direction: row; + align-items: center; +} +.flex-col { + display: flex; + flex-direction: column; + align-items: center; +} +.flex-1 { + flex: 1; +} + +::-webkit-scrollbar { + display: none; +} diff --git a/src/main.js b/src/main.js index 90e6400..492900d 100644 --- a/src/main.js +++ b/src/main.js @@ -1,6 +1,9 @@ import { createApp } from 'vue' import App from './App.vue' - +import ViewUIPlus from 'view-ui-plus' +import 'view-ui-plus/dist/styles/viewuiplus.css' import './assets/main.css' -createApp(App).mount('#app') +createApp(App) + .use(ViewUIPlus) + .mount('#app') diff --git a/src/threejs-tools.js b/src/threejs-tools.js index 7d30d96..24dcdd1 100644 --- a/src/threejs-tools.js +++ b/src/threejs-tools.js @@ -6,15 +6,11 @@ export class ThreejsDefault { constructor(container) { // init scene camera this.scene = new THREE.Scene() - this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000) - this.camera.position.z = 5 - + this.scene.add(new THREE.GridHelper(100, 100, 0x660000, 0x004400)) + // init renderer this.renderer = new THREE.WebGLRenderer() - this.renderer.setSize(window.innerWidth, window.innerHeight) - // init controls - this.controls = new OrbitControls(this.camera, this.renderer.domElement); this.animateFuncs = [] const animate = () => { @@ -25,6 +21,12 @@ export class ThreejsDefault { onMounted(() => { container.value.appendChild(this.renderer.domElement) + this.renderer.setSize(container.value.clientWidth, container.value.clientHeight) + + this.camera = new THREE.PerspectiveCamera(60, container.value.clientWidth / container.value.clientHeight, 0.1, 1000) + this.camera.position.set(0, 10, 10) + this.controls = new OrbitControls(this.camera, this.renderer.domElement); + animate() }) } @@ -34,3 +36,16 @@ export class ThreejsDefault { this.animateFuncs.push(animFunc) } } + +export function createPlane(w = 10, h = 10, position = [0, .1, 0], rotation = [90, 0, 0]) { + const material = new THREE.MeshLambertMaterial({ + color: 0x88888888, + side: THREE.DoubleSide, + // wireframe: true, + }) + const geometry = new THREE.PlaneGeometry(w, h) + const mesh = new THREE.Mesh(geometry, material) + mesh.position.set(...position) + mesh.rotation.set(...rotation.map(deg => deg / 180 * Math.PI)) + return mesh +} diff --git a/src/views/basic.vue b/src/views/basic.vue index 8139b7c..e9a9131 100644 --- a/src/views/basic.vue +++ b/src/views/basic.vue @@ -1,9 +1,29 @@ -- GitLab