ParametricGeometry: Problem with parametric function

Hi Guys, this is my first post :slight_smile:

I got these errors “THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.” and “THREE.DirectGeometry: Faceless geometries are not supported.”

As I complied these codes:

var paraFunction = function (a, b) {
        var x = -5 + 5 * a;
        var y = -5 + 5 * b;
        var z = (Math.sin(a * Math.PI) + Math.sin(b * Math.PI)) * -7;

        return new THREE.Vector3(x, y, z); 

    }

    var paraGeometry = new THREE.ParametricGeometry(paraFunction, 8, 8);
    var paraMaterial = new THREE.MeshLambertMaterial({color: 0xF3FFE2});
    var paraMesh = new THREE.Mesh(paraGeometry, paraMaterial);
    paraMesh.position.set(0, -2, -100);
    scene.add(paraMesh);

any idea or incompatibility on the newest ThreeJS ?

2 Likes

Try it like this:

var paraFunction = function (a, b, target) {
   
   var x = -5 + 5 * a;
   var y = -5 + 5 * b;
   var z = (Math.sin(a * Math.PI) + Math.sin(b * Math.PI)) * -7;

   target.set( x, y, z );

}

The idea is to avoid object creation in each call of your function. Also have a look at the following parametric functions.

4 Likes

Hello There! Thanks it works

So my mistake was I missed the 3rd argument of the function? sorry I’m new with Three.js :slight_smile:

Yep, the third argument was recently changed from optional to mandatory.

1 Like

Thanks @Mugen87! Have a great day!

1 Like

The parametric functions link given is not working. There is a 404 error reporting.

1 Like

Fixed! Thanks for reporting.

1 Like