@galacean/engine 0.0.0-experimental-2.0-game.12 → 0.0.0-experimental-2.0-game.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -12318,7 +12318,7 @@
12318
12318
  };
12319
12319
  var particle_common = "vec3 rotationByQuaternions(in vec3 v, in vec4 q) {\n return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\n\nvec4 quaternionConjugate(in vec4 q) {\n return vec4(-q.xyz, q.w);\n}\n\nvec3 rotationByEuler(in vec3 vector, in vec3 rot) {\n float halfRoll = rot.z * 0.5;\n float halfPitch = rot.x * 0.5;\n float halfYaw = rot.y * 0.5;\n\n float sinRoll = sin(halfRoll);\n float cosRoll = cos(halfRoll);\n float sinPitch = sin(halfPitch);\n float cosPitch = cos(halfPitch);\n float sinYaw = sin(halfYaw);\n float cosYaw = cos(halfYaw);\n\n float cosYawPitch = cosYaw * cosPitch;\n float sinYawPitch = sinYaw * sinPitch;\n\n float quaX = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);\n float quaY = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);\n float quaZ = (cosYawPitch * sinRoll) - (sinYawPitch * cosRoll);\n float quaW = (cosYawPitch * cosRoll) + (sinYawPitch * sinRoll);\n\n return rotationByQuaternions(vector, vec4(quaX, quaY, quaZ, quaW));\n}\n\n// Assume axis is normalized\nvec3 rotationByAxis(in vec3 vector, in vec3 axis, in float angle) {\n float halfAngle = angle * 0.5;\n float s = sin(halfAngle);\n\n return rotationByQuaternions(vector, vec4(axis * s, cos(halfAngle)));\n}\n\n\nfloat evaluateParticleCurve(in vec2 keys[4], in float normalizedAge) {\n float value;\n for (int i = 1; i < 4; i++) {\n vec2 key = keys[i];\n float time = key.x;\n if (time >= normalizedAge) {\n vec2 lastKey = keys[i - 1];\n float lastTime = lastKey.x;\n float age = (normalizedAge - lastTime) / (time - lastTime);\n value = mix(lastKey.y, key.y, age);\n break;\n }\n }\n return value;\n}\n\nfloat evaluateParticleCurveCumulative(in vec2 keys[4], in float normalizedAge, out float currentValue){\n float cumulativeValue = 0.0;\n for (int i = 1; i < 4; i++){\n\t vec2 key = keys[i];\n\t float time = key.x;\n\t vec2 lastKey = keys[i - 1];\n\t float lastValue = lastKey.y;\n\n\t if (time >= normalizedAge){\n\t\t float lastTime = lastKey.x;\n float offsetTime = normalizedAge - lastTime;\n\t\t float age = offsetTime / (time - lastTime);\n currentValue = mix(lastValue, key.y, age);\n\t\t cumulativeValue += (lastValue + currentValue) * 0.5 * offsetTime;\n\t\t break;\n\t\t}\n\t else{\n\t\t cumulativeValue += (lastValue + key.y) * 0.5 * (time - lastKey.x);\n\t\t}\n\t}\n return cumulativeValue;\n}\n\nvec4 evaluateParticleGradient(in vec4 colorKeys[4], in float colorMaxTime, in vec2 alphaKeys[4], in float alphaMaxTime, in float t) {\n vec4 value;\n\n float alphaT = min(t, alphaMaxTime);\n for (int i = 0; i < 4; i++) {\n vec2 key = alphaKeys[i];\n if (alphaT <= key.x) {\n if (i == 0) {\n value.a = alphaKeys[0].y;\n } else {\n vec2 lastKey = alphaKeys[i - 1];\n float age = (alphaT - lastKey.x) / (key.x - lastKey.x);\n value.a = mix(lastKey.y, key.y, age);\n }\n break;\n }\n }\n\n float colorT = min(t, colorMaxTime);\n for (int i = 0; i < 4; i++) {\n vec4 key = colorKeys[i];\n if (colorT <= key.x) {\n if (i == 0) {\n value.rgb = colorKeys[0].yzw;\n } else {\n vec4 lastKey = colorKeys[i - 1];\n float age = (colorT - lastKey.x) / (key.x - lastKey.x);\n value.rgb = mix(lastKey.yzw, key.yzw, age);\n }\n break;\n }\n }\n\n return value;\n}"; // eslint-disable-line
12320
12320
  var velocity_over_lifetime_module = "#if defined(RENDERER_VOL_CONSTANT_MODE) || defined(RENDERER_VOL_CURVE_MODE)\n #define _VOL_MODULE_ENABLED\n#endif\n\n#ifdef _VOL_MODULE_ENABLED\n uniform int renderer_VOLSpace;\n\n #ifdef RENDERER_VOL_CONSTANT_MODE\n uniform vec3 renderer_VOLMaxConst;\n\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n uniform vec3 renderer_VOLMinConst;\n #endif\n #endif\n\n #ifdef RENDERER_VOL_CURVE_MODE\n uniform vec2 renderer_VOLMaxGradientX[4]; // x:time y:value\n uniform vec2 renderer_VOLMaxGradientY[4]; // x:time y:value\n uniform vec2 renderer_VOLMaxGradientZ[4]; // x:time y:value\n\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n uniform vec2 renderer_VOLMinGradientX[4]; // x:time y:value\n uniform vec2 renderer_VOLMinGradientY[4]; // x:time y:value\n uniform vec2 renderer_VOLMinGradientZ[4]; // x:time y:value\n #endif\n #endif\n\n\n vec3 computeVelocityPositionOffset(in float normalizedAge, in float age, out vec3 currentVelocity) {\n vec3 velocityPosition;\n\n #ifdef RENDERER_VOL_CONSTANT_MODE\n currentVelocity = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n currentVelocity = mix(renderer_VOLMinConst, currentVelocity, a_Random1.yzw);\n #endif\n\n velocityPosition = currentVelocity * age;\n #endif\n\n #ifdef RENDERER_VOL_CURVE_MODE\n velocityPosition = vec3(\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientX, normalizedAge, currentVelocity.x),\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientY, normalizedAge, currentVelocity.y),\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ, normalizedAge, currentVelocity.z));\n\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minCurrentVelocity;\n vec3 minVelocityPosition = vec3(\n evaluateParticleCurveCumulative(renderer_VOLMinGradientX, normalizedAge, minCurrentVelocity.x),\n evaluateParticleCurveCumulative(renderer_VOLMinGradientY, normalizedAge, minCurrentVelocity.y),\n evaluateParticleCurveCumulative(renderer_VOLMinGradientZ, normalizedAge, minCurrentVelocity.z));\n\n currentVelocity = mix(minCurrentVelocity, currentVelocity, a_Random1.yzw);\n velocityPosition = mix(minVelocityPosition, velocityPosition, a_Random1.yzw);\n #endif\n\n velocityPosition *= vec3(a_ShapePositionStartLifeTime.w);\n #endif\n return velocityPosition;\n }\n#endif\n"; // eslint-disable-line
