All files / engine/Source/Scene/GltfPipeline removePipelineExtras.js

85.71% Statements 12/14
50% Branches 3/6
80% Functions 4/5
85.71% Lines 12/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                        1647x     1647x 1776x   1647x 411x     1647x   1647x       3834x       3834x 3834x     3834x 3834x          
import ForEach from "./ForEach.js";
import defined from "../../Core/defined.js";
 
/**
 * Iterate through the objects within the glTF and delete their pipeline extras object.
 *
 * @param {object} gltf A javascript object containing a glTF asset.
 * @returns {object} glTF with no pipeline extras.
 *
 * @private
 */
function removePipelineExtras(gltf) {
  ForEach.shader(gltf, function (shader) {
    removeExtras(shader);
  });
  ForEach.buffer(gltf, function (buffer) {
    removeExtras(buffer);
  });
  ForEach.image(gltf, function (image) {
    removeExtras(image);
  });
 
  removeExtras(gltf);
 
  return gltf;
}
 
function removeExtras(object) {
  Iif (!defined(object.extras)) {
    return;
  }
 
  Eif (defined(object.extras._pipeline)) {
    delete object.extras._pipeline;
  }
 
  Eif (Object.keys(object.extras).length === 0) {
    delete object.extras;
  }
}
 
export default removePipelineExtras;