Comments (10)
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.
from physijs.
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.
from physijs.
@josdirksen can you post the code you are using to create the constraint and add it to the scene?
from physijs.
@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();"
from physijs.
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.
from physijs.
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.
from physijs.
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.
from physijs.
👍 as well
from physijs.
Hi there,
having the same issue: looking at the code, I saw that it is still the same.
Is there the possibility to update it?
thank you,
pietro
from physijs.
I have this problem too.
from physijs.
Related Issues (20)
- Refused to execute script (from xyz) because its MIME type ('text/js') is not executable. HOT 1
- How to deform an Physijs.SphereMesh like a WaterDrop?
- PhysijsWorker is not a constructor HOT 2
- How to move blocks out of blocks faster HOT 1
- how to load GLTF model ? HOT 2
- No updates for years, any recommendations for an alternative lib? HOT 3
- THREE.InstancedMesh is not supported
- How do I get the number of layers and roots with a mouse click HOT 1
- Objects after coming to rest are stuck in that state.
- Scenegraph Skipping collision checks - possible issue or me being silly
- How to check for an overlap event
- applyImpulse to object: vector: NaN ? HOT 1
- Use physijs to give three.js Questions about adding physical effects?
- When I used concavemesh to transform the externally introduced obj model, the browser reported an error
- Uncaught TypeError: class constructors must be invoked with 'new' when trying to create Physijs Scene HOT 3
- Vehicle physics HOT 1
- How to use it in vue-cli3?
- Döner alike fractal terrain rolled up
- Physi
- Is it possible to set restitution on objects?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from physijs.