/
point-to-point-constraint.ts
63 lines (52 loc) · 1.39 KB
/
point-to-point-constraint.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
/**
* @packageDocumentation
* @module physics
*/
import {
ccclass,
help,
executeInEditMode,
menu,
type,
serializable,
} from 'cc.decorator';
import { Constraint } from './constraint';
import { Vec3, IVec3Like } from '../../../../core';
import { EConstraintType } from '../../physics-enum';
import { EDITOR } from 'internal:constants';
import { IPointToPointConstraint } from '../../../spec/i-physics-constraint';
@ccclass('cc.PointToPointConstraint')
@help('i18n:cc.PointToPointConstraint')
@menu('Physics/PointToPointConstraint(beta)')
export class PointToPointConstraint extends Constraint {
@type(Vec3)
get pivotA () {
return this._pivotA;
}
set pivotA (v: IVec3Like) {
Vec3.copy(this._pivotA, v);
if (!EDITOR) {
this.constraint.setPivotA(this._pivotA);
}
}
@type(Vec3)
get pivotB () {
return this._pivotB;
}
set pivotB (v: IVec3Like) {
Vec3.copy(this._pivotB, v);
if (!EDITOR) {
this.constraint.setPivotB(this._pivotB);
}
}
get constraint (): IPointToPointConstraint {
return this._constraint as IPointToPointConstraint;
}
@serializable
private readonly _pivotA: Vec3 = new Vec3();
@serializable
private readonly _pivotB: Vec3 = new Vec3();
constructor () {
super(EConstraintType.POINT_TO_POINT);
}
}