@galacean/engine-core 2.0.0-alpha.17 → 2.0.0-alpha.19
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/main.js +195 -202
- package/dist/main.js.map +1 -1
- package/dist/module.js +195 -202
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/particle/modules/LimitVelocityOverLifetimeModule.d.ts +33 -32
- package/types/physics/PhysicsScene.d.ts +2 -6
package/dist/main.js
CHANGED
|
@@ -4916,7 +4916,7 @@ var texture_sheet_animation_module = "#if defined(RENDERER_TSA_FRAME_CURVE) || d
|
|
|
4916
4916
|
|
|
4917
4917
|
var force_over_lifetime_module = "#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE)\n #define _FOL_MODULE_ENABLED\n#endif\n\n#ifdef _FOL_MODULE_ENABLED\n uniform int renderer_FOLSpace;\n\n #ifdef RENDERER_FOL_CONSTANT_MODE\n uniform vec3 renderer_FOLMaxConst;\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n uniform vec3 renderer_FOLMinConst;\n #endif\n\n #endif\n\n #ifdef RENDERER_FOL_CURVE_MODE\n uniform vec2 renderer_FOLMaxGradientX[4];\n uniform vec2 renderer_FOLMaxGradientY[4];\n uniform vec2 renderer_FOLMaxGradientZ[4];\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n uniform vec2 renderer_FOLMinGradientX[4];\n uniform vec2 renderer_FOLMinGradientY[4];\n uniform vec2 renderer_FOLMinGradientZ[4];\n #endif\n #endif\n\n // (tHat - t1) * (tHat - t1) * (tHat - t1) * (a2 - a1) / ((t2 - t1) * 6.0) + a1 * (tHat - t1) * (tHat - t1) * 0.5 + v1 * (tHat - t1);\n // to = tHat - t1; tr = t2 - t1\n float computeDisplacementIntegral(in float to, in float tr, in float a1, in float a2, in float v1) {\n return to * to * to * (a2 - a1) / (tr * 6.0) + a1 * to * to * 0.5 + v1 * to;\n }\n\n float evaluateForceParticleCurveCumulative(in vec2 keys[4], in float normalizedAge, out float velocityCumulative) {\n float cumulativeValue = 0.0;\n velocityCumulative = 0.0;\n\n for (int i = 1; i < 4; i++){\n vec2 key = keys[i];\n vec2 lastKey = keys[i - 1];\n float timeRange = (key.x - lastKey.x) * a_ShapePositionStartLifeTime.w;\n\n if (key.x >= normalizedAge){\n float timeOffset = (normalizedAge - lastKey.x) * a_ShapePositionStartLifeTime.w;\n cumulativeValue += computeDisplacementIntegral(timeOffset, timeRange, lastKey.y, key.y, velocityCumulative);\n\n float finalAcceleration = mix(lastKey.y, key.y, timeOffset / timeRange);\n velocityCumulative += 0.5 * timeOffset * (finalAcceleration + lastKey.y);\n break;\n } else { \n cumulativeValue += computeDisplacementIntegral(timeRange, timeRange, lastKey.y, key.y, velocityCumulative);\n velocityCumulative += 0.5 * timeRange * (lastKey.y + key.y);\n }\n }\n return cumulativeValue;\n }\n\n vec3 computeForcePositionOffset(in float normalizedAge, in float age, out vec3 velocityOffset) {\n vec3 forcePosition;\n\n #if defined(RENDERER_FOL_CONSTANT_MODE)\n vec3 forceAcceleration = renderer_FOLMaxConst;\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n forceAcceleration = mix(renderer_FOLMinConst, forceAcceleration, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n\n velocityOffset = forceAcceleration * age;\n\n forcePosition = 0.5 * forceAcceleration * age * age;\n #elif defined(RENDERER_FOL_CURVE_MODE)\n forcePosition = vec3(\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientX, normalizedAge, velocityOffset.x),\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientY, normalizedAge, velocityOffset.y),\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientZ, normalizedAge, velocityOffset.z)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minVelocityOffset;\n\n forcePosition = vec3(\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientX, normalizedAge, minVelocityOffset.x), forcePosition.x, a_Random2.x),\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientY, normalizedAge, minVelocityOffset.y), forcePosition.y, a_Random2.y),\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientZ, normalizedAge, minVelocityOffset.z), forcePosition.z, a_Random2.z)\n );\n\n velocityOffset = mix(minVelocityOffset, velocityOffset, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n return forcePosition;\n }\n#endif"; // eslint-disable-line
|
|
4918
4918
|
|
|
4919
|
-
var limit_velocity_over_lifetime_module = "#ifdef RENDERER_LVL_MODULE_ENABLED\n uniform int renderer_LVLSpace;\n uniform float renderer_LVLDampen;\n\n // Scalar limit\n #ifndef RENDERER_LVL_SEPARATE_AXES\n #ifdef
|
|
4919
|
+
var limit_velocity_over_lifetime_module = "#ifdef RENDERER_LVL_MODULE_ENABLED\n uniform int renderer_LVLSpace;\n uniform float renderer_LVLDampen;\n\n // Scalar limit\n #ifndef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform float renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform float renderer_LVLSpeedMinConst;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedMinCurve[4];\n #endif\n #endif\n #endif\n\n // Per-axis limit\n #ifdef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform vec3 renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec3 renderer_LVLSpeedMinConstVector;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedXMaxCurve[4];\n uniform vec2 renderer_LVLSpeedYMaxCurve[4];\n uniform vec2 renderer_LVLSpeedZMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedXMinCurve[4];\n uniform vec2 renderer_LVLSpeedYMinCurve[4];\n uniform vec2 renderer_LVLSpeedZMinCurve[4];\n #endif\n #endif\n #endif\n\n // Drag curve\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n uniform vec2 renderer_LVLDragMaxCurve[4];\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n uniform vec2 renderer_LVLDragMinCurve[4];\n #endif\n #endif\n\n float evaluateLVLDrag(float normalizedAge, float dragRand) {\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n float dragMax = evaluateParticleCurve(renderer_LVLDragMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n float dragMin = evaluateParticleCurve(renderer_LVLDragMinCurve, normalizedAge);\n return mix(dragMin, dragMax, dragRand);\n #else\n return dragMax;\n #endif\n #else\n return mix(renderer_LVLDragConstant.x, renderer_LVLDragConstant.y, dragRand);\n #endif\n }\n\n vec3 applyLVLSpeedLimitTF(vec3 velocity, float normalizedAge, float limitRand, float effectiveDampen) {\n #ifdef RENDERER_LVL_SEPARATE_AXES\n vec3 limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConstVector, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMaxCurve, normalizedAge)\n );\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n vec3 minLimitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMinCurve, normalizedAge)\n );\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n vec3 absVel = abs(velocity);\n vec3 excess = max(absVel - limitSpeed, vec3(0.0));\n velocity = sign(velocity) * (absVel - excess * effectiveDampen);\n #else\n float limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConst, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = evaluateParticleCurve(renderer_LVLSpeedMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n float minLimitSpeed = evaluateParticleCurve(renderer_LVLSpeedMinCurve, normalizedAge);\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n float speed = length(velocity);\n if (speed > limitSpeed && speed > 0.0) {\n float excess = speed - limitSpeed;\n velocity = velocity * ((speed - excess * effectiveDampen) / speed);\n }\n #endif\n return velocity;\n }\n\n#endif\n"; // eslint-disable-line
|
|
4920
4920
|
|
|
4921
4921
|
var particle_feedback_simulation = "// Transform Feedback update shader for particle simulation.\n// Update order: VOL/FOL → Dampen → Drag → Position.\n// Runs once per particle per frame (no rasterization).\n\n// Previous frame TF data\nattribute vec3 a_FeedbackPosition;\nattribute vec3 a_FeedbackVelocity;\n\n// Per-particle instance data\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec3 a_StartSize;\nattribute float a_StartSpeed;\nattribute vec4 a_Random0;\nattribute vec4 a_Random1;\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\nattribute vec4 a_Random2;\n\n// Uniforms\nuniform float renderer_CurrentTime;\nuniform float renderer_DeltaTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 renderer_LVLDragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform int renderer_SimulationSpace;\n\n// TF outputs\nvarying vec3 v_FeedbackPosition;\nvarying vec3 v_FeedbackVelocity;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <limit_velocity_over_lifetime_module>\n\n// Get VOL instantaneous velocity at normalizedAge\nvec3 getVOLVelocity(float normalizedAge) {\n vec3 vel = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n #ifdef RENDERER_VOL_CONSTANT_MODE\n vel = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vel = mix(renderer_VOLMinConst, vel, a_Random1.yzw);\n #endif\n #endif\n #ifdef RENDERER_VOL_CURVE_MODE\n vel = vec3(\n evaluateParticleCurve(renderer_VOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minVel = vec3(\n evaluateParticleCurve(renderer_VOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientZ, normalizedAge)\n );\n vel = mix(minVel, vel, a_Random1.yzw);\n #endif\n #endif\n #endif\n return vel;\n}\n\n// Get FOL instantaneous acceleration at normalizedAge\nvec3 getFOLAcceleration(float normalizedAge) {\n vec3 acc = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n #ifdef RENDERER_FOL_CONSTANT_MODE\n acc = renderer_FOLMaxConst;\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n acc = mix(renderer_FOLMinConst, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #ifdef RENDERER_FOL_CURVE_MODE\n acc = vec3(\n evaluateParticleCurve(renderer_FOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minAcc = vec3(\n evaluateParticleCurve(renderer_FOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientZ, normalizedAge)\n );\n acc = mix(minAcc, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #endif\n return acc;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float lifetime = a_ShapePositionStartLifeTime.w;\n float normalizedAge = age / lifetime;\n // Clamp to age on the first TF pass: particles emitted mid-frame have age < dt,\n // so using the full dt would over-integrate. Subsequent passes are unaffected (age >= dt).\n float dt = min(renderer_DeltaTime, age);\n\n // normalizedAge < 0.0: stale TF slot whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 1.0 || normalizedAge < 0.0) {\n v_FeedbackPosition = a_FeedbackPosition;\n v_FeedbackVelocity = a_FeedbackVelocity;\n gl_Position = vec4(0.0);\n return;\n }\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n vec4 invWorldRotation = quaternionConjugate(worldRotation);\n\n // Read previous frame state (initialized by CPU on particle birth)\n vec3 localVelocity = a_FeedbackVelocity;\n\n // =====================================================\n // Step 1: Apply velocity module deltas (VOL + FOL + Gravity)\n // =====================================================\n\n // Gravity (world space)\n vec3 gravityDelta = renderer_Gravity * a_Random0.x * dt;\n\n // VOL instantaneous velocity (animated velocity, not persisted)\n vec3 volLocal = vec3(0.0);\n vec3 volWorld = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n vec3 vol = getVOLVelocity(normalizedAge);\n if (renderer_VOLSpace == 0) {\n volLocal = vol;\n } else {\n volWorld = vol;\n }\n #endif\n\n // FOL acceleration → velocity delta (always persisted, like gravity)\n vec3 folDeltaLocal = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n vec3 folAcc = getFOLAcceleration(normalizedAge);\n vec3 folVelDelta = folAcc * dt;\n if (renderer_FOLSpace == 0) {\n folDeltaLocal = folVelDelta;\n } else {\n // World FOL: convert to local and persist, same as gravity\n folDeltaLocal = rotationByQuaternions(folVelDelta, invWorldRotation);\n }\n #endif\n\n // Gravity and FOL contribute to base velocity (persisted, subject to dampen/drag).\n vec3 gravityLocal = rotationByQuaternions(gravityDelta, invWorldRotation);\n localVelocity += folDeltaLocal + gravityLocal;\n\n // =====================================================\n // Step 2 & 3: Dampen (Limit Velocity) + Drag\n // VOL must be projected into the LVL target space so that\n // limit/drag see the full velocity regardless of VOL.space vs LVL.space.\n // =====================================================\n #ifdef RENDERER_LVL_MODULE_ENABLED\n // Precompute VOL in both spaces\n vec3 volAsLocal = volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n vec3 volAsWorld = rotationByQuaternions(volLocal, worldRotation) + volWorld;\n\n float limitRand = a_Random2.w;\n float dampen = renderer_LVLDampen;\n // Frame-rate independent dampen (30fps as reference)\n float effectiveDampen = 1.0 - pow(1.0 - dampen, dt * 30.0);\n\n if (renderer_LVLSpace == 0) {\n // Local space: total = base + all VOL projected to local\n vec3 totalLocal = localVelocity + volAsLocal;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalLocal, normalizedAge, limitRand, effectiveDampen);\n localVelocity = dampenedTotal - volAsLocal;\n } else {\n // World space: total = rotated base + all VOL projected to world\n vec3 totalWorld = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalWorld, normalizedAge, limitRand, effectiveDampen);\n localVelocity = rotationByQuaternions(dampenedTotal - volAsWorld, invWorldRotation);\n }\n\n // Drag: same space as dampen\n {\n float dragCoeff = evaluateLVLDrag(normalizedAge, a_Random2.w);\n if (dragCoeff > 0.0) {\n vec3 totalVel;\n if (renderer_LVLSpace == 0) {\n totalVel = localVelocity + volAsLocal;\n } else {\n totalVel = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n }\n float velMagSqr = dot(totalVel, totalVel);\n float velMag = sqrt(velMagSqr);\n\n float drag = dragCoeff;\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_SIZE\n float maxDim = max(a_StartSize.x, max(a_StartSize.y, a_StartSize.z));\n float radius = maxDim * 0.5;\n drag *= 3.14159265 * radius * radius;\n #endif\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_VELOCITY\n drag *= velMagSqr;\n #endif\n\n if (velMag > 0.0) {\n float newVelMag = max(0.0, velMag - drag * dt);\n vec3 draggedTotal = totalVel * (newVelMag / velMag);\n if (renderer_LVLSpace == 0) {\n localVelocity = draggedTotal - volAsLocal;\n } else {\n localVelocity = rotationByQuaternions(draggedTotal - volAsWorld, invWorldRotation);\n }\n }\n }\n }\n #endif\n\n // =====================================================\n // Step 4: Integrate position in simulation space\n // Local mode: position in local space, velocity rotated to local\n // World mode: position in world space, velocity rotated to world\n // =====================================================\n // FOL is now fully in localVelocity (both local and world-space FOL).\n // Only VOL overlay needs to be added here.\n vec3 totalVelocity;\n if (renderer_SimulationSpace == 0) {\n // Local: integrate in local space\n totalVelocity = localVelocity + volLocal\n + rotationByQuaternions(volWorld, invWorldRotation);\n } else {\n // World: integrate in world space\n totalVelocity = rotationByQuaternions(localVelocity + volLocal, worldRotation) + volWorld;\n }\n vec3 position = a_FeedbackPosition + totalVelocity * dt;\n\n v_FeedbackPosition = position;\n v_FeedbackVelocity = localVelocity;\n gl_Position = vec4(0.0);\n}\n"; // eslint-disable-line
|
|
4922
4922
|
|
|
@@ -13061,118 +13061,13 @@ __decorate([
|
|
|
13061
13061
|
this._fixedTimeStep = 1 / 60;
|
|
13062
13062
|
this._colliders = new DisorderedArray();
|
|
13063
13063
|
this._gravity = new engineMath.Vector3(0, -9.81, 0);
|
|
13064
|
-
this._onContactEnter = function(nativeCollision) {
|
|
13065
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13066
|
-
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
13067
|
-
var shape1 = physicalObjectsMap[shape0Id];
|
|
13068
|
-
var shape2 = physicalObjectsMap[shape1Id];
|
|
13069
|
-
var collision = PhysicsScene._collision;
|
|
13070
|
-
collision._nativeCollision = nativeCollision;
|
|
13071
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13072
|
-
collision.shape = shape2;
|
|
13073
|
-
element.onCollisionEnter(collision);
|
|
13074
|
-
}, function(element, index) {
|
|
13075
|
-
element._entityScriptsIndex = index;
|
|
13076
|
-
});
|
|
13077
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13078
|
-
collision.shape = shape1;
|
|
13079
|
-
element.onCollisionEnter(collision);
|
|
13080
|
-
}, function(element, index) {
|
|
13081
|
-
element._entityScriptsIndex = index;
|
|
13082
|
-
});
|
|
13083
|
-
};
|
|
13084
|
-
this._onContactExit = function(nativeCollision) {
|
|
13085
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13086
|
-
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
13087
|
-
var shape1 = physicalObjectsMap[shape0Id];
|
|
13088
|
-
var shape2 = physicalObjectsMap[shape1Id];
|
|
13089
|
-
var collision = PhysicsScene._collision;
|
|
13090
|
-
collision._nativeCollision = nativeCollision;
|
|
13091
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13092
|
-
collision.shape = shape2;
|
|
13093
|
-
element.onCollisionExit(collision);
|
|
13094
|
-
}, function(element, index) {
|
|
13095
|
-
element._entityScriptsIndex = index;
|
|
13096
|
-
});
|
|
13097
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13098
|
-
collision.shape = shape1;
|
|
13099
|
-
element.onCollisionExit(collision);
|
|
13100
|
-
}, function(element, index) {
|
|
13101
|
-
element._entityScriptsIndex = index;
|
|
13102
|
-
});
|
|
13103
|
-
};
|
|
13104
|
-
this._onContactStay = function(nativeCollision) {
|
|
13105
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13106
|
-
var shape0Id = nativeCollision.shape0Id, shape1Id = nativeCollision.shape1Id;
|
|
13107
|
-
var shape1 = physicalObjectsMap[shape0Id];
|
|
13108
|
-
var shape2 = physicalObjectsMap[shape1Id];
|
|
13109
|
-
var collision = PhysicsScene._collision;
|
|
13110
|
-
collision._nativeCollision = nativeCollision;
|
|
13111
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13112
|
-
collision.shape = shape2;
|
|
13113
|
-
element.onCollisionStay(collision);
|
|
13114
|
-
}, function(element, index) {
|
|
13115
|
-
element._entityScriptsIndex = index;
|
|
13116
|
-
});
|
|
13117
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13118
|
-
collision.shape = shape1;
|
|
13119
|
-
element.onCollisionStay(collision);
|
|
13120
|
-
}, function(element, index) {
|
|
13121
|
-
element._entityScriptsIndex = index;
|
|
13122
|
-
});
|
|
13123
|
-
};
|
|
13124
|
-
this._onTriggerEnter = function(obj1, obj2) {
|
|
13125
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13126
|
-
var shape1 = physicalObjectsMap[obj1];
|
|
13127
|
-
var shape2 = physicalObjectsMap[obj2];
|
|
13128
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13129
|
-
element.onTriggerEnter(shape2);
|
|
13130
|
-
}, function(element, index) {
|
|
13131
|
-
element._entityScriptsIndex = index;
|
|
13132
|
-
});
|
|
13133
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13134
|
-
element.onTriggerEnter(shape1);
|
|
13135
|
-
}, function(element, index) {
|
|
13136
|
-
element._entityScriptsIndex = index;
|
|
13137
|
-
});
|
|
13138
|
-
};
|
|
13139
|
-
this._onTriggerExit = function(obj1, obj2) {
|
|
13140
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13141
|
-
var shape1 = physicalObjectsMap[obj1];
|
|
13142
|
-
var shape2 = physicalObjectsMap[obj2];
|
|
13143
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13144
|
-
element.onTriggerExit(shape2);
|
|
13145
|
-
}, function(element, index) {
|
|
13146
|
-
element._entityScriptsIndex = index;
|
|
13147
|
-
});
|
|
13148
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13149
|
-
element.onTriggerExit(shape1);
|
|
13150
|
-
}, function(element, index) {
|
|
13151
|
-
element._entityScriptsIndex = index;
|
|
13152
|
-
});
|
|
13153
|
-
};
|
|
13154
|
-
this._onTriggerStay = function(obj1, obj2) {
|
|
13155
|
-
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13156
|
-
var shape1 = physicalObjectsMap[obj1];
|
|
13157
|
-
var shape2 = physicalObjectsMap[obj2];
|
|
13158
|
-
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13159
|
-
element.onTriggerStay(shape2);
|
|
13160
|
-
}, function(element, index) {
|
|
13161
|
-
element._entityScriptsIndex = index;
|
|
13162
|
-
});
|
|
13163
|
-
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13164
|
-
element.onTriggerStay(shape1);
|
|
13165
|
-
}, function(element, index) {
|
|
13166
|
-
element._entityScriptsIndex = index;
|
|
13167
|
-
});
|
|
13168
|
-
};
|
|
13169
13064
|
this._scene = scene;
|
|
13170
13065
|
this._setGravity = this._setGravity.bind(this);
|
|
13171
13066
|
//@ts-ignore
|
|
13172
13067
|
this._gravity._onValueChanged = this._setGravity;
|
|
13173
13068
|
var engine = scene.engine;
|
|
13174
13069
|
if (engine._physicsInitialized) {
|
|
13175
|
-
this._nativePhysicsScene = Engine._nativePhysics.createPhysicsScene(engine._nativePhysicsManager
|
|
13070
|
+
this._nativePhysicsScene = Engine._nativePhysics.createPhysicsScene(engine._nativePhysicsManager);
|
|
13176
13071
|
}
|
|
13177
13072
|
}
|
|
13178
13073
|
var _proto = PhysicsScene.prototype;
|
|
@@ -13384,6 +13279,7 @@ __decorate([
|
|
|
13384
13279
|
this._callColliderOnUpdate();
|
|
13385
13280
|
nativePhysicsManager.update(fixedTimeStep);
|
|
13386
13281
|
this._callColliderOnLateUpdate();
|
|
13282
|
+
this._dispatchEvents(nativePhysicsManager.updateEvents());
|
|
13387
13283
|
}
|
|
13388
13284
|
};
|
|
13389
13285
|
/**
|
|
@@ -13447,7 +13343,9 @@ __decorate([
|
|
|
13447
13343
|
/**
|
|
13448
13344
|
* @internal
|
|
13449
13345
|
*/ _proto._gc = function _gc() {
|
|
13346
|
+
var _this__nativePhysicsScene;
|
|
13450
13347
|
this._colliders.garbageCollection();
|
|
13348
|
+
(_this__nativePhysicsScene = this._nativePhysicsScene) == null ? void 0 : _this__nativePhysicsScene.gc();
|
|
13451
13349
|
};
|
|
13452
13350
|
/**
|
|
13453
13351
|
* @internal
|
|
@@ -13455,6 +13353,92 @@ __decorate([
|
|
|
13455
13353
|
var _this__nativePhysicsScene;
|
|
13456
13354
|
(_this__nativePhysicsScene = this._nativePhysicsScene) == null ? void 0 : _this__nativePhysicsScene.destroy();
|
|
13457
13355
|
};
|
|
13356
|
+
_proto._dispatchEvents = function _dispatchEvents(events) {
|
|
13357
|
+
var _loop = function(i, n) {
|
|
13358
|
+
var _shape1_collider, _shape2_collider;
|
|
13359
|
+
var event = contactEvents[i];
|
|
13360
|
+
var shape1 = physicalObjectsMap[event.shape0Id];
|
|
13361
|
+
var shape2 = physicalObjectsMap[event.shape1Id];
|
|
13362
|
+
// entity.destroy() is deferred, so shapes/colliders stay valid through the dispatch loop
|
|
13363
|
+
// This guard covers synchronous removeShape()/clearShapes() which sets shape._collider = null
|
|
13364
|
+
if (!(shape1 == null ? void 0 : (_shape1_collider = shape1.collider) == null ? void 0 : _shape1_collider.entity) || !(shape2 == null ? void 0 : (_shape2_collider = shape2.collider) == null ? void 0 : _shape2_collider.entity)) return "continue";
|
|
13365
|
+
collision._nativeCollision = event;
|
|
13366
|
+
switch(event.state){
|
|
13367
|
+
case 0:
|
|
13368
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13369
|
+
collision.shape = shape2;
|
|
13370
|
+
element.onCollisionEnter(collision);
|
|
13371
|
+
}, scriptIndexSetter);
|
|
13372
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13373
|
+
collision.shape = shape1;
|
|
13374
|
+
element.onCollisionEnter(collision);
|
|
13375
|
+
}, scriptIndexSetter);
|
|
13376
|
+
break;
|
|
13377
|
+
case 1:
|
|
13378
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13379
|
+
collision.shape = shape2;
|
|
13380
|
+
element.onCollisionStay(collision);
|
|
13381
|
+
}, scriptIndexSetter);
|
|
13382
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13383
|
+
collision.shape = shape1;
|
|
13384
|
+
element.onCollisionStay(collision);
|
|
13385
|
+
}, scriptIndexSetter);
|
|
13386
|
+
break;
|
|
13387
|
+
case 2:
|
|
13388
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13389
|
+
collision.shape = shape2;
|
|
13390
|
+
element.onCollisionExit(collision);
|
|
13391
|
+
}, scriptIndexSetter);
|
|
13392
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13393
|
+
collision.shape = shape1;
|
|
13394
|
+
element.onCollisionExit(collision);
|
|
13395
|
+
}, scriptIndexSetter);
|
|
13396
|
+
break;
|
|
13397
|
+
}
|
|
13398
|
+
}, _loop1 = function(i1, n1) {
|
|
13399
|
+
var _shape1_collider, _shape2_collider;
|
|
13400
|
+
var event = triggerEvents[i1];
|
|
13401
|
+
var shape1 = physicalObjectsMap[event.index1];
|
|
13402
|
+
var shape2 = physicalObjectsMap[event.index2];
|
|
13403
|
+
// entity.destroy() is deferred, so shapes/colliders stay valid through the dispatch loop
|
|
13404
|
+
// This guard covers synchronous removeShape()/clearShapes() which sets shape._collider = null
|
|
13405
|
+
if (!(shape1 == null ? void 0 : (_shape1_collider = shape1.collider) == null ? void 0 : _shape1_collider.entity) || !(shape2 == null ? void 0 : (_shape2_collider = shape2.collider) == null ? void 0 : _shape2_collider.entity)) return "continue";
|
|
13406
|
+
switch(event.dispatchState){
|
|
13407
|
+
case 0:
|
|
13408
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13409
|
+
element.onTriggerEnter(shape2);
|
|
13410
|
+
}, scriptIndexSetter);
|
|
13411
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13412
|
+
element.onTriggerEnter(shape1);
|
|
13413
|
+
}, scriptIndexSetter);
|
|
13414
|
+
break;
|
|
13415
|
+
case 1:
|
|
13416
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13417
|
+
element.onTriggerStay(shape2);
|
|
13418
|
+
}, scriptIndexSetter);
|
|
13419
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13420
|
+
element.onTriggerStay(shape1);
|
|
13421
|
+
}, scriptIndexSetter);
|
|
13422
|
+
break;
|
|
13423
|
+
case 2:
|
|
13424
|
+
shape1.collider.entity._scripts.forEach(function(element) {
|
|
13425
|
+
element.onTriggerExit(shape2);
|
|
13426
|
+
}, scriptIndexSetter);
|
|
13427
|
+
shape2.collider.entity._scripts.forEach(function(element) {
|
|
13428
|
+
element.onTriggerExit(shape1);
|
|
13429
|
+
}, scriptIndexSetter);
|
|
13430
|
+
break;
|
|
13431
|
+
}
|
|
13432
|
+
};
|
|
13433
|
+
var physicalObjectsMap = Engine._physicalObjectsMap;
|
|
13434
|
+
var collision = PhysicsScene._collision;
|
|
13435
|
+
var scriptIndexSetter = PhysicsScene._scriptIndexSetter;
|
|
13436
|
+
var contactEvents = events.contactEvents, contactEventCount = events.contactEventCount, triggerEvents = events.triggerEvents;
|
|
13437
|
+
// Dispatch contact events
|
|
13438
|
+
for(var i = 0, n = contactEventCount; i < n; i++)_loop(i);
|
|
13439
|
+
// Dispatch trigger events
|
|
13440
|
+
for(var i1 = 0, n1 = triggerEvents.length; i1 < n1; i1++)_loop1(i1);
|
|
13441
|
+
};
|
|
13458
13442
|
_proto._setGravity = function _setGravity() {
|
|
13459
13443
|
this._nativePhysicsScene.setGravity(this._gravity);
|
|
13460
13444
|
};
|
|
@@ -13514,6 +13498,9 @@ __decorate([
|
|
|
13514
13498
|
}();
|
|
13515
13499
|
PhysicsScene._collision = new Collision();
|
|
13516
13500
|
PhysicsScene._identityQuaternion = new engineMath.Quaternion(0, 0, 0, 1);
|
|
13501
|
+
PhysicsScene._scriptIndexSetter = function(element, index) {
|
|
13502
|
+
element._entityScriptsIndex = index;
|
|
13503
|
+
};
|
|
13517
13504
|
|
|
13518
13505
|
/**
|
|
13519
13506
|
* A static collider component that will not move.
|
|
@@ -27106,6 +27093,11 @@ ShaderPool.init();
|
|
|
27106
27093
|
this._textSubRenderElementPool.garbageCollection();
|
|
27107
27094
|
this._renderElementPool.garbageCollection();
|
|
27108
27095
|
this._renderContext.garbageCollection();
|
|
27096
|
+
var scenes = this._sceneManager._scenes.getLoopArray();
|
|
27097
|
+
for(var i = 0, n = scenes.length; i < n; i++){
|
|
27098
|
+
var _scenes_i_physics, _scenes_i;
|
|
27099
|
+
(_scenes_i = scenes[i]) == null ? void 0 : (_scenes_i_physics = _scenes_i.physics) == null ? void 0 : _scenes_i_physics._gc();
|
|
27100
|
+
}
|
|
27109
27101
|
};
|
|
27110
27102
|
_create_class(Engine, [
|
|
27111
27103
|
{
|
|
@@ -34970,10 +34962,10 @@ __decorate([
|
|
|
34970
34962
|
_inherits(LimitVelocityOverLifetimeModule, ParticleGeneratorModule);
|
|
34971
34963
|
function LimitVelocityOverLifetimeModule(generator) {
|
|
34972
34964
|
var _this;
|
|
34973
|
-
_this = ParticleGeneratorModule.call(this, generator) || this, /** @internal */ _this.
|
|
34974
|
-
_this.
|
|
34975
|
-
_this.
|
|
34976
|
-
_this.
|
|
34965
|
+
_this = ParticleGeneratorModule.call(this, generator) || this, /** @internal */ _this._speedRand = new engineMath.Rand(0, ParticleRandomSubSeeds.LimitVelocityOverLifetime), _this._speedMinConstantVec = new engineMath.Vector3(), _this._speedMaxConstantVec = new engineMath.Vector3(), _this._dragConstantVec = new engineMath.Vector2(), _this._separateAxes = false, _this._dampen = 0, _this._multiplyDragByParticleSize = false, _this._multiplyDragByParticleVelocity = false, _this._space = ParticleSimulationSpace.Local;
|
|
34966
|
+
_this.speedX = new ParticleCompositeCurve(1);
|
|
34967
|
+
_this.speedY = new ParticleCompositeCurve(1);
|
|
34968
|
+
_this.speedZ = new ParticleCompositeCurve(1);
|
|
34977
34969
|
_this.drag = new ParticleCompositeCurve(0);
|
|
34978
34970
|
return _this;
|
|
34979
34971
|
}
|
|
@@ -34985,19 +34977,19 @@ __decorate([
|
|
|
34985
34977
|
};
|
|
34986
34978
|
/**
|
|
34987
34979
|
* @internal
|
|
34988
|
-
*/ _proto.
|
|
34980
|
+
*/ _proto._isSpeedRandomMode = function _isSpeedRandomMode() {
|
|
34989
34981
|
if (this._separateAxes) {
|
|
34990
|
-
return (this.
|
|
34982
|
+
return (this._speedX.mode === ParticleCurveMode.TwoConstants || this._speedX.mode === ParticleCurveMode.TwoCurves) && (this._speedY.mode === ParticleCurveMode.TwoConstants || this._speedY.mode === ParticleCurveMode.TwoCurves) && (this._speedZ.mode === ParticleCurveMode.TwoConstants || this._speedZ.mode === ParticleCurveMode.TwoCurves);
|
|
34991
34983
|
}
|
|
34992
|
-
return this.
|
|
34984
|
+
return this._speedX.mode === ParticleCurveMode.TwoConstants || this._speedX.mode === ParticleCurveMode.TwoCurves;
|
|
34993
34985
|
};
|
|
34994
34986
|
/**
|
|
34995
34987
|
* @internal
|
|
34996
34988
|
*/ _proto._updateShaderData = function _updateShaderData(shaderData) {
|
|
34997
34989
|
var enabledModuleMacro = null;
|
|
34998
34990
|
var separateAxesMacro = null;
|
|
34999
|
-
var
|
|
35000
|
-
var
|
|
34991
|
+
var speedModeMacro = null;
|
|
34992
|
+
var speedRandomMacro = null;
|
|
35001
34993
|
var dragCurveMacro = null;
|
|
35002
34994
|
var dragRandomMacro = null;
|
|
35003
34995
|
var dragSizeMacro = null;
|
|
@@ -35008,16 +35000,16 @@ __decorate([
|
|
|
35008
35000
|
shaderData.setFloat(LimitVelocityOverLifetimeModule._dampenProperty, this._dampen);
|
|
35009
35001
|
// Space
|
|
35010
35002
|
shaderData.setInt(LimitVelocityOverLifetimeModule._spaceProperty, this._space);
|
|
35011
|
-
// Limit
|
|
35003
|
+
// Limit speed
|
|
35012
35004
|
if (this._separateAxes) {
|
|
35013
35005
|
separateAxesMacro = LimitVelocityOverLifetimeModule._separateAxesMacro;
|
|
35014
|
-
var result = this.
|
|
35015
|
-
|
|
35016
|
-
|
|
35006
|
+
var result = this._uploadSeparateAxisSpeeds(shaderData);
|
|
35007
|
+
speedModeMacro = result.modeMacro;
|
|
35008
|
+
speedRandomMacro = result.randomMacro;
|
|
35017
35009
|
} else {
|
|
35018
|
-
var result1 = this.
|
|
35019
|
-
|
|
35020
|
-
|
|
35010
|
+
var result1 = this._uploadScalarSpeed(shaderData);
|
|
35011
|
+
speedModeMacro = result1.modeMacro;
|
|
35012
|
+
speedRandomMacro = result1.randomMacro;
|
|
35021
35013
|
}
|
|
35022
35014
|
// Drag
|
|
35023
35015
|
var dragResult = this._uploadDrag(shaderData);
|
|
@@ -35033,8 +35025,8 @@ __decorate([
|
|
|
35033
35025
|
}
|
|
35034
35026
|
this._enabledModuleMacro = this._enableMacro(shaderData, this._enabledModuleMacro, enabledModuleMacro);
|
|
35035
35027
|
this._separateAxesCachedMacro = this._enableMacro(shaderData, this._separateAxesCachedMacro, separateAxesMacro);
|
|
35036
|
-
this.
|
|
35037
|
-
this.
|
|
35028
|
+
this._speedModeMacro = this._enableMacro(shaderData, this._speedModeMacro, speedModeMacro);
|
|
35029
|
+
this._speedRandomMacro = this._enableMacro(shaderData, this._speedRandomMacro, speedRandomMacro);
|
|
35038
35030
|
this._dragCurveCachedMacro = this._enableMacro(shaderData, this._dragCurveCachedMacro, dragCurveMacro);
|
|
35039
35031
|
this._dragRandomCachedMacro = this._enableMacro(shaderData, this._dragRandomCachedMacro, dragRandomMacro);
|
|
35040
35032
|
this._dragSizeMacro = this._enableMacro(shaderData, this._dragSizeMacro, dragSizeMacro);
|
|
@@ -35043,26 +35035,26 @@ __decorate([
|
|
|
35043
35035
|
/**
|
|
35044
35036
|
* @internal
|
|
35045
35037
|
*/ _proto._resetRandomSeed = function _resetRandomSeed(seed) {
|
|
35046
|
-
this.
|
|
35038
|
+
this._speedRand.reset(seed, ParticleRandomSubSeeds.LimitVelocityOverLifetime);
|
|
35047
35039
|
};
|
|
35048
|
-
_proto.
|
|
35049
|
-
var
|
|
35040
|
+
_proto._uploadScalarSpeed = function _uploadScalarSpeed(shaderData) {
|
|
35041
|
+
var speedX = this._speedX;
|
|
35050
35042
|
var modeMacro = null;
|
|
35051
35043
|
var randomMacro = null;
|
|
35052
|
-
var isRandomCurveMode =
|
|
35053
|
-
if (isRandomCurveMode ||
|
|
35054
|
-
shaderData.setFloatArray(LimitVelocityOverLifetimeModule.
|
|
35055
|
-
modeMacro = LimitVelocityOverLifetimeModule.
|
|
35044
|
+
var isRandomCurveMode = speedX.mode === ParticleCurveMode.TwoCurves;
|
|
35045
|
+
if (isRandomCurveMode || speedX.mode === ParticleCurveMode.Curve) {
|
|
35046
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedMaxCurveProperty, speedX.curveMax._getTypeArray());
|
|
35047
|
+
modeMacro = LimitVelocityOverLifetimeModule._speedCurveModeMacro;
|
|
35056
35048
|
if (isRandomCurveMode) {
|
|
35057
|
-
shaderData.setFloatArray(LimitVelocityOverLifetimeModule.
|
|
35058
|
-
randomMacro = LimitVelocityOverLifetimeModule.
|
|
35049
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedMinCurveProperty, speedX.curveMin._getTypeArray());
|
|
35050
|
+
randomMacro = LimitVelocityOverLifetimeModule._speedIsRandomMacro;
|
|
35059
35051
|
}
|
|
35060
35052
|
} else {
|
|
35061
|
-
shaderData.setFloat(LimitVelocityOverLifetimeModule.
|
|
35062
|
-
modeMacro = LimitVelocityOverLifetimeModule.
|
|
35063
|
-
if (
|
|
35064
|
-
shaderData.setFloat(LimitVelocityOverLifetimeModule.
|
|
35065
|
-
randomMacro = LimitVelocityOverLifetimeModule.
|
|
35053
|
+
shaderData.setFloat(LimitVelocityOverLifetimeModule._speedMaxConstProperty, speedX.constantMax);
|
|
35054
|
+
modeMacro = LimitVelocityOverLifetimeModule._speedConstantModeMacro;
|
|
35055
|
+
if (speedX.mode === ParticleCurveMode.TwoConstants) {
|
|
35056
|
+
shaderData.setFloat(LimitVelocityOverLifetimeModule._speedMinConstProperty, speedX.constantMin);
|
|
35057
|
+
randomMacro = LimitVelocityOverLifetimeModule._speedIsRandomMacro;
|
|
35066
35058
|
}
|
|
35067
35059
|
}
|
|
35068
35060
|
return {
|
|
@@ -35070,34 +35062,34 @@ __decorate([
|
|
|
35070
35062
|
randomMacro: randomMacro
|
|
35071
35063
|
};
|
|
35072
35064
|
};
|
|
35073
|
-
_proto.
|
|
35074
|
-
var
|
|
35075
|
-
var
|
|
35076
|
-
var
|
|
35065
|
+
_proto._uploadSeparateAxisSpeeds = function _uploadSeparateAxisSpeeds(shaderData) {
|
|
35066
|
+
var speedX = this._speedX;
|
|
35067
|
+
var speedY = this._speedY;
|
|
35068
|
+
var speedZ = this._speedZ;
|
|
35077
35069
|
var modeMacro = null;
|
|
35078
35070
|
var randomMacro = null;
|
|
35079
|
-
var isRandomCurveMode =
|
|
35080
|
-
if (isRandomCurveMode ||
|
|
35081
|
-
shaderData.setFloatArray(LimitVelocityOverLifetimeModule.
|
|
35082
|
-
shaderData.setFloatArray(LimitVelocityOverLifetimeModule.
|
|
35083
|
-
shaderData.setFloatArray(LimitVelocityOverLifetimeModule.
|
|
35084
|
-
modeMacro = LimitVelocityOverLifetimeModule.
|
|
35071
|
+
var isRandomCurveMode = speedX.mode === ParticleCurveMode.TwoCurves && speedY.mode === ParticleCurveMode.TwoCurves && speedZ.mode === ParticleCurveMode.TwoCurves;
|
|
35072
|
+
if (isRandomCurveMode || speedX.mode === ParticleCurveMode.Curve && speedY.mode === ParticleCurveMode.Curve && speedZ.mode === ParticleCurveMode.Curve) {
|
|
35073
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedXMaxCurveProperty, speedX.curveMax._getTypeArray());
|
|
35074
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedYMaxCurveProperty, speedY.curveMax._getTypeArray());
|
|
35075
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedZMaxCurveProperty, speedZ.curveMax._getTypeArray());
|
|
35076
|
+
modeMacro = LimitVelocityOverLifetimeModule._speedCurveModeMacro;
|
|
35085
35077
|
if (isRandomCurveMode) {
|
|
35086
|
-
shaderData.setFloatArray(LimitVelocityOverLifetimeModule.
|
|
35087
|
-
shaderData.setFloatArray(LimitVelocityOverLifetimeModule.
|
|
35088
|
-
shaderData.setFloatArray(LimitVelocityOverLifetimeModule.
|
|
35089
|
-
randomMacro = LimitVelocityOverLifetimeModule.
|
|
35078
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedXMinCurveProperty, speedX.curveMin._getTypeArray());
|
|
35079
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedYMinCurveProperty, speedY.curveMin._getTypeArray());
|
|
35080
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedZMinCurveProperty, speedZ.curveMin._getTypeArray());
|
|
35081
|
+
randomMacro = LimitVelocityOverLifetimeModule._speedIsRandomMacro;
|
|
35090
35082
|
}
|
|
35091
35083
|
} else {
|
|
35092
|
-
var constantMax = this.
|
|
35093
|
-
constantMax.set(
|
|
35094
|
-
shaderData.setVector3(LimitVelocityOverLifetimeModule.
|
|
35095
|
-
modeMacro = LimitVelocityOverLifetimeModule.
|
|
35096
|
-
if (
|
|
35097
|
-
var constantMin = this.
|
|
35098
|
-
constantMin.set(
|
|
35099
|
-
shaderData.setVector3(LimitVelocityOverLifetimeModule.
|
|
35100
|
-
randomMacro = LimitVelocityOverLifetimeModule.
|
|
35084
|
+
var constantMax = this._speedMaxConstantVec;
|
|
35085
|
+
constantMax.set(speedX.constantMax, speedY.constantMax, speedZ.constantMax);
|
|
35086
|
+
shaderData.setVector3(LimitVelocityOverLifetimeModule._speedMaxConstVecProperty, constantMax);
|
|
35087
|
+
modeMacro = LimitVelocityOverLifetimeModule._speedConstantModeMacro;
|
|
35088
|
+
if (speedX.mode === ParticleCurveMode.TwoConstants && speedY.mode === ParticleCurveMode.TwoConstants && speedZ.mode === ParticleCurveMode.TwoConstants) {
|
|
35089
|
+
var constantMin = this._speedMinConstantVec;
|
|
35090
|
+
constantMin.set(speedX.constantMin, speedY.constantMin, speedZ.constantMin);
|
|
35091
|
+
shaderData.setVector3(LimitVelocityOverLifetimeModule._speedMinConstVecProperty, constantMin);
|
|
35092
|
+
randomMacro = LimitVelocityOverLifetimeModule._speedIsRandomMacro;
|
|
35101
35093
|
}
|
|
35102
35094
|
}
|
|
35103
35095
|
return {
|
|
@@ -35147,57 +35139,57 @@ __decorate([
|
|
|
35147
35139
|
}
|
|
35148
35140
|
},
|
|
35149
35141
|
{
|
|
35150
|
-
key: "
|
|
35142
|
+
key: "speed",
|
|
35151
35143
|
get: /**
|
|
35152
35144
|
* Speed limit when separateAxes is false.
|
|
35153
35145
|
*/ function get() {
|
|
35154
|
-
return this.
|
|
35146
|
+
return this._speedX;
|
|
35155
35147
|
},
|
|
35156
35148
|
set: function set(value) {
|
|
35157
|
-
this.
|
|
35149
|
+
this.speedX = value;
|
|
35158
35150
|
}
|
|
35159
35151
|
},
|
|
35160
35152
|
{
|
|
35161
|
-
key: "
|
|
35153
|
+
key: "speedX",
|
|
35162
35154
|
get: /**
|
|
35163
35155
|
* Speed limit for the x-axis (or overall limit when separateAxes is false).
|
|
35164
35156
|
*/ function get() {
|
|
35165
|
-
return this.
|
|
35157
|
+
return this._speedX;
|
|
35166
35158
|
},
|
|
35167
35159
|
set: function set(value) {
|
|
35168
|
-
var lastValue = this.
|
|
35160
|
+
var lastValue = this._speedX;
|
|
35169
35161
|
if (value !== lastValue) {
|
|
35170
|
-
this.
|
|
35162
|
+
this._speedX = value;
|
|
35171
35163
|
this._onCompositeCurveChange(lastValue, value);
|
|
35172
35164
|
}
|
|
35173
35165
|
}
|
|
35174
35166
|
},
|
|
35175
35167
|
{
|
|
35176
|
-
key: "
|
|
35168
|
+
key: "speedY",
|
|
35177
35169
|
get: /**
|
|
35178
35170
|
* Speed limit for the y-axis.
|
|
35179
35171
|
*/ function get() {
|
|
35180
|
-
return this.
|
|
35172
|
+
return this._speedY;
|
|
35181
35173
|
},
|
|
35182
35174
|
set: function set(value) {
|
|
35183
|
-
var lastValue = this.
|
|
35175
|
+
var lastValue = this._speedY;
|
|
35184
35176
|
if (value !== lastValue) {
|
|
35185
|
-
this.
|
|
35177
|
+
this._speedY = value;
|
|
35186
35178
|
this._onCompositeCurveChange(lastValue, value);
|
|
35187
35179
|
}
|
|
35188
35180
|
}
|
|
35189
35181
|
},
|
|
35190
35182
|
{
|
|
35191
|
-
key: "
|
|
35183
|
+
key: "speedZ",
|
|
35192
35184
|
get: /**
|
|
35193
35185
|
* Speed limit for the z-axis.
|
|
35194
35186
|
*/ function get() {
|
|
35195
|
-
return this.
|
|
35187
|
+
return this._speedZ;
|
|
35196
35188
|
},
|
|
35197
35189
|
set: function set(value) {
|
|
35198
|
-
var lastValue = this.
|
|
35190
|
+
var lastValue = this._speedZ;
|
|
35199
35191
|
if (value !== lastValue) {
|
|
35200
|
-
this.
|
|
35192
|
+
this._speedZ = value;
|
|
35201
35193
|
this._onCompositeCurveChange(lastValue, value);
|
|
35202
35194
|
}
|
|
35203
35195
|
}
|
|
@@ -35265,6 +35257,7 @@ __decorate([
|
|
|
35265
35257
|
key: "space",
|
|
35266
35258
|
get: /**
|
|
35267
35259
|
* Specifies if the velocity limits are in local space or world space.
|
|
35260
|
+
* @remarks Only takes effect when 'separateAxes' is enabled.
|
|
35268
35261
|
*/ function get() {
|
|
35269
35262
|
return this._space;
|
|
35270
35263
|
},
|
|
@@ -35299,25 +35292,25 @@ __decorate([
|
|
|
35299
35292
|
}(ParticleGeneratorModule);
|
|
35300
35293
|
LimitVelocityOverLifetimeModule._enabledMacro = ShaderMacro.getByName("RENDERER_LVL_MODULE_ENABLED");
|
|
35301
35294
|
LimitVelocityOverLifetimeModule._separateAxesMacro = ShaderMacro.getByName("RENDERER_LVL_SEPARATE_AXES");
|
|
35302
|
-
LimitVelocityOverLifetimeModule.
|
|
35303
|
-
LimitVelocityOverLifetimeModule.
|
|
35304
|
-
LimitVelocityOverLifetimeModule.
|
|
35295
|
+
LimitVelocityOverLifetimeModule._speedConstantModeMacro = ShaderMacro.getByName("RENDERER_LVL_SPEED_CONSTANT_MODE");
|
|
35296
|
+
LimitVelocityOverLifetimeModule._speedCurveModeMacro = ShaderMacro.getByName("RENDERER_LVL_SPEED_CURVE_MODE");
|
|
35297
|
+
LimitVelocityOverLifetimeModule._speedIsRandomMacro = ShaderMacro.getByName("RENDERER_LVL_SPEED_IS_RANDOM_TWO");
|
|
35305
35298
|
LimitVelocityOverLifetimeModule._dragCurveModeMacro = ShaderMacro.getByName("RENDERER_LVL_DRAG_CURVE_MODE");
|
|
35306
35299
|
LimitVelocityOverLifetimeModule._dragIsRandomMacro = ShaderMacro.getByName("RENDERER_LVL_DRAG_IS_RANDOM_TWO");
|
|
35307
35300
|
LimitVelocityOverLifetimeModule._multiplyDragBySizeMacro = ShaderMacro.getByName("RENDERER_LVL_DRAG_MULTIPLY_SIZE");
|
|
35308
35301
|
LimitVelocityOverLifetimeModule._multiplyDragByVelocityMacro = ShaderMacro.getByName("RENDERER_LVL_DRAG_MULTIPLY_VELOCITY");
|
|
35309
|
-
LimitVelocityOverLifetimeModule.
|
|
35310
|
-
LimitVelocityOverLifetimeModule.
|
|
35311
|
-
LimitVelocityOverLifetimeModule.
|
|
35312
|
-
LimitVelocityOverLifetimeModule.
|
|
35313
|
-
LimitVelocityOverLifetimeModule.
|
|
35314
|
-
LimitVelocityOverLifetimeModule.
|
|
35315
|
-
LimitVelocityOverLifetimeModule.
|
|
35316
|
-
LimitVelocityOverLifetimeModule.
|
|
35317
|
-
LimitVelocityOverLifetimeModule.
|
|
35318
|
-
LimitVelocityOverLifetimeModule.
|
|
35319
|
-
LimitVelocityOverLifetimeModule.
|
|
35320
|
-
LimitVelocityOverLifetimeModule.
|
|
35302
|
+
LimitVelocityOverLifetimeModule._speedMaxConstProperty = ShaderProperty.getByName("renderer_LVLSpeedMaxConst");
|
|
35303
|
+
LimitVelocityOverLifetimeModule._speedMinConstProperty = ShaderProperty.getByName("renderer_LVLSpeedMinConst");
|
|
35304
|
+
LimitVelocityOverLifetimeModule._speedMaxCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedMaxCurve");
|
|
35305
|
+
LimitVelocityOverLifetimeModule._speedMinCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedMinCurve");
|
|
35306
|
+
LimitVelocityOverLifetimeModule._speedMaxConstVecProperty = ShaderProperty.getByName("renderer_LVLSpeedMaxConstVector");
|
|
35307
|
+
LimitVelocityOverLifetimeModule._speedMinConstVecProperty = ShaderProperty.getByName("renderer_LVLSpeedMinConstVector");
|
|
35308
|
+
LimitVelocityOverLifetimeModule._speedXMaxCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedXMaxCurve");
|
|
35309
|
+
LimitVelocityOverLifetimeModule._speedXMinCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedXMinCurve");
|
|
35310
|
+
LimitVelocityOverLifetimeModule._speedYMaxCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedYMaxCurve");
|
|
35311
|
+
LimitVelocityOverLifetimeModule._speedYMinCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedYMinCurve");
|
|
35312
|
+
LimitVelocityOverLifetimeModule._speedZMaxCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedZMaxCurve");
|
|
35313
|
+
LimitVelocityOverLifetimeModule._speedZMinCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedZMinCurve");
|
|
35321
35314
|
LimitVelocityOverLifetimeModule._dampenProperty = ShaderProperty.getByName("renderer_LVLDampen");
|
|
35322
35315
|
LimitVelocityOverLifetimeModule._dragConstantProperty = ShaderProperty.getByName("renderer_LVLDragConstant");
|
|
35323
35316
|
LimitVelocityOverLifetimeModule._dragMaxCurveProperty = ShaderProperty.getByName("renderer_LVLDragMaxCurve");
|
|
@@ -35325,13 +35318,13 @@ LimitVelocityOverLifetimeModule._dragMinCurveProperty = ShaderProperty.getByName
|
|
|
35325
35318
|
LimitVelocityOverLifetimeModule._spaceProperty = ShaderProperty.getByName("renderer_LVLSpace");
|
|
35326
35319
|
__decorate([
|
|
35327
35320
|
ignoreClone
|
|
35328
|
-
], LimitVelocityOverLifetimeModule.prototype, "
|
|
35321
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedRand", void 0);
|
|
35329
35322
|
__decorate([
|
|
35330
35323
|
ignoreClone
|
|
35331
|
-
], LimitVelocityOverLifetimeModule.prototype, "
|
|
35324
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedMinConstantVec", void 0);
|
|
35332
35325
|
__decorate([
|
|
35333
35326
|
ignoreClone
|
|
35334
|
-
], LimitVelocityOverLifetimeModule.prototype, "
|
|
35327
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedMaxConstantVec", void 0);
|
|
35335
35328
|
__decorate([
|
|
35336
35329
|
ignoreClone
|
|
35337
35330
|
], LimitVelocityOverLifetimeModule.prototype, "_dragConstantVec", void 0);
|
|
@@ -35343,10 +35336,10 @@ __decorate([
|
|
|
35343
35336
|
], LimitVelocityOverLifetimeModule.prototype, "_separateAxesCachedMacro", void 0);
|
|
35344
35337
|
__decorate([
|
|
35345
35338
|
ignoreClone
|
|
35346
|
-
], LimitVelocityOverLifetimeModule.prototype, "
|
|
35339
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedModeMacro", void 0);
|
|
35347
35340
|
__decorate([
|
|
35348
35341
|
ignoreClone
|
|
35349
|
-
], LimitVelocityOverLifetimeModule.prototype, "
|
|
35342
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedRandomMacro", void 0);
|
|
35350
35343
|
__decorate([
|
|
35351
35344
|
ignoreClone
|
|
35352
35345
|
], LimitVelocityOverLifetimeModule.prototype, "_dragCurveCachedMacro", void 0);
|
|
@@ -35361,13 +35354,13 @@ __decorate([
|
|
|
35361
35354
|
], LimitVelocityOverLifetimeModule.prototype, "_dragVelocityMacro", void 0);
|
|
35362
35355
|
__decorate([
|
|
35363
35356
|
deepClone
|
|
35364
|
-
], LimitVelocityOverLifetimeModule.prototype, "
|
|
35357
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedX", void 0);
|
|
35365
35358
|
__decorate([
|
|
35366
35359
|
deepClone
|
|
35367
|
-
], LimitVelocityOverLifetimeModule.prototype, "
|
|
35360
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedY", void 0);
|
|
35368
35361
|
__decorate([
|
|
35369
35362
|
deepClone
|
|
35370
|
-
], LimitVelocityOverLifetimeModule.prototype, "
|
|
35363
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedZ", void 0);
|
|
35371
35364
|
__decorate([
|
|
35372
35365
|
deepClone
|
|
35373
35366
|
], LimitVelocityOverLifetimeModule.prototype, "_drag", void 0);
|
|
@@ -37064,8 +37057,8 @@ __decorate([
|
|
|
37064
37057
|
instanceVertices[offset + 40] = rand1.random();
|
|
37065
37058
|
}
|
|
37066
37059
|
var limitVelocityOverLifetime = this.limitVelocityOverLifetime;
|
|
37067
|
-
if (limitVelocityOverLifetime.enabled && (limitVelocityOverLifetime.
|
|
37068
|
-
instanceVertices[offset + 41] = limitVelocityOverLifetime.
|
|
37060
|
+
if (limitVelocityOverLifetime.enabled && (limitVelocityOverLifetime._isSpeedRandomMode() || limitVelocityOverLifetime._isDragRandomMode())) {
|
|
37061
|
+
instanceVertices[offset + 41] = limitVelocityOverLifetime._speedRand.random();
|
|
37069
37062
|
}
|
|
37070
37063
|
// Initialize feedback buffer for this particle
|
|
37071
37064
|
if (this._useTransformFeedback) {
|