"use strict";exports.__esModule=!0,exports.default=void 0;var _extension=require("../../core/extension"),_tool=require("../../webgl/tool"),_three=require("three"),_default=exports.default=(0,_extension.definePlugin)("picker",{setup(a,b){function c(a,d){let e;if(d){const f=b.get(d.uuid);return f?(e=f,e):(e=c(a,d.parent),e)?e:e}}const d=a=>{const d=b.component?[b.component]:[];let e=[];return a.forEach(a=>{if(a.object&&(a.object.isMesh||a.object.isSprite)){const b=a.object;let f=c(d,b);f&&-1===e.indexOf(f)&&e.push(f)}}),e},e=a=>{const c=(0,_tool.getIntersects)([a.x,a.y],b.container,b.camera,b.scene.children).filter(a=>a.object.isMesh||a.object.isSprite);return d(c)};return{fromVector2:e,fromVector3:a=>{let{x:c,y:d}=(0,_tool.threeCoordinateToScreenPoint)(a,b.container,b.camera);return e({x:c,y:d})},fromMulVector3:(a,c)=>{let e=new _three.Vector3(a.x,a.y,a.z),f=new _three.Vector3(c.x,c.y,c.z).sub(e).normalize();const g=new _three.Raycaster;g.set(e,f);const h=g.intersectObjects(b.scene.children);return d(h)},fromBrowserEvent:a=>e({x:a.clientX,y:a.clientY})}},destroyed(){}});