Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
afe9d3b5
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,发现更多精彩内容 >>
提交
afe9d3b5
编写于
6月 06, 2011
作者:
Z
zz85
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
committing text fix changes not pushed :(
上级
49833270
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
81 addition
and
66 deletion
+81
-66
examples/webgl_geometry_text.html
examples/webgl_geometry_text.html
+11
-19
src/extras/geometries/Text.js
src/extras/geometries/Text.js
+70
-47
未找到文件。
examples/webgl_geometry_text.html
浏览文件 @
afe9d3b5
...
...
@@ -45,17 +45,17 @@
<script
type=
"text/javascript"
src=
"../src/extras/geometries/Text.js"
></script>
<!--
<script type="text/javascript" src="helvetiker-normal-normal.js"></script>
http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/dejavu_serif-normal-normal.js
optimer-normal-normal.js
gentilis-normal-normal
http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/helvetiker-normal-normal.js
http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/dejavu_sans-normal-normal.js
http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/dejavu_sans-normal-normal.js
http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/optimer-normal-normal.js
http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/gentilis-normal-normal.js
optimer-bold-normal
-->
<script
type=
"text/javascript"
src=
"http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/
optimer
-normal-normal.js"
></script>
<script
type=
"text/javascript"
src=
"http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/
gentilis
-normal-normal.js"
></script>
<script
type=
"text/javascript"
src=
"js/helvetiker-normal-normal.js"
></script>
<script
type=
"text/javascript"
>
...
...
@@ -94,12 +94,7 @@ http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/dejavu_sans-normal
scene
=
new
THREE
.
Scene
();
// text
//THREE.FontUtils.weight = "bold";
// Materials
...
...
@@ -167,13 +162,15 @@ http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/dejavu_sans-normal
theText
=
hash
;
}
//var
text3d
=
new
THREE
.
Text
(
theText
,
{
textParams
=
{
size
:
80
,
height
:
40
,
curveSegments
:
2
,
font
:
"
optimer
"
});
//dejavu sans
font
:
"
gentilis
"
//gentilis helvetiker
};
//var
text3d
=
new
THREE
.
Text
(
theText
,
textParams
);
//dejavu sans
//MEsh Normal MeshBasic
//MeshPhongMaterial MeshLambertMaterial MeshPhongMaterial
...
...
@@ -315,12 +312,7 @@ http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/dejavu_sans-normal
*/
scene
.
removeChild
(
text
);
text3d
=
new
THREE
.
Text
(
effectController
.
text
,
{
size
:
80
,
height
:
40
,
curveSegments
:
2
,
font
:
"
helvetiker
"
//"helvetiker"
});
text3d
=
new
THREE
.
Text
(
effectController
.
text
,
textParams
);
text
=
new
THREE
.
Mesh
(
text3d
,
textMaterial
)
scene
.
addChild
(
text
);
...
...
src/extras/geometries/Text.js
浏览文件 @
afe9d3b5
...
...
@@ -181,7 +181,7 @@ THREE.FontUtils = {
},
extractPoints
:
function
(
points
)
{
extractPoints
:
function
(
points
,
characters
)
{
// Quick Exit
if
(
points
.
length
<
3
)
{
// throw new exception("")
...
...
@@ -191,53 +191,74 @@ THREE.FontUtils = {
}
// Try to split shapes and holes.
var
all
=
[]
,
point
,
shape
;
var
all
,
point
,
shape
;
var
isolatedShapes
=
[];
// Use a quick hashmap for locating duplicates
for
(
var
p
in
points
)
{
point
=
points
[
p
];
all
.
push
(
point
.
x
+
"
,
"
+
point
.
y
);
}
var
firstPt
=
all
[
0
];
var
endPt
=
all
.
slice
(
1
).
indexOf
(
firstPt
);
if
(
endPt
<
all
.
length
)
{
endPt
++
;
shape
=
points
.
slice
(
0
,
endPt
);
}
holes
=
[];
while
(
endPt
<
all
.
length
)
{
firstIndex
=
endPt
+
1
;
firstPt
=
all
[
firstIndex
];
endPt
=
all
.
slice
(
firstIndex
+
1
).
indexOf
(
firstPt
)
+
firstIndex
;
if
(
endPt
<=
firstIndex
)
break
;
var
contours
=
points
.
slice
(
firstIndex
,
endPt
+
1
);
for
(
var
c
in
characters
)
{
points
=
characters
[
c
];
all
=
[];
// Use a quick hashmap for locating duplicates
for
(
var
p
in
points
)
{
point
=
points
[
p
];
all
.
push
(
point
.
x
+
"
,
"
+
point
.
y
);
}
var
firstPt
,
endPt
,
holes
;
// We check the first loop whether its CW or CCW direction to determine
// whether its shapes or holes first
endPt
=
all
.
slice
(
1
).
indexOf
(
all
[
0
]);
var
shapesFirst
=
this
.
Triangulate
.
area
(
points
.
slice
(
0
,
endPt
+
1
))
<
0
;
//console.log(points.length, "shapesFirst",shapesFirst);
holes
=
[];
endPt
=
-
1
;
while
(
endPt
<
all
.
length
)
{
firstIndex
=
endPt
+
1
;
firstPt
=
all
[
firstIndex
];
endPt
=
all
.
slice
(
firstIndex
+
1
).
indexOf
(
firstPt
)
+
firstIndex
;
if
(
endPt
<=
firstIndex
)
break
;
if
(
this
.
Triangulate
.
area
(
contours
)
<
0
)
{
isolatedShapes
.
push
({
shape
:
shape
,
holes
:
holes
});
// Save the old shapes, then work on new additional seperated shape
var
contours
=
points
.
slice
(
firstIndex
,
endPt
+
1
);
if
(
shapesFirst
)
{
if
(
this
.
Triangulate
.
area
(
contours
)
<
0
)
{
// we got new isolated shape
if
(
firstIndex
>
0
)
{
isolatedShapes
.
push
({
shape
:
shape
,
holes
:
holes
});
}
// Save the old shapes, then work on new additional seperated shape
shape
=
contours
;
holes
=
[];
shape
=
contours
;
holes
=
[];
}
else
{
holes
.
push
(
contours
);
}
endPt
++
;
}
else
{
holes
.
push
(
contours
);
}
}
else
{
if
(
this
.
Triangulate
.
area
(
contours
)
<
0
)
{
isolatedShapes
.
push
({
shape
:
contours
,
holes
:
holes
});
holes
=
[];
}
else
{
holes
.
push
(
contours
);
}
}
endPt
++
;
}
}
isolatedShapes
.
push
({
shape
:
shape
,
holes
:
holes
});
if
(
shapesFirst
)
{
isolatedShapes
.
push
({
shape
:
shape
,
holes
:
holes
});
}
}
//console.log("isolatedShapes", isolatedShapes);
...
...
@@ -365,7 +386,7 @@ THREE.FontUtils = {
},
drawText
:
function
(
text
)
{
pts
=
[];
var
characterpts
=
[],
pts
=
[];
// RenderText
var
face
=
this
.
getFace
(),
...
...
@@ -374,17 +395,18 @@ THREE.FontUtils = {
chars
=
String
(
text
).
split
(
''
),
length
=
chars
.
length
;
for
(
i
=
0
;
i
<
length
;
i
++
)
{
offset
+=
this
.
extractGlyphPoints
(
chars
[
i
],
face
,
scale
,
offset
);
ret
=
this
.
extractGlyphPoints
(
chars
[
i
],
face
,
scale
,
offset
);
offset
+=
ret
.
offset
;
characterpts
.
push
(
ret
.
points
);
pts
=
pts
.
concat
(
ret
.
points
);
}
// get the width
// get the width
width
=
offset
/
2
;
for
(
var
p
in
pts
)
{
pts
[
p
].
x
-=
width
;
}
var
extract
=
this
.
extractPoints
(
pts
);
var
extract
=
this
.
extractPoints
(
pts
,
characterpts
);
extract
.
contour
=
pts
;
return
extract
;
...
...
@@ -439,6 +461,7 @@ THREE.FontUtils = {
extractGlyphPoints
:
function
(
c
,
face
,
scale
,
offset
){
var
i
,
cpx
,
cpy
,
outline
,
action
,
length
,
glyph
=
face
.
glyphs
[
c
]
||
face
.
glyphs
[
ctxt
.
options
.
fallbackCharacter
];
var
pts
=
[];
if
(
!
glyph
)
return
;
...
...
@@ -514,7 +537,7 @@ THREE.FontUtils = {
}
}
}
return
glyph
.
ha
*
scale
;
return
{
offset
:
glyph
.
ha
*
scale
,
points
:
pts
}
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录