938 fixed.4

This commit is contained in:
mige 2025-10-15 15:37:25 +04:00
parent 68908e032d
commit 5c2632c70a
2 changed files with 30 additions and 39 deletions

View File

@ -459,7 +459,6 @@ class EntityCollection {
}
protected _removeRecursively(entity: Entity) {
entity.parent = null;
entity._entityCollection = null;
entity._entityCollectionIndex = -1;
@ -489,6 +488,30 @@ class EntityCollection {
}
}
protected _removeEntity(entity: Entity) {
if (entity.parent) {
let arr = entity.parent.childEntities;
for (let i = 0, len = arr.length; i < len; i++) {
if (arr[i].isEqual(entity)) {
arr.splice(i, 1);
break;
}
}
entity.parent = null;
} else {
this._entities.splice(entity._entityCollectionIndex, 1);
this.reindexEntitiesArray(entity._entityCollectionIndex);
}
// clear picking color
if (this.renderNode && this.renderNode.renderer) {
this.renderNode.renderer.clearPickingColor(entity);
entity._pickingColor.clear();
}
this._removeRecursively(entity);
}
/**
* Removes entity from this collection.
* @public
@ -496,46 +519,14 @@ class EntityCollection {
*/
public removeEntity(entity: Entity) {
if (this.belongs(entity)) {
if (entity.parent) {
let arr = entity.parent.childEntities;
for (let i = 0, len = arr.length; i < len; i++) {
if (arr[i].isEqual(entity)) {
arr.splice(i, 1);
break;
}
}
} else {
this._entities.splice(entity._entityCollectionIndex, 1);
this.reindexEntitiesArray(entity._entityCollectionIndex);
}
// clear picking color
if (this.renderNode && this.renderNode.renderer) {
this.renderNode.renderer.clearPickingColor(entity);
entity._pickingColor.clear();
}
this._removeRecursively(entity);
this._removeEntity(entity);
this.events.dispatch(this.events.entityremove, entity);
}
}
public _removeEntitySilent(entity: Entity) {
if (this.belongs(entity)) {
if (!entity.parent) {
this._entities.splice(entity._entityCollectionIndex, 1);
this.reindexEntitiesArray(entity._entityCollectionIndex);
}
// clear picking color
if (this.renderNode && this.renderNode.renderer) {
this.renderNode.renderer.clearPickingColor(entity);
entity._pickingColor.clear();
}
this._removeRecursively(entity);
this._removeEntity(entity);
}
}

View File

@ -427,12 +427,12 @@ class Vector extends Layer {
if (entity._layer && this.isEqual(entity._layer)) {
this._entities.splice(entity._layerIndex, 1);
this._reindexEntitiesArray(entity._layerIndex);
if (!entity.parent) {
this._entities.splice(entity._layerIndex, 1);
this._reindexEntitiesArray(entity._layerIndex);
}
entity._layer = null;
entity._layerIndex = -1;
if (entity._entityCollection) {