in src/core/Scene.ts [17:60]
constructor() {
super();
this.addObject = (object: Object3D) => {
this.objects.push(object);
this.dispatchEvent(new ObjectAddedEvent(object));
};
this.removeObject = (object: Object3D) => {
const index = this.objects.indexOf(object);
if (index < 0) {
throw new Error("Object not found in scene");
}
this.objects.splice(index, 1);
this.dispatchEvent(new ObjectRemovedEvent(object));
};
this.findObject = (predicate: (object: Object3D) => boolean) => {
for (const object of this.objects) {
if (predicate(object)) {
return object;
}
}
return undefined;
};
this.findObjectOfType = <T extends Object3D>(type: { new (): T }) => {
for (const object of this.objects) {
if (object instanceof type) {
return object;
}
}
return undefined;
};
this.reset = () => {
const objectsToRemove = this.objects.slice();
for (const object of objectsToRemove) {
this.removeObject(object);
}
};
this.reset();
}