<commit_before>import { Bone } from "./Bone";
import { TfConstraintData } from "./TfConstraintData";
import { PathConstraintData } from "./PathConstraintData";
import { DeformAniData } from "./DeformAniData";
import { DeformSlotData } from "./DeformSlotData";
import { DeformSlotDisplayData } from "./DeformSlotDisplayData";
import { DrawOrderData } from "./DrawOrderData";
import { EventData } from "./EventData";
import { AnimationContent } from "../AnimationContent"
import { AnimationTemplet } from "../AnimationTemplet"
import { BoneSlot } from "./BoneSlot"
import { SkinData } from "./SkinData"
import { SkinSlotDisplayData } from "./SkinSlotDisplayData"
import { SlotData } from "./SlotData"
import { Transform } from "./Transform"
import { IkConstraintData } from "./IkConstraintData"
import { Texture } from "../../resource/Texture";
import { Matrix } from "../../maths/Matrix";
import { Handler } from "../../utils/Handler";
import { Event } from "../../events/Event";
import { Byte } from "../../utils/Byte";
import { Graphics } from "../../display/Graphics";
import { IAniLib } from "../AniLibPack";
import { Skeleton } from "./Skeleton";
import { ILaya } from "../../../ILaya";

/**数据解析完成后的调度。
 * @eventType Event.COMPLETE
 * */
/*[Event(name = "complete", type = "laya.events.Event.COMPLETE", desc = "数据解析完成后的调度")]*/
/**数据解析错误后的调度。
 * @eventType Event.ERROR
 * */
/*[Event(name = "error", type = "laya.events.Event.ERROR", desc = "数据解析错误后的调度")]*/
/**
 * 动画模板类
 */
export class Templet extends AnimationTemplet {
	/**@internal */
	static LAYA_ANIMATION_160_VISION: string = "LAYAANIMATION:1.6.0";
	/**@internal */
	static LAYA_ANIMATION_VISION: string = "LAYAANIMATION:1.7.0";
	/**@internal */
	static TEMPLET_DICTIONARY: any;

	private _mainTexture: Texture;
	private _graphicsCache: any[] = [];

	/** 存放原始骨骼信息 */
	srcBoneMatrixArr: any[] = [];
	/** IK数据 */
	ikArr: any[] = [];
	/** transform数据 */
	tfArr: any[] = [];
	/** path数据 */
	pathArr: any[] = [];
	/** 存放插槽数据的字典 */
	boneSlotDic: any = {};
	/** 绑定插槽数据的字典 */
	bindBoneBoneSlotDic: any = {};
	/** 存放插糟数据的数组 */
	boneSlotArray: any[] = [];
	/** 皮肤数据 */
	skinDataArray: any[] = [];
	/** 皮肤的字典数据 */
	skinDic: any = {};
	/** 存放纹理数据 */
	subTextureDic: any = {};
	/** 是否解析失败 */
	isParseFail: boolean = false;
	/** 反转矩阵，有些骨骼动画要反转才能显示 */
	yReverseMatrix: Matrix;
	/** 渲染顺序动画数据 */
	drawOrderAniArr: any[] = [];
	/** 事件动画数据 */
	eventAniArr: any[] = [];
	/** @private 索引对应的名称 */
	attachmentNames: any[] = null;
	/** 顶点动画数据 */
	deformAniArr: any[] = [];
	/** 实际显示对象列表，用于销毁用 */
	skinSlotDisplayDataArr: SkinSlotDisplayData[] = [];

	/** 是否需要解析audio数据 */
	private _isParseAudio: boolean = false;
	private _isDestroyed: boolean = false;
	private _rate: number = 30;
	isParserComplete: boolean = false;
	aniSectionDic: any = {};
	private _skBufferUrl: string;
	private _textureDic: any = {};
	private _loadList: any[];
	private _path: string;
	private _relativeUrl: string;
	/**@private */
	tMatrixDataLen: number;

	mRootBone: Bone;
	mBoneArr: Bone[] = [];

	loadAni(url: string): void {
		this._skBufferUrl = url;
		ILaya.loader.load(url, Handler.create(this, this.onComplete), null, ILaya.Loader.BUFFER);
	}

