@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
40 lines (39 loc) • 1.38 kB
JavaScript
"use strict";
import { ACTOR_COMPILATION_CONTROLLER_DUMMY_OBJECT } from "../../../../../core/actor/ActorCompilationController";
import { pushOnArrayAtEntry } from "../../../../../core/MapUtils";
export class BaseUserInputController {
constructor(actorsManager) {
this.actorsManager = actorsManager;
this._objects = [];
this._propertiesListByObject = /* @__PURE__ */ new Map();
this._scene = actorsManager.scene;
}
addPropertiesForObject(object, properties) {
if (object == ACTOR_COMPILATION_CONTROLLER_DUMMY_OBJECT) {
return;
}
pushOnArrayAtEntry(this._propertiesListByObject, object, properties);
const index = this._objects.indexOf(object);
if (index < 0) {
this._objects.push(object);
}
}
removePropertiesForObject(object, properties) {
if (object == ACTOR_COMPILATION_CONTROLLER_DUMMY_OBJECT) {
return;
}
const propertiesForObject = this._propertiesListByObject.get(object);
if (!propertiesForObject) {
return;
}
const propertyIndex = propertiesForObject.indexOf(properties);
propertiesForObject.splice(propertyIndex, 1);
if (propertiesForObject.length == 0) {
const objectIndex = this._objects.indexOf(object);
if (objectIndex >= 0) {
this._objects.splice(objectIndex, 1);
this._propertiesListByObject.delete(object);
}
}
}
}