Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
7dbf0554
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,发现更多精彩内容 >>
提交
7dbf0554
编写于
7月 27, 2011
作者:
Z
zz85
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed bevel but yet another problem
上级
2134d6b3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
69 addition
and
78 deletion
+69
-78
src/extras/geometries/ExtrudeGeometry.js
src/extras/geometries/ExtrudeGeometry.js
+22
-58
src/extras/geometries/Path.js
src/extras/geometries/Path.js
+8
-2
src/extras/geometries/TextGeometry.js
src/extras/geometries/TextGeometry.js
+39
-18
未找到文件。
src/extras/geometries/ExtrudeGeometry.js
浏览文件 @
7dbf0554
...
...
@@ -29,7 +29,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
var
amount
=
options
.
amount
!==
undefined
?
options
.
amount
:
100
;
var
bevelThickness
=
options
.
bevelThickness
!==
undefined
?
options
.
bevelThickness
:
8
;
// 10
var
bevelThickness
=
options
.
bevelThickness
!==
undefined
?
options
.
bevelThickness
:
6
;
// 10
var
bevelSize
=
options
.
bevelSize
!==
undefined
?
options
.
bevelSize
:
bevelThickness
;
// 8
var
bevelEnabled
=
options
.
bevelEnabled
!==
undefined
?
options
.
bevelEnabled
:
true
;
// false
var
bevelSegments
=
options
.
bevelSegments
!==
undefined
?
options
.
bevelSegments
:
3
;
...
...
@@ -177,72 +177,39 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
function
getBevelVec
(
pt_i
,
pt_j
,
pt_k
)
{
var
anglea
=
Math
.
atan2
(
pt_j
.
y
-
pt_i
.
y
,
pt_j
.
x
-
pt_i
.
x
);
var
angleb
=
Math
.
atan2
(
pt_k
.
y
-
pt_i
.
y
,
pt_k
.
x
-
pt_i
.
x
);
//var anglea = Math.atan2(pt_i.y - pt_j.y, pt_i.x - pt_j.x);
//var angleb = Math.atan2(pt_i.y - pt_k.y, pt_i.x - pt_k.x);
//if (anglea < 0 ) anglea += Math.PI * 2;
/*
if (angleb <= 0 ) {
angleb += Math.PI * 2;
console.log('ping');
if
(
anglea
>
angleb
)
{
angleb
+=
Math
.
PI
*
2
;
}
*/
x
=
Math
.
cos
(
anglea
)
+
Math
.
cos
(
angleb
);
y
=
Math
.
sin
(
anglea
)
+
Math
.
sin
(
angleb
);
anglec
=
Math
.
atan2
(
y
,
x
);
// var anglea = Math.atan2(pt_i.y - pt_j.y, pt_i.x - pt_j.x);
// var angleb = Math.atan2(pt_i.y - pt_k.y, pt_i.x - pt_k.x);
//
// console.log('>?', anglea > angleb);
//
// if ( anglea < angleb) {
// angleb += Math.PI*2;
// }
console
.
log
(
'
angle1
'
,
anglea
*
RAD_TO_DEGREES
,
'
angle2
'
,
angleb
*
RAD_TO_DEGREES
,
'
anglec
'
,
anglec
*
RAD_TO_DEGREES
);
//x = Math.cos(anglea) + Math.cos(angleb);
//y = Math.sin(anglea) + Math.sin(angleb);
//anglec = Math.atan2(y,x);
/*
x = bevelSize * Math.cos(anglec);
y = bevelSize * Math.sin(anglec);
var vec = new THREE.Vector2(x,y).divideScalar(bevelSize);
*/
anglec
=
(
anglea
+
angleb
)
/
2
;
//console.log('angle1', anglea * RAD_TO_DEGREES,'angle2', angleb * RAD_TO_DEGREES, 'anglec', anglec *RAD_TO_DEGREES);
var
x
=
Math
.
cos
(
anglec
);
var
y
=
Math
.
sin
(
anglec
);
// Check quadrants?
console
.
log
(
x
,
y
,
'
x,y
'
);
/*
var quad1 = Math.PI/2;
var quad2 = Math.PI;
var quad3 = Math.PI * 3/2
var quad4 = Math.PI * 2
anglec %= quad4;
if (anglec < 0 ) anglec += quad4;
console.log('>0', anglec * RAD_TO_DEGREES);
if (anglec < quad1) {
} else
if (anglec < quad2) {
x = -x;
} else if (anglec < quad3) {
y = -y;
x = -x;
} else if (anglec < quad4) {
y = -y;
} else {
console.log("die");
}
*/
var
vec
=
new
THREE
.
Vector2
(
x
,
y
);
var
vec
=
new
THREE
.
Vector2
(
x
,
y
).
normalize
();
console
.
log
(
'
xy
'
,
x
,
y
,
vec
,
pt_i
.
x
+
x
,
pt_i
.
y
+
y
);
return
vec
;
}
...
...
@@ -253,9 +220,8 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
if
(
k
==
il
)
k
=
0
;
// (j)---(i)---(k)
console
.
log
(
'
i,j,k
'
,
i
,
j
,
k
)
//
console.log('i,j,k', i, j , k)
var
pt_i
=
contour
[
i
];
var
pt_j
=
contour
[
j
];
var
pt_k
=
contour
[
k
];
...
...
@@ -266,7 +232,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
}
var
holesMovements
=
[],
oneHoleMovements
;
// expand holes
for
(
h
=
0
,
hl
=
holes
.
length
;
h
<
hl
;
h
++
)
{
ahole
=
holes
[
h
];
...
...
@@ -278,10 +244,8 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
if
(
k
==
il
)
k
=
0
;
// (j)---(i)---(k)
oneHoleMovements
[
i
]
=
getBevelVec
(
ahole
[
i
],
ahole
[
j
],
ahole
[
k
]
);
}
holesMovements
.
push
(
oneHoleMovements
);
...
...
src/extras/geometries/Path.js
浏览文件 @
7dbf0554
...
...
@@ -710,7 +710,7 @@ THREE.Path.prototype.toShapes = function() {
action
=
item
.
action
;
if
(
action
==
THREE
.
PathActions
.
MOVE_TO
)
{
if
(
lastPath
.
actions
!=
0
)
{
if
(
lastPath
.
actions
.
length
!=
0
)
{
subPaths
.
push
(
lastPath
);
lastPath
=
new
THREE
.
Path
();
...
...
@@ -721,7 +721,7 @@ THREE.Path.prototype.toShapes = function() {
}
if
(
lastPath
.
actions
!=
0
)
{
if
(
lastPath
.
actions
.
length
!=
0
)
{
subPaths
.
push
(
lastPath
);
...
...
@@ -733,6 +733,8 @@ THREE.Path.prototype.toShapes = function() {
var
tmpShape
,
shapes
=
[];
var
tmpPath
;
console
.
log
(
"
Holes first
"
,
holesFirst
);
if
(
holesFirst
)
{
tmpShape
=
new
THREE
.
Shape
();
for
(
i
=
0
,
il
=
subPaths
.
length
;
i
<
il
;
i
++
)
{
...
...
@@ -746,8 +748,12 @@ THREE.Path.prototype.toShapes = function() {
shapes
.
push
(
tmpShape
);
tmpShape
=
new
THREE
.
Shape
();
console
.
log
(
'
cw
'
,
i
);
}
else
{
tmpShape
.
holes
.
push
(
tmpPath
);
console
.
log
(
'
ccw
'
,
i
);
}
}
...
...
src/extras/geometries/TextGeometry.js
浏览文件 @
7dbf0554
...
...
@@ -44,6 +44,22 @@ THREE.TextGeometry = function ( text, parameters ) {
};
/*
var text3d = new TextGeometry(text);
FactoryStyle
var text3d = FontUtils.createText(text);
var textPath = new TextPath(text);
var textShapes = textPath.toShapes();
var text3d = new ExtrudeGeometry(textShapes, options);
var textShapes = FontUtils.getTextShapes(text);
text3d = new ExtrudeGeometry(textShapes, options);
*/
THREE
.
TextGeometry
.
prototype
=
new
THREE
.
Geometry
();
THREE
.
TextGeometry
.
prototype
.
constructor
=
THREE
.
TextGeometry
;
...
...
@@ -73,19 +89,6 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
THREE
.
FontUtils
.
bezelSize
=
bezelSize
;
// Get a Font data json object
var
data
=
THREE
.
FontUtils
.
drawText
(
text
);
var
path
=
data
.
path
;
//path.debug(document.getElementById("boo"));
this
.
fontShapes
=
path
.
toShapes
();
console
.
log
(
path
);
//console.log(fontShapes);
// Either find actions or curves.
...
...
@@ -94,8 +97,26 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
};
THREE
.
TextGeometry
.
prototype
.
get
=
function
()
{
var
text3d
=
new
THREE
.
ExtrudeGeometry
(
this
.
fontShapes
,
{
amount
:
20
,
bevelEnabled
:
false
,
bevelThickness
:
3
}
);
// Get a Font data json object
var
data
=
THREE
.
FontUtils
.
drawText
(
this
.
text
);
var
paths
=
data
.
paths
;
var
shapes
=
[];
for
(
var
p
=
0
,
pl
=
paths
.
length
;
p
<
pl
;
p
++
)
{
shapes
=
shapes
.
concat
(
paths
[
p
].
toShapes
());
}
//console.log(path);
//console.log(fontShapes);
// Either find actions or curves.
var
text3d
=
new
THREE
.
ExtrudeGeometry
(
shapes
,
{
amount
:
20
,
bevelEnabled
:
true
,
bevelThickness
:
3
}
);
// TOFIX: Fillet Cap
// FIX HOLES
return
text3d
;
};
...
...
@@ -505,14 +526,14 @@ THREE.FontUtils = {
var
fontPaths
=
[];
var
path
=
new
THREE
.
Path
();
for
(
i
=
0
;
i
<
length
;
i
++
)
{
var
path
=
new
THREE
.
Path
();
var
ret
=
this
.
extractGlyphPoints
(
chars
[
i
],
face
,
scale
,
offset
,
path
);
offset
+=
ret
.
offset
;
characterPts
.
push
(
ret
.
points
);
allPts
=
allPts
.
concat
(
ret
.
points
);
//
fontPaths.push( ret.path );
fontPaths
.
push
(
ret
.
path
);
}
...
...
@@ -529,7 +550,7 @@ THREE.FontUtils = {
var
extract
=
this
.
extractPoints
(
allPts
,
characterPts
);
extract
.
contour
=
allPts
;
extract
.
path
=
path
;
extract
.
path
s
=
fontPaths
;
var
bezelPoints
=
[];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录