@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
51 lines (50 loc) • 1.84 kB
JavaScript
"use strict";
import { BaseRayObjectIntersectionsController } from "./_BaseRayObjectIntersectionsController";
import {
buttonConfigFromEvent,
filterObjectsWithMatchModifiersConfig,
propertyMatchesModifiersConfig
} from "./Common";
import { MouseButton } from "../../../../../core/MouseButton";
const _buttonConfig = { button: MouseButton.LEFT, ctrl: false, shift: false, alt: false };
export function DoubleClickParamConfig(Base) {
return class Mixin extends Base {
};
}
export class RayObjectIntersectionsDoubleClickController extends BaseRayObjectIntersectionsController {
constructor() {
super(...arguments);
this._propertiesListByObject = /* @__PURE__ */ new Map();
this._intersectedStateOnDoubleClickByObject = /* @__PURE__ */ new Map();
this._objectsMatchingEventConfig = [];
}
onDoubleClick(event) {
if (this._objects.length == 0) {
return;
}
filterObjectsWithMatchModifiersConfig(
event,
this._objects,
this._propertiesListByObject,
this._objectsMatchingEventConfig
);
if (this._objectsMatchingEventConfig.length == 0) {
return;
}
this._setIntersectedState(this._objectsMatchingEventConfig, this._intersectedStateOnDoubleClickByObject);
buttonConfigFromEvent(event, _buttonConfig);
for (const object of this._objectsMatchingEventConfig) {
const propertiesList = this._propertiesListByObject.get(object);
if (propertiesList) {
const isIntersectingOnDoubleClick = this._intersectedStateOnDoubleClickByObject.get(object);
if (isIntersectingOnDoubleClick == true) {
for (const properties of propertiesList) {
if (propertyMatchesModifiersConfig(properties.config, _buttonConfig)) {
properties.doubleClick.callback();
}
}
}
}
}
}
}