{"version":3,"file":"InstructionSet.mjs","sources":["../../../../../src/rendering/renderers/shared/instructions/InstructionSet.ts"],"sourcesContent":["import { uid } from '../../../../utils/data/uid';\n\nimport type { Renderable } from '../Renderable';\nimport type { Instruction } from './Instruction';\n\n/**\n * A set of instructions that can be executed by the renderer.\n * Basically wraps an array, but with some extra properties that help the renderer\n * to keep things nice and optimised.\n *\n * Note:\n * InstructionSet.instructions contains all the instructions, but does not resize (for performance).\n * So for the true length of the instructions you need to use InstructionSet.instructionSize\n * @category rendering\n * @advanced\n */\nexport class InstructionSet\n{\n    /** a unique id for this instruction set used through the renderer */\n    public readonly uid: number = uid('instructionSet');\n    /** the array of instructions */\n    public readonly instructions: Instruction[] = [];\n    /** the actual size of the array (any instructions passed this should be ignored) */\n    public instructionSize = 0;\n    /** allows for access to the render pipes of the renderer */\n    public renderPipes: any;\n\n    public renderables: Renderable[] = [];\n    /** used by the garbage collector to track when the instruction set was last used */\n    public gcTick = 0;\n\n    /** reset the instruction set so it can be reused set size back to 0 */\n    public reset()\n    {\n        this.instructionSize = 0;\n    }\n\n    /**\n     * Destroy the instruction set, clearing the instructions and renderables.\n     * @internal\n     */\n    public destroy()\n    {\n        this.instructions.length = 0;\n        this.renderables.length = 0;\n\n        this.renderPipes = null;\n        this.gcTick = 0;\n    }\n\n    /**\n     * Add an instruction to the set\n     * @param instruction - add an instruction to the set\n     */\n    public add(instruction: Instruction)\n    {\n        this.instructions[this.instructionSize++] = instruction;\n    }\n\n    /**\n     * Log the instructions to the console (for debugging)\n     * @internal\n     */\n    public log()\n    {\n        this.instructions.length = this.instructionSize;\n        // eslint-disable-next-line no-console\n        console.table(this.instructions, ['type', 'action']);\n    }\n}\n"],"names":[],"mappings":";;;AAgBO,MAAM,cAAA,CACb;AAAA,EADO,WAAA,GAAA;AAGH;AAAA,IAAA,IAAA,CAAgB,GAAA,GAAc,IAAI,gBAAgB,CAAA;AAElD;AAAA,IAAA,IAAA,CAAgB,eAA8B,EAAC;AAE/C;AAAA,IAAA,IAAA,CAAO,eAAA,GAAkB,CAAA;AAIzB,IAAA,IAAA,CAAO,cAA4B,EAAC;AAEpC;AAAA,IAAA,IAAA,CAAO,MAAA,GAAS,CAAA;AAAA,EAAA;AAAA;AAAA,EAGT,KAAA,GACP;AACI,IAAA,IAAA,CAAK,eAAA,GAAkB,CAAA;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,OAAA,GACP;AACI,IAAA,IAAA,CAAK,aAAa,MAAA,GAAS,CAAA;AAC3B,IAAA,IAAA,CAAK,YAAY,MAAA,GAAS,CAAA;AAE1B,IAAA,IAAA,CAAK,WAAA,GAAc,IAAA;AACnB,IAAA,IAAA,CAAK,MAAA,GAAS,CAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,IAAI,WAAA,EACX;AACI,IAAA,IAAA,CAAK,YAAA,CAAa,IAAA,CAAK,eAAA,EAAiB,CAAA,GAAI,WAAA;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,GAAA,GACP;AACI,IAAA,IAAA,CAAK,YAAA,CAAa,SAAS,IAAA,CAAK,eAAA;AAEhC,IAAA,OAAA,CAAQ,MAAM,IAAA,CAAK,YAAA,EAAc,CAAC,MAAA,EAAQ,QAAQ,CAAC,CAAA;AAAA,EACvD;AACJ;;;;"}