Extrude a shape along customized curve

Description of the problem

I integrated a de Boor algorithm + casteljau (bez segments) Curve toolkit into my system (also I have different R. V. distributions implementation to generate control points smartly), which generates curve points adaptively. Now I want to extrude a shape (a series of points, not what three.js default extras/core/Curve.js defined objects), rectangles for example, along a curve, to draw lanes.

All my geometric level data are generated by parameter server (Topological Level) using Half edge based infrastructure. Hence for some well known reasons, I just use three.js for drawing in browser side, and I cannot use any algorithms provided by three.js, like quickhull, to perform computation.

As far as I know, three.js provides me ExtrudeGeomtry. But it uses three’s Curve. I want to extrude a shape along a curve (a series of points or Vector3 instances) instead of /core/Curve object.

Question

Is it possible to extend a shape from array of points or Vector3 instances?

Features 1

As far as I know, three.js provides me ExtrudeGeomtry. But it uses three’s Curve object. I want to extrude a shape along a curve (a series of points or Vector3 instances) instead of /core/Curve object.

Is it possible to extend a shape from array of points or Vector3 instances? Alternatively, if we can adapt a array of points into a Curve instance. It is good for me.

my current solution is drawing faces from scratch, but I think that it will be better if three makes customer curves easier to use.

Feature 2

Another problem is, I have concepts of curve segments internally. But I use it for navigation and location. What I need is?

(1) In which segment, the target is. Retrieve road info like speed limit, traffic signs, type (express?), etc.

(2) the segment is a whatever linked list, (what ever data structure you use), so that navigation can follow, retrace, and make decisions

Feature 3

If you want to check whether there is a hole in the geometry, simply use Euler-Poincare formula:

V - E + F - ( L - F ) = 2 ( S - G )
Three.js version
  • Dev
  • r90
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

Author: Fantashit

1 thought on “Extrude a shape along customized curve

  1. @yiakwy

    Try this:

    // Polyline3 class
    
    function Polyline3( points ) {
    
    	THREE.Curve.call( this );
    
    	// points is an array of THREE.Vector3()
    
    	this.points = points;
    
    }
    
    Polyline3.prototype = Object.create( THREE.Curve.prototype );
    Polyline3.prototype.constructor = Polyline3;
    
    // define the getPoint function for the subClass
    Polyline3.prototype.getPoint = function ( t ) {
    
    	// t is a float between 0 and 1
    
    	var points = this.points;
    
    	var d = ( points.length - 1 ) * t;
    
    	var index1 = Math.floor( d );
    	var index2 = ( index1 < points.length - 1 ) ? index1 + 1 : index1;
    
    	var pt1 = points[ index1 ];
    	var pt2 = points[ index2 ];
    
    	var weight = d - index1;
    
    	return new THREE.Vector3().copy( pt1 ).lerp( pt2, weight );
    
    };
    
    var path = new Polyline3( points );

Comments are closed.