@galacean/engine 0.0.0-experimental-2.0-game.13 → 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
@@ -25401,7 +25401,13 @@
25401
25401
  _inherits$2(Collider, Component);
25402
25402
  function Collider(entity) {
25403
25403
  var _this;
25404
- _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;
25405
25411
  _this._updateFlag = entity.registerWorldChangeFlag();
25406
25412
  return _this;
25407
25413
  }
@@ -25445,9 +25451,14 @@
25445
25451
  * @internal
25446
25452
  */ _proto._onUpdate = function _onUpdate() {
25447
25453
  var shapes = this._shapes;
25448
- if (this._updateFlag.flag) {
25454
+ if (this._pendingReenterTeleport || this._updateFlag.flag) {
25449
25455
  var transform = this.entity.transform;
25450
- 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
+ }
25451
25462
  var worldScale = transform.lossyWorldScale;
25452
25463
  for(var i = 0, n = shapes.length; i < n; i++){
25453
25464
  var _shapes_i__nativeShape;
@@ -25469,6 +25480,7 @@
25469
25480
  * @internal
25470
25481
  */ _proto._onEnableInScene = function _onEnableInScene() {
25471
25482
  this.scene.physics._addCollider(this);
25483
+ this._pendingReenterTeleport = true;
25472
25484
  };
25473
25485
  /**
25474
25486
  * @internal
@@ -25587,6 +25599,9 @@
25587
25599
  __decorate$1([
25588
25600
  deepClone
25589
25601
  ], exports.Collider.prototype, "_shapes", void 0);
25602
+ __decorate$1([
25603
+ ignoreClone
25604
+ ], exports.Collider.prototype, "_pendingReenterTeleport", void 0);
25590
25605
  exports.Collider = __decorate$1([
25591
25606
  dependentComponents(Transform, DependentMode.CheckOnly)
25592
25607
  ], exports.Collider);
@@ -25881,7 +25896,6 @@
25881
25896
  this._isTrigger = false;
25882
25897
  this._rotation = new Vector3();
25883
25898
  this._position = new Vector3();
25884
- this._contactOffset = 0.02;
25885
25899
  /**
25886
25900
  * @internal
25887
25901
  * @beta
@@ -25947,7 +25961,9 @@
25947
25961
  if (!this._nativeShape) return;
25948
25962
  this._nativeShape.setPosition(this._position);
25949
25963
  this._nativeShape.setRotation(this._rotation);
25950
- this._nativeShape.setContactOffset(this._contactOffset);
25964
+ if (this._contactOffset !== undefined) {
25965
+ this._nativeShape.setContactOffset(this._contactOffset);
25966
+ }
25951
25967
  this._nativeShape.setIsTrigger(this._isTrigger);
25952
25968
  this._nativeShape.setMaterial(this._material._nativeMaterial);
25953
25969
  (_this__collider = this._collider) == null ? void 0 : _this__collider._handleShapesChanged(ColliderShapeChangeFlag.Property);
@@ -25985,7 +26001,9 @@
25985
26001
  * Contact offset for this shape, the value must be greater than or equal to 0.
25986
26002
  * @defaultValue 0.02
25987
26003
  */ function get() {
25988
- 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;
25989
26007
  },
25990
26008
  set: function set(value) {
25991
26009
  value = Math.max(0, value);
@@ -26306,7 +26324,7 @@
26306
26324
  _inherits$2(DynamicCollider, Collider);
26307
26325
  function DynamicCollider(entity) {
26308
26326
  var _this;
26309
- _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;
26310
26328
  var transform = _this.entity.transform;
26311
26329
  _this._nativeCollider = Engine._nativePhysics.createDynamicCollider(transform.worldPosition, transform.worldRotationQuaternion);
26312
26330
  _this._setLinearVelocity = _this._setLinearVelocity.bind(_this);
@@ -26398,17 +26416,14 @@
26398
26416
  * collision detection, use setKinematicTarget() instead."
26399
26417
  *
26400
26418
  * setGlobalPose is a teleport: PhysX skips contact detection between the old
26401
- * and new pose, so two kinematic actors moved onto each other via entity.transform
26402
- * mutation would NOT produce onCollisionEnter / onCollisionStay events even when
26403
- * scene.kineKineFilteringMode = eKEEP. Routing the per-frame sync through
26404
- * IDynamicCollider.move() (which the PhysX backend implements as
26405
- * setKinematicTarget) tells PhysX the actor is animating to the target during the
26406
- * next simulate(), enabling sweep contact detection for kine-kine and kine-dynamic
26407
- * 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.
26408
26423
  *
26409
26424
  * @internal
26410
26425
  */ _proto._syncEntityTransformToNative = function _syncEntityTransformToNative(worldPosition, worldRotation) {
26411
- if (this._isKinematic) {
26426
+ if (this._isKinematic && this._kinematicTransformSyncMode === 0) {
26412
26427
  this._nativeCollider.move(worldPosition, worldRotation);
26413
26428
  } else {
26414
26429
  Collider.prototype._syncEntityTransformToNative.call(this, worldPosition, worldRotation);
@@ -26438,6 +26453,7 @@
26438
26453
  target._angularVelocity.copyFrom(this.angularVelocity);
26439
26454
  target._centerOfMass.copyFrom(this.centerOfMass);
26440
26455
  target._inertiaTensor.copyFrom(this.inertiaTensor);
26456
+ target._kinematicTransformSyncMode = this._kinematicTransformSyncMode;
26441
26457
  Collider.prototype._cloneTo.call(this, target);
26442
26458
  };
26443
26459
  /**
@@ -26463,7 +26479,9 @@
26463
26479
  }
26464
26480
  this._nativeCollider.setMaxAngularVelocity(this._maxAngularVelocity);
26465
26481
  this._nativeCollider.setMaxDepenetrationVelocity(this._maxDepenetrationVelocity);
26466
- this._nativeCollider.setSleepThreshold(this._sleepThreshold);
26482
+ if (this._sleepThreshold !== undefined) {
26483
+ this._nativeCollider.setSleepThreshold(this._sleepThreshold);
26484
+ }
26467
26485
  this._nativeCollider.setSolverIterations(this._solverIterations);
26468
26486
  this._nativeCollider.setUseGravity(this._useGravity);
26469
26487
  this._nativeCollider.setIsKinematic(this._isKinematic);
@@ -26687,7 +26705,9 @@
26687
26705
  get: /**
26688
26706
  * The mass-normalized energy threshold, below which objects start going to sleep.
26689
26707
  */ function get() {
26690
- 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;
26691
26711
  },
26692
26712
  set: function set(value) {
26693
26713
  if (value !== this._sleepThreshold) {
@@ -26783,6 +26803,22 @@
26783
26803
  this._nativeCollider.setCollisionDetectionMode(value);
26784
26804
  }
26785
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
+ }
26786
26822
  }
26787
26823
  ]);
26788
26824
  return DynamicCollider;
@@ -26824,6 +26860,13 @@
26824
26860
  /** Speculative continuous collision detection is on for static and dynamic geometries */ CollisionDetectionMode[CollisionDetectionMode["ContinuousSpeculative"] = 3] = "ContinuousSpeculative";
26825
26861
  return CollisionDetectionMode;
26826
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
+ }({});
26827
26870
  /**
26828
26871
  * Use these flags to constrain motion of dynamic collider.
26829
26872
  */ var DynamicColliderConstraints = /*#__PURE__*/ function(DynamicColliderConstraints) {
@@ -37585,6 +37628,13 @@
37585
37628
  /** Finished state. */ LayerState[LayerState["Finished"] = 4] = "Finished";
37586
37629
  return LayerState;
37587
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
+ }({});
37588
37638
  /**
37589
37639
  * @internal
37590
37640
  */ var AnimationEventHandler = /*#__PURE__*/ function() {
@@ -37690,21 +37740,15 @@
37690
37740
  ]);
37691
37741
  return AnimatorStateTransition;
37692
37742
  }();
37693
- /**
37694
- * Animation wrap mode.
37695
- */ var WrapMode = /*#__PURE__*/ function(WrapMode) {
37696
- /** Play once */ WrapMode[WrapMode["Once"] = 0] = "Once";
37697
- /** Loop play */ WrapMode[WrapMode["Loop"] = 1] = "Loop";
37698
- return WrapMode;
37699
- }({});
37700
37743
  /**
37701
37744
  * Per-instance runtime data for an AnimatorState.
37702
37745
  * Proxies read-only properties from the shared AnimatorState asset,
37703
- * while providing per-instance mutable properties (e.g. speed).
37746
+ * while providing per-instance mutable properties (e.g. speed, wrapMode).
37704
37747
  */ var AnimatorStatePlayData = /*#__PURE__*/ function() {
37705
37748
  function AnimatorStatePlayData() {
37706
37749
  /** @internal */ this.isForward = true;
37707
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;
37708
37752
  this._changedOrientation = false;
37709
37753
  }
37710
37754
  var _proto = AnimatorStatePlayData.prototype;
@@ -37723,6 +37767,7 @@
37723
37767
  this.currentEventIndex = 0;
37724
37768
  this.isForward = true;
37725
37769
  this.speed = state.speed;
37770
+ this.wrapMode = state.wrapMode;
37726
37771
  this.state._transitionCollection.needResetCurrentCheckIndex = true;
37727
37772
  };
37728
37773
  _proto.updateOrientation = function updateOrientation(deltaTime) {
@@ -37741,7 +37786,7 @@
37741
37786
  var time = this.playedTime + this.offsetFrameTime;
37742
37787
  var duration = state._getDuration();
37743
37788
  this.playState = AnimatorStatePlayState.Playing;
37744
- if (state.wrapMode === WrapMode.Loop) {
37789
+ if (this.wrapMode === WrapMode.Loop) {
37745
37790
  time = duration ? time % duration : 0;
37746
37791
  } else {
37747
37792
  if (Math.abs(time) >= duration) {
@@ -37775,12 +37820,6 @@
37775
37820
  return this.state.clip;
37776
37821
  }
37777
37822
  },
37778
- {
37779
- key: "wrapMode",
37780
- get: /** The wrap mode. */ function get() {
37781
- return this.state.wrapMode;
37782
- }
37783
- },
37784
37823
  {
37785
37824
  key: "transitions",
37786
37825
  get: /** The transitions going out of this state. */ function get() {
@@ -37927,7 +37966,7 @@
37927
37966
  * @param layerIndex - The layer index(default -1). If layer is -1, find the first state with the given state name
37928
37967
  */ /**
37929
37968
  * Find the per-instance play data for a state by name.
37930
- * 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.
37931
37970
  * @param stateName - The state name
37932
37971
  * @param layerIndex - The layer index (default -1, searches all layers)
37933
37972
  * @returns Per-instance AnimatorStatePlayData, or null if not found
@@ -38749,22 +38788,27 @@
38749
38788
  return true;
38750
38789
  };
38751
38790
  _proto._fireAnimationEvents = function _fireAnimationEvents(playData, eventHandlers, lastClipTime, deltaTime) {
38752
- var state = playData.state, isForward = playData.isForward, clipTime = playData.clipTime;
38791
+ var state = playData.state, isForward = playData.isForward, clipTime = playData.clipTime, wrapMode = playData.wrapMode;
38753
38792
  var startTime = state._getClipActualStartTime();
38754
38793
  var endTime = state._getClipActualEndTime();
38794
+ var canWrap = wrapMode === WrapMode.Loop;
38755
38795
  if (isForward) {
38756
38796
  if (lastClipTime + deltaTime >= endTime) {
38757
38797
  this._fireSubAnimationEvents(playData, eventHandlers, lastClipTime, endTime);
38758
- playData.currentEventIndex = 0;
38759
- this._fireSubAnimationEvents(playData, eventHandlers, startTime, clipTime);
38798
+ if (canWrap) {
38799
+ playData.currentEventIndex = 0;
38800
+ this._fireSubAnimationEvents(playData, eventHandlers, startTime, clipTime);
38801
+ }
38760
38802
  } else {
38761
38803
  this._fireSubAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
38762
38804
  }
38763
38805
  } else {
38764
38806
  if (lastClipTime + deltaTime <= startTime) {
38765
38807
  this._fireBackwardSubAnimationEvents(playData, eventHandlers, lastClipTime, startTime);
38766
- playData.currentEventIndex = eventHandlers.length - 1;
38767
- this._fireBackwardSubAnimationEvents(playData, eventHandlers, endTime, clipTime);
38808
+ if (canWrap) {
38809
+ playData.currentEventIndex = eventHandlers.length - 1;
38810
+ this._fireBackwardSubAnimationEvents(playData, eventHandlers, endTime, clipTime);
38811
+ }
38768
38812
  } else {
38769
38813
  this._fireBackwardSubAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
38770
38814
  }
@@ -41223,7 +41267,7 @@
41223
41267
  _inherits$2(EmissionModule, ParticleGeneratorModule);
41224
41268
  function EmissionModule() {
41225
41269
  var _this;
41226
- _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);
41227
41271
  return _this;
41228
41272
  }
41229
41273
  var _proto = EmissionModule.prototype;
@@ -41260,6 +41304,7 @@
41260
41304
  * @internal
41261
41305
  */ _proto._emit = function _emit(lastPlayTime, playTime) {
41262
41306
  this._emitByRateOverTime(playTime);
41307
+ this._emitByRateOverDistance(lastPlayTime, playTime);
41263
41308
  this._emitByBurst(lastPlayTime, playTime);
41264
41309
  };
41265
41310
  /**
@@ -41273,6 +41318,13 @@
41273
41318
  */ _proto._reset = function _reset() {
41274
41319
  this._frameRateTime = 0;
41275
41320
  this._currentBurstIndex = 0;
41321
+ this._invalidateDistanceBaseline();
41322
+ };
41323
+ /**
41324
+ * @internal
41325
+ */ _proto._invalidateDistanceBaseline = function _invalidateDistanceBaseline() {
41326
+ this._hasLastEmitPosition = false;
41327
+ this._distanceAccumulator = 0;
41276
41328
  };
41277
41329
  /**
41278
41330
  * @internal
@@ -41293,6 +41345,55 @@
41293
41345
  }
41294
41346
  }
41295
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
+ };
41296
41397
  _proto._emitByBurst = function _emitByBurst(lastPlayTime, playTime) {
41297
41398
  var main = this._generator.main;
41298
41399
  var duration = main.duration;
@@ -41389,6 +41490,7 @@
41389
41490
  return EmissionModule;
41390
41491
  }(ParticleGeneratorModule);
41391
41492
  /** @internal */ EmissionModule._emissionShapeMacro = ShaderMacro.getByName("RENDERER_EMISSION_SHAPE");
41493
+ EmissionModule._tempEmitPosition = new Vector3();
41392
41494
  __decorate$1([
41393
41495
  deepClone
41394
41496
  ], EmissionModule.prototype, "rateOverTime", void 0);
@@ -41401,6 +41503,15 @@
41401
41503
  __decorate$1([
41402
41504
  ignoreClone
41403
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);
41404
41515
  __decorate$1([
41405
41516
  deepClone
41406
41517
  ], EmissionModule.prototype, "_bursts", void 0);
@@ -43077,11 +43188,15 @@
43077
43188
  }
43078
43189
  } else {
43079
43190
  this._isPlaying = false;
43191
+ // Invalidate the rateOverDistance baseline so emitter movement during the stop
43192
+ // interval doesn't burst on resume.
43080
43193
  if (stopMode === ParticleStopMode.StopEmittingAndClear) {
43081
43194
  this._clearActiveParticles();
43082
43195
  this._playTime = 0;
43083
43196
  this._firstActiveTransformedBoundingBox = this._firstFreeTransformedBoundingBox;
43084
43197
  this.emission._reset();
43198
+ } else {
43199
+ this.emission._invalidateDistanceBaseline();
43085
43200
  }
43086
43201
  }
43087
43202
  };
@@ -43093,37 +43208,40 @@
43093
43208
  };
43094
43209
  /**
43095
43210
  * @internal
43096
- */ _proto._emit = function _emit(playTime, count) {
43097
- var emission = this.emission;
43098
- if (emission.enabled) {
43099
- var main = this.main;
43100
- // Wait the existing particles to be retired
43101
- var notRetireParticleCount = this._getNotRetiredParticleCount();
43102
- if (notRetireParticleCount >= main.maxParticles) {
43103
- return;
43104
- }
43105
- var position = ParticleGenerator._tempVector30;
43106
- var direction = ParticleGenerator._tempVector31;
43107
- var transform = this._renderer.entity.transform;
43108
- var shape = emission.shape;
43109
- var positionScale = main._getPositionScale();
43110
- for(var i = 0; i < count; i++){
43111
- if (shape == null ? void 0 : shape.enabled) {
43112
- shape._generatePositionAndDirection(emission._shapeRand, playTime, position, direction);
43113
- position.multiply(positionScale);
43114
- direction.normalize().multiply(positionScale);
43115
- } else {
43116
- position.set(0, 0, 0);
43117
- direction.set(0, 0, -1);
43118
- // Speed is scaled by shape scale in world simulation space
43119
- // So if no shape and in world simulation space, we shouldn't scale the speed
43120
- if (main.simulationSpace === ParticleSimulationSpace.Local) {
43121
- direction.multiply(positionScale);
43122
- }
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);
43123
43240
  }
43124
- this._addNewParticle(position, direction, transform, playTime);
43125
43241
  }
43242
+ this._addNewParticle(position, direction, transform, playTime, emitWorldPositionOverride);
43126
43243
  }
43244
+ return count;
43127
43245
  };
43128
43246
  /**
43129
43247
  * @internal
@@ -43525,7 +43643,7 @@
43525
43643
  this._transformedBoundsArray[previousFreeElement * ParticleBufferUtils.boundsFloatStride + boundsTimeOffset] = this._playTime;
43526
43644
  }
43527
43645
  };
43528
- _proto._addNewParticle = function _addNewParticle(position, direction, transform, playTime) {
43646
+ _proto._addNewParticle = function _addNewParticle(position, direction, transform, playTime, emitWorldPositionOverride) {
43529
43647
  var firstFreeElement = this._firstFreeElement;
43530
43648
  var nextFreeElement = firstFreeElement + 1;
43531
43649
  if (nextFreeElement >= this._currentParticleCount) {
@@ -43548,7 +43666,7 @@
43548
43666
  }
43549
43667
  var pos, rot;
43550
43668
  if (main.simulationSpace === ParticleSimulationSpace.World) {
43551
- pos = transform.worldPosition;
43669
+ pos = emitWorldPositionOverride != null ? emitWorldPositionOverride : transform.worldPosition;
43552
43670
  rot = transform.worldRotationQuaternion;
43553
43671
  }
43554
43672
  var startSpeed = main.startSpeed.evaluate(undefined, main._startSpeedRand.random());
@@ -43668,18 +43786,18 @@
43668
43786
  }
43669
43787
  // Initialize feedback buffer for this particle
43670
43788
  if (this._useTransformFeedback) {
43671
- this._addFeedbackParticle(firstFreeElement, position, direction, startSpeed, transform);
43789
+ this._addFeedbackParticle(firstFreeElement, position, direction, startSpeed, transform, pos);
43672
43790
  }
43673
43791
  this._firstFreeElement = nextFreeElement;
43674
43792
  };
43675
- _proto._addFeedbackParticle = function _addFeedbackParticle(index, shapePosition, direction, startSpeed, transform) {
43793
+ _proto._addFeedbackParticle = function _addFeedbackParticle(index, shapePosition, direction, startSpeed, transform, emitWorldPosition) {
43676
43794
  var position;
43677
43795
  if (this.main.simulationSpace === ParticleSimulationSpace.Local) {
43678
43796
  position = shapePosition;
43679
43797
  } else {
43680
43798
  position = ParticleGenerator._tempVector32;
43681
43799
  Vector3.transformByQuat(shapePosition, transform.worldRotationQuaternion, position);
43682
- position.add(transform.worldPosition);
43800
+ position.add(emitWorldPosition != null ? emitWorldPosition : transform.worldPosition);
43683
43801
  }
43684
43802
  this._feedbackSimulator.writeParticleData(index, position, direction.x * startSpeed, direction.y * startSpeed, direction.z * startSpeed);
43685
43803
  };
@@ -46355,6 +46473,7 @@
46355
46473
  Downsampling: Downsampling,
46356
46474
  DynamicCollider: DynamicCollider,
46357
46475
  DynamicColliderConstraints: DynamicColliderConstraints,
46476
+ DynamicColliderKinematicTransformSyncMode: DynamicColliderKinematicTransformSyncMode,
46358
46477
  EmissionModule: EmissionModule,
46359
46478
  Engine: Engine,
46360
46479
  EngineObject: EngineObject,
@@ -55768,6 +55887,14 @@
55768
55887
  if (fog.fogDensity != undefined) scene.fogDensity = fog.fogDensity;
55769
55888
  if (fog.fogColor != undefined) scene.fogColor.copyFrom(fog.fogColor);
55770
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
+ }
55771
55898
  // Post Process
55772
55899
  var postProcessData = data.scene.postProcess;
55773
55900
  if (postProcessData) {
@@ -56294,7 +56421,7 @@
56294
56421
  ], EXT_texture_webp);
56295
56422
 
56296
56423
  //@ts-ignore
56297
- var version = "0.0.0-experimental-2.0-game.13";
56424
+ var version = "0.0.0-experimental-2.0-game.14";
56298
56425
  console.log("Galacean Engine Version: " + version);
56299
56426
  for(var key in CoreObjects){
56300
56427
  Loader.registerClass(key, CoreObjects[key]);
@@ -56398,6 +56525,7 @@
56398
56525
  exports.Downsampling = Downsampling;
56399
56526
  exports.DynamicCollider = DynamicCollider;
56400
56527
  exports.DynamicColliderConstraints = DynamicColliderConstraints;
56528
+ exports.DynamicColliderKinematicTransformSyncMode = DynamicColliderKinematicTransformSyncMode;
56401
56529
  exports.EmissionModule = EmissionModule;
56402
56530
  exports.Engine = Engine;
56403
56531
  exports.EngineObject = EngineObject;