physicsMaterial.d.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * Determines how values from the PhysicsMaterial are combined when
  3. * two objects are in contact. When each PhysicsMaterial specifies
  4. * a different combine mode for some property, the combine mode which
  5. * is used will be selected based on their order in this enum - i.e.
  6. * a value later in this list will be preferentially used.
  7. */
  8. export declare enum PhysicsMaterialCombineMode {
  9. /**
  10. * The final value will be the geometric mean of the two values:
  11. * sqrt( valueA * valueB )
  12. */
  13. GEOMETRIC_MEAN = 0,
  14. /**
  15. * The final value will be the smaller of the two:
  16. * min( valueA , valueB )
  17. */
  18. MINIMUM = 1,
  19. MAXIMUM = 2,
  20. ARITHMETIC_MEAN = 3,
  21. /**
  22. * The final value will be the product of the two values:
  23. * valueA * valueB
  24. */
  25. MULTIPLY = 4
  26. }
  27. /**
  28. * Physics material class
  29. * Helps setting friction and restitution that are used to compute responding forces in collision response
  30. */
  31. export interface PhysicsMaterial {
  32. /**
  33. * Sets the friction used by this material
  34. *
  35. * The friction determines how much an object will slow down when it is in contact with another object.
  36. * This is important for simulating realistic physics, such as when an object slides across a surface.
  37. *
  38. * If not provided, a default value of 0.5 will be used.
  39. */
  40. friction?: number;
  41. /**
  42. * Sets the static friction used by this material.
  43. *
  44. * Static friction is the friction that must be overcome before a pair of objects can start sliding
  45. * relative to each other; for physically-realistic behaviour, it should be at least as high as the
  46. * normal friction value. If not provided, the friction value will be used
  47. */
  48. staticFriction?: number;
  49. /**
  50. * Sets the restitution of the physics material.
  51. *
  52. * The restitution is a factor which describes, the amount of energy that is retained after a collision,
  53. * which should be a number between 0 and 1..
  54. *
  55. * A restitution of 0 means that no energy is retained and the objects will not bounce off each other,
  56. * while a restitution of 1 means that all energy is retained and the objects will bounce.
  57. *
  58. * Note, though, due that due to the simulation implementation, an object with a restitution of 1 may
  59. * still lose energy over time.
  60. *
  61. * If not provided, a default value of 0 will be used.
  62. */
  63. restitution?: number;
  64. /**
  65. * Describes how two different friction values should be combined. See PhysicsMaterialCombineMode for
  66. * more details.
  67. *
  68. * If not provided, will use PhysicsMaterialCombineMode.MINIMUM
  69. */
  70. frictionCombine?: PhysicsMaterialCombineMode;
  71. /**
  72. * Describes how two different restitution values should be combined. See PhysicsMaterialCombineMode for
  73. * more details.
  74. *
  75. * If not provided, will use PhysicsMaterialCombineMode.MAXIMUM
  76. */
  77. restitutionCombine?: PhysicsMaterialCombineMode;
  78. }