Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
73861db1
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,发现更多精彩内容 >>
提交
73861db1
编写于
10月 21, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleaned up Curves code.
上级
9c197530
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
78 addition
and
113 deletion
+78
-113
src/extras/core/Curve.js
src/extras/core/Curve.js
+1
-1
src/extras/curves/ClosedSplineCurve3.js
src/extras/curves/ClosedSplineCurve3.js
+19
-19
src/extras/curves/CubicBezierCurve3.js
src/extras/curves/CubicBezierCurve3.js
+5
-5
src/extras/curves/EllipseCurve.js
src/extras/curves/EllipseCurve.js
+7
-4
src/extras/curves/LineCurve3.js
src/extras/curves/LineCurve3.js
+5
-6
src/extras/curves/QuadraticBezierCurve.js
src/extras/curves/QuadraticBezierCurve.js
+8
-11
src/extras/curves/QuadraticBezierCurve3.js
src/extras/curves/QuadraticBezierCurve3.js
+5
-5
src/extras/curves/SplineCurve.js
src/extras/curves/SplineCurve.js
+14
-14
src/extras/curves/SplineCurve3.js
src/extras/curves/SplineCurve3.js
+14
-48
未找到文件。
src/extras/core/Curve.js
浏览文件 @
73861db1
...
...
@@ -286,8 +286,8 @@ THREE.Curve.Utils = {
3
*
p1
*
(
1
-
t
)
*
(
1
-
t
)
-
6
*
t
*
p1
*
(
1
-
t
)
+
6
*
t
*
p2
*
(
1
-
t
)
-
3
*
t
*
t
*
p2
+
3
*
t
*
t
*
p3
;
},
},
tangentSpline
:
function
(
t
,
p0
,
p1
,
p2
,
p3
)
{
...
...
src/extras/curves/ClosedSplineCurve3.js
浏览文件 @
73861db1
...
...
@@ -7,33 +7,33 @@ THREE.ClosedSplineCurve3 = THREE.Curve.create(
function
(
points
/* array of Vector3 */
)
{
this
.
points
=
(
points
==
undefined
)
?
[]
:
points
;
this
.
points
=
(
points
==
undefined
)
?
[]
:
points
;
},
function
(
t
)
{
function
(
t
)
{
var
v
=
new
THREE
.
Vector3
();
var
c
=
[];
var
points
=
this
.
points
,
point
,
intPoint
,
weight
;
point
=
(
points
.
length
-
0
)
*
t
;
// This needs to be from 0-length +1
var
points
=
this
.
points
;
var
point
=
(
points
.
length
-
0
)
*
t
;
// This needs to be from 0-length +1
intPoint
=
Math
.
floor
(
point
);
weight
=
point
-
intPoint
;
var
intPoint
=
Math
.
floor
(
point
);
var
weight
=
point
-
intPoint
;
intPoint
+=
intPoint
>
0
?
0
:
(
Math
.
floor
(
Math
.
abs
(
intPoint
)
/
points
.
length
)
+
1
)
*
points
.
length
;
c
[
0
]
=
(
intPoint
-
1
)
%
points
.
length
;
c
[
1
]
=
(
intPoint
)
%
points
.
length
;
c
[
2
]
=
(
intPoint
+
1
)
%
points
.
length
;
c
[
3
]
=
(
intPoint
+
2
)
%
points
.
length
;
intPoint
+=
intPoint
>
0
?
0
:
(
Math
.
floor
(
Math
.
abs
(
intPoint
)
/
points
.
length
)
+
1
)
*
points
.
length
;
v
.
x
=
THREE
.
Curve
.
Utils
.
interpolate
(
points
[
c
[
0
]
].
x
,
points
[
c
[
1
]
].
x
,
points
[
c
[
2
]
].
x
,
points
[
c
[
3
]
].
x
,
weight
);
v
.
y
=
THREE
.
Curve
.
Utils
.
interpolate
(
points
[
c
[
0
]
].
y
,
points
[
c
[
1
]
].
y
,
points
[
c
[
2
]
].
y
,
points
[
c
[
3
]
].
y
,
weight
);
v
.
z
=
THREE
.
Curve
.
Utils
.
interpolate
(
points
[
c
[
0
]
].
z
,
points
[
c
[
1
]
].
z
,
points
[
c
[
2
]
].
z
,
points
[
c
[
3
]
].
z
,
weight
);
var
point0
=
points
[
(
intPoint
-
1
)
%
points
.
length
];
var
point1
=
points
[
(
intPoint
)
%
points
.
length
];
var
point2
=
points
[
(
intPoint
+
1
)
%
points
.
length
];
var
point3
=
points
[
(
intPoint
+
2
)
%
points
.
length
];
return
v
;
var
vector
=
new
THREE
.
Vector3
()
;
}
vector
.
x
=
THREE
.
Curve
.
Utils
.
interpolate
(
point0
.
x
,
point1
.
x
,
point2
.
x
,
point3
.
x
,
weight
);
vector
.
y
=
THREE
.
Curve
.
Utils
.
interpolate
(
point0
.
y
,
point1
.
y
,
point2
.
y
,
point3
.
y
,
weight
);
vector
.
z
=
THREE
.
Curve
.
Utils
.
interpolate
(
point0
.
z
,
point1
.
z
,
point2
.
z
,
point3
.
z
,
weight
);
return
vector
;
}
);
src/extras/curves/CubicBezierCurve3.js
浏览文件 @
73861db1
...
...
@@ -15,13 +15,13 @@ THREE.CubicBezierCurve3 = THREE.Curve.create(
function
(
t
)
{
var
tx
,
ty
,
tz
;
var
vector
=
new
THREE
.
Vector3
()
;
t
x
=
THREE
.
Shape
.
Utils
.
b3
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
,
this
.
v3
.
x
);
t
y
=
THREE
.
Shape
.
Utils
.
b3
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
,
this
.
v3
.
y
);
t
z
=
THREE
.
Shape
.
Utils
.
b3
(
t
,
this
.
v0
.
z
,
this
.
v1
.
z
,
this
.
v2
.
z
,
this
.
v3
.
z
);
vector
.
x
=
THREE
.
Shape
.
Utils
.
b3
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
,
this
.
v3
.
x
);
vector
.
y
=
THREE
.
Shape
.
Utils
.
b3
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
,
this
.
v3
.
y
);
vector
.
z
=
THREE
.
Shape
.
Utils
.
b3
(
t
,
this
.
v0
.
z
,
this
.
v1
.
z
,
this
.
v2
.
z
,
this
.
v3
.
z
);
return
new
THREE
.
Vector3
(
tx
,
ty
,
tz
)
;
return
vector
;
}
...
...
src/extras/curves/EllipseCurve.js
浏览文件 @
73861db1
...
...
@@ -21,12 +21,13 @@ THREE.EllipseCurve.prototype = Object.create( THREE.Curve.prototype );
THREE
.
EllipseCurve
.
prototype
.
getPoint
=
function
(
t
)
{
var
angle
;
var
deltaAngle
=
this
.
aEndAngle
-
this
.
aStartAngle
;
if
(
deltaAngle
<
0
)
deltaAngle
+=
Math
.
PI
*
2
;
if
(
deltaAngle
>
Math
.
PI
*
2
)
deltaAngle
-=
Math
.
PI
*
2
;
var
angle
;
if
(
this
.
aClockwise
===
true
)
{
angle
=
this
.
aEndAngle
+
(
1
-
t
)
*
(
Math
.
PI
*
2
-
deltaAngle
);
...
...
@@ -36,10 +37,12 @@ THREE.EllipseCurve.prototype.getPoint = function ( t ) {
angle
=
this
.
aStartAngle
+
t
*
deltaAngle
;
}
var
vector
=
new
THREE
.
Vector2
();
v
ar
t
x
=
this
.
aX
+
this
.
xRadius
*
Math
.
cos
(
angle
);
v
ar
t
y
=
this
.
aY
+
this
.
yRadius
*
Math
.
sin
(
angle
);
v
ector
.
x
=
this
.
aX
+
this
.
xRadius
*
Math
.
cos
(
angle
);
v
ector
.
y
=
this
.
aY
+
this
.
yRadius
*
Math
.
sin
(
angle
);
return
new
THREE
.
Vector2
(
tx
,
ty
)
;
return
vector
;
};
src/extras/curves/LineCurve3.js
浏览文件 @
73861db1
...
...
@@ -13,14 +13,13 @@ THREE.LineCurve3 = THREE.Curve.create(
function
(
t
)
{
var
r
=
new
THREE
.
Vector3
();
var
vecto
r
=
new
THREE
.
Vector3
();
vector
.
subVectors
(
this
.
v2
,
this
.
v1
);
// diff
vector
.
multiplyScalar
(
t
);
vector
.
add
(
this
.
v1
);
r
.
subVectors
(
this
.
v2
,
this
.
v1
);
// diff
r
.
multiplyScalar
(
t
);
r
.
add
(
this
.
v1
);
return
r
;
return
vector
;
}
...
...
src/extras/curves/QuadraticBezierCurve.js
浏览文件 @
73861db1
...
...
@@ -16,28 +16,25 @@ THREE.QuadraticBezierCurve.prototype = Object.create( THREE.Curve.prototype );
THREE
.
QuadraticBezierCurve
.
prototype
.
getPoint
=
function
(
t
)
{
var
tx
,
ty
;
var
vector
=
new
THREE
.
Vector2
()
;
t
x
=
THREE
.
Shape
.
Utils
.
b2
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
);
t
y
=
THREE
.
Shape
.
Utils
.
b2
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
);
vector
.
x
=
THREE
.
Shape
.
Utils
.
b2
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
);
vector
.
y
=
THREE
.
Shape
.
Utils
.
b2
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
);
return
new
THREE
.
Vector2
(
tx
,
ty
)
;
return
vector
;
};
THREE
.
QuadraticBezierCurve
.
prototype
.
getTangent
=
function
(
t
)
{
var
tx
,
ty
;
var
vector
=
new
THREE
.
Vector2
()
;
t
x
=
THREE
.
Curve
.
Utils
.
tangentQuadraticBezier
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
);
t
y
=
THREE
.
Curve
.
Utils
.
tangentQuadraticBezier
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
);
vector
.
x
=
THREE
.
Curve
.
Utils
.
tangentQuadraticBezier
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
);
vector
.
y
=
THREE
.
Curve
.
Utils
.
tangentQuadraticBezier
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
);
// returns unit vector
var
tangent
=
new
THREE
.
Vector2
(
tx
,
ty
);
tangent
.
normalize
();
return
tangent
;
return
vector
.
normalize
();
};
src/extras/curves/QuadraticBezierCurve3.js
浏览文件 @
73861db1
...
...
@@ -14,13 +14,13 @@ THREE.QuadraticBezierCurve3 = THREE.Curve.create(
function
(
t
)
{
var
tx
,
ty
,
tz
;
var
vector
=
new
THREE
.
Vector3
()
;
t
x
=
THREE
.
Shape
.
Utils
.
b2
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
);
t
y
=
THREE
.
Shape
.
Utils
.
b2
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
);
t
z
=
THREE
.
Shape
.
Utils
.
b2
(
t
,
this
.
v0
.
z
,
this
.
v1
.
z
,
this
.
v2
.
z
);
vector
.
x
=
THREE
.
Shape
.
Utils
.
b2
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
);
vector
.
y
=
THREE
.
Shape
.
Utils
.
b2
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
);
vector
.
z
=
THREE
.
Shape
.
Utils
.
b2
(
t
,
this
.
v0
.
z
,
this
.
v1
.
z
,
this
.
v2
.
z
);
return
new
THREE
.
Vector3
(
tx
,
ty
,
tz
)
;
return
vector
;
}
...
...
src/extras/curves/SplineCurve.js
浏览文件 @
73861db1
...
...
@@ -4,7 +4,7 @@
THREE
.
SplineCurve
=
function
(
points
/* array of Vector2 */
)
{
this
.
points
=
(
points
==
undefined
)
?
[]
:
points
;
this
.
points
=
(
points
==
undefined
)
?
[]
:
points
;
};
...
...
@@ -12,22 +12,22 @@ THREE.SplineCurve.prototype = Object.create( THREE.Curve.prototype );
THREE
.
SplineCurve
.
prototype
.
getPoint
=
function
(
t
)
{
var
v
=
new
THREE
.
Vector2
();
var
c
=
[];
var
points
=
this
.
points
,
point
,
intPoint
,
weight
;
point
=
(
points
.
length
-
1
)
*
t
;
var
points
=
this
.
points
;
var
point
=
(
points
.
length
-
1
)
*
t
;
intPoint
=
Math
.
floor
(
point
);
weight
=
point
-
intPoint
;
var
intPoint
=
Math
.
floor
(
point
);
var
weight
=
point
-
intPoint
;
c
[
0
]
=
intPoint
==
0
?
intPoint
:
intPoint
-
1
;
c
[
1
]
=
intPoint
;
c
[
2
]
=
intPoint
>
points
.
length
-
2
?
points
.
length
-
1
:
intPoint
+
1
;
c
[
3
]
=
intPoint
>
points
.
length
-
3
?
points
.
length
-
1
:
intPoint
+
2
;
var
point0
=
points
[
intPoint
==
0
?
intPoint
:
intPoint
-
1
]
var
point1
=
points
[
intPoint
]
var
point2
=
points
[
intPoint
>
points
.
length
-
2
?
points
.
length
-
1
:
intPoint
+
1
]
var
point3
=
points
[
intPoint
>
points
.
length
-
3
?
points
.
length
-
1
:
intPoint
+
2
]
v
.
x
=
THREE
.
Curve
.
Utils
.
interpolate
(
points
[
c
[
0
]
].
x
,
points
[
c
[
1
]
].
x
,
points
[
c
[
2
]
].
x
,
points
[
c
[
3
]
].
x
,
weight
);
v
.
y
=
THREE
.
Curve
.
Utils
.
interpolate
(
points
[
c
[
0
]
].
y
,
points
[
c
[
1
]
].
y
,
points
[
c
[
2
]
].
y
,
points
[
c
[
3
]
].
y
,
weight
);
var
vector
=
new
THREE
.
Vector2
();
return
v
;
vector
.
x
=
THREE
.
Curve
.
Utils
.
interpolate
(
point0
.
x
,
point1
.
x
,
point2
.
x
,
point3
.
x
,
weight
);
vector
.
y
=
THREE
.
Curve
.
Utils
.
interpolate
(
point0
.
y
,
point1
.
y
,
point2
.
y
,
point3
.
y
,
weight
);
return
vector
;
};
src/extras/curves/SplineCurve3.js
浏览文件 @
73861db1
...
...
@@ -7,65 +7,31 @@ THREE.SplineCurve3 = THREE.Curve.create(
function
(
points
/* array of Vector3 */
)
{
this
.
points
=
(
points
==
undefined
)
?
[]
:
points
;
this
.
points
=
(
points
==
undefined
)
?
[]
:
points
;
},
function
(
t
)
{
var
v
=
new
THREE
.
Vector3
();
var
c
=
[];
var
points
=
this
.
points
,
point
,
intPoint
,
weight
;
point
=
(
points
.
length
-
1
)
*
t
;
var
points
=
this
.
points
;
var
point
=
(
points
.
length
-
1
)
*
t
;
intPoint
=
Math
.
floor
(
point
);
weight
=
point
-
intPoint
;
var
intPoint
=
Math
.
floor
(
point
);
var
weight
=
point
-
intPoint
;
c
[
0
]
=
intPoint
==
0
?
intPoint
:
intPoint
-
1
;
c
[
1
]
=
intPoint
;
c
[
2
]
=
intPoint
>
points
.
length
-
2
?
points
.
length
-
1
:
intPoint
+
1
;
c
[
3
]
=
intPoint
>
points
.
length
-
3
?
points
.
length
-
1
:
intPoint
+
2
;
var
point0
=
points
[
intPoint
==
0
?
intPoint
:
intPoint
-
1
]
;
var
point1
=
points
[
intPoint
]
;
var
point2
=
points
[
intPoint
>
points
.
length
-
2
?
points
.
length
-
1
:
intPoint
+
1
]
;
var
point3
=
points
[
intPoint
>
points
.
length
-
3
?
points
.
length
-
1
:
intPoint
+
2
]
;
var
pt0
=
points
[
c
[
0
]
],
pt1
=
points
[
c
[
1
]
],
pt2
=
points
[
c
[
2
]
],
pt3
=
points
[
c
[
3
]
];
var
vector
=
new
THREE
.
Vector3
();
v
.
x
=
THREE
.
Curve
.
Utils
.
interpolate
(
pt0
.
x
,
pt1
.
x
,
pt2
.
x
,
pt3
.
x
,
weight
);
v
.
y
=
THREE
.
Curve
.
Utils
.
interpolate
(
pt0
.
y
,
pt1
.
y
,
pt2
.
y
,
pt3
.
y
,
weight
);
v
.
z
=
THREE
.
Curve
.
Utils
.
interpolate
(
pt0
.
z
,
pt1
.
z
,
pt2
.
z
,
pt3
.
z
,
weight
);
v
ector
.
x
=
THREE
.
Curve
.
Utils
.
interpolate
(
point0
.
x
,
point1
.
x
,
point2
.
x
,
point3
.
x
,
weight
);
v
ector
.
y
=
THREE
.
Curve
.
Utils
.
interpolate
(
point0
.
y
,
point1
.
y
,
point2
.
y
,
point3
.
y
,
weight
);
v
ector
.
z
=
THREE
.
Curve
.
Utils
.
interpolate
(
point0
.
z
,
point1
.
z
,
point2
.
z
,
point3
.
z
,
weight
);
return
v
;
return
v
ector
;
}
);
// THREE.SplineCurve3.prototype.getTangent = function(t) {
// var v = new THREE.Vector3();
// var c = [];
// var points = this.points, point, intPoint, weight;
// point = ( points.length - 1 ) * t;
// intPoint = Math.floor( point );
// weight = point - intPoint;
// c[ 0 ] = intPoint == 0 ? intPoint : intPoint - 1;
// c[ 1 ] = intPoint;
// c[ 2 ] = intPoint > points.length - 2 ? points.length - 1 : intPoint + 1;
// c[ 3 ] = intPoint > points.length - 3 ? points.length - 1 : intPoint + 2;
// var pt0 = points[ c[0] ],
// pt1 = points[ c[1] ],
// pt2 = points[ c[2] ],
// pt3 = points[ c[3] ];
// // t = weight;
// v.x = THREE.Curve.Utils.tangentSpline( t, pt0.x, pt1.x, pt2.x, pt3.x );
// v.y = THREE.Curve.Utils.tangentSpline( t, pt0.y, pt1.y, pt2.y, pt3.y );
// v.z = THREE.Curve.Utils.tangentSpline( t, pt0.z, pt1.z, pt2.z, pt3.z );
// return v;
// }
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录