javascript - 是否可以以 GLTF 格式从场景中导出动画和变形?
问题描述
我想导出场景中包含所有动画、纹理和变形的模型。
const mixers = [];
const loader = new GLTFLoader();
const clock = new THREE.Clock();
let exsp_obj
loader.load( 'models/gltf/Flamingo.glb', function ( gltf ) {
const mesh = gltf.scene.children[ 0 ];
exsp_obj = mesh;
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add( mesh );
const mixer = new THREE.AnimationMixer( mesh );
mixer.clipAction( gltf.animations[ 0 ] ).setDuration( 1 ).play();
mixers.push( mixer );
} );
function gltf_animated() {
const delta = clock.getDelta();
for ( let i = 0; i < mixers.length; i ++ ) {
mixers[ i ].update( delta );
}
}
// Run animate
const animate = function () {
requestAnimationFrame( animate );
renderer.render( scene, camera );
gltf_animated()
};
animate();
// EXPORT MODEL
function exportGLTF( input ) {
const gltfExporter = new GLTFExporter();
const options = {
trs: false,
onlyVisible: true,
truncateDrawRange: true,
binary: false,
maxTextureSize: 4096 || Infinity // To prevent NaN value
};
gltfExporter.parse( input, function ( result ) {
if ( result instanceof ArrayBuffer ) {
// send result code
console.log(result)
} else {
const output = JSON.stringify( result, null, 2 );
// send result code
console.log(output)
}
}, options );
}
exportGLTF( exsp_obj );
但我不太明白如何将场景变成 GLTF 模型。
我再说一遍,我想从 GLTF 的场景中导出所有可能的内容
解决方案
推荐阅读
- javascript - 如何查看 select2 实例的设置选项?
- scala - Scala隐式转换误导
- java - “debuggable false”足以阻止调试我的应用程序?
- wpf - 并非所有样式都在我的 WPF 控件中被覆盖
- python - 如何在python3中打印带有0和*的图案
- node.js - 在使用 nextjs 进行反应编译时退出状态 1
- c# - 有没有办法让 Json.Net 反序列化为声明为“对象”的属性的具体类型
- sql - 如何编写查询/创建视图以限制多条记录仅显示最大值
- node.js - 检查客户端发送的 jwt 和参数是否相等是否过大?
- python - 约束满足问题 - 错误:类对象没有属性