forked from SuperNLZ/cocos-creator-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathliquidfun.d.ts
496 lines (398 loc) · 11.8 KB
/
liquidfun.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
// originally copy from https://github.com/gogachinchaladze/ivanets/blob/eee28cfa4ded80201f7c1e838e094e157490b146/definitions/liquidfun/liquidfun.d.ts
// make it Cocos Creator affine by caogtaa
// add some api by lamyoung [白玉无冰]
declare module b2 {
declare var waterParticle: any;
declare var zombieParticle: any;
declare var wallParticle: any;
declare var springParticle: any;
declare var elasticParticle: any;
declare var viscousParticle: any;
declare var powderParticle: any;
declare var tensileParticle: any;
declare var colorMixingParticle: any;
declare var destructionListenerParticle: any;
declare var barrierParticle: any;
declare var staticPressureParticle: any;
declare var reactiveParticle: any;
declare var repulsiveParticle: any;
declare var fixtureContactListenerParticle: any;
declare var particleContactListenerParticle: any;
declare var fixtureContactFilterParticle: any;
declare var particleContactFilterParticle: any;
declare class Vec2 {
constructor(x: number, y: number);
Set(newX: number, newY: number);
Clone();
x: number
y: number
}
declare class Filter {
categoryBits: number
maskBits: number
groupIndex: number
}
declare class BodyDef {
type: any
position: b2.Vec2
linearDamping: number
angularDamping: number
fixedRotation: boolean
bullet: boolean
active: boolean
userData: number
filter: b2.Filter
}
declare class Fixture {
SetDensity(density: number);
filter: b2.Filter
GetFriction(): number;
SetFriction(friction: number): void;
GetRestitution(): number;
SetRestitution(restitution: number): void;
TestPoint(worldPoint: b2.Vec2): boolean;
GetBody(): b2.Body;
}
declare class MassData {
}
declare class Body {
fixtures: b2.Fixture[]
CreateFixtureFromShape(shape: b2.Shape, density: number): b2.Fixture;
CreateFixtureFromDef(fixtureDefinition: b2.FixtureDef): b2.Fixture;
GetPosition(): b2.Vec2;
GetAngle(): number;
GetMass(): number;
GetInertia(): number;
GetLocalCenter(): b2.Vec2;
SetType(type: any);
GetType(): any;
SetBullet(flag: boolean);
IsBullet(): boolean;
SetSleepingAllowed(flag: boolean);
IsSleepingAllowed(): boolean;
SetAwake(flag: boolean);
IsAwake(): boolean;
SetActive(flag: boolean);
IsActive(): boolean;
SetFixedRotation(flag: boolean);
IsFixedRotation(): boolean;
GetWorldCenter(): b2.Vec2;
GetLocalCenter(): b2.Vec2;
ResetMassData();
DestroyFixture(fixture: b2.Fixture): void;
SetLinearVelocity(lVelocity: b2.Vec2): void;
GetLinearVelocity(): b2.Vec2;
SetAngularVelocity(omega: number): void;
GetAngularVelocity(): number;
ApplyForce(force: b2.Vec2, point: b2.Vec2, wake: boolean): void;
ApplyForceToCenter(force: b2.Vec2, wake: boolean): void;
ApplyTorque(torque: number, wake: boolean): void;
ApplyLinearImpulse(impulse: b2.Vec2, point: b2.Vec2, wake: boolean): void;
ApplyAngularImpulse(impulse: number, wake: boolean): void;
GetMass(): number;
GetInertia(): number;
GetWorldPoint(localPoint: b2.Vec2): b2.Vec2;
GetLocalPoint(worldPoint: b2.Vec2): b2.Vec2;
SetGravityScale(gScale: number): void;
SetSleepingAllowed(flag: boolean): void;
IsSleepingAllowed(): boolean;
SetAwake(flag: boolean): void;
IsAwake(): boolean;
SetActive(flag: boolean): void;
IsActive(): boolean;
GetPositionX(): number;
GetPositionY(): number;
SetTransform(position: b2.Vec2, angle: number): void;
SetLinearVelocity(v: b2.Vec2): void;
GetLinearVelocity(): b2.Vec2;
SetAngularVelocity(omega: number): void;
GetAngularVelocity(): number;
GetUserData(): number;
}
interface QueryCallback {
ReportFixture(fixture: b2.Fixture): boolean;
}
declare class AABB {
lowerBound: b2.Vec2
upperBound: b2.Vec2
}
interface RayCastCallback {
}
declare class World {
constructor(gravity: b2.Vec2);
CreateBody(bodyDefinition: b2.BodyDef): b2.Body;
CreateJoint(jointDefinition: b2.JointDef): b2.Joint;
Step(timeStep: number, velocityIterations: number, positionIterations: number);
SetContactListener(listener: b2.ContactListener): void;
QueryAABB(callback: b2.QueryCallback, aabb: b2.AABB): void;
RayCast(callback: b2.RayCastCallback, point1: b2.Vec2, point2: b2.Vec2): void;
CreateParticleSystem(particleSystemDef: b2.ParticleSystemDef): b2.ParticleSystem;
DestroyParticleSystem(particleSystem: b2.ParticleSystem): void;
bodies: b2.Body[]
particleSystems: b2.ParticleSystem[]
}
interface ContactListener {
BeginContact(contact: b2.Contact): void;
EndContact(contect: b2.Contact): void;
PreSolve(contact: b2.Contact, manifold: b2.Manifold): void;
PostSolve(contect: b2.Contact, manifold: b2.Manifold): void;
}
declare class Shape {
radius: number
GetPositionX(): number;
GetPositionY(): number;
SetPosition(x: number, y: number);
}
declare class EdgeShape extends b2.Shape {
Set(v1: b2.Vec2, v2: b2.Vec2);
}
declare class ChainShape extends b2.Shape {
CreateChain(points: Array<b2Vec2>);
}
declare class CircleShape extends b2.Shape {
}
declare class Transform {
}
declare class PolygonShape extends b2.Shape {
SetAsBoxXY(halfWidth: number, halfHeight: number);
SetAsBox(halfWidth: number, halfHeight: number);
}
declare var dynamicBody: any
declare var kinematicBody: any
declare var staticBody: any
declare class FixtureDef {
shape: any
density: number
friction: number
restitution: number
filter: b2.Filter
}
//Joint definitions
declare class JointDef {
collideConnected: boolean
frequencyHz: number
dampingRatio: number
bodyA: b2.Body
bodyB: b2.Body
}
declare class DistanceJointDef extends b2.JointDef {
localAnchorA: b2.Vec2
localAnchorB: b2.Vec2
length: number
InitializeAndCreate(bodyA: b2.Body, bodyB: b2.Body, anchorA: b2.Vec2, anchorB: b2.Vec2);
}
declare class RevoluteJointDef extends b2.JointDef {
lowerAngle: number
upperAngle: number
enableLimit: boolean
motorSpeed: number
enableMotor: number
localAnchorA: b2.Vec2
localAnchorB: b2.Vec2
InitializeAndCreate(bodyA: b2.Body, bodyB: b2.Body, sharedAnchorInWorldSpace: b2.Vec2);
}
declare class PrismaticJointDef extends b2.JointDef {
lowerTranslation: number
upperTranslation: number
enableLimit: boolean
maxMotorForce: number
motorSpeed: number
enableMotor: boolean
}
declare class PulleyJointDef extends b2.JointDef {
}
declare class GearJointDef extends b2.JointDef {
}
//Joint classes
declare class Joint {
}
declare class DistanceJoint extends b2.Joint {
}
declare class RevoluteJoint extends b2.Joint {
GetJointAngle(): number;
GetJointSpeed(): number;
GetMotorTorque(): number;
SetMotorSpeed(speed: number);
SetMaxMotorTorque(torque: number);
}
declare class PrismaticJoint extends b2.Joint {
GetJointTranslation(): number;
GetJointSpeed(): number;
GetMotorForce(): number;
SetMotorSpeed(speed: number);
SetMotorForce(force: number);
}
declare class PulleyJoint extends b2.Joint {
GetLengthA(): number;
GetLengthB(): number;
}
declare class Contact {
GetManifold(): b2.Manifold;
GetFixtureA(): b2.Fixture;
GetFixtureB(): b2.Fixture;
SetEnabled(enabled: boolean): void;
}
declare class Manifold {
}
//Particles
declare class ParticleColor {
}
declare class ParticleDef {
flags: any
position: b2.Vec2
color: b2.ParticleColor
}
declare class ParticleSystemDef {
strictContactCheck = false;
/**
* Set the particle density.
* See SetDensity for details.
*/
density = 1.0;
/**
* Change the particle gravity scale. Adjusts the effect of the
* global gravity vector on particles. Default value is 1.0f.
*/
gravityScale = 1.0;
/**
* Particles behave as circles with this radius. In Box2D units.
*/
radius = 1.0;
/**
* Set the maximum number of particles.
* By default, there is no maximum. The particle buffers can
* continue to grow while b2World's block allocator still has
* memory.
* See SetMaxParticleCount for details.
*/
maxCount = 0;
/**
* Increases pressure in response to compression
* Smaller values allow more compression
*/
pressureStrength = 0.005;
/**
* Reduces velocity along the collision normal
* Smaller value reduces less
*/
dampingStrength = 1.0;
/**
* Restores shape of elastic particle groups
* Larger values increase elastic particle velocity
*/
elasticStrength = 0.25;
/**
* Restores length of spring particle groups
* Larger values increase spring particle velocity
*/
springStrength = 0.25;
/**
* Reduces relative velocity of viscous particles
* Larger values slow down viscous particles more
*/
viscousStrength = 0.25;
/**
* Produces pressure on tensile particles
* 0~0.2. Larger values increase the amount of surface tension.
*/
surfaceTensionPressureStrength = 0.2;
/**
* Smoothes outline of tensile particles
* 0~0.2. Larger values result in rounder, smoother,
* water-drop-like clusters of particles.
*/
surfaceTensionNormalStrength = 0.2;
/**
* Produces additional pressure on repulsive particles
* Larger values repulse more
* Negative values mean attraction. The range where particles
* behave stably is about -0.2 to 2.0.
*/
repulsiveStrength = 1.0;
/**
* Produces repulsion between powder particles
* Larger values repulse more
*/
powderStrength = 0.5;
/**
* Pushes particles out of solid particle group
* Larger values repulse more
*/
ejectionStrength = 0.5;
/**
* Produces static pressure
* Larger values increase the pressure on neighboring partilces
* For a description of static pressure, see
* http://en.wikipedia.org/wiki/Static_pressure#Static_pressure_in_fluid_dynamics
*/
staticPressureStrength = 0.2;
/**
* Reduces instability in static pressure calculation
* Larger values make stabilize static pressure with fewer
* iterations
*/
staticPressureRelaxation = 0.2;
/**
* Computes static pressure more precisely
* See SetStaticPressureIterations for details
*/
staticPressureIterations = 8;
/**
* Determines how fast colors are mixed
* 1.0f ==> mixed immediately
* 0.5f ==> mixed half way each simulation step (see
* b2World::Step())
*/
colorMixingStrength = 0.5;
/**
* Whether to destroy particles by age when no more particles
* can be created. See #b2ParticleSystem::SetDestructionByAge()
* for more information.
*/
destroyByAge = true;
/**
* Granularity of particle lifetimes in seconds. By default
* this is set to (1.0f / 60.0f) seconds. b2ParticleSystem uses
* a 32-bit signed value to track particle lifetimes so the
* maximum lifetime of a particle is (2^32 - 1) / (1.0f /
* lifetimeGranularity) seconds. With the value set to 1/60 the
* maximum lifetime or age of a particle is 2.27 years.
*/
lifetimeGranularity = 1.0 / 60.0;
}
declare class ParticleGroupDef {
flags: any
position: b2.Vec2
color: b2.ParticleColor
angle: number
angularVelocity: number
shape: b2.Shape
strength: number;
groupFlags: number;
}
declare class ParticleGroup {
SetGroupFlags(flags: any);
GetGroupFlags(): any;
DestroyParticles(callDestructionListener: boolean): void;
}
declare class ParticleSystem {
CreateParticle(particleDefinition: b2.ParticleDef): number;
DestroyParticlesInShape(shape: b2.Shape, transform: b2.Transform): void;
CreateParticleGroup(particleGroupDefinition: b2.ParticleGroupDef);
SetPaused(paused: boolean): void;
SetParticleDestructionByAge(deletionByAge: boolean): void;
SetParticleLifetime(particleIndex: number, lifetime: number): void;
SetDensity(density: number): void;
GetStuckCandidateCount(): number;
GetStuckCandidates(): Array<number>;
GetPositionBuffer(): Float32Array;
GetColorBuffer(): Uint8Array;
SetRadius(radious: number): void;
}
export class ParticleFlag {
static b2_elasticParticle;
}
export class ParticleGroupFlag {
static b2_solidParticleGroup;
}
}