@aura3d/physics 2.0.0 → 2.0.2

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.
Files changed (73) hide show
  1. package/package.json +2 -2
  2. package/dist/CharacterController.d.ts +0 -135
  3. package/dist/CharacterController.d.ts.map +0 -1
  4. package/dist/CharacterController.js +0 -609
  5. package/dist/CharacterController.js.map +0 -1
  6. package/dist/ClothFixtures.d.ts +0 -87
  7. package/dist/ClothFixtures.d.ts.map +0 -1
  8. package/dist/ClothFixtures.js +0 -264
  9. package/dist/ClothFixtures.js.map +0 -1
  10. package/dist/Crowd.d.ts +0 -64
  11. package/dist/Crowd.d.ts.map +0 -1
  12. package/dist/Crowd.js +0 -209
  13. package/dist/Crowd.js.map +0 -1
  14. package/dist/FireSmokeFixtures.d.ts +0 -103
  15. package/dist/FireSmokeFixtures.d.ts.map +0 -1
  16. package/dist/FireSmokeFixtures.js +0 -271
  17. package/dist/FireSmokeFixtures.js.map +0 -1
  18. package/dist/FluidFixtures.d.ts +0 -75
  19. package/dist/FluidFixtures.d.ts.map +0 -1
  20. package/dist/FluidFixtures.js +0 -219
  21. package/dist/FluidFixtures.js.map +0 -1
  22. package/dist/FractureFixtures.d.ts +0 -68
  23. package/dist/FractureFixtures.d.ts.map +0 -1
  24. package/dist/FractureFixtures.js +0 -199
  25. package/dist/FractureFixtures.js.map +0 -1
  26. package/dist/NarrowPhase.d.ts +0 -11
  27. package/dist/NarrowPhase.d.ts.map +0 -1
  28. package/dist/NarrowPhase.js +0 -565
  29. package/dist/NarrowPhase.js.map +0 -1
  30. package/dist/Navigation.d.ts +0 -67
  31. package/dist/Navigation.d.ts.map +0 -1
  32. package/dist/Navigation.js +0 -261
  33. package/dist/Navigation.js.map +0 -1
  34. package/dist/PathFollowDriver.d.ts +0 -162
  35. package/dist/PathFollowDriver.d.ts.map +0 -1
  36. package/dist/PathFollowDriver.js +0 -163
  37. package/dist/PathFollowDriver.js.map +0 -1
  38. package/dist/PhysicsSandboxFixtures.d.ts +0 -53
  39. package/dist/PhysicsSandboxFixtures.d.ts.map +0 -1
  40. package/dist/PhysicsSandboxFixtures.js +0 -280
  41. package/dist/PhysicsSandboxFixtures.js.map +0 -1
  42. package/dist/PlatformerFixtures.d.ts +0 -70
  43. package/dist/PlatformerFixtures.d.ts.map +0 -1
  44. package/dist/PlatformerFixtures.js +0 -120
  45. package/dist/PlatformerFixtures.js.map +0 -1
  46. package/dist/RacingLineProfile.d.ts +0 -116
  47. package/dist/RacingLineProfile.d.ts.map +0 -1
  48. package/dist/RacingLineProfile.js +0 -181
  49. package/dist/RacingLineProfile.js.map +0 -1
  50. package/dist/SoftBodyFixtures.d.ts +0 -70
  51. package/dist/SoftBodyFixtures.d.ts.map +0 -1
  52. package/dist/SoftBodyFixtures.js +0 -272
  53. package/dist/SoftBodyFixtures.js.map +0 -1
  54. package/dist/Steering.d.ts +0 -161
  55. package/dist/Steering.d.ts.map +0 -1
  56. package/dist/Steering.js +0 -347
  57. package/dist/Steering.js.map +0 -1
  58. package/dist/VehicleDynamics.d.ts +0 -162
  59. package/dist/VehicleDynamics.d.ts.map +0 -1
  60. package/dist/VehicleDynamics.js +0 -363
  61. package/dist/VehicleDynamics.js.map +0 -1
  62. package/dist/VehicleMotion.d.ts +0 -125
  63. package/dist/VehicleMotion.d.ts.map +0 -1
  64. package/dist/VehicleMotion.js +0 -373
  65. package/dist/VehicleMotion.js.map +0 -1
  66. package/dist/solverless-entry.d.ts +0 -41
  67. package/dist/solverless-entry.d.ts.map +0 -1
  68. package/dist/solverless-entry.js +0 -40
  69. package/dist/solverless-entry.js.map +0 -1
  70. package/dist/world-entry.d.ts +0 -31
  71. package/dist/world-entry.d.ts.map +0 -1
  72. package/dist/world-entry.js +0 -30
  73. package/dist/world-entry.js.map +0 -1
