src/room.js
function _getCoefficientsFromMaterials(materials) {
  // Initialize coefficients to use defaults.
  let coefficients = {};
  for (let property in Utils.DEFAULT_ROOM_MATERIALS) {
    if (Utils.DEFAULT_ROOM_MATERIALS.hasOwnProperty(property)) {
      coefficients[property] = Utils.ROOM_MATERIAL_COEFFICIENTS[
        Utils.DEFAULT_ROOM_MATERIALS[property]];
    }
  }

  // Sanitize materials.
  if (materials == undefined) {
    materials = {};
    Object.assign(materials, Utils.DEFAULT_ROOM_MATERIALS);
  }

  // Assign coefficients using provided materials.
  for (let property in Utils.DEFAULT_ROOM_MATERIALS) {
    if (Utils.DEFAULT_ROOM_MATERIALS.hasOwnProperty(property) &&
        materials.hasOwnProperty(property)) {
      if (materials[property] in Utils.ROOM_MATERIAL_COEFFICIENTS) {
        coefficients[property] =
          Utils.ROOM_MATERIAL_COEFFICIENTS[materials[property]];
      } else {
        Utils.log('Material \"' + materials[property] + '\" on wall \"' +
          property + '\" not found. Using \"' +
          Utils.DEFAULT_ROOM_MATERIALS[property] + '\".');
      }
    } else {
      Utils.log('Wall \"' + property + '\" is not defined. Default used.');
    }
  }
  return coefficients;
}
function _getCoefficientsFromMaterials(materials) {
  // Initialize coefficients to use defaults.
  let coefficients = {};
  for (let property in Utils.DEFAULT_ROOM_MATERIALS) {
    if (Utils.DEFAULT_ROOM_MATERIALS.hasOwnProperty(property)) {
      coefficients[property] = Utils.ROOM_MATERIAL_COEFFICIENTS[
        Utils.DEFAULT_ROOM_MATERIALS[property]];
    }
  }

  // Sanitize materials.
  if (materials == undefined) {
    materials = {};
    Object.assign(materials, Utils.DEFAULT_ROOM_MATERIALS);
  }

  // Assign coefficients using provided materials.
  for (let property in Utils.DEFAULT_ROOM_MATERIALS) {
    if (Utils.DEFAULT_ROOM_MATERIALS.hasOwnProperty(property) &&
        materials.hasOwnProperty(property)) {
      if (materials[property] in Utils.ROOM_MATERIAL_COEFFICIENTS) {
        coefficients[property] =
          Utils.ROOM_MATERIAL_COEFFICIENTS[materials[property]];
      } else {
        Utils.log('Material \"' + materials[property] + '\" on wall \"' +
          property + '\" not found. Using \"' +
          Utils.DEFAULT_ROOM_MATERIALS[property] + '\".');
      }
    } else {
      Utils.log('Wall \"' + property + '\" is not defined. Default used.');
    }
  }
  return coefficients;
}
function _getCoefficientsFromMaterials ( materials ) { // Initialize coefficients to use defaults. let coefficients = { } ; for ( let property in Utils . DEFAULT_ROOM_MATERIALS ) { if ( Utils . DEFAULT_ROOM_MATERIALS . hasOwnProperty ( property ) ) { coefficients [ property ] = Utils . ROOM_MATERIAL_COEFFICIENTS [ Utils . DEFAULT_ROOM_MATERIALS [ property ] ] ; } } // Sanitize materials. if ( materials == undefined ) { materials = { } ; Object . assign ( materials , Utils . DEFAULT_ROOM_MATERIALS ) ; } // Assign coefficients using provided materials. for ( let property in Utils . DEFAULT_ROOM_MATERIALS ) { if ( Utils . DEFAULT_ROOM_MATERIALS . hasOwnProperty ( property ) && materials . hasOwnProperty ( property ) ) { if ( materials [ property ] in Utils . ROOM_MATERIAL_COEFFICIENTS ) { coefficients [ property ] = Utils . ROOM_MATERIAL_COEFFICIENTS [ materials [ property ] ] ; } else { Utils . log ( 'Material \"' + materials [ property ] + '\" on wall \"' + property + '\" not found. Using \"' + Utils . DEFAULT_ROOM_MATERIALS [ property ] + '\".' ) ; } } else { Utils . log ( 'Wall \"' + property + '\" is not defined. Default used.' ) ; } } return coefficients ; }
Generate absorption coefficients from material names.
@param {Object} materials
@return {Object}
Generate absorption coefficients from material names .