@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
79 lines (78 loc) • 2.42 kB
JavaScript
;
import { TypedEventNode } from "./_Base";
import { EventConnectionPoint, EventConnectionPointType } from "../utils/io/connections/Event";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
class ViewerParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param sets the class of the viewer */
this.className = ParamConfig.STRING("active");
}
}
const ParamsConfig = new ViewerParamsConfig();
export class ViewerEventNode extends TypedEventNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "viewer";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
// class
new EventConnectionPoint(
"setCss",
EventConnectionPointType.BASE,
this._process_trigger_setClass.bind(this)
),
new EventConnectionPoint(
"unSetCss",
EventConnectionPointType.BASE,
this._process_trigger_unsetClass.bind(this)
)
// controls
// new EventConnectionPoint(
// 'createControls',
// EventConnectionPointType.BASE,
// this._process_trigger_createControls.bind(this)
// ),
// new EventConnectionPoint(
// 'disposeControls',
// EventConnectionPointType.BASE,
// this._process_trigger_disposeControls.bind(this)
// ),
]);
}
_getViewer(context) {
if (context.viewer) {
return context.viewer;
} else {
return this.scene().viewersRegister.firstViewer();
}
}
_process_trigger_setClass(context) {
var _a;
const canvas = (_a = this._getViewer(context)) == null ? void 0 : _a.canvas();
if (canvas) {
canvas.classList.add(this.pv.className);
}
}
_process_trigger_unsetClass(context) {
var _a;
const canvas = (_a = this._getViewer(context)) == null ? void 0 : _a.canvas();
if (canvas) {
canvas.classList.remove(this.pv.className);
}
}
// private _process_trigger_createControls(context: EventContext<Event>) {
// this.scene().viewersRegister.traverseViewers((v) => {
// v.controlsController()?.create_controls();
// });
// }
// private _process_trigger_disposeControls(context: EventContext<Event>) {
// this.scene().viewersRegister.traverseViewers((v) => {
// v.controlsController()?.dispose_controls();
// });
// }
}