Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
fda0a0a8
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,发现更多精彩内容 >>
提交
fda0a0a8
编写于
9月 28, 2012
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplified AxisHelper.
上级
15dbd15b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
35 addition
and
70 deletion
+35
-70
build/three.min.js
build/three.min.js
+1
-2
editor/js/ui/Viewport.js
editor/js/ui/Viewport.js
+6
-9
examples/webgl_animation_cloth.html
examples/webgl_animation_cloth.html
+1
-7
examples/webgl_geometries.html
examples/webgl_geometries.html
+1
-1
examples/webgl_geometries2.html
examples/webgl_geometries2.html
+1
-1
examples/webgl_geometry_convex.html
examples/webgl_geometry_convex.html
+1
-1
src/extras/geometries/TubeGeometry.js
src/extras/geometries/TubeGeometry.js
+10
-12
src/extras/helpers/AxisHelper.js
src/extras/helpers/AxisHelper.js
+14
-37
未找到文件。
build/three.min.js
浏览文件 @
fda0a0a8
...
...
@@ -716,8 +716,7 @@ q,o]);g.push([q,p,o])}else{e.push(new THREE.Face4(a,f,j,l));g.push([m,q,p,o])}}t
THREE
.
ConvexGeometry
=
function
(
a
){
function
b
(
a
){
var
b
=
a
.
length
();
return
new
THREE
.
UV
(
a
.
x
/
b
,
a
.
y
/
b
)}
THREE
.
Geometry
.
call
(
this
);
for
(
var
c
=
[[
0
,
1
,
2
],[
0
,
2
,
1
]],
d
=
3
;
d
<
a
.
length
;
d
++
){
var
f
=
d
,
e
=
a
[
f
].
clone
(),
g
=
e
.
length
();
e
.
x
=
e
.
x
+
g
*
(
Math
.
random
()
-
0.5
)
*
2
E
-
6
;
e
.
y
=
e
.
y
+
g
*
(
Math
.
random
()
-
0.5
)
*
2
E
-
6
;
e
.
z
=
e
.
z
+
g
*
(
Math
.
random
()
-
0.5
)
*
2
E
-
6
;
for
(
var
g
=
[],
h
=
0
;
h
<
c
.
length
;){
var
i
=
c
[
h
],
j
=
e
,
l
=
a
[
i
[
0
]],
n
;
n
=
l
;
var
m
=
a
[
i
[
1
]],
q
=
a
[
i
[
2
]],
o
=
new
THREE
.
Vector3
,
p
=
new
THREE
.
Vector3
;
o
.
sub
(
q
,
m
);
p
.
sub
(
n
,
m
);
o
.
crossSelf
(
p
);
o
.
isZero
()
||
o
.
normalize
();
n
=
o
;
l
=
n
.
dot
(
l
);
if
(
n
.
dot
(
j
)
>=
l
){
for
(
j
=
0
;
j
<
3
;
j
++
){
l
=
[
i
[
j
],
i
[(
j
+
1
)
%
3
]];
n
=
true
;
for
(
m
=
0
;
m
<
g
.
length
;
m
++
)
if
(
g
[
m
][
0
]
===
l
[
1
]
&&
g
[
m
][
1
]
===
l
[
0
]){
g
[
m
]
=
g
[
g
.
length
-
1
];
g
.
pop
();
n
=
false
;
break
}
n
&&
g
.
push
(
l
)}
c
[
h
]
=
c
[
c
.
length
-
1
];
c
.
pop
()}
else
h
++
}
for
(
m
=
0
;
m
<
g
.
length
;
m
++
)
c
.
push
([
g
[
m
][
0
],
g
[
m
][
1
],
f
])}
f
=
0
;
e
=
Array
(
a
.
length
);
for
(
d
=
0
;
d
<
c
.
length
;
d
++
){
g
=
c
[
d
];
for
(
h
=
0
;
h
<
3
;
h
++
){
if
(
e
[
g
[
h
]]
===
void
0
){
e
[
g
[
h
]]
=
f
++
;
this
.
vertices
.
push
(
a
[
g
[
h
]])}
g
[
h
]
=
e
[
g
[
h
]]}}
for
(
d
=
0
;
d
<
c
.
length
;
d
++
)
this
.
faces
.
push
(
new
THREE
.
Face3
(
c
[
d
][
0
],
c
[
d
][
1
],
c
[
d
][
2
]));
for
(
d
=
0
;
d
<
this
.
faces
.
length
;
d
++
){
g
=
this
.
faces
[
d
];
this
.
faceVertexUvs
[
0
].
push
([
b
(
this
.
vertices
[
g
.
a
]),
b
(
this
.
vertices
[
g
.
b
]),
b
(
this
.
vertices
[
g
.
c
])])}
this
.
computeCentroids
();
this
.
computeFaceNormals
();
this
.
computeVertexNormals
()};
THREE
.
ConvexGeometry
.
prototype
=
Object
.
create
(
THREE
.
Geometry
.
prototype
);
THREE
.
AxisHelper
=
function
(){
THREE
.
Object3D
.
call
(
this
);
var
a
=
new
THREE
.
Geometry
;
a
.
vertices
.
push
(
new
THREE
.
Vector3
);
a
.
vertices
.
push
(
new
THREE
.
Vector3
(
0
,
100
,
0
));
var
b
=
new
THREE
.
CylinderGeometry
(
0
,
5
,
25
,
5
,
1
),
c
;
c
=
new
THREE
.
Line
(
a
,
new
THREE
.
LineBasicMaterial
({
color
:
16711680
}));
c
.
rotation
.
z
=-
Math
.
PI
/
2
;
this
.
add
(
c
);
c
=
new
THREE
.
Mesh
(
b
,
new
THREE
.
MeshBasicMaterial
({
color
:
16711680
}));
c
.
position
.
x
=
100
;
c
.
rotation
.
z
=-
Math
.
PI
/
2
;
this
.
add
(
c
);
c
=
new
THREE
.
Line
(
a
,
new
THREE
.
LineBasicMaterial
({
color
:
65280
}));
this
.
add
(
c
);
c
=
new
THREE
.
Mesh
(
b
,
new
THREE
.
MeshBasicMaterial
({
color
:
65280
}));
c
.
position
.
y
=
100
;
this
.
add
(
c
);
c
=
new
THREE
.
Line
(
a
,
new
THREE
.
LineBasicMaterial
({
color
:
255
}));
c
.
rotation
.
x
=
Math
.
PI
/
2
;
this
.
add
(
c
);
c
=
new
THREE
.
Mesh
(
b
,
new
THREE
.
MeshBasicMaterial
({
color
:
255
}));
c
.
position
.
z
=
100
;
c
.
rotation
.
x
=
Math
.
PI
/
2
;
this
.
add
(
c
)};
THREE
.
AxisHelper
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
AxisHelper
=
function
(){
var
a
=
new
THREE
.
Geometry
;
a
.
vertices
.
push
(
new
THREE
.
Vector3
,
new
THREE
.
Vector3
(
1
,
0
,
0
),
new
THREE
.
Vector3
,
new
THREE
.
Vector3
(
0
,
1
,
0
),
new
THREE
.
Vector3
,
new
THREE
.
Vector3
(
0
,
0
,
1
));
a
.
colors
.
push
(
new
THREE
.
Color
(
16711680
),
new
THREE
.
Color
(
16755200
),
new
THREE
.
Color
(
65280
),
new
THREE
.
Color
(
11206400
),
new
THREE
.
Color
(
255
),
new
THREE
.
Color
(
43775
));
var
b
=
new
THREE
.
LineBasicMaterial
({
vertexColors
:
THREE
.
VertexColors
});
THREE
.
Line
.
call
(
this
,
a
,
b
,
THREE
.
LinePieces
)};
THREE
.
AxisHelper
.
prototype
=
Object
.
create
(
THREE
.
Line
.
prototype
);
THREE
.
ArrowHelper
=
function
(
a
,
b
,
c
,
d
){
THREE
.
Object3D
.
call
(
this
);
d
===
void
0
&&
(
d
=
16776960
);
c
===
void
0
&&
(
c
=
20
);
var
f
=
new
THREE
.
Geometry
;
f
.
vertices
.
push
(
new
THREE
.
Vector3
(
0
,
0
,
0
));
f
.
vertices
.
push
(
new
THREE
.
Vector3
(
0
,
1
,
0
));
this
.
line
=
new
THREE
.
Line
(
f
,
new
THREE
.
LineBasicMaterial
({
color
:
d
}));
this
.
add
(
this
.
line
);
f
=
new
THREE
.
CylinderGeometry
(
0
,
0.05
,
0.25
,
5
,
1
);
this
.
cone
=
new
THREE
.
Mesh
(
f
,
new
THREE
.
MeshBasicMaterial
({
color
:
d
}));
this
.
cone
.
position
.
set
(
0
,
1
,
0
);
this
.
add
(
this
.
cone
);
if
(
b
instanceof
THREE
.
Vector3
)
this
.
position
=
b
;
this
.
setDirection
(
a
);
this
.
setLength
(
c
)};
THREE
.
ArrowHelper
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
ArrowHelper
.
prototype
.
setDirection
=
function
(
a
){
var
b
=
(
new
THREE
.
Vector3
(
0
,
1
,
0
)).
crossSelf
(
a
),
a
=
Math
.
acos
((
new
THREE
.
Vector3
(
0
,
1
,
0
)).
dot
(
a
.
clone
().
normalize
()));
this
.
matrix
=
(
new
THREE
.
Matrix4
).
makeRotationAxis
(
b
.
normalize
(),
a
);
this
.
rotation
.
setEulerFromRotationMatrix
(
this
.
matrix
,
this
.
eulerOrder
)};
THREE
.
ArrowHelper
.
prototype
.
setLength
=
function
(
a
){
this
.
scale
.
set
(
a
,
a
,
a
)};
THREE
.
ArrowHelper
.
prototype
.
setColor
=
function
(
a
){
this
.
line
.
material
.
color
.
setHex
(
a
);
this
.
cone
.
material
.
color
.
setHex
(
a
)};
...
...
editor/js/ui/Viewport.js
浏览文件 @
fda0a0a8
...
...
@@ -37,16 +37,13 @@ var Viewport = function ( signals ) {
sceneHelpers
.
add
(
selectionBox
);
var
selectionAxis
=
new
THREE
.
AxisHelper
();
selectionAxis
.
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeScale
(
100
,
100
,
100
)
);
selectionAxis
.
material
.
depthTest
=
false
;
selectionAxis
.
material
.
transparent
=
true
;
selectionAxis
.
matrixAutoUpdate
=
false
;
selectionAxis
.
visible
=
false
;
sceneHelpers
.
add
(
selectionAxis
);
for
(
var
i
=
0
;
i
<
selectionAxis
.
children
.
length
;
i
++
)
{
selectionAxis
.
children
[
i
].
material
.
depthTest
=
false
;
selectionAxis
.
children
[
i
].
material
.
transparent
=
true
;
}
//
var
scene
=
new
THREE
.
Scene
();
...
...
@@ -136,7 +133,7 @@ var Viewport = function ( signals ) {
signals
.
objectSelected
.
add
(
function
(
object
)
{
selectionBox
.
visible
=
false
;
selectionAxis
.
traverse
(
function
(
object
)
{
object
.
visible
=
false
}
)
;
selectionAxis
.
visible
=
false
;
if
(
object
!==
null
&&
object
.
geometry
)
{
...
...
@@ -188,7 +185,7 @@ var Viewport = function ( signals ) {
selectionAxis
.
matrixWorld
=
object
.
matrixWorld
;
selectionBox
.
visible
=
true
;
selectionAxis
.
traverse
(
function
(
object
)
{
object
.
visible
=
true
}
)
;
selectionAxis
.
visible
=
true
;
}
...
...
examples/webgl_animation_cloth.html
浏览文件 @
fda0a0a8
...
...
@@ -225,13 +225,7 @@
arrow
=
new
THREE
.
ArrowHelper
(
new
THREE
.
Vector3
(
0
,
1
,
0
),
new
THREE
.
Vector3
(
0
,
0
,
0
),
50
,
0xff0000
);
arrow
.
position
.
set
(
-
200
,
0
,
-
200
);
//scene.add( arrow );
var
axis
;
axis
=
new
THREE
.
AxisHelper
();
axis
.
position
.
set
(
200
,
0
,
-
200
);
axis
.
scale
.
x
=
axis
.
scale
.
y
=
axis
.
scale
.
z
=
0.5
;
//scene.add( axis );
// scene.add( arrow );
// ground
...
...
examples/webgl_geometries.html
浏览文件 @
fda0a0a8
...
...
@@ -113,7 +113,7 @@
object
=
new
THREE
.
AxisHelper
();
object
.
position
.
set
(
200
,
0
,
-
200
);
object
.
scale
.
x
=
object
.
scale
.
y
=
object
.
scale
.
z
=
0.5
;
object
.
scale
.
x
=
object
.
scale
.
y
=
object
.
scale
.
z
=
50
;
scene
.
add
(
object
);
object
=
new
THREE
.
ArrowHelper
(
new
THREE
.
Vector3
(
0
,
1
,
0
),
new
THREE
.
Vector3
(
0
,
0
,
0
),
50
);
...
...
examples/webgl_geometries2.html
浏览文件 @
fda0a0a8
...
...
@@ -159,7 +159,7 @@
object
=
new
THREE
.
AxisHelper
();
object
.
position
.
set
(
200
,
0
,
-
200
);
object
.
scale
.
x
=
object
.
scale
.
y
=
object
.
scale
.
z
=
0.5
;
object
.
scale
.
x
=
object
.
scale
.
y
=
object
.
scale
.
z
=
50
;
scene
.
add
(
object
);
object
=
new
THREE
.
ArrowHelper
(
new
THREE
.
Vector3
(
0
,
1
,
0
),
new
THREE
.
Vector3
(
0
,
0
,
0
),
50
);
...
...
examples/webgl_geometry_convex.html
浏览文件 @
fda0a0a8
...
...
@@ -104,7 +104,7 @@
object
=
new
THREE
.
AxisHelper
();
object
.
position
.
set
(
200
,
0
,
-
200
);
object
.
scale
.
x
=
object
.
scale
.
y
=
object
.
scale
.
z
=
0.5
;
object
.
scale
.
x
=
object
.
scale
.
y
=
object
.
scale
.
z
=
50
;
scene
.
add
(
object
);
object
=
new
THREE
.
ArrowHelper
(
new
THREE
.
Vector3
(
0
,
1
,
0
),
new
THREE
.
Vector3
(
0
,
0
,
0
),
50
);
...
...
src/extras/geometries/TubeGeometry.js
浏览文件 @
fda0a0a8
...
...
@@ -20,6 +20,7 @@ THREE.TubeGeometry = function( path, segments, radius, segmentsRadius, closed, d
this
.
radius
=
radius
||
1
;
this
.
segmentsRadius
=
segmentsRadius
||
8
;
this
.
closed
=
closed
||
false
;
if
(
debug
)
this
.
debug
=
new
THREE
.
Object3D
();
this
.
grid
=
[];
...
...
@@ -31,7 +32,7 @@ THREE.TubeGeometry = function( path, segments, radius, segmentsRadius, closed, d
binormal
,
numpoints
=
this
.
segments
+
1
,
x
,
y
,
z
,
tx
,
ty
,
tz
,
u
,
v
,
...
...
@@ -53,7 +54,6 @@ THREE.TubeGeometry = function( path, segments, radius, segmentsRadius, closed, d
this
.
normals
=
normals
;
this
.
binormals
=
binormals
;
function
vert
(
x
,
y
,
z
)
{
return
scope
.
vertices
.
push
(
new
THREE
.
Vector3
(
x
,
y
,
z
)
)
-
1
;
...
...
@@ -61,8 +61,6 @@ THREE.TubeGeometry = function( path, segments, radius, segmentsRadius, closed, d
}
// consruct the grid
for
(
i
=
0
;
i
<
numpoints
;
i
++
)
{
...
...
@@ -79,9 +77,9 @@ THREE.TubeGeometry = function( path, segments, radius, segmentsRadius, closed, d
if
(
this
.
debug
)
{
this
.
debug
.
add
(
new
THREE
.
ArrowHelper
(
tangent
,
pos
,
radius
,
0x0000ff
));
this
.
debug
.
add
(
new
THREE
.
ArrowHelper
(
normal
,
pos
,
radius
,
0xff0000
)
);
this
.
debug
.
add
(
new
THREE
.
ArrowHelper
(
binormal
,
pos
,
radius
,
0x00ff00
)
);
this
.
debug
.
add
(
new
THREE
.
ArrowHelper
(
tangent
,
pos
,
radius
,
0x0000ff
)
);
this
.
debug
.
add
(
new
THREE
.
ArrowHelper
(
normal
,
pos
,
radius
,
0xff0000
)
);
this
.
debug
.
add
(
new
THREE
.
ArrowHelper
(
binormal
,
pos
,
radius
,
0x00ff00
)
);
}
...
...
@@ -92,12 +90,12 @@ THREE.TubeGeometry = function( path, segments, radius, segmentsRadius, closed, d
cx
=
-
this
.
radius
*
Math
.
cos
(
v
);
// TODO: Hack: Negating it so it faces outside.
cy
=
this
.
radius
*
Math
.
sin
(
v
);
pos2
.
copy
(
pos
);
pos2
.
x
+=
cx
*
normal
.
x
+
cy
*
binormal
.
x
;
pos2
.
y
+=
cx
*
normal
.
y
+
cy
*
binormal
.
y
;
pos2
.
z
+=
cx
*
normal
.
z
+
cy
*
binormal
.
z
;
pos2
.
copy
(
pos
);
pos2
.
x
+=
cx
*
normal
.
x
+
cy
*
binormal
.
x
;
pos2
.
y
+=
cx
*
normal
.
y
+
cy
*
binormal
.
y
;
pos2
.
z
+=
cx
*
normal
.
z
+
cy
*
binormal
.
z
;
this
.
grid
[
i
][
j
]
=
vert
(
pos2
.
x
,
pos2
.
y
,
pos2
.
z
);
this
.
grid
[
i
][
j
]
=
vert
(
pos2
.
x
,
pos2
.
y
,
pos2
.
z
);
}
}
...
...
src/extras/helpers/AxisHelper.js
浏览文件 @
fda0a0a8
...
...
@@ -5,47 +5,24 @@
THREE
.
AxisHelper
=
function
()
{
THREE
.
Object3D
.
call
(
this
);
var
geometry
=
new
THREE
.
Geometry
(
);
var
lineGeometry
=
new
THREE
.
Geometry
();
lineGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
()
);
lineGeometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
0
,
100
,
0
)
);
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
(),
new
THREE
.
Vector3
(
1
,
0
,
0
),
new
THREE
.
Vector3
(),
new
THREE
.
Vector3
(
0
,
1
,
0
),
new
THREE
.
Vector3
(),
new
THREE
.
Vector3
(
0
,
0
,
1
)
);
var
coneGeometry
=
new
THREE
.
CylinderGeometry
(
0
,
5
,
25
,
5
,
1
);
geometry
.
colors
.
push
(
new
THREE
.
Color
(
0xff0000
),
new
THREE
.
Color
(
0xffaa00
),
new
THREE
.
Color
(
0x00ff00
),
new
THREE
.
Color
(
0xaaff00
),
new
THREE
.
Color
(
0x0000ff
),
new
THREE
.
Color
(
0x00aaff
)
);
var
line
,
cone
;
var
material
=
new
THREE
.
LineBasicMaterial
(
{
vertexColors
:
THREE
.
VertexColors
}
)
;
// x
line
=
new
THREE
.
Line
(
lineGeometry
,
new
THREE
.
LineBasicMaterial
(
{
color
:
0xff0000
}
)
);
line
.
rotation
.
z
=
-
Math
.
PI
/
2
;
this
.
add
(
line
);
cone
=
new
THREE
.
Mesh
(
coneGeometry
,
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xff0000
}
)
);
cone
.
position
.
x
=
100
;
cone
.
rotation
.
z
=
-
Math
.
PI
/
2
;
this
.
add
(
cone
);
// y
line
=
new
THREE
.
Line
(
lineGeometry
,
new
THREE
.
LineBasicMaterial
(
{
color
:
0x00ff00
}
)
);
this
.
add
(
line
);
cone
=
new
THREE
.
Mesh
(
coneGeometry
,
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x00ff00
}
)
);
cone
.
position
.
y
=
100
;
this
.
add
(
cone
);
// z
line
=
new
THREE
.
Line
(
lineGeometry
,
new
THREE
.
LineBasicMaterial
(
{
color
:
0x0000ff
}
)
);
line
.
rotation
.
x
=
Math
.
PI
/
2
;
this
.
add
(
line
);
cone
=
new
THREE
.
Mesh
(
coneGeometry
,
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x0000ff
}
)
);
cone
.
position
.
z
=
100
;
cone
.
rotation
.
x
=
Math
.
PI
/
2
;
this
.
add
(
cone
);
THREE
.
Line
.
call
(
this
,
geometry
,
material
,
THREE
.
LinePieces
);
};
THREE
.
AxisHelper
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
AxisHelper
.
prototype
=
Object
.
create
(
THREE
.
Line
.
prototype
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录