"use strict";var Picking=function(){var i=this;this._lastColorBuffer=null;var e=function(){i._lastColorBuffer=new Uint8Array(appMain.getRenderingWindow().windowPixelCountRGBA)};e(),appMain.getRenderingWindow().addResizingCallback(function(){appMain.getRenderingWindow().windowPixelCountRGBA>i._lastColorBuffer.length&&e()}),this._pickingRenderMapTexture=new THREE.WebGLRenderTarget(appMain.getRenderingWindow().windowWidth,appMain.getRenderingWindow().windowHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat}),appMain.getRenderingWindow().updateObjectAfterResize(this._pickingRenderMapTexture.setSize.bind(this._pickingRenderMapTexture)),this._pickingMapDrawnForView=!1,this.currentPickableObject=null,this._pickingIdIncrement=Preferences.Picking.ASSIGN_PICKING_COLORS_DISTINGUISHABLE_BY_EYES?100:1,this._currentPickingId=this._pickingIdIncrement,this._pickingIdToPickableGroupNameMap={},this.pickableGroupNameToPickingIdMap={}};Picking.prototype.assignPickingIds=function(i){var e=this,n=new THREE.Object3D;this._pickingIdToPickableGroupNameMap[0]=null;for(var r=0;r<i.children.length;r++){var t=i.children[r];ContentLibrary.getContentString(t.name)&&(this._pickingIdToPickableGroupNameMap[this._currentPickingId]=t.name,this.pickableGroupNameToPickingIdMap[this._pickingIdToPickableGroupNameMap[this._currentPickingId]]=this._currentPickingId,ObjectInfo.createObjectInfo(this._pickingIdToPickableGroupNameMap[this._currentPickingId]),t.traverse(function(i){i instanceof THREE.Mesh&&(i.userData.pickingId=e._currentPickingId)}),this._currentPickingId+=this._pickingIdIncrement,n.children.push(t))}return n},Picking.prototype.checkPickingState=function(){Preferences.Picking.PICKING_ALLOWED&&(this._pickingMapDrawnForView||(this._pickingMapDrawnForView=!0,this._preparePick()),control.mouseOutOfCanvas||(this.currentPickableObject=this._pick(),gui.showPickableModelNameUnderMouse(this.currentPickableObject)))},Picking.prototype._computeIdFromColor=function(i){return renderer.unpackDepth24(i)},Picking.prototype._computeColorFromId=function(i){return renderer.packDepth24(i)},Picking.prototype.invalidatePickingMap=function(){this._pickingMapDrawnForView=!1},Picking.prototype._preparePick=function(){renderer.renderPick(this._pickingRenderMapTexture),renderer.getRendererThree().readRenderTargetPixels(this._pickingRenderMapTexture,0,0,appMain.getRenderingWindow().windowWidth,appMain.getRenderingWindow().windowHeight,this._lastColorBuffer)},Picking.prototype._pick=function(){control.computeCanvasMouseCoordinates();var i=this.getPickedGroupWithModelsFromColor(Renderer.readPixelColor(this._lastColorBuffer,appMain.getRenderingWindow().windowWidth,appMain.getRenderingWindow().windowHeight,control.mouseCanvas.x,control.mouseCanvas.y));return i},Picking.prototype.getPickedGroupWithModelsFromColor=function(i){var e=this._computeIdFromColor(i),n=Preferences.Picking.getPickingIdInIntegerFullRange(e);return this._pickingIdToPickableGroupNameMap[n]};