Versions
@thatopen/components 3.4.8 (verified against the published dist/index.mjs; source: packages/core/src/core/OrthoPerspectiveCamera/src/projections.ts + index.ts).
What happens
setOrthoCamera() opens with a guard written as a silent early return:
if (this._component.mode === null) return;
But mode is a getter that throws when _mode is unset:
get mode() {
if (!this._mode) {
throw new Error("Mode not found, camera not initialized");
}
return this._mode;
}
_mode is only populated in the camera's worlds.onItemSet handler, i.e. on world.camera = camera. So calling projection.set("Orthographic") (or toggle()) on a camera that has not been assigned to a world yet throws Error: Mode not found, camera not initialized out of a line whose intent is clearly a no-op. As written, the === null comparison is unreachable dead code.
Repro
const camera = new OBC.OrthoPerspectiveCamera(components);
await camera.projection.set("Orthographic"); // throws — expected: no-op or clear error
Suggested fix
Check the backing field (this._component._mode via an internal accessor / a hasMode getter) so the early return works as intended.
Versions
@thatopen/components3.4.8 (verified against the publisheddist/index.mjs; source:packages/core/src/core/OrthoPerspectiveCamera/src/projections.ts+index.ts).What happens
setOrthoCamera()opens with a guard written as a silent early return:But
modeis a getter that throws when_modeis unset:_modeis only populated in the camera'sworlds.onItemSethandler, i.e. onworld.camera = camera. So callingprojection.set("Orthographic")(ortoggle()) on a camera that has not been assigned to a world yet throwsError: Mode not found, camera not initializedout of a line whose intent is clearly a no-op. As written, the=== nullcomparison is unreachable dead code.Repro
Suggested fix
Check the backing field (
this._component._modevia an internal accessor / ahasModegetter) so the early return works as intended.