mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
[fix] box2d-wasm joint2d null check (#16337)
This commit is contained in:
@@ -30,10 +30,14 @@ import { PHYSICS_2D_PTM_RATIO } from '../../framework/physics-types';
|
||||
|
||||
export class B2FixedJoint extends B2Joint implements IFixedJoint {
|
||||
setFrequency (v: number): void {
|
||||
(this._b2joint as B2.WeldJoint).SetFrequency(v);
|
||||
if (this._b2joint) {
|
||||
(this._b2joint as B2.WeldJoint).SetFrequency(v);
|
||||
}
|
||||
}
|
||||
setDampingRatio (v: number): void {
|
||||
(this._b2joint as B2.WeldJoint).SetDampingRatio(v);
|
||||
if (this._b2joint) {
|
||||
(this._b2joint as B2.WeldJoint).SetDampingRatio(v);
|
||||
}
|
||||
}
|
||||
|
||||
_createJointDef (): any {
|
||||
|
||||
@@ -30,12 +30,15 @@ import { PHYSICS_2D_PTM_RATIO } from '../../framework/physics-types';
|
||||
|
||||
export class B2SpringJoint extends B2Joint implements ISpringJoint {
|
||||
setFrequency (v: number): void {
|
||||
(this._b2joint as B2.DistanceJoint).SetFrequency(v);
|
||||
if (this._b2joint) {
|
||||
(this._b2joint as B2.DistanceJoint).SetFrequency(v);
|
||||
}
|
||||
}
|
||||
|
||||
setDampingRatio (v: number): void {
|
||||
//this.updateStiffnessAndDamping();
|
||||
(this._b2joint as B2.DistanceJoint).SetDampingRatio(v);
|
||||
if (this._b2joint) {
|
||||
(this._b2joint as B2.DistanceJoint).SetDampingRatio(v);
|
||||
}
|
||||
}
|
||||
|
||||
setDistance (v: number): void {
|
||||
|
||||
@@ -31,10 +31,14 @@ import { toRadian } from '../../../core';
|
||||
|
||||
export class B2WheelJoint extends B2Joint implements IWheelJoint {
|
||||
setFrequency (v: number): void {
|
||||
(this._b2joint as B2.WheelJoint as any).SetSpringFrequencyHz(v);
|
||||
if (this._b2joint) {
|
||||
(this._b2joint as B2.WheelJoint as any).SetSpringFrequencyHz(v);
|
||||
}
|
||||
}
|
||||
setDampingRatio (v: number): void {
|
||||
(this._b2joint as B2.WheelJoint as any).SetSpringDampingRatio(v);
|
||||
if (this._b2joint) {
|
||||
(this._b2joint as B2.WheelJoint as any).SetSpringDampingRatio(v);
|
||||
}
|
||||
}
|
||||
|
||||
// motor
|
||||
|
||||
Reference in New Issue
Block a user