Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
0e74e725
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,发现更多精彩内容 >>
提交
0e74e725
编写于
12月 31, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Font: Clean up.
上级
a46d7393
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
57 addition
and
75 deletion
+57
-75
src/extras/core/Font.js
src/extras/core/Font.js
+57
-75
未找到文件。
src/extras/core/Font.js
浏览文件 @
0e74e725
...
@@ -13,7 +13,7 @@ THREE.Font.prototype = {
...
@@ -13,7 +13,7 @@ THREE.Font.prototype = {
constructor
:
THREE
.
Font
,
constructor
:
THREE
.
Font
,
generateShapes
:
function
(
text
,
size
,
curveSegment
s
)
{
generateShapes
:
function
(
text
,
size
,
division
s
)
{
function
createPaths
(
text
)
{
function
createPaths
(
text
)
{
...
@@ -25,9 +25,7 @@ THREE.Font.prototype = {
...
@@ -25,9 +25,7 @@ THREE.Font.prototype = {
for
(
var
i
=
0
;
i
<
chars
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
chars
.
length
;
i
++
)
{
var
path
=
new
THREE
.
Path
();
var
ret
=
createPath
(
chars
[
i
],
scale
,
offset
);
var
ret
=
extractGlyphPoints
(
chars
[
i
],
scale
,
offset
,
path
);
offset
+=
ret
.
offset
;
offset
+=
ret
.
offset
;
paths
.
push
(
ret
.
path
);
paths
.
push
(
ret
.
path
);
...
@@ -38,118 +36,102 @@ THREE.Font.prototype = {
...
@@ -38,118 +36,102 @@ THREE.Font.prototype = {
}
}
function
extractGlyphPoints
(
c
,
scale
,
offset
,
path
)
{
function
createPath
(
c
,
scale
,
offset
)
{
var
pts
=
[];
var
b2
=
THREE
.
ShapeUtils
.
b2
;
var
glyph
=
data
.
glyphs
[
c
]
||
data
.
glyphs
[
'
?
'
];
var
b3
=
THREE
.
ShapeUtils
.
b3
;
var
i
,
i2
,
divisions
,
outline
,
action
,
length
,
scaleX
,
scaleY
,
x
,
y
,
cpx
,
cpy
,
cpx0
,
cpy0
,
cpx1
,
cpy1
,
cpx2
,
cpy2
,
laste
,
glyph
=
data
.
glyphs
[
c
]
||
data
.
glyphs
[
'
?
'
];
if
(
!
glyph
)
return
;
if
(
!
glyph
)
return
;
if
(
glyph
.
o
)
{
var
path
=
new
THREE
.
Path
();
outline
=
glyph
.
_cachedOutline
||
(
glyph
.
_cachedOutline
=
glyph
.
o
.
split
(
'
'
)
)
;
var
pts
=
[],
b2
=
THREE
.
ShapeUtils
.
b2
,
b3
=
THREE
.
ShapeUtils
.
b3
;
length
=
outline
.
length
;
var
x
,
y
,
cpx
,
cpy
,
cpx0
,
cpy0
,
cpx1
,
cpy1
,
cpx2
,
cpy2
,
laste
;
scaleX
=
scale
;
if
(
glyph
.
o
)
{
scaleY
=
scale
;
for
(
i
=
0
;
i
<
length
;
)
{
var
outline
=
glyph
.
_cachedOutline
||
(
glyph
.
_cachedOutline
=
glyph
.
o
.
split
(
'
'
)
);
action
=
outline
[
i
++
];
for
(
var
i
=
0
,
l
=
outline
.
length
;
i
<
l
;
)
{
//console.log( action )
;
var
action
=
outline
[
i
++
]
;
switch
(
action
)
{
switch
(
action
)
{
case
'
m
'
:
case
'
m
'
:
// moveTo
// Move To
x
=
outline
[
i
++
]
*
scale
+
offset
;
y
=
outline
[
i
++
]
*
scale
;
x
=
outline
[
i
++
]
*
scaleX
+
offset
;
path
.
moveTo
(
x
,
y
);
y
=
outline
[
i
++
]
*
scaleY
;
path
.
moveTo
(
x
,
y
);
break
;
break
;
case
'
l
'
:
case
'
l
'
:
// lineTo
// Line To
x
=
outline
[
i
++
]
*
scale
+
offset
;
y
=
outline
[
i
++
]
*
scale
;
x
=
outline
[
i
++
]
*
scaleX
+
offset
;
path
.
lineTo
(
x
,
y
);
y
=
outline
[
i
++
]
*
scaleY
;
path
.
lineTo
(
x
,
y
);
break
;
case
'
q
'
:
break
;
// Q
uadraticCurveTo
case
'
q
'
:
// q
uadraticCurveTo
cpx
=
outline
[
i
++
]
*
scaleX
+
offset
;
cpx
=
outline
[
i
++
]
*
scale
+
offset
;
cpy
=
outline
[
i
++
]
*
scaleY
;
cpy
=
outline
[
i
++
]
*
scale
;
cpx1
=
outline
[
i
++
]
*
scaleX
+
offset
;
cpx1
=
outline
[
i
++
]
*
scale
+
offset
;
cpy1
=
outline
[
i
++
]
*
scaleY
;
cpy1
=
outline
[
i
++
]
*
scale
;
path
.
quadraticCurveTo
(
cpx1
,
cpy1
,
cpx
,
cpy
);
path
.
quadraticCurveTo
(
cpx1
,
cpy1
,
cpx
,
cpy
);
laste
=
pts
[
pts
.
length
-
1
];
laste
=
pts
[
pts
.
length
-
1
];
if
(
laste
)
{
if
(
laste
)
{
cpx0
=
laste
.
x
;
cpx0
=
laste
.
x
;
cpy0
=
laste
.
y
;
cpy0
=
laste
.
y
;
for
(
i2
=
1
,
divisions
=
this
.
divisions
;
i2
<=
divisions
;
i2
++
)
{
for
(
var
i2
=
1
;
i2
<=
divisions
;
i2
++
)
{
var
t
=
i2
/
divisions
;
var
t
=
i2
/
divisions
;
b2
(
t
,
cpx0
,
cpx1
,
cpx
);
b2
(
t
,
cpx0
,
cpx1
,
cpx
);
b2
(
t
,
cpy0
,
cpy1
,
cpy
);
b2
(
t
,
cpy0
,
cpy1
,
cpy
);
}
}
}
}
break
;
break
;
case
'
b
'
:
case
'
b
'
:
// bezierCurveTo
// Cubic Bezier Curve
cpx
=
outline
[
i
++
]
*
scale
+
offset
;
cpy
=
outline
[
i
++
]
*
scale
;
cpx1
=
outline
[
i
++
]
*
scale
+
offset
;
cpy1
=
outline
[
i
++
]
*
scale
;
cpx2
=
outline
[
i
++
]
*
scale
+
offset
;
cpy2
=
outline
[
i
++
]
*
scale
;
cpx
=
outline
[
i
++
]
*
scaleX
+
offset
;
path
.
bezierCurveTo
(
cpx1
,
cpy1
,
cpx2
,
cpy2
,
cpx
,
cpy
);
cpy
=
outline
[
i
++
]
*
scaleY
;
cpx1
=
outline
[
i
++
]
*
scaleX
+
offset
;
cpy1
=
outline
[
i
++
]
*
scaleY
;
cpx2
=
outline
[
i
++
]
*
scaleX
+
offset
;
cpy2
=
outline
[
i
++
]
*
scaleY
;
path
.
bezierCurveTo
(
cpx1
,
cpy1
,
cpx2
,
cpy2
,
cpx
,
cpy
)
;
laste
=
pts
[
pts
.
length
-
1
]
;
laste
=
pts
[
pts
.
length
-
1
];
if
(
laste
)
{
if
(
laste
)
{
cpx0
=
laste
.
x
;
cpy0
=
laste
.
y
;
cpx0
=
laste
.
x
;
for
(
var
i2
=
1
;
i2
<=
divisions
;
i2
++
)
{
cpy0
=
laste
.
y
;
for
(
i2
=
1
,
divisions
=
this
.
divisions
;
i2
<=
divisions
;
i2
++
)
{
var
t
=
i2
/
divisions
;
b3
(
t
,
cpx0
,
cpx1
,
cpx2
,
cpx
);
b3
(
t
,
cpy0
,
cpy1
,
cpy2
,
cpy
);
var
t
=
i2
/
divisions
;
}
b3
(
t
,
cpx0
,
cpx1
,
cpx2
,
cpx
);
b3
(
t
,
cpy0
,
cpy1
,
cpy2
,
cpy
);
}
}
}
break
;
break
;
}
}
...
@@ -164,7 +146,7 @@ THREE.Font.prototype = {
...
@@ -164,7 +146,7 @@ THREE.Font.prototype = {
//
//
if
(
size
===
undefined
)
size
=
100
;
if
(
size
===
undefined
)
size
=
100
;
if
(
curveSegments
===
undefined
)
curveSegment
s
=
4
;
if
(
divisions
===
undefined
)
division
s
=
4
;
var
data
=
this
.
data
;
var
data
=
this
.
data
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录