	private onComplete(content: any = null): void {
		if (this._isDestroyed) {
			this.destroy();
			return;
		}

		var tSkBuffer: ArrayBuffer = ILaya.Loader.getRes(this._skBufferUrl);
		if (!tSkBuffer) {
			this.event(Event.ERROR, "load failed:" + this._skBufferUrl);
			return;
		}
		this._path = this._skBufferUrl.slice(0, this._skBufferUrl.lastIndexOf("/")) + "/";
		this.parseData(null, tSkBuffer);
	}

	/**
	 * 解析骨骼动画数据
	 * @param	texture			骨骼动画用到的纹理
	 * @param	skeletonData	骨骼动画信息及纹理分块信息
	 * @param	playbackRate	缓冲的帧率数据（会根据帧率去分帧）
	 */
	parseData(texture: Texture, skeletonData: ArrayBuffer, playbackRate: number = 30): void {
		if (!this._path) {
			var s1: string = (this._relativeUrl || this.url);

			if (s1) {
				var p1: number = s1.lastIndexOf('/');
				if (p1 > 0) {
					this._path = s1.slice(0, p1) + "/";
				} else {
					this._path = '';
				}
			}
		}

		this._mainTexture = texture;
		this._rate = playbackRate;
		this.parse(skeletonData);
	}

	/**
	 * 创建动画
	 * 0,使用模板缓冲的数据，模板缓冲的数据，不允许修改					（内存开销小，计算开销小，不支持换装）
	 * 1,使用动画自己的缓冲区，每个动画都会有自己的缓冲区，相当耗费内存	（内存开销大，计算开销小，支持换装）
	 * 2,使用动态方式，去实时去画										（内存开销小，计算开销大，支持换装,不建议使用）
	 * @param	aniMode 0	动画模式，0:不支持换装,1,2支持换装
	 * @return
	 */
	buildArmature(aniMode: number = 0): Skeleton {
		return new IAniLib.Skeleton(this, aniMode);
	}

