Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
b8ee478f
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,发现更多精彩内容 >>
提交
b8ee478f
编写于
5月 07, 2012
作者:
Z
Zhongpeng Lin (林中鹏)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implemented Path.ellipse
上级
40649e02
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
32124 addition
and
762 deletion
+32124
-762
build/Three.js
build/Three.js
+32037
-728
src/extras/core/Curve.js
src/extras/core/Curve.js
+25
-8
src/extras/core/Path.js
src/extras/core/Path.js
+62
-26
未找到文件。
build/Three.js
浏览文件 @
b8ee478f
此差异已折叠。
点击以展开。
src/extras/core/Curve.js
浏览文件 @
b8ee478f
...
...
@@ -437,17 +437,18 @@ THREE.SplineCurve.prototype.getPoint = function ( t ) {
};
/**************************************************************
*
Arc
curve
*
Ellipse
curve
**************************************************************/
THREE
.
ArcCurve
=
function
(
aX
,
aY
,
a
Radius
,
THREE
.
EllipseCurve
=
function
(
aX
,
aY
,
xRadius
,
y
Radius
,
aStartAngle
,
aEndAngle
,
aClockwise
)
{
this
.
aX
=
aX
;
this
.
aY
=
aY
;
this
.
aRadius
=
aRadius
;
this
.
xRadius
=
xRadius
;
this
.
yRadius
=
yRadius
;
this
.
aStartAngle
=
aStartAngle
;
this
.
aEndAngle
=
aEndAngle
;
...
...
@@ -456,10 +457,10 @@ THREE.ArcCurve = function ( aX, aY, aRadius,
};
THREE
.
Arc
Curve
.
prototype
=
new
THREE
.
Curve
();
THREE
.
ArcCurve
.
prototype
.
constructor
=
THREE
.
Arc
Curve
;
THREE
.
Ellipse
Curve
.
prototype
=
new
THREE
.
Curve
();
THREE
.
EllipseCurve
.
prototype
.
constructor
=
THREE
.
Ellipse
Curve
;
THREE
.
Arc
Curve
.
prototype
.
getPoint
=
function
(
t
)
{
THREE
.
Ellipse
Curve
.
prototype
.
getPoint
=
function
(
t
)
{
var
deltaAngle
=
this
.
aEndAngle
-
this
.
aStartAngle
;
...
...
@@ -471,13 +472,29 @@ THREE.ArcCurve.prototype.getPoint = function ( t ) {
var
angle
=
this
.
aStartAngle
+
t
*
deltaAngle
;
var
tx
=
this
.
aX
+
this
.
a
Radius
*
Math
.
cos
(
angle
);
var
ty
=
this
.
aY
+
this
.
a
Radius
*
Math
.
sin
(
angle
);
var
tx
=
this
.
aX
+
this
.
x
Radius
*
Math
.
cos
(
angle
);
var
ty
=
this
.
aY
+
this
.
y
Radius
*
Math
.
sin
(
angle
);
return
new
THREE
.
Vector2
(
tx
,
ty
);
};
/**************************************************************
* Arc curve
**************************************************************/
THREE
.
ArcCurve
=
function
(
aX
,
aY
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
)
{
THREE
.
EllipseCurve
.
call
(
this
,
aX
,
aY
,
aRadius
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
);
};
THREE
.
ArcCurve
.
prototype
=
new
THREE
.
EllipseCurve
();
THREE
.
ArcCurve
.
prototype
.
constructor
=
THREE
.
ArcCurve
;
/**************************************************************
* Utils
**************************************************************/
...
...
src/extras/core/Path.js
浏览文件 @
b8ee478f
...
...
@@ -29,8 +29,8 @@ THREE.PathActions = {
QUADRATIC_CURVE_TO
:
'
quadraticCurveTo
'
,
// Bezier quadratic curve
BEZIER_CURVE_TO
:
'
bezierCurveTo
'
,
// Bezier cubic curve
CSPLINE_THRU
:
'
splineThru
'
,
// Catmull-rom spline
ARC
:
'
arc
'
// Circle
ARC
:
'
arc
'
,
// Circle
ELLIPSE
:
'
ellipse
'
};
// TODO Clean up PATH API
...
...
@@ -133,16 +133,31 @@ THREE.Path.prototype.splineThru = function( pts /*Array of Vector*/ ) {
};
// FUTURE: Change the API or follow canvas API?
// TODO ARC ( x, y, x - radius, y - radius, startAngle, endAngle )
THREE
.
Path
.
prototype
.
arc
=
function
(
aX
,
aY
,
a
Radius
,
THREE
.
Path
.
prototype
.
ellipse
=
function
(
aX
,
aY
,
xRadius
,
y
Radius
,
aStartAngle
,
aEndAngle
,
aClockwise
)
{
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
laste
=
this
.
actions
[
this
.
actions
.
length
-
1
];
this
.
absellipse
(
laste
.
x
+
aX
,
laste
.
y
+
aY
,
xRadius
,
yRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
);
};
THREE
.
Path
.
prototype
.
arc
=
function
(
aX
,
aY
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
)
{
var
laste
=
this
.
actions
[
this
.
actions
.
length
-
1
];
this
.
absarc
(
laste
.
x
+
aX
,
laste
.
y
+
aY
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
);
};
THREE
.
Path
.
prototype
.
absellipse
=
function
(
aX
,
aY
,
xRadius
,
yRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
)
{
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
curve
=
new
THREE
.
ArcCurve
(
laste
.
x
+
aX
,
laste
.
y
+
aY
,
a
Radius
,
var
curve
=
new
THREE
.
EllipseCurve
(
aX
,
aY
,
xRadius
,
y
Radius
,
aStartAngle
,
aEndAngle
,
aClockwise
);
this
.
curves
.
push
(
curve
);
...
...
@@ -152,29 +167,14 @@ THREE.Path.prototype.arc = function ( aX, aY, aRadius,
args
.
push
(
lastPoint
.
x
);
args
.
push
(
lastPoint
.
y
);
this
.
actions
.
push
(
{
action
:
THREE
.
PathActions
.
ARC
,
args
:
args
}
);
this
.
actions
.
push
(
{
action
:
THREE
.
PathActions
.
ELLIPSE
,
args
:
args
}
);
};
THREE
.
Path
.
prototype
.
absarc
=
function
(
aX
,
aY
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
)
{
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
curve
=
new
THREE
.
ArcCurve
(
aX
,
aY
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
);
this
.
curves
.
push
(
curve
);
// console.log( 'arc', args );
// All of the other actions look to the last two elements in the list to
// find the ending point, so we need to append them.
var
lastPoint
=
curve
.
getPoint
(
aClockwise
?
1
:
0
);
args
.
push
(
lastPoint
.
x
);
args
.
push
(
lastPoint
.
y
);
this
.
actions
.
push
(
{
action
:
THREE
.
PathActions
.
ARC
,
args
:
args
}
);
this
.
absellipse
(
aX
,
aY
,
aRadius
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
);
};
...
...
@@ -342,8 +342,6 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
case
THREE
.
PathActions
.
ARC
:
laste
=
this
.
actions
[
i
-
1
].
args
;
var
aX
=
args
[
0
],
aY
=
args
[
1
],
aRadius
=
args
[
2
],
aStartAngle
=
args
[
3
],
aEndAngle
=
args
[
4
],
...
...
@@ -378,6 +376,44 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
//console.log(points);
break
;
case
THREE
.
PathActions
.
ELLIPSE
:
var
aX
=
args
[
0
],
aY
=
args
[
1
],
xRadius
=
args
[
2
],
yRadius
=
args
[
3
]
aStartAngle
=
args
[
4
],
aEndAngle
=
args
[
5
],
aClockwise
=
!!
args
[
6
];
var
deltaAngle
=
aEndAngle
-
aStartAngle
;
var
angle
;
var
tdivisions
=
divisions
*
2
;
for
(
j
=
1
;
j
<=
tdivisions
;
j
++
)
{
t
=
j
/
tdivisions
;
if
(
!
aClockwise
)
{
t
=
1
-
t
;
}
angle
=
aStartAngle
+
t
*
deltaAngle
;
tx
=
aX
+
xRadius
*
Math
.
cos
(
angle
);
ty
=
aY
+
yRadius
*
Math
.
sin
(
angle
);
//console.log('t', t, 'angle', angle, 'tx', tx, 'ty', ty);
points
.
push
(
new
THREE
.
Vector2
(
tx
,
ty
)
);
}
//console.log(points);
break
;
}
// end switch
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录