import React from 'react';

const Barrel = (props) => {
  const position = props.position || '0 0 0';
  const rotation = props.rotation || '0 0 0';
  const barrelLength = props.barrelLength || 5;
  // TODO: Make better turret angle interpolator
  return (
    <a-entity class='turret' position={position} rotation={rotation}>
      <a-cylinder height={barrelLength} radius='0.2' material={props.material}
      position={`0 0 ${-barrelLength / 2}`} rotation='90 0 0' />
      <a-cylinder height='0.3' radius='0.25' material={props.material}
      position={`0 0 ${-barrelLength}`}
      rotation='90 0 0' />
    </a-entity>
  )
};

module.exports = Barrel;

@@ -186,17 +186,17 @@
 ngth %7C%7C 
-5
+6
 ;%0A  // T
@@ -238,16 +238,197 @@
 polator%0A
+  if(props.fireEvent) %7B%0A    const fireEventArray = props.fireEvent.replace(' ', '').split(';');%0A    const event = fireEventArray.filter(params =%3E params.slice(0,3) === 'on:')%5B0%5D;%0A  
   return
@@ -430,16 +430,18 @@
 eturn (%0A
+  
     %3Ca-e
@@ -453,22 +453,550 @@
  class='
-turret
+barrel' position=%7Bposition%7D rotation=%7Brotation%7D%3E%0A        %3Ca-cylinder height=%7BbarrelLength%7D radius='0.2' material=%7Bprops.material%7D%0A        position=%7B%600 0 $%7B-barrelLength / 2%7D%60%7D rotation='90 0 0' /%3E%0A        %3Ca-cylinder height='0.3' radius='0.25' material=%7Bprops.material%7D%0A        position=%7B%600 0 $%7B-barrelLength%7D%60%7D%0A        rotation='90 0 0' %0A        spawner=%7B%60mixin: projectile; $%7Bevent%7D%60%7D%0A        event-listener=%7Bprops.fireEvent%7D/%3E%0A%0A        %7Bprops.children%7D%0A%0A      %3C/a-entity%3E%0A    )%0A  %7D else %7B%0A    return (%0A      %3Ca-entity class='barrel
 ' positi
@@ -1026,24 +1026,26 @@
 %7Brotation%7D%3E%0A
+  
       %3Ca-cyl
@@ -1103,32 +1103,34 @@
 props.material%7D%0A
+  
       position=%7B
@@ -1180,24 +1180,26 @@
 0' /%3E%0A      
+  
 %3Ca-cylinder 
@@ -1253,24 +1253,26 @@
 rial%7D%0A      
+  
 position=%7B%600
@@ -1289,24 +1289,26 @@
 elLength%7D%60%7D%0A
+  
       rotati
@@ -1318,24 +1318,53 @@
 '90 0 0' /%3E%0A
+%0A        %7Bprops.children%7D%0A%0A  
     %3C/a-enti
@@ -1369,17 +1369,23 @@
 tity%3E%0A  
-)
+  )%0A  %7D
 %0A%7D;%0A%0Amod

Make Barrel component take advantage of dynamic event-listener