Skip to content

Instantly share code, notes, and snippets.

@kevinw
Created September 1, 2013 19:30
Show Gist options
  • Save kevinw/6406708 to your computer and use it in GitHub Desktop.
Save kevinw/6406708 to your computer and use it in GitHub Desktop.
diff --git a/js/roadtrip.js b/js/roadtrip.js
index d738c95..f76cfe2 100644
--- a/js/roadtrip.js
+++ b/js/roadtrip.js
@@ -346,9 +361,15 @@ function addTube(planeMesh, cb) {
function updateFromPoints(points) {
var spline = new THREE.SplineCurve3(points);
spline = layCurveOn(planeMesh, spline);
+
+ var rotMat = new THREE.Matrix4().makeRotationY(Math.PI/2);
+
var tube = roadShape().extrude({
steps: 2000,
- extrudePath: spline
+ extrudePath: spline,
+ normalCallback: function(normal) {
+ normal.crossVectors(normal, v3unitY).applyMatrix4(rotMat);
+ }
});
addGeometry(tube);
return spline;
@@ -364,6 +385,8 @@ function addTube(planeMesh, cb) {
//return updateFromPoints();
}
+var v3unitY = new THREE.Vector3(0, 1, 0);
+
function cameraAlongSpline(camera, spline, t) {
var pos = spline.getPointAt(t);
var offset = 45;
diff --git a/lib/three.js b/lib/three.js
index f549ec4..79ab1e0 100644
--- a/lib/three.js
+++ b/lib/three.js
@@ -32285,6 +32285,9 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
normal.copy( splineTube.normals[s] ).multiplyScalar( vert.x );
binormal.copy( splineTube.binormals[s] ).multiplyScalar( vert.y );
+ if (options.normalCallback)
+ options.normalCallback(normal);
+
position2.copy( extrudePts[s] ).add( normal ).add( binormal );
v( position2.x, position2.y, position2.z );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment