UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

54 lines (53 loc) 2.01 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { CubeCameraSopOperation } from "../../operations/sop/CubeCamera"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { CameraNodeType } from "../../poly/NodeContext"; import { CUBE_CAMERA_DEFAULT, registerCubeCamera } from "../../../core/camera/CoreCubeCamera"; const DEFAULT = CubeCameraSopOperation.DEFAULT_PARAMS; class CubeCameraSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param camera near */ this.near = ParamConfig.FLOAT(DEFAULT.near, { range: [0, 100], rangeLocked: [true, false] }); /** @param camera far */ this.far = ParamConfig.FLOAT(DEFAULT.far, { range: [0, 100], rangeLocked: [true, false] }); /** @param resolution */ this.resolution = ParamConfig.FLOAT(CUBE_CAMERA_DEFAULT.resolution, { range: CUBE_CAMERA_DEFAULT.resolutionRange }); /** @param camera position */ this.position = ParamConfig.VECTOR3(DEFAULT.position); /** @param camera rotation */ this.rotation = ParamConfig.VECTOR3(DEFAULT.rotation); /** @param show helper */ this.showHelper = ParamConfig.BOOLEAN(DEFAULT.showHelper); /** @param matrixAutoUpdate */ this.matrixAutoUpdate = ParamConfig.BOOLEAN(DEFAULT.matrixAutoUpdate); /** @param camera name */ this.name = ParamConfig.STRING("`$OS`"); } } const ParamsConfig = new CubeCameraSopParamsConfig(); export class CubeCameraSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return CameraNodeType.CUBE; } initializeNode() { this.io.inputs.setCount(0); } cook(inputCoreGroups) { this._operation = this._operation || new CubeCameraSopOperation(this._scene, this.states, this); const coreGroup = this._operation.cook(inputCoreGroups, this.pv); this.setCoreGroup(coreGroup); } } CubeCameraSopNode.onRegister = registerCubeCamera;