Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
15899cce
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,发现更多精彩内容 >>
提交
15899cce
编写于
7月 12, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
3ae91fef
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
425 addition
and
339 deletion
+425
-339
build/three.js
build/three.js
+162
-79
build/three.min.js
build/three.min.js
+263
-260
未找到文件。
build/three.js
浏览文件 @
15899cce
...
...
@@ -5058,6 +5058,66 @@ THREE.Ray.prototype = {
}(),
distanceSqAndPointToSegment: function( v0, v1, optionalPointOnLine, optionalPointOnSegment ) {
// from http://www.geometrictools.com/LibMathematics/Distance/Wm5DistLine3Segment3.cpp
// It returns the min distance between the ray (actually... the line) 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 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 diff = this.origin.clone().sub( segCenter );
var a01 = -this.direction.dot( segDir );
var b0 = diff.dot( this.direction );
var c = diff.lengthSq();
var det = Math.abs( 1 - a01 * a01 );
var b1, s0, s1, sqrDist, extDet;
if( det >= 0 ) {
// The line and segment are not parallel.
b1 = -diff.dot( segDir );
s1 = a01 * b0 - b1;
extDet = segExtent * det;
if( s1 >= -extDet ) {
if( s1 <= extDet ) {
// Two interior points are closest, one on the line and one
// on the segment.
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;
}
else {
// The endpoint e1 of the segment and an interior point of
// the line are closest.
s1 = segExtent;
s0 = - ( 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.
s1 = - segExtent;
s0 = - ( a01 * s1 + b0 );
sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
}
}
else {
// The line and segment are parallel. Choose the closest pair so that
// one point is at segment center.
s1 = 0;
s0 = - b0;
sqrDist = b0 * s0 + c;
}
if(optionalPointOnLine)
optionalPointOnLine.copy( this.direction.clone().multiplyScalar( s0 ).add( this.origin ) );
if(optionalPointOnSegment)
optionalPointOnSegment.copy( segDir.clone().multiplyScalar( s1 ).add( segCenter ) );
return sqrDist;
},
isIntersectionSphere: function( sphere ) {
return ( this.distanceToPoint( sphere.center ) <= sphere.radius );
...
...
@@ -5364,12 +5424,17 @@ THREE.Frustum.prototype = {
// this method is expanded inlined for performance reasons.
var geometry = object.geometry;
var matrix = object.matrixWorld;
var planes = this.planes;
var negRadius = - object.geometry.boundingSphere.radius * matrix.getMaxScaleOnAxis();
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
var negRadius = - geometry.boundingSphere.radius * matrix.getMaxScaleOnAxis();
center.getPositionFromMatrix( matrix );
var planes = this.planes;
for ( var i = 0; i < 6; i ++ ) {
var distance = planes[ i ].distanceToPoint( center );
...
...
@@ -6432,9 +6497,14 @@ THREE.EventDispatcher.prototype = {
} else if (object instanceof THREE.Mesh ) {
var geometry = object.geometry;
// Checking boundingSphere distance to ray
matrixPosition.getPositionFromMatrix( object.matrixWorld );
sphere.set( matrixPosition, object.geometry.boundingSphere.radius * object.matrixWorld.getMaxScaleOnAxis() );
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
sphere.set( matrixPosition, geometry.boundingSphere.radius * object.matrixWorld.getMaxScaleOnAxis() );
if ( raycaster.ray.isIntersectionSphere( sphere ) === false ) {
...
...
@@ -6442,7 +6512,6 @@ THREE.EventDispatcher.prototype = {
}
var geometry = object.geometry;
var vertices = geometry.vertices;
if ( geometry instanceof THREE.BufferGeometry ) {
...
...
@@ -6637,6 +6706,58 @@ THREE.EventDispatcher.prototype = {
}
} else if (object instanceof THREE.Line) {
var precision = raycaster.linePrecision;
if(precision < 0)
return intersects;
var precisionSq = precision * precision;
var geometry = object.geometry;
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
// Checking boundingSphere distance to ray
matrixPosition.getPositionFromMatrix(object.matrixWorld);
sphere.set(matrixPosition, geometry.boundingSphere.radius * object.matrixWorld.getMaxScaleOnAxis());
if(!raycaster.ray.isIntersectionSphere(sphere))
return intersects;
inverseMatrix.getInverse(object.matrixWorld);
localRay.copy(raycaster.ray).applyMatrix4(inverseMatrix);
localRay.direction.normalize(); // for scale matrix
var vertices = geometry.vertices;
var nbVertices = vertices.length;
var interSegment = new THREE.Vector3();
var interLine = new THREE.Vector3();
var step = object.type === THREE.LineStrip ? 1 : 2;
for(var i = 0; i < nbVertices - 1; i=i+step) {
localRay.distanceSqAndPointToSegment(vertices[i], vertices[i + 1], interLine, interSegment);
interSegment.applyMatrix4(object.matrixWorld);
interLine.applyMatrix4(object.matrixWorld);
if(interLine.distanceToSquared(interSegment) <= precisionSq) {
var distance = raycaster.ray.origin.distanceTo(interLine);
if(raycaster.near <= distance && distance <= raycaster.far) {
intersects.push( {
distance: distance,
point: interSegment.clone(),
face: null,
faceIndex: null,
object: object
} );
}
}
}
}
};
...
...
@@ -6655,6 +6776,7 @@ THREE.EventDispatcher.prototype = {
//
THREE.Raycaster.prototype.precision = 0.0001;
THREE.Raycaster.prototype.linePrecision = -1; // if negative, we don't pick lines
THREE.Raycaster.prototype.set = function ( origin, direction ) {
...
...
@@ -6719,7 +6841,8 @@ THREE.EventDispatcher.prototype = {
THREE.Object3D = function () {
this.id = THREE.Math.generateUUID();
this.id = THREE.Object3DIdCount ++;
this.uuid = THREE.Math.generateUUID();
this.name = '';
...
...
@@ -7253,7 +7376,7 @@ THREE.Object3D.prototype = {
};
THREE.Object3D
.defaultEulerOrder = 'XYZ'
;
THREE.Object3D
IdCount = 0
;
/**
* @author mrdoob / http://mrdoob.com/
...
...
@@ -8006,7 +8129,8 @@ THREE.Face4.prototype = {
THREE.Geometry = function () {
this.id = THREE.Math.generateUUID();
this.id = THREE.GeometryIdCount ++;
this.uuid = THREE.Math.generateUUID();
this.name = '';
...
...
@@ -8812,13 +8936,16 @@ THREE.Geometry.prototype = {
};
THREE.GeometryIdCount = 0;
/**
* @author alteredq / http://alteredqualia.com/
*/
THREE.BufferGeometry = function () {
this.id = THREE.Math.generateUUID();
this.id = THREE.GeometryIdCount ++;
this.uuid = THREE.Math.generateUUID();
// attributes
...
...
@@ -10505,6 +10632,7 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) {
geometry.computeCentroids();
geometry.computeFaceNormals();
geometry.computeBoundingSphere();
function parseModel( scale ) {
...
...
@@ -11201,10 +11329,11 @@ THREE.ObjectLoader.prototype = {
}
if ( data.id !== undefined ) geometry.id = data.id;
geometry.uuid = data.uuid;
if ( data.name !== undefined ) geometry.name = data.name;
geometries[ data.id ] = geometry;
geometries[ data.
uu
id ] = geometry;
}
...
...
@@ -11227,10 +11356,11 @@ THREE.ObjectLoader.prototype = {
var data = json[ i ];
var material = loader.parse( data );
if ( data.id !== undefined ) material.id = data.id;
material.uuid = data.uuid;
if ( data.name !== undefined ) material.name = data.name;
materials[ data.id ] = material;
materials[ data.
uu
id ] = material;
}
...
...
@@ -11325,6 +11455,9 @@ THREE.ObjectLoader.prototype = {
}
object.uuid = data.uuid;
if ( data.name !== undefined ) object.name = data.name;
if ( data.matrix !== undefined ) {
matrix.fromArray( data.matrix );
...
...
@@ -11338,8 +11471,6 @@ THREE.ObjectLoader.prototype = {
}
if ( data.id !== undefined ) object.id = data.id;
if ( data.name !== undefined ) object.name = data.name;
if ( data.visible !== undefined ) object.visible = data.visible;
if ( data.userData !== undefined ) object.userData = data.userData;
...
...
@@ -12638,7 +12769,8 @@ THREE.TextureLoader.prototype = {
THREE.Material = function () {
this.id = THREE.Math.generateUUID();
this.id = THREE.MaterialIdCount ++;
this.uuid = THREE.Math.generateUUID();
this.name = '';
...
...
@@ -12765,6 +12897,8 @@ THREE.Material.prototype = {
};
THREE.MaterialIdCount = 0;
/**
* @author mrdoob / http://mrdoob.com/
* @author alteredq / http://alteredqualia.com/
...
...
@@ -13692,7 +13826,8 @@ THREE.SpriteAlignment.bottomRight = new THREE.Vector2( -1, 1 );
THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
this.id = THREE.Math.generateUUID();
this.id = THREE.TextureIdCount ++;
this.uuid = THREE.Math.generateUUID();
this.name = '';
...
...
@@ -13774,6 +13909,8 @@ THREE.Texture.prototype = {
};
THREE.TextureIdCount = 0;
/**
* @author alteredq / http://alteredqualia.com/
*/
...
...
@@ -13857,23 +13994,10 @@ THREE.ParticleSystem = function ( geometry, material ) {
THREE.Object3D.call( this );
this.geometry = geometry;
this.material =
( material !== undefined )
? material : new THREE.ParticleBasicMaterial( { color: Math.random() * 0xffffff } );
this.geometry = geometry
!== undefined ? geometry : new THREE.Geometry()
;
this.material =
material !== undefined
? material : new THREE.ParticleBasicMaterial( { color: Math.random() * 0xffffff } );
this.sortParticles = false;
if ( this.geometry ) {
// calc bound radius
if( this.geometry.boundingSphere === null ) {
this.geometry.computeBoundingSphere();
}
}
this.frustumCulled = false;
};
...
...
@@ -13883,6 +14007,7 @@ THREE.ParticleSystem.prototype = Object.create( THREE.Object3D.prototype );
THREE.ParticleSystem.prototype.clone = function ( object ) {
if ( object === undefined ) object = new THREE.ParticleSystem( this.geometry, this.material );
object.sortParticles = this.sortParticles;
THREE.Object3D.prototype.clone.call( this, object );
...
...
@@ -13899,19 +14024,10 @@ THREE.Line = function ( geometry, material, type ) {
THREE.Object3D.call( this );
this.geometry = geometry;
this.material = ( material !== undefined ) ? material : new THREE.LineBasicMaterial( { color: Math.random() * 0xffffff } );
this.type = ( type !== undefined ) ? type : THREE.LineStrip;
if ( this.geometry ) {
if ( ! this.geometry.boundingSphere ) {
this.geometry.computeBoundingSphere();
this.geometry = geometry !== undefined ? geometry : new THREE.Geometry();
this.material = material !== undefined ? material : new THREE.LineBasicMaterial( { color: Math.random() * 0xffffff } );
}
}
this.type = ( type !== undefined ) ? type : THREE.LineStrip;
};
...
...
@@ -13941,48 +14057,15 @@ THREE.Mesh = function ( geometry, material ) {
THREE.Object3D.call( this );
this.geometry =
null
;
this.material =
null
;
this.geometry =
geometry !== undefined ? geometry : new THREE.Geometry()
;
this.material =
material !== undefined ? material : new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } )
;
this.setGeometry( geometry );
this.setMaterial( material );
this.updateMorphTargets();
};
THREE.Mesh.prototype = Object.create( THREE.Object3D.prototype );
THREE.Mesh.prototype.setGeometry = function ( geometry ) {
if ( geometry !== undefined ) {
this.geometry = geometry;
if ( this.geometry.boundingSphere === null ) {
this.geometry.computeBoundingSphere();
}
this.updateMorphTargets();
}
};
THREE.Mesh.prototype.setMaterial = function ( material ) {
if ( material !== undefined ) {
this.material = material;
} else {
this.material = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, wireframe: true } );
}
};
THREE.Mesh.prototype.updateMorphTargets = function () {
if ( this.geometry.morphTargets.length > 0 ) {
...
...
build/three.min.js
浏览文件 @
15899cce
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录