import THREE from 'three.js';
import Entity from './entity';
import Shield from './shield';
import Engine from './engine';
import { defineLazyGetters } from './lazy';
import { collisionMixin, CollisionShapes, CollisionGroups } from './collision';

const geometries = defineLazyGetters( {}, {
  basic() {
    const geometry = new THREE.CylinderGeometry( 0, 0.1, 0.5, 3 );

    geometry.rotateX( -Math.PI / 2 );
    geometry.computeFaceNormals();
    geometry.computeVertexNormals();

    return geometry;
  },

  sphere() {
    return new THREE.IcosahedronGeometry( 0.2, 1 );
  }
});

const material = new THREE.MeshPhongMaterial({
  shading: THREE.FlatShading
});

export default class Ship extends Entity {
  constructor() {
    super( geometries.basic, material.clone() );
    collisionMixin( this );

    this.type = 'ship';
    this.shape = CollisionShapes.SPHERE;
    this.collisionFilterGroup = CollisionGroups.SHIP;

    this.shield = new Shield();
    this.shield.visible = false;
    this.add( this.shield );

    this.engine = new Engine( this );
    this.engine.position.set( 0, 0, 0.3 );
    this.add( this.engine );
  }
}

@@ -241,16 +241,86 @@
 sion';%0A%0A
+const createLathePoint = (%5B x, z %5D) =%3E new THREE.Vector3( x, 0, z );%0A%0A
 const ge
@@ -634,24 +634,890 @@
 ( 0.2, 1 );%0A
+  %7D,%0A%0A  diamonds() %7B%0A    const points = %5B%0A      %5B 0, 0 %5D,%0A      %5B 0.05, 0.1 %5D,%0A      %5B 0, 0.4 %5D%0A    %5D.map( createLathePoint );%0A%0A    const geometry = new THREE.LatheGeometry( points, 3 )%0A      .rotateZ( Math.PI / 6 );%0A%0A    const boosterPoints = %5B%0A      %5B 0, 0 %5D,%0A      %5B 0.025, 0.04 %5D,%0A      %5B 0.025, 0.08 %5D,%0A      %5B 0, 0.2 %5D%0A    %5D.map( createLathePoint );%0A%0A    const leftBoosterGeometry = new THREE.LatheGeometry( boosterPoints, 4 );%0A    const rightBoosterGeometry = new THREE.LatheGeometry( boosterPoints, 4 );%0A%0A    leftBoosterGeometry.translate( -0.1, 0, 0 );%0A    rightBoosterGeometry.translate( 0.1, 0, 0 );%0A%0A    geometry.merge( leftBoosterGeometry );%0A    geometry.merge( rightBoosterGeometry );%0A%0A    geometry.rotateX( Math.PI );%0A    geometry.translate( 0, 0, 0.15 );%0A%0A    geometry.computeFaceNormals();%0A    geometry.computeVertexNormals();%0A%0A    return geometry;%0A
   %7D%0A%7D);%0A%0Acon

Add LatheGeometry test for Ship.