Skip to content

Commit

Permalink
fix: change number children (#279)
Browse files Browse the repository at this point in the history
change number children
  • Loading branch information
ZenderJK committed Aug 10, 2023
1 parent b9d57d4 commit f066490
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/Transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class Transform extends ComponentBase {
} else {
this._scene3d = hasRoot;
for (let c of this.object3D.components.values()) {
ComponentCollect.appendWaitStart(this.object3D, c);
ComponentCollect.appendWaitStart(c);
}
}

Expand Down
13 changes: 5 additions & 8 deletions src/core/entities/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { RenderNode } from '../../components/renderer/RenderNode';
import { Transform } from '../../components/Transform';
import { CEventDispatcher } from '../../event/CEventDispatcher';
import { RenderLayer } from '../../gfx/renderJob/config/RenderLayer';
import { Vector3 } from '../../math/Vector3';
import { BoundUtil } from '../../util/BoundUtil';
import { GetCountInstanceID, UUID } from '../../util/Global';
import { GetCountInstanceID } from '../../util/Global';
import { BoundingBox } from '../bound/BoundingBox';
import { IBound } from '../bound/IBound';
import { Object3D } from './Object3D';
Expand All @@ -24,6 +23,7 @@ export class Entity extends CEventDispatcher {
public name: string = '';

protected readonly _instanceID: string = '';
private _numChildren: number;

/**
* The unique identifier of the object.
Expand Down Expand Up @@ -62,9 +62,6 @@ export class Entity extends CEventDispatcher {
public components: Map<any, IComponent>;


public numChildren: number = 0;


protected waitDisposeComponents: IComponent[];

/**
Expand Down Expand Up @@ -132,7 +129,7 @@ export class Entity extends CEventDispatcher {
* Returns the number of child objects of an object
*/
public get numChildren(): number {
return this.entityChildren.length;
return this._numChildren;
}

/**
Expand All @@ -157,7 +154,7 @@ export class Entity extends CEventDispatcher {
}
child.transform.parent = this.transform;
this.entityChildren.push(child);
this.numChildren = this.entityChildren.length;
this._numChildren = this.entityChildren.length;
return child;
}
return null;
Expand All @@ -175,7 +172,7 @@ export class Entity extends CEventDispatcher {
if (index != -1) {
this.entityChildren.splice(index, 1);
child.transform.parent = null;
this.numChildren = this.entityChildren.length;
this._numChildren = this.entityChildren.length;
}
}

Expand Down

0 comments on commit f066490

Please sign in to comment.