@galacean/engine 0.0.0-experimental-2.0-game.13 → 0.0.0-experimental-2.0-game.15

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
@@ -5457,10 +5457,14 @@
5457
5457
  if (_instanceof1$2(sourceProperty, Map) || _instanceof1$2(sourceProperty, Set)) return CloneMode.Deep;
5458
5458
  // Value types with copyFrom (math types like Vector3, Color, etc.)
5459
5459
  if (sourceProperty.copyFrom) return CloneMode.Deep;
5460
- // Plain objects - deep clone (may contain Entity/Component refs)
5461
- if (sourceProperty.constructor === Object) return CloneMode.Deep;
5462
- // Other class instances (engine resources like Material, Texture) - shared reference
5463
- return CloneMode.Assignment;
5460
+ // Engine resources (Material, Texture, Mesh, Shader, ...) refCount-managed,
5461
+ // shared by reference. Anything outside this contract is treated as a value-like
5462
+ // user class and gets a deep clone (so nested Entity/Component refs are remapped).
5463
+ if (_instanceof1$2(sourceProperty, ReferResource)) return CloneMode.Assignment;
5464
+ // Default: deep clone. Covers plain objects {...} and user-defined value classes
5465
+ // (EventHandler, business data containers). Internal Entity/Component refs reach
5466
+ // line 109's _remap branch and are correctly rebound to the target tree.
5467
+ return CloneMode.Deep;
5464
5468
  };
