UNPKG

@polygonjs/polygonjs

Version:

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

46 lines (45 loc) 1.68 kB
"use strict"; import { BaseRayObjectIntersectionsController } from "./_BaseRayObjectIntersectionsController"; import { filterObjectsWithMatchButtonConfig, buttonConfigFromEvent, propertyMatchesButtonConfig } from "./Common"; import { MouseButton } from "../../../../../core/MouseButton"; const _buttonConfig = { button: MouseButton.LEFT, ctrl: false, shift: false, alt: false }; export class RayObjectIntersectionsPointerupController extends BaseRayObjectIntersectionsController { constructor() { super(...arguments); this._propertiesListByObject = /* @__PURE__ */ new Map(); this._intersectedStateByObject = /* @__PURE__ */ new Map(); this._objectsMatchingEventConfig = []; } // private _processBound = this._process.bind(this); onPointerup(event) { filterObjectsWithMatchButtonConfig( event, this._objects, this._propertiesListByObject, this._objectsMatchingEventConfig ); if (this._objectsMatchingEventConfig.length == 0) { return; } this._setIntersectedState(this._objectsMatchingEventConfig, this._intersectedStateByObject); buttonConfigFromEvent(event, _buttonConfig); const objects = this._objects; for (const object of objects) { const propertiesList = this._propertiesListByObject.get(object); if (propertiesList) { const isIntersecting = this._intersectedStateByObject.get(object); if (isIntersecting == true) { for (const properties of propertiesList) { if (propertyMatchesButtonConfig(properties.config, _buttonConfig)) { properties.pointerup.callback(); } } } } } } }