@@ -5,15 +5,15 @@ import { ICollision } from "@galacean/engine-design";
5
5
/**
6
6
* Describes a contact point where the collision occurs.
7
7
*/
8
- export interface ContractPoint {
8
+ export interface ContactPoint {
9
9
/** The position of the contact point between the shapes, in world space. */
10
- position : Vector3 ;
10
+ readonly position : Vector3 ;
11
11
/** The normal of the contacting surfaces at the contact point. The normal direction points from the second shape to the first shape. */
12
- normal : Vector3 ;
12
+ readonly normal : Vector3 ;
13
13
/** The impulse applied at the contact point, in world space. Divide by the simulation time step to get a force value. */
14
- impulse : Vector3 ;
14
+ readonly impulse : Vector3 ;
15
15
/** The separation of the shapes at the contact point. A negative separation denotes a penetration. */
16
- separation : number ;
16
+ readonly separation : number ;
17
17
}
18
18
19
19
export class Collision {
@@ -32,22 +32,22 @@ export class Collision {
32
32
33
33
/**
34
34
* Get contact points.
35
- * @param contacts - The result of contact points
35
+ * @param outContacts - The result of contact points
36
36
* @returns The result of contact points
37
37
*/
38
- getContacts ( contacts : ContractPoint [ ] ) : ContractPoint [ ] {
39
- const nativeContractPoints = this . _nativeCollision . getContacts ( ) ;
40
- for ( let i = 0 , n = nativeContractPoints . size ( ) ; i < n ; i ++ ) {
41
- const nativeContractPoint = nativeContractPoints . get ( i ) ;
38
+ getContacts ( outContacts : ContactPoint [ ] ) : ContactPoint [ ] {
39
+ const nativeContactPoints = this . _nativeCollision . getContacts ( ) ;
40
+ for ( let i = 0 , n = nativeContactPoints . size ( ) ; i < n ; i ++ ) {
41
+ const nativeContractPoint = nativeContactPoints . get ( i ) ;
42
42
const { position, normal, impulse, separation } = nativeContractPoint ;
43
- const contact : ContractPoint = {
43
+ const contact : ContactPoint = {
44
44
position : new Vector3 ( position . x , position . y , position . z ) ,
45
45
normal : new Vector3 ( normal . x , normal . y , normal . z ) ,
46
46
impulse : new Vector3 ( impulse . x , impulse . y , impulse . z ) ,
47
47
separation : separation
48
48
} ;
49
- contacts . push ( contact ) ;
49
+ outContacts . push ( contact ) ;
50
50
}
51
- return contacts ;
51
+ return outContacts ;
52
52
}
53
53
}
0 commit comments