Jump to content

Mesh disappears when attaching to imported skeleton.


kevzettler
 Share

Recommended Posts

I have a scene where I create a Sphere. I then use BABYLON.SceneLoader.Append to import a skeleton. I attach the sphere to one of the skeleton bones and it disappears.
You can see this happening here:

http://kevzettler.com/robotbones/
 

I can provide the full source if that would help.

The source of the scene looks like:

const canvas = document.getElementById('render-container');
const engine = new BABYLON.Engine(canvas, true);
var scene = new BABYLON.Scene(engine);
scene.clearColor = new BABYLON.Color3(0, 1, 0);

// This creates and positions a free camera
var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);
camera.setTarget(BABYLON.Vector3.Zero());
camera.attachControl(canvas, false);

// This creates a light, aiming 0,1,0 - to the sky.
var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
light.intensity = .5;

// Let's try our built-in 'sphere' shape. Params: name, subdivisions, size, scene
var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 1, scene);
sphere.position.y = 1;

var skeletonPlaceholder = new BABYLON.AbstractMesh('', scene);

function skeletonLoadHandler(scene){
  var skeleton = scene.skeletons[0];
  var viewer = new BABYLON.Debug.SkeletonViewer(skeleton, skeletonPlaceholder, scene);
  viewer.isEnabled = true; //enables skeleton animation

  sphere.attachToBone(skeleton.bones[1], skeletonPlaceholder);
  var anim = skeleton.beginAnimation("ArmatureAction.001", true, 1);
}

function loadProgressHandler(progress){
  console.log("loading: ", progress);
}

engine.runRenderLoop(() => {
  scene.render();
});    

window.addEventListener("resize", () => {
  engine.resize();
});

BABYLON.SceneLoader.ShowLoadingScreen = false;
BABYLON.SceneLoader.Append("./assets/models/mechsniper/babylon/", "combined.babylon", scene, skeletonLoadHandler, loadProgressHandler)

 

Link to comment
Share on other sites

@kevzettler -

I believe I and others recently tried to assist you in a seperate post concerning a similar issue with object visability when parenting objects to bones in Blender. For myself (and most likely others,) it is important to know your pipeline prior to BJS, and how you generated your skeleton (bones.) As we discussed previously, this is often an issue due to how the skelton bones are identified in any application. However, in looking at the code you provided, the process you use in parenting your object to a bone inside of an array may be the issue. I don't have the time at this moment to test this, but perhaps someone else on the forum may be able to see the problem with the limited code you provided.

Otherwise, more info is the key to solving your problem, and if you build a playground scene, this most likely could be solved without delay. Of course, there's always @Wingnut - who obviously hasn't read this post yet - as I'm certain we'd already see him testing a new playground scene using your code.

Cheers,

DB

Link to comment
Share on other sites

http://playground.babylonjs.com/#2F6AQS#0

:)  Hey, I'll make a playground for a friend of BJS sometimes, what the heck.  No time to troubleshoot this at the moment, but I see one error.

In the console:  WebGL: drawElements: bound element array buffer is too small for given count and offsetThat could indicate a situation in the exporter, I suppose.  JSON lint says it's valid JSON..

I'll keep thinking, but I'm scared of skeletons.  :o   Hopefully, the Monday crew will be able to beat this issue into submission.  Help wanted.

@kevzettler - You did no hand-editing of the .babylon file after export from Blender 2.76 (sub 0), right?  (Folks rarely do such edits, but I thought I would ask just the same.)

Ok, talk soon.

Link to comment
Share on other sites

Quote

You did no hand-editing of the .babylon file after export from Blender 2.76 (sub 0), right?  (Folks rarely do such edits, but I thought I would ask just the same.)

 

Correct I did not.

I've open sourced the sample project:

https://github.com/kevzettler/robotbones

you can see the babylon json file here
https://github.com/kevzettler/robotbones/blob/master/assets/models/mechsniper/babylon/combined.babylon

The blender file is also in the /assets directory.

The blender file has 2 layers. layer 1 is the armature, layer 2 is the meshes. the meshes are rigged and animated to the armature. When I export I only export layer 1.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...