Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
3653a820
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,发现更多精彩内容 >>
提交
3653a820
编写于
10月 13, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
19cb79cd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
454 addition
and
458 deletion
+454
-458
build/three.js
build/three.js
+121
-125
build/three.min.js
build/three.min.js
+333
-333
未找到文件。
build/three.js
浏览文件 @
3653a820
...
...
@@ -24492,9 +24492,6 @@
*
* Creates a tube which extrudes along a 3d spline.
*
* Uses parallel transport frames as described in:
*
* http://www.cs.indiana.edu/pub/techreports/TR425.pdf
*/
function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed ) {
...
...
@@ -24516,7 +24513,7 @@
radialSegments = radialSegments || 8;
closed = closed || false;
var frames =
new FrenetFrames( path,
tubularSegments, closed );
var frames =
path.computeFrenetFrames(
tubularSegments, closed );
// expose internals
...
...
@@ -24663,123 +24660,6 @@
TubeBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
TubeBufferGeometry.prototype.constructor = TubeBufferGeometry;
// For computing of Frenet frames, exposing the tangents, normals and binormals the spline
function FrenetFrames( path, segments, closed ) {
var normal = new Vector3();
var tangents = [];
var normals = [];
var binormals = [];
var vec = new Vector3();
var mat = new Matrix4();
var i, u, theta;
// expose internals
this.tangents = tangents;
this.normals = normals;
this.binormals = binormals;
// compute the tangent vectors for each segment on the path
for ( i = 0; i <= segments; i ++ ) {
u = i / segments;
tangents[ i ] = path.getTangentAt( u );
tangents[ i ].normalize();
}
// select an initial normal vector perpendicular to the first tangent vector,
// and in the direction of the minimum tangent xyz component
normals[ 0 ] = new Vector3();
binormals[ 0 ] = new Vector3();
var min = Number.MAX_VALUE;
var tx = Math.abs( tangents[ 0 ].x );
var ty = Math.abs( tangents[ 0 ].y );
var tz = Math.abs( tangents[ 0 ].z );
if ( tx <= min ) {
min = tx;
normal.set( 1, 0, 0 );
}
if ( ty <= min ) {
min = ty;
normal.set( 0, 1, 0 );
}
if ( tz <= min ) {
normal.set( 0, 0, 1 );
}
vec.crossVectors( tangents[ 0 ], normal ).normalize();
normals[ 0 ].crossVectors( tangents[ 0 ], vec );
binormals[ 0 ].crossVectors( tangents[ 0 ], normals[ 0 ] );
// compute the slowly-varying normal and binormal vectors for each segment on the path
for ( i = 1; i <= segments; i ++ ) {
normals[ i ] = normals[ i - 1 ].clone();
binormals[ i ] = binormals[ i - 1 ].clone();
vec.crossVectors( tangents[ i - 1 ], tangents[ i ] );
if ( vec.length() > Number.EPSILON ) {
vec.normalize();
theta = Math.acos( exports.Math.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
}
binormals[ i ].crossVectors( tangents[ i ], normals[ i ] );
}
// if the curve is closed, postprocess the vectors so the first and last normal vectors are the same
if ( closed ) {
theta = Math.acos( exports.Math.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );
theta /= segments;
if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ segments ] ) ) > 0 ) {
theta = - theta;
}
for ( i = 1; i <= segments; i ++ ) {
// twist a little...
normals[ i ].applyMatrix4( mat.makeRotationAxis( tangents[ i ], theta * i ) );
binormals[ i ].crossVectors( tangents[ i ], normals[ i ] );
}
}
}
/**
* @author oosmoxiecode / https://github.com/oosmoxiecode
* @author WestLangley / https://github.com/WestLangley
...
...
@@ -24804,7 +24684,7 @@
closed: closed
};
if( taper !== undefined ) console.warn( 'THREE.TubeGeometry: taper has been removed.' );
if
( taper !== undefined ) console.warn( 'THREE.TubeGeometry: taper has been removed.' );
var bufferGeometry = new TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed );
...
...
@@ -25955,7 +25835,7 @@
* bevelSegments: <int>, // number of bevel layers
*
* extrudePath: <THREE.CurvePath> // 3d spline path to extrude shape along. (creates Frames if .frames aren't defined)
* frames: <
THREE.TubeGeometry.FrenetFrames
> // containing arrays of tangents, normals, binormals
* frames: <
Object
> // containing arrays of tangents, normals, binormals
*
* uvGenerator: <Object> // object that provides UV generator functions
*
...
...
@@ -26037,10 +25917,9 @@
// SETUP TNB variables
// Reuse TNB from TubeGeomtry for now.
// TODO1 - have a .isClosed in spline?
splineTube = options.frames !== undefined ? options.frames :
new TubeGeometry.FrenetFrames( extrudePath,
steps, false );
splineTube = options.frames !== undefined ? options.frames :
extrudePath.computeFrenetFrames(
steps, false );
// console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length);
...
...
@@ -33677,6 +33556,123 @@
var t = this.getUtoTmapping( u );
return this.getTangent( t );
},
computeFrenetFrames: function ( segments, closed ) {
// see http://www.cs.indiana.edu/pub/techreports/TR425.pdf
var normal = new Vector3();
var tangents = [];
var normals = [];
var binormals = [];
var vec = new Vector3();
var mat = new Matrix4();
var i, u, theta;
// compute the tangent vectors for each segment on the curve
for ( i = 0; i <= segments; i ++ ) {
u = i / segments;
tangents[ i ] = this.getTangentAt( u );
tangents[ i ].normalize();
}
// select an initial normal vector perpendicular to the first tangent vector,
// and in the direction of the minimum tangent xyz component
normals[ 0 ] = new Vector3();
binormals[ 0 ] = new Vector3();
var min = Number.MAX_VALUE;
var tx = Math.abs( tangents[ 0 ].x );
var ty = Math.abs( tangents[ 0 ].y );
var tz = Math.abs( tangents[ 0 ].z );
if ( tx <= min ) {
min = tx;
normal.set( 1, 0, 0 );
}
if ( ty <= min ) {
min = ty;
normal.set( 0, 1, 0 );
}
if ( tz <= min ) {
normal.set( 0, 0, 1 );
}
vec.crossVectors( tangents[ 0 ], normal ).normalize();
normals[ 0 ].crossVectors( tangents[ 0 ], vec );
binormals[ 0 ].crossVectors( tangents[ 0 ], normals[ 0 ] );
// compute the slowly-varying normal and binormal vectors for each segment on the curve
for ( i = 1; i <= segments; i ++ ) {
normals[ i ] = normals[ i - 1 ].clone();
binormals[ i ] = binormals[ i - 1 ].clone();
vec.crossVectors( tangents[ i - 1 ], tangents[ i ] );
if ( vec.length() > Number.EPSILON ) {
vec.normalize();
theta = Math.acos( exports.Math.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
}
binormals[ i ].crossVectors( tangents[ i ], normals[ i ] );
}
// if the curve is closed, postprocess the vectors so the first and last normal vectors are the same
if ( closed === true ) {
theta = Math.acos( exports.Math.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );
theta /= segments;
if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ segments ] ) ) > 0 ) {
theta = - theta;
}
for ( i = 1; i <= segments; i ++ ) {
// twist a little...
normals[ i ].applyMatrix4( mat.makeRotationAxis( tangents[ i ], theta * i ) );
binormals[ i ].crossVectors( tangents[ i ], normals[ i ] );
}
}
return {
tangents: tangents,
normals: normals,
binormals: binormals
};
}
};
...
...
build/three.min.js
浏览文件 @
3653a820
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录