12321
- var rotation_over_lifetime_module = "#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n #ifdef RENDERER_ROL_CURVE_MODE\n uniform vec2 renderer_ROLMaxCurveZ[4];\n #ifdef RENDERER_ROL_IS_SEPARATE\n uniform vec2 renderer_ROLMaxCurveX[4];\n uniform vec2 renderer_ROLMaxCurveY[4];\n #endif\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n uniform vec2 renderer_ROLMinCurveZ[4];\n #ifdef RENDERER_ROL_IS_SEPARATE\n uniform vec2 renderer_ROLMinCurveX[4];\n uniform vec2 renderer_ROLMinCurveY[4];\n #endif\n #endif\n #else\n uniform vec3 renderer_ROLMaxConst;\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n uniform vec3 renderer_ROLMinConst;\n #endif\n #endif\n#endif\n\nfloat computeParticleRotationFloat(in float rotation, in float age, in float normalizedAge) {\n #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n #ifdef RENDERER_ROL_CURVE_MODE\n float currentValue;\n float lifeRotation = evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue);\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ, normalizedAge, currentValue), lifeRotation, a_Random0.w);\n #endif\n rotation += lifeRotation * a_ShapePositionStartLifeTime.w;\n #else\n float lifeRotation = renderer_ROLMaxConst.z;\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(renderer_ROLMinConst.z, lifeRotation, a_Random0.w);\n #endif\n rotation += lifeRotation * age;\n #endif\n #endif\n return rotation;\n}\n\n\n#if defined(RENDERER_MODE_MESH) && (defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE))\nvec3 computeParticleRotationVec3(in vec3 rotation, in float age, in float normalizedAge) {\n #ifdef RENDERER_ROL_IS_SEPARATE\n #ifdef RENDERER_ROL_CONSTANT_MODE\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n vec3 ageRot = mix(renderer_ROLMinConst, renderer_ROLMaxConst, a_Random0.w) * age;\n #else\n vec3 ageRot = renderer_ROLMaxConst * age;\n #endif\n rotation += ageRot;\n #endif\n #ifdef RENDERER_ROL_CURVE_MODE\n float currentValue;\n float lifetime = a_ShapePositionStartLifeTime.w;\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n rotation += vec3(\n mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveX, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveX, normalizedAge, currentValue), a_Random0.w),\n mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveY, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveY, normalizedAge, currentValue), a_Random0.w),\n mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue), a_Random0.w)) * lifetime;\n #else\n rotation += vec3(\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveX, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveY, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue)) * lifetime;\n #endif\n #endif\n #else\n #ifdef RENDERER_ROL_CONSTANT_MODE\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n float ageRot = mix(renderer_ROLMinConst.z, renderer_ROLMaxConst.z, a_Random0.w) * age;\n #else\n float ageRot = renderer_ROLMaxConst.z * age;\n #endif\n rotation += ageRot;\n #endif\n\n #ifdef RENDERER_ROL_CURVE_MODE\n float currentValue;\n float lifeRotation = evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue);\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ, normalizedAge, currentValue), lifeRotation, a_Random0.w);\n #endif\n rotation += lifeRotation * a_ShapePositionStartLifeTime.w;\n #endif\n #endif\n return rotation;\n}\n#endif\n"; // eslint-disable-line
12321
+ var rotation_over_lifetime_module = "#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n #ifdef RENDERER_ROL_CURVE_MODE\n uniform vec2 renderer_ROLMaxCurveZ[4];\n #ifdef RENDERER_ROL_IS_SEPARATE\n uniform vec2 renderer_ROLMaxCurveX[4];\n uniform vec2 renderer_ROLMaxCurveY[4];\n #endif\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n uniform vec2 renderer_ROLMinCurveZ[4];\n #ifdef RENDERER_ROL_IS_SEPARATE\n uniform vec2 renderer_ROLMinCurveX[4];\n uniform vec2 renderer_ROLMinCurveY[4];\n #endif\n #endif\n #else\n uniform vec3 renderer_ROLMaxConst;\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n uniform vec3 renderer_ROLMinConst;\n #endif\n #endif\n#endif\n\nfloat computeParticleRotationFloat(in float rotation, in float age, in float normalizedAge) {\n #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n #ifdef RENDERER_ROL_CURVE_MODE\n float currentValue;\n float lifeRotation = evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue);\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ, normalizedAge, currentValue), lifeRotation, a_Random0.w);\n #endif\n rotation += lifeRotation * a_ShapePositionStartLifeTime.w;\n #else\n float lifeRotation = renderer_ROLMaxConst.z;\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(renderer_ROLMinConst.z, lifeRotation, a_Random0.w);\n #endif\n rotation += lifeRotation * age;\n #endif\n #endif\n return rotation;\n}\n\n\n#if defined(RENDERER_MODE_MESH) && (defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE))\nvec3 computeParticleRotationVec3(in vec3 rotation, in float age, in float normalizedAge) {\n #ifdef RENDERER_ROL_IS_SEPARATE\n #ifdef RENDERER_ROL_CONSTANT_MODE\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n vec3 ageRot = mix(renderer_ROLMinConst, renderer_ROLMaxConst, a_Random0.w) * age;\n #else\n vec3 ageRot = renderer_ROLMaxConst * age;\n #endif\n rotation += ageRot;\n #endif\n #ifdef RENDERER_ROL_CURVE_MODE\n float currentValue;\n float lifetime = a_ShapePositionStartLifeTime.w;\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n rotation += vec3(\n mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveX, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveX, normalizedAge, currentValue), a_Random0.w),\n mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveY, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveY, normalizedAge, currentValue), a_Random0.w),\n mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue), a_Random0.w)) * lifetime;\n #else\n rotation += vec3(\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveX, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveY, normalizedAge, currentValue),\n evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue)) * lifetime;\n #endif\n #endif\n #else\n #ifdef RENDERER_ROL_CONSTANT_MODE\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n float ageRot = mix(renderer_ROLMinConst.z, renderer_ROLMaxConst.z, a_Random0.w) * age;\n #else\n float ageRot = renderer_ROLMaxConst.z * age;\n #endif\n rotation.z += ageRot;\n #endif\n\n #ifdef RENDERER_ROL_CURVE_MODE\n float currentValue;\n float lifeRotation = evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ, normalizedAge, currentValue);\n #ifdef RENDERER_ROL_IS_RANDOM_TWO\n lifeRotation = mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ, normalizedAge, currentValue), lifeRotation, a_Random0.w);\n #endif\n rotation.z += lifeRotation * a_ShapePositionStartLifeTime.w;\n #endif\n #endif\n return rotation;\n}\n#endif\n"; // eslint-disable-line
12322
12322
  var size_over_lifetime_module = "#ifdef RENDERER_SOL_CURVE_MODE\n uniform vec2 renderer_SOLMaxCurveX[4]; // x:time y:value\n #ifdef RENDERER_SOL_IS_SEPARATE\n uniform vec2 renderer_SOLMaxCurveY[4]; // x:time y:value\n uniform vec2 renderer_SOLMaxCurveZ[4]; // x:time y:value\n #endif\n\n #ifdef RENDERER_SOL_IS_RANDOM_TWO\n uniform vec2 renderer_SOLMinCurveX[4]; // x:time y:value\n #ifdef RENDERER_SOL_IS_SEPARATE\n uniform vec2 renderer_SOLMinCurveY[4]; // x:time y:value\n uniform vec2 renderer_SOLMinCurveZ[4]; // x:time y:value\n #endif\n #endif\n#endif\n\nvec2 computeParticleSizeBillboard(in vec2 size, in float normalizedAge) {\n #ifdef RENDERER_SOL_CURVE_MODE\n float lifeSizeX = evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge);\n #ifdef RENDERER_SOL_IS_RANDOM_TWO\n lifeSizeX = mix(evaluateParticleCurve(renderer_SOLMinCurveX, normalizedAge), lifeSizeX, a_Random0.z);\n #endif\n\n #ifdef RENDERER_SOL_IS_SEPARATE\n float lifeSizeY = evaluateParticleCurve(renderer_SOLMaxCurveY, normalizedAge);\n #ifdef RENDERER_SOL_IS_RANDOM_TWO\n lifeSizeY = mix(evaluateParticleCurve(renderer_SOLMinCurveY, normalizedAge), lifeSizeY, a_Random0.z);\n #endif\n size *= vec2(lifeSizeX, lifeSizeY);\n #else\n size *= lifeSizeX;\n #endif\n #endif\n return size;\n}\n\n#ifdef RENDERER_MODE_MESH\n vec3 computeParticleSizeMesh(in vec3 size, in float normalizedAge) {\n #ifdef RENDERER_SOL_CURVE\n size *= evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge);\n #endif\n #ifdef RENDERER_SOL_RANDOM_CURVES\n size *= mix(evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge),\n evaluateParticleCurve(u_SOLSizeGradientMax, normalizedAge),\n a_Random0.z);\n #endif\n #ifdef RENDERER_SOL_CURVE_SEPARATE\n size *= vec3(evaluateParticleCurve(renderer_SOLMinCurveX, normalizedAge),\n evaluateParticleCurve(renderer_SOLMinCurveY, normalizedAge),\n evaluateParticleCurve(renderer_SOLMinCurveZ, normalizedAge));\n #endif\n #ifdef RENDERER_SOL_RANDOM_CURVES_SEPARATE\n size *= vec3(mix(evaluateParticleCurve(renderer_SOLMinCurveX, normalizedAge),\n evaluateParticleCurve(renderer_SOLMaxCurveX, normalizedAge),\n a_Random0.z),\n mix(evaluateParticleCurve(renderer_SOLMinCurveY, normalizedAge),\n evaluateParticleCurve(renderer_SOLMaxCurveY, normalizedAge),\n a_Random0.z),\n mix(evaluateParticleCurve(renderer_SOLMinCurveZ, normalizedAge),\n evaluateParticleCurve(renderer_SOLMaxCurveZ, normalizedAge),\n a_Random0.z));\n #endif\n return size;\n }\n#endif"; // eslint-disable-line
