Skip to content

Commit

Permalink
修改头套模型相关
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhang-Tianxu committed Mar 30, 2023
1 parent 688a794 commit 81b21a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/components-react/windows/Camera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 11 additions & 5 deletions app/services/threejs/ModelRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 81b21a6

Please sign in to comment.