Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
cf7dc4d2
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,发现更多精彩内容 >>
提交
cf7dc4d2
编写于
11月 21, 2010
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cube.js now does merge vertices pass.
上级
0bc79b59
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
31 deletion
+62
-31
build/Three.js
build/Three.js
+1
-1
build/ThreeDebug.js
build/ThreeDebug.js
+1
-1
examples/materials_cubemap_sky.html
examples/materials_cubemap_sky.html
+11
-29
src/extras/primitives/Cube.js
src/extras/primitives/Cube.js
+49
-0
未找到文件。
build/Three.js
浏览文件 @
cf7dc4d2
...
...
@@ -72,7 +72,7 @@ THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this
THREE
.
MeshNormalMaterial
=
function
(
a
){
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
FlatShading
;
this
.
blending
=
THREE
.
NormalBlending
;
if
(
a
){
if
(
a
.
opacity
!==
undefined
)
this
.
opacity
=
a
.
opacity
;
if
(
a
.
shading
!==
undefined
)
this
.
shading
=
a
.
shading
;
if
(
a
.
blending
!==
undefined
)
this
.
blending
=
a
.
blending
}
this
.
toString
=
function
(){
return
"
THREE.MeshNormalMaterial
"
}};
THREE
.
MeshFaceMaterial
=
function
(){
this
.
toString
=
function
(){
return
"
THREE.MeshFaceMaterial
"
}};
THREE
.
ParticleBasicMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
offset
=
new
THREE
.
Vector2
;
if
(
a
){
a
.
color
!==
undefined
&&
this
.
color
.
setHex
(
a
.
color
);
if
(
a
.
map
!==
undefined
)
this
.
map
=
a
.
map
;
if
(
a
.
opacity
!==
undefined
)
this
.
opacity
=
a
.
opacity
;
if
(
a
.
blending
!==
undefined
)
this
.
blending
=
a
.
blending
}
this
.
toString
=
function
(){
return
"
THREE.ParticleBasicMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleCircleMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
if
(
a
){
a
.
color
!==
undefined
&&
this
.
color
.
setHex
(
a
.
color
);
if
(
a
.
opacity
!==
undefined
)
this
.
opacity
=
a
.
opacity
;
if
(
a
.
blending
!==
undefined
)
this
.
blending
=
a
.
blending
}
this
.
toString
=
function
(){
return
"
THREE.ParticleCircleMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleDOMMaterial
=
function
(
a
){
this
.
domElement
=
a
;
this
.
toString
=
function
(){
return
"
THREE.ParticleDOMMaterial ( domElement:
"
+
this
.
domElement
+
"
)
"
}};
THREE
.
Texture
=
function
(
a
,
c
){
this
.
image
=
a
;
this
.
mapping
=
c
?
c
:
THREE
.
UVMapping
;
this
.
toString
=
function
(){
return
"
THREE.Texture (<br/>image:
"
+
this
.
image
+
"
<br/>mapping:
"
+
this
.
mapping
+
"
<br/>)
"
}};
THREE
.
UVMapping
=
0
;
THREE
.
ReflectionMap
=
1
;
THREE
.
RefractionMap
=
2
;
THREE
.
Multiply
=
0
;
THREE
.
Mix
=
1
;
THREE
.
ParticleDOMMaterial
=
function
(
a
){
this
.
domElement
=
a
;
this
.
toString
=
function
(){
return
"
THREE.ParticleDOMMaterial ( domElement:
"
+
this
.
domElement
+
"
)
"
}};
THREE
.
Texture
=
function
(
a
,
c
){
this
.
image
=
a
;
this
.
mapping
=
c
!==
undefined
?
c
:
THREE
.
UVMapping
;
this
.
toString
=
function
(){
return
"
THREE.Texture (<br/>image:
"
+
this
.
image
+
"
<br/>mapping:
"
+
this
.
mapping
+
"
<br/>)
"
}};
THREE
.
UVMapping
=
0
;
THREE
.
ReflectionMap
=
1
;
THREE
.
RefractionMap
=
2
;
THREE
.
Multiply
=
0
;
THREE
.
Mix
=
1
;
THREE
.
TextureCube
=
function
(
a
,
c
){
this
.
image
=
a
;
this
.
mapping
=
c
?
c
:
THREE
.
ReflectionMap
;
this
.
toString
=
function
(){
return
"
THREE.TextureCube (<br/>image:
"
+
this
.
image
+
"
<br/>mapping:
"
+
this
.
mapping
+
"
<br/>)
"
}};
THREE
.
Scene
=
function
(){
this
.
objects
=
[];
this
.
lights
=
[];
this
.
addObject
=
function
(
a
){
this
.
objects
.
push
(
a
)};
this
.
removeObject
=
function
(
a
){
a
=
this
.
objects
.
indexOf
(
a
);
a
!==-
1
&&
this
.
objects
.
splice
(
a
,
1
)};
this
.
addLight
=
function
(
a
){
this
.
lights
.
push
(
a
)};
this
.
removeLight
=
function
(
a
){
a
=
this
.
lights
.
indexOf
(
a
);
a
!==-
1
&&
this
.
lights
.
splice
(
a
,
1
)};
this
.
toString
=
function
(){
return
"
THREE.Scene (
"
+
this
.
objects
+
"
)
"
}};
THREE
.
Projector
=
function
(){
function
a
(
D
,
B
){
var
m
;
m
=
0
;
var
v
=
1
,
i
=
D
.
z
+
D
.
w
,
P
=
B
.
z
+
B
.
w
,
M
=-
D
.
z
+
D
.
w
,
x
=-
B
.
z
+
B
.
w
;
if
(
i
>=
0
&&
P
>=
0
&&
M
>=
0
&&
x
>=
0
)
m
=
true
;
else
if
(
i
<
0
&&
P
<
0
||
M
<
0
&&
x
<
0
)
m
=
false
;
else
{
if
(
i
<
0
)
m
=
Math
.
max
(
m
,
i
/
(
i
-
P
));
else
if
(
P
<
0
)
v
=
Math
.
min
(
v
,
i
/
(
i
-
P
));
if
(
M
<
0
)
m
=
Math
.
max
(
m
,
M
/
(
M
-
x
));
else
if
(
x
<
0
)
v
=
Math
.
min
(
v
,
M
/
(
M
-
x
));
if
(
v
<
m
)
m
=
false
;
else
{
D
.
lerpSelf
(
B
,
m
);
B
.
lerpSelf
(
D
,
1
-
v
);
m
=
true
}}
return
m
}
var
c
=
null
,
f
,
b
,
d
=
[],
j
,
o
,
r
=
[],
e
,
g
,
n
=
[],
h
,
l
,
q
=
[],
p
=
new
THREE
.
Vector4
,
s
=
new
THREE
.
Matrix4
,
A
=
new
THREE
.
Matrix4
;
this
.
projectScene
=
function
(
D
,
...
...
build/ThreeDebug.js
浏览文件 @
cf7dc4d2
...
...
@@ -72,7 +72,7 @@ THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this
THREE
.
MeshNormalMaterial
=
function
(
a
){
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
FlatShading
;
this
.
blending
=
THREE
.
NormalBlending
;
if
(
a
){
if
(
a
.
opacity
!==
undefined
)
this
.
opacity
=
a
.
opacity
;
if
(
a
.
shading
!==
undefined
)
this
.
shading
=
a
.
shading
;
if
(
a
.
blending
!==
undefined
)
this
.
blending
=
a
.
blending
}
this
.
toString
=
function
(){
return
"
THREE.MeshNormalMaterial
"
}};
THREE
.
MeshFaceMaterial
=
function
(){
this
.
toString
=
function
(){
return
"
THREE.MeshFaceMaterial
"
}};
THREE
.
ParticleBasicMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
offset
=
new
THREE
.
Vector2
;
if
(
a
){
a
.
color
!==
undefined
&&
this
.
color
.
setHex
(
a
.
color
);
if
(
a
.
map
!==
undefined
)
this
.
map
=
a
.
map
;
if
(
a
.
opacity
!==
undefined
)
this
.
opacity
=
a
.
opacity
;
if
(
a
.
blending
!==
undefined
)
this
.
blending
=
a
.
blending
}
this
.
toString
=
function
(){
return
"
THREE.ParticleBasicMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleCircleMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
if
(
a
){
a
.
color
!==
undefined
&&
this
.
color
.
setHex
(
a
.
color
);
if
(
a
.
opacity
!==
undefined
)
this
.
opacity
=
a
.
opacity
;
if
(
a
.
blending
!==
undefined
)
this
.
blending
=
a
.
blending
}
this
.
toString
=
function
(){
return
"
THREE.ParticleCircleMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleDOMMaterial
=
function
(
a
){
this
.
domElement
=
a
;
this
.
toString
=
function
(){
return
"
THREE.ParticleDOMMaterial ( domElement:
"
+
this
.
domElement
+
"
)
"
}};
THREE
.
Texture
=
function
(
a
,
c
){
this
.
image
=
a
;
this
.
mapping
=
c
?
c
:
THREE
.
UVMapping
;
this
.
toString
=
function
(){
return
"
THREE.Texture (<br/>image:
"
+
this
.
image
+
"
<br/>mapping:
"
+
this
.
mapping
+
"
<br/>)
"
}};
THREE
.
UVMapping
=
0
;
THREE
.
ReflectionMap
=
1
;
THREE
.
RefractionMap
=
2
;
THREE
.
Multiply
=
0
;
THREE
.
Mix
=
1
;
THREE
.
ParticleDOMMaterial
=
function
(
a
){
this
.
domElement
=
a
;
this
.
toString
=
function
(){
return
"
THREE.ParticleDOMMaterial ( domElement:
"
+
this
.
domElement
+
"
)
"
}};
THREE
.
Texture
=
function
(
a
,
c
){
this
.
image
=
a
;
this
.
mapping
=
c
!==
undefined
?
c
:
THREE
.
UVMapping
;
this
.
toString
=
function
(){
return
"
THREE.Texture (<br/>image:
"
+
this
.
image
+
"
<br/>mapping:
"
+
this
.
mapping
+
"
<br/>)
"
}};
THREE
.
UVMapping
=
0
;
THREE
.
ReflectionMap
=
1
;
THREE
.
RefractionMap
=
2
;
THREE
.
Multiply
=
0
;
THREE
.
Mix
=
1
;
THREE
.
TextureCube
=
function
(
a
,
c
){
this
.
image
=
a
;
this
.
mapping
=
c
?
c
:
THREE
.
ReflectionMap
;
this
.
toString
=
function
(){
return
"
THREE.TextureCube (<br/>image:
"
+
this
.
image
+
"
<br/>mapping:
"
+
this
.
mapping
+
"
<br/>)
"
}};
THREE
.
Scene
=
function
(){
this
.
objects
=
[];
this
.
lights
=
[];
this
.
addObject
=
function
(
a
){
this
.
objects
.
push
(
a
)};
this
.
removeObject
=
function
(
a
){
a
=
this
.
objects
.
indexOf
(
a
);
a
!==-
1
&&
this
.
objects
.
splice
(
a
,
1
)};
this
.
addLight
=
function
(
a
){
this
.
lights
.
push
(
a
)};
this
.
removeLight
=
function
(
a
){
a
=
this
.
lights
.
indexOf
(
a
);
a
!==-
1
&&
this
.
lights
.
splice
(
a
,
1
)};
this
.
toString
=
function
(){
return
"
THREE.Scene (
"
+
this
.
objects
+
"
)
"
}};
THREE
.
Projector
=
function
(){
function
a
(
D
,
B
){
var
m
;
m
=
0
;
var
w
=
1
,
h
=
D
.
z
+
D
.
w
,
P
=
B
.
z
+
B
.
w
,
M
=-
D
.
z
+
D
.
w
,
y
=-
B
.
z
+
B
.
w
;
if
(
h
>=
0
&&
P
>=
0
&&
M
>=
0
&&
y
>=
0
)
m
=
true
;
else
if
(
h
<
0
&&
P
<
0
||
M
<
0
&&
y
<
0
)
m
=
false
;
else
{
if
(
h
<
0
)
m
=
Math
.
max
(
m
,
h
/
(
h
-
P
));
else
if
(
P
<
0
)
w
=
Math
.
min
(
w
,
h
/
(
h
-
P
));
if
(
M
<
0
)
m
=
Math
.
max
(
m
,
M
/
(
M
-
y
));
else
if
(
y
<
0
)
w
=
Math
.
min
(
w
,
M
/
(
M
-
y
));
if
(
w
<
m
)
m
=
false
;
else
{
D
.
lerpSelf
(
B
,
m
);
B
.
lerpSelf
(
D
,
1
-
w
);
m
=
true
}}
return
m
}
var
c
=
null
,
f
,
b
,
d
=
[],
j
,
o
,
r
=
[],
e
,
g
,
n
=
[],
i
,
l
,
q
=
[],
p
=
new
THREE
.
Vector4
,
s
=
new
THREE
.
Matrix4
,
A
=
new
THREE
.
Matrix4
;
this
.
projectScene
=
function
(
D
,
...
...
examples/materials_cubemap_sky.html
浏览文件 @
cf7dc4d2
...
...
@@ -35,7 +35,7 @@
<script
type=
"text/javascript"
src=
"../build/Three.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/primitives/Sphere.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/primitives/
Plan
e.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/primitives/
Cub
e.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/GeometryUtils.js"
></script>
<script
type=
"text/javascript"
src=
"js/Stats.js"
></script>
...
...
@@ -100,10 +100,18 @@
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xffffff
,
env_map
:
new
THREE
.
TextureCube
(
images
)
}
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
position
.
x
=
100
;
scene
.
addObject
(
mesh
);
createCube
(
100000
,
images
);
var
materials
=
[];
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
materials
.
push
(
[
new
THREE
.
MeshBasicMaterial
(
{
map
:
new
THREE
.
Texture
(
images
[
i
]
)
}
)
]
);
}
var
mesh
=
new
THREE
.
Mesh
(
new
Cube
(
100000
,
100000
,
100000
,
2
,
2
,
materials
,
true
),
new
THREE
.
MeshFaceMaterial
()
);
sceneCube
.
addObject
(
mesh
);
webglRenderer
=
new
THREE
.
WebGLRenderer
(
scene
);
webglRenderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
...
...
@@ -122,32 +130,6 @@
}
function
addMesh
(
geometry
,
scale
,
x
,
y
,
z
,
rx
,
ry
,
rz
,
material
)
{
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
scale
.
x
=
mesh
.
scale
.
y
=
mesh
.
scale
.
z
=
scale
;
mesh
.
position
.
x
=
x
;
mesh
.
position
.
y
=
y
;
mesh
.
position
.
z
=
z
;
mesh
.
rotation
.
x
=
rx
;
mesh
.
rotation
.
y
=
ry
;
mesh
.
rotation
.
z
=
rz
;
sceneCube
.
addObject
(
mesh
);
}
function
createCube
(
size
,
images
)
{
var
hsize
=
size
/
2
,
plane
=
new
Plane
(
size
,
size
),
pi2
=
Math
.
PI
/
2
,
pi
=
Math
.
PI
;
addMesh
(
plane
,
1
,
0
,
0
,
-
hsize
,
0
,
0
,
0
,
new
THREE
.
MeshBasicMaterial
(
{
map
:
new
THREE
.
Texture
(
images
[
5
]
)
}
)
);
addMesh
(
plane
,
1
,
-
hsize
,
0
,
0
,
0
,
pi2
,
0
,
new
THREE
.
MeshBasicMaterial
(
{
map
:
new
THREE
.
Texture
(
images
[
0
]
)
}
)
);
addMesh
(
plane
,
1
,
hsize
,
0
,
0
,
0
,
-
pi2
,
0
,
new
THREE
.
MeshBasicMaterial
(
{
map
:
new
THREE
.
Texture
(
images
[
1
]
)
}
)
);
addMesh
(
plane
,
1
,
0
,
hsize
,
0
,
pi2
,
0
,
pi
,
new
THREE
.
MeshBasicMaterial
(
{
map
:
new
THREE
.
Texture
(
images
[
2
]
)
}
)
);
addMesh
(
plane
,
1
,
0
,
-
hsize
,
0
,
-
pi2
,
0
,
pi
,
new
THREE
.
MeshBasicMaterial
(
{
map
:
new
THREE
.
Texture
(
images
[
3
]
)
}
)
);
}
function
loadImageArray
(
urls
)
{
var
i
,
images
=
[];
...
...
src/extras/primitives/Cube.js
浏览文件 @
cf7dc4d2
...
...
@@ -44,6 +44,8 @@ var Cube = function ( width, height, depth, segments_width, segments_height, mat
buildPlane
(
'
x
'
,
'
y
'
,
1
*
flip
,
-
1
,
width
,
height
,
depth_half
,
this
.
materials
[
4
]
);
// back
buildPlane
(
'
x
'
,
'
y
'
,
-
1
*
flip
,
-
1
,
width
,
height
,
-
depth_half
,
this
.
materials
[
5
]
);
// front
mergeVertices
();
function
buildPlane
(
u
,
v
,
udir
,
vdir
,
width
,
height
,
depth
,
material
)
{
var
gridX
=
segments_width
||
1
,
...
...
@@ -107,6 +109,53 @@ var Cube = function ( width, height, depth, segments_width, segments_height, mat
}
function
mergeVertices
()
{
var
unique
=
[],
changes
=
[];
for
(
var
i
=
0
,
il
=
scope
.
vertices
.
length
;
i
<
il
;
i
++
)
{
var
v
=
scope
.
vertices
[
i
],
duplicate
=
false
;
for
(
var
j
=
0
,
jl
=
unique
.
length
;
j
<
jl
;
j
++
)
{
var
vu
=
unique
[
j
];
if
(
v
.
position
.
x
==
vu
.
position
.
x
&&
v
.
position
.
y
==
vu
.
position
.
y
&&
v
.
position
.
z
==
vu
.
position
.
z
)
{
changes
[
i
]
=
j
;
duplicate
=
true
;
break
;
}
}
if
(
!
duplicate
)
{
changes
[
i
]
=
unique
.
length
;
unique
.
push
(
new
THREE
.
Vertex
(
v
.
position
.
clone
()
)
);
}
}
for
(
var
i
=
0
,
l
=
scope
.
faces
.
length
;
i
<
l
;
i
++
)
{
var
face
=
scope
.
faces
[
i
];
face
.
a
=
changes
[
face
.
a
];
face
.
b
=
changes
[
face
.
b
];
face
.
c
=
changes
[
face
.
c
];
face
.
d
=
changes
[
face
.
d
];
}
scope
.
vertices
=
unique
;
}
this
.
computeCentroids
();
this
.
computeNormals
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录