12323
12323
  var color_over_lifetime_module = "#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\n uniform vec4 renderer_COLMaxGradientColor[4]; // x:time y:r z:g w:b\n uniform vec2 renderer_COLMaxGradientAlpha[4]; // x:time y:alpha\n\n #ifdef RENDERER_COL_RANDOM_GRADIENTS\n uniform vec4 renderer_COLMinGradientColor[4]; // x:time y:r z:g w:b\n uniform vec2 renderer_COLMinGradientAlpha[4]; // x:time y:alpha\n #endif\n\n uniform vec4 renderer_COLGradientKeysMaxTime; // x: minColorKeysMaxTime, y: minAlphaKeysMaxTime, z: maxColorKeysMaxTime, w: maxAlphaKeysMaxTime\n#endif\n\n\nvec4 computeParticleColor(in vec4 color, in float normalizedAge) {\n #if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\n vec4 gradientColor = evaluateParticleGradient(renderer_COLMaxGradientColor, renderer_COLGradientKeysMaxTime.z, renderer_COLMaxGradientAlpha, renderer_COLGradientKeysMaxTime.w, normalizedAge);\n #endif\n\n #ifdef RENDERER_COL_RANDOM_GRADIENTS\n gradientColor = mix(evaluateParticleGradient(renderer_COLMinGradientColor,renderer_COLGradientKeysMaxTime.x, renderer_COLMinGradientAlpha, renderer_COLGradientKeysMaxTime.y, normalizedAge), gradientColor, a_Random0.y);\n #endif\n\n #if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\n color *= gradientColor;\n #endif\n\n return color;\n}\n"; // eslint-disable-line
12324
12324
  var texture_sheet_animation_module = "#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\n uniform float renderer_TSACycles;\n uniform vec3 renderer_TSATillingParams; // x:subU y:subV z:tileCount\n uniform vec2 renderer_TSAFrameMaxCurve[4]; // x:time y:value\n\n #ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\n uniform vec2 renderer_TSAFrameMinCurve[4]; // x:time y:value\n #endif\n#endif\n\nvec2 computeParticleUV(in vec2 uv, in float normalizedAge) {\n #if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\n float scaledNormalizedAge = normalizedAge * renderer_TSACycles;\n float cycleNormalizedAge = scaledNormalizedAge - floor(scaledNormalizedAge);\n float normalizedFrame = evaluateParticleCurve(renderer_TSAFrameMaxCurve, cycleNormalizedAge);\n #ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\n normalizedFrame = mix(evaluateParticleCurve(renderer_TSAFrameMinCurve, cycleNormalizedAge), normalizedFrame, a_Random1.x);\n #endif\n\n float frame = floor(normalizedFrame * renderer_TSATillingParams.z);\n\n float tileRow = frame * renderer_TSATillingParams.x;\n float tileRowIndex = floor(tileRow);\n uv.x += tileRow - tileRowIndex;\n uv.y += tileRowIndex * renderer_TSATillingParams.y;\n #endif\n \n return uv;\n}\n"; // eslint-disable-line
@@ -12744,7 +12744,13 @@
12744
12744
  };
12745
12745
  ShaderFactory._has300OutInFragReg = /\bout\s+(?:\w+\s+)?vec4\s+\w+\s*;/;
12746
12746
  ShaderFactory._precisionStr = "\n#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n#else\n precision mediump float;\n precision mediump int;\n#endif\n";
12747
- ShaderFactory._derivedDefines = "#define renderer_MVMat (camera_ViewMat * renderer_ModelMat)\n#define renderer_MVPMat (camera_VPMat * renderer_ModelMat)\n#define renderer_NormalMat mat4(transpose(inverse(mat3(renderer_ModelMat))))";
12747
+ // Derived built-ins re-exposed on top of `renderer_ModelMat`.
12748
+ // `renderer_NormalMat` uses the cofactor (cross-product) form, which algebraically equals
12749
+ // `det(M) · transpose(inverse(M))`. After `normalize()` it's directionally identical to the
12750
+ // classic `transpose(inverse(M))`, but stays NaN-free when `M` is singular (e.g. any scale
12751
+ // axis is 0 — common in animations that pop / hide via scale). `sign(det)` (`s` below)
12752
+ // keeps mirrored matrices facing the right way
12753
+ ShaderFactory._derivedDefines = "mat3 _normalMatFromModel(mat3 m) {\n vec3 c0 = cross(m[1], m[2]);\n vec3 c1 = cross(m[2], m[0]);\n vec3 c2 = cross(m[0], m[1]);\n float s = (dot(m[0], c0) < 0.0) ? -1.0 : 1.0;\n return mat3(c0 * s, c1 * s, c2 * s);\n}\n#define renderer_MVMat (camera_ViewMat * renderer_ModelMat)\n#define renderer_MVPMat (camera_VPMat * renderer_ModelMat)\n#define renderer_NormalMat mat4(_normalMatFromModel(mat3(renderer_ModelMat)))";
12748
12754
  // Built-in renderer uniforms. value=true means derived (remove but not added to UBO)