5465
5469
  CloneManager.deepCloneObject = function deepCloneObject(source, target, deepInstanceMap) {
5466
5470
  for(var k in source){
@@ -12318,7 +12322,7 @@
12318
12322
  };
12319
12323
  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
12324
  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
12325
+ 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
12326
  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
12327
  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
12328
  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 +25405,13 @@
25401
25405
  _inherits$2(Collider, Component);
25402
25406
  function Collider(entity) {
25403
25407
  var _this;
25404
- _this = Component.call(this, entity) || this, /** @internal */ _this._index = -1, _this._shapes = [], _this._collisionLayerIndex = 0;
25408
+ _this = Component.call(this, entity) || this, /** @internal */ _this._index = -1, _this._shapes = [], _this._collisionLayerIndex = 0, /**
25409
+ * Disabling a collider only detaches its native actor from the simulation
25410
+ * scene; the actor is not destroyed, so on re-enable it still holds its
25411
+ * pre-disable pose. The first transform sync after (re-)enable must teleport,
25412
+ * never sweep — otherwise a kinematic actor drags across the scene from that
25413
+ * stale pose and fires spurious contacts along the path.
25414
+ */ _this._pendingReenterTeleport = false;
25405
25415
  _this._updateFlag = entity.registerWorldChangeFlag();
25406
25416
  return _this;
25407
25417
  }
@@ -25445,9 +25455,14 @@
25445
25455
  * @internal
25446
25456
  */ _proto._onUpdate = function _onUpdate() {
25447
25457
  var shapes = this._shapes;
25448
- if (this._updateFlag.flag) {
25458
+ if (this._pendingReenterTeleport || this._updateFlag.flag) {
25449
25459
  var transform = this.entity.transform;
25450
- this._syncEntityTransformToNative(transform.worldPosition, transform.worldRotationQuaternion);
25460
+ if (this._pendingReenterTeleport) {
25461
+ this._teleportToEntityTransform(transform.worldPosition, transform.worldRotationQuaternion);
25462
+ this._pendingReenterTeleport = false;
25463
+ } else {
25464
+ this._syncEntityTransformToNative(transform.worldPosition, transform.worldRotationQuaternion);
25465
+ }
25451
25466
  var worldScale = transform.lossyWorldScale;
25452
25467
  for(var i = 0, n = shapes.length; i < n; i++){
25453
25468
  var _shapes_i__nativeShape;
@@ -25469,6 +25484,7 @@
25469
25484
  * @internal
25470
25485
  */ _proto._onEnableInScene = function _onEnableInScene() {
25471
25486
  this.scene.physics._addCollider(this);
25487
+ this._pendingReenterTeleport = true;
25472
25488
  };
25473
25489
  /**
25474
25490
  * @internal
@@ -25587,6 +25603,9 @@
25587
25603
  __decorate$1([
25588
25604
  deepClone
25589
25605
  ], exports.Collider.prototype, "_shapes", void 0);
25606
+ __decorate$1([
25607
+ ignoreClone
25608
+ ], exports.Collider.prototype, "_pendingReenterTeleport", void 0);
25590
25609
  exports.Collider = __decorate$1([
25591
25610
  dependentComponents(Transform, DependentMode.CheckOnly)
25592
25611
  ], exports.Collider);
@@ -25881,7 +25900,6 @@
25881
25900
  this._isTrigger = false;
25882
25901
  this._rotation = new Vector3();
25883
25902
  this._position = new Vector3();
25884
- this._contactOffset = 0.02;
25885
25903
  /**
25886
25904
  * @internal
25887
25905
  * @beta
@@ -25947,7 +25965,9 @@
25947
25965
  if (!this._nativeShape) return;
25948
25966
  this._nativeShape.setPosition(this._position);
25949
25967
  this._nativeShape.setRotation(this._rotation);
25950
- this._nativeShape.setContactOffset(this._contactOffset);
25968
+ if (this._contactOffset !== undefined) {
25969
+ this._nativeShape.setContactOffset(this._contactOffset);
25970
+ }
25951
25971
  this._nativeShape.setIsTrigger(this._isTrigger);
25952
25972
  this._nativeShape.setMaterial(this._material._nativeMaterial);
25953
25973
  (_this__collider = this._collider) == null ? void 0 : _this__collider._handleShapesChanged(ColliderShapeChangeFlag.Property);
@@ -25985,7 +26005,9 @@
25985
26005
  * Contact offset for this shape, the value must be greater than or equal to 0.
25986
26006
  * @defaultValue 0.02
25987
26007
  */ function get() {
25988
- return this._contactOffset;
26008
+ var _Engine__nativePhysics_getDefaultContactOffset, _Engine__nativePhysics;
26009
+ var _this__contactOffset, _ref;
26010
+ 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
26011
  },
25990
26012
  set: function set(value) {
25991
26013
  value = Math.max(0, value);
@@ -26306,7 +26328,7 @@
26306
26328
  _inherits$2(DynamicCollider, Collider);
26307
26329
  function DynamicCollider(entity) {
26308
26330
  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;
26331
+ _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
26332
  var transform = _this.entity.transform;
26311
26333
  _this._nativeCollider = Engine._nativePhysics.createDynamicCollider(transform.worldPosition, transform.worldRotationQuaternion);
26312
26334
  _this._setLinearVelocity = _this._setLinearVelocity.bind(_this);
@@ -26398,17 +26420,14 @@
26398
26420
  * collision detection, use setKinematicTarget() instead."
26399
26421
  *
26400
26422
  * 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.
26423
+ * and new pose. setKinematicTarget tells PhysX the actor is animating to the
26424
+ * target during the next simulate(), enabling swept contacts. Some compatibility
26425
+ * layers need transform writes to stay teleport-like, so the sync mode is
26426
+ * explicit while {@link move} always keeps target semantics.
26408
26427
  *
26409
26428
  * @internal
26410
26429
  */ _proto._syncEntityTransformToNative = function _syncEntityTransformToNative(worldPosition, worldRotation) {
26411
- if (this._isKinematic) {
26430
+ if (this._isKinematic && this._kinematicTransformSyncMode === 0) {
26412
26431
  this._nativeCollider.move(worldPosition, worldRotation);
26413
26432
  } else {
26414
26433
  Collider.prototype._syncEntityTransformToNative.call(this, worldPosition, worldRotation);
@@ -26438,6 +26457,7 @@
26438
26457
  target._angularVelocity.copyFrom(this.angularVelocity);
26439
26458
  target._centerOfMass.copyFrom(this.centerOfMass);
26440
26459
  target._inertiaTensor.copyFrom(this.inertiaTensor);
26460
+ target._kinematicTransformSyncMode = this._kinematicTransformSyncMode;
26441
26461
  Collider.prototype._cloneTo.call(this, target);
26442
26462
  };
26443
26463
  /**
@@ -26463,7 +26483,9 @@
26463
26483
  }
26464
26484
  this._nativeCollider.setMaxAngularVelocity(this._maxAngularVelocity);
26465
26485
  this._nativeCollider.setMaxDepenetrationVelocity(this._maxDepenetrationVelocity);
26466
- this._nativeCollider.setSleepThreshold(this._sleepThreshold);
26486
+ if (this._sleepThreshold !== undefined) {
26487
+ this._nativeCollider.setSleepThreshold(this._sleepThreshold);
26488
+ }
26467
26489
  this._nativeCollider.setSolverIterations(this._solverIterations);
26468
26490
  this._nativeCollider.setUseGravity(this._useGravity);
26469
26491
  this._nativeCollider.setIsKinematic(this._isKinematic);
@@ -26687,7 +26709,9 @@
26687
26709
  get: /**
26688
26710
  * The mass-normalized energy threshold, below which objects start going to sleep.
26689
26711
  */ function get() {
26690
- return this._sleepThreshold;
26712
+ var _Engine__nativePhysics_getDefaultSleepThreshold, _Engine__nativePhysics;
26713
+ var _this__sleepThreshold, _ref;
26714
+ 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
26715
  },
26692
26716
  set: function set(value) {
26693
26717
  if (value !== this._sleepThreshold) {
@@ -26783,6 +26807,22 @@
26783
26807
  this._nativeCollider.setCollisionDetectionMode(value);
26784
26808
  }
26785
26809
  }
26810
+ },
26811
+ {
26812
+ key: "kinematicTransformSyncMode",
26813
+ get: /**
26814
+ * Controls how entity transform changes are synchronized to a kinematic native actor.
26815
+ *
26816
+ * @remarks
26817
+ * `Target` routes transform changes through {@link move}, so PhysX treats the
26818
+ * actor as moving between frames and can generate swept contacts. `Teleport`
26819
+ * writes the native pose directly and does not imply velocity.
26820
+ */ function get() {
26821
+ return this._kinematicTransformSyncMode;
26822
+ },
26823
+ set: function set(value) {
26824
+ this._kinematicTransformSyncMode = value;
26825
+ }
26786
26826
  }
26787
26827
  ]);
26788
26828
  return DynamicCollider;
@@ -26824,6 +26864,13 @@
26824
26864
  /** Speculative continuous collision detection is on for static and dynamic geometries */ CollisionDetectionMode[CollisionDetectionMode["ContinuousSpeculative"] = 3] = "ContinuousSpeculative";
26825
26865
  return CollisionDetectionMode;
26826
26866
  }({});
26867
+ /**
26868
+ * Kinematic transform synchronization mode.
26869
+ */ var DynamicColliderKinematicTransformSyncMode = /*#__PURE__*/ function(DynamicColliderKinematicTransformSyncMode) {
26870
+ /** Synchronize transform changes through PhysX setKinematicTarget. */ DynamicColliderKinematicTransformSyncMode[DynamicColliderKinematicTransformSyncMode["Target"] = 0] = "Target";
26871
+ /** Synchronize transform changes by directly teleporting the native actor. */ DynamicColliderKinematicTransformSyncMode[DynamicColliderKinematicTransformSyncMode["Teleport"] = 1] = "Teleport";
26872
+ return DynamicColliderKinematicTransformSyncMode;
26873
+ }({});
26827
26874
  /**
26828
26875
  * Use these flags to constrain motion of dynamic collider.
26829
26876
  */ var DynamicColliderConstraints = /*#__PURE__*/ function(DynamicColliderConstraints) {
@@ -36426,6 +36473,13 @@
36426
36473
  this._length = 0;
36427
36474
  };
36428
36475
  /**
36476
+ * Samples an animation at a given time.
36477
+ * @param entity - The animated entity
36478
+ * @param time - The time to sample an animation
36479
+ */ _proto.sampleAnimation = function sampleAnimation(entity, time) {
36480
+ this._sampleAnimation(entity, time);
36481
+ };
36482
+ /**
36429
36483
  * @internal
36430
36484
  * Samples an animation at a given time.
36431
36485
  * @param entity - The animated entity
@@ -37585,6 +37639,13 @@
37585
37639
  /** Finished state. */ LayerState[LayerState["Finished"] = 4] = "Finished";
37586
37640
  return LayerState;
37587
37641
  }({});
37642
+ /**
37643
+ * Animation wrap mode.
37644
+ */ var WrapMode = /*#__PURE__*/ function(WrapMode) {
37645
+ /** Play once */ WrapMode[WrapMode["Once"] = 0] = "Once";
37646
+ /** Loop play */ WrapMode[WrapMode["Loop"] = 1] = "Loop";
37647
+ return WrapMode;
37648
+ }({});
37588
37649
  /**
37589
37650
  * @internal
37590
37651
  */ var AnimationEventHandler = /*#__PURE__*/ function() {
@@ -37690,21 +37751,15 @@
37690
37751
  ]);
37691
37752
  return AnimatorStateTransition;
37692
37753
  }();
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
37754
  /**
37701
37755
  * Per-instance runtime data for an AnimatorState.
37702
37756
  * Proxies read-only properties from the shared AnimatorState asset,
37703
- * while providing per-instance mutable properties (e.g. speed).
37757
+ * while providing per-instance mutable properties (e.g. speed, wrapMode).
37704
37758
  */ var AnimatorStatePlayData = /*#__PURE__*/ function() {
37705
37759
  function AnimatorStatePlayData() {
37706
37760
  /** @internal */ this.isForward = true;
37707
37761
  /** Per-instance speed. Initialized from AnimatorState.speed, safe to modify without affecting other instances. */ this.speed = 1.0;
37762
+ /** Per-instance wrap mode. Initialized from AnimatorState.wrapMode, safe to modify without affecting other instances. */ this.wrapMode = WrapMode.Loop;
37708
37763
  this._changedOrientation = false;
37709
37764
  }
37710
37765
  var _proto = AnimatorStatePlayData.prototype;
@@ -37723,6 +37778,7 @@
37723
37778
  this.currentEventIndex = 0;
37724
37779
  this.isForward = true;
37725
37780
  this.speed = state.speed;
37781
+ this.wrapMode = state.wrapMode;
37726
37782
  this.state._transitionCollection.needResetCurrentCheckIndex = true;
37727
37783
  };
37728
37784
  _proto.updateOrientation = function updateOrientation(deltaTime) {
@@ -37741,7 +37797,7 @@
37741
37797
  var time = this.playedTime + this.offsetFrameTime;
37742
37798
  var duration = state._getDuration();
37743
37799
  this.playState = AnimatorStatePlayState.Playing;
37744
- if (state.wrapMode === WrapMode.Loop) {
37800
+ if (this.wrapMode === WrapMode.Loop) {
37745
37801
  time = duration ? time % duration : 0;
37746
37802
  } else {
37747
37803
  if (Math.abs(time) >= duration) {
@@ -37775,12 +37831,6 @@
37775
37831
  return this.state.clip;
37776
37832
  }
37777
37833
  },
37778
- {
37779
- key: "wrapMode",
37780
- get: /** The wrap mode. */ function get() {
37781
- return this.state.wrapMode;
37782
- }
37783
- },
37784
37834
  {
37785
37835
  key: "transitions",
37786
37836
  get: /** The transitions going out of this state. */ function get() {
@@ -37821,6 +37871,8 @@
37821
37871
  */ var AnimatorStateData = function AnimatorStateData() {
37822
37872
  this.curveLayerOwner = [];
37823
37873
  this.eventHandlers = [];
37874
+ this.state = null;
37875
+ this.clipChangedListener = null;
37824
37876
  };
37825
37877
  /**
37826
37878
  * The controller of the animation system.
@@ -37828,7 +37880,7 @@
37828
37880
  _inherits$2(Animator, Component);
37829
37881
  function Animator(entity) {
37830
37882
  var _this;
37831
- _this = Component.call(this, entity) || this, /** Culling mode of this Animator. */ _this.cullingMode = AnimatorCullingMode.None, /** The playback speed of the Animator, 1.0 is normal playback speed. */ _this.speed = 1.0, /** @internal */ _this._playFrameCount = -1, /** @internal */ _this._onUpdateIndex = -1, _this._updateMark = 0, _this._animatorLayersData = new Array(), _this._curveOwnerPool = Object.create(null), _this._animationEventHandlerPool = new ClearableObjectPool(AnimationEventHandler), _this._parametersValueMap = Object.create(null), _this._tempAnimatorStateInfo = {
37883
+ _this = Component.call(this, entity) || this, /** Culling mode of this Animator. */ _this.cullingMode = AnimatorCullingMode.None, /** The playback speed of the Animator, 1.0 is normal playback speed. */ _this.speed = 1.0, /** Whether the Animator sends AnimationEvent callbacks. */ _this.fireEvents = true, /** @internal */ _this._playFrameCount = -1, /** @internal */ _this._onUpdateIndex = -1, _this._updateMark = 0, _this._animatorLayersData = new Array(), _this._curveOwnerPool = Object.create(null), _this._animationEventHandlerPool = new ClearableObjectPool(AnimationEventHandler), _this._parametersValueMap = Object.create(null), _this._tempAnimatorStateInfo = {
37832
37884
  layerIndex: -1,
37833
37885
  state: null
37834
37886
  }, _this._controlledRenderers = new Array();
@@ -37927,7 +37979,7 @@
37927
37979
  * @param layerIndex - The layer index(default -1). If layer is -1, find the first state with the given state name
37928
37980
  */ /**
37929
37981
  * 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.
37982
+ * The returned object's `speed` and `wrapMode` are per-instance and safe to modify without affecting other Animator instances.
37931
37983
  * @param stateName - The state name
37932
37984
  * @param layerIndex - The layer index (default -1, searches all layers)
37933
37985
  * @returns Per-instance AnimatorStatePlayData, or null if not found
@@ -38032,6 +38084,18 @@
38032
38084
  owner.revertDefaultValue();
38033
38085
  }
38034
38086
  }
38087
+ var layersData = this._animatorLayersData;
38088
+ for(var i = 0, n = layersData.length; i < n; i++){
38089
+ var stateDataMap = layersData[i].animatorStateDataMap;
38090
+ for(var stateName in stateDataMap){
38091
+ var stateData = stateDataMap[stateName];
38092
+ if (stateData.clipChangedListener && stateData.state) {
38093
+ stateData.state._updateFlagManager.removeListener(stateData.clipChangedListener);
38094
+ stateData.clipChangedListener = null;
38095
+ stateData.state = null;
38096
+ }
38097
+ }
38098
+ }
38035
38099
  this._animatorLayersData.length = 0;
38036
38100
  this._curveOwnerPool = Object.create(null);
38037
38101
  this._parametersValueMap = Object.create(null);
@@ -38051,6 +38115,7 @@
38051
38115
  };
38052
38116
  _proto._onDestroy = function _onDestroy() {
38053
38117
  Component.prototype._onDestroy.call(this);
38118
+ this._reset();
38054
38119
  var controller = this._animatorController;
38055
38120
  if (controller) {
38056
38121
  var _this__controllerUpdateFlag;
@@ -38171,6 +38236,8 @@
38171
38236
  };
38172
38237
  clipChangedListener();
38173
38238
  state._updateFlagManager.addListener(clipChangedListener);
38239
+ animatorStateData.state = state;
38240
+ animatorStateData.clipChangedListener = clipChangedListener;
38174
38241
  };
38175
38242
  _proto._clearCrossData = function _clearCrossData(animatorLayerData) {
38176
38243
  animatorLayerData.crossCurveMark++;
@@ -38749,22 +38816,27 @@
38749
38816
  return true;
38750
38817
  };
38751
38818
  _proto._fireAnimationEvents = function _fireAnimationEvents(playData, eventHandlers, lastClipTime, deltaTime) {
38752
- var state = playData.state, isForward = playData.isForward, clipTime = playData.clipTime;
38819
+ var state = playData.state, isForward = playData.isForward, clipTime = playData.clipTime, wrapMode = playData.wrapMode;
38753
38820
  var startTime = state._getClipActualStartTime();
38754
38821
  var endTime = state._getClipActualEndTime();
38822
+ var canWrap = wrapMode === WrapMode.Loop;
38755
38823
  if (isForward) {
38756
38824
  if (lastClipTime + deltaTime >= endTime) {
38757
38825
  this._fireSubAnimationEvents(playData, eventHandlers, lastClipTime, endTime);
38758
- playData.currentEventIndex = 0;
38759
- this._fireSubAnimationEvents(playData, eventHandlers, startTime, clipTime);
38826
+ if (canWrap) {
38827
+ playData.currentEventIndex = 0;
38828
+ this._fireSubAnimationEvents(playData, eventHandlers, startTime, clipTime);
38829
+ }
38760
38830
  } else {
38761
38831
  this._fireSubAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
38762
38832
  }
38763
38833
  } else {
38764
38834
  if (lastClipTime + deltaTime <= startTime) {
38765
38835
  this._fireBackwardSubAnimationEvents(playData, eventHandlers, lastClipTime, startTime);
38766
- playData.currentEventIndex = eventHandlers.length - 1;
38767
- this._fireBackwardSubAnimationEvents(playData, eventHandlers, endTime, clipTime);
38836
+ if (canWrap) {
38837
+ playData.currentEventIndex = eventHandlers.length - 1;
38838
+ this._fireBackwardSubAnimationEvents(playData, eventHandlers, endTime, clipTime);
38839
+ }
38768
38840
  } else {
38769
38841
  this._fireBackwardSubAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
38770
38842
  }
@@ -38830,7 +38902,7 @@
38830
38902
  };
38831
38903
  _proto._fireAnimationEventsAndCallScripts = function _fireAnimationEventsAndCallScripts(layerIndex, playData, state, lastClipTime, lastPlayState, deltaTime) {
38832
38904
  var eventHandlers = playData.stateData.eventHandlers;
38833
- eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, deltaTime);
38905
+ this.fireEvents && eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, deltaTime);
38834
38906
  if (lastPlayState === AnimatorStatePlayState.UnStarted) {
38835
38907
  state._callOnEnter(this, layerIndex);
38836
38908
  }
@@ -38894,6 +38966,9 @@
38894
38966
  __decorate$1([
38895
38967
  assignmentClone
38896
38968
  ], Animator.prototype, "speed", void 0);
38969
+ __decorate$1([
38970
+ assignmentClone
38971
+ ], Animator.prototype, "fireEvents", void 0);
38897
38972
  __decorate$1([
38898
38973
  assignmentClone
38899
38974
  ], Animator.prototype, "_animatorController", void 0);
@@ -41223,7 +41298,7 @@
41223
41298
  _inherits$2(EmissionModule, ParticleGeneratorModule);
41224
41299
  function EmissionModule() {
41225
41300
  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);
41301
+ _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
41302
  return _this;
41228
41303
  }
41229
41304
  var _proto = EmissionModule.prototype;
@@ -41260,6 +41335,7 @@
41260
41335
  * @internal
41261
41336
  */ _proto._emit = function _emit(lastPlayTime, playTime) {
41262
41337
  this._emitByRateOverTime(playTime);
41338
+ this._emitByRateOverDistance(lastPlayTime, playTime);
41263
41339
  this._emitByBurst(lastPlayTime, playTime);
41264
41340
  };
41265
41341
  /**
@@ -41273,6 +41349,13 @@
41273
41349
  */ _proto._reset = function _reset() {
41274
41350
  this._frameRateTime = 0;
41275
41351
  this._currentBurstIndex = 0;
41352
+ this._invalidateDistanceBaseline();
41353
+ };
41354
+ /**
41355
+ * @internal
41356
+ */ _proto._invalidateDistanceBaseline = function _invalidateDistanceBaseline() {
41357
+ this._hasLastEmitPosition = false;
41358
+ this._distanceAccumulator = 0;
41276
41359
  };
41277
41360
  /**
41278
41361
  * @internal
@@ -41293,6 +41376,55 @@
41293
41376
  }
41294
41377
  }
41295
41378
  };
41379
+ _proto._emitByRateOverDistance = function _emitByRateOverDistance(lastPlayTime, playTime) {
41380
+ var ratePerUnit = this.rateOverDistance.evaluate(undefined, undefined);
41381
+ var generator = this._generator;
41382
+ if (ratePerUnit <= 0) {
41383
+ this._invalidateDistanceBaseline();
41384
+ return;
41385
+ }
41386
+ if (!this._hasLastEmitPosition) {
41387
+ this._lastEmitPosition.copyFrom(generator._renderer.entity.transform.worldPosition);
41388
+ this._hasLastEmitPosition = true;
41389
+ return;
41390
+ }
41391
+ var lastPos = this._lastEmitPosition;
41392
+ var currentPos = generator._renderer.entity.transform.worldPosition;
41393
+ var dx = currentPos.x - lastPos.x;
41394
+ var dy = currentPos.y - lastPos.y;
41395
+ var dz = currentPos.z - lastPos.z;
41396
+ var moveLength = Math.sqrt(dx * dx + dy * dy + dz * dz);
41397
+ this._distanceAccumulator += moveLength;
41398
+ var emitInterval = 1.0 / ratePerUnit;
41399
+ // `+ zeroTolerance` absorbs float divide error so an exact `N*interval` accumulator doesn't drop 1
41400
+ var count = Math.floor(this._distanceAccumulator / emitInterval + MathUtil.zeroTolerance);
41401
+ if (count > 0) {
41402
+ this._distanceAccumulator -= count * emitInterval;
41403
+ // `subFrameAge ∈ [0, 1]`: how far back into the frame a particle was born
41404
+ // (0 = newest at currentPos/playTime, 1 = oldest at lastPos/lastPlayTime).
41405
+ // The initial clamp protects two edges — moveLength ≈ 0 (collapse to frame-end
41406
+ // emit) and a tiny moveLength near the emitInterval edge (would put age > 1).
41407
+ // Local simulation space ignores the position override but still uses emitTime.
41408
+ var isWorld = generator.main.simulationSpace === ParticleSimulationSpace.World;
41409
+ var invMoveLength = moveLength > MathUtil.zeroTolerance ? 1.0 / moveLength : 0;
41410
+ var ageStep = emitInterval * invMoveLength;
41411
+ var dt = playTime - lastPlayTime;
41412
+ var subFrameAge = Math.min(this._distanceAccumulator * invMoveLength, 1.0);
41413
+ var emitPos = EmissionModule._tempEmitPosition;
41414
+ for(var i = 0; i < count; i++){
41415
+ if (isWorld) {
41416
+ emitPos.set(currentPos.x - dx * subFrameAge, currentPos.y - dy * subFrameAge, currentPos.z - dz * subFrameAge);
41417
+ }
41418
+ if (generator._emit(playTime - dt * subFrameAge, 1, isWorld ? emitPos : undefined) === 0) {
41419
+ // Buffer full: settle the frame's distance budget instead of carrying it over
41420
+ this._distanceAccumulator = 0;
41421
+ break;
41422
+ }
41423
+ subFrameAge += ageStep;
41424
+ }
41425
+ }
41426
+ lastPos.copyFrom(currentPos);
41427
+ };
41296
41428
  _proto._emitByBurst = function _emitByBurst(lastPlayTime, playTime) {
41297
41429
  var main = this._generator.main;
41298
41430
  var duration = main.duration;
@@ -41389,6 +41521,7 @@
41389
41521
  return EmissionModule;
41390
41522
  }(ParticleGeneratorModule);
41391
41523
  /** @internal */ EmissionModule._emissionShapeMacro = ShaderMacro.getByName("RENDERER_EMISSION_SHAPE");
41524
+ EmissionModule._tempEmitPosition = new Vector3();
41392
41525
  __decorate$1([
41393
41526
  deepClone
41394
41527
  ], EmissionModule.prototype, "rateOverTime", void 0);
@@ -41401,6 +41534,15 @@
41401
41534
  __decorate$1([
41402
41535
  ignoreClone
41403
41536
  ], EmissionModule.prototype, "_shapeRand", void 0);
41537
+ __decorate$1([
41538
+ ignoreClone
41539
+ ], EmissionModule.prototype, "_distanceAccumulator", void 0);
41540
+ __decorate$1([
41541
+ ignoreClone
41542
+ ], EmissionModule.prototype, "_lastEmitPosition", void 0);
41543
+ __decorate$1([
41544
+ ignoreClone
41545
+ ], EmissionModule.prototype, "_hasLastEmitPosition", void 0);
41404
41546
  __decorate$1([
41405
41547
  deepClone
41406
41548
  ], EmissionModule.prototype, "_bursts", void 0);
@@ -43077,11 +43219,15 @@
43077
43219
  }
43078
43220
  } else {
43079
43221
  this._isPlaying = false;
43222
+ // Invalidate the rateOverDistance baseline so emitter movement during the stop
43223
+ // interval doesn't burst on resume.
43080
43224
  if (stopMode === ParticleStopMode.StopEmittingAndClear) {
43081
43225
  this._clearActiveParticles();
43082
43226
  this._playTime = 0;
43083
43227
  this._firstActiveTransformedBoundingBox = this._firstFreeTransformedBoundingBox;
43084
43228
  this.emission._reset();
43229
+ } else {
43230
+ this.emission._invalidateDistanceBaseline();
43085
43231
  }
43086
43232
  }
43087
43233
  };
@@ -43093,37 +43239,40 @@
43093
43239
  };
43094
43240
  /**
43095
43241
  * @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
- }
43242
+ */ _proto._emit = function _emit(playTime, count, emitWorldPositionOverride) {
43243
+ var _this = this, emission = _this.emission, main = _this.main;
43244
+ if (!emission.enabled) {
43245
+ return 0;
43246
+ }
43247
+ var budget = main.maxParticles - this._getNotRetiredParticleCount();
43248
+ if (count > budget) {
43249
+ count = budget;
43250
+ }
43251
+ if (count <= 0) {
43252
+ return 0;
43253
+ }
43254
+ var position = ParticleGenerator._tempVector30;
43255
+ var direction = ParticleGenerator._tempVector31;
43256
+ var transform = this._renderer.entity.transform;
43257
+ var shape = emission.shape;
43258
+ var positionScale = main._getPositionScale();
43259
+ for(var i = 0; i < count; i++){
43260
+ if (shape == null ? void 0 : shape.enabled) {
43261
+ shape._generatePositionAndDirection(emission._shapeRand, playTime, position, direction);
43262
+ position.multiply(positionScale);
43263
+ direction.normalize().multiply(positionScale);
43264
+ } else {
43265
+ position.set(0, 0, 0);
43266
+ direction.set(0, 0, -1);
43267
+ // Speed is scaled by shape scale in world simulation space
43268
+ // So if no shape and in world simulation space, we shouldn't scale the speed
43269
+ if (main.simulationSpace === ParticleSimulationSpace.Local) {
43270
+ direction.multiply(positionScale);
43123
43271
  }
43124
- this._addNewParticle(position, direction, transform, playTime);
43125
43272
  }
43273
+ this._addNewParticle(position, direction, transform, playTime, emitWorldPositionOverride);
43126
43274
  }
43275
+ return count;
43127
43276
  };
43128
43277
  /**
43129
43278
  * @internal
@@ -43525,7 +43674,7 @@
43525
43674
  this._transformedBoundsArray[previousFreeElement * ParticleBufferUtils.boundsFloatStride + boundsTimeOffset] = this._playTime;
43526
43675
  }
43527
43676
  };
43528
- _proto._addNewParticle = function _addNewParticle(position, direction, transform, playTime) {
43677
+ _proto._addNewParticle = function _addNewParticle(position, direction, transform, playTime, emitWorldPositionOverride) {
43529
43678
  var firstFreeElement = this._firstFreeElement;
43530
43679
  var nextFreeElement = firstFreeElement + 1;
43531
43680
  if (nextFreeElement >= this._currentParticleCount) {
@@ -43548,7 +43697,7 @@
43548
43697
  }
43549
43698
  var pos, rot;
43550
43699
  if (main.simulationSpace === ParticleSimulationSpace.World) {
43551
- pos = transform.worldPosition;
43700
+ pos = emitWorldPositionOverride != null ? emitWorldPositionOverride : transform.worldPosition;
43552
43701
  rot = transform.worldRotationQuaternion;
43553
43702
  }
43554
43703
  var startSpeed = main.startSpeed.evaluate(undefined, main._startSpeedRand.random());
@@ -43668,18 +43817,18 @@
43668
43817
  }
43669
43818
  // Initialize feedback buffer for this particle
43670
43819
  if (this._useTransformFeedback) {
43671
- this._addFeedbackParticle(firstFreeElement, position, direction, startSpeed, transform);
43820
+ this._addFeedbackParticle(firstFreeElement, position, direction, startSpeed, transform, pos);
43672
43821
  }
43673
43822
  this._firstFreeElement = nextFreeElement;
43674
43823
  };
43675
- _proto._addFeedbackParticle = function _addFeedbackParticle(index, shapePosition, direction, startSpeed, transform) {
43824
+ _proto._addFeedbackParticle = function _addFeedbackParticle(index, shapePosition, direction, startSpeed, transform, emitWorldPosition) {
43676
43825
  var position;
43677
43826
  if (this.main.simulationSpace === ParticleSimulationSpace.Local) {
43678
43827
  position = shapePosition;
43679
43828
  } else {
43680
43829
  position = ParticleGenerator._tempVector32;
43681
43830
  Vector3.transformByQuat(shapePosition, transform.worldRotationQuaternion, position);
43682
- position.add(transform.worldPosition);
43831
+ position.add(emitWorldPosition != null ? emitWorldPosition : transform.worldPosition);
43683
43832
  }
43684
43833
  this._feedbackSimulator.writeParticleData(index, position, direction.x * startSpeed, direction.y * startSpeed, direction.z * startSpeed);
43685
43834
  };
@@ -46355,6 +46504,7 @@
46355
46504
  Downsampling: Downsampling,
46356
46505
  DynamicCollider: DynamicCollider,
46357
46506
  DynamicColliderConstraints: DynamicColliderConstraints,
46507
+ DynamicColliderKinematicTransformSyncMode: DynamicColliderKinematicTransformSyncMode,
46358
46508
  EmissionModule: EmissionModule,
46359
46509
  Engine: Engine,
46360
46510
  EngineObject: EngineObject,
@@ -55768,6 +55918,14 @@
55768
55918
  if (fog.fogDensity != undefined) scene.fogDensity = fog.fogDensity;
55769
55919
  if (fog.fogColor != undefined) scene.fogColor.copyFrom(fog.fogColor);
55770
55920
  }
55921
+ // parse physics
55922
+ var physics = data.scene.physics;
55923
+ // PhysicsScene has a native backing only when the engine was created with a physics backend.
55924
+ // Keep scene files loadable for render-only engines by ignoring serialized physics settings there.
55925
+ if (physics && engine._physicsInitialized) {
55926
+ if (physics.gravity != undefined) scene.physics.gravity.copyFrom(physics.gravity);
55927
+ if (physics.fixedTimeStep != undefined) scene.physics.fixedTimeStep = physics.fixedTimeStep;
55928
+ }
55771
55929
  // Post Process
55772
55930
  var postProcessData = data.scene.postProcess;
55773
55931
  if (postProcessData) {
@@ -56294,7 +56452,7 @@
56294
56452
  ], EXT_texture_webp);
56295
56453
 
56296
56454
  //@ts-ignore
56297
- var version = "0.0.0-experimental-2.0-game.13";
56455
+ var version = "0.0.0-experimental-2.0-game.15";
56298
56456
  console.log("Galacean Engine Version: " + version);
56299
56457
  for(var key in CoreObjects){
56300
56458
  Loader.registerClass(key, CoreObjects[key]);
@@ -56398,6 +56556,7 @@
56398
56556
  exports.Downsampling = Downsampling;
56399
56557
  exports.DynamicCollider = DynamicCollider;
56400
56558
  exports.DynamicColliderConstraints = DynamicColliderConstraints;
56559
+ exports.DynamicColliderKinematicTransformSyncMode = DynamicColliderKinematicTransformSyncMode;
56401
56560
  exports.EmissionModule = EmissionModule;
56402
56561
  exports.Engine = Engine;
56403
56562
  exports.EngineObject = EngineObject;