mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 03:22:39 +08:00
df1594c8d8
* GameView related EDITOR macro modify * remove debug code * fix ci * fix review * fix review
119 lines
3.6 KiB
TypeScript
119 lines
3.6 KiB
TypeScript
/*
|
|
Copyright (c) 2020 Xiamen Yaji Software Co., Ltd.
|
|
|
|
https://www.cocos.com/
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated engine source code (the "Software"), a limited,
|
|
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
|
to use Cocos Creator solely to develop games on your target platforms. You shall
|
|
not use Cocos Creator software for developing other software or tools that's
|
|
used for developing games. You are not granted to publish, distribute,
|
|
sublicense, and/or sell copies of Cocos Creator.
|
|
|
|
The software or tools in this License Agreement are licensed, not sold.
|
|
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
THE SOFTWARE.
|
|
*/
|
|
|
|
import {
|
|
ccclass,
|
|
help,
|
|
menu,
|
|
serializable,
|
|
formerlySerializedAs,
|
|
type,
|
|
} from 'cc.decorator';
|
|
import { EDITOR } from 'internal:constants';
|
|
import { Constraint } from './constraint';
|
|
import { IVec3Like, Vec3 } from '../../../../core';
|
|
import { EConstraintType } from '../../physics-enum';
|
|
import { IHingeConstraint } from '../../../spec/i-physics-constraint';
|
|
import { legacyCC } from '../../../../core/global-exports';
|
|
|
|
@ccclass('cc.HingeConstraint')
|
|
@help('i18n:cc.HingeConstraint')
|
|
@menu('Physics/HingeConstraint(beta)')
|
|
export class HingeConstraint extends Constraint {
|
|
/**
|
|
* @en
|
|
* The position of the own rigid body in local space with respect to the constraint axis.
|
|
* @zh
|
|
* 在本地空间中,自身刚体相对于约束关节的位置。
|
|
*/
|
|
@type(Vec3)
|
|
get pivotA (): Vec3 {
|
|
return this._pivotA;
|
|
}
|
|
|
|
set pivotA (v: Vec3) {
|
|
Vec3.copy(this._pivotA, v);
|
|
if (!EDITOR || legacyCC.GAME_VIEW) {
|
|
this.constraint.setPivotA(this._pivotA);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @en
|
|
* The position of the connected rigid body in the local space with respect to the constraint axis.
|
|
* @zh
|
|
* 在本地空间中,连接刚体相对于约束关节的位置。
|
|
*/
|
|
@type(Vec3)
|
|
get pivotB (): Vec3 {
|
|
return this._pivotB;
|
|
}
|
|
|
|
set pivotB (v: Vec3) {
|
|
Vec3.copy(this._pivotB, v);
|
|
if (!EDITOR || legacyCC.GAME_VIEW) {
|
|
this.constraint.setPivotB(this._pivotB);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @en
|
|
* The direction of the constraint axis rotation in local space.
|
|
* @zh
|
|
* 在本地空间中,约束关节旋转的方向。
|
|
*/
|
|
@type(Vec3)
|
|
get axis (): Vec3 {
|
|
return this._axis;
|
|
}
|
|
|
|
set axis (v: Vec3) {
|
|
Vec3.copy(this._axis, v);
|
|
if (!EDITOR || legacyCC.GAME_VIEW) {
|
|
this.constraint.setAxis(this._axis);
|
|
}
|
|
}
|
|
|
|
@serializable
|
|
@formerlySerializedAs('axisA')
|
|
private readonly _axis: Vec3 = new Vec3();
|
|
|
|
@serializable
|
|
@formerlySerializedAs('pivotA')
|
|
private readonly _pivotA: Vec3 = new Vec3();
|
|
|
|
@serializable
|
|
@formerlySerializedAs('pivotB')
|
|
private readonly _pivotB: Vec3 = new Vec3();
|
|
|
|
get constraint (): IHingeConstraint {
|
|
return this._constraint as IHingeConstraint;
|
|
}
|
|
|
|
constructor () {
|
|
super(EConstraintType.HINGE);
|
|
}
|
|
}
|