How to use the @xviz/io.encodeBinaryXVIZ function in @xviz/io

To help you get started, we’ve selected a few @xviz/io examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / xviz / test / modules / io / writers / xviz-encode-parse.spec.js View on Github external
test('XVIZLoader#encode-and-parse', t => {
  for (const tcName in TEST_CASES) {
    const TEST_JSON = TEST_CASES[tcName];

    const glbFileBuffer = encodeBinaryXVIZ(TEST_JSON, {flattenArrays: true});
    const json = parseBinaryXVIZ(glbFileBuffer);

    t.ok(
      !Array.isArray(json.buffers),
      `${tcName} Encoded and parsed XVIZ - has no JSON buffers field`
    );
    t.ok(
      !Array.isArray(json.bufferViews),
      `${tcName} Encoded and parsed XVIZ - has no JSON bufferViews field`
    );
    t.ok(
      !Array.isArray(json.accessors),
      `${tcName} Encoded and parsed XVIZ - has no JSON accessors field`
    );

    // const reference = toLowPrecision(packJsonArrays(TEST_JSON));
github uber / xviz / test / modules / io / writers / xviz-encode-parse.spec.js View on Github external
const extensionArrayBuffer = encodeSync(
    {json: extensionGlbJsonObject, binary: BINARY_GLB_CHUNK},
    GLBWriter,
    {}
  );

  const extensionJson = parseBinaryXVIZ(extensionArrayBuffer);

  delete extensionJson.data.updates[0].primitives['/object/points'].points[0].colors.accessor;

  t.deepEqual(extensionJson, EXPECTED_STATE_UPDATE, 'Parse extension GLB correctly');

  // Now make sure we are using the XVIZ extension
  const options = {useAVSXVIZExtension: true};
  const encodedArrayBuffer = encodeBinaryXVIZ(EXPECTED_STATE_UPDATE, options);
  const resultStr = buffer2String(encodedArrayBuffer);

  t.notEqual(-1, resultStr.indexOf(XVIZ_GLTF_EXTENSION), 'AVS extension encoding check');

  t.end();
});
github uber / xviz / test / modules / io / writers / xviz-encode-parse.spec.js View on Github external
type: 'points3d',
    color: [255, 0, 0, 255],
    vertices: new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9]),
    reflectance: new Float32Array([9, 8, 7])
  };

  const frame = {
    state_updates: [
      {
        timestamps: 1317042272459,
        primitives: {}
      }
    ]
  };

  const xvizBinary = encodeBinaryXVIZ(sample_lidar, options);
  const xvizBinaryDecoded = parseBinaryXVIZ(xvizBinary);

  validateLidarData(t, xvizBinaryDecoded);

  frame.state_updates[0].primitives.lidarPoints = xvizBinaryDecoded;

  const frameBinary = encodeBinaryXVIZ(frame, options);
  t.equal(frameBinary.byteLength, 584);

  const xvizBinaryDecoded2 = parseBinaryXVIZ(frameBinary);
  const lidar = xvizBinaryDecoded2.state_updates[0].primitives.lidarPoints;
  validateLidarData(t, xvizBinaryDecoded);

  t.end();
});
github uber / xviz / test / modules / io / writers / xviz-encode-parse.spec.js View on Github external
state_updates: [
      {
        timestamps: 1317042272459,
        primitives: {}
      }
    ]
  };

  const xvizBinary = encodeBinaryXVIZ(sample_lidar, options);
  const xvizBinaryDecoded = parseBinaryXVIZ(xvizBinary);

  validateLidarData(t, xvizBinaryDecoded);

  frame.state_updates[0].primitives.lidarPoints = xvizBinaryDecoded;

  const frameBinary = encodeBinaryXVIZ(frame, options);
  t.equal(frameBinary.byteLength, 584);

  const xvizBinaryDecoded2 = parseBinaryXVIZ(frameBinary);
  const lidar = xvizBinaryDecoded2.state_updates[0].primitives.lidarPoints;
  validateLidarData(t, xvizBinaryDecoded);

  t.end();
});