diff --git a/cocos/physics3d/CCPhysics3DConstraint.h b/cocos/physics3d/CCPhysics3DConstraint.h index afad5ce3ad..448d540dd5 100644 --- a/cocos/physics3d/CCPhysics3DConstraint.h +++ b/cocos/physics3d/CCPhysics3DConstraint.h @@ -177,8 +177,6 @@ public: CC_CONSTRUCTOR_ACCESS: Physics3DPointToPointConstraint(); virtual ~Physics3DPointToPointConstraint(); - -protected: bool init(Physics3DRigidBody* rbA, const cocos2d::Vec3& pivotPointInA); bool init(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Vec3& pivotPointInA, const cocos2d::Vec3& pivotPointInB); diff --git a/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d.js b/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d.js index a975a559ca..7e23bb8ba0 100644 --- a/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d.js +++ b/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d.js @@ -339,4 +339,17 @@ jsb.Physics3DComponent.prototype._ctor = function(physicsObj, translateInPhysics this.init(); this.setPhysics3DObject(physicsObj); this.setTransformInPhysics(translateInPhysics, rotInPhsyics); +} + +jsb.Physics3DPointToPointConstraint.prototype._ctor = function(first, second, third, fourth){ + if (arguments.length == 2 ) { + this.init(first, second); + } + else if (arguments.length == 4 ) { + this.init(first, second, third, fourth); + } + else + { + throw new Error("error arguments"); + } } \ No newline at end of file diff --git a/tests/js-tests/src/Physics3DTest/Physics3DTest.js b/tests/js-tests/src/Physics3DTest/Physics3DTest.js index 1eff7180f2..23f68bc9fd 100644 --- a/tests/js-tests/src/Physics3DTest/Physics3DTest.js +++ b/tests/js-tests/src/Physics3DTest/Physics3DTest.js @@ -319,7 +319,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ this._world = physicsScene.getPhysics3DWorld(); //create point to point constraint - var constraint = jsb.Physics3DPointToPointConstraint.create(rigidBody, cc.math.vec3(2.5, 2.5, 2.5)); + var constraint = new jsb.Physics3DPointToPointConstraint(rigidBody, cc.math.vec3(2.5, 2.5, 2.5)); this._world.addPhysics3DConstraint(constraint); //create hinge constraint @@ -437,7 +437,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ var mat = cc.math.mat4GetInversed(result.hitObj.getWorldTransform()); var position = cc.math.mat4TransformPoint(mat, result.hitPosition); - this._constraint = jsb.Physics3DPointToPointConstraint.create(result.hitObj, position); + this._constraint = new jsb.Physics3DPointToPointConstraint(result.hitObj, position); this._world.addPhysics3DConstraint(this._constraint, true); this._pickingDistance = cc.math.vec3Length(cc.math.vec3Sub(result.hitPosition, nearP)); return;