Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
971979b1
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,发现更多精彩内容 >>
提交
971979b1
编写于
4月 10, 2018
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Examples: More clean up
上级
dd1d166f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
109 addition
and
308 deletion
+109
-308
examples/canvas_lines_colors.html
examples/canvas_lines_colors.html
+46
-34
examples/canvas_lines_colors_2d.html
examples/canvas_lines_colors_2d.html
+0
-210
examples/files.js
examples/files.js
+0
-1
examples/webgl_lines_colors.html
examples/webgl_lines_colors.html
+63
-63
未找到文件。
examples/canvas_lines_colors.html
浏览文件 @
971979b1
...
@@ -50,43 +50,56 @@
...
@@ -50,43 +50,56 @@
<script
src=
"js/renderers/CanvasRenderer.js"
></script>
<script
src=
"js/renderers/CanvasRenderer.js"
></script>
<script
src=
"js/Detector.js"
></script>
<script
src=
"js/Detector.js"
></script>
<script
src=
"js/libs/stats.min.js"
></script>
<script
src=
"js/geometries/hilbert3D.js"
></script>
<script
src=
"js/geometries/hilbert3D.js"
></script>
<script
src=
"js/geometries/hilbert2D.js"
></script>
<script>
<script>
if
(
!
Detector
.
webgl
)
Detector
.
addGetWebGLMessage
();
if
(
!
Detector
.
webgl
)
Detector
.
addGetWebGLMessage
();
var
mouseX
=
0
,
mouseY
=
0
;
var
mouseX
=
0
,
mouseY
=
0
,
var
windowHalfX
=
window
.
innerWidth
/
2
;
var
windowHalfY
=
window
.
innerHeight
/
2
;
windowHalfX
=
window
.
innerWidth
/
2
,
var
camera
,
scene
,
renderer
;
windowHalfY
=
window
.
innerHeight
/
2
,
camera
,
scene
,
renderer
,
material
;
init
();
init
();
animate
();
animate
();
function
init
()
{
function
init
()
{
var
i
,
container
;
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
camera
=
new
THREE
.
PerspectiveCamera
(
33
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
10000
);
camera
=
new
THREE
.
PerspectiveCamera
(
33
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
10000
);
camera
.
position
.
z
=
7
00
;
camera
.
position
.
z
=
10
00
;
scene
=
new
THREE
.
Scene
();
scene
=
new
THREE
.
Scene
();
renderer
=
new
THREE
.
CanvasRenderer
();
renderer
=
new
THREE
.
CanvasRenderer
();
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
document
.
body
.
appendChild
(
renderer
.
domElement
);
// 2d lines
var
geometry2
=
new
THREE
.
Geometry
(),
points
=
hilbert2D
(
new
THREE
.
Vector3
(
0
,
0
,
0
),
400
,
4
),
colors2
=
[];
for
(
i
=
0
;
i
<
points
.
length
;
i
++
)
{
geometry2
.
vertices
.
push
(
points
[
i
]
);
colors2
[
i
]
=
new
THREE
.
Color
(
0xffffff
);
colors2
[
i
].
setHSL
(
i
/
points
.
length
,
1
,
0.5
);
}
geometry2
.
colors
=
colors2
;
// 3d lines
var
geometry3
=
new
THREE
.
Geometry
(),
var
geometry3
=
new
THREE
.
Geometry
(),
points
=
hilbert3D
(
new
THREE
.
Vector3
(
0
,
0
,
0
),
200.
0
,
2
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
),
points
=
hilbert3D
(
new
THREE
.
Vector3
(
0
,
0
,
0
),
20
0
,
2
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
),
colors3
=
[];
colors3
=
[];
for
(
i
=
0
;
i
<
points
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
points
.
length
;
i
++
)
{
...
@@ -94,7 +107,7 @@
...
@@ -94,7 +107,7 @@
geometry3
.
vertices
.
push
(
points
[
i
]
);
geometry3
.
vertices
.
push
(
points
[
i
]
);
colors3
[
i
]
=
new
THREE
.
Color
(
0xffffff
);
colors3
[
i
]
=
new
THREE
.
Color
(
0xffffff
);
colors3
[
i
].
setHSL
(
i
/
points
.
length
,
1
.0
,
0.5
);
colors3
[
i
].
setHSL
(
i
/
points
.
length
,
1
,
0.5
);
}
}
...
@@ -102,21 +115,17 @@
...
@@ -102,21 +115,17 @@
// lines
// lines
material
=
new
THREE
.
LineBasicMaterial
(
{
color
:
0xffffff
,
opacity
:
1
,
linewidth
:
3
,
vertexColors
:
THREE
.
VertexColors
}
);
var
material
=
new
THREE
.
LineBasicMaterial
(
{
color
:
0xffffff
,
linewidth
:
3
,
vertexColors
:
THREE
.
VertexColors
}
);
var
line
,
p
,
scale
=
0.3
,
d
=
225
;
line
=
new
THREE
.
Line
(
geometry3
,
material
);
line
.
scale
.
x
=
line
.
scale
.
y
=
line
.
scale
.
z
=
scale
*
1.5
;
line
.
position
.
x
=
0
;
line
.
position
.
y
=
0
;
line
.
position
.
z
=
0
;
scene
.
add
(
line
);
//
var
line3d
=
new
THREE
.
Line
(
geometry3
,
material
);
line3d
.
scale
.
set
(
0.4
,
0.4
,
0.4
);
line3d
.
position
.
set
(
200
,
0
,
0
);
scene
.
add
(
line3d
);
stats
=
new
Stats
();
var
line2d
=
new
THREE
.
Line
(
geometry2
,
material
);
//container.appendChild( stats.dom );
line2d
.
scale
.
copy
(
line3d
.
scale
);
line2d
.
position
.
set
(
-
200
,
0
,
0
);
scene
.
add
(
line2d
);
//
//
...
@@ -183,14 +192,12 @@
...
@@ -183,14 +192,12 @@
requestAnimationFrame
(
animate
);
requestAnimationFrame
(
animate
);
render
();
render
();
stats
.
update
();
}
}
function
render
()
{
function
render
()
{
camera
.
position
.
x
+=
(
mouseX
-
camera
.
position
.
x
)
*
.
05
;
camera
.
position
.
x
+=
(
mouseX
-
camera
.
position
.
x
)
*
0
.05
;
camera
.
position
.
y
+=
(
-
mouseY
+
200
-
camera
.
position
.
y
)
*
.
05
;
camera
.
position
.
y
+=
(
-
mouseY
+
200
-
camera
.
position
.
y
)
*
0
.05
;
camera
.
lookAt
(
scene
.
position
);
camera
.
lookAt
(
scene
.
position
);
...
@@ -199,11 +206,16 @@
...
@@ -199,11 +206,16 @@
for
(
var
i
=
0
;
i
<
scene
.
children
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
scene
.
children
.
length
;
i
++
)
{
var
object
=
scene
.
children
[
i
];
var
object
=
scene
.
children
[
i
];
if
(
object
instanceof
THREE
.
Line
)
object
.
rotation
.
y
=
time
*
(
i
%
2
?
1
:
-
1
);
if
(
object
.
isLine
)
{
object
.
rotation
.
y
=
time
*
(
i
%
2
?
1
:
-
1
);
}
}
}
renderer
.
render
(
scene
,
camera
);
renderer
.
render
(
scene
,
camera
);
}
}
...
...
examples/canvas_lines_colors_2d.html
已删除
100644 → 0
浏览文件 @
dd1d166f
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
three.js webgl - lines - cubes - colors
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
>
<style>
body
{
background-color
:
#000000
;
margin
:
0px
;
overflow
:
hidden
;
}
a
{
color
:
#0078ff
;
}
#info
{
position
:
absolute
;
top
:
10px
;
width
:
100%
;
color
:
#ffffff
;
padding
:
5px
;
font-family
:
Monospace
;
font-size
:
13px
;
text-align
:
center
;
z-index
:
100
;
}
a
{
color
:
orange
;
text-decoration
:
none
;
}
a
:hover
{
color
:
#0080ff
;
}
</style>
</head>
<body>
<div
id=
"info"
>
<a
href=
"http://threejs.org"
target=
"_blank"
rel=
"noopener"
>
three.js
</a>
- color lines WebGL demo
[
<a
href=
"http://en.wikipedia.org/wiki/Hilbert_curve"
>
Hilbert curve
</a>
thanks to
<a
href=
"http://www.openprocessing.org/visuals/?visualID=15599"
>
Thomas Diewald
</a>
]
</div>
<script
src=
"../build/three.js"
></script>
<script
src=
"js/renderers/Projector.js"
></script>
<script
src=
"js/renderers/CanvasRenderer.js"
></script>
<script
src=
"js/Detector.js"
></script>
<script
src=
"js/libs/stats.min.js"
></script>
<script
src=
"js/geometries/hilbert2D.js"
></script>
<script>
if
(
!
Detector
.
webgl
)
Detector
.
addGetWebGLMessage
();
var
mouseX
=
0
,
mouseY
=
0
,
windowHalfX
=
window
.
innerWidth
/
2
,
windowHalfY
=
window
.
innerHeight
/
2
,
camera
,
scene
,
renderer
,
material
;
init
();
animate
();
function
init
()
{
var
i
,
container
;
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
camera
=
new
THREE
.
PerspectiveCamera
(
33
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
10000
);
camera
.
position
.
z
=
700
;
scene
=
new
THREE
.
Scene
();
renderer
=
new
THREE
.
CanvasRenderer
();
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
var
geometry3
=
new
THREE
.
Geometry
(),
points
=
hilbert2D
(
new
THREE
.
Vector3
(
0
,
0
,
0
),
400.0
,
4
),
colors3
=
[];
for
(
i
=
0
;
i
<
points
.
length
;
i
++
)
{
geometry3
.
vertices
.
push
(
points
[
i
]
);
colors3
[
i
]
=
new
THREE
.
Color
(
0xffffff
);
colors3
[
i
].
setHSL
(
i
/
points
.
length
,
1.0
,
0.5
);
}
geometry3
.
colors
=
colors3
;
// lines
material
=
new
THREE
.
LineBasicMaterial
(
{
color
:
0xffffff
,
opacity
:
1
,
linewidth
:
3
,
vertexColors
:
THREE
.
VertexColors
}
);
var
line
,
p
,
scale
=
0.3
,
d
=
225
;
line
=
new
THREE
.
Line
(
geometry3
,
material
);
line
.
scale
.
x
=
line
.
scale
.
y
=
line
.
scale
.
z
=
scale
*
1.5
;
line
.
position
.
x
=
0
;
line
.
position
.
y
=
0
;
line
.
position
.
z
=
0
;
scene
.
add
(
line
);
//
stats
=
new
Stats
();
//container.appendChild( stats.dom );
//
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
document
.
addEventListener
(
'
touchstart
'
,
onDocumentTouchStart
,
false
);
document
.
addEventListener
(
'
touchmove
'
,
onDocumentTouchMove
,
false
);
//
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
}
function
onWindowResize
()
{
windowHalfX
=
window
.
innerWidth
/
2
;
windowHalfY
=
window
.
innerHeight
/
2
;
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
function
onDocumentMouseMove
(
event
)
{
mouseX
=
event
.
clientX
-
windowHalfX
;
mouseY
=
event
.
clientY
-
windowHalfY
;
}
function
onDocumentTouchStart
(
event
)
{
if
(
event
.
touches
.
length
>
1
)
{
event
.
preventDefault
();
mouseX
=
event
.
touches
[
0
].
pageX
-
windowHalfX
;
mouseY
=
event
.
touches
[
0
].
pageY
-
windowHalfY
;
}
}
function
onDocumentTouchMove
(
event
)
{
if
(
event
.
touches
.
length
==
1
)
{
event
.
preventDefault
();
mouseX
=
event
.
touches
[
0
].
pageX
-
windowHalfX
;
mouseY
=
event
.
touches
[
0
].
pageY
-
windowHalfY
;
}
}
//
function
animate
()
{
requestAnimationFrame
(
animate
);
render
();
stats
.
update
();
}
function
render
()
{
camera
.
position
.
x
+=
(
mouseX
-
camera
.
position
.
x
)
*
.
05
;
camera
.
position
.
y
+=
(
-
mouseY
+
200
-
camera
.
position
.
y
)
*
.
05
;
camera
.
lookAt
(
scene
.
position
);
var
time
=
Date
.
now
()
*
0.0005
;
for
(
var
i
=
0
;
i
<
scene
.
children
.
length
;
i
++
)
{
var
object
=
scene
.
children
[
i
];
if
(
object
instanceof
THREE
.
Line
)
object
.
rotation
.
y
=
time
*
(
i
%
2
?
1
:
-
1
);
}
renderer
.
render
(
scene
,
camera
);
}
</script>
</body>
</html>
examples/files.js
浏览文件 @
971979b1
...
@@ -374,7 +374,6 @@ var files = {
...
@@ -374,7 +374,6 @@ var files = {
"
canvas_lights_pointlights
"
,
"
canvas_lights_pointlights
"
,
"
canvas_lines
"
,
"
canvas_lines
"
,
"
canvas_lines_colors
"
,
"
canvas_lines_colors
"
,
"
canvas_lines_colors_2d
"
,
"
canvas_lines_dashed
"
,
"
canvas_lines_dashed
"
,
"
canvas_lines_sphere
"
,
"
canvas_lines_sphere
"
,
"
canvas_materials
"
,
"
canvas_materials
"
,
...
...
examples/webgl_lines_colors.html
浏览文件 @
971979b1
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
<body>
<body>
<div
id=
"info"
>
<div
id=
"info"
>
<a
href=
"http://threejs.org"
target=
"_blank"
rel=
"noopener"
>
three.js
</a>
- color
s WebGL demo
<a
href=
"http://threejs.org"
target=
"_blank"
rel=
"noopener"
>
three.js
</a>
- color
lines
[
<a
href=
"http://en.wikipedia.org/wiki/Hilbert_curve"
>
Hilbert curve
</a>
thanks to
<a
href=
"http://www.openprocessing.org/visuals/?visualID=15599"
>
Thomas Diewald
</a>
]
[
<a
href=
"http://en.wikipedia.org/wiki/Hilbert_curve"
>
Hilbert curve
</a>
thanks to
<a
href=
"http://www.openprocessing.org/visuals/?visualID=15599"
>
Thomas Diewald
</a>
]
</div>
</div>
...
@@ -54,23 +54,18 @@
...
@@ -54,23 +54,18 @@
if
(
!
Detector
.
webgl
)
Detector
.
addGetWebGLMessage
();
if
(
!
Detector
.
webgl
)
Detector
.
addGetWebGLMessage
();
var
mouseX
=
0
,
mouseY
=
0
,
var
mouseX
=
0
,
mouseY
=
0
;
windowHalfX
=
window
.
innerWidth
/
2
,
var
windowHalfX
=
window
.
innerWidth
/
2
;
windowHalfY
=
window
.
innerHeight
/
2
,
var
windowHalfY
=
window
.
innerHeight
/
2
;
camera
,
scene
,
renderer
,
material
;
var
camera
,
scene
,
renderer
;
init
();
init
();
animate
();
animate
();
function
init
()
{
function
init
()
{
var
i
,
container
;
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
camera
=
new
THREE
.
PerspectiveCamera
(
33
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
10000
);
camera
=
new
THREE
.
PerspectiveCamera
(
33
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
10000
);
camera
.
position
.
z
=
1000
;
camera
.
position
.
z
=
1000
;
...
@@ -79,102 +74,107 @@
...
@@ -79,102 +74,107 @@
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
document
.
body
.
appendChild
(
renderer
.
domElement
);
container
.
appendChild
(
renderer
.
domElement
);
//
var
hilbertPoints
=
hilbert3D
(
new
THREE
.
Vector3
(
0
,
0
,
0
),
200.0
,
1
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
);
var
hilbertPoints
=
hilbert3D
(
new
THREE
.
Vector3
(
0
,
0
,
0
),
200.0
,
1
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
);
// Colors with BufferGeometry
var
geometry1
=
new
THREE
.
BufferGeometry
();
var
geometry2
=
new
THREE
.
BufferGeometry
();
var
buffGeometry0
=
new
THREE
.
BufferGeometry
(),
var
geometry3
=
new
THREE
.
BufferGeometry
();
buffGeometry1
=
new
THREE
.
BufferGeometry
(),
buffGeometry2
=
new
THREE
.
BufferGeometry
();
var
subdivisions
=
6
;
var
subdivisions
=
6
;
var
position
=
[],
var
vertices
=
[];
colorArray0
=
[],
var
colors1
=
[];
colorArray1
=
[],
var
colors2
=
[];
colorArray2
=
[];
var
colors3
=
[];
var
point
=
new
THREE
.
Vector3
();
var
point
=
new
THREE
.
Vector3
();
var
color
=
new
THREE
.
Color
();
var
color
=
new
THREE
.
Color
();
var
spline
=
new
THREE
.
CatmullRomCurve3
(
hilbertPoints
);
var
spline
=
new
THREE
.
CatmullRomCurve3
(
hilbertPoints
);
for
(
i
=
0
;
i
<
hilbertPoints
.
length
*
subdivisions
;
i
++
)
{
for
(
var
i
=
0
;
i
<
hilbertPoints
.
length
*
subdivisions
;
i
++
)
{
var
t
=
i
/
(
hilbertPoints
.
length
*
subdivisions
);
var
t
=
i
/
(
hilbertPoints
.
length
*
subdivisions
);
spline
.
getPoint
(
t
,
point
);
spline
.
getPoint
(
t
,
point
);
position
.
push
(
point
.
x
,
point
.
y
,
point
.
z
);
vertices
.
push
(
point
.
x
,
point
.
y
,
point
.
z
);
color
.
setHSL
(
0.6
,
1.0
,
Math
.
max
(
0
,
-
point
.
x
/
200
)
+
0.5
);
color
.
setHSL
(
0.6
,
1.0
,
Math
.
max
(
0
,
-
point
.
x
/
200
)
+
0.5
);
color
Array0
.
push
(
color
.
r
,
color
.
g
,
color
.
b
);
color
s1
.
push
(
color
.
r
,
color
.
g
,
color
.
b
);
color
.
setHSL
(
0.9
,
1.0
,
Math
.
max
(
0
,
-
point
.
y
/
200
)
+
0.5
);
color
.
setHSL
(
0.9
,
1.0
,
Math
.
max
(
0
,
-
point
.
y
/
200
)
+
0.5
);
color
Array1
.
push
(
color
.
r
,
color
.
g
,
color
.
b
);
color
s2
.
push
(
color
.
r
,
color
.
g
,
color
.
b
);
color
.
setHSL
(
i
/
(
hilbertPoints
.
length
*
subdivisions
),
1.0
,
0.5
);
color
.
setHSL
(
i
/
(
hilbertPoints
.
length
*
subdivisions
),
1.0
,
0.5
);
color
Array2
.
push
(
color
.
r
,
color
.
g
,
color
.
b
);
color
s3
.
push
(
color
.
r
,
color
.
g
,
color
.
b
);
}
}
buffGeometry0
.
addAttribute
(
'
position
'
,
new
THREE
.
Float32BufferAttribute
(
position
,
3
)
);
geometry1
.
addAttribute
(
'
position
'
,
new
THREE
.
Float32BufferAttribute
(
vertices
,
3
)
);
buffGeometry1
.
addAttribute
(
'
position
'
,
new
THREE
.
Float32BufferAttribute
(
position
,
3
)
);
geometry2
.
addAttribute
(
'
position
'
,
new
THREE
.
Float32BufferAttribute
(
vertices
,
3
)
);
buffGeometry2
.
addAttribute
(
'
position
'
,
new
THREE
.
Float32BufferAttribute
(
position
,
3
)
);
geometry3
.
addAttribute
(
'
position
'
,
new
THREE
.
Float32BufferAttribute
(
vertices
,
3
)
);
buffGeometry0
.
addAttribute
(
'
color
'
,
new
THREE
.
Float32BufferAttribute
(
colorArray0
,
3
)
);
geometry1
.
addAttribute
(
'
color
'
,
new
THREE
.
Float32BufferAttribute
(
colors1
,
3
)
);
buffGeometry1
.
addAttribute
(
'
color
'
,
new
THREE
.
Float32BufferAttribute
(
colorArray1
,
3
)
);
geometry2
.
addAttribute
(
'
color
'
,
new
THREE
.
Float32BufferAttribute
(
colors2
,
3
)
);
buffGeometry2
.
addAttribute
(
'
color
'
,
new
THREE
.
Float32BufferAttribute
(
colorArray2
,
3
)
);
geometry3
.
addAttribute
(
'
color
'
,
new
THREE
.
Float32BufferAttribute
(
colors3
,
3
)
);
//
Colors with Geometry
//
var
geometry
0
=
new
THREE
.
Geometry
(),
var
geometry
4
=
new
THREE
.
BufferGeometry
();
geometry2
=
new
THREE
.
Geometry
(),
var
geometry5
=
new
THREE
.
BufferGeometry
();
geometry3
=
new
THREE
.
Geometry
();
var
geometry6
=
new
THREE
.
Buffer
Geometry
();
var
colors0
=
[],
vertices
=
[];
colors1
=
[],
colors1
=
[];
colors2
=
[];
colors2
=
[];
colors3
=
[];
for
(
i
=
0
;
i
<
hilbertPoints
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
hilbertPoints
.
length
;
i
++
)
{
geometry0
.
vertices
.
push
(
hilbertPoints
[
i
]
)
;
var
point
=
hilbertPoints
[
i
]
;
colors0
[
i
]
=
new
THREE
.
Color
(
0xffffff
);
vertices
.
push
(
point
.
x
,
point
.
y
,
point
.
z
);
colors0
[
i
].
setHSL
(
0.6
,
1.0
,
Math
.
max
(
0
,
(
200
-
hilbertPoints
[
i
].
x
)
/
400
)
*
0.5
+
0.5
);
color
s1
[
i
]
=
new
THREE
.
Color
(
0xffffff
);
color
.
setHSL
(
0.6
,
1.0
,
Math
.
max
(
0
,
(
200
-
hilbertPoints
[
i
].
x
)
/
400
)
*
0.5
+
0.5
);
colors1
[
i
].
setHSL
(
0.3
,
1.0
,
Math
.
max
(
0
,
(
200
+
hilbertPoints
[
i
].
x
)
/
400
)
*
0.5
);
colors1
.
push
(
color
.
r
,
color
.
g
,
color
.
b
);
colors2
[
i
]
=
new
THREE
.
Color
(
0xffffff
);
color
.
setHSL
(
0.3
,
1.0
,
Math
.
max
(
0
,
(
200
+
hilbertPoints
[
i
].
x
)
/
400
)
*
0.5
);
colors2
[
i
].
setHSL
(
i
/
hilbertPoints
.
length
,
1.0
,
0.5
);
colors2
.
push
(
color
.
r
,
color
.
g
,
color
.
b
);
color
.
setHSL
(
i
/
hilbertPoints
.
length
,
1.0
,
0.5
);
colors3
.
push
(
color
.
r
,
color
.
g
,
color
.
b
);
}
}
geometry2
.
vertices
=
geometry3
.
vertices
=
geometry0
.
vertices
;
geometry4
.
addAttribute
(
'
position
'
,
new
THREE
.
Float32BufferAttribute
(
vertices
,
3
)
);
geometry5
.
addAttribute
(
'
position
'
,
new
THREE
.
Float32BufferAttribute
(
vertices
,
3
)
);
geometry6
.
addAttribute
(
'
position
'
,
new
THREE
.
Float32BufferAttribute
(
vertices
,
3
)
);
geometry
0
.
colors
=
colors0
;
geometry
4
.
addAttribute
(
'
color
'
,
new
THREE
.
Float32BufferAttribute
(
colors1
,
3
)
)
;
geometry
2
.
colors
=
colors1
;
geometry
5
.
addAttribute
(
'
color
'
,
new
THREE
.
Float32BufferAttribute
(
colors2
,
3
)
)
;
geometry
3
.
colors
=
colors2
;
geometry
6
.
addAttribute
(
'
color
'
,
new
THREE
.
Float32BufferAttribute
(
colors3
,
3
)
)
;
// Create lines and add to scene
// Create lines and add to scene
material
=
new
THREE
.
LineBasicMaterial
(
{
color
:
0xffffff
,
opacity
:
1
,
linewidth
:
3
,
vertexColors
:
THREE
.
VertexColors
}
);
var
material
=
new
THREE
.
LineBasicMaterial
(
{
color
:
0xffffff
,
vertexColors
:
THREE
.
VertexColors
}
);
var
line
,
p
,
scale
=
0.3
,
d
=
225
;
var
line
,
p
,
scale
=
0.3
,
d
=
225
;
var
parameters
=
[
var
parameters
=
[
[
material
,
scale
*
1.5
,
[
-
d
,
-
d
/
2
,
0
],
buffGeometry0
],
[
material
,
scale
*
1.5
,
[
-
d
,
-
d
/
2
,
0
],
geometry1
],
[
material
,
scale
*
1.5
,
[
0
,
-
d
/
2
,
0
],
buffGeometry1
],
[
material
,
scale
*
1.5
,
[
0
,
-
d
/
2
,
0
],
geometry2
],
[
material
,
scale
*
1.5
,
[
d
,
-
d
/
2
,
0
],
buffGeometry2
],
[
material
,
scale
*
1.5
,
[
d
,
-
d
/
2
,
0
],
geometry3
],
[
material
,
scale
*
1.5
,
[
-
d
,
d
/
2
,
0
],
geometry
0
],
[
material
,
scale
*
1.5
,
[
-
d
,
d
/
2
,
0
],
geometry
4
],
[
material
,
scale
*
1.5
,
[
0
,
d
/
2
,
0
],
geometry
2
],
[
material
,
scale
*
1.5
,
[
0
,
d
/
2
,
0
],
geometry
5
],
[
material
,
scale
*
1.5
,
[
d
,
d
/
2
,
0
],
geometry
3
],
[
material
,
scale
*
1.5
,
[
d
,
d
/
2
,
0
],
geometry
6
],
];
];
for
(
i
=
0
;
i
<
parameters
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
parameters
.
length
;
i
++
)
{
p
=
parameters
[
i
];
p
=
parameters
[
i
];
line
=
new
THREE
.
Line
(
p
[
3
],
p
[
0
]
);
line
=
new
THREE
.
Line
(
p
[
3
],
p
[
0
]
);
...
@@ -186,13 +186,13 @@
...
@@ -186,13 +186,13 @@
}
}
//
Input Event Listeners
//
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
document
.
addEventListener
(
'
touchstart
'
,
onDocumentTouchStart
,
false
);
document
.
addEventListener
(
'
touchstart
'
,
onDocumentTouchStart
,
false
);
document
.
addEventListener
(
'
touchmove
'
,
onDocumentTouchMove
,
false
);
document
.
addEventListener
(
'
touchmove
'
,
onDocumentTouchMove
,
false
);
//
Resize Event Listener
//
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
...
@@ -252,8 +252,8 @@
...
@@ -252,8 +252,8 @@
function
render
()
{
function
render
()
{
camera
.
position
.
x
+=
(
mouseX
-
camera
.
position
.
x
)
*
.
05
;
camera
.
position
.
x
+=
(
mouseX
-
camera
.
position
.
x
)
*
0
.05
;
camera
.
position
.
y
+=
(
-
mouseY
+
200
-
camera
.
position
.
y
)
*
.
05
;
camera
.
position
.
y
+=
(
-
mouseY
+
200
-
camera
.
position
.
y
)
*
0
.05
;
camera
.
lookAt
(
scene
.
position
);
camera
.
lookAt
(
scene
.
position
);
...
@@ -263,7 +263,7 @@
...
@@ -263,7 +263,7 @@
var
object
=
scene
.
children
[
i
];
var
object
=
scene
.
children
[
i
];
if
(
object
instanceof
THREE
.
Line
)
{
if
(
object
.
is
Line
)
{
object
.
rotation
.
y
=
time
*
(
i
%
2
?
1
:
-
1
);
object
.
rotation
.
y
=
time
*
(
i
%
2
?
1
:
-
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录