UNPKG

@polygonjs/polygonjs

Version:

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

47 lines (46 loc) 1.7 kB
"use strict"; import { BaseSopOperation } from "./_Base"; import { InputCloneMode } from "../../../engine/poly/InputCloneMode"; import { HemisphereLight } from "three"; import { DEFAULT_HEMISPHERE_LIGHT_PARAMS } from "../../../core/lights/HemisphereLight"; import { ObjectType, registerObjectType } from "../../../core/geometry/Constant"; export class HemisphereLightSopOperation extends BaseSopOperation { static type() { return "hemisphereLight"; } cook(inputCoreGroups, params) { const light = this.createLight(); light.name = params.name; this.updateLightParams(light, params); return this.createCoreGroupFromObjects([light]); } createLight() { var _a; registerObjectType({ type: ObjectType.HEMISPHERE_LIGHT, checkFunc: (o) => { if (o.isHemisphereLight) { return ObjectType.HEMISPHERE_LIGHT; } }, ctor: HemisphereLight, humanName: "HemisphereLight" }); const light = new HemisphereLight(); light.name = `HemisphereLight_${((_a = this._node) == null ? void 0 : _a.name()) || ""}`; light.matrixAutoUpdate = false; light.updateMatrix(); light.color.copy(DEFAULT_HEMISPHERE_LIGHT_PARAMS.skyColor); light.groundColor.copy(DEFAULT_HEMISPHERE_LIGHT_PARAMS.groundColor); return light; } updateLightParams(light, params) { light.color.copy(params.skyColor); light.groundColor.copy(params.groundColor); light.intensity = params.intensity; light.position.copy(params.position); light.updateMatrix(); } } HemisphereLightSopOperation.DEFAULT_PARAMS = DEFAULT_HEMISPHERE_LIGHT_PARAMS; HemisphereLightSopOperation.INPUT_CLONED_STATE = InputCloneMode.NEVER;