@@ -1,87 +0,0 @@
1
- export interface ClothSimulationFixtureOptions {
2
- readonly seed?: number;
3
- readonly elapsedSeconds?: number;
4
- readonly segmentsX?: number;
5
- readonly segmentsY?: number;
6
- }
7
- export interface ClothSampleParticle {
8
- readonly index: number;
9
- readonly grid: readonly [number, number];
10
- readonly pinned: boolean;
11
- readonly position: readonly [number, number, number];
12
- readonly uv: readonly [number, number];
13
- }
14
- export interface ClothSimulationFixture {
15
- readonly id: "external-parity-old-branch-cloth-simulation-fixture";
16
- readonly source: "origin-master-cloth-pbd-material-adapted";
17
- readonly sourceFiles: readonly [
18
- "origin/master:src/simulation/cloth/ClothSimulation.ts",
19
- "origin/master:src/simulation/cloth/ClothCollisionSystem.ts",
20
- "origin/master:src/simulation/cloth/ClothTearingSystem.ts",
21
- "origin/master:src/materials/ClothMaterial.ts"
22
- ];
23
- readonly config: {
24
- readonly width: number;
25
- readonly height: number;
26
- readonly segmentsX: number;
27
- readonly segmentsY: number;
28
- readonly particleMass: number;
29
- readonly structuralStiffness: number;
30
- readonly shearStiffness: number;
31
- readonly bendingStiffness: number;
32
- readonly solverIterations: number;
33
- readonly damping: number;
34
- };
35
- readonly mesh: {
36
- readonly particleCount: number;
37
- readonly triangleCount: number;
38
- readonly normalCount: number;
39
- readonly uvCount: number;
40
- readonly indexCount: number;
41
- readonly pinnedCount: number;
42
- readonly pinnedPattern: "top-edge";
43
- readonly sampleParticles: readonly ClothSampleParticle[];
44
- };
45
- readonly constraints: {
46
- readonly structural: number;
47
- readonly shear: number;
48
- readonly bending: number;
49
- readonly total: number;
50
- readonly maxStrain: number;
51
- readonly tearThreshold: number;
52
- readonly tearCandidates: number;
53
- readonly cutPlaneConstraintCandidates: number;
54
- };
55
- readonly wind: {
56
- readonly direction: readonly [number, number, number];
57
- readonly turbulence: number;
58
- readonly frequency: number;
59
- readonly maxOffset: number;
60
- readonly affectedParticles: number;
61
- };
62
- readonly collision: {
63
- readonly shape: "sphere";
64
- readonly center: readonly [number, number, number];
65
- readonly radius: number;
66
- readonly penetrationCount: number;
67
- readonly resolvedParticles: number;
68
- readonly maxPenetration: number;
69
- readonly friction: number;
70
- readonly restitution: number;
71
- };
72
- readonly material: {
73
- readonly preset: "coarse-wool-flag";
74
- readonly sheenIntensity: number;
75
- readonly sheenRoughness: number;
76
- readonly subsurfaceIntensity: number;
77
- readonly anisotropyStrength: number;
78
- readonly fuzzIntensity: number;
79
- readonly roughness: number;
80
- readonly tiling: readonly [number, number];
81
- };
82
- readonly blockedClaims: readonly string[];
83
- readonly hash: string;
84
- readonly claimBoundary: string;
85
- }
86
- export declare function sampleClothSimulationFixture(options?: ClothSimulationFixtureOptions): ClothSimulationFixture;
87
- //# sourceMappingURL=ClothFixtures.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClothFixtures.d.ts","sourceRoot":"","sources":["../../../../packages/physics/src/ClothFixtures.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,EAAE,qDAAqD,CAAC;IACnE,QAAQ,CAAC,MAAM,EAAE,0CAA0C,CAAC;IAC5D,QAAQ,CAAC,WAAW,EAAE,SAAS;QAC7B,uDAAuD;QACvD,4DAA4D;QAC5D,0D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,EAAE,MAAM,CAAC,CAAC;KAC5C,CAAC;IACF,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAoBD,wBAAgB,4BAA4B,CAAC,OAAO,GAAE,6BAAkC,GAAG,sBAAsB,CAyLhH"}
@@ -1,264 +0,0 @@
1
- const sourceFiles = [
2
- "origin/master:src/simulation/cloth/ClothSimulation.ts",
3
- "origin/master:src/simulation/cloth/ClothCollisionSystem.ts",
4
- "origin/master:src/simulation/cloth/ClothTearingSystem.ts",
5
- "origin/master:src/materials/ClothMaterial.ts"
6
- ];
7
- const blockedClaims = [
8
- "GPU cloth compute parity",
9
- "100k particle cloth performance",
10
- "production PBD solver parity",
11
- "cloth self-collision",
12
- "mesh-splitting topology tearing",
13
- "fabric shader parity",
14
- "Unity Cloth parity",
15
- "Unreal Chaos Cloth parity"
16
- ];
17
- export function sampleClothSimulationFixture(options = {}) {
18
- const seed = integer(options.seed ?? 0x3d2025, "seed");
19
- const elapsedSeconds = finiteNonNegative(options.elapsedSeconds ?? 0.4, "elapsedSeconds");
20
- const segmentsX = integerInRange(options.segmentsX ?? 12, "segmentsX", 2, 64);
21
- const segmentsY = integerInRange(options.segmentsY ?? 8, "segmentsY", 2, 64);
22
- const width = 2.4;
23
- const height = 1.5;
24
- const particleCount = (segmentsX + 1) * (segmentsY + 1);
25
- const triangleCount = segmentsX * segmentsY * 2;
26
- const structural = segmentsX * (segmentsY + 1) + (segmentsX + 1) * segmentsY;
27
- const shear = segmentsX * segmentsY * 2;
28
- const bending = Math.max(0, (segmentsX - 1) * (segmentsY + 1) + (segmentsY - 1) * (segmentsX + 1));
29
- const pinnedCount = segmentsX + 1;
30
- const windDirection = [3.2, 0.35, 1.15];
31
- const turbulence = 0.35;
32
- const frequency = 1.8;
33
- const collisionCenter = [0.08, -0.18, 0.06];
34
- const collisionRadius = 0.34;
35
- let maxOffset = 0;
36
- let affectedParticles = 0;
37
- let penetrationCount = 0;
38
- let resolvedParticles = 0;
39
- let maxPenetration = 0;
40
- let maxStrain = 1;
41
- let tearCandidates = 0;
42
- let cutPlaneConstraintCandidates = 0;
43
- const positions = new Map();
44
- const sampleParticles = [];
45
- const sampleKeys = new Set([
46
- particleIndex(0, 0, segmentsX),
47
- particleIndex(Math.floor(segmentsX / 2), 0, segmentsX),
48
- particleIndex(segmentsX, 0, segmentsX),
49
- particleIndex(0, Math.floor(segmentsY / 2), segmentsX),
50
- particleIndex(Math.floor(segmentsX / 2), Math.floor(segmentsY / 2), segmentsX),
51
- particleIndex(segmentsX, Math.floor(segmentsY / 2), segmentsX),
52
- particleIndex(0, segmentsY, segmentsX),
53
- particleIndex(Math.floor(segmentsX / 2), segmentsY, segmentsX),
54
- particleIndex(segmentsX, segmentsY, segmentsX)
55
- ]);
56
- for (let y = 0; y <= segmentsY; y += 1) {
57
- for (let x = 0; x <= segmentsX; x += 1) {
58
- const index = particleIndex(x, y, segmentsX);
59
- const vertical = y / segmentsY;
60
- const horizontal = x / segmentsX;
61
- const pinned = y === 0;
62
- const baseX = (horizontal - 0.5) * width;
63
- const sag = pinned ? 0 : Math.pow(vertical, 1.42) * (0.28 + hash01(seed, 7) * 0.08 + elapsedSeconds * 0.045);
64
- const gust = pinned ? 0 : Math.sin(elapsedSeconds * frequency + x * 0.73 + y * 0.41 + hash01(seed, x + y + 11) * 2) * turbulence * vertical;
65
- const xOffset = pinned ? 0 : windDirection[0] * 0.018 * vertical + gust * 0.06;
66
- const zOffset = pinned ? 0 : windDirection[2] * 0.035 * vertical + gust * 0.1;
67
- let position = [
68
- round4(baseX + xOffset),
69
- round4(height * 0.5 - vertical * height - sag),
70
- round4(zOffset)
71
- ];
72
- const penetration = spherePenetration(position, collisionCenter, collisionRadius);
73
- if (penetration > 0) {
74
- penetrationCount += 1;
75
- resolvedParticles += 1;
76
- maxPenetration = Math.max(maxPenetration, penetration);
77
- position = resolveSphere(position, collisionCenter, collisionRadius);
78
- }
79
- const offset = Math.hypot(position[0] - baseX, position[2]);
80
- if (offset > 0.002 && !pinned)
81
- affectedParticles += 1;
82
- maxOffset = Math.max(maxOffset, offset);
83
- positions.set(index, position);
84
- if (sampleKeys.has(index)) {
85
- sampleParticles.push({
86
- index,
87
- grid: [x, y],
88
- pinned,
89
- position,
90
- uv: [round4(horizontal), round4(vertical)]
91
- });
92
- }
93
- }
94
- }
95
- for (let y = 0; y <= segmentsY; y += 1) {
96
- for (let x = 0; x <= segmentsX; x += 1) {
97
- const current = positions.get(particleIndex(x, y, segmentsX));
98
- if (!current)
99
- continue;
100
- if (x < segmentsX) {
101
- const strain = constraintStrain(current, positions.get(particleIndex(x + 1, y, segmentsX)), width / segmentsX);
102
- maxStrain = Math.max(maxStrain, strain);
103
- if (strain >= 1.035 && y >= segmentsY - 2)
104
- tearCandidates += 1;
105
- if (x < segmentsX / 2 && x + 1 >= segmentsX / 2 && y > 0)
106
- cutPlaneConstraintCandidates += 1;
107
- }
108
- if (y < segmentsY) {
109
- const strain = constraintStrain(current, positions.get(particleIndex(x, y + 1, segmentsX)), height / segmentsY);
110
- maxStrain = Math.max(maxStrain, strain);
111
- if (strain >= 1.05 && y >= segmentsY - 3)
112
- tearCandidates += 1;
113
- }
114
- }
115
- }
116
- const metricsForHash = [
117
- seed,
118
- elapsedSeconds,
119
- segmentsX,
120
- segmentsY,
121
- particleCount,
122
- triangleCount,
123
- structural,
124
- shear,
125
- bending,
126
- pinnedCount,
127
- maxOffset,
128
- affectedParticles,
129
- penetrationCount,
130
- maxPenetration,
131
- maxStrain,
132
- tearCandidates,
133
- cutPlaneConstraintCandidates
134
- ];
135
- return {
136
- id: "external-parity-old-branch-cloth-simulation-fixture",
137
- source: "origin-master-cloth-pbd-material-adapted",
138
- sourceFiles,
139
- config: {
140
- width,
141
- height,
142
- segmentsX,
143
- segmentsY,
144
- particleMass: 0.1,
145
- structuralStiffness: 0.9,
146
- shearStiffness: 0.8,
147
- bendingStiffness: 0.12,
148
- solverIterations: 6,
149
- damping: 0.01
150
- },
151
- mesh: {
152
- particleCount,
153
- triangleCount,
154
- normalCount: particleCount,
155
- uvCount: particleCount,
156
- indexCount: triangleCount * 3,
157
- pinnedCount,
158
- pinnedPattern: "top-edge",
159
- sampleParticles
160
- },
161
- constraints: {
162
- structural,
163
- shear,
164
- bending,
165
- total: structural + shear + bending,
166
- maxStrain: round4(maxStrain),
167
- tearThreshold: 1.035,
168
- tearCandidates,
169
- cutPlaneConstraintCandidates
170
- },
171
- wind: {
172
- direction: windDirection,
173
- turbulence,
174
- frequency,
175
- maxOffset: round4(maxOffset),
176
- affectedParticles
177
- },
178
- collision: {
179
- shape: "sphere",
180
- center: collisionCenter,
181
- radius: collisionRadius,
182
- penetrationCount,
183
- resolvedParticles,
184
- maxPenetration: round4(maxPenetration),
185
- friction: 0.42,
186
- restitution: 0.04
187
- },
188
- material: {
189
- preset: "coarse-wool-flag",
190
- sheenIntensity: 0.56,
191
- sheenRoughness: 0.34,
192
- subsurfaceIntensity: 0.24,
193
- anisotropyStrength: 0.42,
194
- fuzzIntensity: 0.22,
195
- roughness: 0.74,
196
- tiling: [3, 2]
197
- },
198
- blockedClaims,
199
- hash: hashNumbers(metricsForHash),
200
- claimBoundary: "Deterministic bounded cloth telemetry adapted from old PBD cloth, collision, tearing, and cloth-material concepts. It proves a pinned cloth grid, structural/shear/bending constraint counts, wind displacement, sphere-collision response, tear-candidate metrics, and fabric material parameters; it does not claim GPU cloth, self-collision, topology tearing, fabric shader parity, Unity Cloth parity, or Unreal Chaos Cloth parity."
201
- };
202
- }
203
- function particleIndex(x, y, segmentsX) {
204
- return y * (segmentsX + 1) + x;
205
- }
206
- function constraintStrain(left, right, restLength) {
207
- if (!right)
208
- return 1;
209
- const length = Math.hypot(left[0] - right[0], left[1] - right[1], left[2] - right[2]);
210
- return restLength > 0 ? length / restLength : 1;
211
- }
212
- function spherePenetration(position, center, radius) {
213
- const distance = Math.hypot(position[0] - center[0], position[1] - center[1], position[2] - center[2]);
214
- return Math.max(0, radius - distance);
215
- }
216
- function resolveSphere(position, center, radius) {
217
- const dx = position[0] - center[0];
218
- const dy = position[1] - center[1];
219
- const dz = position[2] - center[2];
220
- const length = Math.max(0.0001, Math.hypot(dx, dy, dz));
221
- return [
222
- round4(center[0] + dx / length * radius),
223
- round4(center[1] + dy / length * radius),
224
- round4(center[2] + dz / length * radius)
225
- ];
226
- }
227
- function hash01(seed, salt) {
228
- let value = Math.imul(seed + salt * 1013904223, 1664525) + 1013904223;
229
- value = Math.imul(value ^ (value >>> 13), 1274126177);
230
- return ((value ^ (value >>> 16)) >>> 0) / 4294967296;
231
- }
232
- function hashNumbers(values) {
233
- let hash = 0x811c9dc5;
234
- for (const value of values) {
235
- const scaled = Math.round(value * 10_000);
236
- hash ^= scaled & 0xff;
237
- hash = Math.imul(hash, 0x01000193) >>> 0;
238
- hash ^= (scaled >>> 8) & 0xff;
239
- hash = Math.imul(hash, 0x01000193) >>> 0;
240
- hash ^= (scaled >>> 16) & 0xff;
241
- hash = Math.imul(hash, 0x01000193) >>> 0;
242
- }
243
- return hash.toString(16).padStart(8, "0");
244
- }
245
- function round4(value) {
246
- return Number(value.toFixed(4));
247
- }
248
- function finiteNonNegative(value, label) {
249
- if (!Number.isFinite(value) || value < 0)
250
- throw new RangeError(`Cloth fixture ${label} must be finite and non-negative.`);
251
- return value;
252
- }
253
- function integer(value, label) {
254
- if (!Number.isInteger(value))
255
- throw new RangeError(`Cloth fixture ${label} must be an integer.`);
256
- return value;
257
- }
258
- function integerInRange(value, label, min, max) {
259
- const parsed = integer(value, label);
260
- if (parsed < min || parsed > max)
261
- throw new RangeError(`Cloth fixture ${label} must be in the [${min}, ${max}] range.`);
262
- return parsed;
263
- }
264
- //# sourceMappingURL=ClothFixtures.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClothFixtures.js","sourceRoot":"","sources":["../../../../packages/physics/src/ClothFixtures.ts"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,GAAG,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa,EAAE,KAAa;IACrD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,iBAAiB,KAAK,mCAAmC,CAAC,CAAC;IAC1H,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,KAAa;IAC3C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,iBAAiB,KAAK,sBAAsB,CAAC,CAAC;IACjG,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,KAAa,EAAE,GAAW,EAAE,GAAW;IAC5E,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACrC,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,GAAG,GAAG;QAAE,MAAM,IAAI,UAAU,CAAC,iBAAiB,KAAK,oBAAoB,GAAG,KAAK,GAAG,UAAU,CAAC,CAAC;IACxH,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/Crowd.d.ts DELETED
@@ -1,64 +0,0 @@
1
- import { type SteeringPoint, type SteeringVector } from "./Steering";
2
- export type CrowdFormationType = "line" | "wedge" | "column" | "circle";
3
- export interface CrowdAgentOptions {
4
- readonly id: string;
5
- readonly position: SteeringPoint;
6
- readonly velocity?: SteeringVector;
7
- readonly radius?: number;
8
- readonly maxSpeed?: number;
9
- readonly priority?: number;
10
- }
11
- export interface CrowdSimulationOptions {
12
- readonly neighborRadius?: number;
13
- readonly maxNeighbors?: number;
14
- readonly separationWeight?: number;
15
- readonly alignmentWeight?: number;
16
- readonly cohesionWeight?: number;
17
- readonly formationWeight?: number;
18
- readonly maxForce?: number;
19
- }
20
- export interface CrowdFormationOptions {
21
- readonly type: CrowdFormationType;
22
- readonly center: SteeringPoint;
23
- readonly forward?: SteeringVector;
24
- readonly spacing?: number;
25
- }
26
- export interface CrowdAgentSnapshot {
27
- readonly id: string;
28
- readonly position: SteeringPoint;
29
- readonly velocity: SteeringVector;
30
- readonly speed: number;
31
- readonly neighborCount: number;
32
- readonly formationSlot: SteeringPoint;
33
- }
34
- export interface CrowdSimulationSnapshot {
35
- readonly agentCount: number;
36
- readonly neighborPairs: number;
37
- readonly averageNeighbors: number;
38
- readonly averageSpeed: number;
39
- readonly maxSpeed: number;
40
- readonly formationType: CrowdFormationType | "none";
41
- readonly center: SteeringPoint;
42
- readonly agents: readonly CrowdAgentSnapshot[];
43
- }
44
- export declare class CrowdSimulation {
45
- private readonly agents;
46
- private readonly neighborRadius;
47
- private readonly maxNeighbors;
48
- private readonly separationWeight;
49
- private readonly alignmentWeight;
50
- private readonly cohesionWeight;
51
- private readonly formationWeight;
52
- private readonly maxForce;
53
- private formation;
54
- private lastNeighbors;
55
- private lastSlots;
56
- constructor(options?: CrowdSimulationOptions);
57
- addAgent(options: CrowdAgentOptions): void;
58
- removeAgent(id: string): boolean;
59
- setFormation(options: CrowdFormationOptions | undefined): void;
60
- update(deltaSeconds: number): CrowdSimulationSnapshot;
61
- snapshot(): CrowdSimulationSnapshot;
62
- private neighborsFor;
63
- }
64
- //# sourceMappingURL=Crowd.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Crowd.d.ts","sourceRoot":"","sources":["../../../../packages/physics/src/Crowd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAErF,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAExE,MAAM,WAAW,i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
- export class CrowdSimulation {
3
- agents = [];
4
- neighborRadius;
5
- maxNeighbors;
6
- separationWeight;
7
- alignmentWeight;
8
- cohesionWeight;
9
- formationWeight;
10
- maxForce;
11
- formation;
12
- lastNeighbors = new Map();
13
- lastSlots = new Map();
14
- constructor(options = {}) {
15
- this.neighborRadius = positive(options.neighborRadius ?? 0.55, "neighborRadius");
16
- this.maxNeighbors = Math.max(1, Math.floor(options.maxNeighbors ?? 6));
17
- this.separationWeight = nonNegative(options.separationWeight ?? 1.8, "separationWeight");
18
- this.alignmentWeight = nonNegative(options.alignmentWeight ?? 0.55, "alignmentWeight");
19
- this.cohesionWeight = nonNegative(options.cohesionWeight ?? 0.42, "cohesionWeight");
20
- this.formationWeight = nonNegative(options.formationWeight ?? 0.85, "formationWeight");
21
- this.maxForce = positive(options.maxForce ?? 1.2, "maxForce");
22
- }
23
- addAgent(options) {
24
- if (this.agents.some((agent) => agent.id === options.id))
25
- throw new Error(`Crowd agent already exists: ${options.id}`);
26
- this.agents.push({
27
- id: options.id,
28
- position: options.position,
29
- velocity: options.velocity ?? [0, 0],
30
- radius: positive(options.radius ?? 0.1, "radius"),
31
- maxSpeed: positive(options.maxSpeed ?? 0.65, "maxSpeed"),
32
- priority: nonNegative(options.priority ?? 50, "priority")
33
- });
34
- }
35
- removeAgent(id) {
36
- const index = this.agents.findIndex((agent) => agent.id === id);
37
- if (index < 0)
38
- return false;
39
- this.agents.splice(index, 1);
40
- this.lastNeighbors.delete(id);
41
- this.lastSlots.delete(id);
42
- return true;
43
- }
44
- setFormation(options) {
45
- this.formation = options;
46
- }
47
- update(deltaSeconds) {
48
- const dt = Math.max(0, deltaSeconds);
49
- const neighborsById = new Map(this.agents.map((agent) => [agent.id, this.neighborsFor(agent)]));
50
- const slots = formationSlots(this.agents.length, this.formation);
51
- this.lastNeighbors = neighborsById;
52
- this.lastSlots = new Map(this.agents.map((agent, index) => [agent.id, slots[index] ?? agent.position]));
53
- for (let index = 0; index < this.agents.length; index += 1) {
54
- const agent = this.agents[index];
55
- const neighbors = neighborsById.get(agent.id) ?? [];
56
- const slot = slots[index] ?? agent.position;
57
- const force = clampMagnitude(addMany([
58
- scale(separationForce(agent, neighbors), this.separationWeight),
59
- scale(alignmentForce(agent, neighbors), this.alignmentWeight),
60
- scale(cohesionForce(agent, neighbors), this.cohesionWeight),
61
- scale(formationForce(agent, slot), this.formationWeight)
62
- ]), this.maxForce);
63
- const priorityDamping = Math.max(0.35, Math.min(1, agent.priority / 100));
64
- const velocity = clampMagnitude([
65
- agent.velocity[0] + force[0] * dt * priorityDamping,
66
- agent.velocity[1] + force[1] * dt * priorityDamping
67
- ], agent.maxSpeed);
68
- agent.velocity = velocity;
69
- agent.position = [
70
- round3(agent.position[0] + velocity[0] * dt),
71
- round3(agent.position[1] + velocity[1] * dt)
72
- ];
73
- }
74
- return this.snapshot();
75
- }
76
- snapshot() {
77
- const agentSnapshots = this.agents.map((agent) => {
78
- const neighbors = this.lastNeighbors.get(agent.id) ?? [];
79
- return {
80
- id: agent.id,
81
- position: [round3(agent.position[0]), round3(agent.position[1])],
82
- velocity: [round3(agent.velocity[0]), round3(agent.velocity[1])],
83
- speed: round3(length(agent.velocity)),
84
- neighborCount: neighbors.length,
85
- formationSlot: this.lastSlots.get(agent.id) ?? agent.position
86
- };
87
- });
88
- const neighborPairs = agentSnapshots.reduce((sum, agent) => sum + agent.neighborCount, 0) / 2;
89
- const averageSpeed = agentSnapshots.length > 0
90
- ? agentSnapshots.reduce((sum, agent) => sum + agent.speed, 0) / agentSnapshots.length
91
- : 0;
92
- return {
93
- agentCount: agentSnapshots.length,
94
- neighborPairs: round3(neighborPairs),
95
- averageNeighbors: agentSnapshots.length > 0 ? round3((neighborPairs * 2) / agentSnapshots.length) : 0,
96
- averageSpeed: round3(averageSpeed),
97
- maxSpeed: round3(Math.max(0, ...agentSnapshots.map((agent) => agent.speed))),
98
- formationType: this.formation?.type ?? "none",
99
- center: centerOf(agentSnapshots.map((agent) => agent.position)),
100
- agents: agentSnapshots
101
- };
102
- }
103
- neighborsFor(agent) {
104
- return this.agents
105
- .filter((candidate) => candidate !== agent && distance(agent.position, candidate.position) <= this.neighborRadius)
106
- .sort((left, right) => distance(agent.position, left.position) - distance(agent.position, right.position) || left.id.localeCompare(right.id))
107
- .slice(0, this.maxNeighbors);
108
- }
109
- }
110
- function separationForce(agent, neighbors) {
111
- const contributions = neighbors.map((neighbor) => {
112
- const away = subtract(agent.position, neighbor.position);
113
- const gap = Math.max(0.001, length(away) - agent.radius - neighbor.radius);
114
- return scale(normalize(away), 1 / gap);
115
- });
116
- return normalize(addMany(contributions));
117
- }
118
- function alignmentForce(agent, neighbors) {
119
- if (neighbors.length === 0)
120
- return [0, 0];
121
- const average = scale(addMany(neighbors.map((neighbor) => neighbor.velocity)), 1 / neighbors.length);
122
- return subtract(clampMagnitude(average, agent.maxSpeed), agent.velocity);
123
- }
124
- function cohesionForce(agent, neighbors) {
125
- if (neighbors.length === 0)
126
- return [0, 0];
127
- const center = centerOf(neighbors.map((neighbor) => neighbor.position));
128
- return arriveSteering({ position: agent.position, velocity: agent.velocity, target: center, maxSpeed: agent.maxSpeed, slowingRadius: 0.45 }).force;
129
- }
130
- function formationForce(agent, slot) {
131
- return arriveSteering({ position: agent.position, velocity: agent.velocity, target: slot, maxSpeed: agent.maxSpeed, slowingRadius: 0.35, tolerance: 0.025 }).force;
132
- }
133
- function formationSlots(count, formation) {
134
- if (!formation)
135
- return [];
136
- const spacing = formation.spacing ?? 0.24;
137
- const forward = normalize(formation.forward ?? [1, 0]);
138
- const right = [forward[1], -forward[0]];
139
- return Array.from({ length: count }, (_, index) => {
140
- switch (formation.type) {
141
- case "line":
142
- return offset(formation.center, right, (index - (count - 1) / 2) * spacing);
143
- case "column":
144
- return offset(formation.center, forward, -index * spacing);
145
- case "circle": {
146
- const angle = (Math.PI * 2 * index) / Math.max(1, count);
147
- return [round3(formation.center[0] + Math.cos(angle) * spacing), round3(formation.center[1] + Math.sin(angle) * spacing)];
148
- }
149
- case "wedge": {
150
- if (index === 0)
151
- return formation.center;
152
- const side = index % 2 === 0 ? 1 : -1;
153
- const row = Math.ceil(index / 2);
154
- return add(offset(formation.center, forward, -row * spacing), scale(right, side * row * spacing));
155
- }
156
- }
157
- });
158
- }
159
- function offset(origin, direction, amount) {
160
- return [round3(origin[0] + direction[0] * amount), round3(origin[1] + direction[1] * amount)];
161
- }
162
- function add(left, right) {
163
- return [round3(left[0] + right[0]), round3(left[1] + right[1])];
164
- }
165
- function subtract(left, right) {
166
- return [left[0] - right[0], left[1] - right[1]];
167
- }
168
- function scale(value, scalar) {
169
- return [value[0] * scalar, value[1] * scalar];
170
- }
171
- function addMany(values) {
172
- return values.reduce((sum, value) => [sum[0] + value[0], sum[1] + value[1]], [0, 0]);
173
- }
174
- function distance(left, right) {
175
- return length(subtract(left, right));
176
- }
177
- function length(value) {
178
- return Math.hypot(value[0], value[1]);
179
- }
180
- function normalize(value) {
181
- const magnitude = length(value);
182
- return magnitude === 0 ? [0, 0] : [value[0] / magnitude, value[1] / magnitude];
183
- }
184
- function clampMagnitude(value, maxMagnitude) {
185
- const magnitude = length(value);
186
- if (magnitude === 0 || magnitude <= maxMagnitude)
187
- return value;
188
- return scale(value, maxMagnitude / magnitude);
189
- }
190
- function centerOf(points) {
191
- if (points.length === 0)
192
- return [0, 0];
193
- const sum = points.reduce((total, point) => [total[0] + point[0], total[1] + point[1]], [0, 0]);
194
- return [round3(sum[0] / points.length), round3(sum[1] / points.length)];
195
- }
196
- function positive(value, name) {
197
- if (!Number.isFinite(value) || value <= 0)
198
- throw new RangeError(`Crowd ${name} must be a finite positive number.`);
199
- return value;
200
- }
201
- function nonNegative(value, name) {
202
- if (!Number.isFinite(value) || value < 0)
203
- throw new RangeError(`Crowd ${name} must be a finite non-negative number.`);
204
- return value;
205
- }
206
- function round3(value) {
207
- return Number(value.toFixed(3));
208
- }
209
- //# sourceMappingURL=Crowd.js.map