vendor/GLTFExporter.js
function processAccessor(attribute, geometry, start, count) {
      var types = {
        1: 'SCALAR',
        2: 'VEC2',
        3: 'VEC3',
        4: 'VEC4',
        16: 'MAT4'
      };

      var componentType;

      // Detect the component type of the attribute array (float, uint or ushort)
      if (attribute.array.constructor === Float32Array) {
        componentType = WEBGL_CONSTANTS.FLOAT;
      } else if (attribute.array.constructor === Uint32Array) {
        componentType = WEBGL_CONSTANTS.UNSIGNED_INT;
      } else if (attribute.array.constructor === Uint16Array) {
        componentType = WEBGL_CONSTANTS.UNSIGNED_SHORT;
      } else if (attribute.array.constructor === Uint8Array) {
        componentType = WEBGL_CONSTANTS.UNSIGNED_BYTE;
      } else {
        throw new Error(
          'THREE.GLTFExporter: Unsupported bufferAttribute component type.'
        );
      }

      if (start === undefined) start = 0;
      if (count === undefined) count = attribute.count;

      // @TODO Indexed buffer geometry with drawRange not supported yet
      if (
        options.truncateDrawRange &&
        geometry !== undefined &&
        geometry.index === null
      ) {
        var end = start + count;
        var end2 =
          geometry.drawRange.count === Infinity
            ? attribute.count
            : geometry.drawRange.start + geometry.drawRange.count;

        start = Math.max(start, geometry.drawRange.start);
        count = Math.min(end, end2) - start;

        if (count < 0) count = 0;
      }

      // Skip creating an accessor if the attribute doesn't have data to export
      if (count === 0) {
        return null;
      }

      var minMax = getMinMax(attribute, start, count);

      var bufferViewTarget;

      // If geometry isn't provided, don't infer the target usage of the bufferView. For
      // animation samplers, target must not be set.
      if (geometry !== undefined) {
        bufferViewTarget =
          attribute === geometry.index
            ? WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER
            : WEBGL_CONSTANTS.ARRAY_BUFFER;
      }

      var bufferView = processBufferView(
        attribute,
        componentType,
        start,
        count,
        bufferViewTarget
      );

      var gltfAccessor = {
        bufferView: bufferView.id,
        byteOffset: bufferView.byteOffset,
        componentType: componentType,
        count: count,
        max: minMax.max,
        min: minMax.min,
        type: types[attribute.itemSize]
      };

      if (!outputJSON.accessors) {
        outputJSON.accessors = [];
      }

      outputJSON.accessors.push(gltfAccessor);

      return outputJSON.accessors.length - 1;
    }
function processAccessor(attribute, geometry, start, count) {
      var types = {
        1: 'SCALAR',
        2: 'VEC2',
        3: 'VEC3',
        4: 'VEC4',
        16: 'MAT4'
      };

      var componentType;

      // Detect the component type of the attribute array (float, uint or ushort)
      if (attribute.array.constructor === Float32Array) {
        componentType = WEBGL_CONSTANTS.FLOAT;
      } else if (attribute.array.constructor === Uint32Array) {
        componentType = WEBGL_CONSTANTS.UNSIGNED_INT;
      } else if (attribute.array.constructor === Uint16Array) {
        componentType = WEBGL_CONSTANTS.UNSIGNED_SHORT;
      } else if (attribute.array.constructor === Uint8Array) {
        componentType = WEBGL_CONSTANTS.UNSIGNED_BYTE;
      } else {
        throw new Error(
          'THREE.GLTFExporter: Unsupported bufferAttribute component type.'
        );
      }

      if (start === undefined) start = 0;
      if (count === undefined) count = attribute.count;

      // @TODO Indexed buffer geometry with drawRange not supported yet
      if (
        options.truncateDrawRange &&
        geometry !== undefined &&
        geometry.index === null
      ) {
        var end = start + count;
        var end2 =
          geometry.drawRange.count === Infinity
            ? attribute.count
            : geometry.drawRange.start + geometry.drawRange.count;

        start = Math.max(start, geometry.drawRange.start);
        count = Math.min(end, end2) - start;

        if (count < 0) count = 0;
      }

      // Skip creating an accessor if the attribute doesn't have data to export
      if (count === 0) {
        return null;
      }

      var minMax = getMinMax(attribute, start, count);

      var bufferViewTarget;

      // If geometry isn't provided, don't infer the target usage of the bufferView. For
      // animation samplers, target must not be set.
      if (geometry !== undefined) {
        bufferViewTarget =
          attribute === geometry.index
            ? WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER
            : WEBGL_CONSTANTS.ARRAY_BUFFER;
      }

      var bufferView = processBufferView(
        attribute,
        componentType,
        start,
        count,
        bufferViewTarget
      );

      var gltfAccessor = {
        bufferView: bufferView.id,
        byteOffset: bufferView.byteOffset,
        componentType: componentType,
        count: count,
        max: minMax.max,
        min: minMax.min,
        type: types[attribute.itemSize]
      };

      if (!outputJSON.accessors) {
        outputJSON.accessors = [];
      }

      outputJSON.accessors.push(gltfAccessor);

      return outputJSON.accessors.length - 1;
    }
