Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
483196c2
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 搜索 >>
提交
483196c2
编写于
8月 16, 2020
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WebGLClipping: Refactoring.
上级
662e7e1b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
33 deletion
+37
-33
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+13
-16
src/renderers/webgl/WebGLClipping.d.ts
src/renderers/webgl/WebGLClipping.d.ts
+6
-5
src/renderers/webgl/WebGLClipping.js
src/renderers/webgl/WebGLClipping.js
+11
-5
src/renderers/webgl/WebGLPrograms.d.ts
src/renderers/webgl/WebGLPrograms.d.ts
+3
-3
src/renderers/webgl/WebGLPrograms.js
src/renderers/webgl/WebGLPrograms.js
+4
-4
未找到文件。
src/renderers/WebGLRenderer.js
浏览文件 @
483196c2
...
...
@@ -149,7 +149,6 @@ function WebGLRenderer( parameters ) {
// clipping
const
_clipping
=
new
WebGLClipping
();
let
_clippingEnabled
=
false
;
let
_localClippingEnabled
=
false
;
...
...
@@ -252,7 +251,7 @@ function WebGLRenderer( parameters ) {
let
extensions
,
capabilities
,
state
,
info
;
let
properties
,
textures
,
cubemaps
,
attributes
,
geometries
,
objects
;
let
programCache
,
materials
,
renderLists
,
renderStates
;
let
programCache
,
materials
,
renderLists
,
renderStates
,
clipping
;
let
background
,
morphtargets
,
bufferRenderer
,
indexedBufferRenderer
;
...
...
@@ -294,11 +293,11 @@ function WebGLRenderer( parameters ) {
geometries
=
new
WebGLGeometries
(
_gl
,
attributes
,
info
,
bindingStates
);
objects
=
new
WebGLObjects
(
_gl
,
geometries
,
attributes
,
info
);
morphtargets
=
new
WebGLMorphtargets
(
_gl
);
programCache
=
new
WebGLPrograms
(
_this
,
cubemaps
,
extensions
,
capabilities
,
bindingStates
);
clipping
=
new
WebGLClipping
(
properties
);
programCache
=
new
WebGLPrograms
(
_this
,
cubemaps
,
extensions
,
capabilities
,
bindingStates
,
clipping
);
materials
=
new
WebGLMaterials
(
properties
);
renderLists
=
new
WebGLRenderLists
(
properties
);
renderStates
=
new
WebGLRenderStates
();
background
=
new
WebGLBackground
(
_this
,
cubemaps
,
state
,
objects
,
_premultipliedAlpha
);
bufferRenderer
=
new
WebGLBufferRenderer
(
_gl
,
extensions
,
info
,
capabilities
);
...
...
@@ -1012,7 +1011,7 @@ function WebGLRenderer( parameters ) {
_frustum
.
setFromProjectionMatrix
(
_projScreenMatrix
);
_localClippingEnabled
=
this
.
localClippingEnabled
;
_clippingEnabled
=
_
clipping
.
init
(
this
.
clippingPlanes
,
_localClippingEnabled
,
camera
);
_clippingEnabled
=
clipping
.
init
(
this
.
clippingPlanes
,
_localClippingEnabled
,
camera
);
currentRenderList
=
renderLists
.
get
(
scene
,
camera
);
currentRenderList
.
init
();
...
...
@@ -1029,7 +1028,7 @@ function WebGLRenderer( parameters ) {
//
if
(
_clippingEnabled
===
true
)
_
clipping
.
beginShadows
();
if
(
_clippingEnabled
===
true
)
clipping
.
beginShadows
();
const
shadowsArray
=
currentRenderState
.
state
.
shadowsArray
;
...
...
@@ -1037,7 +1036,7 @@ function WebGLRenderer( parameters ) {
currentRenderState
.
setupLights
(
camera
);
if
(
_clippingEnabled
===
true
)
_
clipping
.
endShadows
();
if
(
_clippingEnabled
===
true
)
clipping
.
endShadows
();
//
...
...
@@ -1306,7 +1305,7 @@ function WebGLRenderer( parameters ) {
const
lightsStateVersion
=
lights
.
state
.
version
;
const
parameters
=
programCache
.
getParameters
(
material
,
lights
.
state
,
shadowsArray
,
scene
,
_clipping
.
numPlanes
,
_clipping
.
numIntersection
,
object
);
const
parameters
=
programCache
.
getParameters
(
material
,
lights
.
state
,
shadowsArray
,
scene
,
object
);
const
programCacheKey
=
programCache
.
getProgramCacheKey
(
parameters
);
let
program
=
materialProperties
.
program
;
...
...
@@ -1394,9 +1393,9 @@ function WebGLRenderer( parameters ) {
!
material
.
isRawShaderMaterial
||
material
.
clipping
===
true
)
{
materialProperties
.
numClippingPlanes
=
_
clipping
.
numPlanes
;
materialProperties
.
numIntersection
=
_
clipping
.
numIntersection
;
uniforms
.
clippingPlanes
=
_
clipping
.
uniform
;
materialProperties
.
numClippingPlanes
=
clipping
.
numPlanes
;
materialProperties
.
numIntersection
=
clipping
.
numIntersection
;
uniforms
.
clippingPlanes
=
clipping
.
uniform
;
}
...
...
@@ -1468,9 +1467,7 @@ function WebGLRenderer( parameters ) {
// we might want to call this function with some ClippingGroup
// object instead of the material, once it becomes feasible
// (#8465, #8379)
_clipping
.
setState
(
material
.
clippingPlanes
,
material
.
clipIntersection
,
material
.
clipShadows
,
camera
,
materialProperties
,
useCache
);
clipping
.
setState
(
material
,
camera
,
useCache
);
}
...
...
@@ -1495,8 +1492,8 @@ function WebGLRenderer( parameters ) {
initMaterial
(
material
,
scene
,
object
);
}
else
if
(
materialProperties
.
numClippingPlanes
!==
undefined
&&
(
materialProperties
.
numClippingPlanes
!==
_
clipping
.
numPlanes
||
materialProperties
.
numIntersection
!==
_
clipping
.
numIntersection
)
)
{
(
materialProperties
.
numClippingPlanes
!==
clipping
.
numPlanes
||
materialProperties
.
numIntersection
!==
clipping
.
numIntersection
)
)
{
initMaterial
(
material
,
scene
,
object
);
...
...
src/renderers/webgl/WebGLClipping.d.ts
浏览文件 @
483196c2
import
{
Camera
}
from
'
./../../cameras/Camera
'
;
import
{
Material
}
from
'
./../../materials/Material
'
;
import
{
WebGLProperties
}
from
'
./WebGLProperties
'
;
export
class
WebGLClipping
{
constructor
(
properties
:
WebGLProperties
);
uniform
:
{
value
:
any
;
needsUpdate
:
boolean
};
/**
...
...
@@ -18,12 +22,9 @@ export class WebGLClipping {
beginShadows
():
void
;
endShadows
():
void
;
setState
(
planes
:
any
[],
clipIntersection
:
boolean
,
clipShadows
:
boolean
,
material
:
Material
,
camera
:
Camera
,
cache
:
any
,
fromCache
:
boolean
useCache
:
boolean
):
void
;
}
src/renderers/webgl/WebGLClipping.js
浏览文件 @
483196c2
import
{
Matrix3
}
from
'
../../math/Matrix3.js
'
;
import
{
Plane
}
from
'
../../math/Plane.js
'
;
function
WebGLClipping
()
{
function
WebGLClipping
(
properties
)
{
const
scope
=
this
;
...
...
@@ -52,7 +52,13 @@ function WebGLClipping() {
};
this
.
setState
=
function
(
planes
,
clipIntersection
,
clipShadows
,
camera
,
cache
,
fromCache
)
{
this
.
setState
=
function
(
material
,
camera
,
useCache
)
{
const
planes
=
material
.
clippingPlanes
,
clipIntersection
=
material
.
clipIntersection
,
clipShadows
=
material
.
clipShadows
;
const
materialProperties
=
properties
.
get
(
material
);
if
(
!
localClippingEnabled
||
planes
===
null
||
planes
.
length
===
0
||
renderingShadows
&&
!
clipShadows
)
{
...
...
@@ -75,11 +81,11 @@ function WebGLClipping() {
const
nGlobal
=
renderingShadows
?
0
:
numGlobalPlanes
,
lGlobal
=
nGlobal
*
4
;
let
dstArray
=
cache
.
clippingState
||
null
;
let
dstArray
=
materialProperties
.
clippingState
||
null
;
uniform
.
value
=
dstArray
;
// ensure unique state
dstArray
=
projectPlanes
(
planes
,
camera
,
lGlobal
,
from
Cache
);
dstArray
=
projectPlanes
(
planes
,
camera
,
lGlobal
,
use
Cache
);
for
(
let
i
=
0
;
i
!==
lGlobal
;
++
i
)
{
...
...
@@ -87,7 +93,7 @@ function WebGLClipping() {
}
cache
.
clippingState
=
dstArray
;
materialProperties
.
clippingState
=
dstArray
;
this
.
numIntersection
=
clipIntersection
?
this
.
numPlanes
:
0
;
this
.
numPlanes
+=
nGlobal
;
...
...
src/renderers/webgl/WebGLPrograms.d.ts
浏览文件 @
483196c2
...
...
@@ -3,12 +3,14 @@ import { WebGLProgram } from './WebGLProgram';
import
{
WebGLCapabilities
}
from
'
./WebGLCapabilities
'
;
import
{
WebGLCubeMaps
}
from
'
./WebGLCubeMaps
'
;
import
{
WebGLExtensions
}
from
'
./WebGLExtensions
'
;
import
{
WebGLClipping
}
from
'
./WebGLClipping
'
;
import
{
WebGLBindingStates
}
from
'
./WebGLBindingStates
'
;
import
{
Material
}
from
'
./../../materials/Material
'
;
import
{
Scene
}
from
'
./../../scenes/Scene
'
;
export
class
WebGLPrograms
{
constructor
(
renderer
:
WebGLRenderer
,
cubemaps
:
WebGLCubeMaps
,
extensions
:
WebGLExtensions
,
capabilities
:
WebGLCapabilities
);
constructor
(
renderer
:
WebGLRenderer
,
cubemaps
:
WebGLCubeMaps
,
extensions
:
WebGLExtensions
,
capabilities
:
WebGLCapabilities
,
bindingStates
:
WebGLBindingStates
,
clipping
:
WebGLClipping
);
programs
:
WebGLProgram
[];
...
...
@@ -17,8 +19,6 @@ export class WebGLPrograms {
lights
:
any
,
shadows
:
object
[],
scene
:
Scene
,
nClipPlanes
:
number
,
nClipIntersection
:
number
,
object
:
any
):
any
;
getProgramCacheKey
(
parameters
:
any
):
string
;
...
...
src/renderers/webgl/WebGLPrograms.js
浏览文件 @
483196c2
...
...
@@ -3,7 +3,7 @@ import { WebGLProgram } from './WebGLProgram.js';
import
{
ShaderLib
}
from
'
../shaders/ShaderLib.js
'
;
import
{
UniformsUtils
}
from
'
../shaders/UniformsUtils.js
'
;
function
WebGLPrograms
(
renderer
,
cubemaps
,
extensions
,
capabilities
,
bindingStates
)
{
function
WebGLPrograms
(
renderer
,
cubemaps
,
extensions
,
capabilities
,
bindingStates
,
clipping
)
{
const
programs
=
[];
...
...
@@ -108,7 +108,7 @@ function WebGLPrograms( renderer, cubemaps, extensions, capabilities, bindingSta
}
function
getParameters
(
material
,
lights
,
shadows
,
scene
,
nClipPlanes
,
nClipIntersection
,
object
)
{
function
getParameters
(
material
,
lights
,
shadows
,
scene
,
object
)
{
const
fog
=
scene
.
fog
;
const
environment
=
material
.
isMeshStandardMaterial
?
scene
.
environment
:
null
;
...
...
@@ -240,8 +240,8 @@ function WebGLPrograms( renderer, cubemaps, extensions, capabilities, bindingSta
numPointLightShadows
:
lights
.
pointShadowMap
.
length
,
numSpotLightShadows
:
lights
.
spotShadowMap
.
length
,
numClippingPlanes
:
nClip
Planes
,
numClipIntersection
:
nClip
Intersection
,
numClippingPlanes
:
clipping
.
num
Planes
,
numClipIntersection
:
clipping
.
num
Intersection
,
dithering
:
material
.
dithering
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录