Skip to content

Commit 9705bc0

Browse files
committed
mobius strip parametric geometry
1 parent 0339f3c commit 9705bc0

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

examples/webgl_geometries2.html

+12-1
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,24 @@
8888
// }
8989

9090
console.log(THREE.ParametricGeometries);
91-
var geo = new THREE.ParametricGeometry(20, 20, THREE.ParametricGeometries.klein);
91+
var geo;
92+
93+
94+
geo = new THREE.ParametricGeometry(20, 20, THREE.ParametricGeometries.klein);
9295
object = THREE.SceneUtils.createMultiMaterialObject( geo, materials );
9396
object.children[ 0 ].doubleSided = true;
9497
object.position.set( 0, 0, 0 );
9598
object.scale.multiplyScalar(10);
9699
scene.add( object );
97100

101+
102+
geo = new THREE.ParametricGeometry(20, 20, THREE.ParametricGeometries.mobius);
103+
object = THREE.SceneUtils.createMultiMaterialObject( geo, materials );
104+
// object.children[ 0 ].doubleSided = true;
105+
object.position.set( 10, 0, 0 );
106+
object.scale.multiplyScalar(100);
107+
scene.add( object );
108+
98109
// var geo = new THREE.ParametricGeometry(10, 10, THREE.ParametricGeometries.plane(200, 200));
99110
THREE.UVsDebug( geo );
100111
document.body.appendChild( THREE.UVsDebug( geo ));

src/extras/geometries/ParametricGeometries.js

+31
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,38 @@ THREE.ParametricGeometries = {
154154

155155
return new THREE.Vector3(x, y, z);
156156
};
157+
},
158+
159+
mobius: function(u, t) {
160+
161+
// flat mobius strip
162+
// http://www.wolframalpha.com/input/?i=M%C3%B6bius+strip+parametric+equations&lk=1&a=ClashPrefs_*Surface.MoebiusStrip.SurfaceProperty.ParametricEquations-
163+
// u = u - 0.5;
164+
// var v = 2 * pi * t;
165+
166+
// var x, y, z;
167+
168+
// var a = 2;
169+
// x = cos(v) * (a + u * cos(v/2));
170+
// y = sin(v) * (a + u * cos(v/2));
171+
// z = u * sin(v/2);
172+
// return new THREE.Vector3(x, y, z);
173+
174+
// volumetric mobius strip
175+
u *= pi;
176+
t *= 2 * pi;
177+
178+
u = u * 2
179+
var phi = u / 2
180+
var major = 2.25, a = 0.125, b = 0.65;
181+
var x, y, z;
182+
x = a * cos(t) * cos(phi) - b * sin(t) * sin(phi);
183+
z = a * cos(t) * sin(phi) + b * sin(t) * cos(phi);
184+
y = (major + x) * sin(u);
185+
x = (major + x) * cos(u);
186+
return new THREE.Vector3(x, y, z);
157187
}
188+
158189
};
159190

160191

0 commit comments

Comments
 (0)