function processAccessor ( attribute , geometry , start , count ) { var types = { 1 : 'SCALAR' , 2 : 'VEC2' , 3 : 'VEC3' , 4 : 'VEC4' , 16 : 'MAT4' } ; var componentType ; // Detect the component type of the attribute array (float, uint or ushort) if ( attribute . array . constructor === Float32Array ) { componentType = WEBGL_CONSTANTS . FLOAT ; } else if ( attribute . array . constructor === Uint32Array ) { componentType = WEBGL_CONSTANTS . UNSIGNED_INT ; } else if ( attribute . array . constructor === Uint16Array ) { componentType = WEBGL_CONSTANTS . UNSIGNED_SHORT ; } else if ( attribute . array . constructor === Uint8Array ) { componentType = WEBGL_CONSTANTS . UNSIGNED_BYTE ; } else { throw new Error ( 'THREE.GLTFExporter: Unsupported bufferAttribute component type.' ) ; } if ( start === undefined ) start = 0 ; if ( count === undefined ) count = attribute . count ; // @TODO Indexed buffer geometry with drawRange not supported yet if ( options . truncateDrawRange && geometry !== undefined && geometry . index === null ) { var end = start + count ; var end2 = geometry . drawRange . count === Infinity ? attribute . count : geometry . drawRange . start + geometry . drawRange . count ; start = Math . max ( start , geometry . drawRange . start ) ; count = Math . min ( end , end2 ) - start ; if ( count < 0 ) count = 0 ; } // Skip creating an accessor if the attribute doesn't have data to export if ( count === 0 ) { return null ; } var minMax = getMinMax ( attribute , start , count ) ; var bufferViewTarget ; // If geometry isn't provided, don't infer the target usage of the bufferView. For // animation samplers, target must not be set. if ( geometry !== undefined ) { bufferViewTarget = attribute === geometry . index ? WEBGL_CONSTANTS . ELEMENT_ARRAY_BUFFER : WEBGL_CONSTANTS . ARRAY_BUFFER ; } var bufferView = processBufferView ( attribute , componentType , start , count , bufferViewTarget ) ; var gltfAccessor = { bufferView : bufferView . id , byteOffset : bufferView . byteOffset , componentType : componentType , count : count , max : minMax . max , min : minMax . min , type : types [ attribute . itemSize ] } ; if ( ! outputJSON . accessors ) { outputJSON . accessors = [ ] ; } outputJSON . accessors . push ( gltfAccessor ) ; return outputJSON . accessors . length - 1 ; }
Process attribute to generate an accessor
@param  {THREE.BufferAttribute} attribute Attribute to process
@param  {THREE.BufferGeometry} geometry (Optional) Geometry used for truncated draw range
@param  {Integer} start (Optional)
@param  {Integer} count (Optional)
@return {Integer}           Index of the processed accessor on the "accessors" array
Process attribute to generate an accessor