diff --git a/examples/canvas_geometry_subdivison.html b/examples/canvas_geometry_subdivison.html
index 15244cfd..503aeeff 100644
--- a/examples/canvas_geometry_subdivison.html
+++ b/examples/canvas_geometry_subdivison.html
@@ -24,7 +24,6 @@
-
@@ -40,8 +39,8 @@
var cube, plane;
- var targetRotation = 0;
- var targetRotationOnMouseDown = 0;
+ var targetYRotation = targetXRotation = 0;
+ var targetYRotationOnMouseDown = targetXRotationOnMouseDown = 0;
var mouseX = 0, mouseY = 0;
var mouseXOnMouseDown = 0;
@@ -113,26 +112,6 @@
}
- var modifier = new THREE.SubdivisionModifier( 3 );
-
-
-
- var createGeometry = function(i, subdivisions) {
- var params = geometriesParams[i];
-
- info.innerHTML = 'Drag to spin the geometry THREE.' + params.type
- + ' with ' + subdivisions + ' subdivisions'; //+ params.args;
-
- geometry = createSomething(THREE[params.type], params.args);
-
- geometry.mergeVertices();
- //smooth = createSubdivision(geometry, subdivisions);
- modifier.modify( geometry );
- return geometry;
- };
-
-
-
var geometriesParams = [
{type: 'CubeGeometry', args: [ 200, 200, 200, 2, 2, 2, materials ] },
@@ -149,13 +128,30 @@
];
- smooth = createGeometry(3, 2);
-
+ var modifier = new THREE.SubdivisionModifier( 2 );
+
+ var params = geometriesParams[1];
+
+ info.innerHTML = 'Drag to spin the geometry THREE.' + params.type
+ + ' with ' + modifier.subdivisions + ' subdivisions'; //+ params.args;
+
//geometry = new THREE.CubeGeometry( 200, 200, 200, 2, 2, 2, materials );
- // make sure mergeVertices(); is run to fix quick duplicated vertices
- // geometry.mergeVertices();
- // smooth = createSubdivision(geometry, 2);
+ geometry = createSomething(THREE[params.type], params.args);
+
+ // Cloning original geometry for debuging
+ smooth = geometry;
+ geometry = THREE.GeometryUtils.clone( geometry );
+
+ // mergeVertices(); is run in case of duplicated vertices
+ smooth.mergeVertices();
+ modifier.modify( smooth );
+
+
+
+
+
+
var faceABCD = "abcd";
var color, f, p, n, vertexIndex;
@@ -190,24 +186,24 @@
scene.add( group );
// Debug new Points
- // var PI2 = Math.PI * 2;
- // var program = function ( context ) {
- //
- // context.beginPath();
- // context.arc( 0, 0, 1, 0, PI2, true );
- // context.closePath();
- // context.fill();
- //
- // }
- //
- // for ( var i = 0; i < smooth.vertices.length; i++ ) {
- //
- // particle = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: Math.random() * 0x808008 + 0x808080, program: program } ) );
- // particle.position = smooth.vertices[i].position;
- // var pos = smooth.vertices.position
- // particle.scale.x = particle.scale.y = 5;
- // group.add( particle );
- // }
+ var PI2 = Math.PI * 2;
+ var program = function ( context ) {
+
+ context.beginPath();
+ context.arc( 0, 0, 1, 0, PI2, true );
+ context.closePath();
+ context.fill();
+
+ }
+
+ for ( var i = 0; i < smooth.vertices.length; i++ ) {
+
+ particle = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: Math.random() * 0x808008 + 0x808080, program: program } ) );
+ particle.position = smooth.vertices[i].position;
+ var pos = smooth.vertices.position
+ particle.scale.x = particle.scale.y = 5;
+ group.add( particle );
+ }
//Debug original points
@@ -234,8 +230,9 @@
var meshmaterials = [
- new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } ),
- new THREE.MeshBasicMaterial( { color: 0x405040, wireframe:true, opacity:0.8 } )
+ new THREE.MeshBasicMaterial( { color: 0x000000, shading: THREE.FlatShading, wireframe: true } )
+ // new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } ),
+ // new THREE.MeshBasicMaterial( { color: 0x405040, wireframe:true, opacity:0.8 } )
];
// new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } ),
@@ -256,7 +253,7 @@
cube.overdraw = true;
scene.add( cube );
- renderer = new THREE.WebGLRenderer(); // WebGLRenderer CanvasRenderer
+ renderer = new THREE.CanvasRenderer(); // WebGLRenderer CanvasRenderer
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
@@ -282,7 +279,9 @@
document.addEventListener( 'mouseout', onDocumentMouseOut, false );
mouseXOnMouseDown = event.clientX - windowHalfX;
- targetRotationOnMouseDown = targetRotation;
+ mouseYOnMouseDown = event.clientY - windowHalfY;
+ targetYRotationOnMouseDown = targetYRotation;
+ targetXRotationOnMouseDown = targetXRotation;
}
function onDocumentMouseMove( event ) {
@@ -290,7 +289,8 @@
mouseX = event.clientX - windowHalfX;
mouseY = event.clientY - windowHalfY;
- targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.02;
+ targetYRotation = targetYRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.02;
+ targetXRotation = targetXRotationOnMouseDown + ( mouseY - mouseYOnMouseDown ) * 0.02;
}
@@ -345,10 +345,10 @@
function render() {
- group.rotation.y = cube.rotation.y += ( targetRotation - cube.rotation.y ) * 0.05;
+ group.rotation.y = cube.rotation.y += ( targetYRotation - cube.rotation.y ) * 0.05;
renderer.render( scene, camera );
- cube.rotation.x = (mouseY/windowHalfY) * Math.PI;
+ group.rotation.x = cube.rotation.x += ( targetXRotation - cube.rotation.x ) * 0.05;
//console.log(cube.rotation.x);
}
diff --git a/src/extras/geometries/SubdivisionGeometry.js b/src/extras/geometries/SubdivisionGeometry.js
deleted file mode 100644
index 8c6a5807..00000000
--- a/src/extras/geometries/SubdivisionGeometry.js
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * @author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog
- * Smooth Geometry (SmoothMesh) using Catmull-Clark Subdivision Surfaces
- * Readings:
- * http://en.wikipedia.org/wiki/Catmull%E2%80%93Clark_subdivision_surface
- * http://www.rorydriscoll.com/2008/08/01/catmull-clark-subdivision-the-basics/
- */
-//
-THREE.SubdivisionGeometry = function( oldGeometry ) {
- THREE.Geometry.call( this );
-
- var scope = this;
-
- function v( x, y, z ) {
- scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
- }
-
- function f4( a, b, c, d, color, material ) {
-
- scope.faces.push( new THREE.Face4( a, b, c, d, null, color, material) );
-
- if (!supportUVs || uvForVertices.length!=0) {
- scope.faceVertexUvs[ 0 ].push( [
- uvForVertices[a],
- uvForVertices[b],
- uvForVertices[c],
- uvForVertices[d]
- ] );
-
- }
- }
-
- function edge_hash( a, b ) {
-
- return Math.min( a, b ) + "_" + Math.max( a, b );
-
- };
-
- function computeEdgeFaces( geometry ) {
-
- function addToMap( map, hash, i ) {
-
- if ( map[ hash ] === undefined ) {
-
- map[ hash ] = { "set": {}, "array": [] };
-
- }
-
- map[ hash ].set[ i ] = 1;
- map[ hash ].array.push( i );
-
- };
-
- var i, il, v1, v2, j, k,
- face, faceIndices, faceIndex,
- edge,
- hash,
- vfMap = {};
-
- // construct vertex -> face map
-
- for( i = 0, il = geometry.faces.length; i < il; i ++ ) {
-
- face = geometry.faces[ i ];
-
- if ( face instanceof THREE.Face3 ) {
-
- hash = edge_hash( face.a, face.b );
- addToMap( vfMap, hash, i );
-
- hash = edge_hash( face.b, face.c );
- addToMap( vfMap, hash, i );
-
- hash = edge_hash( face.c, face.a );
- addToMap( vfMap, hash, i );
-
- } else if ( face instanceof THREE.Face4 ) {
-
- // in WebGLRenderer quad is tesselated
- // to triangles: a,b,d / b,c,d
- // shared edge is: b,d
-
- // add edge B-D only if you wish to slice a face4
- // hash = edge_hash( face.b, face.d );
- // addToMap( vfMap, hash, i );
-
- hash = edge_hash( face.a, face.b );
- addToMap( vfMap, hash, i );
-
- hash = edge_hash( face.b, face.c );
- addToMap( vfMap, hash, i );
-
- hash = edge_hash( face.c, face.d );
- addToMap( vfMap, hash, i );
-
- hash = edge_hash( face.d, face.a );
- addToMap( vfMap, hash, i );
-
- }
-
- }
-
- // extract faces
-
-
- geometry.vfMap = vfMap;
- geometry.edges = [];
-
- var numOfEdges = 0;
- for (i in vfMap) {
- numOfEdges++;
-
- edge = vfMap[i];
- geometry.edges.push(edge.array);
-
- }
-
- //console.log('vfMap', vfMap, 'geometry.edges',geometry.edges, 'numOfEdges', numOfEdges);
-
- return vfMap;
-
- };
-
- var originalPoints = oldGeometry.vertices;
- var originalFaces = oldGeometry.faces;
-
- var newPoints = originalPoints.concat(); // Vertices
-
- var facePoints = [], edgePoints = {};
-
- var uvForVertices = [];
-
- var supportUVs = true;
-
- // Step 1
- // For each face, add a face point
- // Set each face point to be the centroid of all original points for the respective face.
-
- var i, il, j, jl, face;
-
- // For Uvs
- var uvs = oldGeometry.faceVertexUvs[0];
- var abcd = 'abcd', vertice;
-
- for (i=0, il = uvs.length; i