<commit_before>// @flow

// Import third-party modules
import twgl from '../node_modules/twgl.js/dist/3.x/twgl'

// Import local modules
import Node from './node'

// Set local constants
const coverColor = [254 / 255, 116 / 255, 40 / 255, 1]
const hardcoverHeight = 200
const hardcoverWidth = hardcoverHeight * 0.71 // from http://artgorbunov.ru/books/ui/demo/
const fromTop = 100 - hardcoverHeight * 0.1

//  240 — is position 'at screen',
// -249 — size from _almost_ pixel perfect comparison with http://artgorbunov.ru/books/ui/demo/
// Maybe we need that 9 points shift away from camera to gain a space
// for moving hardcover towards user
const fromCamera = -249

// Quick and dirty
export default function hardcoverNode(gl: WebGLRenderingContext, programInfo: Object) {
  return new Node({
    programInfo,
    type: gl.TRIANGLES,
    uniforms: { u_color: coverColor },
    bufferInfo: twgl.createBufferInfoFromArrays(gl, {
      'a_position': [
       -hardcoverWidth / 2, fromTop - hardcoverHeight, fromCamera,
        hardcoverWidth / 2, fromTop - hardcoverHeight, fromCamera,
       -hardcoverWidth / 2, fromTop,                   fromCamera,

        hardcoverWidth / 2, fromTop - hardcoverHeight, fromCamera,
        hardcoverWidth / 2, fromTop,                   fromCamera,
       -hardcoverWidth / 2, fromTop,                   fromCamera,
      ]
    })
  })
}<commit_msg>feat(scene): added all nessesary planes for first part of animation<commit_after>// @flow

// Import third-party modules
import twgl from '../node_modules/twgl.js/dist/3.x/twgl'

// Import local modules
import Node from './node'

// Set local constants
const coverColor = [254 / 255, 116 / 255, 40 / 255, 1]
const hardcoverHeight = 200
const hardcoverWidth = hardcoverHeight * 0.71 // from http://artgorbunov.ru/books/ui/demo/
const fromTop = 100 - hardcoverHeight * 0.1

const coverThickness = 50 // dummy number

//  240 — is position 'at screen',
// -249 — size from _almost_ pixel perfect comparison with http://artgorbunov.ru/books/ui/demo/
// Maybe we need that 9 points shift away from camera to gain a space
// for moving hardcover towards user
const fromCamera = -249

const halfWidth = hardcoverWidth / 2
const bottomY = fromTop - hardcoverHeight
const frontCoverBackZ = fromCamera - coverThickness

// Quick and dirty
export default function hardcoverNode(gl: WebGLRenderingContext, programInfo: Object) {
  // TODO For frontCoverInnerSide() we should copy frontCover() and translate it by Z by (-coverThickness) and rotate it by Y axis and change color
  // TODO For frontCoverFlyleaf() we should copy frontCover() and translate it by Z by (-coverThickness - 1) and change color
  return [
    frontCover(gl, programInfo),
    frontCoverThicknessSide(gl, programInfo),
    frontCoverInnerSide(gl, programInfo),
    frontCoverFlyleaf(gl, programInfo)
  ]
}

function frontCover (gl: WebGLRenderingContext, programInfo: Object) {
  return new Node({
    programInfo,
    type: gl.TRIANGLES,
    uniforms: { u_color: coverColor },
    bufferInfo: twgl.createBufferInfoFromArrays(gl, {
      'a_position': [
       -halfWidth, bottomY, fromCamera,
        halfWidth, bottomY, fromCamera,
       -halfWidth, fromTop, fromCamera,

        halfWidth, bottomY, fromCamera,
        halfWidth, fromTop, fromCamera,
       -halfWidth, fromTop, fromCamera,
      ]
    })
  })
}

function frontCoverThicknessSide (gl: WebGLRenderingContext, programInfo: Object) {
  return new Node({
    programInfo,
    type: gl.TRIANGLES,
    uniforms: { u_color: [1, 1, 1, 1] },
    bufferInfo: twgl.createBufferInfoFromArrays(gl, {
      'a_position': [
       halfWidth, bottomY, fromCamera,
       halfWidth, fromTop, fromCamera,
       halfWidth, bottomY, frontCoverBackZ,

       halfWidth, fromTop, fromCamera,
       halfWidth, fromTop, frontCoverBackZ,
       halfWidth, bottomY, frontCoverBackZ,
      ]
    })
  })
}

function frontCoverFlyleaf (gl: WebGLRenderingContext, programInfo: Object) {
  return new Node({
    programInfo,
    type: gl.TRIANGLES,
    uniforms: { u_color: [63 / 255, 54 /255, 58 /255, 1] },
    bufferInfo: twgl.createBufferInfoFromArrays(gl, {
      'a_position': [
       -halfWidth, bottomY, frontCoverBackZ,
       -halfWidth, fromTop, frontCoverBackZ,
        halfWidth, bottomY, frontCoverBackZ,

        halfWidth, bottomY, frontCoverBackZ,
       -halfWidth, fromTop, frontCoverBackZ,
        halfWidth, fromTop, frontCoverBackZ,
      ]
    })
  })
}

function frontCoverInnerSide (gl: WebGLRenderingContext, programInfo: Object) {
  return new Node({
    programInfo,
    type: gl.TRIANGLES,
    uniforms: { u_color: [63 / 255, 54 /255, 58 /255, 1] },
    bufferInfo: twgl.createBufferInfoFromArrays(gl, {
      'a_position': [ // X and Y are the same as for frontCover, but triangles are backfaced
       -halfWidth, bottomY, frontCoverBackZ,
       -halfWidth, fromTop, frontCoverBackZ,
        halfWidth, bottomY, frontCoverBackZ,

        halfWidth, bottomY, frontCoverBackZ,
       -halfWidth, fromTop, frontCoverBackZ,
        halfWidth, fromTop, frontCoverBackZ,
      ]
    })
  })
}

function frontCoverFlyleaf (gl: WebGLRenderingContext, programInfo: Object) {
  return new Node({
    programInfo,
    type: gl.TRIANGLES,
    uniforms: { u_color: [63 / 255, 54 /255, 58 /255, 1] },
    bufferInfo: twgl.createBufferInfoFromArrays(gl, {
      'a_position': [ // X and Y are the same as for frontCover
       -halfWidth, bottomY, frontCoverBackZ - 1,
        halfWidth, bottomY, frontCoverBackZ - 1,
       -halfWidth, fromTop, frontCoverBackZ - 1,

        halfWidth, bottomY, frontCoverBackZ - 1,
        halfWidth, fromTop, frontCoverBackZ - 1,
       -halfWidth, fromTop, frontCoverBackZ - 1,
      ]
    })
  })
}
{'fraction_non_alphanumeric': 0.10109622411693057, 'fraction_numerical': 0.025752566556464244, 'mean_word_length': 3.067940552016985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '770600', 'n_tokens_mistral': 1944, 'n_tokens_neox': 1766, 'n_words': 524}