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

glTF: Implement support for morph target names #6904

Merged
merged 2 commits into from
Sep 30, 2019
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
5 changes: 4 additions & 1 deletion loaders/src/glTF/2.0/glTFLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -866,10 +866,13 @@ export class GLTFLoader implements IGLTFLoader {
throw new Error(`${context}: Primitives do not have the same number of targets`);
}

const targetNames = mesh.extras ? mesh.extras.targetNames : null;

babylonMesh.morphTargetManager = new MorphTargetManager(babylonMesh.getScene());
for (let index = 0; index < primitive.targets.length; index++) {
const weight = node.weights ? node.weights[index] : mesh.weights ? mesh.weights[index] : 0;
babylonMesh.morphTargetManager.addTarget(new MorphTarget(`morphTarget${index}`, weight, babylonMesh.getScene()));
const name = targetNames ? targetNames[index] : `morphTarget${index}`;
babylonMesh.morphTargetManager.addTarget(new MorphTarget(name, weight, babylonMesh.getScene()));
// TODO: tell the target whether it has positions, normals, tangents
}
}
Expand Down
1 change: 1 addition & 0 deletions what's new.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
- Added support for custom loader extensions ([bghgary](http://www.github.com/bghgary))
- Added support for validating assets using [glTF-Validator](https://github.com/KhronosGroup/glTF-Validator) ([bghgary](http://www.github.com/bghgary))
- Added automatically renormalizes skinweights when loading geometry. Calls core mesh functions to do this ([Bolloxim](https://github.com/Bolloxim))
- Added support for morph target names via `mesh.extras.targetNames` ([zeux](https://github.com/zeux))

### glTF Serializer
- Added support for exporting the scale, rotation and offset texture properties ([kcoley](http://www.github.com/kcoley))
Expand Down