diff --git a/README.md b/README.md index 039a0b9..3012ff9 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,51 @@ ## three.js 是什么 +https://threejs.org/manual/#zh/fundamentals + ## 为什么选择 three.js +- WebGL + - https://developer.mozilla.org/zh-CN/docs/Web/API/WebGL_API +- three.js + - https://threejs.org/ + - http://www.webgl3d.cn/ +- Babylon.js + - https://www.babylonjs.com/ + - https://cnbabylon.com/ + ## three.js 核心概念 + +https://threejs.org/manual/#zh/fundamentals + ### Scene 场景 ### Camera 相机 ### Renderer 渲染器 +## three.js 常用类/对象 + +### Object3D +### Material +https://threejs.org/manual/#zh/materials + +### Texture +### OrbitControls + ## Demos -### 基础几何体 -### 材质与纹理 -### 光照与阴影 -### 动画与交互 -### 粒子系统 + +### 加载GLB模型 +### 添加灯光 +### 添加控制器、AxesHelper +### 设置地面 +### 地面上设置光效 +### 模型漫游(巡检业务) +### [x] 模型动画(模型本身存在动画) +### 修改材质(设备告警业务) +### 粒子效果(蒸汽) +### 模型与Web的交互 ### 后期处理效果 -### 漫游 视角切换 -### 标签 ### 公共函数抽象 -## 如何与建模沟通 +## blender使用 -## blender使用 \ No newline at end of file +## 如何与建模沟通 diff --git a/src/composes/index.ts b/src/composes/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/composes/three/dom.ts b/src/composes/three/dom.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/composes/three/index.ts b/src/composes/three/index.ts new file mode 100644 index 0000000..9043896 --- /dev/null +++ b/src/composes/three/index.ts @@ -0,0 +1,2 @@ +export * from './loader' +export * from './texture' diff --git a/src/composes/three/interface.ts b/src/composes/three/interface.ts new file mode 100644 index 0000000..8241c65 --- /dev/null +++ b/src/composes/three/interface.ts @@ -0,0 +1,5 @@ +import type * as THREE from 'three' + +export interface ScenceOptions { + background?: THREE.Texture | THREE.CubeTexture | THREE.Color | null +} diff --git a/src/composes/three/loader.ts b/src/composes/three/loader.ts new file mode 100644 index 0000000..e4b32b0 --- /dev/null +++ b/src/composes/three/loader.ts @@ -0,0 +1,13 @@ +import * as THREE from 'three' + +export function useThreeLoader() { + const textureLoader = new THREE.TextureLoader() + + return { + textureLoader, + } +} + +const threeLoaders = useThreeLoader() + +export { threeLoaders } diff --git a/src/composes/three/mesh.ts b/src/composes/three/mesh.ts new file mode 100644 index 0000000..b3f4e4a --- /dev/null +++ b/src/composes/three/mesh.ts @@ -0,0 +1,5 @@ +import * as THREE from 'three' + +export function useThreeMesh() { + +} diff --git a/src/composes/three/scene.ts b/src/composes/three/scene.ts new file mode 100644 index 0000000..a543c13 --- /dev/null +++ b/src/composes/three/scene.ts @@ -0,0 +1,9 @@ +import * as THREE from 'three' + +export function useThreeScene() { + function createScene(options) { + const scene = new THREE.Scene() + } + + return { createScene } +} diff --git a/src/composes/three/texture.ts b/src/composes/three/texture.ts new file mode 100644 index 0000000..e2da5b6 --- /dev/null +++ b/src/composes/three/texture.ts @@ -0,0 +1,22 @@ +import type * as THREE from 'three' +import { threeLoaders } from './loader' + +export function useThreeTexture() { + // 加载纹理贴图 + function loadTexture(src: string) { + return new Promise((resolve, reject) => { + threeLoaders.textureLoader.load( + src, + (texture) => { + resolve(texture) + }, + undefined, + (err) => { + reject(err) + }, + ) + }) + } + + return { loadTexture } +} diff --git a/src/router/index.ts b/src/router/index.ts index 1ca35f7..dea81f4 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -9,6 +9,61 @@ const router = createRouter({ name: 'home', component: HomeView, }, + { + path: '/three/1', + name: 'three-1', + component: () => import('../views/three/1/index.vue'), + }, + { + path: '/three/2', + name: 'three-2', + component: () => import('../views/three/2/index.vue'), + }, + { + path: '/three/3', + name: 'three-3', + component: () => import('../views/three/3/index.vue'), + }, + { + path: '/three/4', + name: 'three-4', + component: () => import('../views/three/4/index.vue'), + }, + { + path: '/three/5', + name: 'three-5', + component: () => import('../views/three/5/index.vue'), + }, + { + path: '/three/6', + name: 'three-6', + component: () => import('../views/three/6/index.vue'), + }, + { + path: '/three/7', + name: 'three-7', + component: () => import('../views/three/7/index.vue'), + }, + { + path: '/three/8', + name: 'three-8', + component: () => import('../views/three/8/index.vue'), + }, + { + path: '/three/9', + name: 'three-9', + component: () => import('../views/three/9/index.vue'), + }, + { + path: '/three/10', + name: 'three-10', + component: () => import('../views/three/10/index.vue'), + }, + { + path: '/three/11', + name: 'three-11', + component: () => import('../views/three/11/index.vue'), + }, { path: '/3d-point', name: '3d-point', diff --git a/src/views/home.vue b/src/views/home.vue index 106296e..02c0ec7 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -1,5 +1,18 @@