Three.js r74 JSONLoader 将所有几何体的副本绑定到第一个骨骼 [英] Three.js r74 JSONLoader binds duplicate of all geometry to first bone

查看:27
本文介绍了Three.js r74 JSONLoader 将所有几何体的副本绑定到第一个骨骼的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在重写这个问题,因为我现在对这个错误有了更多的了解.看起来在 r74 中使用 JSONLoader 时,导出的 Maya 场景中的第一个命名骨骼获得了所有几何体的副本.

I'm rewriting this question since I understand more about the bug now. It looks like when using the JSONLoader in r74, the first named bone in an exported Maya scene gets a duplicate of all the geometry.

这是一个 JSFiddle

在这个例子中,我有 2 个盒子.每个框都绑定到单个骨骼,并且每个骨骼都有关键帧来为位置和旋转设置动画.还有另一个骨骼没有绑定几何体,并且具有不改变其位置或旋转的关键帧.

In this example I have 2 boxes. Each box is bound to a single bone, and each of those bones has keyframes that animate the position and rotation. There is another bone that has no geometry bound to it, and has keyframes that make no change to its position or rotation.

静止骨骼在 Maya 中称为joint1".实际上绑定了几何体的骨骼称为joint2"和joint3".如果我将固定骨骼重命名为joint4",结果将是连接到当前动画joint2"的两个框的副本.

The stationary bone is called "joint1" in Maya. The bones that actually have geometry bound to them are called "joint2" and "joint3". If I were to rename the stationary bone "joint4" the result would be a duplicate of both boxes attached to the currently animating "joint2".

我的猜测是这是一个错误,或者我在加载动画时做错了什么.任何提示将不胜感激.我现在能想到的唯一解决方法是将每个动画对象分成一个单独的文件,这确实不可行.另外,当我有一个多骨骼骨架时,这不会解决问题.这个例子只是没有实际变形的单骨骼装备.

My guess is that either this is a bug, or I'm doing something wrong when loading the animations. Any tips would be appreciated. The only workaround I can figure out right now is to separate each animated object into a separate file, and that's really not feasible. Plus, that wouldn't solve the issue when I have a multi-bone skeleton. This example is just single bone rigs with no actual deformation.

这是我当前的加载程序代码.

Here's my current loader code.

        //Load Scene, Materials, and Animation

        var mixer, mesh;
        var actions = {};
        var sceneLoader = new THREE.JSONLoader();
        sceneLoader.load( sceneFile, function( geometry,materials ) {
           materials.forEach( function( material ){
              material.skinning = true; 
           });

            mesh = new THREE.SkinnedMesh( geometry, new THREE.MeshFaceMaterial( materials ) );

            mixer = new THREE.AnimationMixer( mesh );
            actions.main = mixer.clipAction( geometry.animations[ 0 ]);
            actions.main.setEffectiveWeight( 1 );
            actions.main.play();

            scene.add( mesh );

        });

        //Render

        var render = function () {
            requestAnimationFrame( render );

            controls.update;

            var delta = clock.getDelta();
            var theta = clock.getElapsedTime();

            if ( mixer ) { mixer.update( delta ); }

            renderer.render(scene, camera)
        }

        render();

推荐答案

这仍然是一个问题,但我找到了一个不错的解决方法.

This is still an issue, but I've found an ok workaround.

因为复制的几何体总是被分配默认的 Lambert 着色器,在使用 Maya 导出器时总是包含该着色器.只要所有打算保留的对象的材质不是 Maya 中的默认值,您就可以插入

Since the duplicated geometry always gets assigned the default lambert shader that is always included when using the Maya Exporter. As long as all the objects that are intended to be kept have a material other than the default in Maya, you can insert

mesh.material.materials[0].visible = false;

进入加载器代码,这将使任何具有默认朗伯的材料不可见.

into the loader code which will make any material with the default lambert invisible.

这是一个小提琴

这篇关于Three.js r74 JSONLoader 将所有几何体的副本绑定到第一个骨骼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