parseProperty method

dynamic parseProperty(
  1. dynamic reader
)

Implementation

parseProperty(reader) {
  var type = reader.getString(1);
  var length;

  switch (type) {
    case 'C':
      return reader.getBoolean();

    case 'D':
      return reader.getFloat64();

    case 'F':
      return reader.getFloat32();

    case 'I':
      return reader.getInt32();

    case 'L':
      return reader.getInt64();

    case 'R':
      length = reader.getUint32();
      return reader.getArrayBuffer(length);

    case 'S':
      length = reader.getUint32();
      return reader.getString(length);

    case 'Y':
      return reader.getInt16();

    case 'b':
    case 'c':
    case 'd':
    case 'f':
    case 'i':
    case 'l':
      var arrayLength = reader.getUint32();
      var encoding = reader.getUint32(); // 0: non-compressed, 1: compressed
      var compressedLength = reader.getUint32();

      if (encoding == 0) {
        switch (type) {
          case 'b':
          case 'c':
            return reader.getBooleanArray(arrayLength);

          case 'd':
            return reader.getFloat64Array(arrayLength);

          case 'f':
            return reader.getFloat32Array(arrayLength);

          case 'i':
            return reader.getInt32Array(arrayLength);

          case 'l':
            return reader.getInt64Array(arrayLength);
        }
      }

      // https://pub.dev/packages/archive
      // use archive replace fflate.js
      // var data = fflate.unzlibSync( new Uint8Array( reader.getArrayBuffer( compressedLength ) ) ); // eslint-disable-line no-undef

      var data = ZLibDecoder()
          .decodeBytes(reader.getArrayBuffer(compressedLength), verify: true);
      var reader2 = new BinaryReader(data);

      switch (type) {
        case 'b':
        case 'c':
          return reader2.getBooleanArray(arrayLength);

        case 'd':
          return reader2.getFloat64Array(arrayLength);

        case 'f':
          return reader2.getFloat32Array(arrayLength);

        case 'i':
          return reader2.getInt32Array(arrayLength);

        case 'l':
          return reader2.getInt64Array(arrayLength);
      }
      break;

    default:
      throw ('THREE.FBXLoader: Unknown property type ' + type);
  }
}