Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
049f85e7
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,发现更多精彩内容 >>
提交
049f85e7
编写于
7月 13, 2011
作者:
Z
zz85
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
inital an perhaps buggy additions of spline to path
上级
2f5303fb
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
55 addition
and
5 deletion
+55
-5
src/extras/geometries/Path.js
src/extras/geometries/Path.js
+54
-4
src/extras/geometries/TextGeometry.js
src/extras/geometries/TextGeometry.js
+1
-1
未找到文件。
src/extras/geometries/Path.js
浏览文件 @
049f85e7
...
@@ -21,7 +21,7 @@ THREE.PathActions = {
...
@@ -21,7 +21,7 @@ THREE.PathActions = {
LINE_TO
:
'
lineTo
'
,
LINE_TO
:
'
lineTo
'
,
QUADRATIC_CURVE_TO
:
'
quadraticCurveTo
'
,
// BEZIER quadratic CURVE
QUADRATIC_CURVE_TO
:
'
quadraticCurveTo
'
,
// BEZIER quadratic CURVE
BEZIER_CURVE_TO
:
'
bezierCurveTo
'
,
// BEZIER cubic CURVE
BEZIER_CURVE_TO
:
'
bezierCurveTo
'
,
// BEZIER cubic CURVE
CSPLINE_THRU
:
'
cSplineTo
'
// TODO cardinal splines
CSPLINE_THRU
:
'
splineThru
'
// TODO cardinal splines
};
};
...
@@ -194,6 +194,18 @@ THREE.Path.prototype.getPoints = function( divisions ) {
...
@@ -194,6 +194,18 @@ THREE.Path.prototype.getPoints = function( divisions ) {
case
THREE
.
PathActions
.
CSPLINE_THRU
:
case
THREE
.
PathActions
.
CSPLINE_THRU
:
laste
=
this
.
actions
[
i
-
1
].
args
;
var
last
=
new
THREE
.
Vector2
(
laste
[
laste
.
length
-
2
],
laste
[
laste
.
length
-
1
]);
var
spts
=
args
[
0
];
var
n
=
divisions
*
spts
.
length
;
spts
.
unshift
(
last
);
var
j
=
0
;
var
spline
=
new
Spline2
();
for
(;
j
<
n
;
j
++
)
{
points
.
push
(
spline
.
get2DPoint
(
spts
,
j
/
n
));
}
break
;
break
;
}
}
...
@@ -204,7 +216,43 @@ THREE.Path.prototype.getPoints = function( divisions ) {
...
@@ -204,7 +216,43 @@ THREE.Path.prototype.getPoints = function( divisions ) {
};
};
var
Spline2
=
function
()
{
var
c
=
[],
v2
,
point
,
intPoint
,
weight
;
this
.
get2DPoint
=
function
(
points
,
k
)
{
v2
=
new
THREE
.
Vector2
();
point
=
(
points
.
length
-
1
)
*
k
;
intPoint
=
Math
.
floor
(
point
);
weight
=
point
-
intPoint
;
c
[
0
]
=
intPoint
==
0
?
intPoint
:
intPoint
-
1
;
c
[
1
]
=
intPoint
;
c
[
2
]
=
intPoint
>
points
.
length
-
2
?
intPoint
:
intPoint
+
1
;
c
[
3
]
=
intPoint
>
points
.
length
-
3
?
intPoint
:
intPoint
+
2
;
v2
.
x
=
interpolate
(
points
[
c
[
0
]
].
x
,
points
[
c
[
1
]
].
x
,
points
[
c
[
2
]
].
x
,
points
[
c
[
3
]
].
x
,
weight
);
v2
.
y
=
interpolate
(
points
[
c
[
0
]
].
y
,
points
[
c
[
1
]
].
y
,
points
[
c
[
2
]
].
y
,
points
[
c
[
3
]
].
y
,
weight
);
//console.log('point',point, v2);
return
v2
;
}
// Catmull-Rom
function
interpolate
(
p0
,
p1
,
p2
,
p3
,
t
)
{
var
v0
=
(
p2
-
p0
)
*
0.5
;
var
v1
=
(
p3
-
p1
)
*
0.5
;
var
t2
=
t
*
t
;
var
t3
=
t
*
t2
;
return
(
2
*
p1
-
2
*
p2
+
v0
+
v1
)
*
t3
+
(
-
3
*
p1
+
3
*
p2
-
2
*
v0
-
v1
)
*
t2
+
v0
*
t
+
p1
;
}
};
THREE
.
Path
.
prototype
.
getMinAndMax
=
function
()
{
THREE
.
Path
.
prototype
.
getMinAndMax
=
function
()
{
...
@@ -249,13 +297,14 @@ THREE.Path.prototype.getMinAndMax = function() {
...
@@ -249,13 +297,14 @@ THREE.Path.prototype.getMinAndMax = function() {
THREE
.
Path
.
prototype
.
debug
=
function
(
canvas
)
{
THREE
.
Path
.
prototype
.
debug
=
function
(
canvas
)
{
// JUST A STUB
// JUST A STUB
var
bounds
=
this
.
getMinAndMax
();
if
(
!
canvas
)
{
if
(
!
canvas
)
{
canvas
=
document
.
createElement
(
"
canvas
"
);
canvas
=
document
.
createElement
(
"
canvas
"
);
canvas
.
setAttribute
(
'
width
'
,
200
);
canvas
.
setAttribute
(
'
width
'
,
bounds
.
maxX
+
100
);
canvas
.
setAttribute
(
'
height
'
,
2
00
);
canvas
.
setAttribute
(
'
height
'
,
bounds
.
maxY
+
1
00
);
document
.
body
.
appendChild
(
canvas
);
document
.
body
.
appendChild
(
canvas
);
...
@@ -263,7 +312,7 @@ THREE.Path.prototype.debug = function( canvas ) {
...
@@ -263,7 +312,7 @@ THREE.Path.prototype.debug = function( canvas ) {
var
ctx
=
canvas
.
getContext
(
"
2d
"
);
var
ctx
=
canvas
.
getContext
(
"
2d
"
);
ctx
.
fillStyle
=
"
white
"
;
ctx
.
fillStyle
=
"
white
"
;
ctx
.
fillRect
(
0
,
0
,
200
,
200
);
ctx
.
fillRect
(
0
,
0
,
canvas
.
width
,
canvas
.
height
);
ctx
.
strokeStyle
=
"
black
"
;
ctx
.
strokeStyle
=
"
black
"
;
ctx
.
beginPath
();
ctx
.
beginPath
();
...
@@ -281,6 +330,7 @@ THREE.Path.prototype.debug = function( canvas ) {
...
@@ -281,6 +330,7 @@ THREE.Path.prototype.debug = function( canvas ) {
// Short hand for now
// Short hand for now
if
(
action
!=
THREE
.
PathActions
.
CSPLINE_THRU
)
ctx
[
action
].
apply
(
ctx
,
args
);
ctx
[
action
].
apply
(
ctx
,
args
);
/*
/*
...
...
src/extras/geometries/TextGeometry.js
浏览文件 @
049f85e7
...
@@ -1039,7 +1039,7 @@ THREE.FontUtils = {
...
@@ -1039,7 +1039,7 @@ THREE.FontUtils = {
//throw ( "Warning, unable to triangulate polygon!" );
//throw ( "Warning, unable to triangulate polygon!" );
//return null;
//return null;
// Sometimes warning is fine, especially polygons are triangulated in reverse.
console
.
log
(
"
Warning, unable to triangulate polygon!
"
);
console
.
log
(
"
Warning, unable to triangulate polygon!
"
);
if
(
indices
)
return
vertIndices
;
if
(
indices
)
return
vertIndices
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录