Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
ef46e1e4
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,发现更多精彩内容 >>
提交
ef46e1e4
编写于
12月 16, 2019
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Examples: Clean up.
上级
3492536c
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
150 addition
and
154 deletion
+150
-154
examples/jsm/nodes/misc/TextureCubeNode.js
examples/jsm/nodes/misc/TextureCubeNode.js
+0
-2
examples/jsm/nodes/misc/TextureCubeUVNode.js
examples/jsm/nodes/misc/TextureCubeUVNode.js
+110
-112
examples/webgl_materials_envmaps_hdr.html
examples/webgl_materials_envmaps_hdr.html
+20
-20
examples/webgl_materials_envmaps_hdr_nodes.html
examples/webgl_materials_envmaps_hdr_nodes.html
+20
-20
未找到文件。
examples/jsm/nodes/misc/TextureCubeNode.js
浏览文件 @
ef46e1e4
...
@@ -4,11 +4,9 @@
...
@@ -4,11 +4,9 @@
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
import
{
FloatNode
}
from
'
../inputs/FloatNode.js
'
;
import
{
FloatNode
}
from
'
../inputs/FloatNode.js
'
;
import
{
ExpressionNode
}
from
'
../core/ExpressionNode.js
'
;
import
{
TextureCubeUVNode
}
from
'
./TextureCubeUVNode.js
'
;
import
{
TextureCubeUVNode
}
from
'
./TextureCubeUVNode.js
'
;
import
{
ReflectNode
}
from
'
../accessors/ReflectNode.js
'
;
import
{
ReflectNode
}
from
'
../accessors/ReflectNode.js
'
;
import
{
NormalNode
}
from
'
../accessors/NormalNode.js
'
;
import
{
NormalNode
}
from
'
../accessors/NormalNode.js
'
;
import
{
ColorSpaceNode
}
from
'
../utils/ColorSpaceNode.js
'
;
function
TextureCubeNode
(
value
,
uv
,
bias
)
{
function
TextureCubeNode
(
value
,
uv
,
bias
)
{
...
...
examples/jsm/nodes/misc/TextureCubeUVNode.js
浏览文件 @
ef46e1e4
...
@@ -8,11 +8,9 @@ import { StructNode } from '../core/StructNode.js';
...
@@ -8,11 +8,9 @@ import { StructNode } from '../core/StructNode.js';
import
{
FunctionNode
}
from
'
../core/FunctionNode.js
'
;
import
{
FunctionNode
}
from
'
../core/FunctionNode.js
'
;
import
{
FunctionCallNode
}
from
'
../core/FunctionCallNode.js
'
;
import
{
FunctionCallNode
}
from
'
../core/FunctionCallNode.js
'
;
import
{
ExpressionNode
}
from
'
../core/ExpressionNode.js
'
;
import
{
ExpressionNode
}
from
'
../core/ExpressionNode.js
'
;
import
{
ReflectNode
}
from
'
../accessors/ReflectNode.js
'
;
import
{
FloatNode
}
from
'
../inputs/FloatNode.js
'
;
import
{
FloatNode
}
from
'
../inputs/FloatNode.js
'
;
import
{
OperatorNode
}
from
'
../math/OperatorNode.js
'
;
import
{
OperatorNode
}
from
'
../math/OperatorNode.js
'
;
import
{
MathNode
}
from
'
../math/MathNode.js
'
;
import
{
MathNode
}
from
'
../math/MathNode.js
'
;
import
{
CondNode
}
from
'
../math/CondNode.js
'
;
import
{
ColorSpaceNode
}
from
'
../utils/ColorSpaceNode.js
'
;
import
{
ColorSpaceNode
}
from
'
../utils/ColorSpaceNode.js
'
;
function
TextureCubeUVNode
(
value
,
uv
,
bias
)
{
function
TextureCubeUVNode
(
value
,
uv
,
bias
)
{
...
@@ -28,13 +26,13 @@ function TextureCubeUVNode( value, uv, bias ) {
...
@@ -28,13 +26,13 @@ function TextureCubeUVNode( value, uv, bias ) {
TextureCubeUVNode
.
Nodes
=
(
function
()
{
TextureCubeUVNode
.
Nodes
=
(
function
()
{
var
TextureCubeUVData
=
new
StructNode
(
var
TextureCubeUVData
=
new
StructNode
(
`struct TextureCubeUVData {
`struct TextureCubeUVData {
vec4 tl;
vec4 tl;
vec4 tr;
vec4 tr;
vec4 br;
vec4 br;
vec4 bl;
vec4 bl;
vec2 f;
vec2 f;
}`
);
}`
);
var
cubeUV_maxMipLevel
=
new
ConstNode
(
`float cubeUV_maxMipLevel 8.0`
,
true
);
var
cubeUV_maxMipLevel
=
new
ConstNode
(
`float cubeUV_maxMipLevel 8.0`
,
true
);
var
cubeUV_minMipLevel
=
new
ConstNode
(
`float cubeUV_minMipLevel 4.0`
,
true
);
var
cubeUV_minMipLevel
=
new
ConstNode
(
`float cubeUV_minMipLevel 4.0`
,
true
);
...
@@ -46,7 +44,7 @@ TextureCubeUVNode.Nodes = ( function () {
...
@@ -46,7 +44,7 @@ TextureCubeUVNode.Nodes = ( function () {
// sampling a textureCube (not generally normalized).
// sampling a textureCube (not generally normalized).
var
getFace
=
new
FunctionNode
(
var
getFace
=
new
FunctionNode
(
`float getFace(vec3 direction) {
`float getFace(vec3 direction) {
vec3 absDirection = abs(direction);
vec3 absDirection = abs(direction);
float face = -1.0;
float face = -1.0;
if (absDirection.x > absDirection.z) {
if (absDirection.x > absDirection.z) {
...
@@ -61,11 +59,11 @@ TextureCubeUVNode.Nodes = ( function () {
...
@@ -61,11 +59,11 @@ TextureCubeUVNode.Nodes = ( function () {
face = direction.y > 0.0 ? 1.0 : 4.0;
face = direction.y > 0.0 ? 1.0 : 4.0;
}
}
return face;
return face;
}`
);
}`
);
getFace
.
useKeywords
=
false
;
getFace
.
useKeywords
=
false
;
var
getUV
=
new
FunctionNode
(
var
getUV
=
new
FunctionNode
(
`vec2 getUV(vec3 direction, float face) {
`vec2 getUV(vec3 direction, float face) {
vec2 uv;
vec2 uv;
if (face == 0.0) {
if (face == 0.0) {
uv = vec2(-direction.z, direction.y) / abs(direction.x);
uv = vec2(-direction.z, direction.y) / abs(direction.x);
...
@@ -81,11 +79,11 @@ TextureCubeUVNode.Nodes = ( function () {
...
@@ -81,11 +79,11 @@ TextureCubeUVNode.Nodes = ( function () {
uv = vec2(-direction.x, direction.y) / abs(direction.z);
uv = vec2(-direction.x, direction.y) / abs(direction.z);
}
}
return 0.5 * (uv + 1.0);
return 0.5 * (uv + 1.0);
}`
);
}`
);
getUV
.
useKeywords
=
false
;
getUV
.
useKeywords
=
false
;
var
bilinearCubeUV
=
new
FunctionNode
(
var
bilinearCubeUV
=
new
FunctionNode
(
`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
float face = getFace(direction);
float face = getFace(direction);
float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
mipInt = max(mipInt, cubeUV_minMipLevel);
mipInt = max(mipInt, cubeUV_minMipLevel);
...
@@ -114,7 +112,7 @@ TextureCubeUVNode.Nodes = ( function () {
...
@@ -114,7 +112,7 @@ TextureCubeUVNode.Nodes = ( function () {
vec4 bl = texture2D(envMap, uv);
vec4 bl = texture2D(envMap, uv);
return TextureCubeUVData( tl, tr, br, bl, f );
return TextureCubeUVData( tl, tr, br, bl, f );
}`
,
[
TextureCubeUVData
,
getFace
,
getUV
,
cubeUV_maxMipLevel
,
cubeUV_minMipLevel
,
cubeUV_maxTileSize
,
cubeUV_minTileSize
]
);
}`
,
[
TextureCubeUVData
,
getFace
,
getUV
,
cubeUV_maxMipLevel
,
cubeUV_minMipLevel
,
cubeUV_maxTileSize
,
cubeUV_minTileSize
]
);
bilinearCubeUV
.
useKeywords
=
false
;
bilinearCubeUV
.
useKeywords
=
false
;
// These defines must match with PMREMGenerator
// These defines must match with PMREMGenerator
...
@@ -138,7 +136,7 @@ TextureCubeUVNode.Nodes = ( function () {
...
@@ -138,7 +136,7 @@ TextureCubeUVNode.Nodes = ( function () {
var
defines
=
[
r0
,
v0
,
m0
,
r1
,
v1
,
m1
,
r4
,
v4
,
m4
,
r5
,
v5
,
m5
,
r6
,
v6
,
m6
];
var
defines
=
[
r0
,
v0
,
m0
,
r1
,
v1
,
m1
,
r4
,
v4
,
m4
,
r5
,
v5
,
m5
,
r6
,
v6
,
m6
];
var
roughnessToMip
=
new
FunctionNode
(
var
roughnessToMip
=
new
FunctionNode
(
`float roughnessToMip(float roughness) {
`float roughnessToMip(float roughness) {
float mip = 0.0;
float mip = 0.0;
if (roughness >= r1) {
if (roughness >= r1) {
mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
...
@@ -152,7 +150,7 @@ TextureCubeUVNode.Nodes = ( function () {
...
@@ -152,7 +150,7 @@ TextureCubeUVNode.Nodes = ( function () {
mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
}
}
return mip;
return mip;
}`
,
defines
);
}`
,
defines
);
return
{
return
{
bilinearCubeUV
:
bilinearCubeUV
,
bilinearCubeUV
:
bilinearCubeUV
,
...
@@ -209,12 +207,12 @@ TextureCubeUVNode.prototype.bilinearCubeUV = function ( builder, texture, uv, mi
...
@@ -209,12 +207,12 @@ TextureCubeUVNode.prototype.bilinearCubeUV = function ( builder, texture, uv, mi
// --
// --
var
output
=
new
ExpressionNode
(
`mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )`
,
'
v4
'
);
var
output
=
new
ExpressionNode
(
`mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )`
,
'
v4
'
);
output
.
keywords
[
'
cubeUV_TL
'
]
=
this
.
colorSpaceTLExp
;
output
.
keywords
[
'
cubeUV_TL
'
]
=
this
.
colorSpaceTLExp
;
output
.
keywords
[
'
cubeUV_TR
'
]
=
this
.
colorSpaceTRExp
;
output
.
keywords
[
'
cubeUV_TR
'
]
=
this
.
colorSpaceTRExp
;
output
.
keywords
[
'
cubeUV_BL
'
]
=
this
.
colorSpaceBLExp
;
output
.
keywords
[
'
cubeUV_BL
'
]
=
this
.
colorSpaceBLExp
;
output
.
keywords
[
'
cubeUV_BR
'
]
=
this
.
colorSpaceBRExp
;
output
.
keywords
[
'
cubeUV_BR
'
]
=
this
.
colorSpaceBRExp
;
output
.
keywords
[
'
cubeUV
'
]
=
bilinearCubeUV
;
output
.
keywords
[
'
cubeUV
'
]
=
bilinearCubeUV
;
return
output
;
return
output
;
...
@@ -241,7 +239,7 @@ TextureCubeUVNode.prototype.generate = function ( builder, output ) {
...
@@ -241,7 +239,7 @@ TextureCubeUVNode.prototype.generate = function ( builder, output ) {
var
color1Mix
=
new
MathNode
(
color0
,
color1
,
mipF
,
MathNode
.
MIX
);
var
color1Mix
=
new
MathNode
(
color0
,
color1
,
mipF
,
MathNode
.
MIX
);
/*
/*
// TODO: Optimize this in the future
// TODO: Optimize this in the future
var cond = new CondNode(
var cond = new CondNode(
mipF,
mipF,
...
@@ -250,7 +248,7 @@ TextureCubeUVNode.prototype.generate = function ( builder, output ) {
...
@@ -250,7 +248,7 @@ TextureCubeUVNode.prototype.generate = function ( builder, output ) {
color0, // if
color0, // if
color1Mix // else
color1Mix // else
);
);
*/
*/
return
builder
.
format
(
color1Mix
.
build
(
builder
),
'
v4
'
,
output
);
return
builder
.
format
(
color1Mix
.
build
(
builder
),
'
v4
'
,
output
);
...
...
examples/webgl_materials_envmaps_hdr.html
浏览文件 @
ef46e1e4
...
@@ -47,31 +47,31 @@
...
@@ -47,31 +47,31 @@
var
envScene
=
new
THREE
.
Scene
();
var
envScene
=
new
THREE
.
Scene
();
var
geometry
=
new
THREE
.
BoxBufferGeometry
();
var
geometry
=
new
THREE
.
BoxBufferGeometry
();
geometry
.
deleteAttribute
(
'
uv
'
);
geometry
.
deleteAttribute
(
'
uv
'
);
var
roomMaterial
=
new
THREE
.
MeshStandardMaterial
({
metalness
:
0
,
side
:
THREE
.
BackSide
}
);
var
roomMaterial
=
new
THREE
.
MeshStandardMaterial
(
{
metalness
:
0
,
side
:
THREE
.
BackSide
}
);
var
room
=
new
THREE
.
Mesh
(
geometry
,
roomMaterial
);
var
room
=
new
THREE
.
Mesh
(
geometry
,
roomMaterial
);
room
.
scale
.
setScalar
(
10
);
room
.
scale
.
setScalar
(
10
);
envScene
.
add
(
room
);
envScene
.
add
(
room
);
var
mainLight
=
new
THREE
.
PointLight
(
0xffffff
,
50
,
0
,
2
);
var
mainLight
=
new
THREE
.
PointLight
(
0xffffff
,
50
,
0
,
2
);
envScene
.
add
(
mainLight
);
envScene
.
add
(
mainLight
);
var
lightMaterial
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0x000000
,
emissive
:
0xffffff
,
emissiveIntensity
:
10
}
);
var
lightMaterial
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0x000000
,
emissive
:
0xffffff
,
emissiveIntensity
:
10
}
);
var
light1
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
var
light1
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
light1
.
position
.
set
(
-
5
,
2
,
0
);
light1
.
position
.
set
(
-
5
,
2
,
0
);
light1
.
scale
.
set
(
0.1
,
1
,
1
);
light1
.
scale
.
set
(
0.1
,
1
,
1
);
envScene
.
add
(
light1
);
envScene
.
add
(
light1
);
var
light2
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
var
light2
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
light2
.
position
.
set
(
0
,
5
,
0
);
light2
.
position
.
set
(
0
,
5
,
0
);
light2
.
scale
.
set
(
1
,
0.1
,
1
);
light2
.
scale
.
set
(
1
,
0.1
,
1
);
envScene
.
add
(
light2
);
envScene
.
add
(
light2
);
var
light2
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
var
light2
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
light2
.
position
.
set
(
2
,
1
,
5
);
light2
.
position
.
set
(
2
,
1
,
5
);
light2
.
scale
.
set
(
1.5
,
2
,
0.1
);
light2
.
scale
.
set
(
1.5
,
2
,
0.1
);
envScene
.
add
(
light2
);
envScene
.
add
(
light2
);
return
envScene
;
return
envScene
;
...
@@ -118,7 +118,7 @@
...
@@ -118,7 +118,7 @@
pmremGenerator
.
dispose
();
pmremGenerator
.
dispose
();
}
}
;
var
envScene
=
getEnvScene
();
var
envScene
=
getEnvScene
();
generatedCubeRenderTarget
=
pmremGenerator
.
fromScene
(
envScene
,
0.04
);
generatedCubeRenderTarget
=
pmremGenerator
.
fromScene
(
envScene
,
0.04
);
...
...
examples/webgl_materials_envmaps_hdr_nodes.html
浏览文件 @
ef46e1e4
...
@@ -51,31 +51,31 @@
...
@@ -51,31 +51,31 @@
var
envScene
=
new
THREE
.
Scene
();
var
envScene
=
new
THREE
.
Scene
();
var
geometry
=
new
THREE
.
BoxBufferGeometry
();
var
geometry
=
new
THREE
.
BoxBufferGeometry
();
geometry
.
deleteAttribute
(
'
uv
'
);
geometry
.
deleteAttribute
(
'
uv
'
);
var
roomMaterial
=
new
THREE
.
MeshStandardMaterial
({
metalness
:
0
,
side
:
THREE
.
BackSide
}
);
var
roomMaterial
=
new
THREE
.
MeshStandardMaterial
(
{
metalness
:
0
,
side
:
THREE
.
BackSide
}
);
var
room
=
new
THREE
.
Mesh
(
geometry
,
roomMaterial
);
var
room
=
new
THREE
.
Mesh
(
geometry
,
roomMaterial
);
room
.
scale
.
setScalar
(
10
);
room
.
scale
.
setScalar
(
10
);
envScene
.
add
(
room
);
envScene
.
add
(
room
);
var
mainLight
=
new
THREE
.
PointLight
(
0xffffff
,
50
,
0
,
2
);
var
mainLight
=
new
THREE
.
PointLight
(
0xffffff
,
50
,
0
,
2
);
envScene
.
add
(
mainLight
);
envScene
.
add
(
mainLight
);
var
lightMaterial
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0x000000
,
emissive
:
0xffffff
,
emissiveIntensity
:
10
}
);
var
lightMaterial
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0x000000
,
emissive
:
0xffffff
,
emissiveIntensity
:
10
}
);
var
light1
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
var
light1
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
light1
.
position
.
set
(
-
5
,
2
,
0
);
light1
.
position
.
set
(
-
5
,
2
,
0
);
light1
.
scale
.
set
(
0.1
,
1
,
1
);
light1
.
scale
.
set
(
0.1
,
1
,
1
);
envScene
.
add
(
light1
);
envScene
.
add
(
light1
);
var
light2
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
var
light2
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
light2
.
position
.
set
(
0
,
5
,
0
);
light2
.
position
.
set
(
0
,
5
,
0
);
light2
.
scale
.
set
(
1
,
0.1
,
1
);
light2
.
scale
.
set
(
1
,
0.1
,
1
);
envScene
.
add
(
light2
);
envScene
.
add
(
light2
);
var
light2
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
var
light2
=
new
THREE
.
Mesh
(
geometry
,
lightMaterial
);
light2
.
position
.
set
(
2
,
1
,
5
);
light2
.
position
.
set
(
2
,
1
,
5
);
light2
.
scale
.
set
(
1.5
,
2
,
0.1
);
light2
.
scale
.
set
(
1.5
,
2
,
0.1
);
envScene
.
add
(
light2
);
envScene
.
add
(
light2
);
return
envScene
;
return
envScene
;
...
@@ -130,7 +130,7 @@
...
@@ -130,7 +130,7 @@
pmremGenerator
.
dispose
();
pmremGenerator
.
dispose
();
}
}
;
var
envScene
=
getEnvScene
();
var
envScene
=
getEnvScene
();
generatedCubeRenderTarget
=
pmremGenerator
.
fromScene
(
envScene
,
0.04
);
generatedCubeRenderTarget
=
pmremGenerator
.
fromScene
(
envScene
,
0.04
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录