ParametricGeometry, can't make prototype

I’m here making the prototype for all the geometries.
https://openage.org/it/3d/index.html
Might need to refresh.

I’m in the parametric one. And I can’t seem to make the prototype.

The code I have is the following:

mthreejs_api.prototype.geometry_parametric=function(object){
    var radial_wave=function(u,v){
        var r=50;
        var x=Math.sin(u) * r;
        var z=Math.sin(v / 2) * 2 * r;
        var y=(Math.sin(u * 4 * Math.PI) + Math.cos(v * 2 * Math.PI)) * 2.8;

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

    var geometry=new ParametricGeometry(radial_wave, 100, 100, false);

    return geometry;
    } ;

It doesn’t give an error but the Parametric prototype isn’t appearing in the simulation.

I’m looking at the following directions:

https://threejs.org/docs/#examples/en/geometries/ParametricGeometry

Does anybody know what could be causing it not to appear?

Also, it would really be helpful if they provided a runable example on the website.
I don’t get THREE.ParametricGeometries.klein.
Gives error.

Solution: three.js dev template - module - JSFiddle - Code Playground

Your parametric function is missing a third target parameter. It should look like so:

function radialWave( u, v, target ) {

  const r = 10;
  const x = Math.sin( u ) * r;
  const z = Math.sin( v / 2 ) * 2 * r;
  const y = ( Math.sin( u * 4 * Math.PI ) + Math.cos( v * 2 * Math.PI ) ) * 2.8;

  return target.set( x, y, z );

}
2 Likes