Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
5e176f8f
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 搜索 >>
提交
5e176f8f
编写于
10月 23, 2020
作者:
G
Garrett Johnson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add LUT Loaders
上级
9ab55519
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
294 addition
and
0 deletion
+294
-0
examples/jsm/loaders/LUT3dlLoader.js
examples/jsm/loaders/LUT3dlLoader.js
+143
-0
examples/jsm/loaders/LUTCubeLoader.js
examples/jsm/loaders/LUTCubeLoader.js
+151
-0
未找到文件。
examples/jsm/loaders/LUT3dlLoader.js
0 → 100644
浏览文件 @
5e176f8f
// http://download.autodesk.com/us/systemdocs/help/2011/lustre/index.html?url=./files/WSc4e151a45a3b785a24c3d9a411df9298473-7ffd.htm,topicNumber=d0e9492
import
{
Loader
,
FileLoader
,
Vector3
,
DataTexture
,
DataTexture3D
,
RGBFormat
,
UnsignedByteType
,
ClampToEdgeWrapping
,
LinearFilter
,
}
from
'
//unpkg.com/three@0.120.1/build/three.module.js
'
;
export
class
LUT3dlLoader
extends
Loader
{
load
(
url
,
onLoad
,
onProgress
,
onError
)
{
const
loader
=
new
FileLoader
(
this
.
manager
);
loader
.
setPath
(
this
.
path
);
loader
.
setResponseType
(
'
text
'
);
loader
.
load
(
url
,
text
=>
{
try
{
onLoad
(
this
.
parse
(
text
)
);
}
catch
(
e
)
{
if
(
onError
)
{
onError
(
e
);
}
else
{
console
.
error
(
e
);
}
this
.
manager
.
itemError
(
url
);
}
},
onProgress
,
onError
);
}
parse
(
str
)
{
// remove empty lines and comment lints
str
=
str
.
replace
(
/^#.*
?(\n
|
\r)
/gm
,
''
)
.
replace
(
/^
\s
*
?(\n
|
\r)
/gm
,
''
)
.
trim
();
const
lines
=
str
.
split
(
/
[\n\r]
+/g
);
// first line is the positions on the grid that are provided by the LUT
const
gridLines
=
lines
[
0
].
trim
().
split
(
/
\s
+/g
).
map
(
e
=>
parseFloat
(
e
)
);
const
gridStep
=
gridLines
[
1
]
-
gridLines
[
0
];
const
size
=
gridLines
.
length
;
for
(
let
i
=
1
,
l
=
gridLines
.
length
;
i
<
l
;
i
++
)
{
if
(
gridStep
!==
(
gridLines
[
i
]
-
gridLines
[
i
-
1
]
)
)
{
throw
new
Error
(
'
LUT3dlLoader: Inconsistent grid size not supported.
'
);
}
}
const
dataArray
=
new
Array
(
size
*
size
*
size
*
3
);
let
index
=
0
;
let
maxOutputValue
=
0.0
;
for
(
let
i
=
1
,
l
=
lines
.
length
;
i
<
l
;
i
++
)
{
const
line
=
lines
[
i
].
trim
();
const
split
=
line
.
split
(
/
\s
/g
);
const
r
=
parseFloat
(
split
[
0
]
);
const
g
=
parseFloat
(
split
[
1
]
);
const
b
=
parseFloat
(
split
[
2
]
);
maxOutputValue
=
Math
.
max
(
maxOutputValue
,
r
,
g
,
b
);
const
bLayer
=
index
%
size
;
const
gLayer
=
Math
.
floor
(
index
/
size
)
%
size
;
const
rLayer
=
Math
.
floor
(
index
/
(
size
*
size
)
)
%
size
;
// b grows first, then g, then r
const
pixelIndex
=
bLayer
*
size
*
size
+
gLayer
*
size
+
rLayer
;
dataArray
[
3
*
pixelIndex
+
0
]
=
r
;
dataArray
[
3
*
pixelIndex
+
1
]
=
g
;
dataArray
[
3
*
pixelIndex
+
2
]
=
b
;
index
+=
1
;
}
// Find the apparent bit depth of the stored RGB values and scale the
// values to [ 0, 255 ].
const
bits
=
Math
.
ceil
(
Math
.
log2
(
maxOutputValue
)
);
const
maxBitValue
=
Math
.
pow
(
2.0
,
bits
);
for
(
let
i
=
0
,
l
=
dataArray
.
length
;
i
<
l
;
i
++
)
{
const
val
=
dataArray
[
i
];
dataArray
[
i
]
=
255
*
val
/
maxBitValue
;
}
const
data
=
new
Uint8Array
(
dataArray
);
const
texture
=
new
DataTexture
();
texture
.
image
.
data
=
data
;
texture
.
image
.
width
=
size
;
texture
.
image
.
height
=
size
*
size
;
texture
.
format
=
RGBFormat
;
texture
.
type
=
UnsignedByteType
;
texture
.
magFilter
=
LinearFilter
;
texture
.
wrapS
=
ClampToEdgeWrapping
;
texture
.
wrapT
=
ClampToEdgeWrapping
;
texture
.
generateMipmaps
=
false
;
const
texture3D
=
new
DataTexture3D
();
texture3D
.
image
.
data
=
data
;
texture3D
.
image
.
width
=
size
;
texture3D
.
image
.
height
=
size
;
texture3D
.
image
.
depth
=
size
;
texture3D
.
format
=
RGBFormat
;
texture3D
.
type
=
UnsignedByteType
;
texture3D
.
magFilter
=
LinearFilter
;
texture3D
.
wrapS
=
ClampToEdgeWrapping
;
texture3D
.
wrapT
=
ClampToEdgeWrapping
;
texture3D
.
wrapR
=
ClampToEdgeWrapping
;
texture3D
.
generateMipmaps
=
false
;
return
{
size
,
texture
,
texture3D
,
};
}
}
examples/jsm/loaders/LUTCubeLoader.js
0 → 100644
浏览文件 @
5e176f8f
// https://wwwimages2.adobe.com/content/dam/acom/en/products/speedgrade/cc/pdfs/cube-lut-specification-1.0.pdf
import
{
Loader
,
FileLoader
,
Vector3
,
DataTexture
,
DataTexture3D
,
RGBFormat
,
UnsignedByteType
,
ClampToEdgeWrapping
,
LinearFilter
,
}
from
'
//unpkg.com/three@0.120.1/build/three.module.js
'
;
export
class
LUTCubeLoader
extends
Loader
{
load
(
url
,
onLoad
,
onProgress
,
onError
)
{
const
loader
=
new
FileLoader
(
this
.
manager
);
loader
.
setPath
(
this
.
path
);
loader
.
setResponseType
(
'
text
'
);
loader
.
load
(
url
,
text
=>
{
try
{
onLoad
(
this
.
parse
(
text
)
);
}
catch
(
e
)
{
if
(
onError
)
{
onError
(
e
);
}
else
{
console
.
error
(
e
);
}
this
.
manager
.
itemError
(
url
);
}
},
onProgress
,
onError
);
}
parse
(
str
)
{
// Remove empty lines and comments
str
=
str
.
replace
(
/^#.*
?(\n
|
\r)
/gm
,
''
)
.
replace
(
/^
\s
*
?(\n
|
\r)
/gm
,
''
)
.
trim
();
let
title
=
null
;
let
size
=
null
;
const
domainMin
=
new
Vector3
(
0
,
0
,
0
);
const
domainMax
=
new
Vector3
(
1
,
1
,
1
);
const
lines
=
str
.
split
(
/
[\n\r]
+/g
);
let
data
=
null
;
let
currIndex
=
0
;
for
(
let
i
=
0
,
l
=
lines
.
length
;
i
<
l
;
i
++
)
{
const
line
=
lines
[
i
].
trim
();
const
split
=
line
.
split
(
/
\s
/g
);
switch
(
split
[
0
]
)
{
case
'
TITLE
'
:
title
=
line
.
substring
(
7
,
line
.
length
-
1
);
break
;
case
'
LUT_3D_SIZE
'
:
// TODO: A .CUBE LUT file specifies floating point values and could be represented with
// more precision than can be captured with Uint8Array.
const
sizeToken
=
split
[
1
];
size
=
parseFloat
(
sizeToken
);
data
=
new
Uint8Array
(
size
*
size
*
size
*
3
);
break
;
case
'
DOMAIN_MIN
'
:
domainMin
.
x
=
parseFloat
(
split
[
1
]
);
domainMin
.
y
=
parseFloat
(
split
[
2
]
);
domainMin
.
z
=
parseFloat
(
split
[
3
]
);
break
;
case
'
DOMAIN_MAX
'
:
domainMax
.
x
=
parseFloat
(
split
[
1
]
);
domainMax
.
y
=
parseFloat
(
split
[
2
]
);
domainMax
.
z
=
parseFloat
(
split
[
3
]
);
break
;
default
:
const
r
=
parseFloat
(
split
[
0
]
);
const
g
=
parseFloat
(
split
[
1
]
);
const
b
=
parseFloat
(
split
[
2
]
);
if
(
r
>
1.0
||
r
<
0.0
||
g
>
1.0
||
g
<
0.0
||
b
>
1.0
||
b
<
0.0
)
{
throw
new
Error
(
'
LUTCubeLoader : Non normalized values not supported.
'
);
}
data
[
currIndex
+
0
]
=
r
*
255
;
data
[
currIndex
+
1
]
=
g
*
255
;
data
[
currIndex
+
2
]
=
b
*
255
;
currIndex
+=
3
;
}
}
const
texture
=
new
DataTexture
();
texture
.
image
.
data
=
data
;
texture
.
image
.
width
=
size
;
texture
.
image
.
height
=
size
*
size
;
texture
.
format
=
RGBFormat
;
texture
.
type
=
UnsignedByteType
;
texture
.
magFilter
=
LinearFilter
;
texture
.
wrapS
=
ClampToEdgeWrapping
;
texture
.
wrapT
=
ClampToEdgeWrapping
;
texture
.
generateMipmaps
=
false
;
const
texture3D
=
new
DataTexture3D
();
texture3D
.
image
.
data
=
data
;
texture3D
.
image
.
width
=
size
;
texture3D
.
image
.
height
=
size
;
texture3D
.
image
.
depth
=
size
;
texture3D
.
format
=
RGBFormat
;
texture3D
.
type
=
UnsignedByteType
;
texture3D
.
magFilter
=
LinearFilter
;
texture3D
.
wrapS
=
ClampToEdgeWrapping
;
texture3D
.
wrapT
=
ClampToEdgeWrapping
;
texture3D
.
wrapR
=
ClampToEdgeWrapping
;
texture3D
.
generateMipmaps
=
false
;
return
{
title
,
size
,
domainMin
,
domainMax
,
texture
,
texture3D
,
};
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录