-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception when using PointConstraint #59
Comments
What code are you using to create and add the constraint? Also, try updating to the newest version of physi.js and physijs_worker.js - there have been a couple bug fixes lately which may affect this issue. |
I'm having this same issue, with the latest code from GitHub. Uncaught TypeError: Object #<F$> has no method 'getFrameOffsetA' Do you perhaps have a working example for this constraint. The rest of the constraints I can get to work, this one, however, throws this very vague error. |
@josdirksen can you post the code you are using to create the constraint and add it to the scene? |
@chandlerprall I've tried various different ways: var baseMesh = new THREE.SphereGeometry(1);
var armMesh = new THREE.CubeGeometry(2,12,3);
var objectOne = new Physijs.BoxMesh(baseMesh,Physijs.createMaterial(
new THREE.MeshPhongMaterial({color: 0x4444ff, transparent: true, opacity:0.7}),0,0),0);
objectOne.position.z=0;
objectOne.position.x=20;
objectOne.position.y=15.5;
scene.add(objectOne);
var objectTwo = new Physijs.SphereMesh(armMesh,Physijs.createMaterial(
new THREE.MeshPhongMaterial({color: 0x4444ff, transparent: true, opacity:0.7}),0,0),10);
objectTwo.position.z=0;
objectTwo.position.x=20;
objectTwo.position.y=7.5;
scene.add(objectTwo);
// tried with two different objects, with same effect
var pointConstraint = new Physijs.PointConstraint(objectOne, objectTwo, objectTwo.position);
scene.addConstraint(pointConstraint);
// also tried with a parameter less, same effect
var pointConstraint = new Physijs.PointConstraint(objectOne, new THREE.Vector3(0,0,0));
scene.addConstraint(pointConstraint); Both result in: Uncaught TypeError: Object #<F$> has no method 'getFrameOffsetA' at Physijs_worker.js line 1342, "transform = constraint.getFrameOffsetA();" |
I've looked at a bit at the Ammo.js code and I at least understand why the error is thrown. The Point2Point constraint is defined by Module.btPoint2PointConstraint = F$; in Ammo.js. This object doesn't have the getFrameOffsetA function. In the worker thread this function is called on all the constraints in the scene to determine the origin, which is used in the reportConstraints function called from simulate. I don't know how to determine the correct offset for the point2point constraint, but this is basically the issue. |
I've done some experimenting and I can get the pointconstraint to work by changing the code (starting from line 1338) to this (ugly test code). So if there isn't a getFrameOffsetA method (which implies a point2point constraint), I just set the originX, originY and originZ to 0: for ( index in _constraints ) {
if ( _constraints.hasOwnProperty( index ) ) {
constraint = _constraints[index];
offset_body = constraint.getRigidBodyA();
if (constraint.getFrameOffsetA) {
transform = constraint.getFrameOffsetA();
origin = transform.getOrigin();
// add values to report
offset = 1 + (i++) * CONSTRAINTREPORT_ITEMSIZE;
constraintreport[ offset ] = index;
constraintreport[ offset + 1 ] = offset_body.id;
constraintreport[ offset + 2 ] = origin.getX();
constraintreport[ offset + 3 ] = origin.getY();
constraintreport[ offset + 4 ] = origin.getZ();
constraintreport[ offset + 5 ] = constraint.getAppliedImpulse();
} else {
// add values to report
offset = 1 + (i++) * CONSTRAINTREPORT_ITEMSIZE;
constraintreport[ offset ] = index;
constraintreport[ offset + 1 ] = offset_body.id;
constraintreport[ offset + 2 ] = 0;
constraintreport[ offset + 3 ] = 0;
constraintreport[ offset + 4 ] = 0;
constraintreport[ offset + 5 ] = constraint.getAppliedImpulse();
}
}
} I've tested this with the following code: function createPointToPoint() {
var obj1 = new THREE.SphereGeometry(2);
var obj2 = new THREE.SphereGeometry(2);
var objectOne = new Physijs.SphereMesh(obj1,Physijs.createMaterial(
new THREE.MeshPhongMaterial({color: 0xff4444, transparent: true, opacity:0.7}),0,0));
objectOne.position.z=-18;
objectOne.position.x=-10;
objectOne.position.y=2;
scene.add(objectOne);
var objectTwo = new Physijs.SphereMesh(obj2,Physijs.createMaterial(
new THREE.MeshPhongMaterial({color: 0xff4444, transparent: true, opacity:0.7}),0,0));
objectTwo.position.z=-5;
objectTwo.position.x=-20;
objectTwo.position.y=2;
scene.add(objectTwo);
// if no position two, its fixed to a position. Else fixed to objectTwo and both will move
var constraint = new Physijs.PointConstraint(objectOne,objectTwo, objectTwo.position);
scene.addConstraint(constraint);
} And it works as expected. The two objects are linked to one another, and whenever one moves, the other moves, keeping the distance between them the same. |
I've been having the same problem until now. Thanks for the patch, josdirksen! You should consider making a pull request since it seems to me that this is a bug that puts PointConstrants completely out of commission otherwise. |
👍 as well |
Hi there, thank you, |
I have this problem too. |
Adding a PointConstraint toe scene results in the following exception in physijs_worker.js:1006
Uncaught TypeError: Object #<F$> has no method 'getFrameOffsetA'
Not sure how to debug this.
The text was updated successfully, but these errors were encountered: