From 81b21a6ee78f53a833008f8df34b9f3a3ae78960 Mon Sep 17 00:00:00 2001 From: Tianxu Date: Thu, 30 Mar 2023 22:09:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=B4=E5=A5=97=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components-react/windows/Camera.tsx | 4 ++-- app/services/threejs/ModelRender.ts | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/components-react/windows/Camera.tsx b/app/components-react/windows/Camera.tsx index bf79d82c3646..dc9cf6463838 100644 --- a/app/components-react/windows/Camera.tsx +++ b/app/components-react/windows/Camera.tsx @@ -79,10 +79,10 @@ export default function CameraWindows() { const loader = new GLTFLoader(); // TODO: 打包后,model好像会坏掉,删除重新接入model,会 //loader.load('media/models/Duck3.glb', function (gltf: any) { - loader.load('https://github.com/VOKA-AI/react-face-mask/blob/main/public/Duck3.glb?raw=true', function (gltf: any) { + loader.load('https://github.com/VOKA-AI/react-face-mask/blob/main/public/Duck2.glb?raw=true', function (gltf: any) { meshWithMorphTarget = getMorphTargetMesh(gltf) mesh = gltf.scene - mesh.scale.set(11, 11, 11); + mesh.scale.set(13, 13, 13); scene.add(mesh) //scene.add(gltf.scene); //mixer = new AnimationMixer(mesh); diff --git a/app/services/threejs/ModelRender.ts b/app/services/threejs/ModelRender.ts index ecec2e898ee2..1419548aec93 100644 --- a/app/services/threejs/ModelRender.ts +++ b/app/services/threejs/ModelRender.ts @@ -23,17 +23,23 @@ export function setMeshMorphTargetInfluences(meshWithMorphTarget: any, blandshap export function modelUpdateModelPosition(model:any, position:any) { const offsetX = -320; // 变大,模型往右移动,变小模型往左移动 + const offsetY = 100; // 变大,模型往下移动,变小模型往上移动 160 + const offsetZ = -40; //变大,模型往后移动,变小往前移动, -40; var x = (position['x'] + offsetX) / 20; - var y = -(position['y'] + 160) / 60; - var z = (position['z'] - 40) / 5; + var y = -(position['y'] + offsetY) / 60; + var z = (position['z'] + offsetZ) / 5; damp3(model.position, [x, y, z], 0.25, _delta * 5); } export function modelUpdateModelRotation(model: any, rotation:any) { // set rotation and apply it to position - var rx = -(rotation['x'] - 5) / 50; - var ry = -rotation['y'] / 50; - var rz = rotation['z'] / 50; + var rx = -(rotation['x'] - 5) / 50; // 绕x轴旋转 + var ry = -rotation['y'] / 50; // 绕y轴旋转, 0时正对前方 + var rz = rotation['z'] / 50; // 绕z轴旋转 + + // 限制范围 + //ry = ry > 0.3 ? 0.3 : ry; + //ry = ry < -0.3 ? -0.3 : ry; dampE(model.rotation, [rx, ry, rz], 0.25, _delta * 3) }