<commit_before>/** @jsx h */
import { h, Component } from 'preact';
import shuffle from 'just-shuffle';

import './style.scss';

import viewer from '../../viewer';
import audio from '../../audio';

import AudioTimeline from '../AudioTimeline';
import LineTitle from '../LineTitle';

import { worldToScreen } from '../../utils/three';

export default class TutorialTimeline extends Component {
  constructor() {
    super();
    this.performUpdate = this.performUpdate.bind(this);
    this.tick = this.tick.bind(this);
    this.getTime = this.getTime.bind(this);
  }

  componentWillMount() {
    const getHeadPosition = (index) => {
      const { room } = this.context;
      if (!room) return;
      const count = room.frame.count;
      if (!count) return;
      return (
        room &&
        room.getHeadPosition(
          index !== undefined
            ? (index + Math.floor(audio.totalProgress * 0.5)) % count
            : count - 1
        )
      );
    };
    let time = 0;
    const randomIndex = () => Math.floor(Math.random() * 100);
    const compliments = shuffle([
      'Nice moves.',
      'Killer steps.',
      'Sh.. Sh.. Shake it!',
      'So elegant.',
      'Remarkeable.',
      'You monster, you!',
      'Cut that rug up!',
      'Exactly!',
      'Yes!',
      'You the best!',
      'Yes. Yes. Yes!',
      'Get your freak on.',
      'Loved this bit.',
      'E-l-e-c-t-r-i-f-y-i-n-g!',
      'Put that foot down.',
      'Get down with it.',
      'Cha! Cha! Dontcha!',
      'Improvisational.',
      'Pop it. Lock it.',
      'Classic.',
      'Such finesse.',
      'Such concentration!',
      'So nimble.',
      'Gene, is that you?',
      'Crank that.',
    ]);
    const keyframes = this.props.fromRecording
      ? [
        {
          duration: 2,
          text: '',
        },
        {
          duration: 1,
          text: '...',
        },
        {
          duration: 1,
          text: 'Gosh...',
        },
        {
          duration: 2,
          text: 'We have no words!',
        },
        {
          duration: 4,
          text: 'That was amazing.',
        },
        {
          duration: 4,
          text: 'You must be worn out.',
        },
        {
          duration: 6,
          text: 'Thanks so much for your contribution.',
        },
        {
          duration: 4,
          text: 'Let’s take a moment to admire your moves:',
        },
        {
          duration: 3,
          text: '',
        },
      ]
    : [
      {
        duration: 2,
        text: '',
      },
      {
        duration: 2,
        text: '…',
      },
      {
        duration: 6,
        text: 'Here’s your friend in Dance Tonite.',
      },
      {
        duration: 1,
        text: 'Pretty,',
      },
      {
        duration: 1,
        text: 'Pretty, pretty.',
      },
      {
        duration: 1,
        text: 'Pretty, pretty, good,',
      },
      {
        duration: 4,
        text: 'Pretty, pretty, good, right?',
      },
      {
        duration: 4,
        text: 'Be sure to watch them in the full experience.',
      },
      {
        duration: 3,
        text: 'But first…',
      },
      {
        duration: 4,
        text: 'Let’s take a moment to admire their moves:',
      },
      {
        duration: 3,
        text: '',
      },
    ];

    for (let i = 0, l = compliments.length; i < l; i++) {
      const text = compliments.pop();
      keyframes.push({
        duration: Math.max(2, text.length * 0.15),
        text,
        getPosition: getHeadPosition.bind(this, randomIndex()),
      });
      keyframes.push({
        duration: 2 + Math.random() * 8,
        text: '',
      });
    }

    this.keyframes = keyframes.map(keyframe => {
      keyframe.time = time;
      time += keyframe.duration;
      return keyframe;
    });
    viewer.on('tick', this.tick);
  }

  componentWillUnmount() {
    viewer.off('tick', this.tick);
  }

