938 fixed.2

This commit is contained in:
mige 2025-10-15 15:08:42 +04:00
parent b43f70b4ab
commit 45ce13b069
2 changed files with 39 additions and 3 deletions

View File

@ -13,8 +13,8 @@ import {
let renderer = new Renderer("frame", {
msaa: 8,
controls: [
new control.SimpleNavigation({speed: 0.01}),
// new control.GeoObjectEditor()
new control.SimpleNavigation({ speed: 0.01 }),
new control.GeoObjectEditor()
],
autoActivate: true
});
@ -76,6 +76,19 @@ class MyScene extends RenderNode {
}
});
let childEntity2 = new Entity({
cartesian: new Vec3(0, 1, 0),
independentPicking: true,
relativePosition: true,
yaw: 90 * Math.PI / 180,
geoObject: {
color: "rgb(255,255,255)",
instanced: true,
tag: `frustumObj`,
object3d: frustumObj,
}
});
let childChildEntity = new Entity({
cartesian: new Vec3(0, 3, -1),
independentPicking: true,
@ -88,8 +101,22 @@ class MyScene extends RenderNode {
}
});
let childChildEntity2 = new Entity({
cartesian: new Vec3(0, 3, -1),
independentPicking: true,
relativePosition: true,
geoObject: {
color: "rgb(90,90,90)",
instanced: true,
tag: `cylinderObj`,
object3d: cylinderObj,
}
});
childEntity.appendChild(childChildEntity);
childEntity2.appendChild(childChildEntity2);
parentEntity.appendChild(childEntity);
parentEntity.appendChild(childEntity2);
let collection = new EntityCollection({
entities: [parentEntity]

View File

@ -496,7 +496,16 @@ class EntityCollection {
*/
public removeEntity(entity: Entity) {
if (this.belongs(entity)) {
if (!entity.parent) {
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);
}