Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
d1e46316
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,发现更多精彩内容 >>
提交
d1e46316
编写于
8月 06, 2017
作者:
W
WestLangley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Texture rotation: new API
上级
529a142e
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
54 addition
and
39 deletion
+54
-39
docs/api/math/Matrix3.html
docs/api/math/Matrix3.html
+1
-1
docs/api/textures/Texture.html
docs/api/textures/Texture.html
+8
-5
examples/webgl_materials_texture_rotation.html
examples/webgl_materials_texture_rotation.html
+12
-17
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+22
-10
src/textures/Texture.js
src/textures/Texture.js
+11
-6
未找到文件。
docs/api/math/Matrix3.html
浏览文件 @
d1e46316
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
/>
...
...
docs/api/textures/Texture.html
浏览文件 @
d1e46316
...
...
@@ -147,15 +147,18 @@
assigned to achieve the desired repetiton.
</div>
<h3>
[property:
number rotation
]
</h3>
<h3>
[property:
boolean matrixAutoUpdate
]
</h3>
<div>
How much the texture is rotated, in radians. Postive values are counter-clockwise. Default is *0*.
Whether to update the texture's uv-transform [property:Matrix3 matrix] based on the [property:Vector2 offset] and
[property:Vector2 repeat] settings. True by default.
Set this to false if you are specifying the uv-transform matrix directly.
</div>
<h3>
[property:
Vector2 center
]
</h3>
<h3>
[property:
Matrix3 matrix
]
</h3>
<div>
The center point of the texture -- used for both rotation and scaling. The range for each component is *0.0* to *1.0*. The default is [ *0*, *0* ],
which corresponds to the lower-left corner of the texture.
The uv-transform matrix for the texture. Used instead of [property:Vector2 offset] and [property:Vector2 repeat]
when the texture's [property:boolean matrixAutoUpdate] property is false.
Default is the indentity matrix.
</div>
<h3>
[property:boolean generateMipmaps]
</h3>
...
...
examples/webgl_materials_texture_rotation.html
浏览文件 @
d1e46316
...
...
@@ -87,13 +87,14 @@
var
loader
=
new
THREE
.
TextureLoader
();
var
texture
=
loader
.
load
(
'
textures/UV_Grid_Sm.jpg
'
,
render
);
texture
.
wrapS
=
texture
.
wrapT
=
THREE
.
RepeatWrapping
;
texture
.
matrixAutoUpdate
=
false
;
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
map
:
texture
}
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
scene
.
add
(
mesh
);
update
TextureParams
();
update
UvTransform
();
initGui
();
...
...
@@ -119,17 +120,11 @@
}
function
update
TextureParams
()
{
function
update
UvTransform
()
{
var
ma
p
=
mesh
.
material
.
map
;
var
ma
trix
=
mesh
.
material
.
map
.
matrix
;
map
.
offset
.
x
=
API
.
translateX
;
map
.
offset
.
y
=
API
.
translateY
;
map
.
repeat
.
x
=
API
.
scaleX
;
map
.
repeat
.
y
=
API
.
scaleY
;
map
.
rotation
=
API
.
rotation
;
map
.
center
.
x
=
API
.
centerX
;
map
.
center
.
y
=
API
.
centerY
;
matrix
.
setUvTransform
(
API
.
translateX
,
API
.
translateY
,
API
.
scaleX
,
API
.
scaleY
,
API
.
rotation
,
API
.
centerX
,
API
.
centerY
);
render
();
...
...
@@ -141,13 +136,13 @@
gui
=
new
dat
.
GUI
();
gui
.
add
(
API
,
'
translateX
'
,
0.0
,
1.0
).
name
(
'
offset.x
'
).
onChange
(
update
TextureParams
);
gui
.
add
(
API
,
'
translateY
'
,
0.0
,
1.0
).
name
(
'
offset.y
'
).
onChange
(
update
TextureParams
);
gui
.
add
(
API
,
'
scaleX
'
,
0.25
,
2.0
).
name
(
'
repeat.x
'
).
onChange
(
update
TextureParams
);
gui
.
add
(
API
,
'
scaleY
'
,
0.25
,
2.0
).
name
(
'
repeat.y
'
).
onChange
(
update
TextureParams
);
gui
.
add
(
API
,
'
rotation
'
,
-
2.0
,
2.0
).
name
(
'
rotation
'
).
onChange
(
update
TextureParams
);
gui
.
add
(
API
,
'
centerX
'
,
0.0
,
1.0
).
name
(
'
center.x
'
).
onChange
(
update
TextureParams
);
gui
.
add
(
API
,
'
centerY
'
,
0.0
,
1.0
).
name
(
'
center.y
'
).
onChange
(
update
TextureParams
);
gui
.
add
(
API
,
'
translateX
'
,
0.0
,
1.0
).
name
(
'
offset.x
'
).
onChange
(
update
UvTransform
);
gui
.
add
(
API
,
'
translateY
'
,
0.0
,
1.0
).
name
(
'
offset.y
'
).
onChange
(
update
UvTransform
);
gui
.
add
(
API
,
'
scaleX
'
,
0.25
,
2.0
).
name
(
'
repeat.x
'
).
onChange
(
update
UvTransform
);
gui
.
add
(
API
,
'
scaleY
'
,
0.25
,
2.0
).
name
(
'
repeat.y
'
).
onChange
(
update
UvTransform
);
gui
.
add
(
API
,
'
rotation
'
,
-
2.0
,
2.0
).
name
(
'
rotation
'
).
onChange
(
update
UvTransform
);
gui
.
add
(
API
,
'
centerX
'
,
0.0
,
1.0
).
name
(
'
center.x
'
).
onChange
(
update
UvTransform
);
gui
.
add
(
API
,
'
centerY
'
,
0.0
,
1.0
).
name
(
'
center.y
'
).
onChange
(
update
UvTransform
);
}
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
d1e46316
...
...
@@ -1982,12 +1982,18 @@ function WebGLRenderer( parameters ) {
}
if
(
uvScaleMap
.
matrixAutoUpdate
===
true
)
{
var
offset
=
uvScaleMap
.
offset
;
var
repeat
=
uvScaleMap
.
repeat
;
var
rotation
=
uvScaleMap
.
rotation
;
var
center
=
uvScaleMap
.
center
;
uniforms
.
uvTransform
.
value
.
setUvTransform
(
offset
.
x
,
offset
.
y
,
repeat
.
x
,
repeat
.
y
,
rotation
,
center
.
x
,
center
.
y
);
uniforms
.
uvTransform
.
value
.
setUvTransform
(
offset
.
x
,
offset
.
y
,
repeat
.
x
,
repeat
.
y
,
0
,
0
,
0
);
}
else
{
uniforms
.
uvTransform
.
value
.
copy
(
uvScaleMap
.
matrix
);
}
}
...
...
@@ -2019,12 +2025,18 @@ function WebGLRenderer( parameters ) {
if
(
material
.
map
!==
null
)
{
if
(
material
.
map
.
matrixAutoUpdate
===
true
)
{
var
offset
=
material
.
map
.
offset
;
var
repeat
=
material
.
map
.
repeat
;
var
rotation
=
material
.
map
.
rotation
;
var
center
=
material
.
map
.
center
;
uniforms
.
uvTransform
.
value
.
setUvTransform
(
offset
.
x
,
offset
.
y
,
repeat
.
x
,
repeat
.
y
,
rotation
,
center
.
x
,
center
.
y
);
uniforms
.
uvTransform
.
value
.
setUvTransform
(
offset
.
x
,
offset
.
y
,
repeat
.
x
,
repeat
.
y
,
0
,
0
,
0
);
}
else
{
uniforms
.
uvTransform
.
value
.
copy
(
material
.
map
.
matrix
);
}
}
...
...
src/textures/Texture.js
浏览文件 @
d1e46316
...
...
@@ -3,6 +3,7 @@ import { UVMapping } from '../constants';
import
{
MirroredRepeatWrapping
,
ClampToEdgeWrapping
,
RepeatWrapping
,
LinearEncoding
,
UnsignedByteType
,
RGBAFormat
,
LinearMipMapLinearFilter
,
LinearFilter
}
from
'
../constants
'
;
import
{
_Math
}
from
'
../math/Math
'
;
import
{
Vector2
}
from
'
../math/Vector2
'
;
import
{
Matrix3
}
from
'
../math/Matrix3
'
;
/**
* @author mrdoob / http://mrdoob.com/
...
...
@@ -38,8 +39,9 @@ function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, ty
this
.
offset
=
new
Vector2
(
0
,
0
);
this
.
repeat
=
new
Vector2
(
1
,
1
);
this
.
rotation
=
0
;
this
.
center
=
new
Vector2
(
0
,
0
);
this
.
matrixAutoUpdate
=
true
;
this
.
matrix
=
new
Matrix3
();
this
.
generateMipmaps
=
true
;
this
.
premultiplyAlpha
=
false
;
...
...
@@ -104,8 +106,9 @@ Object.assign( Texture.prototype, EventDispatcher.prototype, {
this
.
offset
.
copy
(
source
.
offset
);
this
.
repeat
.
copy
(
source
.
repeat
);
this
.
rotation
=
source
.
rotation
;
this
.
center
.
copy
(
source
.
center
);
this
.
matrixAutoUpdate
=
source
.
matrixAutoUpdate
;
this
.
matrix
.
copy
(
source
.
matrix
);
this
.
generateMipmaps
=
source
.
generateMipmaps
;
this
.
premultiplyAlpha
=
source
.
premultiplyAlpha
;
...
...
@@ -179,8 +182,10 @@ Object.assign( Texture.prototype, EventDispatcher.prototype, {
repeat
:
[
this
.
repeat
.
x
,
this
.
repeat
.
y
],
offset
:
[
this
.
offset
.
x
,
this
.
offset
.
y
],
rotation
:
this
.
rotation
,
center
:
[
this
.
center
.
x
,
this
.
center
.
y
],
matrixAutoUpdate
:
this
.
matrixAutoUpdate
,
matrix
:
this
.
matrix
.
toArray
(),
wrap
:
[
this
.
wrapS
,
this
.
wrapT
],
minFilter
:
this
.
minFilter
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录