UNPKG

@polygonjs/polygonjs

Version:

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

191 lines (190 loc) 7.53 kB
"use strict"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { BaseUserInputJsNode } from "./_BaseUserInput"; import { CoreEventEmitter } from "../../../core/event/CoreEventEmitter"; import { JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF, JsConnectionPoint } from "../utils/io/connections/Js"; import { DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS } from "../../scene/utils/actors/rayObjectIntersection/Common"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; const INPUT_LESS_PARAM_NAMES = ["element"]; export function MouseEventConfigParamConfig(Base) { return class Mixin extends Base { constructor() { super(...arguments); this.buttonLeft = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, { ...STATUS_MENU_OPTIONS, separatorBefore: true }); this.buttonMiddle = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS); this.buttonRight = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS); this.ctrl = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS); this.shift = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS); this.alt = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS); } }; } export function MouseDoubleClickConfigParamConfig(Base) { return class Mixin extends Base { constructor() { super(...arguments); this.ctrl = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS); this.shift = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS); this.alt = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS); } }; } export function PointerEventConfigParamConfig(Base) { return class Mixin extends Base { constructor() { super(...arguments); this.buttonLeft = ParamConfig.BOOLEAN(1, { separatorBefore: true }); this.buttonMiddle = ParamConfig.BOOLEAN(1); this.buttonRight = ParamConfig.BOOLEAN(1); this.ctrl = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS); this.shift = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS); this.alt = ParamConfig.INTEGER(DEFAULT_STATUS_OPTION, STATUS_MENU_OPTIONS); } }; } export class BaseMouseConfigParamsConfig extends MouseEventConfigParamConfig(NodeParamsConfig) { } const baseMouseConfigParamsConfig = new BaseMouseConfigParamsConfig(); export class BaseMouseDoubleClickConfigParamsConfig extends MouseDoubleClickConfigParamConfig(NodeParamsConfig) { } const baseMouseDoubleClickConfigParamsConfig = new BaseMouseDoubleClickConfigParamsConfig(); export class BasePointerConfigParamsConfig extends PointerEventConfigParamConfig(NodeParamsConfig) { } const basePointerConfigParamsConfig = new BasePointerConfigParamsConfig(); export class BaseOnObjectPointerEventBaseJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param blockObjectsBehind */ this.blockObjectsBehind = ParamConfig.BOOLEAN(1); /** @param skipIfObjectsInFront */ this.skipIfObjectsInFront = ParamConfig.BOOLEAN(0); } } export class CPUOnObjectPointerEventJsParamsConfig extends BaseOnObjectPointerEventBaseJsParamsConfig { constructor() { super(...arguments); /** @param include children */ this.traverseChildren = ParamConfig.BOOLEAN(1); /** @param pointsThreshold */ this.pointsThreshold = ParamConfig.FLOAT(0.1); /** @param lineThreshold */ this.lineThreshold = ParamConfig.FLOAT(0.1); } } const CPUParamsConfig = new CPUOnObjectPointerEventJsParamsConfig(); export class GPUOnObjectPointerEventJsParamsConfig extends BaseOnObjectPointerEventBaseJsParamsConfig { /** @param alpha test */ // alphaTest = ParamConfig.FLOAT(0.1); } const GPUParamsConfig = new GPUOnObjectPointerEventJsParamsConfig(); export class ExtendableOnObjectPointerEventJsNode extends BaseUserInputJsNode { isTriggering() { return true; } eventEmitter() { return CoreEventEmitter.CANVAS; } initializeNode() { super.initializeNode(); this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS) ]); this.io.connection_points.spare_params.setInputlessParamNames(INPUT_LESS_PARAM_NAMES); } _additionalInputs() { return []; } } export class BaseOnObjectPointerEventJsNode extends ExtendableOnObjectPointerEventJsNode { constructor() { super(...arguments); this.paramsConfig = CPUParamsConfig; } } export class BaseOnObjectPointerGPUEventJsNode extends ExtendableOnObjectPointerEventJsNode { constructor() { super(...arguments); this.paramsConfig = GPUParamsConfig; } } export class BaseMouseConfigJsNode extends BaseUserInputJsNode { constructor() { super(...arguments); this.paramsConfig = baseMouseConfigParamsConfig; } } export class BaseMouseDoubleClickConfigJsNode extends BaseUserInputJsNode { constructor() { super(...arguments); this.paramsConfig = baseMouseDoubleClickConfigParamsConfig; } } export class BasePointerConfigJsNode extends BaseUserInputJsNode { constructor() { super(...arguments); this.paramsConfig = basePointerConfigParamsConfig; } } export function pointerButtonConfig(node, linesController) { const left = node.variableForInputParam(linesController, node.p.buttonLeft); const middle = node.variableForInputParam(linesController, node.p.buttonMiddle); const right = node.variableForInputParam(linesController, node.p.buttonRight); const ctrl = node.variableForInputParam(linesController, node.p.ctrl); const shift = node.variableForInputParam(linesController, node.p.shift); const alt = node.variableForInputParam(linesController, node.p.alt); return { button: { left, middle, right }, modifier: { ctrl, shift, alt } }; } export function mouseButtonsConfig(node, linesController) { const left = node.variableForInputParam(linesController, node.p.buttonLeft); const middle = node.variableForInputParam(linesController, node.p.buttonMiddle); const right = node.variableForInputParam(linesController, node.p.buttonRight); const ctrl = node.variableForInputParam(linesController, node.p.ctrl); const shift = node.variableForInputParam(linesController, node.p.shift); const alt = node.variableForInputParam(linesController, node.p.alt); return { button: { left, middle, right }, modifier: { ctrl, shift, alt } }; } export function mouseDoubleClickButtonsConfig(node, linesController) { const ctrl = node.variableForInputParam(linesController, node.p.ctrl); const shift = node.variableForInputParam(linesController, node.p.shift); const alt = node.variableForInputParam(linesController, node.p.alt); return { modifier: { ctrl, shift, alt } }; } export var OnObjectPointerEventGPUJsNodeInputName = /* @__PURE__ */ ((OnObjectPointerEventGPUJsNodeInputName2) => { OnObjectPointerEventGPUJsNodeInputName2["worldPosMaterial"] = "worldPosMaterial"; return OnObjectPointerEventGPUJsNodeInputName2; })(OnObjectPointerEventGPUJsNodeInputName || {}); export var OnObjectPointerEventGPUJsNodeOutputName = /* @__PURE__ */ ((OnObjectPointerEventGPUJsNodeOutputName2) => { OnObjectPointerEventGPUJsNodeOutputName2["distance"] = "distance"; return OnObjectPointerEventGPUJsNodeOutputName2; })(OnObjectPointerEventGPUJsNodeOutputName || {});