Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
84d38236
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
84d38236
编写于
1月 29, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
d067474c
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
492 addition
and
418 deletion
+492
-418
build/three.js
build/three.js
+121
-48
build/three.min.js
build/three.min.js
+371
-370
未找到文件。
build/three.js
浏览文件 @
84d38236
...
...
@@ -19905,6 +19905,7 @@ THREE.WebGLRenderer = function ( parameters ) {
parameters = parameters || {};
var _canvas = parameters.canvas !== undefined ? parameters.canvas : document.createElement( 'canvas' ),
_context = parameters.context !== undefined ? parameters.context : null,
_precision = parameters.precision !== undefined ? parameters.precision : 'highp',
...
...
@@ -26410,7 +26411,7 @@ THREE.WebGLRenderer = function ( parameters ) {
preserveDrawingBuffer: _preserveDrawingBuffer
};
_gl = _canvas.getContext( 'webgl', attributes ) || _canvas.getContext( 'experimental-webgl', attributes );
_gl = _c
ontext || _c
anvas.getContext( 'webgl', attributes ) || _canvas.getContext( 'experimental-webgl', attributes );
if ( _gl === null ) {
...
...
@@ -29384,6 +29385,51 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
THREE.Path.prototype.toShapes = function( isCCW ) {
function isPointInsidePolygon( inPt, inPolygon ) {
var EPSILON = 0.0000000001;
var polyLen = inPolygon.length;
// inPt on polygon contour => immediate success or
// toggling of inside/outside at every single! intersection point of an edge
// with the horizontal line through inPt, left of inPt
// not counting lowerY endpoints of edges and whole edges on that line
var inside = false;
for( var p = polyLen - 1, q = 0; q < polyLen; p = q++ ) {
var edgeLowPt = inPolygon[ p ];
var edgeHighPt = inPolygon[ q ];
var edgeDx = edgeHighPt.x - edgeLowPt.x;
var edgeDy = edgeHighPt.y - edgeLowPt.y;
if ( Math.abs(edgeDy) > EPSILON ) { // not parallel
if ( edgeDy < 0 ) {
edgeLowPt = inPolygon[ q ]; edgeDx = -edgeDx;
edgeHighPt = inPolygon[ p ]; edgeDy = -edgeDy;
}
if ( ( inPt.y < edgeLowPt.y ) || ( inPt.y > edgeHighPt.y ) ) continue;
if ( inPt.y == edgeLowPt.y ) {
if ( inPt.x == edgeLowPt.x ) return true; // inPt is on contour ?
// continue; // no intersection or edgeLowPt => doesn't count !!!
} else {
var perpEdge = edgeDy * (inPt.x - edgeLowPt.x) - edgeDx * (inPt.y - edgeLowPt.y);
if ( perpEdge == 0 ) return true; // inPt is on contour ?
if ( perpEdge < 0 ) continue;
inside = !inside; // true intersection left of inPt
}
} else { // parallel or colinear
if ( inPt.y != edgeLowPt.y ) continue; // parallel
// egde lies on the same horizontal line as inPt
if ( ( ( edgeHighPt.x <= inPt.x ) && ( inPt.x <= edgeLowPt.x ) ) ||
( ( edgeLowPt.x <= inPt.x ) && ( inPt.x <= edgeHighPt.x ) ) ) return true; // inPt: Point on contour !
// continue;
}
}
return inside;
}
var i, il, item, action, args;
var subPaths = [], lastPath = new THREE.Path();
...
...
@@ -29437,66 +29483,88 @@ THREE.Path.prototype.toShapes = function( isCCW ) {
holesFirst = isCCW ? !holesFirst : holesFirst;
// console.log("Holes first", holesFirst);
var betterShapeHoles = [];
var newShapes = [];
var newShapeHoles = [];
var mainIdx = 0;
var tmpPoints;
if ( holesFirst ) {
tmpShape = new THREE.Shape();
for ( i = 0, il = subPaths.length; i < il; i ++ ) {
newShapes[mainIdx] = undefined;
newShapeHoles[mainIdx] = [];
tmpPath = subPaths[ i ];
solid = THREE.Shape.Utils.isClockWise( tmpPath.getPoints() );
solid = isCCW ? !solid : solid;
for ( i = 0, il = subPaths.length; i < il; i ++ ) {
if ( solid ) {
tmpPath = subPaths[ i ];
tmpPoints = tmpPath.getPoints();
solid = THREE.Shape.Utils.isClockWise( tmpPoints );
solid = isCCW ? !solid : solid;
tmpShape.actions = tmpPath.actions;
tmpShape.curves = tmpPath.curves;
if ( solid ) {
shapes.push( tmpShape );
tmpShape = new THREE.Shape();
if ( (! holesFirst ) && ( newShapes[mainIdx] ) ) mainIdx++;
//console.log('cw', i);
newShapes[mainIdx] = { s: new THREE.Shape(), p: tmpPoints };
newShapes[mainIdx].s.actions = tmpPath.actions;
newShapes[mainIdx].s.curves = tmpPath.curves;
if ( holesFirst ) mainIdx++;
newShapeHoles[mainIdx] = [];
} else {
//console.log('cw', i);
tmpShape.holes.push( tmpPath );
} else {
//console.log('ccw', i
);
newShapeHoles[mainIdx].push( { h: tmpPath, p: tmpPoints[0] }
);
}
//console.log('ccw', i);
}
} else {
// Shapes first
tmpShape = undefined;
for ( i = 0, il = subPaths.length; i < il; i ++ ) {
tmpPath = subPaths[ i ];
solid = THREE.Shape.Utils.isClockWise( tmpPath.getPoints() );
solid = isCCW ? !solid : solid;
if ( solid ) {
if ( tmpShape ) shapes.push( tmpShape );
tmpShape = new THREE.Shape();
tmpShape.actions = tmpPath.actions;
tmpShape.curves = tmpPath.curves;
} else {
tmpShape.holes.push( tmpPath );
}
if ( newShapes.length > 1 ) {
var ambigious = false;
var toChange = [];
for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++ ) {
betterShapeHoles[sIdx] = [];
}
for (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++ ) {
var sh = newShapes[sIdx];
var sho = newShapeHoles[sIdx];
for (var hIdx = 0; hIdx < sho.length; hIdx++ ) {
var ho = sho[hIdx];
var hole_unassigned = true;
for (var s2Idx = 0; s2Idx < newShapes.length; s2Idx++ ) {
if ( isPointInsidePolygon( ho.p, newShapes[s2Idx].p ) ) {
if ( sIdx != s2Idx ) toChange.push( { froms: sIdx, tos: s2Idx, hole: hIdx } );
if ( hole_unassigned ) {
hole_unassigned = false;
betterShapeHoles[s2Idx].push( ho );
} else {
ambigious = true;
}
}
}
if ( hole_unassigned ) { betterShapeHoles[sIdx].push( ho ); }
}
}
// console.log("ambigious: ", ambigious);
if ( toChange.length > 0 ) {
// console.log("to change: ", toChange);
if (! ambigious) newShapeHoles = betterShapeHoles;
}
}
var tmpHoles, j, jl;
for ( i = 0, il = newShapes.length; i < il; i ++ ) {
tmpShape = newShapes[i].s;
shapes.push( tmpShape );
tmpHoles = newShapeHoles[i];
for ( j = 0, jl = tmpHoles.length; j < jl; j ++ ) {
tmpShape.holes.push( tmpHoles[j].h );
}
}
//console.log("shape", shapes);
...
...
@@ -29632,7 +29700,7 @@ THREE.Shape.Utils = {
triangulateShape: function ( contour, holes ) {
function point_in_segment_2D( inSegPt1, inSegPt2, inOtherPt ) {
function point_in_segment_2D
_colin
( inSegPt1, inSegPt2, inOtherPt ) {
// inOtherPt needs to be colinear to the inSegment
if ( inSegPt1.x != inSegPt2.x ) {
if ( inSegPt1.x < inSegPt2.x ) {
...
...
@@ -29674,7 +29742,8 @@ THREE.Shape.Utils = {
if ( ( perpSeg2 > 0 ) || ( perpSeg2 < limit ) ) return [];
}
// intersection at endpoint ?
// i.e. to reduce rounding errors
// intersection at endpoint of segment#1?
if ( perpSeg2 == 0 ) {
if ( ( inExcludeAdjacentSegs ) &&
( ( perpSeg1 == 0 ) || ( perpSeg1 == limit ) ) ) return [];
...
...
@@ -29685,6 +29754,9 @@ THREE.Shape.Utils = {
( ( perpSeg1 == 0 ) || ( perpSeg1 == limit ) ) ) return [];
return [ inSeg1Pt2 ];
}
// intersection at endpoint of segment#2?
if ( perpSeg1 == 0 ) return [ inSeg2Pt1 ];
if ( perpSeg1 == limit ) return [ inSeg2Pt2 ];
// return real intersection point
var factorSeg1 = perpSeg2 / limit;
...
...
@@ -29692,7 +29764,8 @@ THREE.Shape.Utils = {
y: inSeg1Pt1.y + factorSeg1 * seg1dy } ];
} else { // parallel or colinear
if ( perpSeg1 != 0 ) return [];
if ( ( perpSeg1 != 0 ) ||
( seg2dy * seg1seg2dx != seg2dx * seg1seg2dy ) ) return [];
// they are collinear or degenerate
var seg1Pt = ( (seg1dx == 0) && (seg1dy == 0) ); // segment1 ist just a point?
...
...
@@ -29705,12 +29778,12 @@ THREE.Shape.Utils = {
}
// segment#1 is a single point
if ( seg1Pt ) {
if (! point_in_segment_2D( inSeg2Pt1, inSeg2Pt2, inSeg1Pt1 ) ) return []; // but not in segment#2
if (! point_in_segment_2D
_colin
( inSeg2Pt1, inSeg2Pt2, inSeg1Pt1 ) ) return []; // but not in segment#2
return [ inSeg1Pt1 ];
}
// segment#2 is a single point
if ( seg2Pt ) {
if (! point_in_segment_2D( inSeg1Pt1, inSeg1Pt2, inSeg2Pt1 ) ) return []; // but not in segment#1
if (! point_in_segment_2D
_colin
( inSeg1Pt1, inSeg1Pt2, inSeg2Pt1 ) ) return []; // but not in segment#1
return [ inSeg2Pt1 ];
}
...
...
build/three.min.js
浏览文件 @
84d38236
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录