<commit_before>module.exports = class Lattice extends Echotron.EchoStack
  constructor: ->
    super

    @flipped = [yes, no].random()
    @doubled = [yes, no].random()

    @spiral1 = new Spiral @flipped
    @push @spiral1

    if @doubled
      console.log 'doubled'
      @spiral2 = new Spiral !@flipped, @spiral1
      @push @spiral2



class Spiral extends Echotron.EchoStack
  constructor: (@flipped, source = {}) ->
    super

    @color = source.color || new THREE.Color().setHSV(
      THREE.Math.randFloat(0, 1)
      THREE.Math.randFloat(0, 1)
      THREE.Math.randFloat(0.6, 1)
    )
    @qty   = source.qty   || THREE.Math.randInt 5, 12
    @width = source.width || THREE.Math.randFloat(40, 175) / @qty
    @twist = source.twist || THREE.Math.randFloat 2, 12
    @skew  = source.skew  || [1, 3].random()

    @flippedDir = if @flipped then -1 else 1

    @rotDirection   = source.rotDirection   || [1, -1].random()
    @rotSpeedTarget = source.rotSpeedTarget || THREE.Math.randFloat(20, 75).rad
    @rotSpeedDecay  = source.rotSpeedDecay  || @rotSpeedTarget * THREE.Math.randFloat(4, 12)
    @rotSpeed       = 0


    @push (new Strut(this, i/@qty, @flipped) for i in [0...@qty])...

  setSkew: (@skew) ->
    for layer in @stack.layers
      layer.skew = @skew

  update: (elapsed) ->
    super

    @rotSpeed   -= @rotSpeedDecay * @rotDirection * @flippedDir * elapsed / stage.song.bps
    @rotation.z += @rotSpeed      * @rotDirection * elapsed / stage.song.bps

  beat: ->
    console.log 'before', @rotSpeed
    @rotSpeed = @rotSpeedTarget
    console.log 'after', @rotSpeed

class Strut extends Echotron.Echo
  uniformAttrs:
    color: 'c'
    twist: 'f'
    skew:  'f'
    twistDir: 'f'

  constructor: (@lattice, @angle, @flipped) ->
    super<commit_msg>remove debug lines<commit_after>module.exports = class Lattice extends Echotron.EchoStack
  constructor: ->
    super

    @flipped = [yes, no].random()
    @doubled = [yes, no].random()

    @spiral1 = new Spiral @flipped
    @push @spiral1

    if @doubled
      @spiral2 = new Spiral !@flipped, @spiral1
      @push @spiral2



class Spiral extends Echotron.EchoStack
  constructor: (@flipped, source = {}) ->
    super

    @color = source.color || new THREE.Color().setHSV(
      THREE.Math.randFloat(0, 1)
      THREE.Math.randFloat(0, 1)
      THREE.Math.randFloat(0.6, 1)
    )
    @qty   = source.qty   || THREE.Math.randInt 5, 12
    @width = source.width || THREE.Math.randFloat(40, 175) / @qty
    @twist = source.twist || THREE.Math.randFloat 2, 12
    @skew  = source.skew  || [1, 3].random()

    @flippedDir = if @flipped then -1 else 1

    @rotDirection   = source.rotDirection   || [1, -1].random()
    @rotSpeedTarget = source.rotSpeedTarget || THREE.Math.randFloat(20, 75).rad
    @rotSpeedDecay  = source.rotSpeedDecay  || @rotSpeedTarget * THREE.Math.randFloat(4, 12)
    @rotSpeed       = 0


    @push (new Strut(this, i/@qty, @flipped) for i in [0...@qty])...

  setSkew: (@skew) ->
    for layer in @stack.layers
      layer.skew = @skew

  update: (elapsed) ->
    super

    @rotSpeed   -= @rotSpeedDecay * @rotDirection * @flippedDir * elapsed / stage.song.bps
    @rotation.z += @rotSpeed      * @rotDirection * elapsed / stage.song.bps

  beat: ->
    @rotSpeed = @rotSpeedTarget

class Strut extends Echotron.Echo
  uniformAttrs:
    color: 'c'
    twist: 'f'
    skew:  'f'
    twistDir: 'f'

  constructor: (@lattice, @angle, @flipped) ->
    super
{'fraction_non_alphanumeric': 0.1453757225433526, 'fraction_numerical': 0.021965317919075144, 'mean_word_length': 2.697649572649573, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5698165', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1269, 'n_words': 287}