GithubHelp home page GithubHelp logo

Comments (10)

chandlerprall avatar chandlerprall commented on July 23, 2024

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.

josdirksen avatar josdirksen commented on July 23, 2024

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.

chandlerprall avatar chandlerprall commented on July 23, 2024

@josdirksen can you post the code you are using to create the constraint and add it to the scene?

from physijs.

josdirksen avatar josdirksen commented on July 23, 2024

@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.

josdirksen avatar josdirksen commented on July 23, 2024

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.

josdirksen avatar josdirksen commented on July 23, 2024

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.

yousefamar avatar yousefamar commented on July 23, 2024

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.

raimo avatar raimo commented on July 23, 2024

👍 as well

from physijs.

pietro909 avatar pietro909 commented on July 23, 2024

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.

kpgbrink avatar kpgbrink commented on July 23, 2024

I have this problem too.

from physijs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.