Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
5ad06b54
T
three.js
项目概览
车家大少爷
/
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,体验更适合开发者的 AI 搜索 >>
提交
5ad06b54
编写于
1月 30, 2020
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Editor: Add HDR support for UITexture and UICubeTexture.
上级
fb0ec320
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
92 addition
and
11 deletion
+92
-11
editor/js/Sidebar.Scene.js
editor/js/Sidebar.Scene.js
+19
-2
editor/js/Viewport.js
editor/js/Viewport.js
+0
-6
editor/js/libs/ui.three.js
editor/js/libs/ui.three.js
+72
-3
editor/sw.js
editor/sw.js
+1
-0
未找到文件。
editor/js/Sidebar.Scene.js
浏览文件 @
5ad06b54
...
...
@@ -124,6 +124,23 @@ var SidebarScene = function ( editor ) {
}
function
onTextureChanged
(
texture
)
{
texture
.
encoding
=
texture
.
isHDRTexture
?
THREE
.
RGBEEncoding
:
THREE
.
sRGBEncoding
;
if
(
texture
.
isCubeTexture
&&
texture
.
isHDRTexture
)
{
texture
.
format
=
THREE
.
RGBAFormat
;
texture
.
minFilter
=
THREE
.
NearestFilter
;
texture
.
magFilter
=
THREE
.
NearestFilter
;
texture
.
generateMipmaps
=
false
;
}
onBackgroundChanged
();
}
var
backgroundRow
=
new
UIRow
();
var
backgroundType
=
new
UISelect
().
setOptions
(
{
...
...
@@ -163,7 +180,7 @@ var SidebarScene = function ( editor ) {
textureRow
.
setDisplay
(
'
none
'
);
textureRow
.
setMarginLeft
(
'
90px
'
);
var
backgroundTexture
=
new
UITexture
().
onChange
(
on
Background
Changed
);
var
backgroundTexture
=
new
UITexture
().
onChange
(
on
Texture
Changed
);
textureRow
.
add
(
backgroundTexture
);
container
.
add
(
textureRow
);
...
...
@@ -174,7 +191,7 @@ var SidebarScene = function ( editor ) {
cubeTextureRow
.
setDisplay
(
'
none
'
);
cubeTextureRow
.
setMarginLeft
(
'
90px
'
);
var
backgroundCubeTexture
=
new
UICubeTexture
().
onChange
(
on
Background
Changed
);
var
backgroundCubeTexture
=
new
UICubeTexture
().
onChange
(
on
Texture
Changed
);
cubeTextureRow
.
add
(
backgroundCubeTexture
);
container
.
add
(
cubeTextureRow
);
...
...
editor/js/Viewport.js
浏览文件 @
5ad06b54
...
...
@@ -498,12 +498,6 @@ var Viewport = function ( editor ) {
}
if
(
scene
.
background
!==
null
&&
(
scene
.
background
.
isTexture
||
scene
.
background
.
isCubeTexture
)
)
{
scene
.
background
.
encoding
=
THREE
.
sRGBEncoding
;
}
render
();
}
);
...
...
editor/js/libs/ui.three.js
浏览文件 @
5ad06b54
...
...
@@ -4,6 +4,7 @@
import
*
as
THREE
from
'
../../../build/three.module.js
'
;
import
{
RGBELoader
}
from
'
../../../examples/jsm/loaders/RGBELoader.js
'
;
import
{
TGALoader
}
from
'
../../../examples/jsm/loaders/TGALoader.js
'
;
import
{
UIElement
,
UISpan
,
UIDiv
,
UIRow
,
UIButton
,
UICheckbox
,
UIText
,
UINumber
}
from
'
./ui.js
'
;
...
...
@@ -101,6 +102,33 @@ var UITexture = function ( mapping ) {
}
}
else
{
var
reader
=
new
FileReader
();
reader
.
addEventListener
(
'
load
'
,
function
(
event
)
{
if
(
file
.
name
.
split
(
'
.
'
).
pop
()
===
'
hdr
'
)
{
// assuming RGBE/Radiance HDR iamge format
var
loader
=
new
RGBELoader
().
setDataType
(
THREE
.
UnsignedByteType
);
loader
.
load
(
event
.
target
.
result
,
function
(
hdrTexture
)
{
hdrTexture
.
sourceFile
=
file
.
name
;
hdrTexture
.
isHDRTexture
=
true
;
scope
.
setValue
(
hdrTexture
);
if
(
scope
.
onChangeCallback
)
scope
.
onChangeCallback
(
hdrTexture
);
}
);
}
}
);
reader
.
readAsDataURL
(
file
);
}
form
.
reset
();
...
...
@@ -136,9 +164,18 @@ UITexture.prototype.setValue = function ( texture ) {
if
(
image
!==
undefined
&&
image
.
width
>
0
)
{
canvas
.
title
=
texture
.
sourceFile
;
var
scale
=
canvas
.
width
/
image
.
width
;
context
.
drawImage
(
image
,
0
,
0
,
image
.
width
*
scale
,
image
.
height
*
scale
);
if
(
image
.
data
===
undefined
)
{
context
.
drawImage
(
image
,
0
,
0
,
image
.
width
*
scale
,
image
.
height
*
scale
);
}
else
{
var
canvas2
=
renderToCanvas
(
texture
);
context
.
drawImage
(
canvas2
,
0
,
0
,
image
.
width
*
scale
,
image
.
height
*
scale
);
}
}
else
{
...
...
@@ -237,7 +274,7 @@ var UICubeTexture = function () {
if
(
texture
!==
null
)
{
images
.
push
(
texture
.
image
);
images
.
push
(
texture
.
i
sHDRTexture
?
texture
:
texture
.
i
mage
);
}
...
...
@@ -248,6 +285,8 @@ var UICubeTexture = function () {
var
cubeTexture
=
new
THREE
.
CubeTexture
(
images
);
cubeTexture
.
needsUpdate
=
true
;
if
(
images
[
0
].
isHDRTexture
)
cubeTexture
.
isHDRTexture
=
true
;
scope
.
cubeTexture
=
cubeTexture
;
if
(
scope
.
onChangeCallback
)
scope
.
onChangeCallback
(
cubeTexture
);
...
...
@@ -883,4 +922,34 @@ UIBoolean.prototype.setValue = function ( value ) {
};
var
renderer
;
function
renderToCanvas
(
texture
)
{
if
(
renderer
===
undefined
)
{
renderer
=
new
THREE
.
WebGLRenderer
(
{
canvas
:
new
OffscreenCanvas
(
1
,
1
)
}
);
}
var
image
=
texture
.
image
;
renderer
.
setSize
(
image
.
width
,
image
.
height
,
false
);
renderer
.
toneMapping
=
THREE
.
ReinhardToneMapping
;
renderer
.
outputEncoding
=
THREE
.
sRGBEncoding
;
var
scene
=
new
THREE
.
Scene
();
var
camera
=
new
THREE
.
OrthographicCamera
(
-
1
,
1
,
1
,
-
1
,
0
,
1
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
map
:
texture
}
);
var
quad
=
new
THREE
.
PlaneBufferGeometry
(
2
,
2
);
var
mesh
=
new
THREE
.
Mesh
(
quad
,
material
);
scene
.
add
(
mesh
);
renderer
.
render
(
scene
,
camera
);
return
renderer
.
domElement
;
}
export
{
UITexture
,
UICubeTexture
,
UIOutliner
,
UIPoints
,
UIPoints2
,
UIPoints3
,
UIBoolean
};
editor/sw.js
浏览文件 @
5ad06b54
...
...
@@ -27,6 +27,7 @@ const assets = [
'
../examples/jsm/loaders/OBJLoader.js
'
,
'
../examples/jsm/loaders/MTLLoader.js
'
,
'
../examples/jsm/loaders/PLYLoader.js
'
,
'
../examples/jsm/loaders/RGBELoader.js
'
,
'
../examples/jsm/loaders/STLLoader.js
'
,
'
../examples/jsm/loaders/SVGLoader.js
'
,
'
../examples/jsm/loaders/TGALoader.js
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录