Skip to content
Merged
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
12 changes: 6 additions & 6 deletions src/lib/commands/EntityReparentCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ export class EntityReparentCommand extends Command {
newParent.appendChild(recreatedEntity);
}

// Update position/rotation/scale components relative to new parent
this.updateLocalTransform(recreatedEntity, newParent);

// Wait for entity to be loaded before emitting events
recreatedEntity.addEventListener(
'loaded',
() => {
recreatedEntity.pause();

// Calculate new local position and quaternion relative to new parent
this.updateLocalTransform(recreatedEntity, newParent);

Events.emit('entityremoved', entity);
Events.emit('entitycreated', recreatedEntity);

Expand Down Expand Up @@ -202,15 +202,15 @@ export class EntityReparentCommand extends Command {
oldParent.appendChild(recreatedEntity);
}

// Update position/rotation/scale components relative to old parent
this.updateLocalTransform(recreatedEntity, oldParent);

// Wait for entity to be loaded before emitting events
recreatedEntity.addEventListener(
'loaded',
() => {
recreatedEntity.pause();

// For undo, restore the original local transform relative to old parent
this.updateLocalTransform(recreatedEntity, oldParent);

Events.emit('entityremoved', entity);
Events.emit('entitycreated', recreatedEntity);

Expand Down
Loading