  getTime() {<commit_msg>work on compliments – closes #476<commit_after>/** @jsx h */
import { h, Component } from 'preact';
import shuffle from 'just-shuffle';

import './style.scss';

import viewer from '../../viewer';
import audio from '../../audio';

import AudioTimeline from '../AudioTimeline';
import LineTitle from '../LineTitle';

import { worldToScreen } from '../../utils/three';

export default class TutorialTimeline extends Component {
  constructor() {
    super();
    this.performUpdate = this.performUpdate.bind(this);
    this.tick = this.tick.bind(this);
    this.getTime = this.getTime.bind(this);
  }

  componentWillMount() {
    const getHeadPosition = (index) => {
      const { room } = this.context;
      if (!room) return;
      const count = room.frame.count;
      if (!count) return;
      return (
        room &&
        room.getHeadPosition(
          index !== undefined
            ? (index + Math.floor(audio.totalProgress * 0.5)) % count
            : count - 1
        )
      );
    };
    let time = 0;
    const randomIndex = () => Math.floor(Math.random() * 100);
    const compliments = shuffle([
      'Nice moves.',
      'Killer steps.',
      'Sh.. Sh.. Shake it!',
      'So elegant.',
      'Remarkeable.',
      'You monster, you!',
      'Cut that rug up!',
      'Exactly!',
      'Yes!',
      'You the best!',
      'Yes. Yes. Yes!',
      'Get your freak on.',
      'Loved this bit.',
      'E-l-e-c-t-r-i-f-y-i-n-g!',
      'Put that foot down.',
      'Get down with it.',
      'Cha! Cha! Dontcha!',
      'Improvisational.',
      'Pop it. Lock it.',
      'Classic.',
      'Such finesse.',
      'Such concentration!',
      'So nimble.',
      'Gene, is that you?',
      'Crank that.',
    ]);
    const keyframes = this.props.fromRecording
      ? [
        {
          duration: 2,
          text: '',
        },
        {
          duration: 1,
          text: '...',
        },
        {
          duration: 1,
          text: 'Gosh...',
        },
        {
          duration: 2,
          text: 'We have no words!',
        },
        {
          duration: 4,
          text: 'That was amazing.',
        },
        {
          duration: 4,
          text: 'You must be worn out.',
        },
        {
          duration: 6,
          text: 'Thanks so much for your contribution.',
        },
        {
          duration: 4,
          text: 'Let’s take a moment to admire your moves:',
        },
        {
          duration: 3,
          text: '',
        },
      ]
    : [
      {
        duration: 2,
        text: '',
      },
      {
        duration: 2,
        text: '…',
      },
      {
        duration: 6,
        text: 'Here’s your friend in Dance Tonite.',
      },
      {
        duration: 0.5,
        text: 'Pretty,',
      },
      {
        duration: 0.5,
        text: 'Pretty, pretty.',
      },
      {
        duration: 0.5,
        text: 'Pretty, pretty, good,',
      },
      {
        duration: 4,
        text: 'Pretty, pretty, good, right?',
      },
      {
        duration: 4,
        text: 'Be sure to watch them in the full experience.',
      },
      {
        duration: 3,
        text: 'But first…',
      },
      {
        duration: 4,
        text: 'Let’s take a moment to admire their moves:',
      },
    ];

    for (let i = 0, l = compliments.length; i < l; i++) {
      const text = compliments.pop();
      keyframes.push({
        duration: 4 + Math.random() * 6,
        text: '',
      });
      keyframes.push({
        duration: Math.max(2, text.length * 0.15),
        text,
        getPosition: getHeadPosition.bind(this, randomIndex()),
      });
    }

    this.keyframes = keyframes.map(keyframe => {
      keyframe.time = time;
      time += keyframe.duration;
      return keyframe;
    });
    viewer.on('tick', this.tick);
  }

  componentWillUnmount() {
    viewer.off('tick', this.tick);
  }

  getTime() {
{'fraction_non_alphanumeric': 0.15468630937261874, 'fraction_numerical': 0.009271018542037084, 'mean_word_length': 1.4570982839313573, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '916800', 'n_tokens_mistral': 2514, 'n_tokens_neox': 2418, 'n_words': 632}