Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fktz008
three.js
提交
6f186bb3
T
three.js
项目概览
fktz008
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
6f186bb3
编写于
9月 18, 2018
作者:
W
WestLangley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adopt glTF convention: lights face local neg-z direction
上级
6a136428
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
47 addition
and
45 deletion
+47
-45
docs/api/en/helpers/RectAreaLightHelper.html
docs/api/en/helpers/RectAreaLightHelper.html
+1
-1
docs/api/en/lights/RectAreaLight.html
docs/api/en/lights/RectAreaLight.html
+1
-1
examples/webgl_lights_rectarealight.html
examples/webgl_lights_rectarealight.html
+1
-2
src/core/Object3D.js
src/core/Object3D.js
+1
-1
src/helpers/RectAreaLightHelper.js
src/helpers/RectAreaLightHelper.js
+39
-36
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
...rs/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
+4
-4
未找到文件。
docs/api/en/helpers/RectAreaLightHelper.html
浏览文件 @
6f186bb3
...
...
@@ -23,7 +23,7 @@ var light = new THREE.RectAreaLight( 0xffffbb, 1.0, 5, 5 );
var helper = new THREE.RectAreaLightHelper( light );
scene.add( helper );
light.add( helper ); // helper must be added as a child of the light
</code>
...
...
docs/api/en/lights/RectAreaLight.html
浏览文件 @
6f186bb3
...
...
@@ -41,7 +41,7 @@ rectLight.lookAt( 0, 0, 0 );
scene.add( rectLight )
rectLightHelper = new THREE.RectAreaLightHelper( rectLight );
scene
.add( rectLightHelper );
rectLight
.add( rectLightHelper );
</code>
</p>
...
...
examples/webgl_lights_rectarealight.html
浏览文件 @
6f186bb3
...
...
@@ -107,13 +107,12 @@
rectLight
.
position
.
set
(
5
,
5
,
0
);
scene
.
add
(
rectLight
);
var
rectLightMesh
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneBufferGeometry
(),
new
THREE
.
MeshBasicMaterial
()
);
var
rectLightMesh
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneBufferGeometry
(),
new
THREE
.
MeshBasicMaterial
(
{
side
:
THREE
.
BackSide
}
)
);
rectLightMesh
.
scale
.
x
=
rectLight
.
width
;
rectLightMesh
.
scale
.
y
=
rectLight
.
height
;
rectLight
.
add
(
rectLightMesh
);
var
rectLightMeshBack
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneBufferGeometry
(),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x080808
}
)
);
rectLightMeshBack
.
rotation
.
y
=
Math
.
PI
;
rectLightMesh
.
add
(
rectLightMeshBack
);
var
geoFloor
=
new
THREE
.
BoxBufferGeometry
(
2000
,
0.1
,
2000
);
...
...
src/core/Object3D.js
浏览文件 @
6f186bb3
...
...
@@ -328,7 +328,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
position
.
setFromMatrixPosition
(
this
.
matrixWorld
);
if
(
this
.
isCamera
)
{
if
(
this
.
isCamera
||
this
.
isLight
)
{
m1
.
lookAt
(
position
,
target
,
this
.
up
);
...
...
src/helpers/RectAreaLightHelper.js
浏览文件 @
6f186bb3
...
...
@@ -2,79 +2,82 @@
* @author abelnation / http://github.com/abelnation
* @author Mugen87 / http://github.com/Mugen87
* @author WestLangley / http://github.com/WestLangley
*
* This helper must be added as a child of the light
*/
import
{
Object3D
}
from
'
../core/Object3D.js
'
;
import
{
Line
}
from
'
../objects/Line.js
'
;
import
{
Mesh
}
from
'
../objects/Mesh.js
'
;
import
{
LineBasicMaterial
}
from
'
../materials/LineBasicMaterial.js
'
;
import
{
MeshBasicMaterial
}
from
'
../materials/MeshBasicMaterial.js
'
;
import
{
Float32BufferAttribute
}
from
'
../core/BufferAttribute.js
'
;
import
{
BufferGeometry
}
from
'
../core/BufferGeometry.js
'
;
import
{
BufferAttribute
}
from
'
../core/BufferAttribute.js
'
;
function
RectAreaLightHelper
(
light
,
color
)
{
Object3D
.
call
(
this
)
;
this
.
type
=
'
RectAreaLightHelper
'
;
this
.
light
=
light
;
this
.
light
.
updateMatrixWorld
();
this
.
matrix
=
light
.
matrixWorld
;
this
.
matrixAutoUpdate
=
false
;
this
.
color
=
color
;
// optional hardwired color for the helper
this
.
color
=
color
;
var
positions
=
[
1
,
1
,
0
,
-
1
,
1
,
0
,
-
1
,
-
1
,
0
,
1
,
-
1
,
0
,
1
,
1
,
0
];
var
geometry
=
new
BufferGeometry
();
geometry
.
addAttribute
(
'
position
'
,
new
Float32BufferAttribute
(
positions
,
3
)
);
geometry
.
computeBoundingSphere
();
var
material
=
new
LineBasicMaterial
(
{
fog
:
false
}
);
var
geometry
=
new
BufferGeometry
(
);
Line
.
call
(
this
,
geometry
,
material
);
geometry
.
addAttribute
(
'
position
'
,
new
BufferAttribute
(
new
Float32Array
(
5
*
3
),
3
)
);
//
this
.
line
=
new
Line
(
geometry
,
material
);
this
.
add
(
this
.
line
);
var
positions2
=
[
1
,
1
,
0
,
-
1
,
1
,
0
,
-
1
,
-
1
,
0
,
1
,
1
,
0
,
-
1
,
-
1
,
0
,
1
,
-
1
,
0
];
var
geometry2
=
new
BufferGeometry
();
geometry2
.
addAttribute
(
'
position
'
,
new
Float32BufferAttribute
(
positions2
,
3
)
);
geometry2
.
computeBoundingSphere
();
this
.
add
(
new
Mesh
(
geometry2
,
new
MeshBasicMaterial
(
{
side
:
THREE
.
BackSide
,
fog
:
false
}
)
)
);
this
.
update
();
}
RectAreaLightHelper
.
prototype
=
Object
.
create
(
Object3D
.
prototype
);
RectAreaLightHelper
.
prototype
=
Object
.
create
(
Line
.
prototype
);
RectAreaLightHelper
.
prototype
.
constructor
=
RectAreaLightHelper
;
RectAreaLightHelper
.
prototype
.
dispose
=
function
()
{
this
.
children
[
0
].
geometry
.
dispose
();
this
.
children
[
0
].
material
.
dispose
();
};
RectAreaLightHelper
.
prototype
.
update
=
function
()
{
// calculate new dimensions of the helper
this
.
scale
.
set
(
0.5
*
this
.
light
.
width
,
0.5
*
this
.
light
.
height
,
1
);
var
hx
=
this
.
light
.
width
*
0.5
;
var
hy
=
this
.
light
.
height
*
0.5
;
if
(
this
.
color
!==
undefined
)
{
var
position
=
this
.
line
.
geometry
.
attributes
.
position
;
var
array
=
position
.
array
;
this
.
material
.
color
.
set
(
this
.
color
)
;
this
.
children
[
0
].
material
.
color
.
set
(
this
.
color
)
;
// update vertices
}
else
{
array
[
0
]
=
hx
;
array
[
1
]
=
-
hy
;
array
[
2
]
=
0
;
array
[
3
]
=
hx
;
array
[
4
]
=
hy
;
array
[
5
]
=
0
;
array
[
6
]
=
-
hx
;
array
[
7
]
=
hy
;
array
[
8
]
=
0
;
array
[
9
]
=
-
hx
;
array
[
10
]
=
-
hy
;
array
[
11
]
=
0
;
array
[
12
]
=
hx
;
array
[
13
]
=
-
hy
;
array
[
14
]
=
0
;
this
.
material
.
color
.
copy
(
this
.
light
.
color
).
multiplyScalar
(
this
.
light
.
intensity
);
position
.
needsUpdate
=
true
;
// prevent hue shift
var
c
=
this
.
material
.
color
;
var
max
=
Math
.
max
(
c
.
r
,
c
.
g
,
c
.
b
);
if
(
max
>
1
)
c
.
multiplyScalar
(
1
/
max
);
if
(
this
.
color
!==
undefined
)
{
this
.
children
[
0
].
material
.
color
.
copy
(
this
.
material
.
color
);
this
.
line
.
material
.
color
.
set
(
this
.
color
);
}
}
else
{
};
this
.
line
.
material
.
color
.
copy
(
this
.
light
.
color
);
RectAreaLightHelper
.
prototype
.
dispose
=
function
()
{
}
this
.
geometry
.
dispose
();
this
.
material
.
dispose
();
this
.
children
[
0
].
geometry
.
dispose
();
this
.
children
[
0
].
material
.
dispose
();
};
...
...
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl
浏览文件 @
6f186bb3
...
...
@@ -35,10 +35,10 @@ float clearCoatDHRApprox( const in float roughness, const in float dotNL ) {
float
roughness
=
material
.
specularRoughness
;
vec3
rectCoords
[
4
];
rectCoords
[
0
]
=
lightPos
-
halfWidth
-
halfHeight
;
// counterclockwise
rectCoords
[
1
]
=
lightPos
+
halfWidth
-
halfHeight
;
rectCoords
[
2
]
=
lightPos
+
halfWidth
+
halfHeight
;
rectCoords
[
3
]
=
lightPos
-
halfWidth
+
halfHeight
;
rectCoords
[
0
]
=
lightPos
+
halfWidth
-
halfHeight
;
// counterclockwise; light shines in local neg z direction
rectCoords
[
1
]
=
lightPos
-
halfWidth
-
halfHeight
;
rectCoords
[
2
]
=
lightPos
-
halfWidth
+
halfHeight
;
rectCoords
[
3
]
=
lightPos
+
halfWidth
+
halfHeight
;
vec2
uv
=
LTC_Uv
(
normal
,
viewDir
,
roughness
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录