|
@@ -19,22 +19,22 @@
|
|
* bezelThickness: <float>, // how deep into text bezel goes
|
|
* bezelThickness: <float>, // how deep into text bezel goes
|
|
* bezelSize: <float>, // how far from text outline is bezel
|
|
* bezelSize: <float>, // how far from text outline is bezel
|
|
* }
|
|
* }
|
|
- *
|
|
|
|
- * It uses techniques used in
|
|
|
|
- *
|
|
|
|
|
|
+ *
|
|
|
|
+ * It uses techniques used in:
|
|
|
|
+ *
|
|
* typeface.js and canvastext
|
|
* typeface.js and canvastext
|
|
- * For converting fonts and rendering with javascript
|
|
|
|
|
|
+ * For converting fonts and rendering with javascript
|
|
* http://typeface.neocracy.org
|
|
* http://typeface.neocracy.org
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Triangulation ported from AS3
|
|
* Triangulation ported from AS3
|
|
* Simple Polygon Triangulation
|
|
* Simple Polygon Triangulation
|
|
* http://actionsnippet.com/?p=1462
|
|
* http://actionsnippet.com/?p=1462
|
|
*
|
|
*
|
|
- * A Method to triangulate shapes with holes
|
|
|
|
|
|
+ * A Method to triangulate shapes with holes
|
|
* http://www.sakri.net/blog/2009/06/12/an-approach-to-triangulating-polygons-with-holes/
|
|
* http://www.sakri.net/blog/2009/06/12/an-approach-to-triangulating-polygons-with-holes/
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+
|
|
THREE.TextGeometry = function ( text, parameters ) {
|
|
THREE.TextGeometry = function ( text, parameters ) {
|
|
|
|
|
|
THREE.Geometry.call( this );
|
|
THREE.Geometry.call( this );
|
|
@@ -87,8 +87,8 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
|
|
scope.vertices = [];
|
|
scope.vertices = [];
|
|
scope.faces = [];
|
|
scope.faces = [];
|
|
|
|
|
|
- var i,
|
|
|
|
- vert, vlen = vertices.length,
|
|
|
|
|
|
+ var i,
|
|
|
|
+ vert, vlen = vertices.length,
|
|
face, flen = faces.length,
|
|
face, flen = faces.length,
|
|
bezelPt, blen = bezelPoints.length;
|
|
bezelPt, blen = bezelPoints.length;
|
|
|
|
|
|
@@ -104,7 +104,7 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
|
|
// Front facing vertices
|
|
// Front facing vertices
|
|
|
|
|
|
for ( i = 0; i < vlen; i++ ) {
|
|
for ( i = 0; i < vlen; i++ ) {
|
|
-
|
|
|
|
|
|
+
|
|
vert = vertices[ i ];
|
|
vert = vertices[ i ];
|
|
v( vert.x, vert.y, height );
|
|
v( vert.x, vert.y, height );
|
|
|
|
|
|
@@ -247,13 +247,13 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
|
|
|
|
|
|
function f3( a, b, c ) {
|
|
function f3( a, b, c ) {
|
|
|
|
|
|
- scope.faces.push( new THREE.Face3( a, b, c) );
|
|
|
|
|
|
+ scope.faces.push( new THREE.Face3( a, b, c ) );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
function f4( a, b, c, d ) {
|
|
function f4( a, b, c, d ) {
|
|
|
|
|
|
- scope.faces.push( new THREE.Face4( a, b, c, d) );
|
|
|
|
|
|
+ scope.faces.push( new THREE.Face4( a, b, c, d ) );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -285,7 +285,7 @@ THREE.FontUtils = {
|
|
var ThreeFont = this;
|
|
var ThreeFont = this;
|
|
|
|
|
|
ThreeFont.faces[ family ] = ThreeFont.faces[ family ] || {};
|
|
ThreeFont.faces[ family ] = ThreeFont.faces[ family ] || {};
|
|
-
|
|
|
|
|
|
+
|
|
ThreeFont.faces[ family ][ data.cssFontWeight ] = ThreeFont.faces[ family ][ data.cssFontWeight ] || {};
|
|
ThreeFont.faces[ family ][ data.cssFontWeight ] = ThreeFont.faces[ family ][ data.cssFontWeight ] || {};
|
|
ThreeFont.faces[ family ][ data.cssFontWeight ][ data.cssFontStyle ] = data;
|
|
ThreeFont.faces[ family ][ data.cssFontWeight ][ data.cssFontStyle ] = data;
|
|
|
|
|
|
@@ -358,7 +358,7 @@ THREE.FontUtils = {
|
|
firstPt = all[ firstIndex ];
|
|
firstPt = all[ firstIndex ];
|
|
endPt = all.slice( firstIndex + 1 ).indexOf( firstPt ) + firstIndex;
|
|
endPt = all.slice( firstIndex + 1 ).indexOf( firstPt ) + firstIndex;
|
|
|
|
|
|
- if ( endPt <= firstIndex ) break;
|
|
|
|
|
|
+ if ( endPt <= firstIndex ) break;
|
|
|
|
|
|
var contours = singleCharPoints.slice( firstIndex, endPt + 1 );
|
|
var contours = singleCharPoints.slice( firstIndex, endPt + 1 );
|
|
|
|
|
|
@@ -472,7 +472,7 @@ THREE.FontUtils = {
|
|
prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1;
|
|
prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1;
|
|
nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0;
|
|
nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0;
|
|
|
|
|
|
- prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1;
|
|
|
|
|
|
+ prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1;
|
|
nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ;
|
|
nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ;
|
|
|
|
|
|
var areaapts = [];
|
|
var areaapts = [];
|
|
@@ -495,7 +495,7 @@ THREE.FontUtils = {
|
|
var oldShapeIndex = shapeIndex, oldHoleIndex = holeIndex;
|
|
var oldShapeIndex = shapeIndex, oldHoleIndex = holeIndex;
|
|
shapeIndex += shapeOffset;
|
|
shapeIndex += shapeOffset;
|
|
holeIndex += holeOffset;
|
|
holeIndex += holeOffset;
|
|
-
|
|
|
|
|
|
+
|
|
if ( shapeIndex < 0 ) { shapeIndex += shape.length; }
|
|
if ( shapeIndex < 0 ) { shapeIndex += shape.length; }
|
|
shapeIndex %= shape.length;
|
|
shapeIndex %= shape.length;
|
|
|
|
|
|
@@ -505,7 +505,7 @@ THREE.FontUtils = {
|
|
prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1;
|
|
prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1;
|
|
nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0;
|
|
nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0;
|
|
|
|
|
|
- prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1;
|
|
|
|
|
|
+ prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1;
|
|
nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ;
|
|
nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ;
|
|
|
|
|
|
|
|
|
|
@@ -538,7 +538,7 @@ THREE.FontUtils = {
|
|
prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1;
|
|
prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1;
|
|
nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0;
|
|
nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0;
|
|
|
|
|
|
- prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1;
|
|
|
|
|
|
+ prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1;
|
|
nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ;
|
|
nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ;
|
|
|
|
|
|
}
|
|
}
|
|
@@ -563,7 +563,7 @@ THREE.FontUtils = {
|
|
shapeGroup.shape = shape;
|
|
shapeGroup.shape = shape;
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
var triangulatedPoints = [];
|
|
var triangulatedPoints = [];
|
|
var triangulatedFaces = [];
|
|
var triangulatedFaces = [];
|
|
var lastTriangles = 0;
|
|
var lastTriangles = 0;
|
|
@@ -593,7 +593,7 @@ THREE.FontUtils = {
|
|
lastTriangles += shape.length;
|
|
lastTriangles += shape.length;
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
// Now we push the "cut" vertices back to the triangulated indices.
|
|
// Now we push the "cut" vertices back to the triangulated indices.
|
|
|
|
|
|
@@ -660,20 +660,23 @@ THREE.FontUtils = {
|
|
var i, p,
|
|
var i, p,
|
|
face = this.getFace(),
|
|
face = this.getFace(),
|
|
scale = this.size / face.resolution,
|
|
scale = this.size / face.resolution,
|
|
- offset = 0,
|
|
|
|
- chars = String( text ).split( '' ),
|
|
|
|
|
|
+ offset = 0,
|
|
|
|
+ chars = String( text ).split( '' ),
|
|
length = chars.length;
|
|
length = chars.length;
|
|
|
|
|
|
|
|
+ var fontPaths = [];
|
|
|
|
+
|
|
for ( i = 0; i < length; i++ ) {
|
|
for ( i = 0; i < length; i++ ) {
|
|
|
|
|
|
var ret = this.extractGlyphPoints( chars[ i ], face, scale, offset );
|
|
var ret = this.extractGlyphPoints( chars[ i ], face, scale, offset );
|
|
offset += ret.offset;
|
|
offset += ret.offset;
|
|
characterPts.push( ret.points );
|
|
characterPts.push( ret.points );
|
|
allPts = allPts.concat( ret.points );
|
|
allPts = allPts.concat( ret.points );
|
|
|
|
+ fontPaths.push( ret.path );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- // get the width
|
|
|
|
|
|
+ // get the width
|
|
|
|
|
|
var width = offset / 2;
|
|
var width = offset / 2;
|
|
|
|
|
|
@@ -849,6 +852,8 @@ THREE.FontUtils = {
|
|
extractGlyphPoints : function( c, face, scale, offset ) {
|
|
extractGlyphPoints : function( c, face, scale, offset ) {
|
|
|
|
|
|
var pts = [];
|
|
var pts = [];
|
|
|
|
+ var path = new THREE.Path();
|
|
|
|
+
|
|
|
|
|
|
var i, i2,
|
|
var i, i2,
|
|
outline, action, length,
|
|
outline, action, length,
|
|
@@ -856,21 +861,21 @@ THREE.FontUtils = {
|
|
x, y, cpx, cpy, cpx0, cpy0, cpx1, cpy1, cpx2, cpy2,
|
|
x, y, cpx, cpy, cpx0, cpy0, cpx1, cpy1, cpx2, cpy2,
|
|
laste,
|
|
laste,
|
|
glyph = face.glyphs[ c ] || face.glyphs[ ctxt.options.fallbackCharacter ];
|
|
glyph = face.glyphs[ c ] || face.glyphs[ ctxt.options.fallbackCharacter ];
|
|
-
|
|
|
|
|
|
+
|
|
if ( !glyph ) return;
|
|
if ( !glyph ) return;
|
|
-
|
|
|
|
|
|
+
|
|
if ( glyph.o ) {
|
|
if ( glyph.o ) {
|
|
-
|
|
|
|
|
|
+
|
|
outline = glyph._cachedOutline || ( glyph._cachedOutline = glyph.o.split( ' ' ) );
|
|
outline = glyph._cachedOutline || ( glyph._cachedOutline = glyph.o.split( ' ' ) );
|
|
length = outline.length;
|
|
length = outline.length;
|
|
-
|
|
|
|
|
|
+
|
|
scaleX = scale;
|
|
scaleX = scale;
|
|
scaleY = scale;
|
|
scaleY = scale;
|
|
-
|
|
|
|
|
|
+
|
|
for ( i = 0; i < length; ) {
|
|
for ( i = 0; i < length; ) {
|
|
|
|
|
|
action = outline[ i++ ];
|
|
action = outline[ i++ ];
|
|
-
|
|
|
|
|
|
+
|
|
switch( action ) {
|
|
switch( action ) {
|
|
|
|
|
|
case 'm':
|
|
case 'm':
|
|
@@ -880,6 +885,8 @@ THREE.FontUtils = {
|
|
x = outline[ i++ ] * scaleX + offset;
|
|
x = outline[ i++ ] * scaleX + offset;
|
|
y = outline[ i++ ] * scaleY;
|
|
y = outline[ i++ ] * scaleY;
|
|
pts.push( new THREE.Vector2( x, y ) );
|
|
pts.push( new THREE.Vector2( x, y ) );
|
|
|
|
+
|
|
|
|
+ path.moveTo(x,y);
|
|
break;
|
|
break;
|
|
|
|
|
|
case 'l':
|
|
case 'l':
|
|
@@ -889,24 +896,27 @@ THREE.FontUtils = {
|
|
x = outline[ i++ ] * scaleX + offset;
|
|
x = outline[ i++ ] * scaleX + offset;
|
|
y = outline[ i++ ] * scaleY;
|
|
y = outline[ i++ ] * scaleY;
|
|
pts.push( new THREE.Vector2( x, y ) );
|
|
pts.push( new THREE.Vector2( x, y ) );
|
|
|
|
+ path.lineTo(x,y);
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
case 'q':
|
|
case 'q':
|
|
|
|
|
|
// QuadraticCurveTo
|
|
// QuadraticCurveTo
|
|
-
|
|
|
|
|
|
+
|
|
cpx = outline[ i++ ] * scaleX + offset;
|
|
cpx = outline[ i++ ] * scaleX + offset;
|
|
cpy = outline[ i++ ] * scaleY;
|
|
cpy = outline[ i++ ] * scaleY;
|
|
cpx1 = outline[ i++ ] * scaleX + offset;
|
|
cpx1 = outline[ i++ ] * scaleX + offset;
|
|
cpy1 = outline[ i++ ] * scaleY;
|
|
cpy1 = outline[ i++ ] * scaleY;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ path.quadraticCurveTo(cpx1, cpy1, cpx, cpy);
|
|
|
|
+
|
|
laste = pts[ pts.length - 1 ];
|
|
laste = pts[ pts.length - 1 ];
|
|
-
|
|
|
|
|
|
+
|
|
if ( laste ) {
|
|
if ( laste ) {
|
|
|
|
|
|
cpx0 = laste.x;
|
|
cpx0 = laste.x;
|
|
cpy0 = laste.y;
|
|
cpy0 = laste.y;
|
|
-
|
|
|
|
|
|
+
|
|
for ( i2 = 1, divisions = this.divisions; i2 <= divisions; i2++ ) {
|
|
for ( i2 = 1, divisions = this.divisions; i2 <= divisions; i2++ ) {
|
|
|
|
|
|
var t = i2 / divisions;
|
|
var t = i2 / divisions;
|
|
@@ -916,28 +926,30 @@ THREE.FontUtils = {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
break;
|
|
break;
|
|
|
|
|
|
case 'b':
|
|
case 'b':
|
|
|
|
|
|
// Cubic Bezier Curve
|
|
// Cubic Bezier Curve
|
|
-
|
|
|
|
|
|
+
|
|
cpx = outline[ i++ ] * scaleX + offset;
|
|
cpx = outline[ i++ ] * scaleX + offset;
|
|
cpy = outline[ i++ ] * scaleY;
|
|
cpy = outline[ i++ ] * scaleY;
|
|
cpx1 = outline[ i++ ] * scaleX + offset;
|
|
cpx1 = outline[ i++ ] * scaleX + offset;
|
|
cpy1 = outline[ i++ ] * -scaleY;
|
|
cpy1 = outline[ i++ ] * -scaleY;
|
|
cpx2 = outline[ i++ ] * scaleX + offset;
|
|
cpx2 = outline[ i++ ] * scaleX + offset;
|
|
cpy2 = outline[ i++ ] * -scaleY;
|
|
cpy2 = outline[ i++ ] * -scaleY;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ path.quadraticCurveTo( cpx, cpy, cpx1, cpy1, cpx2, cpy2 );
|
|
|
|
+
|
|
laste = pts[ pts.length - 1 ];
|
|
laste = pts[ pts.length - 1 ];
|
|
-
|
|
|
|
|
|
+
|
|
if ( laste ) {
|
|
if ( laste ) {
|
|
|
|
|
|
cpx0 = laste.x;
|
|
cpx0 = laste.x;
|
|
cpy0 = laste.y;
|
|
cpy0 = laste.y;
|
|
-
|
|
|
|
|
|
+
|
|
for ( i2 = 1, divisions = this.divisions; i2 <= divisions; i2++ ) {
|
|
for ( i2 = 1, divisions = this.divisions; i2 <= divisions; i2++ ) {
|
|
|
|
|
|
var t = i2 / divisions;
|
|
var t = i2 / divisions;
|
|
@@ -956,7 +968,10 @@ THREE.FontUtils = {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return { offset: glyph.ha*scale, points:pts };
|
|
|
|
|
|
+ path.debug(document.getElementById("boo"));
|
|
|
|
+ console.log(path);
|
|
|
|
+
|
|
|
|
+ return { offset: glyph.ha*scale, points:pts, path:path};
|
|
}
|
|
}
|
|
|
|
|
|
};
|
|
};
|
|
@@ -964,17 +979,17 @@ THREE.FontUtils = {
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * This code is a quick port of code written in C++ which was submitted to
|
|
|
|
- * flipcode.com by John W. Ratcliff // July 22, 2000
|
|
|
|
|
|
+ * This code is a quick port of code written in C++ which was submitted to
|
|
|
|
+ * flipcode.com by John W. Ratcliff // July 22, 2000
|
|
* See original code and more information here:
|
|
* See original code and more information here:
|
|
* http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml
|
|
* http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml
|
|
- *
|
|
|
|
|
|
+ *
|
|
* ported to actionscript by Zevan Rosser
|
|
* ported to actionscript by Zevan Rosser
|
|
* www.actionsnippet.com
|
|
* www.actionsnippet.com
|
|
- *
|
|
|
|
|
|
+ *
|
|
* ported to javascript by Joshua Koo
|
|
* ported to javascript by Joshua Koo
|
|
* http://www.lab4games.net/zz85/blog
|
|
* http://www.lab4games.net/zz85/blog
|
|
- *
|
|
|
|
|
|
+ *
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
@@ -982,7 +997,7 @@ THREE.FontUtils = {
|
|
|
|
|
|
var EPSILON = 0.0000000001;
|
|
var EPSILON = 0.0000000001;
|
|
|
|
|
|
- // takes in an contour array and returns
|
|
|
|
|
|
+ // takes in an contour array and returns
|
|
|
|
|
|
var process = function( contour, indices ) {
|
|
var process = function( contour, indices ) {
|
|
|
|
|
|
@@ -991,7 +1006,7 @@ THREE.FontUtils = {
|
|
if ( n < 3 ) return null;
|
|
if ( n < 3 ) return null;
|
|
|
|
|
|
var result = [],
|
|
var result = [],
|
|
- verts = [],
|
|
|
|
|
|
+ verts = [],
|
|
vertIndices = [];
|
|
vertIndices = [];
|
|
|
|
|
|
/* we want a counter-clockwise polygon in verts */
|
|
/* we want a counter-clockwise polygon in verts */
|
|
@@ -1024,7 +1039,7 @@ THREE.FontUtils = {
|
|
|
|
|
|
//throw ( "Warning, unable to triangulate polygon!" );
|
|
//throw ( "Warning, unable to triangulate polygon!" );
|
|
//return null;
|
|
//return null;
|
|
-
|
|
|
|
|
|
+ // Sometimes warning is fine, especially polygons are triangulated in reverse.
|
|
console.log( "Warning, unable to triangulate polygon!" );
|
|
console.log( "Warning, unable to triangulate polygon!" );
|
|
|
|
|
|
if ( indices ) return vertIndices;
|
|
if ( indices ) return vertIndices;
|
|
@@ -1033,19 +1048,19 @@ THREE.FontUtils = {
|
|
}
|
|
}
|
|
|
|
|
|
/* three consecutive vertices in current polygon, <u,v,w> */
|
|
/* three consecutive vertices in current polygon, <u,v,w> */
|
|
-
|
|
|
|
|
|
+
|
|
u = v; if ( nv <= u ) u = 0; /* previous */
|
|
u = v; if ( nv <= u ) u = 0; /* previous */
|
|
v = u + 1; if ( nv <= v ) v = 0; /* new v */
|
|
v = u + 1; if ( nv <= v ) v = 0; /* new v */
|
|
w = v + 1; if ( nv <= w ) w = 0; /* next */
|
|
w = v + 1; if ( nv <= w ) w = 0; /* next */
|
|
-
|
|
|
|
|
|
+
|
|
if ( snip( contour, u, v, w, nv, verts ) ) {
|
|
if ( snip( contour, u, v, w, nv, verts ) ) {
|
|
|
|
|
|
var a, b, c, s, t;
|
|
var a, b, c, s, t;
|
|
-
|
|
|
|
|
|
+
|
|
/* true names of the vertices */
|
|
/* true names of the vertices */
|
|
|
|
|
|
- a = verts[ u ];
|
|
|
|
- b = verts[ v ];
|
|
|
|
|
|
+ a = verts[ u ];
|
|
|
|
+ b = verts[ v ];
|
|
c = verts[ w ];
|
|
c = verts[ w ];
|
|
|
|
|
|
/* output Triangle */
|
|
/* output Triangle */
|
|
@@ -1055,17 +1070,17 @@ THREE.FontUtils = {
|
|
result.push( contour[ c ] );
|
|
result.push( contour[ c ] );
|
|
|
|
|
|
vertIndices.push( [ verts[ u ], verts[ v ], verts[ w ] ] );
|
|
vertIndices.push( [ verts[ u ], verts[ v ], verts[ w ] ] );
|
|
-
|
|
|
|
|
|
+
|
|
/* remove v from the remaining polygon */
|
|
/* remove v from the remaining polygon */
|
|
|
|
|
|
for( s = v, t = v + 1; t < nv; s++, t++ ) {
|
|
for( s = v, t = v + 1; t < nv; s++, t++ ) {
|
|
-
|
|
|
|
- verts[ s ] = verts[ t ];
|
|
|
|
|
|
+
|
|
|
|
+ verts[ s ] = verts[ t ];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
nv--;
|
|
nv--;
|
|
-
|
|
|
|
|
|
+
|
|
/* reset error detection counter */
|
|
/* reset error detection counter */
|
|
|
|
|
|
count = 2 * nv;
|
|
count = 2 * nv;
|
|
@@ -1073,19 +1088,19 @@ THREE.FontUtils = {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if ( indices ) return vertIndices;
|
|
if ( indices ) return vertIndices;
|
|
return result;
|
|
return result;
|
|
|
|
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
// calculate area of the contour polygon
|
|
// calculate area of the contour polygon
|
|
|
|
|
|
var area = function ( contour ) {
|
|
var area = function ( contour ) {
|
|
|
|
|
|
var n = contour.length;
|
|
var n = contour.length;
|
|
var a = 0.0;
|
|
var a = 0.0;
|
|
-
|
|
|
|
|
|
+
|
|
for( var p = n - 1, q = 0; q < n; p = q++ ) {
|
|
for( var p = n - 1, q = 0; q < n; p = q++ ) {
|
|
|
|
|
|
a += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y;
|
|
a += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y;
|
|
@@ -1095,7 +1110,7 @@ THREE.FontUtils = {
|
|
return a * 0.5;
|
|
return a * 0.5;
|
|
|
|
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
// see if p is inside triangle abc
|
|
// see if p is inside triangle abc
|
|
|
|
|
|
var insideTriangle = function( ax, ay,
|
|
var insideTriangle = function( ax, ay,
|
|
@@ -1107,23 +1122,23 @@ THREE.FontUtils = {
|
|
var cX, cY, apx, apy;
|
|
var cX, cY, apx, apy;
|
|
var bpx, bpy, cpx, cpy;
|
|
var bpx, bpy, cpx, cpy;
|
|
var cCROSSap, bCROSScp, aCROSSbp;
|
|
var cCROSSap, bCROSScp, aCROSSbp;
|
|
-
|
|
|
|
|
|
+
|
|
aX = cx - bx; aY = cy - by;
|
|
aX = cx - bx; aY = cy - by;
|
|
bX = ax - cx; bY = ay - cy;
|
|
bX = ax - cx; bY = ay - cy;
|
|
cX = bx - ax; cY = by - ay;
|
|
cX = bx - ax; cY = by - ay;
|
|
apx= px -ax; apy= py - ay;
|
|
apx= px -ax; apy= py - ay;
|
|
bpx= px - bx; bpy= py - by;
|
|
bpx= px - bx; bpy= py - by;
|
|
cpx= px - cx; cpy= py - cy;
|
|
cpx= px - cx; cpy= py - cy;
|
|
-
|
|
|
|
|
|
+
|
|
aCROSSbp = aX*bpy - aY*bpx;
|
|
aCROSSbp = aX*bpy - aY*bpx;
|
|
cCROSSap = cX*apy - cY*apx;
|
|
cCROSSap = cX*apy - cY*apx;
|
|
bCROSScp = bX*cpy - bY*cpx;
|
|
bCROSScp = bX*cpy - bY*cpx;
|
|
-
|
|
|
|
|
|
+
|
|
return ( (aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0) );
|
|
return ( (aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0) );
|
|
|
|
|
|
};
|
|
};
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
var snip = function ( contour, u, v, w, n, verts ) {
|
|
var snip = function ( contour, u, v, w, n, verts ) {
|
|
|
|
|
|
var p;
|
|
var p;
|
|
@@ -1138,13 +1153,13 @@ THREE.FontUtils = {
|
|
|
|
|
|
cx = contour[ verts[ w ] ].x;
|
|
cx = contour[ verts[ w ] ].x;
|
|
cy = contour[ verts[ w ] ].y;
|
|
cy = contour[ verts[ w ] ].y;
|
|
-
|
|
|
|
|
|
+
|
|
if ( EPSILON > (((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))) ) return false;
|
|
if ( EPSILON > (((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))) ) return false;
|
|
-
|
|
|
|
|
|
+
|
|
for ( p = 0; p < n; p++ ) {
|
|
for ( p = 0; p < n; p++ ) {
|
|
|
|
|
|
if( (p == u) || (p == v) || (p == w) ) continue;
|
|
if( (p == u) || (p == v) || (p == w) ) continue;
|
|
-
|
|
|
|
|
|
+
|
|
px = contour[ verts[ p ] ].x
|
|
px = contour[ verts[ p ] ].x
|
|
py = contour[ verts[ p ] ].y
|
|
py = contour[ verts[ p ] ].y
|
|
|
|
|
|
@@ -1155,11 +1170,11 @@ THREE.FontUtils = {
|
|
return true;
|
|
return true;
|
|
|
|
|
|
};
|
|
};
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
namespace.Triangulate = process;
|
|
namespace.Triangulate = process;
|
|
namespace.Triangulate.area = area;
|
|
namespace.Triangulate.area = area;
|
|
-
|
|
|
|
|
|
+
|
|
return namespace;
|
|
return namespace;
|
|
|
|
|
|
})(THREE.FontUtils);
|
|
})(THREE.FontUtils);
|