		/**
		 * @private
		 * 解析动画
		 * @param	data			解析的二进制数据
		 * @param	playbackRate	帧率
		 * @override
		 */
		parse(data: ArrayBuffer): void {<commit_msg>GL  优化代码<commit_after>import { Bone } from "./Bone";
import { TfConstraintData } from "./TfConstraintData";
import { PathConstraintData } from "./PathConstraintData";
import { DeformAniData } from "./DeformAniData";
import { DeformSlotData } from "./DeformSlotData";
import { DeformSlotDisplayData } from "./DeformSlotDisplayData";
import { DrawOrderData } from "./DrawOrderData";
import { EventData } from "./EventData";
import { AnimationContent } from "../AnimationContent"
import { AnimationTemplet } from "../AnimationTemplet"
import { BoneSlot } from "./BoneSlot"
import { SkinData } from "./SkinData"
import { SkinSlotDisplayData } from "./SkinSlotDisplayData"
import { SlotData } from "./SlotData"
import { Transform } from "./Transform"
import { IkConstraintData } from "./IkConstraintData"
import { Texture } from "../../resource/Texture";
import { Matrix } from "../../maths/Matrix";
import { Handler } from "../../utils/Handler";
import { Event } from "../../events/Event";
import { Byte } from "../../utils/Byte";
import { Graphics } from "../../display/Graphics";
import { IAniLib } from "../AniLibPack";
import { Skeleton } from "./Skeleton";
import { ILaya } from "../../../ILaya";

/**数据解析完成后的调度。
 * @eventType Event.COMPLETE
 * */
/*[Event(name = "complete", type = "laya.events.Event.COMPLETE", desc = "数据解析完成后的调度")]*/
/**数据解析错误后的调度。
 * @eventType Event.ERROR
 * */
/*[Event(name = "error", type = "laya.events.Event.ERROR", desc = "数据解析错误后的调度")]*/
/**
 * 动画模板类
 */
export class Templet extends AnimationTemplet {
	/**@internal */
	static LAYA_ANIMATION_160_VISION: string = "LAYAANIMATION:1.6.0";
	/**@internal */
	static LAYA_ANIMATION_VISION: string = "LAYAANIMATION:1.7.0";
	/**@internal */
	static TEMPLET_DICTIONARY: any;

	private _mainTexture: Texture;
	private _graphicsCache: any[] = [];

	/** 存放原始骨骼信息 */
	srcBoneMatrixArr: any[] = [];
	/** IK数据 */
	ikArr: any[] = [];
	/** transform数据 */
	tfArr: any[] = [];
	/** path数据 */
	pathArr: any[] = [];
	/** 存放插槽数据的字典 */
	boneSlotDic: any = {};
	/** 绑定插槽数据的字典 */
	bindBoneBoneSlotDic: any = {};
	/** 存放插糟数据的数组 */
	boneSlotArray: any[] = [];
	/** 皮肤数据 */
	skinDataArray: any[] = [];
	/** 皮肤的字典数据 */
	skinDic: any = {};
	/** 存放纹理数据 */
	subTextureDic: any = {};
	/** 是否解析失败 */
	isParseFail: boolean = false;
	/** 反转矩阵，有些骨骼动画要反转才能显示 */
	yReverseMatrix: Matrix;
	/** 渲染顺序动画数据 */
	drawOrderAniArr: any[] = [];
	/** 事件动画数据 */
	eventAniArr: any[] = [];
	/** @private 索引对应的名称 */
	attachmentNames: any[] = null;
	/** 顶点动画数据 */
	deformAniArr: any[] = [];
	/** 实际显示对象列表，用于销毁用 */
	skinSlotDisplayDataArr: SkinSlotDisplayData[] = [];

	/** 是否需要解析audio数据 */
	private _isParseAudio: boolean = false;
	private _isDestroyed: boolean = false;
	private _rate: number = 30;
	isParserComplete: boolean = false;
	aniSectionDic: any = {};
	private _skBufferUrl: string;
	private _textureDic: any = {};
	private _loadList: any[];
	private _path: string;
	private _relativeUrl: string;
	/**@private */
	tMatrixDataLen: number;

	mRootBone: Bone;
	mBoneArr: Bone[] = [];

	loadAni(url: string): void {
		this._skBufferUrl = url;
		ILaya.loader.load(url, Handler.create(this, this.onComplete), null, ILaya.Loader.BUFFER);
	}

	private onComplete(content: any = null): void {
		if (this._isDestroyed) {
			this.destroy();
			return;
		}

		var tSkBuffer: ArrayBuffer = ILaya.Loader.getRes(this._skBufferUrl);
		if (!tSkBuffer) {
			this.event(Event.ERROR, "load failed:" + this._skBufferUrl);
			return;
		}
		this._path = this._skBufferUrl.slice(0, this._skBufferUrl.lastIndexOf("/")) + "/";
		this.parseData(null, tSkBuffer);
	}

	/**
	 * 解析骨骼动画数据
	 * @param	texture			骨骼动画用到的纹理
	 * @param	skeletonData	骨骼动画信息及纹理分块信息
	 * @param	playbackRate	缓冲的帧率数据（会根据帧率去分帧）
	 */
	parseData(texture: Texture, skeletonData: ArrayBuffer, playbackRate: number = 30): void {
		if (!this._path) {
			var s1: string = (this._relativeUrl || this.url);

			if (s1) {
				var p1: number = s1.lastIndexOf('/');
				if (p1 > 0) {
					this._path = s1.slice(0, p1) + "/";
				} else {
					this._path = '';
				}
			}
		}

		this._mainTexture = texture;
		this._rate = playbackRate;
		this.parse(skeletonData);
	}

	/**
	 * 创建动画
	 * 0,使用模板缓冲的数据，模板缓冲的数据，不允许修改					（内存开销小，计算开销小，不支持换装）
	 * 1,使用动画自己的缓冲区，每个动画都会有自己的缓冲区，相当耗费内存	（内存开销大，计算开销小，支持换装）
	 * 2,使用动态方式，去实时去画										（内存开销小，计算开销大，支持换装,不建议使用）
	 * @param	aniMode 0	动画模式，0:不支持换装,1,2支持换装
	 * @return
	 */
	buildArmature(aniMode: number = 0): Skeleton {
		return new Skeleton(this, aniMode);
	}

		/**
		 * @private
		 * 解析动画
		 * @param	data			解析的二进制数据
		 * @param	playbackRate	帧率
		 * @override
		 */
		parse(data: ArrayBuffer): void {
{'fraction_non_alphanumeric': 0.176342919153554, 'fraction_numerical': 0.006728160607704829, 'mean_word_length': 3.678172588832487, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4722645', 'n_tokens_mistral': 3979, 'n_tokens_neox': 3901, 'n_words': 699}