Skip to content

Commit

Permalink
adds default root attachment (with a warning) for cases with no corre…
Browse files Browse the repository at this point in the history
…sponding bone
  • Loading branch information
TheCodeTherapy committed Feb 6, 2024
1 parent 748e665 commit 3da6a43
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/3d-web-client-core/src/character/CharacterSockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ export class CharacterSockets {

private async setAttachments(parts: MMLCharacterDescriptionPart[]): Promise<void> {
parts.forEach(async (part) => {
if (part.socket?.socket && this.availableBones.has(part.socket.socket)) {
if (part.socket?.socket) {
const socketName = part.socket.socket;
const partGLTF = await this.modelLoader.load(part.url);
if (partGLTF && partGLTF.scene) {
const model = partGLTF.scene as Object3D;
const bone = this.availableBones.get(part.socket.socket);
let bone = this.availableBones.get("root");
if (this.availableBones.has(socketName)) {
bone = this.availableBones.get(socketName);
} else {
console.warn(
`WARNING: no bone found for [${socketName}] socket. Attatching to Root bone`,
);
}
if (bone) {
model.position.set(0, 0, 0);
model.rotation.set(0, 0, 0);
Expand Down Expand Up @@ -60,6 +68,7 @@ export class CharacterSockets {
this.attachments.set(part.socket.socket, model);
}
}
} else if (part.socket?.socket) {
}
});
}
Expand Down

0 comments on commit 3da6a43

Please sign in to comment.