<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">! function(e, t) {
    "use strict";
    class r {
        constructor() {}
        static isZero(e) {
            return Math.abs(e) &lt; r.zeroTolerance
        }
        static nearEqual(e, t) {
            return !!r.isZero(e - t)
        }
        static fastInvSqrt(e) {
            return r.isZero(e) ? e : 1 / Math.sqrt(e)
        }
    }
    r.zeroTolerance = 1e-6, r.MaxValue = 3.40282347e38, r.MinValue = -3.40282347e38, r.Deg2Rad = Math.PI / 180;
    class i {
        constructor(e = 0, t = 0) {
            this.x = e, this.y = t
        }
        setValue(e, t) {
            this.x = e, this.y = t
        }
        static scale(e, t, r) {
            r.x = e.x * t, r.y = e.y * t
        }
        fromArray(e, t = 0) {
            this.x = e[t + 0], this.y = e[t + 1]
        }
        cloneTo(e) {
            var t = e;
            t.x = this.x, t.y = this.y
        }
        static dot(e, t) {
            return e.x * t.x + e.y * t.y
        }
        static normalize(e, t) {
            var r = e.x,
                i = e.y,
                n = r * r + i * i;
            n &gt; 0 &amp;&amp; (n = 1 / Math.sqrt(n), t.x = r * n, t.y = i * n)
        }
        static scalarLength(e) {
            var t = e.x,
                r = e.y;
            return Math.sqrt(t * t + r * r)
        }
        clone() {
            var e = new i;
            return this.cloneTo(e), e
        }
        forNativeElement(e = null) {
            e ? (this.elements = e, this.elements[0] = this.x, this.elements[1] = this.y) : this.elements = new Float32Array([this.x, this.y]), i.rewriteNumProperty(this, "x", 0), i.rewriteNumProperty(this, "y", 1)
        }
        static rewriteNumProperty(e, t, r) {
            Object.defineProperty(e, t, {
                get: function() {
                    return this.elements[r]
                },
                set: function(e) {
                    this.elements[r] = e
                }
            })
        }
    }
    i.ZERO = new i(0, 0), i.ONE = new i(1, 1);
    class n {
        constructor(e = 0, t = 0, r = 0, i = 0) {
            this.x = e, this.y = t, this.z = r, this.w = i
        }
        setValue(e, t, r, i) {
            this.x = e, this.y = t, this.z = r, this.w = i
        }
        fromArray(e, t = 0) {
            this.x = e[t + 0], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3]
        }
        cloneTo(e) {
            var t = e;
            t.x = this.x, t.y = this.y, t.z = this.z, t.w = this.w
        }
        clone() {
            var e = new n;
            return this.cloneTo(e), e
        }
        static lerp(e, t, r, i) {
            var n = e.x,
                a = e.y,
                s = e.z,
                o = e.w;
            i.x = n + r * (t.x - n), i.y = a + r * (t.y - a), i.z = s + r * (t.z - s), i.w = o + r * (t.w - o)
        }
        static transformByM4x4(e, t, r) {
            var i = e.x,
                n = e.y,
                a = e.z,
                s = e.w,
                o = t.elements;
            r.x = i * o[0] + n * o[4] + a * o[8] + s * o[12], r.y = i * o[1] + n * o[5] + a * o[9] + s * o[13], r.z = i * o[2] + n * o[6] + a * o[10] + s * o[14], r.w = i * o[3] + n * o[7] + a * o[11] + s * o[15]
        }
        static equals(e, t) {
            return r.nearEqual(Math.abs(e.x), Math.abs(t.x)) &amp;&amp; r.nearEqual(Math.abs(e.y), Math.abs(t.y)) &amp;&amp; r.nearEqual(Math.abs(e.z), Math.abs(t.z)) &amp;&amp; r.nearEqual(Math.abs(e.w), Math.abs(t.w))
        }
        length() {
            return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
        }
        lengthSquared() {
            return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
        }
        static normalize(e, t) {
            var r = e.length();
            if (r &gt; 0) {
                var i = 1 / r;
                t.x = e.x * i, t.y = e.y * i, t.z = e.z * i, t.w = e.w * i
            }
        }
        static add(e, t, r) {
            r.x = e.x + t.x, r.y = e.y + t.y, r.z = e.z + t.z, r.w = e.w + t.w
        }
        static subtract(e, t, r) {
            r.x = e.x - t.x, r.y = e.y - t.y, r.z = e.z - t.z, r.w = e.w - t.w
        }
        static multiply(e, t, r) {
            r.x = e.x * t.x, r.y = e.y * t.y, r.z = e.z * t.z, r.w = e.w * t.w
        }
        static scale(e, t, r) {
            r.x = e.x * t, r.y = e.y * t, r.z = e.z * t, r.w = e.w * t
        }
        static Clamp(e, t, r, i) {
            var n = e.x,
                a = e.y,
                s = e.z,
                o = e.w,
                l = t.x,
                _ = t.y,
                h = t.z,
                c = t.w,
                d = r.x,
                u = r.y,
                m = r.z,
                f = r.w;
            n = (n = n &gt; d ? d : n) &lt; l ? l : n, a = (a = a &gt; u ? u : a) &lt; _ ? _ : a, s = (s = s &gt; m ? m : s) &lt; h ? h : s, o = (o = o &gt; f ? f : o) &lt; c ? c : o, i.x = n, i.y = a, i.z = s, i.w = o
        }
        static distanceSquared(e, t) {
            var r = e.x - t.x,
                i = e.y - t.y,
                n = e.z - t.z,
                a = e.w - t.w;
            return r * r + i * i + n * n + a * a
        }
        static distance(e, t) {
            var r = e.x - t.x,
                i = e.y - t.y,
                n = e.z - t.z,
                a = e.w - t.w;
            return Math.sqrt(r * r + i * i + n * n + a * a)
        }
        static dot(e, t) {
            return e.x * t.x + e.y * t.y + e.z * t.z + e.w * t.w
        }
        static min(e, t, r) {
            r.x = Math.min(e.x, t.x), r.y = Math.min(e.y, t.y), r.z = Math.min(e.z, t.z), r.w = Math.min(e.w, t.w)
        }
        static max(e, t, r) {
            r.x = Math.max(e.x, t.x), r.y = Math.max(e.y, t.y), r.z = Math.max(e.z, t.z), r.w = Math.max(e.w, t.w)
        }
        forNativeElement(e = null) {
            e ? (this.elements = e, this.elements[0] = this.x, this.elements[1] = this.y, this.elements[2] = this.z, this.elements[3] = this.w) : this.elements = new Float32Array([this.x, this.y, this.z, this.w]), i.rewriteNumProperty(this, "x", 0), i.rewriteNumProperty(this, "y", 1), i.rewriteNumProperty(this, "z", 2), i.rewriteNumProperty(this, "w", 3)
        }
    }
    n.ZERO = new n, n.ONE = new n(1, 1, 1, 1), n.UnitX = new n(1, 0, 0, 0), n.UnitY = new n(0, 1, 0, 0), n.UnitZ = new n(0, 0, 1, 0), n.UnitW = new n(0, 0, 0, 1);
    class a {
        constructor(e = 0, t = 0, r = 0, i = null) {
            this.x = e, this.y = t, this.z = r
        }
        static distanceSquared(e, t) {
            var r = e.x - t.x,
                i = e.y - t.y,
                n = e.z - t.z;
            return r * r + i * i + n * n
        }
        static distance(e, t) {
            var r = e.x - t.x,
                i = e.y - t.y,
                n = e.z - t.z;
            return Math.sqrt(r * r + i * i + n * n)
        }
        static min(e, t, r) {
            r.x = Math.min(e.x, t.x), r.y = Math.min(e.y, t.y), r.z = Math.min(e.z, t.z)
        }
        static max(e, t, r) {
            r.x = Math.max(e.x, t.x), r.y = Math.max(e.y, t.y), r.z = Math.max(e.z, t.z)
        }
        static transformQuat(e, t, r) {
            var i = e.x,
                n = e.y,
                a = e.z,
                s = t.x,
                o = t.y,
                l = t.z,
                _ = t.w,
                h = _ * i + o * a - l * n,
                c = _ * n + l * i - s * a,
                d = _ * a + s * n - o * i,
                u = -s * i - o * n - l * a;
            r.x = h * _ + u * -s + c * -l - d * -o, r.y = c * _ + u * -o + d * -s - h * -l, r.z = d * _ + u * -l + h * -o - c * -s
        }
        static scalarLength(e) {
            var t = e.x,
                r = e.y,
                i = e.z;
            return Math.sqrt(t * t + r * r + i * i)
        }
        static scalarLengthSquared(e) {
            var t = e.x,
                r = e.y,
                i = e.z;
            return t * t + r * r + i * i
        }
        static normalize(e, t) {
            var r = e.x,
                i = e.y,
                n = e.z,
                a = r * r + i * i + n * n;
            a &gt; 0 &amp;&amp; (a = 1 / Math.sqrt(a), t.x = r * a, t.y = i * a, t.z = n * a)
        }
        static multiply(e, t, r) {
            r.x = e.x * t.x, r.y = e.y * t.y, r.z = e.z * t.z
        }
        static scale(e, t, r) {
            r.x = e.x * t, r.y = e.y * t, r.z = e.z * t
        }
        static lerp(e, t, r, i) {
            var n = e.x,
                a = e.y,
                s = e.z;
            i.x = n + r * (t.x - n), i.y = a + r * (t.y - a), i.z = s + r * (t.z - s)
        }
        static transformV3ToV3(e, t, r) {
            var i = a._tempVector4;
            a.transformV3ToV4(e, t, i), r.x = i.x, r.y = i.y, r.z = i.z
        }
        static transformV3ToV4(e, t, r) {
            var i = e.x,
                n = e.y,
                a = e.z,
                s = t.elements;
            r.x = i * s[0] + n * s[4] + a * s[8] + s[12], r.y = i * s[1] + n * s[5] + a * s[9] + s[13], r.z = i * s[2] + n * s[6] + a * s[10] + s[14], r.w = i * s[3] + n * s[7] + a * s[11] + s[15]
        }
        static TransformNormal(e, t, r) {
            var i = e.x,
                n = e.y,
                a = e.z,
                s = t.elements;
            r.x = i * s[0] + n * s[4] + a * s[8], r.y = i * s[1] + n * s[5] + a * s[9], r.z = i * s[2] + n * s[6] + a * s[10]
        }
        static transformCoordinate(e, t, r) {
            var i = e.x,
                n = e.y,
                a = e.z,
                s = t.elements,
                o = i * s[3] + n * s[7] + a * s[11] + s[15];
            r.x = (i * s[0] + n * s[4] + a * s[8] + s[12]) / o, r.y = (i * s[1] + n * s[5] + a * s[9] + s[13]) / o, r.z = (i * s[2] + n * s[6] + a * s[10] + s[14]) / o
        }
        static Clamp(e, t, r, i) {
            var n = e.x,
                a = e.y,
                s = e.z,
                o = t.x,
                l = t.y,
                _ = t.z,
                h = r.x,
                c = r.y,
                d = r.z;
            n = (n = n &gt; h ? h : n) &lt; o ? o : n, a = (a = a &gt; c ? c : a) &lt; l ? l : a, s = (s = s &gt; d ? d : s) &lt; _ ? _ : s, i.x = n, i.y = a, i.z = s
        }
        static add(e, t, r) {
            r.x = e.x + t.x, r.y = e.y + t.y, r.z = e.z + t.z
        }
        static subtract(e, t, r) {
            r.x = e.x - t.x, r.y = e.y - t.y, r.z = e.z - t.z
        }
        static cross(e, t, r) {
            var i = e.x,
                n = e.y,
                a = e.z,
                s = t.x,
                o = t.y,
                l = t.z;
            r.x = n * l - a * o, r.y = a * s - i * l, r.z = i * o - n * s
        }
        static dot(e, t) {
            return e.x * t.x + e.y * t.y + e.z * t.z
        }
        static equals(e, t) {
            return r.nearEqual(e.x, t.x) &amp;&amp; r.nearEqual(e.y, t.y) &amp;&amp; r.nearEqual(e.z, t.z)
        }
        setValue(e, t, r) {
            this.x = e, this.y = t, this.z = r
        }
        fromArray(e, t = 0) {
            this.x = e[t + 0], this.y = e[t + 1], this.z = e[t + 2]
        }
        cloneTo(e) {
            var t = e;
            t.x = this.x, t.y = this.y, t.z = this.z
        }
        clone() {
            var e = new a;
            return this.cloneTo(e), e
        }
        toDefault() {
            this.x = 0, this.y = 0, this.z = 0
        }
        forNativeElement(e = null) {
            e ? (this.elements = e, this.elements[0] = this.x, this.elements[1] = this.y, this.elements[2] = this.z) : this.elements = new Float32Array([this.x, this.y, this.z]), i.rewriteNumProperty(this, "x", 0), i.rewriteNumProperty(this, "y", 1), i.rewriteNumProperty(this, "z", 2)
        }
    }
    var s, o;
    a._tempVector4 = new n, a._ZERO = new a(0, 0, 0), a._ONE = new a(1, 1, 1), a._NegativeUnitX = new a(-1, 0, 0), a._UnitX = new a(1, 0, 0), a._UnitY = new a(0, 1, 0), a._UnitZ = new a(0, 0, 1), a._ForwardRH = new a(0, 0, -1), a._ForwardLH = new a(0, 0, 1), a._Up = new a(0, 1, 0), (s = e.PBRRenderQuality || (e.PBRRenderQuality = {}))[s.High = 0] = "High", s[s.Low = 1] = "Low";
    class l {
        constructor() {
            var e = this.elements = new Float32Array(9);
            e[0] = 1, e[1] = 0, e[2] = 0, e[3] = 0, e[4] = 1, e[5] = 0, e[6] = 0, e[7] = 0, e[8] = 1
        }
        static createRotationQuaternion(e, t) {
            var r = e.x,
                i = e.y,
                n = e.z,
                a = e.w,
                s = r * r,
                o = i * i,
                l = n * n,
                _ = r * i,
                h = n * a,
                c = n * r,
                d = i * a,
                u = i * n,
                m = r * a,
                f = t.elements;
            f[0] = 1 - 2 * (o + l), f[1] = 2 * (_ + h), f[2] = 2 * (c - d), f[3] = 2 * (_ - h), f[4] = 1 - 2 * (l + s), f[5] = 2 * (u + m), f[6] = 2 * (c + d), f[7] = 2 * (u - m), f[8] = 1 - 2 * (o + s)
        }
        static createFromTranslation(e, t) {
            var r = t.elements;
            r[0] = 1, r[1] = 0, r[2] = 0, r[3] = 0, r[4] = 1, r[5] = 0, r[6] = e.x, r[7] = e.y, r[8] = 1
        }
        static createFromRotation(e, t) {
            var r = t.elements,
                i = Math.sin(e),
                n = Math.cos(e);
            r[0] = n, r[1] = i, r[2] = 0, r[3] = -i, r[4] = n, r[5] = 0, r[6] = 0, r[7] = 0, r[8] = 1
        }
        static createFromScaling(e, t) {
            var r = t.elements;
            r[0] = e.x, r[1] = 0, r[2] = 0, r[3] = 0, r[4] = e.y, r[5] = 0, r[6] = 0, r[7] = 0, r[8] = e.z
        }
        static createFromMatrix4x4(e, t) {
            var r = e.elements,
                i = t.elements;
            i[0] = r[0], i[1] = r[1], i[2] = r[2], i[3] = r[4], i[4] = r[5], i[5] = r[6], i[6] = r[8], i[7] = r[9], i[8] = r[10]
        }
        static multiply(e, t, r) {
            var i = e.elements,
                n = t.elements,
                a = r.elements,
                s = i[0],
                o = i[1],
                l = i[2],
                _ = i[3],
                h = i[4],
                c = i[5],
                d = i[6],
                u = i[7],
                m = i[8],
                f = n[0],
                T = n[1],
                E = n[2],
                p = n[3],
                g = n[4],
                S = n[5],
                R = n[6],
                v = n[7],
                A = n[8];
            a[0] = f * s + T * _ + E * d, a[1] = f * o + T * h + E * v, a[2] = f * l + T * c + E * m, a[3] = p * s + g * _ + S * d, a[4] = p * o + g * h + S * u, a[5] = p * l + g * c + S * m, a[6] = R * s + v * _ + A * d, a[7] = R * o + v * h + A * u, a[8] = R * l + v * c + A * m
        }
        determinant() {
            var e = this.elements,
                t = e[0],
                r = e[1],
                i = e[2],
                n = e[3],
                a = e[4],
                s = e[5],
                o = e[6],
                l = e[7],
                _ = e[8];
            return t * (_ * a - s * l) + r * (-_ * n + s * o) + i * (l * n - a * o)
        }
        translate(e, t) {
            var r = t.elements,
                i = this.elements,
                n = i[0],
                a = i[1],
                s = i[2],
                o = i[3],
                l = i[4],
                _ = i[5],
                h = i[6],
                c = i[7],
                d = i[8],
                u = e.x,
                m = e.y;
            r[0] = n, r[1] = a, r[2] = s, r[3] = o, r[4] = l, r[5] = _, r[6] = u * n + m * o + h, r[7] = u * a + m * l + c, r[8] = u * s + m * _ + d
        }
        rotate(e, t) {
            var r = t.elements,
                i = this.elements,
                n = i[0],
                a = i[1],
                s = i[2],
                o = i[3],
                l = i[4],
                _ = i[5],
                h = i[6],
                c = i[7],
                d = i[8],
                u = Math.sin(e),
                m = Math.cos(e);
            r[0] = m * n + u * o, r[1] = m * a + u * l, r[2] = m * s + u * _, r[3] = m * o - u * n, r[4] = m * l - u * a, r[5] = m * _ - u * s, r[6] = h, r[7] = c, r[8] = d
        }
        scale(e, t) {
            var r = t.elements,
                i = this.elements,
                n = e.x,
                a = e.y;
            r[0] = n * i[0], r[1] = n * i[1], r[2] = n * i[2], r[3] = a * i[3], r[4] = a * i[4], r[5] = a * i[5], r[6] = i[6], r[7] = i[7], r[8] = i[8]
        }
        invert(e) {
            var t = e.elements,
                r = this.elements,
                i = r[0],
                n = r[1],
                a = r[2],
                s = r[3],
                o = r[4],
                l = r[5],
                _ = r[6],
                h = r[7],
                c = r[8],
                d = c * o - l * h,
                u = -c * s + l * _,
                m = h * s - o * _,
                f = i * d + n * u + a * m;
            f || (e = null), f = 1 / f, t[0] = d * f, t[1] = (-c * n + a * h) * f, t[2] = (l * n - a * o) * f, t[3] = u * f, t[4] = (c * i - a * _) * f, t[5] = (-l * i + a * s) * f, t[6] = m * f, t[7] = (-h * i + n * _) * f, t[8] = (o * i - n * s) * f
        }
        transpose(e) {
            var t = e.elements,
                r = this.elements;
            if (e === this) {
                var i = r[1],
                    n = r[2],
                    a = r[5];
                t[1] = r[3], t[2] = r[6], t[3] = i, t[5] = r[7], t[6] = n, t[7] = a
            } else t[0] = r[0], t[1] = r[3], t[2] = r[6], t[3] = r[1], t[4] = r[4], t[5] = r[7], t[6] = r[2], t[7] = r[5], t[8] = r[8]
        }
        identity() {
            var e = this.elements;
            e[0] = 1, e[1] = 0, e[2] = 0, e[3] = 0, e[4] = 1, e[5] = 0, e[6] = 0, e[7] = 0, e[8] = 1
        }
        cloneTo(e) {
            var t, r, i;
            if ((r = this.elements) !== (i = e.elements))
                for (t = 0; t &lt; 9; ++t) i[t] = r[t]
        }
        clone() {
            var e = new l;
            return this.cloneTo(e), e
        }
        static lookAt(e, t, r, i) {
            a.subtract(e, t, l._tempV30), a.normalize(l._tempV30, l._tempV30), a.cross(r, l._tempV30, l._tempV31), a.normalize(l._tempV31, l._tempV31), a.cross(l._tempV30, l._tempV31, l._tempV32);
            var n = l._tempV30,
                s = l._tempV31,
                o = l._tempV32,
                _ = i.elements;
            _[0] = s.x, _[3] = s.y, _[6] = s.z, _[1] = o.x, _[4] = o.y, _[7] = o.z, _[2] = n.x, _[5] = n.y, _[8] = n.z
        }
    }
    l.DEFAULT = new l, l._tempV30 = new a, l._tempV31 = new a, l._tempV32 = new a;
    class _ {}
    _.Shader3D = null, _.Scene3D = null, _.MeshRenderStaticBatchManager = null, _.MeshRenderDynamicBatchManager = null, _.SubMeshDynamicBatch = null, _.Laya3D = null, _.Matrix4x4 = null, _.Physics3D = null, _.ShadowLightType = null;
    class h {
        constructor(e = 0, t = 0, r = 0, i = 1, n = null) {
            this.x = e, this.y = t, this.z = r, this.w = i
        }
        static createFromYawPitchRoll(e, t, r, i) {
            var n = .5 * r,
                a = .5 * t,
                s = .5 * e,
                o = Math.sin(n),
                l = Math.cos(n),
                _ = Math.sin(a),
                h = Math.cos(a),
                c = Math.sin(s),
                d = Math.cos(s);
            i.x = d * _ * l + c * h * o, i.y = c * h * l - d * _ * o, i.z = d * h * o - c * _ * l, i.w = d * h * l + c * _ * o
        }
        static multiply(e, t, r) {
            var i = e.x,
                n = e.y,
                a = e.z,
                s = e.w,
                o = t.x,
                l = t.y,
                _ = t.z,
                h = t.w,
                c = n * _ - a * l,
                d = a * o - i * _,
                u = i * l - n * o,
                m = i * o + n * l + a * _;
            r.x = i * h + o * s + c, r.y = n * h + l * s + d, r.z = a * h + _ * s + u, r.w = s * h - m
        }
        static arcTanAngle(e, t) {
            return 0 == e ? 1 == t ? Math.PI / 2 : -Math.PI / 2 : e &gt; 0 ? Math.atan(t / e) : e &lt; 0 ? t &gt; 0 ? Math.atan(t / e) + Math.PI : Math.atan(t / e) - Math.PI : 0
        }
        static angleTo(e, t, r) {
            a.subtract(t, e, h.TEMPVector30), a.normalize(h.TEMPVector30, h.TEMPVector30), r.x = Math.asin(h.TEMPVector30.y), r.y = h.arcTanAngle(-h.TEMPVector30.z, -h.TEMPVector30.x)
        }
        static createFromAxisAngle(e, t, r) {
            t *= .5;
            var i = Math.sin(t);
            r.x = i * e.x, r.y = i * e.y, r.z = i * e.z, r.w = Math.cos(t)
        }
        static createFromMatrix4x4(e, t) {
            var r, i, n = e.elements,
                a = n[0] + n[5] + n[10];
            a &gt; 0 ? (r = Math.sqrt(a + 1), t.w = .5 * r, r = .5 / r, t.x = (n[6] - n[9]) * r, t.y = (n[8] - n[2]) * r, t.z = (n[1] - n[4]) * r) : n[0] &gt;= n[5] &amp;&amp; n[0] &gt;= n[10] ? (i = .5 / (r = Math.sqrt(1 + n[0] - n[5] - n[10])), t.x = .5 * r, t.y = (n[1] + n[4]) * i, t.z = (n[2] + n[8]) * i, t.w = (n[6] - n[9]) * i) : n[5] &gt; n[10] ? (i = .5 / (r = Math.sqrt(1 + n[5] - n[0] - n[10])), t.x = (n[4] + n[1]) * i, t.y = .5 * r, t.z = (n[9] + n[6]) * i, t.w = (n[8] - n[2]) * i) : (i = .5 / (r = Math.sqrt(1 + n[10] - n[0] - n[5])), t.x = (n[8] + n[2]) * i, t.y = (n[9] + n[6]) * i, t.z = .5 * r, t.w = (n[1] - n[4]) * i)
        }
        static slerp(e, t, r, i) {
            var n, a, s, o, l, _ = e.x,
                h = e.y,
                c = e.z,
                d = e.w,
                u = t.x,
                m = t.y,
                f = t.z,
                T = t.w;
            return (a = _ * u + h * m + c * f + d * T) &lt; 0 &amp;&amp; (a = -a, u = -u, m = -m, f = -f, T = -T), 1 - a &gt; 1e-6 ? (n = Math.acos(a), s = Math.sin(n), o = Math.sin((1 - r) * n) / s, l = Math.sin(r * n) / s) : (o = 1 - r, l = r), i.x = o * _ + l * u, i.y = o * h + l * m, i.z = o * c + l * f, i.w = o * d + l * T, i
        }
        static lerp(e, t, r, i) {
            var n = 1 - r;
            h.dot(e, t) &gt;= 0 ? (i.x = n * e.x + r * t.x, i.y = n * e.y + r * t.y, i.z = n * e.z + r * t.z, i.w = n * e.w + r * t.w) : (i.x = n * e.x - r * t.x, i.y = n * e.y - r * t.y, i.z = n * e.z - r * t.z, i.w = n * e.w - r * t.w), i.normalize(i)
        }
        static add(e, t, r) {
            r.x = e.x + t.x, r.y = e.y + t.y, r.z = e.z + t.z, r.w = e.w + t.w
        }
        static dot(e, t) {
            return e.x * t.x + e.y * t.y + e.z * t.z + e.w * t.w
        }
        scaling(e, t) {
            t.x = this.x * e, t.y = this.y * e, t.z = this.z * e, t.w = this.w * e
        }
        normalize(e) {
            var t = this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
            t &gt; 0 &amp;&amp; (t = 1 / Math.sqrt(t), e.x = this.x * t, e.y = this.y * t, e.z = this.z * t, e.w = this.w * t)
        }
        length() {
            return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
        }
        rotateX(e, t) {
            e *= .5;
            var r = Math.sin(e),
                i = Math.cos(e);
            t.x = this.x * i + this.w * r, t.y = this.y * i + this.z * r, t.z = this.z * i - this.y * r, t.w = this.w * i - this.x * r
        }
        rotateY(e, t) {
            e *= .5;
            var r = Math.sin(e),
                i = Math.cos(e);
            t.x = this.x * i - this.z * r, t.y = this.y * i + this.w * r, t.z = this.z * i + this.x * r, t.w = this.w * i - this.y * r
        }
        rotateZ(e, t) {
            e *= .5;
            var r = Math.sin(e),
                i = Math.cos(e);
            t.x = this.x * i + this.y * r, t.y = this.y * i - this.x * r, t.z = this.z * i + this.w * r, t.w = this.w * i - this.z * r
        }
        getYawPitchRoll(e) {
            a.transformQuat(a._ForwardRH, this, h.TEMPVector31), a.transformQuat(a._Up, this, h.TEMPVector32);
            var t = h.TEMPVector32;
            h.angleTo(a._ZERO, h.TEMPVector31, h.TEMPVector33);
            var r = h.TEMPVector33;
            r.x == Math.PI / 2 ? (r.y = h.arcTanAngle(t.z, t.x), r.z = 0) : r.x == -Math.PI / 2 ? (r.y = h.arcTanAngle(-t.z, -t.x), r.z = 0) : (_.Matrix4x4.createRotationY(-r.y, _.Matrix4x4.TEMPMatrix0), _.Matrix4x4.createRotationX(-r.x, _.Matrix4x4.TEMPMatrix1), a.transformCoordinate(h.TEMPVector32, _.Matrix4x4.TEMPMatrix0, h.TEMPVector32), a.transformCoordinate(h.TEMPVector32, _.Matrix4x4.TEMPMatrix1, h.TEMPVector32), r.z = h.arcTanAngle(t.y, -t.x)), r.y &lt;= -Math.PI &amp;&amp; (r.y = Math.PI), r.z &lt;= -Math.PI &amp;&amp; (r.z = Math.PI), r.y &gt;= Math.PI &amp;&amp; r.z &gt;= Math.PI &amp;&amp; (r.y = 0, r.z = 0, r.x = Math.PI - r.x);
            var i = e;
            i.x = r.y, i.y = r.x, i.z = r.z
        }
        invert(e) {
            var t = this.x,
                r = this.y,
                i = this.z,
                n = this.w,
                a = t * t + r * r + i * i + n * n,
                s = a ? 1 / a : 0;
            e.x = -t * s, e.y = -r * s, e.z = -i * s, e.w = n * s
        }
        identity() {
            this.x = 0, this.y = 0, this.z = 0, this.w = 1
        }
        fromArray(e, t = 0) {
            this.x = e[t + 0], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3]
        }
        cloneTo(e) {
            this !== e &amp;&amp; (e.x = this.x, e.y = this.y, e.z = this.z, e.w = this.w)
        }
        clone() {
            var e = new h;
            return this.cloneTo(e), e
        }
        equals(e) {
            return r.nearEqual(this.x, e.x) &amp;&amp; r.nearEqual(this.y, e.y) &amp;&amp; r.nearEqual(this.z, e.z) &amp;&amp; r.nearEqual(this.w, e.w)
        }
        static rotationLookAt(e, t, r) {
            h.lookAt(a._ZERO, e, t, r)
        }
        static lookAt(e, t, r, i) {
            l.lookAt(e, t, r, h._tempMatrix3x3), h.rotationMatrix(h._tempMatrix3x3, i)
        }
        lengthSquared() {
            return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
        }
        static invert(e, t) {
            var i = e.lengthSquared();
            r.isZero(i) || (i = 1 / i, t.x = -e.x * i, t.y = -e.y * i, t.z = -e.z * i, t.w = e.w * i)
        }
        static rotationMatrix(e, t) {
            var r, i, n = e.elements,
                a = n[0],
                s = n[1],
                o = n[2],
                l = n[3],
                _ = n[4],
                h = n[5],
                c = n[6],
                d = n[7],
                u = n[8],
                m = a + _ + u;
            m &gt; 0 ? (r = Math.sqrt(m + 1), t.w = .5 * r, r = .5 / r, t.x = (h - d) * r, t.y = (c - o) * r, t.z = (s - l) * r) : a &gt;= _ &amp;&amp; a &gt;= u ? (i = .5 / (r = Math.sqrt(1 + a - _ - u)), t.x = .5 * r, t.y = (s + l) * i, t.z = (o + c) * i, t.w = (h - d) * i) : _ &gt; u ? (i = .5 / (r = Math.sqrt(1 + _ - a - u)), t.x = (l + s) * i, t.y = .5 * r, t.z = (d + h) * i, t.w = (c - o) * i) : (i = .5 / (r = Math.sqrt(1 + u - a - _)), t.x = (c + o) * i, t.y = (d + h) * i, t.z = .5 * r, t.w = (s - l) * i)
        }
        forNativeElement(e = null) {
            e ? (this.elements = e, this.elements[0] = this.x, this.elements[1] = this.y, this.elements[2] = this.z, this.elements[3] = this.w) : this.elements = new Float32Array([this.x, this.y, this.z, this.w]), i.rewriteNumProperty(this, "x", 0), i.rewriteNumProperty(this, "y", 1), i.rewriteNumProperty(this, "z", 2), i.rewriteNumProperty(this, "w", 3)
        }
    }
    h.TEMPVector30 = new a, h.TEMPVector31 = new a, h.TEMPVector32 = new a, h.TEMPVector33 = new a, h._tempMatrix3x3 = new l, h.DEFAULT = new h, h.NAN = new h(NaN, NaN, NaN, NaN);
    class c {
        constructor(e = 1, t = 0, r = 0, i = 0, n = 0, a = 1, s = 0, o = 0, l = 0, _ = 0, h = 1, c = 0, d = 0, u = 0, m = 0, f = 1, T = null) {
            var E = this.elements = T || new Float32Array(16);
            E[0] = e, E[1] = t, E[2] = r, E[3] = i, E[4] = n, E[5] = a, E[6] = s, E[7] = o, E[8] = l, E[9] = _, E[10] = h, E[11] = c, E[12] = d, E[13] = u, E[14] = m, E[15] = f
        }
        static createRotationX(e, t) {
            var r = t.elements,
                i = Math.sin(e),
                n = Math.cos(e);
            r[1] = r[2] = r[3] = r[4] = r[7] = r[8] = r[11] = r[12] = r[13] = r[14] = 0, r[0] = r[15] = 1, r[5] = r[10] = n, r[6] = i, r[9] = -i
        }
        static createRotationY(e, t) {
            var r = t.elements,
                i = Math.sin(e),
                n = Math.cos(e);
            r[1] = r[3] = r[4] = r[6] = r[7] = r[9] = r[11] = r[12] = r[13] = r[14] = 0, r[5] = r[15] = 1, r[0] = r[10] = n, r[2] = -i, r[8] = i
        }
        static createRotationZ(e, t) {
            var r = t.elements,
                i = Math.sin(e),
                n = Math.cos(e);
            r[2] = r[3] = r[6] = r[7] = r[8] = r[9] = r[11] = r[12] = r[13] = r[14] = 0, r[10] = r[15] = 1, r[0] = r[5] = n, r[1] = i, r[4] = -i
        }
        static createRotationYawPitchRoll(e, t, r, i) {
            h.createFromYawPitchRoll(e, t, r, c._tempQuaternion), c.createRotationQuaternion(c._tempQuaternion, i)
        }
        static createRotationAxis(e, t, r) {
            var i = e.x,
                n = e.y,
                a = e.z,
                s = Math.cos(t),
                o = Math.sin(t),
                l = i * i,
                _ = n * n,
                h = a * a,
                c = i * n,
                d = i * a,
                u = n * a,
                m = r.elements;
            m[3] = m[7] = m[11] = m[12] = m[13] = m[14] = 0, m[15] = 1, m[0] = l + s * (1 - l), m[1] = c - s * c + o * a, m[2] = d - s * d - o * n, m[4] = c - s * c - o * a, m[5] = _ + s * (1 - _), m[6] = u - s * u + o * i, m[8] = d - s * d + o * n, m[9] = u - s * u - o * i, m[10] = h + s * (1 - h)
        }
        setRotation(e) {
            var t = e.x,
                r = e.y,
                i = e.z,
                n = e.w,
                a = t * t,
                s = r * r,
                o = i * i,
                l = t * r,
                _ = i * n,
                h = i * t,
                c = r * n,
                d = r * i,
                u = t * n,
                m = this.elements;
            m[0] = 1 - 2 * (s + o), m[1] = 2 * (l + _), m[2] = 2 * (h - c), m[4] = 2 * (l - _), m[5] = 1 - 2 * (o + a), m[6] = 2 * (d + u), m[8] = 2 * (h + c), m[9] = 2 * (d - u), m[10] = 1 - 2 * (s + a)
        }
        setPosition(e) {
            var t = this.elements;
            t[12] = e.x, t[13] = e.y, t[14] = e.z
        }
        static createRotationQuaternion(e, t) {
            var r = t.elements,
                i = e.x,
                n = e.y,
                a = e.z,
                s = e.w,
                o = i * i,
                l = n * n,
                _ = a * a,
                h = i * n,
                c = a * s,
                d = a * i,
                u = n * s,
                m = n * a,
                f = i * s;
            r[3] = r[7] = r[11] = r[12] = r[13] = r[14] = 0, r[15] = 1, r[0] = 1 - 2 * (l + _), r[1] = 2 * (h + c), r[2] = 2 * (d - u), r[4] = 2 * (h - c), r[5] = 1 - 2 * (_ + o), r[6] = 2 * (m + f), r[8] = 2 * (d + u), r[9] = 2 * (m - f), r[10] = 1 - 2 * (l + o)
        }
        static createTranslate(e, t) {
            var r = t.elements;
            r[4] = r[8] = r[1] = r[9] = r[2] = r[6] = r[3] = r[7] = r[11] = 0, r[0] = r[5] = r[10] = r[15] = 1, r[12] = e.x, r[13] = e.y, r[14] = e.z
        }
        static createScaling(e, t) {
            var r = t.elements;
            r[0] = e.x, r[5] = e.y, r[10] = e.z, r[1] = r[4] = r[8] = r[12] = r[9] = r[13] = r[2] = r[6] = r[14] = r[3] = r[7] = r[11] = 0, r[15] = 1
        }
        static multiply(e, t, r) {
            var i = t.elements,
                n = e.elements,
                a = r.elements,
                s = i[0],
                o = i[1],
                l = i[2],
                _ = i[3],
                h = i[4],
                c = i[5],
                d = i[6],
                u = i[7],
                m = i[8],
                f = i[9],
                T = i[10],
                E = i[11],
                p = i[12],
                g = i[13],
                S = i[14],
                R = i[15],
                v = n[0],
                A = n[1],
                I = n[2],
                x = n[3],
                L = n[4],
                D = n[5],
                C = n[6],
                y = n[7],
                M = n[8],
                O = n[9],
                N = n[10],
                b = n[11],
                P = n[12],
                w = n[13],
                V = n[14],
                B = n[15];
            a[0] = s * v + o * L + l * M + _ * P, a[1] = s * A + o * D + l * O + _ * w, a[2] = s * I + o * C + l * N + _ * V, a[3] = s * x + o * y + l * b + _ * B, a[4] = h * v + c * L + d * M + u * P, a[5] = h * A + c * D + d * O + u * w, a[6] = h * I + c * C + d * N + u * V, a[7] = h * x + c * y + d * b + u * B, a[8] = m * v + f * L + T * M + E * P, a[9] = m * A + f * D + T * O + E * w, a[10] = m * I + f * C + T * N + E * V, a[11] = m * x + f * y + T * b + E * B, a[12] = p * v + g * L + S * M + R * P, a[13] = p * A + g * D + S * O + R * w, a[14] = p * I + g * C + S * N + R * V, a[15] = p * x + g * y + S * b + R * B
        }
        static multiplyForNative(e, r, i) {
            t.LayaGL.instance.matrix4x4Multiply(e.elements, r.elements, i.elements)
        }
        static createFromQuaternion(e, t) {
            var r = t.elements,
                i = e.x,
                n = e.y,
                a = e.z,
                s = e.w,
                o = i + i,
                l = n + n,
                _ = a + a,
                h = i * o,
                c = n * o,
                d = n * l,
                u = a * o,
                m = a * l,
                f = a * _,
                T = s * o,
                E = s * l,
                p = s * _;
            r[0] = 1 - d - f, r[1] = c + p, r[2] = u - E, r[3] = 0, r[4] = c - p, r[5] = 1 - h - f, r[6] = m + T, r[7] = 0, r[8] = u + E, r[9] = m - T, r[10] = 1 - h - d, r[11] = 0, r[12] = 0, r[13] = 0, r[14] = 0, r[15] = 1
        }
        static createAffineTransformation(e, t, r, i) {
            var n = i.elements,
                a = t.x,
                s = t.y,
                o = t.z,
                l = t.w,
                _ = a + a,
                h = s + s,
                c = o + o,
                d = a * _,
                u = a * h,
                m = a * c,
                f = s * h,
                T = s * c,
                E = o * c,
                p = l * _,
                g = l * h,
                S = l * c,
                R = r.x,
                v = r.y,
                A = r.z;
            n[0] = (1 - (f + E)) * R, n[1] = (u + S) * R, n[2] = (m - g) * R, n[3] = 0, n[4] = (u - S) * v, n[5] = (1 - (d + E)) * v, n[6] = (T + p) * v, n[7] = 0, n[8] = (m + g) * A, n[9] = (T - p) * A, n[10] = (1 - (d + f)) * A, n[11] = 0, n[12] = e.x, n[13] = e.y, n[14] = e.z, n[15] = 1
        }
        static createLookAt(e, t, r, i) {
            var n = i.elements,
                s = c._tempVector0,
                o = c._tempVector1,
                l = c._tempVector2;
            a.subtract(e, t, l), a.normalize(l, l), a.cross(r, l, s), a.normalize(s, s), a.cross(l, s, o), n[3] = n[7] = n[11] = 0, n[15] = 1, n[0] = s.x, n[4] = s.y, n[8] = s.z, n[1] = o.x, n[5] = o.y, n[9] = o.z, n[2] = l.x, n[6] = l.y, n[10] = l.z, n[12] = -a.dot(s, e), n[13] = -a.dot(o, e), n[14] = -a.dot(l, e)
        }
        static createPerspective(e, t, r, i, n) {
            var a = 1 / Math.tan(.5 * e),
                s = r / (a / t),
                o = r / a;
            c.createPerspectiveOffCenter(-s, s, -o, o, r, i, n)
        }
        static createPerspectiveOffCenter(e, t, r, i, n, a, s) {
            var o = s.elements,
                l = a / (a - n);
            o[1] = o[2] = o[3] = o[4] = o[6] = o[7] = o[12] = o[13] = o[15] = 0, o[0] = 2 * n / (t - e), o[5] = 2 * n / (i - r), o[8] = (e + t) / (t - e), o[9] = (i + r) / (i - r), o[10] = -l, o[11] = -1, o[14] = -n * l
        }
        static createOrthoOffCenter(e, t, r, i, n, a, s) {
            var o = s.elements,
                l = 1 / (a - n);
            o[1] = o[2] = o[3] = o[4] = o[6] = o[8] = o[7] = o[9] = o[11] = 0, o[15] = 1, o[0] = 2 / (t - e), o[5] = 2 / (i - r), o[10] = -l, o[12] = (e + t) / (e - t), o[13] = (i + r) / (r - i), o[14] = -n * l
        }
        getElementByRowColumn(e, t) {
            if (e &lt; 0 || e &gt; 3) throw new Error("row Rows and columns for matrices run from 0 to 3, inclusive.");
            if (t &lt; 0 || t &gt; 3) throw new Error("column Rows and columns for matrices run from 0 to 3, inclusive.");
            return this.elements[4 * e + t]
        }
        setElementByRowColumn(e, t, r) {
            if (e &lt; 0 || e &gt; 3) throw new Error("row Rows and columns for matrices run from 0 to 3, inclusive.");
            if (t &lt; 0 || t &gt; 3) throw new Error("column Rows and columns for matrices run from 0 to 3, inclusive.");
            this.elements[4 * e + t] = r
        }
        equalsOtherMatrix(e) {
            var t = this.elements,
                i = e.elements;
            return r.nearEqual(t[0], i[0]) &amp;&amp; r.nearEqual(t[1], i[1]) &amp;&amp; r.nearEqual(t[2], i[2]) &amp;&amp; r.nearEqual(t[3], i[3]) &amp;&amp; r.nearEqual(t[4], i[4]) &amp;&amp; r.nearEqual(t[5], i[5]) &amp;&amp; r.nearEqual(t[6], i[6]) &amp;&amp; r.nearEqual(t[7], i[7]) &amp;&amp; r.nearEqual(t[8], i[8]) &amp;&amp; r.nearEqual(t[9], i[9]) &amp;&amp; r.nearEqual(t[10], i[10]) &amp;&amp; r.nearEqual(t[11], i[11]) &amp;&amp; r.nearEqual(t[12], i[12]) &amp;&amp; r.nearEqual(t[13], i[13]) &amp;&amp; r.nearEqual(t[14], i[14]) &amp;&amp; r.nearEqual(t[15], i[15])
        }
        decomposeTransRotScale(e, t, r) {
            var i = c._tempMatrix4x4;
            return this.decomposeTransRotMatScale(e, i, r) ? (h.createFromMatrix4x4(i, t), !0) : (t.identity(), !1)
        }
        decomposeTransRotMatScale(e, t, i) {
            var n = this.elements,
                s = e,
                o = t.elements,
                l = i;
            s.x = n[12], s.y = n[13], s.z = n[14];
            var _ = n[0],
                h = n[1],
                d = n[2],
                u = n[4],
                m = n[5],
                f = n[6],
                T = n[8],
                E = n[9],
                p = n[10],
                g = l.x = Math.sqrt(_ * _ + h * h + d * d),
                S = l.y = Math.sqrt(u * u + m * m + f * f),
                R = l.z = Math.sqrt(T * T + E * E + p * p);
            if (r.isZero(g) || r.isZero(S) || r.isZero(R)) return o[1] = o[2] = o[3] = o[4] = o[6] = o[7] = o[8] = o[9] = o[11] = o[12] = o[13] = o[14] = 0, o[0] = o[5] = o[10] = o[15] = 1, !1;
            var v = c._tempVector0;
            v.x = T / R, v.y = E / R, v.z = p / R;
            var A = c._tempVector1;
            A.x = _ / g, A.y = h / g, A.z = d / g;
            var I = c._tempVector2;
            a.cross(v, A, I);
            var x = c._tempVector1;
            return a.cross(I, v, x), o[3] = o[7] = o[11] = o[12] = o[13] = o[14] = 0, o[15] = 1, o[0] = x.x, o[1] = x.y, o[2] = x.z, o[4] = I.x, o[5] = I.y, o[6] = I.z, o[8] = v.x, o[9] = v.y, o[10] = v.z, o[0] * _ + o[1] * h + o[2] * d &lt; 0 &amp;&amp; (l.x = -g), o[4] * u + o[5] * m + o[6] * f &lt; 0 &amp;&amp; (l.y = -S), o[8] * T + o[9] * E + o[10] * p &lt; 0 &amp;&amp; (l.z = -R), !0
        }
        decomposeYawPitchRoll(e) {
            var t = Math.asin(-this.elements[9]);
            e.y = t, Math.cos(t) &gt; r.zeroTolerance ? (e.z = Math.atan2(this.elements[1], this.elements[5]), e.x = Math.atan2(this.elements[8], this.elements[10])) : (e.z = Math.atan2(-this.elements[4], this.elements[0]), e.x = 0)
        }
        normalize() {
            var e = this.elements,
                t = e[0],
                r = e[1],
                i = e[2],
                n = Math.sqrt(t * t + r * r + i * i);
            if (!n) return e[0] = 0, e[1] = 0, void(e[2] = 0);
            1 != n &amp;&amp; (n = 1 / n, e[0] = t * n, e[1] = r * n, e[2] = i * n)
        }
        transpose() {
            var e, t;
            return t = (e = this.elements)[1], e[1] = e[4], e[4] = t, t = e[2], e[2] = e[8], e[8] = t, t = e[3], e[3] = e[12], e[12] = t, t = e[6], e[6] = e[9], e[9] = t, t = e[7], e[7] = e[13], e[13] = t, t = e[11], e[11] = e[14], e[14] = t, this
        }
        invert(e) {
            var t = this.elements,
                r = e.elements,
                i = t[0],
                n = t[1],
                a = t[2],
                s = t[3],
                o = t[4],
                l = t[5],
                _ = t[6],
                h = t[7],
                c = t[8],
                d = t[9],
                u = t[10],
                m = t[11],
                f = t[12],
                T = t[13],
                E = t[14],
                p = t[15],
                g = i * l - n * o,
                S = i * _ - a * o,
                R = i * h - s * o,
                v = n * _ - a * l,
                A = n * h - s * l,
                I = a * h - s * _,
                x = c * T - d * f,
                L = c * E - u * f,
                D = c * p - m * f,
                C = d * E - u * T,
                y = d * p - m * T,
                M = u * p - m * E,
                O = g * M - S * y + R * C + v * D - A * L + I * x;
            0 !== Math.abs(O) &amp;&amp; (O = 1 / O, r[0] = (l * M - _ * y + h * C) * O, r[1] = (a * y - n * M - s * C) * O, r[2] = (T * I - E * A + p * v) * O, r[3] = (u * A - d * I - m * v) * O, r[4] = (_ * D - o * M - h * L) * O, r[5] = (i * M - a * D + s * L) * O, r[6] = (E * R - f * I - p * S) * O, r[7] = (c * I - u * R + m * S) * O, r[8] = (o * y - l * D + h * x) * O, r[9] = (n * D - i * y - s * x) * O, r[10] = (f * A - T * R + p * g) * O, r[11] = (d * R - c * A - m * g) * O, r[12] = (l * L - o * C - _ * x) * O, r[13] = (i * C - n * L + a * x) * O, r[14] = (T * S - f * v - E * g) * O, r[15] = (c * v - d * S + u * g) * O)
        }
        static billboard(e, t, i, n, s, o) {
            a.subtract(e, t, c._tempVector0);
            var l = a.scalarLengthSquared(c._tempVector0);
            r.isZero(l) ? (a.scale(s, -1, c._tempVector1), c._tempVector1.cloneTo(c._tempVector0)) : a.scale(c._tempVector0, 1 / Math.sqrt(l), c._tempVector0), a.cross(n, c._tempVector0, c._tempVector2), a.normalize(c._tempVector2, c._tempVector2), a.cross(c._tempVector0, c._tempVector2, c._tempVector3);
            var _ = c._tempVector2,
                h = c._tempVector3,
                d = c._tempVector0,
                u = e,
                m = o.elements;
            m[0] = _.x, m[1] = _.y, m[2] = _.z, m[3] = 0, m[4] = h.x, m[5] = h.y, m[6] = h.z, m[7] = 0, m[8] = d.x, m[9] = d.y, m[10] = d.z, m[11] = 0, m[12] = u.x, m[13] = u.y, m[14] = u.z, m[15] = 1
        }
        identity() {
            var e = this.elements;
            e[1] = e[2] = e[3] = e[4] = e[6] = e[7] = e[8] = e[9] = e[11] = e[12] = e[13] = e[14] = 0, e[0] = e[5] = e[10] = e[15] = 1
        }
        cloneTo(e) {
            var t, r, i;
            if ((r = this.elements) !== (i = e.elements))
                for (t = 0; t &lt; 16; ++t) i[t] = r[t]
        }
        clone() {
            var e = new c;
            return this.cloneTo(e), e
        }
        static translation(e, t) {
            var r = t.elements;
            r[0] = r[5] = r[10] = r[15] = 1, r[12] = e.x, r[13] = e.y, r[14] = e.z
        }
        getTranslationVector(e) {
            var t = this.elements;
            e.x = t[12], e.y = t[13], e.z = t[14]
        }
        setTranslationVector(e) {
            var t = this.elements,
                r = e;
            t[12] = r.x, t[13] = r.y, t[14] = r.z
        }
        getForward(e) {
            var t = this.elements;
            e.x = -t[8], e.y = -t[9], e.z = -t[10]
        }
        setForward(e) {
            var t = this.elements;
            t[8] = -e.x, t[9] = -e.y, t[10] = -e.z
        }
    }
    c._tempMatrix4x4 = new c, c.TEMPMatrix0 = new c, c.TEMPMatrix1 = new c, c._tempVector0 = new a, c._tempVector1 = new a, c._tempVector2 = new a, c._tempVector3 = new a, c._tempQuaternion = new h, c.DEFAULT = new c, c.ZERO = new c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    class d {
        constructor() {
            this._scale = new a(1, 1, 1), this._centerMatrix = new c, this._attatched = !1, this._indexInCompound = -1, this._compoundParent = null, this._attatchedCollisionObject = null, this._referenceCount = 0, this._localOffset = new a(0, 0, 0), this._localRotation = new h(0, 0, 0, 1), this.needsCustomCollisionCallback = !1
        }
        static __init__() {
            var e = _.Physics3D._bullet;
            d._btScale = e.btVector3_create(1, 1, 1), d._btVector30 = e.btVector3_create(0, 0, 0), d._btQuaternion0 = e.btQuaternion_create(0, 0, 0, 1), d._btTransform0 = e.btTransform_create()
        }
        static _createAffineTransformation(e, t, r) {
            var i = t.x,
                n = t.y,
                a = t.z,
                s = t.w,
                o = i + i,
                l = n + n,
                _ = a + a,
                h = i * o,
                c = i * l,
                d = i * _,
                u = n * l,
                m = n * _,
                f = a * _,
                T = s * o,
                E = s * l,
                p = s * _;
            r[0] = 1 - (u + f), r[1] = c + p, r[2] = d - E, r[3] = 0, r[4] = c - p, r[5] = 1 - (h + f), r[6] = m + T, r[7] = 0, r[8] = d + E, r[9] = m - T, r[10] = 1 - (h + u), r[11] = 0, r[12] = e.x, r[13] = e.y, r[14] = e.z, r[15] = 1
        }
        get type() {
            return this._type
        }
        get localOffset() {
            return this._localOffset
        }
        set localOffset(e) {
            this._localOffset = e, this._compoundParent &amp;&amp; this._compoundParent._updateChildTransform(this)
        }
        get localRotation() {
            return this._localRotation
        }
        set localRotation(e) {
            this._localRotation = e, this._compoundParent &amp;&amp; this._compoundParent._updateChildTransform(this)
        }
        _setScale(e) {
            if (this._compoundParent) this.updateLocalTransformations();
            else {
                var t = _.Physics3D._bullet;
                t.btVector3_setValue(d._btScale, e.x, e.y, e.z), t.btCollisionShape_setLocalScaling(this._btShape, d._btScale)
            }
        }
        _addReference() {
            this._referenceCount++
        }
        _removeReference() {
            this._referenceCount--
        }
        updateLocalTransformations() {
            if (this._compoundParent) {
                var e = d._tempVector30;
                a.multiply(this.localOffset, this._scale, e), d._createAffineTransformation(e, this.localRotation, this._centerMatrix.elements)
            } else d._createAffineTransformation(this.localOffset, this.localRotation, this._centerMatrix.elements)
        }
        cloneTo(e) {
            var t = e;
            this._localOffset.cloneTo(t.localOffset), this._localRotation.cloneTo(t.localRotation), t.localOffset = t.localOffset, t.localRotation = t.localRotation
        }
        clone() {
            return null
        }
        destroy() {
            this._btShape &amp;&amp; (_.Physics3D._bullet.btCollisionShape_destroy(this._btShape), this._btShape = null)
        }
    }
    d.SHAPEORIENTATION_UPX = 0, d.SHAPEORIENTATION_UPY = 1, d.SHAPEORIENTATION_UPZ = 2, d.SHAPETYPES_BOX = 0, d.SHAPETYPES_SPHERE = 1, d.SHAPETYPES_CYLINDER = 2, d.SHAPETYPES_CAPSULE = 3, d.SHAPETYPES_CONVEXHULL = 4, d.SHAPETYPES_COMPOUND = 5, d.SHAPETYPES_STATICPLANE = 6, d.SHAPETYPES_CONE = 7, d._tempVector30 = new a;
    class u extends d {
        constructor(e, t) {
            super(), this._normal = e, this._offset = t, this._type = d.SHAPETYPES_STATICPLANE;
            var r = _.Physics3D._bullet;
            r.btVector3_setValue(u._btNormal, -e.x, e.y, e.z), this._btShape = r.btStaticPlaneShape_create(u._btNormal, t)
        }
        static __init__() {
            u._btNormal = _.Physics3D._bullet.btVector3_create(0, 0, 0)
        }
        clone() {
            var e = new u(this._normal, this._offset);
            return this.cloneTo(e), e
        }
    }
    class m extends d {
        constructor() {
            super(), this._childColliderShapes = [], this._type = d.SHAPETYPES_COMPOUND, this._btShape = _.Physics3D._bullet.btCompoundShape_create()
        }
        static __init__() {
            var e = _.Physics3D._bullet;
            m._btVector3One = e.btVector3_create(1, 1, 1), m._btTransform = e.btTransform_create(), m._btOffset = e.btVector3_create(0, 0, 0), m._btRotation = e.btQuaternion_create(0, 0, 0, 1)
        }
        _clearChildShape(e) {
            e._attatched = !1, e._compoundParent = null, e._indexInCompound = -1
        }
        _addReference() {}
        _removeReference() {}
        _updateChildTransform(e) {
            var t = _.Physics3D._bullet,
                r = e.localOffset,
                i = e.localRotation,
                n = d._btVector30,
                a = d._btQuaternion0,
                s = d._btTransform0;
            t.btVector3_setValue(n, -r.x, r.y, r.z), t.btQuaternion_setValue(a, -i.x, i.y, i.z, -i.w), t.btTransform_setOrigin(s, n), t.btTransform_setRotation(s, a), t.btCompoundShape_updateChildTransform(this._btShape, e._indexInCompound, s, !0)
        }
        addChildShape(e) {
            if (e._attatched) throw "CompoundColliderShape: this shape has attatched to other entity.";
            e._attatched = !0, e._compoundParent = this, e._indexInCompound = this._childColliderShapes.length, this._childColliderShapes.push(e);
            var t = e.localOffset,
                r = e.localRotation,
                i = _.Physics3D._bullet;
            i.btVector3_setValue(m._btOffset, -t.x, t.y, t.z), i.btQuaternion_setValue(m._btRotation, -r.x, r.y, r.z, -r.w), i.btTransform_setOrigin(m._btTransform, m._btOffset), i.btTransform_setRotation(m._btTransform, m._btRotation);
            var n = i.btCollisionShape_getLocalScaling(this._btShape);
            i.btCollisionShape_setLocalScaling(this._btShape, m._btVector3One), i.btCompoundShape_addChildShape(this._btShape, m._btTransform, e._btShape), i.btCollisionShape_setLocalScaling(this._btShape, n), this._attatchedCollisionObject &amp;&amp; (this._attatchedCollisionObject.colliderShape = this)
        }
        removeChildShape(e) {
            if (e._compoundParent === this) {
                var t = e._indexInCompound;
                this._clearChildShape(e);
                var r = this._childColliderShapes[this._childColliderShapes.length - 1];
                r._indexInCompound = t, this._childColliderShapes[t] = r, this._childColliderShapes.pop(), _.Physics3D._bullet.btCompoundShape_removeChildShapeByIndex(this._btShape, t)
            }
        }
        clearChildShape() {
            for (var e = 0, t = this._childColliderShapes.length; e &lt; t; e++) this._clearChildShape(this._childColliderShapes[e]), _.Physics3D._bullet.btCompoundShape_removeChildShapeByIndex(this._btShape, 0);
            this._childColliderShapes.length = 0
        }
        getChildShapeCount() {
            return this._childColliderShapes.length
        }
        cloneTo(e) {
            var t = e;
            t.clearChildShape();
            for (var r = 0, i = this._childColliderShapes.length; r &lt; i; r++) t.addChildShape(this._childColliderShapes[r].clone())
        }
        clone() {
            var e = new m;
            return this.cloneTo(e), e
        }
        destroy() {
            super.destroy();
            for (var e = 0, t = this._childColliderShapes.length; e &lt; t; e++) {
                var r = this._childColliderShapes[e];
                0 === r._referenceCount &amp;&amp; r.destroy()
            }
        }
    }
    class f extends t.EventDispatcher {
        constructor(e) {
            super(), this._localPosition = new a(0, 0, 0), this._localRotation = new h(0, 0, 0, 1), this._localScale = new a(1, 1, 1), this._localRotationEuler = new a(0, 0, 0), this._localMatrix = new c, this._position = new a(0, 0, 0), this._rotation = new h(0, 0, 0, 1), this._scale = new a(1, 1, 1), this._rotationEuler = new a(0, 0, 0), this._worldMatrix = new c, this._children = null, this._parent = null, this._dummy = null, this._transformFlag = 0, this._owner = e, this._children = [], this._setTransformFlag(f.TRANSFORM_LOCALQUATERNION | f.TRANSFORM_LOCALEULER | f.TRANSFORM_LOCALMATRIX, !1), this._setTransformFlag(f.TRANSFORM_WORLDPOSITION | f.TRANSFORM_WORLDQUATERNION | f.TRANSFORM_WORLDEULER | f.TRANSFORM_WORLDSCALE | f.TRANSFORM_WORLDMATRIX, !0)
        }
        get _isFrontFaceInvert() {
            var e = this.getWorldLossyScale(),
                t = e.x &lt; 0;
            return e.y &lt; 0 &amp;&amp; (t = !t), e.z &lt; 0 &amp;&amp; (t = !t), t
        }
        get owner() {
            return this._owner
        }
        get worldNeedUpdate() {
            return this._getTransformFlag(f.TRANSFORM_WORLDMATRIX)
        }
        get localPositionX() {
            return this._localPosition.x
        }
        set localPositionX(e) {
            this._localPosition.x = e, this.localPosition = this._localPosition
        }
        get localPositionY() {
            return this._localPosition.y
        }
        set localPositionY(e) {
            this._localPosition.y = e, this.localPosition = this._localPosition
        }
        get localPositionZ() {
            return this._localPosition.z
        }
        set localPositionZ(e) {
            this._localPosition.z = e, this.localPosition = this._localPosition
        }
        get localPosition() {
            return this._localPosition
        }
        set localPosition(e) {
            this._localPosition !== e &amp;&amp; e.cloneTo(this._localPosition), this._setTransformFlag(f.TRANSFORM_LOCALMATRIX, !0), this._onWorldPositionTransform()
        }
        get localRotationX() {
            return this.localRotation.x
        }
        set localRotationX(e) {
            this._localRotation.x = e, this.localRotation = this._localRotation
        }
        get localRotationY() {
            return this.localRotation.y
        }
        set localRotationY(e) {
            this._localRotation.y = e, this.localRotation = this._localRotation
        }
        get localRotationZ() {
            return this.localRotation.z
        }
        set localRotationZ(e) {
            this._localRotation.z = e, this.localRotation = this._localRotation
        }
        get localRotationW() {
            return this.localRotation.w
        }
        set localRotationW(e) {
            this._localRotation.w = e, this.localRotation = this._localRotation
        }
        get localRotation() {
            if (this._getTransformFlag(f.TRANSFORM_LOCALQUATERNION)) {
                var e = this._localRotationEuler;
                h.createFromYawPitchRoll(e.y / f._angleToRandin, e.x / f._angleToRandin, e.z / f._angleToRandin, this._localRotation), this._setTransformFlag(f.TRANSFORM_LOCALQUATERNION, !1)
            }
            return this._localRotation
        }
        set localRotation(e) {
            this._localRotation !== e &amp;&amp; e.cloneTo(this._localRotation), this._localRotation.normalize(this._localRotation), this._setTransformFlag(f.TRANSFORM_LOCALEULER | f.TRANSFORM_LOCALMATRIX, !0), this._setTransformFlag(f.TRANSFORM_LOCALQUATERNION, !1), this._onWorldRotationTransform()
        }
        get localScaleX() {
            return this._localScale.x
        }
        set localScaleX(e) {
            this._localScale.x = e, this.localScale = this._localScale
        }
        get localScaleY() {
            return this._localScale.y
        }
        set localScaleY(e) {
            this._localScale.y = e, this.localScale = this._localScale
        }
        get localScaleZ() {
            return this._localScale.z
        }
        set localScaleZ(e) {
            this._localScale.z = e, this.localScale = this._localScale
        }
        get localScale() {
            return this._localScale
        }
        set localScale(e) {
            this._localScale !== e &amp;&amp; e.cloneTo(this._localScale), this._setTransformFlag(f.TRANSFORM_LOCALMATRIX, !0), this._onWorldScaleTransform()
        }
        get localRotationEulerX() {
            return this.localRotationEuler.x
        }
        set localRotationEulerX(e) {
            this._localRotationEuler.x = e, this.localRotationEuler = this._localRotationEuler
        }
        get localRotationEulerY() {
            return this.localRotationEuler.y
        }
        set localRotationEulerY(e) {
            this._localRotationEuler.y = e, this.localRotationEuler = this._localRotationEuler
        }
        get localRotationEulerZ() {
            return this.localRotationEuler.z
        }
        set localRotationEulerZ(e) {
            this._localRotationEuler.z = e, this.localRotationEuler = this._localRotationEuler
        }
        get localRotationEuler() {
            if (this._getTransformFlag(f.TRANSFORM_LOCALEULER)) {
                this._localRotation.getYawPitchRoll(f._tempVector30);
                var e = f._tempVector30,
                    t = this._localRotationEuler;
                t.x = e.y * f._angleToRandin, t.y = e.x * f._angleToRandin, t.z = e.z * f._angleToRandin, this._setTransformFlag(f.TRANSFORM_LOCALEULER, !1)
            }
            return this._localRotationEuler
        }
        set localRotationEuler(e) {
            this._localRotationEuler !== e &amp;&amp; e.cloneTo(this._localRotationEuler), this._setTransformFlag(f.TRANSFORM_LOCALEULER, !1), this._setTransformFlag(f.TRANSFORM_LOCALQUATERNION | f.TRANSFORM_LOCALMATRIX, !0), this._onWorldRotationTransform()
        }
        get localMatrix() {
            return this._getTransformFlag(f.TRANSFORM_LOCALMATRIX) &amp;&amp; (c.createAffineTransformation(this._localPosition, this.localRotation, this._localScale, this._localMatrix), this._setTransformFlag(f.TRANSFORM_LOCALMATRIX, !1)), this._localMatrix
        }
        set localMatrix(e) {
            this._localMatrix !== e &amp;&amp; e.cloneTo(this._localMatrix), this._localMatrix.decomposeTransRotScale(this._localPosition, this._localRotation, this._localScale), this._setTransformFlag(f.TRANSFORM_LOCALEULER, !0), this._setTransformFlag(f.TRANSFORM_LOCALMATRIX, !1), this._onWorldTransform()
        }
        get position() {
            if (this._getTransformFlag(f.TRANSFORM_WORLDPOSITION)) {
                if (null != this._parent) {
                    var e = this.worldMatrix.elements;
                    this._position.x = e[12], this._position.y = e[13], this._position.z = e[14]
                } else this._localPosition.cloneTo(this._position);
                this._setTransformFlag(f.TRANSFORM_WORLDPOSITION, !1)
            }
            return this._position
        }
        set position(e) {
            if (null != this._parent) {
                var t = f._tempMatrix0;
                this._parent.worldMatrix.invert(t), a.transformCoordinate(e, t, this._localPosition)
            } else e.cloneTo(this._localPosition);
            this.localPosition = this._localPosition, this._position !== e &amp;&amp; e.cloneTo(this._position), this._setTransformFlag(f.TRANSFORM_WORLDPOSITION, !1)
        }
        get rotation() {
            return this._getTransformFlag(f.TRANSFORM_WORLDQUATERNION) &amp;&amp; (null != this._parent ? h.multiply(this._parent.rotation, this.localRotation, this._rotation) : this.localRotation.cloneTo(this._rotation), this._setTransformFlag(f.TRANSFORM_WORLDQUATERNION, !1)), this._rotation
        }
        set rotation(e) {
            null != this._parent ? (this._parent.rotation.invert(f._tempQuaternion0), h.multiply(f._tempQuaternion0, e, this._localRotation)) : e.cloneTo(this._localRotation), this.localRotation = this._localRotation, e !== this._rotation &amp;&amp; e.cloneTo(this._rotation), this._setTransformFlag(f.TRANSFORM_WORLDQUATERNION, !1)
        }
        get rotationEuler() {
            if (this._getTransformFlag(f.TRANSFORM_WORLDEULER)) {
                this.rotation.getYawPitchRoll(f._tempVector30);
                var e = f._tempVector30,
                    t = this._rotationEuler;
                t.x = e.y * f._angleToRandin, t.y = e.x * f._angleToRandin, t.z = e.z * f._angleToRandin, this._setTransformFlag(f.TRANSFORM_WORLDEULER, !1)
            }
            return this._rotationEuler
        }
        set rotationEuler(e) {
            h.createFromYawPitchRoll(e.y / f._angleToRandin, e.x / f._angleToRandin, e.z / f._angleToRandin, this._rotation), this.rotation = this._rotation, this._rotationEuler !== e &amp;&amp; e.cloneTo(this._rotationEuler), this._setTransformFlag(f.TRANSFORM_WORLDEULER, !1)
        }
        get worldMatrix() {
            return this._getTransformFlag(f.TRANSFORM_WORLDMATRIX) &amp;&amp; (null != this._parent ? c.multiply(this._parent.worldMatrix, this.localMatrix, this._worldMatrix) : this.localMatrix.cloneTo(this._worldMatrix), this._setTransformFlag(f.TRANSFORM_WORLDMATRIX, !1)), this._worldMatrix
        }
        set worldMatrix(e) {
            null === this._parent ? e.cloneTo(this._localMatrix) : (this._parent.worldMatrix.invert(this._localMatrix), c.multiply(this._localMatrix, e, this._localMatrix)), this.localMatrix = this._localMatrix, this._worldMatrix !== e &amp;&amp; e.cloneTo(this._worldMatrix), this._setTransformFlag(f.TRANSFORM_WORLDMATRIX, !1)
        }
        _getScaleMatrix() {
            var e = f._tempQuaternion0,
                t = f._tempMatrix3x30,
                r = f._tempMatrix3x31,
                i = f._tempMatrix3x32;
            return l.createFromMatrix4x4(this.worldMatrix, r), this.rotation.invert(e), l.createRotationQuaternion(e, t), l.multiply(t, r, i), i
        }
        _setTransformFlag(e, t) {
            t ? this._transformFlag |= e : this._transformFlag &amp;= ~e
        }
        _getTransformFlag(e) {
            return 0 != (this._transformFlag &amp; e)
        }
        _setParent(e) {
            if (this._parent !== e) {
                if (this._parent) {
                    var t = this._parent._children,
                        r = t.indexOf(this);
                    t.splice(r, 1)
                }
                e &amp;&amp; (e._children.push(this), e &amp;&amp; this._onWorldTransform()), this._parent = e
            }
        }
        _onWorldPositionRotationTransform() {
            if (!(this._getTransformFlag(f.TRANSFORM_WORLDMATRIX) &amp;&amp; this._getTransformFlag(f.TRANSFORM_WORLDPOSITION) &amp;&amp; this._getTransformFlag(f.TRANSFORM_WORLDQUATERNION) &amp;&amp; this._getTransformFlag(f.TRANSFORM_WORLDEULER))) {
                this._setTransformFlag(f.TRANSFORM_WORLDMATRIX | f.TRANSFORM_WORLDPOSITION | f.TRANSFORM_WORLDQUATERNION | f.TRANSFORM_WORLDEULER, !0), this.event(t.Event.TRANSFORM_CHANGED, this._transformFlag);
                for (var e = 0, r = this._children.length; e &lt; r; e++) this._children[e]._onWorldPositionRotationTransform()
            }
        }
        _onWorldPositionScaleTransform() {
            if (!this._getTransformFlag(f.TRANSFORM_WORLDMATRIX) || !this._getTransformFlag(f.TRANSFORM_WORLDPOSITION) || !this._getTransformFlag(f.TRANSFORM_WORLDSCALE)) {
                this._setTransformFlag(f.TRANSFORM_WORLDMATRIX | f.TRANSFORM_WORLDPOSITION | f.TRANSFORM_WORLDSCALE, !0), this.event(t.Event.TRANSFORM_CHANGED, this._transformFlag);
                for (var e = 0, r = this._children.length; e &lt; r; e++) this._children[e]._onWorldPositionScaleTransform()
            }
        }
        _onWorldPositionTransform() {
            if (!this._getTransformFlag(f.TRANSFORM_WORLDMATRIX) || !this._getTransformFlag(f.TRANSFORM_WORLDPOSITION)) {
                this._setTransformFlag(f.TRANSFORM_WORLDMATRIX | f.TRANSFORM_WORLDPOSITION, !0), this.event(t.Event.TRANSFORM_CHANGED, this._transformFlag);
                for (var e = 0, r = this._children.length; e &lt; r; e++) this._children[e]._onWorldPositionTransform()
            }
        }
        _onWorldRotationTransform() {
            if (!this._getTransformFlag(f.TRANSFORM_WORLDMATRIX) || !this._getTransformFlag(f.TRANSFORM_WORLDQUATERNION) || !this._getTransformFlag(f.TRANSFORM_WORLDEULER)) {
                this._setTransformFlag(f.TRANSFORM_WORLDMATRIX | f.TRANSFORM_WORLDQUATERNION | f.TRANSFORM_WORLDEULER, !0), this.event(t.Event.TRANSFORM_CHANGED, this._transformFlag);
                for (var e = 0, r = this._children.length; e &lt; r; e++) this._children[e]._onWorldPositionRotationTransform()
            }
        }
        _onWorldScaleTransform() {
            if (!this._getTransformFlag(f.TRANSFORM_WORLDMATRIX) || !this._getTransformFlag(f.TRANSFORM_WORLDSCALE)) {
                this._setTransformFlag(f.TRANSFORM_WORLDMATRIX | f.TRANSFORM_WORLDSCALE, !0), this.event(t.Event.TRANSFORM_CHANGED, this._transformFlag);
                for (var e = 0, r = this._children.length; e &lt; r; e++) this._children[e]._onWorldPositionScaleTransform()
            }
        }
        _onWorldTransform() {
            if (!(this._getTransformFlag(f.TRANSFORM_WORLDMATRIX) &amp;&amp; this._getTransformFlag(f.TRANSFORM_WORLDPOSITION) &amp;&amp; this._getTransformFlag(f.TRANSFORM_WORLDQUATERNION) &amp;&amp; this._getTransformFlag(f.TRANSFORM_WORLDEULER) &amp;&amp; this._getTransformFlag(f.TRANSFORM_WORLDSCALE))) {
                this._setTransformFlag(f.TRANSFORM_WORLDMATRIX | f.TRANSFORM_WORLDPOSITION | f.TRANSFORM_WORLDQUATERNION | f.TRANSFORM_WORLDEULER | f.TRANSFORM_WORLDSCALE, !0), this.event(t.Event.TRANSFORM_CHANGED, this._transformFlag);
                for (var e = 0, r = this._children.length; e &lt; r; e++) this._children[e]._onWorldTransform()
            }
        }
        translate(e, t = !0) {
            t ? (c.createFromQuaternion(this.localRotation, f._tempMatrix0), a.transformCoordinate(e, f._tempMatrix0, f._tempVector30), a.add(this.localPosition, f._tempVector30, this._localPosition), this.localPosition = this._localPosition) : (a.add(this.position, e, this._position), this.position = this._position)
        }
        rotate(e, t = !0, r = !0) {
            var i;
            r ? i = e : (a.scale(e, Math.PI / 180, f._tempVector30), i = f._tempVector30), h.createFromYawPitchRoll(i.y, i.x, i.z, f._tempQuaternion0), t ? (h.multiply(this._localRotation, f._tempQuaternion0, this._localRotation), this.localRotation = this._localRotation) : (h.multiply(f._tempQuaternion0, this.rotation, this._rotation), this.rotation = this._rotation)
        }
        getForward(e) {
            var t = this.worldMatrix.elements;
            e.x = -t[8], e.y = -t[9], e.z = -t[10]
        }
        getUp(e) {
            var t = this.worldMatrix.elements;
            e.x = t[4], e.y = t[5], e.z = t[6]
        }
        getRight(e) {
            var t = this.worldMatrix.elements;
            e.x = t[0], e.y = t[1], e.z = t[2]
        }
        lookAt(e, t, i = !1) {
            var n;
            if (i) {
                if (n = this._localPosition, Math.abs(n.x - e.x) &lt; r.zeroTolerance &amp;&amp; Math.abs(n.y - e.y) &lt; r.zeroTolerance &amp;&amp; Math.abs(n.z - e.z) &lt; r.zeroTolerance) return;
                h.lookAt(this._localPosition, e, t, this._localRotation), this._localRotation.invert(this._localRotation), this.localRotation = this._localRotation
            } else {
                var a = this.position;
                if (n = a, Math.abs(n.x - e.x) &lt; r.zeroTolerance &amp;&amp; Math.abs(n.y - e.y) &lt; r.zeroTolerance &amp;&amp; Math.abs(n.z - e.z) &lt; r.zeroTolerance) return;
                h.lookAt(a, e, t, this._rotation), this._rotation.invert(this._rotation), this.rotation = this._rotation
            }
        }
        getWorldLossyScale() {
            if (this._getTransformFlag(f.TRANSFORM_WORLDSCALE)) {
                if (null !== this._parent) {
                    var e = this._getScaleMatrix().elements;
                    this._scale.x = e[0], this._scale.y = e[4], this._scale.z = e[8]
                } else this._localScale.cloneTo(this._scale);
                this._setTransformFlag(f.TRANSFORM_WORLDSCALE, !1)
            }
            return this._scale
        }
        setWorldLossyScale(e) {
            if (null !== this._parent) {
                var t = f._tempMatrix3x33,
                    r = f._tempMatrix3x33,
                    i = r.elements,
                    n = this._parent._getScaleMatrix();
                n.invert(n), l.createFromScaling(e, t), l.multiply(n, t, r), this._localScale.x = i[0], this._localScale.y = i[4], this._localScale.z = i[8]
            } else e.cloneTo(this._localScale);
            this.localScale = this._localScale, this._scale !== e &amp;&amp; e.cloneTo(this._scale), this._setTransformFlag(f.TRANSFORM_WORLDSCALE, !1)
        }
        get scale() {
            return console.warn("Transfrm3D: discard function,please use getWorldLossyScale instead."), this.getWorldLossyScale()
        }
        set scale(e) {
            console.warn("Transfrm3D: discard function,please use setWorldLossyScale instead."), this.setWorldLossyScale(e)
        }
    }
    f._tempVector30 = new a, f._tempQuaternion0 = new h, f._tempMatrix0 = new c, f._tempMatrix3x30 = new l, f._tempMatrix3x31 = new l, f._tempMatrix3x32 = new l, f._tempMatrix3x33 = new l, f.TRANSFORM_LOCALQUATERNION = 1, f.TRANSFORM_LOCALEULER = 2, f.TRANSFORM_LOCALMATRIX = 4, f.TRANSFORM_WORLDPOSITION = 8, f.TRANSFORM_WORLDQUATERNION = 16, f.TRANSFORM_WORLDSCALE = 32, f.TRANSFORM_WORLDMATRIX = 64, f.TRANSFORM_WORLDEULER = 128, f._angleToRandin = 180 / Math.PI;
    class T {
        constructor() {}
        static setColliderCollision(e, t, r) {}
        static getIColliderCollision(e, t) {
            return !1
        }
    }
    T.COLLISIONFILTERGROUP_DEFAULTFILTER = 1, T.COLLISIONFILTERGROUP_STATICFILTER = 2, T.COLLISIONFILTERGROUP_KINEMATICFILTER = 4, T.COLLISIONFILTERGROUP_DEBRISFILTER = 8, T.COLLISIONFILTERGROUP_SENSORTRIGGER = 16, T.COLLISIONFILTERGROUP_CHARACTERFILTER = 32, T.COLLISIONFILTERGROUP_CUSTOMFILTER1 = 64, T.COLLISIONFILTERGROUP_CUSTOMFILTER2 = 128, T.COLLISIONFILTERGROUP_CUSTOMFILTER3 = 256, T.COLLISIONFILTERGROUP_CUSTOMFILTER4 = 512, T.COLLISIONFILTERGROUP_CUSTOMFILTER5 = 1024, T.COLLISIONFILTERGROUP_CUSTOMFILTER6 = 2048, T.COLLISIONFILTERGROUP_CUSTOMFILTER7 = 4096, T.COLLISIONFILTERGROUP_CUSTOMFILTER8 = 8192, T.COLLISIONFILTERGROUP_CUSTOMFILTER9 = 16384, T.COLLISIONFILTERGROUP_CUSTOMFILTER10 = 32768, T.COLLISIONFILTERGROUP_ALLFILTER = -1, T.gravity = new a(0, -9.81, 0);
    class E extends d {
        constructor(e = 1, t = 1, r = 1) {
            super(), this._sizeX = e, this._sizeY = t, this._sizeZ = r, this._type = d.SHAPETYPES_BOX;
            var i = _.Physics3D._bullet;
            i.btVector3_setValue(E._btSize, e / 2, t / 2, r / 2), this._btShape = i.btBoxShape_create(E._btSize)
        }
        static __init__() {
            E._btSize = _.Physics3D._bullet.btVector3_create(0, 0, 0)
        }
        get sizeX() {
            return this._sizeX
        }
        get sizeY() {
            return this._sizeY
        }
        get sizeZ() {
            return this._sizeZ
        }
        clone() {
            var e = new E(this._sizeX, this._sizeY, this._sizeZ);
            return this.cloneTo(e), e
        }
    }
    class p extends d {
        constructor(e = .5, t = 1.25, r = d.SHAPEORIENTATION_UPY) {
            super(), this._radius = e, this._length = t, this._orientation = r, this._type = d.SHAPETYPES_CAPSULE;
            var i = _.Physics3D._bullet;
            switch (r) {
                case d.SHAPEORIENTATION_UPX:
                    this._btShape = i.btCapsuleShapeX_create(e, t - 2 * e);
                    break;
                case d.SHAPEORIENTATION_UPY:
                    this._btShape = i.btCapsuleShape_create(e, t - 2 * e);
                    break;
                case d.SHAPEORIENTATION_UPZ:
                    this._btShape = i.btCapsuleShapeZ_create(e, t - 2 * e);
                    break;
                default:
                    throw "CapsuleColliderShape:unknown orientation."
            }
        }
        get radius() {
            return this._radius
        }
        get length() {
            return this._length
        }
        get orientation() {
            return this._orientation
        }
        _setScale(e) {
            var t = p._tempVector30;
            switch (this.orientation) {
                case d.SHAPEORIENTATION_UPX:
                    t.x = e.x, t.y = t.z = Math.max(e.y, e.z);
                    break;
                case d.SHAPEORIENTATION_UPY:
                    t.y = e.y, t.x = t.z = Math.max(e.x, e.z);
                    break;
                case d.SHAPEORIENTATION_UPZ:
                    t.z = e.z, t.x = t.y = Math.max(e.x, e.y);
                    break;
                default:
                    throw "CapsuleColliderShape:unknown orientation."
            }
            super._setScale(t)
        }
        clone() {
            var e = new p(this._radius, this._length, this._orientation);
            return this.cloneTo(e), e
        }
    }
    p._tempVector30 = new a;
    class g extends d {
        constructor(e = .5, t = 1, r = d.SHAPEORIENTATION_UPY) {
            super(), this._radius = 1, this._height = .5, this._radius = e, this._height = t, this._orientation = r, this._type = d.SHAPETYPES_CYLINDER;
            var i = _.Physics3D._bullet;
            switch (r) {
                case d.SHAPEORIENTATION_UPX:
                    this._btShape = i.btConeShapeX_create(e, t);
                    break;
                case d.SHAPEORIENTATION_UPY:
                    this._btShape = i.btConeShape_create(e, t);
                    break;
                case d.SHAPEORIENTATION_UPZ:
                    this._btShape = i.btConeShapeZ_create(e, t);
                    break;
                default:
                    throw "ConeColliderShape:unknown orientation."
            }
        }
        get radius() {
            return this._radius
        }
        get height() {
            return this._height
        }
        get orientation() {
            return this._orientation
        }
        clone() {
            var e = new g(this._radius, this._height, this._orientation);
            return this.cloneTo(e), e
        }
    }
    class S extends d {
        constructor(e = .5, t = 1, r = d.SHAPEORIENTATION_UPY) {
            super(), this._radius = 1, this._height = .5, this._radius = e, this._height = t, this._orientation = r, this._type = d.SHAPETYPES_CYLINDER;
            var i = _.Physics3D._bullet;
            switch (r) {
                case d.SHAPEORIENTATION_UPX:
                    i.btVector3_setValue(S._btSize, t / 2, e, e), this._btShape = i.btCylinderShapeX_create(S._btSize);
                    break;
                case d.SHAPEORIENTATION_UPY:
                    i.btVector3_setValue(S._btSize, e, t / 2, e), this._btShape = i.btCylinderShape_create(S._btSize);
                    break;
                case d.SHAPEORIENTATION_UPZ:
                    i.btVector3_setValue(S._btSize, e, e, t / 2), this._btShape = i.btCylinderShapeZ_create(S._btSize);
                    break;
                default:
                    throw "CapsuleColliderShape:unknown orientation."
            }
        }
        static __init__() {
            S._btSize = _.Physics3D._bullet.btVector3_create(0, 0, 0)
        }
        get radius() {
            return this._radius
        }
        get height() {
            return this._height
        }
        get orientation() {
            return this._orientation
        }
        clone() {
            var e = new S(this._radius, this._height, this._orientation);
            return this.cloneTo(e), e
        }
    }
    class R extends d {
        constructor() {
            super(), this._mesh = null, this._convex = !1
        }
        get mesh() {
            return this._mesh
        }
        set mesh(e) {
            if (this._mesh !== e) {
                var t = _.Physics3D._bullet;
                this._mesh &amp;&amp; t.btCollisionShape_destroy(this._btShape), e &amp;&amp; (this._btShape = t.btGImpactMeshShape_create(e._getPhysicMesh()), t.btGImpactShapeInterface_updateBound(this._btShape)), this._mesh = e
            }
        }
        get convex() {
            return this._convex
        }
        set convex(e) {
            this._convex = e
        }
        _setScale(e) {
            if (this._compoundParent) this.updateLocalTransformations();
            else {
                var t = _.Physics3D._bullet;
                t.btVector3_setValue(d._btScale, e.x, e.y, e.z), t.btCollisionShape_setLocalScaling(this._btShape, d._btScale), t.btGImpactShapeInterface_updateBound(this._btShape)
            }
        }
        cloneTo(e) {
            var t = e;
            t.convex = this._convex, t.mesh = this._mesh, super.cloneTo(e)
        }
        clone() {
            var e = new R;
            return this.cloneTo(e), e
        }
        destroy() {
            this._btShape &amp;&amp; (_.Physics3D._bullet.btCollisionShape_destroy(this._btShape), this._btShape = null)
        }
    }
    class v extends d {
        constructor(e = .5) {
            super(), this._radius = e, this._type = d.SHAPETYPES_SPHERE, this._btShape = _.Physics3D._bullet.btSphereShape_create(e)
        }
        get radius() {
            return this._radius
        }
        clone() {
            var e = new v(this._radius);
            return this.cloneTo(e), e
        }
    }
    class A extends t.Component {
        constructor(e, t) {
            super(), this._restitution = 0, this._friction = .5, this._rollingFriction = 0, this._ccdMotionThreshold = 0, this._ccdSweptSphereRadius = 0, this._collisionGroup = T.COLLISIONFILTERGROUP_DEFAULTFILTER, this._canCollideWith = T.COLLISIONFILTERGROUP_ALLFILTER, this._colliderShape = null, this._transformFlag = 2147483647, this._controlBySimulation = !1, this._enableProcessCollisions = !0, this._inPhysicUpdateListIndex = -1, this.canScaleShape = !0, this._collisionGroup = e, this._canCollideWith = t, A._physicObjectsMap[this.id] = this
        }
        static __init__() {
            var e = _.Physics3D._bullet;
            A._btVector30 = e.btVector3_create(0, 0, 0), A._btQuaternion0 = e.btQuaternion_create(0, 0, 0, 1)
        }
        static _createAffineTransformationArray(e, t, r, i, n, a, s, o, l) {
            var _ = i + i,
                h = n + n,
                c = a + a,
                d = i * _,
                u = i * h,
                m = i * c,
                f = n * h,
                T = n * c,
                E = a * c,
                p = s * _,
                g = s * h,
                S = s * c,
                R = o[0],
                v = o[1],
                A = o[2];
            l[0] = (1 - (f + E)) * R, l[1] = (u + S) * R, l[2] = (m - g) * R, l[3] = 0, l[4] = (u - S) * v, l[5] = (1 - (d + E)) * v, l[6] = (T + p) * v, l[7] = 0, l[8] = (m + g) * A, l[9] = (T - p) * A, l[10] = (1 - (d + f)) * A, l[11] = 0, l[12] = e, l[13] = t, l[14] = r, l[15] = 1
        }
        static _creatShape(e) {
            var r;
            switch (e.type) {
                case "BoxColliderShape":
                    var i = e.size;
                    r = i ? new E(i[0], i[1], i[2]) : new E;
                    break;
                case "SphereColliderShape":
                    r = new v(e.radius);
                    break;
                case "CapsuleColliderShape":
                    r = new p(e.radius, e.height, e.orientation);
                    break;
                case "MeshColliderShape":
                    var n = new R;
                    e.mesh &amp;&amp; (n.mesh = t.Loader.getRes(e.mesh)), r = n;
                    break;
                case "ConeColliderShape":
                    r = new g(e.radius, e.height, e.orientation);
                    break;
                case "CylinderColliderShape":
                    r = new S(e.radius, e.height, e.orientation);
                    break;
                default:
                    throw "unknown shape type."
            }
            if (e.center) {
                var a = r.localOffset;
                a.fromArray(e.center), r.localOffset = a
            }
            return r
        }
        static physicVector3TransformQuat(e, t, r, i, n, a) {
            var s = e.x,
                o = e.y,
                l = e.z,
                _ = n * s + r * l - i * o,
                h = n * o + i * s - t * l,
                c = n * l + t * o - r * s,
                d = -t * s - r * o - i * l;
            a.x = _ * n + d * -t + h * -i - c * -r, a.y = h * n + d * -r + c * -t - _ * -i, a.z = c * n + d * -i + _ * -r - h * -t
        }
        static physicQuaternionMultiply(e, t, r, i, n, a) {
            var s = n.x,
                o = n.y,
                l = n.z,
                _ = n.w,
                h = t * l - r * o,
                c = r * s - e * l,
                d = e * o - t * s,
                u = e * s + t * o + r * l;
            a.x = e * _ + s * i + h, a.y = t * _ + o * i + c, a.z = r * _ + l * i + d, a.w = i * _ - u
        }
        get restitution() {
            return this._restitution
        }
        set restitution(e) {
            this._restitution = e, this._btColliderObject &amp;&amp; _.Physics3D._bullet.btCollisionObject_setRestitution(this._btColliderObject, e)
        }
        get friction() {
            return this._friction
        }
        set friction(e) {
            this._friction = e, this._btColliderObject &amp;&amp; _.Physics3D._bullet.btCollisionObject_setFriction(this._btColliderObject, e)
        }
        get rollingFriction() {
            return this._rollingFriction
        }
        set rollingFriction(e) {
            this._rollingFriction = e, this._btColliderObject &amp;&amp; _.Physics3D._bullet.btCollisionObject_setRollingFriction(this._btColliderObject, e)
        }
        get ccdMotionThreshold() {
            return this._ccdMotionThreshold
        }
        set ccdMotionThreshold(e) {
            this._ccdMotionThreshold = e, this._btColliderObject &amp;&amp; _.Physics3D._bullet.btCollisionObject_setCcdMotionThreshold(this._btColliderObject, e)
        }
        get ccdSweptSphereRadius() {
            return this._ccdSweptSphereRadius
        }
        set ccdSweptSphereRadius(e) {
            this._ccdSweptSphereRadius = e, this._btColliderObject &amp;&amp; _.Physics3D._bullet.btCollisionObject_setCcdSweptSphereRadius(this._btColliderObject, e)
        }
        get isActive() {
            return !!this._btColliderObject &amp;&amp; _.Physics3D._bullet.btCollisionObject_isActive(this._btColliderObject)
        }
        get colliderShape() {
            return this._colliderShape
        }
        set colliderShape(e) {
            var t = this._colliderShape;
            if (t &amp;&amp; (t._attatched = !1, t._attatchedCollisionObject = null), this._colliderShape = e, e) {
                if (e._attatched) throw "PhysicsComponent: this shape has attatched to other entity.";
                if (e._attatched = !0, e._attatchedCollisionObject = this, this._btColliderObject) {
                    _.Physics3D._bullet.btCollisionObject_setCollisionShape(this._btColliderObject, e._btShape);
                    var r = this._simulation &amp;&amp; this._enabled;
                    r &amp;&amp; t &amp;&amp; this._removeFromSimulation(), this._onShapeChange(e), r &amp;&amp; (this._derivePhysicsTransformation(!0), this._addToSimulation())
                }
            } else this._simulation &amp;&amp; this._enabled &amp;&amp; t &amp;&amp; this._removeFromSimulation()
        }
        get simulation() {
            return this._simulation
        }
        get collisionGroup() {
            return this._collisionGroup
        }
        set collisionGroup(e) {
            this._collisionGroup !== e &amp;&amp; (this._collisionGroup = e, this._simulation &amp;&amp; this._colliderShape &amp;&amp; this._enabled &amp;&amp; (this._removeFromSimulation(), this._addToSimulation()))
        }
        get canCollideWith() {
            return this._canCollideWith
        }
        set canCollideWith(e) {
            this._canCollideWith !== e &amp;&amp; (this._canCollideWith = e, this._simulation &amp;&amp; this._colliderShape &amp;&amp; this._enabled &amp;&amp; (this._removeFromSimulation(), this._addToSimulation()))
        }
        _parseShape(e) {
            var t = e.length;
            if (1 === t) {
                var r = A._creatShape(e[0]);
                this.colliderShape = r
            } else {
                for (var i = new m, n = 0; n &lt; t; n++) r = A._creatShape(e[n]), i.addChildShape(r);
                this.colliderShape = i
            }
        }
        _onScaleChange(e) {
            this._colliderShape._setScale(e)
        }
        _onEnable() {
            this._simulation = this.owner._scene.physicsSimulation, _.Physics3D._bullet.btCollisionObject_setContactProcessingThreshold(this._btColliderObject, 1e30), this._colliderShape &amp;&amp; (this._derivePhysicsTransformation(!0), this._addToSimulation())
        }
        _onDisable() {
            this._colliderShape &amp;&amp; (this._removeFromSimulation(), -1 !== this._inPhysicUpdateListIndex &amp;&amp; this._simulation._physicsUpdateList.remove(this)), this._simulation = null
        }
        _onDestroy() {
            delete A._physicObjectsMap[this.id], _.Physics3D._bullet.btCollisionObject_destroy(this._btColliderObject), this._colliderShape.destroy(), super._onDestroy(), this._btColliderObject = null, this._colliderShape = null, this._simulation = null, this.owner.transform.off(t.Event.TRANSFORM_CHANGED, this, this._onTransformChanged)
        }
        _isValid() {
            return this._simulation &amp;&amp; this._colliderShape &amp;&amp; this._enabled
        }
        _parse(e) {
            null != e.collisionGroup &amp;&amp; (this.collisionGroup = e.collisionGroup), null != e.canCollideWith &amp;&amp; (this.canCollideWith = e.canCollideWith), null != e.ccdMotionThreshold &amp;&amp; (this.ccdMotionThreshold = e.ccdMotionThreshold), null != e.ccdSweptSphereRadius &amp;&amp; (this.ccdSweptSphereRadius = e.ccdSweptSphereRadius)
        }
        _setTransformFlag(e, t) {
            t ? this._transformFlag |= e : this._transformFlag &amp;= ~e
        }
        _getTransformFlag(e) {
            return 0 != (this._transformFlag &amp; e)
        }
        _addToSimulation() {}
        _removeFromSimulation() {}
        _derivePhysicsTransformation(e) {
            var t = _.Physics3D._bullet,
                r = this._btColliderObject,
                i = t.btCollisionObject_getWorldTransform(r);
            this._innerDerivePhysicsTransformation(i, e), t.btCollisionObject_setWorldTransform(r, i)
        }
        _innerDerivePhysicsTransformation(e, t) {
            var r = _.Physics3D._bullet,
                i = this.owner._transform;
            if (t || this._getTransformFlag(f.TRANSFORM_WORLDPOSITION)) {
                var n = this._colliderShape.localOffset,
                    s = i.position,
                    o = A._btVector30;
                if (0 !== n.x || 0 !== n.y || 0 !== n.z) {
                    var l = A._tempVector30,
                        h = i.worldMatrix;
                    a.transformCoordinate(n, h, l), r.btVector3_setValue(o, -l.x, l.y, l.z)
                } else r.btVector3_setValue(o, -s.x, s.y, s.z);
                r.btTransform_setOrigin(e, o), this._setTransformFlag(f.TRANSFORM_WORLDPOSITION, !1)
            }
            if (t || this._getTransformFlag(f.TRANSFORM_WORLDQUATERNION)) {
                var c = this._colliderShape.localRotation,
                    d = A._btQuaternion0,
                    u = i.rotation;
                if (0 !== c.x || 0 !== c.y || 0 !== c.z || 1 !== c.w) {
                    var m = A._tempQuaternion0;
                    A.physicQuaternionMultiply(u.x, u.y, u.z, u.w, c, m), r.btQuaternion_setValue(d, -m.x, m.y, m.z, -m.w)
                } else r.btQuaternion_setValue(d, -u.x, u.y, u.z, -u.w);
                r.btTransform_setRotation(e, d), this._setTransformFlag(f.TRANSFORM_WORLDQUATERNION, !1)
            }(t || this._getTransformFlag(f.TRANSFORM_WORLDSCALE)) &amp;&amp; (this._onScaleChange(i.getWorldLossyScale()), this._setTransformFlag(f.TRANSFORM_WORLDSCALE, !1))
        }
        _updateTransformComponent(e) {
            var t = _.Physics3D._bullet,
                r = this._colliderShape,
                i = r.localOffset,
                n = r.localRotation,
                s = this.owner._transform,
                o = s.position,
                l = s.rotation,
                h = t.btTransform_getOrigin(e),
                c = t.btTransform_getRotation(e),
                d = -t.btQuaternion_x(c),
                u = t.btQuaternion_y(c),
                m = t.btQuaternion_z(c),
                f = -t.btQuaternion_w(c);
            if (0 !== n.x || 0 !== n.y || 0 !== n.z || 1 !== n.w) {
                var T = A._tempQuaternion0;
                n.invert(T), A.physicQuaternionMultiply(d, u, m, f, T, l)
            } else l.x = d, l.y = u, l.z = m, l.w = f;
            if (s.rotation = l, 0 !== i.x || 0 !== i.y || 0 !== i.z) {
                var E = t.btCollisionShape_getLocalScaling(r._btShape),
                    p = A._tempVector30;
                p.x = i.x * t.btVector3_x(E), p.y = i.y * t.btVector3_y(E), p.z = i.z * t.btVector3_z(E), a.transformQuat(p, l, p), o.x = -t.btVector3_x(h) - p.x, o.y = t.btVector3_y(h) - p.y, o.z = t.btVector3_z(h) - p.z
            } else o.x = -t.btVector3_x(h), o.y = t.btVector3_y(h), o.z = t.btVector3_z(h);
            s.position = o
        }
        _onShapeChange(e) {
            var t = this._btColliderObject,
                r = _.Physics3D._bullet,
                i = r.btCollisionObject_getCollisionFlags(t);
            e.needsCustomCollisionCallback ? 0 == (i &amp; A.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK) &amp;&amp; r.btCollisionObject_setCollisionFlags(t, i | A.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK) : (i &amp; A.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK) &gt; 0 &amp;&amp; r.btCollisionObject_setCollisionFlags(t, i ^ A.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK)
        }
        _onAdded() {
            this.enabled = this._enabled, this.restitution = this._restitution, this.friction = this._friction, this.rollingFriction = this._rollingFriction, this.ccdMotionThreshold = this._ccdMotionThreshold, this.ccdSweptSphereRadius = this._ccdSweptSphereRadius, this.owner.transform.on(t.Event.TRANSFORM_CHANGED, this, this._onTransformChanged)
        }
        _onTransformChanged(e) {
            !A._addUpdateList &amp;&amp; this._controlBySimulation || (e &amp;= f.TRANSFORM_WORLDPOSITION | f.TRANSFORM_WORLDQUATERNION | f.TRANSFORM_WORLDSCALE) &amp;&amp; (this._transformFlag |= e, this._isValid() &amp;&amp; -1 === this._inPhysicUpdateListIndex &amp;&amp; this._simulation._physicsUpdateList.add(this))
        }
        _cloneTo(e) {
            var t = e;
            t.restitution = this._restitution, t.friction = this._friction, t.rollingFriction = this._rollingFriction, t.ccdMotionThreshold = this._ccdMotionThreshold, t.ccdSweptSphereRadius = this._ccdSweptSphereRadius, t.collisionGroup = this._collisionGroup, t.canCollideWith = this._canCollideWith, t.canScaleShape = this.canScaleShape, this._colliderShape &amp;&amp; (t.colliderShape = this._colliderShape.clone())
        }
    }
    A.ACTIVATIONSTATE_ACTIVE_TAG = 1, A.ACTIVATIONSTATE_ISLAND_SLEEPING = 2, A.ACTIVATIONSTATE_WANTS_DEACTIVATION = 3, A.ACTIVATIONSTATE_DISABLE_DEACTIVATION = 4, A.ACTIVATIONSTATE_DISABLE_SIMULATION = 5, A.COLLISIONFLAGS_STATIC_OBJECT = 1, A.COLLISIONFLAGS_KINEMATIC_OBJECT = 2, A.COLLISIONFLAGS_NO_CONTACT_RESPONSE = 4, A.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK = 8, A.COLLISIONFLAGS_CHARACTER_OBJECT = 16, A.COLLISIONFLAGS_DISABLE_VISUALIZE_OBJECT = 32, A.COLLISIONFLAGS_DISABLE_SPU_COLLISION_PROCESSING = 64, A._tempVector30 = new a, A._tempQuaternion0 = new h, A._tempQuaternion1 = new h, A._tempMatrix4x40 = new c, A._physicObjectsMap = {}, A._addUpdateList = !0;
    class I {
        constructor() {
            this.elements = [], this.length = 0
        }
        _add(e) {
            this.length === this.elements.length ? this.elements.push(e) : this.elements[this.length] = e
        }
        add(e) {
            this.length === this.elements.length ? this.elements.push(e) : this.elements[this.length] = e, this.length++
        }
    }
    class x extends I {
        constructor() {
            super()
        }
        add(e) {
            if (-1 !== e._inPhysicUpdateListIndex) throw "PhysicsUpdateList:element has  in  PhysicsUpdateList.";
            this._add(e), e._inPhysicUpdateListIndex = this.length++
        }
        remove(e) {
            var t = e._inPhysicUpdateListIndex;
            if (this.length--, t !== this.length) {
                var r = this.elements[this.length];
                this.elements[t] = r, r._inPhysicUpdateListIndex = t
            }
            e._inPhysicUpdateListIndex = -1
        }
    }
    class L {
        constructor() {
            this._idCounter = 0, this.colliderA = null, this.colliderB = null, this.distance = 0, this.normal = new a, this.positionOnA = new a, this.positionOnB = new a, this._id = ++this._idCounter
        }
    }
    class D {
        constructor() {
            this.succeeded = !1, this.collider = null, this.point = new a, this.normal = new a, this.hitFraction = 0
        }
    }
    class C {
        constructor() {
            this._lastUpdateFrame = -2147483648, this._updateFrame = -2147483648, this._isTrigger = !1, this.contacts = []
        }
        _setUpdateFrame(e) {
            this._lastUpdateFrame = this._updateFrame, this._updateFrame = e
        }
    }
    class y {
        constructor() {
            this._hitResultsPoolIndex = 0, this._hitResultsPool = [], this._contactPonintsPoolIndex = 0, this._contactPointsPool = [], this._collisionsPool = [], this._collisions = {}
        }
        getHitResult() {
            var e = this._hitResultsPool[this._hitResultsPoolIndex++];
            return e || (e = new D, this._hitResultsPool.push(e)), e
        }
        recoverAllHitResultsPool() {
            this._hitResultsPoolIndex = 0
        }
        getContactPoints() {
            var e = this._contactPointsPool[this._contactPonintsPoolIndex++];
            return e || (e = new L, this._contactPointsPool.push(e)), e
        }
        recoverAllContactPointsPool() {
            this._contactPonintsPoolIndex = 0
        }
        getCollision(e, t) {
            var r, i = e.id,
                n = t.id,
                a = this._collisions[i];
            return a &amp;&amp; (r = a[n]), r || (a || (a = {}, this._collisions[i] = a), (r = 0 === this._collisionsPool.length ? new C : this._collisionsPool.pop())._colliderA = e, r._colliderB = t, a[n] = r), r
        }
        recoverCollision(e) {
            var t = e._colliderA.id,
                r = e._colliderB.id;
            this._collisions[t][r] = null, this._collisionsPool.push(e)
        }
        garbageCollection() {
            for (var e in this._hitResultsPoolIndex = 0, this._hitResultsPool.length = 0, this._contactPonintsPoolIndex = 0, this._contactPointsPool.length = 0, this._collisionsPool.length = 0, this._collisionsPool) {
                var t = this._collisionsPool[e],
                    r = !0;
                for (var i in t) t[i] ? r = !1 : delete t[i];
                r &amp;&amp; delete this._collisionsPool[e]
            }
        }
    }
    class M {
        constructor(e, t = 0) {
            this._gravity = new a(0, -10, 0), this._btVector3Zero = _.Physics3D._bullet.btVector3_create(0, 0, 0), this._btDefaultQuaternion = _.Physics3D._bullet.btQuaternion_create(0, 0, 0, -1), this._collisionsUtils = new y, this._previousFrameCollisions = [], this._currentFrameCollisions = [], this._currentConstraint = {}, this._physicsUpdateList = new x, this._characters = [], this._updatedRigidbodies = 0, this.maxSubSteps = 1, this.fixedTimeStep = 1 / 60, this.maxSubSteps = e.maxSubSteps, this.fixedTimeStep = e.fixedTimeStep;
            var r = _.Physics3D._bullet;
            this._btCollisionConfiguration = r.btDefaultCollisionConfiguration_create(), this._btDispatcher = r.btCollisionDispatcher_create(this._btCollisionConfiguration), this._btBroadphase = r.btDbvtBroadphase_create(), r.btOverlappingPairCache_setInternalGhostPairCallback(r.btDbvtBroadphase_getOverlappingPairCache(this._btBroadphase), r.btGhostPairCallback_create());
            var i = e.flags;
            if (i &amp; M.PHYSICSENGINEFLAGS_COLLISIONSONLY) this._btCollisionWorld = new r.btCollisionWorld(this._btDispatcher, this._btBroadphase, this._btCollisionConfiguration);
            else {
                if (i &amp; M.PHYSICSENGINEFLAGS_SOFTBODYSUPPORT) throw "PhysicsSimulation:SoftBody processing is not yet available";
                var n = r.btSequentialImpulseConstraintSolver_create();
                this._btDiscreteDynamicsWorld = r.btDiscreteDynamicsWorld_create(this._btDispatcher, this._btBroadphase, n, this._btCollisionConfiguration), this._btCollisionWorld = this._btDiscreteDynamicsWorld
            }
            this._btDiscreteDynamicsWorld &amp;&amp; (this._btSolverInfo = r.btDynamicsWorld_getSolverInfo(this._btDiscreteDynamicsWorld), this._btDispatchInfo = r.btCollisionWorld_getDispatchInfo(this._btDiscreteDynamicsWorld)), this._btClosestRayResultCallback = r.ClosestRayResultCallback_create(this._btVector3Zero, this._btVector3Zero), this._btAllHitsRayResultCallback = r.AllHitsRayResultCallback_create(this._btVector3Zero, this._btVector3Zero), this._btClosestConvexResultCallback = r.ClosestConvexResultCallback_create(this._btVector3Zero, this._btVector3Zero), this._btAllConvexResultCallback = r.AllConvexResultCallback_create(this._btVector3Zero, this._btVector3Zero), r.btGImpactCollisionAlgorithm_RegisterAlgorithm(this._btDispatcher)
        }
        static __init__() {
            var e = _.Physics3D._bullet;
            M._btTempVector30 = e.btVector3_create(0, 0, 0), M._btTempVector31 = e.btVector3_create(0, 0, 0), M._btTempQuaternion0 = e.btQuaternion_create(0, 0, 0, 1), M._btTempQuaternion1 = e.btQuaternion_create(0, 0, 0, 1), M._btTempTransform0 = e.btTransform_create(), M._btTempTransform1 = e.btTransform_create()
        }
        static createConstraint() {}
        get continuousCollisionDetection() {
            return _.Physics3D._bullet.btCollisionWorld_get_m_useContinuous(this._btDispatchInfo)
        }
        set continuousCollisionDetection(e) {
            _.Physics3D._bullet.btCollisionWorld_set_m_useContinuous(this._btDispatchInfo, e)
        }
        get gravity() {
            if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
            return this._gravity
        }
        set gravity(e) {
            if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
            this._gravity = e;
            var t = _.Physics3D._bullet,
                r = M._btTempVector30;
            t.btVector3_setValue(r, -e.x, e.y, e.z), t.btDiscreteDynamicsWorld_setGravity(this._btDiscreteDynamicsWorld, r)
        }
        get speculativeContactRestitution() {
            if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot Cannot perform this action when the physics engine is set to CollisionsOnly";
            return _.Physics3D._bullet.btDiscreteDynamicsWorld_getApplySpeculativeContactRestitution(this._btDiscreteDynamicsWorld)
        }
        set speculativeContactRestitution(e) {
            if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot Cannot perform this action when the physics engine is set to CollisionsOnly";
            _.Physics3D._bullet.btDiscreteDynamicsWorld_setApplySpeculativeContactRestitution(this._btDiscreteDynamicsWorld, e)
        }
        _simulate(e) {
            this._updatedRigidbodies = 0;
            var t = _.Physics3D._bullet;
            this._btDiscreteDynamicsWorld ? t.btDiscreteDynamicsWorld_stepSimulation(this._btDiscreteDynamicsWorld, e, this.maxSubSteps, this.fixedTimeStep) : t.PerformDiscreteCollisionDetection(this._btCollisionWorld)
        }
        _destroy() {
            var e = _.Physics3D._bullet;
            this._btDiscreteDynamicsWorld ? (e.btCollisionWorld_destroy(this._btDiscreteDynamicsWorld), this._btDiscreteDynamicsWorld = null) : (e.btCollisionWorld_destroy(this._btCollisionWorld), this._btCollisionWorld = null), e.btDbvtBroadphase_destroy(this._btBroadphase), this._btBroadphase = null, e.btCollisionDispatcher_destroy(this._btDispatcher), this._btDispatcher = null, e.btDefaultCollisionConfiguration_destroy(this._btCollisionConfiguration), this._btCollisionConfiguration = null
        }
        _addPhysicsCollider(e, t, r) {
            _.Physics3D._bullet.btCollisionWorld_addCollisionObject(this._btCollisionWorld, e._btColliderObject, t, r)
        }
        _removePhysicsCollider(e) {
            _.Physics3D._bullet.btCollisionWorld_removeCollisionObject(this._btCollisionWorld, e._btColliderObject)
        }
        _addRigidBody(e, t, r) {
            if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
            _.Physics3D._bullet.btDiscreteDynamicsWorld_addRigidBody(this._btCollisionWorld, e._btColliderObject, t, r)
        }
        _removeRigidBody(e) {
            if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
            _.Physics3D._bullet.btDiscreteDynamicsWorld_removeRigidBody(this._btCollisionWorld, e._btColliderObject)
        }
        _addCharacter(e, t, r) {
            if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
            var i = _.Physics3D._bullet;
            i.btCollisionWorld_addCollisionObject(this._btCollisionWorld, e._btColliderObject, t, r), i.btDynamicsWorld_addAction(this._btCollisionWorld, e._btKinematicCharacter)
        }
        _removeCharacter(e) {
            if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
            var t = _.Physics3D._bullet;
            t.btCollisionWorld_removeCollisionObject(this._btCollisionWorld, e._btColliderObject), t.btDynamicsWorld_removeAction(this._btCollisionWorld, e._btKinematicCharacter)
        }
        raycastFromTo(e, t, r = null, i = T.COLLISIONFILTERGROUP_ALLFILTER, n = T.COLLISIONFILTERGROUP_ALLFILTER) {
            var a = _.Physics3D._bullet,
                s = this._btClosestRayResultCallback,
                o = M._btTempVector30,
                l = M._btTempVector31;
            if (a.btVector3_setValue(o, -e.x, e.y, e.z), a.btVector3_setValue(l, -t.x, t.y, t.z), a.ClosestRayResultCallback_set_m_rayFromWorld(s, o), a.ClosestRayResultCallback_set_m_rayToWorld(s, l), a.RayResultCallback_set_m_collisionFilterGroup(s, i), a.RayResultCallback_set_m_collisionFilterMask(s, n), a.RayResultCallback_set_m_collisionObject(s, null), a.RayResultCallback_set_m_closestHitFraction(s, 1), a.btCollisionWorld_rayTest(this._btCollisionWorld, o, l, s), a.RayResultCallback_hasHit(s)) {
                if (r) {
                    r.succeeded = !0, r.collider = A._physicObjectsMap[a.btCollisionObject_getUserIndex(a.RayResultCallback_get_m_collisionObject(s))], r.hitFraction = a.RayResultCallback_get_m_closestHitFraction(s);
                    var h = a.ClosestRayResultCallback_get_m_hitPointWorld(s),
                        c = r.point;
                    c.x = -a.btVector3_x(h), c.y = a.btVector3_y(h), c.z = a.btVector3_z(h);
                    var d = a.ClosestRayResultCallback_get_m_hitNormalWorld(s),
                        u = r.normal;
                    u.x = -a.btVector3_x(d), u.y = a.btVector3_y(d), u.z = a.btVector3_z(d)
                }
                return !0
            }
            return r &amp;&amp; (r.succeeded = !1), !1
        }
        raycastAllFromTo(e, t, r, i = T.COLLISIONFILTERGROUP_ALLFILTER, n = T.COLLISIONFILTERGROUP_ALLFILTER) {
            var a = _.Physics3D._bullet,
                s = this._btAllHitsRayResultCallback,
                o = M._btTempVector30,
                l = M._btTempVector31;
            r.length = 0, a.btVector3_setValue(o, -e.x, e.y, e.z), a.btVector3_setValue(l, -t.x, t.y, t.z), a.AllHitsRayResultCallback_set_m_rayFromWorld(s, o), a.AllHitsRayResultCallback_set_m_rayToWorld(s, l), a.RayResultCallback_set_m_collisionFilterGroup(s, i), a.RayResultCallback_set_m_collisionFilterMask(s, n);
            var h = a.AllHitsRayResultCallback_get_m_collisionObjects(s),
                c = a.AllHitsRayResultCallback_get_m_hitPointWorld(s),
                d = a.AllHitsRayResultCallback_get_m_hitNormalWorld(s),
                u = a.AllHitsRayResultCallback_get_m_hitFractions(s);
            a.tBtCollisionObjectArray_clear(h), a.tVector3Array_clear(c), a.tVector3Array_clear(d), a.tScalarArray_clear(u), a.btCollisionWorld_rayTest(this._btCollisionWorld, o, l, s);
            var m = a.tBtCollisionObjectArray_size(h);
            if (m &gt; 0) {
                this._collisionsUtils.recoverAllHitResultsPool();
                for (var f = 0; f &lt; m; f++) {
                    var E = this._collisionsUtils.getHitResult();
                    r.push(E), E.succeeded = !0, E.collider = A._physicObjectsMap[a.btCollisionObject_getUserIndex(a.tBtCollisionObjectArray_at(h, f))], E.hitFraction = a.tScalarArray_at(u, f);
                    var p = a.tVector3Array_at(c, f),
                        g = E.point;
                    g.x = -a.btVector3_x(p), g.y = a.btVector3_y(p), g.z = a.btVector3_z(p);
                    var S = a.tVector3Array_at(d, f),
                        R = E.normal;
                    R.x = -a.btVector3_x(S), R.y = a.btVector3_y(S), R.z = a.btVector3_z(S)
                }
                return !0
            }
            return !1
        }
        rayCast(e, t = null, r = 2147483647, i = T.COLLISIONFILTERGROUP_ALLFILTER, n = T.COLLISIONFILTERGROUP_ALLFILTER) {
            var s = e.origin,
                o = M._tempVector30;
            return a.normalize(e.direction, o), a.scale(o, r, o), a.add(s, o, o), this.raycastFromTo(s, o, t, i, n)
        }
        rayCastAll(e, t, r = 2147483647, i = T.COLLISIONFILTERGROUP_ALLFILTER, n = T.COLLISIONFILTERGROUP_ALLFILTER) {
            var s = e.origin,
                o = M._tempVector30;
            return a.normalize(e.direction, o), a.scale(o, r, o), a.add(s, o, o), this.raycastAllFromTo(s, o, t, i, n)
        }
        shapeCast(e, t, r, i = null, n = null, a = null, s = T.COLLISIONFILTERGROUP_ALLFILTER, o = T.COLLISIONFILTERGROUP_ALLFILTER, l = 0) {
            var h = _.Physics3D._bullet,
                c = this._btClosestConvexResultCallback,
                d = M._btTempVector30,
                u = M._btTempVector31,
                m = M._btTempQuaternion0,
                f = M._btTempQuaternion1,
                E = M._btTempTransform0,
                p = M._btTempTransform1,
                g = e._btShape;
            if (h.btVector3_setValue(d, -t.x, t.y, t.z), h.btVector3_setValue(u, -r.x, r.y, r.z), h.ConvexResultCallback_set_m_collisionFilterGroup(c, s), h.ConvexResultCallback_set_m_collisionFilterMask(c, o), h.btTransform_setOrigin(E, d), h.btTransform_setOrigin(p, u), n ? (h.btQuaternion_setValue(m, -n.x, n.y, n.z, -n.w), h.btTransform_setRotation(E, m)) : h.btTransform_setRotation(E, this._btDefaultQuaternion), a ? (h.btQuaternion_setValue(f, -a.x, a.y, a.z, -a.w), h.btTransform_setRotation(p, f)) : h.btTransform_setRotation(p, this._btDefaultQuaternion), h.ClosestConvexResultCallback_set_m_hitCollisionObject(c, null), h.ConvexResultCallback_set_m_closestHitFraction(c, 1), h.btCollisionWorld_convexSweepTest(this._btCollisionWorld, g, E, p, c, l), h.ConvexResultCallback_hasHit(c)) {
                if (i) {
                    i.succeeded = !0, i.collider = A._physicObjectsMap[h.btCollisionObject_getUserIndex(h.ClosestConvexResultCallback_get_m_hitCollisionObject(c))], i.hitFraction = h.ConvexResultCallback_get_m_closestHitFraction(c);
                    var S = h.ClosestConvexResultCallback_get_m_hitPointWorld(c),
                        R = h.ClosestConvexResultCallback_get_m_hitNormalWorld(c),
                        v = i.point,
                        I = i.normal;
                    v.x = -h.btVector3_x(S), v.y = h.btVector3_y(S), v.z = h.btVector3_z(S), I.x = -h.btVector3_x(R), I.y = h.btVector3_y(R), I.z = h.btVector3_z(R)
                }
                return !0
            }
            return i &amp;&amp; (i.succeeded = !1), !1
        }
        shapeCastAll(e, t, r, i, n = null, a = null, s = T.COLLISIONFILTERGROUP_ALLFILTER, o = T.COLLISIONFILTERGROUP_ALLFILTER, l = 0) {
            var h = _.Physics3D._bullet,
                c = this._btAllConvexResultCallback,
                d = M._btTempVector30,
                u = M._btTempVector31,
                m = M._btTempQuaternion0,
                f = M._btTempQuaternion1,
                E = M._btTempTransform0,
                p = M._btTempTransform1,
                g = e._btShape;
            i.length = 0, h.btVector3_setValue(d, -t.x, t.y, t.z), h.btVector3_setValue(u, -r.x, r.y, r.z), h.ConvexResultCallback_set_m_collisionFilterGroup(c, s), h.ConvexResultCallback_set_m_collisionFilterMask(c, o), h.btTransform_setOrigin(E, d), h.btTransform_setOrigin(p, u), n ? (h.btQuaternion_setValue(m, -n.x, n.y, n.z, -n.w), h.btTransform_setRotation(E, m)) : h.btTransform_setRotation(E, this._btDefaultQuaternion), a ? (h.btQuaternion_setValue(f, -a.x, a.y, a.z, -a.w), h.btTransform_setRotation(p, f)) : h.btTransform_setRotation(p, this._btDefaultQuaternion);
            var S = h.AllConvexResultCallback_get_m_collisionObjects(c);
            h.tBtCollisionObjectArray_clear(S), h.btCollisionWorld_convexSweepTest(this._btCollisionWorld, g, E, p, c, l);
            var R = h.tBtCollisionObjectArray_size(S);
            if (R &gt; 0) {
                this._collisionsUtils.recoverAllHitResultsPool();
                for (var v = h.AllConvexResultCallback_get_m_hitPointWorld(c), I = h.AllConvexResultCallback_get_m_hitNormalWorld(c), x = h.AllConvexResultCallback_get_m_hitFractions(c), L = 0; L &lt; R; L++) {
                    var D = this._collisionsUtils.getHitResult();
                    i.push(D), D.succeeded = !0, D.collider = A._physicObjectsMap[h.btCollisionObject_getUserIndex(h.tBtCollisionObjectArray_at(S, L))], D.hitFraction = h.tScalarArray_at(x, L);
                    var C = h.tVector3Array_at(v, L),
                        y = D.point;
                    y.x = -h.btVector3_x(C), y.y = h.btVector3_y(C), y.z = h.btVector3_z(C);
                    var O = h.tVector3Array_at(I, L),
                        N = D.normal;
                    N.x = -h.btVector3_x(O), N.y = h.btVector3_y(O), N.z = h.btVector3_z(O)
                }
                return !0
            }
            return !1
        }
        addConstraint(e, t = !1) {
            if (!this._btDiscreteDynamicsWorld) throw "Cannot perform this action when the physics engine is set to CollisionsOnly";
            _.Physics3D._bullet.btCollisionWorld_addConstraint(this._btDiscreteDynamicsWorld, e._btConstraint, t), this._currentConstraint[e.id] = e
        }
        removeConstraint(e) {
            if (!this._btDiscreteDynamicsWorld) throw "Cannot perform this action when the physics engine is set to CollisionsOnly";
            _.Physics3D._bullet.btCollisionWorld_removeConstraint(this._btDiscreteDynamicsWorld, e._btConstraint), delete this._currentConstraint[e.id]
        }
        _updatePhysicsTransformFromRender() {
            for (var e = this._physicsUpdateList.elements, t = 0, r = this._physicsUpdateList.length; t &lt; r; t++) {
                var i = e[t];
                i._derivePhysicsTransformation(!1), i._inPhysicUpdateListIndex = -1
            }
            this._physicsUpdateList.length = 0
        }
        _updateCharacters() {
            for (var e = 0, t = this._characters.length; e &lt; t; e++) {
                var r = this._characters[e];
                r._updateTransformComponent(_.Physics3D._bullet.btCollisionObject_getWorldTransform(r._btColliderObject))
            }
        }
        _updateCollisions() {
            this._collisionsUtils.recoverAllContactPointsPool();
            var e = this._currentFrameCollisions;
            this._currentFrameCollisions = this._previousFrameCollisions, this._currentFrameCollisions.length = 0, this._previousFrameCollisions = e;
            for (var r = t.Stat.loopCount, i = _.Physics3D._bullet, n = i.btDispatcher_getNumManifolds(this._btDispatcher), a = 0; a &lt; n; a++) {
                var s, o = i.btDispatcher_getManifoldByIndexInternal(this._btDispatcher, a),
                    l = A._physicObjectsMap[i.btCollisionObject_getUserIndex(i.btPersistentManifold_getBody0(o))],
                    h = A._physicObjectsMap[i.btCollisionObject_getUserIndex(i.btPersistentManifold_getBody1(o))],
                    c = null,
                    d = null;
                if ((l.isTrigger || h.isTrigger) &amp;&amp; (l.owner._needProcessTriggers || h.owner._needProcessTriggers))
                    for (var u = i.btPersistentManifold_getNumContacts(o), m = 0; m &lt; u; m++) {
                        var f = i.btPersistentManifold_getContactPoint(o, m),
                            T = i.btManifoldPoint_getDistance(f);
                        if (T &lt;= 0) {
                            d = (c = this._collisionsUtils.getCollision(l, h)).contacts, (s = c._updateFrame !== r) &amp;&amp; (c._isTrigger = !0, d.length = 0);
                            break
                        }
                    } else if ((l.owner._needProcessCollisions || h.owner._needProcessCollisions) &amp;&amp; (l._enableProcessCollisions || h._enableProcessCollisions))
                        for (u = i.btPersistentManifold_getNumContacts(o), m = 0; m &lt; u; m++)
                            if (f = i.btPersistentManifold_getContactPoint(o, m), (T = i.btManifoldPoint_getDistance(f)) &lt;= 0) {
                                var E = this._collisionsUtils.getContactPoints();
                                E.colliderA = l, E.colliderB = h, E.distance = T;
                                var p = i.btManifoldPoint_get_m_normalWorldOnB(f),
                                    g = E.normal;
                                g.x = -i.btVector3_x(p), g.y = i.btVector3_y(p), g.z = i.btVector3_z(p);
                                var S = i.btManifoldPoint_get_m_positionWorldOnA(f),
                                    R = E.positionOnA;
                                R.x = -i.btVector3_x(S), R.y = i.btVector3_y(S), R.z = i.btVector3_z(S);
                                var v = i.btManifoldPoint_get_m_positionWorldOnB(f),
                                    I = E.positionOnB;
                                I.x = -i.btVector3_x(v), I.y = i.btVector3_y(v), I.z = i.btVector3_z(v), c || (d = (c = this._collisionsUtils.getCollision(l, h)).contacts, (s = c._updateFrame !== r) &amp;&amp; (c._isTrigger = !1, d.length = 0)), d.push(E)
                            }
                c &amp;&amp; s &amp;&amp; (this._currentFrameCollisions.push(c), c._setUpdateFrame(r))
            }
        }
        _eventScripts() {
            for (var e = t.Stat.loopCount, r = 0, i = this._currentFrameCollisions.length; r &lt; i; r++) {
                var n = this._currentFrameCollisions[r],
                    a = n._colliderA,
                    s = n._colliderB;
                if (!a.destroyed &amp;&amp; !s.destroyed)
                    if (e - n._lastUpdateFrame == 1) {
                        var o = a.owner,
                            l = o._scripts;
                        if (l)
                            if (n._isTrigger) {
                                if (o._needProcessTriggers)
                                    for (var _ = 0, h = l.length; _ &lt; h; _++) l[_].onTriggerStay(s)
                            } else if (o._needProcessCollisions)
                            for (_ = 0, h = l.length; _ &lt; h; _++) n.other = s, l[_].onCollisionStay(n);
                        var c = s.owner,
                            d = c._scripts;
                        if (d)
                            if (n._isTrigger) {
                                if (c._needProcessTriggers)
                                    for (_ = 0, h = d.length; _ &lt; h; _++) d[_].onTriggerStay(a)
                            } else if (c._needProcessCollisions)
                            for (_ = 0, h = d.length; _ &lt; h; _++) n.other = a, d[_].onCollisionStay(n)
                    } else {
                        if (l = (o = a.owner)._scripts)
                            if (n._isTrigger) {
                                if (o._needProcessTriggers)
                                    for (_ = 0, h = l.length; _ &lt; h; _++) l[_].onTriggerEnter(s)
                            } else if (o._needProcessCollisions)
                            for (_ = 0, h = l.length; _ &lt; h; _++) n.other = s, l[_].onCollisionEnter(n);
                        if (d = (c = s.owner)._scripts)
                            if (n._isTrigger) {
                                if (c._needProcessTriggers)
                                    for (_ = 0, h = d.length; _ &lt; h; _++) d[_].onTriggerEnter(a)
                            } else if (c._needProcessCollisions)
                            for (_ = 0, h = d.length; _ &lt; h; _++) n.other = a, d[_].onCollisionEnter(n)
                    }
            }
            for (r = 0, i = this._previousFrameCollisions.length; r &lt; i; r++) {
                var u = this._previousFrameCollisions[r],
                    m = u._colliderA,
                    f = u._colliderB;
                if (!m.destroyed &amp;&amp; !f.destroyed &amp;&amp; e - u._updateFrame == 1) {
                    if (this._collisionsUtils.recoverCollision(u), l = (o = m.owner)._scripts)
                        if (u._isTrigger) {
                            if (o._needProcessTriggers)
                                for (_ = 0, h = l.length; _ &lt; h; _++) l[_].onTriggerExit(f)
                        } else if (o._needProcessCollisions)
                        for (_ = 0, h = l.length; _ &lt; h; _++) u.other = f, l[_].onCollisionExit(u);
                    if (d = (c = f.owner)._scripts)
                        if (u._isTrigger) {
                            if (c._needProcessTriggers)
                                for (_ = 0, h = d.length; _ &lt; h; _++) d[_].onTriggerExit(m)
                        } else if (c._needProcessCollisions)
                        for (_ = 0, h = d.length; _ &lt; h; _++) u.other = m, d[_].onCollisionExit(u)
                }
            }
            for (var T in this._currentConstraint) {
                var E = this._currentConstraint[T],
                    p = E.owner._scripts;
                if (E.enabled &amp;&amp; E._isBreakConstrained() &amp;&amp; p &amp;&amp; 0 != p.length)
                    for (r = 0, i = p.length; r &lt; i; r++) p[r].onJointBreak()
            }
        }
        clearForces() {
            if (!this._btDiscreteDynamicsWorld) throw "Cannot perform this action when the physics engine is set to CollisionsOnly";
            _.Physics3D._bullet.btDiscreteDynamicsWorld_clearForces(this._btDiscreteDynamicsWorld)
        }
    }
    M.PHYSICSENGINEFLAGS_NONE = 0, M.PHYSICSENGINEFLAGS_COLLISIONSONLY = 1, M.PHYSICSENGINEFLAGS_SOFTBODYSUPPORT = 2, M.PHYSICSENGINEFLAGS_MULTITHREADED = 4, M.PHYSICSENGINEFLAGS_USEHARDWAREWHENPOSSIBLE = 8, M.SOLVERMODE_RANDMIZE_ORDER = 1, M.SOLVERMODE_FRICTION_SEPARATE = 2, M.SOLVERMODE_USE_WARMSTARTING = 4, M.SOLVERMODE_USE_2_FRICTION_DIRECTIONS = 16, M.SOLVERMODE_ENABLE_FRICTION_DIRECTION_CACHING = 32, M.SOLVERMODE_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION = 64, M.SOLVERMODE_CACHE_FRIENDLY = 128, M.SOLVERMODE_SIMD = 256, M.SOLVERMODE_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS = 512, M.SOLVERMODE_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS = 1024, M._tempVector30 = new a, M.disableSimulation = !1;
    class O {
        constructor() {}
        static lightAttenTexture(e, t, r, i, n, a) {
            var s = e / r,
                o = 1 / (1 + 25 * s);
            s &gt;= .64 &amp;&amp; (s &gt; 1 ? o = 0 : o *= 1 - (s - .64) / .36), a[n] = Math.floor(255 * o + .5)
        }
        static haloTexture(e, t, r, i, n, a) {
            var s = (e - (r &gt;&gt;= 1)) / r,
                o = (t - (i &gt;&gt;= 1)) / i,
                l = s * s + o * o;
            l &gt; 1 &amp;&amp; (l = 1), a[n] = Math.floor(255 * (1 - l) + .5)
        }
        static _generateTexture2D(e, r, i, n) {
            var a = 0,
                s = 0;
            switch (e.format) {
                case t.TextureFormat.R8G8B8:
                    s = 3;
                    break;
                case t.TextureFormat.R8G8B8A8:
                    s = 4;
                    break;
                case t.TextureFormat.Alpha8:
                    s = 1;
                    break;
                default:
                    throw "GeneratedTexture._generateTexture: unkonw texture format."
            }
            for (var o = new Uint8Array(r * i * s), l = 0; l &lt; i; l++)
                for (var _ = 0; _ &lt; r; _++) n(_, l, r, i, a, o), a += s;
            e.setPixels(o)
        }
    }
    class N {
        static _createFloatTextureBuffer(e, r) {
            var i = new t.Texture2D(e, r, t.TextureFormat.R32G32B32A32, !1, !1);
            return i.filterMode = t.FilterMode.Point, i.wrapModeU = t.WarpMode.Clamp, i.wrapModeV = t.WarpMode.Clamp, i.anisoLevel = 0, i
        }
        static _convertToLayaVec3(e, t, r) {
            var i = _.Physics3D._bullet;
            t.x = r ? -i.btVector3_x(e) : i.btVector3_x(e), t.y = i.btVector3_y(e), t.z = i.btVector3_z(e)
        }
        static _convertToBulletVec3(e, t, r) {
            _.Physics3D._bullet.btVector3_setValue(t, r ? -e.x : e.x, e.y, e.z)
        }
        static _rotationTransformScaleSkinAnimation(e, t, r, i, n, a, s, o, l, _, h, c) {
            var d, u, m, f, T, E = N._tempArray16_0,
                p = N._tempArray16_1,
                g = N._tempArray16_2,
                S = i + i,
                R = n + n,
                v = a + a,
                A = i * S,
                I = n * S,
                x = n * R,
                L = a * S,
                D = a * R,
                C = a * v,
                y = s * S,
                M = s * R,
                O = s * v;
            for (E[15] = 1, E[0] = 1 - x - C, E[1] = I + O, E[2] = L - M, E[4] = I - O, E[5] = 1 - A - C, E[6] = D + y, E[8] = L + M, E[9] = D - y, E[10] = 1 - A - x, p[15] = 1, p[0] = o, p[5] = l, p[10] = _, d = 0; d &lt; 4; d++) u = E[d], m = E[d + 4], f = E[d + 8], T = E[d + 12], g[d] = u, g[d + 4] = m, g[d + 8] = f, g[d + 12] = u * e + m * t + f * r + T;
            for (d = 0; d &lt; 4; d++) u = g[d], m = g[d + 4], f = g[d + 8], T = g[d + 12], h[d + c] = u * p[0] + m * p[1] + f * p[2] + T * p[3], h[d + c + 4] = u * p[4] + m * p[5] + f * p[6] + T * p[7], h[d + c + 8] = u * p[8] + m * p[9] + f * p[10] + T * p[11], h[d + c + 12] = u * p[12] + m * p[13] + f * p[14] + T * p[15]
        }
        static _computeBoneAndAnimationDatasByBindPoseMatrxix(e, t, r, i, n, a) {
            var s, o, l = 0,
                _ = 0,
                h = e.length;
            for (s = 0; s &lt; h; l += e[s].keyframeWidth, _ += 16, s++) N._rotationTransformScaleSkinAnimation(t[l + 0], t[l + 1], t[l + 2], t[l + 3], t[l + 4], t[l + 5], t[l + 6], t[l + 7], t[l + 8], t[l + 9], i, _), 0 != s &amp;&amp; (o = 16 * e[s].parentIndex, N.mulMatrixByArray(i, o, i, _, i, _));
            var c = r.length;
            for (s = 0; s &lt; c; s++) N.mulMatrixByArrayAndMatrixFast(i, 16 * a[s], r[s], n, 16 * s)
        }
        static _computeAnimationDatasByArrayAndMatrixFast(e, t, r, i) {
            for (var n = 0, a = e.length; n &lt; a; n++) N.mulMatrixByArrayAndMatrixFast(t, 16 * i[n], e[n], r, 16 * n)
        }
        static _computeBoneAndAnimationDatasByBindPoseMatrxixOld(e, t, r, i, n) {
            var a, s, o = 0,
                l = 0,
                _ = e.length;
            for (a = 0; a &lt; _; o += e[a].keyframeWidth, l += 16, a++) N._rotationTransformScaleSkinAnimation(t[o + 7], t[o + 8], t[o + 9], t[o + 3], t[o + 4], t[o + 5], t[o + 6], t[o + 0], t[o + 1], t[o + 2], i, l), 0 != a &amp;&amp; (s = 16 * e[a].parentIndex, N.mulMatrixByArray(i, s, i, l, i, l));
            var h = r.length;
            for (a = 0; a &lt; h; a++) {
                var c = 16 * a;
                N.mulMatrixByArrayAndMatrixFast(i, c, r[a], n, c)
            }
        }
        static _computeAnimationDatasByArrayAndMatrixFastOld(e, t, r) {
            for (var i = e.length, n = 0; n &lt; i; n++) {
                var a = 16 * n;
                N.mulMatrixByArrayAndMatrixFast(t, a, e[n], r, a)
            }
        }
        static _computeRootAnimationData(e, t, r) {
            for (var i = 0, n = 0, a = 0, s = e.length; i &lt; s; n += e[i].keyframeWidth, a += 16, i++) N.createAffineTransformationArray(t[n + 0], t[n + 1], t[n + 2], t[n + 3], t[n + 4], t[n + 5], t[n + 6], t[n + 7], t[n + 8], t[n + 9], r, a)
        }
        static transformVector3ArrayByQuat(e, t, r, i, n) {
            var a = e[t],
                s = e[t + 1],
                o = e[t + 2],
                l = r.x,
                _ = r.y,
                h = r.z,
                c = r.w,
                d = c * a + _ * o - h * s,
                u = c * s + h * a - l * o,
                m = c * o + l * s - _ * a,
                f = -l * a - _ * s - h * o;
            i[n] = d * c + f * -l + u * -h - m * -_, i[n + 1] = u * c + f * -_ + m * -l - d * -h, i[n + 2] = m * c + f * -h + d * -_ - u * -l
        }
        static mulMatrixByArray(e, t, r, i, n, a) {
            var s, o, l, _, h;
            if (n === r) {
                for (r = N._tempArray16_3, s = 0; s &lt; 16; ++s) r[s] = n[a + s];
                i = 0
            }
            for (s = 0; s &lt; 4; s++) o = e[t + s], l = e[t + s + 4], _ = e[t + s + 8], h = e[t + s + 12], n[a + s] = o * r[i + 0] + l * r[i + 1] + _ * r[i + 2] + h * r[i + 3], n[a + s + 4] = o * r[i + 4] + l * r[i + 5] + _ * r[i + 6] + h * r[i + 7], n[a + s + 8] = o * r[i + 8] + l * r[i + 9] + _ * r[i + 10] + h * r[i + 11], n[a + s + 12] = o * r[i + 12] + l * r[i + 13] + _ * r[i + 14] + h * r[i + 15]
        }
        static mulMatrixByArrayFast(e, t, r, i, n, a) {
            var s, o, l, _, h;
            for (s = 0; s &lt; 4; s++) o = e[t + s], l = e[t + s + 4], _ = e[t + s + 8], h = e[t + s + 12], n[a + s] = o * r[i + 0] + l * r[i + 1] + _ * r[i + 2] + h * r[i + 3], n[a + s + 4] = o * r[i + 4] + l * r[i + 5] + _ * r[i + 6] + h * r[i + 7], n[a + s + 8] = o * r[i + 8] + l * r[i + 9] + _ * r[i + 10] + h * r[i + 11], n[a + s + 12] = o * r[i + 12] + l * r[i + 13] + _ * r[i + 14] + h * r[i + 15]
        }
        static mulMatrixByArrayAndMatrixFast(e, t, r, i, n) {
            var a, s, o, l, _, h = r.elements,
                c = h[0],
                d = h[1],
                u = h[2],
                m = h[3],
                f = h[4],
                T = h[5],
                E = h[6],
                p = h[7],
                g = h[8],
                S = h[9],
                R = h[10],
                v = h[11],
                A = h[12],
                I = h[13],
                x = h[14],
                L = h[15],
                D = t,
                C = t + 4,
                y = t + 8,
                M = t + 12,
                O = n,
                N = n + 4,
                b = n + 8,
                P = n + 12;
            for (a = 0; a &lt; 4; a++) s = e[D + a], o = e[C + a], l = e[y + a], _ = e[M + a], i[O + a] = s * c + o * d + l * u + _ * m, i[N + a] = s * f + o * T + l * E + _ * p, i[b + a] = s * g + o * S + l * R + _ * v, i[P + a] = s * A + o * I + l * x + _ * L
        }
        static createAffineTransformationArray(e, t, r, i, n, a, s, o, l, _, h, c) {
            var d = i + i,
                u = n + n,
                m = a + a,
                f = i * d,
                T = i * u,
                E = i * m,
                p = n * u,
                g = n * m,
                S = a * m,
                R = s * d,
                v = s * u,
                A = s * m;
            h[c + 0] = (1 - (p + S)) * o, h[c + 1] = (T + A) * o, h[c + 2] = (E - v) * o, h[c + 3] = 0, h[c + 4] = (T - A) * l, h[c + 5] = (1 - (f + S)) * l, h[c + 6] = (g + R) * l, h[c + 7] = 0, h[c + 8] = (E + v) * _, h[c + 9] = (g - R) * _, h[c + 10] = (1 - (f + p)) * _, h[c + 11] = 0, h[c + 12] = e, h[c + 13] = t, h[c + 14] = r, h[c + 15] = 1
        }
        static transformVector3ArrayToVector3ArrayCoordinate(e, t, r, i, n) {
            var a = e[t + 0],
                s = e[t + 1],
                o = e[t + 2],
                l = r.elements,
                _ = a * l[3] + s * l[7] + o * l[11] + l[15];
            i[n] = a * l[0] + s * l[4] + o * l[8] + l[12] / _, i[n + 1] = a * l[1] + s * l[5] + o * l[9] + l[13] / _, i[n + 2] = a * l[2] + s * l[6] + o * l[10] + l[14] / _
        }
        static transformVector3ArrayToVector3ArrayNormal(e, t, r, i, n) {
            var a = e[t + 0],
                s = e[t + 1],
                o = e[t + 2],
                l = r.elements;
            i[n] = a * l[0] + s * l[4] + o * l[8], i[n + 1] = a * l[1] + s * l[5] + o * l[9], i[n + 2] = a * l[2] + s * l[6] + o * l[10]
        }
        static transformLightingMapTexcoordArray(e, t, r, i, n) {
            i[n + 0] = e[t + 0] * r.x + r.z, i[n + 1] = 1 - ((1 - e[t + 1]) * r.y + r.w)
        }
        static getURLVerion(e) {
            var t = e.indexOf("?");
            return t &gt;= 0 ? e.substr(t) : null
        }
        static _createAffineTransformationArray(e, t, r, i) {
            var n = t.x,
                a = t.y,
                s = t.z,
                o = t.w,
                l = n + n,
                _ = a + a,
                h = s + s,
                c = n * l,
                d = n * _,
                u = n * h,
                m = a * _,
                f = a * h,
                T = s * h,
                E = o * l,
                p = o * _,
                g = o * h,
                S = r.x,
                R = r.y,
                v = r.z;
            i[0] = (1 - (m + T)) * S, i[1] = (d + g) * S, i[2] = (u - p) * S, i[3] = 0, i[4] = (d - g) * R, i[5] = (1 - (c + T)) * R, i[6] = (f + E) * R, i[7] = 0, i[8] = (u + p) * v, i[9] = (f - E) * v, i[10] = (1 - (c + m)) * v, i[11] = 0, i[12] = e.x, i[13] = e.y, i[14] = e.z, i[15] = 1
        }
        static _mulMatrixArray(e, t, r, i, n) {
            var a = t,
                s = e,
                o = i,
                l = a[r],
                _ = a[r + 1],
                h = a[r + 2],
                c = a[r + 3],
                d = a[r + 4],
                u = a[r + 5],
                m = a[r + 6],
                f = a[r + 7],
                T = a[r + 8],
                E = a[r + 9],
                p = a[r + 10],
                g = a[r + 11],
                S = a[r + 12],
                R = a[r + 13],
                v = a[r + 14],
                A = a[r + 15],
                I = s[0],
                x = s[1],
                L = s[2],
                D = s[3],
                C = s[4],
                y = s[5],
                M = s[6],
                O = s[7],
                N = s[8],
                b = s[9],
                P = s[10],
                w = s[11],
                V = s[12],
                B = s[13],
                F = s[14],
                U = s[15];
            o[n] = l * I + _ * C + h * N + c * V, o[n + 1] = l * x + _ * y + h * b + c * B, o[n + 2] = l * L + _ * M + h * P + c * F, o[n + 3] = l * D + _ * O + h * w + c * U, o[n + 4] = d * I + u * C + m * N + f * V, o[n + 5] = d * x + u * y + m * b + f * B, o[n + 6] = d * L + u * M + m * P + f * F, o[n + 7] = d * D + u * O + m * w + f * U, o[n + 8] = T * I + E * C + p * N + g * V, o[n + 9] = T * x + E * y + p * b + g * B, o[n + 10] = T * L + E * M + p * P + g * F, o[n + 11] = T * D + E * O + p * w + g * U, o[n + 12] = S * I + R * C + v * N + A * V, o[n + 13] = S * x + R * y + v * b + A * B, o[n + 14] = S * L + R * M + v * P + A * F, o[n + 15] = S * D + R * O + v * w + A * U
        }
        static arcTanAngle(e, t) {
            return 0 == e ? 1 == t ? Math.PI / 2 : -Math.PI / 2 : e &gt; 0 ? Math.atan(t / e) : e &lt; 0 ? t &gt; 0 ? Math.atan(t / e) + Math.PI : Math.atan(t / e) - Math.PI : 0
        }
        static angleTo(e, t, r) {
            a.subtract(t, e, h.TEMPVector30), a.normalize(h.TEMPVector30, h.TEMPVector30), r.x = Math.asin(h.TEMPVector30.y), r.y = N.arcTanAngle(-h.TEMPVector30.z, -h.TEMPVector30.x)
        }
        static transformQuat(e, t, r) {
            var i = t,
                n = e.x,
                a = e.y,
                s = e.z,
                o = i[0],
                l = i[1],
                _ = i[2],
                h = i[3],
                c = h * n + l * s - _ * a,
                d = h * a + _ * n - o * s,
                u = h * s + o * a - l * n,
                m = -o * n - l * a - _ * s;
            r.x = c * h + m * -o + d * -_ - u * -l, r.y = d * h + m * -l + u * -o - c * -_, r.z = u * h + m * -_ + c * -l - d * -o
        }
        static quaternionWeight(e, t, r) {
            r.x = e.x * t, r.y = e.y * t, r.z = e.z * t, r.w = e.w
        }
        static quaternionConjugate(e, t) {
            t.x = -e.x, t.y = -e.y, t.z = -e.z, t.w = e.w
        }
        static scaleWeight(e, t, r) {
            var i = e.x,
                n = e.y,
                a = e.z;
            r.x = i &gt; 0 ? Math.pow(Math.abs(i), t) : -Math.pow(Math.abs(i), t), r.y = n &gt; 0 ? Math.pow(Math.abs(n), t) : -Math.pow(Math.abs(n), t), r.z = a &gt; 0 ? Math.pow(Math.abs(a), t) : -Math.pow(Math.abs(a), t)
        }
        static scaleBlend(e, t, r, i) {
            var n = N._tempVector3_0,
                a = N._tempVector3_1;
            N.scaleWeight(e, 1 - r, n), N.scaleWeight(t, r, a);
            var s = r &gt; .5 ? t : e;
            i.x = s.x &gt; 0 ? Math.abs(n.x * a.x) : -Math.abs(n.x * a.x), i.y = s.y &gt; 0 ? Math.abs(n.y * a.y) : -Math.abs(n.y * a.y), i.z = s.z &gt; 0 ? Math.abs(n.z * a.z) : -Math.abs(n.z * a.z)
        }
        static matrix4x4MultiplyFFF(e, t, r) {
            var i, n, a, s, o;
            if (r === t)
                for (t = new Float32Array(16), i = 0; i &lt; 16; ++i) t[i] = r[i];
            var l = t[0],
                _ = t[1],
                h = t[2],
                c = t[3],
                d = t[4],
                u = t[5],
                m = t[6],
                f = t[7],
                T = t[8],
                E = t[9],
                p = t[10],
                g = t[11],
                S = t[12],
                R = t[13],
                v = t[14],
                A = t[15];
            for (i = 0; i &lt; 4; i++) n = e[i], a = e[i + 4], s = e[i + 8], o = e[i + 12], r[i] = n * l + a * _ + s * h + o * c, r[i + 4] = n * d + a * u + s * m + o * f, r[i + 8] = n * T + a * E + s * p + o * g, r[i + 12] = n * S + a * R + s * v + o * A
        }
        static matrix4x4MultiplyFFFForNative(e, r, i) {
            t.LayaGL.instance.matrix4x4Multiply(e, r, i)
        }
        static matrix4x4MultiplyMFM(e, t, r) {
            N.matrix4x4MultiplyFFF(e.elements, t, r.elements)
        }
        static _buildTexture2D(e, r, i, n, a = !1) {
            var s = new t.Texture2D(e, r, i, a, !0);
            return s.anisoLevel = 1, s.filterMode = t.FilterMode.Point, O._generateTexture2D(s, e, r, n), s
        }
        static _drawBound(e, t, r) {
            e.lineCount + 12 &gt; e.maxLineCount &amp;&amp; (e.maxLineCount += 12);
            var i = N._tempVector3_0,
                n = N._tempVector3_1,
                a = t.min,
                s = t.max;
            i.setValue(a.x, a.y, a.z), n.setValue(s.x, a.y, a.z), e.addLine(i, n, r, r), i.setValue(a.x, a.y, a.z), n.setValue(a.x, a.y, s.z), e.addLine(i, n, r, r), i.setValue(s.x, a.y, a.z), n.setValue(s.x, a.y, s.z), e.addLine(i, n, r, r), i.setValue(a.x, a.y, s.z), n.setValue(s.x, a.y, s.z), e.addLine(i, n, r, r), i.setValue(a.x, a.y, a.z), n.setValue(a.x, s.y, a.z), e.addLine(i, n, r, r), i.setValue(a.x, a.y, s.z), n.setValue(a.x, s.y, s.z), e.addLine(i, n, r, r), i.setValue(s.x, a.y, a.z), n.setValue(s.x, s.y, a.z), e.addLine(i, n, r, r), i.setValue(s.x, a.y, s.z), n.setValue(s.x, s.y, s.z), e.addLine(i, n, r, r), i.setValue(a.x, s.y, a.z), n.setValue(s.x, s.y, a.z), e.addLine(i, n, r, r), i.setValue(a.x, s.y, a.z), n.setValue(a.x, s.y, s.z), e.addLine(i, n, r, r), i.setValue(s.x, s.y, a.z), n.setValue(s.x, s.y, s.z), e.addLine(i, n, r, r), i.setValue(a.x, s.y, s.z), n.setValue(s.x, s.y, s.z), e.addLine(i, n, r, r)
        }
        static _getHierarchyPath(e, t, r) {
            r.length = 0;
            for (var i = t; i !== e;) {
                var n = i._parent;
                if (!n) return null;
                r.push(n.getChildIndex(i)), i = n
            }
            return r
        }
        static _getNodeByHierarchyPath(e, t) {
            for (var r = e, i = t.length - 1; i &gt;= 0; i--) r = r.getChildAt(t[i]);
            return r
        }
    }
    N._tempVector3_0 = new a, N._tempVector3_1 = new a, N._tempArray16_0 = new Float32Array(16), N._tempArray16_1 = new Float32Array(16), N._tempArray16_2 = new Float32Array(16), N._tempArray16_3 = new Float32Array(16), N._compIdToNode = new Object;
    class b extends A {
        constructor(e = .1, t = null, r = T.COLLISIONFILTERGROUP_DEFAULTFILTER, i = T.COLLISIONFILTERGROUP_ALLFILTER) {
            super(r, i), this._upAxis = new a(0, 1, 0), this._maxSlope = 45, this._jumpSpeed = 10, this._fallSpeed = 55, this._gravity = new a(0, 3 * -9.8, 0), this._btKinematicCharacter = null, this._stepHeight = e, t &amp;&amp; (this._upAxis = t), this._controlBySimulation = !0
        }
        static __init__() {
            b._btTempVector30 = _.Physics3D._bullet.btVector3_create(0, 0, 0)
        }
        get fallSpeed() {
            return this._fallSpeed
        }
        set fallSpeed(e) {
            this._fallSpeed = e, _.Physics3D._bullet.btKinematicCharacterController_setFallSpeed(this._btKinematicCharacter, e)
        }
        get jumpSpeed() {
            return this._jumpSpeed
        }
        set jumpSpeed(e) {
            this._jumpSpeed = e, _.Physics3D._bullet.btKinematicCharacterController_setJumpSpeed(this._btKinematicCharacter, e)
        }
        get gravity() {
            return this._gravity
        }
        set gravity(e) {
            this._gravity = e;
            var t = _.Physics3D._bullet,
                r = b._btTempVector30;
            t.btVector3_setValue(r, -e.x, e.y, e.z), t.btKinematicCharacterController_setGravity(this._btKinematicCharacter, r)
        }
        get maxSlope() {
            return this._maxSlope
        }
        set maxSlope(e) {
            this._maxSlope = e, _.Physics3D._bullet.btKinematicCharacterController_setMaxSlope(this._btKinematicCharacter, e / 180 * Math.PI)
        }
        get isGrounded() {
            return _.Physics3D._bullet.btKinematicCharacterController_onGround(this._btKinematicCharacter)
        }
        get stepHeight() {
            return this._stepHeight
        }
        set stepHeight(e) {
            this._stepHeight = e, _.Physics3D._bullet.btKinematicCharacterController_setStepHeight(this._btKinematicCharacter, e)
        }
        get upAxis() {
            return this._upAxis
        }
        set upAxis(e) {
            this._upAxis = e;
            var t = b._btTempVector30;
            N._convertToBulletVec3(e, t, !1), _.Physics3D._bullet.btKinematicCharacterController_setUp(this._btKinematicCharacter, t)
        }
        _constructCharacter() {
            var e = _.Physics3D._bullet;
            this._btKinematicCharacter &amp;&amp; e.btKinematicCharacterController_destroy(this._btKinematicCharacter);
            var t = b._btTempVector30;
            e.btVector3_setValue(t, this._upAxis.x, this._upAxis.y, this._upAxis.z), this._btKinematicCharacter = e.btKinematicCharacterController_create(this._btColliderObject, this._colliderShape._btShape, this._stepHeight, t), this.fallSpeed = this._fallSpeed, this.maxSlope = this._maxSlope, this.jumpSpeed = this._jumpSpeed, this.gravity = this._gravity
        }
        _onShapeChange(e) {
            super._onShapeChange(e), this._constructCharacter()
        }
        _onAdded() {
            var e = _.Physics3D._bullet,
                t = e.btPairCachingGhostObject_create();
            e.btCollisionObject_setUserIndex(t, this.id), e.btCollisionObject_setCollisionFlags(t, A.COLLISIONFLAGS_CHARACTER_OBJECT), this._btColliderObject = t, this._colliderShape &amp;&amp; this._constructCharacter(), super._onAdded()
        }
        _addToSimulation() {
            this._simulation._characters.push(this), this._simulation._addCharacter(this, this._collisionGroup, this._canCollideWith)
        }
        _removeFromSimulation() {
            this._simulation._removeCharacter(this);
            var e = this._simulation._characters;
            e.splice(e.indexOf(this), 1)
        }
        _cloneTo(e) {
            super._cloneTo(e);
            var t = e;
            t.stepHeight = this._stepHeight, t.upAxis = this._upAxis, t.maxSlope = this._maxSlope, t.jumpSpeed = this._jumpSpeed, t.fallSpeed = this._fallSpeed, t.gravity = this._gravity
        }
        _onDestroy() {
            _.Physics3D._bullet.btKinematicCharacterController_destroy(this._btKinematicCharacter), super._onDestroy(), this._btKinematicCharacter = null
        }
        move(e) {
            var t = b._btVector30,
                r = _.Physics3D._bullet;
            r.btVector3_setValue(t, -e.x, e.y, e.z), r.btKinematicCharacterController_setWalkDirection(this._btKinematicCharacter, t)
        }
        jump(e = null) {
            var t = _.Physics3D._bullet,
                r = b._btVector30;
            e ? (N._convertToBulletVec3(e, r, !0), t.btKinematicCharacterController_jump(this._btKinematicCharacter, r)) : (t.btVector3_setValue(r, 0, 0, 0), t.btKinematicCharacterController_jump(this._btKinematicCharacter, r))
        }
    }
    b.UPAXIS_X = 0, b.UPAXIS_Y = 1, b.UPAXIS_Z = 2;
    class P extends A {
        constructor(e, t) {
            super(e, t), this._isTrigger = !1
        }
        get isTrigger() {
            return this._isTrigger
        }
        set isTrigger(e) {
            this._isTrigger = e;
            var t = _.Physics3D._bullet;
            if (this._btColliderObject) {
                var r = t.btCollisionObject_getCollisionFlags(this._btColliderObject);
                e ? 0 == (r &amp; A.COLLISIONFLAGS_NO_CONTACT_RESPONSE) &amp;&amp; t.btCollisionObject_setCollisionFlags(this._btColliderObject, r | A.COLLISIONFLAGS_NO_CONTACT_RESPONSE) : 0 != (r &amp; A.COLLISIONFLAGS_NO_CONTACT_RESPONSE) &amp;&amp; t.btCollisionObject_setCollisionFlags(this._btColliderObject, r ^ A.COLLISIONFLAGS_NO_CONTACT_RESPONSE)
            }
        }
        _onAdded() {
            super._onAdded(), this.isTrigger = this._isTrigger
        }
        _cloneTo(e) {
            super._cloneTo(e), e.isTrigger = this._isTrigger
        }
    }
    class w extends P {
        constructor(e = T.COLLISIONFILTERGROUP_DEFAULTFILTER, t = T.COLLISIONFILTERGROUP_ALLFILTER) {
            super(e, t), this._isKinematic = !1, this._mass = 1, this._gravity = new a(0, -10, 0), this._angularDamping = 0, this._linearDamping = 0, this._overrideGravity = !1, this._totalTorque = new a(0, 0, 0), this._totalForce = new a(0, 0, 0), this._linearVelocity = new a, this._angularVelocity = new a, this._linearFactor = new a(1, 1, 1), this._angularFactor = new a(1, 1, 1), this._detectCollisions = !0, this._controlBySimulation = !0
        }
        static __init__() {
            var e = _.Physics3D._bullet;
            w._btTempVector30 = e.btVector3_create(0, 0, 0), w._btTempVector31 = e.btVector3_create(0, 0, 0), w._btVector3Zero = e.btVector3_create(0, 0, 0), w._btInertia = e.btVector3_create(0, 0, 0), w._btImpulse = e.btVector3_create(0, 0, 0), w._btImpulseOffset = e.btVector3_create(0, 0, 0), w._btGravity = e.btVector3_create(0, 0, 0), w._btTransform0 = e.btTransform_create()
        }
        get mass() {
            return this._mass
        }
        set mass(e) {
            e = Math.max(e, 1e-7), this._mass = e, this._isKinematic || this._updateMass(e)
        }
        get isKinematic() {
            return this._isKinematic
        }
        set isKinematic(e) {
            this._isKinematic = e, this._controlBySimulation = !e;
            var t = _.Physics3D._bullet,
                r = !!(this._simulation &amp;&amp; this._enabled &amp;&amp; this._colliderShape);
            r &amp;&amp; this._removeFromSimulation();
            var i = this._btColliderObject,
                n = t.btCollisionObject_getCollisionFlags(i);
            e ? (n |= A.COLLISIONFLAGS_KINEMATIC_OBJECT, t.btCollisionObject_setCollisionFlags(i, n), t.btCollisionObject_forceActivationState(this._btColliderObject, A.ACTIVATIONSTATE_DISABLE_DEACTIVATION), this._enableProcessCollisions = !1, this._updateMass(0)) : ((n &amp; A.COLLISIONFLAGS_KINEMATIC_OBJECT) &gt; 0 &amp;&amp; (n ^= A.COLLISIONFLAGS_KINEMATIC_OBJECT), t.btCollisionObject_setCollisionFlags(i, n), t.btCollisionObject_setActivationState(this._btColliderObject, A.ACTIVATIONSTATE_ACTIVE_TAG), this._enableProcessCollisions = !0, this._updateMass(this._mass));
            var a = w._btVector3Zero;
            t.btCollisionObject_setInterpolationLinearVelocity(i, a), t.btRigidBody_setLinearVelocity(i, a), t.btCollisionObject_setInterpolationAngularVelocity(i, a), t.btRigidBody_setAngularVelocity(i, a), r &amp;&amp; this._addToSimulation()
        }
        get linearDamping() {
            return this._linearDamping
        }
        set linearDamping(e) {
            this._linearDamping = e, this._btColliderObject &amp;&amp; _.Physics3D._bullet.btRigidBody_setDamping(this._btColliderObject, e, this._angularDamping)
        }
        get angularDamping() {
            return this._angularDamping
        }
        set angularDamping(e) {
            this._angularDamping = e, this._btColliderObject &amp;&amp; _.Physics3D._bullet.btRigidBody_setDamping(this._btColliderObject, this._linearDamping, e)
        }
        get overrideGravity() {
            return this._overrideGravity
        }
        set overrideGravity(e) {
            this._overrideGravity = e;
            var t = _.Physics3D._bullet;
            if (this._btColliderObject) {
                var r = t.btRigidBody_getFlags(this._btColliderObject);
                e ? 0 == (r &amp; w._BT_DISABLE_WORLD_GRAVITY) &amp;&amp; t.btRigidBody_setFlags(this._btColliderObject, r | w._BT_DISABLE_WORLD_GRAVITY) : (r &amp; w._BT_DISABLE_WORLD_GRAVITY) &gt; 0 &amp;&amp; t.btRigidBody_setFlags(this._btColliderObject, r ^ w._BT_DISABLE_WORLD_GRAVITY)
            }
        }
        get gravity() {
            return this._gravity
        }
        set gravity(e) {
            this._gravity = e;
            var t = _.Physics3D._bullet;
            t.btVector3_setValue(w._btGravity, -e.x, e.y, e.z), t.btRigidBody_setGravity(this._btColliderObject, w._btGravity)
        }
        get totalForce() {
            if (this._btColliderObject) {
                var e = _.Physics3D._bullet.btRigidBody_getTotalForce(this._btColliderObject);
                return N._convertToLayaVec3(e, this._totalForce, !0), this._totalForce
            }
            return null
        }
        get linearFactor() {
            return this._linearFactor
        }
        set linearFactor(e) {
            this._linearFactor = e;
            var t = w._btTempVector30;
            N._convertToBulletVec3(e, t, !1), _.Physics3D._bullet.btRigidBody_setLinearFactor(this._btColliderObject, t)
        }
        get linearVelocity() {
            return this._btColliderObject &amp;&amp; N._convertToLayaVec3(_.Physics3D._bullet.btRigidBody_getLinearVelocity(this._btColliderObject), this._linearVelocity, !0), this._linearVelocity
        }
        set linearVelocity(e) {
            if (this._linearVelocity = e, this._btColliderObject) {
                var t = w._btTempVector30;
                N._convertToBulletVec3(e, t, !0), this.isSleeping &amp;&amp; this.wakeUp(), _.Physics3D._bullet.btRigidBody_setLinearVelocity(this._btColliderObject, t)
            }
        }
        get angularFactor() {
            return this._angularFactor
        }
        set angularFactor(e) {
            this._angularFactor = e;
            var t = w._btTempVector30;
            N._convertToBulletVec3(e, t, !1), _.Physics3D._bullet.btRigidBody_setAngularFactor(this._btColliderObject, t)
        }
        get angularVelocity() {
            return this._btColliderObject &amp;&amp; N._convertToLayaVec3(_.Physics3D._bullet.btRigidBody_getAngularVelocity(this._btColliderObject), this._angularVelocity, !0), this._angularVelocity
        }
        set angularVelocity(e) {
            if (this._angularVelocity = e, this._btColliderObject) {
                var t = w._btTempVector30;
                N._convertToBulletVec3(e, t, !0), this.isSleeping &amp;&amp; this.wakeUp(), _.Physics3D._bullet.btRigidBody_setAngularVelocity(this._btColliderObject, t)
            }
        }
        get totalTorque() {
            if (this._btColliderObject) {
                var e = _.Physics3D._bullet.btRigidBody_getTotalTorque(this._btColliderObject);
                return N._convertToLayaVec3(e, this._totalTorque, !0), this._totalTorque
            }
            return null
        }
        get detectCollisions() {
            return this._detectCollisions
        }
        set detectCollisions(e) {
            this._detectCollisions !== e &amp;&amp; (this._detectCollisions = e, this._colliderShape &amp;&amp; this._enabled &amp;&amp; this._simulation &amp;&amp; (this._simulation._removeRigidBody(this), this._simulation._addRigidBody(this, this._collisionGroup, e ? this._canCollideWith : 0)))
        }
        get isSleeping() {
            return !!this._btColliderObject &amp;&amp; _.Physics3D._bullet.btCollisionObject_getActivationState(this._btColliderObject) === A.ACTIVATIONSTATE_ISLAND_SLEEPING
        }
        get sleepLinearVelocity() {
            return _.Physics3D._bullet.btRigidBody_getLinearSleepingThreshold(this._btColliderObject)
        }
        set sleepLinearVelocity(e) {
            var t = _.Physics3D._bullet;
            t.btRigidBody_setSleepingThresholds(this._btColliderObject, e, t.btRigidBody_getAngularSleepingThreshold(this._btColliderObject))
        }
        get sleepAngularVelocity() {
            return _.Physics3D._bullet.btRigidBody_getAngularSleepingThreshold(this._btColliderObject)
        }
        set sleepAngularVelocity(e) {
            var t = _.Physics3D._bullet;
            t.btRigidBody_setSleepingThresholds(this._btColliderObject, t.btRigidBody_getLinearSleepingThreshold(this._btColliderObject), e)
        }
        get btColliderObject() {
            return this._btColliderObject
        }
        set constaintRigidbodyA(e) {
            this._constaintRigidbodyA = e
        }
        get constaintRigidbodyA() {
            return this._constaintRigidbodyA
        }
        set constaintRigidbodyB(e) {
            this._constaintRigidbodyB = e
        }
        get constaintRigidbodyB() {
            return this._constaintRigidbodyB
        }
        _updateMass(e) {
            if (this._btColliderObject &amp;&amp; this._colliderShape) {
                var t = _.Physics3D._bullet;
                t.btCollisionShape_calculateLocalInertia(this._colliderShape._btShape, e, w._btInertia), t.btRigidBody_setMassProps(this._btColliderObject, e, w._btInertia), t.btRigidBody_updateInertiaTensor(this._btColliderObject)
            }
        }
        _onScaleChange(e) {
            super._onScaleChange(e), this._updateMass(this._isKinematic ? 0 : this._mass)
        }
        _derivePhysicsTransformation(e) {
            var t = _.Physics3D._bullet,
                r = this._btColliderObject,
                i = t.btCollisionObject_getWorldTransform(r),
                n = w._btTransform0;
            t.btTransform_equal(n, i), this._innerDerivePhysicsTransformation(n, e), t.btRigidBody_setCenterOfMassTransform(r, n)
        }
        _onAdded() {
            var e = _.Physics3D._bullet,
                t = e.layaMotionState_create();
            e.layaMotionState_set_rigidBodyID(t, this._id), this._btLayaMotionState = t;
            var r = e.btRigidBodyConstructionInfo_create(0, t, null, w._btVector3Zero),
                i = e.btRigidBody_create(r);
            e.btCollisionObject_setUserIndex(i, this.id), this._btColliderObject = i, super._onAdded(), this.mass = this._mass, this.linearFactor = this._linearFactor, this.angularFactor = this._angularFactor, this.linearDamping = this._linearDamping, this.angularDamping = this._angularDamping, this.overrideGravity = this._overrideGravity, this.gravity = this._gravity, this.isKinematic = this._isKinematic, e.btRigidBodyConstructionInfo_destroy(r)
        }
        _onEnable() {
            super._onEnable(), this._constaintRigidbodyA &amp;&amp; this._constaintRigidbodyA.connectedBody._simulation &amp;&amp; (this._constaintRigidbodyA._createConstraint(), this._constaintRigidbodyA._onEnable()), this._constaintRigidbodyB &amp;&amp; this._constaintRigidbodyB.ownBody._simulation &amp;&amp; (this._constaintRigidbodyB._createConstraint(), this._constaintRigidbodyB._onEnable())
        }
        _onShapeChange(e) {
            if (super._onShapeChange(e), this._isKinematic) this._updateMass(0);
            else {
                var t = _.Physics3D._bullet;
                t.btRigidBody_setCenterOfMassTransform(this._btColliderObject, t.btCollisionObject_getWorldTransform(this._btColliderObject)), this._updateMass(this._mass)
            }
        }
        _parse(e) {
            if (null != e.friction &amp;&amp; (this.friction = e.friction), null != e.rollingFriction &amp;&amp; (this.rollingFriction = e.rollingFriction), null != e.restitution &amp;&amp; (this.restitution = e.restitution), null != e.isTrigger &amp;&amp; (this.isTrigger = e.isTrigger), null != e.mass &amp;&amp; (this.mass = e.mass), null != e.linearDamping &amp;&amp; (this.linearDamping = e.linearDamping), null != e.angularDamping &amp;&amp; (this.angularDamping = e.angularDamping), null != e.overrideGravity &amp;&amp; (this.overrideGravity = e.overrideGravity), null != e.linearFactor) {
                var t = this.linearFactor;
                t.fromArray(e.linearFactor), this.linearFactor = t
            }
            if (null != e.angularFactor) {
                var r = this.angularFactor;
                r.fromArray(e.angularFactor), this.angularFactor = r
            }
            e.gravity &amp;&amp; (this.gravity.fromArray(e.gravity), this.gravity = this.gravity), super._parse(e), this._parseShape(e.shapes), null != e.isKinematic &amp;&amp; (this.isKinematic = e.isKinematic)
        }
        _onDestroy() {
            _.Physics3D._bullet.btMotionState_destroy(this._btLayaMotionState), super._onDestroy(), this._btLayaMotionState = null, this._gravity = null, this._totalTorque = null, this._linearVelocity = null, this._angularVelocity = null, this._linearFactor = null, this._angularFactor = null, this.constaintRigidbodyA &amp;&amp; this.constaintRigidbodyA._breakConstrained(), this.constaintRigidbodyB &amp;&amp; (this.constaintRigidbodyB.connectedBody = null, this.constaintRigidbodyB._onDisable())
        }
        _addToSimulation() {
            this._simulation._addRigidBody(this, this._collisionGroup, this._detectCollisions ? this._canCollideWith : 0)
        }
        _removeFromSimulation() {
            this._simulation._removeRigidBody(this)
        }
        _cloneTo(e) {
            super._cloneTo(e);
            var t = e;
            t.isKinematic = this._isKinematic, t.mass = this._mass, t.gravity = this._gravity, t.angularDamping = this._angularDamping, t.linearDamping = this._linearDamping, t.overrideGravity = this._overrideGravity, t.linearVelocity = this._linearVelocity, t.angularVelocity = this._angularVelocity, t.linearFactor = this._linearFactor, t.angularFactor = this._angularFactor, t.detectCollisions = this._detectCollisions
        }
        applyForce(e, t = null) {
            if (null == this._btColliderObject) throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
            var r = _.Physics3D._bullet,
                i = w._btTempVector30;
            if (r.btVector3_setValue(i, -e.x, e.y, e.z), t) {
                var n = w._btTempVector31;
                r.btVector3_setValue(n, -t.x, t.y, t.z), r.btRigidBody_applyForce(this._btColliderObject, i, n)
            } else r.btRigidBody_applyCentralForce(this._btColliderObject, i)
        }
        applyTorque(e) {
            if (null == this._btColliderObject) throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
            var t = _.Physics3D._bullet,
                r = w._btTempVector30;
            t.btVector3_setValue(r, -e.x, e.y, e.z), t.btRigidBody_applyTorque(this._btColliderObject, r)
        }
        applyImpulse(e, t = null) {
            if (null == this._btColliderObject) throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
            var r = _.Physics3D._bullet;
            r.btVector3_setValue(w._btImpulse, -e.x, e.y, e.z), t ? (r.btVector3_setValue(w._btImpulseOffset, -t.x, t.y, t.z), r.btRigidBody_applyImpulse(this._btColliderObject, w._btImpulse, w._btImpulseOffset)) : r.btRigidBody_applyCentralImpulse(this._btColliderObject, w._btImpulse)
        }
        applyTorqueImpulse(e) {
            if (null == this._btColliderObject) throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
            var t = _.Physics3D._bullet,
                r = w._btTempVector30;
            t.btVector3_setValue(r, -e.x, e.y, e.z), t.btRigidBody_applyTorqueImpulse(this._btColliderObject, r)
        }
        wakeUp() {
            this._btColliderObject &amp;&amp; _.Physics3D._bullet.btCollisionObject_activate(this._btColliderObject, !1)
        }
        clearForces() {
            var e = this._btColliderObject;
            if (null == e) throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
            var t = _.Physics3D._bullet;
            t.btRigidBody_clearForces(e);
            var r = w._btVector3Zero;
            t.btCollisionObject_setInterpolationLinearVelocity(e, r), t.btRigidBody_setLinearVelocity(e, r), t.btCollisionObject_setInterpolationAngularVelocity(e, r), t.btRigidBody_setAngularVelocity(e, r)
        }
    }
    w.TYPE_STATIC = 0, w.TYPE_DYNAMIC = 1, w.TYPE_KINEMATIC = 2, w._BT_DISABLE_WORLD_GRAVITY = 1, w._BT_ENABLE_GYROPSCOPIC_FORCE = 2;
    class V {
        static __bulletinit__() {
            this._bullet = window.Physics3D, this._bullet &amp;&amp; (u.__init__(), d.__init__(), m.__init__(), A.__init__(), M.__init__(), E.__init__(), S.__init__(), b.__init__(), w.__init__())
        }
        static __cannoninit__() {
            this._cannon = window.CANNON, this._cannon &amp;&amp; (t.CannonColliderShape.__init__(), t.CannonPhysicsComponent.__init__(), t.CannonPhysicsSimulation.__init__(), t.CannonBoxColliderShape.__init__(), t.CannonRigidbody3D.__init__())
        }
    }
    V._bullet = null, V._cannon = null, V._enablePhysics = !1;
    class B {
        constructor() {
            this._defaultPhysicsMemory = 16, this._maxLightCount = 32, this._lightClusterCount = new a(12, 12, 12), this._editerEnvironment = !1, this.isAntialias = !0, this.isAlpha = !1, this.premultipliedAlpha = !0, this.isStencil = !0, this.enableMultiLight = !0, this.octreeCulling = !1, this.octreeInitialSize = 64, this.octreeInitialCenter = new a(0, 0, 0), this.octreeMinNodeSize = 2, this.octreeLooseness = 1.25, this.debugFrustumCulling = !1, this.pbrRenderQuality = e.PBRRenderQuality.High, this.isUseCannonPhysicsEngine = !1, this._maxAreaLightCountPerClusterAverage = Math.min(4 * Math.floor(2048 / this._lightClusterCount.z - 1), this._maxLightCount)
        }
        static get useCannonPhysics() {
            return B._config.isUseCannonPhysicsEngine
        }
        static set useCannonPhysics(e) {
            B._config.isUseCannonPhysicsEngine = e, e &amp;&amp; (V.__cannoninit__(), _.Scene3D.cannonPhysicsSettings || (_.Scene3D.cannonPhysicsSettings = new t.CannonPhysicsSettings))
        }
        get defaultPhysicsMemory() {
            return this._defaultPhysicsMemory
        }
        set defaultPhysicsMemory(e) {
            if (e &lt; 16) throw "defaultPhysicsMemory must large than 16M";
            this._defaultPhysicsMemory = e
        }
        get maxLightCount() {
            return this._maxLightCount
        }
        set maxLightCount(e) {
            e &gt; 2048 ? (this._maxLightCount = 2048, console.warn("Config3D: maxLightCount must less equal 2048.")) : this._maxLightCount = e
        }
        get lightClusterCount() {
            return this._lightClusterCount
        }
        set lightClusterCount(e) {
            e.x &gt; 128 || e.y &gt; 128 || e.z &gt; 128 ? (this._lightClusterCount.setValue(Math.min(e.x, 128), Math.min(e.y, 128), Math.min(e.z, 128)), console.warn("Config3D: lightClusterCount X and Yã€Z must less equal 128.")) : e.cloneTo(this._lightClusterCount);
            var t = 4 * Math.floor(2048 / this._lightClusterCount.z - 1);
            t &lt; this._maxLightCount &amp;&amp; console.warn("Config3D: if the area light(PointLightã€SpotLight) count is large than " + t + ",maybe the far away culster will ingonre some light."), this._maxAreaLightCountPerClusterAverage = Math.min(t, this._maxLightCount)
        }
        cloneTo(e) {
            var t = e;
            t._defaultPhysicsMemory = this._defaultPhysicsMemory, t._editerEnvironment = this._editerEnvironment, t.isAntialias = this.isAntialias, t.isAlpha = this.isAlpha, t.premultipliedAlpha = this.premultipliedAlpha, t.isStencil = this.isStencil, t.octreeCulling = this.octreeCulling, this.octreeInitialCenter.cloneTo(t.octreeInitialCenter), t.octreeInitialSize = this.octreeInitialSize, t.octreeMinNodeSize = this.octreeMinNodeSize, t.octreeLooseness = this.octreeLooseness, t.debugFrustumCulling = this.debugFrustumCulling, t.maxLightCount = this.maxLightCount, t.enableMultiLight = this.enableMultiLight;
            var r = t.lightClusterCount;
            this.lightClusterCount.cloneTo(r), t.lightClusterCount = r, t.pbrRenderQuality = this.pbrRenderQuality
        }
        clone() {
            var e = new B;
            return this.cloneTo(e), e
        }
    }
    B._config = new B, window.Config3D = B;
    class F {
        constructor() {
            this._ownerPath = [], this._propertys = [], this._keyFrames = []
        }
        get ownerPathCount() {
            return this._ownerPath.length
        }
        get propertyCount() {
            return this._propertys.length
        }
        get keyFramesCount() {
            return this._keyFrames.length
        }
        _setOwnerPathCount(e) {
            this._ownerPath.length = e
        }
        _setOwnerPathByIndex(e, t) {
            this._ownerPath[e] = t
        }
        _joinOwnerPath(e) {
            return this._ownerPath.join(e)
        }
        _setPropertyCount(e) {
            this._propertys.length = e
        }
        _setPropertyByIndex(e, t) {
            this._propertys[e] = t
        }
        _joinProperty(e) {
            return this._propertys.join(e)
        }
        _setKeyframeCount(e) {
            this._keyFrames.length = e
        }
        _setKeyframeByIndex(e, t) {
            this._keyFrames[e] = t
        }
        getOwnerPathByIndex(e) {
            return this._ownerPath[e]
        }
        getPropertyByIndex(e) {
            return this._propertys[e]
        }
        getKeyframeByIndex(e) {
            return this._keyFrames[e]
        }
    }
    class U {
        constructor() {}
    }
    class G {
        constructor() {}
        cloneTo(e) {
            e.time = this.time
        }
        clone() {
            var e = new G;
            return this.cloneTo(e), e
        }
    }
    class z extends G {
        constructor() {
            super()
        }
        cloneTo(e) {
            super.cloneTo(e);
            var t = e;
            t.inTangent = this.inTangent, t.outTangent = this.outTangent, t.value = this.value
        }
    }
    class H extends G {
        constructor() {
            super(), this.inTangent = new n, this.outTangent = new n, this.value = new h
        }
        cloneTo(e) {
            super.cloneTo(e);
            var t = e;
            this.inTangent.cloneTo(t.inTangent), this.outTangent.cloneTo(t.outTangent), this.value.cloneTo(t.value)
        }
    }
    class W extends G {
        constructor() {
            super(), this.inTangent = new a, this.outTangent = new a, this.value = new a
        }
        cloneTo(e) {
            super.cloneTo(e);
            var t = e;
            this.inTangent.cloneTo(t.inTangent), this.outTangent.cloneTo(t.outTangent), this.value.cloneTo(t.value)
        }
    }
    class k {
        static READ_DATA() {
            k._DATA.offset = k._reader.getUint32(), k._DATA.size = k._reader.getUint32()
        }
        static READ_BLOCK() {
            for (var e = k._BLOCK.count = k._reader.getUint16(), t = k._BLOCK.blockStarts = [], r = k._BLOCK.blockLengths = [], i = 0; i &lt; e; i++) t.push(k._reader.getUint32()), r.push(k._reader.getUint32())
        }
        static READ_STRINGS() {
            var e = k._reader.getUint32(),
                t = k._reader.getUint16(),
                r = k._reader.pos;
            k._reader.pos = e + k._DATA.offset;
            for (var i = 0; i &lt; t; i++) k._strings[i] = k._reader.readUTFString();
            k._reader.pos = r
        }
        static parse(e, t) {
            k._animationClip = e, k._reader = t;
            t.__getBuffer();
            k.READ_DATA(), k.READ_BLOCK(), k.READ_STRINGS();
            for (var r = 0, i = k._BLOCK.count; r &lt; i; r++) {
                var n = t.getUint16(),
                    a = k._strings[n],
                    s = k["READ_" + a];
                if (null == s) throw new Error("model file err,no this function:" + n + " " + a);
                s.call(null)
            }
        }
        static READ_ANIMATIONS() {
            var e, r, i, n = k._reader,
                a = (n.__getBuffer(), []),
                s = n.getUint16();
            for (a.length = s, e = 0; e &lt; s; e++) a[e] = n.getFloat32();
            var o = k._animationClip;
            o.name = k._strings[n.getUint16()];
            var l = o._duration = n.getFloat32();
            o.islooping = !!n.getByte(), o._frameRate = n.getInt16();
            var _ = n.getInt16(),
                h = o._nodes;
            h.count = _;
            var c = o._nodesMap = {},
                d = o._nodesDic = {};
            for (e = 0; e &lt; _; e++) {
                i = new F, h.setNodeByIndex(e, i), i._indexInList = e;
                var u = i.type = n.getUint8(),
                    m = n.getUint16();
                for (i._setOwnerPathCount(m), r = 0; r &lt; m; r++) i._setOwnerPathByIndex(r, k._strings[n.getUint16()]);
                var f = i._joinOwnerPath("/"),
                    T = c[f];
                T || (c[f] = T = []), T.push(i), i.propertyOwner = k._strings[n.getUint16()];
                var E = n.getUint16();
                for (i._setPropertyCount(E), r = 0; r &lt; E; r++) i._setPropertyByIndex(r, k._strings[n.getUint16()]);
                var p = f + "." + i.propertyOwner + "." + i._joinProperty(".");
                d[p] = i, i.fullPath = p;
                var g = n.getUint16();
                for (i._setKeyframeCount(g), r = 0; r &lt; g; r++) switch (u) {
                    case 0:
                        var S = new z;
                        i._setKeyframeByIndex(r, S), S.time = a[n.getUint16()], S.inTangent = n.getFloat32(), S.outTangent = n.getFloat32(), S.value = n.getFloat32();
                        break;
                    case 1:
                    case 3:
                    case 4:
                        var R = new W;
                        if (i._setKeyframeByIndex(r, R), R.time = a[n.getUint16()], t.Render.supportWebGLPlusAnimation) {
                            for (var v = R.data = new Float32Array(9), A = 0; A &lt; 3; A++) v[A] = n.getFloat32();
                            for (A = 0; A &lt; 3; A++) v[3 + A] = n.getFloat32();
                            for (A = 0; A &lt; 3; A++) v[6 + A] = n.getFloat32()
                        } else {
                            var I = R.inTangent,
                                x = R.outTangent,
                                L = R.value;
                            I.x = n.getFloat32(), I.y = n.getFloat32(), I.z = n.getFloat32(), x.x = n.getFloat32(), x.y = n.getFloat32(), x.z = n.getFloat32(), L.x = n.getFloat32(), L.y = n.getFloat32(), L.z = n.getFloat32()
                        }
                        break;
                    case 2:
                        var D = new H;
                        if (i._setKeyframeByIndex(r, D), D.time = a[n.getUint16()], t.Render.supportWebGLPlusAnimation) {
                            for (v = D.data = new Float32Array(12), A = 0; A &lt; 4; A++) v[A] = n.getFloat32();
                            for (A = 0; A &lt; 4; A++) v[4 + A] = n.getFloat32();
                            for (A = 0; A &lt; 4; A++) v[8 + A] = n.getFloat32()
                        } else {
                            var C = D.inTangent,
                                y = D.outTangent,
                                M = D.value;
                            C.x = n.getFloat32(), C.y = n.getFloat32(), C.z = n.getFloat32(), C.w = n.getFloat32(), y.x = n.getFloat32(), y.y = n.getFloat32(), y.z = n.getFloat32(), y.w = n.getFloat32(), M.x = n.getFloat32(), M.y = n.getFloat32(), M.z = n.getFloat32(), M.w = n.getFloat32()
                        }
                        break;
                    default:
                        throw "AnimationClipParser03:unknown type."
                }
            }
            var O = n.getUint16();
            for (e = 0; e &lt; O; e++) {
                var N, b = new U;
                b.time = Math.min(l, n.getFloat32()), b.eventName = k._strings[n.getUint16()];
                var P = n.getUint16();
                for (P &gt; 0 &amp;&amp; (b.params = N = []), r = 0; r &lt; P; r++) {
                    switch (n.getByte()) {
                        case 0:
                            N.push(!!n.getByte());
                            break;
                        case 1:
                            N.push(n.getInt32());
                            break;
                        case 2:
                            N.push(n.getFloat32());
                            break;
                        case 3:
                            N.push(k._strings[n.getUint16()]);
                            break;
                        default:
                            throw new Error("unknown type.")
                    }
                }
                o.addEvent(b)
            }
        }
    }
    k._strings = [], k._BLOCK = {
        count: 0
    }, k._DATA = {
        offset: 0,
        size: 0
    };
    class X {
        static __init__() {
            for (var e = 0; e &lt; 256; ++e) {
                var t = e - 127;
                t &lt; -27 ? (X._baseTable[0 | e] = 0, X._baseTable[256 | e] = 32768, X._shiftTable[0 | e] = 24, X._shiftTable[256 | e] = 24) : t &lt; -14 ? (X._baseTable[0 | e] = 1024 &gt;&gt; -t - 14, X._baseTable[256 | e] = 1024 &gt;&gt; -t - 14 | 32768, X._shiftTable[0 | e] = -t - 1, X._shiftTable[256 | e] = -t - 1) : t &lt;= 15 ? (X._baseTable[0 | e] = t + 15 &lt;&lt; 10, X._baseTable[256 | e] = t + 15 &lt;&lt; 10 | 32768, X._shiftTable[0 | e] = 13, X._shiftTable[256 | e] = 13) : t &lt; 128 ? (X._baseTable[0 | e] = 31744, X._baseTable[256 | e] = 64512, X._shiftTable[0 | e] = 24, X._shiftTable[256 | e] = 24) : (X._baseTable[0 | e] = 31744, X._baseTable[256 | e] = 64512, X._shiftTable[0 | e] = 13, X._shiftTable[256 | e] = 13)
            }
            for (X._mantissaTable[0] = 0, e = 1; e &lt; 1024; ++e) {
                var r = e &lt;&lt; 13;
                for (t = 0; 0 == (8388608 &amp; r);) t -= 8388608, r &lt;&lt;= 1;
                r &amp;= -8388609, t += 947912704, X._mantissaTable[e] = r | t
            }
            for (e = 1024; e &lt; 2048; ++e) X._mantissaTable[e] = 939524096 + (e - 1024 &lt;&lt; 13);
            for (X._exponentTable[0] = 0, e = 1; e &lt; 31; ++e) X._exponentTable[e] = e &lt;&lt; 23;
            for (X._exponentTable[31] = 1199570944, X._exponentTable[32] = 2147483648, e = 33; e &lt; 63; ++e) X._exponentTable[e] = 2147483648 + (e - 32 &lt;&lt; 23);
            for (X._exponentTable[63] = 3347054592, X._offsetTable[0] = 0, e = 1; e &lt; 64; ++e) X._offsetTable[e] = 32 === e ? 0 : 1024
        }
        static roundToFloat16Bits(e) {
            X._floatView[0] = e;
            var t = X._uint32View[0],
                r = t &gt;&gt; 23 &amp; 511;
            return X._baseTable[r] + ((8388607 &amp; t) &gt;&gt; X._shiftTable[r])
        }
        static convertToNumber(e) {
            var t = e &gt;&gt; 10;
            return X._uint32View[0] = X._mantissaTable[X._offsetTable[t] + (1023 &amp; e)] + X._exponentTable[t], X._floatView[0]
        }
    }
    X._buffer = new ArrayBuffer(4), X._floatView = new Float32Array(X._buffer), X._uint32View = new Uint32Array(X._buffer), X._baseTable = new Uint32Array(512), X._shiftTable = new Uint32Array(512), X._mantissaTable = new Uint32Array(2048), X._exponentTable = new Uint32Array(64), X._offsetTable = new Uint32Array(64);
    class Y {
        static READ_DATA() {
            Y._DATA.offset = Y._reader.getUint32(), Y._DATA.size = Y._reader.getUint32()
        }
        static READ_BLOCK() {
            for (var e = Y._BLOCK.count = Y._reader.getUint16(), t = Y._BLOCK.blockStarts = [], r = Y._BLOCK.blockLengths = [], i = 0; i &lt; e; i++) t.push(Y._reader.getUint32()), r.push(Y._reader.getUint32())
        }
        static READ_STRINGS() {
            var e = Y._reader.getUint32(),
                t = Y._reader.getUint16(),
                r = Y._reader.pos;
            Y._reader.pos = e + Y._DATA.offset;
            for (var i = 0; i &lt; t; i++) Y._strings[i] = Y._reader.readUTFString();
            Y._reader.pos = r
        }
        static parse(e, t, r) {
            Y._animationClip = e, Y._reader = t, Y._version = r, Y.READ_DATA(), Y.READ_BLOCK(), Y.READ_STRINGS();
            for (var i = 0, n = Y._BLOCK.count; i &lt; n; i++) {
                var a = t.getUint16(),
                    s = Y._strings[a],
                    o = Y["READ_" + s];
                if (null == o) throw new Error("model file err,no this function:" + a + " " + s);
                o.call(null)
            }
            Y._version = null, Y._reader = null, Y._animationClip = null
        }
        static READ_ANIMATIONS() {
            var e, r, i, n = Y._reader,
                a = (n.__getBuffer(), []),
                s = n.getUint16();
            for (a.length = s, e = 0; e &lt; s; e++) a[e] = n.getFloat32();
            var o = Y._animationClip;
            o.name = Y._strings[n.getUint16()];
            var l = o._duration = n.getFloat32();
            o.islooping = !!n.getByte(), o._frameRate = n.getInt16();
            var _ = n.getInt16(),
                h = o._nodes;
            h.count = _;
            var c = o._nodesMap = {},
                d = o._nodesDic = {};
            for (e = 0; e &lt; _; e++) {
                i = new F, h.setNodeByIndex(e, i), i._indexInList = e;
                var u = i.type = n.getUint8(),
                    m = n.getUint16();
                for (i._setOwnerPathCount(m), r = 0; r &lt; m; r++) i._setOwnerPathByIndex(r, Y._strings[n.getUint16()]);
                var f = i._joinOwnerPath("/"),
                    T = c[f];
                T || (c[f] = T = []), T.push(i), i.propertyOwner = Y._strings[n.getUint16()];
                var E = n.getUint16();
                for (i._setPropertyCount(E), r = 0; r &lt; E; r++) i._setPropertyByIndex(r, Y._strings[n.getUint16()]);
                var p = f + "." + i.propertyOwner + "." + i._joinProperty(".");
                d[p] = i, i.fullPath = p;
                var g = n.getUint16();
                switch (i._setKeyframeCount(g), Y._version) {
                    case "LAYAANIMATION:04":
                        for (r = 0; r &lt; g; r++) switch (u) {
                            case 0:
                                var S = new z;
                                i._setKeyframeByIndex(r, S), S.time = a[n.getUint16()], S.inTangent = n.getFloat32(), S.outTangent = n.getFloat32(), S.value = n.getFloat32();
                                break;
                            case 1:
                            case 3:
                            case 4:
                                var R = new W;
                                if (i._setKeyframeByIndex(r, R), R.time = a[n.getUint16()], t.Render.supportWebGLPlusAnimation) {
                                    for (var v = R.data = new Float32Array(9), A = 0; A &lt; 3; A++) v[A] = n.getFloat32();
                                    for (A = 0; A &lt; 3; A++) v[3 + A] = n.getFloat32();
                                    for (A = 0; A &lt; 3; A++) v[6 + A] = n.getFloat32()
                                } else {
                                    var I = R.inTangent,
                                        x = R.outTangent,
                                        L = R.value;
                                    I.x = n.getFloat32(), I.y = n.getFloat32(), I.z = n.getFloat32(), x.x = n.getFloat32(), x.y = n.getFloat32(), x.z = n.getFloat32(), L.x = n.getFloat32(), L.y = n.getFloat32(), L.z = n.getFloat32()
                                }
                                break;
                            case 2:
                                var D = new H;
                                if (i._setKeyframeByIndex(r, D), D.time = a[n.getUint16()], t.Render.supportWebGLPlusAnimation) {
                                    for (v = D.data = new Float32Array(12), A = 0; A &lt; 4; A++) v[A] = n.getFloat32();
                                    for (A = 0; A &lt; 4; A++) v[4 + A] = n.getFloat32();
                                    for (A = 0; A &lt; 4; A++) v[8 + A] = n.getFloat32()
                                } else {
                                    var C = D.inTangent,
                                        y = D.outTangent,
                                        M = D.value;
                                    C.x = n.getFloat32(), C.y = n.getFloat32(), C.z = n.getFloat32(), C.w = n.getFloat32(), y.x = n.getFloat32(), y.y = n.getFloat32(), y.z = n.getFloat32(), y.w = n.getFloat32(), M.x = n.getFloat32(), M.y = n.getFloat32(), M.z = n.getFloat32(), M.w = n.getFloat32()
                                }
                                break;
                            default:
                                throw "AnimationClipParser04:unknown type."
                        }
                        break;
                    case "LAYAANIMATION:COMPRESSION_04":
                        for (r = 0; r &lt; g; r++) switch (u) {
                            case 0:
                                S = new z, i._setKeyframeByIndex(r, S), S.time = a[n.getUint16()], S.inTangent = X.convertToNumber(n.getUint16()), S.outTangent = X.convertToNumber(n.getUint16()), S.value = X.convertToNumber(n.getUint16());
                                break;
                            case 1:
                            case 3:
                            case 4:
                                if (R = new W, i._setKeyframeByIndex(r, R), R.time = a[n.getUint16()], t.Render.supportWebGLPlusAnimation) {
                                    for (v = R.data = new Float32Array(9), A = 0; A &lt; 3; A++) v[A] = X.convertToNumber(n.getUint16());
                                    for (A = 0; A &lt; 3; A++) v[3 + A] = X.convertToNumber(n.getUint16());
                                    for (A = 0; A &lt; 3; A++) v[6 + A] = X.convertToNumber(n.getUint16())
                                } else I = R.inTangent, x = R.outTangent, L = R.value, I.x = X.convertToNumber(n.getUint16()), I.y = X.convertToNumber(n.getUint16()), I.z = X.convertToNumber(n.getUint16()), x.x = X.convertToNumber(n.getUint16()), x.y = X.convertToNumber(n.getUint16()), x.z = X.convertToNumber(n.getUint16()), L.x = X.convertToNumber(n.getUint16()), L.y = X.convertToNumber(n.getUint16()), L.z = X.convertToNumber(n.getUint16());
                                break;
                            case 2:
                                if (D = new H, i._setKeyframeByIndex(r, D), D.time = a[n.getUint16()], t.Render.supportWebGLPlusAnimation) {
                                    for (v = D.data = new Float32Array(12), A = 0; A &lt; 4; A++) v[A] = X.convertToNumber(n.getUint16());
                                    for (A = 0; A &lt; 4; A++) v[4 + A] = X.convertToNumber(n.getUint16());
                                    for (A = 0; A &lt; 4; A++) v[8 + A] = X.convertToNumber(n.getUint16())
                                } else C = D.inTangent, y = D.outTangent, M = D.value, C.x = X.convertToNumber(n.getUint16()), C.y = X.convertToNumber(n.getUint16()), C.z = X.convertToNumber(n.getUint16()), C.w = X.convertToNumber(n.getUint16()), y.x = X.convertToNumber(n.getUint16()), y.y = X.convertToNumber(n.getUint16()), y.z = X.convertToNumber(n.getUint16()), y.w = X.convertToNumber(n.getUint16()), M.x = X.convertToNumber(n.getUint16()), M.y = X.convertToNumber(n.getUint16()), M.z = X.convertToNumber(n.getUint16()), M.w = X.convertToNumber(n.getUint16());
                                break;
                            default:
                                throw "AnimationClipParser04:unknown type."
                        }
                }
            }
            var O = n.getUint16();
            for (e = 0; e &lt; O; e++) {
                var N, b = new U;
                b.time = Math.min(l, n.getFloat32()), b.eventName = Y._strings[n.getUint16()];
                var P = n.getUint16();
                for (P &gt; 0 &amp;&amp; (b.params = N = []), r = 0; r &lt; P; r++) {
                    switch (n.getByte()) {
                        case 0:
                            N.push(!!n.getByte());
                            break;
                        case 1:
                            N.push(n.getInt32());
                            break;
                        case 2:
                            N.push(n.getFloat32());
                            break;
                        case 3:
                            N.push(Y._strings[n.getUint16()]);
                            break;
                        default:
                            throw new Error("unknown type.")
                    }
                }
                o.addEvent(b)
            }
        }
    }
    Y._strings = [], Y._BLOCK = {
        count: 0
    }, Y._DATA = {
        offset: 0,
        size: 0
    };
    class j {
        constructor() {
            this._nodes = []
        }
        get count() {
            return this._nodes.length
        }
        set count(e) {
            this._nodes.length = e
        }
        getNodeByIndex(e) {
            return this._nodes[e]
        }
        setNodeByIndex(e, t) {
            this._nodes[e] = t
        }
    }
    class Z extends t.Resource {
        constructor() {
            super(), this._nodes = new j, this._animationEvents = []
        }
        static _parse(e, r = null, i = null) {
            var n = new Z,
                a = new t.Byte(e),
                s = a.readUTFString();
            switch (s) {
                case "LAYAANIMATION:03":
                    k.parse(n, a);
                    break;
                case "LAYAANIMATION:04":
                case "LAYAANIMATION:COMPRESSION_04":
                    Y.parse(n, a, s);
                    break;
                default:
                    throw "unknown animationClip version."
            }
            return n
        }
        static load(e, r) {
            t.ILaya.loader.create(e, r, null, Z.ANIMATIONCLIP)
        }
        duration() {
            return this._duration
        }
        _hermiteInterpolate(e, t, r, i) {
            var n = e.outTangent,
                a = t.inTangent;
            if (Number.isFinite(n) &amp;&amp; Number.isFinite(a)) {
                var s = r * r,
                    o = s * r,
                    l = o - 2 * s + r,
                    _ = o - s,
                    h = -2 * o + 3 * s;
                return (2 * o - 3 * s + 1) * e.value + l * n * i + _ * a * i + h * t.value
            }
            return e.value
        }
        _hermiteInterpolateVector3(e, t, r, i, n) {
            var a = e.value,
                s = e.outTangent,
                o = t.value,
                l = t.inTangent,
                _ = r * r,
                h = _ * r,
                c = 2 * h - 3 * _ + 1,
                d = h - 2 * _ + r,
                u = h - _,
                m = -2 * h + 3 * _,
                f = s.x,
                T = l.x;
            Number.isFinite(f) &amp;&amp; Number.isFinite(T) ? n.x = c * a.x + d * f * i + u * T * i + m * o.x : n.x = a.x, f = s.y, T = l.y, Number.isFinite(f) &amp;&amp; Number.isFinite(T) ? n.y = c * a.y + d * f * i + u * T * i + m * o.y : n.y = a.y, f = s.z, T = l.z, Number.isFinite(f) &amp;&amp; Number.isFinite(T) ? n.z = c * a.z + d * f * i + u * T * i + m * o.z : n.z = a.z
        }
        _hermiteInterpolateQuaternion(e, t, r, i, n) {
            var a = e.value,
                s = e.outTangent,
                o = t.value,
                l = t.inTangent,
                _ = r * r,
                h = _ * r,
                c = 2 * h - 3 * _ + 1,
                d = h - 2 * _ + r,
                u = h - _,
                m = -2 * h + 3 * _,
                f = s.x,
                T = l.x;
            Number.isFinite(f) &amp;&amp; Number.isFinite(T) ? n.x = c * a.x + d * f * i + u * T * i + m * o.x : n.x = a.x, f = s.y, T = l.y, Number.isFinite(f) &amp;&amp; Number.isFinite(T) ? n.y = c * a.y + d * f * i + u * T * i + m * o.y : n.y = a.y, f = s.z, T = l.z, Number.isFinite(f) &amp;&amp; Number.isFinite(T) ? n.z = c * a.z + d * f * i + u * T * i + m * o.z : n.z = a.z, f = s.w, T = l.w, Number.isFinite(f) &amp;&amp; Number.isFinite(T) ? n.w = c * a.w + d * f * i + u * T * i + m * o.w : n.w = a.w
        }
        _evaluateClipDatasRealTime(e, t, r, i, n, a) {
            for (var s = 0, o = e.count; s &lt; o; s++) {
                var l, _ = e.getNodeByIndex(s),
                    c = _.type,
                    d = _._keyFrames,
                    u = d.length,
                    m = r[s];
                if (n)
                    for (-1 !== m &amp;&amp; t &lt; d[m].time &amp;&amp; (m = -1, r[s] = m), l = m + 1; l &lt; u &amp;&amp; !(d[l].time &gt; t);) m++, l++, r[s] = m;
                else
                    for ((l = m + 1) !== u &amp;&amp; t &gt; d[l].time &amp;&amp; (m = u - 1, r[s] = m), l = m + 1; m &gt; -1 &amp;&amp; !(d[m].time &lt; t);) m--, l--, r[s] = m;
                var f = l === u;
                switch (c) {
                    case 0:
                        if (-1 !== m) {
                            var T = d[m];
                            if (f) a[s] = T.value;
                            else {
                                var E, p = d[l],
                                    g = p.time - T.time;
                                E = 0 !== g ? (t - T.time) / g : 0, a[s] = this._hermiteInterpolate(T, p, E, g)
                            }
                        } else a[s] = d[0].value;
                        i &amp;&amp; (a[s] = a[s] - d[0].value);
                        break;
                    case 1:
                    case 4:
                        var S = a[s];
                        if (this._evaluateFrameNodeVector3DatasRealTime(d, m, f, t, S), i) {
                            var R = d[0].value;
                            S.x -= R.x, S.y -= R.y, S.z -= R.z
                        }
                        break;
                    case 2:
                        var v = a[s];
                        if (this._evaluateFrameNodeQuaternionDatasRealTime(d, m, f, t, v), i) {
                            var A = Z._tempQuaternion0,
                                I = d[0].value;
                            N.quaternionConjugate(I, A), h.multiply(A, v, v)
                        }
                        break;
                    case 3:
                        S = a[s], this._evaluateFrameNodeVector3DatasRealTime(d, m, f, t, S), i &amp;&amp; (R = d[0].value, S.x /= R.x, S.y /= R.y, S.z /= R.z);
                        break;
                    default:
                        throw "AnimationClip:unknown node type."
                }
            }
        }
        _evaluateClipDatasRealTimeForNative(e, r, i, n) {
            t.LayaGL.instance.evaluateClipDatasRealTime(e._nativeObj, r, i, n)
        }
        _evaluateFrameNodeVector3DatasRealTime(e, t, r, i, n) {
            if (-1 !== t) {
                var a = e[t];
                if (r) {
                    var s = a.value;
                    n.x = s.x, n.y = s.y, n.z = s.z
                } else {
                    var o, l = e[t + 1],
                        _ = a.time,
                        h = l.time - _;
                    o = 0 !== h ? (i - _) / h : 0, this._hermiteInterpolateVector3(a, l, o, h, n)
                }
            } else {
                var c = e[0].value;
                n.x = c.x, n.y = c.y, n.z = c.z
            }
        }
        _evaluateFrameNodeQuaternionDatasRealTime(e, t, r, i, n) {
            if (-1 !== t) {
                var a = e[t];
                if (r) {
                    var s = a.value;
                    n.x = s.x, n.y = s.y, n.z = s.z, n.w = s.w
                } else {
                    var o, l = e[t + 1],
                        _ = a.time,
                        h = l.time - _;
                    o = 0 !== h ? (i - _) / h : 0, this._hermiteInterpolateQuaternion(a, l, o, h, n)
                }
            } else {
                var c = e[0].value;
                n.x = c.x, n.y = c.y, n.z = c.z, n.w = c.w
            }
        }
        _binarySearchEventIndex(e) {
            for (var t, r = 0, i = this._animationEvents.length - 1; r &lt;= i;) {
                t = Math.floor((r + i) / 2);
                var n = this._animationEvents[t].time;
                if (n == e) return t;
                n &gt; e ? i = t - 1 : r = t + 1
            }
            return r
        }
        addEvent(e) {
            var t = this._binarySearchEventIndex(e.time);
            this._animationEvents.splice(t, 0, e)
        }
        _disposeResource() {
            this._nodes = null, this._nodesMap = null
        }
    }
    Z.ANIMATIONCLIP = "ANIMATIONCLIP", Z._tempQuaternion0 = new h;
    class q {
        constructor() {
            this._currentState = null
        }
        get normalizedTime() {
            return this._normalizedTime
        }
        get duration() {
            return this._duration
        }
        get animatorState() {
            return this._currentState
        }
        _resetPlayState(e) {
            this._finish = !1, this._startPlayTime = e, this._elapsedTime = e, this._playEventIndex = 0, this._lastIsFront = !0
        }
        _cloneTo(e) {
            e._finish = this._finish, e._startPlayTime = this._startPlayTime, e._elapsedTime = this._elapsedTime, e._normalizedTime = this._normalizedTime, e._normalizedPlayTime = this._normalizedPlayTime, e._playEventIndex = this._playEventIndex, e._lastIsFront = this._lastIsFront
        }
    }
    class Q {
        constructor(e) {
            this._defaultState = null, this._referenceCount = 0, this._playType = -1, this._crossDuration = -1, this._crossMark = 0, this._crossNodesOwnersCount = 0, this._crossNodesOwners = [], this._crossNodesOwnersIndicesMap = {}, this._srcCrossClipNodeIndices = [], this._destCrossClipNodeIndices = [], this._statesMap = {}, this._states = [], this._playStateInfo = new q, this._crossPlayStateInfo = new q, this.blendingMode = Q.BLENDINGMODE_OVERRIDE, this.defaultWeight = 1, this.playOnWake = !0, this.name = e
        }
        get defaultState() {
            return this._defaultState
        }
        set defaultState(e) {
            this._defaultState = e, this._statesMap[e.name] = e
        }
        _removeClip(e, t, r, i) {
            var n = i._clip,
                a = e[r];
            if (e.splice(r, 1), delete t[i.name], this._animator) {
                var s = n._nodes,
                    o = a._nodeOwners;
                n._removeReference();
                for (var l = 0, _ = s.count; l &lt; _; l++) this._animator._removeKeyframeNodeOwner(o, s.getNodeByIndex(l))
            }
        }
        _getReferenceCount() {
            return this._referenceCount
        }
        _addReference(e = 1) {
            for (var t = 0, r = this._states.length; t &lt; r; t++) this._states[t]._addReference(e);
            this._referenceCount += e
        }
        _removeReference(e = 1) {
            for (var t = 0, r = this._states.length; t &lt; r; t++) this._states[t]._removeReference(e);
            this._referenceCount -= e
        }
        _clearReference() {
            this._removeReference(-this._referenceCount)
        }
        getCurrentPlayState() {
            return this._playStateInfo
        }
        getAnimatorState(e) {
            var t = this._statesMap[e];
            return t || null
        }
        addState(e) {
            var t = e.name;
            if (this._statesMap[t]) throw "AnimatorControllerLayer:this stat's name has exist.";
            this._statesMap[t] = e, this._states.push(e), this._animator &amp;&amp; (e._clip._addReference(), this._animator._getOwnersByClip(e))
        }
        removeState(e) {
            for (var t = this._states, r = -1, i = 0, n = t.length; i &lt; n; i++)
                if (t[i] === e) {
                    r = i;
                    break
                } - 1 !== r &amp;&amp; this._removeClip(t, this._statesMap, r, e)
        }
        destroy() {
            this._clearReference(), this._statesMap = null, this._states = null, this._playStateInfo = null, this._crossPlayStateInfo = null, this._defaultState = null
        }
        cloneTo(e) {
            var t = e;
            t.name = this.name, t.blendingMode = this.blendingMode, t.defaultWeight = this.defaultWeight, t.playOnWake = this.playOnWake
        }
        clone() {
            var e = new Q(this.name);
            return this.cloneTo(e), e
        }
    }
    Q.BLENDINGMODE_OVERRIDE = 0, Q.BLENDINGMODE_ADDTIVE = 1;
    class K {
        constructor(e = 0, t = 0, r = 0, i = 0) {
            var n = this.elements = new Float32Array(4);
            n[0] = e, n[1] = t, n[2] = r, n[3] = i
        }
        get x() {
            return this.elements[0]
        }
        set x(e) {
            this.elements[0] = e
        }
        get y() {
            return this.elements[1]
        }
        set y(e) {
            this.elements[1] = e
        }
        get z() {
            return this.elements[2]
        }
        set z(e) {
            this.elements[2] = e
        }
        get w() {
            return this.elements[3]
        }
        set w(e) {
            this.elements[3] = e
        }
        fromArray(e, t = 0) {
            this.elements[0] = e[t + 0], this.elements[1] = e[t + 1], this.elements[2] = e[t + 2], this.elements[3] = e[t + 3]
        }
        cloneTo(e) {
            var t = e.elements,
                r = this.elements;
            t[0] = r[0], t[1] = r[1], t[2] = r[2], t[3] = r[3]
        }
        clone() {
            var e = new K;
            return this.cloneTo(e), e
        }
        static lerp(e, t, r, i) {
            var n = i.elements,
                a = e.elements,
                s = t.elements,
                o = a[0],
                l = a[1],
                _ = a[2],
                h = a[3];
            n[0] = o + r * (s[0] - o), n[1] = l + r * (s[1] - l), n[2] = _ + r * (s[2] - _), n[3] = h + r * (s[3] - h)
        }
        static transformByM4x4(e, t, r) {
            var i = e.elements,
                n = i[0],
                a = i[1],
                s = i[2],
                o = i[3],
                l = t.elements,
                _ = r.elements;
            _[0] = n * l[0] + a * l[4] + s * l[8] + o * l[12], _[1] = n * l[1] + a * l[5] + s * l[9] + o * l[13], _[2] = n * l[2] + a * l[6] + s * l[10] + o * l[14], _[3] = n * l[3] + a * l[7] + s * l[11] + o * l[15]
        }
        static equals(e, t) {
            var i = e.elements,
                n = t.elements;
            return r.nearEqual(Math.abs(i[0]), Math.abs(n[0])) &amp;&amp; r.nearEqual(Math.abs(i[1]), Math.abs(n[1])) &amp;&amp; r.nearEqual(Math.abs(i[2]), Math.abs(n[2])) &amp;&amp; r.nearEqual(Math.abs(i[3]), Math.abs(n[3]))
        }
        length() {
            return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
        }
        lengthSquared() {
            return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
        }
        static normalize(e, t) {
            var r = e.elements,
                i = t.elements,
                n = e.length();
            n &gt; 0 &amp;&amp; (i[0] = r[0] * n, i[1] = r[1] * n, i[2] = r[2] * n, i[3] = r[3] * n)
        }
        static add(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements;
            i[0] = n[0] + a[0], i[1] = n[1] + a[1], i[2] = n[2] + a[2], i[3] = n[3] + a[3]
        }
        static subtract(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements;
            i[0] = n[0] - a[0], i[1] = n[1] - a[1], i[2] = n[2] - a[2], i[3] = n[3] - a[3]
        }
        static multiply(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements;
            i[0] = n[0] * a[0], i[1] = n[1] * a[1], i[2] = n[2] * a[2], i[3] = n[3] * a[3]
        }
        static scale(e, t, r) {
            var i = r.elements,
                n = e.elements;
            i[0] = n[0] * t, i[1] = n[1] * t, i[2] = n[2] * t, i[3] = n[3] * t
        }
        static Clamp(e, t, r, i) {
            var n = e.elements,
                a = n[0],
                s = n[1],
                o = n[2],
                l = n[3],
                _ = t.elements,
                h = _[0],
                c = _[1],
                d = _[2],
                u = _[3],
                m = r.elements,
                f = m[0],
                T = m[1],
                E = m[2],
                p = m[3],
                g = i.elements;
            a = (a = a &gt; f ? f : a) &lt; h ? h : a, s = (s = s &gt; T ? T : s) &lt; c ? c : s, o = (o = o &gt; E ? E : o) &lt; d ? d : o, l = (l = l &gt; p ? p : l) &lt; u ? u : l, g[0] = a, g[1] = s, g[2] = o, g[3] = l
        }
        static distanceSquared(e, t) {
            var r = e.elements,
                i = t.elements,
                n = r[0] - i[0],
                a = r[1] - i[1],
                s = r[2] - i[2],
                o = r[3] - i[3];
            return n * n + a * a + s * s + o * o
        }
        static distance(e, t) {
            var r = e.elements,
                i = t.elements,
                n = r[0] - i[0],
                a = r[1] - i[1],
                s = r[2] - i[2],
                o = r[3] - i[3];
            return Math.sqrt(n * n + a * a + s * s + o * o)
        }
        static dot(e, t) {
            var r = e.elements,
                i = t.elements;
            return r[0] * i[0] + r[1] * i[1] + r[2] * i[2] + r[3] * i[3]
        }
        static min(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements;
            i[0] = Math.min(n[0], a[0]), i[1] = Math.min(n[1], a[1]), i[2] = Math.min(n[2], a[2]), i[3] = Math.min(n[3], a[3])
        }
        static max(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements;
            i[0] = Math.max(n[0], a[0]), i[1] = Math.max(n[1], a[1]), i[2] = Math.max(n[2], a[2]), i[3] = Math.max(n[3], a[3])
        }
    }
    K.ZERO = new K, K.ONE = new K(1, 1, 1, 1), K.UnitX = new K(1, 0, 0, 0), K.UnitY = new K(0, 1, 0, 0), K.UnitZ = new K(0, 0, 1, 0), K.UnitW = new K(0, 0, 0, 1);
    class J {
        constructor(e = 0, t = 0, r = 0, i = null) {
            var n;
            n = i || new Float32Array(3), this.elements = n, n[0] = e, n[1] = t, n[2] = r
        }
        static distanceSquared(e, t) {
            var r = e.elements,
                i = t.elements,
                n = r[0] - i[0],
                a = r[1] - i[1],
                s = r[2] - i[2];
            return n * n + a * a + s * s
        }
        static distance(e, t) {
            var r = e.elements,
                i = t.elements,
                n = r[0] - i[0],
                a = r[1] - i[1],
                s = r[2] - i[2];
            return Math.sqrt(n * n + a * a + s * s)
        }
        static min(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements;
            i[0] = Math.min(n[0], a[0]), i[1] = Math.min(n[1], a[1]), i[2] = Math.min(n[2], a[2])
        }
        static max(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements;
            i[0] = Math.max(n[0], a[0]), i[1] = Math.max(n[1], a[1]), i[2] = Math.max(n[2], a[2])
        }
        static transformQuat(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements,
                s = n[0],
                o = n[1],
                l = n[2],
                _ = a[0],
                h = a[1],
                c = a[2],
                d = a[3],
                u = d * s + h * l - c * o,
                m = d * o + c * s - _ * l,
                f = d * l + _ * o - h * s,
                T = -_ * s - h * o - c * l;
            i[0] = u * d + T * -_ + m * -c - f * -h, i[1] = m * d + T * -h + f * -_ - u * -c, i[2] = f * d + T * -c + u * -h - m * -_
        }
        static scalarLength(e) {
            var t = e.elements,
                r = t[0],
                i = t[1],
                n = t[2];
            return Math.sqrt(r * r + i * i + n * n)
        }
        static scalarLengthSquared(e) {
            var t = e.elements,
                r = t[0],
                i = t[1],
                n = t[2];
            return r * r + i * i + n * n
        }
        static normalize(e, t) {
            var r = e.elements,
                i = t.elements,
                n = r[0],
                a = r[1],
                s = r[2],
                o = n * n + a * a + s * s;
            o &gt; 0 &amp;&amp; (o = 1 / Math.sqrt(o), i[0] = r[0] * o, i[1] = r[1] * o, i[2] = r[2] * o)
        }
        static multiply(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements;
            i[0] = n[0] * a[0], i[1] = n[1] * a[1], i[2] = n[2] * a[2]
        }
        static scale(e, t, r) {
            var i = r.elements,
                n = e.elements;
            i[0] = n[0] * t, i[1] = n[1] * t, i[2] = n[2] * t
        }
        static lerp(e, t, r, i) {
            var n = i.elements,
                a = e.elements,
                s = t.elements,
                o = a[0],
                l = a[1],
                _ = a[2];
            n[0] = o + r * (s[0] - o), n[1] = l + r * (s[1] - l), n[2] = _ + r * (s[2] - _)
        }
        static transformV3ToV3(e, t, r) {
            var i = J._tempVector4;
            J.transformV3ToV4(e, t, i);
            var n = i.elements,
                a = r.elements;
            a[0] = n[0], a[1] = n[1], a[2] = n[2]
        }
        static transformV3ToV4(e, t, r) {
            var i = e.elements,
                n = i[0],
                a = i[1],
                s = i[2],
                o = t.elements,
                l = r.elements;
            l[0] = n * o[0] + a * o[4] + s * o[8] + o[12], l[1] = n * o[1] + a * o[5] + s * o[9] + o[13], l[2] = n * o[2] + a * o[6] + s * o[10] + o[14], l[3] = n * o[3] + a * o[7] + s * o[11] + o[15]
        }
        static TransformNormal(e, t, r) {
            var i = e.elements,
                n = i[0],
                a = i[1],
                s = i[2],
                o = t.elements,
                l = r.elements;
            l[0] = n * o[0] + a * o[4] + s * o[8], l[1] = n * o[1] + a * o[5] + s * o[9], l[2] = n * o[2] + a * o[6] + s * o[10]
        }
        static transformCoordinate(e, t, r) {
            var i = e.elements,
                n = i[0],
                a = i[1],
                s = i[2],
                o = t.elements,
                l = n * o[3] + a * o[7] + s * o[11] + o[15],
                _ = r.elements;
            _[0] = n * o[0] + a * o[4] + s * o[8] + o[12] / l, _[1] = n * o[1] + a * o[5] + s * o[9] + o[13] / l, _[2] = n * o[2] + a * o[6] + s * o[10] + o[14] / l
        }
        static Clamp(e, t, r, i) {
            var n = e.elements,
                a = n[0],
                s = n[1],
                o = n[2],
                l = t.elements,
                _ = l[0],
                h = l[1],
                c = l[2],
                d = r.elements,
                u = d[0],
                m = d[1],
                f = d[2],
                T = i.elements;
            a = (a = a &gt; u ? u : a) &lt; _ ? _ : a, s = (s = s &gt; m ? m : s) &lt; h ? h : s, o = (o = o &gt; f ? f : o) &lt; c ? c : o, T[0] = a, T[1] = s, T[2] = o
        }
        static add(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements;
            i[0] = n[0] + a[0], i[1] = n[1] + a[1], i[2] = n[2] + a[2]
        }
        static subtract(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements;
            i[0] = n[0] - a[0], i[1] = n[1] - a[1], i[2] = n[2] - a[2]
        }
        static cross(e, t, r) {
            var i = e.elements,
                n = t.elements,
                a = r.elements,
                s = i[0],
                o = i[1],
                l = i[2],
                _ = n[0],
                h = n[1],
                c = n[2];
            a[0] = o * c - l * h, a[1] = l * _ - s * c, a[2] = s * h - o * _
        }
        static dot(e, t) {
            var r = e.elements,
                i = t.elements;
            return r[0] * i[0] + r[1] * i[1] + r[2] * i[2]
        }
        static equals(e, t) {
            var i = e.elements,
                n = t.elements;
            return r.nearEqual(i[0], n[0]) &amp;&amp; r.nearEqual(i[1], n[1]) &amp;&amp; r.nearEqual(i[2], n[2])
        }
        get x() {
            return this.elements[0]
        }
        set x(e) {
            this.elements[0] = e
        }
        get y() {
            return this.elements[1]
        }
        set y(e) {
            this.elements[1] = e
        }
        get z() {
            return this.elements[2]
        }
        set z(e) {
            this.elements[2] = e
        }
        setValue(e, t, r) {
            this.elements[0] = e, this.elements[1] = t, this.elements[2] = r
        }
        fromArray(e, t = 0) {
            this.elements[0] = e[t + 0], this.elements[1] = e[t + 1], this.elements[2] = e[t + 2]
        }
        cloneTo(e) {
            var t = e.elements,
                r = this.elements;
            t[0] = r[0], t[1] = r[1], t[2] = r[2]
        }
        clone() {
            var e = new J;
            return this.cloneTo(e), e
        }
        toDefault() {
            this.elements[0] = 0, this.elements[1] = 0, this.elements[2] = 0
        }
    }
    J._tempVector4 = new K, J.ZERO = new J(0, 0, 0), J.ONE = new J(1, 1, 1), J.NegativeUnitX = new J(-1, 0, 0), J.UnitX = new J(1, 0, 0), J.UnitY = new J(0, 1, 0), J.UnitZ = new J(0, 0, 1), J.ForwardRH = new J(0, 0, -1), J.ForwardLH = new J(0, 0, 1), J.Up = new J(0, 1, 0), J.NAN = new J(NaN, NaN, NaN);
    class $ {
        constructor(e = 0, t = 0, r = 0, i = 1, n = null) {
            var a;
            (a = n || new Float32Array(4))[0] = e, a[1] = t, a[2] = r, a[3] = i, this.elements = a
        }
        static _dotArray(e, t) {
            return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] + e[3] * t[3]
        }
        static _normalizeArray(e, t) {
            var r = e[0],
                i = e[1],
                n = e[2],
                a = e[3],
                s = r * r + i * i + n * n + a * a;
            s &gt; 0 &amp;&amp; (s = 1 / Math.sqrt(s), t[0] = r * s, t[1] = i * s, t[2] = n * s, t[3] = a * s)
        }
        static _lerpArray(e, t, r, i) {
            var n = 1 - r;
            $._dotArray(e, t) &gt;= 0 ? (i[0] = n * e[0] + r * t[0], i[1] = n * e[1] + r * t[1], i[2] = n * e[2] + r * t[2], i[3] = n * e[3] + r * t[3]) : (i[0] = n * e[0] - r * t[0], i[1] = n * e[1] - r * t[1], i[2] = n * e[2] - r * t[2], i[3] = n * e[3] - r * t[3]), $._normalizeArray(i, i)
        }
        static createFromYawPitchRoll(e, t, r, i) {
            var n = .5 * r,
                a = .5 * t,
                s = .5 * e,
                o = Math.sin(n),
                l = Math.cos(n),
                _ = Math.sin(a),
                h = Math.cos(a),
                c = Math.sin(s),
                d = Math.cos(s),
                u = i.elements;
            u[0] = d * _ * l + c * h * o, u[1] = c * h * l - d * _ * o, u[2] = d * h * o - c * _ * l, u[3] = d * h * l + c * _ * o
        }
        static multiply(e, t, r) {
            var i = e.elements,
                n = t.elements,
                a = r.elements,
                s = i[0],
                o = i[1],
                l = i[2],
                _ = i[3],
                h = n[0],
                c = n[1],
                d = n[2],
                u = n[3],
                m = o * d - l * c,
                f = l * h - s * d,
                T = s * c - o * h,
                E = s * h + o * c + l * d;
            a[0] = s * u + h * _ + m, a[1] = o * u + c * _ + f, a[2] = l * u + d * _ + T, a[3] = _ * u - E
        }
        static arcTanAngle(e, t) {
            return 0 == e ? 1 == t ? Math.PI / 2 : -Math.PI / 2 : e &gt; 0 ? Math.atan(t / e) : e &lt; 0 ? t &gt; 0 ? Math.atan(t / e) + Math.PI : Math.atan(t / e) - Math.PI : 0
        }
        static angleTo(e, t, r) {
            J.subtract(t, e, $.TEMPVector30), J.normalize($.TEMPVector30, $.TEMPVector30), r.elements[0] = Math.asin($.TEMPVector30.y), r.elements[1] = $.arcTanAngle(-$.TEMPVector30.z, -$.TEMPVector30.x)
        }
        static createFromAxisAngle(e, t, r) {
            var i = r.elements,
                n = e.elements;
            t *= .5;
            var a = Math.sin(t);
            i[0] = a * n[0], i[1] = a * n[1], i[2] = a * n[2], i[3] = Math.cos(t)
        }
        static createFromMatrix3x3(e, t) {
            var r, i = t.elements,
                n = e.elements,
                a = n[0] + n[4] + n[8];
            if (a &gt; 0) r = Math.sqrt(a + 1), i[3] = .5 * r, r = .5 / r, i[0] = (n[5] - n[7]) * r, i[1] = (n[6] - n[2]) * r, i[2] = (n[1] - n[3]) * r;
            else {
                var s = 0;
                n[4] &gt; n[0] &amp;&amp; (s = 1), n[8] &gt; n[3 * s + s] &amp;&amp; (s = 2);
                var o = (s + 1) % 3,
                    l = (s + 2) % 3;
                r = Math.sqrt(n[3 * s + s] - n[3 * o + o] - n[3 * l + l] + 1), i[s] = .5 * r, r = .5 / r, i[3] = (n[3 * o + l] - n[3 * l + o]) * r, i[o] = (n[3 * o + s] + n[3 * s + o]) * r, i[l] = (n[3 * l + s] + n[3 * s + l]) * r
            }
        }
        static createFromMatrix4x4(e, t) {
            var r, i, n = e.elements,
                a = t.elements,
                s = n[0] + n[5] + n[10];
            s &gt; 0 ? (r = Math.sqrt(s + 1), a[3] = .5 * r, r = .5 / r, a[0] = (n[6] - n[9]) * r, a[1] = (n[8] - n[2]) * r, a[2] = (n[1] - n[4]) * r) : n[0] &gt;= n[5] &amp;&amp; n[0] &gt;= n[10] ? (i = .5 / (r = Math.sqrt(1 + n[0] - n[5] - n[10])), a[0] = .5 * r, a[1] = (n[1] + n[4]) * i, a[2] = (n[2] + n[8]) * i, a[3] = (n[6] - n[9]) * i) : n[5] &gt; n[10] ? (i = .5 / (r = Math.sqrt(1 + n[5] - n[0] - n[10])), a[0] = (n[4] + n[1]) * i, a[1] = .5 * r, a[2] = (n[9] + n[6]) * i, a[3] = (n[8] - n[2]) * i) : (i = .5 / (r = Math.sqrt(1 + n[10] - n[0] - n[5])), a[0] = (n[8] + n[2]) * i, a[1] = (n[9] + n[6]) * i, a[2] = .5 * r, a[3] = (n[1] - n[4]) * i)
        }
        static slerp(e, t, r, i) {
            var n, a, s, o, l, _ = e.elements,
                h = t.elements,
                c = i.elements,
                d = _[0],
                u = _[1],
                m = _[2],
                f = _[3],
                T = h[0],
                E = h[1],
                p = h[2],
                g = h[3];
            return (a = d * T + u * E + m * p + f * g) &lt; 0 &amp;&amp; (a = -a, T = -T, E = -E, p = -p, g = -g), 1 - a &gt; 1e-6 ? (n = Math.acos(a), s = Math.sin(n), o = Math.sin((1 - r) * n) / s, l = Math.sin(r * n) / s) : (o = 1 - r, l = r), c[0] = o * d + l * T, c[1] = o * u + l * E, c[2] = o * m + l * p, c[3] = o * f + l * g, c
        }
        static lerp(e, t, r, i) {
            $._lerpArray(e.elements, t.elements, r, i.elements)
        }
        static add(e, t, r) {
            var i = r.elements,
                n = e.elements,
                a = t.elements;
            i[0] = n[0] + a[0], i[1] = n[1] + a[1], i[2] = n[2] + a[2], i[3] = n[3] + a[3]
        }
        static dot(e, t) {
            return $._dotArray(e.elements, t.elements)
        }
        get x() {
            return this.elements[0]
        }
        set x(e) {
            this.elements[0] = e
        }
        get y() {
            return this.elements[1]
        }
        set y(e) {
            this.elements[1] = e
        }
        get z() {
            return this.elements[2]
        }
        set z(e) {
            this.elements[2] = e
        }
        get w() {
            return this.elements[3]
        }
        set w(e) {
            this.elements[3] = e
        }
        scaling(e, t) {
            var r = t.elements,
                i = this.elements;
            r[0] = i[0] * e, r[1] = i[1] * e, r[2] = i[2] * e, r[3] = i[3] * e
        }
        normalize(e) {
            $._normalizeArray(this.elements, e.elements)
        }
        length() {
            var e = this.elements,
                t = e[0],
                r = e[1],
                i = e[2],
                n = e[3];
            return Math.sqrt(t * t + r * r + i * i + n * n)
        }
        rotateX(e, t) {
            var r = t.elements,
                i = this.elements;
            e *= .5;
            var n = i[0],
                a = i[1],
                s = i[2],
                o = i[3],
                l = Math.sin(e),
                _ = Math.cos(e);
            r[0] = n * _ + o * l, r[1] = a * _ + s * l, r[2] = s * _ - a * l, r[3] = o * _ - n * l
        }
        rotateY(e, t) {
            var r = t.elements,
                i = this.elements;
            e *= .5;
            var n = i[0],
                a = i[1],
                s = i[2],
                o = i[3],
                l = Math.sin(e),
                _ = Math.cos(e);
            r[0] = n * _ - s * l, r[1] = a * _ + o * l, r[2] = s * _ + n * l, r[3] = o * _ - a * l
        }
        rotateZ(e, t) {
            var r = t.elements,
                i = this.elements;
            e *= .5;
            var n = i[0],
                a = i[1],
                s = i[2],
                o = i[3],
                l = Math.sin(e),
                _ = Math.cos(e);
            r[0] = n * _ + a * l, r[1] = a * _ - n * l, r[2] = s * _ + o * l, r[3] = o * _ - s * l
        }
        getYawPitchRoll(e) {
            J.transformQuat(J.ForwardRH, this, $.TEMPVector31), J.transformQuat(J.Up, this, $.TEMPVector32);
            var t = $.TEMPVector32.elements;
            $.angleTo(J.ZERO, $.TEMPVector31, $.TEMPVector33);
            var r = $.TEMPVector33.elements;
            r[0] == Math.PI / 2 ? (r[1] = $.arcTanAngle(t[2], t[0]), r[2] = 0) : r[0] == -Math.PI / 2 ? (r[1] = $.arcTanAngle(-t[2], -t[0]), r[2] = 0) : (c.createRotationY(-r[1], $.TEMPMatrix0), c.createRotationX(-r[0], $.TEMPMatrix1), J.transformCoordinate($.TEMPVector32, $.TEMPMatrix0, $.TEMPVector32), J.transformCoordinate($.TEMPVector32, $.TEMPMatrix1, $.TEMPVector32), r[2] = $.arcTanAngle(t[1], -t[0])), r[1] &lt;= -Math.PI &amp;&amp; (r[1] = Math.PI), r[2] &lt;= -Math.PI &amp;&amp; (r[2] = Math.PI), r[1] &gt;= Math.PI &amp;&amp; r[2] &gt;= Math.PI &amp;&amp; (r[1] = 0, r[2] = 0, r[0] = Math.PI - r[0]);
            var i = e.elements;
            i[0] = r[1], i[1] = r[0], i[2] = r[2]
        }
        invert(e) {
            var t = e.elements,
                r = this.elements,
                i = r[0],
                n = r[1],
                a = r[2],
                s = r[3],
                o = i * i + n * n + a * a + s * s,
                l = o ? 1 / o : 0;
            t[0] = -i * l, t[1] = -n * l, t[2] = -a * l, t[3] = s * l
        }
        identity() {
            var e = this.elements;
            e[0] = 0, e[1] = 0, e[2] = 0, e[3] = 1
        }
        fromArray(e, t = 0) {
            this.elements[0] = e[t + 0], this.elements[1] = e[t + 1], this.elements[2] = e[t + 2], this.elements[3] = e[t + 3]
        }
        cloneTo(e) {
            var t, r, i;
            if ((r = this.elements) !== (i = e.elements))
                for (t = 0; t &lt; 4; ++t) i[t] = r[t]
        }
        clone() {
            var e = new $;
            return this.cloneTo(e), e
        }
        equals(e) {
            var t = this.elements,
                i = e.elements;
            return r.nearEqual(t[0], i[0]) &amp;&amp; r.nearEqual(t[1], i[1]) &amp;&amp; r.nearEqual(t[2], i[2]) &amp;&amp; r.nearEqual(t[3], i[3])
        }
        static rotationLookAt(e, t, r) {
            $.lookAt(J.ZERO, e, t, r)
        }
        static lookAt(e, t, r, i) {
            l.lookAt(e, t, r, $._tempMatrix3x3), $.rotationMatrix($._tempMatrix3x3, i)
        }
        lengthSquared() {
            var e = this.elements[0],
                t = this.elements[1],
                r = this.elements[2],
                i = this.elements[3];
            return e * e + t * t + r * r + i * i
        }
        static invert(e, t) {
            var i = e.elements,
                n = t.elements,
                a = e.lengthSquared();
            r.isZero(a) || (a = 1 / a, n[0] = -i[0] * a, n[1] = -i[1] * a, n[2] = -i[2] * a, n[3] = i[3] * a)
        }
        static rotationMatrix(e, t) {
            var r, i, n = e.elements,
                a = n[0],
                s = n[1],
                o = n[2],
                l = n[3],
                _ = n[4],
                h = n[5],
                c = n[6],
                d = n[7],
                u = n[8],
                m = t.elements,
                f = a + _ + u;
            f &gt; 0 ? (r = Math.sqrt(f + 1), m[3] = .5 * r, r = .5 / r, m[0] = (h - d) * r, m[1] = (c - o) * r, m[2] = (s - l) * r) : a &gt;= _ &amp;&amp; a &gt;= u ? (i = .5 / (r = Math.sqrt(1 + a - _ - u)), m[0] = .5 * r, m[1] = (s + l) * i, m[2] = (o + c) * i, m[3] = (h - d) * i) : _ &gt; u ? (i = .5 / (r = Math.sqrt(1 + _ - a - u)), m[0] = (l + s) * i, m[1] = .5 * r, m[2] = (d + h) * i, m[3] = (c - o) * i) : (i = .5 / (r = Math.sqrt(1 + u - a - _)), m[0] = (c + o) * i, m[1] = (d + h) * i, m[2] = .5 * r, m[3] = (s - l) * i)
        }
    }
    $.TEMPVector30 = new J, $.TEMPVector31 = new J, $.TEMPVector32 = new J, $.TEMPVector33 = new J, $.TEMPMatrix0 = new c, $.TEMPMatrix1 = new c, $._tempMatrix3x3 = new l, $.DEFAULT = new $, $.NAN = new $(NaN, NaN, NaN, NaN);
    class ee {
        constructor() {
            this._referenceCount = 0, this._clip = null, this._nodeOwners = [], this._currentFrameIndices = null, this._realtimeDatas = [], this._scripts = null, this.speed = 1, this.clipStart = 0, this.clipEnd = 1
        }
        get clip() {
            return this._clip
        }
        set clip(e) {
            if (this._clip !== e) {
                if (this._clip &amp;&amp; this._referenceCount &gt; 0 &amp;&amp; this._clip._removeReference(this._referenceCount), e) {
                    var r = this._realtimeDatas,
                        i = e._nodes,
                        n = i.count;
                    this._currentFrameIndices = new Int16Array(n), this._resetFrameIndices(), this._referenceCount &gt; 0 &amp;&amp; e._addReference(this._referenceCount), this._realtimeDatas.length = n;
                    for (var s = 0; s &lt; n; s++) switch (i.getNodeByIndex(s).type) {
                        case 0:
                            break;
                        case 1:
                        case 3:
                        case 4:
                            r[s] = t.Render.supportWebGLPlusAnimation ? new J : new a;
                            break;
                        case 2:
                            r[s] = t.Render.supportWebGLPlusAnimation ? new $ : new h;
                            break;
                        default:
                            throw "AnimationClipParser04:unknown type."
                    }
                }
                this._clip = e
            }
        }
        _getReferenceCount() {
            return this._referenceCount
        }
        _addReference(e = 1) {
            this._clip &amp;&amp; this._clip._addReference(e), this._referenceCount += e
        }
        _removeReference(e = 1) {
            this._clip &amp;&amp; this._clip._removeReference(e), this._referenceCount -= e
        }
        _clearReference() {
            this._removeReference(-this._referenceCount)
        }
        _resetFrameIndices() {
            for (var e = 0, t = this._currentFrameIndices.length; e &lt; t; e++) this._currentFrameIndices[e] = -1
        }
        addScript(e) {
            var t = new e;
            return this._scripts = this._scripts || [], this._scripts.push(t), t
        }
        getScript(e) {
            if (this._scripts)
                for (var t = 0, r = this._scripts.length; t &lt; r; t++) {
                    var i = this._scripts[t];
                    if (i instanceof e) return i
                }
            return null
        }
        getScripts(e) {
            var t;
            if (this._scripts)
                for (var r = 0, i = this._scripts.length; r &lt; i; r++) {
                    var n = this._scripts[r];
                    n instanceof e &amp;&amp; (t = t || []).push(n)
                }
            return t
        }
        cloneTo(e) {
            var t = e;
            t.name = this.name, t.speed = this.speed, t.clipStart = this.clipStart, t.clipEnd = this.clipEnd, t.clip = this._clip
        }
        clone() {
            var e = new ee;
            return this.cloneTo(e), e
        }
    }
    class te {
        constructor() {
            this.indexInList = -1, this.referenceCount = 0, this.updateMark = -1, this.type = -1, this.fullPath = null, this.propertyOwner = null, this.property = null, this.defaultValue = null, this.value = null, this.crossFixedValue = null
        }
        saveCrossFixedValue() {
            if (this.propertyOwner) switch (this.type) {
                case 0:
                    this.crossFixedValue = this.value;
                    break;
                case 1:
                case 3:
                case 4:
                case 2:
                    this.value.cloneTo(this.crossFixedValue);
                    break;
                default:
                    throw "Animator:unknown type."
            }
        }
    }
    class re extends t.Component {
        constructor() {
            super(), this._keyframeNodeOwners = [], this._linkAvatarSpritesData = {}, this._linkAvatarSprites = [], this._renderableSprites = [], this.cullingMode = re.CULLINGMODE_CULLCOMPLETELY, this._controllerLayers = [], this._linkSprites = {}, this._speed = 1, this._keyframeNodeOwnerMap = {}, this._updateMark = 0, this._eventDispatcher = new t.EventDispatcher
        }
        static _update(e) {
            for (var t = e._animatorPool, r = t.elements, i = 0, n = t.length; i &lt; n; i++) {
                var a = r[i];
                a &amp;&amp; a.enabled &amp;&amp; a._update()
            }
        }
        get speed() {
            return this._speed
        }
        set speed(e) {
            this._speed = e
        }
        on(e, t, r, i = null) {
            return this._eventDispatcher.on(e, t, r, i, !1)
        }
        _linkToSprites(e) {
            for (var t in e) {
                for (var r = this.owner, i = e[t], n = 0, a = i.length; n &lt; a; n++) {
                    var s = i[n];
                    if ("" === s) break;
                    if (!(r = r.getChildByName(s))) break
                }
                r &amp;&amp; this.linkSprite3DToAvatarNode(t, r)
            }
        }
        _addKeyframeNodeOwner(e, t, r) {
            var i = t._indexInList,
                n = t.fullPath,
                a = this._keyframeNodeOwnerMap[n];
            if (a) a.referenceCount++, e[i] = a;
            else {
                for (var s = r, o = 0, l = t.propertyCount; o &lt; l &amp;&amp; (s = s[t.getPropertyByIndex(o)]); o++);
                (a = this._keyframeNodeOwnerMap[n] = new te).fullPath = n, a.indexInList = this._keyframeNodeOwners.length, a.referenceCount = 1, a.propertyOwner = r;
                var _ = t.propertyCount,
                    h = [];
                for (o = 0; o &lt; _; o++) h[o] = t.getPropertyByIndex(o);
                if (a.property = h, a.type = t.type, s)
                    if (0 === t.type) a.defaultValue = s;
                    else {
                        var c = new s.constructor;
                        s.cloneTo(c), a.defaultValue = c, a.value = new s.constructor, a.crossFixedValue = new s.constructor
                    }
                this._keyframeNodeOwners.push(a), e[i] = a
            }
        }
        _removeKeyframeNodeOwner(e, t) {
            var r = t.fullPath,
                i = this._keyframeNodeOwnerMap[r];
            i &amp;&amp; (i.referenceCount--, 0 === i.referenceCount &amp;&amp; (delete this._keyframeNodeOwnerMap[r], this._keyframeNodeOwners.splice(this._keyframeNodeOwners.indexOf(i), 1)), e[t._indexInList] = null)
        }
        _getOwnersByClip(e) {
            var t = e._clip._nodes,
                r = t.count,
                i = e._nodeOwners;
            i.length = r;
            for (var n = 0; n &lt; r; n++) {
                for (var a = t.getNodeByIndex(n), s = this._avatar ? this._avatarNodeMap[this._avatar._rootNode.name] : this.owner, o = 0, l = a.ownerPathCount; o &lt; l; o++) {
                    var _ = a.getOwnerPathByIndex(o);
                    if ("" === _) break;
                    if (!(s = s.getChildByName(_))) break
                }
                if (s) {
                    var h = a.propertyOwner;
                    h &amp;&amp; (s = s[h]), s &amp;&amp; this._addKeyframeNodeOwner(i, a, s)
                }
            }
        }
        _updatePlayer(e, r, i, n) {
            var a = e._clip._duration * (e.clipEnd - e.clipStart),
                s = r._elapsedTime,
                o = s + i;
            r._lastElapsedTime = s, r._elapsedTime = o;
            var l = o / a;
            r._normalizedTime = l;
            var _ = l % 1;
            r._normalizedPlayTime = _ &lt; 0 ? _ + 1 : _, r._duration = a;
            var h = e._scripts;
            if (!n &amp;&amp; o &gt;= a) {
                if (r._finish = !0, r._elapsedTime = a, r._normalizedPlayTime = 1, h)
                    for (var c = 0, d = h.length; c &lt; d; c++) h[c].onStateExit();
                o &gt;= a &amp;&amp; this._eventDispatcher.event(t.Event.COMPLETE)
            } else if (o &gt;= a &amp;&amp; this._eventDispatcher.event(t.Event.COMPLETE), h)
                for (c = 0, d = h.length; c &lt; d; c++) h[c].onStateUpdate()
        }
        _eventScript(e, t, r, i, n) {
            if (n)
                for (var a = t.length; r &lt; a; r++) {
                    var s = t[r];
                    if (!(s.time &lt;= i)) break;
                    for (var o = 0, l = e.length; o &lt; l; o++) {
                        var _ = e[o],
                            h = _[s.eventName];
                        h &amp;&amp; h.apply(_, s.params)
                    }
                } else
                    for (; r &gt;= 0 &amp;&amp; (s = t[r]).time &gt;= i; r--)
                        for (o = 0, l = e.length; o &lt; l; o++)(h = (_ = e[o])[s.eventName]) &amp;&amp; h.apply(_, s.params);
            return r
        }
        _updateEventScript(e, t) {
            var r = this.owner._scripts;
            if (r) {
                var i = e._clip,
                    n = i._animationEvents,
                    a = i._duration,
                    s = t._elapsedTime,
                    o = s % a,
                    l = Math.abs(Math.floor(s / a) - Math.floor(t._lastElapsedTime / a)),
                    _ = t._elapsedTime &gt;= t._lastElapsedTime;
                if (t._lastIsFront !== _ &amp;&amp; (_ ? t._playEventIndex++ : t._playEventIndex--, t._lastIsFront = _), _) {
                    t._playEventIndex = this._eventScript(r, n, t._playEventIndex, l &gt; 0 ? a : o, !0);
                    for (var h = 0, c = l - 1; h &lt; c; h++) this._eventScript(r, n, 0, a, !0);
                    l &gt; 0 &amp;&amp; o &gt; 0 &amp;&amp; (t._playEventIndex = this._eventScript(r, n, 0, o, !0))
                } else {
                    t._playEventIndex = this._eventScript(r, n, t._playEventIndex, l &gt; 0 ? 0 : o, !1);
                    var d = n.length - 1;
                    for (h = 0, c = l - 1; h &lt; c; h++) this._eventScript(r, n, d, 0, !1);
                    l &gt; 0 &amp;&amp; o &gt; 0 &amp;&amp; (t._playEventIndex = this._eventScript(r, n, d, o, !1))
                }
            }
        }
        _updateClipDatas(e, t, r, i) {
            var n = e._clip,
                a = n._duration,
                s = e.clipStart * a + r._normalizedPlayTime * r._duration,
                o = e._currentFrameIndices,
                l = r._elapsedTime &gt; r._lastElapsedTime;
            n._evaluateClipDatasRealTime(n._nodes, s, o, t, l, e._realtimeDatas)
        }
        _applyFloat(e, t, r, i, n, a, s) {
            if (r.updateMark === this._updateMark)
                if (i) e[t] += n * s;
                else {
                    var o = e[t];
                    e[t] = o + n * (s - o)
                }
            else if (a) e[t] = i ? r.defaultValue + s : s;
            else if (i) e[t] = r.defaultValue + n * s;
            else {
                var l = r.defaultValue;
                e[t] = l + n * (s - l)
            }
        }
        _applyPositionAndRotationEuler(e, t, r, i, n, a) {
            if (e.updateMark === this._updateMark)
                if (t) a.x += r * n.x, a.y += r * n.y, a.z += r * n.z;
                else {
                    var s = a.x,
                        o = a.y,
                        l = a.z;
                    a.x = s + r * (n.x - s), a.y = o + r * (n.y - o), a.z = l + r * (n.z - l)
                }
            else if (i)
                if (t) {
                    var _ = e.defaultValue;
                    a.x = _.x + n.x, a.y = _.y + n.y, a.z = _.z + n.z
                } else a.x = n.x, a.y = n.y, a.z = n.z;
            else if (_ = e.defaultValue, t) a.x = _.x + r * n.x, a.y = _.y + r * n.y, a.z = _.z + r * n.z;
            else {
                var h = _.x,
                    c = _.y,
                    d = _.z;
                a.x = h + r * (n.x - h), a.y = c + r * (n.y - c), a.z = d + r * (n.z - d)
            }
        }
        _applyRotation(e, t, r, i, n, a) {
            if (e.updateMark === this._updateMark)
                if (t) {
                    var s = re._tempQuaternion1;
                    N.quaternionWeight(n, r, s), s.normalize(s), h.multiply(a, s, a)
                } else h.lerp(a, n, r, a);
            else if (i)
                if (t) {
                    var o = e.defaultValue;
                    h.multiply(o, n, a)
                } else a.x = n.x, a.y = n.y, a.z = n.z, a.w = n.w;
            else o = e.defaultValue, t ? (s = re._tempQuaternion1, N.quaternionWeight(n, r, s), s.normalize(s), h.multiply(o, s, a)) : h.lerp(o, n, r, a)
        }
        _applyScale(e, t, r, i, n, a) {
            if (e.updateMark === this._updateMark)
                if (t) {
                    var s = re._tempVector31;
                    N.scaleWeight(n, r, s), a.x = a.x * s.x, a.y = a.y * s.y, a.z = a.z * s.z
                } else N.scaleBlend(a, n, r, a);
            else if (i)
                if (t) {
                    var o = e.defaultValue;
                    a.x = o.x * n.x, a.y = o.y * n.y, a.z = o.z * n.z
                } else a.x = n.x, a.y = n.y, a.z = n.z;
            else o = e.defaultValue, t ? (s = re._tempVector31, N.scaleWeight(n, r, s), a.x = o.x * s.x, a.y = o.y * s.y, a.z = o.z * s.z) : N.scaleBlend(o, n, r, a)
        }
        _applyCrossData(e, t, r, i, n, a, s) {
            var o = e.propertyOwner;
            if (o) {
                switch (e.type) {
                    case 0:
                        for (var l = e.property, _ = l.length - 1, c = 0; c &lt; _ &amp;&amp; (o = o[l[c]]); c++);
                        var d = n + s * (a - n);
                        e.value = d, this._applyFloat(o, l[_], e, t, r, i, d);
                        break;
                    case 1:
                        var u = o.localPosition,
                            m = e.value,
                            f = n.x,
                            T = n.y,
                            E = n.z;
                        m.x = f + s * (a.x - f), m.y = T + s * (a.y - T), m.z = E + s * (a.z - E), this._applyPositionAndRotationEuler(e, t, r, i, m, u), o.localPosition = u;
                        break;
                    case 2:
                        var p = o.localRotation,
                            g = e.value;
                        h.lerp(n, a, s, g), this._applyRotation(e, t, r, i, g, p), o.localRotation = p;
                        break;
                    case 3:
                        var S = o.localScale,
                            R = e.value;
                        N.scaleBlend(n, a, s, R), this._applyScale(e, t, r, i, R, S), o.localScale = S;
                        break;
                    case 4:
                        var v = o.localRotationEuler,
                            A = e.value;
                        f = n.x, T = n.y, E = n.z, A.x = f + s * (a.x - f), A.y = T + s * (a.y - T), A.z = E + s * (a.z - E), this._applyPositionAndRotationEuler(e, t, r, i, A, v), o.localRotationEuler = v
                }
                e.updateMark = this._updateMark
            }
        }
        _setClipDatasToNode(e, t, r, i) {
            for (var n = e._realtimeDatas, a = e._clip._nodes, s = e._nodeOwners, o = 0, l = a.count; o &lt; l; o++) {
                var _ = s[o];
                if (_) {
                    var h = _.propertyOwner;
                    if (h) {
                        switch (_.type) {
                            case 0:
                                for (var c = _.property, d = c.length - 1, u = 0; u &lt; d &amp;&amp; (h = h[c[u]]); u++);
                                this._applyFloat(h, c[d], _, t, r, i, n[o]);
                                break;
                            case 1:
                                var m = h.localPosition;
                                this._applyPositionAndRotationEuler(_, t, r, i, n[o], m), h.localPosition = m;
                                break;
                            case 2:
                                var f = h.localRotation;
                                this._applyRotation(_, t, r, i, n[o], f), h.localRotation = f;
                                break;
                            case 3:
                                var T = h.localScale;
                                this._applyScale(_, t, r, i, n[o], T), h.localScale = T;
                                break;
                            case 4:
                                var E = h.localRotationEuler;
                                this._applyPositionAndRotationEuler(_, t, r, i, n[o], E), h.localRotationEuler = E
                        }
                        _.updateMark = this._updateMark
                    }
                }
            }
        }
        _setCrossClipDatasToNode(e, t, r, i, n) {
            for (var a = e._crossNodesOwners, s = e._crossNodesOwnersCount, o = e.blendingMode !== Q.BLENDINGMODE_OVERRIDE, l = e.defaultWeight, _ = r._realtimeDatas, h = e._destCrossClipNodeIndices, c = r._nodeOwners, d = t._realtimeDatas, u = e._srcCrossClipNodeIndices, m = t._nodeOwners, f = 0; f &lt; s; f++) {
                var T = a[f];
                if (T) {
                    var E = u[f],
                        p = h[f],
                        g = -1 !== E ? d[E] : c[p].defaultValue,
                        S = -1 !== p ? _[p] : m[E].defaultValue;
                    this._applyCrossData(T, o, l, n, g, S, i)
                }
            }
        }
        _setFixedCrossClipDatasToNode(e, t, r, i) {
            for (var n = e._crossNodesOwners, a = e._crossNodesOwnersCount, s = e.blendingMode !== Q.BLENDINGMODE_OVERRIDE, o = e.defaultWeight, l = t._realtimeDatas, _ = e._destCrossClipNodeIndices, h = 0; h &lt; a; h++) {
                var c = n[h];
                if (c) {
                    var d = _[h],
                        u = c.crossFixedValue,
                        m = -1 !== d ? l[d] : c.defaultValue;
                    this._applyCrossData(c, s, o, i, u, m, r)
                }
            }
        }
        _revertDefaultKeyframeNodes(e) {
            for (var t = e._nodeOwners, r = 0, i = t.length; r &lt; i; r++) {
                var n = t[r];
                if (n) {
                    var a = n.propertyOwner;
                    if (a) switch (n.type) {
                        case 0:
                            for (var s = n.property, o = s.length - 1, l = 0; l &lt; o &amp;&amp; (a = a[s[l]]); l++);
                            a[s[o]] = n.defaultValue;
                            break;
                        case 1:
                            var _ = a.localPosition,
                                h = n.defaultValue;
                            _.x = h.x, _.y = h.y, _.z = h.z, a.localPosition = _;
                            break;
                        case 2:
                            var c = a.localRotation,
                                d = n.defaultValue;
                            c.x = d.x, c.y = d.y, c.z = d.z, c.w = d.w, a.localRotation = c;
                            break;
                        case 3:
                            var u = a.localScale;
                            h = n.defaultValue, u.x = h.x, u.y = h.y, u.z = h.z, a.localScale = u;
                            break;
                        case 4:
                            var m = a.localRotationEuler;
                            h = n.defaultValue, m.x = h.x, m.y = h.y, m.z = h.z, a.localRotationEuler = m;
                            break;
                        default:
                            throw "Animator:unknown type."
                    }
                }
            }
        }
        _onAdded() {
            var e = this.owner._parent;
            this.owner._setHierarchyAnimator(this, e ? e._hierarchyAnimator : null), this.owner._changeAnimatorToLinkSprite3DNoAvatar(this, !0, [])
        }
        _onDestroy() {
            for (var e = 0, t = this._controllerLayers.length; e &lt; t; e++) this._controllerLayers[e]._removeReference();
            var r = this.owner._parent;
            this.owner._clearHierarchyAnimator(this, r ? r._hierarchyAnimator : null)
        }
        _onEnable() {
            this.owner._scene._animatorPool.add(this);
            for (var e = 0, t = this._controllerLayers.length; e &lt; t; e++) {
                if (this._controllerLayers[e].playOnWake) this.getDefaultState(e) &amp;&amp; this.play(null, e, 0)
            }
        }
        _onDisable() {
            this._eventDispatcher.offAll(t.Event.COMPLETE), this.owner._scene._animatorPool.remove(this)
        }
        _handleSpriteOwnersBySprite(e, t, r) {
            for (var i = 0, n = this._controllerLayers.length; i &lt; n; i++)
                for (var a = this._controllerLayers[i]._states, s = 0, o = a.length; s &lt; o; s++) {
                    var l = a[s],
                        _ = l._clip,
                        h = t.join("/"),
                        c = _._nodesMap[h];
                    if (c)
                        for (var d = l._nodeOwners, u = 0, m = c.length; u &lt; m; u++) e ? this._addKeyframeNodeOwner(d, c[u], r) : this._removeKeyframeNodeOwner(d, c[u])
                }
        }
        _parse(e) {
            var r = e.avatar;
            if (r) {
                this.avatar = t.Loader.getRes(r.path);
                var i = r.linkSprites;
                this._linkSprites = i, this._linkToSprites(i)
            }
            e.clipPaths;
            for (var n = e.playOnWake, a = e.layers, s = 0; s &lt; a.length; s++) {
                var o = a[s],
                    l = new Q(o.name);
                l.defaultWeight = 0 === s ? 1 : o.weight;
                var _ = o.blendingMode;
                _ &amp;&amp; (l.blendingMode = _), this.addControllerLayer(l);
                for (var h = o.states, c = 0, d = h.length; c &lt; d; c++) {
                    var u = h[c],
                        m = u.clipPath;
                    if (m) {
                        var f, T = u.name;
                        if (f = t.Loader.getRes(m)) {
                            var E = new ee;
                            E.name = T, E.clip = f, l.addState(E), 0 === c &amp;&amp; (this.getControllerLayer(s).defaultState = E)
                        }
                    }
                }
                void 0 !== n &amp;&amp; (l.playOnWake = n)
            }
            var p = e.cullingMode;
            void 0 !== p &amp;&amp; (this.cullingMode = p)
        }
        _update() {
            var e = this.owner._scene.timer,
                r = e._delta / 1e3;
            if (0 !== this._speed &amp;&amp; 0 !== r) {
                var i;
                if (this.cullingMode === re.CULLINGMODE_CULLCOMPLETELY) {
                    i = !1;
                    for (var n = 0, a = this._renderableSprites.length; n &lt; a; n++)
                        if (this._renderableSprites[n]._render.isRender) {
                            i = !0;
                            break
                        }
                } else i = !0;
                this._updateMark++;
                var s = e.scale;
                for (n = 0, a = this._controllerLayers.length; n &lt; a; n++) {
                    var o = this._controllerLayers[n],
                        l = o._playStateInfo,
                        _ = o._crossPlayStateInfo;
                    switch (m = o.blendingMode !== Q.BLENDINGMODE_OVERRIDE, o._playType) {
                        case 0:
                            var h = l._currentState,
                                c = h._clip,
                                d = this._speed * h.speed,
                                u = l._finish;
                            if (u || this._updatePlayer(h, l, r * d, c.islooping), i) {
                                var m = o.blendingMode !== Q.BLENDINGMODE_OVERRIDE;
                                this._updateClipDatas(h, m, l, s * d), this._setClipDatasToNode(h, m, o.defaultWeight, 0 === n), u || this._updateEventScript(h, l)
                            }
                            break;
                        case 1:
                            c = (h = l._currentState)._clip;
                            var f = o._crossPlayState,
                                T = f._clip,
                                E = o._crossDuration,
                                p = _._startPlayTime,
                                g = T._duration - p,
                                S = E &gt; g ? g / E : 1,
                                R = this._speed * f.speed;
                            this._updatePlayer(f, _, r * S * R, T.islooping);
                            var v = (_._elapsedTime - p) / S / E;
                            v &gt;= 1 ? i &amp;&amp; (this._updateClipDatas(f, m, _, s * R), this._setClipDatasToNode(f, m, o.defaultWeight, 0 === n), o._playType = 0, l._currentState = f, _._cloneTo(l)) : (l._finish || (d = this._speed * h.speed, this._updatePlayer(h, l, r * d, c.islooping), i &amp;&amp; this._updateClipDatas(h, m, l, s * d)), i &amp;&amp; (this._updateClipDatas(f, m, _, s * S * R), this._setCrossClipDatasToNode(o, h, f, v, 0 === n))), i &amp;&amp; (this._updateEventScript(h, l), this._updateEventScript(f, _));
                            break;
                        case 2:
                            T = (f = o._crossPlayState)._clip, E = o._crossDuration, p = _._startPlayTime, S = E &gt; (g = T._duration - p) ? g / E : 1, R = this._speed * f.speed, this._updatePlayer(f, _, r * S * R, T.islooping), i &amp;&amp; ((v = (_._elapsedTime - p) / S / E) &gt;= 1 ? (this._updateClipDatas(f, m, _, s * R), this._setClipDatasToNode(f, m, 1, 0 === n), o._playType = 0, l._currentState = f, _._cloneTo(l)) : (this._updateClipDatas(f, m, _, s * S * R), this._setFixedCrossClipDatasToNode(o, f, v, 0 === n)), this._updateEventScript(f, _))
                    }
                }
                i &amp;&amp; this._avatar &amp;&amp; (t.Render.supportWebGLPlusAnimation &amp;&amp; this._updateAnimationNodeWorldMatix(this._animationNodeLocalPositions, this._animationNodeLocalRotations, this._animationNodeLocalScales, this._animationNodeWorldMatrixs, this._animationNodeParentIndices), this._updateAvatarNodesToSprite())
            }
        }
        _cloneTo(e) {
            var t = e;
            t.avatar = this.avatar, t.cullingMode = this.cullingMode;
            for (var r = 0, i = this._controllerLayers.length; r &lt; i; r++) {
                var n = this._controllerLayers[r];
                t.addControllerLayer(n.clone());
                for (var a = n._states, s = 0, o = a.length; s &lt; o; s++) {
                    var l = a[s].clone(),
                        _ = t.getControllerLayer(r);
                    _.addState(l), 0 == s &amp;&amp; (_.defaultState = l)
                }
            }
            t._linkSprites = this._linkSprites, t._linkToSprites(this._linkSprites)
        }
        getDefaultState(e = 0) {
            return this._controllerLayers[e].defaultState
        }
        addState(e, t = 0) {
            this._controllerLayers[t].addState(e), console.warn("Animator:this function is discard,please use animatorControllerLayer.addState() instead.")
        }
        removeState(e, t = 0) {
            this._controllerLayers[t].removeState(e), console.warn("Animator:this function is discard,please use animatorControllerLayer.removeState() instead.")
        }
        addControllerLayer(e) {
            this._controllerLayers.push(e), e._animator = this, e._addReference();
            for (var t = e._states, r = 0, i = t.length; r &lt; i; r++) this._getOwnersByClip(t[r])
        }
        getControllerLayer(e = 0) {
            return this._controllerLayers[e]
        }
        play(e = null, t = 0, r = Number.NEGATIVE_INFINITY) {
            var i = this._controllerLayers[t];
            if (i) {
                var n = i.defaultState;
                if (!e &amp;&amp; !n) throw new Error("Animator:must have default clip value,please set clip property.");
                var a = i._playStateInfo,
                    s = a._currentState,
                    o = e ? i._statesMap[e] : n,
                    l = o._clip._duration;
                s !== o ? (r !== Number.NEGATIVE_INFINITY ? a._resetPlayState(l * r) : a._resetPlayState(0), null !== s &amp;&amp; s !== o &amp;&amp; this._revertDefaultKeyframeNodes(s), i._playType = 0, a._currentState = o) : r !== Number.NEGATIVE_INFINITY &amp;&amp; (a._resetPlayState(l * r), i._playType = 0);
                var _ = o._scripts;
                if (_)
                    for (var h = 0, c = _.length; h &lt; c; h++) _[h].onStateEnter()
            } else console.warn("Invalid layerIndex " + t + ".")
        }
        crossFade(e, t, r = 0, i = Number.NEGATIVE_INFINITY) {
            var n = this._controllerLayers[r];
            if (n) {
                var a = n._statesMap[e];
                if (a) {
                    var s = n._playType;
                    if (-1 === s) return void this.play(e, r, i);
                    var o = n._crossPlayStateInfo,
                        l = n._crossNodesOwners,
                        _ = n._crossNodesOwnersIndicesMap,
                        h = n._playStateInfo._currentState,
                        c = a._nodeOwners,
                        d = n._destCrossClipNodeIndices,
                        u = a._clip,
                        m = u._nodes,
                        f = u._nodesDic;
                    switch (s) {
                        case 0:
                            var T = h._nodeOwners,
                                E = n._srcCrossClipNodeIndices,
                                p = h._clip,
                                g = p._nodes,
                                S = p._nodesDic;
                            n._playType = 1;
                            for (var R = ++n._crossMark, v = n._crossNodesOwnersCount = 0, A = 0, I = g.count; A &lt; I; A++) {
                                var x = g.getNodeByIndex(A),
                                    L = x._indexInList,
                                    D = T[L];
                                if (D) {
                                    var C = x.fullPath;
                                    E[v] = L;
                                    var y = f[C];
                                    d[v] = y ? y._indexInList : -1, _[C] = R, l[v] = D, v++
                                }
                            }
                            for (A = 0, I = m.count; A &lt; I; A++) {
                                var M = (y = m.getNodeByIndex(A))._indexInList,
                                    O = c[M];
                                if (O) {
                                    var N = y.fullPath;
                                    S[N] || (E[v] = -1, d[v] = M, _[N] = R, l[v] = O, v++)
                                }
                            }
                            break;
                        case 1:
                        case 2:
                            for (n._playType = 2, A = 0, I = l.length; A &lt; I; A++) {
                                var b = l[A];
                                b.saveCrossFixedValue(), y = f[b.fullPath], d[A] = y ? y._indexInList : -1
                            }
                            for (v = n._crossNodesOwnersCount, R = n._crossMark, A = 0, I = m.count; A &lt; I; A++)(O = c[M = (y = m.getNodeByIndex(A))._indexInList]) &amp;&amp; _[N = y.fullPath] !== R &amp;&amp; (d[v] = M, _[N] = R, b = c[M], l[v] = b, b.saveCrossFixedValue(), v++)
                    }
                    n._crossNodesOwnersCount = v, n._crossPlayState = a, n._crossDuration = h._clip._duration * t, i !== Number.NEGATIVE_INFINITY ? o._resetPlayState(u._duration * i) : o._resetPlayState(0);
                    var P = a._scripts;
                    if (P)
                        for (A = 0, I = P.length; A &lt; I; A++) P[A].onStateEnter()
                } else console.warn("Invalid name " + r + ".")
            } else console.warn("Invalid layerIndex " + r + ".")
        }
        getCurrentAnimatorPlayState(e = 0) {
            return this._controllerLayers[e]._playStateInfo
        }
        get avatar() {
            return this._avatar
        }
        set avatar(e) {
            if (this._avatar !== e)
                if (this._avatar = e, e) this._getAvatarOwnersAndInitDatasAsync(), this.owner._changeHierarchyAnimatorAvatar(this, e);
                else {
                    var t = this.owner._parent;
                    this.owner._changeHierarchyAnimatorAvatar(this, t ? t._hierarchyAnimator._avatar : null)
                }
        }
        _isLinkSpriteToAnimationNodeData(e, t, r) {
            var i = this._linkAvatarSpritesData[t];
            if (r) i || (this._linkAvatarSpritesData[t] = i = []), i.push(e);
            else {
                var n = i.indexOf(e);
                i.splice(n, 1)
            }
        }
        _getAvatarOwnersAndInitDatasAsync() {
            for (var e = 0, t = this._controllerLayers.length; e &lt; t; e++)
                for (var r = this._controllerLayers[e]._states, i = 0, n = r.length; i &lt; n; i++) this._getOwnersByClip(r[i]);
            for (var a in this._avatar._cloneDatasToAnimator(this), this._linkAvatarSpritesData) {
                var s = this._linkAvatarSpritesData[a];
                if (s)
                    for (var o = 0, l = s.length; o &lt; l; o++) this._isLinkSpriteToAnimationNode(s[o], a, !0)
            }
        }
        _isLinkSpriteToAnimationNode(e, t, r) {
            if (this._avatar) {
                var i = this._avatarNodeMap[t];
                if (i)
                    if (r) {
                        e._transform._dummy = i.transform, this._linkAvatarSprites.push(e);
                        var n = i.transform,
                            a = e.transform;
                        if (!a.owner.isStatic &amp;&amp; n) {
                            var s = a.worldMatrix,
                                o = this.owner._transform._parent;
                            if (o) N.matrix4x4MultiplyMFM(o.worldMatrix, n.getWorldMatrix(), s);
                            else
                                for (var l = s.elements, _ = n.getWorldMatrix(), h = 0; h &lt; 16; h++) l[h] = _[h];
                            a.worldMatrix = s
                        }
                    } else e._transform._dummy = null, this._linkAvatarSprites.splice(this._linkAvatarSprites.indexOf(e), 1)
            }
        }
        _updateAvatarNodesToSprite() {
            for (var e = 0, t = this._linkAvatarSprites.length; e &lt; t; e++) {
                var r = this._linkAvatarSprites[e],
                    i = r.transform._dummy,
                    n = r.transform;
                if (!n.owner.isStatic &amp;&amp; i) {
                    var a = n.worldMatrix,
                        s = this.owner._transform;
                    N.matrix4x4MultiplyMFM(s.worldMatrix, i.getWorldMatrix(), a), n.worldMatrix = a
                }
            }
        }
        linkSprite3DToAvatarNode(e, t) {
            return this._isLinkSpriteToAnimationNodeData(t, e, !0), this._isLinkSpriteToAnimationNode(t, e, !0), !0
        }
        unLinkSprite3DToAvatarNode(e) {
            var t = e.transform._dummy;
            if (t) {
                var r = t._owner.name;
                return this._isLinkSpriteToAnimationNodeData(e, r, !1), this._isLinkSpriteToAnimationNode(e, r, !1), !0
            }
            return !1
        }
        _updateAnimationNodeWorldMatix(e, r, i, n, a) {
            t.LayaGL.instance.updateAnimationNodeWorldMatix(e, r, i, a, n)
        }
    }
    re._tempVector30 = new a, re._tempVector31 = new a, re._tempQuaternion0 = new h, re._tempQuaternion1 = new h, re.CULLINGMODE_ALWAYSANIMATE = 0, re.CULLINGMODE_CULLCOMPLETELY = 2;
    class ie {
        constructor() {
            this.source = null, this.destination = null, this.camera = null, this.compositeShaderData = null, this.command = null, this.deferredReleaseTextures = []
        }
    }
    class ne {
        constructor() {
            this.invertY = !1
        }
    }
    ne._instance = new ne;
    class ae extends t.BaseTexture {
        constructor(e, r, i = t.RenderTextureFormat.R8G8B8, n = t.RenderTextureDepthFormat.DEPTH_16) {
            super(i, !1), this._inPool = !1, this._isCameraTarget = !1, this._glTextureType = t.LayaGL.instance.TEXTURE_2D, this._width = e, this._height = r, this._depthStencilFormat = n, this._mipmapCount = 1, this._create(e, r)
        }
        static get currentActive() {
            return ae._currentActive
        }
        static createFromPool(e, r, i = t.RenderTextureFormat.R8G8B8, n = t.RenderTextureDepthFormat.DEPTH_16) {
            for (var a, s = 0, o = ae._pool.length; s &lt; o; s++)
                if ((a = ae._pool[s])._width == e &amp;&amp; a._height == r &amp;&amp; a._format == i &amp;&amp; a._depthStencilFormat == n) {
                    a._inPool = !1;
                    var l = ae._pool[o - 1];
                    return ae._pool[s] = l, ae._pool.length -= 1, a
                }
            return (a = new ae(e, r, i, n)).lock = !0, a
        }
        static recoverToPool(e) {
            e._inPool || (ae._pool.push(e), e._inPool = !0)
        }
        get depthStencilFormat() {
            return this._depthStencilFormat
        }
        get defaulteTexture() {
            return t.Texture2D.grayTexture
        }
        _create(e, r) {
            var i = t.LayaGL.instance,
                n = i,
                a = this._glTextureType,
                s = t.LayaGL.layaGPUInstance,
                o = s._isWebGL2,
                l = this._format;
            if (this._frameBuffer = i.createFramebuffer(), i.bindFramebuffer(i.FRAMEBUFFER, this._frameBuffer), l !== t.RenderTextureFormat.Depth &amp;&amp; l !== t.RenderTextureFormat.ShadowMap) {
                switch (t.WebGLContext.bindTexture(i, a, this._glTexture), l) {
                    case t.RenderTextureFormat.R8G8B8:
                        o ? n.texStorage2D(a, this._mipmapCount, n.RGB8, e, r) : i.texImage2D(a, 0, i.RGB, e, r, 0, i.RGB, i.UNSIGNED_BYTE, null);
                        break;
                    case t.RenderTextureFormat.R8G8B8A8:
                        o ? n.texStorage2D(a, this._mipmapCount, n.RGBA8, e, r) : i.texImage2D(a, 0, i.RGBA, e, r, 0, i.RGBA, i.UNSIGNED_BYTE, null);
                        break;
                    case t.RenderTextureFormat.Alpha8:
                        o ? n.texStorage2D(a, 0, n.R8, e, r) : i.texImage2D(a, 0, i.ALPHA, e, r, 0, i.ALPHA, i.UNSIGNED_BYTE, null);
                        break;
                    case t.RenderTextureFormat.R16G16B16A16:
                        o ? n.texStorage2D(a, this._mipmapCount, n.RGBA16F, e, r) : i.texImage2D(a, 0, i.RGBA, e, r, 0, i.RGBA, s._oesTextureHalfFloat.HALF_FLOAT_OES, null)
                }
                i.framebufferTexture2D(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, this._glTexture, 0)
            }
            if (l == t.RenderTextureFormat.Depth || l == t.RenderTextureFormat.ShadowMap) {
                switch (t.WebGLContext.bindTexture(i, a, this._glTexture), this._depthStencilFormat) {
                    case t.RenderTextureDepthFormat.DEPTH_16:
                        o ? n.texStorage2D(a, this._mipmapCount, n.DEPTH_COMPONENT16, e, r) : i.texImage2D(a, 0, i.DEPTH_COMPONENT, e, r, 0, i.DEPTH_COMPONENT, i.UNSIGNED_SHORT, null), i.framebufferTexture2D(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.TEXTURE_2D, this._glTexture, 0);
                        break;
                    case t.RenderTextureDepthFormat.DEPTHSTENCIL_24_8:
                        o ? n.texStorage2D(a, this._mipmapCount, n.DEPTH24_STENCIL8, e, r) : i.texImage2D(a, 0, i.DEPTH_STENCIL, e, r, 0, i.DEPTH_STENCIL, s._webgl_depth_texture.UNSIGNED_INT_24_8_WEBGL, null), i.framebufferTexture2D(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.TEXTURE_2D, this._glTexture, 0);
                        break;
                    default:
                        throw "RenderTexture: depth format RenderTexture must use depthFormat with DEPTH_16 and DEPTHSTENCIL_16_8."
                }
                o &amp;&amp; l == t.RenderTextureFormat.ShadowMap &amp;&amp; n.texParameteri(a, n.TEXTURE_COMPARE_MODE, n.COMPARE_REF_TO_TEXTURE)
            } else if (this._depthStencilFormat !== t.RenderTextureDepthFormat.DEPTHSTENCIL_NONE) {
                switch (this._depthStencilBuffer = i.createRenderbuffer(), i.bindRenderbuffer(i.RENDERBUFFER, this._depthStencilBuffer), this._depthStencilFormat) {
                    case t.RenderTextureDepthFormat.DEPTH_16:
                        i.renderbufferStorage(i.RENDERBUFFER, i.DEPTH_COMPONENT16, e, r), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.RENDERBUFFER, this._depthStencilBuffer);
                        break;
                    case t.RenderTextureDepthFormat.STENCIL_8:
                        i.renderbufferStorage(i.RENDERBUFFER, i.STENCIL_INDEX8, e, r), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.STENCIL_ATTACHMENT, i.RENDERBUFFER, this._depthStencilBuffer);
                        break;
                    case t.RenderTextureDepthFormat.DEPTHSTENCIL_24_8:
                        i.renderbufferStorage(i.RENDERBUFFER, i.DEPTH_STENCIL, e, r), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.RENDERBUFFER, this._depthStencilBuffer);
                        break;
                    default:
                        throw "RenderTexture: unkonw depth format."
                }
                i.bindRenderbuffer(i.RENDERBUFFER, null)
            }
            i.bindFramebuffer(i.FRAMEBUFFER, null), this._setWarpMode(i.TEXTURE_WRAP_S, this._wrapModeU), this._setWarpMode(i.TEXTURE_WRAP_T, this._wrapModeV), this._setFilterMode(this._filterMode), this._setAnisotropy(this._anisoLevel), this._readyed = !0, this._activeResource(), this._setGPUMemory(e * r * 4)
        }
        _start() {
            var e = t.LayaGL.instance;
            e.bindFramebuffer(e.FRAMEBUFFER, this._frameBuffer), ae._currentActive = this, this._isCameraTarget &amp;&amp; (ne._instance.invertY = !0), this._readyed = !1
        }
        _end() {
            var e = t.LayaGL.instance;
            e.bindFramebuffer(e.FRAMEBUFFER, null), ae._currentActive = null, this._isCameraTarget &amp;&amp; (ne._instance.invertY = !1), this._readyed = !0
        }
        getData(e, r, i, n, a) {
            if (t.Render.isConchApp &amp;&amp; 2 == window.conchConfig.threadMode) throw "native 2 thread mode use getDataAsync";
            var s = t.LayaGL.instance;
            return s.bindFramebuffer(s.FRAMEBUFFER, this._frameBuffer), s.checkFramebufferStatus(s.FRAMEBUFFER) === s.FRAMEBUFFER_COMPLETE ? (s.readPixels(e, r, i, n, s.RGBA, s.UNSIGNED_BYTE, a), s.bindFramebuffer(s.FRAMEBUFFER, null), a) : (s.bindFramebuffer(s.FRAMEBUFFER, null), null)
        }
        _disposeResource() {
            if (this._frameBuffer) {
                var e = t.LayaGL.instance;
                e.deleteTexture(this._glTexture), e.deleteFramebuffer(this._frameBuffer), e.deleteRenderbuffer(this._depthStencilBuffer), this._glTexture = null, this._frameBuffer = null, this._depthStencilBuffer = null, this._setGPUMemory(0)
            }
        }
        getDataAsync(e, r, i, n, a) {
            var s = t.LayaGL.instance;
            s.bindFramebuffer(s.FRAMEBUFFER, this._frameBuffer), s.readPixelsAsync(e, r, i, n, s.RGBA, s.UNSIGNED_BYTE, function(e) {
                a(new Uint8Array(e))
            }), s.bindFramebuffer(s.FRAMEBUFFER, null)
        }
    }
    ae._pool = [];
    class se {
        constructor() {
            this._mask = [], this._length = 0
        }
        _intersectionDefineDatas(e) {
            for (var t = e._mask, r = this._mask, i = this._length - 1; i &gt;= 0; i--) {
                var n = r[i] &amp; t[i];
                0 == n &amp;&amp; i == this._length - 1 ? this._length-- : r[i] = n
            }
        }
        add(e) {
            var t = e._index,
                r = t + 1,
                i = this._mask,
                n = this._length;
            if (n &lt; r) {
                for (i.length &lt; r &amp;&amp; (i.length = r); n &lt; t; n++) i[n] = 0;
                i[t] = e._value, this._length = r
            } else r &gt; this._length ? (i[t] = e._value, this._length = r) : i[t] |= e._value
        }
        remove(e) {
            var t = e._index,
                r = this._mask,
                i = this._length - 1;
            if (!(t &gt; i)) {
                var n = r[t] &amp; ~e._value;
                t == i &amp;&amp; 0 === n ? this._length-- : r[t] = n
            }
        }
        addDefineDatas(e) {
            var t = e._mask,
                r = e._length,
                i = this._mask,
                n = i.length;
            if (n &lt; r) {
                i.length = r;
                for (var a = 0; a &lt; n; a++) i[a] |= t[a];
                for (; n &lt; r; n++) i[n] = t[n];
                this._length = r
            } else {
                for (a = 0; a &lt; r; a++) i[a] |= t[a];
                this._length = Math.max(this._length, r)
            }
        }
        removeDefineDatas(e) {
            for (var t = e._mask, r = this._mask, i = this._length - 1, n = e._length - 1; n &gt;= 0; n--)
                if (!(n &gt; i)) {
                    var a = r[n] &amp; ~t[n];
                    n == i &amp;&amp; 0 === a ? (i--, this._length--) : r[n] = a
                }
        }
        has(e) {
            var t = e._index;
            return !(t &gt;= this._length) &amp;&amp; 0 != (this._mask[t] &amp; e._value)
        }
        clear() {
            this._length = 0
        }
        cloneTo(e) {
            var t = e,
                r = t._mask,
                i = this._mask,
                n = this._length;
            r.length = n;
            for (var a = 0; a &lt; n; a++) r[a] = i[a];
            t._length = n
        }
        clone() {
            var e = new se;
            return this.cloneTo(e), e
        }
    }
    class oe {
        constructor(e, t) {
            this._index = e, this._value = t
        }
    }
    class le {
        constructor(e, t, r, i) {
            this._subShaderIndex = 0, this._passIndex = 0, this.setValue(e, t, r, i)
        }
        get shader() {
            return this._shader
        }
        get subShaderIndex() {
            return this._subShaderIndex
        }
        get passIndex() {
            return this._passIndex
        }
        get defineNames() {
            return this._defineNames
        }
        setValue(e, t, r, i) {
            if (!e) throw "ShaderVariantInfo:Shader can't be null.";
            var n = e.getSubShaderAt(t);
            if (!n) throw `ShaderVariantInfo:Shader don't have subShaderIndex of ${t}.`;
            var a = n._passes[r];
            if (!a) throw `ShaderVariantInfo:Shader don't have passIndex of ${r}.`;
            for (var s = a._validDefine, o = 0, l = i.length; o &lt; l; o++) {
                var h = i[o];
                if (!s.has(_.Shader3D.getDefineByName(h))) throw `ShaderVariantInfo:Invalid defineName ${h} in ${e._name} subShaderIndex of ${t} passIndex of ${r}.`
            }
            this._shader = e, this._subShaderIndex = t, this._passIndex = r, this._defineNames = i
        }
        equal(e) {
            if (this._shader !== e._shader || this._subShaderIndex !== e._subShaderIndex || this._passIndex !== e._passIndex) return !1;
            var t = this._defineNames,
                r = e._defineNames;
            if (t.length !== r.length) return !1;
            for (var i = 0, n = this._defineNames.length; i &lt; n; i++)
                if (t[i] !== r[i]) return !1;
            return !0
        }
        clone() {
            return new le(this._shader, this._subShaderIndex, this._passIndex, this._defineNames.slice())
        }
    }
    class _e {
        constructor() {
            this._allCompiled = !1, this._variants = []
        }
        get allCompiled() {
            return this._allCompiled
        }
        get variantCount() {
            return this._variants.length
        }
        add(e) {
            for (var t = 0, r = this._variants.length; t &lt; r; t++)
                if (this._variants[t].equal(e)) return !1;
            return this._variants.push(e.clone()), this._allCompiled = !1, !0
        }
        remove(e) {
            for (var t = 0, r = this._variants.length; t &lt; r; t++)
                if (this._variants[t].equal(e)) return this._variants.splice(t, 1), !0;
            return !1
        }
        contatins(e) {
            for (var t = 0, r = this._variants.length; t &lt; r; t++)
                if (this._variants[t].equal(e)) return !0;
            return !1
        }
        getByIndex(e) {
            return this._variants[e]
        }
        clear() {
            this._variants.length = 0
        }
        compile() {
            if (!this._allCompiled) {
                for (var e = this._variants, t = 0, r = e.length; t &lt; r; t++) {
                    var i = e[t];
                    _.Shader3D.compileShaderByDefineNames(i._shader._name, i._subShaderIndex, i._passIndex, i._defineNames)
                }
                this._allCompiled = !0
            }
        }
    }
    class he {
        constructor(e, t, r, i) {
            this._attributeMap = null, this._uniformMap = null, this._enableInstancing = !1, this._subShaders = [], this._name = e, this._attributeMap = t, this._uniformMap = r, this._enableInstancing = i
        }
        static _getNamesByDefineData(e, t) {
            var r = he._maskMap,
                i = e._mask;
            t.length = 0;
            for (var n = 0, a = e._length; n &lt; a; n++)
                for (var s = r[n], o = i[n], l = 0; l &lt; 32; l++) {
                    var _ = 1 &lt;&lt; l;
                    if (o &gt; 0 &amp;&amp; _ &gt; o) break;
                    o &amp; _ &amp;&amp; t.push(s[_])
                }
        }
        static getDefineByName(e) {
            var t = he._defineMap[e];
            if (!t) {
                var r = he._maskMap,
                    i = he._defineCounter,
                    n = Math.floor(i / 32),
                    a = 1 &lt;&lt; i % 32;
                t = new oe(n, a), he._defineMap[e] = t, n == r.length &amp;&amp; (r.length++, r[n] = {}), r[n][a] = e, he._defineCounter++
            }
            return t
        }
        static propertyNameToID(e) {
            if (null != he._propertyNameMap[e]) return he._propertyNameMap[e];
            var t = he._propertyNameCounter++;
            return he._propertyNameMap[e] = t, t
        }
        static addInclude(e, r) {
            r = r.replace(t.ShaderCompile._clearCR, ""), t.ShaderCompile.addInclude(e, r)
        }
        static compileShaderByDefineNames(e, t, r, i) {
            var n = he.find(e);
            if (n) {
                var a = n.getSubShaderAt(t);
                if (a) {
                    var s = a._passes[r];
                    if (s) {
                        var o = he._compileDefineDatas;
                        o.clear();
                        for (var l = 0, _ = i.length; l &lt; _; l++) o.add(he.getDefineByName(i[l]));
                        s.withCompile(o)
                    } else console.warn("Shader3D: unknown passIndex.")
                } else console.warn("Shader3D: unknown subShaderIndex.")
            } else console.warn("Shader3D: unknown shader name.")
        }
        static add(e, t = null, r = null, i = !1) {
            return he._preCompileShader[e] = new he(e, t, r, i)
        }
        static find(e) {
            return he._preCompileShader[e]
        }
        get name() {
            return this._name
        }
        addSubShader(e) {
            this._subShaders.push(e), e._owner = this
        }
        getSubShaderAt(e) {
            return this._subShaders[e]
        }
        static compileShader(e, t, r, ...i) {
            var n = he.find(e);
            if (n) {
                var a = n.getSubShaderAt(t);
                if (a) {
                    var s = a._passes[r];
                    if (s) {
                        var o = he._compileDefineDatas,
                            l = o._mask;
                        l.length = 0;
                        for (var _ = 0, h = i.length; _ &lt; h; _++) l.push(i[_]);
                        o._length = i.length, s.withCompile(o)
                    } else console.warn("Shader3D: unknown passIndex.")
                } else console.warn("Shader3D: unknown subShaderIndex.")
            } else console.warn("Shader3D: unknown shader name.")
        }
    }
    he._compileDefineDatas = new se, he.RENDER_STATE_CULL = 0, he.RENDER_STATE_BLEND = 1, he.RENDER_STATE_BLEND_SRC = 2, he.RENDER_STATE_BLEND_DST = 3, he.RENDER_STATE_BLEND_SRC_RGB = 4, he.RENDER_STATE_BLEND_DST_RGB = 5, he.RENDER_STATE_BLEND_SRC_ALPHA = 6, he.RENDER_STATE_BLEND_DST_ALPHA = 7, he.RENDER_STATE_BLEND_CONST_COLOR = 8, he.RENDER_STATE_BLEND_EQUATION = 9, he.RENDER_STATE_BLEND_EQUATION_RGB = 10, he.RENDER_STATE_BLEND_EQUATION_ALPHA = 11, he.RENDER_STATE_DEPTH_TEST = 12, he.RENDER_STATE_DEPTH_WRITE = 13, he.PERIOD_CUSTOM = 0, he.PERIOD_MATERIAL = 1, he.PERIOD_SPRITE = 2, he.PERIOD_CAMERA = 3, he.PERIOD_SCENE = 4, he._propertyNameCounter = 0, he._propertyNameMap = {}, he._defineCounter = 0, he._defineMap = {}, he._preCompileShader = {}, he._maskMap = [], he.debugMode = !1, he.debugShaderVariantCollection = new _e;
    class ce {
        constructor(e = null) {
            this._ownerResource = null, this._data = null, this._defineDatas = new se, this._runtimeCopyValues = [], this._ownerResource = e, this._initData()
        }
        _initData() {
            this._data = new Object
        }
        getData() {
            return this._data
        }
        addDefine(e) {
            this._defineDatas.add(e)
        }
        removeDefine(e) {
            this._defineDatas.remove(e)
        }
        hasDefine(e) {
            return this._defineDatas.has(e)
        }
        clearDefine() {
            this._defineDatas.clear()
        }
        getBool(e) {
            return this._data[e]
        }
        setBool(e, t) {
            this._data[e] = t
        }
        getInt(e) {
            return this._data[e]
        }
        setInt(e, t) {
            this._data[e] = t
        }
        getNumber(e) {
            return this._data[e]
        }
        setNumber(e, t) {
            this._data[e] = t
        }
        getVector2(e) {
            return this._data[e]
        }
        setVector2(e, t) {
            this._data[e] = t
        }
        getVector3(e) {
            return this._data[e]
        }
        setVector3(e, t) {
            this._data[e] = t
        }
        getVector(e) {
            return this._data[e]
        }
        setVector(e, t) {
            this._data[e] = t
        }
        getQuaternion(e) {
            return this._data[e]
        }
        setQuaternion(e, t) {
            this._data[e] = t
        }
        getMatrix4x4(e) {
            return this._data[e]
        }
        setMatrix4x4(e, t) {
            this._data[e] = t
        }
        getBuffer(e) {
            return this._data[e]
        }
        setBuffer(e, t) {
            this._data[e] = t
        }
        setTexture(e, t) {
            var r = this._data[e];
            this._data[e] = t, this._ownerResource &amp;&amp; this._ownerResource.referenceCount &gt; 0 &amp;&amp; (r &amp;&amp; r._removeReference(), t &amp;&amp; t._addReference())
        }
        getTexture(e) {
            return this._data[e]
        }
        setAttribute(e, t) {
            this._data[e] = t
        }
        getAttribute(e) {
            return this._data[e]
        }
        getLength() {
            return this._data.length
        }
        setLength(e) {
            this._data.length = e
        }
        cloneTo(e) {
            var r = e,
                s = r._data;
            for (var o in this._data) {
                var l = this._data[o];
                if (null != l)
                    if ("number" == typeof l) s[o] = l;
                    else if ("number" == typeof l) s[o] = l;
                else if ("boolean" == typeof l) s[o] = l;
                else if (l instanceof i) {
                    var _ = s[o] || (s[o] = new i);
                    l.cloneTo(_), s[o] = _
                } else if (l instanceof a) {
                    var h = s[o] || (s[o] = new a);
                    l.cloneTo(h), s[o] = h
                } else if (l instanceof n) {
                    var d = s[o] || (s[o] = new n);
                    l.cloneTo(d), s[o] = d
                } else if (l instanceof c) {
                    var u = s[o] || (s[o] = new c);
                    l.cloneTo(u), s[o] = u
                } else l instanceof t.BaseTexture &amp;&amp; (s[o] = l)
            }
            this._defineDatas.cloneTo(r._defineDatas)
        }
        clone() {
            var e = new ce;
            return this.cloneTo(e), e
        }
        cloneToForNative(e) {
            var r = e;
            this._int32Data.length - r._int32Data.length &gt; 0 &amp;&amp; r.needRenewArrayBufferForNative(this._int32Data.length), r._int32Data.set(this._int32Data, 0);
            var s = r._nativeArray,
                o = this._nativeArray.length;
            s.length = o;
            for (var l = 0; l &lt; o; l++) {
                var _ = this._nativeArray[l];
                if (_)
                    if ("number" == typeof _) s[l] = _, r.setNumber(l, _);
                    else if ("number" == typeof _) s[l] = _, r.setInt(l, _);
                else if ("boolean" == typeof _) s[l] = _, r.setBool(l, _);
                else if (_ instanceof i) {
                    var h = s[l] || (s[l] = new i);
                    _.cloneTo(h), s[l] = h, r.setVector2(l, h)
                } else if (_ instanceof a) {
                    var d = s[l] || (s[l] = new a);
                    _.cloneTo(d), s[l] = d, r.setVector3(l, d)
                } else if (_ instanceof n) {
                    var u = s[l] || (s[l] = new n);
                    _.cloneTo(u), s[l] = u, r.setVector(l, u)
                } else if (_ instanceof c) {
                    var m = s[l] || (s[l] = new c);
                    _.cloneTo(m), s[l] = m, r.setMatrix4x4(l, m)
                } else _ instanceof t.BaseTexture &amp;&amp; (s[l] = _, r.setTexture(l, _))
            }
            this._defineDatas.cloneTo(r._defineDatas)
        }
        _initDataForNative() {
            this._frameCount = -1, this._runtimeCopyValues.length = 0, this._nativeArray = [], this._data = new ArrayBuffer(32), this._int32Data = new Int32Array(this._data), this._float32Data = new Float32Array(this._data), t.LayaGL.instance.createArrayBufferRef(this._data, t.LayaGL.ARRAY_BUFFER_TYPE_DATA, !0)
        }
        needRenewArrayBufferForNative(e) {
            if (e &gt;= this._int32Data.length) {
                var r = 4 * (e + 1),
                    i = this._int32Data,
                    n = this._data.conchRef,
                    a = this._data._ptrID;
                this._data = new ArrayBuffer(r), this._int32Data = new Int32Array(this._data), this._float32Data = new Float32Array(this._data), this._data.conchRef = n, this._data._ptrID = a, i &amp;&amp; this._int32Data.set(i, 0);
                var s = t.LayaGL.instance;
                s.updateArrayBufferRef ? s.updateArrayBufferRef(this._data._ptrID, n.isSyncToRender(), this._data) : window.conch.updateArrayBufferRef(this._data._ptrID, n.isSyncToRender(), this._data)
            }
        }
        getDataForNative() {
            return this._nativeArray
        }
        getIntForNative(e) {
            return this._int32Data[e]
        }
        setIntForNative(e, t) {
            this.needRenewArrayBufferForNative(e), this._int32Data[e] = t, this._nativeArray[e] = t
        }
        getBoolForNative(e) {
            return 1 == this._int32Data[e]
        }
        setBoolForNative(e, t) {
            this.needRenewArrayBufferForNative(e), this._int32Data[e] = t ? 1 : 0, this._nativeArray[e] = t
        }
        getNumberForNative(e) {
            return this._float32Data[e]
        }
        setNumberForNative(e, t) {
            this.needRenewArrayBufferForNative(e), this._float32Data[e] = t, this._nativeArray[e] = t
        }
        getMatrix4x4ForNative(e) {
            return this._nativeArray[e]
        }
        setMatrix4x4ForNative(e, t) {
            this.needRenewArrayBufferForNative(e), this._nativeArray[e] = t;
            var r = this.setReferenceForNative(t.elements);
            this._int32Data[e] = r
        }
        getVectorForNative(e) {
            return this._nativeArray[e]
        }
        setVectorForNative(e, t) {
            this.needRenewArrayBufferForNative(e), this._nativeArray[e] = t, t.elements || t.forNativeElement();
            var r = this.setReferenceForNative(t.elements);
            this._int32Data[e] = r
        }
        getVector2ForNative(e) {
            return this._nativeArray[e]
        }
        setVector2ForNative(e, t) {
            this.needRenewArrayBufferForNative(e), this._nativeArray[e] = t, t.elements || t.forNativeElement();
            var r = this.setReferenceForNative(t.elements);
            this._int32Data[e] = r
        }
        getVector3ForNative(e) {
            return this._nativeArray[e]
        }
        setVector3ForNative(e, t) {
            this.needRenewArrayBufferForNative(e), this._nativeArray[e] = t, t.elements || t.forNativeElement();
            var r = this.setReferenceForNative(t.elements);
            this._int32Data[e] = r
        }
        getQuaternionForNative(e) {
            return this._nativeArray[e]
        }
        setQuaternionForNative(e, t) {
            this.needRenewArrayBufferForNative(e), this._nativeArray[e] = t, t.elements || t.forNativeElement();
            var r = this.setReferenceForNative(t.elements);
            this._int32Data[e] = r
        }
        getBufferForNative(e) {
            return this._nativeArray[e]
        }
        setBufferForNative(e, t) {
            this.needRenewArrayBufferForNative(e), this._nativeArray[e] = t;
            var r = this.setReferenceForNative(t);
            this._int32Data[e] = r
        }
        getAttributeForNative(e) {
            return this._nativeArray[e]
        }
        setAttributeForNative(e, r) {
            this._nativeArray[e] = r, r._ptrID || t.LayaGL.instance.createArrayBufferRef(r, t.LayaGL.ARRAY_BUFFER_TYPE_DATA, !0), t.LayaGL.instance.syncBufferToRenderThread(r), this._int32Data[e] = r._ptrID
        }
        getTextureForNative(e) {
            return this._nativeArray[e]
        }
        setTextureForNative(e, t) {
            if (t) {
                this.needRenewArrayBufferForNative(e);
                var r = this._nativeArray[e];
                this._nativeArray[e] = t;
                var i = t._getSource() || t.defaulteTexture._getSource();
                this._int32Data[e] = i.id, this._ownerResource &amp;&amp; this._ownerResource.referenceCount &gt; 0 &amp;&amp; (r &amp;&amp; r._removeReference(), t &amp;&amp; t._addReference())
            }
        }
        setReferenceForNative(e) {
            this.clearRuntimeCopyArray();
            var r = 0,
                i = 0;
            return ce._SET_RUNTIME_VALUE_MODE_REFERENCE_ ? (t.LayaGL.instance.createArrayBufferRefs(e, t.LayaGL.ARRAY_BUFFER_TYPE_DATA, !0, t.LayaGL.ARRAY_BUFFER_REF_REFERENCE), r = 0, i = e.getPtrID(r)) : (t.LayaGL.instance.createArrayBufferRefs(e, t.LayaGL.ARRAY_BUFFER_TYPE_DATA, !0, t.LayaGL.ARRAY_BUFFER_REF_COPY), r = e.getRefNum() - 1, i = e.getPtrID(r), this._runtimeCopyValues.push({
                obj: e,
                refID: r,
                ptrID: i
            })), t.LayaGL.instance.syncBufferToRenderThread(e, r), i
        }
        static setRuntimeValueMode(e) {
            ce._SET_RUNTIME_VALUE_MODE_REFERENCE_ = e
        }
        clearRuntimeCopyArray() {
            var e = t.Stat.loopCount;
            if (this._frameCount != e) {
                this._frameCount = e;
                for (var r = 0, i = this._runtimeCopyValues.length; r &lt; i; r++) {
                    this._runtimeCopyValues[r].obj.clearRefNum()
                }
                this._runtimeCopyValues.length = 0
            }
        }
    }
    ce._SET_RUNTIME_VALUE_MODE_REFERENCE_ = !0;
    class de {
        constructor() {
            this._compositeShader = he.find("PostProcessComposite"), this._compositeShaderData = new ce, this._effects = [], this._context = null, this._context = new ie, this._context.compositeShaderData = this._compositeShaderData
        }
        static __init__() {
            de.SHADERDEFINE_BLOOM_LOW = he.getDefineByName("BLOOM_LOW"), de.SHADERDEFINE_BLOOM = he.getDefineByName("BLOOM"), de.SHADERDEFINE_FINALPASS = he.getDefineByName("FINALPASS")
        }
        _init(e, t) {
            this._context.camera = e, this._context.command = t
        }
        _render() {
            var e = ce._SET_RUNTIME_VALUE_MODE_REFERENCE_;
            t.ILaya.Render.supportWebGLPlusRendering &amp;&amp; ce.setRuntimeValueMode(!1);
            var r = this._context.camera,
                i = r.viewport,
                n = ae.createFromPool(ne.clientWidth, ne.clientHeight, r._getRenderTextureFormat(), t.RenderTextureDepthFormat.DEPTHSTENCIL_NONE),
                a = r._internalRenderTexture;
            this._context.command.clear(), this._context.source = n, this._context.destination = a, this._context.compositeShaderData.clearDefine(), this._context.command.blitScreenTriangle(a, n), this._context.compositeShaderData.setTexture(de.SHADERVALUE_AUTOEXPOSURETEX, t.Texture2D.whiteTexture);
            for (var s = 0, o = this._effects.length; s &lt; o; s++) this._effects[s].render(this._context);
            this._compositeShaderData.addDefine(de.SHADERDEFINE_FINALPASS);
            var l = r._offScreenRenderTexture,
                _ = l || null;
            this._context.destination = _;
            var h = r._getCanvasWidth(),
                c = r._getCanvasHeight();
            r._screenOffsetScale.setValue(i.x / h, i.y / c, i.width / h, i.height / c), this._context.command.blitScreenTriangle(this._context.source, _, r._screenOffsetScale, this._compositeShader, this._compositeShaderData), ae.recoverToPool(n);
            var d = this._context.deferredReleaseTextures;
            for (s = 0, o = d.length; s &lt; o; s++) ae.recoverToPool(d[s]);
            d.length = 0, t.ILaya.Render.supportWebGLPlusRendering &amp;&amp; ce.setRuntimeValueMode(e)
        }
        addEffect(e) {
            this._effects.push(e)
        }
        removeEffect(e) {
            var t = this._effects.indexOf(e); - 1 !== t &amp;&amp; this._effects.splice(t, 1)
        }
    }
    de.SHADERVALUE_MAINTEX = he.propertyNameToID("u_MainTex"), de.SHADERVALUE_BLOOMTEX = he.propertyNameToID("u_BloomTex"), de.SHADERVALUE_AUTOEXPOSURETEX = he.propertyNameToID("u_AutoExposureTex"), de.SHADERVALUE_BLOOM_DIRTTEX = he.propertyNameToID("u_Bloom_DirtTex"), de.SHADERVALUE_BLOOMTEX_TEXELSIZE = he.propertyNameToID("u_BloomTex_TexelSize"), de.SHADERVALUE_BLOOM_DIRTTILEOFFSET = he.propertyNameToID("u_Bloom_DirtTileOffset"), de.SHADERVALUE_BLOOM_SETTINGS = he.propertyNameToID("u_Bloom_Settings"), de.SHADERVALUE_BLOOM_COLOR = he.propertyNameToID("u_Bloom_Color");
    class ue extends t.EventDispatcher {
        constructor(e, r = null, i = null, n = null, s = null) {
            super(), this._owner = e, this._children = [], this._localMatrix = new Float32Array(16), t.Render.supportWebGLPlusAnimation ? (this._localPosition = new J(0, 0, 0, r), this._localRotation = new $(0, 0, 0, 1, i), this._localScale = new J(0, 0, 0, n), this._worldMatrix = s) : (this._localPosition = new a, this._localRotation = new h, this._localScale = new a, this._worldMatrix = new Float32Array(16)), this._localQuaternionUpdate = !1, this._locaEulerlUpdate = !1, this._localUpdate = !1, this._worldUpdate = !0
        }
        _getlocalMatrix() {
            return this._localUpdate &amp;&amp; (N._createAffineTransformationArray(this._localPosition, this._localRotation, this._localScale, this._localMatrix), this._localUpdate = !1), this._localMatrix
        }
        _onWorldTransform() {
            if (!this._worldUpdate) {
                this._worldUpdate = !0, this.event(t.Event.TRANSFORM_CHANGED);
                for (var e = 0, r = this._children.length; e &lt; r; e++) this._children[e]._onWorldTransform()
            }
        }
        get localPosition() {
            return this._localPosition
        }
        set localPosition(e) {
            this._localPosition = e, this._localUpdate = !0, this._onWorldTransform()
        }
        get localRotation() {
            if (this._localQuaternionUpdate) {
                var e = this._localRotationEuler;
                h.createFromYawPitchRoll(e.y / ue._angleToRandin, e.x / ue._angleToRandin, e.z / ue._angleToRandin, this._localRotation), this._localQuaternionUpdate = !1
            }
            return this._localRotation
        }
        set localRotation(e) {
            this._localRotation = e, this._locaEulerlUpdate = !0, this._localQuaternionUpdate = !1, this._localUpdate = !0, this._onWorldTransform()
        }
        get localScale() {
            return this._localScale
        }
        set localScale(e) {
            this._localScale = e, this._localUpdate = !0, this._onWorldTransform()
        }
        get localRotationEuler() {
            if (this._locaEulerlUpdate) {
                this._localRotation.getYawPitchRoll(ue._tempVector3);
                var e = ue._tempVector3,
                    t = this._localRotationEuler;
                t.x = e.y * ue._angleToRandin, t.y = e.x * ue._angleToRandin, t.z = e.z * ue._angleToRandin, this._locaEulerlUpdate = !1
            }
            return this._localRotationEuler
        }
        set localRotationEuler(e) {
            this._localRotationEuler = e, this._locaEulerlUpdate = !1, this._localQuaternionUpdate = !0, this._localUpdate = !0, this._onWorldTransform()
        }
        getWorldMatrix() {
            if (!t.Render.supportWebGLPlusAnimation &amp;&amp; this._worldUpdate) {
                if (null != this._parent) N.matrix4x4MultiplyFFF(this._parent.getWorldMatrix(), this._getlocalMatrix(), this._worldMatrix);
                else {
                    var e = this._worldMatrix;
                    e[1] = e[2] = e[3] = e[4] = e[6] = e[7] = e[8] = e[9] = e[11] = e[12] = e[13] = e[14] = 0, e[0] = e[5] = e[10] = e[15] = 1
                }
                this._worldUpdate = !1
            }
            return t.Render.supportWebGLPlusAnimation &amp;&amp; this._worldUpdate &amp;&amp; (this._worldUpdate = !1), this._worldMatrix
        }
        setParent(e) {
            if (this._parent !== e) {
                if (this._parent) {
                    var t = this._parent._children,
                        r = t.indexOf(this);
                    t.splice(r, 1)
                }
                e &amp;&amp; (e._children.push(this), e &amp;&amp; this._onWorldTransform()), this._parent = e
            }
        }
    }
    ue._tempVector3 = new a, ue._angleToRandin = 180 / Math.PI;
    class me {
        constructor(e = null, t = null, r = null, i = null) {
            this._children = [], this.transform = new ue(this, e, t, r, i)
        }
        addChild(e) {
            e._parent = this, e.transform.setParent(this.transform), this._children.push(e)
        }
        removeChild(e) {
            var t = this._children.indexOf(e); - 1 !== t &amp;&amp; this._children.splice(t, 1)
        }
        getChildByName(e) {
            for (var t = 0, r = this._children.length; t &lt; r; t++) {
                var i = this._children[t];
                if (i.name === e) return i
            }
            return null
        }
        getChildByIndex(e) {
            return this._children[e]
        }
        getChildCount() {
            return this._children.length
        }
        cloneTo(e) {
            var t = e;
            t.name = this.name;
            for (var r = 0, i = this._children.length; r &lt; i; r++) {
                var n = this._children[r],
                    a = n.clone();
                t.addChild(a);
                var s = n.transform,
                    o = a.transform,
                    l = o.localPosition,
                    _ = o.localRotation,
                    h = o.localScale;
                s.localPosition.cloneTo(l), s.localRotation.cloneTo(_), s.localScale.cloneTo(h), o.localPosition = l, o.localRotation = _, o.localScale = h
            }
        }
        clone() {
            var e = new me;
            return this.cloneTo(e), e
        }
        _cloneNative(e, t, r, i, n, a, s) {
            var o = s._nativeCurCloneCount;
            n[o] = a;
            var l = new Float32Array(e.buffer, 3 * o * 4, 3),
                _ = new Float32Array(t.buffer, 4 * o * 4, 4),
                h = new Float32Array(r.buffer, 3 * o * 4, 3),
                c = new Float32Array(i.buffer, 16 * o * 4, 16),
                d = new me(l, _, h, c);
            return d._worldMatrixIndex = o, this._cloneToNative(d, e, t, r, i, n, o, s), d
        }
        _cloneToNative(e, t, r, i, n, a, s, o) {
            var l = e;
            l.name = this.name;
            for (var _ = 0, h = this._children.length; _ &lt; h; _++) {
                var c = this._children[_];
                o._nativeCurCloneCount++;
                var d = c._cloneNative(t, r, i, n, a, s, o);
                l.addChild(d);
                var u = c.transform,
                    m = d.transform,
                    f = m.localPosition,
                    T = m.localRotation,
                    E = m.localScale;
                u.localPosition.cloneTo(f), u.localRotation.cloneTo(T), u.localScale.cloneTo(E), m.localPosition = f, m.localRotation = T, m.localScale = E
            }
        }
    }
    class fe extends t.Resource {
        constructor() {
            super(), this._nativeNodeCount = 0, this._nativeCurCloneCount = 0
        }
        static _parse(e, r = null, i = null) {
            var n = new fe;
            if (n._rootNode = new me(new Float32Array(3), new Float32Array(4), new Float32Array(3), new Float32Array(16)), t.Render.supportWebGLPlusAnimation &amp;&amp; n._nativeNodeCount++, e.version) {
                var a = e.rootNode;
                a &amp;&amp; n._parseNode(a, n._rootNode)
            }
            return n
        }
        static load(e, r) {
            t.ILaya.loader.create(e, r, null, fe.AVATAR)
        }
        _initCloneToAnimator(e, t) {
            t._avatarNodeMap[e.name] = e;
            for (var r = 0, i = e.getChildCount(); r &lt; i; r++) this._initCloneToAnimator(e.getChildByIndex(r), t)
        }
        _parseNode(e, r) {
            var i = e.props.name;
            r.name = i;
            var n = e.props,
                a = r.transform,
                s = a.localPosition,
                o = a.localRotation,
                l = a.localScale;
            s.fromArray(n.translate), o.fromArray(n.rotation), l.fromArray(n.scale), a.localPosition = s, a.localRotation = o, a.localScale = l;
            for (var _ = e.child, h = 0, c = _.length; h &lt; c; h++) {
                var d = _[h],
                    u = new me(new Float32Array(3), new Float32Array(4), new Float32Array(3), new Float32Array(16));
                r.addChild(u), t.Render.supportWebGLPlusAnimation &amp;&amp; this._nativeNodeCount++, this._parseNode(d, u)
            }
        }
        _cloneDatasToAnimator(e) {
            var t;
            t = this._rootNode.clone();
            var r = this._rootNode.transform,
                i = t.transform,
                n = i.localPosition,
                a = i.localRotation,
                s = i.localScale;
            r.localPosition.cloneTo(n), r.localRotation.cloneTo(a), r.localScale.cloneTo(s), i.localPosition = n, i.localRotation = a, i.localScale = s, e._avatarNodeMap = {}, this._initCloneToAnimator(t, e)
        }
        cloneTo(e) {
            var t = e,
                r = this._rootNode.clone();
            t._rootNode = r
        }
        clone() {
            var e = new fe;
            return this.cloneTo(e), e
        }
        _cloneDatasToAnimatorNative(e) {
            var t = new Float32Array(3 * this._nativeNodeCount),
                r = new Float32Array(4 * this._nativeNodeCount),
                i = new Float32Array(3 * this._nativeNodeCount),
                n = new Float32Array(16 * this._nativeNodeCount),
                a = new Int16Array(this._nativeNodeCount);
            e._animationNodeLocalPositions = t, e._animationNodeLocalRotations = r, e._animationNodeLocalScales = i, e._animationNodeWorldMatrixs = n, e._animationNodeParentIndices = a, this._nativeCurCloneCount = 0;
            var s = this._rootNode._cloneNative(t, r, i, n, a, -1, this),
                o = this._rootNode.transform,
                l = s.transform,
                _ = l.localPosition,
                h = l.localRotation,
                c = l.localScale;
            o.localPosition.cloneTo(_), o.localRotation.cloneTo(h), o.localScale.cloneTo(c), l.localPosition = _, l.localRotation = h, l.localScale = c, e._avatarNodeMap = {}, this._initCloneToAnimator(s, e)
        }
    }
    fe.AVATAR = "AVATAR";
    class Te extends t.Resource {
        constructor() {
            super(), this._shaderValues = null, this._shaderValues = new ce(this), this.renderQueue = Te.RENDERQUEUE_OPAQUE, this._alphaTest = !1
        }
        static load(e, r) {
            t.Laya.loader.create(e, r, null, Te.MATERIAL)
        }
        static __initDefine__() {
            Te.SHADERDEFINE_ALPHATEST = he.getDefineByName("ALPHATEST")
        }
        static _parse(e, r = null, s = null) {
            var o, l = e,
                _ = l.props,
                h = _.type,
                c = t.ClassUtils.getRegClass(h);
            if (!c) throw "_getSprite3DHierarchyInnerUrls é”™è¯¯: " + e.type + " ä¸æ˜¯ç±»";
            switch (o = new c, l.version) {
                case "LAYAMATERIAL:01":
                case "LAYAMATERIAL:02":
                    var d, u;
                    for (var m in _) switch (m) {
                        case "type":
                            break;
                        case "vectors":
                            var f = _[m];
                            for (d = 0, u = f.length; d &lt; u; d++) {
                                var T = f[d],
                                    E = T.value;
                                switch (E.length) {
                                    case 2:
                                        o[T.name] = new i(E[0], E[1]);
                                        break;
                                    case 3:
                                        o[T.name] = new a(E[0], E[1], E[2]);
                                        break;
                                    case 4:
                                        o[T.name] = new n(E[0], E[1], E[2], E[3]);
                                        break;
                                    default:
                                        throw new Error("BaseMaterial:unkonwn color length.")
                                }
                            }
                            break;
                        case "textures":
                            var p = _[m];
                            for (d = 0, u = p.length; d &lt; u; d++) {
                                var g = p[d],
                                    S = g.path;
                                S &amp;&amp; (o[g.name] = t.Loader.getRes(S))
                            }
                            break;
                        case "defines":
                            var R = _[m];
                            for (d = 0, u = R.length; d &lt; u; d++) {
                                var v = he.getDefineByName(R[d]);
                                o._shaderValues.addDefine(v)
                            }
                            break;
                        case "renderStates":
                            var A = _[m][0],
                                I = o;
                            I.blend = A.blend, I.cull = A.cull, I.depthTest = A.depthTest, I.depthWrite = A.depthWrite, I.blendSrc = A.srcBlend, I.blendDst = A.dstBlend;
                            break;
                        case "cull":
                            o.cull = _[m];
                            break;
                        case "blend":
                            o.blend = _[m];
                            break;
                        case "depthWrite":
                            o.depthWrite = _[m];
                            break;
                        case "srcBlend":
                            o.blendSrc = _[m];
                            break;
                        case "dstBlend":
                            o.blendDst = _[m];
                            break;
                        default:
                            o[m] = _[m]
                    }
                    break;
                default:
                    throw new Error("BaseMaterial:unkonwn version.")
            }
            return o
        }
        get shaderData() {
            return this._shaderValues
        }
        get alphaTestValue() {
            return this._shaderValues.getNumber(Te.ALPHATESTVALUE)
        }
        set alphaTestValue(e) {
            this._shaderValues.setNumber(Te.ALPHATESTVALUE, e)
        }
        get alphaTest() {
            return this._alphaTest
        }
        set alphaTest(e) {
            this._alphaTest = e, e ? this._shaderValues.addDefine(Te.SHADERDEFINE_ALPHATEST) : this._shaderValues.removeDefine(Te.SHADERDEFINE_ALPHATEST)
        }
        _removeTetxureReference() {
            var e = this._shaderValues.getData();
            for (var r in e) {
                var i = e[r];
                i &amp;&amp; i instanceof t.BaseTexture &amp;&amp; i._removeReference()
            }
        }
        _disposeResource() {
            this._referenceCount &gt; 0 &amp;&amp; this._removeTetxureReference(), this._shaderValues = null
        }
        _addReference(e = 1) {
            super._addReference(e);
            var r = this._shaderValues.getData();
            for (var i in r) {
                var n = r[i];
                n &amp;&amp; n instanceof t.BaseTexture &amp;&amp; n._addReference()
            }
        }
        _removeReference(e = 1) {
            super._removeReference(e), this._removeTetxureReference()
        }
        setShaderName(e) {
            if (this._shader = he.find(e), !this._shader) throw new Error("BaseMaterial: unknown shader name.")
        }
        cloneTo(e) {
            var t = e;
            t.name = this.name, t.renderQueue = this.renderQueue, this._shaderValues.cloneTo(t._shaderValues)
        }
        clone() {
            var e = new Te;
            return this.cloneTo(e), e
        }
        get _defineDatas() {
            return this._shaderValues._defineDatas
        }
    }
    Te.MATERIAL = "MATERIAL", Te.RENDERQUEUE_OPAQUE = 2e3, Te.RENDERQUEUE_ALPHATEST = 2450, Te.RENDERQUEUE_TRANSPARENT = 3e3, Te.ALPHATESTVALUE = he.propertyNameToID("u_AlphaTestValue"), Te.SHADERDEFINE_ALPHATEST = null;
    class Ee {
        static load(e, r) {
            t.Laya.loader.create(e, r, null, Te.MATERIAL)
        }
        static __initDefine__() {
            Ee.SHADERDEFINE_ALPHATEST = Te.SHADERDEFINE_ALPHATEST
        }
    }
    Ee.MATERIAL = "MATERIAL", Ee.RENDERQUEUE_OPAQUE = 2e3, Ee.RENDERQUEUE_ALPHATEST = 2450, Ee.RENDERQUEUE_TRANSPARENT = 3e3, Ee.ALPHATESTVALUE = he.propertyNameToID("u_AlphaTestValue"), Ee.SHADERDEFINE_ALPHATEST = null;
    class pe {
        constructor() {
            this.cull = pe.CULL_BACK, this.blend = pe.BLEND_DISABLE, this.srcBlend = pe.BLENDPARAM_ONE, this.dstBlend = pe.BLENDPARAM_ZERO, this.srcBlendRGB = pe.BLENDPARAM_ONE, this.dstBlendRGB = pe.BLENDPARAM_ZERO, this.srcBlendAlpha = pe.BLENDPARAM_ONE, this.dstBlendAlpha = pe.BLENDPARAM_ZERO, this.blendConstColor = new n(1, 1, 1, 1), this.blendEquation = pe.BLENDEQUATION_ADD, this.blendEquationRGB = pe.BLENDEQUATION_ADD, this.blendEquationAlpha = pe.BLENDEQUATION_ADD, this.depthTest = pe.DEPTHTEST_LEQUAL, this.depthWrite = !0
        }
        cloneTo(e) {
            var t = e;
            t.cull = this.cull, t.blend = this.blend, t.srcBlend = this.srcBlend, t.dstBlend = this.dstBlend, t.srcBlendRGB = this.srcBlendRGB, t.dstBlendRGB = this.dstBlendRGB, t.srcBlendAlpha = this.srcBlendAlpha, t.dstBlendAlpha = this.dstBlendAlpha, this.blendConstColor.cloneTo(t.blendConstColor), t.blendEquation = this.blendEquation, t.blendEquationRGB = this.blendEquationRGB, t.blendEquationAlpha = this.blendEquationAlpha, t.depthTest = this.depthTest, t.depthWrite = this.depthWrite
        }
        clone() {
            var e = new pe;
            return this.cloneTo(e), e
        }
    }
    pe.CULL_NONE = 0, pe.CULL_FRONT = 1, pe.CULL_BACK = 2, pe.BLEND_DISABLE = 0, pe.BLEND_ENABLE_ALL = 1, pe.BLEND_ENABLE_SEPERATE = 2, pe.BLENDPARAM_ZERO = 0, pe.BLENDPARAM_ONE = 1, pe.BLENDPARAM_SRC_COLOR = 768, pe.BLENDPARAM_ONE_MINUS_SRC_COLOR = 769, pe.BLENDPARAM_DST_COLOR = 774, pe.BLENDPARAM_ONE_MINUS_DST_COLOR = 775, pe.BLENDPARAM_SRC_ALPHA = 770, pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA = 771, pe.BLENDPARAM_DST_ALPHA = 772, pe.BLENDPARAM_ONE_MINUS_DST_ALPHA = 773, pe.BLENDPARAM_SRC_ALPHA_SATURATE = 776, pe.BLENDEQUATION_ADD = 32774, pe.BLENDEQUATION_SUBTRACT = 32778, pe.BLENDEQUATION_REVERSE_SUBTRACT = 32779, pe.DEPTHTEST_OFF = 0, pe.DEPTHTEST_NEVER = 512, pe.DEPTHTEST_LESS = 513, pe.DEPTHTEST_EQUAL = 514, pe.DEPTHTEST_LEQUAL = 515, pe.DEPTHTEST_GREATER = 516, pe.DEPTHTEST_NOTEQUAL = 517, pe.DEPTHTEST_GEQUAL = 518, pe.DEPTHTEST_ALWAYS = 519;
    class ge extends Te {
        constructor() {
            super(), this._enableVertexColor = !1, this.setShaderName("BLINNPHONG"), this._albedoIntensity = 1, this._albedoColor = new n(1, 1, 1, 1);
            var e = this._shaderValues;
            e.setVector(ge.ALBEDOCOLOR, new n(1, 1, 1, 1)), e.setVector(ge.MATERIALSPECULAR, new n(1, 1, 1, 1)), e.setNumber(ge.SHININESS, .078125), e.setNumber(Te.ALPHATESTVALUE, .5), e.setVector(ge.TILINGOFFSET, new n(1, 1, 0, 0)), this._enableLighting = !0, this.renderMode = ge.RENDERMODE_OPAQUE
        }
        static __initDefine__() {
            ge.SHADERDEFINE_DIFFUSEMAP = he.getDefineByName("DIFFUSEMAP"), ge.SHADERDEFINE_NORMALMAP = he.getDefineByName("NORMALMAP"), ge.SHADERDEFINE_SPECULARMAP = he.getDefineByName("SPECULARMAP"), ge.SHADERDEFINE_TILINGOFFSET = he.getDefineByName("TILINGOFFSET"), ge.SHADERDEFINE_ENABLEVERTEXCOLOR = he.getDefineByName("ENABLEVERTEXCOLOR")
        }
        get _ColorR() {
            return this._albedoColor.x
        }
        set _ColorR(e) {
            this._albedoColor.x = e, this.albedoColor = this._albedoColor
        }
        get _ColorG() {
            return this._albedoColor.y
        }
        set _ColorG(e) {
            this._albedoColor.y = e, this.albedoColor = this._albedoColor
        }
        get _ColorB() {
            return this._albedoColor.z
        }
        set _ColorB(e) {
            this._albedoColor.z = e, this.albedoColor = this._albedoColor
        }
        get _ColorA() {
            return this._albedoColor.w
        }
        set _ColorA(e) {
            this._albedoColor.w = e, this.albedoColor = this._albedoColor
        }
        get _Color() {
            return this._shaderValues.getVector(ge.ALBEDOCOLOR)
        }
        set _Color(e) {
            this.albedoColor = e
        }
        get _SpecColorR() {
            return this._shaderValues.getVector(ge.MATERIALSPECULAR).x
        }
        set _SpecColorR(e) {
            this._shaderValues.getVector(ge.MATERIALSPECULAR).x = e
        }
        get _SpecColorG() {
            return this._shaderValues.getVector(ge.MATERIALSPECULAR).y
        }
        set _SpecColorG(e) {
            this._shaderValues.getVector(ge.MATERIALSPECULAR).y = e
        }
        get _SpecColorB() {
            return this._shaderValues.getVector(ge.MATERIALSPECULAR).z
        }
        set _SpecColorB(e) {
            this._shaderValues.getVector(ge.MATERIALSPECULAR).z = e
        }
        get _SpecColorA() {
            return this._shaderValues.getVector(ge.MATERIALSPECULAR).w
        }
        set _SpecColorA(e) {
            this._shaderValues.getVector(ge.MATERIALSPECULAR).w = e
        }
        get _SpecColor() {
            return this._shaderValues.getVector(ge.MATERIALSPECULAR)
        }
        set _SpecColor(e) {
            this.specularColor = e
        }
        get _AlbedoIntensity() {
            return this._albedoIntensity
        }
        set _AlbedoIntensity(e) {
            if (this._albedoIntensity !== e) {
                var t = this._shaderValues.getVector(ge.ALBEDOCOLOR);
                n.scale(this._albedoColor, e, t), this._albedoIntensity = e, this._shaderValues.setVector(ge.ALBEDOCOLOR, t)
            }
        }
        get _Shininess() {
            return this._shaderValues.getNumber(ge.SHININESS)
        }
        set _Shininess(e) {
            e = Math.max(0, Math.min(1, e)), this._shaderValues.setNumber(ge.SHININESS, e)
        }
        get _MainTex_STX() {
            return this._shaderValues.getVector(ge.TILINGOFFSET).x
        }
        set _MainTex_STX(e) {
            var t = this._shaderValues.getVector(ge.TILINGOFFSET);
            t.x = e, this.tilingOffset = t
        }
        get _MainTex_STY() {
            return this._shaderValues.getVector(ge.TILINGOFFSET).y
        }
        set _MainTex_STY(e) {
            var t = this._shaderValues.getVector(ge.TILINGOFFSET);
            t.y = e, this.tilingOffset = t
        }
        get _MainTex_STZ() {
            return this._shaderValues.getVector(ge.TILINGOFFSET).z
        }
        set _MainTex_STZ(e) {
            var t = this._shaderValues.getVector(ge.TILINGOFFSET);
            t.z = e, this.tilingOffset = t
        }
        get _MainTex_STW() {
            return this._shaderValues.getVector(ge.TILINGOFFSET).w
        }
        set _MainTex_STW(e) {
            var t = this._shaderValues.getVector(ge.TILINGOFFSET);
            t.w = e, this.tilingOffset = t
        }
        get _MainTex_ST() {
            return this._shaderValues.getVector(ge.TILINGOFFSET)
        }
        set _MainTex_ST(e) {
            this.tilingOffset = e
        }
        get _Cutoff() {
            return this.alphaTestValue
        }
        set _Cutoff(e) {
            this.alphaTestValue = e
        }
        set renderMode(e) {
            switch (e) {
                case ge.RENDERMODE_OPAQUE:
                    this.alphaTest = !1, this.renderQueue = Te.RENDERQUEUE_OPAQUE, this.depthWrite = !0, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_DISABLE, this.depthTest = pe.DEPTHTEST_LESS;
                    break;
                case ge.RENDERMODE_CUTOUT:
                    this.renderQueue = Te.RENDERQUEUE_ALPHATEST, this.alphaTest = !0, this.depthWrite = !0, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_DISABLE, this.depthTest = pe.DEPTHTEST_LESS;
                    break;
                case ge.RENDERMODE_TRANSPARENT:
                    this.renderQueue = Te.RENDERQUEUE_TRANSPARENT, this.alphaTest = !1, this.depthWrite = !1, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_ENABLE_ALL, this.blendSrc = pe.BLENDPARAM_SRC_ALPHA, this.blendDst = pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA, this.depthTest = pe.DEPTHTEST_LESS;
                    break;
                default:
                    throw new Error("Material:renderMode value error.")
            }
        }
        get enableVertexColor() {
            return this._enableVertexColor
        }
        set enableVertexColor(e) {
            this._enableVertexColor = e, e ? this._shaderValues.addDefine(ge.SHADERDEFINE_ENABLEVERTEXCOLOR) : this._shaderValues.removeDefine(ge.SHADERDEFINE_ENABLEVERTEXCOLOR)
        }
        get tilingOffsetX() {
            return this._MainTex_STX
        }
        set tilingOffsetX(e) {
            this._MainTex_STX = e
        }
        get tilingOffsetY() {
            return this._MainTex_STY
        }
        set tilingOffsetY(e) {
            this._MainTex_STY = e
        }
        get tilingOffsetZ() {
            return this._MainTex_STZ
        }
        set tilingOffsetZ(e) {
            this._MainTex_STZ = e
        }
        get tilingOffsetW() {
            return this._MainTex_STW
        }
        set tilingOffsetW(e) {
            this._MainTex_STW = e
        }
        get tilingOffset() {
            return this._shaderValues.getVector(ge.TILINGOFFSET)
        }
        set tilingOffset(e) {
            e &amp;&amp; (1 != e.x || 1 != e.y || 0 != e.z || 0 != e.w) ? this._shaderValues.addDefine(ge.SHADERDEFINE_TILINGOFFSET) : this._shaderValues.removeDefine(ge.SHADERDEFINE_TILINGOFFSET), this._shaderValues.setVector(ge.TILINGOFFSET, e)
        }
        get albedoColorR() {
            return this._ColorR
        }
        set albedoColorR(e) {
            this._ColorR = e
        }
        get albedoColorG() {
            return this._ColorG
        }
        set albedoColorG(e) {
            this._ColorG = e
        }
        get albedoColorB() {
            return this._ColorB
        }
        set albedoColorB(e) {
            this._ColorB = e
        }
        get albedoColorA() {
            return this._ColorA
        }
        set albedoColorA(e) {
            this._ColorA = e
        }
        get albedoColor() {
            return this._albedoColor
        }
        set albedoColor(e) {
            var t = this._shaderValues.getVector(ge.ALBEDOCOLOR);
            n.scale(e, this._albedoIntensity, t), this._albedoColor = e, this._shaderValues.setVector(ge.ALBEDOCOLOR, t)
        }
        get albedoIntensity() {
            return this._albedoIntensity
        }
        set albedoIntensity(e) {
            this._AlbedoIntensity = e
        }
        get specularColorR() {
            return this._SpecColorR
        }
        set specularColorR(e) {
            this._SpecColorR = e
        }
        get specularColorG() {
            return this._SpecColorG
        }
        set specularColorG(e) {
            this._SpecColorG = e
        }
        get specularColorB() {
            return this._SpecColorB
        }
        set specularColorB(e) {
            this._SpecColorB = e
        }
        get specularColorA() {
            return this._SpecColorA
        }
        set specularColorA(e) {
            this._SpecColorA = e
        }
        get specularColor() {
            return this._shaderValues.getVector(ge.MATERIALSPECULAR)
        }
        set specularColor(e) {
            this._shaderValues.setVector(ge.MATERIALSPECULAR, e)
        }
        get shininess() {
            return this._Shininess
        }
        set shininess(e) {
            this._Shininess = e
        }
        get albedoTexture() {
            return this._shaderValues.getTexture(ge.ALBEDOTEXTURE)
        }
        set albedoTexture(e) {
            e ? this._shaderValues.addDefine(ge.SHADERDEFINE_DIFFUSEMAP) : this._shaderValues.removeDefine(ge.SHADERDEFINE_DIFFUSEMAP), this._shaderValues.setTexture(ge.ALBEDOTEXTURE, e)
        }
        get normalTexture() {
            return this._shaderValues.getTexture(ge.NORMALTEXTURE)
        }
        set normalTexture(e) {
            e ? this._shaderValues.addDefine(ge.SHADERDEFINE_NORMALMAP) : this._shaderValues.removeDefine(ge.SHADERDEFINE_NORMALMAP), this._shaderValues.setTexture(ge.NORMALTEXTURE, e)
        }
        get specularTexture() {
            return this._shaderValues.getTexture(ge.SPECULARTEXTURE)
        }
        set specularTexture(e) {
            e ? this._shaderValues.addDefine(ge.SHADERDEFINE_SPECULARMAP) : this._shaderValues.removeDefine(ge.SHADERDEFINE_SPECULARMAP), this._shaderValues.setTexture(ge.SPECULARTEXTURE, e)
        }
        get depthWrite() {
            return this._shaderValues.getBool(ge.DEPTH_WRITE)
        }
        set depthWrite(e) {
            this._shaderValues.setBool(ge.DEPTH_WRITE, e)
        }
        get cull() {
            return this._shaderValues.getInt(ge.CULL)
        }
        set cull(e) {
            this._shaderValues.setInt(ge.CULL, e)
        }
        get blend() {
            return this._shaderValues.getInt(ge.BLEND)
        }
        set blend(e) {
            this._shaderValues.setInt(ge.BLEND, e)
        }
        get blendSrc() {
            return this._shaderValues.getInt(ge.BLEND_SRC)
        }
        set blendSrc(e) {
            this._shaderValues.setInt(ge.BLEND_SRC, e)
        }
        get blendDst() {
            return this._shaderValues.getInt(ge.BLEND_DST)
        }
        set blendDst(e) {
            this._shaderValues.setInt(ge.BLEND_DST, e)
        }
        get depthTest() {
            return this._shaderValues.getInt(ge.DEPTH_TEST)
        }
        set depthTest(e) {
            this._shaderValues.setInt(ge.DEPTH_TEST, e)
        }
        clone() {
            var e = new ge;
            return this.cloneTo(e), e
        }
        cloneTo(e) {
            super.cloneTo(e);
            var t = e;
            t._enableLighting = this._enableLighting, t._albedoIntensity = this._albedoIntensity, t._enableVertexColor = this._enableVertexColor, this._albedoColor.cloneTo(t._albedoColor)
        }
    }
    ge.RENDERMODE_OPAQUE = 0, ge.RENDERMODE_CUTOUT = 1, ge.RENDERMODE_TRANSPARENT = 2, ge.ALBEDOTEXTURE = he.propertyNameToID("u_DiffuseTexture"), ge.NORMALTEXTURE = he.propertyNameToID("u_NormalTexture"), ge.SPECULARTEXTURE = he.propertyNameToID("u_SpecularTexture"), ge.ALBEDOCOLOR = he.propertyNameToID("u_DiffuseColor"), ge.MATERIALSPECULAR = he.propertyNameToID("u_MaterialSpecular"), ge.SHININESS = he.propertyNameToID("u_Shininess"), ge.TILINGOFFSET = he.propertyNameToID("u_TilingOffset"), ge.CULL = he.propertyNameToID("s_Cull"), ge.BLEND = he.propertyNameToID("s_Blend"), ge.BLEND_SRC = he.propertyNameToID("s_BlendSrc"), ge.BLEND_DST = he.propertyNameToID("s_BlendDst"), ge.DEPTH_TEST = he.propertyNameToID("s_DepthTest"), ge.DEPTH_WRITE = he.propertyNameToID("s_DepthWrite");
    class Se extends Te {
        constructor() {
            super(), this.setShaderName("Effect"), this._color = new n(1, 1, 1, 1), this._shaderValues.setVector(Se.TINTCOLOR, new n(1, 1, 1, 1)), this.renderMode = Se.RENDERMODE_ADDTIVE
        }
        static __initDefine__() {
            Se.SHADERDEFINE_MAINTEXTURE = he.getDefineByName("MAINTEXTURE"), Se.SHADERDEFINE_TILINGOFFSET = he.getDefineByName("TILINGOFFSET"), Se.SHADERDEFINE_ADDTIVEFOG = he.getDefineByName("ADDTIVEFOG")
        }
        get _TintColorR() {
            return this._color.x
        }
        set _TintColorR(e) {
            this._color.x = e, this.color = this._color
        }
        get _TintColorG() {
            return this._color.y
        }
        set _TintColorG(e) {
            this._color.y = e, this.color = this._color
        }
        get _TintColorB() {
            return this._color.z
        }
        set _TintColorB(e) {
            this._color.z = e, this.color = this._color
        }
        get _TintColorA() {
            return this._color.w
        }
        set _TintColorA(e) {
            this._color.w = e, this.color = this._color
        }
        get _MainTex_STX() {
            return this._shaderValues.getVector(Se.TILINGOFFSET).x
        }
        set _MainTex_STX(e) {
            var t = this._shaderValues.getVector(Se.TILINGOFFSET);
            t.x = e, this.tilingOffset = t
        }
        get _MainTex_STY() {
            return this._shaderValues.getVector(Se.TILINGOFFSET).y
        }
        set _MainTex_STY(e) {
            var t = this._shaderValues.getVector(Se.TILINGOFFSET);
            t.y = e, this.tilingOffset = t
        }
        get _MainTex_STZ() {
            return this._shaderValues.getVector(Se.TILINGOFFSET).z
        }
        set _MainTex_STZ(e) {
            var t = this._shaderValues.getVector(Se.TILINGOFFSET);
            t.z = e, this.tilingOffset = t
        }
        get _MainTex_STW() {
            return this._shaderValues.getVector(Se.TILINGOFFSET).w
        }
        set _MainTex_STW(e) {
            var t = this._shaderValues.getVector(Se.TILINGOFFSET);
            t.w = e, this.tilingOffset = t
        }
        set renderMode(e) {
            switch (e) {
                case Se.RENDERMODE_ADDTIVE:
                    this.renderQueue = Te.RENDERQUEUE_TRANSPARENT, this.alphaTest = !1, this.depthWrite = !1, this.cull = pe.CULL_NONE, this.blend = pe.BLEND_ENABLE_ALL, this.blendSrc = pe.BLENDPARAM_SRC_ALPHA, this.blendDst = pe.BLENDPARAM_ONE, this.depthTest = pe.DEPTHTEST_LESS, this._shaderValues.addDefine(Se.SHADERDEFINE_ADDTIVEFOG);
                    break;
                case Se.RENDERMODE_ALPHABLENDED:
                    this.renderQueue = Te.RENDERQUEUE_TRANSPARENT, this.alphaTest = !1, this.depthWrite = !1, this.cull = pe.CULL_NONE, this.blend = pe.BLEND_ENABLE_ALL, this.blendSrc = pe.BLENDPARAM_SRC_ALPHA, this.blendDst = pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA, this.depthTest = pe.DEPTHTEST_LESS, this._shaderValues.removeDefine(Se.SHADERDEFINE_ADDTIVEFOG);
                    break;
                default:
                    throw new Error("MeshEffectMaterial : renderMode value error.")
            }
        }
        get colorR() {
            return this._TintColorR
        }
        set colorR(e) {
            this._TintColorR = e
        }
        get colorG() {
            return this._TintColorG
        }
        set colorG(e) {
            this._TintColorG = e
        }
        get colorB() {
            return this._TintColorB
        }
        set colorB(e) {
            this._TintColorB = e
        }
        get colorA() {
            return this._TintColorA
        }
        set colorA(e) {
            this._TintColorA = e
        }
        get color() {
            return this._shaderValues.getVector(Se.TINTCOLOR)
        }
        set color(e) {
            this._shaderValues.setVector(Se.TINTCOLOR, e)
        }
        get texture() {
            return this._shaderValues.getTexture(Se.MAINTEXTURE)
        }
        set texture(e) {
            e ? this._shaderValues.addDefine(Se.SHADERDEFINE_MAINTEXTURE) : this._shaderValues.removeDefine(Se.SHADERDEFINE_MAINTEXTURE), this._shaderValues.setTexture(Se.MAINTEXTURE, e)
        }
        get tilingOffsetX() {
            return this._MainTex_STX
        }
        set tilingOffsetX(e) {
            this._MainTex_STX = e
        }
        get tilingOffsetY() {
            return this._MainTex_STY
        }
        set tilingOffsetY(e) {
            this._MainTex_STY = e
        }
        get tilingOffsetZ() {
            return this._MainTex_STZ
        }
        set tilingOffsetZ(e) {
            this._MainTex_STZ = e
        }
        get tilingOffsetW() {
            return this._MainTex_STW
        }
        set tilingOffsetW(e) {
            this._MainTex_STW = e
        }
        get tilingOffset() {
            return this._shaderValues.getVector(Se.TILINGOFFSET)
        }
        set tilingOffset(e) {
            e &amp;&amp; (1 != e.x || 1 != e.y || 0 != e.z || 0 != e.w) ? this._shaderValues.addDefine(Se.SHADERDEFINE_TILINGOFFSET) : this._shaderValues.removeDefine(Se.SHADERDEFINE_TILINGOFFSET), this._shaderValues.setVector(Se.TILINGOFFSET, e)
        }
        get depthWrite() {
            return this._shaderValues.getBool(Se.DEPTH_WRITE)
        }
        set depthWrite(e) {
            this._shaderValues.setBool(Se.DEPTH_WRITE, e)
        }
        get cull() {
            return this._shaderValues.getInt(Se.CULL)
        }
        set cull(e) {
            this._shaderValues.setInt(Se.CULL, e)
        }
        get blend() {
            return this._shaderValues.getInt(Se.BLEND)
        }
        set blend(e) {
            this._shaderValues.setInt(Se.BLEND, e)
        }
        get blendSrc() {
            return this._shaderValues.getInt(Se.BLEND_SRC)
        }
        set blendSrc(e) {
            this._shaderValues.setInt(Se.BLEND_SRC, e)
        }
        get blendDst() {
            return this._shaderValues.getInt(Se.BLEND_DST)
        }
        set blendDst(e) {
            this._shaderValues.setInt(Se.BLEND_DST, e)
        }
        get depthTest() {
            return this._shaderValues.getInt(Se.DEPTH_TEST)
        }
        set depthTest(e) {
            this._shaderValues.setInt(Se.DEPTH_TEST, e)
        }
        clone() {
            var e = new Se;
            return this.cloneTo(e), e
        }
    }
    Se.RENDERMODE_ADDTIVE = 0, Se.RENDERMODE_ALPHABLENDED = 1, Se.MAINTEXTURE = he.propertyNameToID("u_AlbedoTexture"), Se.TINTCOLOR = he.propertyNameToID("u_AlbedoColor"), Se.TILINGOFFSET = he.propertyNameToID("u_TilingOffset"), Se.CULL = he.propertyNameToID("s_Cull"), Se.BLEND = he.propertyNameToID("s_Blend"), Se.BLEND_SRC = he.propertyNameToID("s_BlendSrc"), Se.BLEND_DST = he.propertyNameToID("s_BlendDst"), Se.DEPTH_TEST = he.propertyNameToID("s_DepthTest"), Se.DEPTH_WRITE = he.propertyNameToID("s_DepthWrite");
    class Re extends Te {
        constructor() {
            super(), this._enableLighting = !0, this.setShaderName("ExtendTerrain"), this.renderMode = Re.RENDERMODE_OPAQUE
        }
        static __initDefine__() {
            Re.SHADERDEFINE_DETAIL_NUM1 = he.getDefineByName("ExtendTerrain_DETAIL_NUM1"), Re.SHADERDEFINE_DETAIL_NUM2 = he.getDefineByName("ExtendTerrain_DETAIL_NUM2"), Re.SHADERDEFINE_DETAIL_NUM3 = he.getDefineByName("ExtendTerrain_DETAIL_NUM3"), Re.SHADERDEFINE_DETAIL_NUM4 = he.getDefineByName("ExtendTerrain_DETAIL_NUM4"), Re.SHADERDEFINE_DETAIL_NUM5 = he.getDefineByName("ExtendTerrain_DETAIL_NUM5")
        }
        get splatAlphaTexture() {
            return this._shaderValues.getTexture(Re.SPLATALPHATEXTURE)
        }
        set splatAlphaTexture(e) {
            this._shaderValues.setTexture(Re.SPLATALPHATEXTURE, e)
        }
        get diffuseTexture1() {
            return this._shaderValues.getTexture(Re.DIFFUSETEXTURE1)
        }
        set diffuseTexture1(e) {
            this._shaderValues.setTexture(Re.DIFFUSETEXTURE1, e), this._setDetailNum(1)
        }
        get diffuseTexture2() {
            return this._shaderValues.getTexture(Re.DIFFUSETEXTURE2)
        }
        set diffuseTexture2(e) {
            this._shaderValues.setTexture(Re.DIFFUSETEXTURE2, e), this._setDetailNum(2)
        }
        get diffuseTexture3() {
            return this._shaderValues.getTexture(Re.DIFFUSETEXTURE3)
        }
        set diffuseTexture3(e) {
            this._shaderValues.setTexture(Re.DIFFUSETEXTURE3, e), this._setDetailNum(3)
        }
        get diffuseTexture4() {
            return this._shaderValues.getTexture(Re.DIFFUSETEXTURE4)
        }
        set diffuseTexture4(e) {
            this._shaderValues.setTexture(Re.DIFFUSETEXTURE4, e), this._setDetailNum(4)
        }
        get diffuseTexture5() {
            return this._shaderValues.getTexture(Re.DIFFUSETEXTURE5)
        }
        set diffuseTexture5(e) {
            this._shaderValues.setTexture(Re.DIFFUSETEXTURE5, e), this._setDetailNum(5)
        }
        set diffuseScaleOffset1(e) {
            this._shaderValues.setVector(Re.DIFFUSESCALEOFFSET1, e)
        }
        set diffuseScaleOffset2(e) {
            this._shaderValues.setVector(Re.DIFFUSESCALEOFFSET2, e)
        }
        set diffuseScaleOffset3(e) {
            this._shaderValues.setVector(Re.DIFFUSESCALEOFFSET3, e)
        }
        set diffuseScaleOffset4(e) {
            this._shaderValues.setVector(Re.DIFFUSESCALEOFFSET4, e)
        }
        set diffuseScaleOffset5(e) {
            this._shaderValues.setVector(Re.DIFFUSESCALEOFFSET5, e)
        }
        set renderMode(e) {
            switch (e) {
                case Re.RENDERMODE_OPAQUE:
                    this.renderQueue = Te.RENDERQUEUE_OPAQUE, this.depthWrite = !0, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_DISABLE, this.depthTest = pe.DEPTHTEST_LESS;
                    break;
                case Re.RENDERMODE_TRANSPARENT:
                    this.renderQueue = Te.RENDERQUEUE_OPAQUE, this.depthWrite = !1, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_ENABLE_ALL, this.blendSrc = pe.BLENDPARAM_SRC_ALPHA, this.blendDst = pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA, this.depthTest = pe.DEPTHTEST_LEQUAL;
                    break;
                default:
                    throw new Error("ExtendTerrainMaterial:renderMode value error.")
            }
        }
        get depthWrite() {
            return this._shaderValues.getBool(Re.DEPTH_WRITE)
        }
        set depthWrite(e) {
            this._shaderValues.setBool(Re.DEPTH_WRITE, e)
        }
        get cull() {
            return this._shaderValues.getInt(Re.CULL)
        }
        set cull(e) {
            this._shaderValues.setInt(Re.CULL, e)
        }
        get blend() {
            return this._shaderValues.getInt(Re.BLEND)
        }
        set blend(e) {
            this._shaderValues.setInt(Re.BLEND, e)
        }
        get blendSrc() {
            return this._shaderValues.getInt(Re.BLEND_SRC)
        }
        set blendSrc(e) {
            this._shaderValues.setInt(Re.BLEND_SRC, e)
        }
        get blendDst() {
            return this._shaderValues.getInt(Re.BLEND_DST)
        }
        set blendDst(e) {
            this._shaderValues.setInt(Re.BLEND_DST, e)
        }
        get depthTest() {
            return this._shaderValues.getInt(Re.DEPTH_TEST)
        }
        set depthTest(e) {
            this._shaderValues.setInt(Re.DEPTH_TEST, e)
        }
        _setDetailNum(e) {
            switch (e) {
                case 1:
                    this._shaderValues.addDefine(Re.SHADERDEFINE_DETAIL_NUM1), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM2), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM3), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM4), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM5);
                    break;
                case 2:
                    this._shaderValues.addDefine(Re.SHADERDEFINE_DETAIL_NUM2), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM1), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM3), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM4), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM5);
                    break;
                case 3:
                    this._shaderValues.addDefine(Re.SHADERDEFINE_DETAIL_NUM3), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM1), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM2), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM4), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM5);
                    break;
                case 4:
                    this._shaderValues.addDefine(Re.SHADERDEFINE_DETAIL_NUM4), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM1), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM2), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM3), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM5);
                    break;
                case 5:
                    this._shaderValues.addDefine(Re.SHADERDEFINE_DETAIL_NUM5), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM1), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM2), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM3), this._shaderValues.removeDefine(Re.SHADERDEFINE_DETAIL_NUM4)
            }
        }
        clone() {
            var e = new Re;
            return this.cloneTo(e), e
        }
    }
    Re.RENDERMODE_OPAQUE = 1, Re.RENDERMODE_TRANSPARENT = 2, Re.SPLATALPHATEXTURE = he.propertyNameToID("u_SplatAlphaTexture"), Re.DIFFUSETEXTURE1 = he.propertyNameToID("u_DiffuseTexture1"), Re.DIFFUSETEXTURE2 = he.propertyNameToID("u_DiffuseTexture2"), Re.DIFFUSETEXTURE3 = he.propertyNameToID("u_DiffuseTexture3"), Re.DIFFUSETEXTURE4 = he.propertyNameToID("u_DiffuseTexture4"), Re.DIFFUSETEXTURE5 = he.propertyNameToID("u_DiffuseTexture5"), Re.DIFFUSESCALEOFFSET1 = he.propertyNameToID("u_DiffuseScaleOffset1"), Re.DIFFUSESCALEOFFSET2 = he.propertyNameToID("u_DiffuseScaleOffset2"), Re.DIFFUSESCALEOFFSET3 = he.propertyNameToID("u_DiffuseScaleOffset3"), Re.DIFFUSESCALEOFFSET4 = he.propertyNameToID("u_DiffuseScaleOffset4"), Re.DIFFUSESCALEOFFSET5 = he.propertyNameToID("u_DiffuseScaleOffset5"), Re.CULL = he.propertyNameToID("s_Cull"), Re.BLEND = he.propertyNameToID("s_Blend"), Re.BLEND_SRC = he.propertyNameToID("s_BlendSrc"), Re.BLEND_DST = he.propertyNameToID("s_BlendDst"), Re.DEPTH_TEST = he.propertyNameToID("s_DepthTest"), Re.DEPTH_WRITE = he.propertyNameToID("s_DepthWrite"), (o = e.PBRRenderMode || (e.PBRRenderMode = {}))[o.Opaque = 0] = "Opaque", o[o.Cutout = 1] = "Cutout", o[o.Fade = 2] = "Fade", o[o.Transparent = 3] = "Transparent";
    class ve extends Te {
        constructor() {
            super(), this._enableEmission = !1, this._shaderValues.setVector(ve.ALBEDOCOLOR, new n(1, 1, 1, 1)), this._shaderValues.setVector(ve.EMISSIONCOLOR, new n(1, 1, 1, 1)), this._shaderValues.setNumber(ve.SMOOTHNESS, .5), this._shaderValues.setNumber(ve.SMOOTHNESSSCALE, 1), this._shaderValues.setNumber(ve.OCCLUSIONSTRENGTH, 1), this._shaderValues.setNumber(ve.NORMALSCALE, 1), this._shaderValues.setNumber(ve.PARALLAXSCALE, .001), this._shaderValues.setNumber(Te.ALPHATESTVALUE, .5), this.renderMode = e.PBRRenderMode.Opaque
        }
        static __init__() {
            ve.SHADERDEFINE_ALBEDOTEXTURE = he.getDefineByName("ALBEDOTEXTURE"), ve.SHADERDEFINE_NORMALTEXTURE = he.getDefineByName("NORMALTEXTURE"), ve.SHADERDEFINE_PARALLAXTEXTURE = he.getDefineByName("PARALLAXTEXTURE"), ve.SHADERDEFINE_OCCLUSIONTEXTURE = he.getDefineByName("OCCLUSIONTEXTURE"), ve.SHADERDEFINE_EMISSION = he.getDefineByName("EMISSION"), ve.SHADERDEFINE_EMISSIONTEXTURE = he.getDefineByName("EMISSIONTEXTURE"), ve.SHADERDEFINE_TILINGOFFSET = he.getDefineByName("TILINGOFFSET"), ve.SHADERDEFINE_TRANSPARENTBLEND = he.getDefineByName("TRANSPARENTBLEND"), ve.SHADERDEFINE_LAYA_PBR_BRDF_HIGH = he.getDefineByName("LAYA_PBR_BRDF_HIGH"), ve.SHADERDEFINE_LAYA_PBR_BRDF_LOW = he.getDefineByName("LAYA_PBR_BRDF_LOW")
        }
        get albedoColor() {
            return this._shaderValues.getVector(ve.ALBEDOCOLOR)
        }
        set albedoColor(e) {
            this._shaderValues.setVector(ve.ALBEDOCOLOR, e)
        }
        get albedoTexture() {
            return this._shaderValues.getTexture(ve.ALBEDOTEXTURE)
        }
        set albedoTexture(e) {
            e ? this._shaderValues.addDefine(ve.SHADERDEFINE_ALBEDOTEXTURE) : this._shaderValues.removeDefine(ve.SHADERDEFINE_ALBEDOTEXTURE), this._shaderValues.setTexture(ve.ALBEDOTEXTURE, e)
        }
        get normalTexture() {
            return this._shaderValues.getTexture(ve.NORMALTEXTURE)
        }
        set normalTexture(e) {
            e ? this._shaderValues.addDefine(ve.SHADERDEFINE_NORMALTEXTURE) : this._shaderValues.removeDefine(ve.SHADERDEFINE_NORMALTEXTURE), this._shaderValues.setTexture(ve.NORMALTEXTURE, e)
        }
        get normalTextureScale() {
            return this._shaderValues.getNumber(ve.NORMALSCALE)
        }
        set normalTextureScale(e) {
            this._shaderValues.setNumber(ve.NORMALSCALE, e)
        }
        get parallaxTexture() {
            return this._shaderValues.getTexture(ve.PARALLAXTEXTURE)
        }
        set parallaxTexture(e) {
            e ? this._shaderValues.addDefine(ve.SHADERDEFINE_PARALLAXTEXTURE) : this._shaderValues.removeDefine(ve.SHADERDEFINE_PARALLAXTEXTURE), this._shaderValues.setTexture(ve.PARALLAXTEXTURE, e)
        }
        get parallaxTextureScale() {
            return this._shaderValues.getNumber(ve.PARALLAXSCALE)
        }
        set parallaxTextureScale(e) {
            this._shaderValues.setNumber(ve.PARALLAXSCALE, Math.max(.005, Math.min(.08, e)))
        }
        get occlusionTexture() {
            return this._shaderValues.getTexture(ve.OCCLUSIONTEXTURE)
        }
        set occlusionTexture(e) {
            e ? this._shaderValues.addDefine(ve.SHADERDEFINE_OCCLUSIONTEXTURE) : this._shaderValues.removeDefine(ve.SHADERDEFINE_OCCLUSIONTEXTURE), this._shaderValues.setTexture(ve.OCCLUSIONTEXTURE, e)
        }
        get occlusionTextureStrength() {
            return this._shaderValues.getNumber(ve.OCCLUSIONSTRENGTH)
        }
        set occlusionTextureStrength(e) {
            this._shaderValues.setNumber(ve.OCCLUSIONSTRENGTH, Math.max(0, Math.min(1, e)))
        }
        get smoothness() {
            return this._shaderValues.getNumber(ve.SMOOTHNESS)
        }
        set smoothness(e) {
            this._shaderValues.setNumber(ve.SMOOTHNESS, Math.max(0, Math.min(1, e)))
        }
        get smoothnessTextureScale() {
            return this._shaderValues.getNumber(ve.SMOOTHNESSSCALE)
        }
        set smoothnessTextureScale(e) {
            this._shaderValues.setNumber(ve.SMOOTHNESSSCALE, Math.max(0, Math.min(1, e)))
        }
        get enableEmission() {
            return this._enableEmission
        }
        set enableEmission(e) {
            e ? this._shaderValues.addDefine(ve.SHADERDEFINE_EMISSION) : this._shaderValues.removeDefine(ve.SHADERDEFINE_EMISSION), this._enableEmission = e
        }
        get emissionColor() {
            return this._shaderValues.getVector(ve.EMISSIONCOLOR)
        }
        set emissionColor(e) {
            this._shaderValues.setVector(ve.EMISSIONCOLOR, e)
        }
        get emissionTexture() {
            return this._shaderValues.getTexture(ve.EMISSIONTEXTURE)
        }
        set emissionTexture(e) {
            e ? this._shaderValues.addDefine(ve.SHADERDEFINE_EMISSIONTEXTURE) : this._shaderValues.removeDefine(ve.SHADERDEFINE_EMISSIONTEXTURE), this._shaderValues.setTexture(ve.EMISSIONTEXTURE, e)
        }
        get tilingOffset() {
            return this._shaderValues.getVector(ve.TILINGOFFSET)
        }
        set tilingOffset(e) {
            e &amp;&amp; (1 != e.x || 1 != e.y || 0 != e.z || 0 != e.w) ? this._shaderValues.addDefine(ve.SHADERDEFINE_TILINGOFFSET) : this._shaderValues.removeDefine(ve.SHADERDEFINE_TILINGOFFSET), this._shaderValues.setVector(ve.TILINGOFFSET, e)
        }
        get depthWrite() {
            return this._shaderValues.getBool(ve.DEPTH_WRITE)
        }
        set depthWrite(e) {
            this._shaderValues.setBool(ve.DEPTH_WRITE, e)
        }
        get cull() {
            return this._shaderValues.getInt(ve.CULL)
        }
        set cull(e) {
            this._shaderValues.setInt(ve.CULL, e)
        }
        get blend() {
            return this._shaderValues.getInt(ve.BLEND)
        }
        set blend(e) {
            this._shaderValues.setInt(ve.BLEND, e)
        }
        get blendSrc() {
            return this._shaderValues.getInt(ve.BLEND_SRC)
        }
        set blendSrc(e) {
            this._shaderValues.setInt(ve.BLEND_SRC, e)
        }
        get blendDst() {
            return this._shaderValues.getInt(ve.BLEND_DST)
        }
        set blendDst(e) {
            this._shaderValues.setInt(ve.BLEND_DST, e)
        }
        get depthTest() {
            return this._shaderValues.getInt(ve.DEPTH_TEST)
        }
        set depthTest(e) {
            this._shaderValues.setInt(ve.DEPTH_TEST, e)
        }
        set renderMode(t) {
            switch (t) {
                case e.PBRRenderMode.Opaque:
                    this.alphaTest = !1, this.renderQueue = Te.RENDERQUEUE_OPAQUE, this.depthWrite = !0, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_DISABLE, this.depthTest = pe.DEPTHTEST_LESS, this._shaderValues.removeDefine(ve.SHADERDEFINE_TRANSPARENTBLEND);
                    break;
                case e.PBRRenderMode.Cutout:
                    this.renderQueue = Te.RENDERQUEUE_ALPHATEST, this.alphaTest = !0, this.depthWrite = !0, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_DISABLE, this.depthTest = pe.DEPTHTEST_LESS, this._shaderValues.removeDefine(ve.SHADERDEFINE_TRANSPARENTBLEND);
                    break;
                case e.PBRRenderMode.Fade:
                    this.renderQueue = Te.RENDERQUEUE_TRANSPARENT, this.alphaTest = !1, this.depthWrite = !1, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_ENABLE_ALL, this.blendSrc = pe.BLENDPARAM_SRC_ALPHA, this.blendDst = pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA, this.depthTest = pe.DEPTHTEST_LESS, this._shaderValues.removeDefine(ve.SHADERDEFINE_TRANSPARENTBLEND);
                    break;
                case e.PBRRenderMode.Transparent:
                    this.renderQueue = Te.RENDERQUEUE_TRANSPARENT, this.alphaTest = !1, this.depthWrite = !1, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_ENABLE_ALL, this.blendSrc = pe.BLENDPARAM_ONE, this.blendDst = pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA, this.depthTest = pe.DEPTHTEST_LESS, this._shaderValues.addDefine(ve.SHADERDEFINE_TRANSPARENTBLEND);
                    break;
                default:
                    throw new Error("PBRMaterial:unknown renderMode value.")
            }
        }
        get enableReflection() {
            return !0
        }
        set enableReflection(e) {}
    }
    ve.ALBEDOTEXTURE = he.propertyNameToID("u_AlbedoTexture"), ve.ALBEDOCOLOR = he.propertyNameToID("u_AlbedoColor"), ve.TILINGOFFSET = he.propertyNameToID("u_TilingOffset"), ve.NORMALTEXTURE = he.propertyNameToID("u_NormalTexture"), ve.NORMALSCALE = he.propertyNameToID("u_NormalScale"), ve.SMOOTHNESS = he.propertyNameToID("u_Smoothness"), ve.SMOOTHNESSSCALE = he.propertyNameToID("u_SmoothnessScale"), ve.OCCLUSIONTEXTURE = he.propertyNameToID("u_OcclusionTexture"), ve.OCCLUSIONSTRENGTH = he.propertyNameToID("u_occlusionStrength"), ve.PARALLAXTEXTURE = he.propertyNameToID("u_ParallaxTexture"), ve.PARALLAXSCALE = he.propertyNameToID("u_ParallaxScale"), ve.EMISSIONTEXTURE = he.propertyNameToID("u_EmissionTexture"), ve.EMISSIONCOLOR = he.propertyNameToID("u_EmissionColor"), ve.CULL = he.propertyNameToID("s_Cull"), ve.BLEND = he.propertyNameToID("s_Blend"), ve.BLEND_SRC = he.propertyNameToID("s_BlendSrc"), ve.BLEND_DST = he.propertyNameToID("s_BlendDst"), ve.DEPTH_TEST = he.propertyNameToID("s_DepthTest"), ve.DEPTH_WRITE = he.propertyNameToID("s_DepthWrite"), ve.renderQuality = e.PBRRenderQuality.High;
    var Ae, Ie, xe, Le, De, Ce, ye, Me, Oe, Ne, be, Pe = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n\tprecision highp int;\r\n#else\r\n\tprecision mediump float;\r\n\tprecision mediump int;\r\n#endif\r\n\r\n#define SETUP_BRDF_INPUT specularSetup\r\n\r\n#include "Lighting.glsl";\r\n#include "PBRFSInput.glsl";\r\n#include "LayaPBRBRDF.glsl";\r\n#include "GlobalIllumination.glsl";\r\n#include "Shadow.glsl"\r\n#include "PBRCore.glsl";\r\n\r\nvoid main()\r\n{\r\n\tfragmentForward();\r\n}',
        we = '#include "PBRVSInput.glsl";\r\n#include "Lighting.glsl";\r\n#include "PBRVertex.glsl";\r\n\r\nvoid main()\r\n{\r\n\tvertexForward();\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',
        Ve = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n\tprecision highp int;\r\n#else\r\n\tprecision mediump float;\r\n\tprecision mediump int;\r\n#endif\r\n\r\n#include "ShadowCasterFS.glsl"\r\n\r\nvoid main()\r\n{\r\n\tgl_FragColor=shadowCasterFragment();\r\n}',
        Be = '#include "ShadowCasterVS.glsl"\r\n\r\nvoid main()\r\n{\r\n\tvec4 positionCS =  shadowCasterVertex();\r\n\tgl_Position=remapGLPositionZ(positionCS);\r\n}';
    class Fe {
        constructor() {
            this.textureID = -1
        }
    }
    class Ue extends t.Resource {
        constructor(e, t, r, i, n) {
            super(), this._stateParamsMap = [], this._uploadMark = -1, this._uploadRenderType = -1, this._vs = e, this._ps = t, this._attributeMap = r, this._uniformMap = i, this._shaderPass = n, this._create(), this.lock = !0
        }
        _create() {
            var e = t.LayaGL.instance;
            for (var r in this._program = e.createProgram(), this._vshader = this._createShader(e, this._vs, e.VERTEX_SHADER), this._pshader = this._createShader(e, this._ps, e.FRAGMENT_SHADER), e.attachShader(this._program, this._vshader), e.attachShader(this._program, this._pshader), this._attributeMap) e.bindAttribLocation(this._program, this._attributeMap[r], r);
            if (e.linkProgram(this._program), !t.Render.isConchApp &amp;&amp; he.debugMode &amp;&amp; !e.getProgramParameter(this._program, e.LINK_STATUS)) throw e.getProgramInfoLog(this._program);
            var i = [],
                n = [],
                a = [],
                s = [],
                o = [];
            this._customUniformParamsMap = [];
            var l, _, h, c = e.getProgramParameter(this._program, e.ACTIVE_UNIFORMS);
            for (t.WebGLContext.useProgram(e, this._program), this._curActTexIndex = 0, _ = 0; _ &lt; c; _++) {
                var d = e.getActiveUniform(this._program, _),
                    u = d.name;
                (l = new Fe).location = e.getUniformLocation(this._program, u), u.indexOf("[0]") &gt; 0 ? (l.name = u = u.substr(0, u.length - 3), l.isArray = !0) : (l.name = u, l.isArray = !1), l.type = d.type, this._addShaderUnifiormFun(l);
                var m = this._uniformMap[u];
                if (null != m) switch (l.dataOffset = he.propertyNameToID(u), m) {
                    case he.PERIOD_CUSTOM:
                        o.push(l);
                        break;
                    case he.PERIOD_MATERIAL:
                        s.push(l);
                        break;
                    case he.PERIOD_SPRITE:
                        a.push(l);
                        break;
                    case he.PERIOD_CAMERA:
                        n.push(l);
                        break;
                    case he.PERIOD_SCENE:
                        i.push(l);
                        break;
                    default:
                        throw new Error("Shader3D: period is unkonw.")
                }
            }
            for (this._sceneUniformParamsMap = t.LayaGL.instance.createCommandEncoder(4 * i.length * 5 + 4, 64, !0), _ = 0, h = i.length; _ &lt; h; _++) this._sceneUniformParamsMap.addShaderUniform(i[_]);
            for (this._cameraUniformParamsMap = t.LayaGL.instance.createCommandEncoder(4 * n.length * 5 + 4, 64, !0), _ = 0, h = n.length; _ &lt; h; _++) this._cameraUniformParamsMap.addShaderUniform(n[_]);
            for (this._spriteUniformParamsMap = t.LayaGL.instance.createCommandEncoder(4 * a.length * 5 + 4, 64, !0), _ = 0, h = a.length; _ &lt; h; _++) this._spriteUniformParamsMap.addShaderUniform(a[_]);
            for (this._materialUniformParamsMap = t.LayaGL.instance.createCommandEncoder(4 * s.length * 5 + 4, 64, !0), _ = 0, h = s.length; _ &lt; h; _++) this._materialUniformParamsMap.addShaderUniform(s[_]);
            for (this._customUniformParamsMap.length = o.length, _ = 0, h = o.length; _ &lt; h; _++) {
                var f = o[_];
                this._customUniformParamsMap[f.dataOffset] = f
            }
            var T = this._shaderPass._stateMap;
            for (var E in T) this._stateParamsMap[T[E]] = he.propertyNameToID(E)
        }
        _getRenderState(e, t) {
            var r = this._stateParamsMap[t];
            return null == r ? null : e[r]
        }
        _disposeResource() {
            t.LayaGL.instance.deleteShader(this._vshader), t.LayaGL.instance.deleteShader(this._pshader), t.LayaGL.instance.deleteProgram(this._program), this._vshader = this._pshader = this._program = null, this._setGPUMemory(0), this._curActTexIndex = 0
        }
        _addShaderUnifiormFun(e) {
            var r = t.LayaGL.instance;
            e.caller = this;
            var i = e.isArray;
            switch (e.type) {
                case r.BOOL:
                    e.fun = this._uniform1i, e.uploadedValue = new Array(1);
                    break;
                case r.INT:
                    e.fun = i ? this._uniform1iv : this._uniform1i, e.uploadedValue = new Array(1);
                    break;
                case r.FLOAT:
                    e.fun = i ? this._uniform1fv : this._uniform1f, e.uploadedValue = new Array(1);
                    break;
                case r.FLOAT_VEC2:
                    e.fun = i ? this._uniform_vec2v : this._uniform_vec2, e.uploadedValue = new Array(2);
                    break;
                case r.FLOAT_VEC3:
                    e.fun = i ? this._uniform_vec3v : this._uniform_vec3, e.uploadedValue = new Array(3);
                    break;
                case r.FLOAT_VEC4:
                    e.fun = i ? this._uniform_vec4v : this._uniform_vec4, e.uploadedValue = new Array(4);
                    break;
                case r.FLOAT_MAT2:
                    e.fun = this._uniformMatrix2fv;
                    break;
                case r.FLOAT_MAT3:
                    e.fun = this._uniformMatrix3fv;
                    break;
                case r.FLOAT_MAT4:
                    e.fun = i ? this._uniformMatrix4fv : this._uniformMatrix4f;
                    break;
                case r.SAMPLER_2D:
                case r.SAMPLER_2D_SHADOW:
                    r.uniform1i(e.location, this._curActTexIndex), e.textureID = t.WebGLContext._glTextureIDs[this._curActTexIndex++], e.fun = this._uniform_sampler2D;
                    break;
                case 35679:
                    r.uniform1i(e.location, this._curActTexIndex), e.textureID = t.WebGLContext._glTextureIDs[this._curActTexIndex++], e.fun = this._uniform_sampler3D;
                    break;
                case r.SAMPLER_CUBE:
                    r.uniform1i(e.location, this._curActTexIndex), e.textureID = t.WebGLContext._glTextureIDs[this._curActTexIndex++], e.fun = this._uniform_samplerCube;
                    break;
                default:
                    throw new Error("compile shader err!")
            }
        }
        _createShader(e, t, r) {
            var i = e.createShader(r);
            if (e.shaderSource(i, t), e.compileShader(i), he.debugMode &amp;&amp; !e.getShaderParameter(i, e.COMPILE_STATUS)) throw e.getShaderInfoLog(i);
            return i
        }
        _uniform1f(e, r) {
            var i = e.uploadedValue;
            return i[0] !== r ? (t.LayaGL.instance.uniform1f(e.location, i[0] = r), 1) : 0
        }
        _uniform1fv(e, r) {
            if (r.length &lt; 4) {
                var i = e.uploadedValue;
                return i[0] !== r[0] || i[1] !== r[1] || i[2] !== r[2] || i[3] !== r[3] ? (t.LayaGL.instance.uniform1fv(e.location, r), i[0] = r[0], i[1] = r[1], i[2] = r[2], i[3] = r[3], 1) : 0
            }
            return t.LayaGL.instance.uniform1fv(e.location, r), 1
        }
        _uniform_vec2(e, r) {
            var i = e.uploadedValue;
            return i[0] !== r.x || i[1] !== r.y ? (t.LayaGL.instance.uniform2f(e.location, i[0] = r.x, i[1] = r.y), 1) : 0
        }
        _uniform_vec2v(e, r) {
            if (r.length &lt; 2) {
                var i = e.uploadedValue;
                return i[0] !== r[0] || i[1] !== r[1] || i[2] !== r[2] || i[3] !== r[3] ? (t.LayaGL.instance.uniform2fv(e.location, r), i[0] = r[0], i[1] = r[1], i[2] = r[2], i[3] = r[3], 1) : 0
            }
            return t.LayaGL.instance.uniform2fv(e.location, r), 1
        }
        _uniform_vec3(e, r) {
            var i = e.uploadedValue;
            return i[0] !== r.x || i[1] !== r.y || i[2] !== r.z ? (t.LayaGL.instance.uniform3f(e.location, i[0] = r.x, i[1] = r.y, i[2] = r.z), 1) : 0
        }
        _uniform_vec3v(e, r) {
            return t.LayaGL.instance.uniform3fv(e.location, r), 1
        }
        _uniform_vec4(e, r) {
            var i = e.uploadedValue;
            return i[0] !== r.x || i[1] !== r.y || i[2] !== r.z || i[3] !== r.w ? (t.LayaGL.instance.uniform4f(e.location, i[0] = r.x, i[1] = r.y, i[2] = r.z, i[3] = r.w), 1) : 0
        }
        _uniform_vec4v(e, r) {
            return t.LayaGL.instance.uniform4fv(e.location, r), 1
        }
        _uniformMatrix2fv(e, r) {
            return t.LayaGL.instance.uniformMatrix2fv(e.location, !1, r), 1
        }
        _uniformMatrix3fv(e, r) {
            return t.LayaGL.instance.uniformMatrix3fv(e.location, !1, r), 1
        }
        _uniformMatrix4f(e, r) {
            var i = r.elements;
            return t.LayaGL.instance.uniformMatrix4fv(e.location, !1, i), 1
        }
        _uniformMatrix4fv(e, r) {
            return t.LayaGL.instance.uniformMatrix4fv(e.location, !1, r), 1
        }
        _uniform1i(e, r) {
            var i = e.uploadedValue;
            return i[0] !== r ? (t.LayaGL.instance.uniform1i(e.location, i[0] = r), 1) : 0
        }
        _uniform1iv(e, r) {
            return t.LayaGL.instance.uniform1iv(e.location, r), 1
        }
        _uniform_ivec2(e, r) {
            var i = e.uploadedValue;
            return i[0] !== r[0] || i[1] !== r[1] ? (t.LayaGL.instance.uniform2i(e.location, i[0] = r[0], i[1] = r[1]), 1) : 0
        }
        _uniform_ivec2v(e, r) {
            return t.LayaGL.instance.uniform2iv(e.location, r), 1
        }
        _uniform_vec3i(e, r) {
            var i = e.uploadedValue;
            return i[0] !== r[0] || i[1] !== r[1] || i[2] !== r[2] ? (t.LayaGL.instance.uniform3i(e.location, i[0] = r[0], i[1] = r[1], i[2] = r[2]), 1) : 0
        }
        _uniform_vec3vi(e, r) {
            return t.LayaGL.instance.uniform3iv(e.location, r), 1
        }
        _uniform_vec4i(e, r) {
            var i = e.uploadedValue;
            return i[0] !== r[0] || i[1] !== r[1] || i[2] !== r[2] || i[3] !== r[3] ? (t.LayaGL.instance.uniform4i(e.location, i[0] = r[0], i[1] = r[1], i[2] = r[2], i[3] = r[3]), 1) : 0
        }
        _uniform_vec4vi(e, r) {
            return t.LayaGL.instance.uniform4iv(e.location, r), 1
        }
        _uniform_sampler2D(e, r) {
            var i = r._getSource() || r.defaulteTexture._getSource(),
                n = t.LayaGL.instance;
            return t.WebGLContext.activeTexture(n, e.textureID), t.WebGLContext.bindTexture(n, n.TEXTURE_2D, i), 0
        }
        _uniform_sampler3D(e, r) {
            var i = r._getSource() || r.defaulteTexture._getSource(),
                n = t.LayaGL.instance;
            return t.WebGLContext.activeTexture(n, e.textureID), t.WebGLContext.bindTexture(n, WebGL2RenderingContext.TEXTURE_3D, i), 0
        }
        _uniform_samplerCube(e, r) {
            var i = r._getSource() || r.defaulteTexture._getSource(),
                n = t.LayaGL.instance;
            return t.WebGLContext.activeTexture(n, e.textureID), t.WebGLContext.bindTexture(n, n.TEXTURE_CUBE_MAP, i), 0
        }
        bind() {
            return t.WebGLContext.useProgram(t.LayaGL.instance, this._program)
        }
        uploadUniforms(e, r, i) {
            t.Stat.shaderCall += t.LayaGLRunner.uploadShaderUniforms(t.LayaGL.instance, e, r, i)
        }
        uploadRenderStateBlendDepth(e) {
            var r = t.LayaGL.instance,
                i = this._shaderPass.renderState,
                n = e.getData(),
                a = this._getRenderState(n, he.RENDER_STATE_DEPTH_WRITE),
                s = this._getRenderState(n, he.RENDER_STATE_DEPTH_TEST),
                o = this._getRenderState(n, he.RENDER_STATE_BLEND);
            switch (null == a &amp;&amp; (a = i.depthWrite), null == s &amp;&amp; (s = i.depthTest), null == o &amp;&amp; (o = i.blend), t.WebGLContext.setDepthMask(r, a), s === pe.DEPTHTEST_OFF ? t.WebGLContext.setDepthTest(r, !1) : (t.WebGLContext.setDepthTest(r, !0), t.WebGLContext.setDepthFunc(r, s)), o) {
                case pe.BLEND_DISABLE:
                    t.WebGLContext.setBlend(r, !1);
                    break;
                case pe.BLEND_ENABLE_ALL:
                    var l = this._getRenderState(n, he.RENDER_STATE_BLEND_EQUATION),
                        _ = this._getRenderState(n, he.RENDER_STATE_BLEND_SRC),
                        h = this._getRenderState(n, he.RENDER_STATE_BLEND_DST);
                    null == l &amp;&amp; (l = i.blendEquation), null == _ &amp;&amp; (_ = i.srcBlend), null == h &amp;&amp; (h = i.dstBlend), t.WebGLContext.setBlend(r, !0), t.WebGLContext.setBlendEquation(r, l), t.WebGLContext.setBlendFunc(r, _, h);
                    break;
                case pe.BLEND_ENABLE_SEPERATE:
                    var c = this._getRenderState(n, he.RENDER_STATE_BLEND_EQUATION_RGB),
                        d = this._getRenderState(n, he.RENDER_STATE_BLEND_EQUATION_ALPHA),
                        u = this._getRenderState(n, he.RENDER_STATE_BLEND_SRC_RGB),
                        m = this._getRenderState(n, he.RENDER_STATE_BLEND_DST_RGB),
                        f = this._getRenderState(n, he.RENDER_STATE_BLEND_SRC_ALPHA),
                        T = this._getRenderState(n, he.RENDER_STATE_BLEND_DST_ALPHA);
                    null == c &amp;&amp; (c = i.blendEquationRGB), null == d &amp;&amp; (d = i.blendEquationAlpha), null == u &amp;&amp; (u = i.srcBlendRGB), null == m &amp;&amp; (m = i.dstBlendRGB), null == f &amp;&amp; (f = i.srcBlendAlpha), null == T &amp;&amp; (T = i.dstBlendAlpha), t.WebGLContext.setBlend(r, !0), t.WebGLContext.setBlendEquationSeparate(r, c, d), t.WebGLContext.setBlendFuncSeperate(r, u, m, f, T)
            }
        }
        uploadRenderStateFrontFace(e, r, i) {
            var n, a = t.LayaGL.instance,
                s = this._shaderPass.renderState,
                o = e.getData(),
                l = this._getRenderState(o, he.RENDER_STATE_CULL);
            switch (null == l &amp;&amp; (l = s.cull), l) {
                case pe.CULL_NONE:
                    t.WebGLContext.setCullFace(a, !1);
                    break;
                case pe.CULL_FRONT:
                    t.WebGLContext.setCullFace(a, !0), n = r ? i ? a.CCW : a.CW : i ? a.CW : a.CCW, t.WebGLContext.setFrontFace(a, n);
                    break;
                case pe.CULL_BACK:
                    t.WebGLContext.setCullFace(a, !0), n = r ? i ? a.CW : a.CCW : i ? a.CCW : a.CW, t.WebGLContext.setFrontFace(a, n)
            }
        }
        uploadCustomUniform(e, r) {
            t.Stat.shaderCall += t.LayaGLRunner.uploadCustomUniform(t.LayaGL.instance, this._customUniformParamsMap, e, r)
        }
        _uniformMatrix2fvForNative(e, r) {
            return t.LayaGL.instance.uniformMatrix2fvEx(e.location, !1, r), 1
        }
        _uniformMatrix3fvForNative(e, r) {
            return t.LayaGL.instance.uniformMatrix3fvEx(e.location, !1, r), 1
        }
        _uniformMatrix4fvForNative(e, r) {
            return t.LayaGL.instance.uniformMatrix4fvEx(e.location, !1, r), 1
        }
    }
    class Ge extends I {
        constructor() {
            super()
        }
        add(e) {
            if (-1 !== e._getIndexInList()) throw "SimpleSingletonList:" + e + " has  in  SingletonList.";
            this._add(e), e._setIndexInList(this.length++)
        }
        remove(e) {
            var t = e._getIndexInList();
            if (this.length--, t !== this.length) {
                var r = this.elements[this.length];
                this.elements[t] = r, r._setIndexInList(t)
            }
            e._setIndexInList(-1)
        }
        clear() {
            for (var e = this.elements, t = 0, r = this.length; t &lt; r; t++) e[t]._setIndexInList(-1);
            this.length = 0
        }
    }
    class ze {
        constructor(e = 1, t = 1, r = 1, i = 1) {
            this.r = e, this.g = t, this.b = r, this.a = i
        }
        static gammaToLinearSpace(e) {
            return e &lt;= .04045 ? e / 12.92 : e &lt; 1 ? Math.pow((e + .055) / 1.055, 2.4) : Math.pow(e, 2.4)
        }
        static linearToGammaSpace(e) {
            return e &lt;= 0 ? 0 : e &lt;= .0031308 ? 12.92 * e : e &lt;= 1 ? 1.055 * Math.pow(e, .41666) - .055 : Math.pow(e, .41666)
        }
        toLinear(e) {
            e.r = ze.gammaToLinearSpace(this.r), e.g = ze.gammaToLinearSpace(this.g), e.b = ze.gammaToLinearSpace(this.b)
        }
        toGamma(e) {
            e.r = ze.linearToGammaSpace(this.r), e.g = ze.linearToGammaSpace(this.g), e.b = ze.linearToGammaSpace(this.b)
        }
        cloneTo(e) {
            var t = e;
            t.r = this.r, t.g = this.g, t.b = this.b, t.a = this.a
        }
        clone() {
            var e = new ze;
            return this.cloneTo(e), e
        }
        forNativeElement() {}
    }
    ze.RED = new ze(1, 0, 0, 1), ze.GREEN = new ze(0, 1, 0, 1), ze.BLUE = new ze(0, 0, 1, 1), ze.CYAN = new ze(0, 1, 1, 1), ze.YELLOW = new ze(1, .92, .016, 1), ze.MAGENTA = new ze(1, 0, 1, 1), ze.GRAY = new ze(.5, .5, .5, 1), ze.WHITE = new ze(1, 1, 1, 1), ze.BLACK = new ze(0, 0, 0, 1);
    class He {}
    class We {}
    class ke {
        static __init__() {
            t.Render.supportWebGLPlusCulling &amp;&amp; (ke._cullingBufferLength = 0, ke._cullingBuffer = new Float32Array(4096))
        }
        static _drawTraversalCullingBound(e, t) {
            for (var r = e.elements, i = 0, n = e.length; i &lt; n; i++) {
                var a = ke._tempColor0;
                a.r = 0, a.g = 1, a.b = 0, a.a = 1, N._drawBound(t, r[i].bounds._getBoundBox(), a)
            }
        }
        static _traversalCulling(e, r, i, n, s, o, l) {
            for (var _ = n.elements, h = e.boundFrustum, c = e.position, d = e.cullingMask, u = t.Stat.loopCount, m = 0, f = n.length; m &lt; f; m++) {
                var T = _[m];
                if ((l ? T._castShadow &amp;&amp; T._enable : 0 != (Math.pow(2, T._owner._layer) &amp; d) &amp;&amp; T._enable) &amp;&amp; (t.Stat.frustumCulling++, !e.useOcclusionCulling || T._needRender(h, i))) {
                    T._renderMark = u, T._distanceForSort = a.distance(T.bounds.getCenter(), c);
                    for (var E = T._renderElements, p = 0, g = E.length; p &lt; g; p++) E[p]._update(r, i, s, o)
                }
            }
        }
        static renderObjectCulling(e, t, r, i, n, a) {
            var s = t._opaqueQueue,
                o = t._transparentQueue,
                l = t._renders;
            t._clearRenderQueue();
            var _ = t._octree;
            if (_ &amp;&amp; (_.updateMotionObjects(), _.shrinkRootIfPossible(), _.getCollidingWithFrustum(e, r, i, n, a)), ke._traversalCulling(e, t, r, l, i, n, a), ke.debugFrustumCulling) {
                var h = t._debugTool;
                h.clear(), _ &amp;&amp; (_.drawAllBounds(h), _.drawAllObjects(h)), ke._drawTraversalCullingBound(l, h)
            }
            var c = s.elements.length;
            c &gt; 0 &amp;&amp; s._quickSort(0, c - 1), (c = o.elements.length) &gt; 0 &amp;&amp; o._quickSort(0, c - 1)
        }
        static cullingShadow(e, r, i) {
            var n = r._renders;
            r._clearRenderQueue();
            for (var s = r._opaqueQueue, o = e.position, l = e.cullPlaneCount, _ = e.cullPlanes, h = (e.cullSphere, e.direction, n.elements), c = t.Stat.loopCount, d = 0, u = n.length; d &lt; u; d++) {
                var m = h[d];
                if (m._castShadow &amp;&amp; m._enable) {
                    t.Stat.frustumCulling++;
                    for (var f = m.bounds, T = f.getMin(), E = f.getMax(), p = T.x, g = T.y, S = T.z, R = E.x, v = E.y, A = E.z, I = !0, x = 0; x &lt; l; x++) {
                        var L = _[x],
                            D = L.normal;
                        if (L.distance + D.x * (D.x &lt; 0 ? p : R) + D.y * (D.y &lt; 0 ? g : v) + D.z * (D.z &lt; 0 ? S : A) &lt; 0) {
                            I = !1;
                            break
                        }
                    }
                    if (I) {
                        m._renderMark = c, m._distanceForSort = a.distance(f.getCenter(), o);
                        for (var C = m._renderElements, y = (x = 0, C.length); x &lt; y; x++) C[x]._update(r, i, null, null)
                    }
                }
            }
            return s.elements.length &gt; 0
        }
        static cullingSpotShadow(e, r, i) {
            var n = r._renders;
            r._clearRenderQueue();
            for (var s = r._opaqueQueue, o = n.elements, l = t.Stat.loopCount, _ = 0, h = n.length; _ &lt; h; _++) {
                var c = o[_];
                if (c._castShadow &amp;&amp; c._enable &amp;&amp; c._needRender(e.boundFrustum, i)) {
                    var d = c.bounds;
                    c._renderMark = l, c._distanceForSort = a.distance(d.getCenter(), e.position);
                    for (var u = c._renderElements, m = 0, f = u.length; m &lt; f; m++) u[m]._update(r, i, null, null)
                }
            }
            return s.elements.length &gt; 0
        }
        static renderObjectCullingNative(e, r, i, n, s, o) {
            var l, _, h, c = r._opaqueQueue,
                d = r._transparentQueue;
            r._clearRenderQueue();
            var u = n.length,
                m = n.elements;
            for (l = 0; l &lt; u; l++) m[l].bounds, m[l]._updateForNative &amp;&amp; m[l]._updateForNative(i);
            e.boundFrustum;
            ke.cullingNative(e._boundFrustumBuffer, ke._cullingBuffer, r._cullingBufferIndices, u, r._cullingBufferResult);
            var f = t.Stat.loopCount,
                T = i.camera._transform.position;
            for (l = 0; l &lt; u; l++) {
                var E = m[l];
                if (!e.useOcclusionCulling || e._isLayerVisible(E._owner._layer) &amp;&amp; E._enable &amp;&amp; r._cullingBufferResult[l]) {
                    E._renderMark = f, E._distanceForSort = a.distance(E.bounds.getCenter(), T);
                    var p = E._renderElements;
                    for (_ = 0, h = p.length; _ &lt; h; _++) {
                        p[_]._update(r, i, s, o)
                    }
                }
            }
            var g = c.elements.length;
            g &gt; 0 &amp;&amp; c._quickSort(0, g - 1), (g = d.elements.length) &gt; 0 &amp;&amp; d._quickSort(0, g - 1)
        }
        static cullingNative(e, r, i, n, a) {
            return t.LayaGL.instance.culling(e, r, i, n, a)
        }
    }
    ke._tempColor0 = new ze, ke._tempVector0 = new a, ke._cameraCullInfo = new He, ke._shadowCullInfo = new We, ke.debugFrustumCulling = !1;
    class Xe {
        constructor() {
            this.updateMark = -1, this.pointLightCount = 0, this.spotLightCount = 0, this.indices = []
        }
    }
    class Ye {
        constructor(e, t, r, n) {
            this._updateMark = 0, this._depthSliceParam = new i, this._xSlices = e, this._ySlices = t, this._zSlices = r;
            var a = e * t,
                s = r * (1 + Math.ceil(n / 4));
            this._clusterTexture = N._createFloatTextureBuffer(a, s), this._clusterTexture.lock = !0, this._clusterPixels = new Float32Array(a * s * 4);
            for (var o = new Array(this._zSlices), l = 0; l &lt; this._zSlices; l++) {
                o[l] = new Array(this._ySlices);
                for (var _ = 0; _ &lt; this._ySlices; _++) {
                    o[l][_] = new Array(this._xSlices);
                    for (var h = 0; h &lt; this._xSlices; h++) o[l][_][h] = new Xe
                }
            }
            this._clusterDatas = o
        }
        _insertSpotLightSphere(e, t, r, i, n) {
            var s = Ye._tempVector35;
            s.x = n.x - e.x, s.y = n.y - e.y, s.z = n.z - e.z;
            var o = a.dot(s, s),
                l = n.w;
            if (!(o &gt; l * l)) return !1;
            var _ = a.dot(s, t);
            return !(Math.cos(i) * Math.sqrt(o - _ * _) - _ * Math.sin(i) &gt; l || _ &gt; l + r || _ &lt; -l)
        }
        _placePointLightToClusters(e, t) {
            for (var r = this._clusterDatas, i = this._updateMark, n = t.zMin, a = t.zMax; n &lt; a; n++)
                for (var s = t.yMin, o = t.yMax; s &lt; o; s++)
                    for (var l = t.xMin, _ = t.xMax; l &lt; _; l++) {
                        var h = r[n][s][l];
                        h.updateMark != i &amp;&amp; (h.pointLightCount = 0, h.spotLightCount = 0, h.updateMark = i);
                        var c = h.indices,
                            d = h.pointLightCount++;
                        d &lt; c.length ? c[d] = e : c.push(e)
                    }
        }
        _placeSpotLightToClusters(e, t) {
            for (var r = this._clusterDatas, i = this._updateMark, n = t.zMin, a = t.zMax; n &lt; a; n++)
                for (var s = t.yMin, o = t.yMax; s &lt; o; s++)
                    for (var l = t.xMin, _ = t.xMax; l &lt; _; l++) {
                        var h = r[n][s][l];
                        h.updateMark != i &amp;&amp; (h.pointLightCount = 0, h.spotLightCount = 0, h.updateMark = i);
                        var c = h.indices,
                            d = h.pointLightCount + h.spotLightCount++;
                        d &lt; c.length ? c[d] = e : c.push(e)
                    }
        }
        _insertConePlane(e, t, r, i, n) {
            var s = Ye._tempVector36,
                o = Ye._tempVector37;
            a.cross(n, t, s), a.cross(s, t, o), a.normalize(o, o);
            var l = r * Math.tan(i),
                _ = e.x + r * t.x + l * o.x,
                h = e.y + r * t.y + l * o.y,
                c = e.z + r * t.z + l * o.z;
            return _ * n.x + h * n.y + c * n.z &lt;= 0 || e.x * n.x + e.y * n.y + e.z * n.z &lt;= 0
        }
        _shrinkSphereLightZPerspective(e, t, r, i, n) {
            var a = r.z,
                s = a - i,
                o = a + i;
            if (s &gt; t || o &lt;= e) return !1;
            var l = this._depthSliceParam;
            return n.zMin = Math.floor(Math.log2(Math.max(s, e)) * l.x - l.y), n.zMax = Math.min(Math.ceil(Math.log2(o) * l.x - l.y), this._zSlices), !0
        }
        _shrinkSpotLightZPerspective(e, t, r, i, n, a, s) {
            var o = i.x,
                l = i.y,
                _ = i.z,
                h = Math.tan(a) * n,
                c = r.x,
                d = r.y,
                u = r.z,
                m = o - c,
                f = l - d,
                T = _ - u,
                E = m * m + f * f + T * T,
                p = Math.sqrt(1 - T * T / E),
                g = Math.max(Math.min(u, _ - p * h), r.z - n),
                S = Math.min(Math.max(u, _ + p * h), r.z + n);
            if (g &gt; t || S &lt;= e) return !1;
            var R = this._depthSliceParam;
            return s.zMin = Math.floor(Math.log2(Math.max(g, e)) * R.x - R.y), s.zMax = Math.min(Math.ceil(Math.log2(S) * R.x - R.y), this._zSlices), !0
        }
        _shrinkSphereLightByBoundOrth(e, t, r, i, n, a, s) {
            var o = n.z,
                l = o - a,
                _ = o + a;
            if (l &gt; i || _ &lt;= r) return !1;
            var h = n.x,
                c = h - a,
                d = h + a;
            if (c &gt; e || d &lt;= -e) return !1;
            var u = n.y,
                m = u - a,
                f = u + a;
            if (m &gt; t || f &lt;= -t) return !1;
            var T = this._xSlices,
                E = this._ySlices,
                p = this._depthSliceParam,
                g = 2 * e / T,
                S = 2 * t / E;
            return s.xMin = Math.max(Math.floor((c + e) / g), 0), s.xMax = Math.min(Math.ceil((d + e) / g), T), s.yMin = Math.max(Math.floor((t - f) / S), 0), s.yMax = Math.min(Math.ceil((t - m) / S), E), s.zMin = Math.floor(Math.log2(Math.max(l, r)) * p.x - p.y), s.zMax = Math.min(Math.ceil(Math.log2(_) * p.x - p.y), this._zSlices), !0
        }
        _shrinkSpotLightByBoundOrth(e, t, r, i, n, a, s, o, l) {
            var _ = a.x,
                h = a.y,
                c = a.z,
                d = Math.tan(o) * s,
                u = n.x,
                m = n.y,
                f = n.z,
                T = _ - u,
                E = h - m,
                p = c - f,
                g = T * T + E * E + p * p,
                S = Math.sqrt(1 - p * p / g),
                R = Math.max(Math.min(f, c - S * d), n.z - s),
                v = Math.min(Math.max(f, c + S * d), n.z + s);
            if (R &gt; i || v &lt;= r) return !1;
            var A = Math.sqrt(1 - T * T / g),
                I = Math.max(Math.min(u, _ - A * d), n.x - s),
                x = Math.min(Math.max(u, _ + A * d), n.x + s);
            if (I &gt; e || x &lt;= -e) return !1;
            var L = Math.sqrt(1 - E * E / g),
                D = Math.max(Math.min(m, h - L * d), n.y - s),
                C = Math.min(Math.max(m, h + L * d), n.y + s);
            if (D &gt; t || C &lt;= -t) return !1;
            var y = this._xSlices,
                M = this._ySlices,
                O = this._depthSliceParam,
                N = 2 * e / y,
                b = 2 * t / M;
            return l.xMin = Math.max(Math.floor((I + e) / N), 0), l.xMax = Math.min(Math.ceil((x + e) / N), y), l.yMin = Math.max(Math.floor((t - C) / b), 0), l.yMax = Math.min(Math.ceil((t - D) / b), M), l.zMin = Math.floor(Math.log2(Math.max(R, r)) * O.x - O.y), l.zMax = Math.min(Math.ceil(Math.log2(v) * O.x - O.y), this._zSlices), !0
        }
        _shrinkXYByRadiusPerspective(e, t, r, i, n) {
            var a, s, o, l, _, h = e.x,
                c = e.y,
                d = e.z,
                u = this._ySlices + 1;
            for (_ = 0; _ &lt; u; _++) {
                if (c * (m = n[_]).y + d * m.z &lt; t) {
                    s = Math.max(0, _ - 1);
                    break
                }
            }
            if (_ == u) return !1;
            for (l = this._ySlices, _ = s + 1; _ &lt; u; _++) {
                if (c * (m = n[_]).y + d * m.z &lt;= -t) {
                    l = Math.max(0, _);
                    break
                }
            }
            for (u = this._xSlices + 1, _ = 0; _ &lt; u; _++) {
                if (h * (m = i[_]).x + d * m.z &lt; t) {
                    a = Math.max(0, _ - 1);
                    break
                }
            }
            for (o = this._xSlices, _ = a + 1; _ &lt; u; _++) {
                var m;
                if (h * (m = i[_]).x + d * m.z &lt;= -t) {
                    o = Math.max(0, _);
                    break
                }
            }
            return r.xMin = a, r.xMax = o, r.yMin = s, r.yMax = l, !0
        }
        _shrinkSpotXYByConePerspective(e, t, r, i, n, a, s) {
            for (var o, l, _, h, c = Ye._tempVector32, d = n.yMax + 1, u = n.yMin + 1; u &lt; d; u++)
                if (this._insertConePlane(e, t, r, i, s[u])) {
                    l = Math.max(0, u - 1);
                    break
                }
            h = n.yMax;
            for (u = l + 1; u &lt; d; u++) {
                var m = s[u];
                if (c.setValue(0, -m.y, -m.z), !this._insertConePlane(e, t, r, i, c)) {
                    h = Math.max(0, u);
                    break
                }
            }
            d = n.xMax + 1;
            for (u = n.xMin + 1; u &lt; d; u++)
                if (this._insertConePlane(e, t, r, i, a[u])) {
                    o = Math.max(0, u - 1);
                    break
                }
            _ = n.xMax;
            for (u = o + 1; u &lt; d; u++) {
                m = a[u];
                if (c.setValue(-m.x, 0, -m.z), !this._insertConePlane(e, t, r, i, c)) {
                    _ = Math.max(0, u);
                    break
                }
            }
            n.xMin = o, n.xMax = _, n.yMin = l, n.yMax = h
        }
        _updatePointLightPerspective(e, t, r, i, n, s, o) {
            var l = Ye._tempLightBound,
                _ = Ye._tempVector30;
            a.transformV3ToV3(i._transform.position, r, _), _.z *= -1, this._shrinkSphereLightZPerspective(e, t, _, i.range, l) &amp;&amp; this._shrinkXYByRadiusPerspective(_, i.range, l, s, o) &amp;&amp; this._placePointLightToClusters(n, l)
        }
        _updateSpotLightPerspective(e, t, r, i, n, s, o) {
            var l = Ye._tempLightBound,
                _ = Ye._tempVector30,
                h = Ye._tempVector31,
                c = Ye._tempVector34,
                d = i._transform.position,
                u = i.range;
            i._transform.worldMatrix.getForward(h), a.normalize(h, h), a.scale(h, u, c), a.add(d, c, c), a.transformV3ToV3(d, r, _), a.transformV3ToV3(c, r, c), _.z *= -1, c.z *= -1;
            var m = i.spotAngle / 2 * Math.PI / 180;
            if (this._shrinkSpotLightZPerspective(e, t, _, c, u, m, l) &amp;&amp; this._shrinkXYByRadiusPerspective(_, u, l, s, o)) {
                var f = Ye._tempVector33;
                f.x = c.x - _.x, f.y = c.y - _.y, f.z = c.z - _.z, a.normalize(f, f), this._shrinkSpotXYByConePerspective(_, f, u, m, l, s, o), this._placeSpotLightToClusters(n, l)
            }
        }
        _updatePointLightOrth(e, t, r, i, n, s, o) {
            var l = Ye._tempLightBound,
                _ = Ye._tempVector30;
            a.transformV3ToV3(s._transform.position, n, _), _.z *= -1, this._shrinkSphereLightByBoundOrth(e, t, r, i, _, s.range, l) &amp;&amp; this._placePointLightToClusters(o, l)
        }
        _updateSpotLightOrth(e, t, r, i, n, s, o) {
            var l = Ye._tempLightBound,
                _ = Ye._tempVector30,
                h = Ye._tempVector31,
                c = Ye._tempVector34,
                d = s._transform.position,
                u = s.range;
            s._transform.worldMatrix.getForward(h), a.normalize(h, h), a.scale(h, u, c), a.add(d, c, c), a.transformV3ToV3(d, n, _), a.transformV3ToV3(c, n, c), _.z *= -1, c.z *= -1;
            var m = s.spotAngle / 2 * Math.PI / 180;
            this._shrinkSpotLightByBoundOrth(e, t, r, i, _, c, u, m, l) &amp;&amp; this._placeSpotLightToClusters(o, l)
        }
        update(e, t) {
            this._updateMark++;
            var r = e.nearPlane;
            this._depthSliceParam.x = B._config.lightClusterCount.z / Math.log2(e.farPlane / r), this._depthSliceParam.y = Math.log2(r) * this._depthSliceParam.x;
            var i = e.nearPlane,
                n = e.farPlane,
                a = e.viewMatrix,
                s = t._directionLights._length,
                o = t._pointLights,
                l = o._length,
                _ = o._elements,
                h = t._spotLights,
                c = h._length,
                d = h._elements;
            if (e.orthographic) {
                for (var u = e.orthographicVerticalSize / 2, m = u * e.aspectRatio, f = 0; f &lt; l; f++, s++) this._updatePointLightOrth(m, u, i, n, a, _[f], s);
                for (f = 0; f &lt; c; f++, s++) this._updateSpotLightOrth(m, u, i, n, a, d[f], s)
            } else {
                e._updateClusterPlaneXY();
                var T = e._clusterXPlanes,
                    E = e._clusterYPlanes;
                for (f = 0; f &lt; l; f++, s++) this._updatePointLightPerspective(i, n, a, _[f], s, T, E);
                for (f = 0; f &lt; c; f++, s++) this._updateSpotLightPerspective(i, n, a, d[f], s, T, E)
            }
            if (l + c &gt; 0) {
                for (var p = this._xSlices, g = this._ySlices, S = this._zSlices, R = p * g * 4, v = R * S, A = this._clusterPixels, I = A.length, x = this._clusterDatas, L = this._updateMark, D = !0, C = 0; C &lt; S; C++)
                    for (var y = 0; y &lt; g; y++)
                        for (var M = 0; M &lt; p; M++) {
                            var O = x[C][y][M],
                                N = 4 * (M + y * p + C * p * g);
                            if (O.updateMark !== L) A[N] = 0, A[N + 1] = 0;
                            else if (D) {
                                var b = O.indices,
                                    P = O.pointLightCount,
                                    w = O.spotLightCount,
                                    V = P + w;
                                if (v + V &lt; I) {
                                    A[N] = P, A[N + 1] = w, A[N + 2] = Math.floor(v / R), A[N + 3] = v % R;
                                    for (f = 0; f &lt; V; f++) A[v++] = b[f]
                                } else {
                                    V = I - (v + V), P = Math.min(P, V), A[N] = P, A[N + 1] = Math.min(w, V - P), A[N + 2] = Math.floor(v / R), A[N + 3] = v % R;
                                    for (f = 0; f &lt; V; f++) A[v++] = b[f];
                                    D = !1
                                }
                            }
                        }
                var F = this._clusterTexture.width;
                this._clusterTexture.setSubPixels(0, 0, F, Math.ceil(v / (4 * F)), A)
            }
        }
    }
    Ye._tempVector30 = new a, Ye._tempVector31 = new a, Ye._tempVector32 = new a, Ye._tempVector33 = new a, Ye._tempVector34 = new a, Ye._tempVector35 = new a, Ye._tempVector36 = new a, Ye._tempVector37 = new a, Ye._tempLightBound = new class {};
    class je {
        constructor() {
            this._coefficients = new Float32Array(27)
        }
        getCoefficient(e, t) {
            return this._coefficients[9 * e + t]
        }
        setCoefficient(e, t, r) {
            this._coefficients[9 * e + t] = r
        }
        setCoefficients(e, t, r, i, n, a, s, o, l, _) {
            var h = 9 * e;
            this._coefficients[h] = t, this._coefficients[++h] = r, this._coefficients[++h] = i, this._coefficients[++h] = n, this._coefficients[++h] = a, this._coefficients[++h] = s, this._coefficients[++h] = o, this._coefficients[++h] = l, this._coefficients[++h] = _
        }
        cloneTo(e) {
            if (this !== e)
                for (var t = this._coefficients, r = e._coefficients, i = 0; i &lt; 27; i++) r[i] = t[i]
        }
    }
    je._default = new je;
    class Ze {
        constructor() {
            this._pressedSprite = null, this._pressedLoopCount = -1, this.sprite = null, this.mousePositionX = 0, this.mousePositionY = 0
        }
    }
    class qe {
        constructor() {
            this._indexInList = -1, this._identifier = -1, this._position = new i
        }
        get identifier() {
            return this._identifier
        }
        get position() {
            return this._position
        }
        _getIndexInList() {
            return this._indexInList
        }
        _setIndexInList(e) {
            this._indexInList = e
        }
    }
    class Qe {
        constructor(e, t = 0) {
            this.normal = e, this.distance = t
        }
        static createPlaneBy3P(e, t, r, i) {
            var n = t.x - e.x,
                a = t.y - e.y,
                s = t.z - e.z,
                o = r.x - e.x,
                l = r.y - e.y,
                _ = r.z - e.z,
                h = a * _ - s * l,
                c = s * o - n * _,
                d = n * l - a * o,
                u = 1 / Math.sqrt(h * h + c * c + d * d),
                m = h * u,
                f = c * u,
                T = d * u,
                E = i.normal;
            E.x = m, E.y = f, E.z = T, i.distance = -(m * e.x + f * e.y + T * e.z)
        }
        normalize() {
            var e = this.normal.x,
                t = this.normal.y,
                r = this.normal.z,
                i = 1 / Math.sqrt(e * e + t * t + r * r);
            this.normal.x = e * i, this.normal.y = t * i, this.normal.z = r * i, this.distance *= i
        }
        cloneTo(e) {
            var t = e;
            this.normal.cloneTo(t.normal), t.distance = this.distance
        }
        clone() {
            var e = new Qe(new a);
            return this.cloneTo(e), e
        }
    }
    Qe.PlaneIntersectionType_Back = 0, Qe.PlaneIntersectionType_Front = 1, Qe.PlaneIntersectionType_Intersecting = 2;
    class Ke {
        constructor(e, t) {
            this.origin = e, this.direction = t
        }
    }
    class Je {}
    Je.Disjoint = 0, Je.Contains = 1, Je.Intersects = 2;
    class $e {
        constructor() {}
        static distancePlaneToPoint(e, t) {
            return a.dot(e.normal, t) - e.distance
        }
        static distanceBoxToPoint(e, t) {
            var r = e.min,
                i = r.x,
                n = r.y,
                a = r.z,
                s = e.max,
                o = s.x,
                l = s.y,
                _ = s.z,
                h = t.x,
                c = t.y,
                d = t.z,
                u = 0;
            return h &lt; i &amp;&amp; (u += (i - h) * (i - h)), h &gt; o &amp;&amp; (u += (o - h) * (o - h)), c &lt; n &amp;&amp; (u += (n - c) * (n - c)), c &gt; l &amp;&amp; (u += (l - c) * (l - c)), d &lt; a &amp;&amp; (u += (a - d) * (a - d)), d &gt; _ &amp;&amp; (u += (_ - d) * (_ - d)), Math.sqrt(u)
        }
        static distanceBoxToBox(e, t) {
            var r, i = e.min,
                n = i.x,
                a = i.y,
                s = i.z,
                o = e.max,
                l = o.x,
                _ = o.y,
                h = o.z,
                c = t.min,
                d = c.x,
                u = c.y,
                m = c.z,
                f = t.max,
                T = f.x,
                E = f.y,
                p = f.z,
                g = 0;
            return n &gt; T ? g += (r = n - T) * r : d &gt; l &amp;&amp; (g += (r = d - l) * r), a &gt; E ? g += (r = a - E) * r : u &gt; _ &amp;&amp; (g += (r = u - _) * r), s &gt; p ? g += (r = s - p) * r : m &gt; h &amp;&amp; (g += (r = m - h) * r), Math.sqrt(g)
        }
        static distanceSphereToPoint(e, t) {
            var r = Math.sqrt(a.distanceSquared(e.center, t));
            return r -= e.radius, Math.max(r, 0)
        }
        static distanceSphereToSphere(e, t) {
            var r = Math.sqrt(a.distanceSquared(e.center, t.center));
            return r -= e.radius + t.radius, Math.max(r, 0)
        }
        static intersectsRayAndTriangleRD(e, t, i, n, a) {
            var s = e.origin,
                o = s.x,
                l = s.y,
                _ = s.z,
                h = e.direction,
                c = h.x,
                d = h.y,
                u = h.z,
                m = t.x,
                f = t.y,
                T = t.z,
                E = i.x,
                p = i.y,
                g = i.z,
                S = n.x,
                R = n.y,
                v = n.z,
                A = $e._tempV30.x,
                I = $e._tempV30.y,
                x = $e._tempV30.z;
            A = E - m, I = p - f, x = g - T;
            var L = $e._tempV31.x,
                D = $e._tempV31.y,
                C = $e._tempV31.z;
            L = S - m, D = R - f, C = v - T;
            var y = $e._tempV32.x,
                M = $e._tempV32.y,
                O = $e._tempV32.z,
                N = A * (y = d * C - u * D) + I * (M = u * L - c * C) + x * (O = c * D - d * L);
            if (r.isZero(N)) return !1;
            var b = 1 / N,
                P = $e._tempV33.x,
                w = $e._tempV33.y,
                V = $e._tempV33.z,
                B = (P = o - m) * y + (w = l - f) * M + (V = _ - T) * O;
            if ((B *= b) &lt; 0 || B &gt; 1) return !1;
            var F = $e._tempV34.x,
                U = $e._tempV34.y,
                G = $e._tempV34.z,
                z = c * (F = w * x - V * I) + d * (U = V * A - P * x) + u * (G = P * I - w * A);
            if ((z *= b) &lt; 0 || B + z &gt; 1) return !1;
            var H = L * F + D * U + C * G;
            return !((H *= b) &lt; 0)
        }
        static intersectsRayAndTriangleRP(e, t, r, i, n) {
            return $e.intersectsRayAndTriangleRD(e, t, r, i, void 0) ? (a.scale(e.direction, void 0, $e._tempV30), a.add(e.origin, $e._tempV30, n), !0) : (n = a._ZERO, !1)
        }
        static intersectsRayAndPoint(e, t) {
            a.subtract(e.origin, t, $e._tempV30);
            var i = a.dot($e._tempV30, e.direction),
                n = a.dot($e._tempV30, $e._tempV30) - r.zeroTolerance;
            return !(n &gt; 0 &amp;&amp; i &gt; 0) &amp;&amp; !(i * i - n &lt; 0)
        }
        static intersectsRayAndRay(e, t, i) {
            var n = e.origin,
                s = n.x,
                o = n.y,
                l = n.z,
                _ = e.direction,
                h = _.x,
                c = _.y,
                d = _.z,
                u = t.origin,
                m = u.x,
                f = u.y,
                T = u.z,
                E = t.direction,
                p = E.x,
                g = E.y,
                S = E.z;
            a.cross(_, E, $e._tempV30);
            var R = $e._tempV30,
                v = a.scalarLength($e._tempV30);
            if (r.isZero(v) &amp;&amp; r.nearEqual(m, s) &amp;&amp; r.nearEqual(f, o) &amp;&amp; r.nearEqual(T, l)) return !0;
            v *= v;
            var A = m - s,
                I = f - o,
                x = T - l,
                L = p,
                D = g,
                C = S,
                y = R.x,
                M = R.y,
                O = R.z,
                N = A * D * O + I * C * y + x * L * M - A * C * M - I * L * O - x * D * y;
            L = h, D = c, C = d;
            var b = N / v;
            a.scale(_, b, $e._tempV30), a.scale(E, b, $e._tempV31), a.add(n, $e._tempV30, $e._tempV32), a.add(u, $e._tempV31, $e._tempV33);
            var P = $e._tempV32,
                w = $e._tempV33;
            return !!(r.nearEqual(w.x, P.x) &amp;&amp; r.nearEqual(w.y, P.y) &amp;&amp; r.nearEqual(w.z, P.z))
        }
        static intersectsPlaneAndTriangle(e, t, r, i) {
            var n = $e.intersectsPlaneAndPoint(e, t),
                a = $e.intersectsPlaneAndPoint(e, r),
                s = $e.intersectsPlaneAndPoint(e, i);
            return n == Qe.PlaneIntersectionType_Front &amp;&amp; a == Qe.PlaneIntersectionType_Front &amp;&amp; s == Qe.PlaneIntersectionType_Front ? Qe.PlaneIntersectionType_Front : n == Qe.PlaneIntersectionType_Back &amp;&amp; a == Qe.PlaneIntersectionType_Back &amp;&amp; s == Qe.PlaneIntersectionType_Back ? Qe.PlaneIntersectionType_Back : Qe.PlaneIntersectionType_Intersecting
        }
        static intersectsRayAndPlaneRD(e, t) {
            var i = t.normal,
                n = a.dot(i, e.direction);
            if (Math.abs(n) &lt; r.zeroTolerance) return -1;
            var s = a.dot(i, e.origin),
                o = (-t.distance - s) / n;
            if (o &lt; 0) {
                if (o &lt; -r.zeroTolerance) return -1;
                o = 0
            }
            return o
        }
        static intersectsRayAndPlaneRP(e, t, r) {
            var i = $e.intersectsRayAndPlaneRD(e, t);
            if (-1 == i) return r.setValue(0, 0, 0), !1;
            var n = $e._tempV30;
            return a.scale(e.direction, i, n), a.add(e.origin, n, r), !0
        }
        static intersectsRayAndBoxRD(e, t) {
            var i = e.origin,
                n = i.x,
                a = i.y,
                s = i.z,
                o = e.direction,
                l = o.x,
                _ = o.y,
                h = o.z,
                c = t.min,
                d = c.x,
                u = c.y,
                m = c.z,
                f = t.max,
                T = f.x,
                E = f.y,
                p = f.z,
                g = 0,
                S = r.MaxValue;
            if (r.isZero(l)) {
                if (n &lt; d || n &gt; T) return -1
            } else {
                var R = 1 / l,
                    v = (d - n) * R,
                    A = (T - n) * R;
                if (v &gt; A) {
                    var I = v;
                    v = A, A = I
                }
                if ((g = Math.max(v, g)) &gt; (S = Math.min(A, S))) return -1
            }
            if (r.isZero(_)) {
                if (a &lt; u || a &gt; E) return -1
            } else {
                var x = 1 / _,
                    L = (u - a) * x,
                    D = (E - a) * x;
                if (L &gt; D) {
                    var C = L;
                    L = D, D = C
                }
                if ((g = Math.max(L, g)) &gt; (S = Math.min(D, S))) return -1
            }
            if (r.isZero(h)) {
                if (s &lt; m || s &gt; p) return -1
            } else {
                var y = 1 / h,
                    M = (m - s) * y,
                    O = (p - s) * y;
                if (M &gt; O) {
                    var N = M;
                    M = O, O = N
                }
                if ((g = Math.max(M, g)) &gt; (S = Math.min(O, S))) return -1
            }
            return g
        }
        static intersectsRayAndBoxRP(e, t, r) {
            var i = $e.intersectsRayAndBoxRD(e, t);
            return -1 === i ? (a._ZERO.cloneTo(r), i) : (a.scale(e.direction, i, $e._tempV30), a.add(e.origin, $e._tempV30, $e._tempV31), $e._tempV31.cloneTo(r), i)
        }
        static intersectsRayAndSphereRD(e, t) {
            var r = t.radius;
            a.subtract(e.origin, t.center, $e._tempV30);
            var i = a.dot($e._tempV30, e.direction),
                n = a.dot($e._tempV30, $e._tempV30) - r * r;
            if (n &gt; 0 &amp;&amp; i &gt; 0) return -1;
            var s = i * i - n;
            if (s &lt; 0) return -1;
            var o = -i - Math.sqrt(s);
            return o &lt; 0 &amp;&amp; (o = 0), o
        }
        static intersectsRayAndSphereRP(e, t, r) {
            var i = $e.intersectsRayAndSphereRD(e, t);
            return -1 === i ? (a._ZERO.cloneTo(r), i) : (a.scale(e.direction, i, $e._tempV30), a.add(e.origin, $e._tempV30, $e._tempV31), $e._tempV31.cloneTo(r), i)
        }
        static intersectsSphereAndTriangle(e, t, r, i) {
            var n = e.center,
                s = e.radius;
            return $e.closestPointPointTriangle(n, t, r, i, $e._tempV30), a.subtract($e._tempV30, n, $e._tempV31), a.dot($e._tempV31, $e._tempV31) &lt;= s * s
        }
        static intersectsPlaneAndPoint(e, t) {
            var r = a.dot(e.normal, t) + e.distance;
            return r &gt; 0 ? Qe.PlaneIntersectionType_Front : r &lt; 0 ? Qe.PlaneIntersectionType_Back : Qe.PlaneIntersectionType_Intersecting
        }
        static intersectsPlaneAndPlane(e, t) {
            a.cross(e.normal, t.normal, $e._tempV30);
            var i = a.dot($e._tempV30, $e._tempV30);
            return !r.isZero(i)
        }
        static intersectsPlaneAndPlaneRL(e, t, i) {
            var n = e.normal,
                s = t.normal;
            a.cross(n, s, $e._tempV34);
            var o = a.dot($e._tempV34, $e._tempV34);
            return !r.isZero(o) &amp;&amp; (a.scale(s, e.distance, $e._tempV30), a.scale(n, t.distance, $e._tempV31), a.subtract($e._tempV30, $e._tempV31, $e._tempV32), a.cross($e._tempV32, $e._tempV34, $e._tempV33), a.normalize($e._tempV34, $e._tempV34), !0)
        }
        static intersectsPlaneAndBox(e, t) {
            var r = e.distance,
                i = e.normal,
                n = i.x,
                s = i.y,
                o = i.z,
                l = t.min,
                _ = l.x,
                h = l.y,
                c = l.z,
                d = t.max,
                u = d.x,
                m = d.y,
                f = d.z;
            $e._tempV30.x = n &gt; 0 ? _ : u, $e._tempV30.y = s &gt; 0 ? h : m, $e._tempV30.z = o &gt; 0 ? c : f, $e._tempV31.x = n &gt; 0 ? u : _, $e._tempV31.y = s &gt; 0 ? m : h, $e._tempV31.z = o &gt; 0 ? f : c;
            var T = a.dot(i, $e._tempV30);
            return T + r &gt; 0 ? Qe.PlaneIntersectionType_Front : (T = a.dot(i, $e._tempV31)) + r &lt; 0 ? Qe.PlaneIntersectionType_Back : Qe.PlaneIntersectionType_Intersecting
        }
        static intersectsPlaneAndSphere(e, t) {
            var r = t.radius,
                i = a.dot(e.normal, t.center) + e.distance;
            return i &gt; r ? Qe.PlaneIntersectionType_Front : i &lt; -r ? Qe.PlaneIntersectionType_Back : Qe.PlaneIntersectionType_Intersecting
        }
        static intersectsBoxAndBox(e, t) {
            var r = e.min,
                i = e.max,
                n = t.min,
                a = t.max;
            return !(r.x &gt; a.x || n.x &gt; i.x) &amp;&amp; (!(r.y &gt; a.y || n.y &gt; i.y) &amp;&amp; !(r.z &gt; a.z || n.z &gt; i.z))
        }
        static intersectsBoxAndSphere(e, t) {
            var r = t.center,
                i = t.radius,
                n = $e._tempV30;
            return a.Clamp(r, e.min, e.max, n), a.distanceSquared(r, n) &lt;= i * i
        }
        static intersectsSphereAndSphere(e, t) {
            var r = e.radius + t.radius;
            return a.distanceSquared(e.center, t.center) &lt;= r * r
        }
        static boxContainsPoint(e, t) {
            var r = e.min,
                i = e.max;
            return r.x &lt;= t.x &amp;&amp; i.x &gt;= t.x &amp;&amp; r.y &lt;= t.y &amp;&amp; i.y &gt;= t.y &amp;&amp; r.z &lt;= t.z &amp;&amp; i.z &gt;= t.z ? Je.Contains : Je.Disjoint
        }
        static boxContainsBox(e, t) {
            var r = e.min,
                i = r.x,
                n = r.y,
                a = r.z,
                s = e.max,
                o = s.x,
                l = s.y,
                _ = s.z,
                h = t.min,
                c = h.x,
                d = h.y,
                u = h.z,
                m = t.max,
                f = m.x,
                T = m.y,
                E = m.z;
            return o &lt; c || i &gt; f ? Je.Disjoint : l &lt; d || n &gt; T ? Je.Disjoint : _ &lt; u || a &gt; E ? Je.Disjoint : i &lt;= c &amp;&amp; f &lt;= o &amp;&amp; n &lt;= d &amp;&amp; T &lt;= l &amp;&amp; a &lt;= u &amp;&amp; E &lt;= _ ? Je.Contains : Je.Intersects
        }
        static boxContainsSphere(e, t) {
            var r = e.min,
                i = r.x,
                n = r.y,
                s = r.z,
                o = e.max,
                l = o.x,
                _ = o.y,
                h = o.z,
                c = t.center,
                d = c.x,
                u = c.y,
                m = c.z,
                f = t.radius;
            return a.Clamp(c, r, o, $e._tempV30), a.distanceSquared(c, $e._tempV30) &gt; f * f ? Je.Disjoint : i + f &lt;= d &amp;&amp; d &lt;= l - f &amp;&amp; l - i &gt; f &amp;&amp; n + f &lt;= u &amp;&amp; u &lt;= _ - f &amp;&amp; _ - n &gt; f &amp;&amp; s + f &lt;= m &amp;&amp; m &lt;= h - f &amp;&amp; h - s &gt; f ? Je.Contains : Je.Intersects
        }
        static sphereContainsPoint(e, t) {
            return a.distanceSquared(t, e.center) &lt;= e.radius * e.radius ? Je.Contains : Je.Disjoint
        }
        static sphereContainsTriangle(e, t, r, i) {
            var n = $e.sphereContainsPoint(e, t),
                a = $e.sphereContainsPoint(e, r),
                s = $e.sphereContainsPoint(e, i);
            return n == Je.Contains &amp;&amp; a == Je.Contains &amp;&amp; s == Je.Contains ? Je.Contains : $e.intersectsSphereAndTriangle(e, t, r, i) ? Je.Intersects : Je.Disjoint
        }
        static sphereContainsBox(e, t) {
            var r = e.center,
                i = r.x,
                n = r.y,
                s = r.z,
                o = e.radius,
                l = t.min,
                _ = l.x,
                h = l.y,
                c = l.z,
                d = t.max,
                u = d.x,
                m = d.y,
                f = d.z,
                T = $e._tempV30;
            T.x, T.y, T.z;
            if (!$e.intersectsBoxAndSphere(t, e)) return Je.Disjoint;
            var E = o * o;
            return i - _, n - m, s - f, a.scalarLengthSquared($e._tempV30) &gt; E ? Je.Intersects : (i - u, n - m, s - f, a.scalarLengthSquared($e._tempV30) &gt; E ? Je.Intersects : (i - u, n - h, s - f, a.scalarLengthSquared($e._tempV30) &gt; E ? Je.Intersects : (i - _, n - h, s - f, a.scalarLengthSquared($e._tempV30) &gt; E ? Je.Intersects : (i - _, n - m, s - c, a.scalarLengthSquared($e._tempV30) &gt; E ? Je.Intersects : (i - u, n - m, s - c, a.scalarLengthSquared($e._tempV30) &gt; E ? Je.Intersects : (i - u, n - h, s - c, a.scalarLengthSquared($e._tempV30) &gt; E ? Je.Intersects : (i - _, n - h, s - c, a.scalarLengthSquared($e._tempV30) &gt; E ? Je.Intersects : Je.Contains)))))))
        }
        static sphereContainsSphere(e, t) {
            var r = e.radius,
                i = t.radius,
                n = a.distance(e.center, t.center);
            return r + i &lt; n ? Je.Disjoint : r - i &lt; n ? Je.Intersects : Je.Contains
        }
        static closestPointPointTriangle(e, t, r, i, n) {
            a.subtract(r, t, $e._tempV30), a.subtract(i, t, $e._tempV31), a.subtract(e, t, $e._tempV32), a.subtract(e, r, $e._tempV33), a.subtract(e, i, $e._tempV34);
            var s = a.dot($e._tempV30, $e._tempV32),
                o = a.dot($e._tempV31, $e._tempV32),
                l = a.dot($e._tempV30, $e._tempV33),
                _ = a.dot($e._tempV31, $e._tempV33),
                h = a.dot($e._tempV30, $e._tempV34),
                c = a.dot($e._tempV31, $e._tempV34);
            if (s &lt;= 0 &amp;&amp; o &lt;= 0) t.cloneTo(n);
            else if (l &gt;= 0 &amp;&amp; _ &lt;= l) r.cloneTo(n);
            else {
                var d = s * _ - l * o;
                if (d &lt;= 0 &amp;&amp; s &gt;= 0 &amp;&amp; l &lt;= 0) {
                    var u = s / (s - l);
                    return a.scale($e._tempV30, u, n), void a.add(t, n, n)
                }
                if (c &gt;= 0 &amp;&amp; h &lt;= c) i.cloneTo(n);
                else {
                    var m = h * o - s * c;
                    if (m &lt;= 0 &amp;&amp; o &gt;= 0 &amp;&amp; c &lt;= 0) {
                        var f = o / (o - c);
                        return a.scale($e._tempV31, f, n), void a.add(t, n, n)
                    }
                    var T = l * c - h * _;
                    if (T &lt;= 0 &amp;&amp; _ - l &gt;= 0 &amp;&amp; h - c &gt;= 0) {
                        var E = (_ - l) / (_ - l + (h - c));
                        return a.subtract(i, r, n), a.scale(n, E, n), void a.add(r, n, n)
                    }
                    var p = 1 / (T + m + d),
                        g = m * p,
                        S = d * p;
                    a.scale($e._tempV30, g, $e._tempV35), a.scale($e._tempV31, S, $e._tempV36), a.add($e._tempV35, $e._tempV36, n), a.add(t, n, n)
                }
            }
        }
        static closestPointPlanePoint(e, t, r) {
            var i = e.normal,
                n = a.dot(i, t) - e.distance;
            a.scale(i, n, $e._tempV30), a.subtract(t, $e._tempV30, r)
        }
        static closestPointBoxPoint(e, t, r) {
            a.max(t, e.min, $e._tempV30), a.min($e._tempV30, e.max, r)
        }
        static closestPointSpherePoint(e, t, r) {
            var i = e.center;
            a.subtract(t, i, r), a.normalize(r, r), a.scale(r, e.radius, r), a.add(r, i, r)
        }
        static closestPointSphereSphere(e, t, r) {
            var i = e.center;
            a.subtract(t.center, i, r), a.normalize(r, r), a.scale(r, e.radius, r), a.add(r, i, r)
        }
    }
    $e._tempV30 = new a, $e._tempV31 = new a, $e._tempV32 = new a, $e._tempV33 = new a, $e._tempV34 = new a, $e._tempV35 = new a, $e._tempV36 = new a, (Ae = e.FrustumCorner || (e.FrustumCorner = {}))[Ae.FarBottomLeft = 0] = "FarBottomLeft", Ae[Ae.FarTopLeft = 1] = "FarTopLeft", Ae[Ae.FarTopRight = 2] = "FarTopRight", Ae[Ae.FarBottomRight = 3] = "FarBottomRight", Ae[Ae.nearBottomLeft = 4] = "nearBottomLeft", Ae[Ae.nearTopLeft = 5] = "nearTopLeft", Ae[Ae.nearTopRight = 6] = "nearTopRight", Ae[Ae.nearBottomRight = 7] = "nearBottomRight", Ae[Ae.unknown = 8] = "unknown";
    class et {
        constructor(e) {
            this._matrix = e, this._near = new Qe(new a), this._far = new Qe(new a), this._left = new Qe(new a), this._right = new Qe(new a), this._top = new Qe(new a), this._bottom = new Qe(new a), et.getPlanesFromMatrix(this._matrix, this._near, this._far, this._left, this._right, this._top, this._bottom)
        }
        static getPlanesFromMatrix(e, t, r, i, n, a, s) {
            var o = e.elements,
                l = o[0],
                _ = o[1],
                h = o[2],
                c = o[3],
                d = o[4],
                u = o[5],
                m = o[6],
                f = o[7],
                T = o[8],
                E = o[9],
                p = o[10],
                g = o[11],
                S = o[12],
                R = o[13],
                v = o[14],
                A = o[15],
                I = t.normal;
            I.x = h, I.y = m, I.z = p, t.distance = v, t.normalize();
            var x = r.normal;
            x.x = c - h, x.y = f - m, x.z = g - p, r.distance = A - v, r.normalize();
            var L = i.normal;
            L.x = c + l, L.y = f + d, L.z = g + T, i.distance = A + S, i.normalize();
            var D = n.normal;
            D.x = c - l, D.y = f - d, D.z = g - T, n.distance = A - S, n.normalize();
            var C = a.normal;
            C.x = c - _, C.y = f - u, C.z = g - E, a.distance = A - R, a.normalize();
            var y = s.normal;
            y.x = c + _, y.y = f + u, y.z = g + E, s.distance = A + R, s.normalize()
        }
        get matrix() {
            return this._matrix
        }
        set matrix(e) {
            e.cloneTo(this._matrix), et.getPlanesFromMatrix(this._matrix, this._near, this._far, this._left, this._right, this._top, this._bottom)
        }
        get near() {
            return this._near
        }
        get far() {
            return this._far
        }
        get left() {
            return this._left
        }
        get right() {
            return this._right
        }
        get top() {
            return this._top
        }
        get bottom() {
            return this._bottom
        }
        equalsBoundFrustum(e) {
            return this._matrix.equalsOtherMatrix(e.matrix)
        }
        equalsObj(e) {
            if (e instanceof et) {
                var t = e;
                return this.equalsBoundFrustum(t)
            }
            return !1
        }
        getPlane(e) {
            switch (e) {
                case 0:
                    return this._near;
                case 1:
                    return this._far;
                case 2:
                    return this._left;
                case 3:
                    return this._right;
                case 4:
                    return this._top;
                case 5:
                    return this._bottom;
                default:
                    return null
            }
        }
        static get3PlaneInterPoint(e, t, r, i) {
            var n = e.normal,
                s = t.normal,
                o = r.normal;
            a.cross(s, o, et._tempV30), a.cross(o, n, et._tempV31), a.cross(n, s, et._tempV32);
            var l = a.dot(n, et._tempV30),
                _ = a.dot(s, et._tempV31),
                h = a.dot(o, et._tempV32);
            a.scale(et._tempV30, -e.distance / l, et._tempV33), a.scale(et._tempV31, -t.distance / _, et._tempV34), a.scale(et._tempV32, -r.distance / h, et._tempV35), a.add(et._tempV33, et._tempV34, et._tempV36), a.add(et._tempV35, et._tempV36, i)
        }
        getCorners(t) {
            et.get3PlaneInterPoint(this._near, this._bottom, this._right, t[e.FrustumCorner.nearBottomRight]), et.get3PlaneInterPoint(this._near, this._top, this._right, t[e.FrustumCorner.nearTopRight]), et.get3PlaneInterPoint(this._near, this._top, this._left, t[e.FrustumCorner.nearTopLeft]), et.get3PlaneInterPoint(this._near, this._bottom, this._left, t[e.FrustumCorner.nearBottomLeft]), et.get3PlaneInterPoint(this._far, this._bottom, this._right, t[e.FrustumCorner.FarBottomRight]), et.get3PlaneInterPoint(this._far, this._top, this._right, t[e.FrustumCorner.FarTopRight]), et.get3PlaneInterPoint(this._far, this._top, this._left, t[e.FrustumCorner.FarTopLeft]), et.get3PlaneInterPoint(this._far, this._bottom, this._left, t[e.FrustumCorner.FarBottomLeft])
        }
        containsPoint(e) {
            for (var t = Qe.PlaneIntersectionType_Front, r = Qe.PlaneIntersectionType_Front, i = 0; i &lt; 6; i++) {
                switch (i) {
                    case 0:
                        r = $e.intersectsPlaneAndPoint(this._near, e);
                        break;
                    case 1:
                        r = $e.intersectsPlaneAndPoint(this._far, e);
                        break;
                    case 2:
                        r = $e.intersectsPlaneAndPoint(this._left, e);
                        break;
                    case 3:
                        r = $e.intersectsPlaneAndPoint(this._right, e);
                        break;
                    case 4:
                        r = $e.intersectsPlaneAndPoint(this._top, e);
                        break;
                    case 5:
                        r = $e.intersectsPlaneAndPoint(this._bottom, e)
                }
                switch (r) {
                    case Qe.PlaneIntersectionType_Back:
                        return Je.Disjoint;
                    case Qe.PlaneIntersectionType_Intersecting:
                        t = Qe.PlaneIntersectionType_Intersecting
                }
            }
            switch (t) {
                case Qe.PlaneIntersectionType_Intersecting:
                    return Je.Intersects;
                default:
                    return Je.Contains
            }
        }
        intersects(e) {
            var t = e.min,
                r = e.max,
                i = t.x,
                n = t.y,
                a = t.z,
                s = r.x,
                o = r.y,
                l = r.z,
                _ = this._near.normal;
            if (this._near.distance + _.x * (_.x &lt; 0 ? i : s) + _.y * (_.y &lt; 0 ? n : o) + _.z * (_.z &lt; 0 ? a : l) &lt; 0) return !1;
            var h = this._left.normal;
            if (this._left.distance + h.x * (h.x &lt; 0 ? i : s) + h.y * (h.y &lt; 0 ? n : o) + h.z * (h.z &lt; 0 ? a : l) &lt; 0) return !1;
            var c = this._right.normal;
            if (this._right.distance + c.x * (c.x &lt; 0 ? i : s) + c.y * (c.y &lt; 0 ? n : o) + c.z * (c.z &lt; 0 ? a : l) &lt; 0) return !1;
            var d = this._bottom.normal;
            if (this._bottom.distance + d.x * (d.x &lt; 0 ? i : s) + d.y * (d.y &lt; 0 ? n : o) + d.z * (d.z &lt; 0 ? a : l) &lt; 0) return !1;
            var u = this._top.normal;
            if (this._top.distance + u.x * (u.x &lt; 0 ? i : s) + u.y * (u.y &lt; 0 ? n : o) + u.z * (u.z &lt; 0 ? a : l) &lt; 0) return !1;
            var m = this._far.normal;
            return !(this._far.distance + m.x * (m.x &lt; 0 ? i : s) + m.y * (m.y &lt; 0 ? n : o) + m.z * (m.z &lt; 0 ? a : l) &lt; 0)
        }
        containsBoundBox(e) {
            for (var t = et._tempV30, r = et._tempV31, i = e.min, n = e.max, a = Je.Contains, s = 0; s &lt; 6; s++) {
                var o = this.getPlane(s),
                    l = o.normal;
                if (l.x &gt;= 0 ? (t.x = n.x, r.x = i.x) : (t.x = i.x, r.x = n.x), l.y &gt;= 0 ? (t.y = n.y, r.y = i.y) : (t.y = i.y, r.y = n.y), l.z &gt;= 0 ? (t.z = n.z, r.z = i.z) : (t.z = i.z, r.z = n.z), $e.intersectsPlaneAndPoint(o, t) === Qe.PlaneIntersectionType_Back) return Je.Disjoint;
                $e.intersectsPlaneAndPoint(o, r) === Qe.PlaneIntersectionType_Back &amp;&amp; (a = Je.Intersects)
            }
            return a
        }
        containsBoundSphere(e) {
            for (var t = Qe.PlaneIntersectionType_Front, r = Qe.PlaneIntersectionType_Front, i = 0; i &lt; 6; i++) {
                switch (i) {
                    case 0:
                        r = $e.intersectsPlaneAndSphere(this._near, e);
                        break;
                    case 1:
                        r = $e.intersectsPlaneAndSphere(this._far, e);
                        break;
                    case 2:
                        r = $e.intersectsPlaneAndSphere(this._left, e);
                        break;
                    case 3:
                        r = $e.intersectsPlaneAndSphere(this._right, e);
                        break;
                    case 4:
                        r = $e.intersectsPlaneAndSphere(this._top, e);
                        break;
                    case 5:
                        r = $e.intersectsPlaneAndSphere(this._bottom, e)
                }
                switch (r) {
                    case Qe.PlaneIntersectionType_Back:
                        return Je.Disjoint;
                    case Qe.PlaneIntersectionType_Intersecting:
                        t = Qe.PlaneIntersectionType_Intersecting
                }
            }
            switch (t) {
                case Qe.PlaneIntersectionType_Intersecting:
                    return Je.Intersects;
                default:
                    return Je.Contains
            }
        }
    }
    et._tempV30 = new a, et._tempV31 = new a, et._tempV32 = new a, et._tempV33 = new a, et._tempV34 = new a, et._tempV35 = new a, et._tempV36 = new a;
    class tt {
        constructor(e, t, r, i) {
            this.minDepth = 0, this.maxDepth = 1, this.x = e, this.y = t, this.width = r, this.height = i
        }
        project(e, t, r) {
            a.transformV3ToV4(e, t, r);
            var i = r.x,
                n = r.y,
                s = r.z,
                o = r.w;
            1 !== o &amp;&amp; (i /= o, n /= o, s /= o), r.x = .5 * (i + 1) * this.width + this.x, r.y = .5 * (1 - n) * this.height + this.y, r.z = s * (this.maxDepth - this.minDepth) + this.minDepth
        }
        unprojectFromMat(e, t, r) {
            var i = t.elements;
            r.x = (e.x - this.x) / this.width * 2 - 1, r.y = -((e.y - this.y) / this.height * 2 - 1), r.z = (e.z - this.minDepth) / (this.maxDepth - this.minDepth);
            var n = r.x * i[3] + r.y * i[7] + r.z * i[11] + i[15];
            a.transformV3ToV3(r, t, r), 1 !== n &amp;&amp; (r.x = r.x / n, r.y = r.y / n, r.z = r.z / n)
        }
        unprojectFromWVP(e, t, r, i, n) {
            c.multiply(t, r, tt._tempMatrix4x4), i &amp;&amp; c.multiply(tt._tempMatrix4x4, i, tt._tempMatrix4x4), tt._tempMatrix4x4.invert(tt._tempMatrix4x4), this.unprojectFromMat(e, tt._tempMatrix4x4, n)
        }
        cloneTo(e) {
            e.x = this.x, e.y = this.y, e.width = this.width, e.height = this.height, e.minDepth = this.minDepth, e.maxDepth = this.maxDepth
        }
    }
    tt._tempMatrix4x4 = new c;
    class rt {
        constructor() {}
        static calculateCursorRay(e, t, r, i, n, s) {
            var o = e.x,
                l = e.y,
                _ = rt._tempVector30,
                h = _;
            h.x = o, h.y = l, h.z = t.minDepth;
            var c = rt._tempVector31,
                d = c;
            d.x = o, d.y = l, d.z = t.maxDepth;
            var u = s.origin,
                m = rt._tempVector32;
            t.unprojectFromWVP(_, r, i, n, u), t.unprojectFromWVP(c, r, i, n, m);
            var f = s.direction;
            f.x = m.x - u.x, f.y = m.y - u.y, f.z = m.z - u.z, a.normalize(s.direction, s.direction)
        }
        static rayIntersectsTriangle(e, t, r, i) {
            var n = rt._tempVector30,
                s = rt._tempVector31;
            a.subtract(r, t, n), a.subtract(i, t, s);
            var o, l = rt._tempVector32;
            if (a.cross(e.direction, s, l), (o = a.dot(n, l)) &gt; -Number.MIN_VALUE &amp;&amp; o &lt; Number.MIN_VALUE) return Number.NaN;
            var _, h = 1 / o,
                c = rt._tempVector33;
            if (a.subtract(e.origin, t, c), _ = a.dot(c, l), (_ *= h) &lt; 0 || _ &gt; 1) return Number.NaN;
            var d, u, m = rt._tempVector34;
            return a.cross(c, n, m), d = a.dot(e.direction, m), (d *= h) &lt; 0 || _ + d &gt; 1 ? Number.NaN : (u = a.dot(s, m), (u *= h) &lt; 0 ? Number.NaN : u)
        }
    }
    rt._tempVector30 = new a, rt._tempVector31 = new a, rt._tempVector32 = new a, rt._tempVector33 = new a, rt._tempVector34 = new a;
    class it extends t.BufferStateBase {
        constructor() {
            super()
        }
        applyVertexBuffer(e) {
            if (t.BufferStateBase._curBindedBufferState !== this) throw "BufferState: must call bind() function first.";
            var r = t.LayaGL.instance,
                i = e.vertexDeclaration,
                n = i._shaderValues.getData();
            for (var a in this.vertexDeclaration = i, e.bind(), n) {
                var s = parseInt(a),
                    o = n[a];
                r.enableVertexAttribArray(s), r.vertexAttribPointer(s, o[0], o[1], !!o[2], o[3], o[4])
            }
        }
        applyVertexBuffers(e) {
            if (t.BufferStateBase._curBindedBufferState !== this) throw "BufferState: must call bind() function first.";
            for (var r = t.LayaGL.instance, i = 0, n = e.length; i &lt; n; i++) {
                var a = e[i],
                    s = a.vertexDeclaration._shaderValues.getData();
                for (var o in a.bind(), s) {
                    var l = parseInt(o),
                        _ = s[o];
                    r.enableVertexAttribArray(l), r.vertexAttribPointer(l, _[0], _[1], !!_[2], _[3], _[4])
                }
            }
        }
        applyInstanceVertexBuffer(e) {
            if (t.LayaGL.layaGPUInstance.supportInstance()) {
                if (t.BufferStateBase._curBindedBufferState !== this) throw "BufferState: must call bind() function first.";
                var r = t.LayaGL.instance,
                    i = e.vertexDeclaration._shaderValues.getData();
                for (var n in e.bind(), i) {
                    var a = parseInt(n),
                        s = i[n];
                    r.enableVertexAttribArray(a), r.vertexAttribPointer(a, s[0], s[1], !!s[2], s[3], s[4]), t.LayaGL.layaGPUInstance.vertexAttribDivisor(a, 1)
                }
            }
        }
        applyIndexBuffer(e) {
            if (t.BufferStateBase._curBindedBufferState !== this) throw "BufferState: must call bind() function first.";
            this._bindedIndexBuffer !== e &amp;&amp; (e._bindForVAO(), this._bindedIndexBuffer = e)
        }
    }(Ie = e.IndexFormat || (e.IndexFormat = {}))[Ie.UInt8 = 0] = "UInt8", Ie[Ie.UInt16 = 1] = "UInt16", Ie[Ie.UInt32 = 2] = "UInt32";
    class nt extends t.Buffer {
        constructor(r, i, n = 35044, a = !1) {
            switch (super(), this._indexType = r, this._indexCount = i, this._bufferUsage = n, this._bufferType = t.LayaGL.instance.ELEMENT_ARRAY_BUFFER, this._canRead = a, r) {
                case e.IndexFormat.UInt32:
                    this._indexTypeByteCount = 4;
                    break;
                case e.IndexFormat.UInt16:
                    this._indexTypeByteCount = 2;
                    break;
                case e.IndexFormat.UInt8:
                    this._indexTypeByteCount = 1;
                    break;
                default:
                    throw new Error("unidentification index type.")
            }
            var s = this._indexTypeByteCount * i,
                o = t.BufferStateBase._curBindedBufferState;
            if (this._byteLength = s, o ? o._bindedIndexBuffer === this ? t.LayaGL.instance.bufferData(this._bufferType, s, this._bufferUsage) : (o.unBind(), this.bind(), t.LayaGL.instance.bufferData(this._bufferType, s, this._bufferUsage), o.bind()) : (this.bind(), t.LayaGL.instance.bufferData(this._bufferType, s, this._bufferUsage)), a) switch (r) {
                case e.IndexFormat.UInt32:
                    this._buffer = new Uint32Array(i);
                    break;
                case e.IndexFormat.UInt16:
                    this._buffer = new Uint16Array(i);
                    break;
                case e.IndexFormat.UInt8:
                    this._buffer = new Uint8Array(i)
            }
        }
        get indexType() {
            return this._indexType
        }
        get indexTypeByteCount() {
            return this._indexTypeByteCount
        }
        get indexCount() {
            return this._indexCount
        }
        get canRead() {
            return this._canRead
        }
        _bindForVAO() {
            if (!t.BufferStateBase._curBindedBufferState) throw "IndexBuffer3D: must bind current BufferState.";
            var e = t.LayaGL.instance;
            e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this._glBuffer)
        }
        bind() {
            if (t.BufferStateBase._curBindedBufferState) throw "IndexBuffer3D: must unbind current BufferState.";
            if (t.Buffer._bindedIndexBuffer !== this._glBuffer) {
                var e = t.LayaGL.instance;
                return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this._glBuffer), t.Buffer._bindedIndexBuffer = this._glBuffer, !0
            }
            return !1
        }
        setData(r, i = 0, n = 0, a = 4294967295) {
            var s = this._indexTypeByteCount;
            if (0 !== n || 4294967295 !== a) switch (this._indexType) {
                case e.IndexFormat.UInt32:
                    r = new Uint32Array(r.buffer, n * s, a);
                    break;
                case e.IndexFormat.UInt16:
                    r = new Uint16Array(r.buffer, n * s, a);
                    break;
                case e.IndexFormat.UInt8:
                    r = new Uint8Array(r.buffer, n * s, a)
            }
            var o = t.BufferStateBase._curBindedBufferState;
            if (o ? o._bindedIndexBuffer === this ? t.LayaGL.instance.bufferSubData(this._bufferType, i * s, r) : (o.unBind(), this.bind(), t.LayaGL.instance.bufferSubData(this._bufferType, i * s, r), o.bind()) : (this.bind(), t.LayaGL.instance.bufferSubData(this._bufferType, i * s, r)), this._canRead)
                if (0 !== i || 0 !== n || 4294967295 !== a) {
                    var l = this._buffer.length - i;
                    a &gt; l &amp;&amp; (a = l);
                    for (var _ = 0; _ &lt; a; _++) this._buffer[i + _] = r[_]
                } else this._buffer = r
        }
        getData() {
            if (this._canRead) return this._buffer;
            throw new Error("Can't read data from VertexBuffer with only write flag!")
        }
        destroy() {
            super.destroy(), this._buffer = null
        }
    }
    class at {
        static __init__() {
            var e = t.LayaGL.instance;
            at._elementInfos = {
                single: [1, e.FLOAT, 0],
                vector2: [2, e.FLOAT, 0],
                vector3: [3, e.FLOAT, 0],
                vector4: [4, e.FLOAT, 0],
                color: [4, e.FLOAT, 0],
                byte4: [4, e.UNSIGNED_BYTE, 0],
                short2: [2, e.FLOAT, 0],
                short4: [4, e.FLOAT, 0],
                normalizedshort2: [2, e.FLOAT, 0],
                normalizedshort4: [4, e.FLOAT, 0],
                halfvector2: [2, e.FLOAT, 0],
                halfvector4: [4, e.FLOAT, 0]
            }
        }
        static getElementInfos(e) {
            var t = at._elementInfos[e];
            if (t) return t;
            throw "VertexElementFormat: this vertexElementFormat is not implement."
        }
    }
    at.Single = "single", at.Vector2 = "vector2", at.Vector3 = "vector3", at.Vector4 = "vector4", at.Color = "color", at.Byte4 = "byte4", at.Short2 = "short2", at.Short4 = "short4", at.NormalizedShort2 = "normalizedshort2", at.NormalizedShort4 = "normalizedshort4", at.HalfVector2 = "halfvector2", at.HalfVector4 = "halfvector4";
    class st {
        constructor(e, t) {
            this._id = ++st._uniqueIDCounter, this._vertexElementsDic = {}, this._vertexStride = e, this._vertexElements = t;
            var r = t.length;
            this._shaderValues = new ce(null);
            for (var i = 0; i &lt; r; i++) {
                var n = t[i],
                    a = n._elementUsage;
                this._vertexElementsDic[a] = n;
                var s = new Int32Array(5),
                    o = at.getElementInfos(n._elementFormat);
                s[0] = o[0], s[1] = o[1], s[2] = o[2], s[3] = this._vertexStride, s[4] = n._offset, this._shaderValues.setAttribute(a, s)
            }
        }
        get id() {
            return this._id
        }
        get vertexStride() {
            return this._vertexStride
        }
        get vertexElementCount() {
            return this._vertexElements.length
        }
        getVertexElementByIndex(e) {
            return this._vertexElements[e]
        }
        getVertexElementByUsage(e) {
            return this._vertexElementsDic[e]
        }
    }
    st._uniqueIDCounter = 1;
    class ot {
        constructor(e, t, r) {
            this._offset = e, this._elementFormat = t, this._elementUsage = r
        }
        get offset() {
            return this._offset
        }
        get elementFormat() {
            return this._elementFormat
        }
        get elementUsage() {
            return this._elementUsage
        }
    }
    class lt {
        static __init__() {
            lt.instanceWorldMatrixDeclaration = new st(64, [new ot(0, at.Vector4, lt.MESH_WORLDMATRIX_ROW0), new ot(16, at.Vector4, lt.MESH_WORLDMATRIX_ROW1), new ot(32, at.Vector4, lt.MESH_WORLDMATRIX_ROW2), new ot(48, at.Vector4, lt.MESH_WORLDMATRIX_ROW3)]), lt.instanceMVPMatrixDeclaration = new st(64, [new ot(0, at.Vector4, lt.MESH_MVPMATRIX_ROW0), new ot(16, at.Vector4, lt.MESH_MVPMATRIX_ROW1), new ot(32, at.Vector4, lt.MESH_MVPMATRIX_ROW2), new ot(48, at.Vector4, lt.MESH_MVPMATRIX_ROW3)])
        }
        static getVertexDeclaration(e, t = !0) {
            var r = lt._vertexDeclarationMap[e + (t ? "_0" : "_1")];
            if (!r) {
                for (var i = e.split(","), n = 0, a = [], s = 0, o = i.length; s &lt; o; s++) {
                    var l;
                    switch (i[s]) {
                        case "POSITION":
                            l = new ot(n, at.Vector3, lt.MESH_POSITION0), n += 12;
                            break;
                        case "NORMAL":
                            l = new ot(n, at.Vector3, lt.MESH_NORMAL0), n += 12;
                            break;
                        case "COLOR":
                            l = new ot(n, at.Vector4, lt.MESH_COLOR0), n += 16;
                            break;
                        case "UV":
                            l = new ot(n, at.Vector2, lt.MESH_TEXTURECOORDINATE0), n += 8;
                            break;
                        case "UV1":
                            l = new ot(n, at.Vector2, lt.MESH_TEXTURECOORDINATE1), n += 8;
                            break;
                        case "BLENDWEIGHT":
                            l = new ot(n, at.Vector4, lt.MESH_BLENDWEIGHT0), n += 16;
                            break;
                        case "BLENDINDICES":
                            t ? (l = new ot(n, at.Vector4, lt.MESH_BLENDINDICES0), n += 16) : (l = new ot(n, at.Byte4, lt.MESH_BLENDINDICES0), n += 4);
                            break;
                        case "TANGENT":
                            l = new ot(n, at.Vector4, lt.MESH_TANGENT0), n += 16;
                            break;
                        default:
                            throw "VertexMesh: unknown vertex flag."
                    }
                    a.push(l)
                }
                r = new st(n, a), lt._vertexDeclarationMap[e + (t ? "_0" : "_1")] = r
            }
            return r
        }
    }
    lt.MESH_POSITION0 = 0, lt.MESH_COLOR0 = 1, lt.MESH_TEXTURECOORDINATE0 = 2, lt.MESH_NORMAL0 = 3, lt.MESH_TANGENT0 = 4, lt.MESH_BLENDINDICES0 = 5, lt.MESH_BLENDWEIGHT0 = 6, lt.MESH_TEXTURECOORDINATE1 = 7, lt.MESH_WORLDMATRIX_ROW0 = 8, lt.MESH_WORLDMATRIX_ROW1 = 9, lt.MESH_WORLDMATRIX_ROW2 = 10, lt.MESH_WORLDMATRIX_ROW3 = 11, lt.MESH_MVPMATRIX_ROW0 = 12, lt.MESH_MVPMATRIX_ROW1 = 13, lt.MESH_MVPMATRIX_ROW2 = 14, lt.MESH_MVPMATRIX_ROW3 = 15, lt._vertexDeclarationMap = {};
    class _t extends t.Buffer {
        constructor(e, r, i = !1) {
            super(), this._vertexDeclaration = null, this._float32Reader = null;
            var n = t.LayaGL.instance;
            this._bufferUsage = r, this._bufferType = n.ARRAY_BUFFER, this._canRead = i, this._byteLength = e, this.bind(), n.bufferData(this._bufferType, this._byteLength, this._bufferUsage), i &amp;&amp; (this._buffer = new Uint8Array(e), this._float32Reader = new Float32Array(this._buffer.buffer))
        }
        get vertexDeclaration() {
            return this._vertexDeclaration
        }
        set vertexDeclaration(e) {
            this._vertexDeclaration = e
        }
        get canRead() {
            return this._canRead
        }
        bind() {
            if (t.Buffer._bindedVertexBuffer !== this._glBuffer) {
                var e = t.LayaGL.instance;
                return e.bindBuffer(e.ARRAY_BUFFER, this._glBuffer), t.Buffer._bindedVertexBuffer = this._glBuffer, !0
            }
            return !1
        }
        orphanStorage() {
            this.bind(), t.LayaGL.instance.bufferData(this._bufferType, this._byteLength, this._bufferUsage)
        }
        setData(e, r = 0, i = 0, n = Number.MAX_SAFE_INTEGER) {
            if (this.bind(), 0 !== i || n !== Number.MAX_SAFE_INTEGER) {
                var a = new Uint8Array(e, i, n);
                t.LayaGL.instance.bufferSubData(this._bufferType, r, a), this._canRead &amp;&amp; this._buffer.set(a, r)
            } else t.LayaGL.instance.bufferSubData(this._bufferType, r, e), this._canRead &amp;&amp; this._buffer.set(new Uint8Array(e), r)
        }
        getUint8Data() {
            if (this._canRead) return this._buffer;
            throw new Error("Can't read data from VertexBuffer with only write flag!")
        }
        getFloat32Data() {
            if (this._canRead) return this._float32Reader;
            throw new Error("Can't read data from VertexBuffer with only write flag!")
        }
        markAsUnreadbale() {
            this._canRead = !1, this._buffer = null, this._float32Reader = null
        }
        destroy() {
            super.destroy(), this._buffer = null, this._float32Reader = null, this._vertexDeclaration = null
        }
    }
    _t.DATATYPE_FLOAT32ARRAY = 0, _t.DATATYPE_UINT8ARRAY = 1;
    class ht {
        constructor() {}
        _render(e) {}
    }
    class ct extends ht {
        constructor() {
            super();
            var r = t.LayaGL.instance,
                i = new Float32Array([-1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1]),
                n = new Uint8Array([0, 1, 2, 2, 3, 0, 4, 7, 6, 6, 5, 4, 0, 3, 7, 7, 4, 0, 1, 5, 6, 6, 2, 1, 3, 2, 6, 6, 7, 3, 0, 4, 5, 5, 1, 0]),
                a = lt.getVertexDeclaration("POSITION");
            this._vertexBuffer = new _t(8 * a.vertexStride, r.STATIC_DRAW, !1), this._vertexBuffer.vertexDeclaration = a, this._indexBuffer = new nt(e.IndexFormat.UInt8, 36, r.STATIC_DRAW, !1), this._vertexBuffer.setData(i.buffer), this._indexBuffer.setData(n);
            var s = new it;
            s.bind(), s.applyVertexBuffer(this._vertexBuffer), s.applyIndexBuffer(this._indexBuffer), s.unBind(), this._bufferState = s
        }
        static __init__() {
            ct.instance = new ct
        }
        _render(e) {
            var r = t.LayaGL.instance;
            r.drawElements(r.TRIANGLES, 36, r.UNSIGNED_BYTE, 0), t.Stat.trianglesFaces += 12, t.Stat.renderBatches++
        }
    }
    class dt {
        constructor() {
            this._mesh = ct.instance
        }
        get material() {
            return this._material
        }
        set material(e) {
            this._material !== e &amp;&amp; (this._material &amp;&amp; this._material._removeReference(), e &amp;&amp; e._addReference(), this._material = e)
        }
        get mesh() {
            return this._mesh
        }
        set mesh(e) {
            this._mesh !== e &amp;&amp; (this._mesh = e)
        }
        _isAvailable() {
            return !(!this._material || !this._mesh)
        }
        _render(e) {
            if (this._material &amp;&amp; this._mesh) {
                var r = t.LayaGL.instance,
                    i = e.scene,
                    n = e.cameraShaderValue,
                    s = e.camera,
                    o = ce._SET_RUNTIME_VALUE_MODE_REFERENCE_;
                t.ILaya.Render.supportWebGLPlusRendering &amp;&amp; ce.setRuntimeValueMode(!1), t.WebGLContext.setCullFace(r, !1), t.WebGLContext.setDepthFunc(r, r.LEQUAL), t.WebGLContext.setDepthMask(r, !1);
                var l = dt._compileDefine;
                this._material._shaderValues._defineDatas.cloneTo(l);
                var _ = e.shader = this._material._shader.getSubShaderAt(0)._passes[0].withCompile(l),
                    h = _.bind(),
                    d = t.Stat.loopCount !== _._uploadMark,
                    u = _._uploadScene !== i || d;
                (u || h) &amp;&amp; (_.uploadUniforms(_._sceneUniformParamsMap, i._shaderValues, u), _._uploadScene = i);
                s._getRenderTexture();
                var m = _._uploadCameraShaderValue !== n || d;
                if (m || h) {
                    var f = dt._tempMatrix0,
                        T = dt._tempMatrix1;
                    s.viewMatrix.cloneTo(f), s.projectionMatrix.cloneTo(T), f.setTranslationVector(a._ZERO), s.orthographic &amp;&amp; c.createPerspective(s.fieldOfView, s.aspectRatio, s.nearPlane, s.farPlane, T);
                    var E = 1 / Math.tan(3.1416 * s.fieldOfView / 180 * .5);
                    T.elements[0] = E / s.aspectRatio, T.elements[5] = E, T.elements[10] = 1e-6 - 1, T.elements[11] = -1, T.elements[14] = -0, s._applyViewProject(e, f, T), _.uploadUniforms(_._cameraUniformParamsMap, n, m), _._uploadCameraShaderValue = n
                }
                var p = _._uploadMaterial !== this._material || d;
                (p || h) &amp;&amp; (_.uploadUniforms(_._materialUniformParamsMap, this._material._shaderValues, p), _._uploadMaterial = this._material), this._mesh._bufferState.bind(), this._mesh._render(e), t.ILaya.Render.supportWebGLPlusRendering &amp;&amp; ce.setRuntimeValueMode(o), t.WebGLContext.setDepthFunc(r, r.LESS), t.WebGLContext.setDepthMask(r, !0), s._applyViewProject(e, s.viewMatrix, s.projectionMatrix)
            }
        }
        destroy() {
            this._material &amp;&amp; (this._material._removeReference(), this._material = null)
        }
    }
    dt._tempMatrix0 = new c, dt._tempMatrix1 = new c, dt._compileDefine = new se;
    class ut extends t.Node {
        constructor(e = null, t = !1) {
            super(), this._needProcessCollisions = !1, this._needProcessTriggers = !1, this._id = ++ut._uniqueIDCounter, this._transform = new f(this), this._isStatic = t, this.layer = 0, this.name = e || "New Sprite3D"
        }
        static __init__() {}
        static instantiate(e, t = null, r = !0, i = null, n = null) {
            var a = e.clone();
            t &amp;&amp; t.addChild(a);
            var s = a.transform;
            if (r) {
                var o = s.worldMatrix;
                e.transform.worldMatrix.cloneTo(o), s.worldMatrix = o
            } else i &amp;&amp; (s.position = i), n &amp;&amp; (s.rotation = n);
            return a
        }
        static load(e, r) {
            t.Laya.loader.create(e, r, null, ut.HIERARCHY)
        }
        get id() {
            return this._id
        }
        get layer() {
            return this._layer
        }
        set layer(e) {
            if (this._layer !== e) {
                if (!(e &gt;= 0 &amp;&amp; e &lt;= 30)) throw new Error("Layer value must be 0-30.");
                this._layer = e
            }
        }
        get url() {
            return this._url
        }
        get isStatic() {
            return this._isStatic
        }
        get transform() {
            return this._transform
        }
        _setCreateURL(e) {
            this._url = t.URL.formatURL(e)
        }
        _changeAnimatorsToLinkSprite3D(e, t, r) {
            var i = this.getComponent(re);
            if (i &amp;&amp; (i.avatar || e._changeAnimatorToLinkSprite3DNoAvatar(i, t, r)), this._parent &amp;&amp; this._parent instanceof ut) {
                r.unshift(this._parent.name);
                var n = this._parent;
                n._hierarchyAnimator &amp;&amp; n._changeAnimatorsToLinkSprite3D(e, t, r)
            }
        }
        _setHierarchyAnimator(e, t) {
            this._changeHierarchyAnimator(e), this._changeAnimatorAvatar(e.avatar);
            for (var r = 0, i = this._children.length; r &lt; i; r++) {
                var n = this._children[r];
                n._hierarchyAnimator == t &amp;&amp; n._setHierarchyAnimator(e, t)
            }
        }
        _clearHierarchyAnimator(e, t) {
            this._changeHierarchyAnimator(t), this._changeAnimatorAvatar(t ? t.avatar : null);
            for (var r = 0, i = this._children.length; r &lt; i; r++) {
                var n = this._children[r];
                n._hierarchyAnimator == e &amp;&amp; n._clearHierarchyAnimator(e, t)
            }
        }
        _changeHierarchyAnimatorAvatar(e, t) {
            this._changeAnimatorAvatar(t);
            for (var r = 0, i = this._children.length; r &lt; i; r++) {
                var n = this._children[r];
                n._hierarchyAnimator == e &amp;&amp; n._changeHierarchyAnimatorAvatar(e, t)
            }
        }
        _changeAnimatorToLinkSprite3DNoAvatar(e, t, r) {
            e._handleSpriteOwnersBySprite(t, r, this);
            for (var i = 0, n = this._children.length; i &lt; n; i++) {
                var a = this._children[i],
                    s = r.length;
                r.push(a.name), a._changeAnimatorToLinkSprite3DNoAvatar(e, t, r), r.splice(s, 1)
            }
        }
        _changeHierarchyAnimator(e) {
            this._hierarchyAnimator = e
        }
        _changeAnimatorAvatar(e) {}
        _onAdded() {
            if (this._parent instanceof ut) {
                var e = this._parent;
                this.transform._setParent(e.transform), e._hierarchyAnimator &amp;&amp; (!this._hierarchyAnimator &amp;&amp; this._setHierarchyAnimator(e._hierarchyAnimator, null), e._changeAnimatorsToLinkSprite3D(this, !0, [this.name]))
            }
            super._onAdded()
        }
        _onRemoved() {
            if (super._onRemoved(), this._parent instanceof ut) {
                var e = this._parent;
                this.transform._setParent(null), e._hierarchyAnimator &amp;&amp; (this._hierarchyAnimator == e._hierarchyAnimator &amp;&amp; this._clearHierarchyAnimator(e._hierarchyAnimator, null), e._changeAnimatorsToLinkSprite3D(this, !1, [this.name]))
            }
        }
        _parse(e, t) {
            if (void 0 !== e.isStatic &amp;&amp; (this._isStatic = e.isStatic), void 0 !== e.active &amp;&amp; (this.active = e.active), null != e.name &amp;&amp; (this.name = e.name), void 0 !== e.position) {
                var r = this.transform.localPosition;
                r.fromArray(e.position), this.transform.localPosition = r
            }
            if (void 0 !== e.rotationEuler) {
                var i = this.transform.localRotationEuler;
                i.fromArray(e.rotationEuler), this.transform.localRotationEuler = i
            }
            if (void 0 !== e.rotation) {
                var n = this.transform.localRotation;
                n.fromArray(e.rotation), this.transform.localRotation = n
            }
            if (void 0 !== e.scale) {
                var a = this.transform.localScale;
                a.fromArray(e.scale), this.transform.localScale = a
            }
            null != e.layer &amp;&amp; (this.layer = e.layer)
        }
        _cloneTo(e, t, r) {
            if (this.destroyed) throw new Error("Sprite3D: Can't be cloned if the Sprite3D has destroyed.");
            var i = e,
                n = this._transform,
                a = i._transform;
            i.name = this.name, i.destroyed = this.destroyed, i.active = this.active, a.localPosition = n.localPosition, a.localRotation = n.localRotation, a.localScale = n.localScale, i._isStatic = this._isStatic, i.layer = this.layer, super._cloneTo(i, t, r)
        }
        static _createSprite3DInstance(e) {
            for (var t = e._create(), r = e._children, i = 0, n = r.length; i &lt; n; i++) {
                var a = ut._createSprite3DInstance(r[i]);
                t.addChild(a)
            }
            return t
        }
        static _parseSprite3DInstance(e, t, r, i) {
            for (var n = r._children, a = i._children, s = 0, o = n.length; s &lt; o; s++) ut._parseSprite3DInstance(e, t, n[s], a[s]);
            r._cloneTo(i, e, t)
        }
        clone() {
            var e = ut._createSprite3DInstance(this);
            return ut._parseSprite3DInstance(this, e, this, e), e
        }
        destroy(e = !0) {
            this.destroyed || (super.destroy(e), this._transform = null, this._scripts = null, this._url &amp;&amp; t.Loader.clearRes(this._url))
        }
        _create() {
            return new ut
        }
    }
    ut.HIERARCHY = "HIERARCHY", ut.WORLDMATRIX = he.propertyNameToID("u_WorldMat"), ut.MVPMATRIX = he.propertyNameToID("u_MvpMatrix"), ut._uniqueIDCounter = 0;
    class mt extends ut {
        constructor(e = .3, t = 1e3) {
            super(), this._skyRenderer = new dt, this._forward = new a, this._up = new a, this.clearColor = new n(100 / 255, 149 / 255, 237 / 255, 1), this._shaderValues = new ce(null), this._fieldOfView = 60, this._useUserProjectionMatrix = !1, this._orthographic = !1, this._orthographicVerticalSize = 10, this.renderingOrder = 0, this._nearPlane = e, this._farPlane = t, this.cullingMask = 2147483647, this.useOcclusionCulling = !0
        }
        get skyRenderer() {
            return this._skyRenderer
        }
        get fieldOfView() {
            return this._fieldOfView
        }
        set fieldOfView(e) {
            this._fieldOfView = e, this._calculateProjectionMatrix()
        }
        get nearPlane() {
            return this._nearPlane
        }
        set nearPlane(e) {
            this._nearPlane = e, this._calculateProjectionMatrix()
        }
        get farPlane() {
            return this._farPlane
        }
        set farPlane(e) {
            this._farPlane = e, this._calculateProjectionMatrix()
        }
        get orthographic() {
            return this._orthographic
        }
        set orthographic(e) {
            this._orthographic = e, this._calculateProjectionMatrix()
        }
        get orthographicVerticalSize() {
            return this._orthographicVerticalSize
        }
        set orthographicVerticalSize(e) {
            this._orthographicVerticalSize = e, this._calculateProjectionMatrix()
        }
        get renderingOrder() {
            return this._renderingOrder
        }
        set renderingOrder(e) {
            this._renderingOrder = e, this._sortCamerasByRenderingOrder()
        }
        _sortCamerasByRenderingOrder() {
            if (this.displayedInStage)
                for (var e = this.scene._cameraPool, t = e.length - 1, r = 0; r &lt; t; r++)
                    if (e[r].renderingOrder &gt; e[t].renderingOrder) {
                        var i = e[r];
                        e[r] = e[t], e[t] = i
                    }
        }
        _calculateProjectionMatrix() {}
        _onScreenSizeChanged() {
            this._calculateProjectionMatrix()
        }
        _prepareCameraToRender() {
            var e = this._shaderValues;
            this.transform.getForward(this._forward), this.transform.getUp(this._up), e.setVector3(mt.CAMERAPOS, this.transform.position), e.setVector3(mt.CAMERADIRECTION, this._forward), e.setVector3(mt.CAMERAUP, this._up)
        }
        render(e = null, t = null) {}
        addLayer(e) {
            this.cullingMask |= Math.pow(2, e)
        }
        removeLayer(e) {
            this.cullingMask &amp;= ~Math.pow(2, e)
        }
        addAllLayers() {
            this.cullingMask = 2147483647
        }
        removeAllLayers() {
            this.cullingMask = 0
        }
        resetProjectionMatrix() {
            this._useUserProjectionMatrix = !1, this._calculateProjectionMatrix()
        }
        _onActive() {
            this._scene._addCamera(this), super._onActive()
        }
        _onInActive() {
            this._scene._removeCamera(this), super._onInActive()
        }
        _parse(e, r) {
            super._parse(e, r), this.orthographic = e.orthographic, void 0 !== e.orthographicVerticalSize &amp;&amp; (this.orthographicVerticalSize = e.orthographicVerticalSize), void 0 !== e.fieldOfView &amp;&amp; (this.fieldOfView = e.fieldOfView), this.nearPlane = e.nearPlane, this.farPlane = e.farPlane;
            var i = e.clearColor;
            this.clearColor = new n(i[0], i[1], i[2], i[3]);
            var a = e.skyboxMaterial;
            a &amp;&amp; (this._skyRenderer.material = t.Loader.getRes(a.path))
        }
        destroy(e = !0) {
            this._skyRenderer.destroy(), this._skyRenderer = null, t.Laya.stage.off(t.Event.RESIZE, this, this._onScreenSizeChanged), super.destroy(e)
        }
        _create() {
            return new mt
        }
    }
    mt._tempMatrix4x40 = new c, mt.CAMERAPOS = he.propertyNameToID("u_CameraPos"), mt.VIEWMATRIX = he.propertyNameToID("u_View"), mt.PROJECTMATRIX = he.propertyNameToID("u_Projection"), mt.VIEWPROJECTMATRIX = he.propertyNameToID("u_ViewProjection"), mt.CAMERADIRECTION = he.propertyNameToID("u_CameraDirection"), mt.CAMERAUP = he.propertyNameToID("u_CameraUp"), mt.VIEWPORT = he.propertyNameToID("u_Viewport"), mt.PROJECTION_PARAMS = he.propertyNameToID("u_ProjectionParams"), mt.RENDERINGTYPE_DEFERREDLIGHTING = "DEFERREDLIGHTING", mt.RENDERINGTYPE_FORWARDRENDERING = "FORWARDRENDERING", mt._invertYScaleMatrix = new c(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), mt._invertYProjectionMatrix = new c, mt._invertYProjectionViewMatrix = new c, mt.CLEARFLAG_SOLIDCOLOR = 0, mt.CLEARFLAG_SKY = 1, mt.CLEARFLAG_DEPTHONLY = 2, mt.CLEARFLAG_NONE = 3, (xe = e.ShadowMode || (e.ShadowMode = {}))[xe.None = 0] = "None", xe[xe.Hard = 1] = "Hard", xe[xe.SoftLow = 2] = "SoftLow", xe[xe.SoftHigh = 3] = "SoftHigh";
    class ft extends t.Resource {
        constructor() {
            super(), this._bufferState = new it, this._bufferStateInvertUV = new it;
            var e = t.LayaGL.instance;
            this._vertexBuffer = new _t(64, e.STATIC_DRAW, !1), this._vertexBuffer.vertexDeclaration = ft._vertexDeclaration, this._vertexBuffer.setData(ft._vertices.buffer), this._bufferState.bind(), this._bufferState.applyVertexBuffer(this._vertexBuffer), this._bufferState.unBind(), this._vertexBufferInvertUV = new _t(64, e.STATIC_DRAW, !1), this._vertexBufferInvertUV.vertexDeclaration = ft._vertexDeclaration, this._vertexBufferInvertUV.setData(ft._verticesInvertUV.buffer), this._bufferStateInvertUV.bind(), this._bufferStateInvertUV.applyVertexBuffer(this._vertexBufferInvertUV), this._bufferStateInvertUV.unBind(), this._setGPUMemory(this._vertexBuffer._byteLength + this._vertexBufferInvertUV._byteLength)
        }
        static __init__() {
            ft._vertexDeclaration = new st(16, [new ot(0, at.Vector4, ft.SCREENQUAD_POSITION_UV)]), ft.instance = new ft, ft.instance.lock = !0
        }
        render() {
            var e = t.LayaGL.instance;
            this._bufferState.bind(), e.drawArrays(e.TRIANGLE_STRIP, 0, 4), t.Stat.renderBatches++
        }
        renderInvertUV() {
            var e = t.LayaGL.instance;
            this._bufferStateInvertUV.bind(), e.drawArrays(e.TRIANGLE_STRIP, 0, 4), t.Stat.renderBatches++
        }
        destroy() {
            super.destroy(), this._bufferState.destroy(), this._vertexBuffer.destroy(), this._bufferStateInvertUV.destroy(), this._vertexBufferInvertUV.destroy(), this._setGPUMemory(0)
        }
    }
    ft.SCREENQUAD_POSITION_UV = 0, ft._vertices = new Float32Array([1, 1, 1, 1, 1, -1, 1, 0, -1, 1, 0, 1, -1, -1, 0, 0]), ft._verticesInvertUV = new Float32Array([1, 1, 1, 0, 1, -1, 1, 1, -1, 1, 0, 0, -1, -1, 0, 1]);
    class Tt extends t.Resource {
        constructor() {
            super(), this._bufferState = new it, this._bufferStateInvertUV = new it;
            var e = t.LayaGL.instance;
            this._vertexBuffer = new _t(48, e.STATIC_DRAW, !1), this._vertexBuffer.vertexDeclaration = Tt._vertexDeclaration, this._vertexBuffer.setData(Tt._vertices.buffer), this._bufferState.bind(), this._bufferState.applyVertexBuffer(this._vertexBuffer), this._bufferState.unBind(), this._vertexBufferInvertUV = new _t(48, e.STATIC_DRAW, !1), this._vertexBufferInvertUV.vertexDeclaration = Tt._vertexDeclaration, this._vertexBufferInvertUV.setData(Tt._verticesInvertUV.buffer), this._bufferStateInvertUV.bind(), this._bufferStateInvertUV.applyVertexBuffer(this._vertexBufferInvertUV), this._bufferStateInvertUV.unBind(), this._setGPUMemory(this._vertexBuffer._byteLength + this._vertexBufferInvertUV._byteLength)
        }
        static __init__() {
            Tt._vertexDeclaration = new st(16, [new ot(0, at.Vector4, Tt.SCREENTRIANGLE_POSITION_UV)]), Tt.instance = new Tt, Tt.instance.lock = !0
        }
        render() {
            var e = t.LayaGL.instance;
            this._bufferState.bind(), e.drawArrays(e.TRIANGLES, 0, 3), t.Stat.renderBatches++
        }
        renderInvertUV() {
            var e = t.LayaGL.instance;
            this._bufferStateInvertUV.bind(), e.drawArrays(e.TRIANGLES, 0, 3), t.Stat.renderBatches++
        }
        destroy() {
            super.destroy(), this._bufferState.destroy(), this._vertexBuffer.destroy(), this._bufferStateInvertUV.destroy(), this._vertexBufferInvertUV.destroy(), this._setGPUMemory(0)
        }
    }
    Tt.SCREENTRIANGLE_POSITION_UV = 0, Tt._vertices = new Float32Array([-1, -1, 0, 0, -1, 3, 0, 2, 3, -1, 2, 0]), Tt._verticesInvertUV = new Float32Array([-1, -1, 0, 1, -1, 3, 0, -1, 3, -1, 2, 1]);
    class Et {
        constructor() {
            this._commandBuffer = null
        }
        static __init__() {
            Et._screenShaderData = new ce, Et._screenShader = he.find("BlitScreen")
        }
        run() {}
        recover() {
            this._commandBuffer = null
        }
    }
    Et.SCREENTEXTURE_NAME = "u_MainTex", Et.SCREENTEXTUREOFFSETSCALE_NAME = "u_OffsetScale", Et.MAINTEXTURE_TEXELSIZE_NAME = "u_MainTex_TexelSize", Et.SCREENTEXTURE_ID = he.propertyNameToID(Et.SCREENTEXTURE_NAME), Et.SCREENTEXTUREOFFSETSCALE_ID = he.propertyNameToID(Et.SCREENTEXTUREOFFSETSCALE_NAME), Et.MAINTEXTURE_TEXELSIZE_ID = he.propertyNameToID(Et.MAINTEXTURE_TEXELSIZE_NAME);
    class pt extends Et {
        constructor() {
            super(...arguments), this._source = null, this._dest = null, this._offsetScale = null, this._shader = null, this._shaderData = null, this._subShader = 0, this._sourceTexelSize = new n, this._screenType = 0
        }
        static create(e, t, r = null, i = null, n = null, a = 0, s = pt._SCREENTYPE_QUAD) {
            var o;
            return (o = pt._pool.length &gt; 0 ? pt._pool.pop() : new pt)._source = e, o._dest = t, o._offsetScale = r, o._shader = i, o._shaderData = n, o._subShader = a, o._screenType = s, o
        }
        run() {
            var e = this._shader || Et._screenShader,
                r = this._shaderData || Et._screenShaderData,
                i = this._dest;
            t.LayaGL.instance.viewport(0, 0, i ? i.width : ne.clientWidth, i ? i.height : ne.clientHeight), r.setTexture(Et.SCREENTEXTURE_ID, this._source), r.setVector(Et.SCREENTEXTUREOFFSETSCALE_ID, this._offsetScale || pt._defaultOffsetScale), this._sourceTexelSize.setValue(1 / this._source.width, 1 / this._source.height, this._source.width, this._source.height), r.setVector(Et.MAINTEXTURE_TEXELSIZE_ID, this._sourceTexelSize), i &amp;&amp; i._start();
            for (var n = e.getSubShaderAt(this._subShader)._passes, a = 0, s = n.length; a &lt; s; a++) {
                var o = pt._compileDefine;
                r._defineDatas.cloneTo(o);
                var l = n[a].withCompile(o);
                switch (l.bind(), l.uploadUniforms(l._materialUniformParamsMap, r, !0), l.uploadRenderStateBlendDepth(r), l.uploadRenderStateFrontFace(r, !1, null), this._screenType) {
                    case pt._SCREENTYPE_QUAD:
                        ne._instance.invertY ? ft.instance.renderInvertUV() : ft.instance.render();
                        break;
                    case pt._SCREENTYPE_TRIANGLE:
                        ne._instance.invertY ? Tt.instance.renderInvertUV() : Tt.instance.render();
                        break;
                    default:
                        throw "BlitScreenQuadCMD:unknown screen Type."
                }
            }
            i &amp;&amp; i._end()
        }
        recover() {
            pt._pool.push(this), this._source = null, this._dest = null, this._offsetScale = null, this._shader = null, this._shaderData = null, super.recover()
        }
    }
    pt._SCREENTYPE_QUAD = 0, pt._SCREENTYPE_TRIANGLE = 1, pt._compileDefine = new se, pt._pool = [], pt._defaultOffsetScale = new n(0, 0, 1, 1);
    class gt extends Et {
        constructor() {
            super(...arguments), this._renderTexture = null
        }
        static create(e) {
            var t;
            return (t = gt._pool.length &gt; 0 ? gt._pool.pop() : new gt)._renderTexture = e, t
        }
        run() {
            this._renderTexture._start()
        }
        recover() {
            gt._pool.push(this), this._renderTexture = null
        }
    }
    gt._pool = [];
    class St extends Et {
        constructor() {
            super(...arguments), this._shaderData = null, this._nameID = 0, this._texture = null
        }
        static create(e, t, r) {
            var i;
            return (i = St._pool.length &gt; 0 ? St._pool.pop() : new St)._shaderData = e, i._nameID = t, i._texture = r, i
        }
        run() {
            this._shaderData.setTexture(this._nameID, this._texture)
        }
        recover() {
            St._pool.push(this), this._shaderData = null, this._nameID = 0, this._texture = null
        }
    }
    St._pool = [];
    class Rt {
        constructor() {
            this._camera = null, this._commands = []
        }
        _apply() {
            for (var e = 0, t = this._commands.length; e &lt; t; e++) this._commands[e].run()
        }
        setShaderDataTexture(e, t, r) {
            this._commands.push(St.create(e, t, r))
        }
        blitScreenQuad(e, t, r = null, i = null, n = null, a = 0) {
            this._commands.push(pt.create(e, t, r, i, n, a, pt._SCREENTYPE_QUAD))
        }
        blitScreenTriangle(e, t, r = null, i = null, n = null, a = 0) {
            this._commands.push(pt.create(e, t, r, i, n, a, pt._SCREENTYPE_TRIANGLE))
        }
        setRenderTarget(e) {
            this._commands.push(gt.create(e))
        }
        clear() {
            for (var e = 0, t = this._commands.length; e &lt; t; e++) this._commands[e].recover();
            this._commands.length = 0
        }
    }
    class vt {}(Le = e.LightType || (e.LightType = {}))[Le.Directional = 0] = "Directional", Le[Le.Spot = 1] = "Spot", Le[Le.Point = 2] = "Point";
    class At extends ut {
        constructor() {
            super(), this._shadowMode = e.ShadowMode.None, this._isAlternate = !1, this._shadowResolution = 2048, this._shadowDistance = 50, this._shadowDepthBias = 1, this._shadowNormalBias = 1, this._shadowNearPlane = .1, this._shadowStrength = 1, this._intensity = 1, this._intensityColor = new a, this.color = new a(1, 1, 1), this._lightmapBakedType = At.LIGHTMAPBAKEDTYPE_REALTIME
        }
        get intensity() {
            return this._intensity
        }
        set intensity(e) {
            this._intensity = e
        }
        get shadowMode() {
            return this._shadowMode
        }
        set shadowMode(e) {
            this._shadowMode = e
        }
        get shadowDistance() {
            return this._shadowDistance
        }
        set shadowDistance(e) {
            this._shadowDistance = e
        }
        get shadowResolution() {
            return this._shadowResolution
        }
        set shadowResolution(e) {
            this._shadowResolution = e
        }
        get shadowDepthBias() {
            return this._shadowDepthBias
        }
        set shadowDepthBias(e) {
            this._shadowDepthBias = e
        }
        get shadowNormalBias() {
            return this._shadowNormalBias
        }
        set shadowNormalBias(e) {
            this._shadowNormalBias = e
        }
        get shadowStrength() {
            return this._shadowStrength
        }
        set shadowStrength(e) {
            this._shadowStrength = e
        }
        get shadowNearPlane() {
            return this._shadowNearPlane
        }
        set shadowNearPlane(e) {
            this._shadowNearPlane = e
        }
        get lightmapBakedType() {
            return this._lightmapBakedType
        }
        set lightmapBakedType(e) {
            this._lightmapBakedType !== e &amp;&amp; (this._lightmapBakedType = e, this.activeInHierarchy &amp;&amp; (e !== At.LIGHTMAPBAKEDTYPE_BAKED ? this._addToScene() : this._removeFromScene()))
        }
        _parse(e, t) {
            super._parse(e, t);
            var r = e.color;
            this.color.fromArray(r), this.intensity = e.intensity, this.lightmapBakedType = e.lightmapBakedType
        }
        _addToScene() {
            var e = this._scene,
                t = B._config.maxLightCount;
            e._lightCount &lt; t ? (e._lightCount++, this._addToLightQueue(), this._isAlternate = !1) : (e._alternateLights.add(this), this._isAlternate = !0, console.warn("LightSprite:light count has large than maxLightCount,the latest added light will be ignore."))
        }
        _removeFromScene() {
            var e = this._scene;
            if (this._isAlternate) e._alternateLights.remove(this);
            else if (e._lightCount--, this._removeFromLightQueue(), e._alternateLights._length &gt; 0) {
                var t = e._alternateLights.shift();
                t._addToLightQueue(), t._isAlternate = !1, e._lightCount++
            }
        }
        _addToLightQueue() {}
        _removeFromLightQueue() {}
        _onActive() {
            super._onActive(), this.lightmapBakedType !== At.LIGHTMAPBAKEDTYPE_BAKED &amp;&amp; this._addToScene()
        }
        _onInActive() {
            super._onInActive(), this.lightmapBakedType !== At.LIGHTMAPBAKEDTYPE_BAKED &amp;&amp; this._removeFromScene()
        }
        _create() {
            return new At
        }
        get diffuseColor() {
            return console.log("LightSprite: discard property,please use color property instead."), this.color
        }
        set diffuseColor(e) {
            console.log("LightSprite: discard property,please use color property instead."), this.color = e
        }
    }
    At.LIGHTMAPBAKEDTYPE_REALTIME = 0, At.LIGHTMAPBAKEDTYPE_MIXED = 1, At.LIGHTMAPBAKEDTYPE_BAKED = 2, (De = e.ShadowCascadesMode || (e.ShadowCascadesMode = {}))[De.NoCascades = 0] = "NoCascades", De[De.TwoCascades = 1] = "TwoCascades", De[De.FourCascades = 2] = "FourCascades",
        function(e) {
            e[e.Near = 0] = "Near", e[e.Far = 1] = "Far", e[e.Left = 2] = "Left", e[e.Right = 3] = "Right", e[e.Bottom = 4] = "Bottom", e[e.Top = 5] = "Top"
        }(Ce || (Ce = {}));
    class It {
        static supportShadow() {
            return t.LayaGL.layaGPUInstance._isWebGL2 || t.SystemUtils.supportRenderTextureFormat(t.RenderTextureFormat.Depth)
        }
        static init() {
            t.LayaGL.layaGPUInstance._isWebGL2 ? It._shadowTextureFormat = t.RenderTextureFormat.ShadowMap : It._shadowTextureFormat = t.RenderTextureFormat.Depth
        }
        static getTemporaryShadowTexture(e, r, i) {
            var n = ae.createFromPool(e, r, It._shadowTextureFormat, i);
            return n.filterMode = t.FilterMode.Bilinear, n.wrapModeU = t.WarpMode.Clamp, n.wrapModeV = t.WarpMode.Clamp, n
        }
        static getShadowBias(t, i, n, a) {
            var s;
            t._lightType == e.LightType.Directional ? s = 2 / i.elements[0] : t._lightType == e.LightType.Spot ? s = Math.tan(.5 * t.spotAngle * r.Deg2Rad) * t.range : (console.warn("ShadowUtils:Only spot and directional shadow casters are supported now."), s = 0);
            var o = s / n,
                l = -t._shadowDepthBias * o,
                _ = -t._shadowNormalBias * o;
            if (t.shadowMode == e.ShadowMode.SoftHigh) {
                const e = 2.5;
                l *= e, _ *= e
            }
            a.setValue(l, _, 0, 0)
        }
        static getCameraFrustumPlanes(e, t) {
            et.getPlanesFromMatrix(e, t[Ce.Near], t[Ce.Far], t[Ce.Left], t[Ce.Right], t[Ce.Top], t[Ce.Bottom])
        }
        static getFarWithRadius(e, t) {
            return Math.sqrt(e * e / t)
        }
        static getCascadesSplitDistance(t, r, i, n, a, s, o, l) {
            l[0] = i;
            var _ = n - i,
                h = Math.tan(.5 * a),
                c = 1 + h * h * (s * s + 1);
            switch (o) {
                case e.ShadowCascadesMode.NoCascades:
                    l[1] = It.getFarWithRadius(n, c);
                    break;
                case e.ShadowCascadesMode.TwoCascades:
                    l[1] = It.getFarWithRadius(i + _ * t, c), l[2] = It.getFarWithRadius(n, c);
                    break;
                case e.ShadowCascadesMode.FourCascades:
                    l[1] = It.getFarWithRadius(i + _ * r.x, c), l[2] = It.getFarWithRadius(i + _ * r.y, c), l[3] = It.getFarWithRadius(i + _ * r.z, c), l[4] = It.getFarWithRadius(n, c)
            }
        }
        static applySliceTransform(e, t, r, i, n) {
            var a = It._tempMatrix0.elements,
                s = 1 / t,
                o = 1 / r;
            a[0] = e.resolution * s, a[5] = e.resolution * o, a[12] = e.offsetX * s, a[13] = e.offsetY * o, a[1] = a[2] = a[2] = a[4] = a[6] = a[7] = a[8] = a[9] = a[11] = a[14] = 0, a[10] = a[15] = 1;
            var l = 16 * i;
            N._mulMatrixArray(a, n, l, n, l)
        }
        static getDirectionLightShadowCullPlanes(t, r, i, n, s, o) {
            var l = It._frustumCorners,
                _ = It._backPlaneFaces,
                h = It._frustumPlaneNeighbors,
                c = It._frustumTwoPlaneCorners,
                d = It._edgePlanePoint2,
                u = o.cullPlanes,
                m = t[Ce.Near],
                f = t[Ce.Far],
                T = t[Ce.Left],
                E = t[Ce.Right],
                p = t[Ce.Bottom],
                g = t[Ce.Top],
                S = i[r] - n,
                R = It._adjustNearPlane,
                v = It._adjustFarPlane;
            m.normal.cloneTo(R.normal), f.normal.cloneTo(v.normal), R.distance = m.distance - S, v.distance = Math.min(-m.distance + o.sphereCenterZ + o.splitBoundSphere.radius, f.distance), et.get3PlaneInterPoint(R, p, E, l[e.FrustumCorner.nearBottomRight]), et.get3PlaneInterPoint(R, g, E, l[e.FrustumCorner.nearTopRight]), et.get3PlaneInterPoint(R, g, T, l[e.FrustumCorner.nearTopLeft]), et.get3PlaneInterPoint(R, p, T, l[e.FrustumCorner.nearBottomLeft]), et.get3PlaneInterPoint(v, p, E, l[e.FrustumCorner.FarBottomRight]), et.get3PlaneInterPoint(v, g, E, l[e.FrustumCorner.FarTopRight]), et.get3PlaneInterPoint(v, g, T, l[e.FrustumCorner.FarTopLeft]), et.get3PlaneInterPoint(v, p, T, l[e.FrustumCorner.FarBottomLeft]);
            for (var A = 0, I = 0; I &lt; 6; I++) {
                var x;
                switch (I) {
                    case Ce.Near:
                        x = R;
                        break;
                    case Ce.Far:
                        x = v;
                        break;
                    default:
                        x = t[I]
                }
                a.dot(x.normal, s) &lt; 0 &amp;&amp; (x.cloneTo(u[A]), _[A] = I, A++)
            }
            var L = A;
            for (I = 0; I &lt; A; I++)
                for (var D = _[I], C = h[D], y = 0; y &lt; 4; y++) {
                    for (var M = C[y], O = !0, N = 0; N &lt; A; N++)
                        if (M == _[N]) {
                            O = !1;
                            break
                        }
                    if (O) {
                        var b = c[D][M],
                            P = l[b[0]],
                            w = l[b[1]];
                        a.add(P, s, d), Qe.createPlaneBy3P(P, w, d, u[L++])
                    }
                }
            o.cullPlaneCount = L
        }
        static getBoundSphereByFrustum(e, t, r, i, n, s, o) {
            var l, _, h = Math.sqrt(1 + i * i) * Math.tan(r / 2),
                c = h * h,
                d = t - e,
                u = t + e;
            c &gt; d / u ? (l = t, _ = t * h) : (l = .5 * u * (1 + c), _ = .5 * Math.sqrt(d * d + 2 * (t * t + e * e) * c + u * u * c * c));
            var m = o.center;
            return o.radius = _, a.scale(s, l, m), a.add(n, m, m), l
        }
        static getMaxTileResolutionInAtlas(e, t, r) {
            for (var i = Math.min(e, t), n = Math.floor(e / i) * Math.floor(t / i); n &lt; r;) i = Math.floor(i &gt;&gt; 1), n = Math.floor(e / i) * Math.floor(t / i);
            return i
        }
        static getDirectionalLightMatrices(e, t, r, i, n, s, o, l) {
            var _ = o.splitBoundSphere,
                h = _.center,
                d = _.radius,
                u = s / 2,
                m = d * u / (u - It.atlasBorderSize),
                f = 2 * m,
                T = s / f,
                E = f / s,
                p = Math.ceil(a.dot(h, e) * T) * E,
                g = Math.ceil(a.dot(h, t) * T) * E,
                S = a.dot(h, r);
            h.x = e.x * p + t.x * g + r.x * S, h.y = e.y * p + t.y * g + r.y * S, h.z = e.z * p + t.z * g + r.z * S;
            var R = o.position,
                v = o.viewMatrix,
                A = o.projectionMatrix,
                I = o.viewProjectMatrix;
            o.resolution = s, o.offsetX = i % 2 * s, o.offsetY = Math.floor(i / 2) * s, a.scale(r, d + n, R), a.subtract(h, R, R), c.createLookAt(R, h, e, v), c.createOrthoOffCenter(-m, m, -m, m, 0, 2 * d + n, A), c.multiply(A, v, I), N._mulMatrixArray(It._shadowMapScaleOffsetMatrix.elements, I.elements, 0, l, 16 * i)
        }
        static getSpotLightShadowData(e, t, r, i, n, a) {
            var s = e.position = t.transform.position;
            e.resolution = r, a.setValue(1 / r, 1 / r, r, r), e.offsetX = 0, e.offsetY = 0;
            var o = t.transform.worldMatrix,
                l = e.viewMatrix,
                _ = e.projectionMatrix,
                h = e.viewProjectMatrix,
                d = e.cameraCullInfo.boundFrustum;
            o.invert(l), c.createPerspective(3.1416 * t.spotAngle / 180, 1, .1, t.range, _), i.y = t.shadowStrength, c.multiply(_, l, h), d.matrix = h, h.cloneTo(n), e.cameraCullInfo.position = s
        }
        static prepareShadowReceiverShaderValues(e, t, r, i, n, a, s, o, l) {
            if (a.setValue(1 / t, 1 / r, t, r), s.setValue(e._shadowStrength, 0, 0, 0), n &gt; 1) {
                const e = 16;
                for (var _ = n * e, h = 4 * e; _ &lt; h; _++) o[_] = 0;
                for (_ = 0; _ &lt; n; _++) {
                    var c = i[_].splitBoundSphere,
                        d = c.center,
                        u = c.radius,
                        m = 4 * _;
                    l[m] = d.x, l[m + 1] = d.y, l[m + 2] = d.z, l[m + 3] = u * u
                }
                const t = 4;
                for (_ = n * t, h = 4 * t; _ &lt; h; _++) l[_] = 0
            }
        }
    }
    It._tempMatrix0 = new c, It._shadowMapScaleOffsetMatrix = new c(.5, 0, 0, 0, 0, .5, 0, 0, 0, 0, 1, 0, .5, .5, 0, 1), It._frustumCorners = [new a, new a, new a, new a, new a, new a, new a, new a], It._adjustNearPlane = new Qe(new a), It._adjustFarPlane = new Qe(new a), It._backPlaneFaces = new Array(5), It._edgePlanePoint2 = new a, It._frustumPlaneNeighbors = [
        [Ce.Left, Ce.Right, Ce.Top, Ce.Bottom],
        [Ce.Left, Ce.Right, Ce.Top, Ce.Bottom],
        [Ce.Near, Ce.Far, Ce.Top, Ce.Bottom],
        [Ce.Near, Ce.Far, Ce.Top, Ce.Bottom],
        [Ce.Near, Ce.Far, Ce.Left, Ce.Right],
        [Ce.Near, Ce.Far, Ce.Left, Ce.Right]
    ], It._frustumTwoPlaneCorners = [
        [
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown],
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown],
            [e.FrustumCorner.nearBottomLeft, e.FrustumCorner.nearTopLeft],
            [e.FrustumCorner.nearTopRight, e.FrustumCorner.nearBottomRight],
            [e.FrustumCorner.nearBottomRight, e.FrustumCorner.nearBottomLeft],
            [e.FrustumCorner.nearTopLeft, e.FrustumCorner.nearTopRight]
        ],
        [
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown],
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown],
            [e.FrustumCorner.FarTopLeft, e.FrustumCorner.FarBottomLeft],
            [e.FrustumCorner.FarBottomRight, e.FrustumCorner.FarTopRight],
            [e.FrustumCorner.FarBottomLeft, e.FrustumCorner.FarBottomRight],
            [e.FrustumCorner.FarTopRight, e.FrustumCorner.FarTopLeft]
        ],
        [
            [e.FrustumCorner.nearTopLeft, e.FrustumCorner.nearBottomLeft],
            [e.FrustumCorner.FarBottomLeft, e.FrustumCorner.FarTopLeft],
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown],
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown],
            [e.FrustumCorner.nearBottomLeft, e.FrustumCorner.FarBottomLeft],
            [e.FrustumCorner.FarTopLeft, e.FrustumCorner.nearTopLeft]
        ],
        [
            [e.FrustumCorner.nearBottomRight, e.FrustumCorner.nearTopRight],
            [e.FrustumCorner.FarTopRight, e.FrustumCorner.FarBottomRight],
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown],
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown],
            [e.FrustumCorner.FarBottomRight, e.FrustumCorner.nearBottomRight],
            [e.FrustumCorner.nearTopRight, e.FrustumCorner.FarTopRight]
        ],
        [
            [e.FrustumCorner.nearBottomLeft, e.FrustumCorner.nearBottomRight],
            [e.FrustumCorner.FarBottomRight, e.FrustumCorner.FarBottomLeft],
            [e.FrustumCorner.FarBottomLeft, e.FrustumCorner.nearBottomLeft],
            [e.FrustumCorner.nearBottomRight, e.FrustumCorner.FarBottomRight],
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown],
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown]
        ],
        [
            [e.FrustumCorner.nearTopRight, e.FrustumCorner.nearTopLeft],
            [e.FrustumCorner.FarTopLeft, e.FrustumCorner.FarTopRight],
            [e.FrustumCorner.nearTopLeft, e.FrustumCorner.FarTopLeft],
            [e.FrustumCorner.FarTopRight, e.FrustumCorner.nearTopRight],
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown],
            [e.FrustumCorner.unknown, e.FrustumCorner.unknown]
        ]
    ], It.atlasBorderSize = 4, (ye = e.CameraClearFlags || (e.CameraClearFlags = {}))[ye.SolidColor = 0] = "SolidColor", ye[ye.Sky = 1] = "Sky", ye[ye.DepthOnly = 2] = "DepthOnly", ye[ye.Nothing = 3] = "Nothing";
    class xt extends mt {
        constructor(r = 0, a = .3, s = 1e3) {
            super(a, s), this._updateViewMatrix = !0, this._postProcess = null, this._enableHDR = !1, this._viewportParams = new n, this._projectionParams = new n, this._offScreenRenderTexture = null, this._internalRenderTexture = null, this._postProcessCommandBuffers = [], this._clusterPlaneCacheFlag = new i(-1, -1), this._screenOffsetScale = new n, this.enableRender = !0, this.clearFlag = e.CameraClearFlags.SolidColor, this._viewMatrix = new c, this._projectionMatrix = new c, this._projectionViewMatrix = new c, this._viewport = new tt(0, 0, 0, 0), this._normalizedViewport = new tt(0, 0, 1, 1), this._aspectRatio = r, this._boundFrustum = new et(new c), t.Render.supportWebGLPlusCulling &amp;&amp; (this._boundFrustumBuffer = new Float32Array(24)), this._calculateProjectionMatrix(), t.Laya.stage.on(t.Event.RESIZE, this, this._onScreenSizeChanged), this.transform.on(t.Event.TRANSFORM_CHANGED, this, this._onTransformChanged)
        }
        get aspectRatio() {
            if (0 === this._aspectRatio) {
                var e = this.viewport;
                return e.width / e.height
            }
            return this._aspectRatio
        }
        set aspectRatio(e) {
            if (e &lt; 0) throw new Error("Camera: the aspect ratio has to be a positive real number.");
            this._aspectRatio = e, this._calculateProjectionMatrix()
        }
        get viewport() {
            return this._offScreenRenderTexture ? this._calculationViewport(this._normalizedViewport, this._offScreenRenderTexture.width, this._offScreenRenderTexture.height) : this._calculationViewport(this._normalizedViewport, ne.clientWidth, ne.clientHeight), this._viewport
        }
        set viewport(e) {
            var t, r;
            this._offScreenRenderTexture ? (t = this._offScreenRenderTexture.width, r = this._offScreenRenderTexture.height) : (t = ne.clientWidth, r = ne.clientHeight), this._normalizedViewport.x = e.x / t, this._normalizedViewport.y = e.y / r, this._normalizedViewport.width = e.width / t, this._normalizedViewport.height = e.height / r, this._calculationViewport(this._normalizedViewport, t, r), this._calculateProjectionMatrix()
        }
        get normalizedViewport() {
            return this._normalizedViewport
        }
        set normalizedViewport(e) {
            var t, r;
            this._offScreenRenderTexture ? (t = this._offScreenRenderTexture.width, r = this._offScreenRenderTexture.height) : (t = ne.clientWidth, r = ne.clientHeight), this._normalizedViewport !== e &amp;&amp; e.cloneTo(this._normalizedViewport), this._calculationViewport(e, t, r), this._calculateProjectionMatrix()
        }
        get viewMatrix() {
            if (this._updateViewMatrix) {
                var e = this.transform.getWorldLossyScale(),
                    t = e.x,
                    r = e.y,
                    i = e.z,
                    n = this._viewMatrix.elements;
                this.transform.worldMatrix.cloneTo(this._viewMatrix), n[0] /= t, n[1] /= t, n[2] /= t, n[4] /= r, n[5] /= r, n[6] /= r, n[8] /= i, n[9] /= i, n[10] /= i, this._viewMatrix.invert(this._viewMatrix), this._updateViewMatrix = !1
            }
            return this._viewMatrix
        }
        get projectionMatrix() {
            return this._projectionMatrix
        }
        set projectionMatrix(e) {
            this._projectionMatrix = e, this._useUserProjectionMatrix = !0
        }
        get projectionViewMatrix() {
            return c.multiply(this.projectionMatrix, this.viewMatrix, this._projectionViewMatrix), this._projectionViewMatrix
        }
        get boundFrustum() {
            if (this._boundFrustum.matrix = this.projectionViewMatrix, t.Render.supportWebGLPlusCulling) {
                var e = this._boundFrustum.near,
                    r = this._boundFrustum.far,
                    i = this._boundFrustum.left,
                    n = this._boundFrustum.right,
                    a = this._boundFrustum.top,
                    s = this._boundFrustum.bottom,
                    o = e.normal,
                    l = r.normal,
                    _ = i.normal,
                    h = n.normal,
                    c = a.normal,
                    d = s.normal,
                    u = this._boundFrustumBuffer;
                u[0] = o.x, u[1] = o.y, u[2] = o.z, u[3] = e.distance, u[4] = l.x, u[5] = l.y, u[6] = l.z, u[7] = r.distance, u[8] = _.x, u[9] = _.y, u[10] = _.z, u[11] = i.distance, u[12] = h.x, u[13] = h.y, u[14] = h.z, u[15] = n.distance, u[16] = c.x, u[17] = c.y, u[18] = c.z, u[19] = a.distance, u[20] = d.x, u[21] = d.y, u[22] = d.z, u[23] = s.distance
            }
            return this._boundFrustum
        }
        get renderTarget() {
            return this._offScreenRenderTexture
        }
        set renderTarget(e) {
            var t = this._offScreenRenderTexture;
            t !== e &amp;&amp; (t &amp;&amp; (t._isCameraTarget = !1), e &amp;&amp; (e._isCameraTarget = !0), this._offScreenRenderTexture = e, this._calculateProjectionMatrix())
        }
        get postProcess() {
            return this._postProcess
        }
        set postProcess(e) {
            this._postProcess = e;
            var t = new Rt;
            this.addCommandBuffer(xt.CAMERAEVENT_POSTPROCESS, t), e._init(this, t)
        }
        get enableHDR() {
            return this._enableHDR
        }
        set enableHDR(e) {
            !e || t.SystemUtils.supportRenderTextureFormat(t.RenderTextureFormat.R16G16B16A16) ? this._enableHDR = e : console.warn("Camera:can't enable HDR in this device.")
        }
        _calculationViewport(e, t, r) {
            var i = e.x * t,
                n = e.y * r,
                a = i + Math.max(e.width * t, 0),
                s = n + Math.max(e.height * r, 0),
                o = Math.ceil(i),
                l = Math.ceil(n),
                _ = Math.floor(a),
                h = Math.floor(s),
                c = o - i &gt;= .5 ? Math.floor(i) : o,
                d = l - n &gt;= .5 ? Math.floor(n) : l,
                u = a - _ &gt;= .5 ? Math.ceil(a) : _,
                m = s - h &gt;= .5 ? Math.ceil(s) : h;
            this._viewport.x = c, this._viewport.y = d, this._viewport.width = u - c, this._viewport.height = m - d
        }
        _calculateProjectionMatrix() {
            if (!this._useUserProjectionMatrix)
                if (this._orthographic) {
                    var e = .5 * this.orthographicVerticalSize,
                        t = e * this.aspectRatio;
                    c.createOrthoOffCenter(-t, t, -e, e, this.nearPlane, this.farPlane, this._projectionMatrix)
                } else c.createPerspective(3.1416 * this.fieldOfView / 180, this.aspectRatio, this.nearPlane, this.farPlane, this._projectionMatrix)
        }
        _isLayerVisible(e) {
            return 0 != (Math.pow(2, e) &amp; this.cullingMask)
        }
        _onTransformChanged(e) {
            (e &amp;= f.TRANSFORM_WORLDMATRIX) &amp;&amp; (this._updateViewMatrix = !0)
        }
        _parse(e, t) {
            super._parse(e, t);
            var r = e.clearFlag;
            void 0 !== r &amp;&amp; (this.clearFlag = r);
            var i = e.viewport;
            this.normalizedViewport = new tt(i[0], i[1], i[2], i[3]);
            var n = e.enableHDR;
            void 0 !== n &amp;&amp; (this.enableHDR = n)
        }
        _getCanvasWidth() {
            return this._offScreenRenderTexture ? this._offScreenRenderTexture.width : ne.clientWidth
        }
        _getCanvasHeight() {
            return this._offScreenRenderTexture ? this._offScreenRenderTexture.height : ne.clientHeight
        }
        _getRenderTexture() {
            return this._internalRenderTexture || this._offScreenRenderTexture
        }
        _needInternalRenderTexture() {
            return !(!this._postProcess &amp;&amp; !this._enableHDR)
        }
        _applyPostProcessCommandBuffers() {
            for (var e = 0, t = this._postProcessCommandBuffers.length; e &lt; t; e++) this._postProcessCommandBuffers[e]._apply()
        }
        _getRenderTextureFormat() {
            return this._enableHDR ? t.RenderTextureFormat.R16G16B16A16 : t.RenderTextureFormat.R8G8B8
        }
        _prepareCameraToRender() {
            super._prepareCameraToRender();
            var e = this.viewport;
            this._viewportParams.setValue(e.x, e.y, e.width, e.height), this._projectionParams.setValue(this._nearPlane, this._farPlane, ne._instance.invertY ? -1 : 1, 0), this._shaderValues.setVector(mt.VIEWPORT, this._viewportParams), this._shaderValues.setVector(mt.PROJECTION_PARAMS, this._projectionParams)
        }
        _applyViewProject(e, t, r) {
            var i, n = this._shaderValues;
            e.invertY ? (c.multiply(mt._invertYScaleMatrix, r, mt._invertYProjectionMatrix), c.multiply(mt._invertYProjectionMatrix, t, mt._invertYProjectionViewMatrix), r = mt._invertYProjectionMatrix, i = mt._invertYProjectionViewMatrix) : (c.multiply(r, t, this._projectionViewMatrix), i = this._projectionViewMatrix), e.viewMatrix = t, e.projectionMatrix = r, e.projectionViewMatrix = i, n.setMatrix4x4(mt.VIEWMATRIX, t), n.setMatrix4x4(mt.PROJECTMATRIX, r), n.setMatrix4x4(mt.VIEWPROJECTMATRIX, i)
        }
        _updateClusterPlaneXY() {
            var e = this.fieldOfView,
                t = this.aspectRatio;
            if (this._clusterPlaneCacheFlag.x !== e || this._clusterPlaneCacheFlag.y !== t) {
                var r = B._config.lightClusterCount,
                    i = r.x,
                    n = r.y,
                    s = i + 1,
                    o = n + 1,
                    l = this._clusterXPlanes,
                    _ = this._clusterYPlanes;
                if (!l) {
                    l = this._clusterXPlanes = new Array(s), _ = this._clusterYPlanes = new Array(o);
                    for (var h = 0; h &lt; s; h++) l[h] = new a;
                    for (h = 0; h &lt; o; h++) _[h] = new a
                }
                var c = Math.tan(this.fieldOfView / 2 * Math.PI / 180),
                    d = this.aspectRatio * c,
                    u = 2 * c / i,
                    m = 2 * d / n;
                for (h = 0; h &lt; s; h++) {
                    var f = m * h - d,
                        T = 1 / Math.sqrt(1 + f * f);
                    l[h].setValue(T, 0, -f * T)
                }
                for (h = 0; h &lt; o; h++) {
                    f = c - u * h;
                    var E = -1 / Math.sqrt(1 + f * f);
                    _[h].setValue(0, E, -f * E)
                }
                this._clusterPlaneCacheFlag.x = e, this._clusterPlaneCacheFlag.y = t
            }
        }
        render(r = null, i = null) {
            if (this.activeInHierarchy) {
                var n, a = this.viewport,
                    s = this._needInternalRenderTexture(),
                    o = t.LayaGL.instance,
                    l = ne._instance,
                    h = l.scene = this._scene;
                l.pipelineMode = "Forward", s ? (this._internalRenderTexture = ae.createFromPool(a.width, a.height, this._getRenderTextureFormat(), t.RenderTextureDepthFormat.DEPTH_16), this._internalRenderTexture.filterMode = t.FilterMode.Bilinear) : this._internalRenderTexture = null;
                var c = h._mainDirectionLight,
                    d = c &amp;&amp; c.shadowMode !== e.ShadowMode.None &amp;&amp; It.supportShadow();
                d ? (h._shaderValues.removeDefine(vt.SHADERDEFINE_SHADOW_SPOT), h._shaderValues.addDefine(vt.SHADERDEFINE_SHADOW), (n = _.Scene3D._shadowCasterPass).update(this, c, _.ShadowLightType.DirectionLight), n.render(l, h, _.ShadowLightType.DirectionLight)) : h._shaderValues.removeDefine(vt.SHADERDEFINE_SHADOW);
                var u = h._mainSpotLight,
                    m = u &amp;&amp; u.shadowMode !== e.ShadowMode.None &amp;&amp; It.supportShadow();
                if (m ? (h._shaderValues.removeDefine(vt.SHADERDEFINE_SHADOW), h._shaderValues.addDefine(vt.SHADERDEFINE_SHADOW_SPOT), (n = _.Scene3D._shadowCasterPass).update(this, u, _.ShadowLightType.SpotLight), n.render(l, h, _.ShadowLightType.SpotLight)) : h._shaderValues.removeDefine(vt.SHADERDEFINE_SHADOW_SPOT), d &amp;&amp; h._shaderValues.addDefine(vt.SHADERDEFINE_SHADOW), m &amp;&amp; h._shaderValues.addDefine(vt.SHADERDEFINE_SHADOW_SPOT), l.camera = this, l.cameraShaderValue = this._shaderValues, xt._updateMark++, h._preRenderScript(), s &amp;&amp; !this._offScreenRenderTexture &amp;&amp; (this.clearFlag == e.CameraClearFlags.DepthOnly || this.clearFlag == e.CameraClearFlags.Nothing))
                    if (this._enableHDR) {
                        var f = ae.createFromPool(a.width, a.height, t.RenderTextureFormat.R8G8B8, t.RenderTextureDepthFormat.DEPTH_16);
                        f.filterMode = t.FilterMode.Bilinear, t.WebGLContext.bindTexture(o, o.TEXTURE_2D, f._getSource()), o.copyTexSubImage2D(o.TEXTURE_2D, 0, 0, 0, a.x, ne.clientHeight - (a.y + a.height), a.width, a.height), (E = pt.create(f, this._internalRenderTexture)).run(), E.recover(), ae.recoverToPool(f)
                    } else t.WebGLContext.bindTexture(o, o.TEXTURE_2D, this._internalRenderTexture._getSource()), o.copyTexSubImage2D(o.TEXTURE_2D, 0, 0, 0, a.x, ne.clientHeight - (a.y + a.height), a.width, a.height);
                var T = this._getRenderTexture();
                if (T &amp;&amp; T._start(), l.viewport = a, this._prepareCameraToRender(), B._config._multiLighting &amp;&amp; Ye.instance.update(this, this._scene), this._applyViewProject(l, this.viewMatrix, this._projectionMatrix), h._preCulling(l, this, r, i), h._clear(o, l), h._renderScene(l), h._postRenderScript(), T &amp;&amp; T._end(), s) {
                    if (this._postProcess) this._postProcess._render(), this._applyPostProcessCommandBuffers();
                    else if (this._enableHDR) {
                        var E, p = this._getCanvasWidth(),
                            g = this._getCanvasHeight();
                        this._screenOffsetScale.setValue(a.x / p, a.y / g, a.width / p, a.height / g), (E = pt.create(this._internalRenderTexture, this._offScreenRenderTexture ? this._offScreenRenderTexture : null, this._screenOffsetScale)).run(), E.recover()
                    }
                    ae.recoverToPool(this._internalRenderTexture)
                }(d || m) &amp;&amp; n.cleanUp()
            }
        }
        viewportPointToRay(e, t) {
            rt.calculateCursorRay(e, this.viewport, this._projectionMatrix, this.viewMatrix, null, t)
        }
        normalizedViewportPointToRay(e, t) {
            var r = xt._tempVector20,
                i = this.viewport;
            r.x = e.x * i.width, r.y = e.y * i.height, rt.calculateCursorRay(r, this.viewport, this._projectionMatrix, this.viewMatrix, null, t)
        }
        worldToViewportPoint(e, r) {
            c.multiply(this._projectionMatrix, this._viewMatrix, this._projectionViewMatrix), this.viewport.project(e, this._projectionViewMatrix, r), r.x = r.x / t.Laya.stage.clientScaleX, r.y = r.y / t.Laya.stage.clientScaleY
        }
        worldToNormalizedViewportPoint(e, r) {
            c.multiply(this._projectionMatrix, this._viewMatrix, this._projectionViewMatrix), this.normalizedViewport.project(e, this._projectionViewMatrix, r), r.x = r.x / t.Laya.stage.clientScaleX, r.y = r.y / t.Laya.stage.clientScaleY
        }
        convertScreenCoordToOrthographicCoord(e, r) {
            if (this._orthographic) {
                var i = ne.clientWidth,
                    n = ne.clientHeight,
                    s = this.orthographicVerticalSize * this.aspectRatio / i,
                    o = this.orthographicVerticalSize / n;
                return r.x = (-i / 2 + e.x * t.Laya.stage.clientScaleX) * s, r.y = (n / 2 - e.y * t.Laya.stage.clientScaleY) * o, r.z = (this.nearPlane - this.farPlane) * (e.z + 1) / 2 - this.nearPlane, a.transformCoordinate(r, this.transform.worldMatrix, r), !0
            }
            return !1
        }
        destroy(e = !0) {
            this._offScreenRenderTexture = null, this.transform.off(t.Event.TRANSFORM_CHANGED, this, this._onTransformChanged), super.destroy(e)
        }
        addCommandBuffer(e, t) {
            switch (e) {
                case xt.CAMERAEVENT_POSTPROCESS:
                    this._postProcessCommandBuffers.push(t), t._camera = this;
                    break;
                default:
                    throw "Camera:unknown event."
            }
        }
        removeCommandBuffer(e, t) {
            switch (e) {
                case xt.CAMERAEVENT_POSTPROCESS:
                    var r = this._postProcessCommandBuffers.indexOf(t); - 1 !== r &amp;&amp; this._postProcessCommandBuffers.splice(r, 1);
                    break;
                default:
                    throw "Camera:unknown event."
            }
        }
        removeCommandBuffers(e) {
            switch (e) {
                case xt.CAMERAEVENT_POSTPROCESS:
                    this._postProcessCommandBuffers.length = 0;
                    break;
                default:
                    throw "Camera:unknown event."
            }
        }
        _create() {
            return new xt
        }
    }
    xt.CAMERAEVENT_POSTPROCESS = 0, xt._tempVector20 = new i, xt._updateMark = 0;
    class Lt {
        constructor() {
            this._eventList = [], this._mouseTouch = new Ze, this._touchPool = [], this._touches = new Ge, this._multiTouchEnabled = !0, this._pushEventList = (e =&gt; {
                e.cancelable &amp;&amp; e.preventDefault(), this._eventList.push(e)
            }).bind(this)
        }
        __init__(e, t) {
            this._scene = t, e.oncontextmenu = function(e) {
                return !1
            }
        }
        _onCanvasEvent(e) {
            e.addEventListener("mousedown", this._pushEventList), e.addEventListener("mouseup", this._pushEventList, !0), e.addEventListener("mousemove", this._pushEventList, !0), e.addEventListener("touchstart", this._pushEventList), e.addEventListener("touchend", this._pushEventList, !0), e.addEventListener("touchmove", this._pushEventList, !0), e.addEventListener("touchcancel", this._pushEventList, !0)
        }
        _offCanvasEvent(e) {
            e.removeEventListener("mousedown", this._pushEventList), e.removeEventListener("mouseup", this._pushEventList, !0), e.removeEventListener("mousemove", this._pushEventList, !0), e.removeEventListener("touchstart", this._pushEventList), e.removeEventListener("touchend", this._pushEventList, !0), e.removeEventListener("touchmove", this._pushEventList, !0), e.removeEventListener("touchcancel", this._pushEventList, !0), this._eventList.length = 0, this._touches.clear()
        }
        touchCount() {
            return this._touches.length
        }
        get multiTouchEnabled() {
            return this._multiTouchEnabled
        }
        set multiTouchEnabled(e) {
            this._multiTouchEnabled = e
        }
        _getTouch(e, t) {
            var r = this._touchPool[e];
            return 0 == t &amp;&amp; r &amp;&amp; -1 != r._getIndexInList() ? null : 1 == t &amp;&amp; r &amp;&amp; -1 == r._getIndexInList() ? null : (r || (r = new qe, this._touchPool[e] = r, r._identifier = e), r)
        }
        _mouseTouchDown() {
            var e = this._mouseTouch,
                r = e.sprite;
            if (e._pressedSprite = r, e._pressedLoopCount = t.Stat.loopCount, r) {
                var i = r._scripts;
                if (i)
                    for (var n = 0, a = i.length; n &lt; a; n++) i[n].onMouseDown()
            }
        }
        _mouseTouchUp() {
            var e, t, r = this._mouseTouch,
                i = r._pressedSprite;
            r._pressedSprite = null, r._pressedLoopCount = -1;
            var n = r.sprite;
            if (n &amp;&amp; n === i) {
                var a = n._scripts;
                if (a)
                    for (e = 0, t = a.length; e &lt; t; e++) a[e].onMouseClick()
            }
            if (i) {
                var s = i._scripts;
                if (s)
                    for (e = 0, t = s.length; e &lt; t; e++) s[e].onMouseUp()
            }
        }
        _mouseTouchRayCast(t) {
            var r = Lt._tempHitResult0,
                i = Lt._tempVector20,
                n = Lt._tempRay0;
            r.succeeded = !1;
            var a = this._mouseTouch.mousePositionX,
                s = this._mouseTouch.mousePositionY;
            i.x = a, i.y = s;
            for (var o = t.length - 1; o &gt;= 0; o--) {
                var l = t[o],
                    _ = l.viewport;
                if (i.x &gt;= _.x &amp;&amp; i.y &gt;= _.y &amp;&amp; i.x &lt;= _.width &amp;&amp; i.y &lt;= _.height)
                    if (l.viewportPointToRay(i, n), this._scene._physicsSimulation.rayCast(n, r) || l.clearFlag === e.CameraClearFlags.SolidColor || l.clearFlag === e.CameraClearFlags.Sky) break
            }
            var h = this._mouseTouch,
                c = h.sprite;
            if (r.succeeded) {
                var d = r.collider.owner;
                h.sprite = d;
                var u = d._scripts;
                if (c !== d &amp;&amp; u)
                    for (var m = 0, f = u.length; m &lt; f; m++) u[m].onMouseEnter()
            } else h.sprite = null;
            if (c &amp;&amp; c !== d) {
                var T = c._scripts;
                if (T)
                    for (m = 0, f = T.length; m &lt; f; m++) T[m].onMouseOut()
            }
        }
        _changeTouches(e, r) {
            for (var i = 0, n = 0, a = this._touches.length, s = 0, o = e.length; s &lt; o; s++) {
                var l = e[s],
                    _ = l.identifier;
                if (this._multiTouchEnabled || 0 === _) {
                    var h = this._getTouch(_, r),
                        c = this._touchPool[_]._position,
                        d = Lt._tempPoint;
                    d.setTo(l.pageX, l.pageY), t.ILaya.stage._canvasTransform.invertTransformPoint(d);
                    var u = d.x,
                        m = d.y;
                    switch (r) {
                        case 0:
                            h &amp;&amp; this._touches.add(h), i += u, n += m;
                            break;
                        case 1:
                            h &amp;&amp; this._touches.remove(h), i -= u, n -= m;
                            break;
                        case 2:
                            i = u - c.x, n = m - c.y
                    }
                    c.x = u, c.y = m
                }
            }
            var f = this._touches.length;
            0 === f ? (this._mouseTouch.mousePositionX = 0, this._mouseTouch.mousePositionY = 0) : (this._mouseTouch.mousePositionX = (this._mouseTouch.mousePositionX * a + i) / f, this._mouseTouch.mousePositionY = (this._mouseTouch.mousePositionY * a + n) / f)
        }
        _update() {
            var e, r, i, n, a = V._enablePhysics &amp;&amp; !M.disableSimulation;
            r = this._eventList.length;
            var s = this._scene._cameraPool;
            if (r &gt; 0) {
                var o = !1;
                for (e = 0; e &lt; r; e++) {
                    var l = this._eventList[e];
                    switch (l.type) {
                        case "mousedown":
                            a &amp;&amp; this._mouseTouchDown();
                            break;
                        case "mouseup":
                            a &amp;&amp; this._mouseTouchUp();
                            break;
                        case "mousemove":
                            var _ = Lt._tempPoint;
                            _.setTo(l.pageX, l.pageY), t.ILaya.stage._canvasTransform.invertTransformPoint(_), this._mouseTouch.mousePositionX = _.x, this._mouseTouch.mousePositionY = _.y, a &amp;&amp; (o = !0);
                            break;
                        case "touchstart":
                            var h = this._touches.length;
                            this._changeTouches(l.changedTouches, 0), a &amp;&amp; (!B._config.isUseCannonPhysicsEngine &amp;&amp; this._mouseTouchRayCast(s), 0 === h &amp;&amp; this._mouseTouchDown());
                            break;
                        case "touchend":
                        case "touchcancel":
                            this._changeTouches(l.changedTouches, 1), a &amp;&amp; 0 === this._touches.length &amp;&amp; this._mouseTouchUp();
                            break;
                        case "touchmove":
                            this._changeTouches(l.changedTouches, 2), a &amp;&amp; (o = !0);
                            break;
                        default:
                            throw "Input3D:unkonwn event type."
                    }
                }
                o &amp;&amp; !B._config.isUseCannonPhysicsEngine &amp;&amp; this._mouseTouchRayCast(s), this._eventList.length = 0
            }
            if (a) {
                var c = this._mouseTouch,
                    d = c._pressedSprite;
                if (d &amp;&amp; t.Stat.loopCount &gt; c._pressedLoopCount) {
                    var u = d._scripts;
                    if (u)
                        for (i = 0, n = u.length; i &lt; n; i++) u[i].onMouseDrag()
                }
                var m = c.sprite;
                if (m) {
                    var f = m._scripts;
                    if (f)
                        for (i = 0, n = f.length; i &lt; n; i++) f[i].onMouseOver()
                }
            }
        }
        getTouch(e) {
            return e &lt; this._touches.length ? this._touches.elements[e] : null
        }
    }
    Lt._tempPoint = new t.Point, Lt._tempVector20 = new i, Lt._tempRay0 = new Ke(new a, new a), Lt._tempHitResult0 = new D;
    class Dt {
        constructor() {
            this.flags = 0, this.maxSubSteps = 1, this.fixedTimeStep = 1 / 60
        }
    }
    class Ct {
        constructor(e, t) {
            this._position = e, this._textureCoordinate0 = t
        }
        static get vertexDeclaration() {
            return Ct._vertexDeclaration
        }
        static __init__() {
            Ct._vertexDeclaration = new st(20, [new ot(0, at.Vector3, lt.MESH_POSITION0), new ot(12, at.Vector2, lt.MESH_TEXTURECOORDINATE0)])
        }
        get position() {
            return this._position
        }
        get textureCoordinate0() {
            return this._textureCoordinate0
        }
        get vertexDeclaration() {
            return Ct._vertexDeclaration
        }
    }
    class yt extends ht {
        constructor(r = 48, i = 48) {
            super();
            var n = t.LayaGL.instance;
            this._stacks = r, this._slices = i;
            for (var a = Ct.vertexDeclaration, s = a.vertexStride / 4, o = (this._stacks + 1) * (this._slices + 1), l = 3 * this._stacks * (this._slices + 1) * 2, _ = new Float32Array(o * s), h = new Uint16Array(l), c = Math.PI / this._stacks, d = 2 * Math.PI / this._slices, u = 0, m = 0, f = 0, T = 0; T &lt; this._stacks + 1; T++)
                for (var E = Math.sin(T * c), p = Math.cos(T * c), g = 0; g &lt; this._slices + 1; g++) {
                    var S = E * Math.sin(g * d),
                        R = E * Math.cos(g * d);
                    _[m + 0] = S * yt._radius, _[m + 1] = p * yt._radius, _[m + 2] = R * yt._radius, _[m + 3] = -g / this._slices + .75, _[m + 4] = T / this._stacks, m += s, T != this._stacks - 1 &amp;&amp; (h[f++] = u + 1, h[f++] = u, h[f++] = u + (this._slices + 1), h[f++] = u + (this._slices + 1), h[f++] = u, h[f++] = u + this._slices, u++)
                }
            this._vertexBuffer = new _t(4 * _.length, n.STATIC_DRAW, !1), this._vertexBuffer.vertexDeclaration = a, this._indexBuffer = new nt(e.IndexFormat.UInt16, h.length, n.STATIC_DRAW, !1), this._vertexBuffer.setData(_.buffer), this._indexBuffer.setData(h);
            var v = new it;
            v.bind(), v.applyVertexBuffer(this._vertexBuffer), v.applyIndexBuffer(this._indexBuffer), v.unBind(), this._bufferState = v
        }
        static __init__() {
            yt.instance = new yt
        }
        get stacks() {
            return this._stacks
        }
        get slices() {
            return this._slices
        }
        _render(e) {
            var r = t.LayaGL.instance,
                i = this._indexBuffer.indexCount;
            r.drawElements(r.TRIANGLES, i, r.UNSIGNED_SHORT, 0), t.Stat.trianglesFaces += i / 3, t.Stat.renderBatches++
        }
    }
    yt._radius = 1, (Me = e.TextureCubeFace || (e.TextureCubeFace = {}))[Me.PositiveX = 0] = "PositiveX", Me[Me.NegativeX = 1] = "NegativeX", Me[Me.PositiveY = 2] = "PositiveY", Me[Me.NegativeY = 3] = "NegativeY", Me[Me.PositiveZ = 4] = "PositiveZ", Me[Me.NegativeZ = 5] = "NegativeZ";
    class Mt extends t.BaseTexture {
        constructor(e, r = t.TextureFormat.R8G8B8, i = !1) {
            super(r, i), this._glTextureType = t.LayaGL.instance.TEXTURE_CUBE_MAP, this._width = e, this._height = e;
            var n = t.LayaGL.instance;
            if (this._setWarpMode(n.TEXTURE_WRAP_S, this._wrapModeU), this._setWarpMode(n.TEXTURE_WRAP_T, this._wrapModeV), this._setFilterMode(this._filterMode), this._setAnisotropy(this._anisoLevel), this._mipmap) {
                this._mipmapCount = Math.ceil(Math.log2(e)) + 1;
                for (var a = 0; a &lt; this._mipmapCount; a++) this._setPixels([], a, Math.max(e &gt;&gt; a, 1), Math.max(e &gt;&gt; a, 1));
                this._setGPUMemory(e * e * 4 * (1 + 1 / 3) * 6)
            } else this._mipmapCount = 1, this._setGPUMemory(e * e * 4 * 6)
        }
        static get blackTexture() {
            return Mt._blackTexture
        }
        static get grayTexture() {
            return Mt._grayTexture
        }
        static __init__() {
            var e = new Mt(1, t.TextureFormat.R8G8B8, !1),
                r = new Mt(1, t.TextureFormat.R8G8B8, !1),
                i = new Uint8Array(3);
            i[0] = 0, i[1] = 0, i[2] = 0, e.setSixSidePixels([i, i, i, i, i, i]), e.lock = !0, i[0] = 128, i[1] = 128, i[2] = 128, r.setSixSidePixels([i, i, i, i, i, i]), r.lock = !0, Mt._grayTexture = r, Mt._blackTexture = e
        }
        static _parse(e, t = null, r = null) {
            var i = r ? new Mt(0, r[0], r[1]) : new Mt(0);
            return i.setSixSideImageSources(e), i
        }
        static _parseBin(e, t = null, r = null) {
            var i = r ? new Mt(0, r[0], r[1]) : new Mt(0);
            return i.setSixSideImageSources(e), i
        }
        static load(e, r) {
            t.ILaya.loader.create(e, r, null, Mt.TEXTURECUBE)
        }
        get defaulteTexture() {
            return Mt.grayTexture
        }
        _setPixels(e, r, i, n) {
            var a = t.LayaGL.instance,
                s = this._getGLFormat();
            t.WebGLContext.bindTexture(a, this._glTextureType, this._glTexture), this.format === t.TextureFormat.R8G8B8 ? (a.pixelStorei(a.UNPACK_ALIGNMENT, 1), a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Z, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[0]), a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Z, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[1]), a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[2]), a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_X, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[3]), a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Y, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[4]), a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Y, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[5]), a.pixelStorei(a.UNPACK_ALIGNMENT, 4)) : (a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Z, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[0]), a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Z, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[1]), a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[2]), a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_X, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[3]), a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_Y, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[4]), a.texImage2D(a.TEXTURE_CUBE_MAP_NEGATIVE_Y, r, s, i, n, 0, s, a.UNSIGNED_BYTE, e[5]))
        }
        setSixSideImageSources(e, r = !1) {
            for (var i, n, a = 0; a &lt; 6; a++) {
                var s = e[a];
                if (!s) return void console.log("TextureCube: image Source can't be null.");
                var o = s.width,
                    l = s.height;
                if (a &gt; 0 &amp;&amp; i !== o) return void console.log("TextureCube: each side image's width and height must same.");
                if ((i = o) !== (n = l)) return void console.log("TextureCube: each side image's width and height must same.")
            }
            this._width = i, this._height = n;
            var _ = t.LayaGL.instance;
            t.WebGLContext.bindTexture(_, this._glTextureType, this._glTexture);
            var h = this._getGLFormat();
            if (t.Render.isConchApp) {
                if (1 == r)
                    for (var c = 0; c &lt; 6; c++) e[c].setPremultiplyAlpha(r);
                _.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, _.RGBA, _.RGBA, _.UNSIGNED_BYTE, e[0]), _.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, _.RGBA, _.RGBA, _.UNSIGNED_BYTE, e[1]), _.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X, 0, _.RGBA, _.RGBA, _.UNSIGNED_BYTE, e[2]), _.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, _.RGBA, _.RGBA, _.UNSIGNED_BYTE, e[3]), _.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, _.RGBA, _.RGBA, _.UNSIGNED_BYTE, e[4]), _.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, _.RGBA, _.RGBA, _.UNSIGNED_BYTE, e[5])
            } else r &amp;&amp; _.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0), _.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, h, h, _.UNSIGNED_BYTE, e[0]), _.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, h, h, _.UNSIGNED_BYTE, e[1]), _.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X, 0, h, h, _.UNSIGNED_BYTE, e[2]), _.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, h, h, _.UNSIGNED_BYTE, e[3]), _.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, h, h, _.UNSIGNED_BYTE, e[4]), _.texImage2D(_.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, h, h, _.UNSIGNED_BYTE, e[5]), r &amp;&amp; _.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1);
            this._mipmap &amp;&amp; this._isPot(i) &amp;&amp; this._isPot(n) ? (_.generateMipmap(this._glTextureType), this._setGPUMemory(i * n * 4 * (1 + 1 / 3) * 6)) : this._setGPUMemory(i * n * 4 * 6), this._setWarpMode(_.TEXTURE_WRAP_S, this._wrapModeU), this._setWarpMode(_.TEXTURE_WRAP_T, this._wrapModeV), this._setFilterMode(this._filterMode), this._readyed = !0, this._activeResource()
        }
        setSixSidePixels(e, r = 0) {
            if (!e) throw new Error("TextureCube:pixels can't be null.");
            var i = Math.max(this._width &gt;&gt; r, 1),
                n = Math.max(this._height &gt;&gt; r, 1),
                a = i * n * this._getFormatByteCount();
            if (e[0].length &lt; a) throw "TextureCube:pixels length should at least " + a + ".";
            if (this._setPixels(e, r, i, n), 0 === r) {
                var s = t.LayaGL.instance;
                this._setWarpMode(s.TEXTURE_WRAP_S, this._wrapModeU), this._setWarpMode(s.TEXTURE_WRAP_T, this._wrapModeV)
            }
            this._readyed = !0, this._activeResource()
        }
        setImageSource(r, i, n = 0) {
            var a = this._width,
                s = this._height;
            if (!i || a === i.width &amp;&amp; s === i.height) {
                var o = t.LayaGL.instance;
                t.WebGLContext.bindTexture(o, this._glTextureType, this._glTexture);
                var l = this._getGLFormat();
                switch (r) {
                    case e.TextureCubeFace.NegativeX:
                        o.texImage2D(o.TEXTURE_CUBE_MAP_NEGATIVE_X, n, l, l, o.UNSIGNED_BYTE, i);
                        break;
                    case e.TextureCubeFace.PositiveX:
                        o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X, n, l, l, o.UNSIGNED_BYTE, i);
                        break;
                    case e.TextureCubeFace.NegativeY:
                        o.texImage2D(o.TEXTURE_CUBE_MAP_NEGATIVE_Y, n, l, l, o.UNSIGNED_BYTE, i);
                        break;
                    case e.TextureCubeFace.PositiveY:
                        o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_Y, n, l, l, o.UNSIGNED_BYTE, i);
                        break;
                    case e.TextureCubeFace.NegativeZ:
                        o.texImage2D(o.TEXTURE_CUBE_MAP_NEGATIVE_Z, n, l, l, o.UNSIGNED_BYTE, i);
                        break;
                    case e.TextureCubeFace.PositiveZ:
                        o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_Z, n, l, l, o.UNSIGNED_BYTE, i)
                }
                this._mipmap &amp;&amp; this._isPot(a) &amp;&amp; this._isPot(s) ? (o.generateMipmap(this._glTextureType), this._setGPUMemory(a * s * 4 * (1 + 1 / 3) * 6)) : this._setGPUMemory(a * s * 4 * 6), this._setWarpMode(o.TEXTURE_WRAP_S, this._wrapModeU), this._setWarpMode(o.TEXTURE_WRAP_T, this._wrapModeV), this._setFilterMode(this._filterMode), this._readyed = !0
            } else console.log("TextureCube: imageSource's width and height must same.")
        }
    }
    Mt.TEXTURECUBE = "TEXTURECUBE";
    class Ot {
        constructor() {
            this._length = 0, this._elements = []
        }
        add(e) {
            this._length === this._elements.length ? this._elements.push(e) : this._elements[this._length] = e, this._length++
        }
        remove(e) {
            var t = this._elements.indexOf(e);
            if (this._length--, t !== this._length) {
                var r = this._elements[this._length];
                this._elements[t] = r
            }
        }
        shift() {
            return this._length--, this._elements.shift()
        }
        getBrightestLight() {
            for (var e, t = -1, r = this._elements, i = 0; i &lt; this._length; i++) {
                var n = r[i]._intensity;
                t &lt; n &amp;&amp; (t = n, e = i)
            }
            return e
        }
        normalLightOrdering(e) {
            this._elements;
            var t = this._elements[0];
            this._elements[0] = this._elements[e], this._elements[e] = t
        }
    }
    class Nt extends Ot {
        remove(e) {
            var t = this._elements.indexOf(e);
            this._elements.splice(t, 1), this._length--
        }
    }
    class bt extends Te {
        constructor() {
            super(), this.setShaderName("LineShader"), this._shaderValues.setVector(bt.COLOR, new n(1, 1, 1, 1))
        }
        static __initDefine__() {}
        get color() {
            return this._shaderValues.getVector(bt.COLOR)
        }
        set color(e) {
            this._shaderValues.setVector(bt.COLOR, e)
        }
        set depthWrite(e) {
            this._shaderValues.setBool(bt.DEPTH_WRITE, e)
        }
        get depthWrite() {
            return this._shaderValues.getBool(bt.DEPTH_WRITE)
        }
        set cull(e) {
            this._shaderValues.setInt(bt.CULL, e)
        }
        get cull() {
            return this._shaderValues.getInt(bt.CULL)
        }
        set blend(e) {
            this._shaderValues.setInt(bt.BLEND, e)
        }
        get blend() {
            return this._shaderValues.getInt(bt.BLEND)
        }
        set blendSrc(e) {
            this._shaderValues.setInt(bt.BLEND_SRC, e)
        }
        get blendSrc() {
            return this._shaderValues.getInt(bt.BLEND_SRC)
        }
        set blendDst(e) {
            this._shaderValues.setInt(bt.BLEND_DST, e)
        }
        get blendDst() {
            return this._shaderValues.getInt(bt.BLEND_DST)
        }
        set depthTest(e) {
            this._shaderValues.setInt(bt.DEPTH_TEST, e)
        }
        get depthTest() {
            return this._shaderValues.getInt(bt.DEPTH_TEST)
        }
        clone() {
            var e = new bt;
            return this.cloneTo(e), e
        }
    }
    bt.COLOR = he.propertyNameToID("u_Color"), bt.CULL = he.propertyNameToID("s_Cull"), bt.BLEND = he.propertyNameToID("s_Blend"), bt.BLEND_SRC = he.propertyNameToID("s_BlendSrc"), bt.BLEND_DST = he.propertyNameToID("s_BlendDst"), bt.DEPTH_TEST = he.propertyNameToID("s_DepthTest"), bt.DEPTH_WRITE = he.propertyNameToID("s_DepthWrite");
    class Pt {
        constructor(e, t) {
            this.min = e, this.max = t
        }
        _rotateExtents(e, t, r) {
            var i = e.x,
                n = e.y,
                a = e.z,
                s = t.elements;
            r.x = Math.abs(s[0] * i) + Math.abs(s[4] * n) + Math.abs(s[8] * a), r.y = Math.abs(s[1] * i) + Math.abs(s[5] * n) + Math.abs(s[9] * a), r.z = Math.abs(s[2] * i) + Math.abs(s[6] * n) + Math.abs(s[10] * a)
        }
        getCorners(e) {
            e.length = 8;
            var t = this.min.x,
                r = this.min.y,
                i = this.min.z,
                n = this.max.x,
                s = this.max.y,
                o = this.max.z;
            e[0] = new a(t, s, o), e[1] = new a(n, s, o), e[2] = new a(n, r, o), e[3] = new a(t, r, o), e[4] = new a(t, s, i), e[5] = new a(n, s, i), e[6] = new a(n, r, i), e[7] = new a(t, r, i)
        }
        getCenter(e) {
            a.add(this.min, this.max, e), a.scale(e, .5, e)
        }
        getExtent(e) {
            a.subtract(this.max, this.min, e), a.scale(e, .5, e)
        }
        setCenterAndExtent(e, t) {
            a.subtract(e, t, this.min), a.add(e, t, this.max)
        }
        tranform(e, t) {
            var r = Pt._tempVector30,
                i = Pt._tempVector31;
            this.getCenter(r), this.getExtent(i), a.transformCoordinate(r, e, r), this._rotateExtents(i, e, i), t.setCenterAndExtent(r, i)
        }
        toDefault() {
            this.min.toDefault(), this.max.toDefault()
        }
        static createfromPoints(e, t) {
            if (null == e) throw new Error("points");
            var r = t.min,
                i = t.max;
            r.x = Number.MAX_VALUE, r.y = Number.MAX_VALUE, r.z = Number.MAX_VALUE, i.x = -Number.MAX_VALUE, i.y = -Number.MAX_VALUE, i.z = -Number.MAX_VALUE;
            for (var n = 0, s = e.length; n &lt; s; ++n) a.min(r, e[n], r), a.max(i, e[n], i)
        }
        static merge(e, t, r) {
            a.min(e.min, t.min, r.min), a.max(e.max, t.max, r.max)
        }
        cloneTo(e) {
            var t = e;
            this.min.cloneTo(t.min), this.max.cloneTo(t.max)
        }
        clone() {
            var e = new Pt(new a, new a);
            return this.cloneTo(e), e
        }
    }
    Pt._tempVector30 = new a, Pt._tempVector31 = new a;
    class wt {
        constructor(e, t) {
            this._updateFlag = 0, this._center = new a, this._extent = new a, this._boundBox = new Pt(new a, new a), e.cloneTo(this._boundBox.min), t.cloneTo(this._boundBox.max), this._setUpdateFlag(wt._UPDATE_CENTER | wt._UPDATE_EXTENT, !0)
        }
        setMin(e) {
            var t = this._boundBox.min;
            e !== t &amp;&amp; e.cloneTo(t), this._setUpdateFlag(wt._UPDATE_CENTER | wt._UPDATE_EXTENT, !0), this._setUpdateFlag(wt._UPDATE_MIN, !1)
        }
        getMin() {
            var e = this._boundBox.min;
            return this._getUpdateFlag(wt._UPDATE_MIN) &amp;&amp; (this._getMin(this.getCenter(), this.getExtent(), e), this._setUpdateFlag(wt._UPDATE_MIN, !1)), e
        }
        setMax(e) {
            var t = this._boundBox.max;
            e !== t &amp;&amp; e.cloneTo(t), this._setUpdateFlag(wt._UPDATE_CENTER | wt._UPDATE_EXTENT, !0), this._setUpdateFlag(wt._UPDATE_MAX, !1)
        }
        getMax() {
            var e = this._boundBox.max;
            return this._getUpdateFlag(wt._UPDATE_MAX) &amp;&amp; (this._getMax(this.getCenter(), this.getExtent(), e), this._setUpdateFlag(wt._UPDATE_MAX, !1)), e
        }
        setCenter(e) {
            e !== this._center &amp;&amp; e.cloneTo(this._center), this._setUpdateFlag(wt._UPDATE_MIN | wt._UPDATE_MAX, !0), this._setUpdateFlag(wt._UPDATE_CENTER, !1)
        }
        getCenter() {
            return this._getUpdateFlag(wt._UPDATE_CENTER) &amp;&amp; (this._getCenter(this.getMin(), this.getMax(), this._center), this._setUpdateFlag(wt._UPDATE_CENTER, !1)), this._center
        }
        setExtent(e) {
            e !== this._extent &amp;&amp; e.cloneTo(this._extent), this._setUpdateFlag(wt._UPDATE_MIN | wt._UPDATE_MAX, !0), this._setUpdateFlag(wt._UPDATE_EXTENT, !1)
        }
        getExtent() {
            return this._getUpdateFlag(wt._UPDATE_EXTENT) &amp;&amp; (this._getExtent(this.getMin(), this.getMax(), this._extent), this._setUpdateFlag(wt._UPDATE_EXTENT, !1)), this._extent
        }
        _getUpdateFlag(e) {
            return 0 != (this._updateFlag &amp; e)
        }
        _setUpdateFlag(e, t) {
            t ? this._updateFlag |= e : this._updateFlag &amp;= ~e
        }
        _getCenter(e, t, r) {
            a.add(e, t, r), a.scale(r, .5, r)
        }
        _getExtent(e, t, r) {
            a.subtract(t, e, r), a.scale(r, .5, r)
        }
        _getMin(e, t, r) {
            a.subtract(e, t, r)
        }
        _getMax(e, t, r) {
            a.add(e, t, r)
        }
        _rotateExtents(e, t, r) {
            var i = e.x,
                n = e.y,
                a = e.z,
                s = t.elements;
            r.x = Math.abs(s[0] * i) + Math.abs(s[4] * n) + Math.abs(s[8] * a), r.y = Math.abs(s[1] * i) + Math.abs(s[5] * n) + Math.abs(s[9] * a), r.z = Math.abs(s[2] * i) + Math.abs(s[6] * n) + Math.abs(s[10] * a)
        }
        _tranform(e, t) {
            var r = t._center,
                i = t._extent;
            a.transformCoordinate(this.getCenter(), e, r), this._rotateExtents(this.getExtent(), e, i), t._boundBox.setCenterAndExtent(r, i), t._updateFlag = 0
        }
        _getBoundBox() {
            if (this._updateFlag &amp; wt._UPDATE_MIN) {
                var e = this._boundBox.min;
                this._getMin(this.getCenter(), this.getExtent(), e), this._setUpdateFlag(wt._UPDATE_MIN, !1)
            }
            if (this._updateFlag &amp; wt._UPDATE_MAX) {
                var t = this._boundBox.max;
                this._getMax(this.getCenter(), this.getExtent(), t), this._setUpdateFlag(wt._UPDATE_MAX, !1)
            }
            return this._boundBox
        }
        cloneTo(e) {
            var t = e;
            this.getMin().cloneTo(t._boundBox.min), this.getMax().cloneTo(t._boundBox.max), this.getCenter().cloneTo(t._center), this.getExtent().cloneTo(t._extent), t._updateFlag = 0
        }
        clone() {
            var e = new wt(new a, new a);
            return this.cloneTo(e), e
        }
    }
    wt._UPDATE_MIN = 1, wt._UPDATE_MAX = 2, wt._UPDATE_CENTER = 4, wt._UPDATE_EXTENT = 8;
    class Vt {
        constructor() {
            this._destroyed = !1
        }
        get destroyed() {
            return this._destroyed
        }
        _getType() {
            throw "GeometryElement:must override it."
        }
        _prepareRender(e) {
            return !0
        }
        _render(e) {
            throw "GeometryElement:must override it."
        }
        destroy() {
            this._destroyed || (this._destroyed = !0)
        }
    }
    Vt._typeCounter = 0;
    class Bt {
        constructor() {}
        static get vertexDeclaration() {
            return Bt._vertexDeclaration
        }
        static __init__() {
            Bt._vertexDeclaration = new st(28, [new ot(0, at.Vector3, lt.MESH_POSITION0), new ot(12, at.Vector4, lt.MESH_COLOR0)])
        }
        get vertexDeclaration() {
            return Bt._vertexDeclaration
        }
    }
    class Ft extends Vt {
        constructor(e, r) {
            super(), this._floatCountPerVertices = 7, this._minUpdate = Number.MAX_VALUE, this._maxUpdate = Number.MIN_VALUE, this._bufferState = new it, this._floatBound = new Float32Array(6), this._calculateBound = !1, this._maxLineCount = 0, this._lineCount = 0;
            var i = 2 * r;
            this._owner = e, this._maxLineCount = r, this._vertices = new Float32Array(i * this._floatCountPerVertices), this._vertexBuffer = new _t(Bt.vertexDeclaration.vertexStride * i, t.LayaGL.instance.STATIC_DRAW, !1), this._vertexBuffer.vertexDeclaration = Bt.vertexDeclaration, this._bufferState.bind(), this._bufferState.applyVertexBuffer(this._vertexBuffer), this._bufferState.unBind();
            var n = Ft._tempVector0,
                a = Ft._tempVector1;
            n.setValue(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), a.setValue(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), this._bounds = new wt(n, a)
        }
        _getType() {
            return Ft._type
        }
        _resizeLineData(e) {
            var r = 2 * e,
                i = this._vertices;
            this._vertexBuffer.destroy(), this._maxLineCount = e;
            var n = r * this._floatCountPerVertices;
            this._vertices = new Float32Array(n), this._vertexBuffer = new _t(Bt.vertexDeclaration.vertexStride * r, t.LayaGL.instance.STATIC_DRAW, !1), this._vertexBuffer.vertexDeclaration = Bt.vertexDeclaration, n &lt; i.length ? (this._vertices.set(new Float32Array(i.buffer, 0, n)), this._vertexBuffer.setData(this._vertices.buffer, 0, 0, 4 * n)) : (this._vertices.set(i), this._vertexBuffer.setData(this._vertices.buffer, 0, 0, 4 * i.length)), this._bufferState.bind(), this._bufferState.applyVertexBuffer(this._vertexBuffer), this._bufferState.unBind()
        }
        _updateLineVertices(e, t, r, i, n) {
            t &amp;&amp; (this._vertices[e + 0] = t.x, this._vertices[e + 1] = t.y, this._vertices[e + 2] = t.z), i &amp;&amp; (this._vertices[e + 3] = i.r, this._vertices[e + 4] = i.g, this._vertices[e + 5] = i.b, this._vertices[e + 6] = i.a), r &amp;&amp; (this._vertices[e + 7] = r.x, this._vertices[e + 8] = r.y, this._vertices[e + 9] = r.z), n &amp;&amp; (this._vertices[e + 10] = n.r, this._vertices[e + 11] = n.g, this._vertices[e + 12] = n.b, this._vertices[e + 13] = n.a), this._minUpdate = Math.min(this._minUpdate, e), this._maxUpdate = Math.max(this._maxUpdate, e + 2 * this._floatCountPerVertices);
            var s = this._bounds,
                o = this._floatBound,
                l = s.getMin(),
                _ = s.getMax();
            a.min(l, t, l), a.min(l, r, l), a.max(_, t, _), a.max(_, r, _), s.setMin(l), s.setMax(_), o[0] = l.x, o[1] = l.y, o[2] = l.z, o[3] = _.x, o[4] = _.y, o[5] = _.z
        }
        _reCalculateBound() {
            if (this._calculateBound) {
                var e = this._vertices,
                    t = Ft._tempVector0,
                    r = Ft._tempVector1;
                t.setValue(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), r.setValue(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
                for (var i = 0; i &lt; 2 * this._lineCount; ++i) {
                    var n = this._floatCountPerVertices * i,
                        a = e[n + 0],
                        s = e[n + 1],
                        o = e[n + 2];
                    t.x = Math.min(a, t.x), t.y = Math.min(s, t.y), t.z = Math.min(o, t.z), r.x = Math.max(a, r.x), r.y = Math.max(s, r.y), r.z = Math.max(o, r.z)
                }
                this._bounds.setMin(t), this._bounds.setMax(r);
                var l = this._floatBound;
                l[0] = t.x, l[1] = t.y, l[2] = t.z, l[3] = r.x, l[4] = r.y, l[5] = r.z, this._calculateBound = !1
            }
        }
        _removeLineData(e) {
            var t = 2 * this._floatCountPerVertices,
                r = e + 1,
                i = e * t,
                n = this._vertices,
                a = new Float32Array(n.buffer, r * t * 4, (this._lineCount - r) * t);
            n.set(a, i), this._minUpdate = Math.min(this._minUpdate, i), this._maxUpdate = Math.max(this._maxUpdate, i + a.length), this._lineCount--;
            var s = this._floatBound,
                o = n[i],
                l = n[i + 1],
                _ = n[i + 2],
                h = n[i + 7],
                c = n[i + 8],
                d = n[i + 9],
                u = s[0],
                m = s[1],
                f = s[2],
                T = s[3],
                E = s[4],
                p = s[5];
            o !== u &amp;&amp; o !== T &amp;&amp; l !== m &amp;&amp; l !== E &amp;&amp; _ !== f &amp;&amp; _ !== p &amp;&amp; h !== u &amp;&amp; h !== T &amp;&amp; c !== m &amp;&amp; c !== E &amp;&amp; d !== f &amp;&amp; d !== p || (this._calculateBound = !0)
        }
        _updateLineData(e, t, r, i, n) {
            var a = 2 * this._floatCountPerVertices;
            this._updateLineVertices(e * a, t, r, i, n)
        }
        _updateLineDatas(e, t) {
            for (var r = 2 * this._floatCountPerVertices, i = t.length, n = 0; n &lt; i; n++) {
                var a = t[n];
                this._updateLineVertices((e + n) * r, a.startPosition, a.endPosition, a.startColor, a.endColor)
            }
        }
        _getLineData(e, t) {
            var r = t.startPosition,
                i = t.startColor,
                n = t.endPosition,
                a = t.endColor,
                s = this._vertices,
                o = e * this._floatCountPerVertices * 2;
            r.x = s[o + 0], r.y = s[o + 1], r.z = s[o + 2], i.r = s[o + 3], i.g = s[o + 4], i.b = s[o + 5], i.a = s[o + 6], n.x = s[o + 7], n.y = s[o + 8], n.z = s[o + 9], a.r = s[o + 10], a.g = s[o + 11], a.b = s[o + 12], a.a = s[o + 13]
        }
        _prepareRender(e) {
            return !0
        }
        _render(e) {
            if (this._minUpdate !== Number.MAX_VALUE &amp;&amp; this._maxUpdate !== Number.MIN_VALUE &amp;&amp; (this._vertexBuffer.setData(this._vertices.buffer, 4 * this._minUpdate, 4 * this._minUpdate, 4 * (this._maxUpdate - this._minUpdate)), this._minUpdate = Number.MAX_VALUE, this._maxUpdate = Number.MIN_VALUE), this._lineCount &gt; 0) {
                this._bufferState.bind();
                var r = t.LayaGL.instance;
                r.drawArrays(r.LINES, 0, 2 * this._lineCount), t.Stat.renderBatches++
            }
        }
        destroy() {
            this._destroyed || (super.destroy(), this._bufferState.destroy(), this._vertexBuffer.destroy(), this._bufferState = null, this._vertexBuffer = null, this._vertices = null)
        }
    }
    Ft._tempVector0 = new a, Ft._tempVector1 = new a, Ft._type = Vt._typeCounter++;
    class Ut extends ut {
        constructor(e) {
            super(e)
        }
        static __init__() {
            Ut.SHADERDEFINE_RECEIVE_SHADOW = he.getDefineByName("RECEIVESHADOW"), Ut.SAHDERDEFINE_LIGHTMAP = he.getDefineByName("LIGHTMAP"), Ut.SHADERDEFINE_LIGHTMAP_DIRECTIONAL = he.getDefineByName("LIGHTMAP_DIRECTIONAL")
        }
        _onInActive() {
            super._onInActive(), this._scene._removeRenderObject(this._render)
        }
        _onActive() {
            super._onActive(), this._scene._addRenderObject(this._render)
        }
        _onActiveInScene() {
            if (super._onActiveInScene(), _.Laya3D._editerEnvironment) {
                var e = this._scene,
                    t = new n;
                e._allotPickColorByID(this.id, t), e._pickIdToSprite[this.id] = this, this._render._shaderValues.setVector(Ut.PICKCOLOR, t)
            }
        }
        _addToInitStaticBatchManager() {}
        _setBelongScene(e) {
            super._setBelongScene(e), this._render._setBelongScene(e)
        }
        _setUnBelongScene() {
            this._render._shaderValues.removeDefine(Ut.SAHDERDEFINE_LIGHTMAP), super._setUnBelongScene()
        }
        _changeHierarchyAnimator(e) {
            if (this._hierarchyAnimator) {
                var t = this._hierarchyAnimator._renderableSprites;
                t.splice(t.indexOf(this), 1)
            }
            e &amp;&amp; e._renderableSprites.push(this), super._changeHierarchyAnimator(e)
        }
        destroy(e = !0) {
            super.destroy(e), this._render._destroy(), this._render = null
        }
        _create() {
            return new Ut(this.name)
        }
    }
    Ut.LIGHTMAPSCALEOFFSET = he.propertyNameToID("u_LightmapScaleOffset"), Ut.LIGHTMAP = he.propertyNameToID("u_LightMap"), Ut.LIGHTMAP_DIRECTION = he.propertyNameToID("u_LightMapDirection"), Ut.PICKCOLOR = he.propertyNameToID("u_PickColor");
    class Gt {
        constructor() {
            this.updateMark = -1, this.indexInList = -1, this.batched = !1
        }
    }
    class zt extends Vt {
        constructor() {
            super(), this.maxInstanceCount = 1024, this.instanceWorldMatrixData = new Float32Array(16 * this.maxInstanceCount), this.instanceMVPMatrixData = new Float32Array(16 * this.maxInstanceCount);
            var e = t.LayaGL.instance;
            this.instanceWorldMatrixBuffer = new _t(4 * this.instanceWorldMatrixData.length, e.DYNAMIC_DRAW), this.instanceMVPMatrixBuffer = new _t(4 * this.instanceMVPMatrixData.length, e.DYNAMIC_DRAW), this.instanceWorldMatrixBuffer.vertexDeclaration = lt.instanceWorldMatrixDeclaration, this.instanceMVPMatrixBuffer.vertexDeclaration = lt.instanceMVPMatrixDeclaration
        }
        static __init__() {
            zt.instance = new zt
        }
        _render(e) {
            var r = t.LayaGL.instance,
                i = e.renderElement,
                n = i.instanceSubMesh,
                a = i.instanceBatchElementList.length,
                s = n._indexCount;
            n._mesh._instanceBufferState.bind(), t.LayaGL.layaGPUInstance.drawElementsInstanced(r.TRIANGLES, s, r.UNSIGNED_SHORT, 2 * n._indexStart, a), t.Stat.renderBatches++, t.Stat.savedRenderBatches += a - 1, t.Stat.trianglesFaces += s * a / 3
        }
    }
    class Ht {
        constructor() {
            this.renderSubShader = null, this.renderType = Ht.RENDERTYPE_NORMAL
        }
        getInvertFront() {
            return this._transform._isFrontFaceInvert
        }
        setTransform(e) {
            this._transform = e
        }
        setGeometry(e) {
            this._geometry = e
        }
        addToOpaqueRenderQueue(e, t) {
            t.elements.add(this)
        }
        addToTransparentRenderQueue(e, t) {
            t.elements.add(this), t.lastTransparentBatched = !1, t.lastTransparentRenderElement = this
        }
        _update(e, t, r, i) {
            if (this.material) {
                var n = this.material._shader.getSubShaderAt(0);
                if (this.renderSubShader = null, r)
                    if (i) {
                        var a = n.getFlag(i);
                        if (!a) return;
                        for (var s = r._subShaders, o = 0, l = s.length; o &lt; l; o++) {
                            var _ = s[o];
                            if (a === _.getFlag(i)) {
                                this.renderSubShader = _;
                                break
                            }
                        }
                        if (!this.renderSubShader) return
                    } else this.renderSubShader = r.getSubShaderAt(0);
                else this.renderSubShader = n;
                var h = e._getRenderQueue(this.material.renderQueue);
                h.isTransparent ? this.addToTransparentRenderQueue(t, h) : this.addToOpaqueRenderQueue(t, h)
            }
        }
        _render(e) {
            var t, r, i, n = e.invertY,
                a = xt._updateMark,
                s = e.scene,
                o = e.cameraShaderValue,
                l = this._transform,
                _ = this._geometry;
            e.renderElement = this, a !== this.render._updateMark || this.renderType !== this.render._updateRenderType ? (this.render._renderUpdate(e, l), this.render._renderUpdateWithCamera(e, l), this.render._updateMark = a, this.render._updateRenderType = this.renderType) : this.renderType == Ht.RENDERTYPE_INSTANCEBATCH &amp;&amp; (this.render._renderUpdate(e, l), this.render._renderUpdateWithCamera(e, l));
            var h = e.pipelineMode;
            if (_._prepareRender(e))
                for (var c = this.renderSubShader._passes, d = 0, u = c.length; d &lt; u; d++) {
                    var m = c[d];
                    if (m._pipelineMode === h) {
                        var f = Ht._compileDefine;
                        s._shaderValues._defineDatas.cloneTo(f), f.addDefineDatas(this.render._shaderValues._defineDatas), f.addDefineDatas(this.material._shaderValues._defineDatas);
                        var T = e.shader = m.withCompile(f),
                            E = T.bind(),
                            p = a !== T._uploadMark,
                            g = T._uploadScene !== s || p;
                        (g || E) &amp;&amp; (T.uploadUniforms(T._sceneUniformParamsMap, s._shaderValues, g), T._uploadScene = s);
                        var S = T._uploadRender !== this.render || T._uploadRenderType !== this.renderType || p;
                        (S || E) &amp;&amp; (T.uploadUniforms(T._spriteUniformParamsMap, this.render._shaderValues, S), T._uploadRender = this.render, T._uploadRenderType = this.renderType);
                        var R = T._uploadCameraShaderValue !== o || p;
                        (R || E) &amp;&amp; (T.uploadUniforms(T._cameraUniformParamsMap, o, R), T._uploadCameraShaderValue = o);
                        var v = T._uploadMaterial !== this.material || p;
                        (v || E) &amp;&amp; (T.uploadUniforms(T._materialUniformParamsMap, this.material._shaderValues, v), T._uploadMaterial = this.material);
                        var A = this.material._shaderValues;
                        t !== this.material || r !== T ? (T.uploadRenderStateBlendDepth(A), T.uploadRenderStateFrontFace(A, n, this.getInvertFront()), t = this.material, r = T, i = this.render) : i !== this.render &amp;&amp; (T.uploadRenderStateFrontFace(A, n, this.getInvertFront()), i = this.render), _._render(e), T._uploadMark = a
                    }
                }
            this.renderType !== Ht.RENDERTYPE_NORMAL &amp;&amp; this.render._revertBatchRenderUpdate(e)
        }
        destroy() {
            this._transform = null, this._geometry = null, this.material = null, this.render = null
        }
    }
    Ht.RENDERTYPE_NORMAL = 0, Ht.RENDERTYPE_STATICBATCH = 1, Ht.RENDERTYPE_INSTANCEBATCH = 2, Ht.RENDERTYPE_VERTEXBATCH = 3, Ht._compileDefine = new se;
    class Wt extends Ht {
        constructor() {
            super(), this._dynamicWorldPositionNormalNeedUpdate = !0
        }
        _onWorldMatrixChanged() {
            this._dynamicWorldPositionNormalNeedUpdate = !0
        }
        _computeWorldPositionsAndNormals(e, t, r, i) {
            if (this._dynamicWorldPositionNormalNeedUpdate) {
                for (var n = this._geometry, a = n._vertexBuffer, s = a.vertexDeclaration.vertexStride / 4, o = a.getFloat32Data(), l = this._transform.worldMatrix, _ = this._transform.rotation, h = n._indices, c = 0; c &lt; i; c++) {
                    var d = (r ? h[c] : c) * s,
                        u = 3 * c;
                    N.transformVector3ArrayToVector3ArrayCoordinate(o, d + e, l, this._dynamicWorldPositions, u), -1 !== t &amp;&amp; N.transformVector3ArrayByQuat(o, d + t, _, this._dynamicWorldNormals, u)
                }
                this._dynamicWorldPositionNormalNeedUpdate = !1
            }
        }
        setTransform(e) {
            this._transform !== e &amp;&amp; (this._transform &amp;&amp; this._transform.off(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatrixChanged), e &amp;&amp; e.on(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatrixChanged), this._dynamicWorldPositionNormalNeedUpdate = !0, this._transform = e)
        }
        setGeometry(e) {
            if (this._geometry !== e) {
                var t = e,
                    r = t._mesh;
                if (r) {
                    var i = r._subMeshes.length &gt; 1,
                        n = i ? t._indexCount : r._vertexCount;
                    if (n &lt;= _.SubMeshDynamicBatch.maxAllowVertexCount) {
                        var a = 3 * n;
                        this._dynamicVertexBatch = !0, this._dynamicWorldPositions = new Float32Array(a), this._dynamicWorldNormals = new Float32Array(a), this._dynamicVertexCount = n, this._dynamicMultiSubMesh = i
                    } else this._dynamicVertexBatch = !1
                }
                this._geometry = e
            }
        }
        addToOpaqueRenderQueue(e, r) {
            var i = this.staticBatch,
                n = r.elements,
                a = n.elements;
            if (i) {
                var s = _.MeshRenderStaticBatchManager.instance,
                    o = s.getBatchOpaquaMark(this.render.lightmapIndex + 1, this.render.receiveShadow, this.material.id, i._batchID);
                if (s._updateCountMark === o.updateMark) {
                    var l = o.indexInList;
                    if (o.batched) a[l].staticBatchElementList.add(this);
                    else {
                        var h = a[l],
                            c = h.render,
                            d = s._getBatchRenderElementFromPool();
                        d.renderType = Ht.RENDERTYPE_STATICBATCH, d.setGeometry(i), d.material = h.material;
                        var u = i.batchOwner,
                            m = u ? u._transform : null;
                        d.setTransform(m), d.render = c, d.renderSubShader = h.renderSubShader;
                        var f = d.staticBatchElementList;
                        f.length = 0, f.add(h), f.add(this), a[l] = d, o.batched = !0
                    }
                } else o.updateMark = s._updateCountMark, o.indexInList = n.length, o.batched = !1, n.add(this)
            } else if (this.renderSubShader._owner._enableInstancing &amp;&amp; t.LayaGL.layaGPUInstance.supportInstance() &amp;&amp; this.render.lightmapIndex &lt; 0) {
                var T = this._geometry,
                    E = _.MeshRenderDynamicBatchManager.instance,
                    p = E.getInstanceBatchOpaquaMark(this.render.receiveShadow, this.material.id, T._id, this._transform._isFrontFaceInvert);
                if (E._updateCountMark === p.updateMark) {
                    var g = p.indexInList;
                    if (p.batched) {
                        var S = a[g].instanceBatchElementList;
                        S.length === zt.instance.maxInstanceCount ? (p.updateMark = E._updateCountMark, p.indexInList = n.length, p.batched = !1, n.add(this)) : S.add(this)
                    } else {
                        var R = a[g],
                            v = R.render,
                            A = E._getBatchRenderElementFromPool();
                        A.renderType = Ht.RENDERTYPE_INSTANCEBATCH, A.setGeometry(zt.instance), A.material = R.material, A.setTransform(null), A.render = v, A.instanceSubMesh = T, A.renderSubShader = R.renderSubShader;
                        var I = A.instanceBatchElementList;
                        I.length = 0, I.add(R), I.add(this), a[g] = A, p.batched = !0
                    }
                } else p.updateMark = E._updateCountMark, p.indexInList = n.length, p.batched = !1, n.add(this)
            } else if (this._dynamicVertexBatch) {
                var x = this._geometry._vertexBuffer.vertexDeclaration,
                    L = _.MeshRenderDynamicBatchManager.instance,
                    D = L.getVertexBatchOpaquaMark(this.render.lightmapIndex + 1, this.render.receiveShadow, this.material.id, x.id);
                if (L._updateCountMark === D.updateMark) {
                    var C = D.indexInList;
                    if (D.batched) a[C].vertexBatchElementList.add(this);
                    else {
                        var y = a[C],
                            M = y.render,
                            O = L._getBatchRenderElementFromPool();
                        O.renderType = Ht.RENDERTYPE_VERTEXBATCH, O.setGeometry(_.SubMeshDynamicBatch.instance), O.material = y.material, O.setTransform(null), O.render = M, O.vertexBatchVertexDeclaration = x, O.renderSubShader = y.renderSubShader;
                        var N = O.vertexBatchElementList;
                        N.length = 0, N.add(y), N.add(this), a[C] = O, D.batched = !0
                    }
                } else D.updateMark = L._updateCountMark, D.indexInList = n.length, D.batched = !1, n.add(this)
            } else n.add(this)
        }
        addToTransparentRenderQueue(e, r) {
            var i = this.staticBatch,
                n = r.elements,
                a = n.elements;
            if (i) {
                var s = _.MeshRenderStaticBatchManager.instance,
                    o = r.lastTransparentRenderElement;
                if (o) {
                    var l = o.render;
                    if (o._geometry._getType() !== this._geometry._getType() || o.staticBatch !== i || o.material !== this.material || l.receiveShadow !== this.render.receiveShadow || l.lightmapIndex !== this.render.lightmapIndex) n.add(this), r.lastTransparentBatched = !1;
                    else {
                        if (r.lastTransparentBatched) a[n.length - 1].staticBatchElementList.add(this);
                        else {
                            var h = s._getBatchRenderElementFromPool();
                            h.renderType = Ht.RENDERTYPE_STATICBATCH, h.setGeometry(i), h.material = o.material;
                            var c = i.batchOwner,
                                d = c ? c._transform : null;
                            h.setTransform(d), h.render = this.render, h.renderSubShader = o.renderSubShader;
                            var u = h.staticBatchElementList;
                            u.length = 0, u.add(o), u.add(this), a[n.length - 1] = h
                        }
                        r.lastTransparentBatched = !0
                    }
                } else n.add(this), r.lastTransparentBatched = !1
            } else if (this.renderSubShader._owner._enableInstancing &amp;&amp; t.LayaGL.layaGPUInstance.supportInstance() &amp;&amp; this.render.lightmapIndex &lt; 0) {
                var m = this._geometry,
                    f = _.MeshRenderDynamicBatchManager.instance,
                    T = r.lastTransparentRenderElement;
                if (T) {
                    var E = T.render;
                    if (T._geometry._getType() !== this._geometry._getType() || T._geometry !== m || T.material !== this.material || E.receiveShadow !== this.render.receiveShadow) n.add(this), r.lastTransparentBatched = !1;
                    else if (r.lastTransparentBatched) {
                        var p = a[n.length - 1].instanceBatchElementList;
                        p.length === zt.instance.maxInstanceCount ? (n.add(this), r.lastTransparentBatched = !1) : (p.add(this), r.lastTransparentBatched = !0)
                    } else {
                        var g = f._getBatchRenderElementFromPool();
                        g.renderType = Ht.RENDERTYPE_INSTANCEBATCH, g.setGeometry(zt.instance), g.material = T.material, g.setTransform(null), g.render = this.render, g.instanceSubMesh = m, g.renderSubShader = T.renderSubShader;
                        var S = g.instanceBatchElementList;
                        S.length = 0, S.add(T), S.add(this), a[n.length - 1] = g, r.lastTransparentBatched = !0
                    }
                } else n.add(this), r.lastTransparentBatched = !1
            } else if (this._dynamicVertexBatch) {
                var R = this._geometry._vertexBuffer.vertexDeclaration,
                    v = _.MeshRenderDynamicBatchManager.instance,
                    A = r.lastTransparentRenderElement;
                if (A) {
                    var I = A.render;
                    if (A._dynamicVertexBatch &amp;&amp; A._geometry._getType() === this._geometry._getType() &amp;&amp; A._geometry._vertexBuffer._vertexDeclaration === R &amp;&amp; A.material === this.material &amp;&amp; I.receiveShadow === this.render.receiveShadow &amp;&amp; I.lightmapIndex === this.render.lightmapIndex) {
                        if (r.lastTransparentBatched) a[n.length - 1].vertexBatchElementList.add(this);
                        else {
                            var x = v._getBatchRenderElementFromPool();
                            x.renderType = Ht.RENDERTYPE_VERTEXBATCH, x.setGeometry(_.SubMeshDynamicBatch.instance), x.material = A.material, x.setTransform(null), x.render = this.render, x.vertexBatchVertexDeclaration = R, x.renderSubShader = A.renderSubShader;
                            var L = x.vertexBatchElementList;
                            L.length = 0, L.add(A), L.add(this), a[n.length - 1] = x
                        }
                        r.lastTransparentBatched = !0
                    } else n.add(this), r.lastTransparentBatched = !1
                } else n.add(this), r.lastTransparentBatched = !1
            } else n.add(this);
            r.lastTransparentRenderElement = this
        }
        getInvertFront() {
            switch (this.renderType) {
                case Ht.RENDERTYPE_NORMAL:
                    return this._transform._isFrontFaceInvert;
                case Ht.RENDERTYPE_STATICBATCH:
                case Ht.RENDERTYPE_VERTEXBATCH:
                    return !1;
                case Ht.RENDERTYPE_INSTANCEBATCH:
                    return this.instanceBatchElementList.elements[0]._transform._isFrontFaceInvert;
                default:
                    throw "SubMeshRenderElement: unknown renderType"
            }
        }
        destroy() {
            super.destroy(), this._dynamicWorldPositions = null, this._dynamicWorldNormals = null, this.staticBatch = null, this.staticBatchElementList = null, this.vertexBatchElementList = null, this.vertexBatchVertexDeclaration = null
        }
    }
    class kt {
        constructor() {
            this._initBatchSprites = [], this._staticBatches = {}, this._batchRenderElementPoolIndex = 0, this._batchRenderElementPool = []
        }
        static _addToStaticBatchQueue(e, t) {
            e instanceof Ut &amp;&amp; t.push(e);
            for (var r = 0, i = e.numChildren; r &lt; i; r++) kt._addToStaticBatchQueue(e._children[r], t)
        }
        static _registerManager(e) {
            kt._managers.push(e)
        }
        static combine(e, t = null) {
            t || (t = [], e &amp;&amp; kt._addToStaticBatchQueue(e, t));
            var r = t.length;
            if (r &gt; 0) {
                for (var i = 0; i &lt; r; i++) {
                    var n = t[i];
                    n.destroyed || (n._render._isPartOfStaticBatch ? console.warn("StaticBatchManager: Sprite " + n.name + " has a part of Static Batch,it will be ignore.") : n._addToInitStaticBatchManager())
                }
                for (var a = 0, s = kt._managers.length; a &lt; s; a++) {
                    kt._managers[a]._initStaticBatchs(e)
                }
            }
        }
        _partition(e, t, r) {
            for (var i = e[Math.floor((r + t) / 2)]; t &lt;= r;) {
                for (; this._compare(e[t], i) &lt; 0;) t++;
                for (; this._compare(e[r], i) &gt; 0;) r--;
                if (t &lt; r) {
                    var n = e[t];
                    e[t] = e[r], e[r] = n, t++, r--
                } else if (t === r) {
                    t++;
                    break
                }
            }
            return t
        }
        _quickSort(e, t, r) {
            if (e.length &gt; 1) {
                var i = this._partition(e, t, r),
                    n = i - 1;
                t &lt; n &amp;&amp; this._quickSort(e, t, n), i &lt; r &amp;&amp; this._quickSort(e, i, r)
            }
        }
        _compare(e, t) {
            throw "StaticBatch:must override this function."
        }
        _initStaticBatchs(e) {
            throw "StaticBatch:must override this function."
        }
        _getBatchRenderElementFromPool() {
            throw "StaticBatch:must override this function."
        }
        _addBatchSprite(e) {
            this._initBatchSprites.push(e)
        }
        _clear() {
            this._batchRenderElementPoolIndex = 0
        }
        _garbageCollection() {
            throw "StaticBatchManager: must override it."
        }
        dispose() {
            this._staticBatches = null
        }
    }
    kt._managers = [];
    class Xt extends Vt {
        constructor(e, t) {
            super(), this._bufferState = new it, this._batchID = Xt._batchIDCounter++, this._batchElements = [], this._currentBatchVertexCount = 0, this._currentBatchIndexCount = 0, this._vertexDeclaration = t, this.batchOwner = e
        }
        _getStaticBatchBakedVertexs(e, t, r, i, n, a) {
            var s, o = a._vertexBuffer,
                l = o.vertexDeclaration,
                _ = l.getVertexElementByUsage(lt.MESH_POSITION0)._offset / 4,
                h = l.getVertexElementByUsage(lt.MESH_NORMAL0),
                d = h ? h._offset / 4 : -1,
                u = l.getVertexElementByUsage(lt.MESH_COLOR0),
                m = u ? u._offset / 4 : -1,
                f = l.getVertexElementByUsage(lt.MESH_TEXTURECOORDINATE0),
                T = f ? f._offset / 4 : -1,
                E = l.getVertexElementByUsage(lt.MESH_TEXTURECOORDINATE1),
                p = E ? E._offset / 4 : -1,
                g = l.getVertexElementByUsage(lt.MESH_TANGENT0),
                S = g ? g._offset / 4 : -1,
                R = l.vertexStride / 4,
                v = o.getFloat32Data();
            r ? (r.worldMatrix.invert(Xt._tempMatrix4x40), s = Xt._tempMatrix4x41, c.multiply(Xt._tempMatrix4x40, i.worldMatrix, s)) : s = i.worldMatrix;
            var A = Xt._tempMatrix4x42;
            s.invert(A), A.transpose();
            var I = Xt._tempQuaternion0;
            s.decomposeTransRotScale(Xt._tempVector30, I, Xt._tempVector31);
            for (var x = n.lightmapScaleOffset, L = a.vertexCount, D = 0; D &lt; L; D++) {
                var C, y, M = D * R,
                    O = 18 * (D + t);
                N.transformVector3ArrayToVector3ArrayCoordinate(v, M + _, s, e, O + 0), -1 !== d &amp;&amp; N.transformVector3ArrayToVector3ArrayNormal(v, M + d, A, e, O + 3);
                var b = O + 6;
                if (-1 !== m) {
                    var P = M + m;
                    for (C = 0, y = 4; C &lt; y; C++) e[b + C] = v[P + C]
                } else
                    for (C = 0, y = 4; C &lt; y; C++) e[b + C] = 1;
                if (-1 !== T) {
                    var w = M + T;
                    e[O + 10] = v[w], e[O + 11] = v[w + 1]
                }
                if (x &amp;&amp; (-1 !== p ? N.transformLightingMapTexcoordArray(v, M + p, x, e, O + 12) : N.transformLightingMapTexcoordArray(v, M + T, x, e, O + 12)), -1 !== S) {
                    var V = M + S;
                    e[O + 14] = v[V], e[O + 15] = v[V + 1], e[O + 16] = v[V + 2], e[O + 17] = v[V + 3]
                }
            }
            return L
        }
        addTest(e) {
            var t = e.meshFilter.sharedMesh.vertexCount;
            return !(this._currentBatchVertexCount + t &gt; Xt.maxBatchVertexCount)
        }
        add(e) {
            var t = e.meshFilter.sharedMesh,
                r = t.vertexCount;
            this._batchElements.push(e);
            var i = e._render;
            i._isPartOfStaticBatch = !0, i._staticBatch = this;
            for (var n = i._renderElements, a = 0, s = n.length; a &lt; s; a++) n[a].staticBatch = this;
            this._currentBatchIndexCount += t._indexBuffer.indexCount, this._currentBatchVertexCount += r
        }
        remove(e) {
            var t = e.meshFilter.sharedMesh,
                r = this._batchElements.indexOf(e);
            if (-1 !== r) {
                this._batchElements.splice(r, 1);
                for (var i = e._render._renderElements, n = 0, a = i.length; n &lt; a; n++) i[n].staticBatch = null;
                this._currentBatchIndexCount = this._currentBatchIndexCount - t._indexBuffer.indexCount, this._currentBatchVertexCount = this._currentBatchVertexCount - t.vertexCount, e._render._isPartOfStaticBatch = !1
            }
        }
        finishInit() {
            this._vertexBuffer &amp;&amp; (this._vertexBuffer.destroy(), this._indexBuffer.destroy(), t.Resource._addGPUMemory(-(this._vertexBuffer._byteLength + this._indexBuffer._byteLength)));
            var r = t.LayaGL.instance,
                i = 0,
                n = 0,
                a = this.batchOwner,
                s = this._vertexDeclaration.vertexStride / 4,
                o = new Float32Array(s * this._currentBatchVertexCount),
                l = new Uint16Array(this._currentBatchIndexCount);
            this._vertexBuffer = new _t(this._vertexDeclaration.vertexStride * this._currentBatchVertexCount, r.STATIC_DRAW), this._vertexBuffer.vertexDeclaration = this._vertexDeclaration, this._indexBuffer = new nt(e.IndexFormat.UInt16, this._currentBatchIndexCount, r.STATIC_DRAW);
            for (var _ = 0, h = this._batchElements.length; _ &lt; h; _++) {
                for (var c, d = this._batchElements[_], u = d.meshFilter.sharedMesh, m = this._getStaticBatchBakedVertexs(o, i, a ? a._transform : null, d._transform, d._render, u), f = u._indexBuffer.getData(), T = i, E = n + f.length, p = d._render._renderElements, g = 0, S = u.subMeshCount; g &lt; S; g++) {
                    var R = u._subMeshes[g],
                        v = n + R._indexStart,
                        A = p[g];
                    A.staticBatchIndexStart = v, A.staticBatchIndexEnd = v + R._indexCount
                }
                if (l.set(f, n), a ? d._transform._isFrontFaceInvert !== a.transform._isFrontFaceInvert : d._transform._isFrontFaceInvert)
                    for (c = n; c &lt; E; c += 3) {
                        l[c] = T + l[c];
                        var I = l[c + 1],
                            x = l[c + 2];
                        l[c + 1] = T + x, l[c + 2] = T + I
                    } else
                        for (c = n; c &lt; E; c += 3) l[c] = T + l[c], l[c + 1] = T + l[c + 1], l[c + 2] = T + l[c + 2];
                n += f.length, i += m
            }
            this._vertexBuffer.setData(o.buffer), this._indexBuffer.setData(l);
            var L = this._vertexBuffer._byteLength + this._indexBuffer._byteLength;
            t.Resource._addGPUMemory(L), this._bufferState.bind(), this._bufferState.applyVertexBuffer(this._vertexBuffer), this._bufferState.applyIndexBuffer(this._indexBuffer), this._bufferState.unBind()
        }
        _render(e) {
            this._bufferState.bind();
            for (var r = t.LayaGL.instance, i = e.renderElement.staticBatchElementList, n = i.elements, a = 0, s = 0, o = i.length, l = 1; l &lt; o; l++) {
                if (n[l - 1].staticBatchIndexEnd !== n[l].staticBatchIndexStart) {
                    var _ = n[a].staticBatchIndexStart,
                        h = n[s].staticBatchIndexEnd - _;
                    r.drawElements(r.TRIANGLES, h, r.UNSIGNED_SHORT, 2 * _), a = ++s, t.Stat.trianglesFaces += h / 3
                } else s++
            }
            _ = n[a].staticBatchIndexStart, h = n[s].staticBatchIndexEnd - _, r.drawElements(r.TRIANGLES, h, r.UNSIGNED_SHORT, 2 * _), t.Stat.renderBatches++, t.Stat.savedRenderBatches += o - 1, t.Stat.trianglesFaces += h / 3
        }
        dispose() {
            var e = this._vertexBuffer._byteLength + this._indexBuffer._byteLength;
            t.Resource._addGPUMemory(-e), this._batchElements = null, this.batchOwner = null, this._vertexDeclaration = null, this._bufferState.destroy(), this._vertexBuffer.destroy(), this._indexBuffer.destroy(), this._vertexBuffer = null, this._indexBuffer = null, this._bufferState = null
        }
    }
    Xt._tempVector30 = new a, Xt._tempVector31 = new a, Xt._tempQuaternion0 = new h, Xt._tempMatrix4x40 = new c, Xt._tempMatrix4x41 = new c, Xt._tempMatrix4x42 = new c, Xt.maxBatchVertexCount = 65535, Xt._batchIDCounter = 0;
    class Yt extends kt {
        constructor() {
            super(), this._opaqueBatchMarks = [], this._updateCountMark = 0
        }
        static __init__() {
            Yt._verDec = lt.getVertexDeclaration("POSITION,NORMAL,COLOR,UV,UV1,TANGENT")
        }
        _compare(e, t) {
            var r = e._render,
                i = t._render,
                n = e.meshFilter.sharedMesh,
                a = t.meshFilter.sharedMesh,
                s = r.lightmapIndex - i.lightmapIndex;
            if (0 === s) {
                var o = (r.receiveShadow ? 1 : 0) - (i.receiveShadow ? 1 : 0);
                if (0 === o) {
                    var l = r.sharedMaterial &amp;&amp; i.sharedMaterial ? r.sharedMaterial.id - i.sharedMaterial.id : 0;
                    if (0 === l) {
                        var _ = n._vertexBuffer.vertexDeclaration.id - a._vertexBuffer.vertexDeclaration.id;
                        return 0 === _ ? a._indexBuffer.indexCount - n._indexBuffer.indexCount : _
                    }
                    return l
                }
                return o
            }
            return s
        }
        _getBatchRenderElementFromPool() {
            var e = this._batchRenderElementPool[this._batchRenderElementPoolIndex++];
            return e || (e = new Wt, this._batchRenderElementPool[this._batchRenderElementPoolIndex - 1] = e, e.staticBatchElementList = new I), e
        }
        _getStaticBatch(e, t, r) {
            var i = e[r];
            return i || (i = e[r] = new Xt(t, Yt._verDec), this._staticBatches[i._batchID] = i), i
        }
        _initStaticBatchs(e) {
            var t = this._initBatchSprites;
            this._quickSort(t, 0, t.length - 1);
            for (var r, i = [], n = !1, a = 0, s = 0, o = t.length; s &lt; o; s++) {
                var l = t[s];
                if (n) r.addTest(l) ? r.add(l) : (n = !1, a++);
                else s !== o - 1 &amp;&amp; ((r = this._getStaticBatch(i, e, a)).add(l), n = !0)
            }
            for (s = 0, o = i.length; s &lt; o; s++) {
                var _ = i[s];
                _ &amp;&amp; _.finishInit()
            }
            this._initBatchSprites.length = 0
        }
        _removeRenderSprite(e) {
            var t = e._render,
                r = t._staticBatch,
                i = r._batchElements,
                n = i.indexOf(e);
            if (-1 !== n) {
                i.splice(n, 1), t._staticBatch = null;
                for (var a = t._renderElements, s = 0, o = a.length; s &lt; o; s++) a[s].staticBatch = null
            }
            0 === i.length &amp;&amp; (delete this._staticBatches[r._batchID], r.dispose())
        }
        _clear() {
            super._clear(), this._updateCountMark++
        }
        _garbageCollection() {
            for (var e in this._staticBatches) {
                var t = this._staticBatches[e];
                0 === t._batchElements.length &amp;&amp; (t.dispose(), delete this._staticBatches[e])
            }
        }
        getBatchOpaquaMark(e, t, r, i) {
            var n = t ? 1 : 0,
                a = this._opaqueBatchMarks[e] || (this._opaqueBatchMarks[e] = []),
                s = a[n] || (a[n] = []),
                o = s[r] || (s[r] = []);
            return o[i] || (o[i] = new Gt)
        }
    }
    Yt.instance = new Yt;
    class jt extends t.EventDispatcher {
        constructor(e) {
            if (super(), this._lightmapScaleOffset = new n(1, 1, 0, 0), this._indexInList = -1, this._indexInCastShadowList = -1, this._boundsChange = !0, this._castShadow = !1, this._supportOctree = !0, this._sharedMaterials = [], this._renderMark = -1, this._indexInOctreeMotionList = -1, this._updateMark = -1, this._updateRenderType = -1, this._isPartOfStaticBatch = !1, this._staticBatch = null, this._id = ++jt._uniqueIDCounter, this._indexInCastShadowList = -1, this._bounds = new wt(a._ZERO, a._ZERO), t.Render.supportWebGLPlusCulling) {
                var r = ke._cullingBufferLength;
                this._cullingBufferIndex = r;
                var i = ke._cullingBuffer,
                    s = r + 7;
                if (s &gt;= i.length) {
                    var o = i;
                    (i = ke._cullingBuffer = new Float32Array(i.length + 4096)).set(o, 0)
                }
                i[r] = 2, ke._cullingBufferLength = s
            }
            this._renderElements = [], this._owner = e, this._enable = !0, this._materialsInstance = [], this._shaderValues = new ce(null), this.lightmapIndex = -1, this.receiveShadow = !1, this.sortingFudge = 0, e &amp;&amp; this._owner.transform.on(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatNeedChange)
        }
        get id() {
            return this._id
        }
        get lightmapIndex() {
            return this._lightmapIndex
        }
        set lightmapIndex(e) {
            this._lightmapIndex = e
        }
        get lightmapScaleOffset() {
            return this._lightmapScaleOffset
        }
        set lightmapScaleOffset(e) {
            if (!e) throw "BaseRender: lightmapScaleOffset can't be null.";
            this._lightmapScaleOffset = e, this._shaderValues.setVector(Ut.LIGHTMAPSCALEOFFSET, e)
        }
        get enable() {
            return this._enable
        }
        set enable(e) {
            this._enable = !!e
        }
        get material() {
            var e = this._sharedMaterials[0];
            if (e &amp;&amp; !this._materialsInstance[0]) {
                var t = this._getInstanceMaterial(e, 0),
                    r = this._renderElements[0];
                r &amp;&amp; (r.material = t)
            }
            return this._sharedMaterials[0]
        }
        set material(e) {
            this.sharedMaterial = e
        }
        get materials() {
            for (var e = 0, t = this._sharedMaterials.length; e &lt; t; e++)
                if (!this._materialsInstance[e]) {
                    var r = this._getInstanceMaterial(this._sharedMaterials[e], e),
                        i = this._renderElements[e];
                    i &amp;&amp; (i.material = r)
                }
            return this._sharedMaterials.slice()
        }
        set materials(e) {
            this.sharedMaterials = e
        }
        get sharedMaterial() {
            return this._sharedMaterials[0]
        }
        set sharedMaterial(e) {
            var t = this._sharedMaterials[0];
            if (t !== e) {
                this._sharedMaterials[0] = e, this._materialsInstance[0] = !1, this._changeMaterialReference(t, e);
                var r = this._renderElements[0];
                r &amp;&amp; (r.material = e)
            }
        }
        get sharedMaterials() {
            return this._sharedMaterials.slice()
        }
        set sharedMaterials(e) {
            for (var t = this._materialsInstance, r = this._sharedMaterials, i = 0, n = r.length; i &lt; n; i++) {
                var a = r[i];
                a &amp;&amp; a._removeReference()
            }
            if (!e) throw new Error("BaseRender: shadredMaterials value can't be null.");
            var s = e.length;
            for (t.length = s, r.length = s, i = 0; i &lt; s; i++) {
                a = r[i];
                var o = e[i];
                if (a !== o) {
                    t[i] = !1;
                    var l = this._renderElements[i];
                    l &amp;&amp; (l.material = o)
                }
                o &amp;&amp; o._addReference(), r[i] = o
            }
        }
        get bounds() {
            return this._boundsChange &amp;&amp; (this._calculateBoundingBox(), this._boundsChange = !1), this._bounds
        }
        set receiveShadow(e) {
            this._receiveShadow !== e &amp;&amp; (this._receiveShadow = e, e ? this._shaderValues.addDefine(Ut.SHADERDEFINE_RECEIVE_SHADOW) : this._shaderValues.removeDefine(Ut.SHADERDEFINE_RECEIVE_SHADOW))
        }
        get receiveShadow() {
            return this._receiveShadow
        }
        get castShadow() {
            return this._castShadow
        }
        set castShadow(e) {
            this._castShadow = e
        }
        get isPartOfStaticBatch() {
            return this._isPartOfStaticBatch
        }
        get isRender() {
            return -1 == this._renderMark || this._renderMark == t.Stat.loopCount - 1
        }
        _getOctreeNode() {
            return this._octreeNode
        }
        _setOctreeNode(e) {
            this._octreeNode = e
        }
        _getIndexInMotionList() {
            return this._indexInOctreeMotionList
        }
        _setIndexInMotionList(e) {
            this._indexInOctreeMotionList = e
        }
        _changeMaterialReference(e, t) {
            e &amp;&amp; e._removeReference(), t._addReference()
        }
        _getInstanceMaterial(e, t) {
            var r = e.clone();
            return r.name = r.name + "(Instance)", this._materialsInstance[t] = !0, this._changeMaterialReference(this._sharedMaterials[t], r), this._sharedMaterials[t] = r, r
        }
        _applyLightMapParams() {
            var e = this._scene.lightmaps,
                t = this._shaderValues,
                r = this._lightmapIndex;
            if (r &gt;= 0 &amp;&amp; r &lt; e.length) {
                var i = e[r];
                t.setTexture(Ut.LIGHTMAP, i.lightmapColor), t.addDefine(Ut.SAHDERDEFINE_LIGHTMAP), i.lightmapDirection ? (t.setTexture(Ut.LIGHTMAP_DIRECTION, i.lightmapDirection), t.addDefine(Ut.SHADERDEFINE_LIGHTMAP_DIRECTIONAL)) : t.removeDefine(Ut.SHADERDEFINE_LIGHTMAP_DIRECTIONAL)
            } else t.removeDefine(Ut.SAHDERDEFINE_LIGHTMAP), t.removeDefine(Ut.SHADERDEFINE_LIGHTMAP_DIRECTIONAL)
        }
        _onWorldMatNeedChange(e) {
            this._boundsChange = !0, this._octreeNode &amp;&amp; (e &amp;= f.TRANSFORM_WORLDPOSITION | f.TRANSFORM_WORLDQUATERNION | f.TRANSFORM_WORLDSCALE) &amp;&amp; -1 === this._indexInOctreeMotionList &amp;&amp; this._octreeNode._octree.addMotionObject(this)
        }
        _calculateBoundingBox() {
            throw "BaseRender: must override it."
        }
        _getIndexInList() {
            return this._indexInList
        }
        _setIndexInList(e) {
            this._indexInList = e
        }
        _setBelongScene(e) {
            this._scene = e
        }
        _needRender(e, t) {
            return !0
        }
        _renderUpdate(e, t) {}
        _renderUpdateWithCamera(e, t) {}
        _revertBatchRenderUpdate(e) {}
        _destroy() {
            -1 !== this._indexInOctreeMotionList &amp;&amp; this._octreeNode._octree.removeMotionObject(this), this.offAll();
            var e = 0,
                t = 0;
            for (e = 0, t = this._renderElements.length; e &lt; t; e++) this._renderElements[e].destroy();
            for (e = 0, t = this._sharedMaterials.length; e &lt; t; e++) this._sharedMaterials[e].destroyed || this._sharedMaterials[e]._removeReference();
            this._renderElements = null, this._owner = null, this._sharedMaterials = null, this._bounds = null, this._lightmapScaleOffset = null
        }
        markAsUnStatic() {
            this._isPartOfStaticBatch &amp;&amp; (Yt.instance._removeRenderSprite(this._owner), this._isPartOfStaticBatch = !1)
        }
    }
    jt._tempBoundBoxCorners = [new a, new a, new a, new a, new a, new a, new a, new a], jt._uniqueIDCounter = 0, jt._defaultLightmapScaleOffset = new n(1, 1, 0, 0);
    class Zt extends jt {
        constructor(e) {
            super(e), this._projectionViewWorldMatrix = new c
        }
        _calculateBoundingBox() {
            var e = this._owner.transform.worldMatrix,
                r = this._owner._geometryFilter;
            if (r._reCalculateBound(), r._bounds._tranform(e, this._bounds), t.Render.supportWebGLPlusCulling) {
                var i = this._bounds.getMin(),
                    n = this._bounds.getMax(),
                    a = ke._cullingBuffer;
                a[this._cullingBufferIndex + 1] = i.x, a[this._cullingBufferIndex + 2] = i.y, a[this._cullingBufferIndex + 3] = i.z, a[this._cullingBufferIndex + 4] = n.x, a[this._cullingBufferIndex + 5] = n.y, a[this._cullingBufferIndex + 6] = n.z
            }
        }
        _renderUpdateWithCamera(e, t) {
            var r = e.projectionViewMatrix,
                i = this._shaderValues;
            if (t) {
                var n = t.worldMatrix;
                i.setMatrix4x4(ut.WORLDMATRIX, n), c.multiply(r, n, this._projectionViewWorldMatrix), i.setMatrix4x4(ut.MVPMATRIX, this._projectionViewWorldMatrix)
            } else i.setMatrix4x4(ut.WORLDMATRIX, c.DEFAULT), i.setMatrix4x4(ut.MVPMATRIX, r)
        }
    }
    class qt extends Ut {
        constructor(e = 2, t = null) {
            super(t), this._geometryFilter = new Ft(this, e), this._render = new Zt(this), this._changeRenderObjects(this._render, 0, bt.defaultMaterial)
        }
        get maxLineCount() {
            return this._geometryFilter._maxLineCount
        }
        set maxLineCount(e) {
            this._geometryFilter._resizeLineData(e), this._geometryFilter._lineCount = Math.min(this._geometryFilter._lineCount, e)
        }
        get lineCount() {
            return this._geometryFilter._lineCount
        }
        set lineCount(e) {
            if (e &gt; this.maxLineCount) throw "PixelLineSprite3D: lineCount can't large than maxLineCount";
            this._geometryFilter._lineCount = e
        }
        get pixelLineRenderer() {
            return this._render
        }
        _changeRenderObjects(e, t, r) {
            var i = this._render._renderElements;
            r || (r = bt.defaultMaterial);
            var n = i[t];
            n || (n = i[t] = new Ht), n.setTransform(this._transform), n.setGeometry(this._geometryFilter), n.render = this._render, n.material = r
        }
        addLine(e, t, r, i) {
            if (this._geometryFilter._lineCount === this._geometryFilter._maxLineCount) throw "PixelLineSprite3D: lineCount has equal with maxLineCount.";
            this._geometryFilter._updateLineData(this._geometryFilter._lineCount++, e, t, r, i)
        }
        addLines(e) {
            var t = this._geometryFilter._lineCount,
                r = e.length;
            if (t + r &gt; this._geometryFilter._maxLineCount) throw "PixelLineSprite3D: lineCount plus lines count must less than maxLineCount.";
            this._geometryFilter._updateLineDatas(t, e), this._geometryFilter._lineCount += r
        }
        removeLine(e) {
            if (!(e &lt; this._geometryFilter._lineCount)) throw "PixelLineSprite3D: index must less than lineCount.";
            this._geometryFilter._removeLineData(e)
        }
        setLine(e, t, r, i, n) {
            if (!(e &lt; this._geometryFilter._lineCount)) throw "PixelLineSprite3D: index must less than lineCount.";
            this._geometryFilter._updateLineData(e, t, r, i, n)
        }
        getLine(e, t) {
            if (!(e &lt; this.lineCount)) throw "PixelLineSprite3D: index must less than lineCount.";
            this._geometryFilter._getLineData(e, t)
        }
        clear() {
            this._geometryFilter._lineCount = 0
        }
        _create() {
            return new qt
        }
    }
    class Qt {
        constructor(e = !1) {
            this.isTransparent = !1, this.elements = new I, this.lastTransparentRenderElement = null, this.lastTransparentBatched = !1, this.isTransparent = e
        }
        _compare(e, t) {
            var r = e.material.renderQueue - t.material.renderQueue;
            return 0 === r ? (this.isTransparent ? t.render._distanceForSort - e.render._distanceForSort : e.render._distanceForSort - t.render._distanceForSort) + t.render.sortingFudge - e.render.sortingFudge : r
        }
        _partitionRenderObject(e, t) {
            for (var r = this.elements.elements, i = r[Math.floor((t + e) / 2)]; e &lt;= t;) {
                for (; this._compare(r[e], i) &lt; 0;) e++;
                for (; this._compare(r[t], i) &gt; 0;) t--;
                if (e &lt; t) {
                    var n = r[e];
                    r[e] = r[t], r[t] = n, e++, t--
                } else if (e === t) {
                    e++;
                    break
                }
            }
            return e
        }
        _quickSort(e, t) {
            if (this.elements.length &gt; 1) {
                var r = this._partitionRenderObject(e, t),
                    i = r - 1;
                e &lt; i &amp;&amp; this._quickSort(e, i), r &lt; t &amp;&amp; this._quickSort(r, t)
            }
        }
        _render(e) {
            for (var t = this.elements.elements, r = 0, i = this.elements.length; r &lt; i; r++) t[r]._render(e)
        }
        clear() {
            this.elements.length = 0, this.lastTransparentRenderElement = null, this.lastTransparentBatched = !1
        }
    }
    class Kt {
        constructor(e, t, r, i) {
            this._bounds = new Pt(new a, new a), this._objects = [], this._isContaion = !1, this.center = new a, this.baseLength = 0, this._setValues(e, t, r, i)
        }
        static _encapsulates(e, t) {
            return $e.boxContainsBox(e, t) == Je.Contains
        }
        _setValues(e, t, r, i) {
            this._octree = e, this._parent = t, this.baseLength = r, i.cloneTo(this.center);
            var n = this._bounds.min,
                a = this._bounds.max,
                s = e._looseness * r / 2;
            n.setValue(i.x - s, i.y - s, i.z - s), a.setValue(i.x + s, i.y + s, i.z + s)
        }
        _getChildBound(e) {
            if (null != this._children &amp;&amp; this._children[e]) return this._children[e]._bounds;
            var t = this.baseLength / 4,
                r = this.baseLength / 2 * this._octree._looseness / 2,
                i = Kt._tempBoundBox,
                n = i.min,
                a = i.max;
            switch (e) {
                case 0:
                    n.x = this.center.x - t - r, n.y = this.center.y + t - r, n.z = this.center.z - t - r, a.x = this.center.x - t + r, a.y = this.center.y + t + r, a.z = this.center.z - t + r;
                    break;
                case 1:
                    n.x = this.center.x + t - r, n.y = this.center.y + t - r, n.z = this.center.z - t - r, a.x = this.center.x + t + r, a.y = this.center.y + t + r, a.z = this.center.z - t + r;
                    break;
                case 2:
                    n.x = this.center.x - t - r, n.y = this.center.y + t - r, n.z = this.center.z + t - r, a.x = this.center.x - t + r, a.y = this.center.y + t + r, a.z = this.center.z + t + r;
                    break;
                case 3:
                    n.x = this.center.x + t - r, n.y = this.center.y + t - r, n.z = this.center.z + t - r, a.x = this.center.x + t + r, a.y = this.center.y + t + r, a.z = this.center.z + t + r;
                    break;
                case 4:
                    n.x = this.center.x - t - r, n.y = this.center.y - t - r, n.z = this.center.z - t - r, a.x = this.center.x - t + r, a.y = this.center.y - t + r, a.z = this.center.z - t + r;
                    break;
                case 5:
                    n.x = this.center.x + t - r, n.y = this.center.y - t - r, n.z = this.center.z - t - r, a.x = this.center.x + t + r, a.y = this.center.y - t + r, a.z = this.center.z - t + r;
                    break;
                case 6:
                    n.x = this.center.x - t - r, n.y = this.center.y - t - r, n.z = this.center.z + t - r, a.x = this.center.x - t + r, a.y = this.center.y - t + r, a.z = this.center.z + t + r;
                    break;
                case 7:
                    n.x = this.center.x + t - r, n.y = this.center.y - t - r, n.z = this.center.z + t - r, a.x = this.center.x + t + r, a.y = this.center.y - t + r, a.z = this.center.z + t + r
            }
            return i
        }
        _getChildCenter(e) {
            if (null != this._children) return this._children[e].center;
            var t = this.baseLength / 4,
                r = Kt._tempVector30;
            switch (e) {
                case 0:
                    r.x = this.center.x - t, r.y = this.center.y + t, r.z = this.center.z - t;
                    break;
                case 1:
                    r.x = this.center.x + t, r.y = this.center.y + t, r.z = this.center.z - t;
                    break;
                case 2:
                    r.x = this.center.x - t, r.y = this.center.y + t, r.z = this.center.z + t;
                    break;
                case 3:
                    r.x = this.center.x + t, r.y = this.center.y + t, r.z = this.center.z + t;
                    break;
                case 4:
                    r.x = this.center.x - t, r.y = this.center.y - t, r.z = this.center.z - t;
                    break;
                case 5:
                    r.x = this.center.x + t, r.y = this.center.y - t, r.z = this.center.z - t;
                    break;
                case 6:
                    r.x = this.center.x - t, r.y = this.center.y - t, r.z = this.center.z + t;
                    break;
                case 7:
                    r.x = this.center.x + t, r.y = this.center.y - t, r.z = this.center.z + t
            }
            return r
        }
        _getChild(e) {
            var t = this.baseLength / 4;
            switch (this._children || (this._children = []), e) {
                case 0:
                    return this._children[0] || (this._children[0] = new Kt(this._octree, this, this.baseLength / 2, new a(this.center.x + -t, this.center.y + t, this.center.z - t)));
                case 1:
                    return this._children[1] || (this._children[1] = new Kt(this._octree, this, this.baseLength / 2, new a(this.center.x + t, this.center.y + t, this.center.z - t)));
                case 2:
                    return this._children[2] || (this._children[2] = new Kt(this._octree, this, this.baseLength / 2, new a(this.center.x - t, this.center.y + t, this.center.z + t)));
                case 3:
                    return this._children[3] || (this._children[3] = new Kt(this._octree, this, this.baseLength / 2, new a(this.center.x + t, this.center.y + t, this.center.z + t)));
                case 4:
                    return this._children[4] || (this._children[4] = new Kt(this._octree, this, this.baseLength / 2, new a(this.center.x - t, this.center.y - t, this.center.z - t)));
                case 5:
                    return this._children[5] || (this._children[5] = new Kt(this._octree, this, this.baseLength / 2, new a(this.center.x + t, this.center.y - t, this.center.z - t)));
                case 6:
                    return this._children[6] || (this._children[6] = new Kt(this._octree, this, this.baseLength / 2, new a(this.center.x - t, this.center.y - t, this.center.z + t)));
                case 7:
                    return this._children[7] || (this._children[7] = new Kt(this._octree, this, this.baseLength / 2, new a(this.center.x + t, this.center.y - t, this.center.z + t)));
                default:
                    throw "BoundsOctreeNode: unknown index."
            }
        }
        _shouldMerge() {
            for (var e = this._objects.length, t = 0; t &lt; 8; t++) {
                var r = this._children[t];
                if (r) {
                    if (null != r._children) return !1;
                    e += r._objects.length
                }
            }
            return e &lt;= Kt._NUM_OBJECTS_ALLOWED
        }
        _mergeChildren() {
            for (var e = 0; e &lt; 8; e++) {
                var t = this._children[e];
                if (t) {
                    t._parent = null;
                    for (var r = t._objects, i = r.length - 1; i &gt;= 0; i--) {
                        var n = r[i];
                        this._objects.push(n), n._setOctreeNode(this)
                    }
                }
            }
            this._children = null
        }
        _merge() {
            if (null === this._children) {
                var e = this._parent;
                e &amp;&amp; e._shouldMerge() &amp;&amp; (e._mergeChildren(), e._merge())
            }
        }
        _checkAddNode(e) {
            if (null == this._children) {
                if (this._objects.length &lt; Kt._NUM_OBJECTS_ALLOWED || this.baseLength / 2 &lt; this._octree._minSize) return this;
                for (var t = this._objects.length - 1; t &gt;= 0; t--) {
                    var r = this._objects[t],
                        i = this._bestFitChild(r.bounds.getCenter());
                    Kt._encapsulates(this._getChildBound(i), r.bounds._getBoundBox()) &amp;&amp; (this._objects.splice(this._objects.indexOf(r), 1), this._getChild(i)._add(r))
                }
            }
            var n = this._bestFitChild(e.bounds.getCenter());
            return Kt._encapsulates(this._getChildBound(n), e.bounds._getBoundBox()) ? this._getChild(n)._checkAddNode(e) : this
        }
        _add(e) {
            var t = this._checkAddNode(e);
            t._objects.push(e), e._setOctreeNode(t)
        }
        _remove(e) {
            var t = this._objects.indexOf(e);
            this._objects.splice(t, 1), e._setOctreeNode(null), this._merge()
        }
        _addUp(e) {
            return $e.boxContainsBox(this._bounds, e.bounds._getBoundBox()) === Je.Contains ? (this._add(e), !0) : !!this._parent &amp;&amp; this._parent._addUp(e)
        }
        _getCollidingWithFrustum(e, r, i, n, s, o) {
            var l = e.boundFrustum,
                _ = e.position,
                h = e.cullingMask;
            if (i) {
                var c = l.containsBoundBox(this._bounds);
                if (t.Stat.octreeNodeCulling++, c === Je.Disjoint) return;
                i = c === Je.Intersects
            }
            this._isContaion = !i;
            for (var d = r.scene, u = t.Stat.loopCount, m = 0, f = this._objects.length; m &lt; f; m++) {
                var T = this._objects[m];
                if (o ? T._castShadow &amp;&amp; T._enable : 0 != (Math.pow(2, T._owner._layer) &amp; h) &amp;&amp; T._enable) {
                    if (i &amp;&amp; (t.Stat.frustumCulling++, !T._needRender(l, r))) continue;
                    T._renderMark = u, T._distanceForSort = a.distance(T.bounds.getCenter(), _);
                    for (var E = T._renderElements, p = 0, g = E.length; p &lt; g; p++) {
                        E[p]._update(d, r, n, s)
                    }
                }
            }
            if (null != this._children)
                for (m = 0; m &lt; 8; m++) {
                    var S = this._children[m];
                    S &amp;&amp; S._getCollidingWithFrustum(e, r, i, n, s, o)
                }
        }
        _getCollidingWithBoundBox(e, t, r) {
            if (t) {
                var i = $e.boxContainsBox(this._bounds, e);
                if (i === Je.Disjoint) return;
                t = i === Je.Intersects
            }
            if (t)
                for (var n = 0, a = this._objects.length; n &lt; a; n++) {
                    var s = this._objects[n];
                    $e.intersectsBoxAndBox(s.bounds._getBoundBox(), e) &amp;&amp; r.push(s)
                }
            if (null != this._children)
                for (n = 0; n &lt; 8; n++) {
                    this._children[n]._getCollidingWithBoundBox(e, t, r)
                }
        }
        _bestFitChild(e) {
            return (e.x &lt;= this.center.x ? 0 : 1) + (e.y &gt;= this.center.y ? 0 : 4) + (e.z &lt;= this.center.z ? 0 : 2)
        }
        _update(e) {
            if ($e.boxContainsBox(this._bounds, e.bounds._getBoundBox()) === Je.Contains) {
                var t = this._checkAddNode(e);
                if (t !== e._getOctreeNode()) {
                    t._objects.push(e), e._setOctreeNode(t);
                    var r = this._objects.indexOf(e);
                    this._objects.splice(r, 1), this._merge()
                }
                return !0
            }
            if (this._parent) {
                var i = this._parent._addUp(e);
                return i &amp;&amp; (r = this._objects.indexOf(e), this._objects.splice(r, 1), this._merge()), i
            }
            return !1
        }
        add(e) {
            return !!Kt._encapsulates(this._bounds, e.bounds._getBoundBox()) &amp;&amp; (this._add(e), !0)
        }
        remove(e) {
            return e._getOctreeNode() === this &amp;&amp; (this._remove(e), !0)
        }
        update(e) {
            return e._getOctreeNode() === this &amp;&amp; this._update(e)
        }
        shrinkIfPossible(e) {
            if (this.baseLength &lt; 2 * e) return this;
            for (var t = -1, r = 0, i = this._objects.length; r &lt; i; r++) {
                var n = this._objects[r],
                    a = this._bestFitChild(n.bounds.getCenter());
                if (0 != r &amp;&amp; a != t) return this;
                var s = this._getChildBound(a);
                if (!Kt._encapsulates(s, n.bounds._getBoundBox())) return this;
                0 == r &amp;&amp; (t = a)
            }
            if (null == this._children) {
                if (-1 != t) {
                    var o = this._getChildCenter(t);
                    this._setValues(this._octree, null, this.baseLength / 2, o)
                }
                return this
            }
            var l = !1;
            for (r = 0, i = this._children.length; r &lt; i; r++) {
                var _ = this._children[r];
                if (_ &amp;&amp; _.hasAnyObjects()) {
                    if (l) return this;
                    if (t &gt;= 0 &amp;&amp; t != r) return this;
                    l = !0, t = r
                }
            }
            if (-1 != t) {
                var h = this._children[t];
                return h._parent = null, h
            }
            return this
        }
        hasAnyObjects() {
            if (this._objects.length &gt; 0) return !0;
            if (null != this._children)
                for (var e = 0; e &lt; 8; e++) {
                    var t = this._children[e];
                    if (t &amp;&amp; t.hasAnyObjects()) return !0
                }
            return !1
        }
        getCollidingWithBoundBox(e, t) {
            this._getCollidingWithBoundBox(e, !0, t)
        }
        getCollidingWithRay(e, t, r = Number.MAX_VALUE) {
            var i = $e.intersectsRayAndBoxRD(e, this._bounds);
            if (!(-1 == i || i &gt; r)) {
                for (var n = 0, a = this._objects.length; n &lt; a; n++) {
                    var s = this._objects[n]; - 1 !== (i = $e.intersectsRayAndBoxRD(e, s.bounds._getBoundBox())) &amp;&amp; i &lt;= r &amp;&amp; t.push(s)
                }
                if (null != this._children)
                    for (n = 0; n &lt; 8; n++) {
                        this._children[n].getCollidingWithRay(e, t, r)
                    }
            }
        }
        getCollidingWithFrustum(e, t, r, i, n) {
            this._getCollidingWithFrustum(e, t, !0, r, i, n)
        }
        isCollidingWithBoundBox(e) {
            if (!$e.intersectsBoxAndBox(this._bounds, e)) return !1;
            for (var t = 0, r = this._objects.length; t &lt; r; t++) {
                var i = this._objects[t];
                if ($e.intersectsBoxAndBox(i.bounds._getBoundBox(), e)) return !0
            }
            if (null != this._children)
                for (t = 0; t &lt; 8; t++) {
                    if (this._children[t].isCollidingWithBoundBox(e)) return !0
                }
            return !1
        }
        isCollidingWithRay(e, t = Number.MAX_VALUE) {
            var r = $e.intersectsRayAndBoxRD(e, this._bounds);
            if (-1 == r || r &gt; t) return !1;
            for (var i = 0, n = this._objects.length; i &lt; n; i++) {
                var a = this._objects[i];
                if (-1 !== (r = $e.intersectsRayAndBoxRD(e, a.bounds._getBoundBox())) &amp;&amp; r &lt;= t) return !0
            }
            if (null != this._children)
                for (i = 0; i &lt; 8; i++) {
                    if (this._children[i].isCollidingWithRay(e, t)) return !0
                }
            return !1
        }
        getBound() {
            return this._bounds
        }
        drawAllBounds(e, t, r) {
            if (null !== this._children || 0 != this._objects.length) {
                t++;
                var i = Kt._tempColor0;
                if (this._isContaion) i.r = 0, i.g = 0, i.b = 1;
                else {
                    var n = r ? t / r : 0;
                    i.r = 1 - n, i.g = n, i.b = 0
                }
                if (i.a = .3, N._drawBound(e, this._bounds, i), null != this._children)
                    for (var a = 0; a &lt; 8; a++) {
                        var s = this._children[a];
                        s &amp;&amp; s.drawAllBounds(e, t, r)
                    }
            }
        }
        drawAllObjects(e, t, r) {
            t++;
            var i = Kt._tempColor0;
            if (this._isContaion) i.r = 0, i.g = 0, i.b = 1;
            else {
                var n = r ? t / r : 0;
                i.r = 1 - n, i.g = n, i.b = 0
            }
            i.a = 1;
            for (var a = 0, s = this._objects.length; a &lt; s; a++) N._drawBound(e, this._objects[a].bounds._getBoundBox(), i);
            if (null != this._children)
                for (a = 0; a &lt; 8; a++) {
                    var o = this._children[a];
                    o &amp;&amp; o.drawAllObjects(e, t, r)
                }
        }
    }
    Kt._tempVector3 = new a, Kt._tempVector30 = new a, Kt._tempVector31 = new a, Kt._tempColor0 = new ze, Kt._tempBoundBox = new Pt(new a, new a), Kt._NUM_OBJECTS_ALLOWED = 8;
    class Jt extends I {
        constructor() {
            super()
        }
        add(e) {
            if (-1 !== e._getIndexInMotionList()) throw "OctreeMotionList:element has  in  PhysicsUpdateList.";
            this._add(e), e._setIndexInMotionList(this.length++)
        }
        remove(e) {
            var t = e._getIndexInMotionList();
            if (this.length--, t !== this.length) {
                var r = this.elements[this.length];
                this.elements[t] = r, r._setIndexInMotionList(t)
            }
            e._setIndexInMotionList(-1)
        }
    }
    class $t {
        constructor(e, t, r, i) {
            this._motionObjects = new Jt, this.count = 0, r &gt; e &amp;&amp; (console.warn("Minimum node size must be at least as big as the initial world size. Was: " + r + " Adjusted to: " + e), r = e), this._initialSize = e, this._minSize = r, this._looseness = Math.min(Math.max(i, 1), 2), this._rootNode = new Kt(this, null, e, t)
        }
        _getMaxDepth(e, t) {
            t++;
            var r = e._children;
            if (null != r)
                for (var i = t, n = 0, a = r.length; n &lt; a; n++) {
                    var s = r[n];
                    s &amp;&amp; (t = Math.max(this._getMaxDepth(s, i), t))
                }
            return t
        }
        _grow(e) {
            var t = e.x &gt;= 0 ? 1 : -1,
                r = e.y &gt;= 0 ? 1 : -1,
                i = e.z &gt;= 0 ? 1 : -1,
                n = this._rootNode,
                s = this._rootNode.baseLength / 2,
                o = 2 * this._rootNode.baseLength,
                l = this._rootNode.center,
                _ = new a(l.x + t * s, l.y + r * s, l.z + i * s);
            if (this._rootNode = new Kt(this, null, o, _), n.hasAnyObjects()) {
                for (var h = this._rootNode._bestFitChild(n.center), c = [], d = 0; d &lt; 8; d++) d == h &amp;&amp; (n._parent = this._rootNode, c[d] = n);
                this._rootNode._children = c
            }
        }
        add(e) {
            for (var t = 0; !this._rootNode.add(e);) {
                var r = $t._tempVector30;
                if (a.subtract(e.bounds.getCenter(), this._rootNode.center, r), this._grow(r), ++t &gt; 20) throw "Aborted Add operation as it seemed to be going on forever (" + (t - 1) + ") attempts at growing the octree."
            }
            this.count++
        }
        remove(e) {
            var t = e._getOctreeNode().remove(e);
            return t &amp;&amp; this.count--, t
        }
        update(e) {
            var t = 0,
                r = e._getOctreeNode();
            if (r) {
                for (; !r._update(e);) {
                    var i = $t._tempVector30;
                    if (a.subtract(e.bounds.getCenter(), this._rootNode.center, i), this._grow(i), ++t &gt; 20) throw "Aborted Add operation as it seemed to be going on forever (" + (t - 1) + ") attempts at growing the octree."
                }
                return !0
            }
            return !1
        }
        shrinkRootIfPossible() {
            this._rootNode = this._rootNode.shrinkIfPossible(this._initialSize)
        }
        addMotionObject(e) {
            this._motionObjects.add(e)
        }
        removeMotionObject(e) {
            this._motionObjects.remove(e)
        }
        updateMotionObjects() {
            for (var e = this._motionObjects.elements, t = 0, r = this._motionObjects.length; t &lt; r; t++) {
                var i = e[t];
                this.update(i), i._setIndexInMotionList(-1)
            }
            this._motionObjects.length = 0
        }
        isCollidingWithBoundBox(e) {
            return this._rootNode.isCollidingWithBoundBox(e)
        }
        isCollidingWithRay(e, t = Number.MAX_VALUE) {
            return this._rootNode.isCollidingWithRay(e, t)
        }
        getCollidingWithBoundBox(e, t) {
            this._rootNode.getCollidingWithBoundBox(e, t)
        }
        getCollidingWithRay(e, t, r = Number.MAX_VALUE) {
            this._rootNode.getCollidingWithRay(e, t, r)
        }
        getCollidingWithFrustum(e, t, r, i, n) {
            this._rootNode.getCollidingWithFrustum(e, t, r, i, n)
        }
        getMaxBounds() {
            return this._rootNode.getBound()
        }
        drawAllBounds(e) {
            var t = this._getMaxDepth(this._rootNode, -1);
            this._rootNode.drawAllBounds(e, -1, t)
        }
        drawAllObjects(e) {
            var t = this._getMaxDepth(this._rootNode, -1);
            this._rootNode.drawAllObjects(e, -1, t)
        }
    }
    $t._tempVector30 = new a;
    class er {}
    class tr {
        constructor(e, t) {
            this.center = e, this.radius = t
        }
        toDefault() {
            this.center.toDefault(), this.radius = 0
        }
        static createFromSubPoints(e, t, r, i) {
            if (null == e) throw new Error("points");
            if (t &lt; 0 || t &gt;= e.length) throw new Error("start" + t + "Must be in the range [0, " + (e.length - 1) + "]");
            if (r &lt; 0 || t + r &gt; e.length) throw new Error("count" + r + "Must be in the range &lt;= " + e.length + "}");
            var n = t + r,
                s = tr._tempVector3;
            s.x = 0, s.y = 0, s.z = 0;
            for (var o = t; o &lt; n; ++o) a.add(e[o], s, s);
            var l = i.center;
            a.scale(s, 1 / r, l);
            var _ = 0;
            for (o = t; o &lt; n; ++o) {
                var h = a.distanceSquared(l, e[o]);
                h &gt; _ &amp;&amp; (_ = h)
            }
            i.radius = Math.sqrt(_)
        }
        static createfromPoints(e, t) {
            if (null == e) throw new Error("points");
            tr.createFromSubPoints(e, 0, e.length, t)
        }
        intersectsRayDistance(e) {
            return $e.intersectsRayAndSphereRD(e, this)
        }
        intersectsRayPoint(e, t) {
            return $e.intersectsRayAndSphereRP(e, this, t)
        }
        cloneTo(e) {
            var t = e;
            this.center.cloneTo(t.center), t.radius = this.radius
        }
        clone() {
            var e = new tr(new a, 0);
            return this.cloneTo(e), e
        }
    }
    tr._tempVector3 = new a;
    class rr {
        constructor() {
            this.cameraShaderValue = new ce, this.position = new a, this.viewMatrix = new c, this.projectionMatrix = new c, this.viewProjectMatrix = new c, this.cullPlanes = [new Qe(new a), new Qe(new a), new Qe(new a), new Qe(new a), new Qe(new a), new Qe(new a), new Qe(new a), new Qe(new a), new Qe(new a), new Qe(new a)], this.splitBoundSphere = new tr(new a, 0)
        }
    }
    class ir {
        constructor() {
            this.cameraShaderValue = new ce, this.position = new a, this.viewMatrix = new c, this.projectionMatrix = new c, this.viewProjectMatrix = new c, this.cameraCullInfo = new He
        }
    }(Oe = e.ShadowLightType || (e.ShadowLightType = {}))[Oe.DirectionLight = 0] = "DirectionLight", Oe[Oe.SpotLight = 1] = "SpotLight", Oe[Oe.PointLight = 2] = "PointLight";
    class nr {
        constructor() {
            this._shadowBias = new n, this._shadowParams = new n, this._shadowMapSize = new n, this._shadowMatrices = new Float32Array(16 * nr._maxCascades), this._shadowSpotMatrices = new c, this._splitBoundSpheres = new Float32Array(4 * nr._maxCascades), this._cascadeCount = 0, this._shadowMapWidth = 0, this._shadowMapHeight = 0, this._shadowSliceDatas = [new rr, new rr, new rr, new rr], this._shadowSpotData = new ir, this._lightUp = new a, this._lightSide = new a, this._lightForward = new a, this._shadowSpotData.cameraCullInfo.boundFrustum = new et(new c)
        }
        _setupShadowCasterShaderValues(t, r, i, n, a, s, o) {
            switch (r.setVector(nr.SHADOW_BIAS, s), o) {
                case e.LightType.Directional:
                    r.setVector3(nr.SHADOW_LIGHT_DIRECTION, n);
                    break;
                case e.LightType.Spot:
                    r.setVector(nr.SHADOW_PARAMS, a);
                    break;
                case e.LightType.Point:
            }
            var l = i.cameraShaderValue;
            l.setMatrix4x4(mt.VIEWMATRIX, i.viewMatrix), l.setMatrix4x4(mt.PROJECTMATRIX, i.projectionMatrix), l.setMatrix4x4(mt.VIEWPROJECTMATRIX, i.viewProjectMatrix), t.viewMatrix = i.viewMatrix, t.projectionMatrix = i.projectionMatrix, t.projectionViewMatrix = i.viewProjectMatrix
        }
        _setupShadowReceiverShaderValues(t) {
            var r = this._light;
            switch (r.shadowCascadesMode !== e.ShadowCascadesMode.NoCascades ? t.addDefine(vt.SHADERDEFINE_SHADOW_CASCADE) : t.removeDefine(vt.SHADERDEFINE_SHADOW_CASCADE), r.shadowMode) {
                case e.ShadowMode.Hard:
                    t.removeDefine(vt.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW), t.removeDefine(vt.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH);
                    break;
                case e.ShadowMode.SoftLow:
                    t.addDefine(vt.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW), t.removeDefine(vt.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH);
                    break;
                case e.ShadowMode.SoftHigh:
                    t.addDefine(vt.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH), t.removeDefine(vt.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW)
            }
            t.setTexture(nr.SHADOW_MAP, this._shadowDirectLightMap), t.setBuffer(nr.SHADOW_MATRICES, this._shadowMatrices), t.setVector(nr.SHADOW_MAP_SIZE, this._shadowMapSize), t.setVector(nr.SHADOW_PARAMS, this._shadowParams), t.setBuffer(nr.SHADOW_SPLIT_SPHERES, this._splitBoundSpheres)
        }
        _setupSpotShadowReceiverShaderValues(t) {
            switch (this._light.shadowMode) {
                case e.ShadowMode.Hard:
                    t.removeDefine(vt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_HIGH), t.removeDefine(vt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_LOW);
                    break;
                case e.ShadowMode.SoftLow:
                    t.addDefine(vt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_LOW), t.removeDefine(vt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_HIGH);
                    break;
                case e.ShadowMode.SoftHigh:
                    t.addDefine(vt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_HIGH), t.removeDefine(vt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_LOW)
            }
            t.setTexture(nr.SHADOW_SPOTMAP, this._shadowSpotLightMap), t.setMatrix4x4(nr.SHADOW_SPOTMATRICES, this._shadowSpotMatrices), t.setVector(nr.SHADOW_MAP_SIZE, this._shadowMapSize), t.setVector(nr.SHADOW_PARAMS, this._shadowParams)
        }
        update(t, i, n) {
            switch (n) {
                case e.ShadowLightType.DirectionLight:
                    this._light = i;
                    var s = (L = nr._tempMatrix0).elements,
                        o = this._lightUp,
                        l = this._lightSide,
                        _ = this._lightForward;
                    c.createFromQuaternion(i._transform.rotation, L), l.setValue(s[0], s[1], s[2]), o.setValue(s[4], s[5], s[6]), _.setValue(-s[8], -s[9], -s[10]);
                    var h, d, u, m, f = i._shadowResolution,
                        T = i._shadowCascadesMode;
                    T == e.ShadowCascadesMode.NoCascades ? (h = 1, d = f, u = f, m = f) : (h = T == e.ShadowCascadesMode.TwoCascades ? 2 : 4, u = 2 * (d = It.getMaxTileResolutionInAtlas(f, f, h)), m = T == e.ShadowCascadesMode.TwoCascades ? d : 2 * d), this._cascadeCount = h, this._shadowMapWidth = u, this._shadowMapHeight = m;
                    var E = nr._cascadesSplitDistance,
                        p = nr._frustumPlanes,
                        g = t.nearPlane,
                        S = Math.min(t.farPlane, i._shadowDistance),
                        R = this._shadowMatrices,
                        v = this._splitBoundSpheres;
                    It.getCascadesSplitDistance(i._shadowTwoCascadeSplits, i._shadowFourCascadeSplits, g, S, t.fieldOfView * r.Deg2Rad, t.aspectRatio, T, E), It.getCameraFrustumPlanes(t.projectionViewMatrix, p);
                    var A = nr._tempVector30;
                    t._transform.getForward(A), a.normalize(A, A);
                    for (var I = 0; I &lt; h; I++) {
                        var x = this._shadowSliceDatas[I];
                        x.sphereCenterZ = It.getBoundSphereByFrustum(E[I], E[I + 1], t.fieldOfView * r.Deg2Rad, t.aspectRatio, t._transform.position, A, x.splitBoundSphere), It.getDirectionLightShadowCullPlanes(p, I, E, g, _, x), It.getDirectionalLightMatrices(o, l, _, I, i._shadowNearPlane, d, x, R), h &gt; 1 &amp;&amp; It.applySliceTransform(x, u, m, I, R)
                    }
                    It.prepareShadowReceiverShaderValues(i, u, m, this._shadowSliceDatas, h, this._shadowMapSize, this._shadowParams, R, v);
                    break;
                case e.ShadowLightType.SpotLight:
                    this._light = i;
                    var L = nr._tempMatrix0,
                        D = (_ = this._lightForward, this._light._shadowResolution);
                    this._shadowMapWidth = D, this._shadowMapHeight = D;
                    var C = this._shadowSpotData;
                    It.getSpotLightShadowData(C, this._light, D, this._shadowParams, this._shadowSpotMatrices, this._shadowMapSize);
                    break;
                case e.ShadowLightType.PointLight:
                    break;
                default:
                    throw "There is no shadow of this type"
            }
        }
        render(r, i, n) {
            switch (n) {
                case e.ShadowLightType.DirectionLight:
                    var a = i._shaderValues;
                    r.pipelineMode = "ShadowCaster", ce.setRuntimeValueMode(!1), (T = this._shadowDirectLightMap = It.getTemporaryShadowTexture(this._shadowMapWidth, this._shadowMapHeight, t.RenderTextureDepthFormat.DEPTH_16))._start();
                    for (var s = this._light, o = 0, l = this._cascadeCount; o &lt; l; o++) {
                        var _ = this._shadowSliceDatas[o];
                        It.getShadowBias(s, _.projectionMatrix, _.resolution, this._shadowBias), this._setupShadowCasterShaderValues(r, a, _, this._lightForward, this._shadowParams, this._shadowBias, e.LightType.Directional);
                        var h = ke._shadowCullInfo;
                        h.position = _.position, h.cullPlanes = _.cullPlanes, h.cullPlaneCount = _.cullPlaneCount, h.cullSphere = _.splitBoundSphere, h.direction = this._lightForward;
                        var c = ke.cullingShadow(h, i, r);
                        r.cameraShaderValue = _.cameraShaderValue, xt._updateMark++;
                        var d = t.LayaGL.instance,
                            u = _.resolution,
                            m = _.offsetX,
                            f = _.offsetY;
                        d.enable(d.SCISSOR_TEST), d.viewport(m, f, u, u), d.scissor(m, f, u, u), d.clear(d.DEPTH_BUFFER_BIT), c &amp;&amp; (d.scissor(m + 1, f + 1, u - 2, u - 2), i._opaqueQueue._render(r))
                    }
                    T._end(), this._setupShadowReceiverShaderValues(a), ce.setRuntimeValueMode(!0), r.pipelineMode = "Forward";
                    break;
                case e.ShadowLightType.SpotLight:
                    a = i._shaderValues;
                    r.pipelineMode = "ShadowCaster", ce.setRuntimeValueMode(!1);
                    var T, E = this._light;
                    (T = this._shadowSpotLightMap = It.getTemporaryShadowTexture(this._shadowMapWidth, this._shadowMapHeight, t.RenderTextureDepthFormat.DEPTH_16))._start();
                    var p = this._shadowSpotData;
                    It.getShadowBias(E, p.projectionMatrix, p.resolution, this._shadowBias), this._setupShadowCasterShaderValues(r, a, p, this._light.transform.position, this._shadowParams, this._shadowBias, e.LightType.Spot);
                    c = ke.cullingSpotShadow(p.cameraCullInfo, i, r);
                    r.cameraShaderValue = p.cameraShaderValue, xt._updateMark++, (d = t.LayaGL.instance).enable(d.SCISSOR_TEST), d.viewport(p.offsetX, p.offsetY, p.resolution, p.resolution), d.scissor(p.offsetX, p.offsetY, p.resolution, p.resolution), d.clear(d.DEPTH_BUFFER_BIT), c &amp;&amp; (d.scissor(p.offsetX, p.offsetY, p.resolution, p.resolution), i._opaqueQueue._render(r)), T._end(), this._setupSpotShadowReceiverShaderValues(a), ce.setRuntimeValueMode(!0), r.pipelineMode = "Forward";
                    break;
                case e.ShadowLightType.PointLight:
                    break;
                default:
                    throw "There is no shadow of this type"
            }
        }
        cleanUp() {
            this._shadowDirectLightMap &amp;&amp; ae.recoverToPool(this._shadowDirectLightMap), this._shadowSpotLightMap &amp;&amp; ae.recoverToPool(this._shadowSpotLightMap), this._shadowDirectLightMap = null, this._shadowSpotLightMap = null, this._light = null
        }
    }
    nr._tempVector30 = new a, nr._tempMatrix0 = new c, nr.SHADOW_BIAS = he.propertyNameToID("u_ShadowBias"), nr.SHADOW_LIGHT_DIRECTION = he.propertyNameToID("u_ShadowLightDirection"), nr.SHADOW_SPLIT_SPHERES = he.propertyNameToID("u_ShadowSplitSpheres"), nr.SHADOW_MATRICES = he.propertyNameToID("u_ShadowMatrices"), nr.SHADOW_MAP_SIZE = he.propertyNameToID("u_ShadowMapSize"), nr.SHADOW_MAP = he.propertyNameToID("u_ShadowMap"), nr.SHADOW_PARAMS = he.propertyNameToID("u_ShadowParams"), nr.SHADOW_SPOTMAP = he.propertyNameToID("u_SpotShadowMap"), nr.SHADOW_SPOTMATRICES = he.propertyNameToID("u_SpotViewProjectMatrix"), nr._maxCascades = 4, nr._cascadesSplitDistance = new Array(nr._maxCascades + 1), nr._frustumPlanes = new Array(new Qe(new a), new Qe(new a), new Qe(new a), new Qe(new a), new Qe(new a), new Qe(new a));
    class ar {
        constructor() {
            this._batchRenderElementPool = []
        }
        static _registerManager(e) {
            ar._managers.push(e)
        }
        _clear() {
            this._batchRenderElementPoolIndex = 0
        }
        _getBatchRenderElementFromPool() {
            throw "StaticBatch:must override this function."
        }
        dispose() {}
    }
    ar._managers = [], (Ne = e.AmbientMode || (e.AmbientMode = {}))[Ne.SolidColor = 0] = "SolidColor", Ne[Ne.SphericalHarmonics = 1] = "SphericalHarmonics";
    class sr extends t.Sprite {
        constructor() {
            super(), this._lightCount = 0, this._pointLights = new Ot, this._spotLights = new Ot, this._directionLights = new Ot, this._alternateLights = new Nt, this._lightmaps = [], this._skyRenderer = new dt, this._input = new Lt, this._timer = t.ILaya.timer, this._time = 0, this._shCoefficients = new Array(7), this._ambientMode = e.AmbientMode.SolidColor, this._ambientSphericalHarmonics = new je, this._ambientSphericalHarmonicsIntensity = 1, this._reflectionDecodeFormat = t.TextureDecodeFormat.Normal, this._reflectionIntensity = 1, this._collsionTestList = [], this._renders = new Ge, this._opaqueQueue = new Qt(!1), this._transparentQueue = new Qt(!0), this._cameraPool = [], this._animatorPool = new Ge, this._scriptPool = new Array, this._tempScriptPool = new Array, this._needClearScriptPool = !1, this._reflectionCubeHDRParams = new n, this.currentCreationLayer = Math.pow(2, 0), this.enableLight = !0, this._key = new t.SubmitKey, this._pickIdToSprite = new Object, this._reflectionMode = 0, !B._config.isUseCannonPhysicsEngine &amp;&amp; V._bullet ? this._physicsSimulation = new M(sr.physicsSettings) : V._cannon &amp;&amp; (this._cannonPhysicsSimulation = new t.CannonPhysicsSimulation(sr.cannonPhysicsSettings)), this._shaderValues = new ce(null), this.enableFog = !1, this.fogStart = 300, this.fogRange = 1e3, this.fogColor = new a(.7, .7, .7), this.ambientColor = new a(.212, .227, .259), this.reflectionIntensity = 1, this.reflection = Mt.blackTexture;
            for (var r = 0; r &lt; 7; r++) this._shCoefficients[r] = new n;
            if (this._shaderValues.setVector(sr.REFLECTIONCUBE_HDR_PARAMS, this._reflectionCubeHDRParams), t.Render.supportWebGLPlusCulling &amp;&amp; (this._cullingBufferIndices = new Int32Array(1024), this._cullingBufferResult = new Int32Array(1024)), this._scene = this, this._input.__init__(t.Render.canvas, this), sr.octreeCulling &amp;&amp; (this._octree = new $t(sr.octreeInitialSize, sr.octreeInitialCenter, sr.octreeMinNodeSize, sr.octreeLooseness)), ke.debugFrustumCulling) {
                this._debugTool = new qt;
                var i = new bt;
                i.renderQueue = Te.RENDERQUEUE_TRANSPARENT, i.alphaTest = !1, i.depthWrite = !1, i.cull = pe.CULL_BACK, i.blend = pe.BLEND_ENABLE_ALL, i.blendSrc = pe.BLENDPARAM_SRC_ALPHA, i.blendDst = pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA, i.depthTest = pe.DEPTHTEST_LESS, this._debugTool.pixelLineRenderer.sharedMaterial = i
            }
        }
        static __init__() {
            var r = B._config;
            if (r._multiLighting) {
                const e = 4;
                var i = r.maxLightCount,
                    n = r.lightClusterCount;
                Ye.instance = new Ye(n.x, n.y, n.z, Math.min(r.maxLightCount, r._maxAreaLightCountPerClusterAverage)), sr._lightTexture = N._createFloatTextureBuffer(e, i), sr._lightTexture.lock = !0, sr._lightPixles = new Float32Array(i * e * 4)
            }
            vt.SHADERDEFINE_FOG = he.getDefineByName("FOG"), vt.SHADERDEFINE_DIRECTIONLIGHT = he.getDefineByName("DIRECTIONLIGHT"), vt.SHADERDEFINE_POINTLIGHT = he.getDefineByName("POINTLIGHT"), vt.SHADERDEFINE_SPOTLIGHT = he.getDefineByName("SPOTLIGHT"), vt.SHADERDEFINE_SHADOW = he.getDefineByName("SHADOW"), vt.SHADERDEFINE_SHADOW_CASCADE = he.getDefineByName("SHADOW_CASCADE"), vt.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW = he.getDefineByName("SHADOW_SOFT_SHADOW_LOW"), vt.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH = he.getDefineByName("SHADOW_SOFT_SHADOW_HIGH"), vt.SHADERDEFINE_GI_AMBIENT_SH = he.getDefineByName("GI_AMBIENT_SH"), vt.SHADERDEFINE_SHADOW_SPOT = he.getDefineByName("SHADOW_SPOT"), vt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_LOW = he.getDefineByName("SHADOW_SPOT_SOFT_SHADOW_LOW"), vt.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_HIGH = he.getDefineByName("SHADOW_SPOT_SOFT_SHADOW_HIGH");
            var a = B._config,
                s = sr._configDefineValues;
            switch (a._multiLighting || s.add(he.SHADERDEFINE_LEGACYSINGALLIGHTING), t.LayaGL.layaGPUInstance._isWebGL2 ? s.add(he.SHADERDEFINE_GRAPHICS_API_GLES3) : s.add(he.SHADERDEFINE_GRAPHICS_API_GLES2), a.pbrRenderQuality) {
                case e.PBRRenderQuality.High:
                    s.add(ve.SHADERDEFINE_LAYA_PBR_BRDF_HIGH);
                    break;
                case e.PBRRenderQuality.Low:
                    s.add(ve.SHADERDEFINE_LAYA_PBR_BRDF_LOW);
                    break;
                default:
                    throw "Scene3D:unknown shader quality."
            }
            a.isUseCannonPhysicsEngine ? sr.cannonPhysicsSettings = new t.CannonPhysicsSettings : sr.physicsSettings = new Dt
        }
        static load(e, r) {
            t.ILaya.loader.create(e, r, null, sr.HIERARCHY)
        }
        get url() {
            return this._url
        }
        get enableFog() {
            return this._enableFog
        }
        set enableFog(e) {
            this._enableFog !== e &amp;&amp; (this._enableFog = e, e ? this._shaderValues.addDefine(vt.SHADERDEFINE_FOG) : this._shaderValues.removeDefine(vt.SHADERDEFINE_FOG))
        }
        get fogColor() {
            return this._shaderValues.getVector3(sr.FOGCOLOR)
        }
        set fogColor(e) {
            this._shaderValues.setVector3(sr.FOGCOLOR, e)
        }
        get fogStart() {
            return this._shaderValues.getNumber(sr.FOGSTART)
        }
        set fogStart(e) {
            this._shaderValues.setNumber(sr.FOGSTART, e)
        }
        get fogRange() {
            return this._shaderValues.getNumber(sr.FOGRANGE)
        }
        set fogRange(e) {
            this._shaderValues.setNumber(sr.FOGRANGE, e)
        }
        get ambientMode() {
            return this._ambientMode
        }
        set ambientMode(t) {
            if (this._ambientMode !== t) {
                switch (t) {
                    case e.AmbientMode.SolidColor:
                        this._shaderValues.removeDefine(vt.SHADERDEFINE_GI_AMBIENT_SH);
                        break;
                    case e.AmbientMode.SphericalHarmonics:
                        this._shaderValues.addDefine(vt.SHADERDEFINE_GI_AMBIENT_SH);
                        break;
                    default:
                        throw "Scene3D: unknown ambientMode."
                }
                this._ambientMode = t
            }
        }
        get ambientColor() {
            return this._shaderValues.getVector3(sr.AMBIENTCOLOR)
        }
        set ambientColor(e) {
            this._shaderValues.setVector3(sr.AMBIENTCOLOR, e)
        }
        get ambientSphericalHarmonics() {
            return this._ambientSphericalHarmonics
        }
        set ambientSphericalHarmonics(e) {
            var t = e || je._default;
            this._applySHCoefficients(t, Math.pow(this._ambientSphericalHarmonicsIntensity, 2.2)), this._ambientSphericalHarmonics != e &amp;&amp; e.cloneTo(this._ambientSphericalHarmonics)
        }
        get ambientSphericalHarmonicsIntensity() {
            return this._ambientSphericalHarmonicsIntensity
        }
        set ambientSphericalHarmonicsIntensity(e) {
            if (e = Math.max(Math.min(e, 8), 0), this._ambientSphericalHarmonicsIntensity !== e) {
                var t = this._ambientSphericalHarmonics || je._default;
                this._applySHCoefficients(t, Math.pow(e, 2.2)), this._ambientSphericalHarmonicsIntensity = e
            }
        }
        get reflection() {
            return this._reflection
        }
        set reflection(e) {
            this._reflection != e &amp;&amp; (this._shaderValues.setTexture(sr.REFLECTIONTEXTURE, e || Mt.blackTexture), this._reflection = e)
        }
        get reflectionDecodingFormat() {
            return this._reflectionDecodeFormat
        }
        set reflectionDecodingFormat(e) {
            this._reflectionDecodeFormat != e &amp;&amp; (this._reflectionCubeHDRParams.x = this._reflectionIntensity, this._reflectionDecodeFormat == t.TextureDecodeFormat.RGBM &amp;&amp; (this._reflectionCubeHDRParams.x *= 5), this._reflectionDecodeFormat = e)
        }
        get reflectionIntensity() {
            return this._reflectionIntensity
        }
        set reflectionIntensity(e) {
            e = Math.max(Math.min(e, 1), 0), this._reflectionCubeHDRParams.x = e, this._reflectionDecodeFormat == t.TextureDecodeFormat.RGBM &amp;&amp; (this._reflectionCubeHDRParams.x *= 5), this._reflectionIntensity = e
        }
        get skyRenderer() {
            return this._skyRenderer
        }
        get physicsSimulation() {
            return this._physicsSimulation
        }
        get cannonPhysicsSimulation() {
            return this._cannonPhysicsSimulation
        }
        get timer() {
            return this._timer
        }
        set timer(e) {
            this._timer = e
        }
        get input() {
            return this._input
        }
        get lightmaps() {
            return this._lightmaps.slice()
        }
        set lightmaps(e) {
            var t = this._lightmaps;
            if (t)
                for (var r = 0, i = t.length; r &lt; i; r++) {
                    (a = t[r]).lightmapColor._removeReference(), a.lightmapDirection._removeReference()
                }
            if (e) {
                var n = e.length;
                for (t.length = n, r = 0; r &lt; n; r++) {
                    var a;
                    (a = e[r]).lightmapColor &amp;&amp; a.lightmapColor._addReference(), a.lightmapDirection &amp;&amp; a.lightmapDirection._addReference(), t[r] = a
                }
            } else t.length = 0
        }
        _applySHCoefficients(e, t) {
            for (var r = this._shCoefficients, i = 0; i &lt; 3; i++) {
                var n = r[i],
                    a = r[i + 3];
                n.setValue(e.getCoefficient(i, 3) * t, e.getCoefficient(i, 1) * t, e.getCoefficient(i, 2) * t, (e.getCoefficient(i, 0) - e.getCoefficient(i, 6)) * t), a.setValue(e.getCoefficient(i, 4) * t, e.getCoefficient(i, 5) * t, 3 * e.getCoefficient(i, 6) * t, e.getCoefficient(i, 7) * t)
            }
            r[6].setValue(e.getCoefficient(0, 8) * t, e.getCoefficient(1, 8) * t, e.getCoefficient(2, 8) * t, 1);
            var s = this._shaderValues;
            s.setVector(sr.AMBIENTSHAR, r[0]), s.setVector(sr.AMBIENTSHAG, r[1]), s.setVector(sr.AMBIENTSHAB, r[2]), s.setVector(sr.AMBIENTSHBR, r[3]), s.setVector(sr.AMBIENTSHBG, r[4]), s.setVector(sr.AMBIENTSHBB, r[5]), s.setVector(sr.AMBIENTSHC, r[6])
        }
        _update() {
            var e = this.timer._delta / 1e3;
            this._time += e, this._shaderValues.setNumber(sr.TIME, this._time);
            var r = this._physicsSimulation;
            if (!V._enablePhysics || M.disableSimulation || B._config.isUseCannonPhysicsEngine || (r._updatePhysicsTransformFromRender(), A._addUpdateList = !1, r._simulate(e), r._updateCharacters(), A._addUpdateList = !0, r._updateCollisions(), r._eventScripts()), V._cannon &amp;&amp; B._config.isUseCannonPhysicsEngine) {
                var i = this._cannonPhysicsSimulation;
                i._updatePhysicsTransformFromRender(), t.CannonPhysicsComponent._addUpdateList = !1, i._simulate(e), t.CannonPhysicsComponent._addUpdateList = !0, i._updateCollisions(), i._eventScripts()
            }
            this._input._update(), this._clearScript(), this._updateScript(), re._update(this), this._lateUpdateScript()
        }
        _binarySearchIndexInCameraPool(e) {
            for (var t, r = 0, i = this._cameraPool.length - 1; r &lt;= i;) {
                t = Math.floor((r + i) / 2);
                var n = this._cameraPool[t]._renderingOrder;
                if (n == e._renderingOrder) return t;
                n &gt; e._renderingOrder ? i = t - 1 : r = t + 1
            }
            return r
        }
        _allotPickColorByID(e, t) {
            var r = Math.floor(e / 65025);
            e -= 255 * r * 255;
            var i = Math.floor(e / 255),
                n = e -= 255 * i;
            t.x = r / 255, t.y = i / 255, t.z = n / 255, t.w = 1
        }
        _searchIDByPickColor(e) {
            return 255 * e.x * 255 + 255 * e.y + e.z
        }
        onEnable() {
            this._input._onCanvasEvent(t.Render.canvas)
        }
        onDisable() {
            this._input._offCanvasEvent(t.Render.canvas)
        }
        _setCreateURL(e) {
            this._url = t.URL.formatURL(e)
        }
        _getGroup() {
            return this._group
        }
        _setGroup(e) {
            this._group = e
        }
        _clearScript() {
            if (this._needClearScriptPool) {
                for (var e = this._scriptPool, t = 0, r = e.length; t &lt; r; t++) {
                    var i = e[t];
                    i &amp;&amp; (i._indexInPool = this._tempScriptPool.length, this._tempScriptPool.push(i))
                }
                this._scriptPool = this._tempScriptPool, e.length = 0, this._tempScriptPool = e, this._needClearScriptPool = !1
            }
        }
        _updateScript() {
            for (var e = this._scriptPool, t = 0, r = e.length; t &lt; r; t++) {
                var i = e[t];
                i &amp;&amp; i.enabled &amp;&amp; i.onUpdate()
            }
        }
        _lateUpdateScript() {
            for (var e = this._scriptPool, t = 0, r = e.length; t &lt; r; t++) {
                var i = e[t];
                i &amp;&amp; i.enabled &amp;&amp; i.onLateUpdate()
            }
        }
        _onActive() {
            super._onActive(), t.ILaya.stage._scene3Ds.push(this)
        }
        _onInActive() {
            super._onInActive();
            var e = t.ILaya.stage._scene3Ds;
            e.splice(e.indexOf(this), 1)
        }
        _prepareSceneToRender() {
            var e = this._shaderValues;
            if (B._config._multiLighting) {
                var t = sr._lightTexture,
                    r = sr._lightPixles;
                const v = t.width,
                    A = 4 * v;
                var i = 0,
                    n = this._directionLights._length,
                    s = this._directionLights._elements;
                if (n &gt; 0) {
                    var o = this._directionLights.getBrightestLight();
                    this._mainDirectionLight = s[o], this._directionLights.normalLightOrdering(o);
                    for (var l = 0; l &lt; n; l++, i++) {
                        var _ = (S = s[l])._direction,
                            h = S._intensityColor,
                            c = A * i;
                        a.scale(S.color, S._intensity, h), S.transform.worldMatrix.getForward(_), a.normalize(_, _), r[c] = h.x, r[c + 1] = h.y, r[c + 2] = h.z, r[c + 4] = _.x, r[c + 5] = _.y, r[c + 6] = _.z, 0 == l &amp;&amp; (e.setVector3(sr.SUNLIGHTDIRCOLOR, h), e.setVector3(sr.SUNLIGHTDIRECTION, _))
                    }
                    e.addDefine(vt.SHADERDEFINE_DIRECTIONLIGHT)
                } else e.removeDefine(vt.SHADERDEFINE_DIRECTIONLIGHT);
                var d = this._pointLights._length;
                if (d &gt; 0) {
                    var u = this._pointLights._elements,
                        m = this._pointLights.getBrightestLight();
                    this._mainPointLight = u[m], this._pointLights.normalLightOrdering(m);
                    for (l = 0; l &lt; d; l++, i++) {
                        var f = (R = u[l]).transform.position;
                        h = R._intensityColor, c = A * i;
                        a.scale(R.color, R._intensity, h), r[c] = h.x, r[c + 1] = h.y, r[c + 2] = h.z, r[c + 3] = R.range, r[c + 4] = f.x, r[c + 5] = f.y, r[c + 6] = f.z
                    }
                    e.addDefine(vt.SHADERDEFINE_POINTLIGHT)
                } else e.removeDefine(vt.SHADERDEFINE_POINTLIGHT);
                var T = this._spotLights._length;
                if (T &gt; 0) {
                    var E = this._spotLights._elements,
                        p = this._spotLights.getBrightestLight();
                    this._mainSpotLight = E[p], this._spotLights.normalLightOrdering(p);
                    for (l = 0; l &lt; T; l++, i++) {
                        var g = E[l];
                        _ = g._direction, f = g.transform.position, h = g._intensityColor, c = A * i;
                        a.scale(g.color, g._intensity, h), g.transform.worldMatrix.getForward(_), a.normalize(_, _), r[c] = h.x, r[c + 1] = h.y, r[c + 2] = h.z, r[c + 3] = g.range, r[c + 4] = f.x, r[c + 5] = f.y, r[c + 6] = f.z, r[c + 7] = g.spotAngle * Math.PI / 180, r[c + 8] = _.x, r[c + 9] = _.y, r[c + 10] = _.z
                    }
                    e.addDefine(vt.SHADERDEFINE_SPOTLIGHT)
                } else e.removeDefine(vt.SHADERDEFINE_SPOTLIGHT);
                i &gt; 0 &amp;&amp; t.setSubPixels(0, 0, v, i, r, 0), e.setTexture(sr.LIGHTBUFFER, t), e.setInt(sr.DIRECTIONLIGHTCOUNT, this._directionLights._length), e.setTexture(sr.CLUSTERBUFFER, Ye.instance._clusterTexture)
            } else {
                if (this._directionLights._length &gt; 0) {
                    var S = this._directionLights._elements[0];
                    this._mainDirectionLight = S, a.scale(S.color, S._intensity, S._intensityColor), S.transform.worldMatrix.getForward(S._direction), a.normalize(S._direction, S._direction), e.setVector3(sr.LIGHTDIRCOLOR, S._intensityColor), e.setVector3(sr.LIGHTDIRECTION, S._direction), e.setVector3(sr.SUNLIGHTDIRCOLOR, S._intensityColor), e.setVector3(sr.SUNLIGHTDIRECTION, S._direction), e.addDefine(vt.SHADERDEFINE_DIRECTIONLIGHT)
                } else e.removeDefine(vt.SHADERDEFINE_DIRECTIONLIGHT);
                if (this._pointLights._length &gt; 0) {
                    var R = this._pointLights._elements[0];
                    a.scale(R.color, R._intensity, R._intensityColor), e.setVector3(sr.POINTLIGHTCOLOR, R._intensityColor), e.setVector3(sr.POINTLIGHTPOS, R.transform.position), e.setNumber(sr.POINTLIGHTRANGE, R.range), e.addDefine(vt.SHADERDEFINE_POINTLIGHT)
                } else e.removeDefine(vt.SHADERDEFINE_POINTLIGHT);
                if (this._spotLights._length &gt; 0) {
                    var v = this._spotLights._elements[0];
                    a.scale(v.color, v._intensity, v._intensityColor), e.setVector3(sr.SPOTLIGHTCOLOR, v._intensityColor), e.setVector3(sr.SPOTLIGHTPOS, v.transform.position), v.transform.worldMatrix.getForward(v._direction), a.normalize(v._direction, v._direction), e.setVector3(sr.SPOTLIGHTDIRECTION, v._direction), e.setNumber(sr.SPOTLIGHTRANGE, v.range), e.setNumber(sr.SPOTLIGHTSPOTANGLE, v.spotAngle * Math.PI / 180), e.addDefine(vt.SHADERDEFINE_SPOTLIGHT)
                } else e.removeDefine(vt.SHADERDEFINE_SPOTLIGHT)
            }
        }
        _addScript(e) {
            var t = this._scriptPool;
            e._indexInPool = t.length, t.push(e)
        }
        _removeScript(e) {
            this._scriptPool[e._indexInPool] = null, e._indexInPool = -1, this._needClearScriptPool = !0
        }
        _preRenderScript() {
            for (var e = this._scriptPool, t = 0, r = e.length; t &lt; r; t++) {
                var i = e[t];
                i &amp;&amp; i.enabled &amp;&amp; i.onPreRender()
            }
        }
        _postRenderScript() {
            for (var e = this._scriptPool, t = 0, r = e.length; t &lt; r; t++) {
                var i = e[t];
                i &amp;&amp; i.enabled &amp;&amp; i.onPostRender()
            }
        }
        _addCamera(e) {
            for (var t = this._binarySearchIndexInCameraPool(e), r = e._renderingOrder, i = this._cameraPool.length; t &lt; i &amp;&amp; this._cameraPool[t]._renderingOrder &lt;= r;) t++;
            this._cameraPool.splice(t, 0, e)
        }
        _removeCamera(e) {
            this._cameraPool.splice(this._cameraPool.indexOf(e), 1)
        }
        _preCulling(e, t, r, i) {
            var n = ke._cameraCullInfo;
            n.position = t._transform.position, n.cullingMask = t.cullingMask, n.boundFrustum = t.boundFrustum, n.useOcclusionCulling = t.useOcclusionCulling, ke.renderObjectCulling(n, this, e, r, i, !1)
        }
        _clear(r, i) {
            var n, a, s, o = i.viewport,
                l = i.camera,
                _ = l._getRenderTexture(),
                h = o.width,
                c = o.height;
            l._needInternalRenderTexture() ? (n = 0, a = 0) : (n = o.x, a = l._getCanvasHeight() - o.y - c), r.viewport(n, a, h, c);
            var d = l.clearFlag;
            switch (d !== e.CameraClearFlags.Sky || l.skyRenderer._isAvailable() || this._skyRenderer._isAvailable() || (d = e.CameraClearFlags.SolidColor), d) {
                case e.CameraClearFlags.SolidColor:
                    var u = l.clearColor;
                    if (r.enable(r.SCISSOR_TEST), r.scissor(n, a, h, c), u ? r.clearColor(u.x, u.y, u.z, u.w) : r.clearColor(0, 0, 0, 0), _) switch (s = r.COLOR_BUFFER_BIT, _.depthStencilFormat) {
                        case t.RenderTextureDepthFormat.DEPTH_16:
                            s |= r.DEPTH_BUFFER_BIT;
                            break;
                        case t.RenderTextureDepthFormat.STENCIL_8:
                            s |= r.STENCIL_BUFFER_BIT;
                            break;
                        case t.RenderTextureDepthFormat.DEPTHSTENCIL_24_8:
                            s |= r.DEPTH_BUFFER_BIT, s |= r.STENCIL_BUFFER_BIT
                    } else s = r.COLOR_BUFFER_BIT | r.DEPTH_BUFFER_BIT;
                    t.WebGLContext.setDepthMask(r, !0), r.clear(s), r.disable(r.SCISSOR_TEST);
                    break;
                case e.CameraClearFlags.Sky:
                case e.CameraClearFlags.DepthOnly:
                    if (r.enable(r.SCISSOR_TEST), r.scissor(n, a, h, c), _) switch (_.depthStencilFormat) {
                        case t.RenderTextureDepthFormat.DEPTH_16:
                            s = r.DEPTH_BUFFER_BIT;
                            break;
                        case t.RenderTextureDepthFormat.STENCIL_8:
                            s = r.STENCIL_BUFFER_BIT;
                            break;
                        case t.RenderTextureDepthFormat.DEPTHSTENCIL_24_8:
                            s = r.DEPTH_BUFFER_BIT | r.STENCIL_BUFFER_BIT
                    } else s = r.DEPTH_BUFFER_BIT;
                    t.WebGLContext.setDepthMask(r, !0), r.clear(s), r.disable(r.SCISSOR_TEST);
                    break;
                case e.CameraClearFlags.Nothing:
                    break;
                default:
                    throw new Error("Scene3D:camera clearFlag invalid.")
            }
        }
        _renderScene(t) {
            var r = t.camera;
            if (this._opaqueQueue._render(t), r.clearFlag === e.CameraClearFlags.Sky &amp;&amp; (r.skyRenderer._isAvailable() ? r.skyRenderer._render(t) : this._skyRenderer._isAvailable() &amp;&amp; this._skyRenderer._render(t)), this._transparentQueue._render(t), ke.debugFrustumCulling)
                for (var i = this._debugTool._render._renderElements, n = 0, a = i.length; n &lt; a; n++) i[n]._update(this, t, null, null), i[n]._render(t)
        }
        _parse(e, r) {
            var i = e.lightmaps;
            if (i) {
                for (var n = i.length, a = new Array(n), s = 0; s &lt; n; s++) {
                    var o = new er,
                        l = i[s];
                    l.path ? o.lightmapColor = t.Loader.getRes(l.path) : (o.lightmapColor = t.Loader.getRes(l.color.path), l.direction &amp;&amp; (o.lightmapDirection = t.Loader.getRes(l.direction.path))), a[s] = o
                }
                this.lightmaps = a
            }
            var _ = e.ambientColor;
            if (_) {
                var h = this.ambientColor;
                h.fromArray(_), this.ambientColor = h
            }
            var c = e.sky;
            if (c) switch (this._skyRenderer.material = t.Loader.getRes(c.material.path), c.mesh) {
                case "SkyBox":
                    this._skyRenderer.mesh = ct.instance;
                    break;
                case "SkyDome":
                    this._skyRenderer.mesh = yt.instance;
                    break;
                default:
                    this.skyRenderer.mesh = ct.instance
            }
            this.enableFog = e.enableFog, this.fogStart = e.fogStart, this.fogRange = e.fogRange;
            var d = e.fogColor;
            if (d) {
                var u = this.fogColor;
                u.fromArray(d), this.fogColor = u
            }
            var m = e.ambientSphericalHarmonics;
            if (m) {
                var f = this.ambientSphericalHarmonics;
                for (s = 0; s &lt; 3; s++) {
                    var T = 9 * s;
                    f.setCoefficients(s, m[T], m[T + 1], m[T + 2], m[T + 3], m[T + 4], m[T + 5], m[T + 6], m[T + 7], m[T + 8])
                }
                this.ambientSphericalHarmonics = f
            }
            var E = e.reflection;
            null != E &amp;&amp; (this.reflection = t.Loader.getRes(E));
            var p = e.reflectionDecodingFormat;
            null != p &amp;&amp; (this.reflectionDecodingFormat = p);
            var g = e.ambientMode;
            null != g &amp;&amp; (this.ambientMode = g);
            var S = e.ambientSphericalHarmonicsIntensity;
            null != S &amp;&amp; (this.ambientSphericalHarmonicsIntensity = S);
            var R = e.reflectionIntensity;
            null != R &amp;&amp; (this.reflectionIntensity = R)
        }
        _addRenderObject(e) {
            if (this._octree &amp;&amp; e._supportOctree) this._octree.add(e);
            else if (this._renders.add(e), t.Render.supportWebGLPlusCulling) {
                var r = e._getIndexInList(),
                    i = this._cullingBufferIndices.length;
                if (r &gt;= i) {
                    var n = this._cullingBufferIndices,
                        a = this._cullingBufferResult;
                    this._cullingBufferIndices = new Int32Array(i + 1024), this._cullingBufferResult = new Int32Array(i + 1024), this._cullingBufferIndices.set(n, 0), this._cullingBufferResult.set(a, 0)
                }
                this._cullingBufferIndices[r] = e._cullingBufferIndex
            }
        }
        _removeRenderObject(e) {
            var r;
            this._octree &amp;&amp; e._supportOctree ? this._octree.remove(e) : (t.Render.supportWebGLPlusCulling &amp;&amp; (r = this._renders.elements[this._renders.length - 1]), this._renders.remove(e), t.Render.supportWebGLPlusCulling &amp;&amp; (this._cullingBufferIndices[r._getIndexInList()] = r._cullingBufferIndex))
        }
        _getRenderQueue(e) {
            return e &lt;= 2500 ? this._opaqueQueue : this._transparentQueue
        }
        _clearRenderQueue() {
            this._opaqueQueue.clear(), this._transparentQueue.clear();
            for (var e = kt._managers, t = 0, r = e.length; t &lt; r; t++) e[t]._clear();
            var i = ar._managers;
            for (t = 0, r = i.length; t &lt; r; t++) i[t]._clear()
        }
        destroy(e = !0) {
            this.destroyed || (super.destroy(e), this._skyRenderer.destroy(), this._skyRenderer = null, this._directionLights = null, this._pointLights = null, this._spotLights = null, this._alternateLights = null, this._lightmaps = null, this._shaderValues = null, this._renders = null, this._cameraPool = null, this._octree = null, this._physicsSimulation &amp;&amp; this._physicsSimulation._destroy(), t.Loader.clearRes(this.url))
        }
        render(e, r, i) {
            e._curSubmit = t.SubmitBase.RENDERBASE, this._children.length &gt; 0 &amp;&amp; e.addRenderObject(this)
        }
        renderSubmit() {
            var e, r, i;
            t.LayaGL.instance;
            for (this._prepareSceneToRender(), e = 0, i = (r = this._cameraPool.length) - 1; e &lt; r; e++) {
                t.Render.supportWebGLPlusRendering &amp;&amp; ce.setRuntimeValueMode(e == i);
                var n = this._cameraPool[e];
                n.enableRender &amp;&amp; n.render()
            }
            return t.Context.set2DRenderConfig(), 1
        }
        getRenderType() {
            return 0
        }
        releaseRender() {}
        reUse(e, t) {
            return 0
        }
        get customReflection() {
            return this._reflection
        }
        set customReflection(e) {
            this._reflection != e &amp;&amp; (this._shaderValues.setTexture(sr.REFLECTIONTEXTURE, e || Mt.blackTexture), this._reflection = e)
        }
        get reflectionMode() {
            return this._reflectionMode
        }
        set reflectionMode(e) {
            this._reflectionMode = e
        }
        setlightmaps(e) {
            for (var t = this._lightmaps, r = 0, i = t.length; r &lt; i; r++) t[r].lightmapColor._removeReference();
            if (!e) throw new Error("Scene3D: value value can't be null.");
            var n = e.length;
            for (t.length = n, r = 0; r &lt; n; r++) {
                var a = e[r];
                a._addReference(), t[r] || (t[r] = new er), t[r].lightmapColor = a
            }
        }
        getlightmaps() {
            for (var e = new Array(this._lightmaps.length), t = 0; t &lt; this._lightmaps.length; t++) e[t] = this._lightmaps[t].lightmapColor;
            return e
        }
    }
    sr._shadowCasterPass = new nr, sr.HIERARCHY = "HIERARCHY", sr.octreeCulling = !1, sr.octreeInitialSize = 64, sr.octreeInitialCenter = new a(0, 0, 0), sr.octreeMinNodeSize = 2, sr.octreeLooseness = 1.25, sr.REFLECTIONMODE_SKYBOX = 0, sr.REFLECTIONMODE_CUSTOM = 1, sr.FOGCOLOR = he.propertyNameToID("u_FogColor"), sr.FOGSTART = he.propertyNameToID("u_FogStart"), sr.FOGRANGE = he.propertyNameToID("u_FogRange"), sr.DIRECTIONLIGHTCOUNT = he.propertyNameToID("u_DirationLightCount"), sr.LIGHTBUFFER = he.propertyNameToID("u_LightBuffer"), sr.CLUSTERBUFFER = he.propertyNameToID("u_LightClusterBuffer"), sr.SUNLIGHTDIRECTION = he.propertyNameToID("u_SunLight.direction"), sr.SUNLIGHTDIRCOLOR = he.propertyNameToID("u_SunLight.color"), sr.AMBIENTSHAR = he.propertyNameToID("u_AmbientSHAr"), sr.AMBIENTSHAG = he.propertyNameToID("u_AmbientSHAg"), sr.AMBIENTSHAB = he.propertyNameToID("u_AmbientSHAb"), sr.AMBIENTSHBR = he.propertyNameToID("u_AmbientSHBr"), sr.AMBIENTSHBG = he.propertyNameToID("u_AmbientSHBg"), sr.AMBIENTSHBB = he.propertyNameToID("u_AmbientSHBb"), sr.AMBIENTSHC = he.propertyNameToID("u_AmbientSHC"), sr.REFLECTIONPROBE = he.propertyNameToID("u_ReflectionProbe"), sr.REFLECTIONCUBE_HDR_PARAMS = he.propertyNameToID("u_ReflectCubeHDRParams"), sr.LIGHTDIRECTION = he.propertyNameToID("u_DirectionLight.direction"), sr.LIGHTDIRCOLOR = he.propertyNameToID("u_DirectionLight.color"), sr.POINTLIGHTPOS = he.propertyNameToID("u_PointLight.position"), sr.POINTLIGHTRANGE = he.propertyNameToID("u_PointLight.range"), sr.POINTLIGHTATTENUATION = he.propertyNameToID("u_PointLight.attenuation"), sr.POINTLIGHTCOLOR = he.propertyNameToID("u_PointLight.color"), sr.SPOTLIGHTPOS = he.propertyNameToID("u_SpotLight.position"), sr.SPOTLIGHTDIRECTION = he.propertyNameToID("u_SpotLight.direction"), sr.SPOTLIGHTSPOTANGLE = he.propertyNameToID("u_SpotLight.spot"), sr.SPOTLIGHTRANGE = he.propertyNameToID("u_SpotLight.range"), sr.SPOTLIGHTCOLOR = he.propertyNameToID("u_SpotLight.color"), sr.AMBIENTCOLOR = he.propertyNameToID("u_AmbientColor"), sr.REFLECTIONTEXTURE = he.propertyNameToID("u_ReflectTexture"), sr.TIME = he.propertyNameToID("u_Time"), sr._configDefineValues = new se;
    class or extends t.ShaderCompile {
        constructor(e, t, r, i) {
            for (var n in super(t, r, null), this._cacheSharders = {}, this._cacheShaderHierarchy = 1, this._renderState = new pe, this._validDefine = new se, this._tags = {}, this._owner = e, this._stateMap = i, this.defs) this._validDefine.add(he.getDefineByName(n))
        }
        get renderState() {
            return this._renderState
        }
        _compileToTree(e, r, i, n, a) {
            var s, o, l, _, h, c, d, u, m, f, T;
            for (m = i; m &lt; r.length; m++)
                if (!((l = r[m]).length &lt; 1) &amp;&amp; 0 !== (c = l.indexOf("//"))) {
                    if (c &gt;= 0 &amp;&amp; (l = l.substr(0, c)), s = u || new t.ShaderNode(n), u = null, s.text = l, (c = l.indexOf("#")) &gt;= 0) {
                        for (_ = "#", T = c + 1, f = l.length; T &lt; f; T++) {
                            var E = l.charAt(T);
                            if (" " === E || "\t" === E || "?" === E) break;
                            _ += E
                        }
                        switch (s.name = _, _) {
                            case "#ifdef":
                            case "#ifndef":
                                if (s.setParent(e), e = s, a)
                                    for (d = l.substr(T).split(t.ShaderCompile._splitToWordExps3), T = 0; T &lt; d.length; T++)(l = d[T]).length &amp;&amp; (a[l] = !0);
                                continue;
                            case "#if":
                            case "#elif":
                                if (s.setParent(e), e = s, a)
                                    for (d = l.substr(T).split(t.ShaderCompile._splitToWordExps3), T = 0; T &lt; d.length; T++)(l = d[T]).length &amp;&amp; "defined" != l &amp;&amp; (a[l] = !0);
                                continue;
                            case "#else":
                                o = (e = e.parent).childs[e.childs.length - 1], s.setParent(e), e = s;
                                continue;
                            case "#endif":
                                o = (e = e.parent).childs[e.childs.length - 1], s.setParent(e);
                                continue;
                            case "#include":
                                d = t.ShaderCompile.splitToWords(l, null);
                                var p = t.ShaderCompile.includes[d[1]];
                                if (!p) throw "ShaderCompile error no this include file:" + d[1];
                                if ((c = d[0].indexOf("?")) &lt; 0) {
                                    s.setParent(e), l = p.getWith("with" == d[2] ? d[3] : null), this._compileToTree(s, l.split("\n"), 0, n, a), s.text = "";
                                    continue
                                }
                                s.setCondition(d[0].substr(c + 1), t.ShaderCompile.IFDEF_YES), s.text = p.getWith("with" == d[2] ? d[3] : null);
                                break;
                            case "#import":
                                h = (d = t.ShaderCompile.splitToWords(l, null))[1], n.push({
                                    node: s,
                                    file: t.ShaderCompile.includes[h],
                                    ofs: s.text.length
                                });
                                continue
                        }
                    } else {
                        if ((o = e.childs[e.childs.length - 1]) &amp;&amp; !o.name) {
                            n.length &gt; 0 &amp;&amp; t.ShaderCompile.splitToWords(l, o), u = s, o.text += "\n" + l;
                            continue
                        }
                        n.length &gt; 0 &amp;&amp; t.ShaderCompile.splitToWords(l, s)
                    }
                    s.setParent(e)
                }
        }
        _resizeCacheShaderMap(e, t, r) {
            var i = this._cacheShaderHierarchy - 1;
            if (t == i) {
                for (var n in e)
                    for (var a = e[n], s = 0, o = r - i; s &lt; o; s++) s == o - 1 ? e[0] = a : e = e[0 == s ? n : 0] = {};
                this._cacheShaderHierarchy = r
            } else
                for (var n in e) this._resizeCacheShaderMap(e[n], ++t, r)
        }
        _addDebugShaderVariantCollection(e, t, r) {
            var i = he._debugShaderVariantInfo,
                n = this._owner,
                a = n._owner,
                s = e._mask;
            he._getNamesByDefineData(e, t), r.length = s.length;
            for (var o = 0, l = s.length; o &lt; l; o++) r[o] = s[o];
            i ? i.setValue(a, a._subShaders.indexOf(n), n._passes.indexOf(this), t) : he._debugShaderVariantInfo = i = new le(a, a._subShaders.indexOf(n), n._passes.indexOf(this), t), he.debugShaderVariantCollection.add(i)
        }
        withCompile(e) {
            var r, i = or._debugDefineString,
                n = or._debugDefineMask;
            e._intersectionDefineDatas(this._validDefine), he.debugMode &amp;&amp; (r = e._length, this._addDebugShaderVariantCollection(e, i, n)), e.addDefineDatas(sr._configDefineValues);
            var a = this._cacheSharders,
                s = e._length;
            s &gt; this._cacheShaderHierarchy &amp;&amp; (this._resizeCacheShaderMap(a, 0, s), this._cacheShaderHierarchy = s);
            for (var o = e._mask, l = e._length - 1, _ = this._cacheShaderHierarchy - 1, h = 0; h &lt; _; h++) {
                var c = l &lt; h ? 0 : o[h],
                    d = a[c];
                d || (a[c] = d = {}), a = d
            }
            var u = l &lt; _ ? 0 : o[_],
                m = a[u];
            if (m) return m;
            var f = or._defineString;
            he._getNamesByDefineData(e, f);
            var T, E, p = B._config,
                g = p.lightClusterCount,
                S = {},
                R = "";
            t.WebGL._isWebGL2 ? (T = "#version 300 es\n\n\t\t\t\t#define attribute in\n\t\t\t\t#define varying out\n\t\t\t\t#define texture2D texture\n", E = "#version 300 es\n\n\t\t\t\t#define varying in\n\t\t\t\tout highp vec4 pc_fragColor;\n\t\t\t\t#define gl_FragColor pc_fragColor\n\t\t\t\t#define gl_FragDepthEXT gl_FragDepth\n\t\t\t\t#define texture2D texture\n\t\t\t\t#define textureCube texture\n\t\t\t\t#define texture2DProj textureProj\n\t\t\t\t#define texture2DLodEXT textureLod\n\t\t\t\t#define texture2DProjLodEXT textureProjLod\n\t\t\t\t#define textureCubeLodEXT textureLod\n\t\t\t\t#define texture2DGradEXT textureGrad\n\t\t\t\t#define texture2DProjGradEXT textureProjGrad\n\t\t\t\t#define textureCubeGradEXT textureGrad\n") : (T = "", E = "#ifdef GL_EXT_shader_texture_lod\n\t\t\t\t\t#extension GL_EXT_shader_texture_lod : enable\n\t\t\t\t#endif\n\t\t\t\t#if !defined(GL_EXT_shader_texture_lod)\n\t\t\t\t\t#define texture1DLodEXT texture1D\n\t\t\t\t\t#define texture2DLodEXT texture2D\n\t\t\t\t\t#define texture2DProjLodEXT texture2DProj\n\t\t\t\t\t#define texture3DLodEXT texture3D\n\t\t\t\t\t#define textureCubeLodEXT textureCube\n\t\t\t\t#endif\n"), R += "#define MAX_LIGHT_COUNT " + p.maxLightCount + "\n", R += "#define MAX_LIGHT_COUNT_PER_CLUSTER " + p._maxAreaLightCountPerClusterAverage + "\n", R += "#define CLUSTER_X_COUNT " + g.x + "\n", R += "#define CLUSTER_Y_COUNT " + g.y + "\n", R += "#define CLUSTER_Z_COUNT " + g.z + "\n", R += "#define SHADER_CAPAILITY_LEVEL " + t.SystemUtils._shaderCapailityLevel + "\n";
            h = 0;
            for (var v = f.length; h &lt; v; h++) {
                var A = f[h];
                R += "#define " + A + "\n", S[A] = !0
            }
            var I = this._VS.toscript(S, []),
                x = "";
            0 == I[0].indexOf("#version") &amp;&amp; (x = I[0] + "\n", I.shift());
            var L = this._PS.toscript(S, []),
                D = "";
            if (0 == L[0].indexOf("#version") &amp;&amp; (D = L[0] + "\n", L.shift()), m = new Ue(x + T + R + I.join("\n"), D + E + R + L.join("\n"), this._owner._attributeMap || this._owner._owner._attributeMap, this._owner._uniformMap || this._owner._owner._uniformMap, this), a[u] = m, he.debugMode) {
                var C = "",
                    y = "";
                for (h = 0, v = r; h &lt; v; h++) y += h == v - 1 ? n[h] : n[h] + ",";
                for (h = 0, v = i.length; h &lt; v; h++) C += h == v - 1 ? i[h] : i[h] + ",";
                console.log("%cLayaAir: Shader Compile Information---ShaderName:" + this._owner._owner._name + " SubShaderIndex:" + this._owner._owner._subShaders.indexOf(this._owner) + " PassIndex:" + this._owner._passes.indexOf(this) + " DefineMask:[" + y + "] DefineNames:[" + C + "]", "color:green")
            }
            return m
        }
        setTag(e, t) {
            t ? this._tags[e] = t : delete this._tags[e]
        }
        getTag(e) {
            return this._tags[e]
        }
    }
    or._defineString = [], or._debugDefineString = [], or._debugDefineMask = [];
    class lr {
        constructor(e, t) {
            this._flags = {}, this._passes = [], this._attributeMap = e, this._uniformMap = t
        }
        setFlag(e, t) {
            t ? this._flags[e] = t : delete this._flags[e]
        }
        getFlag(e) {
            return this._flags[e]
        }
        addShaderPass(e, t, r = null, i = "Forward") {
            var n = new or(this, e, t, r);
            return n._pipelineMode = i, this._passes.push(n), n
        }
    }(be = e.PBRSpecularSmoothnessSource || (e.PBRSpecularSmoothnessSource = {}))[be.SpecularTextureAlpha = 0] = "SpecularTextureAlpha", be[be.AlbedoTextureAlpha = 1] = "AlbedoTextureAlpha";
    class _r extends ve {
        constructor() {
            super(), this.setShaderName("PBRSpecular"), this._shaderValues.setVector(_r.SPECULARCOLOR, new n(.2, .2, .2, 1))
        }
        static __init__() {
            _r.SHADERDEFINE_SPECULARGLOSSTEXTURE = he.getDefineByName("SPECULARGLOSSTEXTURE"), _r.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA = he.getDefineByName("SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA");
            var e = {
                    a_Position: lt.MESH_POSITION0,
                    a_Normal: lt.MESH_NORMAL0,
                    a_Tangent0: lt.MESH_TANGENT0,
                    a_Texcoord0: lt.MESH_TEXTURECOORDINATE0,
                    a_Texcoord1: lt.MESH_TEXTURECOORDINATE1,
                    a_BoneWeights: lt.MESH_BLENDWEIGHT0,
                    a_BoneIndices: lt.MESH_BLENDINDICES0,
                    a_MvpMatrix: lt.MESH_MVPMATRIX_ROW0,
                    a_WorldMat: lt.MESH_WORLDMATRIX_ROW0
                },
                t = {
                    u_Bones: he.PERIOD_CUSTOM,
                    u_MvpMatrix: he.PERIOD_SPRITE,
                    u_WorldMat: he.PERIOD_SPRITE,
                    u_LightmapScaleOffset: he.PERIOD_SPRITE,
                    u_LightMap: he.PERIOD_SPRITE,
                    u_LightMapDirection: he.PERIOD_SPRITE,
                    u_SimpleAnimatorTexture: he.PERIOD_SPRITE,
                    u_SimpleAnimatorParams: he.PERIOD_SPRITE,
                    u_SimpleAnimatorTextureSize: he.PERIOD_SPRITE,
                    u_CameraPos: he.PERIOD_CAMERA,
                    u_View: he.PERIOD_CAMERA,
                    u_ProjectionParams: he.PERIOD_CAMERA,
                    u_Viewport: he.PERIOD_CAMERA,
                    u_ViewProjection: he.PERIOD_CAMERA,
                    u_AlphaTestValue: he.PERIOD_MATERIAL,
                    u_AlbedoColor: he.PERIOD_MATERIAL,
                    u_EmissionColor: he.PERIOD_MATERIAL,
                    u_AlbedoTexture: he.PERIOD_MATERIAL,
                    u_NormalTexture: he.PERIOD_MATERIAL,
                    u_ParallaxTexture: he.PERIOD_MATERIAL,
                    u_OcclusionTexture: he.PERIOD_MATERIAL,
                    u_EmissionTexture: he.PERIOD_MATERIAL,
                    u_Smoothness: he.PERIOD_MATERIAL,
                    u_SmoothnessScale: he.PERIOD_MATERIAL,
                    u_occlusionStrength: he.PERIOD_MATERIAL,
                    u_NormalScale: he.PERIOD_MATERIAL,
                    u_ParallaxScale: he.PERIOD_MATERIAL,
                    u_TilingOffset: he.PERIOD_MATERIAL,
                    u_SpecGlossTexture: he.PERIOD_MATERIAL,
                    u_SpecularColor: he.PERIOD_MATERIAL,
                    u_ReflectTexture: he.PERIOD_SCENE,
                    u_ReflectIntensity: he.PERIOD_SCENE,
                    u_AmbientColor: he.PERIOD_SCENE,
                    u_FogStart: he.PERIOD_SCENE,
                    u_FogRange: he.PERIOD_SCENE,
                    u_FogColor: he.PERIOD_SCENE,
                    u_DirationLightCount: he.PERIOD_SCENE,
                    u_LightBuffer: he.PERIOD_SCENE,
                    u_LightClusterBuffer: he.PERIOD_SCENE,
                    u_ShadowBias: he.PERIOD_SCENE,
                    u_ShadowLightDirection: he.PERIOD_SCENE,
                    u_ShadowMap: he.PERIOD_SCENE,
                    u_ShadowParams: he.PERIOD_SCENE,
                    u_ShadowSplitSpheres: he.PERIOD_SCENE,
                    u_ShadowMatrices: he.PERIOD_SCENE,
                    u_ShadowMapSize: he.PERIOD_SCENE,
                    u_SpotShadowMap: he.PERIOD_SCENE,
                    u_SpotViewProjectMatrix: he.PERIOD_SCENE,
                    u_ShadowLightPosition: he.PERIOD_SCENE,
                    u_AmbientSHAr: he.PERIOD_SCENE,
                    u_AmbientSHAg: he.PERIOD_SCENE,
                    u_AmbientSHAb: he.PERIOD_SCENE,
                    u_AmbientSHBr: he.PERIOD_SCENE,
                    u_AmbientSHBg: he.PERIOD_SCENE,
                    u_AmbientSHBb: he.PERIOD_SCENE,
                    u_AmbientSHC: he.PERIOD_SCENE,
                    u_ReflectionProbe: he.PERIOD_SCENE,
                    u_ReflectCubeHDRParams: he.PERIOD_SCENE,
                    "u_DirectionLight.direction": he.PERIOD_SCENE,
                    "u_DirectionLight.color": he.PERIOD_SCENE,
                    "u_PointLight.position": he.PERIOD_SCENE,
                    "u_PointLight.range": he.PERIOD_SCENE,
                    "u_PointLight.color": he.PERIOD_SCENE,
                    "u_SpotLight.position": he.PERIOD_SCENE,
                    "u_SpotLight.direction": he.PERIOD_SCENE,
                    "u_SpotLight.range": he.PERIOD_SCENE,
                    "u_SpotLight.spot": he.PERIOD_SCENE,
                    "u_SpotLight.color": he.PERIOD_SCENE
                },
                r = {
                    s_Cull: he.RENDER_STATE_CULL,
                    s_Blend: he.RENDER_STATE_BLEND,
                    s_BlendSrc: he.RENDER_STATE_BLEND_SRC,
                    s_BlendDst: he.RENDER_STATE_BLEND_DST,
                    s_DepthTest: he.RENDER_STATE_DEPTH_TEST,
                    s_DepthWrite: he.RENDER_STATE_DEPTH_WRITE
                },
                i = he.add("PBRSpecular", e, t, !0),
                n = new lr(e, t);
            i.addSubShader(n), n.addShaderPass(we, Pe, r, "Forward"), n.addShaderPass(Be, Ve, r, "ShadowCaster")
        }
        get specularTexture() {
            return this._shaderValues.getTexture(_r.SPECULARTEXTURE)
        }
        set specularTexture(e) {
            e ? this._shaderValues.addDefine(_r.SHADERDEFINE_SPECULARGLOSSTEXTURE) : this._shaderValues.removeDefine(_r.SHADERDEFINE_SPECULARGLOSSTEXTURE), this._shaderValues.setTexture(_r.SPECULARTEXTURE, e)
        }
        get specularColor() {
            return this._shaderValues.getVector(_r.SPECULARCOLOR)
        }
        set specularColor(e) {
            this._shaderValues.setVector(_r.SPECULARCOLOR, e)
        }
        clone() {
            var e = new _r;
            return this.cloneTo(e), e
        }
    }
    _r.SPECULARTEXTURE = he.propertyNameToID("u_SpecGlossTexture"), _r.SPECULARCOLOR = he.propertyNameToID("u_SpecularColor");
    var hr, cr, dr = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n\tprecision highp int;\r\n#else\r\n\tprecision mediump float;\r\n\tprecision mediump int;\r\n#endif\r\n\r\n#include "Lighting.glsl";\r\n#include "Shadow.glsl"\r\n#include "PBRFSInput.glsl";\r\n#include "LayaPBRBRDF.glsl";\r\n#include "GlobalIllumination.glsl";\r\n#include "PBRCore.glsl";\r\n\r\nvoid main()\r\n{\r\n\tfragmentForward();\r\n}',
        ur = '#include "Lighting.glsl";\r\n#include "Shadow.glsl"\r\n#include "PBRVSInput.glsl";\r\n#include "PBRVertex.glsl";\r\n\r\nvoid main()\r\n{\r\n\tvertexForward();\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',
        mr = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n\tprecision highp int;\r\n#else\r\n\tprecision mediump float;\r\n\tprecision mediump int;\r\n#endif\r\n\r\n#include "ShadowCasterFS.glsl"\r\n\r\nvoid main()\r\n{\r\n\tgl_FragColor=shadowCasterFragment();\r\n}',
        fr = '#include "ShadowCasterVS.glsl"\r\n\r\nvoid main()\r\n{\r\n\tvec4 positionCS =  shadowCasterVertex();\r\n\tgl_Position=remapGLPositionZ(positionCS);\r\n}';
    (hr = e.PBRMetallicSmoothnessSource || (e.PBRMetallicSmoothnessSource = {}))[hr.MetallicGlossTextureAlpha = 0] = "MetallicGlossTextureAlpha", hr[hr.AlbedoTextureAlpha = 1] = "AlbedoTextureAlpha";
    class Tr extends ve {
        constructor() {
            super(), this._smoothnessSource = 0, this.setShaderName("PBR"), this._shaderValues.setNumber(Tr.METALLIC, 0)
        }
        static __init__() {
            Tr.SHADERDEFINE_METALLICGLOSSTEXTURE = he.getDefineByName("METALLICGLOSSTEXTURE"), Tr.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA = he.getDefineByName("SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA");
            var e = {
                    a_Position: lt.MESH_POSITION0,
                    a_Normal: lt.MESH_NORMAL0,
                    a_Tangent0: lt.MESH_TANGENT0,
                    a_Texcoord0: lt.MESH_TEXTURECOORDINATE0,
                    a_Texcoord1: lt.MESH_TEXTURECOORDINATE1,
                    a_BoneWeights: lt.MESH_BLENDWEIGHT0,
                    a_BoneIndices: lt.MESH_BLENDINDICES0,
                    a_MvpMatrix: lt.MESH_MVPMATRIX_ROW0,
                    a_WorldMat: lt.MESH_WORLDMATRIX_ROW0
                },
                t = {
                    u_Bones: he.PERIOD_CUSTOM,
                    u_MvpMatrix: he.PERIOD_SPRITE,
                    u_WorldMat: he.PERIOD_SPRITE,
                    u_LightmapScaleOffset: he.PERIOD_SPRITE,
                    u_LightMap: he.PERIOD_SPRITE,
                    u_LightMapDirection: he.PERIOD_SPRITE,
                    u_SimpleAnimatorTexture: he.PERIOD_SPRITE,
                    u_SimpleAnimatorParams: he.PERIOD_SPRITE,
                    u_SimpleAnimatorTextureSize: he.PERIOD_SPRITE,
                    u_CameraPos: he.PERIOD_CAMERA,
                    u_View: he.PERIOD_CAMERA,
                    u_ProjectionParams: he.PERIOD_CAMERA,
                    u_Viewport: he.PERIOD_CAMERA,
                    u_ViewProjection: he.PERIOD_CAMERA,
                    u_AlphaTestValue: he.PERIOD_MATERIAL,
                    u_AlbedoColor: he.PERIOD_MATERIAL,
                    u_EmissionColor: he.PERIOD_MATERIAL,
                    u_AlbedoTexture: he.PERIOD_MATERIAL,
                    u_NormalTexture: he.PERIOD_MATERIAL,
                    u_ParallaxTexture: he.PERIOD_MATERIAL,
                    u_OcclusionTexture: he.PERIOD_MATERIAL,
                    u_EmissionTexture: he.PERIOD_MATERIAL,
                    u_Smoothness: he.PERIOD_MATERIAL,
                    u_SmoothnessScale: he.PERIOD_MATERIAL,
                    u_occlusionStrength: he.PERIOD_MATERIAL,
                    u_NormalScale: he.PERIOD_MATERIAL,
                    u_ParallaxScale: he.PERIOD_MATERIAL,
                    u_TilingOffset: he.PERIOD_MATERIAL,
                    u_MetallicGlossTexture: he.PERIOD_MATERIAL,
                    u_Metallic: he.PERIOD_MATERIAL,
                    u_ReflectTexture: he.PERIOD_SCENE,
                    u_ReflectIntensity: he.PERIOD_SCENE,
                    u_AmbientColor: he.PERIOD_SCENE,
                    u_FogStart: he.PERIOD_SCENE,
                    u_FogRange: he.PERIOD_SCENE,
                    u_FogColor: he.PERIOD_SCENE,
                    u_DirationLightCount: he.PERIOD_SCENE,
                    u_LightBuffer: he.PERIOD_SCENE,
                    u_LightClusterBuffer: he.PERIOD_SCENE,
                    u_ShadowBias: he.PERIOD_SCENE,
                    u_ShadowLightDirection: he.PERIOD_SCENE,
                    u_ShadowMap: he.PERIOD_SCENE,
                    u_ShadowParams: he.PERIOD_SCENE,
                    u_ShadowSplitSpheres: he.PERIOD_SCENE,
                    u_ShadowMatrices: he.PERIOD_SCENE,
                    u_ShadowMapSize: he.PERIOD_SCENE,
                    u_SpotShadowMap: he.PERIOD_SCENE,
                    u_SpotViewProjectMatrix: he.PERIOD_SCENE,
                    u_ShadowLightPosition: he.PERIOD_SCENE,
                    u_AmbientSHAr: he.PERIOD_SCENE,
                    u_AmbientSHAg: he.PERIOD_SCENE,
                    u_AmbientSHAb: he.PERIOD_SCENE,
                    u_AmbientSHBr: he.PERIOD_SCENE,
                    u_AmbientSHBg: he.PERIOD_SCENE,
                    u_AmbientSHBb: he.PERIOD_SCENE,
                    u_AmbientSHC: he.PERIOD_SCENE,
                    u_ReflectionProbe: he.PERIOD_SCENE,
                    u_ReflectCubeHDRParams: he.PERIOD_SCENE,
                    "u_DirectionLight.direction": he.PERIOD_SCENE,
                    "u_DirectionLight.color": he.PERIOD_SCENE,
                    "u_PointLight.position": he.PERIOD_SCENE,
                    "u_PointLight.range": he.PERIOD_SCENE,
                    "u_PointLight.color": he.PERIOD_SCENE,
                    "u_SpotLight.position": he.PERIOD_SCENE,
                    "u_SpotLight.direction": he.PERIOD_SCENE,
                    "u_SpotLight.range": he.PERIOD_SCENE,
                    "u_SpotLight.spot": he.PERIOD_SCENE,
                    "u_SpotLight.color": he.PERIOD_SCENE
                },
                r = {
                    s_Cull: he.RENDER_STATE_CULL,
                    s_Blend: he.RENDER_STATE_BLEND,
                    s_BlendSrc: he.RENDER_STATE_BLEND_SRC,
                    s_BlendDst: he.RENDER_STATE_BLEND_DST,
                    s_DepthTest: he.RENDER_STATE_DEPTH_TEST,
                    s_DepthWrite: he.RENDER_STATE_DEPTH_WRITE
                },
                i = he.add("PBR", e, t, !0),
                n = new lr(e, t);
            i.addSubShader(n), n.addShaderPass(ur, dr, r, "Forward"), n.addShaderPass(fr, mr, r, "ShadowCaster")
        }
        get metallicGlossTexture() {
            return this._shaderValues.getTexture(Tr.METALLICGLOSSTEXTURE)
        }
        set metallicGlossTexture(e) {
            e ? this._shaderValues.addDefine(Tr.SHADERDEFINE_METALLICGLOSSTEXTURE) : this._shaderValues.removeDefine(Tr.SHADERDEFINE_METALLICGLOSSTEXTURE), this._shaderValues.setTexture(Tr.METALLICGLOSSTEXTURE, e)
        }
        get metallic() {
            return this._shaderValues.getNumber(Tr.METALLIC)
        }
        set metallic(e) {
            this._shaderValues.setNumber(Tr.METALLIC, Math.max(0, Math.min(1, e)))
        }
        get smoothnessSource() {
            return this._smoothnessSource
        }
        set smoothnessSource(e) {
            e ? this._shaderValues.addDefine(Tr.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA) : this._shaderValues.removeDefine(Tr.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA), this._smoothnessSource = e
        }
        clone() {
            var e = new Tr;
            return this.cloneTo(e), e
        }
    }
    Tr.METALLICGLOSSTEXTURE = he.propertyNameToID("u_MetallicGlossTexture"), Tr.METALLIC = he.propertyNameToID("u_Metallic");
    class Er extends Te {
        constructor() {
            super(), this.setShaderName("SkyBox"), this.tintColor = new n(.5, .5, .5, .5), this.exposure = 1, this.rotation = 0
        }
        static __initDefine__() {}
        get tintColor() {
            return this._shaderValues.getVector(Er.TINTCOLOR)
        }
        set tintColor(e) {
            this._shaderValues.setVector(Er.TINTCOLOR, e)
        }
        get exposure() {
            return this._shaderValues.getNumber(Er.EXPOSURE)
        }
        set exposure(e) {
            this._shaderValues.setNumber(Er.EXPOSURE, e)
        }
        get rotation() {
            return this._shaderValues.getNumber(Er.ROTATION)
        }
        set rotation(e) {
            this._shaderValues.setNumber(Er.ROTATION, e)
        }
        get textureCube() {
            return this._shaderValues.getTexture(Er.TEXTURECUBE)
        }
        set textureCube(e) {
            this._shaderValues.setTexture(Er.TEXTURECUBE, e)
        }
        clone() {
            var e = new Er;
            return this.cloneTo(e), e
        }
    }
    Er.TINTCOLOR = he.propertyNameToID("u_TintColor"), Er.EXPOSURE = he.propertyNameToID("u_Exposure"), Er.ROTATION = he.propertyNameToID("u_Rotation"), Er.TEXTURECUBE = he.propertyNameToID("u_CubeTexture");
    class pr extends Te {
        constructor() {
            super(), this.setShaderName("SkyBoxProcedural"), this.sunDisk = pr.SUN_HIGH_QUALITY, this.sunSize = .04, this.sunSizeConvergence = 5, this.atmosphereThickness = 1, this.skyTint = new n(.5, .5, .5, 1), this.groundTint = new n(.369, .349, .341, 1), this.exposure = 1.3
        }
        static __initDefine__() {
            pr.SHADERDEFINE_SUN_HIGH_QUALITY = he.getDefineByName("SUN_HIGH_QUALITY"), pr.SHADERDEFINE_SUN_SIMPLE = he.getDefineByName("SUN_SIMPLE")
        }
        get sunDisk() {
            return this._sunDisk
        }
        set sunDisk(e) {
            switch (e) {
                case pr.SUN_HIGH_QUALITY:
                    this._shaderValues.removeDefine(pr.SHADERDEFINE_SUN_SIMPLE), this._shaderValues.addDefine(pr.SHADERDEFINE_SUN_HIGH_QUALITY);
                    break;
                case pr.SUN_SIMPLE:
                    this._shaderValues.removeDefine(pr.SHADERDEFINE_SUN_HIGH_QUALITY), this._shaderValues.addDefine(pr.SHADERDEFINE_SUN_SIMPLE);
                    break;
                case pr.SUN_NODE:
                    this._shaderValues.removeDefine(pr.SHADERDEFINE_SUN_HIGH_QUALITY), this._shaderValues.removeDefine(pr.SHADERDEFINE_SUN_SIMPLE);
                    break;
                default:
                    throw "SkyBoxProceduralMaterial: unknown sun value."
            }
            this._sunDisk = e
        }
        get sunSize() {
            return this._shaderValues.getNumber(pr.SUNSIZE)
        }
        set sunSize(e) {
            e = Math.min(Math.max(0, e), 1), this._shaderValues.setNumber(pr.SUNSIZE, e)
        }
        get sunSizeConvergence() {
            return this._shaderValues.getNumber(pr.SUNSIZECONVERGENCE)
        }
        set sunSizeConvergence(e) {
            e = Math.min(Math.max(0, e), 20), this._shaderValues.setNumber(pr.SUNSIZECONVERGENCE, e)
        }
        get atmosphereThickness() {
            return this._shaderValues.getNumber(pr.ATMOSPHERETHICKNESS)
        }
        set atmosphereThickness(e) {
            e = Math.min(Math.max(0, e), 5), this._shaderValues.setNumber(pr.ATMOSPHERETHICKNESS, e)
        }
        get skyTint() {
            return this._shaderValues.getVector(pr.SKYTINT)
        }
        set skyTint(e) {
            this._shaderValues.setVector(pr.SKYTINT, e)
        }
        get groundTint() {
            return this._shaderValues.getVector(pr.GROUNDTINT)
        }
        set groundTint(e) {
            this._shaderValues.setVector(pr.GROUNDTINT, e)
        }
        get exposure() {
            return this._shaderValues.getNumber(pr.EXPOSURE)
        }
        set exposure(e) {
            e = Math.min(Math.max(0, e), 8), this._shaderValues.setNumber(pr.EXPOSURE, e)
        }
        clone() {
            var e = new pr;
            return this.cloneTo(e), e
        }
    }
    pr.SUN_NODE = 0, pr.SUN_SIMPLE = 1, pr.SUN_HIGH_QUALITY = 2, pr.SUNSIZE = he.propertyNameToID("u_SunSize"), pr.SUNSIZECONVERGENCE = he.propertyNameToID("u_SunSizeConvergence"), pr.ATMOSPHERETHICKNESS = he.propertyNameToID("u_AtmosphereThickness"), pr.SKYTINT = he.propertyNameToID("u_SkyTint"), pr.GROUNDTINT = he.propertyNameToID("u_GroundTint"), pr.EXPOSURE = he.propertyNameToID("u_Exposure");
    class gr extends Te {
        constructor() {
            super(), this._albedoColor = new n(1, 1, 1, 1), this._albedoIntensity = 1, this._enableVertexColor = !1, this.setShaderName("Unlit"), this._shaderValues.setVector(gr.ALBEDOCOLOR, new n(1, 1, 1, 1)), this.renderMode = gr.RENDERMODE_OPAQUE
        }
        static __initDefine__() {
            gr.SHADERDEFINE_ALBEDOTEXTURE = he.getDefineByName("ALBEDOTEXTURE"), gr.SHADERDEFINE_TILINGOFFSET = he.getDefineByName("TILINGOFFSET"), gr.SHADERDEFINE_ENABLEVERTEXCOLOR = he.getDefineByName("ENABLEVERTEXCOLOR")
        }
        get _ColorR() {
            return this._albedoColor.x
        }
        set _ColorR(e) {
            this._albedoColor.x = e, this.albedoColor = this._albedoColor
        }
        get _ColorG() {
            return this._albedoColor.y
        }
        set _ColorG(e) {
            this._albedoColor.y = e, this.albedoColor = this._albedoColor
        }
        get _ColorB() {
            return this._albedoColor.z
        }
        set _ColorB(e) {
            this._albedoColor.z = e, this.albedoColor = this._albedoColor
        }
        get _ColorA() {
            return this._albedoColor.w
        }
        set _ColorA(e) {
            this._albedoColor.w = e, this.albedoColor = this._albedoColor
        }
        get _AlbedoIntensity() {
            return this._albedoIntensity
        }
        set _AlbedoIntensity(e) {
            if (this._albedoIntensity !== e) {
                var t = this._shaderValues.getVector(gr.ALBEDOCOLOR);
                n.scale(this._albedoColor, e, t), this._albedoIntensity = e, this._shaderValues.setVector(gr.ALBEDOCOLOR, t)
            }
        }
        get _MainTex_STX() {
            return this._shaderValues.getVector(gr.TILINGOFFSET).x
        }
        set _MainTex_STX(e) {
            var t = this._shaderValues.getVector(gr.TILINGOFFSET);
            t.x = e, this.tilingOffset = t
        }
        get _MainTex_STY() {
            return this._shaderValues.getVector(gr.TILINGOFFSET).y
        }
        set _MainTex_STY(e) {
            var t = this._shaderValues.getVector(gr.TILINGOFFSET);
            t.y = e, this.tilingOffset = t
        }
        get _MainTex_STZ() {
            return this._shaderValues.getVector(gr.TILINGOFFSET).z
        }
        set _MainTex_STZ(e) {
            var t = this._shaderValues.getVector(gr.TILINGOFFSET);
            t.z = e, this.tilingOffset = t
        }
        get _MainTex_STW() {
            return this._shaderValues.getVector(gr.TILINGOFFSET).w
        }
        set _MainTex_STW(e) {
            var t = this._shaderValues.getVector(gr.TILINGOFFSET);
            t.w = e, this.tilingOffset = t
        }
        get _Cutoff() {
            return this.alphaTestValue
        }
        set _Cutoff(e) {
            this.alphaTestValue = e
        }
        get albedoColorR() {
            return this._ColorR
        }
        set albedoColorR(e) {
            this._ColorR = e
        }
        get albedoColorG() {
            return this._ColorG
        }
        set albedoColorG(e) {
            this._ColorG = e
        }
        get albedoColorB() {
            return this._ColorB
        }
        set albedoColorB(e) {
            this._ColorB = e
        }
        get albedoColorA() {
            return this._ColorA
        }
        set albedoColorA(e) {
            this._ColorA = e
        }
        get albedoColor() {
            return this._albedoColor
        }
        set albedoColor(e) {
            var t = this._shaderValues.getVector(gr.ALBEDOCOLOR);
            n.scale(e, this._albedoIntensity, t), this._albedoColor = e, this._shaderValues.setVector(gr.ALBEDOCOLOR, t)
        }
        get albedoIntensity() {
            return this._albedoIntensity
        }
        set albedoIntensity(e) {
            this._AlbedoIntensity = e
        }
        get albedoTexture() {
            return this._shaderValues.getTexture(gr.ALBEDOTEXTURE)
        }
        set albedoTexture(e) {
            e ? this._shaderValues.addDefine(gr.SHADERDEFINE_ALBEDOTEXTURE) : this._shaderValues.removeDefine(gr.SHADERDEFINE_ALBEDOTEXTURE), this._shaderValues.setTexture(gr.ALBEDOTEXTURE, e)
        }
        get tilingOffsetX() {
            return this._MainTex_STX
        }
        set tilingOffsetX(e) {
            this._MainTex_STX = e
        }
        get tilingOffsetY() {
            return this._MainTex_STY
        }
        set tilingOffsetY(e) {
            this._MainTex_STY = e
        }
        get tilingOffsetZ() {
            return this._MainTex_STZ
        }
        set tilingOffsetZ(e) {
            this._MainTex_STZ = e
        }
        get tilingOffsetW() {
            return this._MainTex_STW
        }
        set tilingOffsetW(e) {
            this._MainTex_STW = e
        }
        get tilingOffset() {
            return this._shaderValues.getVector(gr.TILINGOFFSET)
        }
        set tilingOffset(e) {
            e &amp;&amp; (1 != e.x || 1 != e.y || 0 != e.z || 0 != e.w) ? this._shaderValues.addDefine(gr.SHADERDEFINE_TILINGOFFSET) : this._shaderValues.removeDefine(gr.SHADERDEFINE_TILINGOFFSET), this._shaderValues.setVector(gr.TILINGOFFSET, e)
        }
        get enableVertexColor() {
            return this._enableVertexColor
        }
        set enableVertexColor(e) {
            this._enableVertexColor = e, e ? this._shaderValues.addDefine(gr.SHADERDEFINE_ENABLEVERTEXCOLOR) : this._shaderValues.removeDefine(gr.SHADERDEFINE_ENABLEVERTEXCOLOR)
        }
        set renderMode(e) {
            switch (e) {
                case gr.RENDERMODE_OPAQUE:
                    this.alphaTest = !1, this.renderQueue = Te.RENDERQUEUE_OPAQUE, this.depthWrite = !0, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_DISABLE, this.depthTest = pe.DEPTHTEST_LESS;
                    break;
                case gr.RENDERMODE_CUTOUT:
                    this.renderQueue = Te.RENDERQUEUE_ALPHATEST, this.alphaTest = !0, this.depthWrite = !0, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_DISABLE, this.depthTest = pe.DEPTHTEST_LESS;
                    break;
                case gr.RENDERMODE_TRANSPARENT:
                    this.renderQueue = Te.RENDERQUEUE_TRANSPARENT, this.alphaTest = !1, this.depthWrite = !1, this.cull = pe.CULL_BACK, this.blend = pe.BLEND_ENABLE_ALL, this.blendSrc = pe.BLENDPARAM_SRC_ALPHA, this.blendDst = pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA, this.depthTest = pe.DEPTHTEST_LESS;
                    break;
                default:
                    throw new Error("UnlitMaterial : renderMode value error.")
            }
        }
        get depthWrite() {
            return this._shaderValues.getBool(gr.DEPTH_WRITE)
        }
        set depthWrite(e) {
            this._shaderValues.setBool(gr.DEPTH_WRITE, e)
        }
        get cull() {
            return this._shaderValues.getInt(gr.CULL)
        }
        set cull(e) {
            this._shaderValues.setInt(gr.CULL, e)
        }
        get blend() {
            return this._shaderValues.getInt(gr.BLEND)
        }
        set blend(e) {
            this._shaderValues.setInt(gr.BLEND, e)
        }
        get blendSrc() {
            return this._shaderValues.getInt(gr.BLEND_SRC)
        }
        set blendSrc(e) {
            this._shaderValues.setInt(gr.BLEND_SRC, e)
        }
        get blendDst() {
            return this._shaderValues.getInt(gr.BLEND_DST)
        }
        set blendDst(e) {
            this._shaderValues.setInt(gr.BLEND_DST, e)
        }
        get depthTest() {
            return this._shaderValues.getInt(gr.DEPTH_TEST)
        }
        set depthTest(e) {
            this._shaderValues.setInt(gr.DEPTH_TEST, e)
        }
        clone() {
            var e = new gr;
            return this.cloneTo(e), e
        }
    }
    gr.RENDERMODE_OPAQUE = 0, gr.RENDERMODE_CUTOUT = 1, gr.RENDERMODE_TRANSPARENT = 2, gr.RENDERMODE_ADDTIVE = 3, gr.ALBEDOTEXTURE = he.propertyNameToID("u_AlbedoTexture"), gr.ALBEDOCOLOR = he.propertyNameToID("u_AlbedoColor"), gr.TILINGOFFSET = he.propertyNameToID("u_TilingOffset"), gr.CULL = he.propertyNameToID("s_Cull"), gr.BLEND = he.propertyNameToID("s_Blend"), gr.BLEND_SRC = he.propertyNameToID("s_BlendSrc"), gr.BLEND_DST = he.propertyNameToID("s_BlendDst"), gr.DEPTH_TEST = he.propertyNameToID("s_DepthTest"), gr.DEPTH_WRITE = he.propertyNameToID("s_DepthWrite");
    class Sr extends Te {
        constructor() {
            super(), this.setShaderName("WaterPrimary"), this._shaderValues.setVector(Sr.HORIZONCOLOR, new n(.172, .463, .435, 0)), this._shaderValues.setNumber(Sr.WAVESCALE, .15), this._shaderValues.setVector(Sr.WAVESPEED, new n(19, 9, -16, -7))
        }
        static __initDefine__() {
            Sr.SHADERDEFINE_MAINTEXTURE = he.getDefineByName("MAINTEXTURE"), Sr.SHADERDEFINE_NORMALTEXTURE = he.getDefineByName("NORMALTEXTURE")
        }
        get horizonColor() {
            return this._shaderValues.getVector(Sr.HORIZONCOLOR)
        }
        set horizonColor(e) {
            this._shaderValues.setVector(Sr.HORIZONCOLOR, e)
        }
        get mainTexture() {
            return this._shaderValues.getTexture(Sr.MAINTEXTURE)
        }
        set mainTexture(e) {
            e ? this._shaderValues.addDefine(Sr.SHADERDEFINE_MAINTEXTURE) : this._shaderValues.removeDefine(Sr.SHADERDEFINE_MAINTEXTURE), this._shaderValues.setTexture(Sr.MAINTEXTURE, e)
        }
        get normalTexture() {
            return this._shaderValues.getTexture(Sr.NORMALTEXTURE)
        }
        set normalTexture(e) {
            e ? this._shaderValues.addDefine(Sr.SHADERDEFINE_NORMALTEXTURE) : this._shaderValues.removeDefine(Sr.SHADERDEFINE_NORMALTEXTURE), this._shaderValues.setTexture(Sr.NORMALTEXTURE, e)
        }
        get waveScale() {
            return this._shaderValues.getNumber(Sr.WAVESCALE)
        }
        set waveScale(e) {
            this._shaderValues.setNumber(Sr.WAVESCALE, e)
        }
        get waveSpeed() {
            return this._shaderValues.getVector(Sr.WAVESPEED)
        }
        set waveSpeed(e) {
            this._shaderValues.setVector(Sr.WAVESPEED, e)
        }
        clone() {
            var e = new Sr;
            return this.cloneTo(e), e
        }
    }
    Sr.HORIZONCOLOR = he.propertyNameToID("u_HorizonColor"), Sr.MAINTEXTURE = he.propertyNameToID("u_MainTexture"), Sr.NORMALTEXTURE = he.propertyNameToID("u_NormalTexture"), Sr.WAVESCALE = he.propertyNameToID("u_WaveScale"), Sr.WAVESPEED = he.propertyNameToID("u_WaveSpeed");
    class Rr {}
    class vr extends jt {
        constructor(e) {
            super(e), this._revertStaticBatchDefineUV1 = !1, this._projectionViewWorldMatrix = new c
        }
        _createRenderElement() {
            return new Wt
        }
        _onMeshChange(e) {
            if (e) {
                var t = e.subMeshCount;
                this._renderElements.length = t;
                for (var r = 0; r &lt; t; r++) {
                    var i = this._renderElements[r];
                    if (!i) {
                        var n = this.sharedMaterials[r];
                        (i = this._renderElements[r] = this._createRenderElement()).setTransform(this._owner._transform), i.render = this, i.material = n || ge.defaultMaterial
                    }
                    i.setGeometry(e.getSubMesh(r))
                }
            } else this._renderElements.length = 0;
            this._boundsChange = !0
        }
        _calculateBoundingBox() {
            var e = this._owner.meshFilter.sharedMesh;
            if (e) {
                var r = this._owner.transform.worldMatrix;
                e.bounds._tranform(r, this._bounds)
            }
            if (t.Render.supportWebGLPlusCulling) {
                var i = this._bounds.getMin(),
                    n = this._bounds.getMax(),
                    a = ke._cullingBuffer;
                a[this._cullingBufferIndex + 1] = i.x, a[this._cullingBufferIndex + 2] = i.y, a[this._cullingBufferIndex + 3] = i.z, a[this._cullingBufferIndex + 4] = n.x, a[this._cullingBufferIndex + 5] = n.y, a[this._cullingBufferIndex + 6] = n.z
            }
        }
        _needRender(e, t) {
            return !e || e.intersects(this.bounds._getBoundBox())
        }
        _renderUpdate(e, t) {
            this._applyLightMapParams();
            var r = e.renderElement;
            switch (r.renderType) {
                case Ht.RENDERTYPE_NORMAL:
                    this._shaderValues.setMatrix4x4(ut.WORLDMATRIX, t.worldMatrix);
                    break;
                case Ht.RENDERTYPE_STATICBATCH:
                    t ? this._shaderValues.setMatrix4x4(ut.WORLDMATRIX, t.worldMatrix) : this._shaderValues.setMatrix4x4(ut.WORLDMATRIX, c.DEFAULT), this._shaderValues.hasDefine(Rr.SHADERDEFINE_UV1) ? this._revertStaticBatchDefineUV1 = !1 : (this._shaderValues.addDefine(Rr.SHADERDEFINE_UV1), this._revertStaticBatchDefineUV1 = !0), this._shaderValues.setVector(Ut.LIGHTMAPSCALEOFFSET, jt._defaultLightmapScaleOffset);
                    break;
                case Ht.RENDERTYPE_VERTEXBATCH:
                    this._shaderValues.setMatrix4x4(ut.WORLDMATRIX, c.DEFAULT);
                    break;
                case Ht.RENDERTYPE_INSTANCEBATCH:
                    for (var i = zt.instance.instanceWorldMatrixData, n = r.instanceBatchElementList, a = n.elements, s = n.length, o = 0; o &lt; s; o++) i.set(a[o]._transform.worldMatrix.elements, 16 * o);
                    var l = zt.instance.instanceWorldMatrixBuffer;
                    l.orphanStorage(), l.setData(i.buffer, 0, 0, 16 * s * 4), this._shaderValues.addDefine(Rr.SHADERDEFINE_GPU_INSTANCE)
            }
        }
        _renderUpdateWithCamera(e, t) {
            var r = e.projectionViewMatrix;
            if (r) {
                var i = e.renderElement;
                switch (i.renderType) {
                    case Ht.RENDERTYPE_NORMAL:
                    case Ht.RENDERTYPE_STATICBATCH:
                    case Ht.RENDERTYPE_VERTEXBATCH:
                        t ? (c.multiply(r, t.worldMatrix, this._projectionViewWorldMatrix), this._shaderValues.setMatrix4x4(ut.MVPMATRIX, this._projectionViewWorldMatrix)) : this._shaderValues.setMatrix4x4(ut.MVPMATRIX, r);
                        break;
                    case Ht.RENDERTYPE_INSTANCEBATCH:
                        for (var n = zt.instance.instanceMVPMatrixData, a = i.instanceBatchElementList, s = a.elements, o = a.length, l = 0; l &lt; o; l++) {
                            var _ = s[l]._transform.worldMatrix;
                            N.mulMatrixByArray(r.elements, 0, _.elements, 0, n, 16 * l)
                        }
                        var h = zt.instance.instanceMVPMatrixBuffer;
                        h.orphanStorage(), h.setData(n.buffer, 0, 0, 16 * o * 4)
                }
            }
        }
        _revertBatchRenderUpdate(e) {
            switch (e.renderElement.renderType) {
                case Ht.RENDERTYPE_STATICBATCH:
                    this._revertStaticBatchDefineUV1 &amp;&amp; this._shaderValues.removeDefine(Rr.SHADERDEFINE_UV1), this._shaderValues.setVector(Ut.LIGHTMAPSCALEOFFSET, this.lightmapScaleOffset);
                    break;
                case Ht.RENDERTYPE_INSTANCEBATCH:
                    this._shaderValues.removeDefine(Rr.SHADERDEFINE_GPU_INSTANCE)
            }
        }
        _destroy() {
            this._isPartOfStaticBatch &amp;&amp; Yt.instance._removeRenderSprite(this._owner), super._destroy()
        }
    }
    class Ar {
        constructor(e) {
            this._owner = e
        }
        get sharedMesh() {
            return this._sharedMesh
        }
        set sharedMesh(e) {
            if (this._sharedMesh !== e) {
                var t = this._owner._render._shaderValues,
                    r = this._sharedMesh;
                if (r) {
                    r._removeReference(), this._getMeshDefine(r, Ar._meshVerticeDefine);
                    for (var i = 0, n = Ar._meshVerticeDefine.length; i &lt; n; i++) t.removeDefine(Ar._meshVerticeDefine[i])
                }
                if (e) {
                    e._addReference(), this._getMeshDefine(e, Ar._meshVerticeDefine);
                    for (i = 0, n = Ar._meshVerticeDefine.length; i &lt; n; i++) t.addDefine(Ar._meshVerticeDefine[i])
                }
                this._owner._render._onMeshChange(e), this._sharedMesh = e
            }
        }
        _getMeshDefine(e, t) {
            t.length = 0;
            for (var r = 0, i = e._subMeshes.length; r &lt; i; r++)
                for (var n = e.getSubMesh(r)._vertexBuffer._vertexDeclaration._vertexElements, a = 0, s = n.length; a &lt; s; a++) {
                    switch (n[a]._elementUsage) {
                        case lt.MESH_COLOR0:
                            t.push(Rr.SHADERDEFINE_COLOR);
                            break;
                        case lt.MESH_TEXTURECOORDINATE0:
                            t.push(Rr.SHADERDEFINE_UV0);
                            break;
                        case lt.MESH_TEXTURECOORDINATE1:
                            t.push(Rr.SHADERDEFINE_UV1)
                    }
                }
        }
        destroy() {
            this._owner = null, this._sharedMesh &amp;&amp; (this._sharedMesh._removeReference(), this._sharedMesh = null)
        }
    }
    Ar._meshVerticeDefine = [];
    class Ir extends Vt {
        constructor() {
            super(), this._bufferState = new it;
            var r = t.LayaGL.instance,
                i = lt.getVertexDeclaration("POSITION,NORMAL,COLOR,UV,UV1,TANGENT").vertexStride * Ir.maxIndicesCount;
            this._vertices = new Float32Array(i / 4), this._vertexBuffer = new _t(i, r.DYNAMIC_DRAW), this._indices = new Int16Array(Ir.maxIndicesCount), this._indexBuffer = new nt(e.IndexFormat.UInt16, this._indices.length, r.DYNAMIC_DRAW);
            var n = this._vertexBuffer._byteLength + this._indexBuffer._byteLength;
            t.Resource._addMemory(n, n)
        }
        static __init__() {
            Ir.instance = new Ir
        }
        _getBatchVertices(e, t, r, i, n, a) {
            var s = e.vertexStride / 4,
                o = a._vertexBuffer.getFloat32Data(),
                l = (n.render.lightmapScaleOffset, n._dynamicMultiSubMesh),
                _ = n._dynamicVertexCount;
            n._computeWorldPositionsAndNormals(this._positionOffset, this._normalOffset, l, _);
            for (var h = n._dynamicWorldPositions, c = n._dynamicWorldNormals, d = a._indices, u = 0; u &lt; _; u++) {
                var m = (l ? d[u] : u) * s,
                    f = (u + r) * s,
                    T = 3 * u,
                    E = f + this._positionOffset;
                t[E] = h[T], t[E + 1] = h[T + 1], t[E + 2] = h[T + 2], -1 !== this._normalOffset &amp;&amp; (t[E = f + this._normalOffset] = c[T], t[E + 1] = c[T + 1], t[E + 2] = c[T + 2]), -1 !== this._colorOffset &amp;&amp; (E = f + this._colorOffset, T = m + this._colorOffset, t[E] = o[T], t[E + 1] = o[T + 1], t[E + 2] = o[T + 2], t[E + 3] = o[T + 3]), -1 !== this._uv0Offset &amp;&amp; (E = f + this._uv0Offset, T = m + this._uv0Offset, t[E] = o[T], t[E + 1] = o[T + 1]), -1 !== this._sTangentOffset &amp;&amp; (E = f + this._sTangentOffset, T = m + this._sTangentOffset, t[E] = o[T], t[E + 1] = o[T + 1], t[E + 2] = o[T + 2], t[E + 3] = o[T + 3], E = f + this._sTangentOffset, T = m + this._sTangentOffset, t[E] = o[T], t[E + 1] = o[T + 1], t[E + 2] = o[T + 2], t[E + 3] = o[T + 3])
            }
        }
        _getBatchIndices(e, t, r, i, n, a) {
            var s, o, l, _ = n._indices,
                h = i._isFrontFaceInvert;
            if (a)
                if (h)
                    for (s = 0, o = _.length; s &lt; o; s += 3) {
                        var c = r + s;
                        e[l = t + s] = c, e[l + 1] = c + 2, e[l + 2] = c + 1
                    } else
                        for (s = 0, o = _.length; s &lt; o; s += 3) c = r + s, e[l = t + s] = c, e[l + 1] = c + 1, e[l + 2] = c + 2;
                else if (h)
                for (s = 0, o = _.length; s &lt; o; s += 3) e[l = t + s] = r + _[s], e[l + 1] = r + _[s + 2], e[l + 2] = r + _[s + 1];
            else
                for (s = 0, o = _.length; s &lt; o; s += 3) e[l = t + s] = r + _[s], e[l + 1] = r + _[s + 1], e[l + 2] = r + _[s + 2]
        }
        _flush(e, r) {
            var i = t.LayaGL.instance;
            this._vertexBuffer.setData(this._vertices.buffer, 0, 0, e * this._bufferState.vertexDeclaration.vertexStride), this._indexBuffer.setData(this._indices, 0, 0, r), i.drawElements(i.TRIANGLES, r, i.UNSIGNED_SHORT, 0)
        }
        _prepareRender(e) {
            var t = e.renderElement.vertexBatchVertexDeclaration;
            this._bufferState = _.MeshRenderDynamicBatchManager.instance._getBufferState(t), this._positionOffset = t.getVertexElementByUsage(lt.MESH_POSITION0)._offset / 4;
            var r = t.getVertexElementByUsage(lt.MESH_NORMAL0);
            this._normalOffset = r ? r._offset / 4 : -1;
            var i = t.getVertexElementByUsage(lt.MESH_COLOR0);
            this._colorOffset = i ? i._offset / 4 : -1;
            var n = t.getVertexElementByUsage(lt.MESH_TEXTURECOORDINATE0);
            this._uv0Offset = n ? n._offset / 4 : -1;
            var a = t.getVertexElementByUsage(lt.MESH_TEXTURECOORDINATE1);
            this._uv1Offset = a ? a._offset / 4 : -1;
            var s = t.getVertexElementByUsage(lt.MESH_TANGENT0);
            return this._sTangentOffset = s ? s._offset / 4 : -1, !0
        }
        _render(e) {
            this._bufferState.bind();
            for (var r = e.renderElement, i = r.vertexBatchVertexDeclaration, n = r.vertexBatchElementList, a = 0, s = 0, o = (i.vertexStride, 0), l = n.length, _ = n.elements, h = 0; h &lt; l; h++) {
                var c = _[h],
                    d = c._geometry,
                    u = d._indexCount;
                s + u &gt; Ir.maxIndicesCount &amp;&amp; (this._flush(a, s), o++, t.Stat.trianglesFaces += s / 3, a = s = 0);
                var m = c._transform;
                this._getBatchVertices(i, this._vertices, a, m, c, d), this._getBatchIndices(this._indices, s, a, m, d, c._dynamicMultiSubMesh), a += c._dynamicVertexCount, s += u
            }
            this._flush(a, s), o++, t.Stat.renderBatches += o, t.Stat.savedRenderBatches += l - o, t.Stat.trianglesFaces += s / 3
        }
    }
    Ir.maxAllowVertexCount = 10, Ir.maxAllowAttribueCount = 900, Ir.maxIndicesCount = 32e3;
    class xr extends ar {
        constructor() {
            super(), this._instanceBatchOpaqueMarks = [], this._vertexBatchOpaqueMarks = [], this._cacheBufferStates = [], this._updateCountMark = 0
        }
        getInstanceBatchOpaquaMark(e, t, r, i) {
            var n = this._instanceBatchOpaqueMarks[e ? 0 : 1] || (this._instanceBatchOpaqueMarks[e ? 0 : 1] = []),
                a = n[t] || (n[t] = []),
                s = a[r] || (a[r] = []);
            return s[i ? 1 : 0] || (s[i ? 1 : 0] = new Gt)
        }
        getVertexBatchOpaquaMark(e, t, r, i) {
            var n = this._vertexBatchOpaqueMarks[e] || (this._vertexBatchOpaqueMarks[e] = []),
                a = n[t ? 0 : 1] || (n[t ? 0 : 1] = []),
                s = a[r] || (a[r] = []);
            return s[i] || (s[i] = new Gt)
        }
        _getBufferState(e) {
            var t = this._cacheBufferStates[e.id];
            if (!t) {
                var r = Ir.instance;
                (t = new it).bind();
                var i = r._vertexBuffer;
                i.vertexDeclaration = e, t.applyVertexBuffer(i), t.applyIndexBuffer(r._indexBuffer), t.unBind(), this._cacheBufferStates[e.id] = t
            }
            return t
        }
        _getBatchRenderElementFromPool() {
            var e = this._batchRenderElementPool[this._batchRenderElementPoolIndex++];
            return e || (e = new Wt, this._batchRenderElementPool[this._batchRenderElementPoolIndex - 1] = e, e.vertexBatchElementList = new I, e.instanceBatchElementList = new I), e
        }
        _clear() {
            super._clear(), this._updateCountMark++
        }
    }
    xr.instance = new xr;
    class Lr extends Ut {
        constructor(e = null, t = null) {
            super(t), this._meshFilter = new Ar(this), this._render = new vr(this), e &amp;&amp; (this._meshFilter.sharedMesh = e)
        }
        static __init__() {
            Rr.SHADERDEFINE_UV0 = he.getDefineByName("UV"), Rr.SHADERDEFINE_COLOR = he.getDefineByName("COLOR"), Rr.SHADERDEFINE_UV1 = he.getDefineByName("UV1"), Rr.SHADERDEFINE_GPU_INSTANCE = he.getDefineByName("GPU_INSTANCE"), kt._registerManager(Yt.instance), ar._registerManager(xr.instance)
        }
        get meshFilter() {
            return this._meshFilter
        }
        get meshRenderer() {
            return this._render
        }
        _parse(e, r) {
            super._parse(e, r);
            var i = this.meshRenderer,
                a = e.lightmapIndex;
            null != a &amp;&amp; (i.lightmapIndex = a);
            var s = e.lightmapScaleOffset;
            s &amp;&amp; (i.lightmapScaleOffset = new n(s[0], s[1], s[2], s[3])), null != e.meshPath &amp;&amp; (this.meshFilter.sharedMesh = t.Loader.getRes(e.meshPath)), null != e.enableRender &amp;&amp; (i.enable = e.enableRender), null != e.receiveShadows &amp;&amp; (i.receiveShadow = e.receiveShadows), null != e.castShadow &amp;&amp; (i.castShadow = e.castShadow);
            var o = e.materials;
            if (o) {
                var l = i.sharedMaterials,
                    _ = o.length;
                l.length = _;
                for (var h = 0; h &lt; _; h++) l[h] = t.Loader.getRes(o[h].path);
                i.sharedMaterials = l
            }
        }
        _addToInitStaticBatchManager() {
            this.meshFilter.sharedMesh &amp;&amp; Yt.instance._addBatchSprite(this)
        }
        _cloneTo(e, t, r) {
            var i = e;
            i._meshFilter.sharedMesh = this._meshFilter.sharedMesh;
            var n = this._render,
                a = i._render;
            a.enable = n.enable, a.sharedMaterials = n.sharedMaterials, a.castShadow = n.castShadow;
            var s = n.lightmapScaleOffset;
            s &amp;&amp; (a.lightmapScaleOffset = s.clone()), a.lightmapIndex = n.lightmapIndex, a.receiveShadow = n.receiveShadow, a.sortingFudge = n.sortingFudge, super._cloneTo(e, t, r)
        }
        destroy(e = !0) {
            this.destroyed || (super.destroy(e), this._meshFilter.destroy())
        }
        _create() {
            return new Lr
        }
    }
    class Dr {}
    Dr.Blend = 0, Dr.Fixed = 1;
    class Cr {
        constructor(e, t) {
            this._mode = 0, this._maxColorRGBKeysCount = 0, this._maxColorAlphaKeysCount = 0, this._colorRGBKeysCount = 0, this._colorAlphaKeysCount = 0, this._alphaElements = null, this._rgbElements = null, this._maxColorRGBKeysCount = e, this._maxColorAlphaKeysCount = t, this._rgbElements = new Float32Array(4 * e), this._alphaElements = new Float32Array(2 * t)
        }
        get mode() {
            return this._mode
        }
        set mode(e) {
            this._mode = e
        }
        get colorRGBKeysCount() {
            return this._colorRGBKeysCount
        }
        get colorAlphaKeysCount() {
            return this._colorAlphaKeysCount
        }
        get maxColorRGBKeysCount() {
            return this._maxColorRGBKeysCount
        }
        get maxColorAlphaKeysCount() {
            return this._maxColorAlphaKeysCount
        }
        addColorRGB(e, t) {
            if (this._colorRGBKeysCount &lt; this._maxColorRGBKeysCount) {
                var r = 4 * this._colorRGBKeysCount;
                this._rgbElements[r] = e, this._rgbElements[r + 1] = t.r, this._rgbElements[r + 2] = t.g, this._rgbElements[r + 3] = t.b, this._colorRGBKeysCount++
            } else console.warn("Gradient:warning:data count must lessEqual than " + this._maxColorRGBKeysCount)
        }
        addColorAlpha(e, t) {
            if (this._colorAlphaKeysCount &lt; this._maxColorAlphaKeysCount) {
                var r = 2 * this._colorAlphaKeysCount;
                this._alphaElements[r] = e, this._alphaElements[r + 1] = t, this._colorAlphaKeysCount++
            } else console.warn("Gradient:warning:data count must lessEqual than " + this._maxColorAlphaKeysCount)
        }
        updateColorRGB(e, t, r) {
            if (e &lt; this._colorRGBKeysCount) {
                var i = 4 * e;
                this._rgbElements[i] = t, this._rgbElements[i + 1] = r.r, this._rgbElements[i + 2] = r.g, this._rgbElements[i + 3] = r.b
            } else console.warn("Gradient:warning:index must lessEqual than colorRGBKeysCount:" + this._colorRGBKeysCount)
        }
        updateColorAlpha(e, t, r) {
            if (e &lt; this._colorAlphaKeysCount) {
                var i = 2 * e;
                this._alphaElements[i] = t, this._alphaElements[i + 1] = r
            } else console.warn("Gradient:warning:index must lessEqual than colorAlphaKeysCount:" + this._colorAlphaKeysCount)
        }
        evaluateColorRGB(e, t, r = 0, i = !1) {
            e = Math.min(Math.max(e, 0), 1);
            var n = this._rgbElements,
                a = r;
            if (i)
                for (var s = a; s &gt;= 0; s--) {
                    var o = 4 * s;
                    if (e === (u = n[o])) return t.r = n[o + 1], t.g = n[o + 2], t.b = n[o + 3], a;
                    switch (this._mode) {
                        case Dr.Blend:
                            if (e &gt; u) {
                                if (e &gt; (d = n[o + 4])) throw "Gradient:wrong startSearchIndex.";
                                var l = d - u,
                                    _ = d - e,
                                    h = e - u;
                                return t.r = (_ * n[o + 1] + h * n[o + 5]) / l, t.g = (_ * n[o + 2] + h * n[o + 6]) / l, t.b = (_ * n[o + 3] + h * n[o + 7]) / l, a
                            }
                            a--;
                            continue;
                        case Dr.Fixed:
                            if (e &gt; u) {
                                if (e &gt; n[o + 4]) throw "Gradient:wrong startSearchIndex.";
                                return t.r = n[o + 5], t.g = n[o + 6], t.b = n[o + 7], a
                            }
                            a--;
                            continue;
                        default:
                            throw "Gradient:unknown mode."
                    }
                } else {
                    s = 0;
                    for (var c = this._rgbElements.length; s &lt; c; s++) {
                        var d;
                        if (e === (d = n[o = 4 * s])) return t.r = n[o + 1], t.g = n[o + 2], t.b = n[o + 3], a;
                        switch (this._mode) {
                            case Dr.Blend:
                                if (e &lt; d) {
                                    var u;
                                    if (e &lt; (u = n[o - 4])) throw "Gradient:wrong startSearchIndex.";
                                    l = d - u, _ = d - e, h = e - u;
                                    return t.r = (_ * n[o - 3] + h * n[o + 1]) / l, t.g = (_ * n[o - 2] + h * n[o + 2]) / l, t.b = (_ * n[o - 1] + h * n[o + 3]) / l, a
                                }
                                a++;
                                continue;
                            case Dr.Fixed:
                                if (e &lt; d) {
                                    if (e &lt; n[o - 4]) throw "Gradient:wrong startSearchIndex.";
                                    return t.r = n[o + 1], t.g = n[o + 2], t.b = n[o + 3], a
                                }
                                a++;
                                continue;
                            default:
                                throw "Gradient:unknown mode."
                        }
                    }
                }
            return a
        }
        evaluateColorAlpha(e, t, r = 0, i = !1) {
            e = Math.min(Math.max(e, 0), 1);
            var n = this._alphaElements,
                a = r;
            if (i)
                for (var s = a; s &gt;= 0; s--) {
                    if (e === (u = n[c = 2 * s])) return t.a = n[c + 1], a;
                    switch (this._mode) {
                        case Dr.Blend:
                            if (e &gt; u) {
                                if (e &gt; (d = n[c + 2])) throw "Gradient:wrong startSearchIndex.";
                                var o = d - u,
                                    l = d - e,
                                    _ = e - u;
                                return t.a = (l * n[c + 1] + _ * n[c + 3]) / o, a
                            }
                            a--;
                            continue;
                        case Dr.Fixed:
                            if (e &gt; u) {
                                if (e &gt; n[c + 2]) throw "Gradient:wrong startSearchIndex.";
                                return t.a = n[c + 3], a
                            }
                            a--;
                            continue;
                        default:
                            throw "Gradient:unknown mode."
                    }
                } else {
                    s = a;
                    for (var h = this._alphaElements.length; s &lt; h; s++) {
                        var c, d;
                        if (e === (d = n[c = 2 * s])) return t.a = n[c + 1], a;
                        switch (this._mode) {
                            case Dr.Blend:
                                if (e &lt; d) {
                                    var u;
                                    if (e &lt; (u = n[c - 2])) throw "Gradient:wrong startSearchIndex.";
                                    o = d - u, l = d - e, _ = e - u;
                                    return t.a = (l * n[c - 1] + _ * n[c + 1]) / o, a
                                }
                                a++;
                                continue;
                            case Dr.Fixed:
                                if (e &lt; d) {
                                    if (e &lt; n[c - 2]) throw "Gradient:wrong startSearchIndex.";
                                    return t.a = n[c + 1], a
                                }
                                a++;
                                continue;
                            default:
                                throw "Gradient:unknown mode."
                        }
                    }
                }
            return a
        }
        cloneTo(e) {
            var t, r, i = e;
            i._colorAlphaKeysCount = this._colorAlphaKeysCount;
            var n = i._alphaElements;
            for (t = 0, r = this._alphaElements.length; t &lt; r; t++) n[t] = this._alphaElements[t];
            i._colorRGBKeysCount = this._colorRGBKeysCount;
            var a = i._rgbElements;
            for (t = 0, r = this._rgbElements.length; t &lt; r; t++) a[t] = this._rgbElements[t]
        }
        clone() {
            var e = new Cr(this._maxColorRGBKeysCount, this._maxColorAlphaKeysCount);
            return this.cloneTo(e), e
        }
    }
    class yr {
        constructor(e, t, r) {
            this._time = e, this._minCount = t, this._maxCount = r
        }
        get time() {
            return this._time
        }
        get minCount() {
            return this._minCount
        }
        get maxCount() {
            return this._maxCount
        }
        cloneTo(e) {
            var t = e;
            t._time = this._time, t._minCount = this._minCount, t._maxCount = this._maxCount
        }
        clone() {
            var e = new yr(this._time, this._minCount, this._maxCount);
            return this.cloneTo(e), e
        }
    }
    class Mr {
        constructor() {
            this._type = 0, this._constant = null, this._constantMin = null, this._constantMax = null, this._gradient = null, this._gradientMin = null, this._gradientMax = null
        }
        static createByConstant(e) {
            var t = new Mr;
            return t._type = 0, t._constant = e, t
        }
        static createByGradient(e) {
            var t = new Mr;
            return t._type = 1, t._gradient = e, t
        }
        static createByRandomTwoConstant(e, t) {
            var r = new Mr;
            return r._type = 2, r._constantMin = e, r._constantMax = t, r
        }
        static createByRandomTwoGradient(e, t) {
            var r = new Mr;
            return r._type = 3, r._gradientMin = e, r._gradientMax = t, r
        }
        get type() {
            return this._type
        }
        get constant() {
            return this._constant
        }
        get constantMin() {
            return this._constantMin
        }
        get constantMax() {
            return this._constantMax
        }
        get gradient() {
            return this._gradient
        }
        get gradientMin() {
            return this._gradientMin
        }
        get gradientMax() {
            return this._gradientMax
        }
        cloneTo(e) {
            var t = e;
            t._type = this._type, this._constant.cloneTo(t._constant), this._constantMin.cloneTo(t._constantMin), this._constantMax.cloneTo(t._constantMax), this._gradient.cloneTo(t._gradient), this._gradientMin.cloneTo(t._gradientMin), this._gradientMax.cloneTo(t._gradientMax)
        }
        clone() {
            var e = new Mr;
            return this.cloneTo(e), e
        }
    }
    class Or {
        constructor(e) {
            this._color = e
        }
        get color() {
            return this._color
        }
        cloneTo(e) {
            var t = e;
            this._color.cloneTo(t._color), t.enable = this.enable
        }
        clone() {
            var e;
            switch (this._color.type) {
                case 0:
                    e = Mr.createByConstant(this._color.constant.clone());
                    break;
                case 1:
                    e = Mr.createByGradient(this._color.gradient.clone());
                    break;
                case 2:
                    e = Mr.createByRandomTwoConstant(this._color.constantMin.clone(), this._color.constantMax.clone());
                    break;
                case 3:
                    e = Mr.createByRandomTwoGradient(this._color.gradientMin.clone(), this._color.gradientMax.clone())
            }
            var t = new Or(e);
            return t.enable = this.enable, t
        }
    }
    class Nr {
        constructor() {
            this._type = 0, this._constant = 0, this._overTime = null, this._constantMin = 0, this._constantMax = 0, this._overTimeMin = null, this._overTimeMax = null
        }
        static createByConstant(e = 0) {
            var t = new Nr;
            return t._type = 0, t._constant = e, t
        }
        static createByOverTime(e) {
            var t = new Nr;
            return t._type = 1, t._overTime = e, t
        }
        static createByRandomTwoConstant(e = 0, t = 0) {
            var r = new Nr;
            return r._type = 2, r._constantMin = e, r._constantMax = t, r
        }
        static createByRandomTwoOverTime(e, t) {
            var r = new Nr;
            return r._type = 3, r._overTimeMin = e, r._overTimeMax = t, r
        }
        get type() {
            return this._type
        }
        get constant() {
            return this._constant
        }
        get frameOverTimeData() {
            return this._overTime
        }
        get constantMin() {
            return this._constantMin
        }
        get constantMax() {
            return this._constantMax
        }
        get frameOverTimeDataMin() {
            return this._overTimeMin
        }
        get frameOverTimeDataMax() {
            return this._overTimeMax
        }
        cloneTo(e) {
            var t = e;
            t._type = this._type, t._constant = this._constant, this._overTime &amp;&amp; this._overTime.cloneTo(t._overTime), t._constantMin = this._constantMin, t._constantMax = this._constantMax, this._overTimeMin &amp;&amp; this._overTimeMin.cloneTo(t._overTimeMin), this._overTimeMax &amp;&amp; this._overTimeMax.cloneTo(t._overTimeMax)
        }
        clone() {
            var e = new Nr;
            return this.cloneTo(e), e
        }
    }
    class br {
        constructor() {
            this._type = 0, this._separateAxes = !1, this._constant = 0, this._constantSeparate = null, this._gradient = null, this._gradientX = null, this._gradientY = null, this._gradientZ = null, this._gradientW = null, this._constantMin = 0, this._constantMax = 0, this._constantMinSeparate = null, this._constantMaxSeparate = null, this._gradientMin = null, this._gradientMax = null, this._gradientXMin = null, this._gradientXMax = null, this._gradientYMin = null, this._gradientYMax = null, this._gradientZMin = null, this._gradientZMax = null, this._gradientWMin = null, this._gradientWMax = null
        }
        static createByConstant(e) {
            var t = new br;
            return t._type = 0, t._separateAxes = !1, t._constant = e, t
        }
        static createByConstantSeparate(e) {
            var t = new br;
            return t._type = 0, t._separateAxes = !0, t._constantSeparate = e, t
        }
        static createByGradient(e) {
            var t = new br;
            return t._type = 1, t._separateAxes = !1, t._gradient = e, t
        }
        static createByGradientSeparate(e, t, r) {
            var i = new br;
            return i._type = 1, i._separateAxes = !0, i._gradientX = e, i._gradientY = t, i._gradientZ = r, i
        }
        static createByRandomTwoConstant(e, t) {
            var r = new br;
            return r._type = 2, r._separateAxes = !1, r._constantMin = e, r._constantMax = t, r
        }
        static createByRandomTwoConstantSeparate(e, t) {
            var r = new br;
            return r._type = 2, r._separateAxes = !0, r._constantMinSeparate = e, r._constantMaxSeparate = t, r
        }
        static createByRandomTwoGradient(e, t) {
            var r = new br;
            return r._type = 3, r._separateAxes = !1, r._gradientMin = e, r._gradientMax = t, r
        }
        static createByRandomTwoGradientSeparate(e, t, r, i, n, a, s, o) {
            var l = new br;
            return l._type = 3, l._separateAxes = !0, l._gradientXMin = e, l._gradientXMax = t, l._gradientYMin = r, l._gradientYMax = i, l._gradientZMin = n, l._gradientZMax = a, l._gradientWMin = s, l._gradientWMax = o, l
        }
        get type() {
            return this._type
        }
        get separateAxes() {
            return this._separateAxes
        }
        get constant() {
            return this._constant
        }
        get constantSeparate() {
            return this._constantSeparate
        }
        get gradient() {
            return this._gradient
        }
        get gradientX() {
            return this._gradientX
        }
        get gradientY() {
            return this._gradientY
        }
        get gradientZ() {
            return this._gradientZ
        }
        get gradientW() {
            return this._gradientW
        }
        get constantMin() {
            return this._constantMin
        }
        get constantMax() {
            return this._constantMax
        }
        get constantMinSeparate() {
            return this._constantMinSeparate
        }
        get constantMaxSeparate() {
            return this._constantMaxSeparate
        }
        get gradientMin() {
            return this._gradientMin
        }
        get gradientMax() {
            return this._gradientMax
        }
        get gradientXMin() {
            return this._gradientXMin
        }
        get gradientXMax() {
            return this._gradientXMax
        }
        get gradientYMin() {
            return this._gradientYMin
        }
        get gradientYMax() {
            return this._gradientYMax
        }
        get gradientZMin() {
            return this._gradientZMin
        }
        get gradientZMax() {
            return this._gradientZMax
        }
        get gradientWMin() {
            return this._gradientWMin
        }
        get gradientWMax() {
            return this._gradientWMax
        }
        cloneTo(e) {
            var t = e;
            t._type = this._type, t._separateAxes = this._separateAxes, t._constant = this._constant, this._constantSeparate.cloneTo(t._constantSeparate), this._gradient.cloneTo(t._gradient), this._gradientX.cloneTo(t._gradientX), this._gradientY.cloneTo(t._gradientY), this._gradientZ.cloneTo(t._gradientZ), t._constantMin = this._constantMin, t._constantMax = this._constantMax, this._constantMinSeparate.cloneTo(t._constantMinSeparate), this._constantMaxSeparate.cloneTo(t._constantMaxSeparate), this._gradientMin.cloneTo(t._gradientMin), this._gradientMax.cloneTo(t._gradientMax), this._gradientXMin.cloneTo(t._gradientXMin), this._gradientXMax.cloneTo(t._gradientXMax), this._gradientYMin.cloneTo(t._gradientYMin), this._gradientYMax.cloneTo(t._gradientYMax), this._gradientZMin.cloneTo(t._gradientZMin), this._gradientZMax.cloneTo(t._gradientZMax)
        }
        clone() {
            var e = new br;
            return this.cloneTo(e), e
        }
    }
    class Pr {
        constructor() {
            this._currentLength = 0, this._elements = new Float32Array(8)
        }
        get gradientCount() {
            return this._currentLength / 2
        }
        add(e, t) {
            this._currentLength &lt; 8 ? (6 === this._currentLength &amp;&amp; 1 !== e &amp;&amp; (e = 1, console.log("Warning:the forth key is  be force set to 1.")), this._elements[this._currentLength++] = e, this._elements[this._currentLength++] = t) : console.log("Warning:data count must lessEqual than 4")
        }
        cloneTo(e) {
            var t = e;
            t._currentLength = this._currentLength;
            for (var r = t._elements, i = 0, n = this._elements.length; i &lt; n; i++) r[i] = this._elements[i]
        }
        clone() {
            var e = new Pr;
            return this.cloneTo(e), e
        }
    }
    class wr {
        constructor() {
            this._currentLength = 0, this._elements = new Float32Array(8)
        }
        get gradientCount() {
            return this._currentLength / 2
        }
        add(e, t) {
            this._currentLength &lt; 8 ? (6 === this._currentLength &amp;&amp; 1 !== e &amp;&amp; (e = 1, console.log("GradientDataNumber warning:the forth key is  be force set to 1.")), this._elements[this._currentLength++] = e, this._elements[this._currentLength++] = t) : console.log("GradientDataNumber warning:data count must lessEqual than 4")
        }
        getKeyByIndex(e) {
            return this._elements[2 * e]
        }
        getValueByIndex(e) {
            return this._elements[2 * e + 1]
        }
        getAverageValue() {
            for (var e = 0, t = this._currentLength - 2; e &lt; t; e += 2) {
                this._elements[e + 1];
                this._elements[e + 3], this._elements[e + 2] - this._elements[e]
            }
            return 0
        }
        cloneTo(e) {
            var t = e;
            t._currentLength = this._currentLength;
            for (var r = t._elements, i = 0, n = this._elements.length; i &lt; n; i++) r[i] = this._elements[i]
        }
        clone() {
            var e = new wr;
            return this.cloneTo(e), e
        }
    }
    class Vr {
        constructor() {
            this._type = 0, this._separateAxes = !1, this._gradient = null, this._gradientX = null, this._gradientY = null, this._gradientZ = null, this._constantMin = 0, this._constantMax = 0, this._constantMinSeparate = null, this._constantMaxSeparate = null, this._gradientMin = null, this._gradientMax = null, this._gradientXMin = null, this._gradientXMax = null, this._gradientYMin = null, this._gradientYMax = null, this._gradientZMin = null, this._gradientZMax = null
        }
        static createByGradient(e) {
            var t = new Vr;
            return t._type = 0, t._separateAxes = !1, t._gradient = e, t
        }
        static createByGradientSeparate(e, t, r) {
            var i = new Vr;
            return i._type = 0, i._separateAxes = !0, i._gradientX = e, i._gradientY = t, i._gradientZ = r, i
        }
        static createByRandomTwoConstant(e, t) {
            var r = new Vr;
            return r._type = 1, r._separateAxes = !1, r._constantMin = e, r._constantMax = t, r
        }
        static createByRandomTwoConstantSeparate(e, t) {
            var r = new Vr;
            return r._type = 1, r._separateAxes = !0, r._constantMinSeparate = e, r._constantMaxSeparate = t, r
        }
        static createByRandomTwoGradient(e, t) {
            var r = new Vr;
            return r._type = 2, r._separateAxes = !1, r._gradientMin = e, r._gradientMax = t, r
        }
        static createByRandomTwoGradientSeparate(e, t, r, i, n, a) {
            var s = new Vr;
            return s._type = 2, s._separateAxes = !0, s._gradientXMin = e, s._gradientXMax = t, s._gradientYMin = r, s._gradientYMax = i, s._gradientZMin = n, s._gradientZMax = a, s
        }
        get type() {
            return this._type
        }
        get separateAxes() {
            return this._separateAxes
        }
        get gradient() {
            return this._gradient
        }
        get gradientX() {
            return this._gradientX
        }
        get gradientY() {
            return this._gradientY
        }
        get gradientZ() {
            return this._gradientZ
        }
        get constantMin() {
            return this._constantMin
        }
        get constantMax() {
            return this._constantMax
        }
        get constantMinSeparate() {
            return this._constantMinSeparate
        }
        get constantMaxSeparate() {
            return this._constantMaxSeparate
        }
        get gradientMin() {
            return this._gradientMin
        }
        get gradientMax() {
            return this._gradientMax
        }
        get gradientXMin() {
            return this._gradientXMin
        }
        get gradientXMax() {
            return this._gradientXMax
        }
        get gradientYMin() {
            return this._gradientYMin
        }
        get gradientYMax() {
            return this._gradientYMax
        }
        get gradientZMin() {
            return this._gradientZMin
        }
        get gradientZMax() {
            return this._gradientZMax
        }
        getMaxSizeInGradient() {
            var e, t, r = -Number.MAX_VALUE;
            switch (this._type) {
                case 0:
                    if (this._separateAxes) {
                        for (e = 0, t = this._gradientX.gradientCount; e &lt; t; e++) r = Math.max(r, this._gradientX.getValueByIndex(e));
                        for (e = 0, t = this._gradientY.gradientCount; e &lt; t; e++) r = Math.max(r, this._gradientY.getValueByIndex(e))
                    } else
                        for (e = 0, t = this._gradient.gradientCount; e &lt; t; e++) r = Math.max(r, this._gradient.getValueByIndex(e));
                    break;
                case 1:
                    this._separateAxes ? (r = Math.max(this._constantMinSeparate.x, this._constantMaxSeparate.x), r = Math.max(r, this._constantMinSeparate.y), r = Math.max(r, this._constantMaxSeparate.y)) : r = Math.max(this._constantMin, this._constantMax);
                    break;
                case 2:
                    if (this._separateAxes) {
                        for (e = 0, t = this._gradientXMin.gradientCount; e &lt; t; e++) r = Math.max(r, this._gradientXMin.getValueByIndex(e));
                        for (e = 0, t = this._gradientXMax.gradientCount; e &lt; t; e++) r = Math.max(r, this._gradientXMax.getValueByIndex(e));
                        for (e = 0, t = this._gradientYMin.gradientCount; e &lt; t; e++) r = Math.max(r, this._gradientYMin.getValueByIndex(e));
                        for (e = 0, t = this._gradientZMax.gradientCount; e &lt; t; e++) r = Math.max(r, this._gradientZMax.getValueByIndex(e))
                    } else {
                        for (e = 0, t = this._gradientMin.gradientCount; e &lt; t; e++) r = Math.max(r, this._gradientMin.getValueByIndex(e));
                        for (e = 0, t = this._gradientMax.gradientCount; e &lt; t; e++) r = Math.max(r, this._gradientMax.getValueByIndex(e))
                    }
            }
            return r
        }
        cloneTo(e) {
            var t = e;
            t._type = this._type, t._separateAxes = this._separateAxes, this._gradient.cloneTo(t._gradient), this._gradientX.cloneTo(t._gradientX), this._gradientY.cloneTo(t._gradientY), this._gradientZ.cloneTo(t._gradientZ), t._constantMin = this._constantMin, t._constantMax = this._constantMax, this._constantMinSeparate.cloneTo(t._constantMinSeparate), this._constantMaxSeparate.cloneTo(t._constantMaxSeparate), this._gradientMin.cloneTo(t._gradientMin), this._gradientMax.cloneTo(t._gradientMax), this._gradientXMin.cloneTo(t._gradientXMin), this._gradientXMax.cloneTo(t._gradientXMax), this._gradientYMin.cloneTo(t._gradientYMin), this._gradientYMax.cloneTo(t._gradientYMax), this._gradientZMin.cloneTo(t._gradientZMin), this._gradientZMax.cloneTo(t._gradientZMax)
        }
        clone() {
            var e = new Vr;
            return this.cloneTo(e), e
        }
    }
    class Br {
        constructor() {
            this._type = 0, this._constant = null, this._gradientX = null, this._gradientY = null, this._gradientZ = null, this._constantMin = null, this._constantMax = null, this._gradientXMin = null, this._gradientXMax = null, this._gradientYMin = null, this._gradientYMax = null, this._gradientZMin = null, this._gradientZMax = null
        }
        static createByConstant(e) {
            var t = new Br;
            return t._type = 0, t._constant = e, t
        }
        static createByGradient(e, t, r) {
            var i = new Br;
            return i._type = 1, i._gradientX = e, i._gradientY = t, i._gradientZ = r, i
        }
        static createByRandomTwoConstant(e, t) {
            var r = new Br;
            return r._type = 2, r._constantMin = e, r._constantMax = t, r
        }
        static createByRandomTwoGradient(e, t, r, i, n, a) {
            var s = new Br;
            return s._type = 3, s._gradientXMin = e, s._gradientXMax = t, s._gradientYMin = r, s._gradientYMax = i, s._gradientZMin = n, s._gradientZMax = a, s
        }
        get type() {
            return this._type
        }
        get constant() {
            return this._constant
        }
        get gradientX() {
            return this._gradientX
        }
        get gradientY() {
            return this._gradientY
        }
        get gradientZ() {
            return this._gradientZ
        }
        get constantMin() {
            return this._constantMin
        }
        get constantMax() {
            return this._constantMax
        }
        get gradientXMin() {
            return this._gradientXMin
        }
        get gradientXMax() {
            return this._gradientXMax
        }
        get gradientYMin() {
            return this._gradientYMin
        }
        get gradientYMax() {
            return this._gradientYMax
        }
        get gradientZMin() {
            return this._gradientZMin
        }
        get gradientZMax() {
            return this._gradientZMax
        }
        cloneTo(e) {
            var t = e;
            t._type = this._type, this._constant.cloneTo(t._constant), this._gradientX.cloneTo(t._gradientX), this._gradientY.cloneTo(t._gradientY), this._gradientZ.cloneTo(t._gradientZ), this._constantMin.cloneTo(t._constantMin), this._constantMax.cloneTo(t._constantMax), this._gradientXMin.cloneTo(t._gradientXMin), this._gradientXMax.cloneTo(t._gradientXMax), this._gradientYMin.cloneTo(t._gradientYMin), this._gradientYMax.cloneTo(t._gradientYMax), this._gradientZMin.cloneTo(t._gradientZMin), this._gradientZMax.cloneTo(t._gradientZMax)
        }
        clone() {
            var e = new Br;
            return this.cloneTo(e), e
        }
    }
    class Fr {
        constructor(e) {
            this._angularVelocity = e
        }
        get angularVelocity() {
            return this._angularVelocity
        }
        cloneTo(e) {
            var t = e;
            this._angularVelocity.cloneTo(t._angularVelocity), t.enable = this.enable
        }
        clone() {
            var e;
            switch (this._angularVelocity.type) {
                case 0:
                    e = this._angularVelocity.separateAxes ? br.createByConstantSeparate(this._angularVelocity.constantSeparate.clone()) : br.createByConstant(this._angularVelocity.constant);
                    break;
                case 1:
                    e = this._angularVelocity.separateAxes ? br.createByGradientSeparate(this._angularVelocity.gradientX.clone(), this._angularVelocity.gradientY.clone(), this._angularVelocity.gradientZ.clone()) : br.createByGradient(this._angularVelocity.gradient.clone());
                    break;
                case 2:
                    e = this._angularVelocity.separateAxes ? br.createByRandomTwoConstantSeparate(this._angularVelocity.constantMinSeparate.clone(), this._angularVelocity.constantMaxSeparate.clone()) : br.createByRandomTwoConstant(this._angularVelocity.constantMin, this._angularVelocity.constantMax);
                    break;
                case 3:
                    e = this._angularVelocity.separateAxes ? br.createByRandomTwoGradientSeparate(this._angularVelocity.gradientXMin.clone(), this._angularVelocity.gradientYMin.clone(), this._angularVelocity.gradientZMin.clone(), this._angularVelocity.gradientWMin.clone(), this._angularVelocity.gradientXMax.clone(), this._angularVelocity.gradientYMax.clone(), this._angularVelocity.gradientZMax.clone(), this._angularVelocity.gradientWMax.clone()) : br.createByRandomTwoGradient(this._angularVelocity.gradientMin.clone(), this._angularVelocity.gradientMax.clone())
            }
            var t = new Fr(e);
            return t.enable = this.enable, t
        }
    }
    class Ur {
        constructor() {
            this.enable = !0, this.randomDirection = 0
        }
        _getShapeBoundBox(e) {
            throw new Error("BaseShape: must override it.")
        }
        _getSpeedBoundBox(e) {
            throw new Error("BaseShape: must override it.")
        }
        generatePositionAndDirection(e, t, r = null, i = null) {
            throw new Error("BaseShape: must override it.")
        }
        _calculateProceduralBounds(e, t, r) {
            this._getShapeBoundBox(e);
            var i = e.min,
                n = e.max;
            a.multiply(i, t, i), a.multiply(n, t, n);
            var s = new Pt(new a, new a);
            this.randomDirection ? (s.min = new a(-1, -1, -1), s.max = new a(1, 1, 1)) : this._getSpeedBoundBox(s);
            var o = new Pt(new a, new a),
                l = o.min,
                _ = o.max;
            a.scale(s.min, r.y, l), a.scale(s.max, r.y, _), a.add(e.min, l, l), a.add(e.max, _, _), a.min(e.min, l, e.min), a.max(e.max, l, e.max);
            var h = new Pt(new a, new a),
                c = h.min,
                d = h.max;
            a.scale(s.min, r.x, c), a.scale(s.max, r.x, d), a.min(h.min, d, l), a.max(h.min, d, _), a.min(e.min, l, e.min), a.max(e.max, l, e.max)
        }
        cloneTo(e) {
            e.enable = this.enable
        }
        clone() {
            var e = new Ur;
            return this.cloneTo(e), e
        }
    }
    class Gr {
        static _randomPointUnitArcCircle(e, t, r = null) {
            var i;
            i = r ? r.getFloat() * e : Math.random() * e, t.x = Math.cos(i), t.y = Math.sin(i)
        }
        static _randomPointInsideUnitArcCircle(e, t, r = null) {
            var i;
            Gr._randomPointUnitArcCircle(e, t, r), i = r ? Math.pow(r.getFloat(), .5) : Math.pow(Math.random(), .5), t.x = t.x * i, t.y = t.y * i
        }
        static _randomPointUnitCircle(e, t = null) {
            var r;
            r = t ? t.getFloat() * Math.PI * 2 : Math.random() * Math.PI * 2, e.x = Math.cos(r), e.y = Math.sin(r)
        }
        static _randomPointInsideUnitCircle(e, t = null) {
            var r;
            Gr._randomPointUnitCircle(e), r = t ? Math.pow(t.getFloat(), .5) : Math.pow(Math.random(), .5), e.x = e.x * r, e.y = e.y * r
        }
        static _randomPointUnitSphere(e, t = null) {
            var r, i;
            t ? (r = e.z = 2 * t.getFloat() - 1, i = t.getFloat() * Math.PI * 2) : (r = e.z = 2 * Math.random() - 1, i = Math.random() * Math.PI * 2);
            var n = Math.sqrt(1 - r * r);
            e.x = n * Math.cos(i), e.y = n * Math.sin(i)
        }
        static _randomPointInsideUnitSphere(e, t = null) {
            var r;
            Gr._randomPointUnitSphere(e), r = t ? Math.pow(t.getFloat(), 1 / 3) : Math.pow(Math.random(), 1 / 3), e.x = e.x * r, e.y = e.y * r, e.z = e.z * r
        }
        static _randomPointInsideHalfUnitBox(e, t = null) {
            t ? (e.x = t.getFloat() - .5, e.y = t.getFloat() - .5, e.z = t.getFloat() - .5) : (e.x = Math.random() - .5, e.y = Math.random() - .5, e.z = Math.random() - .5)
        }
        constructor() {}
    }
    class zr extends Ur {
        constructor() {
            super(), this.x = 1, this.y = 1, this.z = 1
        }
        _getShapeBoundBox(e) {
            var t = e.min;
            t.x = .5 * -this.x, t.y = .5 * -this.y, t.z = .5 * -this.z;
            var r = e.max;
            r.x = .5 * this.x, r.y = .5 * this.y, r.z = .5 * this.z
        }
        _getSpeedBoundBox(e) {
            var t = e.min;
            t.x = 0, t.y = 0, t.z = 0;
            var r = e.max;
            r.x = 0, r.y = 1, r.z = 0
        }
        generatePositionAndDirection(e, t, r = null, i = null) {
            r ? (r.seed = i[16], Gr._randomPointInsideHalfUnitBox(e, r), i[16] = r.seed) : Gr._randomPointInsideHalfUnitBox(e), e.x = this.x * e.x, e.y = this.y * e.y, e.z = this.z * e.z, this.randomDirection ? r ? (r.seed = i[17], Gr._randomPointUnitSphere(t, r), i[17] = r.seed) : Gr._randomPointUnitSphere(t) : (t.x = 0, t.y = 0, t.z = 1)
        }
        cloneTo(e) {
            super.cloneTo(e);
            var t = e;
            t.x = this.x, t.y = this.y, t.z = this.z, t.randomDirection = this.randomDirection
        }
        clone() {
            var e = new zr;
            return this.cloneTo(e), e
        }
    }
    class Hr extends Ur {
        constructor() {
            super(), this.radius = 1, this.arc = 2 * Math.PI, this.emitFromEdge = !1
        }
        _getShapeBoundBox(e) {
            var t = e.min;
            t.x = t.z = -this.radius, t.y = 0;
            var r = e.max;
            r.x = r.z = this.radius, r.y = 0
        }
        _getSpeedBoundBox(e) {
            var t = e.min;
            t.x = t.y = -1, t.z = 0;
            var r = e.max;
            r.x = r.y = 1, r.z = 0
        }
        generatePositionAndDirection(e, t, r = null, i = null) {
            var n = Hr._tempPositionPoint;
            r ? (r.seed = i[16], this.emitFromEdge ? Gr._randomPointUnitArcCircle(this.arc, Hr._tempPositionPoint, r) : Gr._randomPointInsideUnitArcCircle(this.arc, Hr._tempPositionPoint, r), i[16] = r.seed) : this.emitFromEdge ? Gr._randomPointUnitArcCircle(this.arc, Hr._tempPositionPoint) : Gr._randomPointInsideUnitArcCircle(this.arc, Hr._tempPositionPoint), e.x = -n.x, e.y = n.y, e.z = 0, a.scale(e, this.radius, e), this.randomDirection ? r ? (r.seed = i[17], Gr._randomPointUnitSphere(t, r), i[17] = r.seed) : Gr._randomPointUnitSphere(t) : e.cloneTo(t)
        }
        cloneTo(e) {
            super.cloneTo(e);
            var t = e;
            t.radius = this.radius, t.arc = this.arc, t.emitFromEdge = this.emitFromEdge, t.randomDirection = this.randomDirection
        }
        clone() {
            var e = new Hr;
            return this.cloneTo(e), e
        }
    }
    Hr._tempPositionPoint = new i;
    class Wr extends Ur {
        constructor() {
            super(), this.angle = 25 / 180 * Math.PI, this.radius = 1, this.length = 5, this.emitType = 0
        }
        _getShapeBoundBox(e) {
            const t = this.radius + this.length * Math.sin(this.angle),
                r = this.length * Math.cos(this.angle);
            var i = e.min;
            i.x = i.y = -t, i.z = 0;
            var n = e.max;
            n.x = n.y = t, n.z = r
        }
        _getSpeedBoundBox(e) {
            const t = Math.sin(this.angle);
            var r = e.min;
            r.x = r.y = -t, r.z = 0;
            var i = e.max;
            i.x = i.y = t, i.z = 1
        }
        generatePositionAndDirection(e, t, r = null, i = null) {
            var n, s, o, l = Wr._tempPositionPoint,
                _ = Math.cos(this.angle),
                h = Math.sin(this.angle);
            switch (this.emitType) {
                case 0:
                    r ? (r.seed = i[16], Gr._randomPointInsideUnitCircle(Wr._tempPositionPoint, r), i[16] = r.seed) : Gr._randomPointInsideUnitCircle(Wr._tempPositionPoint), n = l.x, s = l.y, e.x = n * this.radius, e.y = s * this.radius, e.z = 0, this.randomDirection ? (r ? (r.seed = i[17], Gr._randomPointInsideUnitCircle(Wr._tempDirectionPoint, r), i[17] = r.seed) : Gr._randomPointInsideUnitCircle(Wr._tempDirectionPoint), o = Wr._tempDirectionPoint, t.x = o.x * h, t.y = o.y * h) : (t.x = n * h, t.y = s * h), t.z = _;
                    break;
                case 1:
                    r ? (r.seed = i[16], Gr._randomPointUnitCircle(Wr._tempPositionPoint, r), i[16] = r.seed) : Gr._randomPointUnitCircle(Wr._tempPositionPoint), n = l.x, s = l.y, e.x = n * this.radius, e.y = s * this.radius, e.z = 0, this.randomDirection ? (r ? (r.seed = i[17], Gr._randomPointInsideUnitCircle(Wr._tempDirectionPoint, r), i[17] = r.seed) : Gr._randomPointInsideUnitCircle(Wr._tempDirectionPoint), o = Wr._tempDirectionPoint, t.x = o.x * h, t.y = o.y * h) : (t.x = n * h, t.y = s * h), t.z = _;
                    break;
                case 2:
                    r ? (r.seed = i[16], Gr._randomPointInsideUnitCircle(Wr._tempPositionPoint, r)) : Gr._randomPointInsideUnitCircle(Wr._tempPositionPoint), n = l.x, s = l.y, e.x = n * this.radius, e.y = s * this.radius, e.z = 0, t.x = n * h, t.y = s * h, t.z = _, a.normalize(t, t), r ? (a.scale(t, this.length * r.getFloat(), t), i[16] = r.seed) : a.scale(t, this.length * Math.random(), t), a.add(e, t, e), this.randomDirection &amp;&amp; (r ? (r.seed = i[17], Gr._randomPointUnitSphere(t, r), i[17] = r.seed) : Gr._randomPointUnitSphere(t));
                    break;
                case 3:
                    r ? (r.seed = i[16], Gr._randomPointUnitCircle(Wr._tempPositionPoint, r)) : Gr._randomPointUnitCircle(Wr._tempPositionPoint), n = l.x, s = l.y, e.x = n * this.radius, e.y = s * this.radius, e.z = 0, t.x = n * h, t.y = s * h, t.z = _, a.normalize(t, t), r ? (a.scale(t, this.length * r.getFloat(), t), i[16] = r.seed) : a.scale(t, this.length * Math.random(), t), a.add(e, t, e), this.randomDirection &amp;&amp; (r ? (r.seed = i[17], Gr._randomPointUnitSphere(t, r), i[17] = r.seed) : Gr._randomPointUnitSphere(t));
                    break;
                default:
                    throw new Error("ConeShape:emitType is invalid.")
            }
        }
        cloneTo(e) {
            super.cloneTo(e);
            var t = e;
            t.angle = this.angle, t.radius = this.radius, t.length = this.length, t.emitType = this.emitType, t.randomDirection = this.randomDirection
        }
        clone() {
            var e = new Wr;
            return this.cloneTo(e), e
        }
    }
    Wr._tempPositionPoint = new i, Wr._tempDirectionPoint = new i;
    class kr extends Ur {
        constructor() {
            super(), this.radius = 1, this.emitFromShell = !1
        }
        _getShapeBoundBox(e) {
            var t = e.min;
            t.x = t.y = t.z = -this.radius;
            var r = e.max;
            r.x = r.y = this.radius, r.z = 0
        }
        _getSpeedBoundBox(e) {
            var t = e.min;
            t.x = t.y = -1, t.z = 0;
            var r = e.max;
            r.x = r.y = r.z = 1
        }
        generatePositionAndDirection(e, t, r = null, i = null) {
            r ? (r.seed = i[16], this.emitFromShell ? Gr._randomPointUnitSphere(e, r) : Gr._randomPointInsideUnitSphere(e, r), i[16] = r.seed) : this.emitFromShell ? Gr._randomPointUnitSphere(e) : Gr._randomPointInsideUnitSphere(e), a.scale(e, this.radius, e);
            var n = e.z;
            n &lt; 0 &amp;&amp; (e.z = -1 * n), this.randomDirection ? r ? (r.seed = i[17], Gr._randomPointUnitSphere(t, r), i[17] = r.seed) : Gr._randomPointUnitSphere(t) : e.cloneTo(t)
        }
        cloneTo(e) {
            super.cloneTo(e);
            var t = e;
            t.radius = this.radius, t.emitFromShell = this.emitFromShell, t.randomDirection = this.randomDirection
        }
        clone() {
            var e = new kr;
            return this.cloneTo(e), e
        }
    }
    class Xr extends Ur {
        constructor() {
            super(), this.radius = 1, this.emitFromShell = !1
        }
        _getShapeBoundBox(e) {
            var t = e.min;
            t.x = t.y = t.z = -this.radius;
            var r = e.max;
            r.x = r.y = r.z = this.radius
        }
        _getSpeedBoundBox(e) {
            var t = e.min;
            t.x = t.y = t.z = -1;
            var r = e.max;
            r.x = r.y = r.z = 1
        }
        generatePositionAndDirection(e, t, r = null, i = null) {
            r ? (r.seed = i[16], this.emitFromShell ? Gr._randomPointUnitSphere(e, r) : Gr._randomPointInsideUnitSphere(e, r), i[16] = r.seed) : this.emitFromShell ? Gr._randomPointUnitSphere(e) : Gr._randomPointInsideUnitSphere(e), a.scale(e, this.radius, e), this.randomDirection ? r ? (r.seed = i[17], Gr._randomPointUnitSphere(t, r), i[17] = r.seed) : Gr._randomPointUnitSphere(t) : e.cloneTo(t)
        }
        cloneTo(e) {
            super.cloneTo(e);
            var t = e;
            t.radius = this.radius, t.emitFromShell = this.emitFromShell, t.randomDirection = this.randomDirection
        }
        clone() {
            var e = new Xr;
            return this.cloneTo(e), e
        }
    }
    class Yr {
        constructor(e) {
            this._size = e
        }
        get size() {
            return this._size
        }
        cloneTo(e) {
            var t = e;
            this._size.cloneTo(t._size), t.enable = this.enable
        }
        clone() {
            var e;
            switch (this._size.type) {
                case 0:
                    e = this._size.separateAxes ? Vr.createByGradientSeparate(this._size.gradientX.clone(), this._size.gradientY.clone(), this._size.gradientZ.clone()) : Vr.createByGradient(this._size.gradient.clone());
                    break;
                case 1:
                    e = this._size.separateAxes ? Vr.createByRandomTwoConstantSeparate(this._size.constantMinSeparate.clone(), this._size.constantMaxSeparate.clone()) : Vr.createByRandomTwoConstant(this._size.constantMin, this._size.constantMax);
                    break;
                case 2:
                    e = this._size.separateAxes ? Vr.createByRandomTwoGradientSeparate(this._size.gradientXMin.clone(), this._size.gradientYMin.clone(), this._size.gradientZMin.clone(), this._size.gradientXMax.clone(), this._size.gradientYMax.clone(), this._size.gradientZMax.clone()) : Vr.createByRandomTwoGradient(this._size.gradientMin.clone(), this._size.gradientMax.clone())
            }
            var t = new Yr(e);
            return t.enable = this.enable, t
        }
    }
    class jr {
        constructor() {
            this._type = 0, this._constant = 0, this._constantMin = 0, this._constantMax = 0
        }
        static createByConstant(e = 0) {
            var t = new jr;
            return t._type = 0, t._constant = e, t
        }
        static createByRandomTwoConstant(e = 0, t = 0) {
            var r = new jr;
            return r._type = 1, r._constantMin = e, r._constantMax = t, r
        }
        get type() {
            return this._type
        }
        get constant() {
            return this._constant
        }
        get constantMin() {
            return this._constantMin
        }
        get constantMax() {
            return this._constantMax
        }
        cloneTo(e) {
            var t = e;
            t._type = this._type, t._constant = this._constant, t._constantMin = this._constantMin, t._constantMax = this._constantMax
        }
        clone() {
            var e = new jr;
            return this.cloneTo(e), e
        }
    }
    class Zr {
        constructor(e, t) {
            this.type = 0, this.randomRow = !1, this.rowIndex = 0, this.cycles = 0, this.enableUVChannels = 0, this.enable = !1, this.tiles = new i(1, 1), this.type = 0, this.randomRow = !0, this.rowIndex = 0, this.cycles = 1, this.enableUVChannels = 1, this._frame = e, this._startFrame = t
        }
        get frame() {
            return this._frame
        }
        get startFrame() {
            return this._startFrame
        }
        cloneTo(e) {
            var t = e;
            this.tiles.cloneTo(t.tiles), t.type = this.type, t.randomRow = this.randomRow, t.rowIndex = this.rowIndex, t.cycles = this.cycles, t.enableUVChannels = this.enableUVChannels, t.enable = this.enable, this._frame.cloneTo(t._frame), this._startFrame.cloneTo(t._startFrame)
        }
        clone() {
            var e, t;
            switch (this._frame.type) {
                case 0:
                    e = Nr.createByConstant(this._frame.constant);
                    break;
                case 1:
                    e = Nr.createByOverTime(this._frame.frameOverTimeData.clone());
                    break;
                case 2:
                    e = Nr.createByRandomTwoConstant(this._frame.constantMin, this._frame.constantMax);
                    break;
                case 3:
                    e = Nr.createByRandomTwoOverTime(this._frame.frameOverTimeDataMin.clone(), this._frame.frameOverTimeDataMax.clone())
            }
            switch (this._startFrame.type) {
                case 0:
                    t = jr.createByConstant(this._startFrame.constant);
                    break;
                case 1:
                    t = jr.createByRandomTwoConstant(this._startFrame.constantMin, this._startFrame.constantMax)
            }
            var r = new Zr(e, t);
            return this.cloneTo(r), r
        }
    }
    class qr {
        constructor(e) {
            this.enable = !1, this.space = 0, this._velocity = e
        }
        get velocity() {
            return this._velocity
        }
        cloneTo(e) {
            var t = e;
            this._velocity.cloneTo(t._velocity), t.enable = this.enable, t.space = this.space
        }
        clone() {
            var e;
            switch (this._velocity.type) {
                case 0:
                    e = Br.createByConstant(this._velocity.constant.clone());
                    break;
                case 1:
                    e = Br.createByGradient(this._velocity.gradientX.clone(), this._velocity.gradientY.clone(), this._velocity.gradientZ.clone());
                    break;
                case 2:
                    e = Br.createByRandomTwoConstant(this._velocity.constantMin.clone(), this._velocity.constantMax.clone());
                    break;
                case 3:
                    e = Br.createByRandomTwoGradient(this._velocity.gradientXMin.clone(), this._velocity.gradientYMin.clone(), this._velocity.gradientZMin.clone(), this._velocity.gradientXMax.clone(), this._velocity.gradientYMax.clone(), this._velocity.gradientZMax.clone())
            }
            var t = new qr(e);
            return t.enable = this.enable, t.space = this.space, t
        }
    }
    class Qr {}
    Qr.WORLDPOSITION = he.propertyNameToID("u_WorldPosition"), Qr.WORLDROTATION = he.propertyNameToID("u_WorldRotation"), Qr.POSITIONSCALE = he.propertyNameToID("u_PositionScale"), Qr.SIZESCALE = he.propertyNameToID("u_SizeScale"), Qr.SCALINGMODE = he.propertyNameToID("u_ScalingMode"), Qr.GRAVITY = he.propertyNameToID("u_Gravity"), Qr.THREEDSTARTROTATION = he.propertyNameToID("u_ThreeDStartRotation"), Qr.STRETCHEDBILLBOARDLENGTHSCALE = he.propertyNameToID("u_StretchedBillboardLengthScale"), Qr.STRETCHEDBILLBOARDSPEEDSCALE = he.propertyNameToID("u_StretchedBillboardSpeedScale"), Qr.SIMULATIONSPACE = he.propertyNameToID("u_SimulationSpace"), Qr.CURRENTTIME = he.propertyNameToID("u_CurrentTime"), Qr.VOLVELOCITYCONST = he.propertyNameToID("u_VOLVelocityConst"), Qr.VOLVELOCITYGRADIENTX = he.propertyNameToID("u_VOLVelocityGradientX"), Qr.VOLVELOCITYGRADIENTY = he.propertyNameToID("u_VOLVelocityGradientY"), Qr.VOLVELOCITYGRADIENTZ = he.propertyNameToID("u_VOLVelocityGradientZ"), Qr.VOLVELOCITYCONSTMAX = he.propertyNameToID("u_VOLVelocityConstMax"), Qr.VOLVELOCITYGRADIENTXMAX = he.propertyNameToID("u_VOLVelocityGradientMaxX"), Qr.VOLVELOCITYGRADIENTYMAX = he.propertyNameToID("u_VOLVelocityGradientMaxY"), Qr.VOLVELOCITYGRADIENTZMAX = he.propertyNameToID("u_VOLVelocityGradientMaxZ"), Qr.VOLSPACETYPE = he.propertyNameToID("u_VOLSpaceType"), Qr.COLOROVERLIFEGRADIENTALPHAS = he.propertyNameToID("u_ColorOverLifeGradientAlphas"), Qr.COLOROVERLIFEGRADIENTCOLORS = he.propertyNameToID("u_ColorOverLifeGradientColors"), Qr.MAXCOLOROVERLIFEGRADIENTALPHAS = he.propertyNameToID("u_MaxColorOverLifeGradientAlphas"), Qr.MAXCOLOROVERLIFEGRADIENTCOLORS = he.propertyNameToID("u_MaxColorOverLifeGradientColors"), Qr.SOLSIZEGRADIENT = he.propertyNameToID("u_SOLSizeGradient"), Qr.SOLSIZEGRADIENTX = he.propertyNameToID("u_SOLSizeGradientX"), Qr.SOLSIZEGRADIENTY = he.propertyNameToID("u_SOLSizeGradientY"), Qr.SOLSizeGradientZ = he.propertyNameToID("u_SOLSizeGradientZ"), Qr.SOLSizeGradientMax = he.propertyNameToID("u_SOLSizeGradientMax"), Qr.SOLSIZEGRADIENTXMAX = he.propertyNameToID("u_SOLSizeGradientMaxX"), Qr.SOLSIZEGRADIENTYMAX = he.propertyNameToID("u_SOLSizeGradientMaxY"), Qr.SOLSizeGradientZMAX = he.propertyNameToID("u_SOLSizeGradientMaxZ"), Qr.ROLANGULARVELOCITYCONST = he.propertyNameToID("u_ROLAngularVelocityConst"), Qr.ROLANGULARVELOCITYCONSTSEPRARATE = he.propertyNameToID("u_ROLAngularVelocityConstSeprarate"), Qr.ROLANGULARVELOCITYGRADIENT = he.propertyNameToID("u_ROLAngularVelocityGradient"), Qr.ROLANGULARVELOCITYGRADIENTX = he.propertyNameToID("u_ROLAngularVelocityGradientX"), Qr.ROLANGULARVELOCITYGRADIENTY = he.propertyNameToID("u_ROLAngularVelocityGradientY"), Qr.ROLANGULARVELOCITYGRADIENTZ = he.propertyNameToID("u_ROLAngularVelocityGradientZ"), Qr.ROLANGULARVELOCITYCONSTMAX = he.propertyNameToID("u_ROLAngularVelocityConstMax"), Qr.ROLANGULARVELOCITYCONSTMAXSEPRARATE = he.propertyNameToID("u_ROLAngularVelocityConstMaxSeprarate"), Qr.ROLANGULARVELOCITYGRADIENTMAX = he.propertyNameToID("u_ROLAngularVelocityGradientMax"), Qr.ROLANGULARVELOCITYGRADIENTXMAX = he.propertyNameToID("u_ROLAngularVelocityGradientMaxX"), Qr.ROLANGULARVELOCITYGRADIENTYMAX = he.propertyNameToID("u_ROLAngularVelocityGradientMaxY"), Qr.ROLANGULARVELOCITYGRADIENTZMAX = he.propertyNameToID("u_ROLAngularVelocityGradientMaxZ"), Qr.ROLANGULARVELOCITYGRADIENTWMAX = he.propertyNameToID("u_ROLAngularVelocityGradientMaxW"), Qr.TEXTURESHEETANIMATIONCYCLES = he.propertyNameToID("u_TSACycles"), Qr.TEXTURESHEETANIMATIONSUBUVLENGTH = he.propertyNameToID("u_TSASubUVLength"), Qr.TEXTURESHEETANIMATIONGRADIENTUVS = he.propertyNameToID("u_TSAGradientUVs"), Qr.TEXTURESHEETANIMATIONGRADIENTMAXUVS = he.propertyNameToID("u_TSAMaxGradientUVs");
    class Kr extends Te {
        constructor() {
            super(), this.setShaderName("PARTICLESHURIKEN"), this._color = new n(1, 1, 1, 1), this.renderMode = Kr.RENDERMODE_ALPHABLENDED
        }
        static __initDefine__() {
            Kr.SHADERDEFINE_DIFFUSEMAP = he.getDefineByName("DIFFUSEMAP"), Kr.SHADERDEFINE_TINTCOLOR = he.getDefineByName("TINTCOLOR"), Kr.SHADERDEFINE_ADDTIVEFOG = he.getDefineByName("ADDTIVEFOG"), Kr.SHADERDEFINE_TILINGOFFSET = he.getDefineByName("TILINGOFFSET")
        }
        get _TintColor() {
            return this.color
        }
        set _TintColor(e) {
            this.color = e
        }
        get _TintColorR() {
            return this._color.x
        }
        set _TintColorR(e) {
            this._color.x = e, this.color = this._color
        }
        get _TintColorG() {
            return this._color.y
        }
        set _TintColorG(e) {
            this._color.y = e, this.color = this._color
        }
        get _TintColorB() {
            return this._color.z
        }
        set _TintColorB(e) {
            this._color.z = e, this.color = this._color
        }
        get _TintColorA() {
            return this._color.w
        }
        set _TintColorA(e) {
            this._color.w = e, this.color = this._color
        }
        get _MainTex_ST() {
            return this._shaderValues.getVector(Kr.TILINGOFFSET)
        }
        set _MainTex_ST(e) {
            var t = this._shaderValues.getVector(Kr.TILINGOFFSET);
            t.setValue(e.x, e.y, e.z, e.w), this.tilingOffset = t
        }
        get _MainTex_STX() {
            return this._shaderValues.getVector(Kr.TILINGOFFSET).x
        }
        set _MainTex_STX(e) {
            var t = this._shaderValues.getVector(Kr.TILINGOFFSET);
            t.x = e, this.tilingOffset = t
        }
        get _MainTex_STY() {
            return this._shaderValues.getVector(Kr.TILINGOFFSET).y
        }
        set _MainTex_STY(e) {
            var t = this._shaderValues.getVector(Kr.TILINGOFFSET);
            t.y = e, this.tilingOffset = t
        }
        get _MainTex_STZ() {
            return this._shaderValues.getVector(Kr.TILINGOFFSET).z
        }
        set _MainTex_STZ(e) {
            var t = this._shaderValues.getVector(Kr.TILINGOFFSET);
            t.z = e, this.tilingOffset = t
        }
        get _MainTex_STW() {
            return this._shaderValues.getVector(Kr.TILINGOFFSET).w
        }
        set _MainTex_STW(e) {
            var t = this._shaderValues.getVector(Kr.TILINGOFFSET);
            t.w = e, this.tilingOffset = t
        }
        set renderMode(e) {
            switch (e) {
                case Kr.RENDERMODE_ADDTIVE:
                    this.renderQueue = Te.RENDERQUEUE_TRANSPARENT, this.depthWrite = !1, this.cull = pe.CULL_NONE, this.blend = pe.BLEND_ENABLE_ALL, this.blendSrc = pe.BLENDPARAM_SRC_ALPHA, this.blendDst = pe.BLENDPARAM_ONE, this.alphaTest = !1, this._shaderValues.addDefine(Kr.SHADERDEFINE_ADDTIVEFOG);
                    break;
                case Kr.RENDERMODE_ALPHABLENDED:
                    this.renderQueue = Te.RENDERQUEUE_TRANSPARENT, this.depthWrite = !1, this.cull = pe.CULL_NONE, this.blend = pe.BLEND_ENABLE_ALL, this.blendSrc = pe.BLENDPARAM_SRC_ALPHA, this.blendDst = pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA, this.alphaTest = !1, this._shaderValues.removeDefine(Kr.SHADERDEFINE_ADDTIVEFOG);
                    break;
                default:
                    throw new Error("ShurikenParticleMaterial : renderMode value error.")
            }
        }
        get colorR() {
            return this._TintColorR
        }
        set colorR(e) {
            this._TintColorR = e
        }
        get colorG() {
            return this._TintColorG
        }
        set colorG(e) {
            this._TintColorG = e
        }
        get colorB() {
            return this._TintColorB
        }
        set colorB(e) {
            this._TintColorB = e
        }
        get colorA() {
            return this._TintColorA
        }
        set colorA(e) {
            this._TintColorA = e
        }
        get color() {
            return this._shaderValues.getVector(Kr.TINTCOLOR)
        }
        set color(e) {
            e ? this._shaderValues.addDefine(Kr.SHADERDEFINE_TINTCOLOR) : this._shaderValues.removeDefine(Kr.SHADERDEFINE_TINTCOLOR), this._shaderValues.setVector(Kr.TINTCOLOR, e)
        }
        get tilingOffsetX() {
            return this._MainTex_STX
        }
        set tilingOffsetX(e) {
            this._MainTex_STX = e
        }
        get tilingOffsetY() {
            return this._MainTex_STY
        }
        set tilingOffsetY(e) {
            this._MainTex_STY = e
        }
        get tilingOffsetZ() {
            return this._MainTex_STZ
        }
        set tilingOffsetZ(e) {
            this._MainTex_STZ = e
        }
        get tilingOffsetW() {
            return this._MainTex_STW
        }
        set tilingOffsetW(e) {
            this._MainTex_STW = e
        }
        get tilingOffset() {
            return this._shaderValues.getVector(Kr.TILINGOFFSET)
        }
        set tilingOffset(e) {
            e &amp;&amp; (1 != e.x || 1 != e.y || 0 != e.z || 0 != e.w) ? this._shaderValues.addDefine(Kr.SHADERDEFINE_TILINGOFFSET) : this._shaderValues.removeDefine(Kr.SHADERDEFINE_TILINGOFFSET), this._shaderValues.setVector(Kr.TILINGOFFSET, e)
        }
        get texture() {
            return this._shaderValues.getTexture(Kr.DIFFUSETEXTURE)
        }
        set texture(e) {
            e ? this._shaderValues.addDefine(Kr.SHADERDEFINE_DIFFUSEMAP) : this._shaderValues.removeDefine(Kr.SHADERDEFINE_DIFFUSEMAP), this._shaderValues.setTexture(Kr.DIFFUSETEXTURE, e)
        }
        get depthWrite() {
            return this._shaderValues.getBool(Kr.DEPTH_WRITE)
        }
        set depthWrite(e) {
            this._shaderValues.setBool(Kr.DEPTH_WRITE, e)
        }
        get cull() {
            return this._shaderValues.getInt(Kr.CULL)
        }
        set cull(e) {
            this._shaderValues.setInt(Kr.CULL, e)
        }
        get blend() {
            return this._shaderValues.getInt(Kr.BLEND)
        }
        set blend(e) {
            this._shaderValues.setInt(Kr.BLEND, e)
        }
        get blendSrc() {
            return this._shaderValues.getInt(Kr.BLEND_SRC)
        }
        set blendSrc(e) {
            this._shaderValues.setInt(Kr.BLEND_SRC, e)
        }
        get blendDst() {
            return this._shaderValues.getInt(Kr.BLEND_DST)
        }
        set blendDst(e) {
            this._shaderValues.setInt(Kr.BLEND_DST, e)
        }
        get depthTest() {
            return this._shaderValues.getInt(Kr.DEPTH_TEST)
        }
        set depthTest(e) {
            this._shaderValues.setInt(Kr.DEPTH_TEST, e)
        }
        clone() {
            var e = new Kr;
            return this.cloneTo(e), e
        }
    }
    Kr.RENDERMODE_ALPHABLENDED = 0, Kr.RENDERMODE_ADDTIVE = 1, Kr.DIFFUSETEXTURE = he.propertyNameToID("u_texture"), Kr.TINTCOLOR = he.propertyNameToID("u_Tintcolor"), Kr.TILINGOFFSET = he.propertyNameToID("u_TilingOffset"), Kr.CULL = he.propertyNameToID("s_Cull"), Kr.BLEND = he.propertyNameToID("s_Blend"), Kr.BLEND_SRC = he.propertyNameToID("s_BlendSrc"), Kr.BLEND_DST = he.propertyNameToID("s_BlendDst"), Kr.DEPTH_TEST = he.propertyNameToID("s_DepthTest"), Kr.DEPTH_WRITE = he.propertyNameToID("s_DepthWrite");
    class Jr extends jt {
        constructor(e) {
            super(e), this._finalGravity = new a, this._tempRotationMatrix = new c, this._mesh = null, this.stretchedBillboardCameraSpeedScale = 0, this.stretchedBillboardSpeedScale = 0, this.stretchedBillboardLengthScale = 2, this._defaultBoundBox = new Pt(new a, new a), this.renderMode = 0, this._supportOctree = !1
        }
        get renderMode() {
            return this._renderMode
        }
        set renderMode(e) {
            if (this._renderMode !== e) {
                var t = this._shaderValues;
                switch (this._renderMode) {
                    case 0:
                        t.removeDefine(Qr.SHADERDEFINE_RENDERMODE_BILLBOARD);
                        break;
                    case 1:
                        t.removeDefine(Qr.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD);
                        break;
                    case 2:
                        t.removeDefine(Qr.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD);
                        break;
                    case 3:
                        t.removeDefine(Qr.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD);
                        break;
                    case 4:
                        t.removeDefine(Qr.SHADERDEFINE_RENDERMODE_MESH)
                }
                switch (this._renderMode = e, e) {
                    case 0:
                        t.addDefine(Qr.SHADERDEFINE_RENDERMODE_BILLBOARD);
                        break;
                    case 1:
                        t.addDefine(Qr.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD);
                        break;
                    case 2:
                        t.addDefine(Qr.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD);
                        break;
                    case 3:
                        t.addDefine(Qr.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD);
                        break;
                    case 4:
                        t.addDefine(Qr.SHADERDEFINE_RENDERMODE_MESH);
                        break;
                    default:
                        throw new Error("ShurikenParticleRender: unknown renderMode Value.")
                }
                var r = this._owner.particleSystem;
                r &amp;&amp; r._initBufferDatas()
            }
        }
        get mesh() {
            return this._mesh
        }
        set mesh(e) {
            this._mesh !== e &amp;&amp; (this._mesh &amp;&amp; this._mesh._removeReference(), this._mesh = e, e &amp;&amp; e._addReference(), this._owner.particleSystem._initBufferDatas())
        }
        _calculateBoundingBox() {
            if ((e = this._bounds.getMin()).x = -Number.MAX_VALUE, e.y = -Number.MAX_VALUE, e.z = -Number.MAX_VALUE, this._bounds.setMin(e), (r = this._bounds.getMax()).x = Number.MAX_VALUE, r.y = Number.MAX_VALUE, r.z = Number.MAX_VALUE, this._bounds.setMax(r), t.Render.supportWebGLPlusCulling) {
                var e = this._bounds.getMin(),
                    r = this._bounds.getMax(),
                    i = ke._cullingBuffer;
                i[this._cullingBufferIndex + 1] = e.x, i[this._cullingBufferIndex + 2] = e.y, i[this._cullingBufferIndex + 3] = e.z, i[this._cullingBufferIndex + 4] = r.x, i[this._cullingBufferIndex + 5] = r.y, i[this._cullingBufferIndex + 6] = r.z
            }
        }
        _needRender(e, t) {
            return !e || !!e.intersects(this.bounds._getBoundBox()) &amp;&amp; !!this._owner.particleSystem.isAlive
        }
        _renderUpdate(e, t) {
            var r = this._owner.particleSystem,
                i = this._shaderValues,
                n = this._owner.transform;
            switch (r.simulationSpace) {
                case 0:
                    break;
                case 1:
                    i.setVector3(Qr.WORLDPOSITION, n.position), i.setQuaternion(Qr.WORLDROTATION, n.rotation);
                    break;
                default:
                    throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.")
            }
            switch (r.scaleMode) {
                case 0:
                    var s = n.getWorldLossyScale();
                    i.setVector3(Qr.POSITIONSCALE, s), i.setVector3(Qr.SIZESCALE, s);
                    break;
                case 1:
                    var o = n.localScale;
                    i.setVector3(Qr.POSITIONSCALE, o), i.setVector3(Qr.SIZESCALE, o);
                    break;
                case 2:
                    i.setVector3(Qr.POSITIONSCALE, n.getWorldLossyScale()), i.setVector3(Qr.SIZESCALE, a._ONE)
            }
            a.scale(T.gravity, r.gravityModifier, this._finalGravity), i.setVector3(Qr.GRAVITY, this._finalGravity), i.setInt(Qr.SIMULATIONSPACE, r.simulationSpace), i.setBool(Qr.THREEDSTARTROTATION, r.threeDStartRotation), i.setInt(Qr.SCALINGMODE, r.scaleMode), i.setNumber(Qr.STRETCHEDBILLBOARDLENGTHSCALE, this.stretchedBillboardLengthScale), i.setNumber(Qr.STRETCHEDBILLBOARDSPEEDSCALE, this.stretchedBillboardSpeedScale), i.setNumber(Qr.CURRENTTIME, r._currentTime)
        }
        get bounds() {
            return this._boundsChange &amp;&amp; (this._calculateBoundingBox(), this._boundsChange = !1), this._bounds
        }
        _destroy() {
            super._destroy(), this._mesh &amp;&amp; (this._mesh._removeReference(), this._mesh = null)
        }
    }
    class $r {
        constructor() {}
    }
    $r.PARTICLE_CORNERTEXTURECOORDINATE0 = 5, $r.PARTICLE_POSITION0 = 1, $r.PARTICLE_COLOR0 = 2, $r.PARTICLE_TEXTURECOORDINATE0 = 3, $r.PARTICLE_SHAPEPOSITIONSTARTLIFETIME = 4, $r.PARTICLE_DIRECTIONTIME = 0, $r.PARTICLE_STARTCOLOR0 = 6, $r.PARTICLE_ENDCOLOR0 = 7, $r.PARTICLE_STARTSIZE = 8, $r.PARTICLE_STARTROTATION = 9, $r.PARTICLE_STARTSPEED = 10, $r.PARTICLE_RANDOM0 = 11, $r.PARTICLE_RANDOM1 = 12, $r.PARTICLE_SIMULATIONWORLDPOSTION = 13, $r.PARTICLE_SIMULATIONWORLDROTATION = 14;
    class ei extends $r {
        constructor(e, t, r, i, n, a, s, o, l, _, h, c, d, u) {
            super(), this._cornerTextureCoordinate = e, this._positionStartLifeTime = t, this._velocity = r, this._startColor = i, this._startSize = n, this._startRotation0 = a, this._startRotation1 = s, this._startRotation2 = o, this._startLifeTime = l, this._time = _, this._startSpeed = h, this._randoms0 = this.random0, this._randoms1 = this.random1, this._simulationWorldPostion = u
        }
        static get vertexDeclaration() {
            return ei._vertexDeclaration
        }
        static __init__() {
            ei._vertexDeclaration = new st(152, [new ot(0, at.Vector4, $r.PARTICLE_CORNERTEXTURECOORDINATE0), new ot(16, at.Vector4, $r.PARTICLE_SHAPEPOSITIONSTARTLIFETIME), new ot(32, at.Vector4, $r.PARTICLE_DIRECTIONTIME), new ot(48, at.Vector4, $r.PARTICLE_STARTCOLOR0), new ot(64, at.Vector3, $r.PARTICLE_STARTSIZE), new ot(76, at.Vector3, $r.PARTICLE_STARTROTATION), new ot(88, at.Single, $r.PARTICLE_STARTSPEED), new ot(92, at.Vector4, $r.PARTICLE_RANDOM0), new ot(108, at.Vector4, $r.PARTICLE_RANDOM1), new ot(124, at.Vector3, $r.PARTICLE_SIMULATIONWORLDPOSTION), new ot(136, at.Vector4, $r.PARTICLE_SIMULATIONWORLDROTATION)])
        }
        get cornerTextureCoordinate() {
            return this._cornerTextureCoordinate
        }
        get positionStartLifeTime() {
            return this._positionStartLifeTime
        }
        get velocity() {
            return this._velocity
        }
        get startColor() {
            return this._startColor
        }
        get startSize() {
            return this._startSize
        }
        get startRotation0() {
            return this._startRotation0
        }
        get startRotation1() {
            return this._startRotation1
        }
        get startRotation2() {
            return this._startRotation2
        }
        get startLifeTime() {
            return this._startLifeTime
        }
        get time() {
            return this._time
        }
        get startSpeed() {
            return this._startSpeed
        }
        get random0() {
            return this._randoms0
        }
        get random1() {
            return this._randoms1
        }
        get simulationWorldPostion() {
            return this._simulationWorldPostion
        }
    }
    class ti extends $r {
        constructor(e, t, r, i, n, a, s, o, l, _, h, c, d, u) {
            super(), this._cornerTextureCoordinate = e, this._positionStartLifeTime = t, this._velocity = r, this._startColor = i, this._startSize = n, this._startRotation0 = a, this._startRotation1 = s, this._startRotation2 = o, this._startLifeTime = l, this._time = _, this._startSpeed = h, this._randoms0 = this.random0, this._randoms1 = this.random1, this._simulationWorldPostion = u
        }
        static __init__() {
            ti._vertexDeclaration = new st(172, [new ot(0, at.Vector3, $r.PARTICLE_POSITION0), new ot(12, at.Vector4, $r.PARTICLE_COLOR0), new ot(28, at.Vector2, $r.PARTICLE_TEXTURECOORDINATE0), new ot(36, at.Vector4, $r.PARTICLE_SHAPEPOSITIONSTARTLIFETIME), new ot(52, at.Vector4, $r.PARTICLE_DIRECTIONTIME), new ot(68, at.Vector4, $r.PARTICLE_STARTCOLOR0), new ot(84, at.Vector3, $r.PARTICLE_STARTSIZE), new ot(96, at.Vector3, $r.PARTICLE_STARTROTATION), new ot(108, at.Single, $r.PARTICLE_STARTSPEED), new ot(112, at.Vector4, $r.PARTICLE_RANDOM0), new ot(128, at.Vector4, $r.PARTICLE_RANDOM1), new ot(144, at.Vector3, $r.PARTICLE_SIMULATIONWORLDPOSTION), new ot(156, at.Vector4, $r.PARTICLE_SIMULATIONWORLDROTATION)])
        }
        static get vertexDeclaration() {
            return ti._vertexDeclaration
        }
        get cornerTextureCoordinate() {
            return this._cornerTextureCoordinate
        }
        get position() {
            return this._positionStartLifeTime
        }
        get velocity() {
            return this._velocity
        }
        get startColor() {
            return this._startColor
        }
        get startSize() {
            return this._startSize
        }
        get startRotation0() {
            return this._startRotation0
        }
        get startRotation1() {
            return this._startRotation1
        }
        get startRotation2() {
            return this._startRotation2
        }
        get startLifeTime() {
            return this._startLifeTime
        }
        get time() {
            return this._time
        }
        get startSpeed() {
            return this._startSpeed
        }
        get random0() {
            return this._randoms0
        }
        get random1() {
            return this._randoms1
        }
        get simulationWorldPostion() {
            return this._simulationWorldPostion
        }
    }
    class ri {
        constructor(e) {
            this._temp = new Uint32Array(1), this.seeds = new Uint32Array(4), this.seeds[0] = e, this.seeds[1] = 1812433253 * this.seeds[0] + 1, this.seeds[2] = 1812433253 * this.seeds[1] + 1, this.seeds[3] = 1812433253 * this.seeds[2] + 1
        }
        static getFloatFromInt(e) {
            return 1 / 8388607 * (8388607 &amp; e)
        }
        static getByteFromInt(e) {
            return (8388607 &amp; e) &gt;&gt;&gt; 15
        }
        get seed() {
            return this.seeds[0]
        }
        set seed(e) {
            this.seeds[0] = e, this.seeds[1] = 1812433253 * this.seeds[0] + 1, this.seeds[2] = 1812433253 * this.seeds[1] + 1, this.seeds[3] = 1812433253 * this.seeds[2] + 1
        }
        getUint() {
            return this._temp[0] = this.seeds[0] ^ this.seeds[0] &lt;&lt; 11, this.seeds[0] = this.seeds[1], this.seeds[1] = this.seeds[2], this.seeds[2] = this.seeds[3], this.seeds[3] = this.seeds[3] ^ this.seeds[3] &gt;&gt;&gt; 19 ^ this._temp[0] ^ this._temp[0] &gt;&gt;&gt; 8, this.seeds[3]
        }
        getFloat() {
            return this.getUint(), (8388607 &amp; this.seeds[3]) * (1 / 8388607)
        }
        getSignedFloat() {
            return 2 * this.getFloat() - 1
        }
    }
    class ii {
        constructor() {
            this._emissionRate = 10, this._destroyed = !1, this._bursts = []
        }
        set emissionRate(e) {
            if (e &lt; 0) throw new Error("ParticleBaseShape:emissionRate value must large or equal than 0.");
            this._emissionRate = e
        }
        get emissionRate() {
            return this._emissionRate
        }
        get destroyed() {
            return this._destroyed
        }
        destroy() {
            this._bursts = null, this._destroyed = !0
        }
        getBurstsCount() {
            return this._bursts.length
        }
        getBurstByIndex(e) {
            return this._bursts[e]
        }
        addBurst(e) {
            var t = this._bursts.length;
            if (t &gt; 0)
                for (var r = 0; r &lt; t; r++) this._bursts[r].time &gt; e.time &amp;&amp; this._bursts.splice(r, 0, e);
            this._bursts.push(e)
        }
        removeBurst(e) {
            var t = this._bursts.indexOf(e); - 1 !== t &amp;&amp; this._bursts.splice(t, 1)
        }
        removeBurstByIndex(e) {
            this._bursts.splice(e, 1)
        }
        clearBurst() {
            this._bursts.length = 0
        }
        cloneTo(e) {
            var t = e,
                r = t._bursts;
            r.length = this._bursts.length;
            for (var i = 0, n = this._bursts.length; i &lt; n; i++) {
                var a = r[i];
                a ? this._bursts[i].cloneTo(a) : r[i] = this._bursts[i].clone()
            }
            t._emissionRate = this._emissionRate, t.enable = this.enable
        }
        clone() {
            var e = new ii;
            return this.cloneTo(e), e
        }
    }
    class ni {
        constructor() {}
        static _getStartLifetimeFromGradient(e, r) {
            for (var i = 1, n = e.gradientCount; i &lt; n; i++) {
                var a = e.getKeyByIndex(i);
                if (a &gt;= r) {
                    var s = e.getKeyByIndex(i - 1),
                        o = (r - s) / (a - s);
                    return t.MathUtil.lerp(e.getValueByIndex(i - 1), e.getValueByIndex(i), o)
                }
            }
            throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.")
        }
        static _randomInvertRoationArray(e, t, r, i, n) {
            var a;
            i ? (i.seed = n[6], a = i.getFloat(), n[6] = i.seed) : a = Math.random(), a &lt; r ? (t.x = -e.x, t.y = -e.y, t.z = -e.z) : (t.x = e.x, t.y = e.y, t.z = e.z)
        }
        static _randomInvertRoation(e, t, r, i) {
            var n;
            return r ? (r.seed = i[6], n = r.getFloat(), i[6] = r.seed) : n = Math.random(), n &lt; t &amp;&amp; (e = -e), e
        }
        static create(e, r, i) {
            var a = e.autoRandomSeed,
                s = e._rand,
                o = e._randomSeeds;
            switch (e.startColorType) {
                case 0:
                    var l = e.startColorConstant;
                    ni.startColor.x = l.x, ni.startColor.y = l.y, ni.startColor.z = l.z, ni.startColor.w = l.w;
                    break;
                case 2:
                    a ? n.lerp(e.startColorConstantMin, e.startColorConstantMax, Math.random(), ni.startColor) : (s.seed = o[3], n.lerp(e.startColorConstantMin, e.startColorConstantMax, s.getFloat(), ni.startColor), o[3] = s.seed)
            }
            var _ = e.colorOverLifetime;
            if (_ &amp;&amp; _.enable) {
                var h = _.color;
                switch (h.type) {
                    case 0:
                        ni.startColor.x = ni.startColor.x * h.constant.x, ni.startColor.y = ni.startColor.y * h.constant.y, ni.startColor.z = ni.startColor.z * h.constant.z, ni.startColor.w = ni.startColor.w * h.constant.w;
                        break;
                    case 2:
                        var c;
                        a ? c = Math.random() : (s.seed = o[10], c = s.getFloat(), o[10] = s.seed);
                        var d = h.constantMin,
                            u = h.constantMax;
                        ni.startColor.x = ni.startColor.x * t.MathUtil.lerp(d.x, u.x, c), ni.startColor.y = ni.startColor.y * t.MathUtil.lerp(d.y, u.y, c), ni.startColor.z = ni.startColor.z * t.MathUtil.lerp(d.z, u.z, c), ni.startColor.w = ni.startColor.w * t.MathUtil.lerp(d.w, u.w, c)
                }
            }
            var m = ni.startSize;
            switch (e.startSizeType) {
                case 0:
                    if (e.threeDStartSize) {
                        var f = e.startSizeConstantSeparate;
                        m[0] = f.x, m[1] = f.y, m[2] = f.z
                    } else m[0] = m[1] = m[2] = e.startSizeConstant;
                    break;
                case 2:
                    if (e.threeDStartSize) {
                        var T = e.startSizeConstantMinSeparate,
                            E = e.startSizeConstantMaxSeparate;
                        a ? (m[0] = t.MathUtil.lerp(T.x, E.x, Math.random()), m[1] = t.MathUtil.lerp(T.y, E.y, Math.random()), m[2] = t.MathUtil.lerp(T.z, E.z, Math.random())) : (s.seed = o[4], m[0] = t.MathUtil.lerp(T.x, E.x, s.getFloat()), m[1] = t.MathUtil.lerp(T.y, E.y, s.getFloat()), m[2] = t.MathUtil.lerp(T.z, E.z, s.getFloat()), o[4] = s.seed)
                    } else a ? m[0] = m[1] = m[2] = t.MathUtil.lerp(e.startSizeConstantMin, e.startSizeConstantMax, Math.random()) : (s.seed = o[4], m[0] = m[1] = m[2] = t.MathUtil.lerp(e.startSizeConstantMin, e.startSizeConstantMax, s.getFloat()), o[4] = s.seed)
            }
            var p = e.sizeOverLifetime;
            if (p &amp;&amp; p.enable &amp;&amp; 1 === p.size.type) {
                var g, S = p.size;
                if (S.separateAxes) a ? (m[0] = m[0] * t.MathUtil.lerp(S.constantMinSeparate.x, S.constantMaxSeparate.x, Math.random()), m[1] = m[1] * t.MathUtil.lerp(S.constantMinSeparate.y, S.constantMaxSeparate.y, Math.random()), m[2] = m[2] * t.MathUtil.lerp(S.constantMinSeparate.z, S.constantMaxSeparate.z, Math.random())) : (s.seed = o[11], m[0] = m[0] * t.MathUtil.lerp(S.constantMinSeparate.x, S.constantMaxSeparate.x, s.getFloat()), m[1] = m[1] * t.MathUtil.lerp(S.constantMinSeparate.y, S.constantMaxSeparate.y, s.getFloat()), m[2] = m[2] * t.MathUtil.lerp(S.constantMinSeparate.z, S.constantMaxSeparate.z, s.getFloat()), o[11] = s.seed);
                else a ? g = t.MathUtil.lerp(S.constantMin, S.constantMax, Math.random()) : (s.seed = o[11], g = t.MathUtil.lerp(S.constantMin, S.constantMax, s.getFloat()), o[11] = s.seed), m[0] = m[0] * g, m[1] = m[1] * g, m[2] = m[2] * g
            }
            var R = r.renderMode;
            if (1 !== R) switch (e.startRotationType) {
                case 0:
                    if (e.threeDStartRotation) {
                        var v = e.startRotationConstantSeparate,
                            A = ni._tempVector30;
                        ni._randomInvertRoationArray(v, A, e.randomizeRotationDirection, a ? null : s, o), ni.startRotation[0] = A.x, ni.startRotation[1] = A.y, ni.startRotation[2] = 4 !== R ? -A.z : A.z
                    } else ni.startRotation[0] = ni._randomInvertRoation(e.startRotationConstant, e.randomizeRotationDirection, a ? null : s, o), ni.startRotation[1] = 0, ni.startRotation[2] = 0;
                    break;
                case 2:
                    if (e.threeDStartRotation) {
                        var I = e.startRotationConstantMinSeparate,
                            x = e.startRotationConstantMaxSeparate,
                            L = ni._tempVector30;
                        a ? (L.x = t.MathUtil.lerp(I.x, x.x, Math.random()), L.y = t.MathUtil.lerp(I.y, x.y, Math.random()), L.z = t.MathUtil.lerp(I.z, x.z, Math.random())) : (s.seed = o[5], L.x = t.MathUtil.lerp(I.x, x.x, s.getFloat()), L.y = t.MathUtil.lerp(I.y, x.y, s.getFloat()), L.z = t.MathUtil.lerp(I.z, x.z, s.getFloat()), o[5] = s.seed), ni._randomInvertRoationArray(L, L, e.randomizeRotationDirection, a ? null : s, o), ni.startRotation[0] = L.x, ni.startRotation[1] = L.y, ni.startRotation[2] = 4 !== R ? -L.z : L.z
                    } else a ? ni.startRotation[0] = ni._randomInvertRoation(t.MathUtil.lerp(e.startRotationConstantMin, e.startRotationConstantMax, Math.random()), e.randomizeRotationDirection, a ? null : s, o) : (s.seed = o[5], ni.startRotation[0] = ni._randomInvertRoation(t.MathUtil.lerp(e.startRotationConstantMin, e.startRotationConstantMax, s.getFloat()), e.randomizeRotationDirection, a ? null : s, o), o[5] = s.seed)
            }
            switch (e.startLifetimeType) {
                case 0:
                    ni.startLifeTime = e.startLifetimeConstant;
                    break;
                case 1:
                    ni.startLifeTime = ni._getStartLifetimeFromGradient(e.startLifeTimeGradient, e.emissionTime);
                    break;
                case 2:
                    a ? ni.startLifeTime = t.MathUtil.lerp(e.startLifetimeConstantMin, e.startLifetimeConstantMax, Math.random()) : (s.seed = o[7], ni.startLifeTime = t.MathUtil.lerp(e.startLifetimeConstantMin, e.startLifetimeConstantMax, s.getFloat()), o[7] = s.seed);
                    break;
                case 3:
                    var D = e.emissionTime;
                    a ? ni.startLifeTime = t.MathUtil.lerp(ni._getStartLifetimeFromGradient(e.startLifeTimeGradientMin, D), ni._getStartLifetimeFromGradient(e.startLifeTimeGradientMax, D), Math.random()) : (s.seed = o[7], ni.startLifeTime = t.MathUtil.lerp(ni._getStartLifetimeFromGradient(e.startLifeTimeGradientMin, D), ni._getStartLifetimeFromGradient(e.startLifeTimeGradientMax, D), s.getFloat()), o[7] = s.seed)
            }
            var C = e.textureSheetAnimation;
            if (C &amp;&amp; C.enable) {
                var y, M = C.tiles,
                    O = M.x,
                    N = M.y,
                    b = 1 / O,
                    P = 1 / N,
                    w = C.startFrame;
                switch (w.type) {
                    case 0:
                        y = w.constant;
                        break;
                    case 1:
                        a ? y = t.MathUtil.lerp(w.constantMin, w.constantMax, Math.random()) : (s.seed = o[14], y = t.MathUtil.lerp(w.constantMin, w.constantMax, s.getFloat()), o[14] = s.seed)
                }
                var V = C.frame,
                    B = C.cycles;
                switch (V.type) {
                    case 0:
                        y += V.constant * B;
                        break;
                    case 2:
                        a ? y += t.MathUtil.lerp(V.constantMin, V.constantMax, Math.random()) * B : (s.seed = o[15], y += t.MathUtil.lerp(V.constantMin, V.constantMax, s.getFloat()) * B, o[15] = s.seed)
                }
                var F = 0;
                switch (C.type) {
                    case 0:
                        F = Math.floor(y / O);
                        break;
                    case 1:
                        C.randomRow ? a ? F = Math.floor(Math.random() * N) : (s.seed = o[13], F = Math.floor(s.getFloat() * N), o[13] = s.seed) : F = C.rowIndex
                }
                var U = Math.floor(y % O);
                ni.startUVInfo = ni.startUVInfo, ni.startUVInfo[0] = b, ni.startUVInfo[1] = P, ni.startUVInfo[2] = U * b, ni.startUVInfo[3] = F * P
            } else ni.startUVInfo = ni.startUVInfo, ni.startUVInfo[0] = 1, ni.startUVInfo[1] = 1, ni.startUVInfo[2] = 0, ni.startUVInfo[3] = 0
        }
    }
    ni._tempVector30 = new a, ni.startColor = new n, ni.startSize = new Float32Array(3), ni.startRotation = new Float32Array(3), ni.startUVInfo = new Float32Array(4);
    class ai extends Vt {
        constructor(e) {
            super(), this._boundingSphere = null, this._boundingBox = null, this._boundingBoxCorners = null, this._owner = null, this._ownerRender = null, this._vertices = null, this._floatCountPerVertex = 0, this._startLifeTimeIndex = 0, this._timeIndex = 0, this._simulateUpdate = !1, this._firstActiveElement = 0, this._firstNewElement = 0, this._firstFreeElement = 0, this._firstRetiredElement = 0, this._drawCounter = 0, this._bufferMaxParticles = 0, this._emission = null, this._shape = null, this._isEmitting = !1, this._isPlaying = !1, this._isPaused = !1, this._playStartDelay = 0, this._frameRateTime = 0, this._emissionTime = 0, this._totalDelayTime = 0, this._burstsIndex = 0, this._velocityOverLifetime = null, this._colorOverLifetime = null, this._sizeOverLifetime = null, this._rotationOverLifetime = null, this._textureSheetAnimation = null, this._startLifetimeType = 0, this._startLifetimeConstant = 0, this._startLifeTimeGradient = null, this._startLifetimeConstantMin = 0, this._startLifetimeConstantMax = 0, this._startLifeTimeGradientMin = null, this._startLifeTimeGradientMax = null, this._maxStartLifetime = 0, this._uvLength = new i, this._vertexStride = 0, this._indexStride = 0, this._vertexBuffer = null, this._indexBuffer = null, this._bufferState = new it, this._currentTime = 0, this._startUpdateLoopCount = 0, this._rand = null, this._randomSeeds = null, this.duration = 0, this.looping = !1, this.prewarm = !1, this.startDelayType = 0, this.startDelay = 0, this.startDelayMin = 0, this.startDelayMax = 0, this.startSpeedType = 0, this.startSpeedConstant = 0, this.startSpeedConstantMin = 0, this.startSpeedConstantMax = 0, this.threeDStartSize = !1, this.startSizeType = 0, this.startSizeConstant = 0, this.startSizeConstantSeparate = null, this.startSizeConstantMin = 0, this.startSizeConstantMax = 0, this.startSizeConstantMinSeparate = null, this.startSizeConstantMaxSeparate = null, this.threeDStartRotation = !1, this.startRotationType = 0, this.startRotationConstant = 0, this.startRotationConstantSeparate = null, this.startRotationConstantMin = 0, this.startRotationConstantMax = 0, this.startRotationConstantMinSeparate = null, this.startRotationConstantMaxSeparate = null, this.randomizeRotationDirection = 0, this.startColorType = 0, this.startColorConstant = new n(1, 1, 1, 1), this.startColorConstantMin = new n(0, 0, 0, 0), this.startColorConstantMax = new n(1, 1, 1, 1), this.gravityModifier = 0, this.simulationSpace = 0, this.simulationSpeed = 1, this.scaleMode = 1, this.playOnAwake = !1, this.randomSeed = null, this.autoRandomSeed = !1, this.isPerformanceMode = !1, this._firstActiveElement = 0, this._firstNewElement = 0, this._firstFreeElement = 0, this._firstRetiredElement = 0, this._owner = e, this._ownerRender = e.particleRenderer, this._boundingBoxCorners = [], this._boundingSphere = new tr(new a, Number.MAX_VALUE), this._boundingBox = new Pt(new a(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), new a(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE)), this._currentTime = 0, this._isEmitting = !1, this._isPlaying = !1, this._isPaused = !1, this._burstsIndex = 0, this._frameRateTime = 0, this._emissionTime = 0, this._totalDelayTime = 0, this._simulateUpdate = !1, this._bufferMaxParticles = 1, this.duration = 5, this.looping = !0, this.prewarm = !1, this.startDelayType = 0, this.startDelay = 0, this.startDelayMin = 0, this.startDelayMax = 0, this._startLifetimeType = 0, this._startLifetimeConstant = 5, this._startLifeTimeGradient = new wr, this._startLifetimeConstantMin = 0, this._startLifetimeConstantMax = 5, this._startLifeTimeGradientMin = new wr, this._startLifeTimeGradientMax = new wr, this._maxStartLifetime = 5, this.startSpeedType = 0, this.startSpeedConstant = 5, this.startSpeedConstantMin = 0, this.startSpeedConstantMax = 5, this.threeDStartSize = !1, this.startSizeType = 0, this.startSizeConstant = 1, this.startSizeConstantSeparate = new a(1, 1, 1), this.startSizeConstantMin = 0, this.startSizeConstantMax = 1, this.startSizeConstantMinSeparate = new a(0, 0, 0), this.startSizeConstantMaxSeparate = new a(1, 1, 1), this.threeDStartRotation = !1, this.startRotationType = 0, this.startRotationConstant = 0, this.startRotationConstantSeparate = new a(0, 0, 0), this.startRotationConstantMin = 0, this.startRotationConstantMax = 0, this.startRotationConstantMinSeparate = new a(0, 0, 0), this.startRotationConstantMaxSeparate = new a(0, 0, 0), this.gravityModifier = 0, this.simulationSpace = 1, this.scaleMode = 1, this.playOnAwake = !0, this._rand = new ri(0), this.autoRandomSeed = !0, this.randomSeed = new Uint32Array(1), this._randomSeeds = new Uint32Array(ai._RANDOMOFFSET.length), this.isPerformanceMode = !0, this._emission = new ii, this._emission.enable = !0
        }
        get maxParticles() {
            return this._bufferMaxParticles - 1
        }
        set maxParticles(e) {
            var t = e + 1;
            t !== this._bufferMaxParticles &amp;&amp; (this._bufferMaxParticles = t, this._initBufferDatas())
        }
        get emission() {
            return this._emission
        }
        get aliveParticleCount() {
            return this._firstNewElement &gt;= this._firstRetiredElement ? this._firstNewElement - this._firstRetiredElement : this._bufferMaxParticles - this._firstRetiredElement + this._firstNewElement
        }
        get emissionTime() {
            return this._emissionTime &gt; this.duration ? this.duration : this._emissionTime
        }
        get shape() {
            return this._shape
        }
        set shape(e) {
            this._shape !== e &amp;&amp; (e &amp;&amp; e.enable ? this._owner._render._shaderValues.addDefine(Qr.SHADERDEFINE_SHAPE) : this._owner._render._shaderValues.removeDefine(Qr.SHADERDEFINE_SHAPE), this._shape = e)
        }
        get isAlive() {
            return !!(this._isPlaying || this.aliveParticleCount &gt; 0)
        }
        get isEmitting() {
            return this._isEmitting
        }
        get isPlaying() {
            return this._isPlaying
        }
        get isPaused() {
            return this._isPaused
        }
        get startLifetimeType() {
            return this._startLifetimeType
        }
        set startLifetimeType(e) {
            var t, r;
            switch (this.startLifetimeType) {
                case 0:
                    this._maxStartLifetime = this.startLifetimeConstant;
                    break;
                case 1:
                    this._maxStartLifetime = -Number.MAX_VALUE;
                    var i = i;
                    for (t = 0, r = i.gradientCount; t &lt; r; t++) this._maxStartLifetime = Math.max(this._maxStartLifetime, i.getValueByIndex(t));
                    break;
                case 2:
                    this._maxStartLifetime = Math.max(this.startLifetimeConstantMin, this.startLifetimeConstantMax);
                    break;
                case 3:
                    this._maxStartLifetime = -Number.MAX_VALUE;
                    var n = n;
                    for (t = 0, r = n.gradientCount; t &lt; r; t++) this._maxStartLifetime = Math.max(this._maxStartLifetime, n.getValueByIndex(t));
                    var a = a;
                    for (t = 0, r = a.gradientCount; t &lt; r; t++) this._maxStartLifetime = Math.max(this._maxStartLifetime, a.getValueByIndex(t))
            }
            this._startLifetimeType = e
        }
        get startLifetimeConstant() {
            return this._startLifetimeConstant
        }
        set startLifetimeConstant(e) {
            0 === this._startLifetimeType &amp;&amp; (this._maxStartLifetime = e), this._startLifetimeConstant = e
        }
        get startLifeTimeGradient() {
            return this._startLifeTimeGradient
        }
        set startLifeTimeGradient(e) {
            if (1 === this._startLifetimeType) {
                this._maxStartLifetime = -Number.MAX_VALUE;
                for (var t = 0, r = e.gradientCount; t &lt; r; t++) this._maxStartLifetime = Math.max(this._maxStartLifetime, e.getValueByIndex(t))
            }
            this._startLifeTimeGradient = e
        }
        get startLifetimeConstantMin() {
            return this._startLifetimeConstantMin
        }
        set startLifetimeConstantMin(e) {
            2 === this._startLifetimeType &amp;&amp; (this._maxStartLifetime = Math.max(e, this._startLifetimeConstantMax)), this._startLifetimeConstantMin = e
        }
        get startLifetimeConstantMax() {
            return this._startLifetimeConstantMax
        }
        set startLifetimeConstantMax(e) {
            2 === this._startLifetimeType &amp;&amp; (this._maxStartLifetime = Math.max(this._startLifetimeConstantMin, e)), this._startLifetimeConstantMax = e
        }
        get startLifeTimeGradientMin() {
            return this._startLifeTimeGradientMin
        }
        set startLifeTimeGradientMin(e) {
            if (3 === this._startLifetimeType) {
                var t, r;
                for (this._maxStartLifetime = -Number.MAX_VALUE, t = 0, r = e.gradientCount; t &lt; r; t++) this._maxStartLifetime = Math.max(this._maxStartLifetime, e.getValueByIndex(t));
                for (t = 0, r = this._startLifeTimeGradientMax.gradientCount; t &lt; r; t++) this._maxStartLifetime = Math.max(this._maxStartLifetime, this._startLifeTimeGradientMax.getValueByIndex(t))
            }
            this._startLifeTimeGradientMin = e
        }
        get startLifeTimeGradientMax() {
            return this._startLifeTimeGradientMax
        }
        set startLifeTimeGradientMax(e) {
            if (3 === this._startLifetimeType) {
                var t, r;
                for (this._maxStartLifetime = -Number.MAX_VALUE, t = 0, r = this._startLifeTimeGradientMin.gradientCount; t &lt; r; t++) this._maxStartLifetime = Math.max(this._maxStartLifetime, this._startLifeTimeGradientMin.getValueByIndex(t));
                for (t = 0, r = e.gradientCount; t &lt; r; t++) this._maxStartLifetime = Math.max(this._maxStartLifetime, e.getValueByIndex(t))
            }
            this._startLifeTimeGradientMax = e
        }
        get velocityOverLifetime() {
            return this._velocityOverLifetime
        }
        set velocityOverLifetime(e) {
            var t = this._owner._render._shaderValues;
            if (e) {
                var r = e.velocity,
                    i = r.type;
                if (e.enable) switch (i) {
                    case 0:
                        t.addDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT);
                        break;
                    case 1:
                        t.addDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE);
                        break;
                    case 2:
                        t.addDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT);
                        break;
                    case 3:
                        t.addDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE)
                } else t.removeDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT), t.removeDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE), t.removeDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT), t.removeDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE);
                switch (i) {
                    case 0:
                        t.setVector3(Qr.VOLVELOCITYCONST, r.constant);
                        break;
                    case 1:
                        t.setBuffer(Qr.VOLVELOCITYGRADIENTX, r.gradientX._elements), t.setBuffer(Qr.VOLVELOCITYGRADIENTY, r.gradientY._elements), t.setBuffer(Qr.VOLVELOCITYGRADIENTZ, r.gradientZ._elements);
                        break;
                    case 2:
                        t.setVector3(Qr.VOLVELOCITYCONST, r.constantMin), t.setVector3(Qr.VOLVELOCITYCONSTMAX, r.constantMax);
                        break;
                    case 3:
                        t.setBuffer(Qr.VOLVELOCITYGRADIENTX, r.gradientXMin._elements), t.setBuffer(Qr.VOLVELOCITYGRADIENTXMAX, r.gradientXMax._elements), t.setBuffer(Qr.VOLVELOCITYGRADIENTY, r.gradientYMin._elements), t.setBuffer(Qr.VOLVELOCITYGRADIENTYMAX, r.gradientYMax._elements), t.setBuffer(Qr.VOLVELOCITYGRADIENTZ, r.gradientZMin._elements), t.setBuffer(Qr.VOLVELOCITYGRADIENTZMAX, r.gradientZMax._elements)
                }
                t.setInt(Qr.VOLSPACETYPE, e.space)
            } else t.removeDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT), t.removeDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE), t.removeDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT), t.removeDefine(Qr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE);
            this._velocityOverLifetime = e
        }
        get colorOverLifetime() {
            return this._colorOverLifetime
        }
        set colorOverLifetime(e) {
            var t = this._owner._render._shaderValues;
            if (e) {
                var r = e.color;
                if (e.enable) switch (r.type) {
                    case 1:
                        t.addDefine(Qr.SHADERDEFINE_COLOROVERLIFETIME);
                        break;
                    case 3:
                        t.addDefine(Qr.SHADERDEFINE_RANDOMCOLOROVERLIFETIME)
                } else t.removeDefine(Qr.SHADERDEFINE_COLOROVERLIFETIME), t.removeDefine(Qr.SHADERDEFINE_RANDOMCOLOROVERLIFETIME);
                switch (r.type) {
                    case 1:
                        var i = r.gradient;
                        t.setBuffer(Qr.COLOROVERLIFEGRADIENTALPHAS, i._alphaElements), t.setBuffer(Qr.COLOROVERLIFEGRADIENTCOLORS, i._rgbElements);
                        break;
                    case 3:
                        var n = r.gradientMin,
                            a = r.gradientMax;
                        t.setBuffer(Qr.COLOROVERLIFEGRADIENTALPHAS, n._alphaElements), t.setBuffer(Qr.COLOROVERLIFEGRADIENTCOLORS, n._rgbElements), t.setBuffer(Qr.MAXCOLOROVERLIFEGRADIENTALPHAS, a._alphaElements), t.setBuffer(Qr.MAXCOLOROVERLIFEGRADIENTCOLORS, a._rgbElements)
                }
            } else t.removeDefine(Qr.SHADERDEFINE_COLOROVERLIFETIME), t.removeDefine(Qr.SHADERDEFINE_RANDOMCOLOROVERLIFETIME), t.setBuffer(Qr.COLOROVERLIFEGRADIENTALPHAS, i._alphaElements), t.setBuffer(Qr.COLOROVERLIFEGRADIENTCOLORS, i._rgbElements), t.setBuffer(Qr.COLOROVERLIFEGRADIENTALPHAS, n._alphaElements), t.setBuffer(Qr.COLOROVERLIFEGRADIENTCOLORS, n._rgbElements), t.setBuffer(Qr.MAXCOLOROVERLIFEGRADIENTALPHAS, a._alphaElements), t.setBuffer(Qr.MAXCOLOROVERLIFEGRADIENTCOLORS, a._rgbElements);
            this._colorOverLifetime = e
        }
        get sizeOverLifetime() {
            return this._sizeOverLifetime
        }
        set sizeOverLifetime(e) {
            var t = this._owner._render._shaderValues;
            if (e) {
                var r = e.size,
                    i = r.separateAxes,
                    n = r.type;
                if (e.enable) switch (n) {
                    case 0:
                        i ? t.addDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE) : t.addDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMECURVE);
                        break;
                    case 2:
                        i ? t.addDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE) : t.addDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES)
                } else t.removeDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMECURVE), t.removeDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE), t.removeDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES), t.removeDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE);
                switch (n) {
                    case 0:
                        i ? (t.setBuffer(Qr.SOLSIZEGRADIENTX, r.gradientX._elements), t.setBuffer(Qr.SOLSIZEGRADIENTY, r.gradientY._elements), t.setBuffer(Qr.SOLSizeGradientZ, r.gradientZ._elements)) : t.setBuffer(Qr.SOLSIZEGRADIENT, r.gradient._elements);
                        break;
                    case 2:
                        i ? (t.setBuffer(Qr.SOLSIZEGRADIENTX, r.gradientXMin._elements), t.setBuffer(Qr.SOLSIZEGRADIENTXMAX, r.gradientXMax._elements), t.setBuffer(Qr.SOLSIZEGRADIENTY, r.gradientYMin._elements), t.setBuffer(Qr.SOLSIZEGRADIENTYMAX, r.gradientYMax._elements), t.setBuffer(Qr.SOLSizeGradientZ, r.gradientZMin._elements), t.setBuffer(Qr.SOLSizeGradientZMAX, r.gradientZMax._elements)) : (t.setBuffer(Qr.SOLSIZEGRADIENT, r.gradientMin._elements), t.setBuffer(Qr.SOLSizeGradientMax, r.gradientMax._elements))
                }
            } else t.removeDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMECURVE), t.removeDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE), t.removeDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES), t.removeDefine(Qr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE);
            this._sizeOverLifetime = e
        }
        get rotationOverLifetime() {
            return this._rotationOverLifetime
        }
        set rotationOverLifetime(e) {
            var t = this._owner._render._shaderValues;
            if (e) {
                var r = e.angularVelocity;
                if (!r) return;
                var i = r.separateAxes,
                    n = r.type;
                if (e.enable) switch (i ? t.addDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE) : t.addDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIME), n) {
                    case 0:
                        t.addDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT);
                        break;
                    case 1:
                        t.addDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE);
                        break;
                    case 2:
                        t.addDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS);
                        break;
                    case 3:
                        t.addDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES)
                } else t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIME), t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE), t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT), t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE), t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS), t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES);
                switch (n) {
                    case 0:
                        i ? t.setVector3(Qr.ROLANGULARVELOCITYCONSTSEPRARATE, r.constantSeparate) : t.setNumber(Qr.ROLANGULARVELOCITYCONST, r.constant);
                        break;
                    case 1:
                        i ? (t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENTX, r.gradientX._elements), t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENTY, r.gradientY._elements), t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENTZ, r.gradientZ._elements)) : t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENT, r.gradient._elements);
                        break;
                    case 2:
                        i ? (t.setVector3(Qr.ROLANGULARVELOCITYCONSTSEPRARATE, r.constantMinSeparate), t.setVector3(Qr.ROLANGULARVELOCITYCONSTMAXSEPRARATE, r.constantMaxSeparate)) : (t.setNumber(Qr.ROLANGULARVELOCITYCONST, r.constantMin), t.setNumber(Qr.ROLANGULARVELOCITYCONSTMAX, r.constantMax));
                        break;
                    case 3:
                        i ? (t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENTX, r.gradientXMin._elements), t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENTXMAX, r.gradientXMax._elements), t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENTY, r.gradientYMin._elements), t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENTYMAX, r.gradientYMax._elements), t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENTZ, r.gradientZMin._elements), t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENTZMAX, r.gradientZMax._elements)) : (t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENT, r.gradientMin._elements), t.setBuffer(Qr.ROLANGULARVELOCITYGRADIENTMAX, r.gradientMax._elements))
                }
            } else t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIME), t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE), t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT), t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE), t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS), t.removeDefine(Qr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES);
            this._rotationOverLifetime = e
        }
        get textureSheetAnimation() {
            return this._textureSheetAnimation
        }
        set textureSheetAnimation(e) {
            var t = this._owner._render._shaderValues;
            if (e) {
                var r = e.frame,
                    i = r.type;
                if (e.enable) switch (i) {
                    case 1:
                        t.addDefine(Qr.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE);
                        break;
                    case 3:
                        t.addDefine(Qr.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE)
                } else t.removeDefine(Qr.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE), t.removeDefine(Qr.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE);
                if (1 === i || 3 === i) {
                    t.setNumber(Qr.TEXTURESHEETANIMATIONCYCLES, e.cycles);
                    var n = e.tiles,
                        a = this._uvLength;
                    a.x = 1 / n.x, a.y = 1 / n.y, t.setVector2(Qr.TEXTURESHEETANIMATIONSUBUVLENGTH, this._uvLength)
                }
                switch (i) {
                    case 1:
                        t.setBuffer(Qr.TEXTURESHEETANIMATIONGRADIENTUVS, r.frameOverTimeData._elements);
                        break;
                    case 3:
                        t.setBuffer(Qr.TEXTURESHEETANIMATIONGRADIENTUVS, r.frameOverTimeDataMin._elements), t.setBuffer(Qr.TEXTURESHEETANIMATIONGRADIENTMAXUVS, r.frameOverTimeDataMax._elements)
                }
            } else t.removeDefine(Qr.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE), t.removeDefine(Qr.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE);
            this._textureSheetAnimation = e
        }
        _getVertexBuffer(e = 0) {
            return 0 === e ? this._vertexBuffer : null
        }
        _getIndexBuffer() {
            return this._indexBuffer
        }
        _generateBoundingSphere() {
            var e = this._boundingSphere.center;
            e.x = 0, e.y = 0, e.z = 0, this._boundingSphere.radius = Number.MAX_VALUE
        }
        _generateBoundingBox() {
            var e, t, r, i, n, s, o, l, _, h = this._owner.particleRenderer,
                c = this._boundingBox.min,
                d = this._boundingBox.max;
            switch (this.startLifetimeType) {
                case 0:
                    r = this.startLifetimeConstant;
                    break;
                case 1:
                    r = -Number.MAX_VALUE;
                    var u = u;
                    for (e = 0, t = u.gradientCount; e &lt; t; e++) r = Math.max(r, u.getValueByIndex(e));
                    break;
                case 2:
                    r = Math.max(this.startLifetimeConstantMin, this.startLifetimeConstantMax);
                    break;
                case 3:
                    r = -Number.MAX_VALUE;
                    var m = m;
                    for (e = 0, t = m.gradientCount; e &lt; t; e++) r = Math.max(r, m.getValueByIndex(e));
                    var f = f;
                    for (e = 0, t = f.gradientCount; e &lt; t; e++) r = Math.max(r, f.getValueByIndex(e))
            }
            switch (this.startSpeedType) {
                case 0:
                    i = n = this.startSpeedConstant;
                    break;
                case 1:
                    break;
                case 2:
                    i = this.startLifetimeConstantMin, n = this.startLifetimeConstantMax
            }
            this._shape &amp;&amp; this._shape.enable || (s = o = a._ZERO, l = a._ZERO, _ = a._UnitZ);
            var T, E, p = new a(l.x * i, l.y * i, l.z * i),
                g = new a(_.x * n, _.y * n, _.z * n);
            if (this._velocityOverLifetime &amp;&amp; this._velocityOverLifetime.enable) {
                var S = this._velocityOverLifetime.velocity;
                switch (S.type) {
                    case 0:
                        S.constant;
                        break;
                    case 1:
                        new a(S.gradientX.getAverageValue(), S.gradientY.getAverageValue(), S.gradientZ.getAverageValue());
                        break;
                    case 2:
                        S.constantMin, S.constantMax;
                        break;
                    case 3:
                        new a(S.gradientXMin.getAverageValue(), S.gradientYMin.getAverageValue(), S.gradientZMin.getAverageValue()), new a(S.gradientXMax.getAverageValue(), S.gradientYMax.getAverageValue(), S.gradientZMax.getAverageValue())
                }
            }
            var R, v, A, I, x = this._owner.transform,
                L = x.position,
                D = ai._tempVector39,
                C = h.renderMode;
            switch (this.scaleMode) {
                case 0:
                    var y = x.getWorldLossyScale();
                    T = y, D.x = y.x, D.y = y.z, D.z = y.y, 1 === C &amp;&amp; (E = y);
                    break;
                case 1:
                    var M = x.localScale;
                    T = M, D.x = M.x, D.y = M.z, D.z = M.y, 1 === C &amp;&amp; (E = M);
                    break;
                case 2:
                    T = x.getWorldLossyScale(), D.x = D.y = D.z = 1, 1 === C &amp;&amp; (E = a._ONE)
            }
            switch (this._velocityOverLifetime &amp;&amp; this._velocityOverLifetime.enable || (R = new a(p.x * r, p.y * r, p.z * r), v = new a(g.x * r, g.y * r, g.z * r), 2 != this.scaleMode ? (a.add(s, R, c), a.multiply(T, c, c), a.add(o, v, d), a.multiply(T, d, d)) : (a.multiply(T, s, c), a.add(c, R, c), a.multiply(T, o, d), a.add(d, v, d))), this.simulationSpace) {
                case 0:
                    break;
                case 1:
                    a.add(c, L, c), a.add(d, L, d)
            }
            switch (this.startSizeType) {
                case 0:
                    if (this.threeDStartSize) {
                        var O = O;
                        A = Math.max(O.x, O.y), 1 === C &amp;&amp; (I = O.y)
                    } else A = this.startSizeConstant, 1 === C &amp;&amp; (I = this.startSizeConstant);
                    break;
                case 1:
                    break;
                case 2:
                    if (this.threeDStartSize) {
                        var N = N;
                        A = Math.max(N.x, N.y), 1 === C &amp;&amp; (I = N.y)
                    } else A = this.startSizeConstantMax, 1 === C &amp;&amp; (I = this.startSizeConstantMax)
            }
            if (this._sizeOverLifetime &amp;&amp; this._sizeOverLifetime.enable) {
                this._sizeOverLifetime.size;
                A *= this._sizeOverLifetime.size.getMaxSizeInGradient()
            }
            var b, P, w = ai._tempVector30;
            switch (C) {
                case 0:
                    b = A * ai.halfKSqrtOf2, a.scale(D, A, w), a.subtract(c, w, c), a.add(d, w, d);
                    break;
                case 1:
                    var V = ai._tempVector31,
                        B = ai._tempVector32,
                        F = ai._tempVector33,
                        U = ai._tempVector34;
                    this._velocityOverLifetime &amp;&amp; this._velocityOverLifetime.enable || (a.multiply(E, g, B), a.multiply(E, p, F));
                    var G = I * h.stretchedBillboardLengthScale,
                        z = a.scalarLength(B) * h.stretchedBillboardSpeedScale + G,
                        H = a.scalarLength(F) * h.stretchedBillboardSpeedScale + G,
                        W = ai._tempVector35,
                        k = ai._tempVector36;
                    a.normalize(B, W), a.scale(W, z, U), a.subtract(v, U, U), a.normalize(F, k), a.scale(k, H, V), a.add(R, V, V), b = A * ai.halfKSqrtOf2, a.scale(D, b, w);
                    var X = ai._tempVector37,
                        Y = ai._tempVector38;
                    a.scale(W, .5, X), a.scale(k, .5, Y), a.multiply(X, D, X), a.multiply(Y, D, Y), a.add(c, Y, c), a.min(c, U, c), a.subtract(c, w, c), a.subtract(d, X, d), a.max(d, V, d), a.add(d, w, d);
                    break;
                case 2:
                    P = .5 * (A *= Math.cos(.7853981633974483)), w.x = D.x * P, w.y = D.z * P, a.subtract(c, w, c), a.add(d, w, d);
                    break;
                case 3:
                    P = .5 * (A *= Math.cos(.7853981633974483)), a.scale(D, P, w), a.subtract(c, w, c), a.add(d, w, d)
            }
            this._boundingBox.getCorners(this._boundingBoxCorners)
        }
        _updateEmission() {
            if (this.isAlive)
                if (this._simulateUpdate) this._simulateUpdate = !1;
                else {
                    var e = this._startUpdateLoopCount === t.Stat.loopCount || this._isPaused ? 0 : this._owner._scene.timer._delta / 1e3;
                    e = Math.min(ai._maxElapsedTime, e * this.simulationSpeed), this._updateParticles(e)
                }
        }
        _updateParticles(e) {
            (4 !== this._ownerRender.renderMode || this._ownerRender.mesh) &amp;&amp; (this._currentTime += e, this._retireActiveParticles(), this._freeRetiredParticles(), this._totalDelayTime += e, this._totalDelayTime &lt; this._playStartDelay || this._emission.enable &amp;&amp; this._isEmitting &amp;&amp; !this._isPaused &amp;&amp; this._advanceTime(e, this._currentTime))
        }
        _updateParticlesSimulationRestart(e) {
            this._firstActiveElement = 0, this._firstNewElement = 0, this._firstFreeElement = 0, this._firstRetiredElement = 0, this._burstsIndex = 0, this._frameRateTime = e, this._emissionTime = 0, this._totalDelayTime = 0, this._currentTime = e;
            var t = e;
            t &lt; this._playStartDelay ? this._totalDelayTime = t : this._emission.enable &amp;&amp; this._advanceTime(e, e)
        }
        _retireActiveParticles() {
            for (; this._firstActiveElement != this._firstNewElement;) {
                var e = this._firstActiveElement * this._floatCountPerVertex * this._vertexStride,
                    t = e + this._timeIndex;
                if (this._currentTime - this._vertices[t] + 1e-4 &lt; this._vertices[e + this._startLifeTimeIndex]) break;
                this._vertices[t] = this._drawCounter, this._firstActiveElement++, this._firstActiveElement &gt;= this._bufferMaxParticles &amp;&amp; (this._firstActiveElement = 0)
            }
        }
        _freeRetiredParticles() {
            for (; this._firstRetiredElement != this._firstActiveElement;) {
                var e = this._drawCounter - this._vertices[this._firstRetiredElement * this._floatCountPerVertex * this._vertexStride + this._timeIndex];
                if (this.isPerformanceMode &amp;&amp; e &lt; 3) break;
                this._firstRetiredElement++, this._firstRetiredElement &gt;= this._bufferMaxParticles &amp;&amp; (this._firstRetiredElement = 0)
            }
        }
        _burst(e, r) {
            for (var i = 0, n = this._emission._bursts, a = n.length; this._burstsIndex &lt; a; this._burstsIndex++) {
                var s, o = n[this._burstsIndex],
                    l = o.time;
                if (!(e &lt;= l &amp;&amp; l &lt; r)) break;
                this.autoRandomSeed ? s = t.MathUtil.lerp(o.minCount, o.maxCount, Math.random()) : (this._rand.seed = this._randomSeeds[0], s = t.MathUtil.lerp(o.minCount, o.maxCount, this._rand.getFloat()), this._randomSeeds[0] = this._rand.seed), i += s
            }
            return i
        }
        _advanceTime(e, t) {
            var r, i = this._emissionTime;
            this._emissionTime += e;
            var n = 0;
            if (this._emissionTime &gt; this.duration) {
                if (!this.looping) {
                    for (n = Math.min(this.maxParticles - this.aliveParticleCount, n), r = 0; r &lt; n; r++) this.emit(t);
                    return this._isPlaying = !1, void this.stop()
                }
                n += this._burst(i, this._emissionTime), this._emissionTime -= this.duration, this._burstsIndex = 0, n += this._burst(0, this._emissionTime)
            } else n += this._burst(i, this._emissionTime);
            for (n = Math.min(this.maxParticles - this.aliveParticleCount, n), r = 0; r &lt; n; r++) this.emit(t);
            var a = this.emission.emissionRate;
            if (a &gt; 0) {
                var s = 1 / a;
                for (this._frameRateTime += s, this._frameRateTime = this._currentTime - (this._currentTime - this._frameRateTime) % this._maxStartLifetime; this._frameRateTime &lt;= t &amp;&amp; this.emit(this._frameRateTime);) this._frameRateTime += s;
                this._frameRateTime = Math.floor(t / s) * s
            }
        }
        _initBufferDatas() {
            if (this._vertexBuffer) {
                this._vertexBuffer.destroy(), this._indexBuffer.destroy();
                var r = this._vertexBuffer._byteLength + 2 * this._indexBuffer.indexCount;
                t.Resource._addMemory(-r, -r)
            }
            var i = t.LayaGL.instance,
                n = this._ownerRender,
                a = n.renderMode;
            if (-1 !== a &amp;&amp; this.maxParticles &gt; 0) {
                var s, o, l, _, h, c, d, u = 0,
                    m = (r = 0, n.mesh);
                if (4 === a) {
                    if (m) {
                        d = ti.vertexDeclaration, this._floatCountPerVertex = d.vertexStride / 4, this._startLifeTimeIndex = 12, this._timeIndex = 16, this._vertexStride = m._vertexCount;
                        var f = this._bufferMaxParticles * this._vertexStride,
                            T = f % 65535;
                        if (Math.floor(f / 65535) + 1 &gt; 1) throw new Error("ShurikenParticleSystem:the maxParticleCount multiply mesh vertexCount is large than 65535.");
                        u = d.vertexStride * T, this._vertexBuffer = new _t(u, i.DYNAMIC_DRAW), this._vertexBuffer.vertexDeclaration = d, this._vertices = new Float32Array(this._floatCountPerVertex * T), this._indexStride = m._indexBuffer.indexCount;
                        var E = m._indexBuffer.getData(),
                            p = this._bufferMaxParticles * this._indexStride;
                        for (this._indexBuffer = new nt(e.IndexFormat.UInt16, p, i.STATIC_DRAW), s = new Uint16Array(p), r = u + 2 * p, h = 0, o = 0; o &lt; this._bufferMaxParticles; o++) {
                            var g = o * this._vertexStride;
                            for (l = 0, _ = E.length; l &lt; _; l++) s[h++] = g + E[l]
                        }
                        this._indexBuffer.setData(s), this._bufferState.bind(), this._bufferState.applyVertexBuffer(this._vertexBuffer), this._bufferState.applyIndexBuffer(this._indexBuffer), this._bufferState.unBind()
                    }
                } else {
                    for (d = ei.vertexDeclaration, this._floatCountPerVertex = d.vertexStride / 4, this._startLifeTimeIndex = 7, this._timeIndex = 11, this._vertexStride = 4, u = d.vertexStride * this._bufferMaxParticles * this._vertexStride, this._vertexBuffer = new _t(u, i.DYNAMIC_DRAW), this._vertexBuffer.vertexDeclaration = d, this._vertices = new Float32Array(this._floatCountPerVertex * this._bufferMaxParticles * this._vertexStride), o = 0; o &lt; this._bufferMaxParticles; o++) c = o * this._floatCountPerVertex * this._vertexStride, this._vertices[c] = -.5, this._vertices[c + 1] = -.5, this._vertices[c + 2] = 0, this._vertices[c + 3] = 1, c += this._floatCountPerVertex, this._vertices[c] = .5, this._vertices[c + 1] = -.5, this._vertices[c + 2] = 1, this._vertices[c + 3] = 1, c += this._floatCountPerVertex, this._vertices[c] = .5, this._vertices[c + 1] = .5, this._vertices[c + 2] = 1, this._vertices[c + 3] = 0, c += this._floatCountPerVertex, this._vertices[c] = -.5, this._vertices[c + 1] = .5, this._vertices[c + 2] = 0, this._vertices[c + 3] = 0;
                    for (this._indexStride = 6, this._indexBuffer = new nt(e.IndexFormat.UInt16, 6 * this._bufferMaxParticles, i.STATIC_DRAW), s = new Uint16Array(6 * this._bufferMaxParticles), o = 0; o &lt; this._bufferMaxParticles; o++) {
                        h = 6 * o;
                        var S = o * this._vertexStride,
                            R = S + 2;
                        s[h++] = S, s[h++] = R, s[h++] = S + 1, s[h++] = S, s[h++] = S + 3, s[h++] = R
                    }
                    this._indexBuffer.setData(s), r = u + 6 * this._bufferMaxParticles * 2, this._bufferState.bind(), this._bufferState.applyVertexBuffer(this._vertexBuffer), this._bufferState.applyIndexBuffer(this._indexBuffer), this._bufferState.unBind()
                }
                t.Resource._addMemory(r, r)
            }
        }
        destroy() {
            super.destroy();
            var e = this._vertexBuffer._byteLength + 2 * this._indexBuffer.indexCount;
            t.Resource._addMemory(-e, -e), this._bufferState.destroy(), this._vertexBuffer.destroy(), this._indexBuffer.destroy(), this._emission.destroy(), this._bufferState = null, this._vertexBuffer = null, this._indexBuffer = null, this._owner = null, this._vertices = null, this._indexBuffer = null, this._emission = null, this._shape = null, this.startLifeTimeGradient = null, this.startLifeTimeGradientMin = null, this.startLifeTimeGradientMax = null, this.startSizeConstantSeparate = null, this.startSizeConstantMinSeparate = null, this.startSizeConstantMaxSeparate = null, this.startRotationConstantSeparate = null, this.startRotationConstantMinSeparate = null, this.startRotationConstantMaxSeparate = null, this.startColorConstant = null, this.startColorConstantMin = null, this.startColorConstantMax = null, this._velocityOverLifetime = null, this._colorOverLifetime = null, this._sizeOverLifetime = null, this._rotationOverLifetime = null, this._textureSheetAnimation = null
        }
        emit(e) {
            var t = ai._tempPosition,
                r = ai._tempDirection;
            return this._shape &amp;&amp; this._shape.enable ? this.autoRandomSeed ? this._shape.generatePositionAndDirection(t, r) : this._shape.generatePositionAndDirection(t, r, this._rand, this._randomSeeds) : (t.x = t.y = t.z = 0, r.x = r.y = 0, r.z = 1), this.addParticle(t, r, e)
        }
        addParticle(e, r, i) {
            a.normalize(r, r);
            var n = this._firstFreeElement + 1;
            if (n &gt;= this._bufferMaxParticles &amp;&amp; (n = 0), n === this._firstRetiredElement) return !1;
            var s, o, l, _, h, c, d, u, m, f, T = this._owner.transform;
            if (ni.create(this, this._ownerRender, T), this._currentTime - i &gt;= ni.startLifeTime) return !0;
            switch (0 == this.simulationSpace &amp;&amp; (s = T.position, o = T.rotation), this.startSpeedType) {
                case 0:
                    l = this.startSpeedConstant;
                    break;
                case 2:
                    this.autoRandomSeed ? l = t.MathUtil.lerp(this.startSpeedConstantMin, this.startSpeedConstantMax, Math.random()) : (this._rand.seed = this._randomSeeds[8], l = t.MathUtil.lerp(this.startSpeedConstantMin, this.startSpeedConstantMax, this._rand.getFloat()), this._randomSeeds[8] = this._rand.seed)
            }
            var E = this._velocityOverLifetime &amp;&amp; this._velocityOverLifetime.enable;
            if (E) {
                var p = this._velocityOverLifetime.velocity.type;
                2 === p || 3 === p ? this.autoRandomSeed ? (_ = Math.random(), h = Math.random(), c = Math.random()) : (this._rand.seed = this._randomSeeds[9], _ = this._rand.getFloat(), h = this._rand.getFloat(), c = this._rand.getFloat(), this._randomSeeds[9] = this._rand.seed) : E = !1
            } else E = !1;
            var g = this._colorOverLifetime &amp;&amp; this._colorOverLifetime.enable;
            g ? 3 === this._colorOverLifetime.color.type ? this.autoRandomSeed ? d = Math.random() : (this._rand.seed = this._randomSeeds[10], d = this._rand.getFloat(), this._randomSeeds[10] = this._rand.seed) : g = !1 : g = !1;
            var S = this._sizeOverLifetime &amp;&amp; this._sizeOverLifetime.enable;
            S ? 3 === this._sizeOverLifetime.size.type ? this.autoRandomSeed ? u = Math.random() : (this._rand.seed = this._randomSeeds[11], u = this._rand.getFloat(), this._randomSeeds[11] = this._rand.seed) : S = !1 : S = !1;
            var R = this._rotationOverLifetime &amp;&amp; this._rotationOverLifetime.enable;
            if (R) {
                var v = this._rotationOverLifetime.angularVelocity.type;
                2 === v || 3 === v ? this.autoRandomSeed ? m = Math.random() : (this._rand.seed = this._randomSeeds[12], m = this._rand.getFloat(), this._randomSeeds[12] = this._rand.seed) : R = !1
            } else R = !1;
            var A = this._textureSheetAnimation &amp;&amp; this._textureSheetAnimation.enable;
            A ? 3 === this._textureSheetAnimation.frame.type ? this.autoRandomSeed ? f = Math.random() : (this._rand.seed = this._randomSeeds[15], f = this._rand.getFloat(), this._randomSeeds[15] = this._rand.seed) : A = !1 : A = !1;
            var I, x, L, D, C, y, M = this._firstFreeElement * this._floatCountPerVertex * this._vertexStride,
                O = ni.startUVInfo[0],
                N = ni.startUVInfo[1],
                b = ni.startUVInfo[2],
                P = ni.startUVInfo[3],
                w = this._ownerRender;
            if (4 === w.renderMode) {
                var V = w.mesh._vertexBuffer;
                I = V.getFloat32Data();
                var B = V.vertexDeclaration;
                L = B.getVertexElementByUsage(lt.MESH_POSITION0)._offset / 4;
                var F = B.getVertexElementByUsage(lt.MESH_COLOR0);
                D = F ? F._offset / 4 : -1;
                var U = B.getVertexElementByUsage(lt.MESH_TEXTURECOORDINATE0);
                C = U ? U._offset / 4 : -1, x = B.vertexStride / 4, y = 0
            } else {
                this._vertices[M + 2] = b, this._vertices[M + 3] = P + N;
                var G = M + this._floatCountPerVertex;
                this._vertices[G + 2] = b + O, this._vertices[G + 3] = P + N;
                var z = G + this._floatCountPerVertex;
                this._vertices[z + 2] = b + O, this._vertices[z + 3] = P;
                var H = z + this._floatCountPerVertex;
                this._vertices[H + 2] = b, this._vertices[H + 3] = P
            }
            for (var W = M, k = M + this._floatCountPerVertex * this._vertexStride; W &lt; k; W += this._floatCountPerVertex) {
                var X;
                if (4 === w.renderMode) {
                    X = W;
                    var Y = x * y++,
                        j = Y + L;
                    this._vertices[X++] = I[j++], this._vertices[X++] = I[j++], this._vertices[X++] = I[j], -1 === D ? (this._vertices[X++] = 1, this._vertices[X++] = 1, this._vertices[X++] = 1, this._vertices[X++] = 1) : (j = Y + D, this._vertices[X++] = I[j++], this._vertices[X++] = I[j++], this._vertices[X++] = I[j++], this._vertices[X++] = I[j]), -1 === C ? (this._vertices[X++] = 0, this._vertices[X++] = 0) : (j = Y + C, this._vertices[X++] = b + I[j++] * O, this._vertices[X++] = P + I[j] * N)
                } else X = W + 4;
                switch (this._vertices[X++] = e.x, this._vertices[X++] = e.y, this._vertices[X++] = e.z, this._vertices[X++] = ni.startLifeTime, this._vertices[X++] = r.x, this._vertices[X++] = r.y, this._vertices[X++] = r.z, this._vertices[X++] = i, this._vertices[X++] = ni.startColor.x, this._vertices[X++] = ni.startColor.y, this._vertices[X++] = ni.startColor.z, this._vertices[X++] = ni.startColor.w, this._vertices[X++] = ni.startSize[0], this._vertices[X++] = ni.startSize[1], this._vertices[X++] = ni.startSize[2], this._vertices[X++] = ni.startRotation[0], this._vertices[X++] = ni.startRotation[1], this._vertices[X++] = ni.startRotation[2], this._vertices[X++] = l, g &amp;&amp; (this._vertices[X + 1] = d), S &amp;&amp; (this._vertices[X + 2] = u), R &amp;&amp; (this._vertices[X + 3] = m), A &amp;&amp; (this._vertices[X + 4] = f), E &amp;&amp; (this._vertices[X + 5] = _, this._vertices[X + 6] = h, this._vertices[X + 7] = c), this.simulationSpace) {
                    case 0:
                        X += 8, this._vertices[X++] = s.x, this._vertices[X++] = s.y, this._vertices[X++] = s.z, this._vertices[X++] = o.x, this._vertices[X++] = o.y, this._vertices[X++] = o.z, this._vertices[X++] = o.w;
                        break;
                    case 1:
                        break;
                    default:
                        throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.")
                }
            }
            return this._firstFreeElement = n, !0
        }
        addNewParticlesToVertexBuffer() {
            var e, t = this._vertexStride * this._floatCountPerVertex * 4;
            this._firstNewElement &lt; this._firstFreeElement ? (e = this._firstNewElement * t, this._vertexBuffer.setData(this._vertices.buffer, e, e, (this._firstFreeElement - this._firstNewElement) * t)) : (e = this._firstNewElement * t, this._vertexBuffer.setData(this._vertices.buffer, e, e, (this._bufferMaxParticles - this._firstNewElement) * t), this._firstFreeElement &gt; 0 &amp;&amp; this._vertexBuffer.setData(this._vertices.buffer, 0, 0, this._firstFreeElement * t)), this._firstNewElement = this._firstFreeElement
        }
        _getType() {
            return ai._type
        }
        _prepareRender(e) {
            return this._updateEmission(), this._firstNewElement != this._firstFreeElement &amp;&amp; this.addNewParticlesToVertexBuffer(), this._drawCounter++, this._firstActiveElement != this._firstFreeElement
        }
        _render(e) {
            var r;
            this._bufferState.bind();
            var i = t.LayaGL.instance;
            this._firstActiveElement &lt; this._firstFreeElement ? (r = (this._firstFreeElement - this._firstActiveElement) * this._indexStride, i.drawElements(i.TRIANGLES, r, i.UNSIGNED_SHORT, 2 * this._firstActiveElement * this._indexStride), t.Stat.trianglesFaces += r / 3, t.Stat.renderBatches++) : (r = (this._bufferMaxParticles - this._firstActiveElement) * this._indexStride, i.drawElements(i.TRIANGLES, r, i.UNSIGNED_SHORT, 2 * this._firstActiveElement * this._indexStride), t.Stat.trianglesFaces += r / 3, t.Stat.renderBatches++, this._firstFreeElement &gt; 0 &amp;&amp; (r = this._firstFreeElement * this._indexStride, i.drawElements(i.TRIANGLES, r, i.UNSIGNED_SHORT, 0), t.Stat.trianglesFaces += r / 3, t.Stat.renderBatches++))
        }
        play() {
            if (this._burstsIndex = 0, this._isEmitting = !0, this._isPlaying = !0, this._isPaused = !1, this._emissionTime = 0, this._totalDelayTime = 0, !this.autoRandomSeed)
                for (var e = 0, r = this._randomSeeds.length; e &lt; r; e++) this._randomSeeds[e] = this.randomSeed[0] + ai._RANDOMOFFSET[e];
            switch (this.startDelayType) {
                case 0:
                    this._playStartDelay = this.startDelay;
                    break;
                case 1:
                    this.autoRandomSeed ? this._playStartDelay = t.MathUtil.lerp(this.startDelayMin, this.startDelayMax, Math.random()) : (this._rand.seed = this._randomSeeds[2], this._playStartDelay = t.MathUtil.lerp(this.startDelayMin, this.startDelayMax, this._rand.getFloat()), this._randomSeeds[2] = this._rand.seed);
                    break;
                default:
                    throw new Error("Utils3D: startDelayType is invalid.")
            }
            this._frameRateTime = this._currentTime + this._playStartDelay, this._startUpdateLoopCount = t.Stat.loopCount
        }
        pause() {
            this._isPaused = !0
        }
        simulate(e, t = !0) {
            this._simulateUpdate = !0, t ? this._updateParticlesSimulationRestart(e) : (this._isPaused = !1, this._updateParticles(e)), this.pause()
        }
        stop() {
            this._burstsIndex = 0, this._isEmitting = !1, this._emissionTime = 0
        }
        cloneTo(e) {
            var t = e;
            t.duration = this.duration, t.looping = this.looping, t.prewarm = this.prewarm, t.startDelayType = this.startDelayType, t.startDelay = this.startDelay, t.startDelayMin = this.startDelayMin, t.startDelayMax = this.startDelayMax, t._maxStartLifetime = this._maxStartLifetime, t.startLifetimeType = this.startLifetimeType, t.startLifetimeConstant = this.startLifetimeConstant, this.startLifeTimeGradient.cloneTo(t.startLifeTimeGradient), t.startLifetimeConstantMin = this.startLifetimeConstantMin, t.startLifetimeConstantMax = this.startLifetimeConstantMax, this.startLifeTimeGradientMin.cloneTo(t.startLifeTimeGradientMin), this.startLifeTimeGradientMax.cloneTo(t.startLifeTimeGradientMax), t.startSpeedType = this.startSpeedType, t.startSpeedConstant = this.startSpeedConstant, t.startSpeedConstantMin = this.startSpeedConstantMin, t.startSpeedConstantMax = this.startSpeedConstantMax, t.threeDStartSize = this.threeDStartSize, t.startSizeType = this.startSizeType, t.startSizeConstant = this.startSizeConstant, this.startSizeConstantSeparate.cloneTo(t.startSizeConstantSeparate), t.startSizeConstantMin = this.startSizeConstantMin, t.startSizeConstantMax = this.startSizeConstantMax, this.startSizeConstantMinSeparate.cloneTo(t.startSizeConstantMinSeparate), this.startSizeConstantMaxSeparate.cloneTo(t.startSizeConstantMaxSeparate), t.threeDStartRotation = this.threeDStartRotation, t.startRotationType = this.startRotationType, t.startRotationConstant = this.startRotationConstant, this.startRotationConstantSeparate.cloneTo(t.startRotationConstantSeparate), t.startRotationConstantMin = this.startRotationConstantMin, t.startRotationConstantMax = this.startRotationConstantMax, this.startRotationConstantMinSeparate.cloneTo(t.startRotationConstantMinSeparate), this.startRotationConstantMaxSeparate.cloneTo(t.startRotationConstantMaxSeparate), t.randomizeRotationDirection = this.randomizeRotationDirection, t.startColorType = this.startColorType, this.startColorConstant.cloneTo(t.startColorConstant), this.startColorConstantMin.cloneTo(t.startColorConstantMin), this.startColorConstantMax.cloneTo(t.startColorConstantMax), t.gravityModifier = this.gravityModifier, t.simulationSpace = this.simulationSpace, t.scaleMode = this.scaleMode, t.playOnAwake = this.playOnAwake, t.autoRandomSeed = this.autoRandomSeed, t.randomSeed[0] = this.randomSeed[0], t.maxParticles = this.maxParticles, this._emission &amp;&amp; (t._emission = this._emission.clone()), this.shape &amp;&amp; (t.shape = this.shape.clone()), this.velocityOverLifetime &amp;&amp; (t.velocityOverLifetime = this.velocityOverLifetime.clone()), this.colorOverLifetime &amp;&amp; (t.colorOverLifetime = this.colorOverLifetime.clone()), this.sizeOverLifetime &amp;&amp; (t.sizeOverLifetime = this.sizeOverLifetime.clone()), this.rotationOverLifetime &amp;&amp; (t.rotationOverLifetime = this.rotationOverLifetime.clone()), this.textureSheetAnimation &amp;&amp; (t.textureSheetAnimation = this.textureSheetAnimation.clone()), t.isPerformanceMode = this.isPerformanceMode, t._isEmitting = this._isEmitting, t._isPlaying = this._isPlaying, t._isPaused = this._isPaused, t._playStartDelay = this._playStartDelay, t._frameRateTime = this._frameRateTime, t._emissionTime = this._emissionTime, t._totalDelayTime = this._totalDelayTime, t._burstsIndex = this._burstsIndex
        }
        clone() {
            var e = new ai(null);
            return this.cloneTo(e), e
        }
    }
    ai._RANDOMOFFSET = new Uint32Array([592910910, 3276756734, 322376503, 306581307, 1793934638, 3737431713, 2527743459, 2368504881, 4085612399, 3774601268, 326370691, 1494990940, 1089181156, 3159510623, 2941263940, 2786374529, 271901988, 4233252447]), ai.halfKSqrtOf2 = .71, ai._maxElapsedTime = 1 / 3, ai._tempVector30 = new a, ai._tempVector31 = new a, ai._tempVector32 = new a, ai._tempVector33 = new a, ai._tempVector34 = new a, ai._tempVector35 = new a, ai._tempVector36 = new a, ai._tempVector37 = new a, ai._tempVector38 = new a, ai._tempVector39 = new a, ai._tempPosition = new a, ai._tempDirection = new a, ai._type = Vt._typeCounter++;
    class si extends Ut {
        constructor() {
            super(null), this._render = new Jr(this), this._particleSystem = new ai(this);
            var e = this._render._renderElements[0] = new Ht;
            e.setTransform(this._transform), e.render = this._render, e.setGeometry(this._particleSystem), e.material = Kr.defaultMaterial
        }
        static __init__() {
            Qr.SHADERDEFINE_RENDERMODE_BILLBOARD = he.getDefineByName("SPHERHBILLBOARD"), Qr.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD = he.getDefineByName("STRETCHEDBILLBOARD"), Qr.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD = he.getDefineByName("HORIZONTALBILLBOARD"), Qr.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD = he.getDefineByName("VERTICALBILLBOARD"), Qr.SHADERDEFINE_COLOROVERLIFETIME = he.getDefineByName("COLOROVERLIFETIME"), Qr.SHADERDEFINE_RANDOMCOLOROVERLIFETIME = he.getDefineByName("RANDOMCOLOROVERLIFETIME"), Qr.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT = he.getDefineByName("VELOCITYOVERLIFETIMECONSTANT"), Qr.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE = he.getDefineByName("VELOCITYOVERLIFETIMECURVE"), Qr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT = he.getDefineByName("VELOCITYOVERLIFETIMERANDOMCONSTANT"), Qr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE = he.getDefineByName("VELOCITYOVERLIFETIMERANDOMCURVE"), Qr.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE = he.getDefineByName("TEXTURESHEETANIMATIONCURVE"), Qr.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE = he.getDefineByName("TEXTURESHEETANIMATIONRANDOMCURVE"), Qr.SHADERDEFINE_ROTATIONOVERLIFETIME = he.getDefineByName("ROTATIONOVERLIFETIME"), Qr.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE = he.getDefineByName("ROTATIONOVERLIFETIMESEPERATE"), Qr.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT = he.getDefineByName("ROTATIONOVERLIFETIMECONSTANT"), Qr.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE = he.getDefineByName("ROTATIONOVERLIFETIMECURVE"), Qr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS = he.getDefineByName("ROTATIONOVERLIFETIMERANDOMCONSTANTS"), Qr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES = he.getDefineByName("ROTATIONOVERLIFETIMERANDOMCURVES"), Qr.SHADERDEFINE_SIZEOVERLIFETIMECURVE = he.getDefineByName("SIZEOVERLIFETIMECURVE"), Qr.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE = he.getDefineByName("SIZEOVERLIFETIMECURVESEPERATE"), Qr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES = he.getDefineByName("SIZEOVERLIFETIMERANDOMCURVES"), Qr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE = he.getDefineByName("SIZEOVERLIFETIMERANDOMCURVESSEPERATE"), Qr.SHADERDEFINE_RENDERMODE_MESH = he.getDefineByName("RENDERMODE_MESH"), Qr.SHADERDEFINE_SHAPE = he.getDefineByName("SHAPE")
        }
        get particleSystem() {
            return this._particleSystem
        }
        get particleRenderer() {
            return this._render
        }
        _parseModule(e, r) {
            for (var i in r) switch (i) {
                case "bases":
                    var n = r.bases;
                    for (var a in n) e[a] = n[a];
                    break;
                case "vector2s":
                    var s = r.vector2s;
                    for (var a in s) {
                        var o = e[a],
                            l = s[a];
                        o.setValue(l[0], l[1]), e[a] = o
                    }
                    break;
                case "vector3s":
                    var _ = r.vector3s;
                    for (var a in _) {
                        var h = e[a],
                            c = _[a];
                        h.setValue(c[0], c[1], c[2]), e[a] = h
                    }
                    break;
                case "vector4s":
                    var d = r.vector4s;
                    for (var a in d) {
                        var u = e[a],
                            m = d[a];
                        u.setValue(m[0], m[1], m[2], m[3]), e[a] = u
                    }
                    break;
                case "gradientDataNumbers":
                    var f = r.gradientDataNumbers;
                    for (var a in f) {
                        for (var T = e[a], E = r[a], p = 0, g = E.length; p &lt; g; p++) {
                            var S = E[p];
                            T.add(S.key, S.value)
                        }
                        e[a] = T
                    }
                    break;
                case "resources":
                    var R = r.resources;
                    for (var a in R) e[a] = t.Loader.getRes(R[a]);
                    break;
                case "bursts":
                    var v = r.bursts;
                    for (p = 0, g = v.length; p &lt; g; p++) {
                        var A = v[p];
                        e.addBurst(new yr(A.time, A.min, A.max))
                    }
                    break;
                case "randomSeed":
                    e.randomSeed[0] = r.randomSeed;
                    break;
                case "shapeType":
                case "type":
                case "color":
                case "size":
                case "frame":
                case "startFrame":
                case "angularVelocity":
                case "velocity":
                    break;
                default:
                    throw "ShurikenParticle3D:unknown type."
            }
        }
        _parse(e, t) {
            if (super._parse(e, t), e.main) {
                var r = this.particleSystem,
                    i = this.particleRenderer;
                this._parseModule(i, e.renderer), this._parseModule(r, e.main), this._parseModule(r.emission, e.emission);
                var s = e.shape;
                if (s) {
                    var o;
                    switch (s.shapeType) {
                        case 0:
                            o = new Xr;
                            break;
                        case 1:
                            o = new kr;
                            break;
                        case 2:
                            o = new Wr;
                            break;
                        case 3:
                            o = new zr;
                            break;
                        case 7:
                            o = new Hr;
                            break;
                        default:
                            throw "ShuriKenParticle3D:unknown shape type."
                    }
                    this._parseModule(o, s), r.shape = o
                }
                var l = e.velocityOverLifetime;
                if (l) {
                    var _, h = l.velocity;
                    switch (h.type) {
                        case 0:
                            var c = h.constant;
                            _ = Br.createByConstant(c ? new a(c[0], c[1], c[2]) : new a(0, 0, 0));
                            break;
                        case 1:
                            _ = Br.createByGradient(this._initParticleVelocity(h.gradientX), this._initParticleVelocity(h.gradientY), this._initParticleVelocity(h.gradientZ));
                            break;
                        case 2:
                            var d = h.constantMin,
                                u = h.constantMax;
                            _ = Br.createByRandomTwoConstant(d ? new a(d[0], d[1], d[2]) : new a(0, 0, 0), u ? new a(u[0], u[1], u[2]) : new a(0, 0, 0));
                            break;
                        case 3:
                            _ = Br.createByRandomTwoGradient(this._initParticleVelocity(h.gradientXMin), this._initParticleVelocity(h.gradientXMax), this._initParticleVelocity(h.gradientYMin), this._initParticleVelocity(h.gradientYMax), this._initParticleVelocity(h.gradientZMin), this._initParticleVelocity(h.gradientZMax))
                    }
                    var m = new qr(_);
                    this._parseModule(m, l), r.velocityOverLifetime = m
                }
                var f = e.colorOverLifetime;
                if (f) {
                    var T, E = f.color;
                    switch (E.type) {
                        case 0:
                            var p = E.constant;
                            T = Mr.createByConstant(p ? new n(p[0], p[1], p[2], p[3]) : new n(0, 0, 0, 0));
                            break;
                        case 1:
                            T = Mr.createByGradient(this._initParticleColor(E.gradient));
                            break;
                        case 2:
                            var g = E.constantMin,
                                S = E.constantMax;
                            T = Mr.createByRandomTwoConstant(g ? new n(g[0], g[1], g[2], g[3]) : new n(0, 0, 0, 0), g ? new n(S[0], S[1], S[2], S[3]) : new n(0, 0, 0, 0));
                            break;
                        case 3:
                            T = Mr.createByRandomTwoGradient(this._initParticleColor(E.gradientMin), this._initParticleColor(E.gradientMax))
                    }
                    var R = new Or(T);
                    this._parseModule(R, f), r.colorOverLifetime = R
                }
                var v = e.sizeOverLifetime;
                if (v) {
                    var A, I = v.size;
                    switch (I.type) {
                        case 0:
                            A = I.separateAxes ? Vr.createByGradientSeparate(this._initParticleSize(I.gradientX), this._initParticleSize(I.gradientY), this._initParticleSize(I.gradientZ)) : Vr.createByGradient(this._initParticleSize(I.gradient));
                            break;
                        case 1:
                            if (I.separateAxes) {
                                var x = I.constantMinSeparate,
                                    L = I.constantMaxSeparate;
                                A = Vr.createByRandomTwoConstantSeparate(x ? new a(x[0], x[1], x[2]) : new a(0, 0, 0), L ? new a(L[0], L[1], L[2]) : new a(0, 0, 0))
                            } else A = Vr.createByRandomTwoConstant(I.constantMin || 0, I.constantMax || 0);
                            break;
                        case 2:
                            A = I.separateAxes ? Vr.createByRandomTwoGradientSeparate(this._initParticleSize(I.gradientXMin), this._initParticleSize(I.gradientYMin), this._initParticleSize(I.gradientZMin), this._initParticleSize(I.gradientXMax), this._initParticleSize(I.gradientYMax), this._initParticleSize(I.gradientZMax)) : Vr.createByRandomTwoGradient(this._initParticleSize(I.gradientMin), this._initParticleSize(I.gradientMax))
                    }
                    var D = new Yr(A);
                    this._parseModule(D, v), r.sizeOverLifetime = D
                }
                var C = e.rotationOverLifetime;
                if (C) {
                    var y, M = C.angularVelocity;
                    switch (M.type) {
                        case 0:
                            if (M.separateAxes) {
                                var O = M.constantSeparate;
                                y = br.createByConstantSeparate(O ? new a(O[0], O[1], O[2]) : new a(0, 0, Math.PI / 4))
                            } else y = br.createByConstant(M.constant || Math.PI / 4);
                            break;
                        case 1:
                            y = M.separateAxes ? br.createByGradientSeparate(this._initParticleRotation(M.gradientX), this._initParticleRotation(M.gradientY), this._initParticleRotation(M.gradientZ)) : br.createByGradient(this._initParticleRotation(M.gradient));
                            break;
                        case 2:
                            if (M.separateAxes) {
                                var N = M.constantMinSeparate,
                                    b = M.constantMaxSeparate;
                                y = br.createByRandomTwoConstantSeparate(N ? new a(N[0], N[1], N[2]) : new a(0, 0, 0), b ? new a(b[0], b[1], b[2]) : new a(0, 0, Math.PI / 4))
                            } else y = br.createByRandomTwoConstant(M.constantMin || 0, M.constantMax || Math.PI / 4);
                            break;
                        case 3:
                            M.separateAxes || (y = br.createByRandomTwoGradient(this._initParticleRotation(M.gradientMin), this._initParticleRotation(M.gradientMax)))
                    }
                    var P = new Fr(y);
                    this._parseModule(P, C), r.rotationOverLifetime = P
                }
                var w = e.textureSheetAnimation;
                if (w) {
                    var V, B = w.frame;
                    switch (B.type) {
                        case 0:
                            V = Nr.createByConstant(B.constant);
                            break;
                        case 1:
                            V = Nr.createByOverTime(this._initParticleFrame(B.overTime));
                            break;
                        case 2:
                            V = Nr.createByRandomTwoConstant(B.constantMin, B.constantMax);
                            break;
                        case 3:
                            V = Nr.createByRandomTwoOverTime(this._initParticleFrame(B.overTimeMin), this._initParticleFrame(B.overTimeMax))
                    }
                    var F, U = w.startFrame;
                    switch (U.type) {
                        case 0:
                            F = jr.createByConstant(U.constant);
                            break;
                        case 1:
                            F = jr.createByRandomTwoConstant(U.constantMin, U.constantMax)
                    }
                    var G = new Zr(V, F);
                    this._parseModule(G, w), r.textureSheetAnimation = G
                }
            } else this._parseOld(e)
        }
        _activeHierarchy(e) {
            super._activeHierarchy(e), this.particleSystem.playOnAwake &amp;&amp; this.particleSystem.play()
        }
        _inActiveHierarchy(e) {
            super._inActiveHierarchy(e), this.particleSystem.isAlive &amp;&amp; this.particleSystem.simulate(0, !0)
        }
        _cloneTo(e, t, r) {
            var i = e,
                n = i._particleSystem;
            this._particleSystem.cloneTo(n);
            var a = i._render,
                s = this._render;
            a.sharedMaterials = s.sharedMaterials, a.enable = s.enable, a.renderMode = s.renderMode, a.mesh = s.mesh, a.stretchedBillboardCameraSpeedScale = s.stretchedBillboardCameraSpeedScale, a.stretchedBillboardSpeedScale = s.stretchedBillboardSpeedScale, a.stretchedBillboardLengthScale = s.stretchedBillboardLengthScale, a.sortingFudge = s.sortingFudge, super._cloneTo(e, t, r)
        }
        destroy(e = !0) {
            this.destroyed || (super.destroy(e), this._particleSystem.destroy(), this._particleSystem = null)
        }
        _create() {
            return new si
        }
        _parseOld(e) {
            const r = Math.PI / 180;
            var s, o, l, _ = this.particleRenderer,
                h = e.material;
            h &amp;&amp; (l = t.Loader.getRes(h.path)), _.sharedMaterial = l;
            var c = e.meshPath;
            c &amp;&amp; (_.mesh = t.Loader.getRes(c)), _.renderMode = e.renderMode, _.stretchedBillboardCameraSpeedScale = e.stretchedBillboardCameraSpeedScale, _.stretchedBillboardSpeedScale = e.stretchedBillboardSpeedScale, _.stretchedBillboardLengthScale = e.stretchedBillboardLengthScale, _.sortingFudge = e.sortingFudge ? e.sortingFudge : 0;
            var d = this.particleSystem;
            d.isPerformanceMode = e.isPerformanceMode, d.duration = e.duration, d.looping = e.looping, d.prewarm = e.prewarm, d.startDelayType = e.startDelayType, d.startDelay = e.startDelay, d.startDelayMin = e.startDelayMin, d.startDelayMax = e.startDelayMax, d.startLifetimeType = e.startLifetimeType, d.startLifetimeConstant = e.startLifetimeConstant, d.startLifeTimeGradient = si._initStartLife(e.startLifetimeGradient), d.startLifetimeConstantMin = e.startLifetimeConstantMin, d.startLifetimeConstantMax = e.startLifetimeConstantMax, d.startLifeTimeGradientMin = si._initStartLife(e.startLifetimeGradientMin), d.startLifeTimeGradientMax = si._initStartLife(e.startLifetimeGradientMax), d.startSpeedType = e.startSpeedType, d.startSpeedConstant = e.startSpeedConstant, d.startSpeedConstantMin = e.startSpeedConstantMin, d.startSpeedConstantMax = e.startSpeedConstantMax, d.threeDStartSize = e.threeDStartSize, d.startSizeType = e.startSizeType, d.startSizeConstant = e.startSizeConstant;
            var u = e.startSizeConstantSeparate,
                m = d.startSizeConstantSeparate;
            m.x = u[0], m.y = u[1], m.z = u[2], d.startSizeConstantMin = e.startSizeConstantMin, d.startSizeConstantMax = e.startSizeConstantMax;
            var f = e.startSizeConstantMinSeparate,
                T = d.startSizeConstantMinSeparate;
            T.x = f[0], T.y = f[1], T.z = f[2];
            var E = e.startSizeConstantMaxSeparate,
                p = d.startSizeConstantMaxSeparate;
            p.x = E[0], p.y = E[1], p.z = E[2], d.threeDStartRotation = e.threeDStartRotation, d.startRotationType = e.startRotationType, d.startRotationConstant = e.startRotationConstant * r;
            var g = e.startRotationConstantSeparate,
                S = d.startRotationConstantSeparate;
            S.x = g[0] * r, S.y = g[1] * r, S.z = g[2] * r, d.startRotationConstantMin = e.startRotationConstantMin * r, d.startRotationConstantMax = e.startRotationConstantMax * r;
            var R = e.startRotationConstantMinSeparate,
                v = d.startRotationConstantMinSeparate;
            v.x = R[0] * r, v.y = R[1] * r, v.z = R[2] * r;
            var A = e.startRotationConstantMaxSeparate,
                I = d.startRotationConstantMaxSeparate;
            I.x = A[0] * r, I.y = A[1] * r, I.z = A[2] * r, d.randomizeRotationDirection = e.randomizeRotationDirection, d.startColorType = e.startColorType;
            var x = e.startColorConstant,
                L = d.startColorConstant;
            L.x = x[0], L.y = x[1], L.z = x[2], L.w = x[3];
            var D = e.startColorConstantMin,
                C = d.startColorConstantMin;
            C.x = D[0], C.y = D[1], C.z = D[2], C.w = D[3];
            var y = e.startColorConstantMax,
                M = d.startColorConstantMax;
            M.x = y[0], M.y = y[1], M.z = y[2], M.w = y[3], d.gravityModifier = e.gravityModifier, d.simulationSpace = e.simulationSpace, void 0 !== e.simulationSpeed &amp;&amp; (d.simulationSpeed = e.simulationSpeed), d.scaleMode = e.scaleMode, d.playOnAwake = e.playOnAwake, d.maxParticles = e.maxParticles;
            var O = e.autoRandomSeed;
            null != O &amp;&amp; (d.autoRandomSeed = O);
            var N = e.randomSeed;
            null != N &amp;&amp; (d.randomSeed[0] = N);
            var b = e.emission,
                P = d.emission;
            if (b) {
                P.emissionRate = b.emissionRate;
                var w = b.bursts;
                if (w)
                    for (s = 0, o = w.length; s &lt; o; s++) {
                        var V = w[s];
                        P.addBurst(new yr(V.time, V.min, V.max))
                    }
                P.enable = b.enable
            } else P.enable = !1;
            var B = e.shape;
            if (B) {
                var F;
                switch (B.shapeType) {
                    case 0:
                        var U;
                        F = U = new Xr, U.radius = B.sphereRadius, U.emitFromShell = B.sphereEmitFromShell, U.randomDirection = B.sphereRandomDirection;
                        break;
                    case 1:
                        var G;
                        F = G = new kr, G.radius = B.hemiSphereRadius, G.emitFromShell = B.hemiSphereEmitFromShell, G.randomDirection = B.hemiSphereRandomDirection;
                        break;
                    case 2:
                        var z;
                        F = z = new Wr, z.angle = B.coneAngle * r, z.radius = B.coneRadius, z.length = B.coneLength, z.emitType = B.coneEmitType, z.randomDirection = B.coneRandomDirection;
                        break;
                    case 3:
                        var H;
                        F = H = new zr, H.x = B.boxX, H.y = B.boxY, H.z = B.boxZ, H.randomDirection = B.boxRandomDirection;
                        break;
                    case 7:
                        var W;
                        F = W = new Hr, W.radius = B.circleRadius, W.arc = B.circleArc * r, W.emitFromEdge = B.circleEmitFromEdge, W.randomDirection = B.circleRandomDirection;
                        break;
                    default:
                        var k;
                        F = k = new Hr, k.radius = B.circleRadius, k.arc = B.circleArc * r, k.emitFromEdge = B.circleEmitFromEdge, k.randomDirection = B.circleRandomDirection
                }
                F.enable = B.enable, d.shape = F
            }
            var X = e.velocityOverLifetime;
            if (X) {
                var Y, j = X.velocity;
                switch (j.type) {
                    case 0:
                        var Z = j.constant;
                        Y = Br.createByConstant(new a(Z[0], Z[1], Z[2]));
                        break;
                    case 1:
                        Y = Br.createByGradient(this._initParticleVelocity(j.gradientX), this._initParticleVelocity(j.gradientY), this._initParticleVelocity(j.gradientZ));
                        break;
                    case 2:
                        var q = j.constantMin,
                            Q = j.constantMax;
                        Y = Br.createByRandomTwoConstant(new a(q[0], q[1], q[2]), new a(Q[0], Q[1], Q[2]));
                        break;
                    case 3:
                        Y = Br.createByRandomTwoGradient(this._initParticleVelocity(j.gradientXMin), this._initParticleVelocity(j.gradientXMax), this._initParticleVelocity(j.gradientYMin), this._initParticleVelocity(j.gradientYMax), this._initParticleVelocity(j.gradientZMin), this._initParticleVelocity(j.gradientZMax))
                }
                var K = new qr(Y);
                K.space = X.space, K.enable = X.enable, d.velocityOverLifetime = K
            }
            var J = e.colorOverLifetime;
            if (J) {
                var $, ee = J.color;
                switch (ee.type) {
                    case 0:
                        var te = ee.constant;
                        $ = Mr.createByConstant(new n(te[0], te[1], te[2], te[3]));
                        break;
                    case 1:
                        $ = Mr.createByGradient(this._initParticleColor(ee.gradient));
                        break;
                    case 2:
                        var re = ee.constantMin,
                            ie = ee.constantMax;
                        $ = Mr.createByRandomTwoConstant(new n(re[0], re[1], re[2], re[3]), new n(ie[0], ie[1], ie[2], ie[3]));
                        break;
                    case 3:
                        $ = Mr.createByRandomTwoGradient(this._initParticleColor(ee.gradientMin), this._initParticleColor(ee.gradientMax))
                }
                var ne = new Or($);
                ne.enable = J.enable, d.colorOverLifetime = ne
            }
            var ae = e.sizeOverLifetime;
            if (ae) {
                var se, oe = ae.size;
                switch (oe.type) {
                    case 0:
                        se = oe.separateAxes ? Vr.createByGradientSeparate(this._initParticleSize(oe.gradientX), this._initParticleSize(oe.gradientY), this._initParticleSize(oe.gradientZ)) : Vr.createByGradient(this._initParticleSize(oe.gradient));
                        break;
                    case 1:
                        if (oe.separateAxes) {
                            var le = oe.constantMinSeparate,
                                _e = oe.constantMaxSeparate;
                            se = Vr.createByRandomTwoConstantSeparate(new a(le[0], le[1], le[2]), new a(_e[0], _e[1], _e[2]))
                        } else se = Vr.createByRandomTwoConstant(oe.constantMin, oe.constantMax);
                        break;
                    case 2:
                        se = oe.separateAxes ? Vr.createByRandomTwoGradientSeparate(this._initParticleSize(oe.gradientXMin), this._initParticleSize(oe.gradientYMin), this._initParticleSize(oe.gradientZMin), this._initParticleSize(oe.gradientXMax), this._initParticleSize(oe.gradientYMax), this._initParticleSize(oe.gradientZMax)) : Vr.createByRandomTwoGradient(this._initParticleSize(oe.gradientMin), this._initParticleSize(oe.gradientMax))
                }
                var he = new Yr(se);
                he.enable = ae.enable, d.sizeOverLifetime = he
            }
            var ce = e.rotationOverLifetime;
            if (ce) {
                var de, ue = ce.angularVelocity;
                switch (ue.type) {
                    case 0:
                        if (ue.separateAxes) {
                            var me = ue.constantSeparate;
                            de = br.createByConstantSeparate(new a(me[0] * r, me[1] * r, me[2] * r))
                        } else de = br.createByConstant(ue.constant * r);
                        break;
                    case 1:
                        de = ue.separateAxes ? br.createByGradientSeparate(this._initParticleRotation(ue.gradientX), this._initParticleRotation(ue.gradientY), this._initParticleRotation(ue.gradientZ)) : br.createByGradient(this._initParticleRotation(ue.gradient));
                        break;
                    case 2:
                        if (ue.separateAxes) {
                            var fe = ue.constantMinSeparate,
                                Te = ue.constantMaxSeparate;
                            de = br.createByRandomTwoConstantSeparate(new a(fe[0] * r, fe[1] * r, fe[2] * r), new a(Te[0] * r, Te[1] * r, Te[2] * r))
                        } else de = br.createByRandomTwoConstant(ue.constantMin * r, ue.constantMax * r);
                        break;
                    case 3:
                        ue.separateAxes || (de = br.createByRandomTwoGradient(this._initParticleRotation(ue.gradientMin), this._initParticleRotation(ue.gradientMax)))
                }
                var Ee = new Fr(de);
                Ee.enable = ce.enable, d.rotationOverLifetime = Ee
            }
            var pe = e.textureSheetAnimation;
            if (pe) {
                var ge, Se = pe.frame;
                switch (Se.type) {
                    case 0:
                        ge = Nr.createByConstant(Se.constant);
                        break;
                    case 1:
                        ge = Nr.createByOverTime(this._initParticleFrame(Se.overTime));
                        break;
                    case 2:
                        ge = Nr.createByRandomTwoConstant(Se.constantMin, Se.constantMax);
                        break;
                    case 3:
                        ge = Nr.createByRandomTwoOverTime(this._initParticleFrame(Se.overTimeMin), this._initParticleFrame(Se.overTimeMax))
                }
                var Re, ve = pe.startFrame;
                switch (ve.type) {
                    case 0:
                        Re = jr.createByConstant(ve.constant);
                        break;
                    case 1:
                        Re = jr.createByRandomTwoConstant(ve.constantMin, ve.constantMax)
                }
                var Ae = new Zr(ge, Re);
                Ae.enable = pe.enable;
                var Ie = pe.tiles;
                Ae.tiles = new i(Ie[0], Ie[1]), Ae.type = pe.type, Ae.randomRow = pe.randomRow;
                var xe = pe.rowIndex;
                void 0 !== xe &amp;&amp; (Ae.rowIndex = xe), Ae.cycles = pe.cycles, d.textureSheetAnimation = Ae
            }
        }
        _initParticleColor(e) {
            var t = new Cr(4, 4);
            if (e) {
                var r, i, n = e.alphas;
                if (n)
                    for (r = 0, i = n.length; r &lt; i; r++) {
                        3 == r &amp;&amp; i &gt; 4 &amp;&amp; (r = i - 1, console.warn("GradientDataColor warning:alpha data length is large than 4, will ignore the middle data."));
                        var a = n[r];
                        t.addColorAlpha(a.key, a.value)
                    } else t.addColorAlpha(0, 1), t.addColorAlpha(1, 1);
                var s = e.rgbs;
                if (s)
                    for (r = 0, i = s.length; r &lt; i; r++) {
                        3 == r &amp;&amp; i &gt; 4 &amp;&amp; (r = i - 1, console.warn("GradientDataColor warning:rgb data length is large than 4, will ignore the middle data."));
                        var o = s[r],
                            l = o.value;
                        t.addColorRGB(o.key, new ze(l[0], l[1], l[2], 1))
                    } else t.addColorRGB(0, new ze(1, 1, 1, 1)), t.addColorRGB(1, new ze(1, 1, 1, 1))
            } else t.addColorAlpha(0, 1), t.addColorAlpha(1, 1), t.addColorRGB(0, new ze(1, 1, 1, 1)), t.addColorRGB(1, new ze(1, 1, 1, 1));
            return t
        }
        _initParticleFrame(e) {
            var t = new Pr;
            if (e)
                for (var r = e.frames, i = 0, n = r.length; i &lt; n; i++) {
                    var a = r[i];
                    t.add(a.key, a.value)
                } else t.add(0, 0), t.add(1, 1);
            return t
        }
        static _initStartLife(e) {
            for (var t = new wr, r = e.startLifetimes, i = 0, n = r.length; i &lt; n; i++) {
                var a = r[i];
                t.add(a.key, a.value)
            }
            return t
        }
        _initParticleVelocity(e) {
            for (var t = new wr, r = e.velocitys, i = 0, n = r.length; i &lt; n; i++) {
                var a = r[i];
                t.add(a.key, a.value)
            }
            return t
        }
        _initParticleSize(e) {
            var t = new wr;
            if (e)
                for (var r = e.sizes, i = 0, n = r.length; i &lt; n; i++) {
                    var a = r[i];
                    t.add(a.key, a.value)
                } else t.add(0, 0), t.add(1, 1);
            return t
        }
        _initParticleRotation(e) {
            for (var t = new wr, r = e.angularVelocitys, i = 0, n = r.length; i &lt; n; i++) {
                var a = r[i];
                t.add(a.key, a.value / 180 * Math.PI)
            }
            return t
        }
    }
    class oi {}
    class li extends vr {
        constructor(e) {
            super(e), this._bones = [], this._skinnedDataLoopMarks = [], this._localBounds = new wt(a._ZERO, a._ZERO), this._cacheAnimationNode = []
        }
        get localBounds() {
            return this._localBounds
        }
        set localBounds(e) {
            this._localBounds = e
        }
        get rootBone() {
            return this._cacheRootBone
        }
        set rootBone(e) {
            this._cacheRootBone != e &amp;&amp; (this._cacheRootBone ? this._cacheRootBone.transform.off(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatNeedChange) : this._owner.transform.off(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatNeedChange), e ? e.transform.on(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatNeedChange) : this._owner.transform.on(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatNeedChange), this._cacheRootBone = e, this._onWorldMatNeedChange(f.TRANSFORM_WORLDPOSITION | f.TRANSFORM_WORLDQUATERNION | f.TRANSFORM_WORLDSCALE))
        }
        get bones() {
            return this._bones
        }
        _computeSkinnedData() {
            if (this._cacheMesh &amp;&amp; this._cacheAvatar || this._cacheMesh &amp;&amp; !this._cacheAvatar)
                for (var e = this._cacheMesh._inverseBindPoses, t = this._cacheMesh._skinnedMatrixCaches, r = 0, i = this._cacheMesh.subMeshCount; r &lt; i; r++)
                    for (var n = this._cacheMesh.getSubMesh(r)._boneIndicesList, a = this._skinnedData[r], s = 0, o = n.length; s &lt; o; s++) {
                        var l = n[s];
                        this._computeSubSkinnedData(e, l, a[s], t)
                    }
        }
        _computeSubSkinnedData(e, r, i, n) {
            for (var a = 0, s = r.length; a &lt; s; a++) {
                var o = r[a];
                if (this._skinnedDataLoopMarks[o] === t.Stat.loopCount)
                    for (var l = n[o], _ = this._skinnedData[l.subMeshIndex][l.batchIndex], h = 16 * l.batchBoneIndex, c = 16 * a, d = 0; d &lt; 16; d++) i[c + d] = _[h + d];
                else this._cacheAvatar ? N._mulMatrixArray(this._cacheAnimationNode[o].transform.getWorldMatrix(), e[o].elements, 0, i, 16 * a) : N._mulMatrixArray(this._bones[o].transform.worldMatrix.elements, e[o].elements, 0, i, 16 * a), this._skinnedDataLoopMarks[o] = t.Stat.loopCount
            }
        }
        _onWorldMatNeedChange(e) {
            this._boundsChange = !0, this._octreeNode &amp;&amp; (this._cacheAvatar ? -1 === this._indexInOctreeMotionList &amp;&amp; this._octreeNode._octree.addMotionObject(this) : (e &amp;= f.TRANSFORM_WORLDPOSITION | f.TRANSFORM_WORLDQUATERNION | f.TRANSFORM_WORLDSCALE) &amp;&amp; -1 === this._indexInOctreeMotionList &amp;&amp; this._octreeNode._octree.addMotionObject(this))
        }
        _createRenderElement() {
            return new Ht
        }
        _onMeshChange(e) {
            super._onMeshChange(e), this._cacheMesh = e;
            var t = e.subMeshCount;
            this._skinnedData = [], this._skinnedDataLoopMarks.length = e._inverseBindPoses.length;
            for (var r = 0; r &lt; t; r++)
                for (var i = e.getSubMesh(r)._boneIndicesList, n = i.length, a = this._skinnedData[r] = [], s = 0; s &lt; n; s++) a[s] = new Float32Array(16 * i[s].length);
            this._cacheAvatar &amp;&amp; e &amp;&amp; this._getCacheAnimationNodes()
        }
        _setCacheAnimator(e) {
            this._cacheAnimator = e, this._shaderValues.addDefine(oi.SHADERDEFINE_BONE), this._setRootNode()
        }
        _calculateBoundingBox() {
            if (this._cacheAvatar)
                if (this._cacheAnimator &amp;&amp; this._rootBone) {
                    var e = li._tempMatrix4x4;
                    N.matrix4x4MultiplyMFM(this._cacheAnimator.owner.transform.worldMatrix, this._cacheRootAnimationNode.transform.getWorldMatrix(), e), this._localBounds._tranform(e, this._bounds)
                } else super._calculateBoundingBox();
            else this._cacheRootBone ? this._localBounds._tranform(this._cacheRootBone.transform.worldMatrix, this._bounds) : this._localBounds._tranform(this._owner.transform.worldMatrix, this._bounds);
            if (t.Render.supportWebGLPlusCulling) {
                var r = this._bounds.getMin(),
                    i = this._bounds.getMax(),
                    n = ke._cullingBuffer;
                n[this._cullingBufferIndex + 1] = r.x, n[this._cullingBufferIndex + 2] = r.y, n[this._cullingBufferIndex + 3] = r.z, n[this._cullingBufferIndex + 4] = i.x, n[this._cullingBufferIndex + 5] = i.y, n[this._cullingBufferIndex + 6] = i.z
            }
        }
        _renderUpdate(e, t) {
            if (this._cacheAnimator)
                if (this._computeSkinnedData(), this._cacheAvatar) {
                    var r = this._cacheAnimator.owner._transform;
                    this._shaderValues.setMatrix4x4(ut.WORLDMATRIX, r.worldMatrix)
                } else this._shaderValues.setMatrix4x4(ut.WORLDMATRIX, c.DEFAULT);
            else this._shaderValues.setMatrix4x4(ut.WORLDMATRIX, t.worldMatrix)
        }
        _renderUpdateWithCamera(e, t) {
            var r = e.projectionViewMatrix;
            if (this._cacheAnimator)
                if (this._cacheAvatar) {
                    var i = this._cacheAnimator.owner._transform;
                    c.multiply(r, i.worldMatrix, this._projectionViewWorldMatrix), this._shaderValues.setMatrix4x4(ut.MVPMATRIX, this._projectionViewWorldMatrix)
                } else this._shaderValues.setMatrix4x4(ut.MVPMATRIX, r);
            else c.multiply(r, t.worldMatrix, this._projectionViewWorldMatrix), this._shaderValues.setMatrix4x4(ut.MVPMATRIX, this._projectionViewWorldMatrix)
        }
        _destroy() {
            super._destroy(), this._cacheAvatar ? this._cacheRootAnimationNode &amp;&amp; this._cacheRootAnimationNode.transform.off(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatNeedChange) : this._cacheRootBone ? !this._cacheRootBone.destroyed &amp;&amp; this._cacheRootBone.transform.off(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatNeedChange) : this._owner &amp;&amp; !this._owner.destroyed &amp;&amp; this._owner.transform.off(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatNeedChange)
        }
        get bounds() {
            return (this._boundsChange || this._cacheAvatar) &amp;&amp; (this._calculateBoundingBox(), this._boundsChange = !1), this._bounds
        }
        _setRootBone(e) {
            this._rootBone = e, this._setRootNode()
        }
        _setRootNode() {
            var e;
            e = this._cacheAnimator &amp;&amp; this._rootBone &amp;&amp; this._cacheAvatar ? this._cacheAnimator._avatarNodeMap[this._rootBone] : null, this._cacheRootAnimationNode != e &amp;&amp; (this._onWorldMatNeedChange(f.TRANSFORM_WORLDPOSITION | f.TRANSFORM_WORLDQUATERNION | f.TRANSFORM_WORLDSCALE), this._owner.transform.off(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatNeedChange), this._cacheRootAnimationNode &amp;&amp; this._cacheRootAnimationNode.transform.off(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatNeedChange), e &amp;&amp; e.transform.on(t.Event.TRANSFORM_CHANGED, this, this._onWorldMatNeedChange), this._cacheRootAnimationNode = e)
        }
        _getCacheAnimationNodes() {
            var e = this._cacheMesh._boneNames,
                r = this._cacheMesh._inverseBindPoses.length;
            if (t.Render.supportWebGLPlusAnimation) {
                this._cacheAnimationNodeIndices = new Uint16Array(r);
                var i = this._cacheAnimator._avatarNodeMap;
                for (s = 0; s &lt; r; s++) {
                    var n = i[e[s]];
                    this._cacheAnimationNodeIndices[s] = n ? n._worldMatrixIndex : 0
                }
            } else {
                this._cacheAnimationNode.length = r;
                for (var a = this._cacheAnimator._avatarNodeMap, s = 0; s &lt; r; s++) {
                    var o = a[e[s]];
                    this._cacheAnimationNode[s] = o
                }
            }
        }
        _setCacheAvatar(e) {
            this._cacheAvatar !== e &amp;&amp; (this._cacheMesh ? (this._cacheAvatar = e, e &amp;&amp; (this._shaderValues.addDefine(oi.SHADERDEFINE_BONE), this._getCacheAnimationNodes())) : this._cacheAvatar = e, this._setRootNode())
        }
        _computeSubSkinnedDataNative(e, r, i, n, a) {
            t.LayaGL.instance.computeSubSkinnedData(e, r, i, n, a)
        }
        _computeSkinnedDataForNative() {
            if (this._cacheMesh &amp;&amp; this._cacheAvatar || this._cacheMesh &amp;&amp; !this._cacheAvatar)
                for (var e = this._cacheMesh._inverseBindPoses, r = this._cacheMesh._skinnedMatrixCaches, i = 0, n = this._cacheMesh.subMeshCount; i &lt; n; i++)
                    for (var a = this._cacheMesh.getSubMesh(i)._boneIndicesList, s = this._skinnedData[i], o = 0, l = a.length; o &lt; l; o++) {
                        var _ = a[o];
                        this._cacheAvatar &amp;&amp; t.Render.supportWebGLPlusAnimation ? this._computeSubSkinnedDataNative(this._cacheAnimator._animationNodeWorldMatrixs, this._cacheAnimationNodeIndices, this._cacheMesh._inverseBindPosesBuffer, _, s[o]) : this._computeSubSkinnedData(e, _, s[o], r)
                    }
        }
    }
    li._tempMatrix4x4 = new c;
    class _i extends Ut {
        constructor(e = null, t = null) {
            super(t), this._meshFilter = new Ar(this), this._render = new li(this), e &amp;&amp; (this._meshFilter.sharedMesh = e)
        }
        static __init__() {
            oi.SHADERDEFINE_BONE = he.getDefineByName("BONE")
        }
        get meshFilter() {
            return this._meshFilter
        }
        get skinnedMeshRenderer() {
            return this._render
        }
        _parse(e, r) {
            super._parse(e, r);
            var i = this.skinnedMeshRenderer,
                s = e.lightmapIndex;
            null != s &amp;&amp; (i.lightmapIndex = s);
            var o, l = e.lightmapScaleOffset;
            if (l &amp;&amp; (i.lightmapScaleOffset = new n(l[0], l[1], l[2], l[3])), null != e.enableRender &amp;&amp; (i.enable = e.enableRender), null != e.receiveShadows &amp;&amp; (i.receiveShadow = e.receiveShadows), null != e.castShadow &amp;&amp; (i.castShadow = e.castShadow), o = e.meshPath) {
                var _ = t.Loader.getRes(o);
                _ &amp;&amp; (this.meshFilter.sharedMesh = _)
            }
            var h = e.materials;
            if (h) {
                var c = i.sharedMaterials,
                    d = h.length;
                c.length = d;
                for (var u = 0; u &lt; d; u++) c[u] = t.Loader.getRes(h[u].path);
                i.sharedMaterials = c
            }
            var m = e.boundBox,
                f = m.min,
                T = m.max;
            if (i.localBounds.setMin(new a(f[0], f[1], f[2])), i.localBounds.setMax(new a(T[0], T[1], T[2])), r) {
                var E = e.rootBone;
                i.rootBone = r[E];
                var p, g = e.bones;
                for (u = 0, p = g.length; u &lt; p; u++) i.bones.push(r[g[u]])
            } else e.rootBone &amp;&amp; i._setRootBone(e.rootBone)
        }
        _changeHierarchyAnimator(e) {
            super._changeHierarchyAnimator(e), this.skinnedMeshRenderer._setCacheAnimator(e)
        }
        _changeAnimatorAvatar(e) {
            this.skinnedMeshRenderer._setCacheAvatar(e)
        }
        _cloneTo(e, t, r) {
            var i = e;
            i.meshFilter.sharedMesh = this.meshFilter.sharedMesh;
            var n = this._render,
                a = i._render;
            a.enable = n.enable, a.sharedMaterials = n.sharedMaterials, a.castShadow = n.castShadow;
            var s = n.lightmapScaleOffset;
            s &amp;&amp; (a.lightmapScaleOffset = s.clone()), a.receiveShadow = n.receiveShadow, a.sortingFudge = n.sortingFudge, a._rootBone = n._rootBone;
            var o = n.bones,
                l = a.bones,
                _ = o.length;
            l.length = _;
            var h = n.rootBone;
            if (h) {
                var c = N._getHierarchyPath(t, h, _i._tempArray0);
                a.rootBone = c ? N._getNodeByHierarchyPath(r, c) : h
            }
            for (var d = 0; d &lt; o.length; d++) c = N._getHierarchyPath(t, o[d], _i._tempArray0), l[d] = c ? N._getNodeByHierarchyPath(r, c) : o[d];
            var u = n.localBounds;
            u &amp;&amp; u.cloneTo(a.localBounds), super._cloneTo(e, t, r)
        }
        destroy(e = !0) {
            this.destroyed || (super.destroy(e), this._meshFilter.destroy())
        }
        _create() {
            return new _i
        }
    }
    _i._tempArray0 = [], _i.BONES = he.propertyNameToID("u_Bones");
    class hi extends Te {
        constructor() {
            super(), this.setShaderName("Trail"), this._color = new n(1, 1, 1, 1), this._shaderValues.setVector(hi.TINTCOLOR, new n(1, 1, 1, 1)), this.renderMode = hi.RENDERMODE_ALPHABLENDED
        }
        static __initDefine__() {
            hi.SHADERDEFINE_MAINTEXTURE = he.getDefineByName("MAINTEXTURE"), hi.SHADERDEFINE_TILINGOFFSET = he.getDefineByName("TILINGOFFSET"), hi.SHADERDEFINE_ADDTIVEFOG = he.getDefineByName("ADDTIVEFOG")
        }
        get _TintColorR() {
            return this._color.x
        }
        set _TintColorR(e) {
            this._color.x = e, this.color = this._color
        }
        get _TintColorG() {
            return this._color.y
        }
        set _TintColorG(e) {
            this._color.y = e, this.color = this._color
        }
        get _TintColorB() {
            return this._color.z
        }
        set _TintColorB(e) {
            this._color.z = e, this.color = this._color
        }
        get _TintColorA() {
            return this._color.w
        }
        set _TintColorA(e) {
            this._color.w = e, this.color = this._color
        }
        get _MainTex_STX() {
            return this._shaderValues.getVector(hi.TILINGOFFSET).x
        }
        set _MainTex_STX(e) {
            var t = this._shaderValues.getVector(hi.TILINGOFFSET);
            t.x = e, this.tilingOffset = t
        }
        get _MainTex_STY() {
            return this._shaderValues.getVector(hi.TILINGOFFSET).y
        }
        set _MainTex_STY(e) {
            var t = this._shaderValues.getVector(hi.TILINGOFFSET);
            t.y = e, this.tilingOffset = t
        }
        get _MainTex_STZ() {
            return this._shaderValues.getVector(hi.TILINGOFFSET).z
        }
        set _MainTex_STZ(e) {
            var t = this._shaderValues.getVector(hi.TILINGOFFSET);
            t.z = e, this.tilingOffset = t
        }
        get _MainTex_STW() {
            return this._shaderValues.getVector(hi.TILINGOFFSET).w
        }
        set _MainTex_STW(e) {
            var t = this._shaderValues.getVector(hi.TILINGOFFSET);
            t.w = e, this.tilingOffset = t
        }
        set renderMode(e) {
            switch (e) {
                case hi.RENDERMODE_ADDTIVE:
                    this.renderQueue = Te.RENDERQUEUE_TRANSPARENT, this.alphaTest = !1, this.depthWrite = !1, this.cull = pe.CULL_NONE, this.blend = pe.BLEND_ENABLE_ALL, this.blendSrc = pe.BLENDPARAM_SRC_ALPHA, this.blendDst = pe.BLENDPARAM_ONE, this.depthTest = pe.DEPTHTEST_LESS, this._shaderValues.addDefine(hi.SHADERDEFINE_ADDTIVEFOG);
                    break;
                case hi.RENDERMODE_ALPHABLENDED:
                    this.renderQueue = Te.RENDERQUEUE_TRANSPARENT, this.alphaTest = !1, this.depthWrite = !1, this.cull = pe.CULL_NONE, this.blend = pe.BLEND_ENABLE_ALL, this.blendSrc = pe.BLENDPARAM_SRC_ALPHA, this.blendDst = pe.BLENDPARAM_ONE_MINUS_SRC_ALPHA, this.depthTest = pe.DEPTHTEST_LESS, this._shaderValues.removeDefine(hi.SHADERDEFINE_ADDTIVEFOG);
                    break;
                default:
                    throw new Error("TrailMaterial : renderMode value error.")
            }
        }
        get colorR() {
            return this._TintColorR
        }
        set colorR(e) {
            this._TintColorR = e
        }
        get colorG() {
            return this._TintColorG
        }
        set colorG(e) {
            this._TintColorG = e
        }
        get colorB() {
            return this._TintColorB
        }
        set colorB(e) {
            this._TintColorB = e
        }
        get colorA() {
            return this._TintColorA
        }
        set colorA(e) {
            this._TintColorA = e
        }
        get color() {
            return this._shaderValues.getVector(hi.TINTCOLOR)
        }
        set color(e) {
            this._shaderValues.setVector(hi.TINTCOLOR, e)
        }
        get texture() {
            return this._shaderValues.getTexture(hi.MAINTEXTURE)
        }
        set texture(e) {
            e ? this._shaderValues.addDefine(hi.SHADERDEFINE_MAINTEXTURE) : this._shaderValues.removeDefine(hi.SHADERDEFINE_MAINTEXTURE), this._shaderValues.setTexture(hi.MAINTEXTURE, e)
        }
        get tilingOffsetX() {
            return this._MainTex_STX
        }
        set tilingOffsetX(e) {
            this._MainTex_STX = e
        }
        get tilingOffsetY() {
            return this._MainTex_STY
        }
        set tilingOffsetY(e) {
            this._MainTex_STY = e
        }
        get tilingOffsetZ() {
            return this._MainTex_STZ
        }
        set tilingOffsetZ(e) {
            this._MainTex_STZ = e
        }
        get tilingOffsetW() {
            return this._MainTex_STW
        }
        set tilingOffsetW(e) {
            this._MainTex_STW = e
        }
        get tilingOffset() {
            return this._shaderValues.getVector(hi.TILINGOFFSET)
        }
        set tilingOffset(e) {
            e &amp;&amp; (1 != e.x || 1 != e.y || 0 != e.z || 0 != e.w) ? this._shaderValues.addDefine(hi.SHADERDEFINE_TILINGOFFSET) : this._shaderValues.removeDefine(hi.SHADERDEFINE_TILINGOFFSET), this._shaderValues.setVector(hi.TILINGOFFSET, e)
        }
        set depthWrite(e) {
            this._shaderValues.setBool(hi.DEPTH_WRITE, e)
        }
        get depthWrite() {
            return this._shaderValues.getBool(hi.DEPTH_WRITE)
        }
        set cull(e) {
            this._shaderValues.setInt(hi.CULL, e)
        }
        get cull() {
            return this._shaderValues.getInt(hi.CULL)
        }
        set blend(e) {
            this._shaderValues.setInt(hi.BLEND, e)
        }
        get blend() {
            return this._shaderValues.getInt(hi.BLEND)
        }
        set blendSrc(e) {
            this._shaderValues.setInt(hi.BLEND_SRC, e)
        }
        get blendSrc() {
            return this._shaderValues.getInt(hi.BLEND_SRC)
        }
        set blendDst(e) {
            this._shaderValues.setInt(hi.BLEND_DST, e)
        }
        get blendDst() {
            return this._shaderValues.getInt(hi.BLEND_DST)
        }
        set depthTest(e) {
            this._shaderValues.setInt(hi.DEPTH_TEST, e)
        }
        get depthTest() {
            return this._shaderValues.getInt(hi.DEPTH_TEST)
        }
        clone() {
            var e = new hi;
            return this.cloneTo(e), e
        }
    }
    hi.RENDERMODE_ALPHABLENDED = 0, hi.RENDERMODE_ADDTIVE = 1, hi.MAINTEXTURE = he.propertyNameToID("u_MainTexture"), hi.TINTCOLOR = he.propertyNameToID("u_MainColor"), hi.TILINGOFFSET = he.propertyNameToID("u_TilingOffset"), hi.CULL = he.propertyNameToID("s_Cull"), hi.BLEND = he.propertyNameToID("s_Blend"), hi.BLEND_SRC = he.propertyNameToID("s_BlendSrc"), hi.BLEND_DST = he.propertyNameToID("s_BlendDst"), hi.DEPTH_TEST = he.propertyNameToID("s_DepthTest"), hi.DEPTH_WRITE = he.propertyNameToID("s_DepthWrite");
    class ci {}
    ci.Stretch = 0, ci.Tile = 1, (cr = e.TrailAlignment || (e.TrailAlignment = {}))[cr.View = 0] = "View", cr[cr.TransformZ = 1] = "TransformZ";
    class di {
        static get vertexDeclaration1() {
            return di._vertexDeclaration1
        }
        static get vertexDeclaration2() {
            return di._vertexDeclaration2
        }
        get vertexDeclaration() {
            return di._vertexDeclaration1
        }
        static __init__() {
            di._vertexDeclaration1 = new st(32, [new ot(0, at.Vector3, di.TRAIL_POSITION0), new ot(12, at.Vector3, di.TRAIL_OFFSETVECTOR), new ot(24, at.Single, di.TRAIL_TIME0), new ot(28, at.Single, di.TRAIL_TEXTURECOORDINATE0Y)]), di._vertexDeclaration2 = new st(20, [new ot(0, at.Single, di.TRAIL_TEXTURECOORDINATE0X), new ot(4, at.Color, di.TRAIL_COLOR)])
        }
    }
    di.TRAIL_POSITION0 = 0, di.TRAIL_OFFSETVECTOR = 1, di.TRAIL_TIME0 = 2, di.TRAIL_TEXTURECOORDINATE0Y = 3, di.TRAIL_TEXTURECOORDINATE0X = 4, di.TRAIL_COLOR = 5;
    class ui extends Vt {
        constructor(e) {
            super(), this._floatCountPerVertices1 = 8, this._floatCountPerVertices2 = 5, this._increaseSegementCount = 16, this._activeIndex = 0, this._endIndex = 0, this._needAddFirstVertex = !1, this._isTempEndVertex = !1, this._vertices1 = null, this._vertices2 = null, this._lastFixedVertexPosition = new a, this._bufferState = new it, this.tmpColor = new ze, this._disappearBoundsMode = !1, this._owner = e, this._segementCount = this._increaseSegementCount, this._resizeData(this._segementCount, this._bufferState);
            var r = this._owner._owner.trailRenderer.bounds,
                i = this._owner._owner.transform.position;
            r.setMin(i), r.setMax(i), t.Render.supportWebGLPlusCulling &amp;&amp; this._calculateBoundingBoxForNative()
        }
        _resizeData(e, r) {
            this._subBirthTime = new Float32Array(e), this._subDistance = new Float64Array(e);
            var i = t.LayaGL.instance,
                n = 2 * e,
                a = di.vertexDeclaration1,
                s = di.vertexDeclaration2,
                o = [],
                l = n * a.vertexStride,
                _ = n * s.vertexStride,
                h = l + _;
            this._vertices1 = new Float32Array(n * this._floatCountPerVertices1), this._vertices2 = new Float32Array(n * this._floatCountPerVertices2), this._vertexBuffer1 = new _t(l, i.STATIC_DRAW, !1), this._vertexBuffer1.vertexDeclaration = a, this._vertexBuffer2 = new _t(_, i.DYNAMIC_DRAW, !1), this._vertexBuffer2.vertexDeclaration = s, o.push(this._vertexBuffer1), o.push(this._vertexBuffer2), r.bind(), r.applyVertexBuffers(o), r.unBind(), t.Resource._addMemory(h, h)
        }
        _resetData() {
            var e = this._endIndex - this._activeIndex,
                r = new Float32Array(this._vertices1.buffer, 2 * this._floatCountPerVertices1 * this._activeIndex * 4, 2 * this._floatCountPerVertices1 * e),
                i = new Float32Array(this._vertices2.buffer, 2 * this._floatCountPerVertices2 * this._activeIndex * 4, 2 * this._floatCountPerVertices2 * e),
                n = new Float64Array(this._subDistance.buffer, 8 * this._activeIndex, e),
                a = new Float32Array(this._subBirthTime.buffer, 4 * this._activeIndex, e);
            if (e === this._segementCount) {
                this._vertexBuffer1.destroy(), this._vertexBuffer2.destroy();
                var s = this._vertexBuffer1._byteLength + this._vertexBuffer2._byteLength;
                t.Resource._addMemory(-s, -s), this._segementCount += this._increaseSegementCount, this._resizeData(this._segementCount, this._bufferState)
            }
            this._vertices1.set(r, 0), this._vertices2.set(i, 0), this._subDistance.set(n, 0), this._subBirthTime.set(a, 0), this._endIndex = e, this._activeIndex = 0, this._vertexBuffer1.setData(this._vertices1.buffer, 0, 2 * this._floatCountPerVertices1 * this._activeIndex * 4, 2 * this._floatCountPerVertices1 * e * 4), this._vertexBuffer2.setData(this._vertices2.buffer, 0, 2 * this._floatCountPerVertices2 * this._activeIndex * 4, 2 * this._floatCountPerVertices2 * e * 4)
        }
        _updateTrail(e, t, r) {
            a.equals(t, r) || (this._endIndex - this._activeIndex == 0 ? this._addTrailByFirstPosition(e, r) : this._addTrailByNextPosition(e, r))
        }
        _addTrailByFirstPosition(e, t) {
            this._endIndex === this._segementCount &amp;&amp; this._resetData(), this._subDistance[this._endIndex] = 0, this._subBirthTime[this._endIndex] = this._owner._curtime, this._endIndex++, t.cloneTo(this._lastFixedVertexPosition), this._needAddFirstVertex = !0
        }
        _addTrailByNextPosition(t, i) {
            var n = ui._tempVector30,
                s = ui._tempVector31;
            switch (this._owner.alignment) {
                case e.TrailAlignment.View:
                    var o = t.viewMatrix;
                    a.transformCoordinate(i, o, ui._tempVector33), a.transformCoordinate(this._lastFixedVertexPosition, o, ui._tempVector34), a.subtract(ui._tempVector33, ui._tempVector34, n), a.cross(ui._tempVector33, n, s);
                    break;
                case e.TrailAlignment.TransformZ:
                    a.subtract(i, this._lastFixedVertexPosition, n);
                    var l = ui._tempVector32;
                    this._owner._owner.transform.getForward(l), a.cross(n, l, s)
            }
            a.normalize(s, s), a.scale(s, this._owner.widthMultiplier / 2, s);
            var _, h, c = a.scalarLength(n);
            this._needAddFirstVertex &amp;&amp; (this._updateVerticesByPositionData(i, s, this._endIndex - 1), this._needAddFirstVertex = !1), c - this._owner.minVertexDistance &gt;= r.zeroTolerance ? (this._isTempEndVertex ? (_ = this._endIndex - 1, h = c - this._subDistance[_], this._updateVerticesByPosition(i, s, c, _), this._owner._totalLength += h) : (this._endIndex === this._segementCount &amp;&amp; this._resetData(), this._updateVerticesByPosition(i, s, c, this._endIndex), this._owner._totalLength += c, this._endIndex++), i.cloneTo(this._lastFixedVertexPosition), this._isTempEndVertex = !1) : (this._isTempEndVertex ? (_ = this._endIndex - 1, h = c - this._subDistance[_], this._updateVerticesByPosition(i, s, c, _), this._owner._totalLength += h) : (this._endIndex === this._segementCount &amp;&amp; this._resetData(), this._updateVerticesByPosition(i, s, c, this._endIndex), this._owner._totalLength += c, this._endIndex++), this._isTempEndVertex = !0)
        }
        _updateVerticesByPositionData(e, r, i) {
            var n = 2 * this._floatCountPerVertices1 * i,
                s = this._owner._curtime;
            this._vertices1[n] = e.x, this._vertices1[n + 1] = e.y, this._vertices1[n + 2] = e.z, this._vertices1[n + 3] = -r.x, this._vertices1[n + 4] = -r.y, this._vertices1[n + 5] = -r.z, this._vertices1[n + 6] = s, this._vertices1[n + 7] = 1, this._vertices1[n + 8] = e.x, this._vertices1[n + 9] = e.y, this._vertices1[n + 10] = e.z, this._vertices1[n + 11] = r.x, this._vertices1[n + 12] = r.y, this._vertices1[n + 13] = r.z, this._vertices1[n + 14] = s, this._vertices1[n + 15] = 0;
            var o = this._owner._owner.trailRenderer.bounds,
                l = o.getMin(),
                _ = o.getMax(),
                h = ui._tempVector35,
                c = ui._tempVector36,
                d = ui._tempVector32;
            a.add(e, r, h), a.subtract(e, r, c), a.min(c, h, d), a.min(l, d, l), o.setMin(l), a.max(h, c, d), a.max(_, d, _), o.setMax(_), t.Render.supportWebGLPlusCulling &amp;&amp; this._calculateBoundingBoxForNative();
            var u = 2 * this._floatCountPerVertices1;
            this._vertexBuffer1.setData(this._vertices1.buffer, 4 * n, 4 * n, 4 * u)
        }
        _updateVerticesByPosition(e, t, r, i) {
            this._updateVerticesByPositionData(e, t, i), this._subDistance[i] = r, this._subBirthTime[i] = this._owner._curtime
        }
        _updateVertexBufferUV() {
            var e, r, i;
            if (this._disappearBoundsMode) {
                e = this._owner._owner.trailRenderer.bounds;
                var n = this._owner._owner.transform.position;
                e.setMin(n), e.setMax(n), r = e.getMin(), i = e.getMax(), t.Render.supportWebGLPlusCulling &amp;&amp; this._calculateBoundingBoxForNative()
            }
            for (var s = this._endIndex, o = 0, l = this._owner.colorGradient, _ = l.colorAlphaKeysCount - 1, h = l.colorRGBKeysCount - 1, c = this._owner._totalLength, d = 2 * this._floatCountPerVertices2, u = this._activeIndex; u &lt; s; u++) {
                var m, f;
                u !== this._activeIndex &amp;&amp; (o += this._subDistance[u]), this._owner.textureMode == ci.Stretch ? f = m = 1 - o / c : (f = 1 - o / c, m = 1 - (c - o)), h = l.evaluateColorRGB(f, this.tmpColor, h, !0), _ = l.evaluateColorAlpha(f, this.tmpColor, _, !0);
                var T = u * d;
                if (this._vertices2[T + 0] = m, this._vertices2[T + 1] = this.tmpColor.r, this._vertices2[T + 2] = this.tmpColor.g, this._vertices2[T + 3] = this.tmpColor.b, this._vertices2[T + 4] = this.tmpColor.a, this._vertices2[T + 5] = m, this._vertices2[T + 6] = this.tmpColor.r, this._vertices2[T + 7] = this.tmpColor.g, this._vertices2[T + 8] = this.tmpColor.b, this._vertices2[T + 9] = this.tmpColor.a, this._disappearBoundsMode) {
                    var E = 2 * this._floatCountPerVertices1 * u,
                        p = ui._tempVector32,
                        g = ui._tempVector33,
                        S = ui._tempVector34;
                    p.setValue(this._vertices1[E + 0], this._vertices1[E + 1], this._vertices1[E + 2]), g.setValue(this._vertices1[E + 3], this._vertices1[E + 4], this._vertices1[E + 5]), a.add(p, g, S), a.min(S, r, r), a.max(S, i, i), a.subtract(p, g, S), a.min(S, r, r), a.max(S, i, i)
                }
            }
            this._disappearBoundsMode &amp;&amp; (e.setMin(r), e.setMax(i), this._disappearBoundsMode = !1, t.Render.supportWebGLPlusCulling &amp;&amp; this._calculateBoundingBoxForNative());
            var R = this._activeIndex * d;
            this._vertexBuffer2.setData(this._vertices2.buffer, 4 * R, 4 * R, 4 * (s * d - R))
        }
        _updateDisappear() {
            for (var e = this._endIndex, t = this._activeIndex; t &lt; e &amp;&amp; this._owner._curtime - this._subBirthTime[t] &gt;= this._owner.time + r.zeroTolerance; t++) {
                var i = t + 1;
                if (i !== e &amp;&amp; (this._owner._totalLength -= this._subDistance[i]), this._isTempEndVertex &amp;&amp; i === e - 1) {
                    this._floatCountPerVertices1;
                    var n = this._lastFixedVertexPosition;
                    n.x = this._vertices1[0], n.y = this._vertices1[1], n.z = this._vertices1[2], this._isTempEndVertex = !1
                }
                this._activeIndex++, this._disappearBoundsMode = !0
            }
        }
        _getType() {
            return ui._type
        }
        _prepareRender(e) {
            return this._endIndex - this._activeIndex &gt; 1
        }
        _render(e) {
            this._bufferState.bind();
            var r = t.LayaGL.instance,
                i = 2 * this._activeIndex,
                n = 2 * this._endIndex - i;
            r.drawArrays(r.TRIANGLE_STRIP, i, n), t.Stat.renderBatches++, t.Stat.trianglesFaces += n - 2
        }
        destroy() {
            super.destroy();
            var e = this._vertexBuffer1._byteLength + this._vertexBuffer2._byteLength;
            t.Resource._addMemory(-e, -e), this._bufferState.destroy(), this._vertexBuffer1.destroy(), this._vertexBuffer2.destroy(), this._bufferState = null, this._vertices1 = null, this._vertexBuffer1 = null, this._vertices2 = null, this._vertexBuffer2 = null, this._subBirthTime = null, this._subDistance = null, this._lastFixedVertexPosition = null, this._disappearBoundsMode = !1
        }
        _calculateBoundingBoxForNative() {
            var e = this._owner._owner.trailRenderer,
                t = e.bounds,
                r = t.getMin(),
                i = t.getMax(),
                n = ke._cullingBuffer;
            n[e._cullingBufferIndex + 1] = r.x, n[e._cullingBufferIndex + 2] = r.y, n[e._cullingBufferIndex + 3] = r.z, n[e._cullingBufferIndex + 4] = i.x, n[e._cullingBufferIndex + 5] = i.y, n[e._cullingBufferIndex + 6] = i.z
        }
        clear() {
            this._activeIndex = 0, this._endIndex = 0, this._disappearBoundsMode = !1, this._subBirthTime.fill(0), this._subDistance.fill(0), this._segementCount = 0, this._isTempEndVertex = !1, this._needAddFirstVertex = !1, this._lastFixedVertexPosition.setValue(0, 0, 0)
        }
    }
    ui.ALIGNMENT_VIEW = 0, ui.ALIGNMENT_TRANSFORM_Z = 1, ui._tempVector30 = new a, ui._tempVector31 = new a, ui._tempVector32 = new a, ui._tempVector33 = new a, ui._tempVector34 = new a, ui._tempVector35 = new a, ui._tempVector36 = new a, ui._type = Vt._typeCounter++;
    class mi {
        constructor(e) {
            this._totalLength = 0, this._lastPosition = new a, this._curtime = 0, this.alignment = mi.ALIGNMENT_VIEW, this._owner = e, this._initDefaultData(), this.addRenderElement()
        }
        get time() {
            return this._time
        }
        set time(e) {
            this._time = e, this._owner._render._shaderValues.setNumber(mi.LIFETIME, e)
        }
        get minVertexDistance() {
            return this._minVertexDistance
        }
        set minVertexDistance(e) {
            this._minVertexDistance = e
        }
        get widthMultiplier() {
            return this._widthMultiplier
        }
        set widthMultiplier(e) {
            this._widthMultiplier = e
        }
        get widthCurve() {
            return this._widthCurve
        }
        set widthCurve(e) {
            this._widthCurve = e;
            var t, r, i = new Float32Array(4 * e.length),
                n = 0;
            for (t = 0, r = e.length; t &lt; r; t++) i[n++] = e[t].time, i[n++] = e[t].inTangent, i[n++] = e[t].outTangent, i[n++] = e[t].value;
            this._owner._render._shaderValues.setBuffer(mi.WIDTHCURVE, i), this._owner._render._shaderValues.setInt(mi.WIDTHCURVEKEYLENGTH, e.length)
        }
        get colorGradient() {
            return this._colorGradient
        }
        set colorGradient(e) {
            this._colorGradient = e
        }
        get textureMode() {
            return this._textureMode
        }
        set textureMode(e) {
            this._textureMode = e
        }
        addRenderElement() {
            var e = this._owner._render,
                t = e._renderElements,
                r = e.sharedMaterials[0];
            r || (r = hi.defaultMaterial);
            var i = new Ht;
            i.setTransform(this._owner._transform), i.render = e, i.material = r, this._trialGeometry = new ui(this), i.setGeometry(this._trialGeometry), t.push(i)
        }
        _update(e) {
            var t = this._owner._render;
            this._curtime += e.scene.timer._delta / 1e3, t._shaderValues.setNumber(mi.CURTIME, this._curtime);
            var r = this._owner.transform.position,
                i = t._renderElements[0]._geometry;
            i._updateDisappear(), i._updateTrail(e.camera, this._lastPosition, r), i._updateVertexBufferUV(), r.cloneTo(this._lastPosition)
        }
        _initDefaultData() {
            this.time = 5, this.minVertexDistance = .1, this.widthMultiplier = 1, this.textureMode = ci.Stretch;
            var e = [],
                t = new z;
            t.time = 0, t.inTangent = 0, t.outTangent = 0, t.value = 1, e.push(t);
            var r = new z;
            r.time = 1, r.inTangent = 0, r.outTangent = 0, r.value = 1, e.push(r), this.widthCurve = e;
            var i = new Cr(2, 2);
            i.mode = Dr.Blend, i.addColorRGB(0, ze.WHITE), i.addColorRGB(1, ze.WHITE), i.addColorAlpha(0, 1), i.addColorAlpha(1, 1), this.colorGradient = i
        }
        destroy() {
            this._trialGeometry.destroy(), this._trialGeometry = null, this._widthCurve = null, this._colorGradient = null
        }
        clear() {
            this._trialGeometry.clear(), this._lastPosition.setValue(0, 0, 0), this._curtime = 0, this._totalLength = 0
        }
    }
    mi.CURTIME = he.propertyNameToID("u_CurTime"), mi.LIFETIME = he.propertyNameToID("u_LifeTime"), mi.WIDTHCURVE = he.propertyNameToID("u_WidthCurve"), mi.WIDTHCURVEKEYLENGTH = he.propertyNameToID("u_WidthCurveKeyLength"), mi.ALIGNMENT_VIEW = 0, mi.ALIGNMENT_TRANSFORM_Z = 1;
    class fi extends jt {
        constructor(e) {
            super(e), this._projectionViewWorldMatrix = new c
        }
        _calculateBoundingBox() {}
        _needRender(e, t) {
            return this._owner.trailFilter._update(t), !e || e.intersects(this.bounds._getBoundBox())
        }
        _updateForNative(e) {
            this._owner.trailFilter._update(e)
        }
        _renderUpdate(e, t) {
            super._renderUpdate(e, t)
        }
        _renderUpdateWithCamera(e, t) {
            var r = e.projectionViewMatrix;
            t ? (c.multiply(r, t.worldMatrix, this._projectionViewWorldMatrix), this._shaderValues.setMatrix4x4(ut.MVPMATRIX, this._projectionViewWorldMatrix)) : this._shaderValues.setMatrix4x4(ut.MVPMATRIX, r)
        }
    }
    class Ti extends Ut {
        constructor(e = null) {
            super(e), this._render = new fi(this), this._geometryFilter = new mi(this)
        }
        static __init__() {}
        get trailFilter() {
            return this._geometryFilter
        }
        get trailRenderer() {
            return this._render
        }
        _parse(e, r) {
            super._parse(e, r);
            var i, n, a = this._render,
                s = this._geometryFilter,
                o = e.materials;
            if (o) {
                var l = a.sharedMaterials,
                    _ = o.length;
                for (l.length = _, i = 0; i &lt; _; i++) l[i] = t.Loader.getRes(o[i].path);
                a.sharedMaterials = l
            }
            s.time = e.time, s.minVertexDistance = e.minVertexDistance, s.widthMultiplier = e.widthMultiplier, s.textureMode = e.textureMode, null != e.alignment &amp;&amp; (s.alignment = e.alignment);
            var h = [],
                c = e.widthCurve;
            for (i = 0, n = c.length; i &lt; n; i++) {
                var d = new z;
                d.time = c[i].time, d.inTangent = c[i].inTangent, d.outTangent = c[i].outTangent, d.value = c[i].value, h.push(d)
            }
            s.widthCurve = h;
            var u = e.colorGradient,
                m = u.colorKeys,
                f = u.alphaKeys,
                T = new Cr(m.length, f.length);
            for (T.mode = u.mode, i = 0, n = m.length; i &lt; n; i++) {
                var E = m[i];
                T.addColorRGB(E.time, new ze(E.value[0], E.value[1], E.value[2], 1))
            }
            for (i = 0, n = f.length; i &lt; n; i++) {
                var p = f[i];
                T.addColorAlpha(p.time, p.value)
            }
            s.colorGradient = T
        }
        _onActive() {
            super._onActive(), this._transform.position.cloneTo(this._geometryFilter._lastPosition)
        }
        _cloneTo(e, t, r) {
            var i, n;
            super._cloneTo(e, t, r);
            var a = e,
                s = a.trailFilter;
            s.time = this.trailFilter.time, s.minVertexDistance = this.trailFilter.minVertexDistance, s.widthMultiplier = this.trailFilter.widthMultiplier, s.textureMode = this.trailFilter.textureMode, s.alignment = this.trailFilter.alignment;
            var o = this.trailFilter.widthCurve,
                l = [];
            for (i = 0, n = o.length; i &lt; n; i++) {
                var _ = new z;
                o[i].cloneTo(_), l.push(_)
            }
            s.widthCurve = l;
            var h = new Cr(this.trailFilter.colorGradient.maxColorRGBKeysCount, this.trailFilter.colorGradient.maxColorAlphaKeysCount);
            this.trailFilter.colorGradient.cloneTo(h), s.colorGradient = h, a.trailRenderer.sharedMaterial = this.trailRenderer.sharedMaterial
        }
        destroy(e = !0) {
            this.destroyed || (super.destroy(e), this._geometryFilter.destroy(), this._geometryFilter = null)
        }
        clear() {
            this._geometryFilter.clear()
        }
        _create() {
            return new Ti
        }
    }
    class Ei {
        constructor(e, t, r, i) {
            this._position = e, this._normal = t, this._textureCoord0 = r, this._textureCoord1 = i
        }
        static __init__() {
            Ei._vertexDeclaration = new st(40, [new ot(0, at.Vector3, Ei.TERRAIN_POSITION0), new ot(12, at.Vector3, Ei.TERRAIN_NORMAL0), new ot(24, at.Vector2, Ei.TERRAIN_TEXTURECOORDINATE0), new ot(32, at.Vector2, Ei.TERRAIN_TEXTURECOORDINATE1)])
        }
        static get vertexDeclaration() {
            return Ei._vertexDeclaration
        }
        get position() {
            return this._position
        }
        get normal() {
            return this._normal
        }
        get textureCoord0() {
            return this._textureCoord0
        }
        get textureCoord1() {
            return this._textureCoord1
        }
        get vertexDeclaration() {
            return Ei._vertexDeclaration
        }
    }
    Ei.TERRAIN_POSITION0 = 0, Ei.TERRAIN_NORMAL0 = 1, Ei.TERRAIN_TEXTURECOORDINATE0 = 2, Ei.TERRAIN_TEXTURECOORDINATE1 = 3;
    class pi {}
    pi._interactive = {
        getWorldTransform: (e, t) =&gt; {},
        setWorldTransform: (e, t) =&gt; {
            var r = A._physicObjectsMap[e];
            r._simulation._updatedRigidbodies++, r._updateTransformComponent(t)
        }
    };
    class gi extends P {
        constructor(e = T.COLLISIONFILTERGROUP_DEFAULTFILTER, t = T.COLLISIONFILTERGROUP_ALLFILTER) {
            super(e, t), this._enableProcessCollisions = !1
        }
        _addToSimulation() {
            this._simulation._addPhysicsCollider(this, this._collisionGroup, this._canCollideWith)
        }
        _removeFromSimulation() {
            this._simulation._removePhysicsCollider(this)
        }
        _parse(e) {
            null != e.friction &amp;&amp; (this.friction = e.friction), null != e.rollingFriction &amp;&amp; (this.rollingFriction = e.rollingFriction), null != e.restitution &amp;&amp; (this.restitution = e.restitution), null != e.isTrigger &amp;&amp; (this.isTrigger = e.isTrigger), super._parse(e), this._parseShape(e.shapes)
        }
        _onAdded() {
            var e = V._bullet,
                t = e.btCollisionObject_create();
            e.btCollisionObject_setUserIndex(t, this.id), e.btCollisionObject_forceActivationState(t, A.ACTIVATIONSTATE_DISABLE_SIMULATION);
            var r = e.btCollisionObject_getCollisionFlags(t);
            this.owner.isStatic ? ((r &amp; A.COLLISIONFLAGS_KINEMATIC_OBJECT) &gt; 0 &amp;&amp; (r ^= A.COLLISIONFLAGS_KINEMATIC_OBJECT), r |= A.COLLISIONFLAGS_STATIC_OBJECT) : ((r &amp; A.COLLISIONFLAGS_STATIC_OBJECT) &gt; 0 &amp;&amp; (r ^= A.COLLISIONFLAGS_STATIC_OBJECT), r |= A.COLLISIONFLAGS_KINEMATIC_OBJECT), e.btCollisionObject_setCollisionFlags(t, r), this._btColliderObject = t, super._onAdded()
        }
    }
    class Si extends Vt {
        constructor(e) {
            super(), this._id = ++Si._uniqueIDCounter, this._mesh = e, this._boneIndicesList = [], this._subIndexBufferStart = [], this._subIndexBufferCount = []
        }
        get indexCount() {
            return this._indexCount
        }
        _setIndexRange(e, t) {
            this._indexStart = e, this._indexCount = t, this._indices = new Uint16Array(this._indexBuffer.getData().buffer, 2 * e, t)
        }
        _getType() {
            return Si._type
        }
        _prepareRender(e) {
            return this._mesh._uploadVerticesData(), !0
        }
        _render(r) {
            var i = this._mesh;
            if (i.indexFormat !== e.IndexFormat.UInt32 || t.LayaGL.layaGPUInstance.supportElementIndexUint32()) {
                var n, a, s = t.LayaGL.instance,
                    o = r.renderElement.render._skinnedData;
                switch (i.indexFormat) {
                    case e.IndexFormat.UInt32:
                        n = s.UNSIGNED_INT, a = 4;
                        break;
                    case e.IndexFormat.UInt16:
                        n = s.UNSIGNED_SHORT, a = 2;
                        break;
                    case e.IndexFormat.UInt8:
                        n = s.UNSIGNED_BYTE, a = 1
                }
                if (i._bufferState.bind(), o)
                    for (var l = o[this._indexInMesh], _ = 0, h = this._boneIndicesList.length; _ &lt; h; _++) r.shader.uploadCustomUniform(_i.BONES, l[_]), s.drawElements(s.TRIANGLES, this._subIndexBufferCount[_], n, this._subIndexBufferStart[_] * a);
                else s.drawElements(s.TRIANGLES, this._indexCount, n, this._indexStart * a);
                t.Stat.trianglesFaces += this._indexCount / 3, t.Stat.renderBatches++
            } else console.warn("SubMesh:this device do not support IndexFormat.UInt32.")
        }
        getIndices() {
            if (this._mesh._isReadable) return this._indices.slice();
            throw "SubMesh:can't get indices on subMesh,mesh's isReadable must be true."
        }
        setIndices(e) {
            this._indexBuffer.setData(e, this._indexStart, 0, this._indexCount)
        }
        destroy() {
            this._destroyed || (super.destroy(), this._indexBuffer.destroy(), this._indexBuffer = null, this._mesh = null, this._boneIndicesList = null, this._subIndexBufferStart = null, this._subIndexBufferCount = null, this._skinAnimationDatas = null)
        }
    }
    Si._uniqueIDCounter = 0, Si._type = Vt._typeCounter++;
    class Ri {
        constructor(e, t, r) {
            this.subMeshIndex = e, this.batchIndex = t, this.batchBoneIndex = r
        }
    }
    class vi extends t.Resource {
        constructor(t = !0) {
            super(), this._tempVector30 = new a, this._tempVector31 = new a, this._tempVector32 = new a, this._minVerticesUpdate = -1, this._maxVerticesUpdate = -1, this._needUpdateBounds = !0, this._bounds = new wt(new a, new a), this._bufferState = new it, this._instanceBufferState = new it, this._vertexBuffer = null, this._indexBuffer = null, this._skinnedMatrixCaches = [], this._vertexCount = 0, this._indexFormat = e.IndexFormat.UInt16, this._isReadable = t, this._subMeshes = []
        }
        static __init__() {
            var e = V._bullet;
            e &amp;&amp; (vi._nativeTempVector30 = e.btVector3_create(0, 0, 0), vi._nativeTempVector31 = e.btVector3_create(0, 0, 0), vi._nativeTempVector32 = e.btVector3_create(0, 0, 0))
        }
        static load(e, r) {
            t.ILaya.loader.create(e, r, null, vi.MESH)
        }
        get inverseAbsoluteBindPoses() {
            return this._inverseBindPoses
        }
        get vertexCount() {
            return this._vertexCount
        }
        get indexCount() {
            return this._indexBuffer.indexCount
        }
        get subMeshCount() {
            return this._subMeshes.length
        }
        get bounds() {
            return this._bounds
        }
        set bounds(e) {
            this._bounds !== e &amp;&amp; e.cloneTo(this._bounds)
        }
        get indexFormat() {
            return this._indexFormat
        }
        _getPositionElement(e) {
            for (var t = e.vertexDeclaration._vertexElements, r = 0, i = t.length; r &lt; i; r++) {
                var n = t[r];
                if (n._elementFormat === at.Vector3 &amp;&amp; n._elementUsage === lt.MESH_POSITION0) return n
            }
            return null
        }
        _getVerticeElementData(e, t) {
            e.length = this._vertexCount;
            var r = this._vertexBuffer.vertexDeclaration,
                s = r.getVertexElementByUsage(t);
            if (s) {
                var o = this._vertexBuffer.getUint8Data(),
                    l = this._vertexBuffer.getFloat32Data(),
                    _ = r.vertexStride,
                    h = _ / 4,
                    c = s._offset,
                    d = c / 4;
                switch (t) {
                    case lt.MESH_TEXTURECOORDINATE0:
                    case lt.MESH_TEXTURECOORDINATE1:
                        for (var u = 0; u &lt; this._vertexCount; u++) {
                            var m = h * u + d;
                            e[u] = new i(l[m], l[m + 1])
                        }
                        break;
                    case lt.MESH_POSITION0:
                    case lt.MESH_NORMAL0:
                        for (u = 0; u &lt; this._vertexCount; u++) {
                            m = h * u + d;
                            e[u] = new a(l[m], l[m + 1], l[m + 2])
                        }
                        break;
                    case lt.MESH_TANGENT0:
                    case lt.MESH_BLENDWEIGHT0:
                        for (u = 0; u &lt; this._vertexCount; u++) {
                            m = h * u + d;
                            e[u] = new n(l[m], l[m + 1], l[m + 2], l[m + 3])
                        }
                        break;
                    case lt.MESH_COLOR0:
                        for (u = 0; u &lt; this._vertexCount; u++) {
                            m = h * u + d;
                            e[u] = new ze(l[m], l[m + 1], l[m + 2], l[m + 3])
                        }
                        break;
                    case lt.MESH_BLENDINDICES0:
                        for (u = 0; u &lt; this._vertexCount; u++) {
                            m = _ * u + c;
                            e[u] = new n(o[m], o[m + 1], o[m + 2], o[m + 3])
                        }
                        break;
                    default:
                        throw "Mesh:Unknown elementUsage."
                }
            }
        }
        _setVerticeElementData(e, t) {
            var r = this._vertexBuffer.vertexDeclaration,
                i = r.getVertexElementByUsage(t);
            if (i) {
                var n = this._vertexBuffer.getUint8Data(),
                    a = this._vertexBuffer.getFloat32Data(),
                    s = r.vertexStride,
                    o = s / 4,
                    l = i._offset,
                    _ = l / 4;
                switch (t) {
                    case lt.MESH_TEXTURECOORDINATE0:
                    case lt.MESH_TEXTURECOORDINATE1:
                        for (var h = 0, c = e.length; h &lt; c; h++) {
                            var d = o * h + _,
                                u = e[h];
                            a[d] = u.x, a[d + 1] = u.y
                        }
                        break;
                    case lt.MESH_POSITION0:
                    case lt.MESH_NORMAL0:
                        for (h = 0, c = e.length; h &lt; c; h++) {
                            d = o * h + _;
                            var m = e[h];
                            a[d] = m.x, a[d + 1] = m.y, a[d + 2] = m.z
                        }
                        break;
                    case lt.MESH_TANGENT0:
                    case lt.MESH_BLENDWEIGHT0:
                        for (h = 0, c = e.length; h &lt; c; h++) {
                            d = o * h + _;
                            var f = e[h];
                            a[d] = f.x, a[d + 1] = f.y, a[d + 2] = f.z, a[d + 3] = f.w
                        }
                        break;
                    case lt.MESH_COLOR0:
                        for (h = 0, c = e.length; h &lt; c; h++) {
                            d = o * h + _;
                            var T = e[h];
                            a[d] = T.r, a[d + 1] = T.g, a[d + 2] = T.b, a[d + 3] = T.a
                        }
                        break;
                    case lt.MESH_BLENDINDICES0:
                        for (h = 0, c = e.length; h &lt; c; h++) {
                            d = s * h + l, f = e[h];
                            n[d] = f.x, n[d + 1] = f.y, n[d + 2] = f.z, n[d + 3] = f.w
                        }
                        break;
                    default:
                        throw "Mesh:Unknown elementUsage."
                }
                this._minVerticesUpdate = 0, this._maxVerticesUpdate = Number.MAX_SAFE_INTEGER
            } else console.warn("Mesh: the mesh don't have  this VertexElement.")
        }
        _disposeResource() {
            for (var e = 0, t = this._subMeshes.length; e &lt; t; e++) this._subMeshes[e].destroy();
            this._btTriangleMesh &amp;&amp; V._bullet.btStridingMeshInterface_destroy(this._btTriangleMesh), this._vertexBuffer.destroy(), this._indexBuffer.destroy(), this._bufferState.destroy(), this._instanceBufferState.destroy(), this._setCPUMemory(0), this._setGPUMemory(0), this._bufferState = null, this._instanceBufferState = null, this._vertexBuffer = null, this._indexBuffer = null, this._subMeshes = null, this._btTriangleMesh = null, this._indexBuffer = null, this._boneNames = null, this._inverseBindPoses = null
        }
        _setSubMeshes(e) {
            this._subMeshes = e;
            for (var t = 0, r = e.length; t &lt; r; t++) e[t]._indexInMesh = t
        }
        _setBuffer(e, t) {
            var r = this._bufferState;
            r.bind(), r.applyVertexBuffer(e), r.applyIndexBuffer(t), r.unBind();
            var i = this._instanceBufferState;
            i.bind(), i.applyVertexBuffer(e), i.applyInstanceVertexBuffer(zt.instance.instanceWorldMatrixBuffer), i.applyInstanceVertexBuffer(zt.instance.instanceMVPMatrixBuffer), i.applyIndexBuffer(t), i.unBind()
        }
        _getPhysicMesh() {
            if (!this._btTriangleMesh) {
                for (var e = V._bullet, t = e.btTriangleMesh_create(), r = vi._nativeTempVector30, i = vi._nativeTempVector31, n = vi._nativeTempVector32, a = this._tempVector30, s = this._tempVector31, o = this._tempVector32, l = this._vertexBuffer, _ = this._getPositionElement(l), h = l.getFloat32Data(), c = l.vertexDeclaration.vertexStride / 4, d = _._offset / 4, u = this._indexBuffer.getData(), m = 0, f = u.length; m &lt; f; m += 3) {
                    var T = u[m] * c + d,
                        E = u[m + 1] * c + d,
                        p = u[m + 2] * c + d;
                    a.setValue(h[T], h[T + 1], h[T + 2]), s.setValue(h[E], h[E + 1], h[E + 2]), o.setValue(h[p], h[p + 1], h[p + 2]), N._convertToBulletVec3(a, r, !0), N._convertToBulletVec3(s, i, !0), N._convertToBulletVec3(o, n, !0), e.btTriangleMesh_addTriangle(t, r, i, n, !0)
                }
                this._btTriangleMesh = t
            }
            return this._btTriangleMesh
        }
        _uploadVerticesData() {
            var e = this._minVerticesUpdate,
                t = this._maxVerticesUpdate;
            if (-1 !== e &amp;&amp; -1 !== t) {
                var r = e;
                this._vertexBuffer.setData(this._vertexBuffer.getUint8Data().buffer, r, r, t - e), this._minVerticesUpdate = -1, this._maxVerticesUpdate = -1
            }
        }
        getSubMesh(e) {
            return this._subMeshes[e]
        }
        getPositions(e) {
            if (!this._isReadable) throw "Mesh:can't get positions on mesh,isReadable must be true.";
            this._getVerticeElementData(e, lt.MESH_POSITION0)
        }
        setPositions(e) {
            if (!this._isReadable) throw "Mesh:setPosition() need isReadable must be true or use setVertices().";
            this._setVerticeElementData(e, lt.MESH_POSITION0), this._needUpdateBounds = !0
        }
        getColors(e) {
            if (!this._isReadable) throw "Mesh:can't get colors on mesh,isReadable must be true.";
            this._getVerticeElementData(e, lt.MESH_COLOR0)
        }
        setColors(e) {
            if (!this._isReadable) throw "Mesh:setColors() need isReadable must be true or use setVertices().";
            this._setVerticeElementData(e, lt.MESH_COLOR0)
        }
        getUVs(e, t = 0) {
            if (!this._isReadable) throw "Mesh:can't get uvs on mesh,isReadable must be true.";
            switch (t) {
                case 0:
                    this._getVerticeElementData(e, lt.MESH_TEXTURECOORDINATE0);
                    break;
                case 1:
                    this._getVerticeElementData(e, lt.MESH_TEXTURECOORDINATE1);
                    break;
                default:
                    throw "Mesh:Invalid channel."
            }
        }
        setUVs(e, t = 0) {
            if (!this._isReadable) throw "Mesh:setUVs() need isReadable must be true or use setVertices().";
            switch (t) {
                case 0:
                    this._setVerticeElementData(e, lt.MESH_TEXTURECOORDINATE0);
                    break;
                case 1:
                    this._setVerticeElementData(e, lt.MESH_TEXTURECOORDINATE1);
                    break;
                default:
                    throw "Mesh:Invalid channel."
            }
        }
        getNormals(e) {
            if (!this._isReadable) throw "Mesh:can't get colors on mesh,isReadable must be true.";
            this._getVerticeElementData(e, lt.MESH_NORMAL0)
        }
        setNormals(e) {
            if (!this._isReadable) throw "Mesh:setNormals() need must be true or use setVertices().";
            this._setVerticeElementData(e, lt.MESH_NORMAL0)
        }
        getTangents(e) {
            if (!this._isReadable) throw "Mesh:can't get colors on mesh,isReadable must be true.";
            this._getVerticeElementData(e, lt.MESH_TANGENT0)
        }
        setTangents(e) {
            if (!this._isReadable) throw "Mesh:setTangents() need isReadable must be true or use setVertices().";
            this._setVerticeElementData(e, lt.MESH_TANGENT0)
        }
        getBoneWeights(e) {
            if (!this._isReadable) throw "Mesh:can't get boneWeights on mesh,isReadable must be true.";
            this._getVerticeElementData(e, lt.MESH_BLENDWEIGHT0)
        }
        setBoneWeights(e) {
            if (!this._isReadable) throw "Mesh:setBoneWeights() need isReadable must be true or use setVertices().";
            this._setVerticeElementData(e, lt.MESH_BLENDWEIGHT0)
        }
        getBoneIndices(e) {
            if (!this._isReadable) throw "Mesh:can't get boneIndices on mesh,isReadable must be true.";
            this._getVerticeElementData(e, lt.MESH_BLENDINDICES0)
        }
        setBoneIndices(e) {
            if (!this._isReadable) throw "Mesh:setBoneIndices() need isReadable must be true or use setVertices().";
            this._setVerticeElementData(e, lt.MESH_BLENDINDICES0)
        }
        markAsUnreadbale() {
            this._uploadVerticesData(), this._vertexBuffer.markAsUnreadbale(), this._isReadable = !1
        }
        getVertexDeclaration() {
            return this._vertexBuffer._vertexDeclaration
        }
        getVertices() {
            if (this._isReadable) return this._vertexBuffer.getUint8Data().buffer.slice(0);
            throw "Mesh:can't get vertices on mesh,isReadable must be true."
        }
        setVertices(e) {
            this._vertexBuffer.setData(e), this._needUpdateBounds = !0
        }
        getIndices() {
            if (this._isReadable) return this._indexBuffer.getData().slice();
            throw "Mesh:can't get indices on subMesh,mesh's isReadable must be true."
        }
        setIndices(r) {
            var i;
            r instanceof Uint32Array ? i = e.IndexFormat.UInt32 : r instanceof Uint16Array ? i = e.IndexFormat.UInt16 : r instanceof Uint8Array &amp;&amp; (i = e.IndexFormat.UInt8);
            var n = this._indexBuffer;
            this._indexFormat === i &amp;&amp; n.indexCount === r.length || (n.destroy(), this._indexBuffer = n = new nt(i, r.length, t.LayaGL.instance.STATIC_DRAW, this._isReadable)), n.setData(r), this._indexFormat = i
        }
        calculateBounds() {
            if (!this._isReadable) throw "Mesh:can't calculate bounds on subMesh,mesh's isReadable must be true.";
            if (this._needUpdateBounds) {
                var e = this._tempVector30,
                    t = this._tempVector31;
                e.x = e.y = e.z = Number.MAX_VALUE, t.x = t.y = t.z = -Number.MAX_VALUE;
                for (var r = this._vertexBuffer, i = this._getPositionElement(r), n = r.getFloat32Data(), a = r.vertexDeclaration.vertexStride / 4, s = i._offset / 4, o = 0, l = n.length; o &lt; l; o += a) {
                    var _ = o + s,
                        h = n[_],
                        c = n[_ + 1],
                        d = n[_ + 2];
                    e.x = Math.min(e.x, h), e.y = Math.min(e.y, c), e.z = Math.min(e.z, d), t.x = Math.max(t.x, h), t.y = Math.max(t.y, c), t.z = Math.max(t.z, d)
                }
                this._bounds.setMin(e), this._bounds.setMax(t), this._needUpdateBounds = !1
            }
        }
        cloneTo(t) {
            var r = t,
                i = this._vertexBuffer,
                n = new _t(i._byteLength, i.bufferUsage, i.canRead);
            n.vertexDeclaration = i.vertexDeclaration, n.setData(i.getUint8Data().slice().buffer), r._vertexBuffer = n, r._vertexCount = this._vertexCount;
            var a, s = this._indexBuffer,
                o = new nt(e.IndexFormat.UInt16, s.indexCount, s.bufferUsage, s.canRead);
            o.setData(s.getData().slice()), r._indexBuffer = o, r._setBuffer(r._vertexBuffer, o), r._setCPUMemory(this.cpuMemory), r._setGPUMemory(this.gpuMemory);
            var l = this._boneNames;
            if (l) {
                var _ = r._boneNames = [];
                for (a = 0; a &lt; l.length; a++) _[a] = l[a]
            }
            var h = this._inverseBindPoses;
            if (h) {
                var c = r._inverseBindPoses = [];
                for (a = 0; a &lt; h.length; a++) c[a] = h[a]
            }
            var d = this._skinnedMatrixCaches.length;
            for (r._skinnedMatrixCaches.length = d, a = 0; a &lt; d; a++) {
                var u = this._skinnedMatrixCaches[a];
                r._skinnedMatrixCaches[a] = new Ri(u.subMeshIndex, u.batchIndex, u.batchBoneIndex)
            }
            for (a = 0; a &lt; this.subMeshCount; a++) {
                var m = this._subMeshes[a],
                    f = m._subIndexBufferStart,
                    T = m._subIndexBufferCount,
                    E = m._boneIndicesList,
                    p = new Si(r);
                p._subIndexBufferStart.length = f.length, p._subIndexBufferCount.length = T.length, p._boneIndicesList.length = E.length;
                for (var g = 0; g &lt; f.length; g++) p._subIndexBufferStart[g] = f[g];
                for (g = 0; g &lt; T.length; g++) p._subIndexBufferCount[g] = T[g];
                for (g = 0; g &lt; E.length; g++) p._boneIndicesList[g] = new Uint16Array(E[g]);
                p._indexBuffer = o, p._indexStart = m._indexStart, p._indexCount = m._indexCount, p._indices = new Uint16Array(o.getData().buffer, 2 * m._indexStart, m._indexCount);
                var S = r._vertexBuffer;
                p._vertexBuffer = S, r._subMeshes.push(p)
            }
            r._setSubMeshes(r._subMeshes)
        }
        clone() {
            var e = new vi;
            return this.cloneTo(e), e
        }
    }
    vi.MESH = "MESH";
    class Ai {
        static __init__() {}
        static _createMesh(r, i, n) {
            var a = t.LayaGL.instance,
                s = new vi,
                o = new Si(s),
                l = new _t(4 * i.length, a.STATIC_DRAW, !0);
            l.vertexDeclaration = r, l.setData(i.buffer), s._vertexBuffer = l, s._vertexCount = l._byteLength / r.vertexStride;
            var _ = new nt(e.IndexFormat.UInt16, n.length, a.STATIC_DRAW, !0);
            _.setData(n), s._indexBuffer = _, s._setBuffer(l, _), o._vertexBuffer = l, o._indexBuffer = _, o._setIndexRange(0, _.indexCount);
            var h = o._subIndexBufferStart,
                c = o._subIndexBufferCount,
                d = o._boneIndicesList;
            h.length = 1, c.length = 1, d.length = 1, h[0] = 0, c[0] = _.indexCount;
            var u = [];
            u.push(o), s._setSubMeshes(u), s.calculateBounds();
            var m = l._byteLength + _._byteLength;
            return s._setCPUMemory(m), s._setGPUMemory(m), s
        }
        static createBox(e = 1, t = 1, r = 1) {
            var i = lt.getVertexDeclaration("POSITION,NORMAL,UV"),
                n = e / 2,
                a = t / 2,
                s = r / 2,
                o = new Float32Array([-n, a, -s, 0, 1, 0, 0, 0, n, a, -s, 0, 1, 0, 1, 0, n, a, s, 0, 1, 0, 1, 1, -n, a, s, 0, 1, 0, 0, 1, -n, -a, -s, 0, -1, 0, 0, 1, n, -a, -s, 0, -1, 0, 1, 1, n, -a, s, 0, -1, 0, 1, 0, -n, -a, s, 0, -1, 0, 0, 0, -n, a, -s, -1, 0, 0, 0, 0, -n, a, s, -1, 0, 0, 1, 0, -n, -a, s, -1, 0, 0, 1, 1, -n, -a, -s, -1, 0, 0, 0, 1, n, a, -s, 1, 0, 0, 1, 0, n, a, s, 1, 0, 0, 0, 0, n, -a, s, 1, 0, 0, 0, 1, n, -a, -s, 1, 0, 0, 1, 1, -n, a, s, 0, 0, 1, 0, 0, n, a, s, 0, 0, 1, 1, 0, n, -a, s, 0, 0, 1, 1, 1, -n, -a, s, 0, 0, 1, 0, 1, -n, a, -s, 0, 0, -1, 1, 0, n, a, -s, 0, 0, -1, 0, 0, n, -a, -s, 0, 0, -1, 0, 1, -n, -a, -s, 0, 0, -1, 1, 1]),
                l = new Uint16Array([0, 1, 2, 2, 3, 0, 4, 7, 6, 6, 5, 4, 8, 9, 10, 10, 11, 8, 12, 15, 14, 14, 13, 12, 16, 17, 18, 18, 19, 16, 20, 23, 22, 22, 21, 20]);
            return Ai._createMesh(i, o, l)
        }
        static createCapsule(e = .5, t = 2, r = 16, i = 32) {
            var n, a, s = (r + 1) * (i + 1) * 2 + 2 * (i + 1),
                o = 3 * r * (i + 1) * 2 * 2 + 2 * i * 3,
                l = lt.getVertexDeclaration("POSITION,NORMAL,UV"),
                _ = l.vertexStride / 4,
                h = new Float32Array(s * _),
                c = new Uint16Array(o),
                d = Math.PI / 2 / r,
                u = 2 * Math.PI / i,
                m = t / 2 - e,
                f = 0,
                T = 0,
                E = 0,
                p = 0,
                g = 0,
                S = 0;
            for (n = 0; n &lt;= r; n++)
                for (a = 0; a &lt;= i; a++) f = e * Math.cos(n * d) * Math.cos(a * u + Math.PI), T = e * Math.sin(n * d), E = e * Math.cos(n * d) * Math.sin(a * u + Math.PI), h[p++] = f, h[p++] = T + m, h[p++] = E, h[p++] = f, h[p++] = T, h[p++] = E, h[p++] = 1 - a / i, h[p++] = (1 - n / r) * (Math.PI * e / 2 / (t + Math.PI * e)), n &lt; r &amp;&amp; (c[g++] = n * (i + 1) + a + (i + 1), c[g++] = n * (i + 1) + a, c[g++] = n * (i + 1) + a + 1, c[g++] = n * (i + 1) + a + i, c[g++] = n * (i + 1) + a, c[g++] = n * (i + 1) + a + (i + 1));
            for (S += (r + 1) * (i + 1), n = 0; n &lt;= r; n++)
                for (a = 0; a &lt;= i; a++) f = e * Math.cos(n * d) * Math.cos(a * u + Math.PI), T = e * Math.sin(-n * d), E = e * Math.cos(n * d) * Math.sin(a * u + Math.PI), h[p++] = f, h[p++] = T - m, h[p++] = E, h[p++] = f, h[p++] = T, h[p++] = E, h[p++] = 1 - a / i, h[p++] = (n / r * (Math.PI * e / 2) + (t + Math.PI * e / 2)) / (t + Math.PI * e), n &lt; r &amp;&amp; (c[g++] = S + n * (i + 1) + a, c[g++] = S + n * (i + 1) + a + (i + 1), c[g++] = S + n * (i + 1) + a + 1, c[g++] = S + n * (i + 1) + a, c[g++] = S + n * (i + 1) + a + i, c[g++] = S + n * (i + 1) + a + (i + 1));
            for (S += (r + 1) * (i + 1), a = 0; a &lt;= i; a++) f = e * Math.cos(a * u + Math.PI), T = m, E = e * Math.sin(a * u + Math.PI), h[p++] = f, h[p + 8 * (i + 1) - 1] = f, h[p++] = T, h[p + 8 * (i + 1) - 1] = -T, h[p++] = E, h[p + 8 * (i + 1) - 1] = E, h[p++] = f, h[p + 8 * (i + 1) - 1] = f, h[p++] = 0, h[p + 8 * (i + 1) - 1] = 0, h[p++] = E, h[p + 8 * (i + 1) - 1] = E, h[p++] = 1 - 1 * a / i, h[p + 8 * (i + 1) - 1] = 1 - 1 * a / i, h[p++] = Math.PI * e / 2 / (t + Math.PI * e), h[p + 8 * (i + 1) - 1] = (Math.PI * e / 2 + t) / (t + Math.PI * e);
            for (a = 0; a &lt; i; a++) c[g++] = a + S + (i + 1), c[g++] = a + S + 1, c[g++] = a + S, c[g++] = a + S + (i + 1), c[g++] = a + S + (i + 1) + 1, c[g++] = a + S + 1;
            return S += 2 * (i + 1), Ai._createMesh(l, h, c)
        }
        static createCone(e = .5, t = 1, r = 32) {
            for (var i, n = r + 1 + 1 + 2 * (r + 1), s = 6 * r + 3 * r, o = lt.getVertexDeclaration("POSITION,NORMAL,UV"), l = o.vertexStride / 4, _ = new Float32Array(n * l), c = new Uint16Array(s), d = 2 * Math.PI / r, u = t / 2, m = 0, f = 0, T = 0, E = 0, p = 0, g = new a, S = new a(0, -1, 0), R = new a(0, u, 0), v = new a, A = new a, I = new h, x = new a, L = 0, D = 0, C = 0; C &lt;= r; C++) m = C * d, T = Math.cos(m + Math.PI) * e, E = u, p = Math.sin(m + Math.PI) * e, _[L++] = 0, _[L + 8 * (r + 1) - 1] = T, _[L++] = E, _[L + 8 * (r + 1) - 1] = -E, _[L++] = 0, _[L + 8 * (r + 1) - 1] = p, g.x = T, g.y = 0, g.z = p, v.x = T, v.y = -E, v.z = p, a.subtract(v, R, A), a.normalize(A, A), i = Math.acos(a.dot(S, A)), a.cross(S, A, x), a.normalize(x, x), h.createFromAxisAngle(x, i, I), a.normalize(g, g), a.transformQuat(g, I, g), a.normalize(g, g), _[L++] = g.x, _[L + 8 * (r + 1) - 1] = g.x, _[L++] = g.y, _[L + 8 * (r + 1) - 1] = g.y, _[L++] = g.z, _[L + 8 * (r + 1) - 1] = g.z, _[L++] = 1 - 1 * C / r, _[L + 8 * (r + 1) - 1] = 1 - 1 * C / r, _[L++] = 0, _[L + 8 * (r + 1) - 1] = 1;
            L += 8 * (r + 1);
            for (var y = 0; y &lt; r; y++) c[D++] = y + f + (r + 1), c[D++] = y + f + 1, c[D++] = y + f, c[D++] = y + f + (r + 1), c[D++] = y + f + (r + 1) + 1, c[D++] = y + f + 1;
            f += 2 * (r + 1);
            for (var M = 0; M &lt;= r; M++) 0 === M &amp;&amp; (_[L++] = 0, _[L++] = -u, _[L++] = 0, _[L++] = 0, _[L++] = -1, _[L++] = 0, _[L++] = .5, _[L++] = .5), m = M * d, T = Math.cos(m + Math.PI) * e, E = -u, p = Math.sin(m + Math.PI) * e, _[L++] = T, _[L++] = E, _[L++] = p, _[L++] = 0, _[L++] = -1, _[L++] = 0, _[L++] = .5 + .5 * Math.cos(m), _[L++] = .5 + .5 * Math.sin(m);
            for (var O = 0; O &lt; r; O++) c[D++] = 0 + f, c[D++] = O + 2 + f, c[D++] = O + 1 + f;
            return f += r + 1 + 1, Ai._createMesh(o, _, c)
        }
        static createCylinder(e = .5, t = 2, r = 32) {
            for (var i = r + 1 + 1 + 2 * (r + 1) + (r + 1 + 1), n = 3 * r + 6 * r + 3 * r, a = lt.getVertexDeclaration("POSITION,NORMAL,UV"), s = a.vertexStride / 4, o = new Float32Array(i * s), l = new Uint16Array(n), _ = 2 * Math.PI / r, h = t / 2, c = 0, d = 0, u = 0, m = 0, f = 0, T = 0, E = 0, p = 0; p &lt;= r; p++) 0 === p &amp;&amp; (o[T++] = 0, o[T++] = h, o[T++] = 0, o[T++] = 0, o[T++] = 1, o[T++] = 0, o[T++] = .5, o[T++] = .5), c = p * _, u = Math.cos(c) * e, m = h, f = Math.sin(c) * e, o[T++] = u, o[T++] = m, o[T++] = f, o[T++] = 0, o[T++] = 1, o[T++] = 0, o[T++] = .5 + .5 * Math.cos(c), o[T++] = .5 + .5 * Math.sin(c);
            for (var g = 0; g &lt; r; g++) l[E++] = 0, l[E++] = g + 1, l[E++] = g + 2;
            d += r + 1 + 1;
            for (var S = 0; S &lt;= r; S++) c = S * _, u = Math.cos(c + Math.PI) * e, m = h, f = Math.sin(c + Math.PI) * e, o[T++] = u, o[T + 8 * (r + 1) - 1] = u, o[T++] = m, o[T + 8 * (r + 1) - 1] = -m, o[T++] = f, o[T + 8 * (r + 1) - 1] = f, o[T++] = u, o[T + 8 * (r + 1) - 1] = u, o[T++] = 0, o[T + 8 * (r + 1) - 1] = 0, o[T++] = f, o[T + 8 * (r + 1) - 1] = f, o[T++] = 1 - 1 * S / r, o[T + 8 * (r + 1) - 1] = 1 - 1 * S / r, o[T++] = 0, o[T + 8 * (r + 1) - 1] = 1;
            T += 8 * (r + 1);
            for (var R = 0; R &lt; r; R++) l[E++] = R + d + (r + 1), l[E++] = R + d + 1, l[E++] = R + d, l[E++] = R + d + (r + 1), l[E++] = R + d + (r + 1) + 1, l[E++] = R + d + 1;
            d += 2 * (r + 1);
            for (var v = 0; v &lt;= r; v++) 0 === v &amp;&amp; (o[T++] = 0, o[T++] = -h, o[T++] = 0, o[T++] = 0, o[T++] = -1, o[T++] = 0, o[T++] = .5, o[T++] = .5), c = v * _, u = Math.cos(c + Math.PI) * e, m = -h, f = Math.sin(c + Math.PI) * e, o[T++] = u, o[T++] = m, o[T++] = f, o[T++] = 0, o[T++] = -1, o[T++] = 0, o[T++] = .5 + .5 * Math.cos(c), o[T++] = .5 + .5 * Math.sin(c);
            for (var A = 0; A &lt; r; A++) l[E++] = 0 + d, l[E++] = A + 2 + d, l[E++] = A + 1 + d;
            return d += r + 1 + 1, Ai._createMesh(a, o, l)
        }
        static createPlane(e = 10, t = 10, r = 10, i = 10) {
            for (var n = (r + 1) * (i + 1), a = new Uint16Array(r * i * 2 * 3), s = lt.getVertexDeclaration("POSITION,NORMAL,UV"), o = s.vertexStride / 4, l = new Float32Array(n * o), _ = e / 2, h = t / 2, c = e / r, d = t / i, u = 0, m = 0; m &lt;= i; m++)
                for (var f = 0; f &lt;= r; f++) l[u++] = f * c - _, l[u++] = 0, l[u++] = m * d - h, l[u++] = 0, l[u++] = 1, l[u++] = 0, l[u++] = 1 * f / r, l[u++] = 1 * m / i;
            var T = 0;
            for (m = 0; m &lt; i; m++)
                for (f = 0; f &lt; r; f++) a[T++] = (m + 1) * (r + 1) + f, a[T++] = m * (r + 1) + f, a[T++] = (m + 1) * (r + 1) + f + 1, a[T++] = m * (r + 1) + f, a[T++] = m * (r + 1) + f + 1, a[T++] = (m + 1) * (r + 1) + f + 1;
            return Ai._createMesh(s, l, a)
        }
        static createQuad(e = 1, t = 1) {
            var r = lt.getVertexDeclaration("POSITION,NORMAL,UV"),
                i = e / 2,
                n = t / 2,
                a = new Float32Array([-i, n, 0, 0, 0, 1, 0, 0, i, n, 0, 0, 0, 1, 1, 0, -i, -n, 0, 0, 0, 1, 0, 1, i, -n, 0, 0, 0, 1, 1, 1]),
                s = new Uint16Array([0, 1, 2, 3, 2, 1]);
            return Ai._createMesh(r, a, s)
        }
        static createSphere(e = .5, t = 32, r = 32) {
            var i = (t + 1) * (r + 1),
                n = 3 * t * (r + 1) * 2,
                a = new Uint16Array(n),
                s = lt.getVertexDeclaration("POSITION,NORMAL,UV"),
                o = s.vertexStride / 4,
                l = new Float32Array(i * o),
                _ = Math.PI / t,
                h = 2 * Math.PI / r,
                c = 0;
            i = 0, n = 0;
            for (var d = 0; d &lt; t + 1; d++)
                for (var u = Math.sin(d * _), m = Math.cos(d * _), f = 0; f &lt; r + 1; f++) {
                    var T = u * Math.sin(f * h + 1 * Math.PI / 2),
                        E = u * Math.cos(f * h + 1 * Math.PI / 2);
                    l[i + 0] = T * e, l[i + 1] = m * e, l[i + 2] = E * e, l[i + 3] = T, l[i + 4] = m, l[i + 5] = E, l[i + 6] = f / r, l[i + 7] = d / t, i += o, d != t - 1 &amp;&amp; (a[n++] = c + (r + 1), a[n++] = c, a[n++] = c + 1, a[n++] = c + r, a[n++] = c, a[n++] = c + (r + 1), c++)
                }
            return Ai._createMesh(s, l, a)
        }
    }
    var Ii = "#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\nuniform sampler2D u_MainTex;\r\nvarying vec2 v_Texcoord0;\r\n\r\nvoid main() {\r\n\tgl_FragColor = texture2D(u_MainTex, v_Texcoord0);\r\n}\r\n\r\n",
        xi = '#include "Lighting.glsl";\r\n\r\nattribute vec4 a_PositionTexcoord;\r\nuniform vec4 u_OffsetScale;\r\nvarying vec2 v_Texcoord0;\r\n\r\nvoid main() {\t\r\n\tgl_Position = vec4(u_OffsetScale.x*2.0-1.0+(a_PositionTexcoord.x+1.0)*u_OffsetScale.z,(1.0-((u_OffsetScale.y*2.0-1.0+(-a_PositionTexcoord.y+1.0)*u_OffsetScale.w)+1.0)/2.0)*2.0-1.0, 0.0, 1.0);\t\r\n\tv_Texcoord0 = a_PositionTexcoord.zw;\r\n\tgl_Position = remapGLPositionZ(gl_Position);\r\n}',
        Li = "#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#ifdef COLOR\r\n\tvarying vec4 v_Color;\r\n#endif\r\nvarying vec2 v_Texcoord0;\r\n\r\n#ifdef MAINTEXTURE\r\n\tuniform sampler2D u_AlbedoTexture;\r\n#endif\r\n\r\nuniform vec4 u_AlbedoColor;\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\t#ifdef ADDTIVEFOG\r\n\t#else\r\n\t\tuniform vec3 u_FogColor;\r\n\t#endif\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tvec4 color =  2.0 * u_AlbedoColor;\r\n\t#ifdef COLOR\r\n\t\tcolor *= v_Color;\r\n\t#endif\r\n\t#ifdef MAINTEXTURE\r\n\t\tcolor *= texture2D(u_AlbedoTexture, v_Texcoord0);\r\n\t#endif\r\n\t\r\n\tgl_FragColor = color;\r\n\t\r\n\t#ifdef FOG\r\n\t\tfloat lerpFact = clamp((1.0 / gl_FragCoord.w - u_FogStart) / u_FogRange, 0.0, 1.0);\r\n\t\t#ifdef ADDTIVEFOG\r\n\t\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.0), lerpFact);\r\n\t\t#else\r\n\t\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, u_FogColor, lerpFact);\r\n\t\t#endif\r\n\t#endif\r\n}\r\n\r\n",
        Di = '#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nattribute vec4 a_Color;\r\nattribute vec2 a_Texcoord0;\r\n\r\n#ifdef GPU_INSTANCE\r\n\tattribute mat4 a_MvpMatrix;\r\n#else\r\n\tuniform mat4 u_MvpMatrix;\r\n#endif\r\n\r\n#ifdef COLOR\r\n\tvarying vec4 v_Color;\r\n#endif\r\nvarying vec2 v_Texcoord0;\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif\r\n\r\n#ifdef BONE\r\n\tconst int c_MaxBoneCount = 24;\r\n\tattribute vec4 a_BoneIndices;\r\n\tattribute vec4 a_BoneWeights;\r\n\tuniform mat4 u_Bones[c_MaxBoneCount];\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tvec4 position;\r\n\t#ifdef BONE\r\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\tposition=skinTransform*a_Position;\r\n\t#else\r\n\t\tposition=a_Position;\r\n\t#endif\r\n\t#ifdef GPU_INSTANCE\r\n\t\tgl_Position = a_MvpMatrix * position;\r\n\t#else\r\n\t\tgl_Position = u_MvpMatrix * position;\r\n\t#endif\r\n\t\r\n\t#ifdef TILINGOFFSET\r\n\t\tv_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\r\n\t#else\r\n\t\tv_Texcoord0=a_Texcoord0;\r\n\t#endif\r\n\t\t\r\n\t#ifdef COLOR\r\n\t\tv_Color = a_Color;\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',
        Ci = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Lighting.glsl";\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\r\n\tuniform vec3 u_CameraPos;\r\n\tvarying vec3 v_Normal;\r\n\tvarying vec3 v_PositionWorld;\r\n#endif\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\tuniform vec3 u_FogColor;\r\n#endif\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t#ifdef LEGACYSINGLELIGHTING\r\n\t\t#ifdef DIRECTIONLIGHT\r\n\t\t\tuniform DirectionLight u_DirectionLight;\r\n\t\t#endif\r\n\t\t#ifdef POINTLIGHT\r\n\t\t\tuniform PointLight u_PointLight;\r\n\t\t#endif\r\n\t\t#ifdef SPOTLIGHT\r\n\t\t\tuniform SpotLight u_SpotLight;\r\n\t\t#endif\r\n\t#else\r\n\t\tuniform mat4 u_View;\r\n\t\tuniform vec4 u_ProjectionParams;\r\n\t\tuniform vec4 u_Viewport;\r\n\t\tuniform int u_DirationLightCount;\r\n\t\tuniform sampler2D u_LightBuffer;\r\n\t\tuniform sampler2D u_LightClusterBuffer;\r\n\t#endif\r\n#endif\r\n\r\n#include "Shadow.glsl"\r\n#ifdef CALCULATE_SHADOWS\r\n\tvarying vec4 v_ShadowCoord;\r\n#endif\r\nvarying float v_posViewZ;\r\n\r\nuniform vec3 u_AmbientColor;\r\n\r\nuniform sampler2D u_SplatAlphaTexture;\r\n\r\nuniform sampler2D u_DiffuseTexture1;\r\nuniform sampler2D u_DiffuseTexture2;\r\nuniform sampler2D u_DiffuseTexture3;\r\nuniform sampler2D u_DiffuseTexture4;\r\nuniform sampler2D u_DiffuseTexture5;\r\n\r\nuniform vec4 u_DiffuseScaleOffset1;\r\nuniform vec4 u_DiffuseScaleOffset2;\r\nuniform vec4 u_DiffuseScaleOffset3;\r\nuniform vec4 u_DiffuseScaleOffset4;\r\nuniform vec4 u_DiffuseScaleOffset5;\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\n#ifdef LIGHTMAP\r\n\tuniform sampler2D u_LightMap;\r\n\tvarying vec2 v_LightMapUV;\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tvec4 splatAlpha = vec4(1.0);\r\n\t#ifdef ExtendTerrain_DETAIL_NUM1\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r;\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM2\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * (1.0 - splatAlpha.r);\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM3\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r  + color2.xyz * splatAlpha.g + color3.xyz * (1.0 - splatAlpha.r - splatAlpha.g);\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM4\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\r\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r  + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b);\r\n\t#endif\r\n\t#ifdef ExtendTerrain_DETAIL_NUM5\r\n\t\tsplatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\r\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\r\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\r\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\r\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\r\n\t\tvec4 color5 = texture2D(u_DiffuseTexture5, v_Texcoord0 * u_DiffuseScaleOffset5.xy);\r\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r  + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * splatAlpha.a + color5.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b - splatAlpha.a);\r\n\t#endif\r\n\t\tgl_FragColor.w = splatAlpha.a;\r\n\t\t\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\tvec3 normal = v_Normal;\r\n\t\tvec3 dif, spe;\r\n\t#endif\r\n\r\n\tvec3 diffuse = vec3(0.0);\r\n\tvec3 specular= vec3(0.0);\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\r\n\t\tvec3 toEye;\r\n\t\t#ifdef FOG\r\n\t\t\ttoEye=u_CameraPos-v_PositionWorld;\r\n\t\t\tfloat toEyeLength=length(toEye);\r\n\t\t\ttoEye/=toEyeLength;\r\n\t\t#else\r\n\t\t\ttoEye=normalize(u_CameraPos-v_PositionWorld);\r\n\t\t#endif\r\n\t#endif\r\n\r\n\t#ifdef LEGACYSINGLELIGHTING\r\n\t\t#ifdef DIRECTIONLIGHT\r\n\t\t\tLayaAirBlinnPhongDiectionLight(vec3(0.0),1.0,normal,vec3(1.0),toEye,u_DirectionLight,dif,spe);\r\n\t\t\tdiffuse+=dif;\r\n\t\t\tspecular+=spe;\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef POINTLIGHT\r\n\t\t\tLayaAirBlinnPhongPointLight(v_PositionWorld,vec3(0.0),1.0,normal,vec3(1.0),toEye,u_PointLight,dif,spe);\r\n\t\t\tdiffuse+=dif;\r\n\t\t\tspecular+=spe;\r\n\t\t#endif\r\n\r\n\t\t#ifdef SPOTLIGHT\r\n\t\t\tLayaAirBlinnPhongSpotLight(v_PositionWorld,vec3(0.0),1.0,normal,vec3(1.0),toEye,u_SpotLight,dif,spe);\r\n\t\t\tdiffuse+=dif;\r\n\t\t\tspecular+=spe;\r\n\t\t#endif\r\n\t#else\r\n\t\t#ifdef DIRECTIONLIGHT\r\n\t\t\tfor (int i = 0; i &lt; MAX_LIGHT_COUNT; i++) \r\n\t\t\t{\r\n\t\t\t\tif(i &gt;= u_DirationLightCount)\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tDirectionLight directionLight = getDirectionLight(u_LightBuffer,i);\r\n\t\t\t\tLayaAirBlinnPhongDiectionLight(vec3(0.0),1.0,normal,vec3(1.0),toEye,directionLight,dif,spe);\r\n\t\t\t\tdiffuse+=dif;\r\n\t\t\t\tspecular+=spe;\r\n\t\t\t}\r\n\t\t#endif\r\n\t\t#if defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\t\tivec4 clusterInfo =getClusterInfo(u_LightClusterBuffer,u_View,u_Viewport, v_PositionWorld,gl_FragCoord,u_ProjectionParams);\r\n\t\t\t#ifdef POINTLIGHT\r\n\t\t\t\tfor (int i = 0; i &lt; MAX_LIGHT_COUNT; i++) \r\n\t\t\t\t{\r\n\t\t\t\t\tif(i &gt;= clusterInfo.x)//PointLightCount\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tPointLight pointLight = getPointLight(u_LightBuffer,u_LightClusterBuffer,clusterInfo,i);\r\n\t\t\t\t\tLayaAirBlinnPhongPointLight(v_PositionWorld,vec3(0.0),1.0,normal,vec3(1.0),toEye,pointLight,dif,spe);\r\n\t\t\t\t\tdiffuse+=dif;\r\n\t\t\t\t\tspecular+=spe;\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t\t#ifdef SPOTLIGHT\r\n\t\t\t\tfor (int i = 0; i &lt; MAX_LIGHT_COUNT; i++) \r\n\t\t\t\t{\r\n\t\t\t\t\tif(i &gt;= clusterInfo.y)//SpotLightCount\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tSpotLight spotLight = getSpotLight(u_LightBuffer,u_LightClusterBuffer,clusterInfo,i);\r\n\t\t\t\t\tLayaAirBlinnPhongSpotLight(v_PositionWorld,vec3(0.0),1.0,normal,vec3(1.0),toEye\t,spotLight,dif,spe);\r\n\t\t\t\t\tdiffuse+=dif;\r\n\t\t\t\t\tspecular+=spe;\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t#endif\r\n\t#endif\r\n\r\nvec3 globalDiffuse = u_AmbientColor;\r\n#ifdef LIGHTMAP\r\n\tglobalDiffuse += decodeHDR(texture2D(u_LightMap, v_LightMapUV),5.0);\r\n#endif\r\n\r\n#ifdef CALCULATE_SHADOWS\r\n\tfloat shadowValue = shadowValue = sampleShadowmap(v_ShadowCoord);\r\n\tgl_FragColor = vec4(gl_FragColor.rgb * (globalDiffuse + diffuse) * shadowValue, gl_FragColor.a);\r\n#else\r\n\tgl_FragColor = vec4(gl_FragColor.rgb * (globalDiffuse + diffuse), gl_FragColor.a);\r\n#endif\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t#ifdef CALCULATE_SHADOWS\r\n\t\tgl_FragColor.rgb += specular * shadowValue;\r\n\t#else\r\n\t\tgl_FragColor.rgb += specular;\r\n\t#endif\r\n#endif\r\n\r\n#ifdef FOG\r\n\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\r\n\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\r\n#endif\r\n}\r\n\r\n\r\n\r\n\r\n\r\n',
        yi = '#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nattribute vec2 a_Texcoord0;\r\n\r\nuniform mat4 u_MvpMatrix;\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(LIGHTMAP)\r\n\tattribute vec3 a_Normal;\r\n\tvarying vec3 v_Normal;\r\n#endif\r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(CALCULATE_SHADOWS)&amp;&amp;defined(SHADOWMAP_PSSM1))\r\n\tuniform mat4 u_WorldMat;\r\n\tvarying vec3 v_PositionWorld;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tvarying vec2 v_LightMapUV;\r\n\tuniform vec4 u_LightmapScaleOffset;\r\n#endif\r\n\r\n#ifdef CALCULATE_SHADOWS\r\n\tvarying vec4 v_ShadowCoord;\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tgl_Position = u_MvpMatrix * a_Position;\r\n  \r\n\tv_Texcoord0 = a_Texcoord0;\r\n  \r\n\t#ifdef LIGHTMAP\r\n\t\tv_LightMapUV = vec2(a_Texcoord0.x, 1.0 - a_Texcoord0.y) * u_LightmapScaleOffset.xy + u_LightmapScaleOffset.zw;\r\n\t\tv_LightMapUV.y = 1.0 - v_LightMapUV.y;\r\n\t#endif\r\n  \r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\tv_Normal = a_Normal;\r\n\t#endif\r\n\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(CALCULATE_SHADOWS)&amp;&amp;defined(SHADOWMAP_PSSM1))\r\n\t\tv_PositionWorld=(u_WorldMat*a_Position).xyz;\r\n\t#endif\r\n\r\n\t#ifdef CALCULATE_SHADOWS\r\n\t\tv_ShadowCoord = getShadowCoord(vec4(v_PositionWorld));\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',
        Mi = 'struct LayaGIInput\r\n{\r\n\tvec2 lightmapUV;\r\n};\r\n\r\n#define LAYA_SPECCUBE_LOD_STEPS 6.0\r\n\r\nuniform vec3 u_AmbientColor;\r\n\r\n#if defined(GI_AMBIENT_SH)\r\n\tuniform vec4 u_AmbientSHAr;\r\n\tuniform vec4 u_AmbientSHAg;\r\n\tuniform vec4 u_AmbientSHAb;\r\n\tuniform vec4 u_AmbientSHBr;\r\n\tuniform vec4 u_AmbientSHBg;\r\n\tuniform vec4 u_AmbientSHBb;\r\n\tuniform vec4 u_AmbientSHC;\r\n#endif\r\n\r\nuniform samplerCube u_ReflectTexture;\r\nuniform vec4 u_ReflectCubeHDRParams;\r\n\r\n\r\n#ifdef GI_AMBIENT_SH\r\n\tmediump vec3 shEvalLinearL0L1(mediump vec4 normal)\r\n\t{\r\n\t\tmediump vec3 x;\r\n\t\t// Linear (L1) + constant (L0) polynomial terms\r\n\t\tx.r = dot(u_AmbientSHAr, normal);\r\n\t\tx.g = dot(u_AmbientSHAg, normal);\r\n\t\tx.b = dot(u_AmbientSHAb, normal);\r\n\t\treturn x;\r\n\t}\r\n\r\n\tmediump vec3 shEvalLinearL2(mediump vec4 normal)\r\n\t{\r\n\t\tmediump vec3 x1,x2;\r\n\t\t// 4 of the quadratic (L2) polynomials\r\n\t\tmediump vec4 vB = normal.xyzz * normal.yzzx;\r\n\t\tx1.r = dot(u_AmbientSHBr, vB);\r\n\t\tx1.g = dot(u_AmbientSHBg, vB);\r\n\t\tx1.b = dot(u_AmbientSHBb, vB);\r\n\r\n\t\t// Final (5th) quadratic (L2) polynomial\r\n\t\tmediump float vC = normal.x*normal.x - normal.y*normal.y;\r\n\t\tx2 = u_AmbientSHC.rgb * vC;\r\n\r\n\t\treturn x1 + x2;\r\n\t}\r\n\t\r\n\tmediump vec3 shadeSHPerPixel(mediump vec3 normal)\r\n\t{\r\n\t\tmediump vec3 ambientContrib;\r\n\t\tmediump vec4 normalV4=vec4(-normal.x,normal.yz, 1.0);//Note:SH Data is left-hand,so x need inverse\r\n\t\tambientContrib = shEvalLinearL0L1(normalV4);\r\n\t\tambientContrib += shEvalLinearL2(normalV4);\r\n\t\tmediump vec3 ambient = max(vec3(0.0), ambientContrib);\r\n\t\tambient = layaLinearToGammaSpace(ambient);\r\n\t\treturn ambient;\r\n\t}\r\n#endif\r\n\r\nmediump vec3 layaDecodeDirectionalLightmap (mediump vec3 color, lowp vec4 dirTex, mediump vec3 normalWorld)\r\n{\r\n    // In directional (non-specular) mode Enlighten bakes dominant light direction\r\n    // in a way, that using it for half Lambert and then dividing by a "rebalancing coefficient"\r\n    // gives a result close to plain diffuse response lightmaps, but normalmapped.\r\n\r\n    // Note that dir is not unit length on purpose. Its length is "directionality", like\r\n    // for the directional specular lightmaps.\r\n\tlowp vec3 directional=dirTex.xyz - 0.5;\r\n\tdirectional.x=-directional.x;//NOTE:because coord System\r\n    mediump float halfLambert = dot(normalWorld,directional) + 0.5;\r\n\r\n    return color * halfLambert / max(1e-4, dirTex.w);\r\n}\r\n\r\nvec3 layaGIBase(LayaGIInput giInput,mediump float occlusion, mediump vec3 normalWorld)\r\n{\r\n\tvec3 indirectDiffuse;\r\n\t#ifdef LIGHTMAP\t\r\n\t\tmediump vec3 bakedColor =decodeHDR(texture2D(u_LightMap, giInput.lightmapUV),5.0);\r\n\t\t#ifdef LIGHTMAP_DIRECTIONAL\r\n\t\t\tlowp vec4 bakedDirTex = texture2D (u_LightMapDirection, giInput.lightmapUV);\r\n            indirectDiffuse = layaDecodeDirectionalLightmap (bakedColor, bakedDirTex, normalWorld);\r\n\t\t#else //unDirectional lightmap\r\n\t\t\tindirectDiffuse = bakedColor;\r\n\t\t#endif\r\n\t#else\r\n\t\t#ifdef GI_AMBIENT_SH\r\n\t\t\tindirectDiffuse = shadeSHPerPixel(normalWorld);\r\n\t\t#else\r\n\t\t\tindirectDiffuse = u_AmbientColor; //already in gamma space\r\n\t\t#endif\r\n\t#endif\r\n\r\n\tindirectDiffuse*=occlusion;\r\n\treturn indirectDiffuse;\r\n}\r\n\r\nmediump vec3 layaGlossyEnvironment(mediump vec4 glossIn)\r\n{\r\n\tmediump float perceptualRoughness = glossIn.a;\r\n\r\n\t// use approximation to solve,below is more reasonable,but maybe slow. \r\n\t// float m = perceptualRoughnessToRoughness(perceptualRoughness); // m is the real roughness parameter\r\n    // const float fEps = 1.192092896e-07F;        // smallest such that 1.0+FLT_EPSILON != 1.0  (+1e-4h is NOT good here. is visibly very wrong)\r\n    // float n =  (2.0/max(fEps, m*m))-2.0;        // remap to spec power. See eq. 21 in --\x3e https://dl.dropboxusercontent.com/u/55891920/papers/mm_brdf.pdf\r\n    // n /= 4;                                     // remap from n_dot_h formulatino to n_dot_r. See section "Pre-convolved Cube Maps vs Path Tracers" --\x3e https://s3.amazonaws.com/docs.knaldtech.com/knald/1.0.0/lys_power_drops.html\r\n    // perceptualRoughness = pow( 2/(n+2), 0.25);  // remap back to square root of real roughness (0.25 include both the sqrt root of the conversion and sqrt for going from roughness to perceptualRoughness)\r\n\tperceptualRoughness = perceptualRoughness * (1.7 - 0.7*perceptualRoughness);//just a approximation,but fast.\r\n \r\n\tmediump float mip = perceptualRoughness * LAYA_SPECCUBE_LOD_STEPS;\r\n\tmediump vec3 uvw = glossIn.rgb;\r\n\tuvw.x=-uvw.x;//Note:reflectCube is left-hand,so x need inverse\r\n\tmediump vec4 rgbm=textureCubeLodEXT(u_ReflectTexture,uvw,mip);\r\n\treturn decodeHDR(rgbm,u_ReflectCubeHDRParams.x);\r\n}\r\n\r\nmediump vec3 layaGIIndirectSpecular(LayaGIInput giInput,mediump float occlusion, vec4 glossIn)\r\n{\r\n\tmediump vec3 specular = layaGlossyEnvironment(glossIn);\r\n\treturn specular * occlusion;\r\n}\r\n\r\n\r\nLayaGI layaGlobalIllumination(LayaGIInput giInput,mediump float occlusion, mediump vec3 normalWorld,mediump vec4 uvwRoughness)\r\n{\r\n\tLayaGI gi;\r\n\tgi.diffuse = layaGIBase(giInput,occlusion, normalWorld);\r\n\tgi.specular = layaGIIndirectSpecular(giInput,occlusion, uvwRoughness);\r\n\treturn gi;\r\n}\r\n\r\n\r\n',
        Oi = "#ifdef GRAPHICS_API_GLES3\r\n\t#define INVERSE_MAT(mat) inverse(mat)\r\n#else\r\n\t#define INVERSE_MAT(mat) inverseMat(mat)\r\n#endif\r\n\r\nstruct DirectionLight {\r\n\tvec3 color;\r\n\tvec3 direction;\r\n};\r\n\r\nstruct PointLight {\r\n\tvec3 color;\r\n\tvec3 position;\r\n\tfloat range;\r\n};\r\n\r\nstruct SpotLight {\r\n\tvec3 color;\r\n\tvec3 position;\r\n\tfloat range;\r\n\tvec3 direction;\r\n\tfloat spot;\r\n};\r\n\r\nstruct LayaGI{\r\n\tvec3 diffuse;\r\n\tvec3 specular;\r\n};\r\n\r\nstruct LayaLight{\r\n\tvec3 color;\r\n\tvec3 dir;\r\n};\r\n\r\nconst int c_ClusterBufferWidth = CLUSTER_X_COUNT*CLUSTER_Y_COUNT;\r\nconst int c_ClusterBufferHeight = CLUSTER_Z_COUNT*(1+int(ceil(float(MAX_LIGHT_COUNT_PER_CLUSTER)/4.0)));\r\nconst int c_ClusterBufferFloatWidth = c_ClusterBufferWidth*4;\r\n\r\n#ifndef GRAPHICS_API_GLES3\r\n\tmat3 inverseMat(mat3 m) {\r\n\t\tfloat a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\r\n\t\tfloat a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\r\n\t\tfloat a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\r\n\r\n\t\tfloat b01 = a22 * a11 - a12 * a21;\r\n\t\tfloat b11 = -a22 * a10 + a12 * a20;\r\n\t\tfloat b21 = a21 * a10 - a11 * a20;\r\n\r\n\t\tfloat det = a00 * b01 + a01 * b11 + a02 * b21;\r\n\r\n\t\treturn mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\r\n\t\t\t\t\tb11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\r\n\t\t\t\t\tb21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\r\n\t}\r\n#endif\r\n\r\nivec4 getClusterInfo(sampler2D clusterBuffer,mat4 viewMatrix,vec4 viewport,vec3 position,vec4 fragCoord,vec4 projectParams)\r\n{\r\n\tvec3 viewPos = vec3(viewMatrix*vec4(position, 1.0)); //position in viewspace\r\n\r\n\tint clusterXIndex = int(floor(fragCoord.x/ (float(viewport.z)/float(CLUSTER_X_COUNT))));\r\n    int clusterYIndex = int(floor((viewport.w * (projectParams.z &lt;0.0? 0.0 : 1.0) - fragCoord.y * projectParams.z)/ (float(viewport.w)/float(CLUSTER_Y_COUNT))));//Maybe Flipped ProjectMatrix\r\n\tfloat zSliceParam =float(CLUSTER_Z_COUNT)/log2(projectParams.y / projectParams.x);\r\n \tint clusterZIndex = int(floor(log2(-viewPos.z) * zSliceParam- log2(projectParams.x) * zSliceParam));//projectParams x:cameraNear y:cameraFar\r\n\r\n\tvec2 uv= vec2((float(clusterXIndex + clusterYIndex * CLUSTER_X_COUNT)+0.5)/float(c_ClusterBufferWidth),\r\n\t\t\t\t(float(clusterZIndex)+0.5)/float(c_ClusterBufferHeight));\r\n\tvec4 clusterPixel=texture2D(clusterBuffer, uv);\r\n\treturn ivec4(clusterPixel);//X:Point Count Y:Spot Count Zã€W:Light Offset\r\n}\r\n\r\n\r\nint getLightIndex(sampler2D clusterBuffer,int offset,int index) \r\n{\r\n\tint totalOffset=offset+index;\r\n\tint row=totalOffset/c_ClusterBufferFloatWidth;\r\n\tint lastRowFloat=totalOffset-row*c_ClusterBufferFloatWidth;\r\n\tint col=lastRowFloat/4;\r\n\tvec2 uv=vec2((float(col)+0.5)/float(c_ClusterBufferWidth),\r\n\t\t\t\t(float(row)+0.5)/float(c_ClusterBufferHeight));\r\n\tvec4 texel = texture2D(clusterBuffer, uv);\r\n    int pixelComponent = lastRowFloat-col*4;\r\n    if (pixelComponent == 0) \r\n      return int(texel.x);\r\n    else if (pixelComponent == 1) \r\n      return int(texel.y);\r\n    else if (pixelComponent == 2) \r\n      return int(texel.z);\r\n    else //pixelComponent==3\r\n      return int(texel.w);\r\n}\r\n\r\nDirectionLight getDirectionLight(sampler2D lightBuffer,int index) \r\n{\r\n    DirectionLight light;\r\n    float v = (float(index)+0.5)/ float(MAX_LIGHT_COUNT);\r\n    vec4 p1 = texture2D(lightBuffer, vec2(0.125,v));\r\n    vec4 p2 = texture2D(lightBuffer, vec2(0.375,v));\r\n\tlight.color=p1.rgb;\r\n    light.direction = p2.rgb;\r\n    return light;\r\n}\r\n\r\nPointLight getPointLight(sampler2D lightBuffer,sampler2D clusterBuffer,ivec4 clusterInfo,int index) \r\n{\r\n    PointLight light;\r\n\tint pointIndex=getLightIndex(clusterBuffer,clusterInfo.z*c_ClusterBufferFloatWidth+clusterInfo.w,index);\r\n    float v = (float(pointIndex)+0.5)/ float(MAX_LIGHT_COUNT);\r\n    vec4 p1 = texture2D(lightBuffer, vec2(0.125,v));\r\n    vec4 p2 = texture2D(lightBuffer, vec2(0.375,v));\r\n\tlight.color=p1.rgb;\r\n\tlight.range = p1.a;\r\n    light.position = p2.rgb;\r\n    return light;\r\n}\r\n\r\nSpotLight getSpotLight(sampler2D lightBuffer,sampler2D clusterBuffer,ivec4 clusterInfo,int index) \r\n{\r\n    SpotLight light;\r\n\tint spoIndex=getLightIndex(clusterBuffer,clusterInfo.z*c_ClusterBufferFloatWidth+clusterInfo.w,clusterInfo.x+index);\r\n    float v = (float(spoIndex)+0.5)/ float(MAX_LIGHT_COUNT);\r\n    vec4 p1 = texture2D(lightBuffer, vec2(0.125,v));\r\n    vec4 p2 = texture2D(lightBuffer, vec2(0.375,v));\r\n\tvec4 p3 = texture2D(lightBuffer, vec2(0.625,v));\r\n    light.color = p1.rgb;\r\n\tlight.range=p1.a;\r\n    light.position = p2.rgb;\r\n\tlight.spot = p2.a;\r\n\tlight.direction = p3.rgb;\r\n    return light;\r\n}\r\n\r\n// Layaä¸­ä½¿ç”¨è¡°å‡çº¹ç†\r\nfloat LayaAttenuation(in vec3 L,in float invLightRadius) {\r\n\tfloat fRatio = clamp(length(L) * invLightRadius,0.0,1.0);\r\n\tfRatio *= fRatio;\r\n\treturn 1.0 / (1.0 + 25.0 * fRatio)* clamp(4.0*(1.0 - fRatio),0.0,1.0); //fade to black as if 4 pixel texture\r\n}\r\n\r\n// Same as Just Cause 2 and Crysis 2 (you can read GPU Pro 1 book for more information)\r\nfloat BasicAttenuation(in vec3 L,in float invLightRadius) {\r\n\tvec3 distance = L * invLightRadius;\r\n\tfloat attenuation = clamp(1.0 - dot(distance, distance),0.0,1.0); // Equals float attenuation = saturate(1.0f - dot(L, L) / (lightRadius *  lightRadius));\r\n\treturn attenuation * attenuation;\r\n}\r\n\r\n// Inspired on http://fools.slindev.com/viewtopic.php?f=11&amp;t=21&amp;view=unread#unread\r\nfloat NaturalAttenuation(in vec3 L,in float invLightRadius) {\r\n\tfloat attenuationFactor = 30.0;\r\n\tvec3 distance = L * invLightRadius;\r\n\tfloat attenuation = dot(distance, distance); // Equals float attenuation = dot(L, L) / (lightRadius *  lightRadius);\r\n\tattenuation = 1.0 / (attenuation * attenuationFactor + 1.0);\r\n\t// Second we move down the function therewith it reaches zero at abscissa 1:\r\n\tattenuationFactor = 1.0 / (attenuationFactor + 1.0); //attenuationFactor contains now the value we have to subtract\r\n\tattenuation = max(attenuation - attenuationFactor, 0.0); // The max fixes a bug.\r\n\t// Finally we expand the equation along the y-axis so that it starts with a function value of 1 again.\r\n\tattenuation /= 1.0 - attenuationFactor;\r\n\treturn attenuation;\r\n}\r\n\r\nvoid LayaAirBlinnPhongLight (in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir,in vec3 lightColor, in vec3 lightVec,out vec3 diffuseColor,out vec3 specularColor) {\r\n\tmediump vec3 h = normalize(viewDir-lightVec);\r\n\tlowp float ln = max (0.0, dot (-lightVec,normal));\r\n\tfloat nh = max (0.0, dot (h,normal));\r\n\tdiffuseColor=lightColor * ln;\r\n\tspecularColor=lightColor *specColor*pow (nh, specColorIntensity*128.0) * gloss;\r\n}\r\n\r\nvoid LayaAirBlinnPhongDiectionLight (in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in DirectionLight light,out vec3 diffuseColor,out vec3 specularColor) {\r\n\tvec3 lightVec=normalize(light.direction);\r\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.color,lightVec,diffuseColor,specularColor);\r\n}\r\n\r\nvoid LayaAirBlinnPhongPointLight (in vec3 pos,in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in PointLight light,out vec3 diffuseColor,out vec3 specularColor) {\r\n\tvec3 lightVec =  pos-light.position;\r\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.color,lightVec/length(lightVec),diffuseColor,specularColor);\r\n\tfloat attenuate = LayaAttenuation(lightVec, 1.0/light.range);\r\n\tdiffuseColor *= attenuate;\r\n\tspecularColor*= attenuate;\r\n}\r\n\r\nvoid LayaAirBlinnPhongSpotLight (in vec3 pos,in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in SpotLight light,out vec3 diffuseColor,out vec3 specularColor) {\r\n\tvec3 lightVec =  pos-light.position;\r\n\tvec3 normalLightVec=lightVec/length(lightVec);\r\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.color,normalLightVec,diffuseColor,specularColor);\r\n\tvec2 cosAngles=cos(vec2(light.spot,light.spot*0.5)*0.5);//ConeAttenuation\r\n\tfloat dl=dot(normalize(light.direction),normalLightVec);\r\n\tdl*=smoothstep(cosAngles[0],cosAngles[1],dl);\r\n\tfloat attenuate = LayaAttenuation(lightVec, 1.0/light.range)*dl;\r\n\tdiffuseColor *=attenuate;\r\n\tspecularColor *=attenuate;\r\n}\r\n\r\nvec3 NormalSampleToWorldSpace(vec3 normalMapSample, vec3 unitNormal, vec3 tangent,vec3 binormal) {\r\n\tvec3 normalT =vec3(2.0*normalMapSample.x - 1.0,1.0-2.0*normalMapSample.y,2.0*normalMapSample.z - 1.0);\r\n\tmediump vec3 N = unitNormal;\r\n\tmediump vec3 T = tangent;\r\n\tmediump vec3 B = binormal;\r\n\tmat3 TBN = mat3(T, B, N);\r\n\r\n\t// Transform from tangent space to world space.\r\n\tvec3 bumpedNormal =normalize(TBN*normalT);\r\n\treturn bumpedNormal;\r\n}\r\n\r\nvec3 NormalSampleToWorldSpace1(vec4 normalMapSample, vec3 tangent, vec3 binormal, vec3 unitNormal) {\r\n\tvec3 normalT;\r\n\tnormalT.x = 2.0 * normalMapSample.x - 1.0;\r\n\tnormalT.y = 1.0 - 2.0 * normalMapSample.y;\r\n\tnormalT.z = sqrt(1.0 - clamp(dot(normalT.xy, normalT.xy), 0.0, 1.0));\r\n\r\n\tvec3 T = normalize(tangent);\r\n\tvec3 B = normalize(binormal);\r\n\tvec3 N = normalize(unitNormal);\r\n\tmat3 TBN = mat3(T, B, N);\r\n\r\n\t// Transform from tangent space to world space.\r\n\tvec3 bumpedNormal = TBN * normalize(normalT);\r\n\r\n\treturn bumpedNormal;\r\n}\r\n\r\nvec3 DecodeLightmap(vec4 color) {\r\n\treturn color.rgb*color.a*5.0;\r\n}\r\n\r\nvec3 decodeHDR(vec4 color,float range) {\r\n\treturn color.rgb*color.a*range;\r\n}\r\n\r\nvec2 TransformUV(vec2 texcoord,vec4 tilingOffset) {\r\n\tvec2 transTexcoord=vec2(texcoord.x,texcoord.y-1.0)*tilingOffset.xy+vec2(tilingOffset.z,-tilingOffset.w);\r\n\ttransTexcoord.y+=1.0;\r\n\treturn transTexcoord;\r\n}\r\n\r\nvec4 remapGLPositionZ(vec4 position) {\r\n\tposition.z=position.z * 2.0 - position.w;\r\n\treturn position;\r\n}\r\n\r\nmediump vec3 layaLinearToGammaSpace (mediump vec3 linRGB)\r\n{\r\n    linRGB = max(linRGB, vec3(0.0));\r\n    // An almost-perfect approximation from http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1\r\n    return max(1.055 * pow(linRGB,vec3(0.416666667)) - 0.055, 0.0);   \r\n}\r\n\r\nLayaLight layaDirectionLightToLight(in DirectionLight light,in float attenuate)\r\n{\r\n\tLayaLight relight;\r\n\trelight.color = light.color*attenuate;\r\n\trelight.dir = light.direction;\r\n\treturn relight;\r\n}\r\n\r\nLayaLight layaPointLightToLight(in vec3 pos,in vec3 normal, in PointLight light,in float attenuate)\r\n{\r\n\tLayaLight relight;\r\n\tvec3 lightVec =  pos-light.position;\r\n\tattenuate *= LayaAttenuation(lightVec, 1.0/light.range);\r\n\trelight.color = light.color*attenuate;\r\n\trelight.dir = normalize(lightVec);\r\n\treturn relight;\r\n}\r\n\r\nLayaLight layaSpotLightToLight(in vec3 pos,in vec3 normal, in SpotLight light,in float attenuate)\r\n{\r\n\tLayaLight relight;\r\n\tvec3 lightVec =  pos-light.position;\r\n\tvec3 normalLightVec=lightVec/length(lightVec);\r\n\tvec2 cosAngles=cos(vec2(light.spot,light.spot*0.5)*0.5);//ConeAttenuation\r\n\tfloat dl=dot(normalize(light.direction),normalLightVec);\r\n\tdl*=smoothstep(cosAngles[0],cosAngles[1],dl);\r\n\tattenuate *= LayaAttenuation(lightVec, 1.0/light.range)*dl;\r\n\trelight.dir = lightVec;\r\n\trelight.color = light.color*attenuate;\r\n\treturn relight;\r\n}\r\n\r\n",
        Ni = '// ------------------------------------------------------------------\r\n//  PCF Filtering Tent Functions\r\n// ------------------------------------------------------------------\r\n\r\n// Assuming a isoceles right angled triangle of height "triangleHeight" (as drawn below).\r\n// This function return the area of the triangle above the first texel(in Y the first texel).\r\n//\r\n// |\\      &lt;-- 45 degree slop isosceles right angled triangle\r\n// | \\\r\n// ----    &lt;-- length of this side is "triangleHeight"\r\n// _ _ _ _ &lt;-- texels\r\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight)\r\n{\r\n    return triangleHeight - 0.5;\r\n}\r\n\r\n// Assuming a isoceles triangle of 1.5 texels height and 3 texels wide lying on 4 texels.\r\n// This function return the area of the triangle above each of those texels.\r\n//    |    &lt;-- offset from -0.5 to 0.5, 0 meaning triangle is exactly in the center\r\n//   / \\   &lt;-- 45 degree slop isosceles triangle (ie tent projected in 2D)\r\n//  /   \\\r\n// _ _ _ _ &lt;-- texels\r\n// X Y Z W &lt;-- result indices (in computedArea.xyzw and computedAreaUncut.xyzw)\r\n// Top point at (right,top) in a texel,left bottom point at (middle,middle) in a texel,right bottom point at (middle,middle) in a texel.\r\nvoid sampleShadowGetTexelAreasTent3x3(float offset, out vec4 computedArea, out vec4 computedAreaUncut)\r\n{\r\n    // Compute the exterior areas,a and h is same.\r\n    float a = offset + 0.5;\r\n    float offsetSquaredHalved = a * a * 0.5;\r\n    computedAreaUncut.x = computedArea.x = offsetSquaredHalved - offset;\r\n    computedAreaUncut.w = computedArea.w = offsetSquaredHalved;\r\n\r\n    // Compute the middle areas\r\n    // For Y : We find the area in Y of as if the left section of the isoceles triangle would\r\n    // intersect the axis between Y and Z (ie where offset = 0).\r\n    computedAreaUncut.y = sampleShadowGetIRTriangleTexelArea(1.5 - offset);\r\n    // This area is superior to the one we are looking for if (offset &lt; 0) thus we need to\r\n    // subtract the area of the triangle defined by (0,1.5-offset), (0,1.5+offset), (-offset,1.5).\r\n    float clampedOffsetLeft = min(offset,0.0);\r\n    float areaOfSmallLeftTriangle = clampedOffsetLeft * clampedOffsetLeft;\r\n    computedArea.y = computedAreaUncut.y - areaOfSmallLeftTriangle;\r\n\r\n    // We do the same for the Z but with the right part of the isoceles triangle\r\n    computedAreaUncut.z = sampleShadowGetIRTriangleTexelArea(1.5 + offset);\r\n    float clampedOffsetRight = max(offset,0.0);\r\n    float areaOfSmallRightTriangle = clampedOffsetRight * clampedOffsetRight;\r\n    computedArea.z = computedAreaUncut.z - areaOfSmallRightTriangle;\r\n}\r\n\r\n// Assuming a isoceles triangle of 2.5 texel height and 5 texels wide lying on 6 texels.\r\n// This function return the weight of each texels area relative to the full triangle area.\r\n//  /       \\\r\n// _ _ _ _ _ _ &lt;-- texels\r\n// 0 1 2 3 4 5 &lt;-- computed area indices (in texelsWeights[])\r\n// Top point at (right,top) in a texel,left bottom point at (middle,middle) in a texel,right bottom point at (middle,middle) in a texel.\r\nvoid sampleShadowGetTexelWeightsTent5x5(float offset, out vec3 texelsWeightsA, out vec3 texelsWeightsB)\r\n{\r\n    vec4 areaFrom3texelTriangle;\r\n    vec4 areaUncutFrom3texelTriangle;\r\n    sampleShadowGetTexelAreasTent3x3(offset, areaFrom3texelTriangle, areaUncutFrom3texelTriangle);\r\n\r\n    // Triangle slope is 45 degree thus we can almost reuse the result of the 3 texel wide computation.\r\n    // the 5 texel wide triangle can be seen as the 3 texel wide one but shifted up by one unit/texel.\r\n    // 0.16 is 1/(the triangle area)\r\n    texelsWeightsA.x = 0.16 * (areaFrom3texelTriangle.x);\r\n    texelsWeightsA.y = 0.16 * (areaUncutFrom3texelTriangle.y);\r\n    texelsWeightsA.z = 0.16 * (areaFrom3texelTriangle.y + 1.0);\r\n    texelsWeightsB.x = 0.16 * (areaFrom3texelTriangle.z + 1.0);\r\n    texelsWeightsB.y = 0.16 * (areaUncutFrom3texelTriangle.z);\r\n    texelsWeightsB.z = 0.16 * (areaFrom3texelTriangle.w);\r\n}\r\n\r\n// 5x5 Tent filter (45 degree sloped triangles in U and V)\r\nvoid sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize, vec2 coord, out float fetchesWeights[9], out vec2 fetchesUV[9])\r\n{\r\n    // tent base is 5x5 base thus covering from 25 to 36 texels, thus we need 9 bilinear PCF fetches\r\n    vec2 tentCenterInTexelSpace = coord.xy * shadowMapTextureTexelSize.zw;\r\n    vec2 centerOfFetchesInTexelSpace = floor(tentCenterInTexelSpace + 0.5);\r\n    vec2 offsetFromTentCenterToCenterOfFetches = tentCenterInTexelSpace - centerOfFetchesInTexelSpace;\r\n\r\n    // find the weight of each texel based on the area of a 45 degree slop tent above each of them.\r\n    vec3 texelsWeightsUA, texelsWeightsUB;\r\n    vec3 texelsWeightsVA, texelsWeightsVB;\r\n    sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x, texelsWeightsUA, texelsWeightsUB);\r\n    sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y, texelsWeightsVA, texelsWeightsVB);\r\n\r\n    // each fetch will cover a group of 2x2 texels, the weight of each group is the sum of the weights of the texels\r\n    vec3 fetchesWeightsU = vec3(texelsWeightsUA.xz, texelsWeightsUB.y) + vec3(texelsWeightsUA.y, texelsWeightsUB.xz);\r\n    vec3 fetchesWeightsV = vec3(texelsWeightsVA.xz, texelsWeightsVB.y) + vec3(texelsWeightsVA.y, texelsWeightsVB.xz);\r\n\r\n    // move the PCF bilinear fetches to respect texels weights\r\n    vec3 fetchesOffsetsU = vec3(texelsWeightsUA.y, texelsWeightsUB.xz) / fetchesWeightsU.xyz + vec3(-2.5,-0.5,1.5);\r\n    vec3 fetchesOffsetsV = vec3(texelsWeightsVA.y, texelsWeightsVB.xz) / fetchesWeightsV.xyz + vec3(-2.5,-0.5,1.5);\r\n    fetchesOffsetsU *= shadowMapTextureTexelSize.xxx;\r\n    fetchesOffsetsV *= shadowMapTextureTexelSize.yyy;\r\n\r\n    vec2 bilinearFetchOrigin = centerOfFetchesInTexelSpace * shadowMapTextureTexelSize.xy;\r\n    fetchesUV[0] = bilinearFetchOrigin + vec2(fetchesOffsetsU.x, fetchesOffsetsV.x);\r\n    fetchesUV[1] = bilinearFetchOrigin + vec2(fetchesOffsetsU.y, fetchesOffsetsV.x);\r\n    fetchesUV[2] = bilinearFetchOrigin + vec2(fetchesOffsetsU.z, fetchesOffsetsV.x);\r\n    fetchesUV[3] = bilinearFetchOrigin + vec2(fetchesOffsetsU.x, fetchesOffsetsV.y);\r\n    fetchesUV[4] = bilinearFetchOrigin + vec2(fetchesOffsetsU.y, fetchesOffsetsV.y);\r\n    fetchesUV[5] = bilinearFetchOrigin + vec2(fetchesOffsetsU.z, fetchesOffsetsV.y);\r\n    fetchesUV[6] = bilinearFetchOrigin + vec2(fetchesOffsetsU.x, fetchesOffsetsV.z);\r\n    fetchesUV[7] = bilinearFetchOrigin + vec2(fetchesOffsetsU.y, fetchesOffsetsV.z);\r\n    fetchesUV[8] = bilinearFetchOrigin + vec2(fetchesOffsetsU.z, fetchesOffsetsV.z);\r\n\r\n    fetchesWeights[0] = fetchesWeightsU.x * fetchesWeightsV.x;\r\n    fetchesWeights[1] = fetchesWeightsU.y * fetchesWeightsV.x;\r\n    fetchesWeights[2] = fetchesWeightsU.z * fetchesWeightsV.x;\r\n    fetchesWeights[3] = fetchesWeightsU.x * fetchesWeightsV.y;\r\n    fetchesWeights[4] = fetchesWeightsU.y * fetchesWeightsV.y;\r\n    fetchesWeights[5] = fetchesWeightsU.z * fetchesWeightsV.y;\r\n    fetchesWeights[6] = fetchesWeightsU.x * fetchesWeightsV.z;\r\n    fetchesWeights[7] = fetchesWeightsU.y * fetchesWeightsV.z;\r\n    fetchesWeights[8] = fetchesWeightsU.z * fetchesWeightsV.z;\r\n}',
        bi = "#ifdef GL_FRAGMENT_PRECISION_HIGH\r\nprecision highp float;\r\n#else\r\nprecision mediump float;\r\n#endif\r\n\r\nvarying vec4 v_Color;\r\nuniform vec4 u_Color;\r\n\r\nvoid main()\r\n{\r\n  gl_FragColor = v_Color * u_Color; \r\n}\r\n\r\n",
        Pi = '#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nuniform mat4 u_MvpMatrix;\r\nuniform vec4 u_Color;\r\nattribute vec4 a_Color;\r\nvarying vec4 v_Color;\r\n\r\n\r\nvoid main()\r\n{\r\n\tgl_Position = u_MvpMatrix * a_Position;\r\n\tv_Color=a_Color*u_Color;\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',
        wi = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n\tprecision highp int;\r\n#else\r\n\tprecision mediump float;\r\n\tprecision mediump int;\r\n#endif\r\n\r\n#include "Lighting.glsl";\r\n#include "Shadow.glsl"\r\n\r\nuniform vec4 u_DiffuseColor;\r\n\r\n#if defined(COLOR)&amp;&amp;defined(ENABLEVERTEXCOLOR)\r\n\tvarying vec4 v_Color;\r\n#endif\r\n\r\n#ifdef ALPHATEST\r\n\tuniform float u_AlphaTestValue;\r\n#endif\r\n\r\n#ifdef DIFFUSEMAP\r\n\tuniform sampler2D u_DiffuseTexture;\r\n#endif\r\n\r\n\r\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&amp;&amp;(defined(SPECULARMAP)||defined(NORMALMAP)))\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tvarying vec2 v_LightMapUV;\r\n\tuniform sampler2D u_LightMap;\r\n#endif\r\n\r\nvarying vec3 v_Normal;\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\tvarying vec3 v_ViewDir; \r\n\r\n\tuniform vec3 u_MaterialSpecular;\r\n\tuniform float u_Shininess;\r\n\r\n\t#ifdef LEGACYSINGLELIGHTING\r\n\t\t#ifdef DIRECTIONLIGHT\r\n\t\t\tuniform DirectionLight u_DirectionLight;\r\n\t\t#endif\r\n\t\t#ifdef POINTLIGHT\r\n\t\t\tuniform PointLight u_PointLight;\r\n\t\t#endif\r\n\t\t#ifdef SPOTLIGHT\r\n\t\t\tuniform SpotLight u_SpotLight;\r\n\t\t#endif\r\n\t#else\r\n\t\tuniform mat4 u_View;\r\n\t\tuniform vec4 u_ProjectionParams;\r\n\t\tuniform vec4 u_Viewport;\r\n\t\tuniform int u_DirationLightCount;\r\n\t\tuniform sampler2D u_LightBuffer;\r\n\t\tuniform sampler2D u_LightClusterBuffer;\r\n\t#endif\r\n\r\n\t#ifdef SPECULARMAP \r\n\t\tuniform sampler2D u_SpecularTexture;\r\n\t#endif\r\n#endif\r\n\r\n#ifdef NORMALMAP \r\n\tuniform sampler2D u_NormalTexture;\r\n\tvarying vec3 v_Tangent;\r\n\tvarying vec3 v_Binormal;\r\n#endif\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\tuniform vec3 u_FogColor;\r\n#endif\r\n\r\n#if defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(CALCULATE_SHADOWS)&amp;&amp;defined(SHADOW_CASCADE))||defined(CALCULATE_SPOTSHADOWS)\r\n\tvarying vec3 v_PositionWorld;\r\n#endif\r\n\r\n\r\n#include "GlobalIllumination.glsl";//"GlobalIllumination.glsl use uniform should at front of this\r\n\r\n#if defined(CALCULATE_SHADOWS)&amp;&amp;!defined(SHADOW_CASCADE)\r\n\tvarying vec4 v_ShadowCoord;\r\n#endif\r\n\r\n#ifdef CALCULATE_SPOTSHADOWS\r\n\tvarying vec4 v_SpotShadowCoord;\r\n#endif\r\n\r\n\r\nvoid main()\r\n{\r\n\tvec3 normal;//light and SH maybe use normal\r\n\t#if defined(NORMALMAP)\r\n\t\tvec3 normalMapSample = texture2D(u_NormalTexture, v_Texcoord0).rgb;\r\n\t\tnormal = normalize(NormalSampleToWorldSpace(normalMapSample, v_Normal, v_Tangent,v_Binormal));\r\n\t#else\r\n\t\tnormal = normalize(v_Normal);\r\n\t#endif\r\n\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\tvec3 viewDir= normalize(v_ViewDir);\r\n\t#endif\r\n\r\n\tLayaGIInput giInput;\r\n\t#ifdef LIGHTMAP\t\r\n\t\tgiInput.lightmapUV=v_LightMapUV;\r\n\t#endif\r\n\tvec3 globalDiffuse=layaGIBase(giInput,1.0,normal);\r\n\t\r\n\tvec4 mainColor=u_DiffuseColor;\r\n\t#ifdef DIFFUSEMAP\r\n\t\tvec4 difTexColor=texture2D(u_DiffuseTexture, v_Texcoord0);\r\n\t\tmainColor=mainColor*difTexColor;\r\n\t#endif \r\n\t#if defined(COLOR)&amp;&amp;defined(ENABLEVERTEXCOLOR)\r\n\t\tmainColor=mainColor*v_Color;\r\n\t#endif \r\n    \r\n\t#ifdef ALPHATEST\r\n\t\tif(mainColor.a&lt;u_AlphaTestValue)\r\n\t\t\tdiscard;\r\n\t#endif\r\n  \r\n\t\r\n\tvec3 diffuse = vec3(0.0);\r\n\tvec3 specular= vec3(0.0);\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\tvec3 dif,spe;\r\n\t\t#ifdef SPECULARMAP\r\n\t\t\tvec3 gloss=texture2D(u_SpecularTexture, v_Texcoord0).rgb;\r\n\t\t#else\r\n\t\t\t#ifdef DIFFUSEMAP\r\n\t\t\t\tvec3 gloss=vec3(difTexColor.a);\r\n\t\t\t#else\r\n\t\t\t\tvec3 gloss=vec3(1.0);\r\n\t\t\t#endif\r\n\t\t#endif\r\n\t#endif\r\n\r\n\t\r\n\t\r\n\t#ifdef LEGACYSINGLELIGHTING\r\n\t\t#ifdef DIRECTIONLIGHT\r\n\t\t\tLayaAirBlinnPhongDiectionLight(u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,u_DirectionLight,dif,spe);\r\n\t\t\t#ifdef CALCULATE_SHADOWS\r\n\t\t\t\t#ifdef SHADOW_CASCADE\r\n\t\t\t\t\tvec4 shadowCoord = getShadowCoord(vec4(v_PositionWorld,1.0));\r\n\t\t\t\t#else\r\n\t\t\t\t\tvec4 shadowCoord = v_ShadowCoord;\r\n\t\t\t\t#endif\r\n\t\t\t\tfloat shadowAttenuation=sampleShadowmap(shadowCoord);\r\n\t\t\t\tdif *= shadowAttenuation;\r\n\t\t\t\tspe *= shadowAttenuation;\r\n\t\t\t#endif\r\n\t\t\tdiffuse+=dif;\r\n\t\t\tspecular+=spe;\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef POINTLIGHT\r\n\t\t\tLayaAirBlinnPhongPointLight(v_PositionWorld,u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,u_PointLight,dif,spe);\r\n\t\t\tdiffuse+=dif;\r\n\t\t\tspecular+=spe;\r\n\t\t#endif\r\n\r\n\t\t#ifdef SPOTLIGHT\r\n\t\t\tLayaAirBlinnPhongSpotLight(v_PositionWorld,u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,u_SpotLight,dif,spe);\r\n\t\t\t#ifdef CALCULATE_SPOTSHADOWS\r\n\t\t\t\tvec4 spotShadowcoord = v_SpotShadowCoord;\r\n\t\t\t\tfloat spotShadowAttenuation = sampleSpotShadowmap(spotShadowcoord);\r\n\t\t\t\tdif *= shadowAttenuation;\r\n\t\t\t\tspe *= shadowAttenuation;\r\n\t\t\t#endif\r\n\t\t\tdiffuse+=dif;\r\n\t\t\tspecular+=spe;\r\n\t\t#endif\r\n\t#else\r\n\t\t#ifdef DIRECTIONLIGHT\r\n\t\t\tfor (int i = 0; i &lt; MAX_LIGHT_COUNT; i++) \r\n\t\t\t{\r\n\t\t\t\tif(i &gt;= u_DirationLightCount)\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tDirectionLight directionLight = getDirectionLight(u_LightBuffer,i);\r\n\t\t\t\t#ifdef CALCULATE_SHADOWS\r\n\t\t\t\t\tif(i == 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t#ifdef SHADOW_CASCADE\r\n\t\t\t\t\t\t\tvec4 shadowCoord = getShadowCoord(vec4(v_PositionWorld,1.0));\r\n\t\t\t\t\t\t#else\r\n\t\t\t\t\t\t\tvec4 shadowCoord = v_ShadowCoord;\r\n\t\t\t\t\t\t#endif\r\n\t\t\t\t\t\tdirectionLight.color *= sampleShadowmap(shadowCoord);\r\n\t\t\t\t\t}\r\n\t\t\t\t#endif\r\n\t\t\t\tLayaAirBlinnPhongDiectionLight(u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,directionLight,dif,spe);\r\n\t\t\t\tdiffuse+=dif;\r\n\t\t\t\tspecular+=spe;\r\n\t\t\t}\r\n\t\t#endif\r\n\t\t#if defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\t\tivec4 clusterInfo =getClusterInfo(u_LightClusterBuffer,u_View,u_Viewport, v_PositionWorld,gl_FragCoord,u_ProjectionParams);\r\n\t\t\t#ifdef POINTLIGHT\r\n\t\t\t\tfor (int i = 0; i &lt; MAX_LIGHT_COUNT; i++) \r\n\t\t\t\t{\r\n\t\t\t\t\tif(i &gt;= clusterInfo.x)//PointLightCount\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tPointLight pointLight = getPointLight(u_LightBuffer,u_LightClusterBuffer,clusterInfo,i);\r\n\t\t\t\t\tLayaAirBlinnPhongPointLight(v_PositionWorld,u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,pointLight,dif,spe);\r\n\t\t\t\t\tdiffuse+=dif;\r\n\t\t\t\t\tspecular+=spe;\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t\t#ifdef SPOTLIGHT\r\n\t\t\t\tfor (int i = 0; i &lt; MAX_LIGHT_COUNT; i++) \r\n\t\t\t\t{\r\n\t\t\t\t\tif(i &gt;= clusterInfo.y)//SpotLightCount\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tSpotLight spotLight = getSpotLight(u_LightBuffer,u_LightClusterBuffer,clusterInfo,i);\r\n\t\t\t\t\t#ifdef CALCULATE_SPOTSHADOWS\r\n\t\t\t\t\t\tif(i == 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvec4 spotShadowcoord = v_SpotShadowCoord;\r\n\t\t\t\t\t\t\tspotLight.color *= sampleSpotShadowmap(spotShadowcoord);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t#endif\r\n\t\t\t\t\tLayaAirBlinnPhongSpotLight(v_PositionWorld,u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,spotLight,dif,spe);\r\n\t\t\t\t\tdiffuse+=dif;\r\n\t\t\t\t\tspecular+=spe;\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t#endif\r\n\t#endif\r\n\r\n\tgl_FragColor =vec4(mainColor.rgb*(globalDiffuse + diffuse),mainColor.a);\r\n\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\tgl_FragColor.rgb+=specular;\r\n\t#endif\r\n\t  \r\n\t#ifdef FOG\r\n\t\tfloat lerpFact=clamp((1.0/gl_FragCoord.w-u_FogStart)/u_FogRange,0.0,1.0);\r\n\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\r\n\t#endif\r\n}\r\n\r\n',
        Vi = '#include "Lighting.glsl";\r\n#include "Shadow.glsl";\r\n\r\nattribute vec4 a_Position;\r\n\r\n#ifdef GPU_INSTANCE\r\n\tattribute mat4 a_MvpMatrix;\r\n#else\r\n\tuniform mat4 u_MvpMatrix;\r\n#endif\r\n\r\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&amp;&amp;(defined(SPECULARMAP)||defined(NORMALMAP)))||(defined(LIGHTMAP)&amp;&amp;defined(UV))\r\n\tattribute vec2 a_Texcoord0;\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\n#if defined(LIGHTMAP)&amp;&amp;defined(UV1)\r\n\tattribute vec2 a_Texcoord1;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tuniform vec4 u_LightmapScaleOffset;\r\n\tvarying vec2 v_LightMapUV;\r\n#endif\r\n\r\n#ifdef COLOR\r\n\tattribute vec4 a_Color;\r\n\tvarying vec4 v_Color;\r\n#endif\r\n\r\n#ifdef BONE\r\n\tconst int c_MaxBoneCount = 24;\r\n\tattribute vec4 a_BoneIndices;\r\n\tattribute vec4 a_BoneWeights;\r\n\tuniform mat4 u_Bones[c_MaxBoneCount];\r\n#endif\r\n\r\nattribute vec3 a_Normal;\r\nvarying vec3 v_Normal; \r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\tuniform vec3 u_CameraPos;\r\n\tvarying vec3 v_ViewDir; \r\n#endif\r\n\r\n#if defined(NORMALMAP)\r\n\tattribute vec4 a_Tangent0;\r\n\tvarying vec3 v_Tangent;\r\n\tvarying vec3 v_Binormal;\r\n#endif\r\n\r\n#ifdef GPU_INSTANCE\r\n\tattribute mat4 a_WorldMat;\r\n#else\r\n\tuniform mat4 u_WorldMat;\r\n#endif\r\n\r\n#if defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(CALCULATE_SHADOWS)&amp;&amp;defined(SHADOW_CASCADE))||defined(CALCULATE_SPOTSHADOWS)\r\n\tvarying vec3 v_PositionWorld;\r\n#endif\r\n\r\n#if defined(CALCULATE_SHADOWS)&amp;&amp;!defined(SHADOW_CASCADE)\r\n\tvarying vec4 v_ShadowCoord;\r\n#endif\r\n\r\n#ifdef CALCULATE_SPOTSHADOWS\r\n\tvarying vec4 v_SpotShadowCoord;\r\n#endif\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tvec4 position;\r\n\t#ifdef BONE\r\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\tposition=skinTransform*a_Position;\r\n\t#else\r\n\t\tposition=a_Position;\r\n\t#endif\r\n\t#ifdef GPU_INSTANCE\r\n\t\tgl_Position = a_MvpMatrix * position;\r\n\t#else\r\n\t\tgl_Position = u_MvpMatrix * position;\r\n\t#endif\r\n\t\r\n\tmat4 worldMat;\r\n\t#ifdef GPU_INSTANCE\r\n\t\tworldMat = a_WorldMat;\r\n\t#else\r\n\t\tworldMat = u_WorldMat;\r\n\t#endif\r\n\r\n\tmat3 worldInvMat;\r\n\t#ifdef BONE\r\n\t\tworldInvMat=INVERSE_MAT(mat3(worldMat*skinTransform));\r\n\t#else\r\n\t\tworldInvMat=INVERSE_MAT(mat3(worldMat));\r\n\t#endif  \r\n\tv_Normal=normalize(a_Normal*worldInvMat);\r\n\t#if defined(NORMALMAP)\r\n\t\tv_Tangent=normalize(a_Tangent0.xyz*worldInvMat);\r\n\t\tv_Binormal=cross(v_Normal,v_Tangent)*a_Tangent0.w;\r\n\t#endif\r\n\r\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(CALCULATE_SHADOWS)&amp;&amp;defined(SHADOW_CASCADE))||defined(CALCULATE_SPOTSHADOWS)\r\n\t\tvec3 positionWS=(worldMat*position).xyz;\r\n\t\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\t\tv_ViewDir = u_CameraPos-positionWS;\r\n\t\t#endif\r\n\t\t#if defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(CALCULATE_SHADOWS)&amp;&amp;defined(SHADOW_CASCADE))||defined(CALCULATE_SPOTSHADOWS)\r\n\t\t\tv_PositionWorld = positionWS;\r\n\t\t#endif\r\n\t#endif\r\n\r\n\t#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&amp;&amp;(defined(SPECULARMAP)||defined(NORMALMAP)))\r\n\t\t#ifdef TILINGOFFSET\r\n\t\t\tv_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\r\n\t\t#else\r\n\t\t\tv_Texcoord0=a_Texcoord0;\r\n\t\t#endif\r\n\t#endif\r\n\r\n\t#ifdef LIGHTMAP\r\n\t\t#ifdef UV1\r\n\t\t\tv_LightMapUV=vec2(a_Texcoord1.x,1.0-a_Texcoord1.y)*u_LightmapScaleOffset.xy+u_LightmapScaleOffset.zw;\r\n\t\t#else\r\n\t\t\tv_LightMapUV=vec2(a_Texcoord0.x,1.0-a_Texcoord0.y)*u_LightmapScaleOffset.xy+u_LightmapScaleOffset.zw;\r\n\t\t#endif \r\n\t\tv_LightMapUV.y=1.0-v_LightMapUV.y;\r\n\t#endif\r\n\r\n\t#if defined(COLOR)&amp;&amp;defined(ENABLEVERTEXCOLOR)\r\n\t\tv_Color=a_Color;\r\n\t#endif\r\n\r\n\t#if defined(CALCULATE_SHADOWS)&amp;&amp;!defined(SHADOW_CASCADE)\r\n\t\tv_ShadowCoord =getShadowCoord(vec4(positionWS,1.0));\r\n\t#endif\r\n\r\n\t#ifdef CALCULATE_SPOTSHADOWS\r\n\t\tv_SpotShadowCoord = u_SpotViewProjectMatrix*vec4(positionWS,1.0);\r\n\t#endif\r\n\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',
        Bi = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n\tprecision highp int;\r\n#else\r\n\tprecision mediump float;\r\n\tprecision mediump int;\r\n#endif\r\n\r\n#include "ShadowCasterFS.glsl"\r\n\r\nvoid main()\r\n{\r\n\tgl_FragColor=shadowCasterFragment();\r\n}',
        Fi = '#include "ShadowCasterVS.glsl"\r\n\r\nvoid main()\r\n{\r\n\tvec4 positionCS =  shadowCasterVertex();\r\n\tgl_Position=remapGLPositionZ(positionCS);\r\n}',
        Ui = "#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n  precision highp float;\r\n#else\r\n  precision mediump float;\r\n#endif\r\n\r\nvarying vec4 v_Color;\r\nvarying vec2 v_TextureCoordinate;\r\nuniform sampler2D u_texture;\r\nuniform vec4 u_Tintcolor;\r\n\r\n#ifdef RENDERMODE_MESH\r\n\tvarying vec4 v_MeshColor;\r\n#endif\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\t#ifdef ADDTIVEFOG\r\n\t#else\r\n\t\tuniform vec3 u_FogColor;\r\n\t#endif\r\n#endif\r\n\r\n\r\nvoid main()\r\n{\t\r\n\t#ifdef RENDERMODE_MESH\r\n\t\tgl_FragColor=v_MeshColor;\r\n\t#else\r\n\t\tgl_FragColor=vec4(1.0);\t\r\n\t#endif\r\n\t\t\r\n\t#ifdef DIFFUSEMAP\r\n\t\t#ifdef TINTCOLOR\r\n\t\t\tgl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*u_Tintcolor*2.0*v_Color;\r\n\t\t#else\r\n\t\t\tgl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*v_Color;\r\n\t\t#endif\r\n\t#else\r\n\t\t#ifdef TINTCOLOR\r\n\t\t\tgl_FragColor*=u_Tintcolor*2.0*v_Color;\r\n\t\t#else\r\n\t\t\tgl_FragColor*=v_Color;\r\n\t\t#endif\r\n\t#endif\r\n\t\r\n\t#ifdef FOG\r\n\t\tfloat lerpFact=clamp((1.0/gl_FragCoord.w-u_FogStart)/u_FogRange,0.0,1.0);\r\n\t\t#ifdef ADDTIVEFOG\r\n\t\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,vec3(0.0,0.0,0.0),lerpFact);\r\n\t\t#else\r\n\t\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\r\n\t\t#endif\r\n\t#endif\r\n}",
        Gi = '#include "Lighting.glsl";\r\n\r\n#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n  precision highp float;\r\n#else\r\n  precision mediump float;\r\n#endif\r\n\r\n#if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\r\n\tattribute vec4 a_CornerTextureCoordinate;\r\n#endif\r\n#ifdef RENDERMODE_MESH\r\n\tattribute vec3 a_MeshPosition;\r\n\tattribute vec4 a_MeshColor;\r\n\tattribute vec2 a_MeshTextureCoordinate;\r\n\tvarying vec4 v_MeshColor;\r\n#endif\r\n\r\nattribute vec4 a_ShapePositionStartLifeTime;\r\nattribute vec4 a_DirectionTime;\r\nattribute vec4 a_StartColor;\r\nattribute vec3 a_StartSize;\r\nattribute vec3 a_StartRotation0;\r\nattribute float a_StartSpeed;\r\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)||defined(SIZEOVERLIFETIMERANDOMCURVES)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\r\n  attribute vec4 a_Random0;\r\n#endif\r\n#if defined(TEXTURESHEETANIMATIONRANDOMCURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n  attribute vec4 a_Random1;\r\n#endif\r\nattribute vec3 a_SimulationWorldPostion;\r\nattribute vec4 a_SimulationWorldRotation;\r\n\r\nvarying vec4 v_Color;\r\n#ifdef DIFFUSEMAP\r\n\tvarying vec2 v_TextureCoordinate;\r\n#endif\r\n\r\nuniform float u_CurrentTime;\r\nuniform vec3 u_Gravity;\r\n\r\nuniform vec3 u_WorldPosition;\r\nuniform vec4 u_WorldRotation;\r\nuniform bool u_ThreeDStartRotation;\r\nuniform int u_ScalingMode;\r\nuniform vec3 u_PositionScale;\r\nuniform vec3 u_SizeScale;\r\nuniform mat4 u_View;\r\nuniform mat4 u_Projection;\r\n\r\n#ifdef STRETCHEDBILLBOARD\r\n\tuniform vec3 u_CameraPos;\r\n#endif\r\nuniform vec3 u_CameraDirection;//TODO:åªæœ‰å‡&nbsp;ç§å¹¿å‘Šç‰Œæ¨¡å¼éœ€è¦ç”¨\r\nuniform vec3 u_CameraUp;\r\n\r\nuniform  float u_StretchedBillboardLengthScale;\r\nuniform  float u_StretchedBillboardSpeedScale;\r\nuniform int u_SimulationSpace;\r\n\r\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n  uniform  int  u_VOLSpaceType;\r\n#endif\r\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)\r\n  uniform  vec3 u_VOLVelocityConst;\r\n#endif\r\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n  uniform  vec2 u_VOLVelocityGradientX[4];//xä¸ºkey,yä¸ºé€Ÿåº¦\r\n  uniform  vec2 u_VOLVelocityGradientY[4];//xä¸ºkey,yä¸ºé€Ÿåº¦\r\n  uniform  vec2 u_VOLVelocityGradientZ[4];//xä¸ºkey,yä¸ºé€Ÿåº¦\r\n#endif\r\n#ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\r\n  uniform  vec3 u_VOLVelocityConstMax;\r\n#endif\r\n#ifdef VELOCITYOVERLIFETIMERANDOMCURVE\r\n  uniform  vec2 u_VOLVelocityGradientMaxX[4];//xä¸ºkey,yä¸ºé€Ÿåº¦\r\n  uniform  vec2 u_VOLVelocityGradientMaxY[4];//xä¸ºkey,yä¸ºé€Ÿåº¦\r\n  uniform  vec2 u_VOLVelocityGradientMaxZ[4];//xä¸ºkey,yä¸ºé€Ÿåº¦\r\n#endif\r\n\r\n#ifdef COLOROVERLIFETIME\r\n  uniform  vec4 u_ColorOverLifeGradientColors[4];//xä¸ºkey,yzwä¸ºColor\r\n  uniform  vec2 u_ColorOverLifeGradientAlphas[4];//xä¸ºkey,yä¸ºAlpha\r\n#endif\r\n#ifdef RANDOMCOLOROVERLIFETIME\r\n  uniform  vec4 u_ColorOverLifeGradientColors[4];//xä¸ºkey,yzwä¸ºColor\r\n  uniform  vec2 u_ColorOverLifeGradientAlphas[4];//xä¸ºkey,yä¸ºAlpha\r\n  uniform  vec4 u_MaxColorOverLifeGradientColors[4];//xä¸ºkey,yzwä¸ºColor\r\n  uniform  vec2 u_MaxColorOverLifeGradientAlphas[4];//xä¸ºkey,yä¸ºAlpha\r\n#endif\r\n\r\n\r\n#if defined(SIZEOVERLIFETIMECURVE)||defined(SIZEOVERLIFETIMERANDOMCURVES)\r\n  uniform  vec2 u_SOLSizeGradient[4];//xä¸ºkey,yä¸ºå°ºå¯¸\r\n#endif\r\n#ifdef SIZEOVERLIFETIMERANDOMCURVES\r\n  uniform  vec2 u_SOLSizeGradientMax[4];//xä¸ºkey,yä¸ºå°ºå¯¸\r\n#endif\r\n#if defined(SIZEOVERLIFETIMECURVESEPERATE)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)\r\n  uniform  vec2 u_SOLSizeGradientX[4];//xä¸ºkey,yä¸ºå°ºå¯¸\r\n  uniform  vec2 u_SOLSizeGradientY[4];//xä¸ºkey,yä¸ºå°ºå¯¸\r\n  uniform  vec2 u_SOLSizeGradientZ[4];//xä¸ºkey,yä¸ºå°ºå¯¸\r\n#endif\r\n#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\r\n  uniform  vec2 u_SOLSizeGradientMaxX[4];//xä¸ºkey,yä¸ºå°ºå¯¸\r\n  uniform  vec2 u_SOLSizeGradientMaxY[4];//xä¸ºkey,yä¸ºå°ºå¯¸\r\n  uniform  vec2 u_SOLSizeGradientMaxZ[4];//xä¸ºkey,yä¸ºå°ºå¯¸\r\n#endif\r\n\r\n\r\n#ifdef ROTATIONOVERLIFETIME\r\n  #if defined(ROTATIONOVERLIFETIMECONSTANT)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)\r\n    uniform  float u_ROLAngularVelocityConst;\r\n  #endif\r\n  #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n    uniform  float u_ROLAngularVelocityConstMax;\r\n  #endif\r\n  #if defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\r\n    uniform  vec2 u_ROLAngularVelocityGradient[4];//xä¸ºkey,yä¸ºæ—‹è½¬\r\n  #endif\r\n  #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n    uniform  vec2 u_ROLAngularVelocityGradientMax[4];//xä¸ºkey,yä¸ºæ—‹è½¬\r\n  #endif\r\n#endif\r\n#ifdef ROTATIONOVERLIFETIMESEPERATE\r\n  #if defined(ROTATIONOVERLIFETIMECONSTANT)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)\r\n    uniform  vec3 u_ROLAngularVelocityConstSeprarate;\r\n  #endif\r\n  #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n    uniform  vec3 u_ROLAngularVelocityConstMaxSeprarate;\r\n  #endif\r\n  #if defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\r\n    uniform  vec2 u_ROLAngularVelocityGradientX[4];\r\n    uniform  vec2 u_ROLAngularVelocityGradientY[4];\r\n    uniform  vec2 u_ROLAngularVelocityGradientZ[4];\r\n  #endif\r\n  #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n    uniform  vec2 u_ROLAngularVelocityGradientMaxX[4];\r\n    uniform  vec2 u_ROLAngularVelocityGradientMaxY[4];\r\n    uniform  vec2 u_ROLAngularVelocityGradientMaxZ[4];\r\n\tuniform  vec2 u_ROLAngularVelocityGradientMaxW[4];\r\n  #endif\r\n#endif\r\n\r\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\r\n  uniform  float u_TSACycles;\r\n  uniform  vec2 u_TSASubUVLength;\r\n  uniform  vec2 u_TSAGradientUVs[4];//xä¸ºkey,yä¸ºframe\r\n#endif\r\n#ifdef TEXTURESHEETANIMATIONRANDOMCURVE\r\n  uniform  vec2 u_TSAMaxGradientUVs[4];//xä¸ºkey,yä¸ºframe\r\n#endif\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif\r\n\r\nvec3 rotationByEuler(in vec3 vector,in vec3 rot)\r\n{\r\n\tfloat halfRoll = rot.z * 0.5;\r\n    float halfPitch = rot.x * 0.5;\r\n\tfloat halfYaw = rot.y * 0.5;\r\n\r\n\tfloat sinRoll = sin(halfRoll);\r\n\tfloat cosRoll = cos(halfRoll);\r\n\tfloat sinPitch = sin(halfPitch);\r\n\tfloat cosPitch = cos(halfPitch);\r\n\tfloat sinYaw = sin(halfYaw);\r\n\tfloat cosYaw = cos(halfYaw);\r\n\r\n\tfloat quaX = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);\r\n\tfloat quaY = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);\r\n\tfloat quaZ = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);\r\n\tfloat quaW = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);\r\n\t\r\n\t//vec4 q=vec4(quaX,quaY,quaZ,quaW);\r\n\t//vec3 temp = cross(q.xyz, vector) + q.w * vector;\r\n\t//return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\r\n\t\r\n\tfloat x = quaX + quaX;\r\n    float y = quaY + quaY;\r\n    float z = quaZ + quaZ;\r\n    float wx = quaW * x;\r\n    float wy = quaW * y;\r\n    float wz = quaW * z;\r\n\tfloat xx = quaX * x;\r\n    float xy = quaX * y;\r\n\tfloat xz = quaX * z;\r\n    float yy = quaY * y;\r\n    float yz = quaY * z;\r\n    float zz = quaZ * z;\r\n\r\n    return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\r\n                ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\r\n                ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\r\n\t\r\n}\r\n\r\n//å‡å®šaxiså·²ç»å½’ä¸€åŒ–\r\nvec3 rotationByAxis(in vec3 vector,in vec3 axis, in float angle)\r\n{\r\n\tfloat halfAngle = angle * 0.5;\r\n\tfloat sin = sin(halfAngle);\r\n\t\r\n\tfloat quaX = axis.x * sin;\r\n\tfloat quaY = axis.y * sin;\r\n\tfloat quaZ = axis.z * sin;\r\n\tfloat quaW = cos(halfAngle);\r\n\t\r\n\t//vec4 q=vec4(quaX,quaY,quaZ,quaW);\r\n\t//vec3 temp = cross(q.xyz, vector) + q.w * vector;\r\n\t//return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\r\n\t\r\n\tfloat x = quaX + quaX;\r\n    float y = quaY + quaY;\r\n    float z = quaZ + quaZ;\r\n    float wx = quaW * x;\r\n    float wy = quaW * y;\r\n    float wz = quaW * z;\r\n\tfloat xx = quaX * x;\r\n    float xy = quaX * y;\r\n\tfloat xz = quaX * z;\r\n    float yy = quaY * y;\r\n    float yz = quaY * z;\r\n    float zz = quaZ * z;\r\n\r\n    return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\r\n                ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\r\n                ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\r\n\t\r\n}\r\n\r\nvec3 rotationByQuaternions(in vec3 v,in vec4 q) \r\n{\r\n\treturn v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\r\n}\r\n\r\n \r\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(SIZEOVERLIFETIMECURVE)||defined(SIZEOVERLIFETIMECURVESEPERATE)||defined(SIZEOVERLIFETIMERANDOMCURVES)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)\r\nfloat getCurValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\r\n{\r\n\tfloat curValue;\r\n\tfor(int i=1;i&lt;4;i++)\r\n\t{\r\n\t\tvec2 gradientNumber=gradientNumbers[i];\r\n\t\tfloat key=gradientNumber.x;\r\n\t\tif(key&gt;=normalizedAge)\r\n\t\t{\r\n\t\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\r\n\t\t\tfloat lastKey=lastGradientNumber.x;\r\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\r\n\t\t\tcurValue=mix(lastGradientNumber.y,gradientNumber.y,age);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn curValue;\r\n}\r\n#endif\r\n\r\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\r\nfloat getTotalValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\r\n{\r\n\tfloat totalValue=0.0;\r\n\tfor(int i=1;i&lt;4;i++)\r\n\t{\r\n\t\tvec2 gradientNumber=gradientNumbers[i];\r\n\t\tfloat key=gradientNumber.x;\r\n\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\r\n\t\tfloat lastValue=lastGradientNumber.y;\r\n\t\t\r\n\t\tif(key&gt;=normalizedAge){\r\n\t\t\tfloat lastKey=lastGradientNumber.x;\r\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\r\n\t\t\ttotalValue+=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0*a_ShapePositionStartLifeTime.w*(normalizedAge-lastKey);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\telse{\r\n\t\t\ttotalValue+=(lastValue+gradientNumber.y)/2.0*a_ShapePositionStartLifeTime.w*(key-lastGradientNumber.x);\r\n\t\t}\r\n\t}\r\n\treturn totalValue;\r\n}\r\n#endif\r\n\r\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)\r\nvec4 getColorFromGradient(in vec2 gradientAlphas[4],in vec4 gradientColors[4],in float normalizedAge)\r\n{\r\n\tvec4 overTimeColor;\r\n\tfor(int i=1;i&lt;4;i++)\r\n\t{\r\n\t\tvec2 gradientAlpha=gradientAlphas[i];\r\n\t\tfloat alphaKey=gradientAlpha.x;\r\n\t\tif(alphaKey&gt;=normalizedAge)\r\n\t\t{\r\n\t\t\tvec2 lastGradientAlpha=gradientAlphas[i-1];\r\n\t\t\tfloat lastAlphaKey=lastGradientAlpha.x;\r\n\t\t\tfloat age=(normalizedAge-lastAlphaKey)/(alphaKey-lastAlphaKey);\r\n\t\t\toverTimeColor.a=mix(lastGradientAlpha.y,gradientAlpha.y,age);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t\r\n\tfor(int i=1;i&lt;4;i++)\r\n\t{\r\n\t\tvec4 gradientColor=gradientColors[i];\r\n\t\tfloat colorKey=gradientColor.x;\r\n\t\tif(colorKey&gt;=normalizedAge)\r\n\t\t{\r\n\t\t\tvec4 lastGradientColor=gradientColors[i-1];\r\n\t\t\tfloat lastColorKey=lastGradientColor.x;\r\n\t\t\tfloat age=(normalizedAge-lastColorKey)/(colorKey-lastColorKey);\r\n\t\t\toverTimeColor.rgb=mix(gradientColors[i-1].yzw,gradientColor.yzw,age);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn overTimeColor;\r\n}\r\n#endif\r\n\r\n\r\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\r\nfloat getFrameFromGradient(in vec2 gradientFrames[4],in float normalizedAge)\r\n{\r\n\tfloat overTimeFrame;\r\n\tfor(int i=1;i&lt;4;i++)\r\n\t{\r\n\t\tvec2 gradientFrame=gradientFrames[i];\r\n\t\tfloat key=gradientFrame.x;\r\n\t\tif(key&gt;=normalizedAge)\r\n\t\t{\r\n\t\t\tvec2 lastGradientFrame=gradientFrames[i-1];\r\n\t\t\tfloat lastKey=lastGradientFrame.x;\r\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\r\n\t\t\toverTimeFrame=mix(lastGradientFrame.y,gradientFrame.y,age);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn floor(overTimeFrame);\r\n}\r\n#endif\r\n\r\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\nvec3 computeParticleLifeVelocity(in float normalizedAge)\r\n{\r\n  vec3 outLifeVelocity;\r\n  #ifdef VELOCITYOVERLIFETIMECONSTANT\r\n\t outLifeVelocity=u_VOLVelocityConst; \r\n  #endif\r\n  #ifdef VELOCITYOVERLIFETIMECURVE\r\n     outLifeVelocity= vec3(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\r\n  #endif\r\n  #ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\r\n\t outLifeVelocity=mix(u_VOLVelocityConst,u_VOLVelocityConstMax,vec3(a_Random1.y,a_Random1.z,a_Random1.w)); \r\n  #endif\r\n  #ifdef VELOCITYOVERLIFETIMERANDOMCURVE\r\n     outLifeVelocity=vec3(mix(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y),\r\n\t                 mix(getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z),\r\n\t\t\t\t\t mix(getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\r\n  #endif\r\n\t\t\t\t\t\r\n  return outLifeVelocity;\r\n} \r\n#endif\r\n\r\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation)\r\n{\r\n   vec3 startPosition;\r\n   vec3 lifePosition;\r\n   #if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n\t#ifdef VELOCITYOVERLIFETIMECONSTANT\r\n\t\t  startPosition=startVelocity*age;\r\n\t\t  lifePosition=lifeVelocity*age;\r\n\t#endif\r\n\t#ifdef VELOCITYOVERLIFETIMECURVE\r\n\t\t  startPosition=startVelocity*age;\r\n\t\t  lifePosition=vec3(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\r\n\t#endif\r\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\r\n\t\t  startPosition=startVelocity*age;\r\n\t\t  lifePosition=lifeVelocity*age;\r\n\t#endif\r\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCURVE\r\n\t\t  startPosition=startVelocity*age;\r\n\t\t  lifePosition=vec3(mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y)\r\n\t      ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z)\r\n\t      ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\r\n\t#endif\r\n\t\r\n\tvec3 finalPosition;\r\n\tif(u_VOLSpaceType==0){\r\n\t  if(u_ScalingMode!=2)\r\n\t   finalPosition =rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition),worldRotation);\r\n\t  else\r\n\t   finalPosition =rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);\r\n\t}\r\n\telse{\r\n\t  if(u_ScalingMode!=2)\r\n\t    finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation)+lifePosition;\r\n\t  else\r\n\t    finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;\r\n\t}\r\n  #else\r\n\t startPosition=startVelocity*age;\r\n\t vec3 finalPosition;\r\n\t if(u_ScalingMode!=2)\r\n\t\t\tfinalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation);\r\n\t else\r\n\t   \tfinalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\r\n  #endif\r\n  \r\n  if(u_SimulationSpace==0)\r\n    finalPosition=finalPosition+a_SimulationWorldPostion;\r\n  else if(u_SimulationSpace==1) \r\n    finalPosition=finalPosition+u_WorldPosition;\r\n  \r\n  finalPosition+=0.5*gravityVelocity*age;\r\n \r\n  return  finalPosition;\r\n}\r\n\r\n\r\nvec4 computeParticleColor(in vec4 color,in float normalizedAge)\r\n{\r\n\t#ifdef COLOROVERLIFETIME\r\n\t  color*=getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge);\r\n\t#endif\r\n\t\r\n\t#ifdef RANDOMCOLOROVERLIFETIME\r\n\t  color*=mix(getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge),getColorFromGradient(u_MaxColorOverLifeGradientAlphas,u_MaxColorOverLifeGradientColors,normalizedAge),a_Random0.y);\r\n\t#endif\r\n\r\n    return color;\r\n}\r\n\r\nvec2 computeParticleSizeBillbard(in vec2 size,in float normalizedAge)\r\n{\r\n\t#ifdef SIZEOVERLIFETIMECURVE\r\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\r\n\t    size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\r\n\t\tsize*=vec2(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge));\r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\r\n\t    size*=vec2(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\r\n\t    ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z));\r\n\t#endif\r\n\treturn size;\r\n}\r\n\r\n#ifdef RENDERMODE_MESH\r\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge)\r\n{\r\n\t#ifdef SIZEOVERLIFETIMECURVE\r\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\r\n\t    size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\r\n\t\tsize*=vec3(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge));\r\n\t#endif\r\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\r\n\t    size*=vec3(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\r\n\t    ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z)\r\n\t\t,mix(getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxZ,normalizedAge),a_Random0.z));\r\n\t#endif\r\n\treturn size;\r\n}\r\n#endif\r\n\r\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge)\r\n{ \r\n\t#ifdef ROTATIONOVERLIFETIME\r\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\r\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\r\n\t        rotation+=ageRot;\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\r\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\r\n\t        rotation+=ageRot;\r\n\t    #endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\r\n\t\t#endif\r\n\t#endif\r\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\r\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\r\n\t\t\tfloat ageRot=u_ROLAngularVelocityConstSeprarate.z*age;\r\n\t        rotation+=ageRot;\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\r\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge);\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConstSeprarate.z,u_ROLAngularVelocityConstMaxSeprarate.z,a_Random0.w)*age;\r\n\t        rotation+=ageRot;\r\n\t    #endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\r\n\t\t#endif\r\n\t#endif\r\n\treturn rotation;\r\n}\r\n\r\n#if defined(RENDERMODE_MESH)&amp;&amp;(defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE))\r\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge)\r\n{ \r\n\t#ifdef ROTATIONOVERLIFETIME\r\n\t#ifdef ROTATIONOVERLIFETIMECONSTANT\r\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\r\n\t        rotation+=ageRot;\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\r\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\r\n\t        rotation+=ageRot;\r\n\t    #endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\r\n\t\t#endif\r\n\t#endif\r\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\r\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\r\n\t\t\tvec3 ageRot=u_ROLAngularVelocityConstSeprarate*age;\r\n\t        rotation+=ageRot;\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\r\n\t\t\trotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\r\n\t\t#endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\r\n\t\t\tvec3 ageRot=mix(u_ROLAngularVelocityConstSeprarate,u_ROLAngularVelocityConstMaxSeprarate,a_Random0.w)*age;\r\n\t        rotation+=ageRot;\r\n\t    #endif\r\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\r\n\t\t\trotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxX,normalizedAge),a_Random0.w)\r\n\t        ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxY,normalizedAge),a_Random0.w)\r\n\t        ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\r\n\t\t#endif\r\n\t#endif\r\n\treturn rotation;\r\n}\r\n#endif\r\n\r\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge)\r\n{ \r\n\t#ifdef TEXTURESHEETANIMATIONCURVE\r\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\r\n\t\tfloat frame=getFrameFromGradient(u_TSAGradientUVs,cycleNormalizedAge-floor(cycleNormalizedAge));\r\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\r\n\t\tfloat floorTotalULength=floor(totalULength);\r\n\t    uv.x+=totalULength-floorTotalULength;\r\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\r\n    #endif\r\n\t#ifdef TEXTURESHEETANIMATIONRANDOMCURVE\r\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\r\n\t\tfloat uvNormalizedAge=cycleNormalizedAge-floor(cycleNormalizedAge);\r\n\t    float frame=floor(mix(getFrameFromGradient(u_TSAGradientUVs,uvNormalizedAge),getFrameFromGradient(u_TSAMaxGradientUVs,uvNormalizedAge),a_Random1.x));\r\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\r\n\t\tfloat floorTotalULength=floor(totalULength);\r\n\t    uv.x+=totalULength-floorTotalULength;\r\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\r\n    #endif\r\n\treturn uv;\r\n}\r\n\r\nvoid main()\r\n{\r\n\tfloat age = u_CurrentTime - a_DirectionTime.w;\r\n\tfloat normalizedAge = age/a_ShapePositionStartLifeTime.w;\r\n\tvec3 lifeVelocity;\r\n\tif(normalizedAge&lt;1.0)\r\n\t{ \r\n\t\tvec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\r\n\t\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n\t\t\tlifeVelocity= computeParticleLifeVelocity(normalizedAge);//è®¡ç®—ç²’å­ç”Ÿå‘½å‘¨æœŸé€Ÿåº¦\r\n\t\t#endif \r\n\t\tvec3 gravityVelocity=u_Gravity*age;\r\n\t\t\r\n\t\tvec4 worldRotation;\r\n\t\tif(u_SimulationSpace==0)\r\n\t\t\tworldRotation=a_SimulationWorldRotation;\r\n\t\telse\r\n\t\t\tworldRotation=u_WorldRotation;\r\n\t\t\r\n\t\tvec3 center=computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge,gravityVelocity,worldRotation);//è®¡ç®—ç²’å­ä½ç½®\r\n\t\r\n\t\r\n\t\t#ifdef SPHERHBILLBOARD\r\n\t\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboardæ¨¡å¼zè½´æ—&nbsp;æ•ˆ\r\n\t\t\tvec3 cameraUpVector =normalize(u_CameraUp);//TODO:æ˜¯å¦å¤–é¢å½’ä¸€åŒ–\r\n\t\t\tvec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\r\n\t\t\tvec3 upVector = normalize(cross(sideVector,u_CameraDirection));\r\n\t\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\r\n\t\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\r\n\t\t\t\tif(u_ThreeDStartRotation){\r\n\t\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));\r\n\t\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\r\n\t\t\t\t\tfloat c = cos(rot);\r\n\t\t\t\t\tfloat s = sin(rot);\r\n\t\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\r\n\t\t\t\t\tcorner=rotation*corner;\r\n\t\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\r\n\t\t\t\t}\r\n\t\t\t#else\r\n\t\t\t\tif(u_ThreeDStartRotation){\r\n\t\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\tfloat c = cos(a_StartRotation0.x);\r\n\t\t\t\t\tfloat s = sin(a_StartRotation0.x);\r\n\t\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\r\n\t\t\t\t\tcorner=rotation*corner;\r\n\t\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef STRETCHEDBILLBOARD\r\n\t\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboardæ¨¡å¼zè½´æ—&nbsp;æ•ˆ\r\n\t\t\tvec3 velocity;\r\n\t\t\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\r\n\t\t\t\tif(u_VOLSpaceType==0)\r\n\t\t\t\tvelocity=rotationByQuaternions(u_SizeScale*(startVelocity+lifeVelocity),worldRotation)+gravityVelocity;\r\n\t\t\t\telse\r\n\t\t\t\tvelocity=rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+lifeVelocity+gravityVelocity;\r\n\t\t\t#else\r\n\t\t\t\tvelocity= rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+gravityVelocity;\r\n\t\t\t#endif\t\r\n\t\t\tvec3 cameraUpVector = normalize(velocity);\r\n\t\t\tvec3 direction = normalize(center-u_CameraPos);\r\n\t\t\tvec3 sideVector = normalize(cross(direction,normalize(velocity)));\r\n\t\t\t\r\n\t\t\tsideVector=u_SizeScale.xzy*sideVector;\r\n\t\t\tcameraUpVector=length(vec3(u_SizeScale.x,0.0,0.0))*cameraUpVector;\r\n\t\t\t\r\n\t\t\tvec2 size=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\r\n\t\t\t\r\n\t\t\tconst mat2 rotaionZHalfPI=mat2(0.0, -1.0, 1.0, 0.0);\r\n\t\t\tcorner=rotaionZHalfPI*corner;\r\n\t\t\tcorner.y=corner.y-abs(corner.y);\r\n\t\t\t\r\n\t\t\tfloat speed=length(velocity);//TODO:\r\n\t\t\tcenter +=sign(u_SizeScale.x)*(sign(u_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*u_StretchedBillboardSpeedScale+size.y*u_StretchedBillboardLengthScale)*corner.y*cameraUpVector);\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef HORIZONTALBILLBOARD\r\n\t\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboardæ¨¡å¼zè½´æ—&nbsp;æ•ˆ\r\n\t\t\tconst vec3 cameraUpVector=vec3(0.0,0.0,1.0);\r\n\t\t\tconst vec3 sideVector = vec3(-1.0,0.0,0.0);\r\n\t\t\t\r\n\t\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\r\n\t\t\tfloat c = cos(rot);\r\n\t\t\tfloat s = sin(rot);\r\n\t\t\tmat2 rotation= mat2(c, -s, s, c);\r\n\t\t\tcorner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:ä¸´æ—¶ç¼©å°cos45,ä¸ç¡®å®šU3DåŽŸå›&nbsp;\r\n\t\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\r\n\t\t\tcenter +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef VERTICALBILLBOARD\r\n\t\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboardæ¨¡å¼zè½´æ—&nbsp;æ•ˆ\r\n\t\t\tconst vec3 cameraUpVector =vec3(0.0,1.0,0.0);\r\n\t\t\tvec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\r\n\t\t\t\r\n\t\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\r\n\t\t\tfloat c = cos(rot);\r\n\t\t\tfloat s = sin(rot);\r\n\t\t\tmat2 rotation= mat2(c, -s, s, c);\r\n\t\t\tcorner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:ä¸´æ—¶ç¼©å°cos45,ä¸ç¡®å®šU3DåŽŸå›&nbsp;\r\n\t\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\r\n\t\t\tcenter +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef RENDERMODE_MESH\r\n\t\t\tvec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge);\r\n\t\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\r\n\t\t\t\tif(u_ThreeDStartRotation){\r\n\t\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z, age,normalizedAge));\r\n\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,rotation),worldRotation);\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\t#ifdef ROTATIONOVERLIFETIME\r\n\t\t\t\t\t\tfloat angle=computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\r\n\t\t\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\r\n\t\t\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),angle),worldRotation));//å·²éªŒè¯\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse{\r\n\t\t\t\t\t\t\t#ifdef SHAPE\r\n\t\t\t\t\t\t\t\tcenter+= u_SizeScale.xzy*(rotationByQuaternions(rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),angle),worldRotation));\r\n\t\t\t\t\t\t\t#else\r\n\t\t\t\t\t\t\t\tif(u_SimulationSpace==0)\r\n\t\t\t\t\t\t\t\t\tcenter+=rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle);//å·²éªŒè¯\r\n\t\t\t\t\t\t\t\telse if(u_SimulationSpace==1)\r\n\t\t\t\t\t\t\t\t\tcenter+=rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle),worldRotation);//å·²éªŒè¯\r\n\t\t\t\t\t\t\t#endif\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t#endif\r\n\t\t\t\t\t#ifdef ROTATIONOVERLIFETIMESEPERATE\r\n\t\t\t\t\t\t//TODO:æ˜¯å¦åº”åˆå¹¶if(u_ThreeDStartRotation)åˆ†æ”¯ä»£ç&nbsp;,å¾…æµ‹è¯•\r\n\t\t\t\t\t\tvec3 angle=computeParticleRotationVec3(vec3(0.0,0.0,-a_StartRotation0.x), age,normalizedAge);\r\n\t\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByEuler(u_SizeScale*a_MeshPosition*size,vec3(angle.x,angle.y,angle.z)),worldRotation));//å·²éªŒè¯\r\n\t\t\t\t\t#endif\t\t\r\n\t\t\t\t}\r\n\t\t\t#else\r\n\t\t\t\tif(u_ThreeDStartRotation){\r\n\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,a_StartRotation0),worldRotation);//å·²éªŒè¯\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\r\n\t\t\t\t\t\tif(u_SimulationSpace==0)\r\n\t\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x);\r\n\t\t\t\t\t\telse if(u_SimulationSpace==1)\r\n\t\t\t\t\t\t\tcenter+= (rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x),worldRotation));//å·²éªŒè¯\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse{\r\n\t\t\t\t\t\t#ifdef SHAPE\r\n\t\t\t\t\t\t\tif(u_SimulationSpace==0)\r\n\t\t\t\t\t\t\t\tcenter+= u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x);\r\n\t\t\t\t\t\t\telse if(u_SimulationSpace==1)\r\n\t\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x),worldRotation);\t\r\n\t\t\t\t\t\t#else\r\n\t\t\t\t\t\t\tif(u_SimulationSpace==0)\r\n\t\t\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x);\r\n\t\t\t\t\t\t\telse if(u_SimulationSpace==1)\r\n\t\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x),worldRotation);//å·²éªŒè¯\r\n\t\t\t\t\t\t#endif\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t\tv_MeshColor=a_MeshColor;\r\n\t\t#endif\r\n\t\r\n\t\tgl_Position=u_Projection*u_View*vec4(center,1.0);\r\n\t\tv_Color = computeParticleColor(a_StartColor, normalizedAge);\r\n\t\t#ifdef DIFFUSEMAP\r\n\t\t\t#if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\r\n\t\t\t\tv_TextureCoordinate =computeParticleUV(a_CornerTextureCoordinate.zw, normalizedAge);\r\n\t\t\t#endif\r\n\t\t\t#ifdef RENDERMODE_MESH\r\n\t\t\t\tv_TextureCoordinate =computeParticleUV(a_MeshTextureCoordinate, normalizedAge);\r\n\t\t\t#endif\r\n\t\t\t\r\n\t\t\t#ifdef TILINGOFFSET\r\n\t\t\t\tv_TextureCoordinate=TransformUV(v_TextureCoordinate,u_TilingOffset);\r\n\t\t\t#endif\r\n\t\t#endif\r\n   \t}\r\n   \telse\r\n\t{\r\n\t\tgl_Position=vec4(2.0,2.0,2.0,1.0);//Discard use out of X(-1,1),Y(-1,1),Z(0,1)\r\n\t}\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}\r\n\r\n',
        zi = '// allow to explicitly override LAYA_BRDF_GI and LAYA_BRDF_LIGHT in custom shader,default is layaBRDFHighGI and layaBRDFHighLight\r\n#if !defined (LAYA_BRDF_GI) \r\n\t#if defined(LAYA_PBR_BRDF_LOW)\r\n\t\t#define LAYA_BRDF_GI layaBRDFLowGI\r\n\t#elif defined(LAYA_PBR_BRDF_HIGH)\r\n\t\t#define LAYA_BRDF_GI layaBRDFHighGI\r\n\t#endif\r\n#endif\r\n#if !defined (LAYA_BRDF_LIGHT)\r\n\t#if defined(LAYA_PBR_BRDF_LOW)\r\n\t\t#define LAYA_BRDF_LIGHT layaBRDFLowLight\r\n\t#elif defined(LAYA_PBR_BRDF_HIGH)\r\n\t\t#define LAYA_BRDF_LIGHT layaBRDFHighLight\r\n\t#endif\r\n#endif\r\n\r\n#define PI 3.14159265359\r\n#define INV_PI 0.31830988618\r\n\r\nmediump float pow4(mediump float x)\r\n{\r\n\treturn x * x * x * x;\r\n}\r\n\r\nmediump float pow5(mediump float x)\r\n{\r\n\treturn x * x * x * x * x;\r\n}\r\n\r\nmediump vec3 fresnelLerp(mediump vec3 F0,mediump vec3 F90,mediump float cosA)\r\n{\r\n\tfloat t = pow5(1.0 - cosA);   // ala Schlick interpoliation\r\n\treturn mix(F0, F90, t);\r\n}\r\n\r\nmediump vec3 fresnelTerm(mediump vec3 F0,mediump float cosA)\r\n{\r\n\tfloat t = pow5(1.0 - cosA);   // ala Schlick interpoliation\r\n\treturn F0 + (vec3(1.0) - F0) * t;\r\n}\r\n\r\n// approximage Schlick with ^4 instead of ^5\r\nmediump vec3 fresnelLerpFast (mediump vec3 F0, mediump vec3 F90,mediump float cosA)\r\n{\r\n    mediump float t = pow4 (1.0 - cosA);\r\n    return mix (F0, F90, t);\r\n}\r\n\r\nfloat smoothnessToPerceptualRoughness(float smoothness)\r\n{\r\n    return 1.0 - smoothness;\r\n}\r\n\r\nfloat perceptualRoughnessToRoughness(float perceptualRoughness)\r\n{\r\n    return perceptualRoughness * perceptualRoughness;\r\n}\r\n\r\nvec3 safeNormalize(vec3 inVec)\r\n{\r\n\tfloat dp3 = max(0.001,dot(inVec,inVec));\r\n\treturn inVec * inversesqrt(dp3);\r\n}\r\n\r\n// Note: Disney diffuse must be multiply by diffuseAlbedo / PI. This is done outside of this function.\r\nmediump float disneyDiffuse(mediump float NdotV,mediump float NdotL,mediump float LdotH,mediump float perceptualRoughness)\r\n{\r\n\t//https://www.cnblogs.com/herenzhiming/articles/5790389.html\r\n\tmediump float fd90 = 0.5 + 2.0 * LdotH * LdotH * perceptualRoughness;\r\n\t// Two schlick fresnel term\r\n\tmediump float lightScatter = (1.0 + (fd90 - 1.0) * pow5(1.0 - NdotL));\r\n\tmediump float viewScatter = (1.0 + (fd90 - 1.0) * pow5(1.0 - NdotV));\r\n\r\n\treturn lightScatter * viewScatter;\r\n}\r\n\r\n// Ref: http://jcgt.org/published/0003/02/03/paper.pdf\r\nfloat smithJointGGXVisibilityTerm(float NdotL, float NdotV, float roughness)\r\n{\r\n\t// Original formulation:\r\n    // lambda_v    = (-1 + sqrt(a2 * (1 - NdotL2) / NdotL2 + 1)) * 0.5f;\r\n    // lambda_l    = (-1 + sqrt(a2 * (1 - NdotV2) / NdotV2 + 1)) * 0.5f;\r\n    // G           = 1 / (1 + lambda_v + lambda_l);\r\n\r\n\t// scientific code implement:\r\n\t// Reorder code to be more optimal\r\n    // half a          = roughness;\r\n    // half a2         = a * a;\r\n\r\n    // half lambdaV    = NdotL * sqrt((-NdotV * a2 + NdotV) * NdotV + a2);\r\n    // half lambdaL    = NdotV * sqrt((-NdotL * a2 + NdotL) * NdotL + a2);\r\n\r\n    // Simplify visibility term: (2.0f * NdotL * NdotV) /  ((4.0f * NdotL * NdotV) * (lambda_v + lambda_l + 1e-5f));\r\n    // return 0.5f / (lambdaV + lambdaL + 1e-5f);  \r\n\t// This function is not intended to be running on Mobile,therefore epsilon is smaller than can be represented by half\r\n\r\n\t// Approximation of the above formulation (simplify the sqrt, not mathematically correct but close enough)\r\n\tfloat a = roughness;\r\n\tfloat lambdaV = NdotL * (NdotV * (1.0 - a) + a);\r\n\tfloat lambdaL = NdotV * (NdotL * (1.0 - a) + a);\r\n\treturn 0.5 / (lambdaV + lambdaL + 1e-5);\r\n}\r\n\r\nfloat ggxTerm(float NdotH, float roughness)\r\n{\r\n\tfloat a2 = roughness * roughness;\r\n\tfloat d = (NdotH * a2 - NdotH) * NdotH + 1.0; // 2 mad\r\n\treturn INV_PI * a2 / (d * d + 1e-7); // This function is not intended to be running on Mobile,therefore epsilon is smaller than what can be represented by half//è¿”å›žå€¼å°ç”¨halfæ¥è¿”å›ž\r\n}\r\n\r\n// BRDF1-------------------------------------------------------------------------------------\r\n\r\n// Note: BRDF entry points use smoothness and oneMinusReflectivity for optimization purposes,\r\n// mostly for DX9 SM2.0 level. Most of the math is being done on these (1-x) values, and that saves a few precious ALU slots.\r\n\r\n// Main Physically Based BRDF\r\n// Derived from Disney work and based on Torrance-Sparrow micro-facet model\r\n//\r\n// BRDF = kD / pi + kS * (D * V * F) / 4\r\n// I = BRDF * NdotL\r\n//\r\n// *NDF GGX:\r\n// *Smith for Visiblity term\r\n// *Schlick approximation for Fresnel\r\nmediump vec4 layaBRDFHighLight(mediump vec3 diffColor, mediump vec3 specColor, mediump float oneMinusReflectivity, float perceptualRoughness,float roughness,mediump float nv,vec3 normal, vec3 viewDir,LayaLight light)\r\n{\r\n\tvec3 halfDir = safeNormalize(viewDir-light.dir);\r\n\r\n\tfloat nl = clamp(dot(normal, -light.dir),0.0,1.0);\r\n\tfloat nh = clamp(dot(normal, halfDir),0.0,1.0);\r\n\tmediump float lv = clamp(dot(light.dir, viewDir),0.0,1.0);\r\n\tmediump float lh = clamp(dot(light.dir, -halfDir),0.0,1.0);\r\n\r\n\t// Diffuse term\r\n\tmediump float diffuseTerm = disneyDiffuse(nv, nl, lh, perceptualRoughness) * nl;\r\n\r\n\t// Specular term\r\n    // HACK: theoretically we should divide diffuseTerm by Pi and not multiply specularTerm!\r\n    // BUT that will make shader look significantly darker than Legacy ones\r\n\r\n\t// GGX with roughtness to 0 would mean no specular at all, using max(roughness, 0.002) here to match HDrenderloop roughtness remapping.\r\n\troughness = max(roughness, 0.002);\r\n\tfloat V = smithJointGGXVisibilityTerm(nl, nv, roughness);\r\n\tfloat D = ggxTerm(nh, roughness);\r\n\r\n\tfloat specularTerm = V * D * PI; // Torrance-Sparrow model, Fresnel is applied later\r\n\r\n\t//#ifdef LAYA_COLORSPACE_GAMMA\r\n\tspecularTerm = sqrt(max(1e-4, specularTerm));\r\n\t//#endif\r\n\tspecularTerm = max(0.0, specularTerm * nl);\r\n\t\t\r\n\tmediump vec3 color = diffColor * light.color * diffuseTerm + specularTerm * light.color * fresnelTerm(specColor, lh);\r\n\treturn vec4(color, 1.0);\r\n}\r\n\r\nvec4 layaBRDFHighGI(mediump vec3 diffColor,mediump vec3 specColor,mediump float oneMinusReflectivity,float smoothness ,float perceptualRoughness,float roughness,mediump float nv,vec3 normal, vec3 viewDir,LayaGI gi)\r\n{\r\n\t// surfaceReduction = Int D(NdotH) * NdotH * Id(NdotL&gt;0) dH = 1/(roughness^2+1)\r\n\tfloat surfaceReduction;\r\n\tsurfaceReduction = 1.0 - 0.28*roughness*perceptualRoughness;// 1-0.28*x^3 as approximation for (1/(x^4+1))^(1/2.2) on the domain [0;1]\r\n\tfloat grazingTerm = clamp(smoothness + (1.0 - oneMinusReflectivity),0.0,1.0);\r\n\tmediump vec3 color =diffColor * gi.diffuse + surfaceReduction * gi.specular * fresnelLerp(specColor,vec3(grazingTerm), nv);\r\n\treturn vec4(color,1.0);\r\n}\r\n// BRDF1-------------------------------------------------------------------------------------\r\n\r\n\r\n// BRDF2-------------------------------------------------------------------------------------\r\n// Based on Minimalist CookTorrance BRDF\r\n// Implementation is slightly different from original derivation: http://www.thetenthplanet.de/archives/255\r\n//\r\n// *NDF [Modified] GGX:\r\n// *Modified Kelemen and Szirmay-â€‹Kalos for Visibility term\r\n// *Fresnel approximated with 1/LdotH\r\nmediump vec4 layaBRDFLowLight (mediump vec3 diffColor, mediump vec3 specColor,mediump float oneMinusReflectivity,float perceptualRoughness,float roughness,mediump float nv,vec3 normal,vec3 viewDir,LayaLight light)\r\n{\r\n    vec3 halfDir = safeNormalize (viewDir-light.dir);\r\n    mediump float nl = clamp(dot(normal, -light.dir),0.0,1.0);\r\n    float nh = clamp(dot(normal, halfDir),0.0,1.0);\r\n    float lh = clamp(dot(-light.dir, halfDir),0.0,1.0);\r\n\r\n    // GGX Distribution multiplied by combined approximation of Visibility and Fresnel\r\n    // See "Optimizing PBR for Mobile" from Siggraph 2015 moving mobile graphics course\r\n    // https://community.arm.com/events/1155\r\n    mediump float a = roughness;\r\n    float a2 = a*a;\r\n\r\n    float d = nh * nh * (a2 - 1.0) + 1.00001;\r\n\t// #ifdef LAYA_COLORSPACE_GAMMA\r\n\t\t// Tighter approximation for Gamma only rendering mode!\r\n\t\t// DVF = sqrt(DVF);\r\n\t\t// DVF = (a * sqrt(.25)) / (max(sqrt(0.1), lh)*sqrt(roughness + .5) * d);\r\n\t\tfloat specularTerm = a / (max(0.32, lh) * (1.5 + roughness) * d);\r\n\t// #else\r\n\t// \tfloat specularTerm = a2 / (max(0.1f, lh*lh) * (roughness + 0.5f) * (d * d) * 4);\r\n\t// #endif\r\n\r\n    // on mobiles (where half actually means something) denominator have risk of overflow\r\n    // clamp below was added specifically to "fix" that, but dx compiler (we convert bytecode to metal/gles)\r\n    // sees that specularTerm have only non-negative terms, so it skips max(0,..) in clamp (leaving only min(100,...))\r\n\r\n\t//#if defined (SHADER_API_MOBILE)\r\n    specularTerm = specularTerm - 1e-4;\r\n\t//#endif\r\n\r\n\t// #else\r\n\t\t// // Legacy\r\n\t\t// half specularPower = PerceptualRoughnessToSpecPower(perceptualRoughness);\r\n\t\t// // Modified with approximate Visibility function that takes roughness into account\r\n\t\t// // Original ((n+1)*N.H^n) / (8*Pi * L.H^3) didn\'t take into account roughness\r\n\t\t// // and produced extremely bright specular at grazing angles\r\n\r\n\t\t// half invV = lh * lh * smoothness + perceptualRoughness * perceptualRoughness; // approx ModifiedKelemenVisibilityTerm(lh, perceptualRoughness);\r\n\t\t// half invF = lh;\r\n\r\n\t\t// half specularTerm = ((specularPower + 1) * pow (nh, specularPower)) / (8 * invV * invF + 1e-4h);\r\n\r\n\t\t// #ifdef LAYA_COLORSPACE_GAMMA\r\n\t\t// \tspecularTerm = sqrt(max(1e-4f, specularTerm));\r\n\t\t// #endif\r\n\t// #endif\r\n\r\n\t// #if defined (SHADER_API_MOBILE)\r\n\t\tspecularTerm = clamp(specularTerm, 0.0, 100.0); // Prevent FP16 overflow on mobiles\r\n\t// #endif\r\n    \r\n    mediump vec3 color = (diffColor + specularTerm * specColor) * light.color * nl;\r\n\r\n    return vec4(color, 1.0);\r\n}\r\n\r\nmediump vec4 layaBRDFLowGI (mediump vec3 diffColor, mediump vec3 specColor,mediump float oneMinusReflectivity,mediump float smoothness,float perceptualRoughness,float roughness,mediump float nv,vec3 normal,vec3 viewDir,LayaGI gi)\r\n{\r\n\t// surfaceReduction = Int D(NdotH) * NdotH * Id(NdotL&gt;0) dH = 1/(realRoughness^2+1)\r\n\r\n    // 1-0.28*x^3 as approximation for (1/(x^4+1))^(1/2.2) on the domain [0;1]\r\n    // 1-x^3*(0.6-0.08*x)   approximation for 1/(x^4+1)\r\n\t// #ifdef LAYA_COLORSPACE_GAMMA\r\n\t\tmediump float surfaceReduction = 0.28;\r\n\t// #else\r\n\t\t// mediump float surfaceReduction = (0.6-0.08*perceptualRoughness);\r\n\t// #endif\r\n\r\n    surfaceReduction = 1.0 - roughness*perceptualRoughness*surfaceReduction;\r\n\r\n\tmediump float grazingTerm = clamp(smoothness + (1.0-oneMinusReflectivity),0.0,1.0);\r\n\tmediump vec3 color =gi.diffuse * diffColor+ surfaceReduction * gi.specular * fresnelLerpFast (specColor, vec3(grazingTerm), nv);\r\n\r\n    return vec4(color, 1.0);\r\n}\r\n// BRDF2-------------------------------------------------------------------------------------',
        Hi = "struct FragmentCommonData{\r\n\tvec3 diffColor;\r\n\tvec3 specColor;\r\n\tfloat oneMinusReflectivity;\r\n\tfloat smoothness;\r\n\t//vec3 eyeVec;TODO:maybe can remove\r\n\t//float alpha;\r\n\t//vec3 reflUVW;\r\n};\r\n\r\n#ifndef SETUP_BRDF_INPUT\r\n    #define SETUP_BRDF_INPUT metallicSetup//default is metallicSetup,also can be other. \r\n#endif\r\n\r\nconst mediump vec4 dielectricSpecularColor = vec4(0.220916301, 0.220916301, 0.220916301, 1.0 - 0.220916301);\r\n\r\nmediump vec3 diffuseAndSpecularFromMetallic(mediump vec3 albedo,mediump float metallic, out mediump vec3 specColor, out mediump float oneMinusReflectivity)\r\n{\r\n\tspecColor = mix(dielectricSpecularColor.rgb, albedo, metallic);\r\n\toneMinusReflectivity= dielectricSpecularColor.a*(1.0-metallic);//diffuse proportion\r\n\treturn albedo * oneMinusReflectivity;\r\n}\r\n\r\nmediump float specularStrength(mediump vec3 specular)\r\n{\r\n    return max (max (specular.r, specular.g), specular.b);\r\n}\r\n\r\n// Diffuse/Spec Energy conservation\r\nmediump vec3 energyConservationBetweenDiffuseAndSpecular (mediump vec3 albedo, mediump vec3 specColor, out mediump float oneMinusReflectivity)\r\n{\r\n\toneMinusReflectivity = 1.0 - specularStrength(specColor);\r\n    return albedo * (vec3(1.0) - specColor);\r\n}\r\n\r\n#ifdef TRANSPARENTBLEND\r\n\tmediump vec3 preMultiplyAlpha (mediump vec3 diffColor, mediump float alpha, mediump float oneMinusReflectivity,out mediump float modifiedAlpha)\r\n\t{\r\n\t\t// Transparency 'removes' from Diffuse component\r\n\t\tdiffColor *= alpha;\r\n\t\t// Reflectivity 'removes' from the rest of components, including Transparency\r\n\t\t// modifiedAlpha = 1.0-(1.0-alpha)*(1.0-reflectivity) = 1.0-(oneMinusReflectivity - alpha*oneMinusReflectivity) = 1.0-oneMinusReflectivity + alpha*oneMinusReflectivity\r\n\t\tmodifiedAlpha = 1.0 - oneMinusReflectivity + alpha*oneMinusReflectivity;\r\n\t\treturn diffColor;\r\n\t}\r\n#endif\r\n\r\nFragmentCommonData metallicSetup(vec2 uv)\r\n{\r\n\tmediump vec2 metallicGloss = getMetallicGloss(uv);\r\n\tmediump float metallic = metallicGloss.x;\r\n\tmediump float smoothness = metallicGloss.y; // this is 1 minus the square root of real roughness m.\r\n\tmediump float oneMinusReflectivity;\r\n\tmediump vec3 specColor;\r\n\tmediump vec3 diffColor = diffuseAndSpecularFromMetallic(albedo(uv), metallic,/*out*/specColor,/*out*/oneMinusReflectivity);\r\n\r\n\tFragmentCommonData o;\r\n\to.diffColor = diffColor;\r\n\to.specColor = specColor;\r\n\to.oneMinusReflectivity = oneMinusReflectivity;\r\n\to.smoothness = smoothness;\r\n\treturn o;\r\n}\r\n\r\nFragmentCommonData specularSetup(vec2 uv)\r\n{\r\n    mediump vec4 specGloss = specularGloss(uv);\r\n    mediump vec3 specColor = specGloss.rgb;\r\n    mediump float smoothness = specGloss.a;\r\n\r\n    mediump float oneMinusReflectivity;\r\n    mediump vec3 diffColor = energyConservationBetweenDiffuseAndSpecular (albedo(uv), specColor, /*out*/ oneMinusReflectivity);\r\n\r\n    FragmentCommonData o;\r\n    o.diffColor = diffColor;\r\n    o.specColor = specColor;\r\n    o.oneMinusReflectivity = oneMinusReflectivity;\r\n    o.smoothness = smoothness;\r\n    return o;\r\n}\r\n\r\nLayaGI fragmentGI(float smoothness,vec3 eyeVec,mediump float occlusion,mediump vec2 lightmapUV,vec3 worldnormal)\r\n{\r\n\tLayaGIInput giInput;\r\n\t#ifdef LIGHTMAP\r\n\t\tgiInput.lightmapUV=lightmapUV;\r\n\t#endif\r\n\r\n\tvec3 worldViewDir = -eyeVec;\r\n\tmediump vec4 uvwRoughness;\r\n\tuvwRoughness.rgb = reflect(worldViewDir, worldnormal);//reflectUVW\r\n\tuvwRoughness.a= smoothnessToPerceptualRoughness(smoothness);//perceptualRoughness\r\n\r\n\treturn layaGlobalIllumination(giInput,occlusion, worldnormal, uvwRoughness);\r\n}\r\n\r\n\r\nvec3 perPixelWorldNormal(vec2 uv,vec3 normal,vec3 binormal,vec3 tangent)\r\n{\r\n\t#ifdef NORMALTEXTURE\r\n\t\tmediump vec3 normalTangent=normalInTangentSpace(uv);\r\n\t\tvec3 normalWorld = normalize(tangent * normalTangent.x + binormal * normalTangent.y + normal * normalTangent.z);\r\n\t#else\r\n\t\tvec3 normalWorld = normalize(normal);\r\n\t#endif\r\n\t\treturn normalWorld;\r\n}\r\n\r\nvoid fragmentForward()\r\n{\r\n\tvec2 uv;\r\n\t#if defined(ALBEDOTEXTURE)||defined(METALLICGLOSSTEXTURE)||defined(NORMALTEXTURE)||defined(EMISSIONTEXTURE)||defined(OCCLUSIONTEXTURE)||defined(PARALLAXTEXTURE)\r\n\t\t#ifdef PARALLAXTEXTURE\r\n\t\t\tuv = parallax(v_Texcoord0,normalize(v_ViewDirForParallax));\r\n\t\t#else\r\n\t\t\tuv = v_Texcoord0;\r\n\t\t#endif\r\n\t#endif\r\n\r\n\tmediump float alpha = getAlpha(uv);\r\n\t#ifdef ALPHATEST\r\n\t\tif(alpha&lt;u_AlphaTestValue)\r\n\t\t\tdiscard;\r\n\t#endif\r\n\r\n\tFragmentCommonData o = SETUP_BRDF_INPUT(uv);\r\n\t\r\n\tvec3 binormal;\r\n\tvec3 tangent;\r\n\t#ifdef NORMALTEXTURE\r\n\t\ttangent = v_Tangent;\r\n\t\tbinormal = v_Binormal;\r\n\t#endif\r\n\r\n\tvec3 normal = v_Normal;\r\n\tvec3 normalWorld = perPixelWorldNormal(uv,normal,binormal,tangent);//In FS if the normal use mediump before normalize will cause precision prolem in mobile device.\r\n\tvec3 eyeVec = normalize(v_EyeVec);\r\n\tvec3 posworld = v_PositionWorld;\r\n\r\n\t#ifdef TRANSPARENTBLEND\r\n\t\to.diffColor=preMultiplyAlpha(o.diffColor,alpha,o.oneMinusReflectivity,/*out*/alpha);// shader relies on pre-multiply alpha-blend (srcBlend = One, dstBlend = OneMinusSrcAlpha)\r\n\t#endif\r\n\r\n\tmediump float occlusion = getOcclusion(uv);\r\n\tmediump vec2 lightMapUV;\r\n\t#ifdef LIGHTMAP\r\n\t\tlightMapUV=v_LightMapUV;\r\n\t#endif\r\n\tfloat perceptualRoughness = smoothnessToPerceptualRoughness(o.smoothness);\r\n\tfloat roughness = perceptualRoughnessToRoughness(perceptualRoughness);\r\n\tfloat nv = abs(dot(normalWorld, eyeVec));\r\n\tLayaGI gi =fragmentGI(o.smoothness,eyeVec,occlusion,lightMapUV,normalWorld);\r\n\tvec4 color = LAYA_BRDF_GI(o.diffColor,o.specColor,o.oneMinusReflectivity,o.smoothness,perceptualRoughness,roughness,nv,normalWorld,eyeVec,gi);\r\n\t\r\n\tfloat shadowAttenuation = 1.0;\r\n\t#ifdef LEGACYSINGLELIGHTING\r\n\t\t#ifdef DIRECTIONLIGHT\r\n\t\t\t#ifdef CALCULATE_SHADOWS\r\n\t\t\t\t#ifdef SHADOW_CASCADE\r\n\t\t\t\t\tvec4 shadowCoord = getShadowCoord(vec4(v_PositionWorld,1.0));\r\n\t\t\t\t#else\r\n\t\t\t\t\tvec4 shadowCoord = v_ShadowCoord;\r\n\t\t\t\t#endif\r\n\t\t\t\tshadowAttenuation=sampleShadowmap(shadowCoord);\r\n\t\t\t#endif\r\n\t\t\tLayaLight dirLight = layaDirectionLightToLight(u_DirectionLight,shadowAttenuation);\r\n\t\t\tcolor+= LAYA_BRDF_LIGHT(o.diffColor,o.specColor,o.oneMinusReflectivity,perceptualRoughness,roughness,nv,normalWorld,eyeVec,dirLight);\r\n\t\t#endif\r\n\t\r\n\t\t#ifdef POINTLIGHT\r\n\t\t\tshadowAttenuation = 1.0;\r\n\t\t\tLayaLight poiLight = layaPointLightToLight(posworld,normalWorld,u_PointLight,shadowAttenuation);\r\n\t\t\tcolor+= LAYA_BRDF_LIGHT(o.diffColor,o.specColor,o.oneMinusReflectivity,perceptualRoughness,roughness,nv,normalWorld,eyeVec,poiLight);\r\n\t\t#endif\r\n\t\t\r\n\t\t#ifdef SPOTLIGHT\r\n\t\t\tshadowAttenuation = 1.0;\r\n\t\t\t#ifdef CALCULATE_SPOTSHADOWS\r\n\t\t\t\tvec4 spotShadowcoord = v_SpotShadowCoord;\r\n\t\t\t\tshadowAttenuation = sampleSpotShadowmap(spotShadowcoord);\r\n\t\t\t#endif\r\n\t\t    LayaLight spoLight = layaSpotLightToLight(posworld,normalWorld,u_SpotLight,shadowAttenuation);\r\n\t\t\tcolor+= LAYA_BRDF_LIGHT(o.diffColor,o.specColor,o.oneMinusReflectivity,perceptualRoughness,roughness,nv,normalWorld,eyeVec,spoLight);\r\n\t\t#endif\r\n\t#else\r\n\t \t#ifdef DIRECTIONLIGHT\r\n\t\t\tfor (int i = 0; i &lt; MAX_LIGHT_COUNT; i++) \r\n\t\t\t{\r\n\t\t\t\tshadowAttenuation = 1.0;\r\n\t\t\t\tif(i &gt;= u_DirationLightCount)\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t#ifdef CALCULATE_SHADOWS\r\n\t\t\t\t\tif(i == 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t#ifdef SHADOW_CASCADE\r\n\t\t\t\t\t\t\tvec4 shadowCoord = getShadowCoord(vec4(v_PositionWorld,1.0));\r\n\t\t\t\t\t\t#else\r\n\t\t\t\t\t\t\tvec4 shadowCoord = v_ShadowCoord;\r\n\t\t\t\t\t\t#endif\r\n\t\t\t\t\t\tshadowAttenuation *= sampleShadowmap(shadowCoord);\r\n\t\t\t\t\t}\r\n\t\t\t\t#endif\r\n\t\t\t\tDirectionLight directionLight = getDirectionLight(u_LightBuffer,i);\r\n\t\t\t\tLayaLight dirLight = layaDirectionLightToLight(directionLight,shadowAttenuation);\r\n\t\t\t \tcolor+=LAYA_BRDF_LIGHT(o.diffColor,o.specColor,o.oneMinusReflectivity,perceptualRoughness,roughness,nv,normalWorld,eyeVec,dirLight);\r\n\t\t\t}\r\n\t \t#endif\r\n\t\t#if defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t\t\tivec4 clusterInfo =getClusterInfo(u_LightClusterBuffer,u_View,u_Viewport, v_PositionWorld,gl_FragCoord,u_ProjectionParams);\r\n\t\t\t#ifdef POINTLIGHT\r\n\t\t\t\tfor (int i = 0; i &lt; MAX_LIGHT_COUNT; i++) \r\n\t\t\t\t{\r\n\t\t\t\t\tshadowAttenuation = 1.0;\r\n\t\t\t\t\tif(i &gt;= clusterInfo.x)//PointLightCount\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tPointLight pointLight = getPointLight(u_LightBuffer,u_LightClusterBuffer,clusterInfo,i);\r\n\t\t\t\t\tLayaLight poiLight = layaPointLightToLight(posworld,normalWorld,pointLight,shadowAttenuation);\r\n\t\t\t\t\tcolor+= LAYA_BRDF_LIGHT(o.diffColor,o.specColor,o.oneMinusReflectivity,perceptualRoughness,roughness,nv,normalWorld,eyeVec,poiLight);\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t\t#ifdef SPOTLIGHT\r\n\t\t\t\tfor (int i = 0; i &lt; MAX_LIGHT_COUNT; i++) \r\n\t\t\t\t{\r\n\t\t\t\t\tshadowAttenuation = 1.0;\r\n\t\t\t\t\tif(i &gt;= clusterInfo.y)//SpotLightCount\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t#ifdef CALCULATE_SPOTSHADOWS\r\n\t\t\t\t\t\tif(i == 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvec4 spotShadowcoord = v_SpotShadowCoord;\r\n\t\t\t\t\t\t\tshadowAttenuation= sampleSpotShadowmap(spotShadowcoord);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t#endif\r\n\t\t\t\t\tSpotLight spotLight = getSpotLight(u_LightBuffer,u_LightClusterBuffer,clusterInfo,i);\r\n\t\t\t\t\tLayaLight spoLight = layaSpotLightToLight(posworld,normalWorld,spotLight,shadowAttenuation);\r\n\t\t\t\t\tcolor+= LAYA_BRDF_LIGHT(o.diffColor,o.specColor,o.oneMinusReflectivity,perceptualRoughness,roughness,nv,normalWorld,eyeVec,spoLight);\r\n\t\t\t\t}\r\n\t\t\t#endif\r\n\t\t#endif\r\n\t #endif\r\n\r\n\t#ifdef EMISSION\r\n\t\tcolor.rgb += emission(uv);\r\n\t#endif\r\n\r\n\t#ifdef FOG\r\n\t\tfloat lerpFact=clamp((1.0/gl_FragCoord.w-u_FogStart)/u_FogRange,0.0,1.0);\r\n\t\tcolor.rgb=mix(color.rgb,u_FogColor,lerpFact);\r\n\t#endif\r\n\t\r\n\tgl_FragColor=vec4(color.rgb,alpha);\r\n}\r\n\r\n\r\n",
        Wi = "attribute vec4 a_Position;\r\n\r\n#ifdef GPU_INSTANCE\r\n\tattribute mat4 a_MvpMatrix;\r\n\tattribute mat4 a_WorldMat;\r\n#else\r\n\tuniform mat4 u_MvpMatrix;\r\n\tuniform mat4 u_WorldMat;\r\n#endif\r\n\r\n#ifdef BONE\r\n\tconst int c_MaxBoneCount = 24;\r\n\tattribute vec4 a_BoneIndices;\r\n\tattribute vec4 a_BoneWeights;\r\n\tuniform mat4 u_Bones[c_MaxBoneCount];\r\n#endif\r\n\r\nattribute vec3 a_Normal;\r\nvarying vec3 v_Normal; \r\n\r\n#if defined(NORMALTEXTURE)||defined(PARALLAXTEXTURE)\r\n\tattribute vec4 a_Tangent0;\r\n\tvarying vec3 v_Tangent;\r\n\tvarying vec3 v_Binormal;\r\n    #ifdef PARALLAXTEXTURE\r\n\t    varying vec3 v_ViewDirForParallax;\r\n    #endif\r\n#endif\r\n\r\n#if defined(ALBEDOTEXTURE)||defined(METALLICGLOSSTEXTURE)||defined(NORMALTEXTURE)||defined(EMISSIONTEXTURE)||defined(OCCLUSIONTEXTURE)||defined(PARALLAXTEXTURE)||(defined(LIGHTMAP)&amp;&amp;defined(UV))\r\n\tattribute vec2 a_Texcoord0;\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\n#if defined(LIGHTMAP)&amp;&amp;defined(UV1)\r\n\tattribute vec2 a_Texcoord1;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tuniform vec4 u_LightmapScaleOffset;\r\n\tvarying vec2 v_LightMapUV;\r\n#endif\r\n\r\nuniform vec3 u_CameraPos;\r\nvarying vec3 v_EyeVec;\r\nvarying vec3 v_PositionWorld;\r\nvarying float v_posViewZ;\r\n\r\n#if defined(CALCULATE_SHADOWS)&amp;&amp;!defined(SHADOW_CASCADE)\r\n\tvarying vec4 v_ShadowCoord;\r\n#endif\r\n\r\n#ifdef CALCULATE_SPOTSHADOWS\r\n\tvarying vec4 v_SpotShadowCoord;\r\n#endif\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif",
        ki = "#ifdef ALPHATEST\r\n\tuniform float u_AlphaTestValue;\r\n#endif\r\n\r\nuniform vec4 u_AlbedoColor;\r\n\r\n#ifdef NORMALTEXTURE\r\n\tuniform sampler2D u_NormalTexture;\r\n\tuniform float u_NormalScale;\r\n#endif\r\n\r\n#ifdef ALBEDOTEXTURE\r\n\tuniform sampler2D u_AlbedoTexture;\r\n#endif\r\n\r\n#ifdef METALLICGLOSSTEXTURE\r\n\tuniform sampler2D u_MetallicGlossTexture;\r\n#endif\r\nuniform float u_Metallic;\r\n\r\n#ifdef SPECULARGLOSSTEXTURE\r\n\tuniform sampler2D u_SpecGlossTexture;\r\n#endif\r\nuniform vec3 u_SpecularColor;\r\n\r\nuniform float u_Smoothness;\r\nuniform float u_SmoothnessScale;\r\n\r\n#ifdef PARALLAXTEXTURE\r\n\tuniform sampler2D u_ParallaxTexture;\r\n\tuniform float u_ParallaxScale;\r\n\tvarying vec3 v_ViewDirForParallax;\r\n#endif\r\n\r\n#ifdef OCCLUSIONTEXTURE\r\n\tuniform sampler2D u_OcclusionTexture;\r\n\tuniform float u_occlusionStrength;\r\n#endif\r\n\r\n#ifdef EMISSION \r\n\t#ifdef EMISSIONTEXTURE\r\n\t\tuniform sampler2D u_EmissionTexture;\r\n\t#endif\r\n\tuniform vec4 u_EmissionColor;\r\n#endif\r\n\r\n#if defined(ALBEDOTEXTURE)||defined(METALLICGLOSSTEXTURE)||defined(NORMALTEXTURE)||defined(EMISSIONTEXTURE)||defined(OCCLUSIONTEXTURE)||defined(PARALLAXTEXTURE)\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\n#ifdef LIGHTMAP\r\n\tvarying vec2 v_LightMapUV;\r\n\tuniform sampler2D u_LightMap;\r\n\t#ifdef LIGHTMAP_DIRECTIONAL\r\n\t\tuniform sampler2D u_LightMapDirection;\r\n\t#endif\r\n#endif\r\n\r\nvarying vec3 v_Normal; \r\n\r\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\r\n\t#ifdef LEGACYSINGLELIGHTING\r\n\t\t#ifdef DIRECTIONLIGHT\r\n\t\t\tuniform DirectionLight u_DirectionLight;\r\n\t\t#endif\r\n\t\t#ifdef POINTLIGHT\r\n\t\t\tuniform PointLight u_PointLight;\r\n\t\t#endif\r\n\t\t#ifdef SPOTLIGHT\r\n\t\t\tuniform SpotLight u_SpotLight;\r\n\t\t#endif\r\n\t#else\r\n\t\tuniform mat4 u_View;\r\n\t\tuniform vec4 u_ProjectionParams;\r\n\t\tuniform vec4 u_Viewport;\r\n\t\tuniform int u_DirationLightCount;\r\n\t\tuniform sampler2D u_LightBuffer;\r\n\t\tuniform sampler2D u_LightClusterBuffer;\r\n\t#endif\r\n#endif\r\n\r\nvarying vec3 v_EyeVec;\r\n\r\n#ifdef NORMALTEXTURE\r\n\tvarying vec3 v_Tangent;\r\n\tvarying vec3 v_Binormal;\r\n#endif\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\tuniform vec3 u_FogColor;\r\n#endif\r\n\r\n\r\n//åŽé¢è€ƒè™‘å®TODO\r\nvarying vec3 v_PositionWorld;\r\n\r\n#if defined(CALCULATE_SHADOWS)&amp;&amp;!defined(SHADOW_CASCADE)\r\n\tvarying vec4 v_ShadowCoord;\r\n#endif\r\n\r\n#ifdef CALCULATE_SPOTSHADOWS\r\n\tvarying vec4 v_SpotShadowCoord;\r\n#endif\r\n\r\nmediump float lerpOneTo(mediump float b, mediump float t)\r\n{\r\n    mediump float oneMinusT = 1.0 - t;\r\n    return oneMinusT + b * t;\r\n}\r\n\r\n#ifdef EMISSION \r\n\tvec3 emission(vec2 uv)\r\n\t{\r\n\t\t#ifdef EMISSIONTEXTURE\r\n\t\t\treturn texture2D(u_EmissionTexture, uv).rgb * u_EmissionColor.rgb;\r\n\t\t#else\r\n\t\t\treturn u_EmissionColor.rgb;\r\n\t\t#endif\r\n\t}\r\n#endif\r\n\r\nmediump float getAlpha(vec2 uv)\r\n{\r\n\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\r\n\t\treturn u_AlbedoColor.a;\r\n\t#else\r\n\t\t#ifdef ALBEDOTEXTURE\r\n\t\t\treturn texture2D(u_AlbedoTexture, uv).a * u_AlbedoColor.a;\r\n\t\t#else\r\n\t\t\treturn u_AlbedoColor.a;\r\n\t\t#endif\r\n\t#endif\r\n}\r\n\r\nmediump float getOcclusion(vec2 uv)\r\n{\r\n\t#ifdef OCCLUSIONTEXTURE\r\n\t\tmediump float occ = texture2D(u_OcclusionTexture, uv).g;\r\n\t\treturn lerpOneTo(occ, u_occlusionStrength);\r\n\t#else\r\n\t\treturn 1.0;\r\n\t#endif\r\n}\r\n\r\nmediump vec3 albedo(vec2 uv)\r\n{\r\n\t#ifdef ALBEDOTEXTURE\r\n\t\treturn u_AlbedoColor.rgb * texture2D(u_AlbedoTexture, uv).rgb;\r\n\t#else\r\n\t\treturn u_AlbedoColor.rgb;\r\n\t#endif\r\n\t//TODO:Detail Texture\r\n}\r\n\r\nmediump vec2 getMetallicGloss(vec2 uv)\r\n{\r\n\tmediump vec2 ms;//x is metallic,y is smoothness\r\n\t#ifdef METALLICGLOSSTEXTURE\r\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\r\n\t\t\tms.x = texture2D(u_MetallicGlossTexture, uv).r;\r\n\t\t\t#ifdef ALBEDOTEXTURE\r\n\t\t\t\tms.y = texture2D(u_AlbedoTexture, uv).a*u_SmoothnessScale;\r\n\t\t\t#else\r\n\t\t\t\tms.y = u_SmoothnessScale;\r\n\t\t\t#endif\r\n\t\t#else\r\n\t\t\tms = texture2D(u_MetallicGlossTexture, uv).ra;\r\n\t\t\tms.y *= u_SmoothnessScale;\r\n\t\t#endif\r\n\t#else\r\n\t\tms.x = u_Metallic;\r\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\r\n\t\t\t#ifdef ALBEDOTEXTURE\r\n\t\t\t\tms.y = texture2D(u_AlbedoTexture, uv).a * u_SmoothnessScale;\r\n\t\t\t#else\r\n\t\t\t\tms.y = u_SmoothnessScale;\r\n\t\t\t#endif\r\n\t\t#else\r\n\t\t\tms.y = u_Smoothness;\r\n\t\t#endif\r\n\t#endif\r\n\treturn ms;\r\n}\r\n\r\nmediump vec4 specularGloss(vec2 uv)\r\n{\r\n\tmediump vec4 sg;\r\n\t#ifdef SPECULARGLOSSTEXTURE\r\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\r\n\t\t\tsg.rgb = texture2D(u_SpecGlossTexture, uv).rgb;\r\n\t\t\t#ifdef ALBEDOTEXTURE\r\n\t\t\t\tsg.a = texture2D(u_AlbedoTexture, uv).a*u_SmoothnessScale;\r\n\t\t\t#else\r\n\t\t\t\tsg.a = u_SmoothnessScale;\r\n\t\t\t#endif\r\n\t\t#else\r\n\t\t\tsg = texture2D(u_SpecGlossTexture, uv);\r\n\t\t\tsg.a *= u_SmoothnessScale;\r\n\t\t#endif\r\n\t#else\r\n\t\tsg.rgb = u_SpecularColor.rgb;\r\n\t\t#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\r\n\t\t\t#ifdef ALBEDOTEXTURE\r\n\t\t\t\tsg.a = texture2D(u_AlbedoTexture, uv).a * u_SmoothnessScale;\r\n\t\t\t#else\r\n\t\t\t\tsg.a = u_SmoothnessScale;\r\n\t\t\t#endif\r\n\t\t#else\r\n\t\t\tsg.a = u_Smoothness;\r\n\t\t#endif\r\n\t#endif\r\n\t\treturn sg;\r\n}\r\n\r\n\r\n#ifdef NORMALTEXTURE\r\n\tmediump vec3 unpackScaleNormal(mediump vec3 packednormal, mediump float bumpScale)\r\n\t{\r\n\t\tmediump vec3 normal = packednormal.xyz * 2.0 - 1.0;\r\n\t\tnormal.y=-normal.y;//NOTE:because unity to LayaAir coordSystem.\r\n\t\tnormal.xy *= bumpScale;\r\n\t\treturn normal;\r\n\t}\r\n\t\r\n\tmediump vec3 normalInTangentSpace(vec2 texcoords)\r\n\t{\r\n\t\tmediump vec3 normalTangent = unpackScaleNormal(texture2D(u_NormalTexture, texcoords).rgb,u_NormalScale);\r\n\t\treturn normalTangent;\r\n\t}\r\n#endif\r\n\r\n#ifdef PARALLAXTEXTURE\r\n\tmediump vec2 parallaxOffset1Step(mediump float h, mediump float height, mediump vec3 viewDir)\r\n\t{\r\n\t\th = h * height - height / 2.0;\r\n\t\tviewDir.z += 0.42;\r\n\t\treturn h * (viewDir.xy / viewDir.z);\r\n\t}\r\n\r\n\tvec2 parallax(vec2 texcoords, mediump vec3 viewDir)\r\n\t{\r\n\t\tmediump float h = texture2D(u_ParallaxTexture, texcoords.xy).g;\r\n\t\tvec2 offset = parallaxOffset1Step(h, u_ParallaxScale, viewDir);\r\n\t\treturn texcoords+offset;\r\n\t}\r\n#endif\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n",
        Xi = "vec2 transformLightMapUV(in vec2 texcoord,in vec4 lightmapScaleOffset)\r\n{\r\n\tvec2 lightMapUV=vec2(texcoord.x,1.0-texcoord.y)*lightmapScaleOffset.xy+lightmapScaleOffset.zw;\r\n\tlightMapUV.y=1.0-lightMapUV.y;\r\n\treturn lightMapUV; \r\n}\r\n\r\nvoid vertexForward()\r\n{\r\n\tvec4 position;\r\n\t#ifdef BONE\r\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\tposition=skinTransform*a_Position;\r\n\t#else\r\n\t\tposition=a_Position;\r\n\t#endif\r\n\r\n\t#ifdef GPU_INSTANCE\r\n\t\tgl_Position = a_MvpMatrix * position;\r\n\t#else\r\n\t\tgl_Position = u_MvpMatrix * position;\r\n\t#endif\r\n\r\n\tmat4 worldMat;\r\n\t#ifdef GPU_INSTANCE\r\n\t\tworldMat = a_WorldMat;\r\n\t#else\r\n\t\tworldMat = u_WorldMat;\r\n\t#endif\r\n\r\n\tv_PositionWorld=(worldMat*position).xyz;\r\n\r\n\t#if defined(ALBEDOTEXTURE)||defined(METALLICGLOSSTEXTURE)||defined(NORMALTEXTURE)||defined(EMISSIONTEXTURE)||defined(OCCLUSIONTEXTURE)||defined(PARALLAXTEXTURE)\r\n\t\t#ifdef TILINGOFFSET\r\n\t\t\tv_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\r\n\t\t#else\r\n\t\t\tv_Texcoord0=a_Texcoord0;\r\n\t\t#endif\r\n\t#endif\r\n\r\n\tv_EyeVec =u_CameraPos-v_PositionWorld;//will normalize per-pixel\r\n\r\n\t#ifdef LIGHTMAP\r\n\t\tvec2 texcoord;\r\n\t\t#ifdef UV1\r\n\t\t\ttexcoord=a_Texcoord1;\r\n\t\t#else\r\n\t\t\ttexcoord=a_Texcoord0;\r\n\t\t#endif\r\n\t\tv_LightMapUV=transformLightMapUV(texcoord,u_LightmapScaleOffset);\r\n\t#endif\r\n\r\n\tmat3 worldInvMat;\r\n\t#ifdef BONE\r\n\t\tworldInvMat=INVERSE_MAT(mat3(worldMat*skinTransform));\r\n\t#else\r\n\t\tworldInvMat=INVERSE_MAT(mat3(worldMat));\r\n\t#endif\r\n\r\n\tv_Normal=normalize(a_Normal*worldInvMat);//if no normalize will cause precision problem.\r\n\r\n\t#ifdef NORMALTEXTURE\r\n\t\tv_Tangent=normalize(a_Tangent0.xyz*worldInvMat);\r\n\t\tv_Binormal=cross(v_Normal,v_Tangent)*a_Tangent0.w;\r\n\t#endif\r\n\r\n\t#ifdef PARALLAXTEXTURE\r\n\t\tvec3 binormal = cross(a_Normal, a_Tangent0.xyz)*a_Tangent0.w;\r\n\t\tmat3 objectTBN = mat3(a_Tangent0.xyz, binormal, a_Normal);\r\n\t\tv_ViewDirForParallax=(worldInvMat*u_CameraPos-position.xyz)*objectTBN;\r\n\t#endif\r\n\r\n\t#if defined(CALCULATE_SHADOWS)&amp;&amp;!defined(SHADOW_CASCADE)\r\n\t\tv_ShadowCoord = getShadowCoord(vec4(v_PositionWorld,1.0));\r\n\t#endif\r\n\r\n\t#ifdef CALCULATE_SPOTSHADOWS\r\n\t\tv_SpotShadowCoord = u_SpotViewProjectMatrix*vec4(positionWS,1.0);\r\n\t#endif\r\n}",
        Yi = '#include "Lighting.glsl";\r\n\r\nattribute vec4 a_PositionTexcoord;\r\nvarying vec2 v_Texcoord0;\r\n\r\nvoid main() {\r\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\r\n\tv_Texcoord0 = a_PositionTexcoord.zw;\r\n\tgl_Position = remapGLPositionZ(gl_Position);\r\n}',
        ji = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform vec4 u_MainTex_TexelSize;\r\n\r\nvoid fragDownsample13() {\r\n\tmediump vec4 color = downsampleBox13Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\r\n\tgl_FragColor = color;\r\n}\r\n\r\nvoid main() {\r\n\tfragDownsample13();\r\n}',
        Zi = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform vec4 u_MainTex_TexelSize;\r\n\r\nvoid fragDownsample4() {\r\n\tmediump vec4 color = downsampleBox4Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\r\n\tgl_FragColor = color;\r\n}\r\n\r\nvoid main() {\r\n\tfragDownsample4();\r\n}',
        qi = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform sampler2D u_AutoExposureTex;\r\nuniform vec4 u_MainTex_TexelSize;\r\nuniform vec4 u_Threshold; // x: threshold value (linear), y: threshold - knee, z: knee * 2, w: 0.25 / knee\r\nuniform vec4 u_Params; // x: clamp, yzw: unused\r\n\r\nmediump vec4 prefilter(mediump vec4 color, vec2 uv) {\r\n\tmediump float autoExposure = texture2D(u_AutoExposureTex, uv).r;\r\n\tcolor *= autoExposure;\r\n\tcolor = min(vec4(u_Params.x), color); // clamp to max\r\n\tcolor = quadraticThreshold(color, u_Threshold.x, u_Threshold.yzw);\r\n\treturn color;\r\n}\r\n\r\nvoid fragPrefilter13() {\r\n\tmediump vec4 color = downsampleBox13Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\r\n\tgl_FragColor = prefilter(safeHDR(color), v_Texcoord0);\r\n}\r\n\r\nvoid main() {\r\n\tfragPrefilter13();\r\n}',
        Qi = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform sampler2D u_AutoExposureTex;\r\nuniform vec4 u_MainTex_TexelSize;\r\nuniform vec4 u_Threshold; // x: threshold value (linear), y: threshold - knee, z: knee * 2, w: 0.25 / knee\r\nuniform vec4 u_Params; // x: clamp, yzw: unused\r\n\r\nmediump vec4 prefilter(mediump vec4 color, vec2 uv) {\r\n\tmediump float autoExposure = texture2D(u_AutoExposureTex, uv).r;\r\n\tcolor *= autoExposure;\r\n\tcolor = min(vec4(u_Params.x), color); // clamp to max\r\n\tcolor = quadraticThreshold(color, u_Threshold.x, u_Threshold.yzw);\r\n\treturn color;\r\n}\r\n\r\nvoid fragPrefilter4() {\r\n\tmediump vec4 color = downsampleBox4Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\r\n\tgl_FragColor = prefilter(safeHDR(color), v_Texcoord0);\r\n}\r\n\r\nvoid main() {\r\n\tfragPrefilter4();\r\n}',
        Ki = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform sampler2D u_BloomTex;\r\n\r\nuniform vec4 u_MainTex_TexelSize;\r\nuniform float u_SampleScale;\r\n\r\nmediump vec4 combine(mediump vec4 bloom, vec2 uv) {\r\n\tmediump vec4 color = texture2D(u_BloomTex, uv);\r\n\treturn bloom + color;\r\n}\r\n\r\nvoid fragUpsampleBox() {\r\n\tmediump vec4 bloom = upsampleBox(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy, vec4(u_SampleScale));\r\n\tgl_FragColor = combine(bloom, v_Texcoord0);\r\n}\r\n\r\nvoid main() {\r\n\tfragUpsampleBox();\r\n}',
        Ji = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform sampler2D u_BloomTex;\r\n\r\nuniform vec4 u_MainTex_TexelSize;\r\nuniform float u_SampleScale;\r\n\r\nmediump vec4 combine(mediump vec4 bloom, vec2 uv) {\r\n\tmediump vec4 color = texture2D(u_BloomTex, uv);\r\n\treturn bloom + color;\r\n}\r\n\r\nvoid fragUpsampleTent() {\r\n\tmediump vec4 bloom = upsampleTent(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy, vec4(u_SampleScale));\r\n\tgl_FragColor = combine(bloom, v_Texcoord0);\r\n}\r\n\r\nvoid main() {\r\n\tfragUpsampleTent();\r\n}',
        $i = '#include "StdLib.glsl";\r\n\r\n#define EPSILON 1.0e-4\r\n\r\n// Quadratic color thresholding\r\n// curve = (threshold - knee, knee * 2, 0.25 / knee)\r\nmediump vec4 quadraticThreshold(mediump vec4 color, mediump float threshold, mediump vec3 curve) {\r\n\t// Pixel brightness\r\n\tmediump float br = max3(color.r, color.g, color.b);\r\n\r\n\t// Under-threshold part: quadratic curve\r\n\tmediump float rq = clamp(br - curve.x, 0.0, curve.y);\r\n\trq = curve.z * rq * rq;\r\n\r\n\t// Combine and apply the brightness response curve.\r\n\tcolor *= max(rq, br - threshold) / max(br, EPSILON);\r\n\r\n\treturn color;\r\n}\r\n\r\n\r\n\r\n//\r\n// sRGB transfer functions\r\n// Fast path ref: http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1\r\n//\r\nmediump vec3 sRGBToLinear(mediump vec3 c) {\r\n\t#ifdef USE_VERY_FAST_SRGB\r\n\t\treturn c * c;\r\n\t#elif defined(USE_FAST_SRGB)\r\n\t\treturn c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878);\r\n\t#else\r\n\t\tmediump vec3 linearRGBLo = c / 12.92;\r\n\t\tmediump vec3 power=vec3(2.4, 2.4, 2.4);\r\n\t\tmediump vec3 linearRGBHi = positivePow((c + 0.055) / 1.055, power);\r\n\t\tmediump vec3 linearRGB =vec3((c.r&lt;=0.04045) ? linearRGBLo.r : linearRGBHi.r,(c.g&lt;=0.04045) ? linearRGBLo.g : linearRGBHi.g,(c.b&lt;=0.04045) ? linearRGBLo.b : linearRGBHi.b);\r\n\t\treturn linearRGB;\r\n\t#endif\r\n}\r\n\r\nmediump vec4 sRGBToLinear(mediump vec4 c){\r\n    return vec4(sRGBToLinear(c.rgb), c.a);\r\n}\r\n\r\n\r\n\r\nmediump vec3 linearToSRGB(mediump vec3 c) {\r\n\t#ifdef USE_VERY_FAST_SRGB\r\n\t\treturn sqrt(c);\r\n\t#elif defined(USE_FAST_SRGB)\r\n\t\treturn max(1.055 * PositivePow(c, 0.416666667) - 0.055, 0.0);\r\n\t#else\r\n\t\tmediump vec3 sRGBLo = c * 12.92;\r\n\t\tmediump vec3 power=vec3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4);\r\n\t\tmediump vec3 sRGBHi = (positivePow(c, power) * 1.055) - 0.055;\r\n\t\tmediump vec3 sRGB =vec3((c.r&lt;=0.0031308) ? sRGBLo.r : sRGBHi.r,(c.g&lt;=0.0031308) ? sRGBLo.g : sRGBHi.g,(c.b&lt;=0.0031308) ? sRGBLo.b : sRGBHi.b);\r\n\t\treturn sRGB;\r\n\t#endif\r\n}\r\n\r\nmediump vec4 linearToSRGB(mediump vec4 c){\r\n    return vec4(linearToSRGB(c.rgb), c.a);\r\n}',
        en = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Colors.glsl";\r\n#include "Sampling.glsl";\r\n\r\nvarying vec2 v_Texcoord0;\r\n\r\nuniform sampler2D u_MainTex;\r\nuniform sampler2D u_BloomTex;\r\n\r\nuniform sampler2D u_AutoExposureTex;\r\nuniform sampler2D u_Bloom_DirtTex;\r\nuniform vec4 u_BloomTex_TexelSize;\r\nuniform vec4 u_Bloom_DirtTileOffset; // xy: tiling, zw: offset\r\nuniform mediump vec3 u_Bloom_Settings;// x: sampleScale, y: intensity, z: dirt intensity\r\nuniform mediump vec3 u_Bloom_Color;\r\n\r\nvoid main() {\r\n\tmediump float autoExposure = texture2D(u_AutoExposureTex, v_Texcoord0).r;\r\n\tmediump vec4 color=vec4(0.0);\r\n\tcolor = texture2D(u_MainTex, v_Texcoord0);\r\n\t\r\n\tcolor = sRGBToLinear(color);\r\n\tcolor.rgb *= autoExposure;\r\n\t\r\n\t#if defined(BLOOM)||defined(BLOOM_LOW)\r\n\t\t#ifdef BLOOM\r\n\t\t\tmediump vec4 bloom = upsampleTent(u_BloomTex, v_Texcoord0, u_BloomTex_TexelSize.xy, vec4(u_Bloom_Settings.x));\r\n\t\t#else\r\n\t\t\tmediump vec4 bloom = upsampleBox(u_BloomTex, v_Texcoord0, u_BloomTex_TexelSize.xy, vec4(u_Bloom_Settings.x));\r\n\t\t#endif\r\n\r\n\t\t// UVs should be Distort(uv * u_Bloom_DirtTileOffset.xy + u_Bloom_DirtTileOffset.zw)\r\n\t\t// but considering we use a cover-style scale on the dirt texture the difference\r\n\t\t// isn\'t massive so we chose to save a few ALUs here instead in case lens distortion\r\n\t\t// is active\r\n\t\tmediump vec4 dirt =vec4(texture2D(u_Bloom_DirtTex, v_Texcoord0 * u_Bloom_DirtTileOffset.xy + u_Bloom_DirtTileOffset.zw).rgb, 0.0);\r\n\r\n\t\t// Additive bloom (artist friendly)\r\n\t\tbloom *= u_Bloom_Settings.y;\r\n\t\tdirt *= u_Bloom_Settings.z;\r\n\t\tmediump vec4 bloomColor=vec4(u_Bloom_Color, 1.0);\r\n\t\tcolor += bloom * bloomColor;\r\n\t\tcolor += dirt * bloom;\r\n\t#endif\r\n\t\r\n\tmediump vec4 finalColor = color;\r\n\tfinalColor = linearToSRGB(finalColor);\r\n\t//finalColor.rgb = Dither(finalColor.rgb, v_Texcoord0);//TODO:æŠ–åŠ¨\r\n\tgl_FragColor = finalColor;\r\n}',
        tn = '#include "Lighting.glsl";\r\n\r\nattribute vec4 a_PositionTexcoord;\r\nvarying vec2 v_Texcoord0;\r\n\r\nvoid main() {\r\n\tgl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\r\n\tv_Texcoord0 = a_PositionTexcoord.zw;\r\n\tgl_Position = remapGLPositionZ(gl_Position);\r\n}',
        rn = "// Better, temporally stable box filtering\r\n// [Jimenez14] http://goo.gl/eomGso\r\n// . . . . . . .\r\n// . A . B . C .\r\n// . . D . E . .\r\n// . F . G . H .\r\n// . . I . J . .\r\n// . K . L . M .\r\n// . . . . . . .\r\nmediump vec4 downsampleBox13Tap(sampler2D tex, vec2 uv, vec2 texelSize)\r\n{\r\n    mediump vec4 A = texture2D(tex, uv + texelSize * vec2(-1.0, -1.0));\r\n    mediump vec4 B = texture2D(tex, uv + texelSize * vec2( 0.0, -1.0));\r\n    mediump vec4 C = texture2D(tex, uv + texelSize * vec2( 1.0, -1.0));\r\n    mediump vec4 D = texture2D(tex, uv + texelSize * vec2(-0.5, -0.5));\r\n    mediump vec4 E = texture2D(tex, uv + texelSize * vec2( 0.5, -0.5));\r\n    mediump vec4 F = texture2D(tex, uv + texelSize * vec2(-1.0,  0.0));\r\n    mediump vec4 G = texture2D(tex, uv);\r\n    mediump vec4 H = texture2D(tex, uv + texelSize * vec2( 1.0,  0.0));\r\n    mediump vec4 I = texture2D(tex, uv + texelSize * vec2(-0.5,  0.5));\r\n    mediump vec4 J = texture2D(tex, uv + texelSize * vec2( 0.5,  0.5));\r\n    mediump vec4 K = texture2D(tex, uv + texelSize * vec2(-1.0,  1.0));\r\n    mediump vec4 L = texture2D(tex, uv + texelSize * vec2( 0.0,  1.0));\r\n    mediump vec4 M = texture2D(tex, uv + texelSize * vec2( 1.0,  1.0));\r\n\r\n\tmediump vec2 scale= vec2(0.5, 0.125);\r\n    mediump vec2 div = (1.0 / 4.0) * scale;\r\n\r\n    mediump vec4 o = (D + E + I + J) * div.x;\r\n    o += (A + B + G + F) * div.y;\r\n    o += (B + C + H + G) * div.y;\r\n    o += (F + G + L + K) * div.y;\r\n    o += (G + H + M + L) * div.y;\r\n\r\n    return o;\r\n}\r\n\r\n// Standard box filtering\r\nmediump vec4 downsampleBox4Tap(sampler2D tex, vec2 uv, vec2 texelSize)\r\n{\r\n    vec4 d = texelSize.xyxy * vec4(-1.0, -1.0, 1.0, 1.0);\r\n\r\n    mediump vec4 s =  texture2D(tex, uv + d.xy);\r\n    s += texture2D(tex, uv + d.zy);\r\n    s += texture2D(tex, uv + d.xw);\r\n    s += texture2D(tex, uv + d.zw);\r\n\r\n    return s * (1.0 / 4.0);\r\n}\r\n\r\n// 9-tap bilinear upsampler (tent filter)\r\n// . . . . . . .\r\n// . 1 . 2 . 1 .\r\n// . . . . . . .\r\n// . 2 . 4 . 2 .\r\n// . . . . . . .\r\n// . 1 . 2 . 1 .\r\n// . . . . . . .\r\nmediump vec4 upsampleTent(sampler2D tex, vec2 uv, vec2 texelSize, vec4 sampleScale)\r\n{\r\n    vec4 d = texelSize.xyxy * vec4(1.0, 1.0, -1.0, 0.0) * sampleScale;\r\n\r\n    mediump vec4 s =  texture2D(tex, uv - d.xy);\r\n    s += texture2D(tex, uv - d.wy) * 2.0;\r\n    s += texture2D(tex, uv - d.zy);\r\n\r\n    s += texture2D(tex, uv + d.zw) * 2.0;\r\n    s += texture2D(tex, uv) * 4.0;\r\n    s += texture2D(tex,\tuv + d.xw) * 2.0;\r\n\r\n    s += texture2D(tex, uv + d.zy);\r\n    s += texture2D(tex, uv + d.wy) * 2.0;\r\n    s += texture2D(tex, uv + d.xy);\r\n\r\n    return s * (1.0 / 16.0);\r\n}\r\n\r\n// Standard box filtering\r\nmediump vec4 upsampleBox(sampler2D tex, vec2 uv, vec2 texelSize, vec4 sampleScale)\r\n{\r\n    vec4 d = texelSize.xyxy * vec4(-1.0, -1.0, 1.0, 1.0) * 0.5 * sampleScale;\r\n\r\n    mediump vec4 s =  texture2D(tex, uv + d.xy);\r\n    s += texture2D(tex, uv + d.zy);\r\n    s += texture2D(tex, uv + d.xw);\r\n    s += texture2D(tex, uv + d.zw);\r\n\r\n    return s * (1.0 / 4.0);\r\n}",
        nn = "#define HALF_MAX       65504.0 // (2 - 2^-10) * 2^15\r\n\r\n#define FLT_EPSILON    1.192092896e-07 // Smallest positive number, such that 1.0 + FLT_EPSILON != 1.0\r\n\r\nmediump vec4 safeHDR(mediump vec4 c)\r\n{\r\n    return min(c, HALF_MAX);\r\n}\r\n\r\nfloat max3(float a, float b, float c)\r\n{\r\n    return max(max(a, b), c);\r\n}\r\n\r\nvec3 positivePow(vec3 base, vec3 power)\r\n{\r\n    return pow(max(abs(base), vec3(FLT_EPSILON, FLT_EPSILON, FLT_EPSILON)), power);\r\n}",
        an = '#ifndef GRAPHICS_API_GLES3\r\n\t#define NO_NATIVE_SHADOWMAP\r\n#endif\r\n\r\n#ifdef NO_NATIVE_SHADOWMAP\r\n\t#define TEXTURE2D_SHADOW(textureName) uniform mediump sampler2D textureName\r\n\t#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName,coord3.xy).r&lt;coord3.z?0.0:1.0)\r\n\t#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\r\n#else\r\n\t#define TEXTURE2D_SHADOW(textureName) uniform mediump sampler2DShadow textureName\r\n\t#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName,coord3,0.0)\r\n\t#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\r\n#endif\r\n\r\n#if defined(RECEIVESHADOW)&amp;&amp;defined(SHADOW)\r\n    #define CALCULATE_SHADOWS\r\n#endif\r\n\r\n#if defined(RECEIVESHADOW)&amp;&amp;defined(SHADOW_SPOT)\r\n\t#define CALCULATE_SPOTSHADOWS\r\n#endif\r\n\r\nuniform vec4 u_ShadowBias; // x: depth bias, y: normal bias\r\n\r\n#if defined(CALCULATE_SHADOWS)||defined(CALCULATE_SPOTSHADOWS)\r\n\t#include "ShadowSampleTent.glsl"\r\n\tuniform vec4 u_ShadowMapSize;\r\n\tuniform vec4 u_ShadowParams; // x: shadowStrength y: ShadowSpotLightStrength\r\n\r\n\t\r\n\tfloat sampleShdowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize)\r\n\t{\r\n\t\tfloat attenuation;\r\n\t\tvec4 attenuation4;\r\n\t\tvec2 offset=shadowMapSize.xy/2.0;\r\n\t\tvec3 shadowCoord0=shadowCoord + vec3(-offset,0.0);\r\n\t\tvec3 shadowCoord1=shadowCoord + vec3(offset.x,-offset.y,0.0);\r\n\t\tvec3 shadowCoord2=shadowCoord + vec3(-offset.x,offset.y,0.0);\r\n\t\tvec3 shadowCoord3=shadowCoord + vec3(offset,0.0);\r\n\t\tattenuation4.x = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord0);\r\n\t\tattenuation4.y = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord1);\r\n\t\tattenuation4.z = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord2);\r\n\t\tattenuation4.w = SAMPLE_TEXTURE2D_SHADOW(shadowMap, shadowCoord3);\r\n\t\tattenuation = dot(attenuation4, vec4(0.25));\r\n\t\treturn attenuation;\r\n\t}\r\n\r\n\tfloat sampleShdowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize)\r\n\t{\r\n\t\tfloat attenuation;\r\n\t\tfloat fetchesWeights[9];\r\n\t\tvec2 fetchesUV[9];\r\n\t\tsampleShadowComputeSamplesTent5x5(shadowmapSize, shadowCoord.xy, fetchesWeights, fetchesUV);\r\n\t\tattenuation = fetchesWeights[0] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[0].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[1] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[1].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[2] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[2].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[3] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[3].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[4] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[4].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[5] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[5].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[6] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[6].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[7] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[7].xy, shadowCoord.z));\r\n\t\tattenuation += fetchesWeights[8] * SAMPLE_TEXTURE2D_SHADOW(shadowMap, vec3(fetchesUV[8].xy, shadowCoord.z));\r\n\t\treturn attenuation;\r\n\t}\r\n\r\n#endif\r\n\r\n\r\n\r\n\r\n#ifdef CALCULATE_SHADOWS\r\n\r\n\tTEXTURE2D_SHADOW(u_ShadowMap);\r\n\r\n\tuniform mat4 u_ShadowMatrices[4];\r\n\tuniform vec4 u_ShadowSplitSpheres[4];// max cascade is 4\r\n\r\n\tmediump int computeCascadeIndex(vec3 positionWS)\r\n\t{\r\n\t\tvec3 fromCenter0 = positionWS - u_ShadowSplitSpheres[0].xyz;\r\n\t\tvec3 fromCenter1 = positionWS - u_ShadowSplitSpheres[1].xyz;\r\n\t\tvec3 fromCenter2 = positionWS - u_ShadowSplitSpheres[2].xyz;\r\n\t\tvec3 fromCenter3 = positionWS - u_ShadowSplitSpheres[3].xyz;\r\n\r\n\t\tmediump vec4 comparison = vec4(\r\n\t\t\tdot(fromCenter0, fromCenter0)&lt;u_ShadowSplitSpheres[0].w,\r\n\t\t\tdot(fromCenter1, fromCenter1)&lt;u_ShadowSplitSpheres[1].w,\r\n\t\t\tdot(fromCenter2, fromCenter2)&lt;u_ShadowSplitSpheres[2].w,\r\n\t\t\tdot(fromCenter3, fromCenter3)&lt;u_ShadowSplitSpheres[3].w);\r\n\t\tcomparison.yzw = clamp(comparison.yzw - comparison.xyz,0.0,1.0);//keep the nearest\r\n\t\tmediump vec4 indexCoefficient = vec4(4.0,3.0,2.0,1.0);\r\n\t\tmediump int index = 4 - int(dot(comparison, indexCoefficient));\r\n\t\treturn index;\r\n\t}\r\n\r\n\tvec4 getShadowCoord(vec4 positionWS)\r\n\t{\r\n\t\t#ifdef SHADOW_CASCADE\r\n\t\t\tmediump int cascadeIndex = computeCascadeIndex(positionWS.xyz);\r\n\t\t\tif(cascadeIndex &gt; 3)// out of shadow range cascadeIndex is 4.\r\n\t\t\t\treturn vec4(0.0);\r\n\t\t\t\r\n\t\t\t#ifdef GRAPHICS_API_GLES3\r\n\t\t\t\treturn u_ShadowMatrices[cascadeIndex] * positionWS;\r\n\t\t\t#else\r\n\t\t\t\tmat4 shadowMat;\r\n\t\t\t\tif(cascadeIndex == 0)\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[0];\r\n\t\t\t\telse if(cascadeIndex == 1)\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[1];\r\n\t\t\t\telse if(cascadeIndex == 2)\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[2];\r\n\t\t\t\telse\r\n\t\t\t\t\tshadowMat = u_ShadowMatrices[3];\r\n\t\t\t\treturn shadowMat * positionWS;\r\n\t\t\t#endif\r\n\t\t#else\r\n\t\t\treturn u_ShadowMatrices[0] * positionWS;\r\n\t\t#endif\r\n\t}\r\n\r\n\tfloat sampleShadowmap(vec4 shadowCoord)\r\n\t{\r\n\t\tshadowCoord.xyz /= shadowCoord.w;\r\n\t\tfloat attenuation = 1.0;\r\n\t\tif(shadowCoord.z &gt; 0.0 &amp;&amp; shadowCoord.z &lt; 1.0)\r\n\t\t{\r\n\t\t\t#if defined(SHADOW_SOFT_SHADOW_HIGH)\r\n\t\t\t\tattenuation = sampleShdowMapFiltered9(u_ShadowMap,shadowCoord.xyz,u_ShadowMapSize);\r\n\t\t\t#elif defined(SHADOW_SOFT_SHADOW_LOW)\r\n\t\t\t\tattenuation = sampleShdowMapFiltered4(u_ShadowMap,shadowCoord.xyz,u_ShadowMapSize);\r\n\t\t\t#else\r\n\t\t\t\tattenuation = SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,shadowCoord.xyz);\r\n\t\t\t#endif\r\n\t\t\tattenuation = mix(1.0,attenuation,u_ShadowParams.x);//shadowParams.x:shadow strength\r\n\t\t}\r\n\t\treturn attenuation;\r\n\t}\r\n#endif\r\n\r\n#ifdef CALCULATE_SPOTSHADOWS\r\n\tTEXTURE2D_SHADOW(u_SpotShadowMap);\r\n\tuniform mat4 u_SpotViewProjectMatrix;\r\n\tfloat sampleSpotShadowmap(vec4 shadowCoord)\r\n\t{\r\n\t\tshadowCoord.xyz /= shadowCoord.w;\r\n\t\tfloat attenuation = 1.0;\r\n\t\tshadowCoord.xy +=1.0;\r\n\t\tshadowCoord.xy/=2.0; \r\n\t\tif(shadowCoord.z &gt; 0.0 &amp;&amp; shadowCoord.z &lt; 1.0)\r\n\t\t{\r\n\t\t\t#if defined(SHADOW_SPOT_SOFT_SHADOW_HIGH)\r\n\t\t\t\tattenuation = sampleShdowMapFiltered9(u_SpotShadowMap,shadowCoord.xyz,u_ShadowMapSize);\r\n\t\t\t#elif defined(SHADOW_SPOT_SOFT_SHADOW_LOW)\r\n\t\t\t\tattenuation = sampleShdowMapFiltered4(u_SpotShadowMap,shadowCoord.xyz,u_ShadowMapSize);\r\n\t\t\t#else\r\n\t\t\t\tattenuation = SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,shadowCoord.xyz);\r\n\t\t\t#endif\r\n\t\t\tattenuation = mix(1.0,attenuation,u_ShadowParams.y);//shadowParams.y:shadow strength\r\n\t\t}\r\n\t\treturn attenuation;\r\n\t}\r\n#endif\r\n\r\nvec3 applyShadowBias(vec3 positionWS, vec3 normalWS, vec3 lightDirection)\r\n{\r\n    float invNdotL = 1.0 - clamp(dot(-lightDirection, normalWS),0.0,1.0);\r\n    float scale = invNdotL * u_ShadowBias.y;\r\n\r\n    // normal bias is negative since we want to apply an inset normal offset\r\n    positionWS += -lightDirection * u_ShadowBias.xxx;\r\n    positionWS += normalWS * vec3(scale);\r\n    return positionWS;\r\n}\r\n',
        sn = '#include "Lighting.glsl";\r\n#include "Shadow.glsl"\r\n\r\nattribute vec4 a_Position;\r\nattribute vec3 a_Normal;\r\n\r\n#ifdef BONE\r\n\tconst int c_MaxBoneCount = 24;\r\n\tattribute vec4 a_BoneIndices;\r\n\tattribute vec4 a_BoneWeights;\r\n\tuniform mat4 u_Bones[c_MaxBoneCount];\r\n#endif\r\n\r\n#ifdef GPU_INSTANCE\r\n\tattribute mat4 a_WorldMat;\r\n#else\r\n\tuniform mat4 u_WorldMat;\r\n#endif\r\n\r\nuniform mat4 u_ViewProjection;\r\n\r\n#ifdef SHADOW\r\n\tuniform vec3 u_ShadowLightDirection;\r\n#endif\r\n\r\n\r\n\r\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&amp;&amp;(defined(SPECULARMAP)||defined(NORMALMAP)))||(defined(LIGHTMAP)&amp;&amp;defined(UV))\r\n\tattribute vec2 a_Texcoord0;\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\nvec4 shadowCasterVertex()\r\n{\r\n\tmat4 worldMat;\r\n\t#ifdef GPU_INSTANCE\r\n\t\tworldMat = a_WorldMat;\r\n\t#else\r\n\t\tworldMat = u_WorldMat;\r\n\t#endif\r\n\t\r\n\t#ifdef BONE\r\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\tworldMat = worldMat * skinTransform;\r\n\t#endif\r\n\r\n\tvec4 positionWS = worldMat * a_Position;\r\n\tvec3 normalWS = normalize(a_Normal*INVERSE_MAT(mat3(worldMat)));//if no normalize will cause precision problem\r\n\r\n\t#ifdef SHADOW\r\n\t\tpositionWS.xyz = applyShadowBias(positionWS.xyz,normalWS,u_ShadowLightDirection);\r\n\t#endif\r\n\r\n\tvec4 positionCS = u_ViewProjection * positionWS;\r\n\t#ifdef SHADOW_SPOT\r\n\t\tpositionCS.z = positionCS.z-u_ShadowBias.x/positionCS.w;\r\n\t#endif\r\n\tpositionCS.z = max(positionCS.z, 0.0);//min ndc z is 0.0\r\n\t\r\n\t// //TODOæ²¡è€ƒè™‘UVåŠ¨ç”»å‘¢\r\n\t// #if defined(DIFFUSEMAP)&amp;&amp;defined(ALPHATEST)\r\n\t// \tv_Texcoord0=a_Texcoord0;\r\n\t// #endif\r\n    return positionCS;\r\n}\r\n',
        on = "// #ifdef ALPHATEST\r\n// \tuniform float u_AlphaTestValue;\r\n// #endif\r\n\r\n// #ifdef DIFFUSEMAP\r\n// \tuniform sampler2D u_DiffuseTexture;\r\n// #endif\r\n\r\n// #if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&amp;&amp;(defined(SPECULARMAP)||defined(NORMALMAP)))\r\n// \tvarying vec2 v_Texcoord0;\r\n// #endif\r\n\r\nvec4 shadowCasterFragment()\r\n{\r\n    return vec4(0.0);\r\n    // #if defined(DIFFUSEMAP)&amp;&amp;defined(ALPHATEST)\r\n\t// \tfloat alpha = texture2D(u_DiffuseTexture,v_Texcoord0).w;\r\n\t// \tif( alpha &lt; u_AlphaTestValue )\r\n\t// \t{\r\n\t// \t\tdiscard;\r\n\t// \t}\r\n\t// #endif\r\n}\r\n",
        ln = "#ifdef GL_FRAGMENT_PRECISION_HIGH\r\nprecision highp float;\r\n#else\r\nprecision mediump float;\r\n#endif\r\n\r\nvarying vec3 v_Texcoord;\r\n\r\nuniform samplerCube u_CubeTexture;\r\nuniform float u_Exposure;\r\nuniform vec4 u_TintColor;\r\n\r\n\r\nvoid main()\r\n{\t\r\n\tvec3 color=textureCube(u_CubeTexture, v_Texcoord).rgb*u_TintColor.rgb*u_Exposure*2.0;\r\n\tgl_FragColor=vec4(color,1.0);\r\n}\r\n\r\n",
        _n = '#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nuniform mat4 u_ViewProjection;\r\nuniform float u_Rotation;\r\nvarying vec3 v_Texcoord;\r\n\r\n\r\nvec4 rotateAroundYInDegrees (vec4 vertex, float degrees)\r\n{\r\n\tfloat angle = degrees * 3.141593 / 180.0;\r\n\tfloat sina=sin(angle);\r\n\tfloat cosa=cos(angle);\r\n\tmat2 m = mat2(cosa, -sina, sina, cosa);\r\n\treturn vec4(m*vertex.xz, vertex.yw).xzyw;\r\n}\r\n\t\t\r\nvoid main()\r\n{\r\n\tvec4 position=rotateAroundYInDegrees(a_Position,u_Rotation);\r\n\tgl_Position = u_ViewProjection*position;\r\n\tv_Texcoord=vec3(-a_Position.x,a_Position.yz);//è½¬æ¢åæ&nbsp;‡ç³»\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}\r\n',
        hn = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include "Lighting.glsl";\r\n\r\nconst float MIE_G = -0.990;\r\nconst float MIE_G2 = 0.9801;\r\nconst float SKY_GROUND_THRESHOLD = 0.02;\r\n\r\nuniform float u_SunSize;\r\nuniform float u_SunSizeConvergence;\r\nuniform DirectionLight u_SunLight;\r\n\r\n\r\nvarying vec3 v_GroundColor;\r\nvarying vec3 v_SkyColor;\r\n\r\n\r\n#ifdef SUN_HIGH_QUALITY\r\n\tvarying vec3 v_Vertex;\r\n#elif defined(SUN_SIMPLE)\r\n\tvarying vec3 v_RayDir;\r\n#else\r\n\tvarying float v_SkyGroundFactor;\r\n#endif\r\n\r\n#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\r\n\tvarying vec3 v_SunColor;\r\n#endif\r\n\r\n// Calculates the Mie phase function\r\nfloat getMiePhase(float eyeCos, float eyeCos2) {\r\n\tfloat temp = 1.0 + MIE_G2 - 2.0 * MIE_G * eyeCos;\r\n\ttemp = pow(temp, pow(u_SunSize,0.65) * 10.0);\r\n\ttemp = max(temp,1.0e-4); // prevent division by zero, esp. in half precision\r\n\ttemp = 1.5 * ((1.0 - MIE_G2) / (2.0 + MIE_G2)) * (1.0 + eyeCos2) / temp;\r\n\treturn temp;\r\n}\r\n\r\n// Calculates the sun shape\r\nfloat calcSunAttenuation(vec3 lightPos, vec3 ray) {\r\n\t#ifdef SUN_HIGH_QUALITY\r\n\t\tfloat focusedEyeCos = pow(clamp(dot(lightPos, ray),0.0,1.0), u_SunSizeConvergence);\r\n\t\treturn getMiePhase(-focusedEyeCos, focusedEyeCos * focusedEyeCos);\r\n\t#else //SUN_SIMPLE\r\n\t\tvec3 delta = lightPos - ray;\r\n\t\tfloat dist = length(delta);\r\n\t\tfloat spot = 1.0 - smoothstep(0.0, u_SunSize, dist);\r\n\t\treturn spot * spot;\r\n\t#endif\r\n}\r\n\r\nvoid main() {\r\n\t// if y &gt; 1 [eyeRay.y &lt; -SKY_GROUND_THRESHOLD] - ground\r\n\t// if y &gt;= 0 and &lt; 1 [eyeRay.y &lt;= 0 and &gt; -SKY_GROUND_THRESHOLD] - horizon\r\n\t// if y &lt; 0 [eyeRay.y &gt; 0] - sky\r\n\tvec3 col = vec3(0.0, 0.0, 0.0);\r\n\r\n\t#ifdef SUN_HIGH_QUALITY\r\n\t\tvec3 ray = normalize(v_Vertex);\r\n\t\tfloat y = ray.y / SKY_GROUND_THRESHOLD;\r\n\t#elif defined(SUN_SIMPLE) \r\n\t\tvec3 ray = v_RayDir;\r\n\t\tfloat y = ray.y / SKY_GROUND_THRESHOLD;\t\r\n\t#else\r\n\t\tfloat y = v_SkyGroundFactor;\r\n\t#endif\r\n\r\n\t// if we did precalculate color in vprog: just do lerp between them\r\n\tcol = mix(v_SkyColor, v_GroundColor, clamp(y,0.0,1.0));\r\n\r\n\t#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\r\n\t\tif (y &lt; 0.0)\r\n\t\t\tcol += v_SunColor * calcSunAttenuation(-u_SunLight.direction, -ray);\r\n\t#endif\r\n\r\n\tcol = sqrt(col);//linear space convert to gamma space\r\n\tgl_FragColor=vec4(col,1.0);\r\n}\r\n\r\n',
        cn = "#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#include \"Lighting.glsl\";\r\n\r\n#define OUTER_RADIUS 1.025\r\n#define RAYLEIGH (mix(0.0, 0.0025, pow(u_AtmosphereThickness,2.5)))// Rayleigh constant Rayleighä¸ºå¤œç©ºå…‰å’Œæžå…‰äº®åº¦å•ä½\r\n#define MIE 0.0010             // Mie constant ç±³æ°æ•£å°„\r\n#define SUN_BRIGHTNESS 20.0    // Sun brightness\r\n#define MAX_SCATTER 50.0 // Maximum scattering value, to prevent math overflows on Adrenos\r\n\r\nconst float SKY_GROUND_THRESHOLD = 0.02;\r\nconst float outerRadius = OUTER_RADIUS;\r\nconst float outerRadius2 = OUTER_RADIUS*OUTER_RADIUS;\r\nconst float innerRadius = 1.0;\r\nconst float innerRadius2 = 1.0;\r\nconst float cameraHeight = 0.0001;\r\n\r\nconst float HDSundiskIntensityFactor = 15.0;\r\nconst float simpleSundiskIntensityFactor = 27.0;\r\n\r\nconst float sunScale = 400.0 * SUN_BRIGHTNESS;\r\nconst float kmESun = MIE * SUN_BRIGHTNESS;\r\nconst float km4PI = MIE * 4.0 * 3.14159265;\r\nconst float scale = 1.0 / (OUTER_RADIUS - 1.0);\r\nconst float scaleDepth = 0.25;\r\nconst float scaleOverScaleDepth = (1.0 / (OUTER_RADIUS - 1.0)) / 0.25;\r\nconst float samples = 2.0; // THIS IS UNROLLED MANUALLY, DON'T TOUCH\r\n\r\n// RGB wavelengths        .35 (.62=158), .43 (.68=174), .525 (.75=190)\r\nconst vec3 c_DefaultScatteringWavelength = vec3(0.65, 0.57, 0.475);//é»˜è®¤æ•£å°„æ³¢é•¿\r\nconst vec3 c_VariableRangeForScatteringWavelength = vec3(0.15, 0.15, 0.15);//æ•£å°„æ’­æ”¾çš„å¯å˜èŒƒå›´\r\n\r\nattribute vec4 a_Position;\r\n\r\nuniform mat4 u_ViewProjection;\r\nuniform vec3 u_SkyTint;\r\nuniform vec3 u_GroundTint;\r\nuniform float u_Exposure;\r\nuniform float u_AtmosphereThickness;\r\nuniform DirectionLight u_SunLight;\r\n\r\nvarying vec3 v_GroundColor;\r\nvarying vec3 v_SkyColor;\r\n\r\n#ifdef SUN_HIGH_QUALITY\r\n\tvarying vec3 v_Vertex;\r\n#elif defined(SUN_SIMPLE)\r\n\tvarying vec3 v_RayDir;\r\n#else\r\n\tvarying float v_SkyGroundFactor;\r\n#endif\r\n\r\n#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\r\n\tvarying vec3 v_SunColor;\r\n#endif\r\n\r\n// Calculates the Rayleigh phase function\r\nfloat getRayleighPhase(vec3 light, vec3 ray) \r\n{\r\n\tfloat eyeCos = dot(light, ray);\r\n\treturn 0.75 + 0.75*eyeCos*eyeCos;\r\n}\r\n\r\nfloat scaleAngle(float inCos)\r\n{\r\n\tfloat x = 1.0 - inCos;\r\n\treturn 0.25 * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25))));\r\n}\r\n\r\n\r\nvoid main () {\r\n\tgl_Position = u_ViewProjection*a_Position;\r\n\r\n\tvec3 skyTintInGammaSpace = u_SkyTint;//æ”¯æŒéžGAMMAç©ºé—´åŽè¦è°ƒæ•´\r\n\tvec3 scatteringWavelength = mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0) - skyTintInGammaSpace); // using Tint in sRGB+ gamma allows for more visually linear interpolation and to keep (0.5) at (128, gray in sRGB) point\r\n\tvec3 invWavelength = 1.0 / pow(scatteringWavelength, vec3(4.0));\r\n\r\n\tfloat krESun = RAYLEIGH * SUN_BRIGHTNESS;\r\n\tfloat kr4PI = RAYLEIGH * 4.0 * 3.14159265;\r\n\r\n\tvec3 cameraPos = vec3(0.0,innerRadius + cameraHeight,0.0); // The camera's current position\r\n\r\n\t// Get the ray from the camera to the vertex and its length (which is the far point of the ray passing through the atmosphere)\r\n\tvec3 eyeRay = normalize(a_Position.xyz);\r\n\r\n\tfloat far = 0.0;\r\n\tvec3 cIn, cOut;\r\n\tif (eyeRay.y &gt;= 0.0) {// Sky\r\n\t\t// Calculate the length of the \"atmosphere\"\r\n\t\tfar = sqrt(outerRadius2 + innerRadius2 * eyeRay.y * eyeRay.y - innerRadius2) - innerRadius * eyeRay.y;\r\n\r\n\t\t// Calculate the ray's starting position, then calculate its scattering offset\r\n\t\tfloat height = innerRadius + cameraHeight;\r\n\t\tfloat depth = exp(scaleOverScaleDepth * -cameraHeight);\r\n\t\tfloat startAngle = dot(eyeRay, cameraPos) / height;\r\n\t\tfloat startOffset = depth*scaleAngle(startAngle);\r\n\r\n\t\t// Initialize the scattering loop variables\r\n\t\tfloat sampleLength = far / samples;\r\n\t\tfloat scaledLength = sampleLength * scale;\r\n\t\tvec3 sampleRay = eyeRay * sampleLength;\r\n\t\tvec3 samplePoint = cameraPos + sampleRay * 0.5;\r\n\r\n\t\tvec3 frontColor = vec3(0.0);\r\n\t\t//unrolling this manually to avoid some platform for loop slow\r\n\t\t{\r\n\t\t\tfloat height = length(samplePoint);\r\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\r\n\t\t\tfloat lightAngle = dot(-u_SunLight.direction, samplePoint) / height;\r\n\t\t\tfloat cameraAngle = dot(eyeRay, samplePoint) / height;\r\n\t\t\tfloat scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\r\n\t\t\tvec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\r\n\r\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\r\n\t\t\tsamplePoint += sampleRay;\r\n\t\t}\r\n\t\t{\r\n\t\t\tfloat height = length(samplePoint);\r\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\r\n\t\t\tfloat lightAngle = dot(-u_SunLight.direction, samplePoint) / height;\r\n\t\t\tfloat cameraAngle = dot(eyeRay, samplePoint) / height;\r\n\t\t\tfloat scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\r\n\t\t\tvec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\r\n\r\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\r\n\t\t\tsamplePoint += sampleRay;\r\n\t\t}\r\n\r\n\t\t// Finally, scale the Mie and Rayleigh colors and set up the varying variables for the pixel shader\r\n\t\tcIn = frontColor * (invWavelength * krESun);\r\n\t\tcOut = frontColor * kmESun;\r\n\t} else {// Ground\r\n\t\tfar = (-cameraHeight) / (min(-0.001, eyeRay.y));\r\n\t\tvec3 pos = cameraPos + far * eyeRay;\r\n\r\n\t\t// Calculate the ray's starting position, then calculate its scattering offset\r\n\t\tfloat depth = exp((-cameraHeight) * (1.0/scaleDepth));\r\n\t\tfloat cameraAngle = dot(-eyeRay, pos);\r\n\t\tfloat lightAngle = dot(-u_SunLight.direction, pos);\r\n\t\tfloat cameraScale = scaleAngle(cameraAngle);\r\n\t\tfloat lightScale = scaleAngle(lightAngle);\r\n\t\tfloat cameraOffset = depth*cameraScale;\r\n\t\tfloat temp = lightScale + cameraScale;\r\n\r\n\t\t// Initialize the scattering loop variables\r\n\t\tfloat sampleLength = far / samples;\r\n\t\tfloat scaledLength = sampleLength * scale;\r\n\t\tvec3 sampleRay = eyeRay * sampleLength;\r\n\t\tvec3 samplePoint = cameraPos + sampleRay * 0.5;\r\n\r\n\t\t// Now loop through the sample rays\r\n\t\tvec3 frontColor = vec3(0.0, 0.0, 0.0);\r\n\t\tvec3 attenuate;\r\n\r\n\t\t// Loop removed because we kept hitting SM2.0 temp variable limits. Doesn't affect the image too much.\r\n\t\t{\r\n\t\t\tfloat height = length(samplePoint);\r\n\t\t\tfloat depth = exp(scaleOverScaleDepth * (innerRadius - height));\r\n\t\t\tfloat scatter = depth*temp - cameraOffset;\r\n\t\t\tattenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\r\n\t\t\tfrontColor += attenuate * (depth * scaledLength);\r\n\t\t\tsamplePoint += sampleRay;\r\n\t\t}\r\n\r\n\t\tcIn = frontColor * (invWavelength * krESun + kmESun);\r\n\t\tcOut = clamp(attenuate, 0.0, 1.0);\r\n\t}\r\n\r\n\t#ifdef SUN_HIGH_QUALITY\r\n\t\tv_Vertex = -a_Position.xyz;\r\n\t#elif defined(SUN_SIMPLE) \r\n\t\tv_RayDir = -eyeRay;\r\n\t#else\r\n\t\tv_SkyGroundFactor = -eyeRay.y / SKY_GROUND_THRESHOLD;\r\n\t#endif\r\n\r\n\t// if we want to calculate color in vprog:\r\n\t// in case of linear: multiply by _Exposure in here (even in case of lerp it will be common multiplier, so we can skip mul in fshader)\r\n\tv_GroundColor = u_Exposure * (cIn + u_GroundTint*u_GroundTint * cOut);//u_GroundColor*u_GroundColor is gamma space convert to linear space\r\n\tv_SkyColor    = u_Exposure * (cIn * getRayleighPhase(-u_SunLight.direction, -eyeRay));\r\n\r\n\t\r\n\t// The sun should have a stable intensity in its course in the sky. Moreover it should match the highlight of a purely specular material.\r\n\t// This matching was done using the Unity3D standard shader BRDF1 on the 5/31/2017\r\n\t// Finally we want the sun to be always bright even in LDR thus the normalization of the lightColor for low intensity.\r\n\tfloat lightColorIntensity = clamp(length(u_SunLight.color), 0.25, 1.0);\r\n\r\n\t#ifdef SUN_HIGH_QUALITY \r\n\t\tv_SunColor = HDSundiskIntensityFactor * clamp(cOut,0.0,1.0) * u_SunLight.color / lightColorIntensity;\r\n\t#elif defined(SUN_SIMPLE) \r\n\t\tv_SunColor = simpleSundiskIntensityFactor * clamp(cOut * sunScale,0.0,1.0) * u_SunLight.color / lightColorIntensity;\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}\r\n",
        dn = "#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\nuniform sampler2D u_MainTexture;\r\nuniform vec4 u_MainColor;\r\n\r\nvarying vec2 v_Texcoord0;\r\nvarying vec4 v_Color;\r\n\r\nvoid main()\r\n{\r\n\tvec4 color = 2.0 * u_MainColor * v_Color;\r\n\t#ifdef MAINTEXTURE\r\n\t\tvec4 mainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\r\n\t\tcolor *= mainTextureColor;\r\n\t#endif\r\n\tgl_FragColor = color;\r\n}\r\n\r\n     ",
        un = '#include "Lighting.glsl";\r\n\r\nattribute vec3 a_Position;\r\nattribute vec3 a_OffsetVector;\r\nattribute vec4 a_Color;\r\nattribute float a_Texcoord0X;\r\nattribute float a_Texcoord0Y;\r\nattribute float a_BirthTime;\r\n\r\nuniform mat4 u_View;\r\nuniform mat4 u_Projection;\r\n\r\nuniform vec4 u_TilingOffset;\r\n\r\nuniform float u_CurTime;\r\nuniform float u_LifeTime;\r\nuniform vec4 u_WidthCurve[10];\r\nuniform int u_WidthCurveKeyLength;\r\n\r\nvarying vec2 v_Texcoord0;\r\nvarying vec4 v_Color;\r\n\r\nfloat hermiteInterpolate(float t, float outTangent, float inTangent, float duration, float value1, float value2)\r\n{\r\n\tfloat t2 = t * t;\r\n\tfloat t3 = t2 * t;\r\n\tfloat a = 2.0 * t3 - 3.0 * t2 + 1.0;\r\n\tfloat b = t3 - 2.0 * t2 + t;\r\n\tfloat c = t3 - t2;\r\n\tfloat d = -2.0 * t3 + 3.0 * t2;\r\n\treturn a * value1 + b * outTangent * duration + c * inTangent * duration + d * value2;\r\n}\r\n\r\nfloat getCurWidth(in float normalizeTime)\r\n{\r\n\tfloat width;\r\n\tif(normalizeTime == 0.0){\r\n\t\twidth=u_WidthCurve[0].w;\r\n\t}\r\n\telse if(normalizeTime &gt;= 1.0){\r\n\t\twidth=u_WidthCurve[u_WidthCurveKeyLength - 1].w;\r\n\t}\r\n\telse{\r\n\t\tfor(int i = 0; i &lt; 10; i ++ )\r\n\t\t{\r\n\t\t\tif(normalizeTime == u_WidthCurve[i].x){\r\n\t\t\t\twidth=u_WidthCurve[i].w;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvec4 lastFrame = u_WidthCurve[i];\r\n\t\t\tvec4 nextFrame = u_WidthCurve[i + 1];\r\n\t\t\tif(normalizeTime &gt; lastFrame.x &amp;&amp; normalizeTime &lt; nextFrame.x)\r\n\t\t\t{\r\n\t\t\t\tfloat duration = nextFrame.x - lastFrame.x;\r\n\t\t\t\tfloat t = (normalizeTime - lastFrame.x) / duration;\r\n\t\t\t\tfloat outTangent = lastFrame.z;\r\n\t\t\t\tfloat inTangent = nextFrame.y;\r\n\t\t\t\tfloat value1 = lastFrame.w;\r\n\t\t\t\tfloat value2 = nextFrame.w;\r\n\t\t\t\twidth=hermiteInterpolate(t, outTangent, inTangent, duration, value1, value2);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn width;\r\n}\t\r\n\r\nvoid main()\r\n{\r\n\tfloat normalizeTime = (u_CurTime - a_BirthTime) / u_LifeTime;\r\n\t\r\n\t#ifdef TILINGOFFSET\r\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, 1.0 - a_Texcoord0Y) * u_TilingOffset.xy + u_TilingOffset.zw;\r\n\t#else\r\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, a_Texcoord0Y);\r\n\t#endif\r\n\t\r\n\tv_Color = a_Color;\r\n\t\r\n\tgl_Position = u_Projection * u_View * vec4(a_Position + a_OffsetVector * getCurWidth(normalizeTime),1.0);\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}\r\n',
        mn = "#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#if defined(COLOR)&amp;&amp;defined(ENABLEVERTEXCOLOR)\r\n\tvarying vec4 v_Color;\r\n#endif\r\n\r\n#ifdef ALBEDOTEXTURE\r\n\tuniform sampler2D u_AlbedoTexture;\r\n\tvarying vec2 v_Texcoord0;\r\n#endif\r\n\r\nuniform vec4 u_AlbedoColor;\r\n\r\n#ifdef ALPHATEST\r\n\tuniform float u_AlphaTestValue;\r\n#endif\r\n\r\n#ifdef FOG\r\n\tuniform float u_FogStart;\r\n\tuniform float u_FogRange;\r\n\t#ifdef ADDTIVEFOG\r\n\t#else\r\n\t\tuniform vec3 u_FogColor;\r\n\t#endif\r\n#endif\r\n\r\nvoid main()\r\n{\r\n\tvec4 color =  u_AlbedoColor;\r\n\t#ifdef ALBEDOTEXTURE\r\n\t\tcolor *= texture2D(u_AlbedoTexture, v_Texcoord0);\r\n\t#endif\r\n\t#if defined(COLOR)&amp;&amp;defined(ENABLEVERTEXCOLOR)\r\n\t\tcolor *= v_Color;\r\n\t#endif\r\n\t\r\n\t#ifdef ALPHATEST\r\n\t\tif(color.a &lt; u_AlphaTestValue)\r\n\t\t\tdiscard;\r\n\t#endif\r\n\t\r\n\tgl_FragColor = color;\r\n\t\r\n\t#ifdef FOG\r\n\t\tfloat lerpFact = clamp((1.0 / gl_FragCoord.w - u_FogStart) / u_FogRange, 0.0, 1.0);\r\n\t\t#ifdef ADDTIVEFOG\r\n\t\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.0), lerpFact);\r\n\t\t#else\r\n\t\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, u_FogColor, lerpFact);\r\n\t\t#endif\r\n\t#endif\r\n\t\r\n}\r\n\r\n",
        fn = '#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\n\r\nattribute vec2 a_Texcoord0;\r\n\r\n#ifdef GPU_INSTANCE\r\n\tattribute mat4 a_MvpMatrix;\r\n#else\r\n\tuniform mat4 u_MvpMatrix;\r\n#endif\r\n\r\nattribute vec4 a_Color;\r\nvarying vec4 v_Color;\r\nvarying vec2 v_Texcoord0;\r\n\r\n#ifdef TILINGOFFSET\r\n\tuniform vec4 u_TilingOffset;\r\n#endif\r\n\r\n#ifdef BONE\r\n\tconst int c_MaxBoneCount = 24;\r\n\tattribute vec4 a_BoneIndices;\r\n\tattribute vec4 a_BoneWeights;\r\n\tuniform mat4 u_Bones[c_MaxBoneCount];\r\n#endif\r\n\r\nvoid main() {\r\n\tvec4 position;\r\n\t#ifdef BONE\r\n\t\tmat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\r\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\r\n\t\tposition=skinTransform*a_Position;\r\n\t#else\r\n\t\tposition=a_Position;\r\n\t#endif\r\n\t#ifdef GPU_INSTANCE\r\n\t\tgl_Position = a_MvpMatrix * position;\r\n\t#else\r\n\t\tgl_Position = u_MvpMatrix * position;\r\n\t#endif\r\n\r\n\t#ifdef TILINGOFFSET\r\n\t\tv_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\r\n\t#else\r\n\t\tv_Texcoord0=a_Texcoord0;\r\n\t#endif\r\n\r\n\t#if defined(COLOR)&amp;&amp;defined(ENABLEVERTEXCOLOR)\r\n\t\tv_Color = a_Color;\r\n\t#endif\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}',
        Tn = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#ifdef MAINTEXTURE\r\n\tuniform sampler2D u_MainTexture;\r\n#endif\r\n\r\n#ifdef NORMALTEXTURE\r\n\tuniform sampler2D u_NormalTexture;\r\n#endif\r\n\r\nuniform vec4 u_HorizonColor;\r\n\r\nvarying vec3 v_Normal;\r\nvarying vec3 v_Tangent;\r\nvarying vec3 v_Binormal;\r\nvarying vec3 v_ViewDir;\r\nvarying vec2 v_Texcoord0;\r\nvarying vec2 v_Texcoord1;\r\n\r\n\r\n#include "Lighting.glsl"\r\n\r\n\r\n\r\nvec3 NormalSampleToWorldSpace(vec4 normalMapSample) {\r\n\tvec3 normalT;\r\n\tnormalT.x = 2.0 * normalMapSample.x - 1.0;\r\n\tnormalT.y = 1.0 - 2.0 * normalMapSample.y;\r\n\tnormalT.z = sqrt(1.0 - clamp(dot(normalT.xy, normalT.xy), 0.0, 1.0));\r\n\r\n\tvec3 bumpedNormal = normalize(normalT);\r\n\r\n\treturn bumpedNormal;\r\n}\r\n\r\n\r\nvoid main()\r\n{\r\n\tvec4 bumpColor1 = texture2D(u_NormalTexture, v_Texcoord0);\r\n\tvec4 bumpColor2 = texture2D(u_NormalTexture, v_Texcoord1);\r\n\r\n\tvec3 normal1 = NormalSampleToWorldSpace(bumpColor1);\r\n\tvec3 normal2 = NormalSampleToWorldSpace(bumpColor2);\r\n\t\r\n\tvec3 normal = normalize((normal1 + normal2) * 0.5);\r\n\tvec3 viewDir = normalize(v_ViewDir);\r\n\tfloat fresnel = dot(viewDir, normal);\r\n\t\r\n\tvec4 waterColor = texture2D(u_MainTexture, vec2(fresnel, fresnel));\r\n\t\r\n\tvec4 color;\r\n\tcolor.rgb = mix(waterColor.rgb, u_HorizonColor.rgb, vec3(waterColor.a));\r\n\tcolor.a = u_HorizonColor.a;\r\n\t\r\n\tgl_FragColor = color;\r\n}\r\n\r\n\r\n',
        En = '#include "Lighting.glsl";\r\n\r\nattribute vec4 a_Position;\r\nattribute vec3 a_Normal;\r\nattribute vec4 a_Tangent0;\r\n\r\nuniform mat4 u_MvpMatrix;\r\nuniform mat4 u_WorldMat;\r\nuniform vec3 u_CameraPos;\r\nuniform float u_WaveScale;\r\nuniform vec4 u_WaveSpeed;\r\nuniform float u_Time;\r\n\r\nvarying vec3 v_Normal;\r\nvarying vec3 v_Tangent;\r\nvarying vec3 v_Binormal;\r\nvarying vec3 v_ViewDir;\r\nvarying vec2 v_Texcoord0;\r\nvarying vec2 v_Texcoord1;\r\n\r\nvoid main()\r\n{\r\n\tvec4 positionWorld = u_WorldMat * a_Position;\r\n\tvec4 position = u_MvpMatrix * a_Position;\r\n\t\r\n\tvec4 temp = vec4(positionWorld.x, positionWorld.z, positionWorld.x, positionWorld.z) * u_WaveScale + u_WaveSpeed * u_WaveScale * u_Time;\r\n\t\r\n\tv_Texcoord0 = temp.xy * vec2(0.4, 0.45);\r\n\tv_Texcoord1 = temp.wz;\r\n\t\r\n\tmat3 worldMat = mat3(u_WorldMat);\r\n\tv_Normal = worldMat * a_Normal;\r\n\tv_Tangent = worldMat * a_Tangent0.xyz;\r\n\tv_Binormal = cross(v_Normal, v_Tangent) * a_Tangent0.w;\r\n\t\r\n\tv_ViewDir = u_CameraPos - positionWorld.xyz;\r\n\tgl_Position = position;\r\n\tgl_Position=remapGLPositionZ(gl_Position);\r\n}';
    class pn {
        constructor() {}
        static __init__() {
            he.SHADERDEFINE_LEGACYSINGALLIGHTING = he.getDefineByName("LEGACYSINGLELIGHTING"), he.SHADERDEFINE_GRAPHICS_API_GLES2 = he.getDefineByName("GRAPHICS_API_GLES2"), he.SHADERDEFINE_GRAPHICS_API_GLES3 = he.getDefineByName("GRAPHICS_API_GLES3"), he.addInclude("Lighting.glsl", Oi), he.addInclude("ShadowSampleTent.glsl", Ni), he.addInclude("GlobalIllumination.glsl", Mi), he.addInclude("Shadow.glsl", an), he.addInclude("ShadowCasterVS.glsl", sn), he.addInclude("ShadowCasterFS.glsl", on), he.addInclude("Colors.glsl", $i), he.addInclude("Sampling.glsl", rn), he.addInclude("StdLib.glsl", nn), he.addInclude("PBRVSInput.glsl", Wi), he.addInclude("PBRFSInput.glsl", ki), he.addInclude("LayaPBRBRDF.glsl", zi), he.addInclude("PBRCore.glsl", Hi), he.addInclude("PBRVertex.glsl", Xi);
            var e = {
                    a_Position: lt.MESH_POSITION0,
                    a_Color: lt.MESH_COLOR0,
                    a_Normal: lt.MESH_NORMAL0,
                    a_Texcoord0: lt.MESH_TEXTURECOORDINATE0,
                    a_Texcoord1: lt.MESH_TEXTURECOORDINATE1,
                    a_BoneWeights: lt.MESH_BLENDWEIGHT0,
                    a_BoneIndices: lt.MESH_BLENDINDICES0,
                    a_Tangent0: lt.MESH_TANGENT0,
                    a_MvpMatrix: lt.MESH_MVPMATRIX_ROW0,
                    a_WorldMat: lt.MESH_WORLDMATRIX_ROW0
                },
                t = {
                    u_Bones: he.PERIOD_CUSTOM,
                    u_DiffuseTexture: he.PERIOD_MATERIAL,
                    u_SpecularTexture: he.PERIOD_MATERIAL,
                    u_NormalTexture: he.PERIOD_MATERIAL,
                    u_AlphaTestValue: he.PERIOD_MATERIAL,
                    u_DiffuseColor: he.PERIOD_MATERIAL,
                    u_MaterialSpecular: he.PERIOD_MATERIAL,
                    u_Shininess: he.PERIOD_MATERIAL,
                    u_TilingOffset: he.PERIOD_MATERIAL,
                    u_WorldMat: he.PERIOD_SPRITE,
                    u_MvpMatrix: he.PERIOD_SPRITE,
                    u_LightmapScaleOffset: he.PERIOD_SPRITE,
                    u_LightMap: he.PERIOD_SPRITE,
                    u_LightMapDirection: he.PERIOD_SPRITE,
                    u_CameraPos: he.PERIOD_CAMERA,
                    u_Viewport: he.PERIOD_CAMERA,
                    u_ProjectionParams: he.PERIOD_CAMERA,
                    u_View: he.PERIOD_CAMERA,
                    u_ViewProjection: he.PERIOD_CAMERA,
                    u_ReflectTexture: he.PERIOD_SCENE,
                    u_ReflectIntensity: he.PERIOD_SCENE,
                    u_FogStart: he.PERIOD_SCENE,
                    u_FogRange: he.PERIOD_SCENE,
                    u_FogColor: he.PERIOD_SCENE,
                    u_DirationLightCount: he.PERIOD_SCENE,
                    u_LightBuffer: he.PERIOD_SCENE,
                    u_LightClusterBuffer: he.PERIOD_SCENE,
                    u_AmbientColor: he.PERIOD_SCENE,
                    u_ShadowBias: he.PERIOD_SCENE,
                    u_ShadowLightDirection: he.PERIOD_SCENE,
                    u_ShadowMap: he.PERIOD_SCENE,
                    u_ShadowParams: he.PERIOD_SCENE,
                    u_ShadowSplitSpheres: he.PERIOD_SCENE,
                    u_ShadowMatrices: he.PERIOD_SCENE,
                    u_ShadowMapSize: he.PERIOD_SCENE,
                    u_SpotShadowMap: he.PERIOD_SCENE,
                    u_SpotViewProjectMatrix: he.PERIOD_SCENE,
                    u_ShadowLightPosition: he.PERIOD_SCENE,
                    u_AmbientSHAr: he.PERIOD_SCENE,
                    u_AmbientSHAg: he.PERIOD_SCENE,
                    u_AmbientSHAb: he.PERIOD_SCENE,
                    u_AmbientSHBr: he.PERIOD_SCENE,
                    u_AmbientSHBg: he.PERIOD_SCENE,
                    u_AmbientSHBb: he.PERIOD_SCENE,
                    u_AmbientSHC: he.PERIOD_SCENE,
                    "u_DirectionLight.color": he.PERIOD_SCENE,
                    "u_DirectionLight.direction": he.PERIOD_SCENE,
                    "u_PointLight.position": he.PERIOD_SCENE,
                    "u_PointLight.range": he.PERIOD_SCENE,
                    "u_PointLight.color": he.PERIOD_SCENE,
                    "u_SpotLight.position": he.PERIOD_SCENE,
                    "u_SpotLight.direction": he.PERIOD_SCENE,
                    "u_SpotLight.range": he.PERIOD_SCENE,
                    "u_SpotLight.spot": he.PERIOD_SCENE,
                    "u_SpotLight.color": he.PERIOD_SCENE
                },
                r = {
                    s_Cull: he.RENDER_STATE_CULL,
                    s_Blend: he.RENDER_STATE_BLEND,
                    s_BlendSrc: he.RENDER_STATE_BLEND_SRC,
                    s_BlendDst: he.RENDER_STATE_BLEND_DST,
                    s_DepthTest: he.RENDER_STATE_DEPTH_TEST,
                    s_DepthWrite: he.RENDER_STATE_DEPTH_WRITE
                },
                i = he.add("BLINNPHONG", null, null, !0),
                n = new lr(e, t);
            i.addSubShader(n), n.addShaderPass(Vi, wi, r, "Forward");
            n.addShaderPass(Fi, Bi, r, "ShadowCaster");
            e = {
                a_Position: lt.MESH_POSITION0,
                a_Color: lt.MESH_COLOR0
            }, t = {
                u_MvpMatrix: he.PERIOD_SPRITE,
                u_Color: he.PERIOD_MATERIAL
            }, r = {
                s_Cull: he.RENDER_STATE_CULL,
                s_Blend: he.RENDER_STATE_BLEND,
                s_BlendSrc: he.RENDER_STATE_BLEND_SRC,
                s_BlendDst: he.RENDER_STATE_BLEND_DST,
                s_DepthTest: he.RENDER_STATE_DEPTH_TEST,
                s_DepthWrite: he.RENDER_STATE_DEPTH_WRITE
            }, i = he.add("LineShader"), n = new lr(e, t), i.addSubShader(n), n.addShaderPass(Pi, bi, r), e = {
                a_Position: lt.MESH_POSITION0,
                a_Color: lt.MESH_COLOR0,
                a_Texcoord0: lt.MESH_TEXTURECOORDINATE0,
                a_BoneWeights: lt.MESH_BLENDWEIGHT0,
                a_BoneIndices: lt.MESH_BLENDINDICES0,
                a_MvpMatrix: lt.MESH_MVPMATRIX_ROW0
            }, t = {
                u_Bones: he.PERIOD_CUSTOM,
                u_AlbedoTexture: he.PERIOD_MATERIAL,
                u_AlbedoColor: he.PERIOD_MATERIAL,
                u_TilingOffset: he.PERIOD_MATERIAL,
                u_AlphaTestValue: he.PERIOD_MATERIAL,
                u_MvpMatrix: he.PERIOD_SPRITE,
                u_FogStart: he.PERIOD_SCENE,
                u_FogRange: he.PERIOD_SCENE,
                u_FogColor: he.PERIOD_SCENE
            }, r = {
                s_Cull: he.RENDER_STATE_CULL,
                s_Blend: he.RENDER_STATE_BLEND,
                s_BlendSrc: he.RENDER_STATE_BLEND_SRC,
                s_BlendDst: he.RENDER_STATE_BLEND_DST,
                s_DepthTest: he.RENDER_STATE_DEPTH_TEST,
                s_DepthWrite: he.RENDER_STATE_DEPTH_WRITE
            }, i = he.add("Unlit", null, null, !0), n = new lr(e, t), i.addSubShader(n), n.addShaderPass(fn, mn, r), e = {
                a_Position: lt.MESH_POSITION0,
                a_Texcoord0: lt.MESH_TEXTURECOORDINATE0,
                a_BoneWeights: lt.MESH_BLENDWEIGHT0,
                a_BoneIndices: lt.MESH_BLENDINDICES0,
                a_MvpMatrix: lt.MESH_MVPMATRIX_ROW0
            }, t = {
                u_Bones: he.PERIOD_CUSTOM,
                u_AlbedoTexture: he.PERIOD_MATERIAL,
                u_AlbedoColor: he.PERIOD_MATERIAL,
                u_TilingOffset: he.PERIOD_MATERIAL,
                u_AlphaTestValue: he.PERIOD_MATERIAL,
                u_MvpMatrix: he.PERIOD_SPRITE,
                u_FogStart: he.PERIOD_SCENE,
                u_FogRange: he.PERIOD_SCENE,
                u_FogColor: he.PERIOD_SCENE
            }, r = {
                s_Cull: he.RENDER_STATE_CULL,
                s_Blend: he.RENDER_STATE_BLEND,
                s_BlendSrc: he.RENDER_STATE_BLEND_SRC,
                s_BlendDst: he.RENDER_STATE_BLEND_DST,
                s_DepthTest: he.RENDER_STATE_DEPTH_TEST,
                s_DepthWrite: he.RENDER_STATE_DEPTH_WRITE
            }, i = he.add("Effect", null, null, !0), n = new lr(e, t), i.addSubShader(n), n.addShaderPass(Di, Li, r), e = {
                a_CornerTextureCoordinate: $r.PARTICLE_CORNERTEXTURECOORDINATE0,
                a_MeshPosition: $r.PARTICLE_POSITION0,
                a_MeshColor: $r.PARTICLE_COLOR0,
                a_MeshTextureCoordinate: $r.PARTICLE_TEXTURECOORDINATE0,
                a_ShapePositionStartLifeTime: $r.PARTICLE_SHAPEPOSITIONSTARTLIFETIME,
                a_DirectionTime: $r.PARTICLE_DIRECTIONTIME,
                a_StartColor: $r.PARTICLE_STARTCOLOR0,
                a_EndColor: $r.PARTICLE_ENDCOLOR0,
                a_StartSize: $r.PARTICLE_STARTSIZE,
                a_StartRotation0: $r.PARTICLE_STARTROTATION,
                a_StartSpeed: $r.PARTICLE_STARTSPEED,
                a_Random0: $r.PARTICLE_RANDOM0,
                a_Random1: $r.PARTICLE_RANDOM1,
                a_SimulationWorldPostion: $r.PARTICLE_SIMULATIONWORLDPOSTION,
                a_SimulationWorldRotation: $r.PARTICLE_SIMULATIONWORLDROTATION
            }, t = {
                u_Tintcolor: he.PERIOD_MATERIAL,
                u_TilingOffset: he.PERIOD_MATERIAL,
                u_texture: he.PERIOD_MATERIAL,
                u_WorldPosition: he.PERIOD_SPRITE,
                u_WorldRotation: he.PERIOD_SPRITE,
                u_PositionScale: he.PERIOD_SPRITE,
                u_SizeScale: he.PERIOD_SPRITE,
                u_ScalingMode: he.PERIOD_SPRITE,
                u_Gravity: he.PERIOD_SPRITE,
                u_ThreeDStartRotation: he.PERIOD_SPRITE,
                u_StretchedBillboardLengthScale: he.PERIOD_SPRITE,
                u_StretchedBillboardSpeedScale: he.PERIOD_SPRITE,
                u_SimulationSpace: he.PERIOD_SPRITE,
                u_CurrentTime: he.PERIOD_SPRITE,
                u_ColorOverLifeGradientAlphas: he.PERIOD_SPRITE,
                u_ColorOverLifeGradientColors: he.PERIOD_SPRITE,
                u_MaxColorOverLifeGradientAlphas: he.PERIOD_SPRITE,
                u_MaxColorOverLifeGradientColors: he.PERIOD_SPRITE,
                u_VOLVelocityConst: he.PERIOD_SPRITE,
                u_VOLVelocityGradientX: he.PERIOD_SPRITE,
                u_VOLVelocityGradientY: he.PERIOD_SPRITE,
                u_VOLVelocityGradientZ: he.PERIOD_SPRITE,
                u_VOLVelocityConstMax: he.PERIOD_SPRITE,
                u_VOLVelocityGradientMaxX: he.PERIOD_SPRITE,
                u_VOLVelocityGradientMaxY: he.PERIOD_SPRITE,
                u_VOLVelocityGradientMaxZ: he.PERIOD_SPRITE,
                u_VOLSpaceType: he.PERIOD_SPRITE,
                u_SOLSizeGradient: he.PERIOD_SPRITE,
                u_SOLSizeGradientX: he.PERIOD_SPRITE,
                u_SOLSizeGradientY: he.PERIOD_SPRITE,
                u_SOLSizeGradientZ: he.PERIOD_SPRITE,
                u_SOLSizeGradientMax: he.PERIOD_SPRITE,
                u_SOLSizeGradientMaxX: he.PERIOD_SPRITE,
                u_SOLSizeGradientMaxY: he.PERIOD_SPRITE,
                u_SOLSizeGradientMaxZ: he.PERIOD_SPRITE,
                u_ROLAngularVelocityConst: he.PERIOD_SPRITE,
                u_ROLAngularVelocityConstSeprarate: he.PERIOD_SPRITE,
                u_ROLAngularVelocityGradient: he.PERIOD_SPRITE,
                u_ROLAngularVelocityGradientX: he.PERIOD_SPRITE,
                u_ROLAngularVelocityGradientY: he.PERIOD_SPRITE,
                u_ROLAngularVelocityGradientZ: he.PERIOD_SPRITE,
                u_ROLAngularVelocityConstMax: he.PERIOD_SPRITE,
                u_ROLAngularVelocityConstMaxSeprarate: he.PERIOD_SPRITE,
                u_ROLAngularVelocityGradientMax: he.PERIOD_SPRITE,
                u_ROLAngularVelocityGradientMaxX: he.PERIOD_SPRITE,
                u_ROLAngularVelocityGradientMaxY: he.PERIOD_SPRITE,
                u_ROLAngularVelocityGradientMaxZ: he.PERIOD_SPRITE,
                u_ROLAngularVelocityGradientMaxW: he.PERIOD_SPRITE,
                u_TSACycles: he.PERIOD_SPRITE,
                u_TSASubUVLength: he.PERIOD_SPRITE,
                u_TSAGradientUVs: he.PERIOD_SPRITE,
                u_TSAMaxGradientUVs: he.PERIOD_SPRITE,
                u_CameraPos: he.PERIOD_CAMERA,
                u_CameraDirection: he.PERIOD_CAMERA,
                u_CameraUp: he.PERIOD_CAMERA,
                u_View: he.PERIOD_CAMERA,
                u_Projection: he.PERIOD_CAMERA,
                u_FogStart: he.PERIOD_SCENE,
                u_FogRange: he.PERIOD_SCENE,
                u_FogColor: he.PERIOD_SCENE
            }, r = {
                s_Cull: he.RENDER_STATE_CULL,
                s_Blend: he.RENDER_STATE_BLEND,
                s_BlendSrc: he.RENDER_STATE_BLEND_SRC,
                s_BlendDst: he.RENDER_STATE_BLEND_DST,
                s_DepthTest: he.RENDER_STATE_DEPTH_TEST,
                s_DepthWrite: he.RENDER_STATE_DEPTH_WRITE
            }, i = he.add("PARTICLESHURIKEN"), n = new lr(e, t), i.addSubShader(n), n.addShaderPass(Gi, Ui, r), e = {
                a_Position: lt.MESH_POSITION0
            }, t = {
                u_TintColor: he.PERIOD_MATERIAL,
                u_Exposure: he.PERIOD_MATERIAL,
                u_Rotation: he.PERIOD_MATERIAL,
                u_CubeTexture: he.PERIOD_MATERIAL,
                u_ViewProjection: he.PERIOD_CAMERA
            }, i = he.add("SkyBox"), n = new lr(e, t), i.addSubShader(n), n.addShaderPass(_n, ln), e = {
                a_Position: lt.MESH_POSITION0
            }, t = {
                u_SunSize: he.PERIOD_MATERIAL,
                u_SunSizeConvergence: he.PERIOD_MATERIAL,
                u_AtmosphereThickness: he.PERIOD_MATERIAL,
                u_SkyTint: he.PERIOD_MATERIAL,
                u_GroundTint: he.PERIOD_MATERIAL,
                u_Exposure: he.PERIOD_MATERIAL,
                u_ViewProjection: he.PERIOD_CAMERA,
                "u_SunLight.direction": he.PERIOD_SCENE,
                "u_SunLight.color": he.PERIOD_SCENE
            }, i = he.add("SkyBoxProcedural"), n = new lr(e, t), i.addSubShader(n), n.addShaderPass(cn, hn), e = {
                a_Position: lt.MESH_POSITION0,
                a_Normal: lt.MESH_NORMAL0,
                a_Texcoord0: lt.MESH_TEXTURECOORDINATE0
            }, t = {
                u_MvpMatrix: he.PERIOD_SPRITE,
                u_WorldMat: he.PERIOD_SPRITE,
                u_CameraPos: he.PERIOD_CAMERA,
                u_Viewport: he.PERIOD_CAMERA,
                u_ProjectionParams: he.PERIOD_CAMERA,
                u_View: he.PERIOD_CAMERA,
                u_LightmapScaleOffset: he.PERIOD_SPRITE,
                u_LightMap: he.PERIOD_SPRITE,
                u_SplatAlphaTexture: he.PERIOD_MATERIAL,
                u_DiffuseTexture1: he.PERIOD_MATERIAL,
                u_DiffuseTexture2: he.PERIOD_MATERIAL,
                u_DiffuseTexture3: he.PERIOD_MATERIAL,
                u_DiffuseTexture4: he.PERIOD_MATERIAL,
                u_DiffuseTexture5: he.PERIOD_MATERIAL,
                u_DiffuseScaleOffset1: he.PERIOD_MATERIAL,
                u_DiffuseScaleOffset2: he.PERIOD_MATERIAL,
                u_DiffuseScaleOffset3: he.PERIOD_MATERIAL,
                u_DiffuseScaleOffset4: he.PERIOD_MATERIAL,
                u_DiffuseScaleOffset5: he.PERIOD_MATERIAL,
                u_FogStart: he.PERIOD_SCENE,
                u_FogRange: he.PERIOD_SCENE,
                u_FogColor: he.PERIOD_SCENE,
                u_DirationLightCount: he.PERIOD_SCENE,
                u_LightBuffer: he.PERIOD_SCENE,
                u_LightClusterBuffer: he.PERIOD_SCENE,
                u_AmbientColor: he.PERIOD_SCENE,
                u_ShadowMap: he.PERIOD_SCENE,
                u_shadowMap2: he.PERIOD_SCENE,
                u_shadowMap3: he.PERIOD_SCENE,
                u_ShadowSplitSpheres: he.PERIOD_SCENE,
                u_ShadowMatrices: he.PERIOD_SCENE,
                u_ShadowMapSize: he.PERIOD_SCENE,
                "u_DirectionLight.color": he.PERIOD_SCENE,
                "u_DirectionLight.direction": he.PERIOD_SCENE,
                "u_PointLight.position": he.PERIOD_SCENE,
                "u_PointLight.range": he.PERIOD_SCENE,
                "u_PointLight.color": he.PERIOD_SCENE,
                "u_SpotLight.position": he.PERIOD_SCENE,
                "u_SpotLight.direction": he.PERIOD_SCENE,
                "u_SpotLight.range": he.PERIOD_SCENE,
                "u_SpotLight.spot": he.PERIOD_SCENE,
                "u_SpotLight.color": he.PERIOD_SCENE
            }, r = {
                s_Cull: he.RENDER_STATE_CULL,
                s_Blend: he.RENDER_STATE_BLEND,
                s_BlendSrc: he.RENDER_STATE_BLEND_SRC,
                s_BlendDst: he.RENDER_STATE_BLEND_DST,
                s_DepthTest: he.RENDER_STATE_DEPTH_TEST,
                s_DepthWrite: he.RENDER_STATE_DEPTH_WRITE
            }, i = he.add("ExtendTerrain"), n = new lr(e, t), i.addSubShader(n), n.addShaderPass(yi, Ci, r), e = {
                a_Position: di.TRAIL_POSITION0,
                a_OffsetVector: di.TRAIL_OFFSETVECTOR,
                a_Texcoord0X: di.TRAIL_TEXTURECOORDINATE0X,
                a_Texcoord0Y: di.TRAIL_TEXTURECOORDINATE0Y,
                a_BirthTime: di.TRAIL_TIME0,
                a_Color: di.TRAIL_COLOR
            }, t = {
                u_MvpMatrix: he.PERIOD_SPRITE,
                u_View: he.PERIOD_CAMERA,
                u_Projection: he.PERIOD_CAMERA,
                u_TilingOffset: he.PERIOD_MATERIAL,
                u_MainTexture: he.PERIOD_MATERIAL,
                u_MainColor: he.PERIOD_MATERIAL,
                u_CurTime: he.PERIOD_SPRITE,
                u_LifeTime: he.PERIOD_SPRITE,
                u_WidthCurve: he.PERIOD_SPRITE,
                u_WidthCurveKeyLength: he.PERIOD_SPRITE,
                u_GradientColorkey: he.PERIOD_SPRITE,
                u_GradientAlphakey: he.PERIOD_SPRITE
            }, r = {
                s_Cull: he.RENDER_STATE_CULL,
                s_Blend: he.RENDER_STATE_BLEND,
                s_BlendSrc: he.RENDER_STATE_BLEND_SRC,
                s_BlendDst: he.RENDER_STATE_BLEND_DST,
                s_DepthTest: he.RENDER_STATE_DEPTH_TEST,
                s_DepthWrite: he.RENDER_STATE_DEPTH_WRITE
            }, i = he.add("Trail"), n = new lr(e, t), i.addSubShader(n), n.addShaderPass(un, dn, r), e = {
                a_Position: lt.MESH_POSITION0,
                a_Normal: lt.MESH_NORMAL0,
                a_Tangent0: lt.MESH_TANGENT0
            }, t = {
                u_MvpMatrix: he.PERIOD_SPRITE,
                u_WorldMat: he.PERIOD_SPRITE,
                u_CameraPos: he.PERIOD_CAMERA,
                u_Time: he.PERIOD_SCENE,
                u_MainTexture: he.PERIOD_MATERIAL,
                u_NormalTexture: he.PERIOD_MATERIAL,
                u_HorizonColor: he.PERIOD_MATERIAL,
                u_WaveScale: he.PERIOD_MATERIAL,
                u_WaveSpeed: he.PERIOD_MATERIAL
            }, i = he.add("WaterPrimary"), n = new lr(e, t), i.addSubShader(n), n.addShaderPass(En, Tn), e = {
                a_PositionTexcoord: lt.MESH_POSITION0
            }, t = {
                u_MainTex: he.PERIOD_MATERIAL,
                u_OffsetScale: he.PERIOD_MATERIAL
            }, i = he.add("BlitScreen"), n = new lr(e, t), i.addSubShader(n);
            var a = n.addShaderPass(xi, Ii).renderState;
            a.depthTest = pe.DEPTHTEST_ALWAYS, a.depthWrite = !1, a.cull = pe.CULL_NONE, a.blend = pe.BLEND_DISABLE, e = {
                a_PositionTexcoord: lt.MESH_POSITION0
            }, t = {
                u_MainTex: he.PERIOD_MATERIAL,
                u_BloomTex: he.PERIOD_MATERIAL,
                u_AutoExposureTex: he.PERIOD_MATERIAL,
                u_MainTex_TexelSize: he.PERIOD_MATERIAL,
                u_SampleScale: he.PERIOD_MATERIAL,
                u_Threshold: he.PERIOD_MATERIAL,
                u_Params: he.PERIOD_MATERIAL
            }, i = he.add("PostProcessBloom"), n = new lr(e, t), i.addSubShader(n), (a = n.addShaderPass(Yi, qi).renderState).depthTest = pe.DEPTHTEST_ALWAYS, a.depthWrite = !1, a.cull = pe.CULL_NONE, a.blend = pe.BLEND_DISABLE, n = new lr(e, t), i.addSubShader(n), (a = n.addShaderPass(Yi, Qi).renderState).depthTest = pe.DEPTHTEST_ALWAYS, a.depthWrite = !1, a.cull = pe.CULL_NONE, a.blend = pe.BLEND_DISABLE, n = new lr(e, t), i.addSubShader(n), (a = n.addShaderPass(Yi, ji).renderState).depthTest = pe.DEPTHTEST_ALWAYS, a.depthWrite = !1, a.cull = pe.CULL_NONE, a.blend = pe.BLEND_DISABLE, n = new lr(e, t), i.addSubShader(n), (a = n.addShaderPass(Yi, Zi).renderState).depthTest = pe.DEPTHTEST_ALWAYS, a.depthWrite = !1, a.cull = pe.CULL_NONE, a.blend = pe.BLEND_DISABLE, n = new lr(e, t), i.addSubShader(n), (a = n.addShaderPass(Yi, Ji).renderState).depthTest = pe.DEPTHTEST_ALWAYS, a.depthWrite = !1, a.cull = pe.CULL_NONE, a.blend = pe.BLEND_DISABLE, n = new lr(e, t), i.addSubShader(n), (a = n.addShaderPass(Yi, Ki).renderState).depthTest = pe.DEPTHTEST_ALWAYS, a.depthWrite = !1, a.cull = pe.CULL_NONE, a.blend = pe.BLEND_DISABLE, e = {
                a_PositionTexcoord: lt.MESH_POSITION0
            }, t = {
                u_MainTex: he.PERIOD_MATERIAL,
                u_BloomTex: he.PERIOD_MATERIAL,
                u_AutoExposureTex: he.PERIOD_MATERIAL,
                u_Bloom_DirtTileOffset: he.PERIOD_MATERIAL,
                u_Bloom_DirtTex: he.PERIOD_MATERIAL,
                u_BloomTex_TexelSize: he.PERIOD_MATERIAL,
                u_Bloom_Settings: he.PERIOD_MATERIAL,
                u_Bloom_Color: he.PERIOD_MATERIAL
            }, i = he.add("PostProcessComposite"), n = new lr(e, t), i.addSubShader(n), (a = n.addShaderPass(tn, en).renderState).depthTest = pe.DEPTHTEST_ALWAYS, a.depthWrite = !1, a.cull = pe.CULL_NONE, a.blend = pe.BLEND_DISABLE
        }
    }
    class gn extends At {
        constructor() {
            super(), this._direction = new a, this._shadowCascadesMode = e.ShadowCascadesMode.NoCascades, this._shadowTwoCascadeSplits = 1 / 3, this._shadowFourCascadeSplits = new a(1 / 15, .2, 7 / 15), this._lightType = e.LightType.Directional
        }
        get shadowCascadesMode() {
            return this._shadowCascadesMode
        }
        set shadowCascadesMode(e) {
            this._shadowCascadesMode = e
        }
        get shadowTwoCascadeSplits() {
            return this._shadowTwoCascadeSplits
        }
        set shadowTwoCascadeSplits(e) {
            this._shadowTwoCascadeSplits = e
        }
        get shadowFourCascadeSplits() {
            return this._shadowFourCascadeSplits
        }
        set shadowFourCascadeSplits(e) {
            if (e.x &gt; e.y || e.y &gt; e.z || e.z &gt; 1) throw "DiretionLight:Invalid value.";
            e.cloneTo(this._shadowFourCascadeSplits)
        }
        _addToLightQueue() {
            this._scene._directionLights.add(this)
        }
        _removeFromLightQueue() {
            this._scene._directionLights.remove(this)
        }
    }
    class Sn extends At {
        constructor() {
            super(), this._range = 6, this._lightType = e.LightType.Point
        }
        get range() {
            return this._range
        }
        set range(e) {
            this._range = e
        }
        _addToLightQueue() {
            this._scene._pointLights.add(this)
        }
        _removeFromLightQueue() {
            this._scene._pointLights.remove(this)
        }
        _parse(e, t) {
            super._parse(e, t), this.range = e.range
        }
    }
    class Rn extends At {
        constructor() {
            super(), this._spotAngle = 30, this._range = 10, this._direction = new a, this._lightType = e.LightType.Spot
        }
        get spotAngle() {
            return this._spotAngle
        }
        set spotAngle(e) {
            this._spotAngle = Math.max(Math.min(e, 179), 0)
        }
        get range() {
            return this._range
        }
        set range(e) {
            this._range = e
        }
        _addToLightQueue() {
            this._scene._spotLights.add(this)
        }
        _removeFromLightQueue() {
            this._scene._spotLights.remove(this)
        }
        _parse(e, t) {
            super._parse(e, t), this.range = e.range, this.spotAngle = e.spotAngle
        }
    }
    class vn {
        static _createSprite3DInstance(e, t, r) {
            var i;
            switch (e.type) {
                case "Scene3D":
                    i = new sr;
                    break;
                case "Sprite3D":
                    i = new ut;
                    break;
                case "MeshSprite3D":
                    i = new Lr, r &amp;&amp; e.props.isStatic &amp;&amp; r.push(i);
                    break;
                case "SkinnedMeshSprite3D":
                    i = new _i;
                    break;
                case "ShuriKenParticle3D":
                    i = new si;
                    break;
                case "Camera":
                    i = new xt;
                    break;
                case "DirectionLight":
                    i = new gn;
                    break;
                case "PointLight":
                    i = new Sn;
                    break;
                case "SpotLight":
                    i = new Rn;
                    break;
                case "TrailSprite3D":
                    i = new Ti;
                    break;
                default:
                    throw new Error("Utils3D:unidentified class type in (.lh) file.")
            }
            var n = e.child;
            if (n)
                for (var a = 0, s = n.length; a &lt; s; a++) {
                    var o = vn._createSprite3DInstance(n[a], t, r);
                    i.addChild(o)
                }
            return t[e.instanceID] = i, i
        }
        static _createComponentInstance(e, r, i) {
            var n = r[e.instanceID];
            n._parse(e.props, r);
            var a = e.child;
            if (a)
                for (var s = 0, o = a.length; s &lt; o; s++) vn._createComponentInstance(a[s], r, i);
            var l = e.components;
            if (l)
                for (var _ = 0, h = l.length; _ &lt; h; _++) {
                    var c = l[_],
                        d = t.ClassUtils.getRegClass(c.type);
                    if (d) n.addComponent(d)._parse(c, i);
                    else console.warn("Unkown component type.")
                }
        }
        static _createNodeByJson02(e, t) {
            var r = {},
                i = {
                    component: [],
                    data: []
                },
                n = vn._createSprite3DInstance(e, r, t);
            return vn._createComponentInstance(e, r, i), vn._createInteractInstance(i, r), n
        }
        static _createInteractInstance(e, t) {
            for (var r = e.component, i = e.data, n = 0, a = r.length; n &lt; a; n++) r[n]._parseInteractive(i[n], t)
        }
        static _parse(e, t = null, r = null) {
            var i, n = e.data,
                a = [];
            switch (e.version) {
                case "LAYAHIERARCHY:02":
                    i = vn._createNodeByJson02(n, a);
                    break;
                default:
                    i = vn._createNodeByJson(n, a)
            }
            return kt.combine(i, a), i
        }
        static _parseScene(e, t = null, r = null) {
            var i, n = e.data,
                a = [];
            switch (e.version) {
                case "LAYASCENE3D:02":
                    i = vn._createNodeByJson02(n, a);
                    break;
                default:
                    i = vn._createNodeByJson(n, a)
            }
            return kt.combine(null, a), i
        }
        static _createNodeByJson(e, r) {
            var i;
            switch (e.type) {
                case "Scene3D":
                    i = new sr;
                    break;
                case "Sprite3D":
                    i = new ut;
                    break;
                case "MeshSprite3D":
                    i = new Lr, r &amp;&amp; e.props.isStatic &amp;&amp; r.push(i);
                    break;
                case "SkinnedMeshSprite3D":
                    i = new _i;
                    break;
                case "ShuriKenParticle3D":
                    i = new si;
                    break;
                case "Camera":
                    i = new xt;
                    break;
                case "DirectionLight":
                    i = new gn;
                    break;
                case "PointLight":
                    i = new Sn;
                    break;
                case "SpotLight":
                    i = new Rn;
                    break;
                case "TrailSprite3D":
                    i = new Ti;
                    break;
                default:
                    throw new Error("Utils3D:unidentified class type in (.lh) file.")
            }
            var n = e.child;
            if (n)
                for (var a = 0, s = n.length; a &lt; s; a++) {
                    var o = vn._createNodeByJson(n[a], r);
                    i.addChild(o)
                }
            var l = e.components;
            if (l)
                for (var _ = 0, h = l.length; _ &lt; h; _++) {
                    var c = l[_],
                        d = t.ClassUtils.getRegClass(c.type);
                    if (d) i.addComponent(d)._parse(c);
                    else console.warn("Unkown component type.")
                }
            return i._parse(e.props, null), i
        }
    }
    class An {
        static parse(e, t, r, i) {
            An._mesh = r, An._subMeshes = i, An._version = t, An._readData = e, An.READ_DATA(), An.READ_BLOCK(), An.READ_STRINGS();
            for (var n = 0, a = An._BLOCK.count; n &lt; a; n++) {
                An._readData.pos = An._BLOCK.blockStarts[n];
                var s = An._readData.getUint16(),
                    o = An._strings[s],
                    l = An["READ_" + o];
                if (null == l) throw new Error("model file err,no this function:" + s + " " + o);
                l.call(null)
            }
            An._strings.length = 0, An._readData = null, An._version = null, An._mesh = null, An._subMeshes = null
        }
        static _readString() {
            return An._strings[An._readData.getUint16()]
        }
        static READ_DATA() {
            An._DATA.offset = An._readData.getUint32(), An._DATA.size = An._readData.getUint32()
        }
        static READ_BLOCK() {
            for (var e = An._BLOCK.count = An._readData.getUint16(), t = An._BLOCK.blockStarts = [], r = An._BLOCK.blockLengths = [], i = 0; i &lt; e; i++) t.push(An._readData.getUint32()), r.push(An._readData.getUint32())
        }
        static READ_STRINGS() {
            var e = An._readData.getUint32(),
                t = An._readData.getUint16(),
                r = An._readData.pos;
            An._readData.pos = e + An._DATA.offset;
            for (var i = 0; i &lt; t; i++) An._strings[i] = An._readData.readUTFString();
            An._readData.pos = r
        }
        static READ_MESH() {
            var r, i = t.LayaGL.instance,
                n = (An._readString(), An._readData.__getBuffer()),
                a = 0,
                s = An._readData.getInt16(),
                o = An._DATA.offset;
            for (r = 0; r &lt; s; r++) {
                var l, _ = o + An._readData.getUint32(),
                    h = An._readData.getUint32(),
                    d = n.slice(_, _ + h),
                    u = new Float32Array(d),
                    m = An._readString();
                switch (An._version) {
                    case "LAYAMODEL:0301":
                    case "LAYAMODEL:0400":
                        l = lt.getVertexDeclaration(m);
                        break;
                    case "LAYAMODEL:0401":
                        l = lt.getVertexDeclaration(m, !1);
                        break;
                    default:
                        throw new Error("LoadModelV03: unknown version.")
                }
                if (!l) throw new Error("LoadModelV03: unknown vertexDeclaration.");
                var f = new _t(4 * u.length, i.STATIC_DRAW, !0);
                f.vertexDeclaration = l, f.setData(u.buffer), An._mesh._vertexBuffer = f, An._mesh._vertexCount += f._byteLength / l.vertexStride, a += 4 * u.length
            }
            var T = o + An._readData.getUint32(),
                E = An._readData.getUint32(),
                p = new Uint16Array(n.slice(T, T + E)),
                g = new nt(e.IndexFormat.UInt16, E / 2, i.STATIC_DRAW, !0);
            g.setData(p), An._mesh._indexBuffer = g, a += 2 * g.indexCount, An._mesh._setBuffer(An._mesh._vertexBuffer, g), An._mesh._setCPUMemory(a), An._mesh._setGPUMemory(a);
            var S = An._mesh._boneNames = [],
                R = An._readData.getUint16();
            for (S.length = R, r = 0; r &lt; R; r++) S[r] = An._strings[An._readData.getUint16()];
            An._readData.pos += 8;
            var v = An._readData.getUint32(),
                A = An._readData.getUint32(),
                I = new Float32Array(n.slice(o + v, o + v + A)),
                x = I.length,
                L = An._mesh._inverseBindPosesBuffer = new ArrayBuffer(4 * x);
            for (An._mesh._inverseBindPoses = [], r = 0; r &lt; x; r += 16) {
                var D = new c(I[r + 0], I[r + 1], I[r + 2], I[r + 3], I[r + 4], I[r + 5], I[r + 6], I[r + 7], I[r + 8], I[r + 9], I[r + 10], I[r + 11], I[r + 12], I[r + 13], I[r + 14], I[r + 15], new Float32Array(L, 4 * r, 16));
                An._mesh._inverseBindPoses[r / 16] = D
            }
            return !0
        }
        static READ_SUBMESH() {
            var e = An._readData.__getBuffer(),
                t = new Si(An._mesh);
            An._readData.getInt16(), An._readData.getUint32(), An._readData.getUint32();
            var r = An._readData.getUint32(),
                i = An._readData.getUint32(),
                n = An._mesh._indexBuffer;
            t._indexBuffer = n, t._setIndexRange(r, i);
            var a = An._mesh._vertexBuffer;
            t._vertexBuffer = a;
            var s = An._DATA.offset,
                o = t._subIndexBufferStart,
                l = t._subIndexBufferCount,
                _ = t._boneIndicesList,
                h = An._readData.getUint16();
            o.length = h, l.length = h, _.length = h;
            var c = An._mesh._skinnedMatrixCaches,
                d = An._subMeshes.length;
            c.length = An._mesh._inverseBindPoses.length;
            for (var u = 0; u &lt; h; u++) {
                o[u] = An._readData.getUint32(), l[u] = An._readData.getUint32();
                for (var m = An._readData.getUint32(), f = An._readData.getUint32(), T = _[u] = new Uint16Array(e.slice(s + m, s + m + f)), E = T.length, p = 0; p &lt; E; p++) {
                    var g = T[p];
                    c[g] || (c[g] = new Ri(d, u, p))
                }
            }
            return An._subMeshes.push(t), !0
        }
    }
    An._BLOCK = {
        count: 0
    }, An._DATA = {
        offset: 0,
        size: 0
    }, An._strings = [];
    class In {
        static parse(e, t, r, i) {
            In._mesh = r, In._subMeshes = i, In._version = t, In._readData = e, In.READ_DATA(), In.READ_BLOCK(), In.READ_STRINGS();
            for (var n = 0, a = In._BLOCK.count; n &lt; a; n++) {
                In._readData.pos = In._BLOCK.blockStarts[n];
                var s = In._readData.getUint16(),
                    o = In._strings[s],
                    l = In["READ_" + o];
                if (null == l) throw new Error("model file err,no this function:" + s + " " + o);
                l.call(null)
            }
            In._strings.length = 0, In._readData = null, In._version = null, In._mesh = null, In._subMeshes = null
        }
        static _readString() {
            return In._strings[In._readData.getUint16()]
        }
        static READ_DATA() {
            In._DATA.offset = In._readData.getUint32(), In._DATA.size = In._readData.getUint32()
        }
        static READ_BLOCK() {
            for (var e = In._BLOCK.count = In._readData.getUint16(), t = In._BLOCK.blockStarts = [], r = In._BLOCK.blockLengths = [], i = 0; i &lt; e; i++) t.push(In._readData.getUint32()), r.push(In._readData.getUint32())
        }
        static READ_STRINGS() {
            var e = In._readData.getUint32(),
                t = In._readData.getUint16(),
                r = In._readData.pos;
            In._readData.pos = e + In._DATA.offset;
            for (var i = 0; i &lt; t; i++) In._strings[i] = In._readData.readUTFString();
            In._readData.pos = r
        }
        static READ_MESH() {
            var r, i = t.LayaGL.instance,
                n = 0,
                a = (In._readString(), In._readData),
                s = a.__getBuffer(),
                o = a.getInt16(),
                l = In._DATA.offset;
            for (r = 0; r &lt; o; r++) {
                var _, h, d, u = l + a.getUint32(),
                    m = a.getUint32(),
                    f = In._readString(),
                    T = lt.getVertexDeclaration(f, !1),
                    E = T.vertexStride,
                    p = f.split(","),
                    g = p.length,
                    S = In._mesh;
                switch (In._version) {
                    case "LAYAMODEL:05":
                    case "LAYAMODEL:0501":
                        _ = s.slice(u, u + m * E), h = new Float32Array(_), d = new Uint8Array(_);
                        break;
                    case "LAYAMODEL:COMPRESSION_05":
                    case "LAYAMODEL:COMPRESSION_0501":
                        _ = new ArrayBuffer(E * m), h = new Float32Array(_), d = new Uint8Array(_);
                        var R = a.pos;
                        a.pos = u;
                        for (var v = 0; v &lt; m; v++)
                            for (var A, I = v * E, x = 0; x &lt; g; x++) switch (p[x]) {
                                case "POSITION":
                                    h[A = I / 4] = X.convertToNumber(a.getUint16()), h[A + 1] = X.convertToNumber(a.getUint16()), h[A + 2] = X.convertToNumber(a.getUint16()), I += 12;
                                    break;
                                case "NORMAL":
                                    h[A = I / 4] = a.getUint8() / 127.5 - 1, h[A + 1] = a.getUint8() / 127.5 - 1, h[A + 2] = a.getUint8() / 127.5 - 1, I += 12;
                                    break;
                                case "COLOR":
                                    h[A = I / 4] = a.getUint8() / 255, h[A + 1] = a.getUint8() / 255, h[A + 2] = a.getUint8() / 255, h[A + 3] = a.getUint8() / 255, I += 16;
                                    break;
                                case "UV":
                                case "UV1":
                                    h[A = I / 4] = X.convertToNumber(a.getUint16()), h[A + 1] = X.convertToNumber(a.getUint16()), I += 8;
                                    break;
                                case "BLENDWEIGHT":
                                    h[A = I / 4] = a.getUint8() / 255, h[A + 1] = a.getUint8() / 255, h[A + 2] = a.getUint8() / 255, h[A + 3] = a.getUint8() / 255, I += 16;
                                    break;
                                case "BLENDINDICES":
                                    d[I] = a.getUint8(), d[I + 1] = a.getUint8(), d[I + 2] = a.getUint8(), d[I + 3] = a.getUint8(), I += 4;
                                    break;
                                case "TANGENT":
                                    h[A = I / 4] = a.getUint8() / 127.5 - 1, h[A + 1] = a.getUint8() / 127.5 - 1, h[A + 2] = a.getUint8() / 127.5 - 1, h[A + 3] = a.getUint8() / 127.5 - 1, I += 16
                            }
                        a.pos = R
                }
                var L = new _t(_.byteLength, i.STATIC_DRAW, !0);
                L.vertexDeclaration = T, L.setData(_);
                m = L._byteLength / T.vertexStride;
                S._indexFormat = m &gt; 65535 ? e.IndexFormat.UInt32 : e.IndexFormat.UInt16, S._vertexBuffer = L, S._vertexCount += m, n += 4 * h.length
            }
            var D, C = l + a.getUint32(),
                y = a.getUint32();
            D = S.indexFormat == e.IndexFormat.UInt32 ? new Uint32Array(s.slice(C, C + y)) : new Uint16Array(s.slice(C, C + y));
            var M = new nt(S.indexFormat, D.length, i.STATIC_DRAW, !0);
            if (M.setData(D), S._indexBuffer = M, S._setBuffer(S._vertexBuffer, M), n += 2 * M.indexCount, S._setCPUMemory(n), S._setGPUMemory(n), "LAYAMODEL:0501" == In._version || "LAYAMODEL:COMPRESSION_0501" == In._version) {
                var O = S.bounds,
                    N = O.getMin(),
                    b = O.getMax();
                N.setValue(a.getFloat32(), a.getFloat32(), a.getFloat32()), b.setValue(a.getFloat32(), a.getFloat32(), a.getFloat32()), O.setMin(N), O.setMax(b), S.bounds = O
            }
            var P = S._boneNames = [],
                w = a.getUint16();
            for (P.length = w, r = 0; r &lt; w; r++) P[r] = In._strings[a.getUint16()];
            var V = a.getUint32(),
                B = a.getUint32(),
                F = new Float32Array(s.slice(l + V, l + V + B)),
                U = F.length,
                G = S._inverseBindPosesBuffer = new ArrayBuffer(4 * U);
            for (S._inverseBindPoses = [], r = 0; r &lt; U; r += 16) {
                var z = new c(F[r + 0], F[r + 1], F[r + 2], F[r + 3], F[r + 4], F[r + 5], F[r + 6], F[r + 7], F[r + 8], F[r + 9], F[r + 10], F[r + 11], F[r + 12], F[r + 13], F[r + 14], F[r + 15], new Float32Array(G, 4 * r, 16));
                S._inverseBindPoses[r / 16] = z
            }
            return !0
        }
        static READ_SUBMESH() {
            var e = In._readData,
                t = e.__getBuffer(),
                r = new Si(In._mesh);
            e.getInt16();
            var i = e.getUint32(),
                n = e.getUint32(),
                a = In._mesh._indexBuffer;
            r._indexBuffer = a, r._setIndexRange(i, n);
            var s = In._mesh._vertexBuffer;
            r._vertexBuffer = s;
            var o = In._DATA.offset,
                l = r._subIndexBufferStart,
                _ = r._subIndexBufferCount,
                h = r._boneIndicesList,
                c = e.getUint16();
            l.length = c, _.length = c, h.length = c;
            var d = In._mesh._skinnedMatrixCaches,
                u = In._subMeshes.length;
            d.length = In._mesh._inverseBindPoses.length;
            for (var m = 0; m &lt; c; m++) {
                l[m] = e.getUint32(), _[m] = e.getUint32();
                for (var f = e.getUint32(), T = e.getUint32(), E = h[m] = new Uint16Array(t.slice(o + f, o + f + T)), p = 0, g = E.length; p &lt; g; p++) {
                    var S = E[p];
                    d[S] || (d[S] = new Ri(u, m, p))
                }
            }
            return In._subMeshes.push(r), !0
        }
    }
    In._BLOCK = {
        count: 0
    }, In._DATA = {
        offset: 0,
        size: 0
    }, In._strings = [];
    class xn {
        static _parse(e, t = null, r = null) {
            var i = new vi;
            return xn.read(e, i, i._subMeshes), i
        }
        static read(e, r, i) {
            var n = new t.Byte(e);
            n.pos = 0;
            var a = n.readUTFString();
            switch (a) {
                case "LAYAMODEL:0301":
                case "LAYAMODEL:0400":
                case "LAYAMODEL:0401":
                    An.parse(n, a, r, i);
                    break;
                case "LAYAMODEL:05":
                case "LAYAMODEL:COMPRESSION_05":
                case "LAYAMODEL:0501":
                case "LAYAMODEL:COMPRESSION_0501":
                    In.parse(n, a, r, i);
                    break;
                default:
                    throw new Error("MeshReader: unknown mesh version.")
            }
            r._setSubMeshes(i), "LAYAMODEL:0501" != a &amp;&amp; "LAYAMODEL:COMPRESSION_0501" != a &amp;&amp; r.calculateBounds()
        }
    }
    var Ln = '#ifdef GL_FRAGMENT_PRECISION_HIGH\r\n\tprecision highp float;\r\n#else\r\n\tprecision mediump float;\r\n#endif\r\n\r\n#define PI 3.14159265359\r\n#include "Lighting.glsl";\r\n\r\nuniform sampler2D u_Texture;\r\nuniform vec4 u_TextureHDRParams;\r\nuniform vec4 u_TintColor;\r\n\r\nvarying vec3 v_Texcoord;\r\nvarying vec2 v_Image180ScaleAndCutoff;\r\nvarying vec4 v_Layout3DScaleAndOffset;\r\n\r\nvec2 ToRadialCoords(vec3 coords)\r\n{\r\n\tvec3 normalizedCoords = normalize(coords);\r\n\tfloat latitude = acos(normalizedCoords.y);\r\n\tfloat longitude = atan(normalizedCoords.z,normalizedCoords.x);\r\n\tvec2 sphereCoords = vec2(longitude, latitude) * vec2(0.5/PI, 1.0/PI);\r\n\treturn vec2(0.5,1.0) - sphereCoords;\r\n}\r\n\r\n\r\nvoid main()\r\n{\t\r\n\tvec2 tc = ToRadialCoords(v_Texcoord);\r\n\tif (tc.x &gt; v_Image180ScaleAndCutoff.y)\r\n\t\tgl_FragColor=vec4(0,0,0,1);\r\n\ttc.x = mod(tc.x*v_Image180ScaleAndCutoff.x, 1.0);\r\n\ttc = (tc + v_Layout3DScaleAndOffset.xy) * v_Layout3DScaleAndOffset.zw;\r\n\r\n\tmediump vec4 tex = texture2D (u_Texture, tc);\r\n\tmediump vec3 c = decodeHDR (tex, u_TextureHDRParams.x);\r\n\tc = c * u_TintColor.rgb * 2.0;//Gamma Space is 2.0,linear space is 4.59479380\r\n\tgl_FragColor=vec4(c, 1.0);\r\n}\r\n\r\n',
        Dn = '#include "Lighting.glsl";\r\n\r\n#define PI 3.14159265359\r\n\r\nattribute vec4 a_Position;\r\n\r\nuniform mat4 u_ViewProjection;\r\nuniform float u_Rotation;\r\n\r\nvarying vec3 v_Texcoord;\r\nvarying vec2 v_Image180ScaleAndCutoff;\r\nvarying vec4 v_Layout3DScaleAndOffset;\r\n\r\nvec4 rotateAroundYInDegrees (vec4 vertex, float degrees)\r\n{\r\n\tfloat angle = degrees * PI / 180.0;\r\n\tfloat sina=sin(angle);\r\n\tfloat cosa=cos(angle);\r\n\tmat2 m = mat2(cosa, -sina, sina, cosa);\r\n\treturn vec4(m*vertex.xz, vertex.yw).xzyw;\r\n}\r\n\r\n\t\t\r\nvoid main()\r\n{\r\n\tvec4 position = rotateAroundYInDegrees(a_Position, u_Rotation);\r\n\tgl_Position = u_ViewProjection*position;\r\n\r\n\tv_Texcoord=vec3(-a_Position.x,-a_Position.y,a_Position.z);// NOTE: -a_Position.x convert coords system\r\n\r\n\t// Calculate constant horizontal scale and cutoff for 180 (vs 360) image type\r\n\tv_Image180ScaleAndCutoff = vec2(1.0, 1.0);// 360 degree mode\r\n\r\n\t// Calculate constant scale and offset for 3D layouts\r\n\tv_Layout3DScaleAndOffset = vec4(0,0,1,1);\r\n}\r\n';
    class Cn extends Te {
        constructor() {
            super(), this._exposure = 1, this._textureDecodeFormat = t.TextureDecodeFormat.Normal, this._textureHDRParams = new n(1, 0, 0, 1), this.setShaderName("SkyPanoramic");
            var e = this._shaderValues;
            e.setVector(Cn.TINTCOLOR, new n(.5, .5, .5, .5)), e.setNumber(Cn.ROTATION, 0), e.setVector(Cn.TEXTURE_HDR_PARAMS, this._textureHDRParams)
        }
        static __init__() {
            var e = {
                    a_Position: lt.MESH_POSITION0
                },
                t = {
                    u_TintColor: he.PERIOD_MATERIAL,
                    u_TextureHDRParams: he.PERIOD_MATERIAL,
                    u_Rotation: he.PERIOD_MATERIAL,
                    u_Texture: he.PERIOD_MATERIAL,
                    u_ViewProjection: he.PERIOD_CAMERA
                },
                r = he.add("SkyPanoramic"),
                i = new lr(e, t);
            r.addSubShader(i), i.addShaderPass(Dn, Ln)
        }
        get tintColor() {
            return this._shaderValues.getVector(Cn.TINTCOLOR)
        }
        set tintColor(e) {
            this._shaderValues.setVector(Cn.TINTCOLOR, e)
        }
        get exposure() {
            return this._exposure
        }
        set exposure(e) {
            this._exposure !== e &amp;&amp; (this._exposure = e, this._textureDecodeFormat == t.TextureDecodeFormat.RGBM ? this._textureHDRParams.x = e * t.BaseTexture._rgbmRange : this._textureHDRParams.x = e)
        }
        get rotation() {
            return this._shaderValues.getNumber(Cn.ROTATION)
        }
        set rotation(e) {
            this._shaderValues.setNumber(Cn.ROTATION, e)
        }
        get panoramicTexture() {
            return this._shaderValues.getTexture(Cn.TEXTURE)
        }
        set panoramicTexture(e) {
            this._shaderValues.setTexture(Cn.TEXTURE, e)
        }
        get panoramicTextureDecodeFormat() {
            return this._textureDecodeFormat
        }
        set panoramicTextureDecodeFormat(e) {
            this._textureDecodeFormat !== e &amp;&amp; (this._textureDecodeFormat = e, e == t.TextureDecodeFormat.RGBM ? this._textureHDRParams.x = this._exposure * t.BaseTexture._rgbmRange : this._textureHDRParams.x = this._exposure)
        }
    }
    Cn.TINTCOLOR = he.propertyNameToID("u_TintColor"), Cn.EXPOSURE = he.propertyNameToID("u_Exposure"), Cn.ROTATION = he.propertyNameToID("u_Rotation"), Cn.TEXTURE = he.propertyNameToID("u_Texture"), Cn.TEXTURE_HDR_PARAMS = he.propertyNameToID("u_TextureHDRParams");
    class yn extends t.Component {
        constructor(e) {
            super(), this._anchor = new a, this._connectAnchor = new a, this._feedbackEnabled = !1, this._getJointFeedBack = !1, this._currentForce = new a, this._currentTorque = new a, this._constraintType = e;
            var t = V._bullet;
            this._btframATrans = t.btTransform_create(), this._btframBTrans = t.btTransform_create(), t.btTransform_setIdentity(this._btframATrans), t.btTransform_setIdentity(this._btframBTrans), this._btframAPos = t.btVector3_create(0, 0, 0), this._btframBPos = t.btVector3_create(0, 0, 0), t.btTransform_setOrigin(this._btframATrans, this._btframAPos), t.btTransform_setOrigin(this._btframBTrans, this._btframBPos), this._breakForce = -1, this._breakTorque = -1
        }
        get enabled() {
            return super.enabled
        }
        set enabled(e) {
            super.enabled = e
        }
        get appliedImpulse() {
            return this._feedbackEnabled || (this._btConstraint.EnableFeedback(!0), this._feedbackEnabled = !0), this._btConstraint.AppliedImpulse
        }
        set connectedBody(e) {
            this._connectedBody = e, e.constaintRigidbodyB = this
        }
        get connectedBody() {
            return this._connectedBody
        }
        get ownBody() {
            return this._ownBody
        }
        set ownBody(e) {
            this._ownBody = e, e.constaintRigidbodyA = this
        }
        get currentForce() {
            return this._getJointFeedBack || this._getFeedBackInfo(), this._currentForce
        }
        get currentTorque() {
            return this._getJointFeedBack || this._getFeedBackInfo(), this._currentTorque
        }
        get breakForce() {
            return this._breakForce
        }
        set breakForce(e) {
            this._breakForce = e
        }
        get breakTorque() {
            return this._breakTorque
        }
        set breakTorque(e) {
            this._breakTorque = e
        }
        set anchor(e) {
            e.cloneTo(this._anchor), this.setFrames()
        }
        get anchor() {
            return this._anchor
        }
        set connectAnchor(e) {
            e.cloneTo(this._connectAnchor), this.setFrames()
        }
        get connectAnchor() {
            return this._connectAnchor
        }
        setOverrideNumSolverIterations(e) {
            V._bullet.btTypedConstraint_setOverrideNumSolverIterations(this._btConstraint, e)
        }
        setConstraintEnabled(e) {
            V._bullet.btTypedConstraint_setEnabled(this._btConstraint, e)
        }
        _onEnable() {
            super._onEnable(), this.enabled = !0
        }
        _onDisable() {
            super._onDisable(), this.enabled = !1
        }
        setFrames() {
            var e = V._bullet;
            e.btVector3_setValue(this._btframAPos, -this._anchor.x, this.anchor.y, this.anchor.z), e.btVector3_setValue(this._btframBPos, -this._connectAnchor.x, this._connectAnchor.y, this._connectAnchor.z), e.btTransform_setOrigin(this._btframATrans, this._btframAPos), e.btTransform_setOrigin(this._btframBTrans, this._btframBPos)
        }
        _addToSimulation() {}
        _removeFromSimulation() {}
        _createConstraint() {}
        setConnectRigidBody(e, t) {
            var r = e &amp;&amp; !!(e._simulation &amp;&amp; e._enabled &amp;&amp; e.colliderShape),
                i = t &amp;&amp; !!(t._simulation &amp;&amp; t._enabled &amp;&amp; t.colliderShape);
            if (!r || !i) throw "ownerRigid or connectRigidBody is not in Simulation";
            e == this._ownBody &amp;&amp; t == this._connectedBody || (!(!this.enabled || !this._simulation) &amp;&amp; this._removeFromSimulation(), this._ownBody = e, this._connectedBody = t, this._ownBody.constaintRigidbodyA = this, this._connectedBody.constaintRigidbodyB = this, this._createConstraint())
        }
        getcurrentForce(e) {
            if (!this._btJointFeedBackObj) throw "this Constraint is not simulation";
            var t = V._bullet,
                r = t.btJointFeedback_getAppliedForceBodyA(this._btJointFeedBackObj);
            e.setValue(t.btVector3_x(r), t.btVector3_y(r), t.btVector3_z(r))
        }
        getcurrentTorque(e) {
            if (!this._btJointFeedBackObj) throw "this Constraint is not simulation";
            var t = V._bullet,
                r = t.btJointFeedback_getAppliedTorqueBodyA(this._btJointFeedBackObj);
            e.setValue(t.btVector3_x(r), t.btVector3_y(r), t.btVector3_z(r))
        }
        _onDestroy() {
            var e = V._bullet;
            this._removeFromSimulation(), this._btConstraint &amp;&amp; this._btJointFeedBackObj &amp;&amp; this._simulation &amp;&amp; (e.btTypedConstraint_destroy(this._btConstraint), e.btJointFeedback_destroy(this._btJointFeedBackObj), this._btJointFeedBackObj = null, this._btConstraint = null), super._onDisable()
        }
        _isBreakConstrained() {
            if (this._getJointFeedBack = !1, -1 == this.breakForce &amp;&amp; -1 == this.breakTorque) return !1;
            this._getFeedBackInfo();
            var e = -1 != this._breakForce &amp;&amp; a.scalarLength(this._currentForce) &gt; this._breakForce,
                t = -1 != this._breakTorque &amp;&amp; a.scalarLength(this._currentTorque) &gt; this._breakTorque;
            return !(!e &amp;&amp; !t) &amp;&amp; (this._breakConstrained(), !0)
        }
        _parse(e) {
            this._anchor.fromArray(e.anchor), this._connectAnchor.fromArray(e.connectAnchor), this.setFrames()
        }
        _getFeedBackInfo() {
            var e = V._bullet,
                t = e.btJointFeedback_getAppliedForceBodyA(this._btJointFeedBackObj),
                r = e.btJointFeedback_getAppliedTorqueBodyA(this._btJointFeedBackObj);
            this._currentTorque.setValue(e.btVector3_x(r), e.btVector3_y(r), e.btVector3_z(r)), this._currentForce.setValue(e.btVector3_x(t), e.btVector3_y(t), e.btVector3_z(t)), this._getJointFeedBack = !0
        }
        _breakConstrained() {
            this.ownBody.constaintRigidbodyA = null, this.connectedBody.constaintRigidbodyB = null, this.destroy()
        }
    }
    yn.CONSTRAINT_POINT2POINT_CONSTRAINT_TYPE = 3, yn.CONSTRAINT_HINGE_CONSTRAINT_TYPE = 4, yn.CONSTRAINT_CONETWIST_CONSTRAINT_TYPE = 5, yn.CONSTRAINT_D6_CONSTRAINT_TYPE = 6, yn.CONSTRAINT_SLIDER_CONSTRAINT_TYPE = 7, yn.CONSTRAINT_CONTACT_CONSTRAINT_TYPE = 8, yn.CONSTRAINT_D6_SPRING_CONSTRAINT_TYPE = 9, yn.CONSTRAINT_GEAR_CONSTRAINT_TYPE = 10, yn.CONSTRAINT_FIXED_CONSTRAINT_TYPE = 11, yn.CONSTRAINT_MAX_CONSTRAINT_TYPE = 12, yn.CONSTRAINT_CONSTRAINT_ERP = 1, yn.CONSTRAINT_CONSTRAINT_STOP_ERP = 2, yn.CONSTRAINT_CONSTRAINT_CFM = 3, yn.CONSTRAINT_CONSTRAINT_STOP_CFM = 4, yn.tempForceV3 = new a;
    class Mn extends yn {
        constructor() {
            super(yn.CONSTRAINT_FIXED_CONSTRAINT_TYPE), this.breakForce = -1, this.breakTorque = -1
        }
        _addToSimulation() {
            this._simulation &amp;&amp; this._simulation.addConstraint(this, this.enabled)
        }
        _removeFromSimulation() {
            this._simulation.removeConstraint(this), this._simulation = null
        }
        _createConstraint() {
            if (this.ownBody &amp;&amp; this.ownBody._simulation &amp;&amp; this.connectedBody &amp;&amp; this.connectedBody._simulation) {
                var e = V._bullet;
                this._btConstraint = e.btFixedConstraint_create(this.ownBody.btColliderObject, this._btframATrans, this.connectedBody.btColliderObject, this._btframBTrans), this._btJointFeedBackObj = e.btJointFeedback_create(this._btConstraint), e.btTypedConstraint_setJointFeedback(this._btConstraint, this._btJointFeedBackObj), this._simulation = this.owner._scene.physicsSimulation, this._addToSimulation(), V._bullet.btTypedConstraint_setEnabled(this._btConstraint, !0)
            }
        }
        _onAdded() {
            super._onAdded()
        }
        _onEnable() {
            this._btConstraint &amp;&amp; (super._onEnable(), this._btConstraint &amp;&amp; V._bullet.btTypedConstraint_setEnabled(this._btConstraint, !0))
        }
        _onDisable() {
            super._onDisable(), this.connectedBody || this._removeFromSimulation(), this._btConstraint &amp;&amp; V._bullet.btTypedConstraint_setEnabled(this._btConstraint, !1)
        }
        _onDestroy() {
            super._onDestroy()
        }
        _parse(e, t = null) {
            super._parse(e), -1 != e.rigidbodyID &amp;&amp; -1 != e.connectRigidbodyID &amp;&amp; (t.component.push(this), t.data.push(e)), null != e.breakForce &amp;&amp; (this.breakForce = e.breakForce), null != e.breakTorque &amp;&amp; (this.breakTorque = e.breakTorque)
        }
        _parseInteractive(e = null, t = null) {
            var r = t[e.rigidbodyID].getComponent(w),
                i = t[e.connectRigidbodyID].getComponent(w);
            this.ownBody = r, this.connectedBody = i
        }
        _cloneTo(e) {}
    }
    class On extends yn {
        constructor() {
            super(yn.CONSTRAINT_D6_SPRING_CONSTRAINT_TYPE), this._axis = new a, this._secondaryAxis = new a, this._minLinearLimit = new a, this._maxLinearLimit = new a, this._minAngularLimit = new a, this._maxAngularLimit = new a, this._linearLimitSpring = new a, this._angularLimitSpring = new a, this._linearBounce = new a, this._angularBounce = new a, this._linearDamp = new a, this._angularDamp = new a, this._xMotion = 0, this._yMotion = 0, this._zMotion = 0, this._angularXMotion = 0, this._angularYMotion = 0, this._angularZMotion = 0;
            var e = V._bullet;
            this._btAxis = e.btVector3_create(-1, 0, 0), this._btSecondaryAxis = e.btVector3_create(0, 1, 0)
        }
        get axis() {
            return this._axis
        }
        get secondaryAxis() {
            return this._secondaryAxis
        }
        set maxAngularLimit(e) {
            e.cloneTo(this._maxAngularLimit)
        }
        set minAngularLimit(e) {
            e.cloneTo(this._minAngularLimit)
        }
        get maxAngularLimit() {
            return this._maxAngularLimit
        }
        get minAngularLimit() {
            return this._minAngularLimit
        }
        set maxLinearLimit(e) {
            e.cloneTo(this._maxLinearLimit)
        }
        set minLinearLimit(e) {
            e.cloneTo(this._minLinearLimit)
        }
        get maxLinearLimit() {
            return this._maxLinearLimit
        }
        get minLinearLimit() {
            return this._minLinearLimit
        }
        set XMotion(e) {
            this._xMotion != e &amp;&amp; (this._xMotion = e, this.setLimit(On.MOTION_LINEAR_INDEX_X, e, -this._maxLinearLimit.x, -this._minLinearLimit.x))
        }
        get XMotion() {
            return this._xMotion
        }
        set YMotion(e) {
            this._yMotion != e &amp;&amp; (this._yMotion = e, this.setLimit(On.MOTION_LINEAR_INDEX_Y, e, this._minLinearLimit.y, this._maxLinearLimit.y))
        }
        get YMotion() {
            return this._yMotion
        }
        set ZMotion(e) {
            this._zMotion != e &amp;&amp; (this._zMotion = e, this.setLimit(On.MOTION_LINEAR_INDEX_Z, e, this._minLinearLimit.z, this._maxLinearLimit.z))
        }
        get ZMotion() {
            return this._zMotion
        }
        set angularXMotion(e) {
            this._angularXMotion != e &amp;&amp; (this._angularXMotion = e, this.setLimit(On.MOTION_ANGULAR_INDEX_X, e, -this._maxAngularLimit.x, -this._minAngularLimit.x))
        }
        get angularXMotion() {
            return this._angularXMotion
        }
        set angularYMotion(e) {
            this._angularYMotion != e &amp;&amp; (this._angularYMotion = e, this.setLimit(On.MOTION_ANGULAR_INDEX_Y, e, this._minAngularLimit.y, this._maxAngularLimit.y))
        }
        get angularYMotion() {
            return this._angularYMotion
        }
        set angularZMotion(e) {
            this._angularZMotion != e &amp;&amp; (this._angularZMotion = e, this.setLimit(On.MOTION_ANGULAR_INDEX_Z, e, this._minAngularLimit.z, this._maxAngularLimit.z))
        }
        get angularZMotion() {
            return this._angularZMotion
        }
        set linearLimitSpring(e) {
            a.equals(this._linearLimitSpring, e) || (e.cloneTo(this._linearLimitSpring), this.setSpring(On.MOTION_LINEAR_INDEX_X, e.x), this.setSpring(On.MOTION_LINEAR_INDEX_Y, e.y), this.setSpring(On.MOTION_LINEAR_INDEX_Z, e.z))
        }
        get linearLimitSpring() {
            return this._linearLimitSpring
        }
        set angularLimitSpring(e) {
            a.equals(this._angularLimitSpring, e) || (e.cloneTo(this._angularLimitSpring), this.setSpring(On.MOTION_ANGULAR_INDEX_X, e.x), this.setSpring(On.MOTION_ANGULAR_INDEX_Y, e.y), this.setSpring(On.MOTION_ANGULAR_INDEX_Z, e.z))
        }
        get angularLimitSpring() {
            return this._angularLimitSpring
        }
        set linearBounce(e) {
            a.equals(this._linearBounce, e) || (e.cloneTo(this._linearBounce), this.setBounce(On.MOTION_LINEAR_INDEX_X, e.x), this.setBounce(On.MOTION_LINEAR_INDEX_Y, e.y), this.setBounce(On.MOTION_LINEAR_INDEX_Z, e.z))
        }
        get linearBounce() {
            return this._linearBounce
        }
        set angularBounce(e) {
            a.equals(this._angularBounce, e) || (e.cloneTo(this._angularBounce), this.setBounce(On.MOTION_ANGULAR_INDEX_X, e.x), this.setBounce(On.MOTION_ANGULAR_INDEX_Y, e.y), this.setBounce(On.MOTION_ANGULAR_INDEX_Z, e.z))
        }
        get angularBounce() {
            return this._angularBounce
        }
        set linearDamp(e) {
            a.equals(this._linearDamp, e) || (e.cloneTo(this._linearDamp), this.setDamping(On.MOTION_LINEAR_INDEX_X, e.x), this.setDamping(On.MOTION_LINEAR_INDEX_Y, e.y), this.setDamping(On.MOTION_LINEAR_INDEX_Z, e.z))
        }
        get linearDamp() {
            return this._linearDamp
        }
        set angularDamp(e) {
            a.equals(this._angularDamp, e) || (e.cloneTo(this._angularDamp), this.setDamping(On.MOTION_ANGULAR_INDEX_X, e.x), this.setDamping(On.MOTION_ANGULAR_INDEX_Y, e.y), this.setDamping(On.MOTION_ANGULAR_INDEX_Z, e.z))
        }
        get angularDamp() {
            return this._angularDamp
        }
        set anchor(e) {
            e.cloneTo(this._anchor), this.setFrames()
        }
        get anchor() {
            return this._anchor
        }
        set connectAnchor(e) {
            e.cloneTo(this._connectAnchor), this.setFrames()
        }
        get connectAnchor() {
            return this._connectAnchor
        }
        setAxis(e, t) {
            if (this._btConstraint) {
                var r = V._bullet;
                this._axis.setValue(e.x, e.y, e.y), this._secondaryAxis.setValue(t.x, t.y, t.z), this._btAxis = r.btVector3_setValue(-e.x, e.y, e.z), this._btSecondaryAxis = r.btVector3_setValue(-t.x, t.y, t.z), r.btGeneric6DofSpring2Constraint_setAxis(this._btConstraint, this._btAxis, this._btSecondaryAxis)
            }
        }
        setLimit(e, t, r, i) {
            if (this._btConstraint) {
                var n = V._bullet;
                switch (t) {
                    case On.CONFIG_MOTION_TYPE_LOCKED:
                        n.btGeneric6DofSpring2Constraint_setLimit(this._btConstraint, e, 0, 0);
                        break;
                    case On.CONFIG_MOTION_TYPE_LIMITED:
                        r &lt; i &amp;&amp; n.btGeneric6DofSpring2Constraint_setLimit(this._btConstraint, e, r, i);
                        break;
                    case On.CONFIG_MOTION_TYPE_FREE:
                        n.btGeneric6DofSpring2Constraint_setLimit(this._btConstraint, e, 1, 0);
                        break;
                    default:
                        throw "No Type of Axis Motion"
                }
            }
        }
        setSpring(e, t, r = !0) {
            if (this._btConstraint) {
                var i = V._bullet,
                    n = t &gt; 0;
                i.btGeneric6DofSpring2Constraint_enableSpring(this._btConstraint, e, n), n &amp;&amp; i.btGeneric6DofSpring2Constraint_setStiffness(this._btConstraint, e, t, r)
            }
        }
        setBounce(e, t) {
            this._btConstraint &amp;&amp; (t = t &lt;= 0 ? 0 : t, V._bullet.btGeneric6DofSpring2Constraint_setBounce(this._btConstraint, e, t))
        }
        setDamping(e, t, r = !0) {
            this._btConstraint &amp;&amp; (t = t &lt;= 0 ? 0 : t, V._bullet.btGeneric6DofSpring2Constraint_setDamping(this._btConstraint, e, t, r))
        }
        setEquilibriumPoint(e, t) {
            V._bullet.btGeneric6DofSpring2Constraint_setEquilibriumPoint(this._btConstraint, e, t)
        }
        enableMotor(e, t) {
            V._bullet.btGeneric6DofSpring2Constraint_enableMotor(this._btConstraint, e, t)
        }
        setServo(e, t) {
            V._bullet.btGeneric6DofSpring2Constraint_setServo(this._btConstraint, e, t)
        }
        setTargetVelocity(e, t) {
            V._bullet.btGeneric6DofSpring2Constraint_setTargetVelocity(this._btConstraint, e, t)
        }
        setTargetPosition(e, t) {
            V._bullet.btGeneric6DofSpring2Constraint_setServoTarget(this._btConstraint, e, t)
        }
        setMaxMotorForce(e, t) {
            V._bullet.btGeneric6DofSpring2Constraint_setMaxMotorForce(this._btConstraint, e, t)
        }
        setParam(e, t, r) {
            V._bullet.btTypedConstraint_setParam(this._btConstraint, e, t, r)
        }
        setFrames() {
            super.setFrames();
            var e = V._bullet;
            this._btConstraint &amp;&amp; e.btGeneric6DofSpring2Constraint_setFrames(this._btConstraint, this._btframATrans, this._btframBTrans)
        }
        _addToSimulation() {
            this._simulation &amp;&amp; this._simulation.addConstraint(this, this.enabled)
        }
        _removeFromSimulation() {
            this._simulation.removeConstraint(this), this._simulation = null
        }
        _createConstraint() {
            var e = V._bullet;
            this._btConstraint = e.btGeneric6DofSpring2Constraint_create(this.ownBody.btColliderObject, this._btframAPos, this.connectedBody.btColliderObject, this._btframBPos, On.RO_XYZ), this._btJointFeedBackObj = e.btJointFeedback_create(this._btConstraint), e.btTypedConstraint_setJointFeedback(this._btConstraint, this._btJointFeedBackObj), this._simulation = this.owner._scene.physicsSimulation, this._initAllConstraintInfo(), this._addToSimulation(), V._bullet.btTypedConstraint_setEnabled(this._btConstraint, !0)
        }
        _initAllConstraintInfo() {
            this.setLimit(On.MOTION_LINEAR_INDEX_X, this._xMotion, -this._maxLinearLimit.x, -this._minLinearLimit.x), this.setLimit(On.MOTION_LINEAR_INDEX_Y, this._yMotion, this._minLinearLimit.y, this._maxLinearLimit.y), this.setLimit(On.MOTION_LINEAR_INDEX_Z, this._zMotion, this._minLinearLimit.z, this._maxLinearLimit.z), this.setLimit(On.MOTION_ANGULAR_INDEX_X, this._angularXMotion, -this._maxAngularLimit.x, -this._minAngularLimit.x), this.setLimit(On.MOTION_ANGULAR_INDEX_Y, this._angularYMotion, this._minAngularLimit.y, this._maxAngularLimit.y), this.setLimit(On.MOTION_ANGULAR_INDEX_Z, this._angularZMotion, this._minAngularLimit.z, this._maxAngularLimit.z), this.setSpring(On.MOTION_LINEAR_INDEX_X, this._linearLimitSpring.x), this.setSpring(On.MOTION_LINEAR_INDEX_Y, this._linearLimitSpring.y), this.setSpring(On.MOTION_LINEAR_INDEX_Z, this._linearLimitSpring.z), this.setSpring(On.MOTION_ANGULAR_INDEX_X, this._angularLimitSpring.x), this.setSpring(On.MOTION_ANGULAR_INDEX_Y, this._angularLimitSpring.y), this.setSpring(On.MOTION_ANGULAR_INDEX_Z, this._angularLimitSpring.z), this.setBounce(On.MOTION_LINEAR_INDEX_X, this._linearBounce.x), this.setBounce(On.MOTION_LINEAR_INDEX_Y, this._linearBounce.y), this.setBounce(On.MOTION_LINEAR_INDEX_Z, this._linearBounce.z), this.setBounce(On.MOTION_ANGULAR_INDEX_X, this._angularBounce.x), this.setBounce(On.MOTION_ANGULAR_INDEX_Y, this._angularBounce.y), this.setBounce(On.MOTION_ANGULAR_INDEX_Z, this._angularBounce.z), this.setDamping(On.MOTION_LINEAR_INDEX_X, this._linearDamp.x), this.setDamping(On.MOTION_LINEAR_INDEX_Y, this._linearDamp.y), this.setDamping(On.MOTION_LINEAR_INDEX_Z, this._linearDamp.z), this.setDamping(On.MOTION_ANGULAR_INDEX_X, this._angularDamp.x), this.setDamping(On.MOTION_ANGULAR_INDEX_Y, this._angularDamp.y), this.setDamping(On.MOTION_ANGULAR_INDEX_Z, this._angularDamp.z), this.setFrames(), this.setEquilibriumPoint(0, 0)
        }
        _onAdded() {
            super._onAdded()
        }
        _onEnable() {
            this._btConstraint &amp;&amp; (super._onEnable(), this._btConstraint &amp;&amp; V._bullet.btTypedConstraint_setEnabled(this._btConstraint, !0))
        }
        _onDisable() {
            super._onDisable(), this.connectedBody || this._removeFromSimulation(), this._btConstraint &amp;&amp; V._bullet.btTypedConstraint_setEnabled(this._btConstraint, !1)
        }
        _parse(e, t = null) {
            super._parse(e), this._axis.fromArray(e.axis), this._secondaryAxis.fromArray(e.secondaryAxis);
            var r = e.linearLimit;
            this._minLinearLimit.setValue(-r, -r, -r), this._maxLinearLimit.setValue(r, r, r);
            var i = e.linearLimitSpring;
            this._linearLimitSpring.setValue(i, i, i);
            var n = e.linearLimitDamper;
            this._linearDamp.setValue(n, n, n);
            var a = e.linearLimitBounciness;
            this._linearBounce.setValue(a, a, a);
            var s = e.lowAngularXLimit,
                o = e.highAngularXLimit,
                l = e.angularYLimit,
                _ = e.angularZLimit;
            this._minAngularLimit.setValue(s, -l, -_), this._maxAngularLimit.setValue(o, l, _);
            var h = e.highAngularXLimitBounciness,
                c = e.angularYLimitBounciness,
                d = e.angularZLimitBounciness;
            this._angularBounce.setValue(h, c, d);
            var u = e.angularXLimitSpring,
                m = e.angularYZLimitSpring;
            this._angularLimitSpring.setValue(u, m, m);
            var f = e.angularXLimitDamper,
                T = e.angularYZLimitDamper;
            this._angularDamp.setValue(f, T, T), this.XMotion = e.xMotion, this.YMotion = e.yMotion, this.ZMotion = e.zMotion, this.angularXMotion = e.angularXMotion, this.angularYMotion = e.angularYMotion, this.angularZMotion = e.angularZMotion, -1 != e.rigidbodyID &amp;&amp; -1 != e.connectRigidbodyID &amp;&amp; (t.component.push(this), t.data.push(e)), null != e.breakForce &amp;&amp; (this.breakForce = e.breakForce), null != e.breakTorque &amp;&amp; (this.breakTorque = e.breakTorque)
        }
        _parseInteractive(e = null, t = null) {
            var r = t[e.rigidbodyID].getComponent(w),
                i = t[e.connectRigidbodyID].getComponent(w);
            this.ownBody = r, this.connectedBody = i
        }
        _onDestroy() {
            super._onDestroy()
        }
        _cloneTo(e) {}
    }
    On.CONFIG_MOTION_TYPE_LOCKED = 0, On.CONFIG_MOTION_TYPE_LIMITED = 1, On.CONFIG_MOTION_TYPE_FREE = 2, On.MOTION_LINEAR_INDEX_X = 0, On.MOTION_LINEAR_INDEX_Y = 1, On.MOTION_LINEAR_INDEX_Z = 2, On.MOTION_ANGULAR_INDEX_X = 3, On.MOTION_ANGULAR_INDEX_Y = 4, On.MOTION_ANGULAR_INDEX_Z = 5, On.RO_XYZ = 0, On.RO_XZY = 1, On.RO_YXZ = 2, On.RO_YZX = 3, On.RO_ZXY = 4, On.RO_ZYX = 5;
    class Nn {
        constructor() {}
        static get enablePhysics() {
            return V._enablePhysics
        }
        static _cancelLoadByUrl(e) {
            t.Laya.loader.cancelLoadByUrl(e), Nn._innerFirstLevelLoaderManager.cancelLoadByUrl(e), Nn._innerSecondLevelLoaderManager.cancelLoadByUrl(e), Nn._innerThirdLevelLoaderManager.cancelLoadByUrl(e), Nn._innerFourthLevelLoaderManager.cancelLoadByUrl(e)
        }
        static _changeWebGLSize(e, r) {
            t.WebGL.onStageResize(e, r), ne.clientWidth = e, ne.clientHeight = r
        }
        static __init__(r, i, n) {
            if (t.Config.isAntialias = n.isAntialias, t.Config.isAlpha = n.isAlpha, t.Config.premultipliedAlpha = n.premultipliedAlpha, t.Config.isStencil = n.isStencil, t.WebGL.enable()) {
                t.RunDriver.changeWebGLSize = Nn._changeWebGLSize, t.Render.is3DMode = !0, t.Laya.init(r, i), t.Render.supportWebGLPlusRendering || (t.LayaGL.instance = t.WebGLContext.mainContext, t.LayaGL.instance.createCommandEncoder = function(e = 128, r = 64, i = !1) {
                    return new t.CommandEncoder(this, e, r, i)
                }), n._multiLighting = n.enableMultiLight &amp;&amp; t.SystemUtils.supportTextureFormat(t.TextureFormat.R32G32B32A32), _.Shader3D = he, _.Scene3D = sr, _.MeshRenderStaticBatchManager = Yt, _.MeshRenderDynamicBatchManager = xr, _.SubMeshDynamicBatch = Ir, _.Laya3D = Nn, _.Matrix4x4 = c, _.Physics3D = V, _.ShadowLightType = e.ShadowLightType, Nn.enableNative3D(), n.isUseCannonPhysicsEngine &amp;&amp; V.__cannoninit__(), V.__bulletinit__(), at.__init__(), lt.__init__(), ei.__init__(), ti.__init__(), Ct.__init__(), di.__init__(), Ei.__init__(), Bt.__init__(), zt.__init__(), Ir.__init__(), pn.__init__(), It.init(), ve.__init__(), Tr.__init__(), _r.__init__(), Cn.__init__(), vi.__init__(), Ai.__init__(), ut.__init__(), Ut.__init__(), Lr.__init__(), _i.__init__(), si.__init__(), Ti.__init__(), de.__init__(), sr.__init__(), Yt.__init__(), Te.__initDefine__(), Ee.__initDefine__(), ge.__initDefine__(), pr.__initDefine__(), gr.__initDefine__(), hi.__initDefine__(), Se.__initDefine__(), Sr.__initDefine__(), Kr.__initDefine__(), Re.__initDefine__(), bt.__initDefine__(), Er.__initDefine__(), Et.__init__(), t.ClassUtils.regClass("Laya.SkyPanoramicMaterial", Cn), t.ClassUtils.regClass("Laya.EffectMaterial", Se), t.ClassUtils.regClass("Laya.UnlitMaterial", gr), t.ClassUtils.regClass("Laya.BlinnPhongMaterial", ge), t.ClassUtils.regClass("Laya.SkyProceduralMaterial", pr), t.ClassUtils.regClass("Laya.PBRStandardMaterial", Tr), t.ClassUtils.regClass("Laya.PBRSpecularMaterial", _r), t.ClassUtils.regClass("Laya.SkyBoxMaterial", Er), t.ClassUtils.regClass("Laya.WaterPrimaryMaterial", Sr), t.ClassUtils.regClass("Laya.ExtendTerrainMaterial", Re), t.ClassUtils.regClass("Laya.ShurikenParticleMaterial", Kr), t.ClassUtils.regClass("Laya.TrailMaterial", hi), t.ClassUtils.regClass("Laya.PhysicsCollider", gi), t.ClassUtils.regClass("Laya.Rigidbody3D", w), t.ClassUtils.regClass("Laya.CharacterController", b), t.ClassUtils.regClass("Laya.Animator", re), t.ClassUtils.regClass("PhysicsCollider", gi), t.ClassUtils.regClass("CharacterController", b), t.ClassUtils.regClass("Animator", re), t.ClassUtils.regClass("Rigidbody3D", w), t.ClassUtils.regClass("FixedConstraint", Mn), t.ClassUtils.regClass("ConfigurableConstraint", On), bt.defaultMaterial = new bt, ge.defaultMaterial = new ge, Se.defaultMaterial = new Se, gr.defaultMaterial = new gr, Kr.defaultMaterial = new Kr, hi.defaultMaterial = new hi, pr.defaultMaterial = new pr, Er.defaultMaterial = new Er, Sr.defaultMaterial = new Sr, bt.defaultMaterial.lock = !0, ge.defaultMaterial.lock = !0, Se.defaultMaterial.lock = !0, gr.defaultMaterial.lock = !0, Kr.defaultMaterial.lock = !0, hi.defaultMaterial.lock = !0, pr.defaultMaterial.lock = !0, Er.defaultMaterial.lock = !0, Sr.defaultMaterial.lock = !0, t.Texture2D.__init__(), Mt.__init__(), ct.__init__(), yt.__init__(), ft.__init__(), Tt.__init__(), ke.__init__(), X.__init__();
                var a = t.LoaderManager.createMap;
                a.lh = [Nn.HIERARCHY, vn._parse], a.ls = [Nn.HIERARCHY, vn._parseScene], a.lm = [Nn.MESH, xn._parse], a.lmat = [Nn.MATERIAL, Te._parse], a.jpg = [Nn.TEXTURE2D, t.Texture2D._parse], a.jpeg = [Nn.TEXTURE2D, t.Texture2D._parse], a.bmp = [Nn.TEXTURE2D, t.Texture2D._parse], a.gif = [Nn.TEXTURE2D, t.Texture2D._parse], a.png = [Nn.TEXTURE2D, t.Texture2D._parse], a.dds = [Nn.TEXTURE2D, t.Texture2D._parse], a.ktx = [Nn.TEXTURE2D, t.Texture2D._parse], a.pvr = [Nn.TEXTURE2D, t.Texture2D._parse], a.lani = [Nn.ANIMATIONCLIP, Z._parse], a.lav = [Nn.AVATAR, fe._parse], a.ltc = [Nn.TEXTURECUBE, Mt._parse], a.ltcb = [Nn.TEXTURECUBEBIN, Mt._parseBin], a["ltcb.ls"] = [Nn.TEXTURECUBEBIN, Mt._parseBin];
                var s = t.Loader.parserMap;
                s[Nn.HIERARCHY] = Nn._loadHierarchy, s[Nn.MESH] = Nn._loadMesh, s[Nn.MATERIAL] = Nn._loadMaterial, s[Nn.TEXTURECUBE] = Nn._loadTextureCube, s[Nn.TEXTURECUBEBIN] = Nn._loadTextureCubeBin, s[Nn.TEXTURE2D] = Nn._loadTexture2D, s[Nn.ANIMATIONCLIP] = Nn._loadAnimationClip, s[Nn.AVATAR] = Nn._loadAvatar, Nn._innerFirstLevelLoaderManager.on(t.Event.ERROR, null, Nn._eventLoadManagerError), Nn._innerSecondLevelLoaderManager.on(t.Event.ERROR, null, Nn._eventLoadManagerError), Nn._innerThirdLevelLoaderManager.on(t.Event.ERROR, null, Nn._eventLoadManagerError), Nn._innerFourthLevelLoaderManager.on(t.Event.ERROR, null, Nn._eventLoadManagerError)
            } else alert("Laya3D init error,must support webGL!")
        }
        static enableNative3D() {
            var e = ce,
                r = Ue,
                i = li,
                n = fe,
                a = ke;
            if (t.Render.supportWebGLPlusRendering &amp;&amp; (e.prototype._initData = e.prototype._initDataForNative, e.prototype.setBool = e.prototype.setBoolForNative, e.prototype.getBool = e.prototype.getBoolForNative, e.prototype.setInt = e.prototype.setIntForNative, e.prototype.getInt = e.prototype.getIntForNative, e.prototype.setNumber = e.prototype.setNumberForNative, e.prototype.getNumber = e.prototype.getNumberForNative, e.prototype.setVector = e.prototype.setVectorForNative, e.prototype.getVector = e.prototype.getVectorForNative, e.prototype.setVector2 = e.prototype.setVector2ForNative, e.prototype.getVector2 = e.prototype.getVector2ForNative, e.prototype.setVector3 = e.prototype.setVector3ForNative, e.prototype.getVector3 = e.prototype.getVector3ForNative, e.prototype.setQuaternion = e.prototype.setQuaternionForNative, e.prototype.getQuaternion = e.prototype.getQuaternionForNative, e.prototype.setMatrix4x4 = e.prototype.setMatrix4x4ForNative, e.prototype.getMatrix4x4 = e.prototype.getMatrix4x4ForNative, e.prototype.setBuffer = e.prototype.setBufferForNative, e.prototype.getBuffer = e.prototype.getBufferForNative, e.prototype.setTexture = e.prototype.setTextureForNative, e.prototype.getTexture = e.prototype.getTextureForNative, e.prototype.setAttribute = e.prototype.setAttributeForNative, e.prototype.getAttribute = e.prototype.getAttributeForNative, e.prototype.cloneTo = e.prototype.cloneToForNative, e.prototype.getData = e.prototype.getDataForNative, r.prototype._uniformMatrix2fv = r.prototype._uniformMatrix2fvForNative, r.prototype._uniformMatrix3fv = r.prototype._uniformMatrix3fvForNative, r.prototype._uniformMatrix4fv = r.prototype._uniformMatrix4fvForNative, t.LayaGLRunner.uploadShaderUniforms = t.LayaGLRunner.uploadShaderUniformsForNative), t.Render.supportWebGLPlusCulling &amp;&amp; (a.renderObjectCulling = ke.renderObjectCullingNative), t.Render.supportWebGLPlusAnimation) {
                n.prototype._cloneDatasToAnimator = n.prototype._cloneDatasToAnimatorNative;
                var s = Z;
                s.prototype._evaluateClipDatasRealTime = s.prototype._evaluateClipDatasRealTimeForNative, i.prototype._computeSkinnedData = i.prototype._computeSkinnedDataForNative
            }
        }
        static formatRelativePath(e, t) {
            var r;
            if (r = e + t, "." === t.charAt(0)) {
                for (var i = r.split("/"), n = 0, a = i.length; n &lt; a; n++)
                    if (".." == i[n]) {
                        var s = n - 1;
                        s &gt; 0 &amp;&amp; ".." !== i[s] &amp;&amp; (i.splice(s, 2), n -= 2)
                    }
                r = i.join("/")
            }
            return r
        }
        static _endLoad(e, r = null, i = null) {
            if (i)
                for (var n = 0, a = i.length; n &lt; a; n++) {
                    var s = t.Loader.getRes(i[n]);
                    s &amp;&amp; s._removeReference()
                }
            e.endLoad(r)
        }
        static _eventLoadManagerError(e) {
            t.Laya.loader.event(t.Event.ERROR, e)
        }
        static _addHierarchyInnerUrls(e, t, r, i, n, a, s = null, o = null) {
            var l = Nn.formatRelativePath(i, n);
            return r &amp;&amp; (l += r), e.push({
                url: l,
                type: a,
                constructParams: s,
                propertyParams: o
            }), t.push(l), l
        }
        static _getSprite3DHierarchyInnerUrls(e, t, r, i, n, a, s, o) {
            var l, _, h = e.props;
            switch (e.type) {
                case "Scene3D":
                    var c = h.lightmaps;
                    for (l = 0, _ = c.length; l &lt; _; l++) {
                        var d = c[l];
                        if (d.path) d.path = Nn._addHierarchyInnerUrls(n, a, s, o, d.path, Nn.TEXTURE2D, d.constructParams, d.propertyParams);
                        else {
                            var u = d.color;
                            u.path = Nn._addHierarchyInnerUrls(n, a, s, o, u.path, Nn.TEXTURE2D, u.constructParams, u.propertyParams);
                            var m = d.direction;
                            m &amp;&amp; (m.path = Nn._addHierarchyInnerUrls(n, a, s, o, m.path, Nn.TEXTURE2D, m.constructParams, m.propertyParams))
                        }
                    }
                    var f = h.reflectionTexture;
                    f &amp;&amp; (h.reflection = Nn._addHierarchyInnerUrls(i, a, s, o, f, Nn.TEXTURECUBE));
                    var T = h.reflection;
                    if (T &amp;&amp; (h.reflection = Nn._addHierarchyInnerUrls(n, a, s, o, T, Nn.TEXTURECUBEBIN)), h.sky) {
                        var E = h.sky.material;
                        E &amp;&amp; (E.path = Nn._addHierarchyInnerUrls(r, a, s, o, E.path, Nn.MATERIAL))
                    }
                    break;
                case "Camera":
                    var p = h.skyboxMaterial;
                    p &amp;&amp; (p.path = Nn._addHierarchyInnerUrls(r, a, s, o, p.path, Nn.MATERIAL));
                    break;
                case "TrailSprite3D":
                case "MeshSprite3D":
                case "SkinnedMeshSprite3D":
                    var g = h.meshPath;
                    g &amp;&amp; (h.meshPath = Nn._addHierarchyInnerUrls(t, a, s, o, g, Nn.MESH));
                    var S = h.materials;
                    if (S)
                        for (l = 0, _ = S.length; l &lt; _; l++) S[l].path = Nn._addHierarchyInnerUrls(r, a, s, o, S[l].path, Nn.MATERIAL);
                    break;
                case "ShuriKenParticle3D":
                    if (h.main) {
                        var R = h.renderer.resources,
                            v = R.mesh,
                            A = R.material;
                        v &amp;&amp; (R.mesh = Nn._addHierarchyInnerUrls(t, a, s, o, v, Nn.MESH)), A &amp;&amp; (R.material = Nn._addHierarchyInnerUrls(r, a, s, o, A, Nn.MATERIAL))
                    } else {
                        var I = h.meshPath;
                        I &amp;&amp; (h.meshPath = Nn._addHierarchyInnerUrls(t, a, s, o, I, Nn.MESH)), h.material.path = Nn._addHierarchyInnerUrls(r, a, s, o, h.material.path, Nn.MATERIAL)
                    }
                    break;
                case "Terrain":
                    Nn._addHierarchyInnerUrls(n, a, s, o, h.dataPath, Nn.TERRAINRES)
            }
            var x = e.components;
            if (x)
                for (var L = 0, D = x.length; L &lt; D; L++) {
                    var C = x[L];
                    switch (C.type) {
                        case "Animator":
                            C.avatarPath;
                            var y = C.avatar;
                            y &amp;&amp; (y.path = Nn._addHierarchyInnerUrls(n, a, s, o, y.path, Nn.AVATAR));
                            var M = C.clipPaths;
                            if (M)
                                for (l = 0, _ = M.length; l &lt; _; l++) M[l] = Nn._addHierarchyInnerUrls(n, a, s, o, M[l], Nn.ANIMATIONCLIP);
                            else {
                                var O = C.layers;
                                for (l = 0; l &lt; O.length; l++)
                                    for (var N = O[l].states, b = 0, P = N.length; b &lt; P; b++) {
                                        var w = N[b].clipPath;
                                        w &amp;&amp; (N[b].clipPath = Nn._addHierarchyInnerUrls(n, a, s, o, w, Nn.ANIMATIONCLIP))
                                    }
                            }
                            break;
                        case "PhysicsCollider":
                        case "Rigidbody3D":
                        case "CharacterController":
                            var V = C.shapes;
                            for (l = 0; l &lt; V.length; l++) {
                                var B = V[l];
                                if ("MeshColliderShape" === B.type)(v = B.mesh) &amp;&amp; (B.mesh = Nn._addHierarchyInnerUrls(t, a, s, o, v, Nn.MESH))
                            }
                    }
                }
            var F = e.child;
            for (l = 0, _ = F.length; l &lt; _; l++) Nn._getSprite3DHierarchyInnerUrls(F[l], t, r, i, n, a, s, o)
        }
        static _loadHierarchy(e) {
            e._originType = e.type, e.on(t.Event.LOADED, null, Nn._onHierarchylhLoaded, [e]), e.load(e.url, t.Loader.JSON, !1, null, !0)
        }
        static _onHierarchylhLoaded(e, r) {
            var i = e.url,
                n = N.getURLVerion(i),
                a = t.URL.getPath(i),
                s = [],
                o = [],
                l = [],
                _ = [],
                h = [];
            Nn._getSprite3DHierarchyInnerUrls(r.data, s, o, l, _, h, n, a);
            var c = s.length + o.length + _.length,
                d = c + 1,
                u = 1 / d;
            if (Nn._onProcessChange(e, 0, u, 1), _.length &gt; 0) {
                var m = c / d,
                    f = t.Handler.create(null, Nn._onProcessChange, [e, u, m], !1);
                Nn._innerFourthLevelLoaderManager._create(_, !1, t.Handler.create(null, Nn._onHierarchyInnerForthLevResouLoaded, [e, f, r, h, s, o, l, u + m * _.length, m]), f, null, null, null, 1, !0)
            } else Nn._onHierarchyInnerForthLevResouLoaded(e, null, r, h, s, o, l, u, m)
        }
        static _onHierarchyInnerForthLevResouLoaded(e, r, i, n, a, s, o, l, _) {
            if (r &amp;&amp; r.recover(), o.length &gt; 0) {
                var h = t.Handler.create(null, Nn._onProcessChange, [e, l, _], !1);
                Nn._innerThirdLevelLoaderManager._create(o, !1, t.Handler.create(null, Nn._onHierarchyInnerThirdLevResouLoaded, [e, h, i, n, a, s, l + _ * s.length, _]), r, null, null, null, 1, !0)
            } else Nn._onHierarchyInnerThirdLevResouLoaded(e, null, i, n, a, s, l, _)
        }
        static _onHierarchyInnerThirdLevResouLoaded(e, r, i, n, a, s, o, l) {
            if (r &amp;&amp; r.recover(), s.length &gt; 0) {
                var _ = t.Handler.create(null, Nn._onProcessChange, [e, o, l], !1);
                Nn._innerSecondLevelLoaderManager._create(s, !1, t.Handler.create(null, Nn._onHierarchyInnerSecondLevResouLoaded, [e, _, i, n, a, o + l * s.length, l]), r, null, null, null, 1, !0)
            } else Nn._onHierarchyInnerSecondLevResouLoaded(e, null, i, n, a, o, l)
        }
        static _onHierarchyInnerSecondLevResouLoaded(e, r, i, n, a, s, o) {
            if (r &amp;&amp; r.recover(), a.length &gt; 0) {
                var l = t.Handler.create(null, Nn._onProcessChange, [e, s, o], !1);
                Nn._innerFirstLevelLoaderManager._create(a, !1, t.Handler.create(null, Nn._onHierarchyInnerFirstLevResouLoaded, [e, l, i, n]), r, null, null, null, 1, !0)
            } else Nn._onHierarchyInnerFirstLevResouLoaded(e, null, i, n)
        }
        static _onHierarchyInnerFirstLevResouLoaded(e, t, r, i) {
            t &amp;&amp; t.recover(), e._cache = e._createCache;
            var n = "Scene3D" === r.data.type ? vn._parseScene(r, e._propertyParams, e._constructParams) : vn._parse(r, e._propertyParams, e._constructParams);
            Nn._endLoad(e, n, i)
        }
        static _loadMesh(e) {
            e.on(t.Event.LOADED, null, Nn._onMeshLmLoaded, [e]), e.load(e.url, t.Loader.BUFFER, !1, null, !0)
        }
        static _onMeshLmLoaded(e, t) {
            e._cache = e._createCache;
            var r = xn._parse(t, e._propertyParams, e._constructParams);
            Nn._endLoad(e, r)
        }
        static _loadMaterial(e) {
            e.on(t.Event.LOADED, null, Nn._onMaterilLmatLoaded, [e]), e.load(e.url, t.Loader.JSON, !1, null, !0)
        }
        static _onMaterilLmatLoaded(e, r) {
            var i, n = e.url,
                a = N.getURLVerion(n),
                s = t.URL.getPath(n),
                o = [],
                l = [];
            r.customProps;
            switch (r.version) {
                case "LAYAMATERIAL:01":
                case "LAYAMATERIAL:02":
                    var _, h, c = r.props.textures;
                    if (c)
                        for (_ = 0, h = c.length; _ &lt; h; _++) {
                            var d = c[_],
                                u = d.path;
                            u &amp;&amp; (i = Nn.formatRelativePath(s, u), a &amp;&amp; (i += a), o.push({
                                url: i,
                                constructParams: d.constructParams,
                                propertyParams: d.propertyParams
                            }), l.push(i), d.path = i)
                        }
                    break;
                default:
                    throw new Error("Laya3D:unkonwn version.")
            }
            var m = o.length,
                f = m + 1,
                T = 1 / f;
            if (Nn._onProcessChange(e, 0, T, 1), m &gt; 0) {
                var E = t.Handler.create(null, Nn._onProcessChange, [e, T, m / f], !1);
                Nn._innerFourthLevelLoaderManager._create(o, !1, t.Handler.create(null, Nn._onMateialTexturesLoaded, [e, E, r, l]), E, null, null, null, 1, !0)
            } else Nn._onMateialTexturesLoaded(e, null, r, null)
        }
        static _onMateialTexturesLoaded(e, t, r, i) {
            e._cache = e._createCache;
            var n = Te._parse(r, e._propertyParams, e._constructParams);
            Nn._endLoad(e, n, i), t &amp;&amp; t.recover()
        }
        static _loadAvatar(e) {
            e.on(t.Event.LOADED, null, function(t) {
                e._cache = e._createCache;
                var r = fe._parse(t, e._propertyParams, e._constructParams);
                Nn._endLoad(e, r)
            }), e.load(e.url, t.Loader.JSON, !1, null, !0)
        }
        static _loadAnimationClip(e) {
            e.on(t.Event.LOADED, null, function(t) {
                e._cache = e._createCache;
                var r = Z._parse(t, e._propertyParams, e._constructParams);
                Nn._endLoad(e, r)
            }), e.load(e.url, t.Loader.BUFFER, !1, null, !0)
        }
        static _loadTexture2D(e) {
            var r, i = e.url,
                n = i.lastIndexOf(".") + 1,
                a = i.indexOf("?"),
                s = -1 == a ? i.length : a;
            switch (i.substr(n, s - n)) {
                case "jpg":
                case "jpeg":
                case "bmp":
                case "gif":
                case "png":
                    r = "nativeimage";
                    break;
                case "dds":
                case "ktx":
                case "pvr":
                    r = t.Loader.BUFFER
            }
            e.on(t.Event.LOADED, null, function(r) {
                e._cache = e._createCache;
                var i = t.Texture2D._parse(r, e._propertyParams, e._constructParams);
                Nn._endLoad(e, i)
            }), e.load(e.url, r, !1, null, !0)
        }
        static _loadTextureCube(e) {
            e.on(t.Event.LOADED, null, Nn._onTextureCubeLtcLoaded, [e]), e.load(e.url, t.Loader.JSON, !1, null, !0)
        }
        static _loadTextureCubeBin(e) {
            e.on(t.Event.LOADED, null, r =&gt; {
                e._cache = e._createCache;
                var i = new t.Byte(r);
                if ("LAYATEXTURECUBE:0000" !== i.readUTFString()) throw "Laya3D:unknow version.";
                var n = i.readUint8(),
                    a = i.getUint8(),
                    s = i.readUint16(),
                    o = i.getUint8(),
                    l = i.getUint8(),
                    _ = i.getUint8(),
                    h = i.getUint8(),
                    c = new Mt(s, n, a &gt; 1);
                c.filterMode = o, c.wrapModeU = l, c.wrapModeV = _, c.anisoLevel = h;
                for (var d = i.pos, u = s, m = 0; m &lt; a; m++) {
                    for (var f = new Array(6), T = u * u * c._getFormatByteCount(), E = 0; E &lt; 6; E++) f[E] = new Uint8Array(r, d, T), d += T;
                    c.setSixSidePixels(f, m), u /= 2
                }
                Nn._endLoad(e, c)
            }), e.load(e.url, t.Loader.BUFFER, !1, null, !0)
        }
        static _onTextureCubeLtcLoaded(e, r) {
            var i = t.URL.getPath(e.url),
                n = [Nn.formatRelativePath(i, r.front), Nn.formatRelativePath(i, r.back), Nn.formatRelativePath(i, r.left), Nn.formatRelativePath(i, r.right), Nn.formatRelativePath(i, r.up), Nn.formatRelativePath(i, r.down)];
            Nn._onProcessChange(e, 0, 1 / 7, 1);
            var a = t.Handler.create(null, Nn._onProcessChange, [e, 1 / 7, 6 / 7], !1);
            Nn._innerFourthLevelLoaderManager.load(n, t.Handler.create(null, Nn._onTextureCubeImagesLoaded, [e, n, a]), a, "nativeimage")
        }
        static _onTextureCubeImagesLoaded(e, r, i) {
            for (var n = new Array(6), a = 0; a &lt; 6; a++) n[a] = t.Loader.getRes(r[a]);
            e._cache = e._createCache;
            var s = Mt._parse(n, e._propertyParams, e._constructParams);
            for (i.recover(), a = 0; a &lt; 6; a++) t.Loader.clearRes(r[a]);
            Nn._endLoad(e, s)
        }
        static _onProcessChange(e, r, i, n) {
            (n = r + n * i) &lt; 1 &amp;&amp; e.event(t.Event.PROGRESS, 2 * n / 3 + 1 / 3)
        }
        static init(e, t, r = null, i = null) {
            if (Nn._isInit) i &amp;&amp; i.run();
            else {
                Nn._isInit = !0, r &amp;&amp; r.cloneTo(B._config), r = B._config, ke.debugFrustumCulling = r.debugFrustumCulling, Nn._editerEnvironment = r._editerEnvironment, sr.octreeCulling = r.octreeCulling, sr.octreeInitialSize = r.octreeInitialSize, sr.octreeInitialCenter = r.octreeInitialCenter, sr.octreeMinNodeSize = r.octreeMinNodeSize, sr.octreeLooseness = r.octreeLooseness;
                var n = window.Physics3D;
                null == n || r.isUseCannonPhysicsEngine ? (V._enablePhysics = !1, Nn.__init__(e, t, r), i &amp;&amp; i.run()) : (V._enablePhysics = !0, n(16 * r.defaultPhysicsMemory, pi._interactive).then(function() {
                    Nn.__init__(e, t, r), i &amp;&amp; i.run()
                }))
            }
        }
    }
    Nn.HIERARCHY = "HIERARCHY", Nn.MESH = "MESH", Nn.MATERIAL = "MATERIAL", Nn.TEXTURE2D = "TEXTURE2D", Nn.TEXTURECUBE = "TEXTURECUBE", Nn.TEXTURECUBEBIN = "TEXTURECUBEBIN", Nn.ANIMATIONCLIP = "ANIMATIONCLIP", Nn.AVATAR = "AVATAR", Nn.TERRAINHEIGHTDATA = "TERRAINHEIGHTDATA", Nn.TERRAINRES = "TERRAIN", Nn._innerFirstLevelLoaderManager = new t.LoaderManager, Nn._innerSecondLevelLoaderManager = new t.LoaderManager, Nn._innerThirdLevelLoaderManager = new t.LoaderManager, Nn._innerFourthLevelLoaderManager = new t.LoaderManager, Nn._isInit = !1, Nn._editerEnvironment = !1, Nn.physicsSettings = new Dt, window.Laya3D = Nn;
    class bn extends t.Component {
        constructor() {
            super(...arguments), this._indexInPool = -1
        }
        get isSingleton() {
            return !1
        }
        _checkProcessTriggers() {
            var e = bn.prototype;
            return this.onTriggerEnter !== e.onTriggerEnter || (this.onTriggerStay !== e.onTriggerStay || this.onTriggerExit !== e.onTriggerExit)
        }
        _checkProcessCollisions() {
            var e = bn.prototype;
            return this.onCollisionEnter !== e.onCollisionEnter || (this.onCollisionStay !== e.onCollisionStay || this.onCollisionExit !== e.onCollisionExit)
        }
        _onAwake() {
            this.onAwake(), this.onStart !== bn.prototype.onStart &amp;&amp; t.Laya.startTimer.callLater(this, this.onStart)
        }
        _onEnable() {
            this.owner._scene._addScript(this), this.onEnable()
        }
        _onDisable() {
            this.owner._scene._removeScript(this), this.owner.offAllCaller(this), this.onDisable()
        }
        _onDestroy() {
            var e = this.owner._scripts;
            e.splice(e.indexOf(this), 1);
            var t = this.owner;
            t._needProcessTriggers = !1;
            for (var r = 0, i = e.length; r &lt; i; r++)
                if (e[r]._checkProcessTriggers()) {
                    t._needProcessTriggers = !0;
                    break
                }
            for (t._needProcessCollisions = !1, r = 0, i = e.length; r &lt; i; r++)
                if (e[r]._checkProcessCollisions()) {
                    t._needProcessCollisions = !0;
                    break
                }
            this.onDestroy()
        }
        _isScript() {
            return !0
        }
        _onAdded() {
            var e = this.owner,
                t = e._scripts;
            t || (e._scripts = t = []), t.push(this), e._needProcessCollisions || (e._needProcessCollisions = this._checkProcessCollisions()), e._needProcessTriggers || (e._needProcessTriggers = this._checkProcessTriggers())
        }
        onAwake() {}
        onEnable() {}
        onStart() {}
        onTriggerEnter(e) {}
        onTriggerStay(e) {}
        onTriggerExit(e) {}
        onCollisionEnter(e) {}
        onCollisionStay(e) {}
        onCollisionExit(e) {}
        onJointBreak() {}
        onMouseDown() {}
        onMouseDrag() {}
        onMouseClick() {}
        onMouseUp() {}
        onMouseEnter() {}
        onMouseOver() {}
        onMouseOut() {}
        onUpdate() {}
        onLateUpdate() {}
        onPreRender() {}
        onPostRender() {}
        onDisable() {}
        onDestroy() {}
    }
    class Pn {
        constructor(e, t, r, i) {
            this._datas = [], this._w = e, this._h = t, this._minHeight = r, this._maxHeight = i
        }
        static creatFromMesh(e, t, r, i) {
            for (var n = [], s = [], o = e.subMeshCount, l = 0; l &lt; o; l++) {
                for (var _ = e.getSubMesh(l), h = _._vertexBuffer, c = h.getFloat32Data(), d = [], u = 0; u &lt; c.length; u += h.vertexDeclaration.vertexStride / 4) {
                    var m = new a(c[u + 0], c[u + 1], c[u + 2]);
                    d.push(m)
                }
                n.push(d);
                var f = _._indexBuffer;
                s.push(f.getData())
            }
            var T = e.bounds,
                E = T.getMin().x,
                p = T.getMin().z,
                g = T.getMax().x,
                S = T.getMax().z,
                R = T.getMin().y,
                v = T.getMax().y,
                A = g - E,
                I = S - p,
                x = i.x = A / (t - 1),
                L = i.y = I / (r - 1),
                D = new Pn(t, r, R, v),
                C = Pn._tempRay,
                y = C.direction;
            y.x = 0, y.y = -1, y.z = 0;
            var M = v + .1;
            C.origin.y = M;
            for (var O = 0; O &lt; r; O++) {
                var N = p + O * L;
                D._datas[O] = [];
                for (var b = 0; b &lt; t; b++) {
                    var P = E + b * x,
                        w = C.origin;
                    w.x = P, w.z = N;
                    var V = Pn._getPosition(C, n, s);
                    D._datas[O][b] = V === Number.MAX_VALUE ? NaN : M - V
                }
            }
            return D
        }
        static createFromImage(e, t, r) {
            for (var i = e.width, n = e.height, a = new Pn(i, n, t, r), s = (r - t) / 254, o = e.getPixels(), l = 0, _ = 0; _ &lt; n; _++)
                for (var h = a._datas[_] = [], c = 0; c &lt; i; c++) {
                    var d = o[l++],
                        u = o[l++],
                        m = o[l++],
                        f = o[l++];
                    h[c] = 255 == d &amp;&amp; 255 == u &amp;&amp; 255 == m &amp;&amp; 255 == f ? NaN : (d + u + m) / 3 * s + t
                }
            return a
        }
        static _getPosition(e, t, r) {
            for (var i = Number.MAX_VALUE, n = 0; n &lt; t.length; n++)
                for (var a = t[n], s = r[n], o = 0; o &lt; s.length; o += 3) {
                    var l = a[s[o + 0]],
                        _ = a[s[o + 1]],
                        h = a[s[o + 2]],
                        c = rt.rayIntersectsTriangle(e, l, _, h);
                    !isNaN(c) &amp;&amp; c &lt; i &amp;&amp; (i = c)
                }
            return i
        }
        get width() {
            return this._w
        }
        get height() {
            return this._h
        }
        get maxHeight() {
            return this._maxHeight
        }
        get minHeight() {
            return this._minHeight
        }
        _inBounds(e, t) {
            return e &gt;= 0 &amp;&amp; e &lt; this._h &amp;&amp; t &gt;= 0 &amp;&amp; t &lt; this._w
        }
        getHeight(e, t) {
            return this._inBounds(e, t) ? this._datas[e][t] : NaN
        }
    }
    Pn._tempRay = new Ke(new a, new a);
    class wn extends Lr {
        constructor(e, t, r = null) {
            super(e, r), this._heightMap = t, this._cellSize = new i
        }
        static createFromMesh(e, t, r, i = null) {
            var n = new wn(e, null, i);
            return n._initCreateFromMesh(t, r), n
        }
        static createFromMeshAndHeightMap(e, t, r, i, n = null) {
            var a = new wn(e, null, n);
            return a._initCreateFromMeshHeightMap(t, r, i), a
        }
        get minX() {
            var e = this.transform.worldMatrix.elements;
            return this._minX * this._getScaleX() + e[12]
        }
        get minZ() {
            var e = this.transform.worldMatrix.elements;
            return this._minZ * this._getScaleZ() + e[14]
        }
        get width() {
            return (this._heightMap.width - 1) * this._cellSize.x * this._getScaleX()
        }
        get depth() {
            return (this._heightMap.height - 1) * this._cellSize.y * this._getScaleZ()
        }
        _disableRotation() {
            var e = this.transform.rotation;
            e.x = 0, e.y = 0, e.z = 0, e.w = 1, this.transform.rotation = e
        }
        _getScaleX() {
            var e = this.transform.worldMatrix.elements,
                t = e[0],
                r = e[1],
                i = e[2];
            return Math.sqrt(t * t + r * r + i * i)
        }
        _getScaleZ() {
            var e = this.transform.worldMatrix.elements,
                t = e[8],
                r = e[9],
                i = e[10];
            return Math.sqrt(t * t + r * r + i * i)
        }
        _initCreateFromMesh(e, t) {
            this._heightMap = Pn.creatFromMesh(this.meshFilter.sharedMesh, e, t, this._cellSize);
            var r = this.meshFilter.sharedMesh.bounds,
                i = r.getMin();
            r.getMax();
            this._minX = i.x, this._minZ = i.z
        }
        _initCreateFromMeshHeightMap(e, t, r) {
            var i = this.meshFilter.sharedMesh.bounds;
            this._heightMap = Pn.createFromImage(e, t, r), this._computeCellSize(i);
            var n = i.getMin();
            i.getMax();
            this._minX = n.x, this._minZ = n.z
        }
        _computeCellSize(e) {
            var t = e.getMin(),
                r = e.getMax(),
                i = t.x,
                n = t.z,
                a = r.x - i,
                s = r.z - n;
            this._cellSize.x = a / (this._heightMap.width - 1), this._cellSize.y = s / (this._heightMap.height - 1)
        }
        _update(e) {
            this._disableRotation()
        }
        getHeight(e, t) {
            wn._tempVector3.x = e, wn._tempVector3.y = 0, wn._tempVector3.z = t, this._disableRotation();
            var r = this.transform.worldMatrix;
            r.invert(wn._tempMatrix4x4), a.transformCoordinate(wn._tempVector3, wn._tempMatrix4x4, wn._tempVector3), e = wn._tempVector3.x, t = wn._tempVector3.z;
            var i = (e - this._minX) / this._cellSize.x,
                n = (t - this._minZ) / this._cellSize.y,
                s = Math.floor(n),
                o = Math.floor(i),
                l = i - o,
                _ = n - s,
                h = r.elements,
                c = h[4],
                d = h[5],
                u = h[6],
                m = Math.sqrt(c * c + d * d + u * u),
                f = h[13],
                T = this._heightMap.getHeight(s, o + 1),
                E = this._heightMap.getHeight(s + 1, o);
            if (isNaN(T) || isNaN(E)) return NaN;
            if (l + _ &lt;= 1) {
                var p = this._heightMap.getHeight(s, o);
                return isNaN(p) ? NaN : (p + l * (T - p) + _ * (E - p)) * m + f
            }
            var g = this._heightMap.getHeight(s + 1, o + 1);
            return isNaN(g) ? NaN : (g + (1 - l) * (E - g) + (1 - _) * (T - g)) * m + f
        }
    }
    wn._tempVector3 = new a, wn._tempMatrix4x4 = new c;
    class Vn {
        constructor() {
            this._currentLength = 0, this._elements = new Float32Array(12)
        }
        get gradientCount() {
            return this._currentLength / 3
        }
        add(e, t) {
            this._currentLength &lt; 8 ? (6 === this._currentLength &amp;&amp; 1 !== e &amp;&amp; (e = 1, console.log("GradientDataVector2 warning:the forth key is  be force set to 1.")), this._elements[this._currentLength++] = e, this._elements[this._currentLength++] = t.x, this._elements[this._currentLength++] = t.y) : console.log("GradientDataVector2 warning:data count must lessEqual than 4")
        }
        cloneTo(e) {
            var t = e;
            t._currentLength = this._currentLength;
            for (var r = t._elements, i = 0, n = this._elements.length; i &lt; n; i++) r[i] = this._elements[i]
        }
        clone() {
            var e = new Vn;
            return this.cloneTo(e), e
        }
    }
    class Bn {
        constructor() {}
        render(e) {}
    }
    class Fn extends Bn {
        constructor() {
            super(), this._shader = null, this._shaderData = new ce, this._linearColor = new ze, this._bloomTextureTexelSize = new n, this._shaderThreshold = new n, this._shaderParams = new n, this._pyramid = null, this._intensity = 0, this._threshold = 1, this._softKnee = .5, this._diffusion = 7, this._anamorphicRatio = 0, this._dirtIntensity = 0, this._shaderSetting = new n, this._dirtTileOffset = new n, this.clamp = 65472, this.color = new ze(1, 1, 1, 1), this.fastMode = !1, this.dirtTexture = null, this._shader = he.find("PostProcessBloom"), this._pyramid = new Array(2 * Fn.MAXPYRAMIDSIZE)
        }
        get intensity() {
            return this._intensity
        }
        set intensity(e) {
            this._intensity = Math.max(e, 0)
        }
        get threshold() {
            return this._threshold
        }
        set threshold(e) {
            this._threshold = Math.max(e, 0)
        }
        get softKnee() {
            return this._softKnee
        }
        set softKnee(e) {
            this._softKnee = Math.min(Math.max(e, 0), 1)
        }
        get diffusion() {
            return this._diffusion
        }
        set diffusion(e) {
            this._diffusion = Math.min(Math.max(e, 1), 10)
        }
        get anamorphicRatio() {
            return this._anamorphicRatio
        }
        set anamorphicRatio(e) {
            this._anamorphicRatio = Math.min(Math.max(e, -1), 1)
        }
        get dirtIntensity() {
            return this._dirtIntensity
        }
        set dirtIntensity(e) {
            this._dirtIntensity = Math.max(e, 0)
        }
        render(e) {
            var r = e.command,
                i = e.camera.viewport;
            this._shaderData.setTexture(Fn.SHADERVALUE_AUTOEXPOSURETEX, t.Texture2D.whiteTexture);
            var a, s = this._anamorphicRatio,
                o = s &lt; 0 ? -s : 0,
                l = s &gt; 0 ? s : 0,
                _ = Math.floor(i.width / (2 - o)),
                h = Math.floor(i.height / (2 - l)),
                c = Math.max(_, h);
            a = Math.log2(c) + this._diffusion - 10;
            var d = Math.floor(a),
                u = Math.min(Math.max(d, 1), Fn.MAXPYRAMIDSIZE),
                m = .5 + a - d;
            this._shaderData.setNumber(Fn.SHADERVALUE_SAMPLESCALE, m);
            var f = ze.gammaToLinearSpace(this.threshold),
                T = f * this._softKnee + 1e-5;
            this._shaderThreshold.setValue(f, f - T, 2 * T, .25 / T), this._shaderData.setVector(Fn.SHADERVALUE_THRESHOLD, this._shaderThreshold);
            var E = ze.gammaToLinearSpace(this.clamp);
            this._shaderParams.setValue(E, 0, 0, 0), this._shaderData.setVector(Fn.SHADERVALUE_PARAMS, this._shaderParams);
            for (var p = this.fastMode ? 1 : 0, g = e.source, S = 0; S &lt; u; S++) {
                var R = 2 * S,
                    v = R + 1,
                    A = 0 == S ? Fn.SUBSHADER_PREFILTER13 + p : Fn.SUBSHADER_DOWNSAMPLE13 + p,
                    I = ae.createFromPool(_, h, t.RenderTextureFormat.R8G8B8, t.RenderTextureDepthFormat.DEPTHSTENCIL_NONE);
                if (I.filterMode = t.FilterMode.Bilinear, this._pyramid[R] = I, S !== u - 1) {
                    var x = ae.createFromPool(_, h, t.RenderTextureFormat.R8G8B8, t.RenderTextureDepthFormat.DEPTHSTENCIL_NONE);
                    x.filterMode = t.FilterMode.Bilinear, this._pyramid[v] = x
                }
                r.blitScreenTriangle(g, I, null, this._shader, this._shaderData, A), g = I, _ = Math.max(Math.floor(_ / 2), 1), h = Math.max(Math.floor(h / 2), 1)
            }
            var L = this._pyramid[2 * (u - 1)];
            for (S = u - 2; S &gt;= 0; S--) v = (R = 2 * S) + 1, I = this._pyramid[R], x = this._pyramid[v], r.setShaderDataTexture(this._shaderData, Fn.SHADERVALUE_BLOOMTEX, I), r.blitScreenTriangle(L, x, null, this._shader, this._shaderData, Fn.SUBSHADER_UPSAMPLETENT + p), L = x;
            var D = this._linearColor;
            this.color.toLinear(D);
            var C = Math.pow(2, this._intensity / 10) - 1,
                y = this._shaderSetting;
            this._shaderSetting.setValue(m, C, this._dirtIntensity, u);
            var M = this.dirtTexture ? this.dirtTexture : t.Texture2D.blackTexture,
                O = M.width / M.height,
                N = i.width / i.height,
                b = this._dirtTileOffset;
            O &gt; N ? b.setValue(N / O, 1, .5 * (1 - b.x), 0) : O &lt; N &amp;&amp; b.setValue(1, O / N, 0, .5 * (1 - b.y));
            var P = e.compositeShaderData;
            for (this.fastMode ? P.addDefine(de.SHADERDEFINE_BLOOM_LOW) : P.addDefine(de.SHADERDEFINE_BLOOM), this._bloomTextureTexelSize.setValue(1 / L.width, 1 / L.height, L.width, L.height), P.setVector(de.SHADERVALUE_BLOOM_DIRTTILEOFFSET, b), P.setVector(de.SHADERVALUE_BLOOM_SETTINGS, y), P.setVector(de.SHADERVALUE_BLOOM_COLOR, new n(D.r, D.g, D.b, D.a)), P.setTexture(de.SHADERVALUE_BLOOM_DIRTTEX, M), P.setTexture(de.SHADERVALUE_BLOOMTEX, L), P.setVector(de.SHADERVALUE_BLOOMTEX_TEXELSIZE, this._bloomTextureTexelSize), S = 0; S &lt; u; S++) v = (R = 2 * S) + 1, ae.recoverToPool(this._pyramid[R]), 0 !== S &amp;&amp; S !== u - 1 &amp;&amp; ae.recoverToPool(this._pyramid[v]);
            e.deferredReleaseTextures.push(L)
        }
    }
    Fn.SHADERVALUE_MAINTEX = he.propertyNameToID("u_MainTex"), Fn.SHADERVALUE_AUTOEXPOSURETEX = he.propertyNameToID("u_AutoExposureTex"), Fn.SHADERVALUE_SAMPLESCALE = he.propertyNameToID("u_SampleScale"), Fn.SHADERVALUE_THRESHOLD = he.propertyNameToID("u_Threshold"), Fn.SHADERVALUE_PARAMS = he.propertyNameToID("u_Params"), Fn.SHADERVALUE_BLOOMTEX = he.propertyNameToID("u_BloomTex"), Fn.SUBSHADER_PREFILTER13 = 0, Fn.SUBSHADER_PREFILTER4 = 1, Fn.SUBSHADER_DOWNSAMPLE13 = 2, Fn.SUBSHADER_DOWNSAMPLE4 = 3, Fn.SUBSHADER_UPSAMPLETENT = 4, Fn.SUBSHADER_UPSAMPLEBOX = 5, Fn.MAXPYRAMIDSIZE = 16;
    class Un {
        constructor(e) {
            if (!(e instanceof Array) || 4 !== e.length) throw new Error("Rand:Seed must be an array with 4 numbers");
            this._state0U = 0 | e[0], this._state0L = 0 | e[1], this._state1U = 0 | e[2], this._state1L = 0 | e[3]
        }
        randomint() {
            var e = this._state0U,
                t = this._state0L,
                r = this._state1U,
                i = this._state1L,
                n = (i &gt;&gt;&gt; 0) + (t &gt;&gt;&gt; 0),
                a = r + e + (n / 2 &gt;&gt;&gt; 31) &gt;&gt;&gt; 0,
                s = n &gt;&gt;&gt; 0;
            this._state0U = r, this._state0L = i;
            var o = 0,
                l = 0;
            o = (e ^= o = e &lt;&lt; 23 | (-512 &amp; t) &gt;&gt;&gt; 9) ^ r, l = (t ^= l = t &lt;&lt; 23) ^ i;
            o ^= e &gt;&gt;&gt; 18, l ^= t &gt;&gt;&gt; 18 | (262143 &amp; e) &lt;&lt; 14;
            return o ^= r &gt;&gt;&gt; 5, l ^= i &gt;&gt;&gt; 5 | (31 &amp; r) &lt;&lt; 27, this._state1U = o, this._state1L = l, [a, s]
        }
        random() {
            var e = this.randomint(),
                t = e[0],
                r = 1023 &lt;&lt; 20 | t &gt;&gt;&gt; 12,
                i = 0 | (e[1] &gt;&gt;&gt; 12 | (4095 &amp; t) &lt;&lt; 20);
            return Un._CONVERTION_BUFFER.setUint32(0, r, !1), Un._CONVERTION_BUFFER.setUint32(4, i, !1), Un._CONVERTION_BUFFER.getFloat64(0, !1) - 1
        }
    }
    Un._CONVERTION_BUFFER = new DataView(new ArrayBuffer(8)), Un.defaultRand = new Un([0, Date.now() / 65536, 0, Date.now() % 65536]);
    class Gn {
        constructor(e, t) {
            this._width = 0, this._height = 0, this._width = e, this._height = t
        }
        static get fullScreen() {
            return new Gn(-1, -1)
        }
        get width() {
            return -1 === this._width ? ne.clientWidth : this._width
        }
        get height() {
            return -1 === this._height ? ne.clientHeight : this._height
        }
    }
    e.AlternateLightQueue = Nt, e.AnimationClip = Z, e.AnimationClipParser03 = k, e.AnimationClipParser04 = Y, e.AnimationEvent = U, e.AnimationNode = me, e.AnimationTransform3D = ue, e.Animator = re, e.AnimatorControllerLayer = Q, e.AnimatorPlayState = q, e.AnimatorState = ee, e.AnimatorStateScript = class {
        constructor() {}
        onStateEnter() {}
        onStateUpdate() {}
        onStateExit() {}
    }, e.Avatar = fe, e.BaseCamera = mt, e.BaseMaterial = Ee, e.BaseRender = jt, e.BaseShape = Ur, e.BatchMark = Gt, e.BlinnPhongMaterial = ge, e.BlitScreenQuadCMD = pt, e.BloomEffect = Fn, e.BoundBox = Pt, e.BoundFrustum = et, e.BoundSphere = tr, e.Bounds = wt, e.BoundsOctree = $t, e.BoundsOctreeNode = Kt, e.BoxColliderShape = E, e.BoxShape = zr, e.BufferState = it, e.BulletInteractive = pi, e.Burst = yr, e.Camera = xt, e.CameraCullInfo = He, e.CapsuleColliderShape = p, e.CastShadowList = class extends I {
        constructor() {
            super()
        }
        add(e) {
            if (-1 !== e._indexInCastShadowList) throw "CastShadowList:element has  in  CastShadowList.";
            this._add(e), e._indexInCastShadowList = this.length++
        }
        remove(e) {
            var t = e._indexInCastShadowList;
            if (this.length--, t !== this.length) {
                var r = this.elements[this.length];
                this.elements[t] = r, r._indexInCastShadowList = t
            }
            e._indexInCastShadowList = -1
        }
    }, e.CharacterController = b, e.CircleShape = Hr, e.Cluster = Ye, e.ColliderShape = d, e.Collision = C, e.CollisionTool = y, e.CollisionUtils = $e, e.Color = ze, e.ColorOverLifetime = Or, e.Command = Et, e.CommandBuffer = Rt, e.CompoundColliderShape = m, e.ConchQuaternion = $, e.ConchVector3 = J, e.ConchVector4 = K, e.ConeColliderShape = g, e.ConeShape = Wr, e.Config3D = B, e.ConfigurableConstraint = On, e.Constraint3D = class {
        constructor() {}
    }, e.ConstraintComponent = yn, e.ContactPoint = L, e.ContainmentType = Je, e.CylinderColliderShape = S, e.DefineDatas = se, e.DirectionLight = gn, e.DynamicBatchManager = ar, e.EffectMaterial = Se, e.Emission = ii, e.ExtendTerrainMaterial = Re, e.FixedConstraint = Mn, e.FloatKeyframe = z, e.FrameOverTime = Nr, e.FrustumCulling = ke, e.GeometryElement = Vt, e.Gradient = Cr, e.GradientAngularVelocity = br, e.GradientColor = Mr, e.GradientDataInt = Pr, e.GradientDataNumber = wr, e.GradientDataVector2 = Vn, e.GradientMode = Dr, e.GradientSize = Vr, e.GradientVelocity = Br, e.HalfFloatUtils = X, e.HeightMap = Pn, e.HeightfieldColliderShape = class {
        constructor() {}
    }, e.HemisphereShape = kr, e.HitResult = D, e.ILaya3D = _, e.IndexBuffer3D = nt, e.Input3D = Lt, e.Keyframe = G, e.KeyframeNode = F, e.KeyframeNodeList = j, e.KeyframeNodeOwner = te, e.Laya3D = Nn, e.LightQueue = Ot, e.LightSprite = At, e.Lightmap = er, e.LoadModelV04 = An, e.LoadModelV05 = In, e.Material = Te, e.MathUtils3D = r, e.Matrix3x3 = l, e.Matrix4x4 = c, e.Mesh = vi, e.MeshColliderShape = R, e.MeshFilter = Ar, e.MeshReader = xn, e.MeshRenderDynamicBatchManager = xr, e.MeshRenderStaticBatchManager = Yt, e.MeshRenderer = vr, e.MeshSprite3D = Lr, e.MeshSprite3DShaderDeclaration = Rr, e.MeshTerrainSprite3D = wn, e.MouseTouch = Ze, e.OctreeMotionList = Jt, e.PBRMaterial = ve, e.PBRSpecularMaterial = _r, e.PBRStandardMaterial = Tr, e.Physics3D = V, e.Physics3DUtils = T, e.PhysicsCollider = gi, e.PhysicsComponent = A, e.PhysicsSettings = Dt, e.PhysicsSimulation = M, e.PhysicsTriggerComponent = P, e.PhysicsUpdateList = x, e.Picker = rt, e.PixelLineData = class {
        constructor() {
            this.startPosition = new a, this.endPosition = new a, this.startColor = new ze, this.endColor = new ze
        }
        cloneTo(e) {
            this.startPosition.cloneTo(e.startPosition), this.endPosition.cloneTo(e.endPosition), this.startColor.cloneTo(e.startColor), this.endColor.cloneTo(e.endColor)
        }
    }, e.PixelLineFilter = Ft, e.PixelLineMaterial = bt, e.PixelLineRenderer = Zt, e.PixelLineSprite3D = qt, e.PixelLineVertex = Bt, e.Plane = Qe, e.Point2PointConstraint = class {
        constructor() {
            this._pivotInA = new a, this._pivotInB = new a
        }
        get pivotInA() {
            return this._pivotInA
        }
        set pivotInA(e) {
            this._pivotInA = e
        }
        get pivotInB() {
            return this._pivotInB
        }
        set pivotInB(e) {
            this._pivotInB = e
        }
        get damping() {
            return this._damping
        }
        set damping(e) {
            this._damping = e
        }
        get impulseClamp() {
            return this._impulseClamp
        }
        set impulseClamp(e) {
            this._impulseClamp = e
        }
        get tau() {
            return this._tau
        }
        set tau(e) {
            this._tau = e
        }
    }, e.PointLight = Sn, e.PostProcess = de, e.PostProcessEffect = Bn, e.PostProcessRenderContext = ie, e.PrimitiveMesh = Ai, e.Quaternion = h, e.QuaternionKeyframe = H, e.Rand = ri, e.RandX = Un, e.Ray = Ke, e.RenderContext3D = ne, e.RenderElement = Ht, e.RenderQueue = Qt, e.RenderState = pe, e.RenderTexture = ae, e.RenderableSprite3D = Ut, e.Rigidbody3D = w, e.RotationOverLifetime = Fr, e.Scene3D = sr, e.Scene3DShaderDeclaration = vt, e.Scene3DUtils = vn, e.SceneManager = class {
        constructor() {}
    }, e.ScreenQuad = ft, e.ScreenTriangle = Tt, e.Script3D = bn, e.SetRenderTargetCMD = gt, e.SetShaderDataTextureCMD = St, e.Shader3D = he, e.ShaderData = ce, e.ShaderDefine = oe, e.ShaderInit3D = pn, e.ShaderInstance = Ue, e.ShaderPass = or, e.ShaderVariable = Fe, e.ShaderVariant = le, e.ShaderVariantCollection = _e, e.ShadowCasterPass = nr, e.ShadowCullInfo = We, e.ShadowSliceData = rr, e.ShadowSpotData = ir, e.ShadowUtils = It, e.ShapeUtils = Gr, e.ShuriKenParticle3D = si, e.ShuriKenParticle3DShaderDeclaration = Qr, e.ShurikenParticleData = ni, e.ShurikenParticleMaterial = Kr, e.ShurikenParticleRenderer = Jr, e.ShurikenParticleSystem = ai, e.SimpleSingletonList = Ge, e.SingletonList = I, e.Size = Gn, e.SizeOverLifetime = Yr, e.SkinnedMeshRenderer = li, e.SkinnedMeshSprite3D = _i, e.SkinnedMeshSprite3DShaderDeclaration = oi, e.SkyBox = ct, e.SkyBoxMaterial = Er, e.SkyDome = yt, e.SkyMesh = ht, e.SkyPanoramicMaterial = Cn, e.SkyProceduralMaterial = pr, e.SkyRenderer = dt, e.SphereColliderShape = v, e.SphereShape = Xr, e.SphericalHarmonicsL2 = je, e.SpotLight = Rn, e.Sprite3D = ut, e.StartFrame = jr, e.StaticBatchManager = kt, e.StaticPlaneColliderShape = u, e.SubMesh = Si, e.SubMeshDynamicBatch = Ir, e.SubMeshInstanceBatch = zt, e.SubMeshRenderElement = Wt, e.SubMeshStaticBatch = Xt, e.SubShader = lr, e.TextMesh = class {
        constructor() {}
        get text() {
            return this._text
        }
        set text(e) {
            this._text = e
        }
        get fontSize() {
            return this._fontSize
        }
        set fontSize(e) {
            this._fontSize = e
        }
        get color() {
            return this._color
        }
        set color(e) {
            this._color = e
        }
        _createVertexBuffer(e) {}
        _resizeVertexBuffer(e) {}
        _addChar() {}
    }, e.TextureCube = Mt, e.TextureGenerator = O, e.TextureMode = ci, e.TextureSheetAnimation = Zr, e.Touch = qe, e.TrailFilter = mi, e.TrailGeometry = ui, e.TrailMaterial = hi, e.TrailRenderer = fi, e.TrailSprite3D = Ti, e.Transform3D = f, e.UnlitMaterial = gr, e.Utils3D = N, e.Vector2 = i, e.Vector3 = a, e.Vector3Keyframe = W, e.Vector4 = n, e.VelocityOverLifetime = qr, e.VertexBuffer3D = _t, e.VertexDeclaration = st, e.VertexElement = ot, e.VertexElementFormat = at, e.VertexMesh = lt, e.VertexPositionTerrain = Ei, e.VertexPositionTexture0 = Ct, e.VertexShuriKenParticle = $r, e.VertexShurikenParticleBillboard = ei, e.VertexShurikenParticleMesh = ti, e.VertexTrail = di, e.Viewport = tt, e.WaterPrimaryMaterial = Sr, e.skinnedMatrixCache = Ri
}(window.Laya = window.Laya || {}, Laya);</pre></body></html>