@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
41 lines (40 loc) • 1.36 kB
JavaScript
;
import { BaseSopOperation } from "./_Base";
import { InputCloneMode } from "../../../engine/poly/InputCloneMode";
import { AmbientLight } from "three";
import { DEFAULT_AMBIENT_LIGHT_PARAMS } from "../../../core/lights/AmbientLight";
import { ObjectType, registerObjectType } from "../../../core/geometry/Constant";
export class AmbientLightSopOperation extends BaseSopOperation {
static type() {
return "ambientLight";
}
cook(_, params) {
const light = this.createLight();
light.name = params.name;
this.updateLightParams(light, params);
return this.createCoreGroupFromObjects([light]);
}
createLight() {
var _a;
registerObjectType({
type: ObjectType.AMBIENT_LIGHT,
checkFunc: (o) => {
if (o.isAmbientLight) {
return ObjectType.AMBIENT_LIGHT;
}
},
ctor: AmbientLight,
humanName: "AmbientLight"
});
const light = new AmbientLight();
light.matrixAutoUpdate = false;
light.name = `AmbientLight_${((_a = this._node) == null ? void 0 : _a.name()) || ""}`;
return light;
}
updateLightParams(light, params) {
light.color.copy(params.color);
light.intensity = params.intensity;
}
}
AmbientLightSopOperation.DEFAULT_PARAMS = DEFAULT_AMBIENT_LIGHT_PARAMS;
AmbientLightSopOperation.INPUT_CLONED_STATE = InputCloneMode.NEVER;