I am new to babylonjs or web3D.
I am try on https://playground.babylonjs.com/#TNT7WW#2
to control the xbot by skeleton with code like this :
var createScene = function () {
var scene = new BABYLON.Scene(engine);
var camera = new BABYLON.ArcRotateCamera("camera", -4.70, 0.9, 4,
BABYLON.Vector3.Zero(), scene);
camera.setTarget(new BABYLON.Vector3(-0.06, 0.95, -0.1));
camera.attachControl();
// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);
light.intensity = 0.7;
BABYLON.SceneLoader.ImportMesh("", Assets.meshes.Xbot.rootUrl, Assets.meshes.Xbot.filename, scene,
function(newMeshes, particleSystems, skeletons){
scene.animationGroups.forEach(function(animationGroup) {
animationGroup.stop();
});
// const xbot = newMeshes[0];
const skeleton = skeletons[0];
var spine = skeleton.bones.find(bone => bone.name === "mixamorig:Spine");
console.log('spine',spine);
scene.onBeforeRenderObservable.add(() => {
spine.rotate(BABYLON.Axis.Y, BABYLON.Tools.ToRadians(1), BABYLON.Space.LOCAL);
// xbot.rotate(BABYLON.Axis.Y, BABYLON.Tools.ToRadians(1), BABYLON.Space.LOCAL);
});
});
return scene; }
If I try to rotate by xbot mesh, it works. but if I try to rotate by bone of skeleton, failed.
as above code , nothing happens for spine.rotate, works ok for xbot.rotate
can anyone help to tell me why, thanks.