@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
83 lines (82 loc) • 3.15 kB
JavaScript
"use strict";
import { TypedThreejsCameraObjNode, ThreejsCameraTransformParamConfig, CameraMainCameraParamConfig } from "./_BaseCamera";
import { NodeParamsConfig } from "../utils/params/ParamsConfig";
import { CameraRenderParamConfig } from "./utils/cameras/RenderController";
import { LayerParamConfig } from "./utils/LayersController";
import { TransformedParamConfig } from "./utils/TransformController";
import { CameraNodeType } from "../../poly/NodeContext";
import { CameraPostProcessParamConfig } from "./utils/cameras/PostProcessParamOptions";
import {
PerspectiveCameraParamConfigMixin,
PERSPECTIVE_CAMERA_DEFAULT,
registerPerspectiveCamera
} from "../../../core/camera/CorePerspectiveCamera";
import { CORE_CAMERA_DEFAULT } from "../../../core/camera/CoreCamera";
import { CoreCameraFrameParamConfig } from "../../../core/camera/CoreCameraFrameMode";
import { PerspectiveCameraSopOperation } from "../../operations/sop/PerspectiveCamera";
import { CameraWebXRParamConfig } from "./utils/cameras/WebXRParamOptions";
import { CameraWebXRARSopOperation } from "../../operations/sop/CameraWebXRAR";
import { CameraWebXRVRSopOperation } from "../../operations/sop/CameraWebXRVR";
class PerspectiveCameraObjParamConfig extends CameraWebXRParamConfig(
CameraPostProcessParamConfig(
CameraRenderParamConfig(
LayerParamConfig(
CameraMainCameraParamConfig(
CoreCameraFrameParamConfig(
PerspectiveCameraParamConfigMixin(
ThreejsCameraTransformParamConfig(
TransformedParamConfig(NodeParamsConfig, { matrixAutoUpdate: true })
)
)
)
)
)
)
)
) {
}
const ParamsConfig = new PerspectiveCameraObjParamConfig();
export class PerspectiveCameraObjNode extends TypedThreejsCameraObjNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return CameraNodeType.PERSPECTIVE;
}
createObject() {
const camera = PerspectiveCameraSopOperation.createCamera(
{
...PERSPECTIVE_CAMERA_DEFAULT,
...CORE_CAMERA_DEFAULT
},
this
);
PerspectiveCameraSopOperation.setCameraAttributes(camera, { fov: PERSPECTIVE_CAMERA_DEFAULT.fov });
return camera;
}
updateCamera() {
if (this._object.fov != this.pv.fov) {
this._object.fov = this.pv.fov;
PerspectiveCameraSopOperation.setCameraAttributes(this._object, this.pv);
this._object.updateProjectionMatrix();
}
const objects = [this._object];
CameraWebXRARSopOperation.updateObject({
scene: this.scene(),
objects,
params: CameraWebXRARSopOperation.DEFAULT_PARAMS,
active: this.pv.useWebXR && this.pv.useAR
});
CameraWebXRVRSopOperation.updateObject({
scene: this.scene(),
objects,
params: CameraWebXRVRSopOperation.DEFAULT_PARAMS,
active: this.pv.useWebXR && this.pv.useVR
});
}
// protected override _updateForAspectRatio() {
// CoreCameraPerspectiveFrameMode.updateCameraAspect(this._object, this._aspect);
// }
}
PerspectiveCameraObjNode.onRegister = registerPerspectiveCamera;