更新的纹理在 three.js 中停止动画
Updated textures stops animation in three.js
从 开始。我正在页面刷新时换出 .GLTF 上的纹理。纹理现在可以正常工作了……
但仅限于没有动画的文件。然而,纹理更新似乎阻止了它们的原意。我不确定是什么原因造成的,也不知道如何重新加载动画。
代码如下:
var creaturePath = "models/gltf/creature/";
var creatureFile = "creature_roar.gltf";
// load the model
var loader = new GLTFLoader().setPath( creaturePath ); // creature
loader.load( creatureFile, function ( gltf )
{
gltf.scene.traverse( function ( child )
{
if ( child.isMesh )
{
// override textures
texture.flipX = false;
texture.flipY = false;
my_material = new THREE.MeshBasicMaterial({map: texture});
// child.material = my_material; // this is the problem line
texture.needsUpdate = true;
}
} );
var model = gltf.scene;
如果替换 material,则必须确保将 MeshBasicMaterial.skinning and/or MeshBasicMaterial.morphTargets 设置为 true
。否则骨骼 and/or 变形目标动画将不受 material.
支持
three.js R113
从
但仅限于没有动画的文件。然而,纹理更新似乎阻止了它们的原意。我不确定是什么原因造成的,也不知道如何重新加载动画。
代码如下:
var creaturePath = "models/gltf/creature/";
var creatureFile = "creature_roar.gltf";
// load the model
var loader = new GLTFLoader().setPath( creaturePath ); // creature
loader.load( creatureFile, function ( gltf )
{
gltf.scene.traverse( function ( child )
{
if ( child.isMesh )
{
// override textures
texture.flipX = false;
texture.flipY = false;
my_material = new THREE.MeshBasicMaterial({map: texture});
// child.material = my_material; // this is the problem line
texture.needsUpdate = true;
}
} );
var model = gltf.scene;
如果替换 material,则必须确保将 MeshBasicMaterial.skinning and/or MeshBasicMaterial.morphTargets 设置为 true
。否则骨骼 and/or 变形目标动画将不受 material.
three.js R113