THREE.JS | glTF变形针对glTF问题

问题描述

我正在尝试调整nop Jiarathanakul的Particle Dreams demo并将其移植到更新的THREE.JS版本和glTF格式。

虽然代码结构复杂,但是我无法作为摘要发布,但是当前状态为here

它基于变形目标,可以与THREE.JS示例中的马模型配合使用。

enter image description here

但是,如果glTF没有变形目标,因为它是一项古老的技术,并且基于骨骼运动学,那么该怎么办。

enter image description here

非常确定我需要更新shaders/UVMapShader.vs.glsl

varying vec3 vPos;

#ifdef USE_MORPHTARGETS
    uniform float morphTargetInfluences[ 4 ];
#endif

void main() {

#ifdef USE_MORPHTARGETS

    vec3 morphed = vec3( 0.0 );
    morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];
    morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];
    morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];
    morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];
    morphed += position;

    vPos = (modelMatrix * vec4(morphed,1.0)).xyz;
#else
    vPos = (modelMatrix * vec4(position,1.0)).xyz;
#endif

    vec2 drawUV = uv * 2.0 - 1.0;
    gl_Position = vec4(drawUV.x,drawUV.y,0.0,1.0);

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)