Is there a way to check what instance is being used?
I am logging this to the console:
import { OrthographicCamera } from 'three';
// Later in the file:
console.log(camera instanceof OrthographicCamera, camera);
and It outputs false, but when I log the value of camera to the console, I get this:
I am not sure why it is showing that the camera isn't an instance, so is there a way to get more information as to what it is actually looking at?
Here is where the camera is created:
export function Camera(options?: CameraOptions) {
return function (target: new () => object) {
return class GameCamera extends target {
readonly camera!: Camera;
constructor() {
super();
const dim = this.cameraDimensions();
// create the Three camera
this.camera = new OrthographicCamera(dim.left, dim.right, dim.top, dim.bottom, options?.near ?? 0, options?.far ?? 100);
}
}
}
}}
The camera gets created in the Decorator and added to the gameObjects array. Then when I get the activeCamera it is a reference to the above decorator that extends target.
Here is where I am doing the instanceof lookup:
@Injectable({ providedIn: 'root' })
export class Camera {
get activeCamera() {
return Engine.activeCamera;
}
mouseToWorldPoint(mousePoint: Vector3) {
if (this.activeCamera) {
// Here is the check:
console.log(camera instanceof OrthographicCamera, camera);
}
}
}
This is how I get the camera:
export class Engine {
static gameObjects: GameObject[] = [];
static get activeCamera() {
return this.gameObjects.find(i => i.gameObjectType === 'camera' && i.isActive === true) as GameCamera | undefined;
};
}
I have broken the project up into multiple npm workspaces:
{
"name": "game-engine",
"version": "1.0.0",
"scripts": {
"start": "npm run start --workspace=test"
},
"workspaces": [
"test",
"packages/core",
"packages/common",
"packages/input",
"packages/objects"
]
}
2 of the workspaces get information from the three module.
- class
GameCamerais apart of thepackages/objectsmodule (creates the camera). - class
Camerais apart of thepackages/commonmodule (checks for instance).
Note: This been working like this for some time and just seems to have started happening.
