Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skinned model fix #3224

Merged
merged 3 commits into from
Nov 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Change Log
* Added 'Video' Sandcastle showcase to demonstrate video materials.
* Added `createOpenStreetMapImageryProvider` function to replace the `OpenStreetMapImageryProvider` class. This function returns a constructed `UrlTemplateImageryProvider`.
* Fixed an issue with tile selection when below the surface of the ellipsoid. [#3170](https://github.com/AnalyticalGraphicsInc/cesium/issues/3170)
* Fixed an issue with loading skeletons for skinned glTF models. [#3224](https://github.com/AnalyticalGraphicsInc/cesium/pull/3224)

### 1.15 - 2015-11-02

Expand Down
14 changes: 8 additions & 6 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1712,16 +1712,17 @@ define([
return attributeLocations;
}

function searchForest(forest, jointName) {
function searchForest(forest, jointName, nodes) {
var length = forest.length;
for (var i = 0; i < length; ++i) {
var stack = [forest[i]]; // Push root node of tree

while (stack.length > 0) {
var n = stack.pop();
var id = stack.pop();
var n = nodes[id];

if (n.jointName === jointName) {
return n;
return id;
}

var children = n.children;
Expand Down Expand Up @@ -1755,19 +1756,20 @@ define([

// 1. Find nodes with the names in node.skeletons (the node's skeletons)
// 2. These nodes form the root nodes of the forest to search for each joint in skin.jointNames. This search uses jointName, not the node's name.

// 3. Search for the joint name among the gltf node hierarchy instead of the runtime node hierarchy. Child links aren't set up yet for runtime nodes.
var forest = [];
var gltfSkeletons = node.skeletons;
var skeletonsLength = gltfSkeletons.length;
for (var k = 0; k < skeletonsLength; ++k) {
forest.push(runtimeNodes[gltfSkeletons[k]]);
forest.push(gltfSkeletons[k]);
}

var gltfJointNames = skins[node.skin].jointNames;
var jointNamesLength = gltfJointNames.length;
for (var i = 0; i < jointNamesLength; ++i) {
var jointName = gltfJointNames[i];
skinnedNode.joints.push(searchForest(forest, jointName));
var jointNode = runtimeNodes[searchForest(forest, jointName, nodes)];
skinnedNode.joints.push(jointNode);
}
}
}
Expand Down
Loading