"use strict";exports.__esModule=!0,exports.default=void 0;var _three=require("three"),_extension=require("../../core/extension"),_util=require("../../common/util"),_default=exports.default=(0,_extension.definePlugin)("light",{setup(a,b){const c=a=>{const b=new _three.DirectionalLight(a.color||16770201,a.intensity||5);if(a.position){let[c,d,e]=a.position;b.position.set(c,d,e)}else b.position.set(.5,.5,1);return b},d=a=>{const b=new _three.AmbientLight(a.color||12237498,a.intensity||.7);return b},e=a=>{const b=new _three.SpotLight(a.color||11579568,a.intensity||.8);let[c,d,e]=a.position||[0,0,0];return b.position.set(c,d,e),b},f=new Set,g=a=>{let g;return"DirectionalLight"===a.type?g=c(a):"AmbientLight"===a.type?g=d(a):"SpotLight"===a.type?g=e(a):void 0,g&&(f.add(g),b.scene.add(g)),g};return a&&(0,_util.toArray)(a).forEach(a=>{g(a)}),{lights:f,createLight:a=>{(0,_util.toArray)(a).forEach(a=>{g(a)})},remove:a=>{f.delete(a),a.removeFromParent(),a.dispose()},clear:()=>{f.forEach(a=>{a.removeFromParent(),a.dispose()}),f.clear()}}},destroyed(){this.lights.forEach(a=>{this.remove(a)})}});