Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
8e8589c8
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,发现更多精彩内容 >>
提交
8e8589c8
编写于
12月 22, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Renamed Bezier functions.
上级
4ea73e58
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
41 addition
and
42 deletion
+41
-42
src/extras/core/Bezier.js
src/extras/core/Bezier.js
+18
-19
src/extras/core/Font.js
src/extras/core/Font.js
+5
-5
src/extras/curves/CubicBezierCurve.js
src/extras/curves/CubicBezierCurve.js
+5
-5
src/extras/curves/CubicBezierCurve3.js
src/extras/curves/CubicBezierCurve3.js
+4
-4
src/extras/curves/QuadraticBezierCurve.js
src/extras/curves/QuadraticBezierCurve.js
+5
-5
src/extras/curves/QuadraticBezierCurve3.js
src/extras/curves/QuadraticBezierCurve3.js
+4
-4
未找到文件。
src/extras/core/Bezier.js
浏览文件 @
8e8589c8
...
...
@@ -5,77 +5,76 @@
* http://en.wikipedia.org/wiki/Bézier_curve
*/
// Quad Bezier Functions
function
b2p0
(
t
,
p
)
{
function
QuadraticBezierP0
(
t
,
p
)
{
var
k
=
1
-
t
;
return
k
*
k
*
p
;
}
function
b2p
1
(
t
,
p
)
{
function
QuadraticBezierP
1
(
t
,
p
)
{
return
2
*
(
1
-
t
)
*
t
*
p
;
}
function
b2p
2
(
t
,
p
)
{
function
QuadraticBezierP
2
(
t
,
p
)
{
return
t
*
t
*
p
;
}
function
b2
(
t
,
p0
,
p1
,
p2
)
{
function
QuadraticBezier
(
t
,
p0
,
p1
,
p2
)
{
return
b2p0
(
t
,
p0
)
+
b2p1
(
t
,
p1
)
+
b2p2
(
t
,
p2
);
return
QuadraticBezierP0
(
t
,
p0
)
+
QuadraticBezierP1
(
t
,
p1
)
+
QuadraticBezierP2
(
t
,
p2
);
}
//
Cubic Bezier Functions
//
function
b3p
0
(
t
,
p
)
{
function
CubicBezierP
0
(
t
,
p
)
{
var
k
=
1
-
t
;
return
k
*
k
*
k
*
p
;
}
function
b3p
1
(
t
,
p
)
{
function
CubicBezierP
1
(
t
,
p
)
{
var
k
=
1
-
t
;
return
3
*
k
*
k
*
t
*
p
;
}
function
b3p
2
(
t
,
p
)
{
function
CubicBezierP
2
(
t
,
p
)
{
var
k
=
1
-
t
;
return
3
*
k
*
t
*
t
*
p
;
return
3
*
(
1
-
t
)
*
t
*
t
*
p
;
}
function
b3p
3
(
t
,
p
)
{
function
CubicBezierP
3
(
t
,
p
)
{
return
t
*
t
*
t
*
p
;
}
function
b3
(
t
,
p0
,
p1
,
p2
,
p3
)
{
function
CubicBezier
(
t
,
p0
,
p1
,
p2
,
p3
)
{
return
b3p0
(
t
,
p0
)
+
b3p1
(
t
,
p1
)
+
b3p2
(
t
,
p2
)
+
b3p3
(
t
,
p3
);
return
CubicBezierP0
(
t
,
p0
)
+
CubicBezierP1
(
t
,
p1
)
+
CubicBezierP2
(
t
,
p2
)
+
CubicBezierP3
(
t
,
p3
);
}
//
function
t
angentQuadraticBezier
(
t
,
p0
,
p1
,
p2
)
{
function
T
angentQuadraticBezier
(
t
,
p0
,
p1
,
p2
)
{
return
2
*
(
1
-
t
)
*
(
p1
-
p0
)
+
2
*
t
*
(
p2
-
p1
);
}
function
t
angentCubicBezier
(
t
,
p0
,
p1
,
p2
,
p3
)
{
function
T
angentCubicBezier
(
t
,
p0
,
p1
,
p2
,
p3
)
{
return
-
3
*
p0
*
(
1
-
t
)
*
(
1
-
t
)
+
3
*
p1
*
(
1
-
t
)
*
(
1
-
t
)
-
6
*
t
*
p1
*
(
1
-
t
)
+
...
...
@@ -84,4 +83,4 @@ function tangentCubicBezier( t, p0, p1, p2, p3 ) {
}
export
{
b2
,
b3
,
tangentQuadraticBezier
,
t
angentCubicBezier
};
export
{
QuadraticBezier
,
CubicBezier
,
TangentQuadraticBezier
,
T
angentCubicBezier
};
src/extras/core/Font.js
浏览文件 @
8e8589c8
import
{
b2
,
b3
}
from
'
./Bezier
'
;
import
{
QuadraticBezier
,
CubicBezier
}
from
'
./Bezier
'
;
import
{
ShapePath
}
from
'
./ShapePath
'
;
/**
...
...
@@ -97,8 +97,8 @@ Object.assign( Font.prototype, {
for
(
var
i2
=
1
;
i2
<=
divisions
;
i2
++
)
{
var
t
=
i2
/
divisions
;
b2
(
t
,
cpx0
,
cpx1
,
cpx
);
b2
(
t
,
cpy0
,
cpy1
,
cpy
);
QuadraticBezier
(
t
,
cpx0
,
cpx1
,
cpx
);
QuadraticBezier
(
t
,
cpy0
,
cpy1
,
cpy
);
}
...
...
@@ -127,8 +127,8 @@ Object.assign( Font.prototype, {
for
(
var
i2
=
1
;
i2
<=
divisions
;
i2
++
)
{
var
t
=
i2
/
divisions
;
b3
(
t
,
cpx0
,
cpx1
,
cpx2
,
cpx
);
b3
(
t
,
cpy0
,
cpy1
,
cpy2
,
cpy
);
CubicBezier
(
t
,
cpx0
,
cpx1
,
cpx2
,
cpx
);
CubicBezier
(
t
,
cpy0
,
cpy1
,
cpy2
,
cpy
);
}
...
...
src/extras/curves/CubicBezierCurve.js
浏览文件 @
8e8589c8
import
{
b3
,
t
angentCubicBezier
}
from
'
../core/Bezier
'
;
import
{
CubicBezier
,
T
angentCubicBezier
}
from
'
../core/Bezier
'
;
import
{
Curve
}
from
'
../core/Curve
'
;
import
{
Vector2
}
from
'
../../math/Vector2
'
;
...
...
@@ -21,8 +21,8 @@ CubicBezierCurve.prototype.constructor = CubicBezierCurve;
CubicBezierCurve
.
prototype
.
getPoint
=
function
(
t
)
{
return
new
Vector2
(
b3
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
,
this
.
v3
.
x
),
b3
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
,
this
.
v3
.
y
)
CubicBezier
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
,
this
.
v3
.
x
),
CubicBezier
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
,
this
.
v3
.
y
)
);
};
...
...
@@ -30,8 +30,8 @@ CubicBezierCurve.prototype.getPoint = function ( t ) {
CubicBezierCurve
.
prototype
.
getTangent
=
function
(
t
)
{
return
new
Vector2
(
t
angentCubicBezier
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
,
this
.
v3
.
x
),
t
angentCubicBezier
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
,
this
.
v3
.
y
)
T
angentCubicBezier
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
,
this
.
v3
.
x
),
T
angentCubicBezier
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
,
this
.
v3
.
y
)
).
normalize
();
};
...
...
src/extras/curves/CubicBezierCurve3.js
浏览文件 @
8e8589c8
import
{
b3
}
from
'
../core/Bezier
'
;
import
{
CubicBezier
}
from
'
../core/Bezier
'
;
import
{
Curve
}
from
'
../core/Curve
'
;
import
{
Vector3
}
from
'
../../math/Vector3
'
;
...
...
@@ -20,9 +20,9 @@ var CubicBezierCurve3 = Curve.create(
function
(
t
)
{
return
new
Vector3
(
b3
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
,
this
.
v3
.
x
),
b3
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
,
this
.
v3
.
y
),
b3
(
t
,
this
.
v0
.
z
,
this
.
v1
.
z
,
this
.
v2
.
z
,
this
.
v3
.
z
)
CubicBezier
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
,
this
.
v3
.
x
),
CubicBezier
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
,
this
.
v3
.
y
),
CubicBezier
(
t
,
this
.
v0
.
z
,
this
.
v1
.
z
,
this
.
v2
.
z
,
this
.
v3
.
z
)
);
}
...
...
src/extras/curves/QuadraticBezierCurve.js
浏览文件 @
8e8589c8
import
{
b2
,
t
angentQuadraticBezier
}
from
'
../core/Bezier
'
;
import
{
QuadraticBezier
,
T
angentQuadraticBezier
}
from
'
../core/Bezier
'
;
import
{
Curve
}
from
'
../core/Curve
'
;
import
{
Vector2
}
from
'
../../math/Vector2
'
;
...
...
@@ -22,8 +22,8 @@ QuadraticBezierCurve.prototype.constructor = QuadraticBezierCurve;
QuadraticBezierCurve
.
prototype
.
getPoint
=
function
(
t
)
{
return
new
Vector2
(
b2
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
),
b2
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
)
QuadraticBezier
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
),
QuadraticBezier
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
)
);
};
...
...
@@ -32,8 +32,8 @@ QuadraticBezierCurve.prototype.getPoint = function ( t ) {
QuadraticBezierCurve
.
prototype
.
getTangent
=
function
(
t
)
{
return
new
Vector2
(
t
angentQuadraticBezier
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
),
t
angentQuadraticBezier
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
)
T
angentQuadraticBezier
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
),
T
angentQuadraticBezier
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
)
).
normalize
();
};
...
...
src/extras/curves/QuadraticBezierCurve3.js
浏览文件 @
8e8589c8
import
{
b2
}
from
'
../core/Bezier
'
;
import
{
QuadraticBezier
}
from
'
../core/Bezier
'
;
import
{
Curve
}
from
'
../core/Curve
'
;
import
{
Vector3
}
from
'
../../math/Vector3
'
;
...
...
@@ -19,9 +19,9 @@ var QuadraticBezierCurve3 = Curve.create(
function
(
t
)
{
return
new
Vector3
(
b2
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
),
b2
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
),
b2
(
t
,
this
.
v0
.
z
,
this
.
v1
.
z
,
this
.
v2
.
z
)
QuadraticBezier
(
t
,
this
.
v0
.
x
,
this
.
v1
.
x
,
this
.
v2
.
x
),
QuadraticBezier
(
t
,
this
.
v0
.
y
,
this
.
v1
.
y
,
this
.
v2
.
y
),
QuadraticBezier
(
t
,
this
.
v0
.
z
,
this
.
v1
.
z
,
this
.
v2
.
z
)
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录