12749
12755
  ShaderFactory._builtinRendererUniforms = {
12750
12756
  renderer_ModelMat: false,
@@ -23980,7 +23986,7 @@
23980
23986
  /** Scene. */ AssetType["Scene"] = "Scene";
23981
23987
  /** Font. */ AssetType["Font"] = "Font";
23982
23988
  /** Source Font, include ttf, otf and woff. */ AssetType["SourceFont"] = "SourceFont";
23983
- /** AudioClip, include ogg, wav and mp3. */ AssetType["Audio"] = "Audio";
23989
+ /** AudioClip, include ogg, wav, mp3, m4a, aac and flac. */ AssetType["Audio"] = "Audio";
23984
23990
  /** Project asset. */ AssetType["Project"] = "project";
23985
23991
  /** PhysicsMaterial. */ AssetType["PhysicsMaterial"] = "PhysicsMaterial";
23986
23992
  /** RenderTarget. */ AssetType["RenderTarget"] = "RenderTarget";
@@ -25395,7 +25401,13 @@
25395
25401
  _inherits$2(Collider, Component);
25396
25402
  function Collider(entity) {
25397
25403
  var _this;
25398
- _this = Component.call(this, entity) || this, /** @internal */ _this._index = -1, _this._shapes = [], _this._collisionLayerIndex = 0;
25404
+ _this = Component.call(this, entity) || this, /** @internal */ _this._index = -1, _this._shapes = [], _this._collisionLayerIndex = 0, /**
25405
+ * Disabling a collider only detaches its native actor from the simulation
25406
+ * scene; the actor is not destroyed, so on re-enable it still holds its
25407
+ * pre-disable pose. The first transform sync after (re-)enable must teleport,
25408
+ * never sweep — otherwise a kinematic actor drags across the scene from that
25409
+ * stale pose and fires spurious contacts along the path.
25410
+ */ _this._pendingReenterTeleport = false;
25399
25411
  _this._updateFlag = entity.registerWorldChangeFlag();
25400
25412
  return _this;
25401
25413
  }
@@ -25439,9 +25451,14 @@
25439
25451
  * @internal
25440
25452
  */ _proto._onUpdate = function _onUpdate() {
25441
25453
  var shapes = this._shapes;
25442
- if (this._updateFlag.flag) {
25454
+ if (this._pendingReenterTeleport || this._updateFlag.flag) {
25443
25455
  var transform = this.entity.transform;
25444
- this._syncEntityTransformToNative(transform.worldPosition, transform.worldRotationQuaternion);
25456
+ if (this._pendingReenterTeleport) {
25457
+ this._teleportToEntityTransform(transform.worldPosition, transform.worldRotationQuaternion);
25458
+ this._pendingReenterTeleport = false;
25459
+ } else {
25460
+ this._syncEntityTransformToNative(transform.worldPosition, transform.worldRotationQuaternion);
25461
+ }
25445
25462
  var worldScale = transform.lossyWorldScale;
25446
25463
  for(var i = 0, n = shapes.length; i < n; i++){
25447
25464
  var _shapes_i__nativeShape;
@@ -25463,6 +25480,7 @@
25463
25480
  * @internal
25464
25481
  */ _proto._onEnableInScene = function _onEnableInScene() {
25465
25482
  this.scene.physics._addCollider(this);
25483
+ this._pendingReenterTeleport = true;
25466
25484
  };
25467
25485
  /**
25468
25486
  * @internal
@@ -25581,6 +25599,9 @@
25581
25599
  __decorate$1([
25582
25600
  deepClone
25583
25601
  ], exports.Collider.prototype, "_shapes", void 0);
25602
+ __decorate$1([
25603
+ ignoreClone
25604
+ ], exports.Collider.prototype, "_pendingReenterTeleport", void 0);
25584
25605
  exports.Collider = __decorate$1([
25585
25606
  dependentComponents(Transform, DependentMode.CheckOnly)
25586
25607
  ], exports.Collider);
@@ -25875,7 +25896,6 @@
25875
25896
  this._isTrigger = false;
25876
25897
  this._rotation = new Vector3();
25877
25898
  this._position = new Vector3();
25878
- this._contactOffset = 0.02;
25879
25899
  /**
25880
25900
  * @internal
25881
25901
  * @beta
@@ -25941,7 +25961,9 @@
25941
25961
  if (!this._nativeShape) return;
25942
25962
  this._nativeShape.setPosition(this._position);
25943
25963
  this._nativeShape.setRotation(this._rotation);
25944
- this._nativeShape.setContactOffset(this._contactOffset);
25964
+ if (this._contactOffset !== undefined) {
25965
+ this._nativeShape.setContactOffset(this._contactOffset);
25966
+ }
25945
25967
  this._nativeShape.setIsTrigger(this._isTrigger);
25946
25968
  this._nativeShape.setMaterial(this._material._nativeMaterial);
25947
25969
  (_this__collider = this._collider) == null ? void 0 : _this__collider._handleShapesChanged(ColliderShapeChangeFlag.Property);
@@ -25979,7 +26001,9 @@
25979
26001
  * Contact offset for this shape, the value must be greater than or equal to 0.
25980
26002
  * @defaultValue 0.02
25981
26003
  */ function get() {
25982
- return this._contactOffset;
26004
+ var _Engine__nativePhysics_getDefaultContactOffset, _Engine__nativePhysics;
26005
+ var _this__contactOffset, _ref;
26006
+ return (_ref = (_this__contactOffset = this._contactOffset) != null ? _this__contactOffset : (_Engine__nativePhysics = Engine._nativePhysics) == null ? void 0 : (_Engine__nativePhysics_getDefaultContactOffset = _Engine__nativePhysics.getDefaultContactOffset) == null ? void 0 : _Engine__nativePhysics_getDefaultContactOffset.call(_Engine__nativePhysics)) != null ? _ref : 0.02;
25983
26007
  },
25984
26008
  set: function set(value) {
25985
26009
  value = Math.max(0, value);
@@ -26300,7 +26324,7 @@
26300
26324
  _inherits$2(DynamicCollider, Collider);
26301
26325
  function DynamicCollider(entity) {
26302
26326
  var _this;
26303
- _this = Collider.call(this, entity) || this, _this._linearDamping = 0, _this._angularDamping = 0.05, _this._linearVelocity = new Vector3(), _this._angularVelocity = new Vector3(), _this._mass = 1.0, _this._centerOfMass = new Vector3(), _this._inertiaTensor = new Vector3(1, 1, 1), _this._maxAngularVelocity = 18000 / Math.PI, _this._maxDepenetrationVelocity = 1.0000000331813535e32, _this._solverIterations = 4, _this._useGravity = true, _this._isKinematic = false, _this._constraints = 0, _this._collisionDetectionMode = 0, _this._sleepThreshold = 5e-3, _this._automaticCenterOfMass = true, _this._automaticInertiaTensor = true;
26327
+ _this = Collider.call(this, entity) || this, _this._linearDamping = 0, _this._angularDamping = 0.05, _this._linearVelocity = new Vector3(), _this._angularVelocity = new Vector3(), _this._mass = 1.0, _this._centerOfMass = new Vector3(), _this._inertiaTensor = new Vector3(1, 1, 1), _this._maxAngularVelocity = 18000 / Math.PI, _this._maxDepenetrationVelocity = 1.0000000331813535e32, _this._solverIterations = 4, _this._useGravity = true, _this._isKinematic = false, _this._constraints = 0, _this._collisionDetectionMode = 0, _this._kinematicTransformSyncMode = 0, _this._automaticCenterOfMass = true, _this._automaticInertiaTensor = true;
26304
26328
  var transform = _this.entity.transform;
26305
26329
  _this._nativeCollider = Engine._nativePhysics.createDynamicCollider(transform.worldPosition, transform.worldRotationQuaternion);
26306
26330
  _this._setLinearVelocity = _this._setLinearVelocity.bind(_this);
@@ -26392,17 +26416,14 @@
26392
26416
  * collision detection, use setKinematicTarget() instead."
26393
26417
  *
26394
26418
  * setGlobalPose is a teleport: PhysX skips contact detection between the old
26395
- * and new pose, so two kinematic actors moved onto each other via entity.transform
26396
- * mutation would NOT produce onCollisionEnter / onCollisionStay events even when
26397
- * scene.kineKineFilteringMode = eKEEP. Routing the per-frame sync through
26398
- * IDynamicCollider.move() (which the PhysX backend implements as
26399
- * setKinematicTarget) tells PhysX the actor is animating to the target during the
26400
- * next simulate(), enabling sweep contact detection for kine-kine and kine-dynamic
26401
- * pairs alike.
26419
+ * and new pose. setKinematicTarget tells PhysX the actor is animating to the
26420
+ * target during the next simulate(), enabling swept contacts. Some compatibility
26421
+ * layers need transform writes to stay teleport-like, so the sync mode is
26422
+ * explicit while {@link move} always keeps target semantics.
26402
26423
  *
26403
26424
  * @internal
26404
26425
  */ _proto._syncEntityTransformToNative = function _syncEntityTransformToNative(worldPosition, worldRotation) {
26405
- if (this._isKinematic) {
26426
+ if (this._isKinematic && this._kinematicTransformSyncMode === 0) {
26406
26427
  this._nativeCollider.move(worldPosition, worldRotation);
26407
26428
  } else {
26408
26429
  Collider.prototype._syncEntityTransformToNative.call(this, worldPosition, worldRotation);
@@ -26432,6 +26453,7 @@
26432
26453
  target._angularVelocity.copyFrom(this.angularVelocity);
26433
26454
  target._centerOfMass.copyFrom(this.centerOfMass);
26434
26455
  target._inertiaTensor.copyFrom(this.inertiaTensor);
26456
+ target._kinematicTransformSyncMode = this._kinematicTransformSyncMode;
26435
26457
  Collider.prototype._cloneTo.call(this, target);
26436
26458
  };
26437
26459
  /**
@@ -26457,7 +26479,9 @@
26457
26479
  }
26458
26480
  this._nativeCollider.setMaxAngularVelocity(this._maxAngularVelocity);
26459
26481
  this._nativeCollider.setMaxDepenetrationVelocity(this._maxDepenetrationVelocity);
26460
- this._nativeCollider.setSleepThreshold(this._sleepThreshold);
26482
+ if (this._sleepThreshold !== undefined) {
26483
+ this._nativeCollider.setSleepThreshold(this._sleepThreshold);
26484
+ }
26461
26485
  this._nativeCollider.setSolverIterations(this._solverIterations);
26462
26486
  this._nativeCollider.setUseGravity(this._useGravity);
26463
26487
  this._nativeCollider.setIsKinematic(this._isKinematic);
@@ -26681,7 +26705,9 @@
26681
26705
  get: /**
26682
26706
  * The mass-normalized energy threshold, below which objects start going to sleep.
26683
26707
  */ function get() {
26684
- return this._sleepThreshold;
26708
+ var _Engine__nativePhysics_getDefaultSleepThreshold, _Engine__nativePhysics;
26709
+ var _this__sleepThreshold, _ref;
26710
+ return (_ref = (_this__sleepThreshold = this._sleepThreshold) != null ? _this__sleepThreshold : (_Engine__nativePhysics = Engine._nativePhysics) == null ? void 0 : (_Engine__nativePhysics_getDefaultSleepThreshold = _Engine__nativePhysics.getDefaultSleepThreshold) == null ? void 0 : _Engine__nativePhysics_getDefaultSleepThreshold.call(_Engine__nativePhysics)) != null ? _ref : 5e-3;
26685
26711
  },
26686
26712
  set: function set(value) {
26687
26713
  if (value !== this._sleepThreshold) {
@@ -26777,6 +26803,22 @@
26777
26803
  this._nativeCollider.setCollisionDetectionMode(value);
26778
26804
  }
26779
26805
  }
26806
+ },
26807
+ {
26808
+ key: "kinematicTransformSyncMode",
26809
+ get: /**
26810
+ * Controls how entity transform changes are synchronized to a kinematic native actor.
26811
+ *
26812
+ * @remarks
26813
+ * `Target` routes transform changes through {@link move}, so PhysX treats the
26814
+ * actor as moving between frames and can generate swept contacts. `Teleport`
26815
+ * writes the native pose directly and does not imply velocity.
26816
+ */ function get() {
26817
+ return this._kinematicTransformSyncMode;
26818
+ },
26819
+ set: function set(value) {
26820
+ this._kinematicTransformSyncMode = value;
26821
+ }
26780
26822
  }
26781
26823
  ]);
26782
26824
  return DynamicCollider;
@@ -26818,6 +26860,13 @@
26818
26860
  /** Speculative continuous collision detection is on for static and dynamic geometries */ CollisionDetectionMode[CollisionDetectionMode["ContinuousSpeculative"] = 3] = "ContinuousSpeculative";
26819
26861
  return CollisionDetectionMode;
26820
26862
  }({});
26863
+ /**
26864
+ * Kinematic transform synchronization mode.
26865
+ */ var DynamicColliderKinematicTransformSyncMode = /*#__PURE__*/ function(DynamicColliderKinematicTransformSyncMode) {
26866
+ /** Synchronize transform changes through PhysX setKinematicTarget. */ DynamicColliderKinematicTransformSyncMode[DynamicColliderKinematicTransformSyncMode["Target"] = 0] = "Target";
26867
+ /** Synchronize transform changes by directly teleporting the native actor. */ DynamicColliderKinematicTransformSyncMode[DynamicColliderKinematicTransformSyncMode["Teleport"] = 1] = "Teleport";
26868
+ return DynamicColliderKinematicTransformSyncMode;
26869
+ }({});
26821
26870
  /**
26822
26871
  * Use these flags to constrain motion of dynamic collider.
26823
26872
  */ var DynamicColliderConstraints = /*#__PURE__*/ function(DynamicColliderConstraints) {
@@ -26860,8 +26909,7 @@
26860
26909
  * You need to obtain the actual number of contact points from the function's return value.
26861
26910
  */ _proto.getContacts = function getContacts(outContacts) {
26862
26911
  var nativeCollision = this._nativeCollision;
26863
- var smallerShapeId = Math.min(nativeCollision.shape0Id, nativeCollision.shape1Id);
26864
- var factor = this.shape.id === smallerShapeId ? 1 : -1;
26912
+ var factor = this.shape.id === nativeCollision.shape1Id ? 1 : -1;
26865
26913
  var nativeContactPoints = nativeCollision.getContacts();
26866
26914
  var length = nativeContactPoints.size();
26867
26915
  for(var i = 0; i < length; i++){
@@ -37580,6 +37628,13 @@
37580
37628
  /** Finished state. */ LayerState[LayerState["Finished"] = 4] = "Finished";
37581
37629
  return LayerState;
37582
37630
  }({});
37631
+ /**
37632
+ * Animation wrap mode.
37633
+ */ var WrapMode = /*#__PURE__*/ function(WrapMode) {
37634
+ /** Play once */ WrapMode[WrapMode["Once"] = 0] = "Once";
37635
+ /** Loop play */ WrapMode[WrapMode["Loop"] = 1] = "Loop";
37636
+ return WrapMode;
37637
+ }({});
37583
37638
  /**
37584
37639
  * @internal
37585
37640
  */ var AnimationEventHandler = /*#__PURE__*/ function() {
@@ -37685,21 +37740,15 @@
37685
37740
  ]);
37686
37741
  return AnimatorStateTransition;
37687
37742
  }();
37688
- /**
37689
- * Animation wrap mode.
37690
- */ var WrapMode = /*#__PURE__*/ function(WrapMode) {
37691
- /** Play once */ WrapMode[WrapMode["Once"] = 0] = "Once";
37692
- /** Loop play */ WrapMode[WrapMode["Loop"] = 1] = "Loop";
37693
- return WrapMode;
37694
- }({});
37695
37743
  /**
37696
37744
  * Per-instance runtime data for an AnimatorState.
37697
37745
  * Proxies read-only properties from the shared AnimatorState asset,
37698
- * while providing per-instance mutable properties (e.g. speed).
37746
+ * while providing per-instance mutable properties (e.g. speed, wrapMode).
37699
37747
  */ var AnimatorStatePlayData = /*#__PURE__*/ function() {
37700
37748
  function AnimatorStatePlayData() {
37701
37749
  /** @internal */ this.isForward = true;
37702
37750
  /** Per-instance speed. Initialized from AnimatorState.speed, safe to modify without affecting other instances. */ this.speed = 1.0;
37751
+ /** Per-instance wrap mode. Initialized from AnimatorState.wrapMode, safe to modify without affecting other instances. */ this.wrapMode = WrapMode.Loop;
37703
37752
  this._changedOrientation = false;
37704
37753
  }
37705
37754
  var _proto = AnimatorStatePlayData.prototype;
@@ -37718,6 +37767,7 @@
37718
37767
  this.currentEventIndex = 0;
37719
37768
  this.isForward = true;
37720
37769
  this.speed = state.speed;
37770
+ this.wrapMode = state.wrapMode;
37721
37771
  this.state._transitionCollection.needResetCurrentCheckIndex = true;
37722
37772
  };
37723
37773
  _proto.updateOrientation = function updateOrientation(deltaTime) {
@@ -37736,7 +37786,7 @@
37736
37786
  var time = this.playedTime + this.offsetFrameTime;
37737
37787
  var duration = state._getDuration();
37738
37788
  this.playState = AnimatorStatePlayState.Playing;
37739
- if (state.wrapMode === WrapMode.Loop) {
37789
+ if (this.wrapMode === WrapMode.Loop) {
37740
37790
  time = duration ? time % duration : 0;
37741
37791
  } else {
37742
37792
  if (Math.abs(time) >= duration) {
@@ -37770,12 +37820,6 @@
37770
37820
  return this.state.clip;
37771
37821
  }
37772
37822
  },
37773
- {
37774
- key: "wrapMode",
37775
- get: /** The wrap mode. */ function get() {
37776
- return this.state.wrapMode;
37777
- }
37778
- },
37779
37823
  {
37780
37824
  key: "transitions",
37781
37825
  get: /** The transitions going out of this state. */ function get() {
@@ -37922,7 +37966,7 @@
37922
37966
  * @param layerIndex - The layer index(default -1). If layer is -1, find the first state with the given state name
37923
37967
  */ /**
37924
37968
  * Find the per-instance play data for a state by name.
37925
- * The returned object's `speed` is per-instance and safe to modify without affecting other Animator instances.
37969
+ * The returned object's `speed` and `wrapMode` are per-instance and safe to modify without affecting other Animator instances.
37926
37970
  * @param stateName - The state name
37927
37971
  * @param layerIndex - The layer index (default -1, searches all layers)
37928
37972
  * @returns Per-instance AnimatorStatePlayData, or null if not found
@@ -38341,8 +38385,8 @@
38341
38385
  if (this._tryCrossFadeInterrupt(layerData, transitionDuration, destState, deltaTime, aniUpdate)) {
38342
38386
  return;
38343
38387
  }
38344
- var srcPlaySpeed = srcState.speed * speed;
38345
- var dstPlaySpeed = destState.speed * speed;
38388
+ var srcPlaySpeed = srcPlayData.speed * speed;
38389
+ var dstPlaySpeed = destPlayData.speed * speed;
38346
38390
  var dstPlayDeltaTime = dstPlaySpeed * deltaTime;
38347
38391
  srcPlayData && srcPlayData.updateOrientation(srcPlaySpeed * deltaTime);
38348
38392
  destPlayData && destPlayData.updateOrientation(dstPlayDeltaTime);
@@ -38744,22 +38788,27 @@
38744
38788
  return true;
38745
38789
  };
38746
38790
  _proto._fireAnimationEvents = function _fireAnimationEvents(playData, eventHandlers, lastClipTime, deltaTime) {
38747
- var state = playData.state, isForward = playData.isForward, clipTime = playData.clipTime;
38791
+ var state = playData.state, isForward = playData.isForward, clipTime = playData.clipTime, wrapMode = playData.wrapMode;
38748
38792
  var startTime = state._getClipActualStartTime();
38749
38793
  var endTime = state._getClipActualEndTime();
38794
+ var canWrap = wrapMode === WrapMode.Loop;
38750
38795
  if (isForward) {
38751
38796
  if (lastClipTime + deltaTime >= endTime) {
38752
38797
  this._fireSubAnimationEvents(playData, eventHandlers, lastClipTime, endTime);
38753
- playData.currentEventIndex = 0;
38754
- this._fireSubAnimationEvents(playData, eventHandlers, startTime, clipTime);
38798
+ if (canWrap) {
38799
+ playData.currentEventIndex = 0;
38800
+ this._fireSubAnimationEvents(playData, eventHandlers, startTime, clipTime);
38801
+ }
38755
38802
  } else {
38756
38803
  this._fireSubAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
38757
38804
  }
38758
38805
  } else {
38759
38806
  if (lastClipTime + deltaTime <= startTime) {
38760
38807
  this._fireBackwardSubAnimationEvents(playData, eventHandlers, lastClipTime, startTime);
38761
- playData.currentEventIndex = eventHandlers.length - 1;
38762
- this._fireBackwardSubAnimationEvents(playData, eventHandlers, endTime, clipTime);
38808
+ if (canWrap) {
38809
+ playData.currentEventIndex = eventHandlers.length - 1;
38810
+ this._fireBackwardSubAnimationEvents(playData, eventHandlers, endTime, clipTime);
38811
+ }
38763
38812
  } else {
38764
38813
  this._fireBackwardSubAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
38765
38814
  }
@@ -41218,7 +41267,7 @@
41218
41267
  _inherits$2(EmissionModule, ParticleGeneratorModule);
41219
41268
  function EmissionModule() {
41220
41269
  var _this;
41221
- _this = ParticleGeneratorModule.apply(this, arguments) || this, /** The rate of particle emission. */ _this.rateOverTime = new ParticleCompositeCurve(10), /** The rate at which the emitter spawns new particles over distance. */ _this.rateOverDistance = new ParticleCompositeCurve(0), /** @internal */ _this._shapeRand = new Rand(0, ParticleRandomSubSeeds.Shape), /** @internal */ _this._frameRateTime = 0, _this._bursts = [], _this._currentBurstIndex = 0, _this._burstRand = new Rand(0, ParticleRandomSubSeeds.Burst);
41270
+ _this = ParticleGeneratorModule.apply(this, arguments) || this, /** The rate of particle emission. */ _this.rateOverTime = new ParticleCompositeCurve(10), /** The rate at which the emitter spawns new particles over distance. */ _this.rateOverDistance = new ParticleCompositeCurve(0), /** @internal */ _this._shapeRand = new Rand(0, ParticleRandomSubSeeds.Shape), /** @internal */ _this._frameRateTime = 0, _this._distanceAccumulator = 0, _this._lastEmitPosition = new Vector3(), _this._hasLastEmitPosition = false, _this._bursts = [], _this._currentBurstIndex = 0, _this._burstRand = new Rand(0, ParticleRandomSubSeeds.Burst);
41222
41271
  return _this;
41223
41272
  }
41224
41273
  var _proto = EmissionModule.prototype;
@@ -41255,6 +41304,7 @@
41255
41304
  * @internal
41256
41305
  */ _proto._emit = function _emit(lastPlayTime, playTime) {
41257
41306
  this._emitByRateOverTime(playTime);
41307
+ this._emitByRateOverDistance(lastPlayTime, playTime);
41258
41308
  this._emitByBurst(lastPlayTime, playTime);
41259
41309
  };
41260
41310
  /**
@@ -41268,6 +41318,13 @@
41268
41318
  */ _proto._reset = function _reset() {
41269
41319
  this._frameRateTime = 0;
41270
41320
  this._currentBurstIndex = 0;
41321
+ this._invalidateDistanceBaseline();
41322
+ };
41323
+ /**
41324
+ * @internal
41325
+ */ _proto._invalidateDistanceBaseline = function _invalidateDistanceBaseline() {
41326
+ this._hasLastEmitPosition = false;
41327
+ this._distanceAccumulator = 0;
41271
41328
  };
41272
41329
  /**
41273
41330
  * @internal
@@ -41288,6 +41345,55 @@
41288
41345
  }
41289
41346
  }
41290
41347
  };
41348
+ _proto._emitByRateOverDistance = function _emitByRateOverDistance(lastPlayTime, playTime) {
41349
+ var ratePerUnit = this.rateOverDistance.evaluate(undefined, undefined);
41350
+ var generator = this._generator;
41351
+ if (ratePerUnit <= 0) {
41352
+ this._invalidateDistanceBaseline();
41353
+ return;
41354
+ }
41355
+ if (!this._hasLastEmitPosition) {
41356
+ this._lastEmitPosition.copyFrom(generator._renderer.entity.transform.worldPosition);
41357
+ this._hasLastEmitPosition = true;
41358
+ return;
41359
+ }
41360
+ var lastPos = this._lastEmitPosition;
41361
+ var currentPos = generator._renderer.entity.transform.worldPosition;
41362
+ var dx = currentPos.x - lastPos.x;
41363
+ var dy = currentPos.y - lastPos.y;
41364
+ var dz = currentPos.z - lastPos.z;
41365
+ var moveLength = Math.sqrt(dx * dx + dy * dy + dz * dz);
41366
+ this._distanceAccumulator += moveLength;
41367
+ var emitInterval = 1.0 / ratePerUnit;
41368
+ // `+ zeroTolerance` absorbs float divide error so an exact `N*interval` accumulator doesn't drop 1
41369
+ var count = Math.floor(this._distanceAccumulator / emitInterval + MathUtil.zeroTolerance);
41370
+ if (count > 0) {
41371
+ this._distanceAccumulator -= count * emitInterval;
41372
+ // `subFrameAge ∈ [0, 1]`: how far back into the frame a particle was born
41373
+ // (0 = newest at currentPos/playTime, 1 = oldest at lastPos/lastPlayTime).
41374
+ // The initial clamp protects two edges — moveLength ≈ 0 (collapse to frame-end
41375
+ // emit) and a tiny moveLength near the emitInterval edge (would put age > 1).
41376
+ // Local simulation space ignores the position override but still uses emitTime.
41377
+ var isWorld = generator.main.simulationSpace === ParticleSimulationSpace.World;
41378
+ var invMoveLength = moveLength > MathUtil.zeroTolerance ? 1.0 / moveLength : 0;
41379
+ var ageStep = emitInterval * invMoveLength;
41380
+ var dt = playTime - lastPlayTime;
41381
+ var subFrameAge = Math.min(this._distanceAccumulator * invMoveLength, 1.0);
41382
+ var emitPos = EmissionModule._tempEmitPosition;
41383
+ for(var i = 0; i < count; i++){
41384
+ if (isWorld) {
41385
+ emitPos.set(currentPos.x - dx * subFrameAge, currentPos.y - dy * subFrameAge, currentPos.z - dz * subFrameAge);
41386
+ }
41387
+ if (generator._emit(playTime - dt * subFrameAge, 1, isWorld ? emitPos : undefined) === 0) {
41388
+ // Buffer full: settle the frame's distance budget instead of carrying it over
41389
+ this._distanceAccumulator = 0;
41390
+ break;
41391
+ }
41392
+ subFrameAge += ageStep;
41393
+ }
41394
+ }
41395
+ lastPos.copyFrom(currentPos);
41396
+ };
41291
41397
  _proto._emitByBurst = function _emitByBurst(lastPlayTime, playTime) {
41292
41398
  var main = this._generator.main;
41293
41399
  var duration = main.duration;
@@ -41384,6 +41490,7 @@
41384
41490
  return EmissionModule;
41385
41491
  }(ParticleGeneratorModule);
41386
41492
  /** @internal */ EmissionModule._emissionShapeMacro = ShaderMacro.getByName("RENDERER_EMISSION_SHAPE");
41493
+ EmissionModule._tempEmitPosition = new Vector3();
41387
41494
  __decorate$1([
41388
41495
  deepClone
41389
41496
  ], EmissionModule.prototype, "rateOverTime", void 0);
@@ -41396,6 +41503,15 @@
41396
41503
  __decorate$1([
41397
41504
  ignoreClone
41398
41505
  ], EmissionModule.prototype, "_shapeRand", void 0);
41506
+ __decorate$1([
41507
+ ignoreClone
41508
+ ], EmissionModule.prototype, "_distanceAccumulator", void 0);
41509
+ __decorate$1([
41510
+ ignoreClone
41511
+ ], EmissionModule.prototype, "_lastEmitPosition", void 0);
41512
+ __decorate$1([
41513
+ ignoreClone
41514
+ ], EmissionModule.prototype, "_hasLastEmitPosition", void 0);
41399
41515
  __decorate$1([
41400
41516
  deepClone
41401
41517
  ], EmissionModule.prototype, "_bursts", void 0);
@@ -43072,11 +43188,15 @@
43072
43188
  }
43073
43189
  } else {
43074
43190
  this._isPlaying = false;
43191
+ // Invalidate the rateOverDistance baseline so emitter movement during the stop
43192
+ // interval doesn't burst on resume.
43075
43193
  if (stopMode === ParticleStopMode.StopEmittingAndClear) {
43076
43194
  this._clearActiveParticles();
43077
43195
  this._playTime = 0;
43078
43196
  this._firstActiveTransformedBoundingBox = this._firstFreeTransformedBoundingBox;
43079
43197
  this.emission._reset();
43198
+ } else {
43199
+ this.emission._invalidateDistanceBaseline();
43080
43200
  }
43081
43201
  }
43082
43202
  };
@@ -43088,37 +43208,40 @@
43088
43208
  };
43089
43209
  /**
43090
43210
  * @internal
43091
- */ _proto._emit = function _emit(playTime, count) {
43092
- var emission = this.emission;
43093
- if (emission.enabled) {
43094
- var main = this.main;
43095
- // Wait the existing particles to be retired
43096
- var notRetireParticleCount = this._getNotRetiredParticleCount();
43097
- if (notRetireParticleCount >= main.maxParticles) {
43098
- return;
43099
- }
43100
- var position = ParticleGenerator._tempVector30;
43101
- var direction = ParticleGenerator._tempVector31;
43102
- var transform = this._renderer.entity.transform;
43103
- var shape = emission.shape;
43104
- var positionScale = main._getPositionScale();
43105
- for(var i = 0; i < count; i++){
43106
- if (shape == null ? void 0 : shape.enabled) {
43107
- shape._generatePositionAndDirection(emission._shapeRand, playTime, position, direction);
43108
- position.multiply(positionScale);
43109
- direction.normalize().multiply(positionScale);
43110
- } else {
43111
- position.set(0, 0, 0);
43112
- direction.set(0, 0, -1);
43113
- // Speed is scaled by shape scale in world simulation space
43114
- // So if no shape and in world simulation space, we shouldn't scale the speed
43115
- if (main.simulationSpace === ParticleSimulationSpace.Local) {
43116
- direction.multiply(positionScale);
43117
- }
43211
+ */ _proto._emit = function _emit(playTime, count, emitWorldPositionOverride) {
43212
+ var _this = this, emission = _this.emission, main = _this.main;
43213
+ if (!emission.enabled) {
43214
+ return 0;
43215
+ }
43216
+ var budget = main.maxParticles - this._getNotRetiredParticleCount();
43217
+ if (count > budget) {
43218
+ count = budget;
43219
+ }
43220
+ if (count <= 0) {
43221
+ return 0;
43222
+ }
43223
+ var position = ParticleGenerator._tempVector30;
43224
+ var direction = ParticleGenerator._tempVector31;
43225
+ var transform = this._renderer.entity.transform;
43226
+ var shape = emission.shape;
43227
+ var positionScale = main._getPositionScale();
43228
+ for(var i = 0; i < count; i++){
43229
+ if (shape == null ? void 0 : shape.enabled) {
43230
+ shape._generatePositionAndDirection(emission._shapeRand, playTime, position, direction);
43231
+ position.multiply(positionScale);
43232
+ direction.normalize().multiply(positionScale);
43233
+ } else {
43234
+ position.set(0, 0, 0);
43235
+ direction.set(0, 0, -1);
43236
+ // Speed is scaled by shape scale in world simulation space
43237
+ // So if no shape and in world simulation space, we shouldn't scale the speed
43238
+ if (main.simulationSpace === ParticleSimulationSpace.Local) {
43239
+ direction.multiply(positionScale);
43118
43240
  }
43119
- this._addNewParticle(position, direction, transform, playTime);
43120
43241
  }
43242
+ this._addNewParticle(position, direction, transform, playTime, emitWorldPositionOverride);
43121
43243
  }
43244
+ return count;
43122
43245
  };
43123
43246
  /**
43124
43247
  * @internal
@@ -43520,7 +43643,7 @@
43520
43643
  this._transformedBoundsArray[previousFreeElement * ParticleBufferUtils.boundsFloatStride + boundsTimeOffset] = this._playTime;
43521
43644
  }
43522
43645
  };
43523
- _proto._addNewParticle = function _addNewParticle(position, direction, transform, playTime) {
43646
+ _proto._addNewParticle = function _addNewParticle(position, direction, transform, playTime, emitWorldPositionOverride) {
43524
43647
  var firstFreeElement = this._firstFreeElement;
43525
43648
  var nextFreeElement = firstFreeElement + 1;
43526
43649
  if (nextFreeElement >= this._currentParticleCount) {
@@ -43543,7 +43666,7 @@
43543
43666
  }
43544
43667
  var pos, rot;
43545
43668
  if (main.simulationSpace === ParticleSimulationSpace.World) {
43546
- pos = transform.worldPosition;
43669
+ pos = emitWorldPositionOverride != null ? emitWorldPositionOverride : transform.worldPosition;
43547
43670
  rot = transform.worldRotationQuaternion;
43548
43671
  }
43549
43672
  var startSpeed = main.startSpeed.evaluate(undefined, main._startSpeedRand.random());
@@ -43663,18 +43786,18 @@
43663
43786
  }
43664
43787
  // Initialize feedback buffer for this particle
43665
43788
  if (this._useTransformFeedback) {
43666
- this._addFeedbackParticle(firstFreeElement, position, direction, startSpeed, transform);
43789
+ this._addFeedbackParticle(firstFreeElement, position, direction, startSpeed, transform, pos);
43667
43790
  }
43668
43791
  this._firstFreeElement = nextFreeElement;
43669
43792
  };
43670
- _proto._addFeedbackParticle = function _addFeedbackParticle(index, shapePosition, direction, startSpeed, transform) {
43793
+ _proto._addFeedbackParticle = function _addFeedbackParticle(index, shapePosition, direction, startSpeed, transform, emitWorldPosition) {
43671
43794
  var position;
43672
43795
  if (this.main.simulationSpace === ParticleSimulationSpace.Local) {
43673
43796
  position = shapePosition;
43674
43797
  } else {
43675
43798
  position = ParticleGenerator._tempVector32;
43676
43799
  Vector3.transformByQuat(shapePosition, transform.worldRotationQuaternion, position);
43677
- position.add(transform.worldPosition);
43800
+ position.add(emitWorldPosition != null ? emitWorldPosition : transform.worldPosition);
43678
43801
  }
43679
43802
  this._feedbackSimulator.writeParticleData(index, position, direction.x * startSpeed, direction.y * startSpeed, direction.z * startSpeed);
43680
43803
  };
@@ -46350,6 +46473,7 @@
46350
46473
  Downsampling: Downsampling,
46351
46474
  DynamicCollider: DynamicCollider,
46352
46475
  DynamicColliderConstraints: DynamicColliderConstraints,
46476
+ DynamicColliderKinematicTransformSyncMode: DynamicColliderKinematicTransformSyncMode,
46353
46477
  EmissionModule: EmissionModule,
46354
46478
  Engine: Engine,
46355
46479
  EngineObject: EngineObject,
@@ -53859,33 +53983,11 @@
53859
53983
  if (rootBoneIndex !== -1) {
53860
53984
  BoundingBox.transform(mesh.bounds, inverseBindMatrices[rootBoneIndex], skinnedMeshRenderer.localBounds);
53861
53985
  } else {
53862
- // Root bone is not in joints list, we can only compute approximate inverse bind matrix
53863
- // Average all root bone's children inverse bind matrix
53864
- var approximateBindMatrix = new Matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
53865
- var subRootBoneCount = this._computeApproximateBindMatrix(bones, inverseBindMatrices, rootBone, approximateBindMatrix);
53866
- if (subRootBoneCount !== 0) {
53867
- Matrix.multiplyScalar(approximateBindMatrix, 1.0 / subRootBoneCount, approximateBindMatrix);
53868
- BoundingBox.transform(mesh.bounds, approximateBindMatrix, skinnedMeshRenderer.localBounds);
53869
- } else {
53870
- skinnedMeshRenderer.localBounds.copyFrom(mesh.bounds);
53871
- }
53986
+ var inverseRootBoneWorld = new Matrix();
53987
+ Matrix.invert(rootBone.transform.worldMatrix, inverseRootBoneWorld);
53988
+ BoundingBox.transform(mesh.bounds, inverseRootBoneWorld, skinnedMeshRenderer.localBounds);
53872
53989
  }
53873
53990
  };
53874
- _proto._computeApproximateBindMatrix = function _computeApproximateBindMatrix(jointEntities, inverseBindMatrices, rootEntity, approximateBindMatrix) {
53875
- var subRootBoneCount = 0;
53876
- var children = rootEntity.children;
53877
- for(var i = 0, n = children.length; i < n; i++){
53878
- var rootChild = children[i];
53879
- var index = jointEntities.indexOf(rootChild);
53880
- if (index !== -1) {
53881
- Matrix.add(approximateBindMatrix, inverseBindMatrices[index], approximateBindMatrix);
53882
- subRootBoneCount++;
53883
- } else {
53884
- subRootBoneCount += this._computeApproximateBindMatrix(jointEntities, inverseBindMatrices, rootChild, approximateBindMatrix);
53885
- }
53886
- }
53887
- return subRootBoneCount;
53888
- };
53889
53991
  return GLTFSceneParser;
53890
53992
  }(GLTFParser);
53891
53993
  exports.GLTFSceneParser = __decorate([
@@ -53926,8 +54028,7 @@
53926
54028
  var rootBone = entities[skeleton];
53927
54029
  skin.rootBone = rootBone;
53928
54030
  } else {
53929
- var _this__findSceneRootBone;
53930
- var rootBone1 = (_this__findSceneRootBone = _this._findSceneRootBone(context, joints, entities)) != null ? _this__findSceneRootBone : _this._findSkeletonRootBone(joints, entities);
54031
+ var rootBone1 = _this._findSkinRootBoneByLCA(index, joints, entities, glTF.nodes);
53931
54032
  if (rootBone1) {
53932
54033
  skin.rootBone = rootBone1;
53933
54034
  } else {
@@ -53938,46 +54039,20 @@
53938
54039
  });
53939
54040
  return AssetPromise.resolve(skinPromise);
53940
54041
  };
53941
- _proto._findSceneRootBone = function _findSceneRootBone(context, joints, entities) {
53942
- var glTF = context.glTF, glTFResource = context.glTFResource;
53943
- var scenes = glTF.scenes;
53944
- var sceneRoots = glTFResource._sceneRoots;
53945
- if (!(scenes == null ? void 0 : scenes.length) || !(sceneRoots == null ? void 0 : sceneRoots.length)) {
53946
- return null;
53947
- }
53948
- for(var i = 0, n = scenes.length; i < n; i++){
53949
- var _scenes_i_nodes;
53950
- var sceneNodes = (_scenes_i_nodes = scenes[i].nodes) != null ? _scenes_i_nodes : [];
53951
- if (sceneNodes.length <= 1) {
53952
- continue;
53953
- }
53954
- var sceneRoot = sceneRoots[i];
53955
- if (!sceneRoot) {
53956
- continue;
53957
- }
53958
- var sceneRootChildren = new Set(sceneNodes.map(function(nodeIndex) {
53959
- return entities[nodeIndex];
53960
- }));
53961
- var allJointsUnderSceneRoot = true;
53962
- for(var j = 0, m = joints.length; j < m; j++){
53963
- var entity = entities[joints[j]];
53964
- while(entity == null ? void 0 : entity.parent){
53965
- entity = entity.parent;
53966
- }
53967
- if (!sceneRootChildren.has(entity)) {
53968
- allJointsUnderSceneRoot = false;
53969
- break;
53970
- }
53971
- }
53972
- if (allJointsUnderSceneRoot) {
53973
- return sceneRoot;
54042
+ _proto._findSkinRootBoneByLCA = function _findSkinRootBoneByLCA(skinIndex, joints, entities, nodes) {
54043
+ if (nodes === void 0) nodes = [];
54044
+ var nodeIndices = joints.slice();
54045
+ for(var i = 0, n = nodes.length; i < n; i++){
54046
+ var _nodes_i;
54047
+ if (((_nodes_i = nodes[i]) == null ? void 0 : _nodes_i.skin) === skinIndex) {
54048
+ nodeIndices.push(i);
53974
54049
  }
53975
54050
  }
53976
- return null;
54051
+ return this._findRootBoneByLCA(nodeIndices, entities);
53977
54052
  };
53978
- _proto._findSkeletonRootBone = function _findSkeletonRootBone(joints, entities) {
53979
- var paths = {};
53980
- for(var _iterator = _create_for_of_iterator_helper_loose(joints), _step; !(_step = _iterator()).done;){
54053
+ _proto._findRootBoneByLCA = function _findRootBoneByLCA(nodeIndices, entities) {
54054
+ var paths = [];
54055
+ for(var _iterator = _create_for_of_iterator_helper_loose(nodeIndices), _step; !(_step = _iterator()).done;){
53981
54056
  var index = _step.value;
53982
54057
  var path = new Array();
53983
54058
  var entity = entities[index];
@@ -53985,17 +54060,22 @@
53985
54060
  path.unshift(entity);
53986
54061
  entity = entity.parent;
53987
54062
  }
53988
- paths[index] = path;
54063
+ if (path.length) {
54064
+ paths.push(path);
54065
+ }
54066
+ }
54067
+ if (!paths.length) {
54068
+ return null;
53989
54069
  }
53990
54070
  var rootNode = null;
53991
54071
  for(var i = 0;; i++){
53992
- var path1 = paths[joints[0]];
54072
+ var path1 = paths[0];
53993
54073
  if (i >= path1.length) {
53994
54074
  return rootNode;
53995
54075
  }
53996
54076
  var entity1 = path1[i];
53997
- for(var j = 1, m = joints.length; j < m; j++){
53998
- path1 = paths[joints[j]];
54077
+ for(var j = 1, m = paths.length; j < m; j++){
54078
+ path1 = paths[j];
53999
54079
  if (i >= path1.length || entity1 !== path1[i]) {
54000
54080
  return rootNode;
54001
54081
  }
@@ -55540,7 +55620,10 @@
55540
55620
  "mp3",
55541
55621
  "ogg",
55542
55622
  "wav",
55543
- "audio"
55623
+ "audio",
55624
+ "m4a",
55625
+ "aac",
55626
+ "flac"
55544
55627
  ])
55545
55628
  ], AudioLoader);
55546
55629
  var ShaderChunkLoader = /*#__PURE__*/ function(Loader) {
@@ -55804,6 +55887,14 @@
55804
55887
  if (fog.fogDensity != undefined) scene.fogDensity = fog.fogDensity;
55805
55888
  if (fog.fogColor != undefined) scene.fogColor.copyFrom(fog.fogColor);
55806
55889
  }
55890
+ // parse physics
55891
+ var physics = data.scene.physics;
55892
+ // PhysicsScene has a native backing only when the engine was created with a physics backend.
55893
+ // Keep scene files loadable for render-only engines by ignoring serialized physics settings there.
55894
+ if (physics && engine._physicsInitialized) {
55895
+ if (physics.gravity != undefined) scene.physics.gravity.copyFrom(physics.gravity);
55896
+ if (physics.fixedTimeStep != undefined) scene.physics.fixedTimeStep = physics.fixedTimeStep;
55897
+ }
55807
55898
  // Post Process
55808
55899
  var postProcessData = data.scene.postProcess;
55809
55900
  if (postProcessData) {
@@ -56330,7 +56421,7 @@
56330
56421
  ], EXT_texture_webp);
56331
56422
 
56332
56423
  //@ts-ignore
56333
- var version = "0.0.0-experimental-2.0-game.12";
56424
+ var version = "0.0.0-experimental-2.0-game.14";
56334
56425
  console.log("Galacean Engine Version: " + version);
56335
56426
  for(var key in CoreObjects){
56336
56427
  Loader.registerClass(key, CoreObjects[key]);
@@ -56434,6 +56525,7 @@
56434
56525
  exports.Downsampling = Downsampling;
56435
56526
  exports.DynamicCollider = DynamicCollider;
56436
56527
  exports.DynamicColliderConstraints = DynamicColliderConstraints;
56528
+ exports.DynamicColliderKinematicTransformSyncMode = DynamicColliderKinematicTransformSyncMode;
56437
56529
  exports.EmissionModule = EmissionModule;
56438
56530
  exports.Engine = Engine;
56439
56531
  exports.EngineObject = EngineObject;