Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
2148d37e
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,发现更多精彩内容 >>
提交
2148d37e
编写于
11月 26, 2012
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Whitespace cleanup in manual mipmaps example.
See #2681
上级
389ba009
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
190 addition
and
157 deletion
+190
-157
build/three.js
build/three.js
+24
-1
build/three.min.js
build/three.min.js
+9
-9
examples/webgl_materials_texture_manualmipmap.html
examples/webgl_materials_texture_manualmipmap.html
+142
-140
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+15
-7
未找到文件。
build/three.js
浏览文件 @
2148d37e
...
...
@@ -10813,6 +10813,7 @@ THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, f
this.name = '';
this.image = image;
this.mipmaps = null;
this.mapping = mapping !== undefined ? mapping : new THREE.UVMapping();
...
...
@@ -10848,6 +10849,7 @@ THREE.Texture.prototype = {
var texture = new THREE.Texture();
texture.image = this.image;
texture.mipmaps = this.mipmaps;
texture.mapping = this.mapping;
...
...
@@ -22273,7 +22275,28 @@ THREE.WebGLRenderer = function ( parameters ) {
} else {
_gl.texImage2D( _gl.TEXTURE_2D, 0, glFormat, glFormat, glType, texture.image );
var mipmap, mipmaps = texture.mipmaps;
if ( mipmaps && isImagePowerOfTwo ) {
// pre generated mipmaped regular texture
for ( var i = 0, il = mipmaps.length; i < il; i ++ ) {
mipmap = mipmaps[ i ];
_gl.texImage2D(_gl.TEXTURE_2D, i, glFormat, glFormat, glType, mipmap );
}
texture.generateMipmaps = false;
} else {
// regular texture
_gl.texImage2D( _gl.TEXTURE_2D, 0, glFormat, glFormat, glType, texture.image );
}
}
...
...
build/three.min.js
浏览文件 @
2148d37e
...
...
@@ -197,10 +197,10 @@ THREE.ShaderMaterial.prototype.clone=function(){var a=new THREE.ShaderMaterial;T
this
.
morphTargets
;
a
.
morphNormals
=
this
.
morphNormals
;
return
a
};
THREE
.
SpriteMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
);
this
.
color
=
new
THREE
.
Color
(
16777215
);
this
.
map
=
new
THREE
.
Texture
;
this
.
useScreenCoordinates
=!
0
;
this
.
depthTest
=!
this
.
useScreenCoordinates
;
this
.
sizeAttenuation
=!
this
.
useScreenCoordinates
;
this
.
scaleByViewport
=!
this
.
sizeAttenuation
;
this
.
alignment
=
THREE
.
SpriteAlignment
.
center
.
clone
();
this
.
fog
=!
1
;
this
.
uvOffset
=
new
THREE
.
Vector2
(
0
,
0
);
this
.
uvScale
=
new
THREE
.
Vector2
(
1
,
1
);
this
.
setValues
(
a
);
a
=
a
||
{};
void
0
===
a
.
depthTest
&&
(
this
.
depthTest
=!
this
.
useScreenCoordinates
);
void
0
===
a
.
sizeAttenuation
&&
(
this
.
sizeAttenuation
=!
this
.
useScreenCoordinates
);
void
0
===
a
.
scaleByViewport
&&
(
this
.
scaleByViewport
=!
this
.
sizeAttenuation
)};
THREE
.
SpriteMaterial
.
prototype
=
Object
.
create
(
THREE
.
Material
.
prototype
);
THREE
.
SpriteMaterial
.
prototype
.
clone
=
function
(){
var
a
=
new
THREE
.
SpriteMaterial
;
THREE
.
Material
.
prototype
.
clone
.
call
(
this
,
a
);
a
.
color
.
copy
(
this
.
color
);
a
.
map
=
this
.
map
;
a
.
useScreenCoordinates
=
this
.
useScreenCoordinates
;
a
.
sizeAttenuation
=
this
.
sizeAttenuation
;
a
.
scaleByViewport
=
this
.
scaleByViewport
;
a
.
alignment
.
copy
(
this
.
alignment
);
a
.
uvOffset
.
copy
(
this
.
uvOffset
);
a
.
uvScale
.
copy
(
this
.
uvScale
);
a
.
fog
=
this
.
fog
;
return
a
};
THREE
.
SpriteAlignment
=
{};
THREE
.
SpriteAlignment
.
topLeft
=
new
THREE
.
Vector2
(
1
,
-
1
);
THREE
.
SpriteAlignment
.
topCenter
=
new
THREE
.
Vector2
(
0
,
-
1
);
THREE
.
SpriteAlignment
.
topRight
=
new
THREE
.
Vector2
(
-
1
,
-
1
);
THREE
.
SpriteAlignment
.
centerLeft
=
new
THREE
.
Vector2
(
1
,
0
);
THREE
.
SpriteAlignment
.
center
=
new
THREE
.
Vector2
(
0
,
0
);
THREE
.
SpriteAlignment
.
centerRight
=
new
THREE
.
Vector2
(
-
1
,
0
);
THREE
.
SpriteAlignment
.
bottomLeft
=
new
THREE
.
Vector2
(
1
,
1
);
THREE
.
SpriteAlignment
.
bottomCenter
=
new
THREE
.
Vector2
(
0
,
1
);
THREE
.
SpriteAlignment
.
bottomRight
=
new
THREE
.
Vector2
(
-
1
,
1
);
THREE
.
Texture
=
function
(
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
){
THREE
.
TextureLibrary
.
push
(
this
);
this
.
id
=
THREE
.
TextureIdCount
++
;
this
.
name
=
""
;
this
.
image
=
a
;
this
.
mapping
=
void
0
!==
b
?
b
:
new
THREE
.
UVMapping
;
this
.
wrapS
=
void
0
!==
c
?
c
:
THREE
.
ClampToEdgeWrapping
;
this
.
wrapT
=
void
0
!==
d
?
d
:
THREE
.
ClampToEdgeWrapping
;
this
.
magFilter
=
void
0
!==
e
?
e
:
THREE
.
LinearFilter
;
this
.
minFilter
=
void
0
!==
f
?
f
:
THREE
.
LinearMipMapLinearFilter
;
this
.
anisotropy
=
void
0
!==
i
?
i
:
1
;
this
.
format
=
void
0
!==
g
?
g
:
THREE
.
RGBAFormat
;
this
.
type
=
void
0
!==
h
?
h
:
THREE
.
UnsignedByteType
;
THREE
.
SpriteAlignment
.
topCenter
=
new
THREE
.
Vector2
(
0
,
-
1
);
THREE
.
SpriteAlignment
.
topRight
=
new
THREE
.
Vector2
(
-
1
,
-
1
);
THREE
.
SpriteAlignment
.
centerLeft
=
new
THREE
.
Vector2
(
1
,
0
);
THREE
.
SpriteAlignment
.
center
=
new
THREE
.
Vector2
(
0
,
0
);
THREE
.
SpriteAlignment
.
centerRight
=
new
THREE
.
Vector2
(
-
1
,
0
);
THREE
.
SpriteAlignment
.
bottomLeft
=
new
THREE
.
Vector2
(
1
,
1
);
THREE
.
SpriteAlignment
.
bottomCenter
=
new
THREE
.
Vector2
(
0
,
1
);
THREE
.
SpriteAlignment
.
bottomRight
=
new
THREE
.
Vector2
(
-
1
,
1
);
THREE
.
Texture
=
function
(
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
){
THREE
.
TextureLibrary
.
push
(
this
);
this
.
id
=
THREE
.
TextureIdCount
++
;
this
.
name
=
""
;
this
.
image
=
a
;
this
.
m
ipmaps
=
null
;
this
.
m
apping
=
void
0
!==
b
?
b
:
new
THREE
.
UVMapping
;
this
.
wrapS
=
void
0
!==
c
?
c
:
THREE
.
ClampToEdgeWrapping
;
this
.
wrapT
=
void
0
!==
d
?
d
:
THREE
.
ClampToEdgeWrapping
;
this
.
magFilter
=
void
0
!==
e
?
e
:
THREE
.
LinearFilter
;
this
.
minFilter
=
void
0
!==
f
?
f
:
THREE
.
LinearMipMapLinearFilter
;
this
.
anisotropy
=
void
0
!==
i
?
i
:
1
;
this
.
format
=
void
0
!==
g
?
g
:
THREE
.
RGBAFormat
;
this
.
type
=
void
0
!==
h
?
h
:
THREE
.
UnsignedByteType
;
this
.
offset
=
new
THREE
.
Vector2
(
0
,
0
);
this
.
repeat
=
new
THREE
.
Vector2
(
1
,
1
);
this
.
generateMipmaps
=!
0
;
this
.
premultiplyAlpha
=!
1
;
this
.
flipY
=!
0
;
this
.
needsUpdate
=!
1
;
this
.
onUpdate
=
null
};
THREE
.
Texture
.
prototype
=
{
constructor
:
THREE
.
Texture
,
clone
:
function
(){
var
a
=
new
THREE
.
Texture
;
a
.
image
=
this
.
image
;
a
.
m
apping
=
this
.
mapping
;
a
.
wrapS
=
this
.
wrapS
;
a
.
wrapT
=
this
.
wrapT
;
a
.
magFilter
=
this
.
magFilter
;
a
.
minFilter
=
this
.
minFilter
;
a
.
anisotropy
=
this
.
anisotropy
;
a
.
format
=
this
.
format
;
a
.
type
=
this
.
type
;
a
.
offset
.
copy
(
this
.
offset
);
a
.
repeat
.
copy
(
this
.
repeat
);
a
.
generateMipmaps
=
this
.
generateMipmaps
;
a
.
premultiplyAlpha
=
this
.
premultiplyAlpha
;
a
.
flipY
=
this
.
flipY
;
return
a
},
deallocate
:
function
(){
var
a
=
THREE
.
TextureLibrary
.
indexOf
(
this
);
-
1
!==
a
&&
THREE
.
TextureLibrary
.
splice
(
a
,
1
)}};
THREE
.
TextureIdCount
=
0
;
THREE
.
TextureLibrary
=
[];
THREE
.
CompressedTexture
=
function
(
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
,
j
,
l
){
THREE
.
Texture
.
call
(
this
,
null
,
f
,
g
,
h
,
i
,
j
,
d
,
e
,
l
);
this
.
image
=
{
width
:
b
,
height
:
c
};
this
.
mipmaps
=
a
};
THREE
.
CompressedTexture
.
prototype
=
Object
.
create
(
THREE
.
Texture
.
prototype
);
THREE
.
Texture
.
prototype
=
{
constructor
:
THREE
.
Texture
,
clone
:
function
(){
var
a
=
new
THREE
.
Texture
;
a
.
image
=
this
.
image
;
a
.
m
ipmaps
=
this
.
mipmaps
;
a
.
mapping
=
this
.
mapping
;
a
.
wrapS
=
this
.
wrapS
;
a
.
wrapT
=
this
.
wrapT
;
a
.
magFilter
=
this
.
magFilter
;
a
.
minFilter
=
this
.
minFilter
;
a
.
anisotropy
=
this
.
anisotropy
;
a
.
format
=
this
.
format
;
a
.
type
=
this
.
type
;
a
.
offset
.
copy
(
this
.
offset
);
a
.
repeat
.
copy
(
this
.
repeat
);
a
.
generateMipmaps
=
this
.
generateMipmaps
;
a
.
premultiplyAlpha
=
this
.
premultiplyAlpha
;
a
.
flipY
=
this
.
flipY
;
return
a
},
deallocate
:
function
(){
var
a
=
THREE
.
TextureLibrary
.
indexOf
(
this
);
-
1
!==
a
&&
THREE
.
TextureLibrary
.
splice
(
a
,
1
)}};
THREE
.
TextureIdCount
=
0
;
THREE
.
TextureLibrary
=
[];
THREE
.
CompressedTexture
=
function
(
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
,
j
,
l
){
THREE
.
Texture
.
call
(
this
,
null
,
f
,
g
,
h
,
i
,
j
,
d
,
e
,
l
);
this
.
image
=
{
width
:
b
,
height
:
c
};
this
.
mipmaps
=
a
};
THREE
.
CompressedTexture
.
prototype
=
Object
.
create
(
THREE
.
Texture
.
prototype
);
THREE
.
CompressedTexture
.
prototype
.
clone
=
function
(){
var
a
=
new
THREE
.
CompressedTexture
;
a
.
image
=
this
.
image
;
a
.
mipmaps
=
this
.
mipmaps
;
a
.
format
=
this
.
format
;
a
.
type
=
this
.
type
;
a
.
mapping
=
this
.
mapping
;
a
.
wrapS
=
this
.
wrapS
;
a
.
wrapT
=
this
.
wrapT
;
a
.
magFilter
=
this
.
magFilter
;
a
.
minFilter
=
this
.
minFilter
;
a
.
anisotropy
=
this
.
anisotropy
;
a
.
offset
.
copy
(
this
.
offset
);
a
.
repeat
.
copy
(
this
.
repeat
);
return
a
};
THREE
.
DataTexture
=
function
(
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
,
j
,
l
){
THREE
.
Texture
.
call
(
this
,
null
,
f
,
g
,
h
,
i
,
j
,
d
,
e
,
l
);
this
.
image
=
{
data
:
a
,
width
:
b
,
height
:
c
}};
THREE
.
DataTexture
.
prototype
=
Object
.
create
(
THREE
.
Texture
.
prototype
);
THREE
.
DataTexture
.
prototype
.
clone
=
function
(){
var
a
=
new
THREE
.
DataTexture
(
this
.
image
.
data
,
this
.
image
.
width
,
this
.
image
.
height
,
this
.
format
,
this
.
type
,
this
.
mapping
,
this
.
wrapS
,
this
.
wrapT
,
this
.
magFilter
,
this
.
minFilter
,
this
.
anisotropy
);
a
.
offset
.
copy
(
this
.
offset
);
a
.
repeat
.
copy
(
this
.
repeat
);
return
a
};
THREE
.
Particle
=
function
(
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
material
=
a
};
THREE
.
Particle
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
Particle
.
prototype
.
clone
=
function
(
a
){
void
0
===
a
&&
(
a
=
new
THREE
.
Particle
(
this
.
material
));
THREE
.
Object3D
.
prototype
.
clone
.
call
(
this
,
a
);
return
a
};
THREE
.
ParticleSystem
=
function
(
a
,
b
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
a
;
this
.
material
=
void
0
!==
b
?
b
:
new
THREE
.
ParticleBasicMaterial
({
color
:
16777215
*
Math
.
random
()});
this
.
sortParticles
=!
1
;
this
.
geometry
&&
(
null
===
this
.
geometry
.
boundingSphere
&&
this
.
geometry
.
computeBoundingSphere
(),
this
.
boundRadius
=
a
.
boundingSphere
.
radius
);
this
.
frustumCulled
=!
1
};
THREE
.
ParticleSystem
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
ParticleSystem
.
prototype
.
clone
=
function
(
a
){
void
0
===
a
&&
(
a
=
new
THREE
.
ParticleSystem
(
this
.
geometry
,
this
.
material
));
a
.
sortParticles
=
this
.
sortParticles
;
THREE
.
Object3D
.
prototype
.
clone
.
call
(
this
,
a
);
return
a
};
THREE
.
Line
=
function
(
a
,
b
,
c
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
a
;
this
.
material
=
void
0
!==
b
?
b
:
new
THREE
.
LineBasicMaterial
({
color
:
16777215
*
Math
.
random
()});
this
.
type
=
void
0
!==
c
?
c
:
THREE
.
LineStrip
;
this
.
geometry
&&
(
this
.
geometry
.
boundingSphere
||
this
.
geometry
.
computeBoundingSphere
())};
THREE
.
LineStrip
=
0
;
THREE
.
LinePieces
=
1
;
THREE
.
Line
.
prototype
=
Object
.
create
(
THREE
.
Object3D
.
prototype
);
THREE
.
Line
.
prototype
.
clone
=
function
(
a
){
void
0
===
a
&&
(
a
=
new
THREE
.
Line
(
this
.
geometry
,
this
.
material
,
this
.
type
));
THREE
.
Object3D
.
prototype
.
clone
.
call
(
this
,
a
);
return
a
};
THREE
.
Mesh
=
function
(
a
,
b
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
a
;
this
.
material
=
void
0
!==
b
?
b
:
new
THREE
.
MeshBasicMaterial
({
color
:
16777215
*
Math
.
random
(),
wireframe
:
!
0
});
if
(
this
.
geometry
&&
(
null
===
this
.
geometry
.
boundingSphere
&&
this
.
geometry
.
computeBoundingSphere
(),
this
.
boundRadius
=
a
.
boundingSphere
.
radius
,
this
.
geometry
.
morphTargets
.
length
)){
this
.
morphTargetBase
=-
1
;
this
.
morphTargetForcedOrder
=
[];
this
.
morphTargetInfluences
=
[];
this
.
morphTargetDictionary
=
{};
for
(
var
c
=
0
;
c
<
this
.
geometry
.
morphTargets
.
length
;
c
++
)
this
.
morphTargetInfluences
.
push
(
0
),
...
...
@@ -436,12 +436,12 @@ x);for(x=0;x<c.maxMorphNormals;x++)t.push("morphNormal"+x);for(j in b)t.push(j);
b
+
j
,
0
<=
x
[
v
]
&&
a
.
numSupportedMorphNormals
++
}
a
.
uniformsList
=
[];
for
(
i
in
a
.
uniforms
)
a
.
uniformsList
.
push
([
a
.
uniforms
[
i
],
i
])};
this
.
setFaceCulling
=
function
(
a
,
b
){
a
?(
!
b
||
"
ccw
"
===
b
?
k
.
frontFace
(
k
.
CCW
):
k
.
frontFace
(
k
.
CW
),
"
back
"
===
a
?
k
.
cullFace
(
k
.
BACK
):
"
front
"
===
a
?
k
.
cullFace
(
k
.
FRONT
):
k
.
cullFace
(
k
.
FRONT_AND_BACK
),
k
.
enable
(
k
.
CULL_FACE
)):
k
.
disable
(
k
.
CULL_FACE
)};
this
.
setMaterialFaces
=
function
(
a
){
var
b
=
a
.
side
===
THREE
.
DoubleSide
,
a
=
a
.
side
===
THREE
.
BackSide
;
za
!==
b
&&
(
b
?
k
.
disable
(
k
.
CULL_FACE
):
k
.
enable
(
k
.
CULL_FACE
),
za
=
b
);
qa
!==
a
&&
(
a
?
k
.
frontFace
(
k
.
CW
):
k
.
frontFace
(
k
.
CCW
),
qa
=
a
)};
this
.
setDepthTest
=
function
(
a
){
nb
!==
a
&&
(
a
?
k
.
enable
(
k
.
DEPTH_TEST
):
k
.
disable
(
k
.
DEPTH_TEST
),
nb
=
a
)};
this
.
setDepthWrite
=
function
(
a
){
mb
!==
a
&&
(
k
.
depthMask
(
a
),
mb
=
a
)};
this
.
setBlending
=
function
(
a
,
b
,
c
,
d
){
a
!==
Sa
&&
(
a
===
THREE
.
NoBlending
?
k
.
disable
(
k
.
BLEND
):
a
===
THREE
.
AdditiveBlending
?(
k
.
enable
(
k
.
BLEND
),
k
.
blendEquation
(
k
.
FUNC_ADD
),
k
.
blendFunc
(
k
.
SRC_ALPHA
,
k
.
ONE
)):
a
===
THREE
.
SubtractiveBlending
?(
k
.
enable
(
k
.
BLEND
),
k
.
blendEquation
(
k
.
FUNC_ADD
),
k
.
blendFunc
(
k
.
ZERO
,
k
.
ONE_MINUS_SRC_COLOR
)):
a
===
THREE
.
MultiplyBlending
?(
k
.
enable
(
k
.
BLEND
),
k
.
blendEquation
(
k
.
FUNC_ADD
),
k
.
blendFunc
(
k
.
ZERO
,
k
.
SRC_COLOR
)):
a
===
THREE
.
CustomBlending
?
k
.
enable
(
k
.
BLEND
):(
k
.
enable
(
k
.
BLEND
),
k
.
blendEquationSeparate
(
k
.
FUNC_ADD
,
k
.
FUNC_ADD
),
k
.
blendFuncSeparate
(
k
.
SRC_ALPHA
,
k
.
ONE_MINUS_SRC_ALPHA
,
k
.
ONE
,
k
.
ONE_MINUS_SRC_ALPHA
)),
Sa
=
a
);
if
(
a
===
THREE
.
CustomBlending
){
if
(
b
!==
gb
&&
(
k
.
blendEquation
(
Q
(
b
)),
gb
=
b
),
c
!==
vb
||
d
!==
rb
)
k
.
blendFunc
(
Q
(
c
),
Q
(
d
)),
vb
=
c
,
rb
=
d
}
else
rb
=
vb
=
gb
=
null
};
this
.
setTexture
=
function
(
a
,
b
){
if
(
a
.
needsUpdate
){
a
.
__webglInit
||
(
a
.
__webglInit
=!
0
,
a
.
__webglTexture
=
k
.
createTexture
(),
H
.
info
.
memory
.
textures
++
);
k
.
activeTexture
(
k
.
TEXTURE0
+
b
);
k
.
bindTexture
(
k
.
TEXTURE_2D
,
a
.
__webglTexture
);
k
.
pixelStorei
(
k
.
UNPACK_FLIP_Y_WEBGL
,
a
.
flipY
);
k
.
pixelStorei
(
k
.
UNPACK_PREMULTIPLY_ALPHA_WEBGL
,
a
.
premultiplyAlpha
);
var
c
=
a
.
image
,
d
=
0
===
(
c
.
width
&
c
.
width
-
1
)
&&
0
===
(
c
.
height
&
c
.
height
-
1
),
e
=
Q
(
a
.
format
),
f
=
Q
(
a
.
type
);
L
(
k
.
TEXTURE_2D
,
a
,
d
);
if
(
a
instanceof
THREE
.
CompressedTexture
)
for
(
var
f
=
a
.
mipmaps
,
g
=
0
,
h
=
f
.
length
;
g
<
h
;
g
++
)
c
=
f
[
g
],
k
.
compressedTexImage2D
(
k
.
TEXTURE_2D
,
g
,
e
,
c
.
width
,
c
.
height
,
0
,
c
.
data
);
else
a
instanceof
THREE
.
DataTexture
?
k
.
texImage2D
(
k
.
TEXTURE_2D
,
0
,
e
,
c
.
width
,
c
.
height
,
0
,
e
,
f
,
c
.
data
):
k
.
texImage2D
(
k
.
TEXTURE_2D
,
0
,
e
,
e
,
f
,
a
.
image
);
a
.
generateMipmaps
&&
d
&&
k
.
generateMipmap
(
k
.
TEXTURE_2D
);
a
.
needsUpdate
=!
1
;
if
(
a
.
onUpdate
)
a
.
onUpdate
()}
else
k
.
activeTexture
(
k
.
TEXTURE0
+
b
),
k
.
bindTexture
(
k
.
TEXTURE_2D
,
a
.
__webglTexture
)};
this
.
setRenderTarget
=
function
(
a
){
var
b
=
a
instanceof
THREE
.
WebGLRenderTargetCube
;
if
(
a
&&!
a
.
__webglFramebuffer
){
void
0
===
a
.
depthBuffer
&&
(
a
.
depthBuffer
=!
0
);
void
0
===
a
.
stencilBuffer
&&
(
a
.
stencilBuffer
=!
0
);
a
.
__webglTexture
=
k
.
createTexture
();
H
.
info
.
memory
.
textures
++
;
var
c
=
0
===
(
a
.
width
&
a
.
width
-
1
)
&&
0
===
(
a
.
height
&
a
.
height
-
1
),
d
=
Q
(
a
.
format
),
e
=
Q
(
a
.
type
);
if
(
b
){
a
.
__webglFramebuffer
=
[];
a
.
__webglRenderbuffer
=
[];
k
.
bindTexture
(
k
.
TEXTURE_CUBE_MAP
,
a
.
__webglTexture
);
L
(
k
.
TEXTURE_CUBE_MAP
,
a
,
c
);
for
(
var
f
=
0
;
6
>
f
;
f
++
){
a
.
__webglFramebuffer
[
f
]
=
k
.
createFramebuffer
();
a
.
__webglRenderbuffer
[
f
]
=
k
.
createRenderbuffer
();
k
.
texImage2D
(
k
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
f
,
0
,
d
,
a
.
width
,
a
.
height
,
0
,
d
,
e
,
null
);
var
g
=
a
,
h
=
k
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
f
;
k
.
bindFramebuffer
(
k
.
FRAMEBUFFER
,
a
.
__webglFramebuffer
[
f
]);
k
.
framebufferTexture2D
(
k
.
FRAMEBUFFER
,
k
.
COLOR_ATTACHMENT0
,
h
,
g
.
__webglTexture
,
0
);
I
(
a
.
__webglRenderbuffer
[
f
],
a
)}
c
&&
k
.
generateMipmap
(
k
.
TEXTURE_CUBE_MAP
)}
else
a
.
__webglFramebuffer
=
k
.
createFramebuffer
(),
a
.
__webglRenderbuffer
=
k
.
createRenderbuffer
(),
k
.
bindTexture
(
k
.
TEXTURE_2D
,
a
.
__webglTexture
),
L
(
k
.
TEXTURE_2D
,
a
,
c
),
k
.
texImage2D
(
k
.
TEXTURE_2D
,
0
,
d
,
a
.
width
,
a
.
height
,
0
,
d
,
e
,
null
),
d
=
k
.
TEXTURE_2D
,
k
.
bindFramebuffer
(
k
.
FRAMEBUFFER
,
a
.
__webglFramebuffer
),
k
.
framebufferTexture2D
(
k
.
FRAMEBUFFER
,
k
.
COLOR_ATTACHMENT0
,
d
,
a
.
__webglTexture
,
0
),
I
(
a
.
__webglRenderbuffer
,
a
),
c
&&
k
.
generateMipmap
(
k
.
TEXTURE_2D
);
b
?
k
.
bindTexture
(
k
.
TEXTURE_CUBE_MAP
,
null
):
k
.
bindTexture
(
k
.
TEXTURE_2D
,
null
);
k
.
bindRenderbuffer
(
k
.
RENDERBUFFER
,
null
);
k
.
bindFramebuffer
(
k
.
FRAMEBUFFER
,
null
)}
a
?(
b
=
b
?
a
.
__webglFramebuffer
[
a
.
activeCubeFace
]:
a
.
__webglFramebuffer
,
c
=
a
.
width
,
a
=
a
.
height
,
e
=
d
=
0
):(
b
=
null
,
c
=
sb
,
a
=
hb
,
d
=
ob
,
e
=
la
);
b
!==
ja
&&
(
k
.
bindFramebuffer
(
k
.
FRAMEBUFFER
,
b
),
k
.
viewport
(
d
,
e
,
c
,
a
)
,
ja
=
b
);
Ba
=
c
;
tb
=
a
};
this
.
shadowMapPlugin
=
new
THREE
.
ShadowMapPlugin
;
this
.
addPrePlugin
(
this
.
shadowMapPlugin
);
this
.
addPostPlugin
(
new
THREE
.
SpritePlugin
);
this
.
addPostPlugin
(
new
THREE
.
LensFlarePlugin
)};
THREE
.
WebGLRenderTarget
=
function
(
a
,
b
,
c
){
this
.
width
=
a
;
this
.
height
=
b
;
c
=
c
||
{};
this
.
wrapS
=
void
0
!==
c
.
wrapS
?
c
.
wrapS
:
THREE
.
ClampToEdgeWrapping
;
this
.
wrapT
=
void
0
!==
c
.
wrapT
?
c
.
wrapT
:
THREE
.
ClampToEdgeWrapping
;
this
.
magFilter
=
void
0
!==
c
.
magFilter
?
c
.
magFilter
:
THREE
.
LinearFilter
;
this
.
minFilter
=
void
0
!==
c
.
minFilter
?
c
.
minFilter
:
THREE
.
LinearMipMapLinearFilter
;
this
.
anisotropy
=
void
0
!==
c
.
anisotropy
?
c
.
anisotropy
:
1
;
this
.
offset
=
new
THREE
.
Vector2
(
0
,
0
);
this
.
repeat
=
new
THREE
.
Vector2
(
1
,
1
);
this
.
format
=
void
0
!==
c
.
format
?
c
.
format
:
(
a
.
__webglInit
=!
0
,
a
.
__webglTexture
=
k
.
createTexture
(),
H
.
info
.
memory
.
textures
++
);
k
.
activeTexture
(
k
.
TEXTURE0
+
b
);
k
.
bindTexture
(
k
.
TEXTURE_2D
,
a
.
__webglTexture
);
k
.
pixelStorei
(
k
.
UNPACK_FLIP_Y_WEBGL
,
a
.
flipY
);
k
.
pixelStorei
(
k
.
UNPACK_PREMULTIPLY_ALPHA_WEBGL
,
a
.
premultiplyAlpha
);
var
c
=
a
.
image
,
d
=
0
===
(
c
.
width
&
c
.
width
-
1
)
&&
0
===
(
c
.
height
&
c
.
height
-
1
),
e
=
Q
(
a
.
format
),
f
=
Q
(
a
.
type
);
L
(
k
.
TEXTURE_2D
,
a
,
d
);
if
(
a
instanceof
THREE
.
CompressedTexture
)
for
(
var
g
=
a
.
mipmaps
,
h
=
0
,
i
=
g
.
length
;
h
<
i
;
h
++
)
c
=
g
[
h
],
k
.
compressedTexImage2D
(
k
.
TEXTURE_2D
,
h
,
e
,
c
.
width
,
c
.
height
,
0
,
c
.
data
);
else
if
(
a
instanceof
THREE
.
DataTexture
)
k
.
texImage2D
(
k
.
TEXTURE_2D
,
0
,
e
,
c
.
width
,
c
.
height
,
0
,
e
,
f
,
c
.
data
);
else
if
((
g
=
a
.
mipmaps
)
&&
d
){
h
=
0
;
for
(
i
=
g
.
length
;
h
<
i
;
h
++
)
c
=
g
[
h
],
k
.
texImage2D
(
k
.
TEXTURE_2D
,
h
,
e
,
e
,
f
,
c
);
a
.
generateMipmaps
=!
1
}
else
k
.
texImage2D
(
k
.
TEXTURE_2D
,
0
,
e
,
e
,
f
,
a
.
image
);
a
.
generateMipmaps
&&
d
&&
k
.
generateMipmap
(
k
.
TEXTURE_2D
);
a
.
needsUpdate
=!
1
;
if
(
a
.
onUpdate
)
a
.
onUpdate
()}
else
k
.
activeTexture
(
k
.
TEXTURE0
+
b
),
k
.
bindTexture
(
k
.
TEXTURE_2D
,
a
.
__webglTexture
)};
this
.
setRenderTarget
=
function
(
a
){
var
b
=
a
instanceof
THREE
.
WebGLRenderTargetCube
;
if
(
a
&&!
a
.
__webglFramebuffer
){
void
0
===
a
.
depthBuffer
&&
(
a
.
depthBuffer
=!
0
);
void
0
===
a
.
stencilBuffer
&&
(
a
.
stencilBuffer
=!
0
);
a
.
__webglTexture
=
k
.
createTexture
();
H
.
info
.
memory
.
textures
++
;
var
c
=
0
===
(
a
.
width
&
a
.
width
-
1
)
&&
0
===
(
a
.
height
&
a
.
height
-
1
),
d
=
Q
(
a
.
format
),
e
=
Q
(
a
.
type
);
if
(
b
){
a
.
__webglFramebuffer
=
[];
a
.
__webglRenderbuffer
=
[];
k
.
bindTexture
(
k
.
TEXTURE_CUBE_MAP
,
a
.
__webglTexture
);
L
(
k
.
TEXTURE_CUBE_MAP
,
a
,
c
);
for
(
var
f
=
0
;
6
>
f
;
f
++
){
a
.
__webglFramebuffer
[
f
]
=
k
.
createFramebuffer
();
a
.
__webglRenderbuffer
[
f
]
=
k
.
createRenderbuffer
();
k
.
texImage2D
(
k
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
f
,
0
,
d
,
a
.
width
,
a
.
height
,
0
,
d
,
e
,
null
);
var
g
=
a
,
h
=
k
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
f
;
k
.
bindFramebuffer
(
k
.
FRAMEBUFFER
,
a
.
__webglFramebuffer
[
f
]);
k
.
framebufferTexture2D
(
k
.
FRAMEBUFFER
,
k
.
COLOR_ATTACHMENT0
,
h
,
g
.
__webglTexture
,
0
);
I
(
a
.
__webglRenderbuffer
[
f
],
a
)}
c
&&
k
.
generateMipmap
(
k
.
TEXTURE_CUBE_MAP
)}
else
a
.
__webglFramebuffer
=
k
.
createFramebuffer
(),
a
.
__webglRenderbuffer
=
k
.
createRenderbuffer
(),
k
.
bindTexture
(
k
.
TEXTURE_2D
,
a
.
__webglTexture
)
,
L
(
k
.
TEXTURE_2D
,
a
,
c
),
k
.
texImage2D
(
k
.
TEXTURE_2D
,
0
,
d
,
a
.
width
,
a
.
height
,
0
,
d
,
e
,
null
),
d
=
k
.
TEXTURE_2D
,
k
.
bindFramebuffer
(
k
.
FRAMEBUFFER
,
a
.
__webglFramebuffer
),
k
.
framebufferTexture2D
(
k
.
FRAMEBUFFER
,
k
.
COLOR_ATTACHMENT0
,
d
,
a
.
__webglTexture
,
0
),
I
(
a
.
__webglRenderbuffer
,
a
),
c
&&
k
.
generateMipmap
(
k
.
TEXTURE_2D
);
b
?
k
.
bindTexture
(
k
.
TEXTURE_CUBE_MAP
,
null
):
k
.
bindTexture
(
k
.
TEXTURE_2D
,
null
);
k
.
bindRenderbuffer
(
k
.
RENDERBUFFER
,
null
);
k
.
bindFramebuffer
(
k
.
FRAMEBUFFER
,
null
)}
a
?(
b
=
b
?
a
.
__webglFramebuffer
[
a
.
activeCubeFace
]:
a
.
__webglFramebuffer
,
c
=
a
.
width
,
a
=
a
.
height
,
e
=
d
=
0
):(
b
=
null
,
c
=
sb
,
a
=
hb
,
d
=
ob
,
e
=
la
);
b
!==
ja
&&
(
k
.
bindFramebuffer
(
k
.
FRAMEBUFFER
,
b
),
k
.
viewport
(
d
,
e
,
c
,
a
),
ja
=
b
);
Ba
=
c
;
tb
=
a
};
this
.
shadowMapPlugin
=
new
THREE
.
ShadowMapPlugin
;
this
.
addPrePlugin
(
this
.
shadowMapPlugin
);
this
.
addPostPlugin
(
new
THREE
.
SpritePlugin
);
this
.
addPostPlugin
(
new
THREE
.
LensFlarePlugin
)};
THREE
.
WebGLRenderTarget
=
function
(
a
,
b
,
c
){
this
.
width
=
a
;
this
.
height
=
b
;
c
=
c
||
{};
this
.
wrapS
=
void
0
!==
c
.
wrapS
?
c
.
wrapS
:
THREE
.
ClampToEdgeWrapping
;
this
.
wrapT
=
void
0
!==
c
.
wrapT
?
c
.
wrapT
:
THREE
.
ClampToEdgeWrapping
;
this
.
magFilter
=
void
0
!==
c
.
magFilter
?
c
.
magFilter
:
THREE
.
LinearFilter
;
this
.
minFilter
=
void
0
!==
c
.
minFilter
?
c
.
minFilter
:
THREE
.
LinearMipMapLinearFilter
;
this
.
anisotropy
=
void
0
!==
c
.
anisotropy
?
c
.
anisotropy
:
1
;
this
.
offset
=
new
THREE
.
Vector2
(
0
,
0
);
this
.
repeat
=
new
THREE
.
Vector2
(
1
,
1
);
this
.
format
=
void
0
!==
c
.
format
?
c
.
format
:
THREE
.
RGBAFormat
;
this
.
type
=
void
0
!==
c
.
type
?
c
.
type
:
THREE
.
UnsignedByteType
;
this
.
depthBuffer
=
void
0
!==
c
.
depthBuffer
?
c
.
depthBuffer
:
!
0
;
this
.
stencilBuffer
=
void
0
!==
c
.
stencilBuffer
?
c
.
stencilBuffer
:
!
0
;
this
.
generateMipmaps
=!
0
};
THREE
.
WebGLRenderTarget
.
prototype
.
clone
=
function
(){
var
a
=
new
THREE
.
WebGLRenderTarget
(
this
.
width
,
this
.
height
);
a
.
wrapS
=
this
.
wrapS
;
a
.
wrapT
=
this
.
wrapT
;
a
.
magFilter
=
this
.
magFilter
;
a
.
anisotropy
=
this
.
anisotropy
;
a
.
minFilter
=
this
.
minFilter
;
a
.
offset
.
copy
(
this
.
offset
);
a
.
repeat
.
copy
(
this
.
repeat
);
a
.
format
=
this
.
format
;
a
.
type
=
this
.
type
;
a
.
depthBuffer
=
this
.
depthBuffer
;
a
.
stencilBuffer
=
this
.
stencilBuffer
;
a
.
generateMipmaps
=
this
.
generateMipmaps
;
return
a
};
THREE
.
WebGLRenderTargetCube
=
function
(
a
,
b
,
c
){
THREE
.
WebGLRenderTarget
.
call
(
this
,
a
,
b
,
c
);
this
.
activeCubeFace
=
0
};
THREE
.
WebGLRenderTargetCube
.
prototype
=
Object
.
create
(
THREE
.
WebGLRenderTarget
.
prototype
);
THREE
.
RenderableVertex
=
function
(){
this
.
positionWorld
=
new
THREE
.
Vector3
;
this
.
positionScreen
=
new
THREE
.
Vector4
;
this
.
visible
=!
0
};
THREE
.
RenderableVertex
.
prototype
.
copy
=
function
(
a
){
this
.
positionWorld
.
copy
(
a
.
positionWorld
);
this
.
positionScreen
.
copy
(
a
.
positionScreen
)};
THREE
.
RenderableFace3
=
function
(){
this
.
v1
=
new
THREE
.
RenderableVertex
;
this
.
v2
=
new
THREE
.
RenderableVertex
;
this
.
v3
=
new
THREE
.
RenderableVertex
;
this
.
centroidWorld
=
new
THREE
.
Vector3
;
this
.
centroidScreen
=
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
vertexNormalsWorld
=
[
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
];
this
.
vertexNormalsLength
=
0
;
this
.
material
=
this
.
color
=
null
;
this
.
uvs
=
[[]];
this
.
z
=
null
};
THREE
.
RenderableFace4
=
function
(){
this
.
v1
=
new
THREE
.
RenderableVertex
;
this
.
v2
=
new
THREE
.
RenderableVertex
;
this
.
v3
=
new
THREE
.
RenderableVertex
;
this
.
v4
=
new
THREE
.
RenderableVertex
;
this
.
centroidWorld
=
new
THREE
.
Vector3
;
this
.
centroidScreen
=
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
vertexNormalsWorld
=
[
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
];
this
.
vertexNormalsLength
=
0
;
this
.
material
=
this
.
color
=
null
;
this
.
uvs
=
[[]];
this
.
z
=
null
};
THREE
.
RenderableObject
=
function
(){
this
.
z
=
this
.
object
=
null
};
THREE
.
RenderableParticle
=
function
(){
this
.
rotation
=
this
.
z
=
this
.
y
=
this
.
x
=
this
.
object
=
null
;
this
.
scale
=
new
THREE
.
Vector2
;
this
.
material
=
null
};
THREE
.
RenderableLine
=
function
(){
this
.
z
=
null
;
this
.
v1
=
new
THREE
.
RenderableVertex
;
this
.
v2
=
new
THREE
.
RenderableVertex
;
this
.
material
=
null
};
THREE
.
ColorUtils
=
{
adjustHSV
:
function
(
a
,
b
,
c
,
d
){
var
e
=
THREE
.
ColorUtils
.
__hsv
;
a
.
getHSV
(
e
);
e
.
h
=
THREE
.
Math
.
clamp
(
e
.
h
+
b
,
0
,
1
);
e
.
s
=
THREE
.
Math
.
clamp
(
e
.
s
+
c
,
0
,
1
);
e
.
v
=
THREE
.
Math
.
clamp
(
e
.
v
+
d
,
0
,
1
);
a
.
setHSV
(
e
.
h
,
e
.
s
,
e
.
v
)}};
THREE
.
ColorUtils
.
__hsv
=
{
h
:
0
,
s
:
0
,
v
:
0
};
THREE
.
GeometryUtils
=
{
merge
:
function
(
a
,
b
){
var
c
,
d
,
e
=
a
.
vertices
.
length
,
f
=
b
instanceof
THREE
.
Mesh
?
b
.
geometry
:
b
,
g
=
a
.
vertices
,
h
=
f
.
vertices
,
i
=
a
.
faces
,
j
=
f
.
faces
,
l
=
a
.
faceVertexUvs
[
0
],
f
=
f
.
faceVertexUvs
[
0
];
b
instanceof
THREE
.
Mesh
&&
(
b
.
matrixAutoUpdate
&&
b
.
updateMatrix
(),
c
=
b
.
matrix
,
d
=
new
THREE
.
Matrix4
,
d
.
extractRotation
(
c
,
b
.
scale
));
for
(
var
n
=
0
,
m
=
h
.
length
;
n
<
m
;
n
++
){
var
p
=
h
[
n
].
clone
();
c
&&
c
.
multiplyVector3
(
p
);
g
.
push
(
p
)}
n
=
0
;
for
(
m
=
j
.
length
;
n
<
m
;
n
++
){
var
p
=
j
[
n
],
q
,
r
,
u
=
p
.
vertexNormals
,
s
=
p
.
vertexColors
;
p
instanceof
THREE
.
Face3
?
q
=
new
THREE
.
Face3
(
p
.
a
+
e
,
p
.
b
+
e
,
p
.
c
+
e
):
p
instanceof
THREE
.
Face4
&&
(
q
=
new
THREE
.
Face4
(
p
.
a
+
e
,
p
.
b
+
e
,
p
.
c
+
e
,
p
.
d
+
e
));
q
.
normal
.
copy
(
p
.
normal
);
d
&&
d
.
multiplyVector3
(
q
.
normal
);
g
=
0
;
for
(
h
=
u
.
length
;
g
<
h
;
g
++
)
r
=
u
[
g
].
clone
(),
d
&&
d
.
multiplyVector3
(
r
),
q
.
vertexNormals
.
push
(
r
);
q
.
color
.
copy
(
p
.
color
);
g
=
0
;
for
(
h
=
s
.
length
;
g
<
h
;
g
++
)
r
=
s
[
g
],
q
.
vertexColors
.
push
(
r
.
clone
());
q
.
materialIndex
=
p
.
materialIndex
;
q
.
centroid
.
copy
(
p
.
centroid
);
c
&&
c
.
multiplyVector3
(
q
.
centroid
);
i
.
push
(
q
)}
n
=
0
;
for
(
m
=
f
.
length
;
n
<
m
;
n
++
){
c
=
f
[
n
];
d
=
[];
g
=
0
;
for
(
h
=
c
.
length
;
g
<
...
...
examples/webgl_materials_texture_manualmipmap.html
浏览文件 @
2148d37e
...
...
@@ -60,7 +60,7 @@
mag:
<span
class=
"c"
>
Nearest
</span><br/>
min:
<span
class=
"c"
>
Nearest
</span>
</div>
<script
src=
"../build/three.min.js"
></script>
<script
src=
"js/Detector.js"
></script>
...
...
@@ -68,213 +68,215 @@
<script>
if
(
!
Detector
.
webgl
)
Detector
.
addGetWebGLMessage
();
if
(
!
Detector
.
webgl
)
Detector
.
addGetWebGLMessage
();
var
SCREEN_WIDTH
=
window
.
innerWidth
;
var
SCREEN_HEIGHT
=
window
.
innerHeight
;
var
SCREEN_WIDTH
=
window
.
innerWidth
;
var
SCREEN_HEIGHT
=
window
.
innerHeight
;
var
container
,
stats
;
var
container
,
stats
;
var
camera
,
scene
,
scene2
,
renderer
;
var
camera
,
scene
,
scene2
,
renderer
;
var
mouseX
=
0
,
mouseY
=
0
;
var
mouseX
=
0
,
mouseY
=
0
;
var
windowHalfX
=
window
.
innerWidth
/
2
;
var
windowHalfY
=
window
.
innerHeight
/
2
;
var
windowHalfX
=
window
.
innerWidth
/
2
;
var
windowHalfY
=
window
.
innerHeight
/
2
;
init
();
animate
();
init
();
animate
();
function
init
()
{
function
init
()
{
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
camera
=
new
THREE
.
PerspectiveCamera
(
35
,
SCREEN_WIDTH
/
SCREEN_HEIGHT
,
1
,
5000
);
camera
.
position
.
z
=
1500
;
camera
=
new
THREE
.
PerspectiveCamera
(
35
,
SCREEN_WIDTH
/
SCREEN_HEIGHT
,
1
,
5000
);
camera
.
position
.
z
=
1500
;
scene
=
new
THREE
.
Scene
();
scene
.
fog
=
new
THREE
.
Fog
(
0x000000
,
1500
,
4000
);
scene
=
new
THREE
.
Scene
();
scene
.
fog
=
new
THREE
.
Fog
(
0x000000
,
1500
,
4000
);
scene2
=
new
THREE
.
Scene
();
scene2
.
fog
=
scene
.
fog
;
scene2
=
new
THREE
.
Scene
();
scene2
.
fog
=
scene
.
fog
;
// GROUND
// GROUND
function
mipmap
(
size
,
color
)
{
var
imageCanvas
=
document
.
createElement
(
"
canvas
"
),
context
=
imageCanvas
.
getContext
(
"
2d
"
);
function
mipmap
(
size
,
color
)
{
imageCanvas
.
width
=
imageCanvas
.
height
=
size
;
var
imageCanvas
=
document
.
createElement
(
"
canvas
"
),
context
=
imageCanvas
.
getContext
(
"
2d
"
);
context
.
fillStyle
=
"
#444
"
;
context
.
fillRect
(
0
,
0
,
size
,
size
);
imageCanvas
.
width
=
imageCanvas
.
height
=
size
;
context
.
fillStyle
=
color
;
context
.
fillRect
(
0
,
0
,
size
/
2
,
size
/
2
);
context
.
fillRect
(
size
/
2
,
size
/
2
,
size
/
2
,
size
/
2
);
return
imageCanvas
;
}
var
canvas
=
mipmap
(
128
,
'
#f00
'
);
var
textureCanvas
=
new
THREE
.
Texture
(
canvas
,
THREE
.
UVMapping
,
THREE
.
RepeatWrapping
,
THREE
.
RepeatWrapping
);
textureCanvas
.
mipmaps
=
[];
textureCanvas
.
mipmaps
[
0
]
=
canvas
;
textureCanvas
.
mipmaps
[
1
]
=
mipmap
(
64
,
'
#0f0
'
);
textureCanvas
.
mipmaps
[
2
]
=
mipmap
(
32
,
'
#00f
'
);
textureCanvas
.
mipmaps
[
3
]
=
mipmap
(
16
,
'
#400
'
);
textureCanvas
.
mipmaps
[
4
]
=
mipmap
(
8
,
'
#040
'
);
textureCanvas
.
mipmaps
[
5
]
=
mipmap
(
4
,
'
#004
'
);
textureCanvas
.
mipmaps
[
6
]
=
mipmap
(
2
,
'
#044
'
);
textureCanvas
.
mipmaps
[
7
]
=
mipmap
(
1
,
'
#404
'
);
context
.
fillStyle
=
"
#444
"
;
context
.
fillRect
(
0
,
0
,
size
,
size
);
materialCanvas
=
new
THREE
.
MeshBasicMaterial
({
map
:
textureCanvas
});
context
.
fillStyle
=
color
;
context
.
fillRect
(
0
,
0
,
size
/
2
,
size
/
2
);
context
.
fillRect
(
size
/
2
,
size
/
2
,
size
/
2
,
size
/
2
);
return
imageCanvas
;
textureCanvas
.
needsUpdate
=
true
;
textureCanvas
.
repeat
.
set
(
1000
,
1000
);
}
canvas
=
mipmap
(
128
,
'
#f00
'
);
var
textureCanvas2
=
new
THREE
.
Texture
(
canvas
,
THREE
.
UVMapping
,
THREE
.
RepeatWrapping
,
THREE
.
RepeatWrapping
,
THREE
.
NearestFilter
,
THREE
.
NearestMipMapNearestFilter
);
textureCanvas2
.
mipmaps
=
[];
textureCanvas2
.
mipmaps
[
0
]
=
canvas
;
textureCanvas2
.
mipmaps
[
1
]
=
mipmap
(
64
,
'
#0f0
'
);
textureCanvas2
.
mipmaps
[
2
]
=
mipmap
(
32
,
'
#00f
'
);
textureCanvas2
.
mipmaps
[
3
]
=
mipmap
(
16
,
'
#400
'
);
textureCanvas2
.
mipmaps
[
4
]
=
mipmap
(
8
,
'
#040
'
);
textureCanvas2
.
mipmaps
[
5
]
=
mipmap
(
4
,
'
#004
'
);
textureCanvas2
.
mipmaps
[
6
]
=
mipmap
(
2
,
'
#044
'
);
textureCanvas2
.
mipmaps
[
7
]
=
mipmap
(
1
,
'
#404
'
);
materialCanvas2
=
new
THREE
.
MeshBasicMaterial
({
color
:
0xffccaa
,
map
:
textureCanvas2
});
var
canvas
=
mipmap
(
128
,
'
#f00
'
);
var
textureCanvas
=
new
THREE
.
Texture
(
canvas
,
THREE
.
UVMapping
,
THREE
.
RepeatWrapping
,
THREE
.
RepeatWrapping
);
textureCanvas
.
mipmaps
=
[];
textureCanvas
.
mipmaps
[
0
]
=
canvas
;
textureCanvas
.
mipmaps
[
1
]
=
mipmap
(
64
,
'
#0f0
'
);
textureCanvas
.
mipmaps
[
2
]
=
mipmap
(
32
,
'
#00f
'
);
textureCanvas
.
mipmaps
[
3
]
=
mipmap
(
16
,
'
#400
'
);
textureCanvas
.
mipmaps
[
4
]
=
mipmap
(
8
,
'
#040
'
);
textureCanvas
.
mipmaps
[
5
]
=
mipmap
(
4
,
'
#004
'
);
textureCanvas
.
mipmaps
[
6
]
=
mipmap
(
2
,
'
#044
'
);
textureCanvas
.
mipmaps
[
7
]
=
mipmap
(
1
,
'
#404
'
);
textureCanvas2
.
needsUpdate
=
true
;
textureCanvas2
.
repeat
.
set
(
1000
,
1000
);
materialCanvas
=
new
THREE
.
MeshBasicMaterial
(
{
map
:
textureCanvas
}
);
var
geometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
textureCanvas
.
needsUpdate
=
true
;
textureCanvas
.
repeat
.
set
(
1000
,
1000
);
var
meshCanvas
=
new
THREE
.
Mesh
(
geometry
,
materialCanvas
);
meshCanvas
.
rotation
.
x
=
-
Math
.
PI
/
2
;
meshCanvas
.
scale
.
set
(
1000
,
1000
,
1000
);
canvas
=
mipmap
(
128
,
'
#f00
'
);
var
textureCanvas2
=
new
THREE
.
Texture
(
canvas
,
THREE
.
UVMapping
,
THREE
.
RepeatWrapping
,
THREE
.
RepeatWrapping
,
THREE
.
NearestFilter
,
THREE
.
NearestMipMapNearestFilter
);
textureCanvas2
.
mipmaps
=
[];
textureCanvas2
.
mipmaps
[
0
]
=
canvas
;
textureCanvas2
.
mipmaps
[
1
]
=
mipmap
(
64
,
'
#0f0
'
);
textureCanvas2
.
mipmaps
[
2
]
=
mipmap
(
32
,
'
#00f
'
);
textureCanvas2
.
mipmaps
[
3
]
=
mipmap
(
16
,
'
#400
'
);
textureCanvas2
.
mipmaps
[
4
]
=
mipmap
(
8
,
'
#040
'
);
textureCanvas2
.
mipmaps
[
5
]
=
mipmap
(
4
,
'
#004
'
);
textureCanvas2
.
mipmaps
[
6
]
=
mipmap
(
2
,
'
#044
'
);
textureCanvas2
.
mipmaps
[
7
]
=
mipmap
(
1
,
'
#404
'
);
materialCanvas2
=
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xffccaa
,
map
:
textureCanvas2
}
);
var
meshCanvas2
=
new
THREE
.
Mesh
(
geometry
,
materialCanvas2
);
meshCanvas2
.
rotation
.
x
=
-
Math
.
PI
/
2
;
meshCanvas2
.
scale
.
set
(
1000
,
1000
,
1000
);
textureCanvas2
.
needsUpdate
=
true
;
textureCanvas2
.
repeat
.
set
(
1000
,
1000
);
var
geometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
// PAINTING
var
meshCanvas
=
new
THREE
.
Mesh
(
geometry
,
materialCanvas
);
meshCanvas
.
rotation
.
x
=
-
Math
.
PI
/
2
;
meshCanvas
.
scale
.
set
(
1000
,
1000
,
1000
);
var
callbackPainting
=
function
()
{
var
meshCanvas2
=
new
THREE
.
Mesh
(
geometry
,
materialCanvas2
);
meshCanvas2
.
rotation
.
x
=
-
Math
.
PI
/
2
;
meshCanvas2
.
scale
.
set
(
1000
,
1000
,
1000
);
var
image
=
texturePainting
.
image
;
texturePainting2
.
image
=
image
;
texturePainting2
.
needsUpdate
=
true
;
// PAINTING
scene
.
add
(
meshCanvas
);
scene2
.
add
(
meshCanvas2
);
var
callbackPainting
=
function
()
{
var
geometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
materialPainting
);
var
mesh2
=
new
THREE
.
Mesh
(
geometry
,
materialPainting2
);
var
image
=
texturePainting
.
image
;
addPainting
(
scene
,
mesh
)
;
addPainting
(
scene2
,
mesh2
)
;
texturePainting2
.
image
=
image
;
texturePainting2
.
needsUpdate
=
true
;
function
addPainting
(
zscene
,
zmesh
)
{
scene
.
add
(
meshCanvas
);
scene2
.
add
(
meshCanvas2
);
zmesh
.
scale
.
x
=
image
.
width
/
100
;
zmesh
.
scale
.
y
=
image
.
height
/
100
;
var
geometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
materialPainting
);
var
mesh2
=
new
THREE
.
Mesh
(
geometry
,
materialPainting2
);
zscene
.
add
(
zmesh
);
addPainting
(
scene
,
mesh
);
addPainting
(
scene2
,
mesh2
);
var
meshFrame
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshBasicMaterial
({
color
:
0x000000
,
polygonOffset
:
true
,
polygonOffsetFactor
:
1
,
polygonOffsetUnits
:
5
}));
meshFrame
.
scale
.
x
=
1.1
*
image
.
width
/
100
;
meshFrame
.
scale
.
y
=
1.1
*
image
.
height
/
100
;
function
addPainting
(
zscene
,
zmesh
)
{
zscene
.
add
(
meshFrame
);
zmesh
.
scale
.
x
=
image
.
width
/
100
;
zmesh
.
scale
.
y
=
image
.
height
/
100
;
var
meshShadow
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshBasicMaterial
({
color
:
0x000000
,
opacity
:
0.75
,
transparent
:
true
}));
meshShadow
.
position
.
y
=
-
1.1
*
image
.
height
/
2
;
meshShadow
.
position
.
z
=
-
1.1
*
image
.
height
/
2
;
meshShadow
.
rotation
.
x
=
-
Math
.
PI
/
2
;
meshShadow
.
scale
.
x
=
1.1
*
image
.
width
/
100
;
meshShadow
.
scale
.
y
=
1.1
*
image
.
height
/
100
;
zscene
.
add
(
meshShadow
);
zscene
.
add
(
zmesh
);
var
floorHeight
=
-
1.117
*
image
.
height
/
2
;
meshCanvas
.
position
.
y
=
meshCanvas2
.
position
.
y
=
floorHeight
;
var
meshFrame
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x000000
,
polygonOffset
:
true
,
polygonOffsetFactor
:
1
,
polygonOffsetUnits
:
5
}
)
);
meshFrame
.
scale
.
x
=
1.1
*
image
.
width
/
100
;
meshFrame
.
scale
.
y
=
1.1
*
image
.
height
/
100
;
}
zscene
.
add
(
meshFrame
);
var
meshShadow
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x000000
,
opacity
:
0.75
,
transparent
:
true
}
)
);
meshShadow
.
position
.
y
=
-
1.1
*
image
.
height
/
2
;
meshShadow
.
position
.
z
=
-
1.1
*
image
.
height
/
2
;
meshShadow
.
rotation
.
x
=
-
Math
.
PI
/
2
;
meshShadow
.
scale
.
x
=
1.1
*
image
.
width
/
100
;
meshShadow
.
scale
.
y
=
1.1
*
image
.
height
/
100
;
zscene
.
add
(
meshShadow
);
};
var
floorHeight
=
-
1.117
*
image
.
height
/
2
;
meshCanvas
.
position
.
y
=
meshCanvas2
.
position
.
y
=
floorHeight
;
var
texturePainting
=
THREE
.
ImageUtils
.
loadTexture
(
"
textures/758px-Canestra_di_frutta_(Caravaggio).jpg
"
,
THREE
.
UVMapping
,
callbackPainting
),
texturePainting2
=
new
THREE
.
Texture
(),
materialPainting
=
new
THREE
.
MeshBasicMaterial
({
color
:
0xffffff
,
map
:
texturePainting
}),
materialPainting2
=
new
THREE
.
MeshBasicMaterial
({
color
:
0xffccaa
,
map
:
texturePainting2
});
}
texturePainting2
.
minFilter
=
texturePainting2
.
magFilter
=
THREE
.
NearestFilter
;
texturePainting
.
minFilter
=
texturePainting
.
magFilter
=
THREE
.
LinearFilter
;
};
renderer
=
new
THREE
.
WebGLRenderer
({
antialias
:
true
});
renderer
.
setSize
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
renderer
.
setClearColor
(
scene
.
fog
.
color
,
1
);
renderer
.
autoClear
=
false
;
var
texturePainting
=
THREE
.
ImageUtils
.
loadTexture
(
"
textures/758px-Canestra_di_frutta_(Caravaggio).jpg
"
,
THREE
.
UVMapping
,
callbackPainting
),
texturePainting2
=
new
THREE
.
Texture
(),
materialPainting
=
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xffffff
,
map
:
texturePainting
}
),
materialPainting2
=
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xffccaa
,
map
:
texturePainting2
}
)
;
renderer
.
domElement
.
style
.
position
=
"
relative
"
;
container
.
appendChild
(
renderer
.
domElement
)
;
texturePainting2
.
minFilter
=
texturePainting2
.
magFilter
=
THREE
.
NearestFilter
;
texturePainting
.
minFilter
=
texturePainting
.
magFilter
=
THREE
.
LinearFilter
;
stats
=
new
Stats
();
stats
.
domElement
.
style
.
position
=
'
absolute
'
;
stats
.
domElement
.
style
.
top
=
'
0px
'
;
stats
.
domElement
.
style
.
zIndex
=
100
;
//container.appendChild( stats.domElement );
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
.
setSize
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
renderer
.
setClearColor
(
scene
.
fog
.
color
,
1
);
renderer
.
autoClear
=
false
;
}
renderer
.
domElement
.
style
.
position
=
"
relative
"
;
container
.
appendChild
(
renderer
.
domElement
);
stats
=
new
Stats
();
stats
.
domElement
.
style
.
position
=
'
absolute
'
;
stats
.
domElement
.
style
.
top
=
'
0px
'
;
stats
.
domElement
.
style
.
zIndex
=
100
;
//container.appendChild( stats.domElement );
function
onDocumentMouseMove
(
event
)
{
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
mouseX
=
(
event
.
clientX
-
windowHalfX
);
mouseY
=
(
event
.
clientY
-
windowHalfY
);
}
}
function
onDocumentMouseMove
(
event
)
{
function
animate
()
{
mouseX
=
(
event
.
clientX
-
windowHalfX
);
mouseY
=
(
event
.
clientY
-
windowHalfY
);
requestAnimationFrame
(
animate
);
}
render
();
stats
.
update
();
}
function
animate
()
{
function
render
()
{
requestAnimationFrame
(
animate
);
camera
.
position
.
x
+=
(
mouseX
-
camera
.
position
.
x
)
*
.
05
;
camera
.
position
.
y
+=
(
-
(
mouseY
-
200
)
-
camera
.
position
.
y
)
*
.
05
;
render
()
;
stats
.
update
()
;
camera
.
lookAt
(
scene
.
position
);
}
function
render
()
{
renderer
.
enableScissorTest
(
false
);
renderer
.
clear
();
renderer
.
enableScissorTest
(
true
);
camera
.
position
.
x
+=
(
mouseX
-
camera
.
position
.
x
)
*
.
05
;
camera
.
position
.
y
+=
(
-
(
mouseY
-
200
)
-
camera
.
position
.
y
)
*
.
05
;
//renderer.setViewport( 0, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT );
renderer
.
setScissor
(
0
,
0
,
SCREEN_WIDTH
/
2
-
2
,
SCREEN_HEIGHT
);
renderer
.
render
(
scene
,
camera
);
camera
.
lookAt
(
scene
.
position
);
renderer
.
enableScissorTest
(
false
);
renderer
.
clear
();
renderer
.
enableScissorTest
(
true
);
//renderer.setViewport( SCREEN_WIDTH/2
, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT );
renderer
.
setScissor
(
SCREEN_WIDTH
/
2
,
0
,
SCREEN_WIDTH
/
2
-
2
,
SCREEN_HEIGHT
);
renderer
.
render
(
scene2
,
camera
);
//renderer.setViewport( 0
, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT );
renderer
.
setScissor
(
0
,
0
,
SCREEN_WIDTH
/
2
-
2
,
SCREEN_HEIGHT
);
renderer
.
render
(
scene
,
camera
);
}
//renderer.setViewport( SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT );
renderer
.
setScissor
(
SCREEN_WIDTH
/
2
,
0
,
SCREEN_WIDTH
/
2
-
2
,
SCREEN_HEIGHT
);
renderer
.
render
(
scene2
,
camera
);
}
</script>
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
2148d37e
...
...
@@ -6648,18 +6648,26 @@ THREE.WebGLRenderer = function ( parameters ) {
}
else
{
var
mipmap
,
mipmaps
=
texture
.
mipmaps
;
if
(
mipmaps
&&
isImagePowerOfTwo
)
{
if
(
mipmaps
&&
isImagePowerOfTwo
)
{
// pre generated mipmaped regular texture
for
(
var
i
=
0
,
il
=
mipmaps
.
length
;
i
<
il
;
i
++
)
{
mipmap
=
mipmaps
[
i
];
_gl
.
texImage2D
(
_gl
.
TEXTURE_2D
,
i
,
glFormat
,
glFormat
,
glType
,
mipmap
);
for
(
var
i
=
0
,
il
=
mipmaps
.
length
;
i
<
il
;
i
++
)
{
mipmap
=
mipmaps
[
i
];
_gl
.
texImage2D
(
_gl
.
TEXTURE_2D
,
i
,
glFormat
,
glFormat
,
glType
,
mipmap
);
}
texture
.
generateMipmaps
=
false
;
}
else
{
}
else
{
// regular texture
_gl
.
texImage2D
(
_gl
.
TEXTURE_2D
,
0
,
glFormat
,
glFormat
,
glType
,
texture
.
image
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录