<commit_before>/* eslint-env es6 */
/* global THREE, VertexIndices */

function transformBoxVertices( method ) {
  'use strict';

  const vector = new THREE.Vector3();
  const zero = new THREE.Vector3();

  function baseTransform( geometry, key, delta, ...args ) {
    const indices = VertexIndices[ key.toUpperCase() ];

    if ( Array.isArray( delta ) ) {
      vector.fromArray( delta );
    } else if ( typeof delta === 'object' ) {
      Object.assign( vector, zero, delta );
    } else if ( typeof delta === 'number' ) {
      vector.setScalar( delta );
    } else {
      return geometry;
    }

    if ( Array.isArray( indices ) ) {
      indices.forEach( index =>
        geometry.vertices[ index ][ method ]( vector, ...args )
      );
    }

    return geometry;
  }

  return function transform( geometry, vectors, ...args ) {
    if ( typeof vectors === 'string' ) {
      return baseTransform( geometry, vectors, ...args );
    } else if ( typeof vectors === 'object' ) {
      Object.keys( vectors ).forEach( key => {
        const delta = vectors[ key ];
        baseTransform( geometry, key, delta, ...args );
      });
    }

    return geometry;
  };
}

window.translateBoxVertices = transformBoxVertices( 'add' );
window.scaleBoxVertices = transformBoxVertices( 'multiply' );
window.lerpBoxVertices = transformBoxVertices( 'lerp' );

// Per-axis THREE.BoxGeometry methods.
const transformAxisBoxVertices = (function() {
  'use strict';

  const vector = new THREE.Vector3();

  return ( method, identity = new THREE.Vector3() ) => {
    return axis => {
      function baseTransformAxis(
        geometry,
        key,
        delta = identity.getComponent( axis ),
        ...args
      ) {
        const indices = VertexIndices[ key.toUpperCase() ];

        if ( Array.isArray( indices ) ) {
          vector
            .copy( identity )
            .setComponent( axis, delta );

          indices.forEach( index =>
            geometry.vertices[ index ][ method ]( vector, ...args )<commit_msg>lathe[cuboid]: Support identity THREE.BoxGeometry vertex transforms.<commit_after>/* eslint-env es6 */
/* global THREE, VertexIndices */


const transformBoxVertices = (function() {
  'use strict';

  const vector = new THREE.Vector3();

  return ( method, identity = new THREE.Vector3() ) => {
    function baseTransform( geometry, key, delta, ...args ) {
      const indices = VertexIndices[ key.toUpperCase() ];

      if ( Array.isArray( delta ) ) {
        vector.fromArray( delta );
      } else if ( typeof delta === 'object' ) {
        Object.assign( vector, identity, delta );
      } else if ( typeof delta === 'number' ) {
        vector.setScalar( delta );
      } else {
        return geometry;
      }

      if ( Array.isArray( indices ) ) {
        indices.forEach( index =>
          geometry.vertices[ index ][ method ]( vector, ...args )
        );
      }

      return geometry;
    }

    return function transform( geometry, vectors, ...args ) {
      if ( typeof vectors === 'string' ) {
        return baseTransform( geometry, vectors, ...args );
      } else if ( typeof vectors === 'object' ) {
        Object.keys( vectors ).forEach( key => {
          const delta = vectors[ key ];
          baseTransform( geometry, key, delta, ...args );
        });
      }

      return geometry;
    };
  };
}());

window.translateBoxVertices = transformBoxVertices( 'add' );
window.scaleBoxVertices = transformBoxVertices( 'multiply', new THREE.Vector3( 1, 1, 1 ) );
window.lerpBoxVertices = transformBoxVertices( 'lerp' );

// Per-axis THREE.BoxGeometry methods.
const transformAxisBoxVertices = (function() {
  'use strict';

  const vector = new THREE.Vector3();

  return ( method, identity = new THREE.Vector3() ) => {
    return axis => {
      function baseTransformAxis(
        geometry,
        key,
        delta = identity.getComponent( axis ),
        ...args
      ) {
        const indices = VertexIndices[ key.toUpperCase() ];

        if ( Array.isArray( indices ) ) {
          vector
            .copy( identity )
            .setComponent( axis, delta );

          indices.forEach( index =>
            geometry.vertices[ index ][ method ]( vector, ...args )
{'fraction_non_alphanumeric': 0.13652524294856602, 'fraction_numerical': 0.0033183218772220905, 'mean_word_length': 2.3438985736925515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '2232005', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1171, 'n_words': 323}