我正在尝试使用姿势估计坐标来对 Three.js 中的装配模型进行动画处理 我正在使用的姿势估计技术提供了视频源中人物的实时 x、y、z 坐标,我正在尝试使用这些坐标相应地移动 3D 模型。我使用下面的代码(其中一些代码是我在相关问题的答案中找到的)作为起点......
let camera, scene, renderer, clock, rightArm;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.01, 10);
camera.position.set(2, 2, -2);
clock = new THREE.Clock();
scene = new THREE.Scene();
scene.background = new THREE.Color(0xffffff);
const light = new THREE.HemisphereLight(0xbbbbff, 0x444422);
light.position.set(0, 1, 0);
scene.add(light);
// model
const loader = new THREE.GLTFLoader();
loader.load('https://threejs.org/examples/models/gltf/Soldier.glb', function(gltf) {
const model = gltf.scene;
rightArm = model.getObjectByName('mixamorigRightArm');
scene.add(model);
});
renderer = new THREE.WebGLRenderer({
antialias: true
});
renderer.setPixelRatio(window.devicePixelRatio); …Run Code Online (Sandbox Code Playgroud)我试图将我采样的一组矢量旋转到三角形的法线
如果这是正确的,随机抽样的半球将与三角形对齐.
目前我在Z轴上生成它并尝试将所有样本旋转到三角形的法线.
但它似乎"刚刚关闭"

glm::quat getQuat(glm::vec3 v1, glm::vec3 v2)
{
glm::quat myQuat;
float dot = glm::dot(v1, v2);
if (dot != 1)
{
glm::vec3 aa = glm::normalize(glm::cross(v1, v2));
float w = sqrt(glm::length(v1)*glm::length(v1) * glm::length(v2)*glm::length(v2)) + dot;
myQuat.x = aa.x;
myQuat.y = aa.y;
myQuat.z = aa.z;
myQuat.w = w;
}
return myQuat;
}
Run Code Online (Sandbox Code Playgroud)
我从本页底部提取的内容:http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors
然后我 :
glm::vec3 zaxis = glm::normalize( glm::vec3(0, 0, 1) ); // hardcoded but test orginal axis
glm::vec3 n1 = glm::normalize( glm::cross((p2 - p1), (p3 - …Run Code Online (Sandbox Code Playgroud) animation ×1
javascript ×1
math ×1
mediapipe ×1
opengl ×1
quaternions ×1
rotation ×1
three.js ×1