mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
update api docs and cannon (#8224)
* DOCS * update @cocos/cannon to 1.2.3
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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<typeof EConstraintType>;
|
||||
export type Type = EnumAlias<typeof EConstraintType>;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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',
|
||||
|
||||
Generated
+3
-3
@@ -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",
|
||||
|
||||
+1
-1
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user