Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
aa5c581e
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,发现更多精彩内容 >>
提交
aa5c581e
编写于
10月 29, 2020
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Examples: Clean up.
上级
e6308763
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
5 addition
and
102 deletion
+5
-102
examples/js/loaders/EXRLoader.js
examples/js/loaders/EXRLoader.js
+2
-51
examples/jsm/loaders/EXRLoader.js
examples/jsm/loaders/EXRLoader.js
+3
-51
未找到文件。
examples/js/loaders/EXRLoader.js
浏览文件 @
aa5c581e
...
...
@@ -1231,7 +1231,7 @@ THREE.EXRLoader.prototype = Object.assign( Object.create( THREE.DataTextureLoade
for
(
var
i
=
0
;
i
<
64
;
++
i
)
{
dst
[
idx
+
i
]
=
encodeFloat16
(
toLinear
(
src
[
i
]
)
);
dst
[
idx
+
i
]
=
THREE
.
DataUtils
.
toHalfFloat
(
toLinear
(
src
[
i
]
)
);
}
...
...
@@ -1816,7 +1816,7 @@ THREE.EXRLoader.prototype = Object.assign( Object.create( THREE.DataTextureLoade
function
decodeFloat32
(
dataView
,
offset
)
{
return
encodeFloat16
(
parseFloat32
(
dataView
,
offset
)
);
return
THREE
.
DataUtils
.
toHalfFloat
(
parseFloat32
(
dataView
,
offset
)
);
}
...
...
@@ -1838,55 +1838,6 @@ THREE.EXRLoader.prototype = Object.assign( Object.create( THREE.DataTextureLoade
}
// http://gamedev.stackexchange.com/questions/17326/conversion-of-a-number-from-single-precision-floating-point-representation-to-a/17410#17410
function
encodeFloat16
(
val
)
{
/* This method is faster than the OpenEXR implementation (very often
* used, eg. in Ogre), with the additional benefit of rounding, inspired
* by James Tursa?s half-precision code.
*/
tmpDataView
.
setFloat32
(
0
,
val
);
var
x
=
tmpDataView
.
getInt32
(
0
);
var
bits
=
(
x
>>
16
)
&
0x8000
;
/* Get the sign */
var
m
=
(
x
>>
12
)
&
0x07ff
;
/* Keep one extra bit for rounding */
var
e
=
(
x
>>
23
)
&
0xff
;
/* Using int is faster here */
/* If zero, or denormal, or exponent underflows too much for a denormal
* half, return signed zero. */
if
(
e
<
103
)
return
bits
;
/* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
if
(
e
>
142
)
{
bits
|=
0x7c00
;
/* If exponent was 0xff and one mantissa bit was set, it means NaN,
* not Inf, so make sure we set one mantissa bit too. */
bits
|=
(
(
e
==
255
)
?
0
:
1
)
&&
(
x
&
0x007fffff
);
return
bits
;
}
/* If exponent underflows but not too much, return a denormal */
if
(
e
<
113
)
{
m
|=
0x0800
;
/* Extra rounding may overflow and set mantissa to 0 and exponent
* to 1, which is OK. */
bits
|=
(
m
>>
(
114
-
e
)
)
+
(
(
m
>>
(
113
-
e
)
)
&
1
);
return
bits
;
}
bits
|=
(
(
e
-
112
)
<<
10
)
|
(
m
>>
1
);
/* Extra rounding. An overflow will set mantissa to 0 and increment
* the exponent, which is OK. */
bits
+=
m
&
1
;
return
bits
;
}
function
parseUint16
(
dataView
,
offset
)
{
var
Uint16
=
dataView
.
getUint16
(
offset
.
value
,
true
);
...
...
examples/jsm/loaders/EXRLoader.js
浏览文件 @
aa5c581e
import
{
DataTextureLoader
,
DataUtils
,
FloatType
,
HalfFloatType
,
LinearEncoding
,
...
...
@@ -1246,7 +1247,7 @@ EXRLoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
for
(
var
i
=
0
;
i
<
64
;
++
i
)
{
dst
[
idx
+
i
]
=
encodeFloat16
(
toLinear
(
src
[
i
]
)
);
dst
[
idx
+
i
]
=
DataUtils
.
toHalfFloat
(
toLinear
(
src
[
i
]
)
);
}
...
...
@@ -1831,7 +1832,7 @@ EXRLoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
function
decodeFloat32
(
dataView
,
offset
)
{
return
encodeFloat16
(
parseFloat32
(
dataView
,
offset
)
);
return
DataUtils
.
toHalfFloat
(
parseFloat32
(
dataView
,
offset
)
);
}
...
...
@@ -1853,55 +1854,6 @@ EXRLoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
}
// http://gamedev.stackexchange.com/questions/17326/conversion-of-a-number-from-single-precision-floating-point-representation-to-a/17410#17410
function
encodeFloat16
(
val
)
{
/* This method is faster than the OpenEXR implementation (very often
* used, eg. in Ogre), with the additional benefit of rounding, inspired
* by James Tursa?s half-precision code.
*/
tmpDataView
.
setFloat32
(
0
,
val
);
var
x
=
tmpDataView
.
getInt32
(
0
);
var
bits
=
(
x
>>
16
)
&
0x8000
;
/* Get the sign */
var
m
=
(
x
>>
12
)
&
0x07ff
;
/* Keep one extra bit for rounding */
var
e
=
(
x
>>
23
)
&
0xff
;
/* Using int is faster here */
/* If zero, or denormal, or exponent underflows too much for a denormal
* half, return signed zero. */
if
(
e
<
103
)
return
bits
;
/* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
if
(
e
>
142
)
{
bits
|=
0x7c00
;
/* If exponent was 0xff and one mantissa bit was set, it means NaN,
* not Inf, so make sure we set one mantissa bit too. */
bits
|=
(
(
e
==
255
)
?
0
:
1
)
&&
(
x
&
0x007fffff
);
return
bits
;
}
/* If exponent underflows but not too much, return a denormal */
if
(
e
<
113
)
{
m
|=
0x0800
;
/* Extra rounding may overflow and set mantissa to 0 and exponent
* to 1, which is OK. */
bits
|=
(
m
>>
(
114
-
e
)
)
+
(
(
m
>>
(
113
-
e
)
)
&
1
);
return
bits
;
}
bits
|=
(
(
e
-
112
)
<<
10
)
|
(
m
>>
1
);
/* Extra rounding. An overflow will set mantissa to 0 and increment
* the exponent, which is OK. */
bits
+=
m
&
1
;
return
bits
;
}
function
parseUint16
(
dataView
,
offset
)
{
var
Uint16
=
dataView
.
getUint16
(
offset
.
value
,
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录