Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
d3cd0887
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,发现更多精彩内容 >>
提交
d3cd0887
编写于
11月 24, 2010
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added handling of object removal to WebGLRender. Added visibility parameter to Object3D.
上级
8f38ddca
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
66 addition
and
29 deletion
+66
-29
build/Three.js
build/Three.js
+7
-7
build/ThreeDebug.js
build/ThreeDebug.js
+7
-7
examples/lights_test.html
examples/lights_test.html
+3
-3
src/extras/SceneUtils.js
src/extras/SceneUtils.js
+8
-0
src/objects/Object3D.js
src/objects/Object3D.js
+2
-0
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+37
-12
src/scenes/Scene.js
src/scenes/Scene.js
+2
-0
未找到文件。
build/Three.js
浏览文件 @
d3cd0887
...
...
@@ -49,7 +49,7 @@ this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y
THREE
.
Camera
=
function
(
a
,
c
,
f
,
h
){
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
target
=
{
position
:
new
THREE
.
Vector3
(
0
,
0
,
0
)};
this
.
up
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
matrix
=
new
THREE
.
Matrix4
;
this
.
projectionMatrix
=
THREE
.
Matrix4
.
makePerspective
(
a
,
c
,
f
,
h
);
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrix
.
lookAt
(
this
.
position
,
this
.
target
.
position
,
this
.
up
)};
this
.
toString
=
function
(){
return
"
THREE.Camera (
"
+
this
.
position
+
"
,
"
+
this
.
target
.
position
+
"
)
"
}};
THREE
.
Light
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
-
16777216
|
a
)};
THREE
.
AmbientLight
=
function
(
a
){
THREE
.
Light
.
call
(
this
,
a
)};
THREE
.
AmbientLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
AmbientLight
.
prototype
.
constructor
=
THREE
.
AmbientLight
;
THREE
.
DirectionalLight
=
function
(
a
,
c
){
THREE
.
Light
.
call
(
this
,
a
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
intensity
=
c
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
DirectionalLight
;
THREE
.
PointLight
=
function
(
a
,
c
){
THREE
.
Light
.
call
(
this
,
a
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
intensity
=
c
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
PointLight
;
THREE
.
Object3D
=
function
(){
this
.
position
=
new
THREE
.
Vector3
;
this
.
rotation
=
new
THREE
.
Vector3
;
this
.
scale
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
matrix
=
new
THREE
.
Matrix4
;
this
.
matrixTranslation
=
new
THREE
.
Matrix4
;
this
.
matrixRotation
=
new
THREE
.
Matrix4
;
this
.
matrixScale
=
new
THREE
.
Matrix4
;
this
.
screen
=
new
THREE
.
Vector3
;
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrixPosition
=
THREE
.
Matrix4
.
translationMatrix
(
this
.
position
.
x
,
this
.
position
.
y
,
this
.
position
.
z
);
this
.
matrixRotation
=
THREE
.
Matrix4
.
rotationXMatrix
(
this
.
rotation
.
x
);
THREE
.
Object3D
=
function
(){
this
.
position
=
new
THREE
.
Vector3
;
this
.
rotation
=
new
THREE
.
Vector3
;
this
.
scale
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
matrix
=
new
THREE
.
Matrix4
;
this
.
matrixTranslation
=
new
THREE
.
Matrix4
;
this
.
matrixRotation
=
new
THREE
.
Matrix4
;
this
.
matrixScale
=
new
THREE
.
Matrix4
;
this
.
screen
=
new
THREE
.
Vector3
;
this
.
autoUpdateMatrix
=
t
his
.
visible
=
t
rue
;
this
.
updateMatrix
=
function
(){
this
.
matrixPosition
=
THREE
.
Matrix4
.
translationMatrix
(
this
.
position
.
x
,
this
.
position
.
y
,
this
.
position
.
z
);
this
.
matrixRotation
=
THREE
.
Matrix4
.
rotationXMatrix
(
this
.
rotation
.
x
);
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationYMatrix
(
this
.
rotation
.
y
));
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationZMatrix
(
this
.
rotation
.
z
));
this
.
matrixScale
=
THREE
.
Matrix4
.
scaleMatrix
(
this
.
scale
.
x
,
this
.
scale
.
y
,
this
.
scale
.
z
);
this
.
matrix
.
copy
(
this
.
matrixPosition
);
this
.
matrix
.
multiplySelf
(
this
.
matrixRotation
);
this
.
matrix
.
multiplySelf
(
this
.
matrixScale
)}};
THREE
.
Particle
=
function
(
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
material
=
a
instanceof
Array
?
a
:[
a
];
this
.
autoUpdateMatrix
=
false
};
THREE
.
Particle
.
prototype
=
new
THREE
.
Object3D
;
THREE
.
Particle
.
prototype
.
constructor
=
THREE
.
Particle
;
THREE
.
Line
=
function
(
a
,
c
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
a
;
this
.
material
=
c
instanceof
Array
?
c
:[
c
]};
THREE
.
Line
.
prototype
=
new
THREE
.
Object3D
;
THREE
.
Line
.
prototype
.
constructor
=
THREE
.
Line
;
THREE
.
Mesh
=
function
(
a
,
c
,
f
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
a
;
this
.
material
=
c
instanceof
Array
?
c
:[
c
];
this
.
overdraw
=
this
.
doubleSided
=
this
.
flipSided
=
false
;
this
.
materialFaceGroup
=
{};
this
.
sortFacesByMaterial
();
f
&&
this
.
normalizeUVs
();
this
.
geometry
.
computeBoundingBox
()};
THREE
.
Mesh
.
prototype
=
new
THREE
.
Object3D
;
THREE
.
Mesh
.
prototype
.
constructor
=
THREE
.
Mesh
;
...
...
@@ -75,7 +75,7 @@ THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);thi
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
,
f
,
h
){
this
.
image
=
a
;
this
.
mapping
=
c
!==
undefined
?
c
:
THREE
.
UVMapping
;
this
.
wrap_s
=
f
!==
undefined
?
f
:
THREE
.
ClampToEdge
;
this
.
wrap_t
=
h
!==
undefined
?
h
:
THREE
.
ClampToEdge
;
this
.
toString
=
function
(){
return
"
THREE.Texture (<br/>image:
"
+
this
.
image
+
"
<br/>wrap_s:
"
+
this
.
wrap_s
+
"
<br/>wrap_t:
"
+
this
.
wrap_t
+
"
<br/>)
"
}};
THREE
.
UVMapping
=
0
;
THREE
.
ReflectionMap
=
1
;
THREE
.
RefractionMap
=
2
;
THREE
.
Multiply
=
0
;
THREE
.
Mix
=
1
;
THREE
.
Repeat
=
0
;
THREE
.
ClampToEdge
=
1
;
THREE
.
MirroredRepeat
=
2
;
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
.
Scene
=
function
(){
this
.
objects
=
[];
this
.
lights
=
[];
this
.
addObject
=
function
(
a
){
this
.
objects
.
push
(
a
)};
this
.
removeObject
=
function
(
a
){
var
c
=
this
.
objects
.
indexOf
(
a
);
c
!==-
1
&&
this
.
objects
.
splice
(
c
,
1
);
a
.
__removed
=
true
};
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
(
r
,
q
){
var
l
=
0
,
Q
=
1
,
H
=
r
.
z
+
r
.
w
,
T
=
q
.
z
+
q
.
w
,
$
=-
r
.
z
+
r
.
w
,
t
=-
q
.
z
+
q
.
w
;
if
(
H
>=
0
&&
T
>=
0
&&
$
>=
0
&&
t
>=
0
)
return
true
;
else
if
(
H
<
0
&&
T
<
0
||
$
<
0
&&
t
<
0
)
return
false
;
else
{
if
(
H
<
0
)
l
=
Math
.
max
(
l
,
H
/
(
H
-
T
));
else
if
(
T
<
0
)
Q
=
Math
.
min
(
Q
,
H
/
(
H
-
T
));
if
(
$
<
0
)
l
=
Math
.
max
(
l
,
$
/
(
$
-
t
));
else
if
(
t
<
0
)
Q
=
Math
.
min
(
Q
,
$
/
(
$
-
t
));
if
(
Q
<
l
)
return
false
;
else
{
r
.
lerpSelf
(
q
,
l
);
q
.
lerpSelf
(
r
,
1
-
Q
);
return
true
}}}
var
c
=
null
,
f
,
h
,
b
=
[],
d
,
p
,
s
=
[],
o
,
e
,
g
=
[],
k
,
i
,
n
=
[],
j
=
new
THREE
.
Vector4
,
z
=
new
THREE
.
Matrix4
,
C
=
new
THREE
.
Matrix4
,
v
=
new
THREE
.
Vector4
,
L
=
new
THREE
.
Vector4
;
this
.
projectScene
=
function
(
r
,
q
){
var
l
,
Q
,
H
,
T
,
$
,
t
,
F
,
D
,
u
,
N
,
oa
,
Z
,
R
,
B
;
c
=
[];
i
=
e
=
p
=
h
=
0
;
q
.
autoUpdateMatrix
&&
q
.
updateMatrix
();
z
.
multiply
(
q
.
projectionMatrix
,
q
.
matrix
);
$
=
r
.
objects
;
l
=
0
;
for
(
Q
=
$
.
length
;
l
<
Q
;
l
++
){
t
=
$
[
l
];
F
=
t
.
matrix
;
t
.
autoUpdateMatrix
&&
t
.
updateMatrix
();
if
(
t
instanceof
THREE
.
Mesh
){
C
.
multiply
(
z
,
F
);
D
=
t
.
geometry
.
vertices
;
H
=
0
;
for
(
T
=
D
.
length
;
H
<
T
;
H
++
){
u
=
D
[
H
];
N
=
u
.
positionScreen
;
N
.
copy
(
u
.
position
);
C
.
transform
(
N
);
N
.
multiplyScalar
(
1
/
N
.
w
);
u
.
__visible
=
N
.
z
>
0
&&
N
.
z
<
1
}
oa
=
t
.
geometry
.
faces
;
H
=
0
;
for
(
T
=
oa
.
length
;
H
<
T
;
H
++
){
Z
=
oa
[
H
];
if
(
Z
instanceof
THREE
.
Face3
){
u
=
D
[
Z
.
a
];
N
=
D
[
Z
.
b
];
R
=
D
[
Z
.
c
];
if
(
u
.
__visible
&&
N
.
__visible
&&
R
.
__visible
)
if
(
t
.
doubleSided
||
t
.
flipSided
!=
(
R
.
positionScreen
.
x
-
u
.
positionScreen
.
x
)
*
(
N
.
positionScreen
.
y
-
u
.
positionScreen
.
y
)
-
(
R
.
positionScreen
.
y
-
u
.
positionScreen
.
y
)
*
(
N
.
positionScreen
.
x
-
u
.
positionScreen
.
x
)
<
0
){
f
=
b
[
h
]
=
b
[
h
]
||
new
THREE
.
RenderableFace3
;
f
.
v1
.
positionScreen
.
copy
(
u
.
positionScreen
);
f
.
v2
.
positionScreen
.
copy
(
N
.
positionScreen
);
f
.
v3
.
positionScreen
.
copy
(
R
.
positionScreen
);
f
.
normalWorld
.
copy
(
Z
.
normal
);
...
...
@@ -154,11 +154,11 @@ f(e.map.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(e.map.wrap_t));
for
(
i
=
0
;
i
<
6
;
++
i
)
b
.
texImage2D
(
b
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
0
,
b
.
RGBA
,
b
.
RGBA
,
b
.
UNSIGNED_BYTE
,
e
.
env_map
.
image
[
i
]);
b
.
generateMipmap
(
b
.
TEXTURE_CUBE_MAP
);
b
.
bindTexture
(
b
.
TEXTURE_CUBE_MAP
,
null
);
e
.
env_map
.
image
.
__cubeMapInitialized
=
true
}
b
.
activeTexture
(
b
.
TEXTURE1
);
b
.
bindTexture
(
b
.
TEXTURE_CUBE_MAP
,
e
.
env_map
.
image
.
__webGLTextureCube
);
b
.
uniform1i
(
d
.
tCube
,
1
)}
b
.
uniform1i
(
d
.
enableCubeMap
,
1
)}
else
b
.
uniform1i
(
d
.
enableCubeMap
,
0
);
b
.
bindBuffer
(
b
.
ARRAY_BUFFER
,
g
.
__webGLVertexBuffer
);
b
.
vertexAttribPointer
(
d
.
position
,
3
,
b
.
FLOAT
,
false
,
0
,
0
);
b
.
bindBuffer
(
b
.
ARRAY_BUFFER
,
g
.
__webGLNormalBuffer
);
b
.
vertexAttribPointer
(
d
.
normal
,
3
,
b
.
FLOAT
,
false
,
0
,
0
);
if
(
v
){
b
.
bindBuffer
(
b
.
ARRAY_BUFFER
,
g
.
__webGLUVBuffer
);
b
.
enableVertexAttribArray
(
d
.
uv
);
b
.
vertexAttribPointer
(
d
.
uv
,
2
,
b
.
FLOAT
,
false
,
0
,
0
)}
else
b
.
disableVertexAttribArray
(
d
.
uv
);
if
(
j
){
b
.
lineWidth
(
z
);
b
.
bindBuffer
(
b
.
ELEMENT_ARRAY_BUFFER
,
g
.
__webGLLineBuffer
);
b
.
drawElements
(
b
.
LINES
,
g
.
__webGLLineCount
,
b
.
UNSIGNED_SHORT
,
0
)}
else
{
b
.
bindBuffer
(
b
.
ELEMENT_ARRAY_BUFFER
,
g
.
__webGLFaceBuffer
);
b
.
drawElements
(
b
.
TRIANGLES
,
g
.
__webGLFaceCount
,
b
.
UNSIGNED_SHORT
,
0
)}};
this
.
renderPass
=
function
(
e
,
g
,
k
,
i
){
var
n
,
j
,
z
,
C
,
v
;
z
=
0
;
for
(
C
=
e
.
material
.
length
;
z
<
C
;
z
++
){
n
=
e
.
material
[
z
];
if
(
n
instanceof
THREE
.
MeshFaceMaterial
){
n
=
0
;
for
(
j
=
g
.
material
.
length
;
n
<
j
;
n
++
)
if
((
v
=
g
.
material
[
n
])
&&
v
.
blending
==
k
&&
v
.
opacity
<
1
==
i
){
this
.
setBlending
(
v
.
blending
);
this
.
renderBuffer
(
v
,
g
)}}
else
if
((
v
=
n
)
&&
v
.
blending
==
k
&&
v
.
opacity
<
1
==
i
){
this
.
setBlending
(
v
.
blending
);
this
.
renderBuffer
(
v
,
g
)}}};
this
.
render
=
function
(
e
,
g
){
var
k
,
i
;
this
.
initWebGLObjects
(
e
);
this
.
autoClear
&&
this
.
clear
();
g
.
autoUpdateMatrix
&&
g
.
updateMatrix
();
b
.
uniform3f
(
d
.
cameraPosition
,
g
.
position
.
x
,
g
.
position
.
y
,
g
.
position
.
z
);
this
.
setupLights
(
e
);
k
=
0
;
for
(
i
=
e
.
__webGLObjects
.
length
;
k
<
i
;
k
++
){
webGLObject
=
e
.
__webGLObjects
[
k
];
this
.
setupMatrices
(
webGLObject
.
__object
,
g
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
false
)}
k
=
0
;
for
(
i
=
e
.
__webGLObjects
.
length
;
k
<
i
;
k
++
){
webGLObject
=
e
.
__webGLObjects
[
k
];
this
.
setupMatrices
(
webGLObject
.
__object
,
g
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
false
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
false
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
true
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
true
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
true
)}};
this
.
initWebGLObjects
=
function
(
e
){
var
g
,
k
,
i
,
n
,
j
;
if
(
!
e
.
__webGLObjects
)
e
.
__webGLObjects
=
[];
g
=
0
;
for
(
k
=
e
.
objects
.
length
;
g
<
k
;
g
++
){
i
=
e
.
objects
[
g
];
if
(
i
instanceof
THREE
.
Mesh
)
for
(
n
in
i
.
materialFaceGroup
){
j
=
i
.
materialFaceGroup
[
n
];
if
(
!
j
.
__webGLVertexBuffer
){
this
.
createBuffers
(
i
,
n
);
j
.
__object
=
i
;
e
.
__webGLObjects
.
push
(
j
)}}}};
this
.
setupMatrices
=
function
(
e
,
g
){
e
.
autoUpdateMatrix
&&
e
.
updateMatrix
();
p
.
multiply
(
g
.
matrix
,
e
.
matrix
);
d
.
viewMatrixArray
=
new
Float32Array
(
g
.
matrix
.
flatten
());
d
.
modelViewMatrixArray
=
new
Float32Array
(
p
.
flatten
());
d
.
projectionMatrixArray
=
new
Float32Array
(
g
.
projectionMatrix
.
flatten
());
s
=
THREE
.
Matrix4
.
makeInvert3x3
(
p
).
transpose
();
d
.
normalMatrixArray
=
new
Float32Array
(
s
.
m
);
b
.
uniformMatrix4fv
(
d
.
viewMatrix
,
false
,
d
.
viewMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
modelViewMatrix
,
false
,
d
.
modelViewMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
projectionMatrix
,
false
,
d
.
projectionMatrixArray
);
b
.
uniformMatrix3fv
(
d
.
normalMatrix
,
false
,
d
.
normalMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
objMatrix
,
false
,
new
Float32Array
(
e
.
matrix
.
flatten
()))};
this
.
setBlending
=
function
(
e
){
switch
(
e
){
case
THREE
.
AdditiveBlending
:
b
.
blendEquation
(
b
.
FUNC_ADD
);
b
.
blendFunc
(
b
.
ONE
,
b
.
ONE
);
break
;
case
THREE
.
SubtractiveBlending
:
b
.
blendFunc
(
b
.
DST_COLOR
,
b
.
ZERO
);
break
;
default
:
b
.
blendEquation
(
b
.
FUNC_ADD
)
;
b
.
blendFunc
(
b
.
ONE
,
b
.
ONE_MINUS_SRC_ALPHA
)}};
this
.
setFaceCulling
=
function
(
e
,
g
){
if
(
e
){
!
g
||
g
==
"
ccw
"
?
b
.
frontFace
(
b
.
CCW
):
b
.
frontFace
(
b
.
CW
);
if
(
e
==
"
back
"
)
b
.
cullFace
(
b
.
BACK
);
else
e
==
"
front
"
?
b
.
cullFace
(
b
.
FRONT
):
b
.
cullFace
(
b
.
FRONT_AND_BACK
);
b
.
enable
(
b
.
CULL_FACE
)}
else
b
.
disable
(
b
.
CULL_FACE
)}};
g
.
autoUpdateMatrix
&&
g
.
updateMatrix
();
b
.
uniform3f
(
d
.
cameraPosition
,
g
.
position
.
x
,
g
.
position
.
y
,
g
.
position
.
z
);
this
.
setupLights
(
e
);
k
=
0
;
for
(
i
=
e
.
__webGLObjects
.
length
;
k
<
i
;
k
++
){
webGLObject
=
e
.
__webGLObjects
[
k
];
if
(
webGLObject
.
__object
.
visible
){
this
.
setupMatrices
(
webGLObject
.
__object
,
g
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
false
)}}
k
=
0
;
for
(
i
=
e
.
__webGLObjects
.
length
;
k
<
i
;
k
++
){
webGLObject
=
e
.
__webGLObjects
[
k
];
if
(
webGLObject
.
__object
.
visible
){
this
.
setupMatrices
(
webGLObject
.
__object
,
g
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
false
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
false
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
true
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
true
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
true
)}}};
this
.
initWebGLObjects
=
function
(
e
){
var
g
,
k
,
i
,
n
,
j
;
if
(
!
e
.
__webGLObjects
)
e
.
__webGLObjects
=
[];
g
=
0
;
for
(
k
=
e
.
objects
.
length
;
g
<
k
;
g
++
){
i
=
e
.
objects
[
g
];
if
(
i
instanceof
THREE
.
Mesh
)
for
(
n
in
i
.
materialFaceGroup
){
j
=
i
.
materialFaceGroup
[
n
];
if
(
!
j
.
__webGLVertexBuffer
){
this
.
createBuffers
(
i
,
n
);
j
.
__object
=
i
;
e
.
__webGLObjects
.
push
(
j
)}}}
for
(
g
=
e
.
__webGLObjects
.
length
-
1
;
g
>=
0
;
g
--
){
i
=
e
.
__webGLObjects
[
g
].
__object
;
i
.
__removed
&&
e
.
__webGLObjects
.
splice
(
g
,
1
)}};
this
.
setupMatrices
=
function
(
e
,
g
){
e
.
autoUpdateMatrix
&&
e
.
updateMatrix
();
p
.
multiply
(
g
.
matrix
,
e
.
matrix
);
d
.
viewMatrixArray
=
new
Float32Array
(
g
.
matrix
.
flatten
());
d
.
modelViewMatrixArray
=
new
Float32Array
(
p
.
flatten
());
d
.
projectionMatrixArray
=
new
Float32Array
(
g
.
projectionMatrix
.
flatten
());
s
=
THREE
.
Matrix4
.
makeInvert3x3
(
p
).
transpose
();
d
.
normalMatrixArray
=
new
Float32Array
(
s
.
m
);
b
.
uniformMatrix4fv
(
d
.
viewMatrix
,
false
,
d
.
viewMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
modelViewMatrix
,
false
,
d
.
modelViewMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
projectionMatrix
,
false
,
d
.
projectionMatrixArray
);
b
.
uniformMatrix3fv
(
d
.
normalMatrix
,
false
,
d
.
normalMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
objMatrix
,
false
,
new
Float32Array
(
e
.
matrix
.
flatten
()))}
;
this
.
setBlending
=
function
(
e
){
switch
(
e
){
case
THREE
.
AdditiveBlending
:
b
.
blendEquation
(
b
.
FUNC_ADD
);
b
.
blendFunc
(
b
.
ONE
,
b
.
ONE
);
break
;
case
THREE
.
SubtractiveBlending
:
b
.
blendFunc
(
b
.
DST_COLOR
,
b
.
ZERO
);
break
;
default
:
b
.
blendEquation
(
b
.
FUNC_ADD
);
b
.
blendFunc
(
b
.
ONE
,
b
.
ONE_MINUS_SRC_ALPHA
)}};
this
.
setFaceCulling
=
function
(
e
,
g
){
if
(
e
){
!
g
||
g
==
"
ccw
"
?
b
.
frontFace
(
b
.
CCW
):
b
.
frontFace
(
b
.
CW
);
if
(
e
==
"
back
"
)
b
.
cullFace
(
b
.
BACK
);
else
e
==
"
front
"
?
b
.
cullFace
(
b
.
FRONT
):
b
.
cullFace
(
b
.
FRONT_AND_BACK
);
b
.
enable
(
b
.
CULL_FACE
)}
else
b
.
disable
(
b
.
CULL_FACE
)}};
THREE
.
RenderableFace3
=
function
(){
this
.
v1
=
new
THREE
.
Vertex
;
this
.
v2
=
new
THREE
.
Vertex
;
this
.
v3
=
new
THREE
.
Vertex
;
this
.
centroidWorld
=
new
THREE
.
Vector3
;
this
.
centroidScreen
=
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
material
=
this
.
color
=
this
.
z
=
null
};
THREE
.
RenderableFace4
=
function
(){
this
.
v1
=
new
THREE
.
Vertex
;
this
.
v2
=
new
THREE
.
Vertex
;
this
.
v3
=
new
THREE
.
Vertex
;
this
.
v4
=
new
THREE
.
Vertex
;
this
.
centroidWorld
=
new
THREE
.
Vector3
;
this
.
centroidScreen
=
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
material
=
this
.
color
=
this
.
z
=
null
};
THREE
.
RenderableParticle
=
function
(){
this
.
rotation
=
this
.
z
=
this
.
y
=
this
.
x
=
null
;
this
.
scale
=
new
THREE
.
Vector2
;
this
.
material
=
this
.
color
=
null
};
THREE
.
RenderableLine
=
function
(){
this
.
v1
=
new
THREE
.
Vertex
;
this
.
v2
=
new
THREE
.
Vertex
;
this
.
material
=
this
.
color
=
this
.
z
=
null
};
build/ThreeDebug.js
浏览文件 @
d3cd0887
...
...
@@ -49,7 +49,7 @@ this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y
THREE
.
Camera
=
function
(
a
,
c
,
f
,
h
){
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
target
=
{
position
:
new
THREE
.
Vector3
(
0
,
0
,
0
)};
this
.
up
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
matrix
=
new
THREE
.
Matrix4
;
this
.
projectionMatrix
=
THREE
.
Matrix4
.
makePerspective
(
a
,
c
,
f
,
h
);
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrix
.
lookAt
(
this
.
position
,
this
.
target
.
position
,
this
.
up
)};
this
.
toString
=
function
(){
return
"
THREE.Camera (
"
+
this
.
position
+
"
,
"
+
this
.
target
.
position
+
"
)
"
}};
THREE
.
Light
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
-
16777216
|
a
)};
THREE
.
AmbientLight
=
function
(
a
){
THREE
.
Light
.
call
(
this
,
a
)};
THREE
.
AmbientLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
AmbientLight
.
prototype
.
constructor
=
THREE
.
AmbientLight
;
THREE
.
DirectionalLight
=
function
(
a
,
c
){
THREE
.
Light
.
call
(
this
,
a
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
intensity
=
c
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
DirectionalLight
;
THREE
.
PointLight
=
function
(
a
,
c
){
THREE
.
Light
.
call
(
this
,
a
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
intensity
=
c
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
PointLight
;
THREE
.
Object3D
=
function
(){
this
.
position
=
new
THREE
.
Vector3
;
this
.
rotation
=
new
THREE
.
Vector3
;
this
.
scale
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
matrix
=
new
THREE
.
Matrix4
;
this
.
matrixTranslation
=
new
THREE
.
Matrix4
;
this
.
matrixRotation
=
new
THREE
.
Matrix4
;
this
.
matrixScale
=
new
THREE
.
Matrix4
;
this
.
screen
=
new
THREE
.
Vector3
;
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrixPosition
=
THREE
.
Matrix4
.
translationMatrix
(
this
.
position
.
x
,
this
.
position
.
y
,
this
.
position
.
z
);
this
.
matrixRotation
=
THREE
.
Matrix4
.
rotationXMatrix
(
this
.
rotation
.
x
);
THREE
.
Object3D
=
function
(){
this
.
position
=
new
THREE
.
Vector3
;
this
.
rotation
=
new
THREE
.
Vector3
;
this
.
scale
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
matrix
=
new
THREE
.
Matrix4
;
this
.
matrixTranslation
=
new
THREE
.
Matrix4
;
this
.
matrixRotation
=
new
THREE
.
Matrix4
;
this
.
matrixScale
=
new
THREE
.
Matrix4
;
this
.
screen
=
new
THREE
.
Vector3
;
this
.
autoUpdateMatrix
=
t
his
.
visible
=
t
rue
;
this
.
updateMatrix
=
function
(){
this
.
matrixPosition
=
THREE
.
Matrix4
.
translationMatrix
(
this
.
position
.
x
,
this
.
position
.
y
,
this
.
position
.
z
);
this
.
matrixRotation
=
THREE
.
Matrix4
.
rotationXMatrix
(
this
.
rotation
.
x
);
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationYMatrix
(
this
.
rotation
.
y
));
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationZMatrix
(
this
.
rotation
.
z
));
this
.
matrixScale
=
THREE
.
Matrix4
.
scaleMatrix
(
this
.
scale
.
x
,
this
.
scale
.
y
,
this
.
scale
.
z
);
this
.
matrix
.
copy
(
this
.
matrixPosition
);
this
.
matrix
.
multiplySelf
(
this
.
matrixRotation
);
this
.
matrix
.
multiplySelf
(
this
.
matrixScale
)}};
THREE
.
Particle
=
function
(
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
material
=
a
instanceof
Array
?
a
:[
a
];
this
.
autoUpdateMatrix
=
false
};
THREE
.
Particle
.
prototype
=
new
THREE
.
Object3D
;
THREE
.
Particle
.
prototype
.
constructor
=
THREE
.
Particle
;
THREE
.
Line
=
function
(
a
,
c
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
a
;
this
.
material
=
c
instanceof
Array
?
c
:[
c
]};
THREE
.
Line
.
prototype
=
new
THREE
.
Object3D
;
THREE
.
Line
.
prototype
.
constructor
=
THREE
.
Line
;
THREE
.
Mesh
=
function
(
a
,
c
,
f
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
a
;
this
.
material
=
c
instanceof
Array
?
c
:[
c
];
this
.
overdraw
=
this
.
doubleSided
=
this
.
flipSided
=
false
;
this
.
materialFaceGroup
=
{};
this
.
sortFacesByMaterial
();
f
&&
this
.
normalizeUVs
();
this
.
geometry
.
computeBoundingBox
()};
THREE
.
Mesh
.
prototype
=
new
THREE
.
Object3D
;
THREE
.
Mesh
.
prototype
.
constructor
=
THREE
.
Mesh
;
...
...
@@ -75,7 +75,7 @@ THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);thi
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
,
f
,
h
){
this
.
image
=
a
;
this
.
mapping
=
c
!==
undefined
?
c
:
THREE
.
UVMapping
;
this
.
wrap_s
=
f
!==
undefined
?
f
:
THREE
.
ClampToEdge
;
this
.
wrap_t
=
h
!==
undefined
?
h
:
THREE
.
ClampToEdge
;
this
.
toString
=
function
(){
return
"
THREE.Texture (<br/>image:
"
+
this
.
image
+
"
<br/>wrap_s:
"
+
this
.
wrap_s
+
"
<br/>wrap_t:
"
+
this
.
wrap_t
+
"
<br/>)
"
}};
THREE
.
UVMapping
=
0
;
THREE
.
ReflectionMap
=
1
;
THREE
.
RefractionMap
=
2
;
THREE
.
Multiply
=
0
;
THREE
.
Mix
=
1
;
THREE
.
Repeat
=
0
;
THREE
.
ClampToEdge
=
1
;
THREE
.
MirroredRepeat
=
2
;
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
.
Scene
=
function
(){
this
.
objects
=
[];
this
.
lights
=
[];
this
.
addObject
=
function
(
a
){
this
.
objects
.
push
(
a
)};
this
.
removeObject
=
function
(
a
){
var
c
=
this
.
objects
.
indexOf
(
a
);
c
!==-
1
&&
this
.
objects
.
splice
(
c
,
1
);
a
.
__removed
=
true
};
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
(
r
,
q
){
var
k
=
0
,
Q
=
1
,
H
=
r
.
z
+
r
.
w
,
T
=
q
.
z
+
q
.
w
,
$
=-
r
.
z
+
r
.
w
,
t
=-
q
.
z
+
q
.
w
;
if
(
H
>=
0
&&
T
>=
0
&&
$
>=
0
&&
t
>=
0
)
return
true
;
else
if
(
H
<
0
&&
T
<
0
||
$
<
0
&&
t
<
0
)
return
false
;
else
{
if
(
H
<
0
)
k
=
Math
.
max
(
k
,
H
/
(
H
-
T
));
else
if
(
T
<
0
)
Q
=
Math
.
min
(
Q
,
H
/
(
H
-
T
));
if
(
$
<
0
)
k
=
Math
.
max
(
k
,
$
/
(
$
-
t
));
else
if
(
t
<
0
)
Q
=
Math
.
min
(
Q
,
$
/
(
$
-
t
));
if
(
Q
<
k
)
return
false
;
else
{
r
.
lerpSelf
(
q
,
k
);
q
.
lerpSelf
(
r
,
1
-
Q
);
return
true
}}}
var
c
=
null
,
f
,
h
,
b
=
[],
d
,
p
,
s
=
[],
o
,
e
,
g
=
[],
l
,
i
,
n
=
[],
j
=
new
THREE
.
Vector4
,
A
=
new
THREE
.
Matrix4
,
C
=
new
THREE
.
Matrix4
,
v
=
new
THREE
.
Vector4
,
L
=
new
THREE
.
Vector4
;
this
.
projectScene
=
function
(
r
,
q
){
var
k
,
Q
,
H
,
T
,
$
,
t
,
F
,
D
,
u
,
N
,
pa
,
Z
,
R
,
B
;
c
=
[];
i
=
e
=
p
=
h
=
0
;
q
.
autoUpdateMatrix
&&
q
.
updateMatrix
();
A
.
multiply
(
q
.
projectionMatrix
,
q
.
matrix
);
$
=
r
.
objects
;
k
=
0
;
for
(
Q
=
$
.
length
;
k
<
Q
;
k
++
){
t
=
$
[
k
];
F
=
t
.
matrix
;
t
.
autoUpdateMatrix
&&
t
.
updateMatrix
();
if
(
t
instanceof
THREE
.
Mesh
){
C
.
multiply
(
A
,
F
);
D
=
t
.
geometry
.
vertices
;
H
=
0
;
for
(
T
=
D
.
length
;
H
<
T
;
H
++
){
u
=
D
[
H
];
N
=
u
.
positionScreen
;
N
.
copy
(
u
.
position
);
C
.
transform
(
N
);
N
.
multiplyScalar
(
1
/
N
.
w
);
u
.
__visible
=
N
.
z
>
0
&&
N
.
z
<
1
}
pa
=
t
.
geometry
.
faces
;
H
=
0
;
for
(
T
=
pa
.
length
;
H
<
T
;
H
++
){
Z
=
pa
[
H
];
if
(
Z
instanceof
THREE
.
Face3
){
u
=
D
[
Z
.
a
];
N
=
D
[
Z
.
b
];
R
=
D
[
Z
.
c
];
if
(
u
.
__visible
&&
N
.
__visible
&&
R
.
__visible
)
if
(
t
.
doubleSided
||
t
.
flipSided
!=
(
R
.
positionScreen
.
x
-
u
.
positionScreen
.
x
)
*
(
N
.
positionScreen
.
y
-
u
.
positionScreen
.
y
)
-
(
R
.
positionScreen
.
y
-
u
.
positionScreen
.
y
)
*
(
N
.
positionScreen
.
x
-
u
.
positionScreen
.
x
)
<
0
){
f
=
b
[
h
]
=
b
[
h
]
||
new
THREE
.
RenderableFace3
;
f
.
v1
.
positionScreen
.
copy
(
u
.
positionScreen
);
f
.
v2
.
positionScreen
.
copy
(
N
.
positionScreen
);
f
.
v3
.
positionScreen
.
copy
(
R
.
positionScreen
);
f
.
normalWorld
.
copy
(
Z
.
normal
);
...
...
@@ -154,11 +154,11 @@ f(e.map.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(e.map.wrap_t));
for
(
i
=
0
;
i
<
6
;
++
i
)
b
.
texImage2D
(
b
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
0
,
b
.
RGBA
,
b
.
RGBA
,
b
.
UNSIGNED_BYTE
,
e
.
env_map
.
image
[
i
]);
b
.
generateMipmap
(
b
.
TEXTURE_CUBE_MAP
);
b
.
bindTexture
(
b
.
TEXTURE_CUBE_MAP
,
null
);
e
.
env_map
.
image
.
__cubeMapInitialized
=
true
}
b
.
activeTexture
(
b
.
TEXTURE1
);
b
.
bindTexture
(
b
.
TEXTURE_CUBE_MAP
,
e
.
env_map
.
image
.
__webGLTextureCube
);
b
.
uniform1i
(
d
.
tCube
,
1
)}
b
.
uniform1i
(
d
.
enableCubeMap
,
1
)}
else
b
.
uniform1i
(
d
.
enableCubeMap
,
0
);
b
.
bindBuffer
(
b
.
ARRAY_BUFFER
,
g
.
__webGLVertexBuffer
);
b
.
vertexAttribPointer
(
d
.
position
,
3
,
b
.
FLOAT
,
false
,
0
,
0
);
b
.
bindBuffer
(
b
.
ARRAY_BUFFER
,
g
.
__webGLNormalBuffer
);
b
.
vertexAttribPointer
(
d
.
normal
,
3
,
b
.
FLOAT
,
false
,
0
,
0
);
if
(
v
){
b
.
bindBuffer
(
b
.
ARRAY_BUFFER
,
g
.
__webGLUVBuffer
);
b
.
enableVertexAttribArray
(
d
.
uv
);
b
.
vertexAttribPointer
(
d
.
uv
,
2
,
b
.
FLOAT
,
false
,
0
,
0
)}
else
b
.
disableVertexAttribArray
(
d
.
uv
);
if
(
j
){
b
.
lineWidth
(
A
);
b
.
bindBuffer
(
b
.
ELEMENT_ARRAY_BUFFER
,
g
.
__webGLLineBuffer
);
b
.
drawElements
(
b
.
LINES
,
g
.
__webGLLineCount
,
b
.
UNSIGNED_SHORT
,
0
)}
else
{
b
.
bindBuffer
(
b
.
ELEMENT_ARRAY_BUFFER
,
g
.
__webGLFaceBuffer
);
b
.
drawElements
(
b
.
TRIANGLES
,
g
.
__webGLFaceCount
,
b
.
UNSIGNED_SHORT
,
0
)}};
this
.
renderPass
=
function
(
e
,
g
,
l
,
i
){
var
n
,
j
,
A
,
C
,
v
;
A
=
0
;
for
(
C
=
e
.
material
.
length
;
A
<
C
;
A
++
){
n
=
e
.
material
[
A
];
if
(
n
instanceof
THREE
.
MeshFaceMaterial
){
n
=
0
;
for
(
j
=
g
.
material
.
length
;
n
<
j
;
n
++
)
if
((
v
=
g
.
material
[
n
])
&&
v
.
blending
==
l
&&
v
.
opacity
<
1
==
i
){
this
.
setBlending
(
v
.
blending
);
this
.
renderBuffer
(
v
,
g
)}}
else
if
((
v
=
n
)
&&
v
.
blending
==
l
&&
v
.
opacity
<
1
==
i
){
this
.
setBlending
(
v
.
blending
);
this
.
renderBuffer
(
v
,
g
)}}};
this
.
render
=
function
(
e
,
g
){
var
l
,
i
;
this
.
initWebGLObjects
(
e
);
this
.
autoClear
&&
this
.
clear
();
g
.
autoUpdateMatrix
&&
g
.
updateMatrix
();
b
.
uniform3f
(
d
.
cameraPosition
,
g
.
position
.
x
,
g
.
position
.
y
,
g
.
position
.
z
);
this
.
setupLights
(
e
);
l
=
0
;
for
(
i
=
e
.
__webGLObjects
.
length
;
l
<
i
;
l
++
){
webGLObject
=
e
.
__webGLObjects
[
l
];
this
.
setupMatrices
(
webGLObject
.
__object
,
g
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
false
)}
l
=
0
;
for
(
i
=
e
.
__webGLObjects
.
length
;
l
<
i
;
l
++
){
webGLObject
=
e
.
__webGLObjects
[
l
];
this
.
setupMatrices
(
webGLObject
.
__object
,
g
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
false
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
false
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
true
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
true
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
true
)}};
this
.
initWebGLObjects
=
function
(
e
){
var
g
,
l
,
i
,
n
,
j
;
if
(
!
e
.
__webGLObjects
)
e
.
__webGLObjects
=
[];
g
=
0
;
for
(
l
=
e
.
objects
.
length
;
g
<
l
;
g
++
){
i
=
e
.
objects
[
g
];
if
(
i
instanceof
THREE
.
Mesh
)
for
(
n
in
i
.
materialFaceGroup
){
j
=
i
.
materialFaceGroup
[
n
];
if
(
!
j
.
__webGLVertexBuffer
){
this
.
createBuffers
(
i
,
n
);
j
.
__object
=
i
;
e
.
__webGLObjects
.
push
(
j
)}}}};
this
.
setupMatrices
=
function
(
e
,
g
){
e
.
autoUpdateMatrix
&&
e
.
updateMatrix
();
p
.
multiply
(
g
.
matrix
,
e
.
matrix
);
d
.
viewMatrixArray
=
new
Float32Array
(
g
.
matrix
.
flatten
());
d
.
modelViewMatrixArray
=
new
Float32Array
(
p
.
flatten
());
d
.
projectionMatrixArray
=
new
Float32Array
(
g
.
projectionMatrix
.
flatten
());
s
=
THREE
.
Matrix4
.
makeInvert3x3
(
p
).
transpose
();
d
.
normalMatrixArray
=
new
Float32Array
(
s
.
m
);
b
.
uniformMatrix4fv
(
d
.
viewMatrix
,
false
,
d
.
viewMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
modelViewMatrix
,
false
,
d
.
modelViewMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
projectionMatrix
,
false
,
d
.
projectionMatrixArray
);
b
.
uniformMatrix3fv
(
d
.
normalMatrix
,
false
,
d
.
normalMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
objMatrix
,
false
,
new
Float32Array
(
e
.
matrix
.
flatten
()))};
this
.
setBlending
=
function
(
e
){
switch
(
e
){
case
THREE
.
AdditiveBlending
:
b
.
blendEquation
(
b
.
FUNC_ADD
);
b
.
blendFunc
(
b
.
ONE
,
b
.
ONE
);
break
;
case
THREE
.
SubtractiveBlending
:
b
.
blendFunc
(
b
.
DST_COLOR
,
b
.
ZERO
);
break
;
default
:
b
.
blendEquation
(
b
.
FUNC_ADD
)
;
b
.
blendFunc
(
b
.
ONE
,
b
.
ONE_MINUS_SRC_ALPHA
)}};
this
.
setFaceCulling
=
function
(
e
,
g
){
if
(
e
){
!
g
||
g
==
"
ccw
"
?
b
.
frontFace
(
b
.
CCW
):
b
.
frontFace
(
b
.
CW
);
if
(
e
==
"
back
"
)
b
.
cullFace
(
b
.
BACK
);
else
e
==
"
front
"
?
b
.
cullFace
(
b
.
FRONT
):
b
.
cullFace
(
b
.
FRONT_AND_BACK
);
b
.
enable
(
b
.
CULL_FACE
)}
else
b
.
disable
(
b
.
CULL_FACE
)}};
g
.
autoUpdateMatrix
&&
g
.
updateMatrix
();
b
.
uniform3f
(
d
.
cameraPosition
,
g
.
position
.
x
,
g
.
position
.
y
,
g
.
position
.
z
);
this
.
setupLights
(
e
);
l
=
0
;
for
(
i
=
e
.
__webGLObjects
.
length
;
l
<
i
;
l
++
){
webGLObject
=
e
.
__webGLObjects
[
l
];
if
(
webGLObject
.
__object
.
visible
){
this
.
setupMatrices
(
webGLObject
.
__object
,
g
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
false
)}}
l
=
0
;
for
(
i
=
e
.
__webGLObjects
.
length
;
l
<
i
;
l
++
){
webGLObject
=
e
.
__webGLObjects
[
l
];
if
(
webGLObject
.
__object
.
visible
){
this
.
setupMatrices
(
webGLObject
.
__object
,
g
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
false
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
false
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
true
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
true
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
true
)}}};
this
.
initWebGLObjects
=
function
(
e
){
var
g
,
l
,
i
,
n
,
j
;
if
(
!
e
.
__webGLObjects
)
e
.
__webGLObjects
=
[];
g
=
0
;
for
(
l
=
e
.
objects
.
length
;
g
<
l
;
g
++
){
i
=
e
.
objects
[
g
];
if
(
i
instanceof
THREE
.
Mesh
)
for
(
n
in
i
.
materialFaceGroup
){
j
=
i
.
materialFaceGroup
[
n
];
if
(
!
j
.
__webGLVertexBuffer
){
this
.
createBuffers
(
i
,
n
);
j
.
__object
=
i
;
e
.
__webGLObjects
.
push
(
j
)}}}
for
(
g
=
e
.
__webGLObjects
.
length
-
1
;
g
>=
0
;
g
--
){
i
=
e
.
__webGLObjects
[
g
].
__object
;
i
.
__removed
&&
e
.
__webGLObjects
.
splice
(
g
,
1
)}};
this
.
setupMatrices
=
function
(
e
,
g
){
e
.
autoUpdateMatrix
&&
e
.
updateMatrix
();
p
.
multiply
(
g
.
matrix
,
e
.
matrix
);
d
.
viewMatrixArray
=
new
Float32Array
(
g
.
matrix
.
flatten
());
d
.
modelViewMatrixArray
=
new
Float32Array
(
p
.
flatten
());
d
.
projectionMatrixArray
=
new
Float32Array
(
g
.
projectionMatrix
.
flatten
());
s
=
THREE
.
Matrix4
.
makeInvert3x3
(
p
).
transpose
();
d
.
normalMatrixArray
=
new
Float32Array
(
s
.
m
);
b
.
uniformMatrix4fv
(
d
.
viewMatrix
,
false
,
d
.
viewMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
modelViewMatrix
,
false
,
d
.
modelViewMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
projectionMatrix
,
false
,
d
.
projectionMatrixArray
);
b
.
uniformMatrix3fv
(
d
.
normalMatrix
,
false
,
d
.
normalMatrixArray
);
b
.
uniformMatrix4fv
(
d
.
objMatrix
,
false
,
new
Float32Array
(
e
.
matrix
.
flatten
()))}
;
this
.
setBlending
=
function
(
e
){
switch
(
e
){
case
THREE
.
AdditiveBlending
:
b
.
blendEquation
(
b
.
FUNC_ADD
);
b
.
blendFunc
(
b
.
ONE
,
b
.
ONE
);
break
;
case
THREE
.
SubtractiveBlending
:
b
.
blendFunc
(
b
.
DST_COLOR
,
b
.
ZERO
);
break
;
default
:
b
.
blendEquation
(
b
.
FUNC_ADD
);
b
.
blendFunc
(
b
.
ONE
,
b
.
ONE_MINUS_SRC_ALPHA
)}};
this
.
setFaceCulling
=
function
(
e
,
g
){
if
(
e
){
!
g
||
g
==
"
ccw
"
?
b
.
frontFace
(
b
.
CCW
):
b
.
frontFace
(
b
.
CW
);
if
(
e
==
"
back
"
)
b
.
cullFace
(
b
.
BACK
);
else
e
==
"
front
"
?
b
.
cullFace
(
b
.
FRONT
):
b
.
cullFace
(
b
.
FRONT_AND_BACK
);
b
.
enable
(
b
.
CULL_FACE
)}
else
b
.
disable
(
b
.
CULL_FACE
)}};
THREE
.
RenderableFace3
=
function
(){
this
.
v1
=
new
THREE
.
Vertex
;
this
.
v2
=
new
THREE
.
Vertex
;
this
.
v3
=
new
THREE
.
Vertex
;
this
.
centroidWorld
=
new
THREE
.
Vector3
;
this
.
centroidScreen
=
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
material
=
this
.
color
=
this
.
z
=
null
};
THREE
.
RenderableFace4
=
function
(){
this
.
v1
=
new
THREE
.
Vertex
;
this
.
v2
=
new
THREE
.
Vertex
;
this
.
v3
=
new
THREE
.
Vertex
;
this
.
v4
=
new
THREE
.
Vertex
;
this
.
centroidWorld
=
new
THREE
.
Vector3
;
this
.
centroidScreen
=
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
material
=
this
.
color
=
this
.
z
=
null
};
THREE
.
RenderableParticle
=
function
(){
this
.
rotation
=
this
.
z
=
this
.
y
=
this
.
x
=
null
;
this
.
scale
=
new
THREE
.
Vector2
;
this
.
material
=
this
.
color
=
null
};
THREE
.
RenderableLine
=
function
(){
this
.
v1
=
new
THREE
.
Vertex
;
this
.
v2
=
new
THREE
.
Vertex
;
this
.
material
=
this
.
color
=
this
.
z
=
null
};
examples/lights_test.html
浏览文件 @
d3cd0887
...
...
@@ -102,9 +102,9 @@
// SPHERES
sphere
=
new
Sphere
(
100
,
16
,
8
,
0
);
sphere
=
new
Sphere
(
100
,
16
,
8
);
for
(
var
i
=
0
;
i
<
30
;
i
++
)
{
mesh
=
new
THREE
.
Mesh
(
sphere
,
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xffffff
}
)
);
mesh
=
new
THREE
.
Mesh
(
sphere
,
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xffffff
,
shading
:
THREE
.
FlatShading
}
)
);
mesh
.
position
.
x
=
500
*
(
Math
.
random
()
-
0.5
);
mesh
.
position
.
y
=
500
*
(
Math
.
random
()
-
0.5
);
mesh
.
position
.
z
=
500
*
(
Math
.
random
()
-
0.5
);
...
...
@@ -133,7 +133,7 @@
scene
.
addLight
(
pointLight
);
sphere
=
new
Sphere
(
100
,
16
,
8
,
1
);
sphere
=
new
Sphere
(
100
,
16
,
8
);
lightMesh
=
new
THREE
.
Mesh
(
sphere
,
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xffaa00
}
)
);
lightMesh
.
scale
.
x
=
lightMesh
.
scale
.
y
=
lightMesh
.
scale
.
z
=
0.05
;
lightMesh
.
position
=
pointLight
.
position
;
...
...
src/extras/SceneUtils.js
浏览文件 @
d3cd0887
...
...
@@ -12,6 +12,8 @@ var SceneUtils = {
mesh
.
rotation
.
z
=
rz
;
scene
.
addObject
(
mesh
);
return
mesh
;
},
addPanoramaCubeWebGL
:
function
(
scene
,
size
,
textureCube
)
{
...
...
@@ -21,6 +23,8 @@ var SceneUtils = {
scene
.
addObject
(
mesh
);
return
mesh
;
},
addPanoramaCube
:
function
(
scene
,
size
,
images
)
{
...
...
@@ -35,6 +39,8 @@ var SceneUtils = {
mesh
=
new
THREE
.
Mesh
(
new
Cube
(
size
,
size
,
size
,
1
,
1
,
materials
,
true
),
new
THREE
.
MeshFaceMaterial
()
);
scene
.
addObject
(
mesh
);
return
mesh
;
},
...
...
@@ -49,6 +55,8 @@ var SceneUtils = {
SceneUtils
.
addMesh
(
scene
,
plane
,
1
,
0
,
hsize
,
0
,
pi2
,
0
,
pi
,
new
THREE
.
MeshBasicMaterial
(
{
map
:
new
THREE
.
Texture
(
images
[
2
]
)
}
)
);
SceneUtils
.
addMesh
(
scene
,
plane
,
1
,
0
,
-
hsize
,
0
,
-
pi2
,
0
,
pi
,
new
THREE
.
MeshBasicMaterial
(
{
map
:
new
THREE
.
Texture
(
images
[
3
]
)
}
)
);
return
mesh
;
}
}
\ No newline at end of file
src/objects/Object3D.js
浏览文件 @
d3cd0887
...
...
@@ -15,6 +15,8 @@ THREE.Object3D = function ( material ) {
this
.
screen
=
new
THREE
.
Vector3
();
this
.
visible
=
true
;
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
()
{
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
d3cd0887
...
...
@@ -655,9 +655,13 @@ THREE.WebGLRenderer = function ( scene ) {
for
(
o
=
0
,
ol
=
scene
.
__webGLObjects
.
length
;
o
<
ol
;
o
++
)
{
webGLObject
=
scene
.
__webGLObjects
[
o
];
if
(
webGLObject
.
__object
.
visible
)
{
this
.
setupMatrices
(
webGLObject
.
__object
,
camera
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
false
);
this
.
setupMatrices
(
webGLObject
.
__object
,
camera
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
false
);
}
}
...
...
@@ -667,18 +671,25 @@ THREE.WebGLRenderer = function ( scene ) {
webGLObject
=
scene
.
__webGLObjects
[
o
];
this
.
setupMatrices
(
webGLObject
.
__object
,
camera
);
if
(
webGLObject
.
__object
.
visible
)
{
this
.
setupMatrices
(
webGLObject
.
__object
,
camera
);
// opaque blended materials
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
false
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
false
);
// transparent blended materials
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
true
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
true
);
// opaque blended materials
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
false
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
false
);
// transparent blended materials
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
AdditiveBlending
,
true
);
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
SubtractiveBlending
,
true
);
// transparent normal materials
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
true
);
// transparent normal materials
this
.
renderPass
(
webGLObject
.
__object
,
webGLObject
,
THREE
.
NormalBlending
,
true
);
}
}
...
...
@@ -725,6 +736,20 @@ THREE.WebGLRenderer = function ( scene ) {
}*/
}
// clean up orphaned objects
for
(
o
=
scene
.
__webGLObjects
.
length
-
1
;
o
>=
0
;
o
--
)
{
object
=
scene
.
__webGLObjects
[
o
].
__object
;
if
(
object
.
__removed
)
{
scene
.
__webGLObjects
.
splice
(
o
,
1
);
}
}
};
...
...
src/scenes/Scene.js
浏览文件 @
d3cd0887
...
...
@@ -23,6 +23,8 @@ THREE.Scene = function () {
}
object
.
__removed
=
true
;
};
this
.
addLight
=
function
(
light
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录