<commit_before>import MaterialFactory from "./MaterialFactory";
import ITechniqueRecipe from "./ITechniqueRecipe";
import Technique from "./Technique";
import IAttributeDeclaration from "grimoirejs/ref/Node/IAttributeDeclaration";
import IMaterialArgument from "./IMaterialArgument";
import Pass from "./Pass";
/**
 * Provides abstraction of configurations for multiple shaders.
 */
export default class Material {

    public techniques: { [key: string]: Technique } = {};

    constructor(public gl: WebGLRenderingContext, public techniqueRecipes: { [key: string]: ITechniqueRecipe }) {
        for (let key in techniqueRecipes) {
            this.techniques[key] = new Technique(this, techniqueRecipes[key]);
        }
    }

    public draw(arg: IMaterialArgument): void {
        const technique = this.techniques[arg.technique];
        if (technique) {
            technique.draw(arg);
        }
    }

    /**
     * Clone this material to new instance.
     * @return {Material} new material instance
     */
    public clone(): Material {
        const cloned = new Material(this.gl, this.techniqueRecipes);
        throw new Error("Non implemented"); // TODO
        // return cloned;
    }
}<commit_msg>fix: Reimplemented clone() of Material<commit_after>import MaterialFactory from "./MaterialFactory";
import ITechniqueRecipe from "./ITechniqueRecipe";
import Technique from "./Technique";
import IAttributeDeclaration from "grimoirejs/ref/Node/IAttributeDeclaration";
import IMaterialArgument from "./IMaterialArgument";
import Pass from "./Pass";
/**
 * Provides abstraction of configurations for multiple shaders.
 */
export default class Material {

    public techniques: { [key: string]: Technique } = {};

    constructor(public gl: WebGLRenderingContext, public techniqueRecipes: { [key: string]: ITechniqueRecipe }) {
        for (let key in techniqueRecipes) {
            this.techniques[key] = new Technique(this, techniqueRecipes[key]);
        }
    }

    public draw(arg: IMaterialArgument): void {
        const technique = this.techniques[arg.technique];
        if (technique) {
            technique.draw(arg);
        }
    }

    /**
     * Clone this material to new instance.
     * @return {Material} new material instance
     */
    public clone(): Material {
        const cloned = new Material(this.gl, this.techniqueRecipes);
        for (let techniqueKey in this.techniques) {
          const technique = this.techniques[techniqueKey];
          const destTechnique = cloned.techniques[techniqueKey];
          for (let passIndex in technique.passes) {
            const pass = technique.passes[passIndex];
            const destPass = destTechnique.passes[passIndex];
            for (let argument in pass.arguments) {
              destPass[argument] = pass[argument];
            }
          }
        }
        return cloned;
    }
}
{'fraction_non_alphanumeric': 0.1051353226925746, 'fraction_numerical': 0.0, 'mean_word_length': 2.9224489795918367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7555355', 'n_tokens_mistral': 768, 'n_tokens_neox': 747, 'n_words': 214}