import {BaseSopOperation} from "./_Base";
import {InputCloneMode as InputCloneMode2} from "../../../engine/poly/InputCloneMode";
export class ObjectPropertiesSopOperation extends BaseSopOperation {
  static type() {
    return "objectProperties";
  }
  cook(input_contents, params) {
    const core_group = input_contents[0];
    for (let object of core_group.objects()) {
      if (params.applyToChildren) {
        object.traverse((child) => {
          this._update_object(child, params);
        });
      } else {
        this._update_object(object, params);
      }
    }
    return core_group;
  }
  _update_object(object, params) {
    if (params.tname) {
      object.name = params.name;
    }
    if (params.trenderOrder) {
      object.renderOrder = params.renderOrder;
    }
    if (params.tfrustumCulled) {
      object.frustumCulled = params.frustumCulled;
    }
    if (params.tmatrixAutoUpdate) {
      object.matrixAutoUpdate = params.matrixAutoUpdate;
    }
    if (params.tvisible) {
      object.visible = params.visible;
    }
    if (params.tcastShadow) {
      object.castShadow = params.castShadow;
    }
    if (params.treceiveShadow) {
      object.receiveShadow = params.receiveShadow;
    }
  }
}
ObjectPropertiesSopOperation.DEFAULT_PARAMS = {
  applyToChildren: false,
  tname: false,
  name: "",
  trenderOrder: false,
  renderOrder: 0,
  tfrustumCulled: false,
  frustumCulled: true,
  tmatrixAutoUpdate: false,
  matrixAutoUpdate: false,
  tvisible: false,
  visible: true,
  tcastShadow: false,
  castShadow: true,
  treceiveShadow: false,
  receiveShadow: true
};
ObjectPropertiesSopOperation.INPUT_CLONED_STATE = InputCloneMode2.FROM_NODE;
