diff --git a/cocos/physics/framework/components/colliders/collider.ts b/cocos/physics/framework/components/colliders/collider.ts index 390f576fbd..411b80498d 100644 --- a/cocos/physics/framework/components/colliders/collider.ts +++ b/cocos/physics/framework/components/colliders/collider.ts @@ -45,7 +45,7 @@ import { createShape } from '../../instance'; /** * @en - * Base class of collider. + * Base class for colliders. * @zh * 碰撞器的基类。 */ @@ -71,9 +71,9 @@ export class Collider extends Eventify(Component) { /** * @en - * Gets the collider attached rigid-body, this may be null. + * Get the rigid body component to which the collider is bound, possibly null. * @zh - * 获取碰撞器所绑定的刚体组件,可能为 null 。 + * 获取碰撞器所绑定的刚体组件,可能为空。 */ @type(RigidBody) @readOnly @@ -165,7 +165,7 @@ export class Collider extends Eventify(Component) { * @en * Gets or sets the center of the collider, in local space. * @zh - * 获取或设置碰撞器的中心点。 + * 在本地空间中,获取或设置碰撞器的中心点。 */ @type(Vec3) @displayOrder(1) diff --git a/cocos/physics/framework/components/constraints/constraint.ts b/cocos/physics/framework/components/constraints/constraint.ts index c506d99a36..6fe8401794 100644 --- a/cocos/physics/framework/components/constraints/constraint.ts +++ b/cocos/physics/framework/components/constraints/constraint.ts @@ -38,11 +38,29 @@ import { IBaseConstraint } from '../../../spec/i-physics-constraint'; import { createConstraint } from '../../instance'; import { EConstraintType } from '../../physics-enum'; +/** + * @en + * Base class for joint constraints, which depends on rigid body components. + * @zh + * 关节约束的基类,它依赖于刚体组件。 + */ @ccclass('cc.Constraint') @requireComponent(RigidBody) export class Constraint extends Eventify(Component) { - static readonly EConstraintType = EConstraintType; + /** + * @en + * Enumeration of joint types. + * @zh + * 关节类型的枚举。 + */ + static readonly Type = EConstraintType; + /** + * @en + * Gets the collider attached rigid-body. + * @zh + * 获取碰撞器所绑定的刚体组件。 + */ @type(RigidBody) @readOnly @displayOrder(-2) @@ -50,6 +68,12 @@ export class Constraint extends Eventify(Component) { return this.getComponent(RigidBody); } + /** + * @en + * Get or set the jointed rigid body, null means link to a static rigid body at the world origin. + * @zh + * 获取或设置关节连接的刚体,为空时表示链接到位于世界原点的静态刚体。 + */ @type(RigidBody) @displayOrder(-1) get connectedBody (): RigidBody | null { @@ -63,6 +87,12 @@ export class Constraint extends Eventify(Component) { } } + /** + * @en + * Get or set whether collision is turned on between two rigid bodies connected by a joint. + * @zh + * 获取或设置关节连接的两刚体之间是否开启碰撞。 + */ @displayOrder(0) get enableCollision () { return this._enableCollision; @@ -75,6 +105,12 @@ export class Constraint extends Eventify(Component) { } } + /** + * @en + * Gets the type of this joint. + * @zh + * 获取此关节的类型。 + */ readonly TYPE: EConstraintType; /// PROTECTED PROPERTY /// @@ -121,5 +157,5 @@ export class Constraint extends Eventify(Component) { } export namespace Constraint { - export type EConstraintType = EnumAlias; + export type Type = EnumAlias; } diff --git a/cocos/physics/framework/components/constraints/hinge-constraint.ts b/cocos/physics/framework/components/constraints/hinge-constraint.ts index 75721b5fb1..dd0279d4fb 100644 --- a/cocos/physics/framework/components/constraints/hinge-constraint.ts +++ b/cocos/physics/framework/components/constraints/hinge-constraint.ts @@ -46,6 +46,12 @@ import { IHingeConstraint } from '../../../spec/i-physics-constraint'; @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; @@ -58,6 +64,12 @@ export class HingeConstraint extends Constraint { } } + /** + * @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; @@ -70,6 +82,12 @@ export class HingeConstraint extends Constraint { } } + /** + * @en + * The direction of the constraint axis rotation in local space. + * @zh + * 在本地空间中,约束关节旋转的方向。 + */ @type(Vec3) get axis (): Vec3 { return this._axis; diff --git a/cocos/physics/framework/components/constraints/point-to-point-constraint.ts b/cocos/physics/framework/components/constraints/point-to-point-constraint.ts index 489a678da4..238e152b0e 100644 --- a/cocos/physics/framework/components/constraints/point-to-point-constraint.ts +++ b/cocos/physics/framework/components/constraints/point-to-point-constraint.ts @@ -46,6 +46,12 @@ import { IPointToPointConstraint } from '../../../spec/i-physics-constraint'; @help('i18n:cc.PointToPointConstraint') @menu('Physics/PointToPointConstraint(beta)') export class PointToPointConstraint extends Constraint { + /** + * @en + * The position of the own rigid body in local space with respect to the constraint axis. + * @zh + * 在本地空间中,自身刚体相对于约束关节的位置。 + */ @type(Vec3) get pivotA () { return this._pivotA; @@ -58,6 +64,12 @@ export class PointToPointConstraint extends Constraint { } } + /** + * @en + * The position of the connected rigid body in the local space with respect to the constraint axis. + * @zh + * 在本地空间中,连接刚体相对于约束关节的位置。 + */ @type(Vec3) get pivotB () { return this._pivotB; diff --git a/cocos/physics/framework/deprecated.ts b/cocos/physics/framework/deprecated.ts index 30eeef1d3a..127a8861ea 100644 --- a/cocos/physics/framework/deprecated.ts +++ b/cocos/physics/framework/deprecated.ts @@ -40,6 +40,7 @@ import { Collider } from './components/colliders/collider'; import { js } from '../../core/utils/js'; import { legacyCC } from '../../core/global-exports'; import { PhysicsMaterial } from './assets/physics-material'; +import { Constraint } from './components/constraints/constraint'; replaceProperty(PhysicsSystem, 'PhysicsSystem', [ { @@ -98,6 +99,13 @@ replaceProperty(Collider, 'Collider', [ }, ]); +replaceProperty(Constraint, 'Constraint', [ + { + name: 'EConstraintType', + newName: 'Type', + }, +]); + replaceProperty(BoxCollider.prototype, 'BoxCollider.prototype', [ { name: 'boxShape', diff --git a/package-lock.json b/package-lock.json index d29d911916..3f424ddc97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1652,9 +1652,9 @@ } }, "@cocos/cannon": { - "version": "1.2.2", - "resolved": "https://registry.npm.taobao.org/@cocos/cannon/download/@cocos/cannon-1.2.2.tgz", - "integrity": "sha1-12hR0B3EcMqmvP7KvdwvdinevPQ=" + "version": "1.2.3", + "resolved": "https://registry.npm.taobao.org/@cocos/cannon/download/@cocos/cannon-1.2.3.tgz", + "integrity": "sha1-78BfuDuh3xRLJtvC8WPlPwKYi6I=" }, "@cocos/physx": { "version": "1.0.0-beta.5", diff --git a/package.json b/package.json index 6160102c2d..0837bae581 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "dependencies": { "@cocos/ammo": "1.1.1", "@cocos/box2d": "1.0.1", - "@cocos/cannon": "1.2.2", + "@cocos/cannon": "1.2.3", "@cocos/physx": "1.0.0-beta.5" } }