Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
9949be37
T
three.js
项目概览
Ablesons
/
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,发现更多精彩内容 >>
提交
9949be37
编写于
7月 14, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
34a9d6c0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
298 addition
and
218 deletion
+298
-218
build/three.js
build/three.js
+150
-71
build/three.min.js
build/three.min.js
+148
-147
未找到文件。
build/three.js
浏览文件 @
9949be37
...
...
@@ -5039,6 +5039,12 @@ THREE.Ray.prototype = {
result.subVectors( point, this.origin );
var directionDistance = result.dot( this.direction );
if ( directionDistance < 0 ) {
return this.origin.clone();
}
return result.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );
},
...
...
@@ -5050,6 +5056,15 @@ THREE.Ray.prototype = {
return function ( point ) {
var directionDistance = v1.subVectors( point, this.origin ).dot( this.direction );
// point behind the ray
if ( directionDistance < 0 ) {
return this.origin.distanceTo( point );
}
v1.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );
return v1.distanceTo( point );
...
...
@@ -5058,81 +5073,112 @@ THREE.Ray.prototype = {
}(),
distance
SqAndPointToSegment: function ( v0, v1, optionalPointOnLine
, optionalPointOnSegment ) {
distance
ToSegment: function( v0, v1, optionalPointOnRay
, optionalPointOnSegment ) {
// from http://www.geometrictools.com/LibMathematics/Distance/Wm5Dist
Line
3Segment3.cpp
// It returns the min distance between the ray
(actually... the line)
and the segment
// from http://www.geometrictools.com/LibMathematics/Distance/Wm5Dist
Ray
3Segment3.cpp
// It returns the min distance between the ray and the segment
// defined by v0 and v1
// It can also set two optional targets :
// - The closest point on the ray
(...line)
// - The closest point on the ray
// - The closest point on the segment
var segCenter = v0.clone().add( v1 ).multiplyScalar( 0.5 );
var segDir = v1.clone().sub( v0 ).normalize();
var segExtent = v0.distanceTo( v1 ) *0.5;
var segExtent = v0.distanceTo( v1 ) *
0.5;
var diff = this.origin.clone().sub( segCenter );
var a01 = -this.direction.dot( segDir );
var a01 = -
this.direction.dot( segDir );
var b0 = diff.dot( this.direction );
var b1 = - diff.dot( segDir );
var c = diff.lengthSq();
var det = Math.abs( 1 - a01 * a01 );
var b1, s0, s1, sqrDist, extDet;
var s0, s1, sqrDist, extDet;
if (det >= 0) {
if ( det >= 0 ) {
// The ray and segment are not parallel.
// The line and segment are not parallel.
b1 = -diff.dot( segDir );
s0 = a01 * b1 - b0;
s1 = a01 * b0 - b1;
extDet = segExtent * det;
if (
s1 >= -extDet
) {
if (
s0 >= 0
) {
if (
s1 <= extDet
) {
if (
s1 >= -extDet
) {
// Two interior points are closest, one on the line and one
// on the segment.
if (s1 <= extDet) {
var invDet = 1 / det;
s0 = ( a01 * b1 - b0 ) * invDet;
s1 *= invDet;
sqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;
// region 0
// Minimum at interior points of ray and segment.
} else {
var invDet = 1 / det;
s0 *= invDet;
s1 *= invDet;
sqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;
// The endpoint e1 of the segment and an interior point of
// the line are closest.
} else {
// region 1
s1 = segExtent;
s0 = - ( a01 * s1 + b0 );
s1 = segExtent;
s0 = Math.max( 0, - ( a01 * s1 + b0) );
sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
}
}
else {
// region 5
s1 = - segExtent;
s0 = Math.max( 0, - ( a01 * s1 + b0) );
sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
}
} else {
// The end point e0 of the segment and an interior point of the
// line are closest.
if ( s1 <= - extDet) {
// region 4
s0 = Math.max( 0, - ( - a01 * segExtent + b0 ) );
s1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );
sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
} else if (s1 <= extDet) {
// region 3
s0 = 0;
s1 = Math.min( Math.max( - segExtent, - b1 ), segExtent );
sqrDist = s1 * ( s1 + 2 * b1 ) + c;
} else {
// region 2
s0 = Math.max( 0, - ( a01 * segExtent + b0 ) );
s1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );
sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
s1 = - segExtent;
s0 = - ( a01 * s1 + b0 );
sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
}
}
}
else {
}
else {
// The line and segment are parallel. Choose the closest pair so that
// one point is at segment center.
// Ray and segment are parallel.
s1 =
0
;
s0 =
- b0
;
sqrDist =
b0 * s0
+ c;
s1 =
( a01 > 0 ) ? - segExtent : segExtent
;
s0 =
Math.max( 0, - ( a01 * s1 + b0 ) )
;
sqrDist =
- s0 * s0 + s1 * ( s1 + 2 * b1 )
+ c;
}
if ( optionalPointOn
Line
) {
if ( optionalPointOn
Ray
) {
optionalPointOn
Line
.copy( this.direction.clone().multiplyScalar( s0 ).add( this.origin ) );
optionalPointOn
Ray
.copy( this.direction.clone().multiplyScalar( s0 ).add( this.origin ) );
}
...
...
@@ -5154,24 +5200,26 @@ THREE.Ray.prototype = {
isIntersectionPlane: function ( plane ) {
// check if the line and plane are non-perpendicular, if they
// eventually they will intersect.
// check if the ray lies on the plane first
var d
enominator = plane.normal.dot( this.directio
n );
var d
istToPoint = plane.distanceToPoint( this.origi
n );
if ( d
enominator !
= 0 ) {
if ( d
istToPoint ==
= 0 ) {
return true;
}
// line is coplanar, return origin
if( plane.distanceToPoint( this.origin ) == 0 ) {
var denominator = plane.normal.dot( this.direction );
if ( denominator * distToPoint < 0 ) {
return true
;
return true
}
// ray origin is behind the plane (and is pointing behind it)
return false;
},
...
...
@@ -5188,14 +5236,17 @@ THREE.Ray.prototype = {
}
// Unsure if this is the correct method to handle this case.
return undefined;
// Null is preferable to undefined since undefined means.... it is undefined
return null;
}
var t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator;
return t;
// Return if the ray never intersects the plane
return t >= 0 ? t : null;
},
...
...
@@ -5203,9 +5254,9 @@ THREE.Ray.prototype = {
var t = this.distanceToPlane( plane );
if ( t ===
undefined
) {
if ( t ===
null
) {
return
undefined
;
return
null
;
}
return this.at( t, optionalTarget );
...
...
@@ -6663,11 +6714,11 @@ THREE.EventDispatcher.prototype = {
var planeDistance = localRay.distanceToPlane( facePlane );
// bail if
raycaster and plane are parallel
if (
Math.abs( planeDistance )
< precision ) continue;
// bail if
the ray is too close to the plane
if (
planeDistance
< precision ) continue;
//
if negative distance, then plane is behind raycaster
if ( planeDistance
< 0
) continue;
//
bail if the ray is behind the plane
if ( planeDistance
=== null
) continue;
// check if we hit the wrong side of a single sided face
side = material.side;
...
...
@@ -6743,11 +6794,11 @@ THREE.EventDispatcher.prototype = {
var planeDistance = localRay.distanceToPlane( facePlane );
// bail if
raycaster and plane are parallel
if (
Math.abs( planeDistance )
< precision ) continue;
// bail if
the ray is too close to the plane
if (
planeDistance
< precision ) continue;
//
if negative distance, then plane is behind raycaster
if ( planeDistance
< 0
) continue;
//
bail if the ray is behind the plane
if ( planeDistance
=== null
) continue;
// check if we hit the wrong side of a single sided face
side = material.side;
...
...
@@ -6847,18 +6898,18 @@ THREE.EventDispatcher.prototype = {
var vertices = geometry.vertices;
var nbVertices = vertices.length;
var interSegment = new THREE.Vector3();
var inter
Line
= new THREE.Vector3();
var inter
Ray
= new THREE.Vector3();
var step = object.type === THREE.LineStrip ? 1 : 2;
for ( var i = 0; i < nbVertices - 1; i = i + step ) {
localRay.distance
SqAndPointToSegment( vertices[ i ], vertices[ i + 1 ], interLine
, interSegment );
localRay.distance
ToSegment( vertices[ i ], vertices[ i + 1 ], interRay
, interSegment );
interSegment.applyMatrix4( object.matrixWorld );
inter
Line
.applyMatrix4( object.matrixWorld );
inter
Ray
.applyMatrix4( object.matrixWorld );
if ( inter
Line
.distanceToSquared( interSegment ) <= precisionSq ) {
if ( inter
Ray
.distanceToSquared( interSegment ) <= precisionSq ) {
var distance = raycaster.ray.origin.distanceTo( inter
Line
);
var distance = raycaster.ray.origin.distanceTo( inter
Ray
);
if ( raycaster.near <= distance && distance <= raycaster.far ) {
...
...
@@ -7583,6 +7634,7 @@ THREE.Projector = function () {
var getObject = function ( object ) {
_object = getNextObjectInPool();
_object.id = object.id;
_object.object = object;
if ( object.renderDepth !== null ) {
...
...
@@ -7745,6 +7797,7 @@ THREE.Projector = function () {
_face = getNextFace3InPool();
_face.id = object.id;
_face.v1.copy( v1 );
_face.v2.copy( v2 );
_face.v3.copy( v3 );
...
...
@@ -7786,6 +7839,7 @@ THREE.Projector = function () {
_face = getNextFace4InPool();
_face.id = object.id;
_face.v1.copy( v1 );
_face.v2.copy( v2 );
_face.v3.copy( v3 );
...
...
@@ -7897,6 +7951,8 @@ THREE.Projector = function () {
_clippedVertex2PositionScreen.multiplyScalar( 1 / _clippedVertex2PositionScreen.w );
_line = getNextLineInPool();
_line.id = object.id;
_line.v1.positionScreen.copy( _clippedVertex1PositionScreen );
_line.v2.positionScreen.copy( _clippedVertex2PositionScreen );
...
...
@@ -7937,10 +7993,11 @@ THREE.Projector = function () {
if ( _vector4.z > 0 && _vector4.z < 1 ) {
_particle = getNextParticleInPool();
_particle.
object = object
;
_particle.
id = object.id
;
_particle.x = _vector4.x / _vector4.w;
_particle.y = _vector4.y / _vector4.w;
_particle.z = _vector4.z;
_particle.object = object;
_particle.rotation = object.rotation.z;
...
...
@@ -8066,7 +8123,19 @@ THREE.Projector = function () {
function painterSort( a, b ) {
return b.z - a.z;
if ( a.z !== b.z ) {
return b.z - a.z;
} else if ( a.id !== b.id ) {
return a.id - b.id;
} else {
return 0;
}
}
...
...
@@ -27045,6 +27114,8 @@ THREE.RenderableVertex.prototype.copy = function ( vertex ) {
THREE.RenderableFace3 = function () {
this.id = 0;
this.v1 = new THREE.RenderableVertex();
this.v2 = new THREE.RenderableVertex();
this.v3 = new THREE.RenderableVertex();
...
...
@@ -27062,7 +27133,7 @@ THREE.RenderableFace3 = function () {
this.material = null;
this.uvs = [[]];
this.z =
null
;
this.z =
0
;
};
...
...
@@ -27072,6 +27143,8 @@ THREE.RenderableFace3 = function () {
THREE.RenderableFace4 = function () {
this.id = 0;
this.v1 = new THREE.RenderableVertex();
this.v2 = new THREE.RenderableVertex();
this.v3 = new THREE.RenderableVertex();
...
...
@@ -27090,7 +27163,7 @@ THREE.RenderableFace4 = function () {
this.material = null;
this.uvs = [[]];
this.z =
null
;
this.z =
0
;
};
...
...
@@ -27100,8 +27173,10 @@ THREE.RenderableFace4 = function () {
THREE.RenderableObject = function () {
this.id = 0;
this.object = null;
this.z =
null
;
this.z =
0
;
};
...
...
@@ -27111,11 +27186,13 @@ THREE.RenderableObject = function () {
THREE.RenderableParticle = function () {
this.id = 0;
this.object = null;
this.x =
null
;
this.y =
null
;
this.z =
null
;
this.x =
0
;
this.y =
0
;
this.z =
0
;
this.rotation = null;
this.scale = new THREE.Vector2();
...
...
@@ -27130,7 +27207,7 @@ THREE.RenderableParticle = function () {
THREE.RenderableLine = function () {
this.
z = null
;
this.
id = 0
;
this.v1 = new THREE.RenderableVertex();
this.v2 = new THREE.RenderableVertex();
...
...
@@ -27138,6 +27215,8 @@ THREE.RenderableLine = function () {
this.vertexColors = [ new THREE.Color(), new THREE.Color() ];
this.material = null;
this.z = 0;
};
/**
...
...
build/three.min.js
浏览文件 @
9949be37
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录