UNPKG

@polygonjs/polygonjs

Version:

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

36 lines (30 loc) 1.3 kB
/** * Creates a spot light. * * @remarks * This is very similar to the [object level SpotLight](https://polygonjs.com/docs/nodes/obj/SpotLight), but can be more useful if you want to instanciate it or process it using other SOP nodes. * */ import {TypedSopNode} from './_Base'; import {CoreGroup} from '../../../core/geometry/Group'; import {NodeParamsConfig} from '../utils/params/ParamsConfig'; import {SpotLightParamConfig} from '../../../core/lights/SpotLight'; import {SpotLightSopOperation} from '../../operations/sop/SpotLight'; import {LightType} from '../../poly/registers/nodes/types/Light'; class SpotLightSopParamsConfig extends SpotLightParamConfig(NodeParamsConfig) {} const ParamsConfig = new SpotLightSopParamsConfig(); export class SpotLightSopNode extends TypedSopNode<SpotLightSopParamsConfig> { override paramsConfig = ParamsConfig; static override type() { return LightType.SPOT; } override initializeNode() { this.io.inputs.setCount(0); } private _operation: SpotLightSopOperation | undefined; override async cook(inputCoreGroups: CoreGroup[]) { this._operation = this._operation || new SpotLightSopOperation(this._scene, this.states, this); const coreGroup = await this._operation.cook(inputCoreGroups, this.pv); this.setCoreGroup(coreGroup); } }