Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
5bdc8489
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,发现更多精彩内容 >>
提交
5bdc8489
编写于
1月 19, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7989 from rfm1201/Lathe-with-Vector2
Lathe with Vector2
上级
9cf29aff
2108a4eb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
29 deletion
+76
-29
editor/js/Menubar.Add.js
editor/js/Menubar.Add.js
+13
-13
editor/js/Sidebar.Geometry.LatheGeometry.js
editor/js/Sidebar.Geometry.LatheGeometry.js
+14
-3
src/extras/geometries/LatheGeometry.js
src/extras/geometries/LatheGeometry.js
+47
-12
src/loaders/ObjectLoader.js
src/loaders/ObjectLoader.js
+2
-1
未找到文件。
editor/js/Menubar.Add.js
浏览文件 @
5bdc8489
...
...
@@ -254,19 +254,19 @@ Menubar.Add = function ( editor ) {
var
phiStart
=
0
;
var
phiLength
=
2
*
Math
.
PI
;
points
.
push
(
new
THREE
.
Vector
3
(
0
,
0
,
0
)
);
points
.
push
(
new
THREE
.
Vector
3
(
4
,
0
,
0
)
);
points
.
push
(
new
THREE
.
Vector
3
(
3.5
,
0
,
0.5
)
);
points
.
push
(
new
THREE
.
Vector
3
(
1
,
0
,
0.75
)
);
points
.
push
(
new
THREE
.
Vector
3
(
0.8
,
0
,
1
)
);
points
.
push
(
new
THREE
.
Vector
3
(
0.8
,
0
,
4
)
);
points
.
push
(
new
THREE
.
Vector
3
(
1
,
0
,
4.2
)
);
points
.
push
(
new
THREE
.
Vector
3
(
1.4
,
0
,
4.8
)
);
points
.
push
(
new
THREE
.
Vector
3
(
2
,
0
,
5
)
);
points
.
push
(
new
THREE
.
Vector
3
(
2.5
,
0
,
5.4
)
);
points
.
push
(
new
THREE
.
Vector
3
(
2.5
,
0
,
12
)
);
var
geometry
=
new
THREE
.
LatheGeometry
(
points
,
segments
,
phiStart
,
phiLength
);
points
.
push
(
new
THREE
.
Vector
2
(
0
,
0
)
);
points
.
push
(
new
THREE
.
Vector
2
(
4
,
0
)
);
points
.
push
(
new
THREE
.
Vector
2
(
3.5
,
0.5
)
);
points
.
push
(
new
THREE
.
Vector
2
(
1
,
0.75
)
);
points
.
push
(
new
THREE
.
Vector
2
(
0.8
,
1
)
);
points
.
push
(
new
THREE
.
Vector
2
(
0.8
,
4
)
);
points
.
push
(
new
THREE
.
Vector
2
(
1
,
4.2
)
);
points
.
push
(
new
THREE
.
Vector
2
(
1.4
,
4.8
)
);
points
.
push
(
new
THREE
.
Vector
2
(
2
,
5
)
);
points
.
push
(
new
THREE
.
Vector
2
(
2.5
,
5.4
)
);
points
.
push
(
new
THREE
.
Vector
2
(
3
,
12
)
);
var
geometry
=
new
THREE
.
LatheGeometry
(
points
,
segments
,
phiStart
,
phiLength
,
'
Y
'
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshStandardMaterial
(
{
side
:
THREE
.
DoubleSide
}
)
);
mesh
.
name
=
'
Lathe
'
+
(
++
meshCount
);
...
...
editor/js/Sidebar.Geometry.LatheGeometry.js
浏览文件 @
5bdc8489
...
...
@@ -40,6 +40,16 @@ Sidebar.Geometry.LatheGeometry = function( editor, object ) {
container
.
add
(
phiLengthRow
);
// axe
var
axeRow
=
new
UI
.
Row
();
var
axe
=
new
UI
.
Input
(
parameters
.
axe
).
setWidth
(
'
10px
'
).
onChange
(
update
);
axeRow
.
add
(
new
UI
.
Text
(
'
Axe
'
).
setWidth
(
'
90px
'
)
);
axeRow
.
add
(
axe
);
container
.
add
(
axeRow
);
// points
var
lastPointIdx
=
0
;
...
...
@@ -57,7 +67,7 @@ Sidebar.Geometry.LatheGeometry = function( editor, object ) {
for
(
var
i
=
0
;
i
<
parameters
.
points
.
length
;
i
++
)
{
var
point
=
parameters
.
points
[
i
];
pointsList
.
add
(
createPointRow
(
point
.
x
,
point
.
z
)
);
pointsList
.
add
(
createPointRow
(
point
.
x
,
point
.
y
)
);
}
...
...
@@ -119,7 +129,7 @@ Sidebar.Geometry.LatheGeometry = function( editor, object ) {
if
(
!
pointUI
)
continue
;
points
.
push
(
new
THREE
.
Vector
3
(
pointUI
.
x
.
getValue
(),
0
,
pointUI
.
y
.
getValue
()
)
);
points
.
push
(
new
THREE
.
Vector
2
(
pointUI
.
x
.
getValue
()
,
pointUI
.
y
.
getValue
()
)
);
count
++
;
pointUI
.
lbl
.
setValue
(
count
);
...
...
@@ -129,7 +139,8 @@ Sidebar.Geometry.LatheGeometry = function( editor, object ) {
points
,
segments
.
getValue
(),
phiStart
.
getValue
()
/
180
*
Math
.
PI
,
phiLength
.
getValue
()
/
180
*
Math
.
PI
phiLength
.
getValue
()
/
180
*
Math
.
PI
,
axe
.
getValue
()
);
editor
.
execute
(
new
SetGeometryCommand
(
object
,
geometry
)
);
...
...
src/extras/geometries/LatheGeometry.js
浏览文件 @
5bdc8489
...
...
@@ -4,31 +4,50 @@
* @author bhouston / http://clara.io
*/
// points - to create a closed torus, one must use a set of points
// points - to create a closed torus, one must use a set of points
// like so: [ a, b, c, d, a ], see first is the same as last.
// segments - the number of circumference segments to create
// phiStart - the starting radian
// phiLength - the radian (0 to 2*PI) range of the lathed section
// 2*pi is a closed lathe, less than 2PI is a portion.
// axe - the axis of revolution ('X', 'Y' or 'Z')
THREE
.
LatheGeometry
=
function
(
points
,
segments
,
phiStart
,
phiLength
)
{
THREE
.
LatheGeometry
=
function
(
points
,
segments
,
phiStart
,
phiLength
,
axe
)
{
var
thePoints
=
points
;
if
(
points
.
length
&&
points
[
0
]
instanceof
THREE
.
Vector3
)
{
console
.
warn
(
'
THREE.LatheGeometry has been updated. Use an array of THREE.Vector2 as first parameter.
'
);
thePoints
=
[];
axe
=
'
Z
'
;
for
(
var
i
=
0
;
i
<
points
.
length
;
i
++
)
{
var
pt
=
points
[
i
];
thePoints
.
push
(
new
THREE
.
Vector2
(
Math
.
sqrt
(
pt
.
x
*
pt
.
x
+
pt
.
y
*
pt
.
y
),
pt
.
z
)
);
}
}
THREE
.
Geometry
.
call
(
this
);
this
.
type
=
'
LatheGeometry
'
;
this
.
parameters
=
{
points
:
p
oints
,
points
:
theP
oints
,
segments
:
segments
,
phiStart
:
phiStart
,
phiLength
:
phiLength
phiLength
:
phiLength
,
axe
:
axe
};
segments
=
segments
||
12
;
phiStart
=
phiStart
||
0
;
phiLength
=
phiLength
||
2
*
Math
.
PI
;
axe
=
axe
||
'
Y
'
;
var
inversePointLength
=
1.0
/
(
p
oints
.
length
-
1
);
var
inversePointLength
=
1.0
/
(
theP
oints
.
length
-
1
);
var
inverseSegments
=
1.0
/
segments
;
for
(
var
i
=
0
,
il
=
segments
;
i
<=
il
;
i
++
)
{
...
...
@@ -38,15 +57,31 @@ THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
var
c
=
Math
.
cos
(
phi
),
s
=
Math
.
sin
(
phi
);
for
(
var
j
=
0
,
jl
=
p
oints
.
length
;
j
<
jl
;
j
++
)
{
for
(
var
j
=
0
,
jl
=
theP
oints
.
length
;
j
<
jl
;
j
++
)
{
var
pt
=
p
oints
[
j
];
var
pt
=
theP
oints
[
j
];
var
vertex
=
new
THREE
.
Vector3
();
vertex
.
x
=
c
*
pt
.
x
-
s
*
pt
.
y
;
vertex
.
y
=
s
*
pt
.
x
+
c
*
pt
.
y
;
vertex
.
z
=
pt
.
z
;
if
(
axe
===
'
Z
'
)
{
vertex
.
x
=
c
*
pt
.
x
;
vertex
.
y
=
s
*
pt
.
x
;
vertex
.
z
=
pt
.
y
;
}
else
if
(
axe
===
'
X
'
)
{
vertex
.
y
=
c
*
pt
.
x
;
vertex
.
z
=
s
*
pt
.
x
;
vertex
.
x
=
pt
.
y
;
}
else
{
vertex
.
z
=
c
*
pt
.
x
;
vertex
.
x
=
s
*
pt
.
x
;
vertex
.
y
=
pt
.
y
;
}
this
.
vertices
.
push
(
vertex
);
...
...
@@ -54,11 +89,11 @@ THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
}
var
np
=
p
oints
.
length
;
var
np
=
theP
oints
.
length
;
for
(
var
i
=
0
,
il
=
segments
;
i
<
il
;
i
++
)
{
for
(
var
j
=
0
,
jl
=
p
oints
.
length
-
1
;
j
<
jl
;
j
++
)
{
for
(
var
j
=
0
,
jl
=
theP
oints
.
length
-
1
;
j
<
jl
;
j
++
)
{
var
base
=
j
+
np
*
i
;
var
a
=
base
;
...
...
src/loaders/ObjectLoader.js
浏览文件 @
5bdc8489
...
...
@@ -263,7 +263,8 @@ THREE.ObjectLoader.prototype = {
data
.
points
,
data
.
segments
,
data
.
phiStart
,
data
.
phiLength
data
.
phiLength
,
data
.
axe
);
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录