mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
101.6k stars 35.29k forks source link

Bone property for rigging #14887

Closed tiancaipipi110 closed 6 years ago

tiancaipipi110 commented 6 years ago

Say I have two bones: Bone_0, Bone_1. I would like to create 6 GUI controls to control position on x, y, z and rotation on x,y,z for Bone_0, same for Bone_1.
I've assigned child.skeleton.bones[0].position.y = guiControls.Bone_0; Then what should I assign child.skeleton.bones[0].position.z to ? I wasn't able to find the 'Bone_0' properties.

 ////GUI
        guiControls = new function () {
            this.Bone_0 = 0.0;
            this.Bone_1 = 0.0;
        }

        datGUI = new dat.GUI();
        //datGUI.add(guiControls, "scene");
        var folder = datGUI.addFolder('Controls');

        folder.add(guiControls, 'Bone_0', -3.14, 3.14);
        folder.add(guiControls, 'Bone_0', -3.14, 3.14);

        folder.add(guiControls, 'Bone_1', -3.14, 3.14);
        folder.add(guiControls, 'Bone_1', -3.14, 3.14);

 scene.traverse(function (child) {
            if (child instanceof THREE.SkinnedMesh) {

                child.position.y += .01;

                child.skeleton.bones[0].position.y = guiControls.Bone_0;
                child.skeleton.bones[0].rotation.y = guiControls.Bone_0;

                child.skeleton.bones[1].position.y = guiControls.Bone_1;
                child.skeleton.bones[1].rotation.y = guiControls.Bone_1;

            }
        });
tiancaipipi110 commented 6 years ago

simple.txt

WestLangley commented 6 years ago

Please, use the forum for help. We use GitHub issues for bug reports and feature requests only.