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

100% Statements 10/10
100% Branches 4/4
100% Functions 5/5
100% Lines 10/10

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                          2864x 22x   2864x 2993x   2864x 552x     2864x   2864x       6431x 6431x            
import ForEach from "./ForEach.js";
import defined from "../../Core/defined.js";
 
/**
 * Adds extras._pipeline to each object that can have extras in the glTF asset.
 * This stage runs before updateVersion and handles both glTF 1.0 and glTF 2.0 assets.
 *
 * @param {object} gltf A javascript object containing a glTF asset.
 * @returns {object} The glTF asset with the added pipeline extras.
 *
 * @private
 */
function addPipelineExtras(gltf) {
  ForEach.shader(gltf, function (shader) {
    addExtras(shader);
  });
  ForEach.buffer(gltf, function (buffer) {
    addExtras(buffer);
  });
  ForEach.image(gltf, function (image) {
    addExtras(image);
  });
 
  addExtras(gltf);
 
  return gltf;
}
 
function addExtras(object) {
  object.extras = defined(object.extras) ? object.extras : {};
  object.extras._pipeline = defined(object.extras._pipeline)
    ? object.extras._pipeline
    : {};
}
 
export default addPipelineExtras;