Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
7ee8fb8f
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,发现更多精彩内容 >>
提交
7ee8fb8f
编写于
7月 14, 2011
作者:
Z
zz85
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Playing with text wrapping with quad bezier using arc lengths
上级
cac14305
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
50 addition
and
2 deletion
+50
-2
src/extras/geometries/Path.js
src/extras/geometries/Path.js
+50
-2
未找到文件。
src/extras/geometries/Path.js
浏览文件 @
7ee8fb8f
...
...
@@ -327,6 +327,9 @@ THREE.Path.prototype.createPathGeometry = function(divisions, lineMaterial) {
return
(
pathGeometry
);
};
// ALL THINGS BELOW TO BE REFACTORSED
// QN: Transform final pts or transform ACTIONS or add transform filters?
THREE
.
Path
.
prototype
.
getPoint
=
function
(
t
)
{
var
x0
,
y0
,
x1
,
y1
,
x2
,
y2
;
x0
=
this
.
actions
[
0
].
args
[
0
];
...
...
@@ -368,18 +371,61 @@ THREE.Path.prototype.getNormalVector = function(t) {
};
THREE
.
Path
.
prototype
.
cacheArcLengths
=
function
()
{
var
divisions
=
200
;
var
cache
=
[];
var
p
=
1
;
var
last
=
this
.
getPoint
(
0
),
current
;
var
sum
=
0
;
for
(;
p
<=
divisions
;
p
++
)
{
current
=
this
.
getPoint
(
p
/
divisions
);
sum
+=
current
.
distanceTo
(
last
);
cache
.
push
(
sum
);
last
=
current
;
}
this
.
arcLengthCache
=
cache
;
return
{
sums
:
cache
,
sum
:
sum
};
};
/* Given u (0..1), get a t to find p. This gives you pt which are equi distance */
THREE
.
Path
.
prototype
.
getUtoTmapping
=
function
(
u
,
distance
)
{
//var arcs = this.cacheArcLengths();
var
cache
=
this
.
arcLengthCache
;
var
i
=
0
,
il
=
cache
.
length
;
var
distanceForU
=
u
*
cache
[
cache
.
length
-
1
];
if
(
distance
)
distanceForU
=
distance
;
// Should do binary search + sub division + interpolation if needed
while
(
i
<
il
)
{
if
(
cache
[
i
]
>
distanceForU
)
break
;
i
++
;
}
var
t
=
i
/
il
;
return
t
;
};
var
tangentQuad
=
function
(
t
,
p0
,
p1
,
p2
)
{
return
2
*
(
1
-
t
)
*
(
p1
-
p0
)
+
2
*
t
*
(
p2
-
p1
)
;
}
// FUTURE refactor path = an array of lines -> straight, bezier, splines, arc, funcexpr lines
// Read http://www.planetclegg.com/projects/WarpingTextToSplines.html
THREE
.
Path
.
prototype
.
transform
=
function
(
path
)
{
path
=
new
THREE
.
Path
();
path
.
moveTo
(
0
,
0
);
path
.
quadraticCurveTo
(
100
,
50
,
400
,
0
);
path
.
quadraticCurveTo
(
200
,
20
,
240
,
80
);
console
.
log
(
path
.
cacheArcLengths
());
var
thisBounds
=
this
.
getMinAndMax
();
...
...
@@ -391,6 +437,8 @@ THREE.Path.prototype.transform = function(path) {
oldY
=
p
.
y
;
var
xNorm
=
oldX
/
thisBounds
.
maxX
;
xNorm
=
path
.
getUtoTmapping
(
xNorm
,
oldX
);
// 3 styles. 1) wrap stretched. 2) wrap stretch by arc length 3) warp by actual distance
var
pathPt
=
path
.
getPoint
(
xNorm
);
var
normal
=
path
.
getNormalVector
(
xNorm
).
multiplyScalar
(
oldY
);;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录