@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
67 lines (66 loc) • 2.65 kB
JavaScript
;
import { TypedSopNode } from "./_Base";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { Group } from "three";
import { ThreejsCoreObject } from "../../../core/geometry/modules/three/ThreejsCoreObject";
import { CoreWebXRAREstimatedLightController } from "../../../core/webXR/webXRAR/CoreWebXRAREstimatedLightController";
import { SopType } from "../../poly/registers/nodes/types/Sop";
const ATTRIB_NAME = CoreWebXRAREstimatedLightController.ATTRIB_NAME;
class WebXRAREstimatedLightSopParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param default environment map */
// defaultEnvironment = ParamConfig.NODE_PATH('', {
// nodeSelection: {
// context: NodeContext.COP,
// },
// });
/** @param apply computed environment */
this.applyEnv = ParamConfig.BOOLEAN(1);
/** @param apply computed light Probe */
this.applyLightProbe = ParamConfig.BOOLEAN(1);
/** @param apply computed directional Light */
this.applyDirectionalLight = ParamConfig.BOOLEAN(1);
}
/** @param directional Light intensity */
// directionalLightIntensity = ParamConfig.FLOAT(1, {
// range: [0, 1],
// rangeLocked: [true, false],
// visibleIf: {
// applyDirectionalLight: 1,
// },
// });
}
const ParamsConfig = new WebXRAREstimatedLightSopParamsConfig();
export class WebXRAREstimatedLightSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopType.WEB_XR_AR_ESTIMATED_LIGHT;
}
initializeNode() {
this.io.inputs.setCount(0, 1);
}
cook(inputCoreGroups) {
const coreGroup = inputCoreGroups[0];
const defaultLightsParent = new Group();
defaultLightsParent.name = `defaultLightsParent`;
defaultLightsParent.matrixAutoUpdate = false;
ThreejsCoreObject.addAttribute(defaultLightsParent, ATTRIB_NAME.IS_DEFAULT_LIGHTS_PARENT, true);
const objects = coreGroup.threejsObjects();
for (const object of objects) {
defaultLightsParent.add(object);
}
const group = new Group();
group.name = this.path();
group.matrixAutoUpdate = false;
group.add(defaultLightsParent);
ThreejsCoreObject.addAttribute(group, ATTRIB_NAME.IS_ESTIMATED_LIGHT, true);
ThreejsCoreObject.addAttribute(group, ATTRIB_NAME.APPLY_ENV, this.pv.applyEnv);
ThreejsCoreObject.addAttribute(group, ATTRIB_NAME.APPLY_LIGHT_PROBE, this.pv.applyLightProbe);
ThreejsCoreObject.addAttribute(group, ATTRIB_NAME.APPLY_DIR_LIGHT, this.pv.applyDirectionalLight);
this.setObject(group);
}
}