-
Notifications
You must be signed in to change notification settings - Fork 2
/
aframe-area-light-component.min.js
2 lines (2 loc) · 1.83 KB
/
aframe-area-light-component.min.js
1
2
!function(t){function e(r){if(i[r])return i[r].exports;var o=i[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e){"use strict";if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");if("undefined"==typeof THREE)throw new Error("Component attempted to register before THREE was available.");AFRAME.registerComponent("area-light",{schema:{intensity:{type:"number",default:1},color:{type:"color",default:"#FFFFFF"},width:{type:"number",default:2},height:{type:"number",default:2},helperColor:{type:"color",default:void 0},showHelper:{type:"boolean",default:!0}},init:function(){this.setHelperColor=this.setHelperColor.bind(this),this.rectLight=new THREE.RectAreaLight(this.data.color,this.data.intensity,this.data.width,this.data.height),this.rectLight.position.set(this.data.width/2,0,0),this.el.object3D.add(this.rectLight),this.data.showHelper&&(this.rectLightHelper=new THREE.RectAreaLightHelper(this.rectLight),this.rectLightHelper.position.set(this.rectLight.position.x,0,0),this.el.object3D.add(this.rectLightHelper),void 0!==this.data.helperColor?this.setHelperColor(this.data.helperColor):this.setHelperColor(this.data.color))},setHelperColor:function(t){this.rectLightHelper.children.forEach(function(e){return e.material.color.set(t)})},update:function(t){this.rectLight.intensity=this.data.intensity,this.rectLight.width=this.data.width,this.rectLight.height=this.data.height,this.rectLight.color.set(this.data.color),void 0!==this.rectLightHelper&&(this.rectLightHelper.visible=this.data.showHelper,this.rectLightHelper.update(),void 0!==this.data.helperColor?this.setHelperColor(this.data.helperColor):this.setHelperColor(this.data.color))}})}]);
//# sourceMappingURL=aframe-area-light-component.min.js.map