Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
eb17987e
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,发现更多精彩内容 >>
提交
eb17987e
编写于
7月 27, 2011
作者:
Z
zz85
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New Bevel algorithm, TextPath, TextGeometry updated
上级
b72d731c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
81 addition
and
53 deletion
+81
-53
src/extras/geometries/ExtrudeGeometry.js
src/extras/geometries/ExtrudeGeometry.js
+31
-22
src/extras/geometries/Path.js
src/extras/geometries/Path.js
+6
-5
src/extras/geometries/TextGeometry.js
src/extras/geometries/TextGeometry.js
+44
-26
未找到文件。
src/extras/geometries/ExtrudeGeometry.js
浏览文件 @
eb17987e
...
...
@@ -4,7 +4,10 @@
**/
THREE
.
ExtrudeGeometry
=
function
(
shapes
,
options
)
{
if
(
typeof
(
shapes
)
==
"
undefined
"
)
{
shapes
=
[];
}
THREE
.
Geometry
.
call
(
this
);
shapes
=
shapes
instanceof
Array
?
shapes
:
[
shapes
];
...
...
@@ -12,8 +15,9 @@ THREE.ExtrudeGeometry = function( shapes, options ) {
var
s
=
0
,
sl
=
shapes
.
length
,
shape
;
for
(;
s
<
sl
;
s
++
)
{
shape
=
shapes
[
s
];
console
.
log
(
shape
);
//
console.log(shape);
this
.
addShape
(
shape
,
options
);
}
...
...
@@ -29,7 +33,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
var
amount
=
options
.
amount
!==
undefined
?
options
.
amount
:
100
;
var
bevelThickness
=
options
.
bevelThickness
!==
undefined
?
options
.
bevelThickness
:
6
;
// 10
var
bevelThickness
=
options
.
bevelThickness
!==
undefined
?
options
.
bevelThickness
:
10
;
// 10
var
bevelSize
=
options
.
bevelSize
!==
undefined
?
options
.
bevelSize
:
bevelThickness
;
// 8
var
bevelEnabled
=
options
.
bevelEnabled
!==
undefined
?
options
.
bevelEnabled
:
true
;
// false
...
...
@@ -264,15 +268,15 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
// Loop bevelSegments, 1 for the front, 1 for the back
for
(
b
=
bevelSegments
;
b
>
0
;
b
--
)
{
for
(
b
=
0
;
b
<
bevelSegments
;
b
++
)
{
//
for ( b = bevelSegments; b > 0; b -- ) {
t
=
b
/
bevelSegments
;
z
=
bevelThickness
*
t
;
z
=
bevelThickness
*
(
1
-
t
)
;
//
Formula could probably be simplified
//bs = bevelSize * (Math.sin ((1-t) * Math.PI/2 )) ; //bevelSize * t ;
bs
=
bevelSize
*
(
1
-
t
)
;
//
z = bevelThickness * t;
bs
=
bevelSize
*
(
Math
.
sin
((
t
)
*
Math
.
PI
/
2
))
;
// curved
//bs = bevelSize * t ; // linear
// contract shape
for
(
i
=
0
,
il
=
contour
.
length
;
i
<
il
;
i
++
)
{
...
...
@@ -284,8 +288,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
}
console
.
log
(
bs
);
// expand holes
for
(
h
=
0
,
hl
=
holes
.
length
;
h
<
hl
;
h
++
)
{
...
...
@@ -306,17 +309,17 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
}
bs
=
bevelSize
;
// Back facing vertices
for
(
i
=
0
;
i
<
vlen
;
i
++
)
{
vert
=
vertices
[
i
];
//v( vert.x, vert.y, 0
);
//
vert = vertices[ i ];
vert
=
scalePt2
(
vertices
[
i
],
verticesMovements
[
i
],
bs
);
if
(
!
extrudeByPath
)
{
vert
=
scalePt2
(
vert
,
verticesMovements
[
i
],
bs
);
v
(
vert
.
x
,
vert
.
y
,
0
);
}
else
{
...
...
@@ -336,10 +339,11 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
for
(
i
=
0
;
i
<
vlen
;
i
++
)
{
vert
=
vertices
[
i
];
//vert = vertices[ i ];
vert
=
scalePt2
(
vertices
[
i
],
verticesMovements
[
i
],
bs
);
if
(
!
extrudeByPath
)
{
vert
=
scalePt2
(
vert
,
verticesMovements
[
i
],
bs
);
v
(
vert
.
x
,
vert
.
y
,
amount
/
steps
*
s
);
}
else
{
...
...
@@ -355,17 +359,20 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
// Add bevel segments planes
for
(
b
=
1
;
b
<=
bevelSegments
;
b
++
)
{
//for ( b = 1; b <= bevelSegments; b ++ ) {
for
(
b
=
bevelSegments
-
1
;
b
>=
0
;
b
--
)
{
t
=
b
/
bevelSegments
;
z
=
bevelThickness
*
t
;
bs
=
bevelSize
*
(
1
-
Math
.
sin
(
(
1
-
t
)
*
Math
.
PI
/
2
)
);
z
=
bevelThickness
*
(
1
-
t
);
//bs = bevelSize * ( 1-Math.sin ( ( 1 - t ) * Math.PI/2 ) );
bs
=
bevelSize
*
Math
.
sin
(
t
*
Math
.
PI
/
2
)
;
// contract shape
for
(
i
=
0
,
il
=
contour
.
length
;
i
<
il
;
i
++
)
{
vert
=
scalePt
(
contour
[
i
],
contourCentroid
,
bs
,
false
);
vert
=
scalePt2
(
contour
[
i
],
contourMovements
[
i
],
bs
);
//vert = scalePt( contour[ i ], contourCentroid, bs, false );
v
(
vert
.
x
,
vert
.
y
,
amount
+
z
);
}
...
...
@@ -375,10 +382,12 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
for
(
h
=
0
,
hl
=
holes
.
length
;
h
<
hl
;
h
++
)
{
ahole
=
holes
[
h
];
oneHoleMovements
=
holesMovements
[
h
];
for
(
i
=
0
,
il
=
ahole
.
length
;
i
<
il
;
i
++
)
{
vert
=
scalePt
(
ahole
[
i
],
holesCentroids
[
h
],
bs
,
true
);
//vert = scalePt( ahole[ i ], holesCentroids[h], bs, true );
vert
=
scalePt2
(
ahole
[
i
],
oneHoleMovements
[
i
],
bs
);
if
(
!
extrudeByPath
)
{
...
...
src/extras/geometries/Path.js
浏览文件 @
eb17987e
...
...
@@ -747,13 +747,14 @@ THREE.Path.prototype.toShapes = function() {
}
console
.
log
(
subPaths
);
//console.log(subPaths);
if
(
subPaths
.
length
==
0
)
return
[];
var
holesFirst
=
!
THREE
.
Shape
.
Utils
.
isClockWise
(
subPaths
[
0
].
getPoints
());
var
tmpShape
,
shapes
=
[];
var
tmpPath
;
console
.
log
(
"
Holes first
"
,
holesFirst
);
//
console.log("Holes first", holesFirst);
if
(
holesFirst
)
{
tmpShape
=
new
THREE
.
Shape
();
...
...
@@ -768,11 +769,11 @@ THREE.Path.prototype.toShapes = function() {
shapes
.
push
(
tmpShape
);
tmpShape
=
new
THREE
.
Shape
();
console
.
log
(
'
cw
'
,
i
);
//
console.log('cw', i);
}
else
{
tmpShape
.
holes
.
push
(
tmpPath
);
console
.
log
(
'
ccw
'
,
i
);
//
console.log('ccw', i);
}
...
...
@@ -799,7 +800,7 @@ THREE.Path.prototype.toShapes = function() {
shapes
.
push
(
tmpShape
);
}
console
.
log
(
"
shape
"
,
shapes
);
//
console.log("shape", shapes);
return
shapes
;
};
src/extras/geometries/TextGeometry.js
浏览文件 @
eb17987e
...
...
@@ -35,35 +35,18 @@
*
*/
THREE
.
TextGeometry
=
function
(
text
,
parameters
)
{
THREE
.
Geometry
.
call
(
this
);
THREE
.
TextPath
=
function
(
text
,
parameters
)
{
THREE
.
Path
.
call
(
this
);
this
.
parameters
=
parameters
||
{};
this
.
set
(
text
);
};
/*
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
;
THREE
.
TextGeometry
.
prototype
.
set
=
function
(
text
,
parameters
)
{
THREE
.
TextPath
.
prototype
.
set
=
function
(
text
,
parameters
)
{
this
.
text
=
text
;
var
parameters
=
parameters
||
this
.
parameters
;
...
...
@@ -92,7 +75,9 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
};
THREE
.
TextGeometry
.
prototype
.
get
=
function
()
{
THREE
.
TextPath
.
prototype
.
toShapes
=
function
()
{
// Get a Font data json object
...
...
@@ -104,18 +89,51 @@ THREE.TextGeometry.prototype.get = function () {
for
(
var
p
=
0
,
pl
=
paths
.
length
;
p
<
pl
;
p
++
)
{
shapes
=
shapes
.
concat
(
paths
[
p
].
toShapes
());
}
return
shapes
;
//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
;
//var text3d = new THREE.ExtrudeGeometry( shapes , { amount: 20, bevelEnabled:true, bevelThickness:3 } );
//return text3d;
};
THREE
.
TextGeometry
=
function
(
text
,
parameters
)
{
var
textPath
=
new
THREE
.
TextPath
(
text
,
parameters
);
var
textShapes
=
textPath
.
toShapes
();
console
.
log
(
"
params
"
,
parameters
);
THREE
.
ExtrudeGeometry
.
call
(
this
,
textShapes
,
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
.
ExtrudeGeometry
();
THREE
.
TextGeometry
.
prototype
.
constructor
=
THREE
.
TextGeometry
;
THREE
.
FontUtils
=
{
faces
:
{},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录