LineMaterial.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937
  1. /**
  2. * parameters = {
  3. * color: <hex>,
  4. * lineWidth: <float>,
  5. * dashed: <boolean>,
  6. * dashScale: <float>,
  7. * dashSize: <float>,
  8. * dashOffset: <float>,
  9. * gapSize: <float>,
  10. * resolution: <Vector2>, // to be set by renderer
  11. * }
  12. */
  13. import {
  14. ShaderLib,
  15. ShaderMaterial,
  16. UniformsLib,
  17. UniformsUtils,
  18. Vector2,
  19. Color
  20. } from '../build/three.module.js';
  21. UniformsLib.line = {
  22. /*
  23. worldUnits: { value: 1 },
  24. lineWidth: { value: 1 },
  25. resolution: { value: new Vector2( 1, 1 ) },
  26. dashOffset: { value: 0 },
  27. dashScale: { value: 1 },
  28. dashSize: { value: 1 },
  29. gapSize: { value: 1 } // todo FIX - maybe change to totalSize
  30. */
  31. worldUnits: { value: 1 },
  32. lineWidth: { value: 1 },
  33. resolution: { value: new Vector2( 1, 1 ) },
  34. viewportOffset: { value: new Vector2(0, 0 ) }, //left, top
  35. dashScale: { value: 1 },
  36. dashSize: { value: 1 },
  37. dashOffset: { value: 0 },
  38. gapSize: { value: 1 },
  39. opacity: { value: 1 },
  40. backColor: {type:'v3', value: new Color("#ddd")},
  41. clipDistance : { type: 'f', value: 4}, //消失距离
  42. occlusionDistance : { type: 'f', value: 1 }, //变为backColor距离
  43. maxClipFactor : { type: 'f', value: 1 }, //0-1
  44. depthTexture:{ value: null },
  45. nearPlane:{value: 0.1},
  46. farPlane:{value: 100000},
  47. };
  48. ShaderLib[ 'line' ] = {
  49. uniforms: UniformsUtils.merge( [
  50. UniformsLib.common,
  51. UniformsLib.fog,
  52. UniformsLib.line
  53. ] ),
  54. vertexShader:
  55. /* glsl */`
  56. #include <common>
  57. #include <color_pars_vertex>
  58. #include <fog_pars_vertex>
  59. #include <logdepthbuf_pars_vertex>
  60. #include <clipping_planes_pars_vertex>
  61. uniform float lineWidth;
  62. uniform vec2 resolution;
  63. attribute vec3 instanceStart;
  64. attribute vec3 instanceEnd;
  65. attribute vec3 instanceColorStart;
  66. attribute vec3 instanceColorEnd;
  67. #ifdef WORLD_UNITS
  68. varying vec4 worldPos;
  69. varying vec3 worldStart;
  70. varying vec3 worldEnd;
  71. #ifdef USE_DASH
  72. varying vec2 vUv;
  73. #endif
  74. #else
  75. varying vec2 vUv;
  76. #endif
  77. #ifdef USE_DASH
  78. uniform float dashScale;
  79. attribute float instanceDistanceStart;
  80. attribute float instanceDistanceEnd;
  81. varying float vLineDistance;
  82. #endif
  83. void trimSegment( const in vec4 start, inout vec4 end ) {
  84. // trim end segment so it terminates between the camera plane and the near plane
  85. // conservative estimate of the near plane
  86. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  87. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  88. float nearEstimate = - 0.5 * b / a;
  89. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  90. end.xyz = mix( start.xyz, end.xyz, alpha );
  91. }
  92. void main() {
  93. #ifdef USE_COLOR
  94. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  95. #endif
  96. #ifdef USE_DASH
  97. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  98. vUv = uv;
  99. #endif
  100. float aspect = resolution.x / resolution.y;
  101. // camera space
  102. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  103. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  104. #ifdef WORLD_UNITS
  105. worldStart = start.xyz;
  106. worldEnd = end.xyz;
  107. #else
  108. vUv = uv;
  109. #endif
  110. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  111. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  112. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  113. // perhaps there is a more elegant solution -- WestLangley
  114. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  115. if ( perspective ) {
  116. if ( start.z < 0.0 && end.z >= 0.0 ) {
  117. trimSegment( start, end );
  118. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  119. trimSegment( end, start );
  120. }
  121. }
  122. // clip space
  123. vec4 clipStart = projectionMatrix * start;
  124. vec4 clipEnd = projectionMatrix * end;
  125. // ndc space
  126. vec3 ndcStart = clipStart.xyz / clipStart.w;
  127. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  128. // direction
  129. vec2 dir = ndcEnd.xy - ndcStart.xy;
  130. // account for clip-space aspect ratio
  131. dir.x *= aspect;
  132. dir = normalize( dir );
  133. #ifdef WORLD_UNITS
  134. // get the offset direction as perpendicular to the view vector
  135. vec3 worldDir = normalize( end.xyz - start.xyz );
  136. vec3 offset;
  137. if ( position.y < 0.5 ) {
  138. offset = normalize( cross( start.xyz, worldDir ) );
  139. } else {
  140. offset = normalize( cross( end.xyz, worldDir ) );
  141. }
  142. // sign flip
  143. if ( position.x < 0.0 ) offset *= - 1.0;
  144. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  145. // don't extend the line if we're rendering dashes because we
  146. // won't be rendering the endcaps
  147. #ifndef USE_DASH
  148. // extend the line bounds to encompass endcaps
  149. start.xyz += - worldDir * lineWidth * 0.5;
  150. end.xyz += worldDir * lineWidth * 0.5;
  151. // shift the position of the quad so it hugs the forward edge of the line
  152. offset.xy -= dir * forwardOffset;
  153. offset.z += 0.5;
  154. #endif
  155. // endcaps
  156. if ( position.y > 1.0 || position.y < 0.0 ) {
  157. offset.xy += dir * 2.0 * forwardOffset;
  158. }
  159. // adjust for lineWidth
  160. offset *= lineWidth * 0.5;
  161. // set the world position
  162. worldPos = ( position.y < 0.5 ) ? start : end;
  163. worldPos.xyz += offset;
  164. // project the worldpos
  165. vec4 clip = projectionMatrix * worldPos;
  166. // shift the depth of the projected points so the line
  167. // segments overlap neatly
  168. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  169. clip.z = clipPose.z * clip.w;
  170. #else
  171. vec2 offset = vec2( dir.y, - dir.x );
  172. // undo aspect ratio adjustment
  173. dir.x /= aspect;
  174. offset.x /= aspect;
  175. // sign flip
  176. if ( position.x < 0.0 ) offset *= - 1.0;
  177. // endcaps
  178. if ( position.y < 0.0 ) {
  179. offset += - dir;
  180. } else if ( position.y > 1.0 ) {
  181. offset += dir;
  182. }
  183. // adjust for lineWidth
  184. offset *= lineWidth;
  185. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  186. offset /= resolution.y;
  187. // select end
  188. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  189. // back to clip space
  190. offset *= clip.w;
  191. clip.xy += offset;
  192. #endif
  193. gl_Position = clip;
  194. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  195. #include <logdepthbuf_vertex>
  196. #include <clipping_planes_vertex>
  197. #include <fog_vertex>
  198. }
  199. `,
  200. fragmentShader:
  201. /* glsl */`
  202. uniform vec3 diffuse;
  203. uniform float opacity;
  204. uniform float lineWidth;
  205. uniform vec3 backColor;
  206. uniform float occlusionDistance;
  207. uniform float clipDistance;
  208. uniform float maxClipFactor;
  209. #ifdef USE_DASH
  210. uniform float dashOffset;
  211. uniform float dashSize;
  212. uniform float gapSize;
  213. #endif
  214. //加
  215. #if defined(GL_EXT_frag_depth) && defined(useDepth)
  216. uniform sampler2D depthTexture;
  217. uniform float nearPlane;
  218. uniform float farPlane;
  219. uniform vec2 resolution;
  220. uniform vec2 viewportOffset;
  221. #endif
  222. varying float vLineDistance;
  223. #ifdef WORLD_UNITS
  224. varying vec4 worldPos;
  225. varying vec3 worldStart;
  226. varying vec3 worldEnd;
  227. #ifdef USE_DASH
  228. varying vec2 vUv;
  229. #endif
  230. #else
  231. varying vec2 vUv;
  232. #endif
  233. #include <common>
  234. #include <color_pars_fragment>
  235. #include <fog_pars_fragment>
  236. #include <logdepthbuf_pars_fragment>
  237. #include <clipping_planes_pars_fragment>
  238. #if defined(GL_EXT_frag_depth) && defined(useDepth)
  239. float convertToLinear(float zValue)
  240. {
  241. float z = zValue * 2.0 - 1.0;
  242. return (2.0 * nearPlane * farPlane) / (farPlane + nearPlane - z * (farPlane - nearPlane));
  243. }
  244. #endif
  245. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  246. float mua;
  247. float mub;
  248. vec3 p13 = p1 - p3;
  249. vec3 p43 = p4 - p3;
  250. vec3 p21 = p2 - p1;
  251. float d1343 = dot( p13, p43 );
  252. float d4321 = dot( p43, p21 );
  253. float d1321 = dot( p13, p21 );
  254. float d4343 = dot( p43, p43 );
  255. float d2121 = dot( p21, p21 );
  256. float denom = d2121 * d4343 - d4321 * d4321;
  257. float numer = d1343 * d4321 - d1321 * d4343;
  258. mua = numer / denom;
  259. mua = clamp( mua, 0.0, 1.0 );
  260. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  261. mub = clamp( mub, 0.0, 1.0 );
  262. return vec2( mua, mub );
  263. }
  264. void main() {
  265. #include <clipping_planes_fragment>
  266. /*#ifdef USE_DASH
  267. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  268. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  269. #endif*/
  270. #ifdef USE_DASH
  271. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  272. bool unvisible = mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize;
  273. //加
  274. #ifdef DASH_with_depth
  275. #else
  276. if (unvisible) discard; // todo - FIX
  277. #endif
  278. #endif
  279. float alpha = opacity;
  280. #ifdef WORLD_UNITS
  281. // Find the closest points on the view ray and the line segment
  282. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  283. vec3 lineDir = worldEnd - worldStart;
  284. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  285. vec3 p1 = worldStart + lineDir * params.x;
  286. vec3 p2 = rayEnd * params.y;
  287. vec3 delta = p1 - p2;
  288. float len = length( delta );
  289. float norm = len / lineWidth;
  290. #ifndef USE_DASH
  291. #ifdef USE_ALPHA_TO_COVERAGE
  292. float dnorm = fwidth( norm );
  293. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  294. #else
  295. if ( norm > 0.5 ) {
  296. discard;
  297. }
  298. #endif
  299. #endif
  300. #else
  301. #ifdef USE_ALPHA_TO_COVERAGE
  302. // artifacts appear on some hardware if a derivative is taken within a conditional
  303. float a = vUv.x;
  304. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  305. float len2 = a * a + b * b;
  306. float dlen = fwidth( len2 );
  307. if ( abs( vUv.y ) > 1.0 ) {
  308. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  309. }
  310. #else
  311. if ( abs( vUv.y ) > 1.0 ) {
  312. float a = vUv.x;
  313. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  314. float len2 = a * a + b * b;
  315. if ( len2 > 1.0 ) discard;
  316. }
  317. #endif
  318. #endif
  319. vec4 diffuseColor = vec4( diffuse, alpha );
  320. //加
  321. #if defined(GL_EXT_frag_depth) && defined(useDepth)
  322. float mixFactor = 0.0;
  323. float clipFactor = 0.0;
  324. float fragDepth = convertToLinear(gl_FragCoord.z);
  325. vec2 depthTxtCoords = vec2(gl_FragCoord.x - viewportOffset.x, gl_FragCoord.y - viewportOffset.y) / resolution;
  326. float textureDepth = convertToLinear(texture2D(depthTexture, depthTxtCoords).r);
  327. float delta = fragDepth - textureDepth;
  328. if (delta > 0.0)
  329. {
  330. mixFactor = clamp(delta / occlusionDistance, 0.0, 1.0);
  331. clipFactor = clamp(delta / clipDistance, 0.0, maxClipFactor);
  332. }
  333. if (clipFactor == 1.0)
  334. {
  335. discard;
  336. }
  337. vec4 backColor_ = vec4(backColor, opacity); //vec4(0.8,0.8,0.8, 0.8*opacity);
  338. #ifdef DASH_with_depth
  339. // 只在被遮住的部分显示虚线, 所以若同时是虚线不可见部分和被遮住时, a为0
  340. if(unvisible) backColor_.a = 0.0;
  341. #endif
  342. //vec4 diffuseColor = vec4(mix(diffuse, backColor_, mixFactor), opacity*(1.0 - clipFactor));
  343. diffuseColor = mix(diffuseColor, backColor_ , mixFactor);
  344. diffuseColor.a *= (1.0 - clipFactor);
  345. #endif
  346. #include <logdepthbuf_fragment>
  347. #include <color_fragment>
  348. //gl_FragColor = vec4( diffuseColor.rgb, alpha );
  349. gl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );
  350. #include <tonemapping_fragment>
  351. #include <encodings_fragment>
  352. #include <fog_fragment>
  353. #include <premultiplied_alpha_fragment>
  354. }
  355. `
  356. };
  357. class LineMaterial extends ShaderMaterial {
  358. constructor( parameters ) {
  359. super( {
  360. type: 'LineMaterial',
  361. uniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),
  362. vertexShader: ShaderLib[ 'line' ].vertexShader,
  363. fragmentShader: ShaderLib[ 'line' ].fragmentShader,
  364. clipping: true // required for clipping support
  365. } );
  366. this.isLineMaterial = true;
  367. this.lineWidth_ = 0
  368. this.supportExtDepth = parameters.supportExtDepth
  369. this.depthTestWhenPick = false //pick时是否识别点云等
  370. if(parameters.color){
  371. this.color = new Color(parameters.color)
  372. }
  373. if(parameters.backColor){
  374. this.uniforms.backColor.value = new Color(parameters.backColor)
  375. }
  376. if(parameters.clipDistance){
  377. this.uniforms.clipDistance.value = parameters.clipDistance
  378. }
  379. if(parameters.occlusionDistance){
  380. this.uniforms.occlusionDistance.value = parameters.occlusionDistance
  381. }
  382. if(parameters.maxClipFactor){
  383. this.uniforms.maxClipFactor.value = parameters.maxClipFactor
  384. }
  385. Object.defineProperties( this, {
  386. color: {
  387. enumerable: true,
  388. get: function () {
  389. return this.uniforms.diffuse.value;
  390. },
  391. set: function ( value ) {
  392. this.uniforms.diffuse.value = value;
  393. }
  394. },
  395. worldUnits: {
  396. enumerable: true,
  397. get: function () {
  398. return 'WORLD_UNITS' in this.defines;
  399. },
  400. set: function ( value ) {
  401. if ( value === true ) {
  402. this.defines.WORLD_UNITS = '';
  403. } else {
  404. delete this.defines.WORLD_UNITS;
  405. }
  406. }
  407. },
  408. lineWidth: {
  409. enumerable: true,
  410. get: function () {
  411. return this.lineWidth_;//this.uniforms.lineWidth.value;
  412. },
  413. set: function ( value ) {
  414. this.uniforms.lineWidth.value = value * window.devicePixelRatio;
  415. this.lineWidth_ = value
  416. }
  417. },
  418. dashed: {
  419. enumerable: true,
  420. get: function () {
  421. return Boolean( 'USE_DASH' in this.defines );
  422. },
  423. set( value ) {
  424. if ( Boolean( value ) !== Boolean( 'USE_DASH' in this.defines ) ) {
  425. this.needsUpdate = true;
  426. }
  427. if ( value === true ) {
  428. this.defines.USE_DASH = '';
  429. } else {
  430. delete this.defines.USE_DASH;
  431. }
  432. }
  433. },
  434. dashScale: {
  435. enumerable: true,
  436. get: function () {
  437. return this.uniforms.dashScale.value;
  438. },
  439. set: function ( value ) {
  440. this.uniforms.dashScale.value = value;
  441. }
  442. },
  443. dashSize: {
  444. enumerable: true,
  445. get: function () {
  446. return this.uniforms.dashSize.value;
  447. },
  448. set: function ( value ) {
  449. this.uniforms.dashSize.value = value;
  450. }
  451. },
  452. dashOffset: {
  453. enumerable: true,
  454. get: function () {
  455. return this.uniforms.dashOffset.value;
  456. },
  457. set: function ( value ) {
  458. this.uniforms.dashOffset.value = value;
  459. }
  460. },
  461. gapSize: {
  462. enumerable: true,
  463. get: function () {
  464. return this.uniforms.gapSize.value;
  465. },
  466. set: function ( value ) {
  467. this.uniforms.gapSize.value = value;
  468. }
  469. },
  470. opacity: {
  471. enumerable: true,
  472. get: function () {
  473. return this.uniforms.opacity.value;
  474. },
  475. set: function ( value ) {
  476. this.uniforms.opacity.value = value;
  477. }
  478. },
  479. resolution: {
  480. enumerable: true,
  481. get: function () {
  482. return this.uniforms.resolution.value;
  483. },
  484. set: function ( value ) {
  485. this.uniforms.resolution.value.copy( value );
  486. }
  487. },
  488. alphaToCoverage: {
  489. enumerable: true,
  490. get: function () {
  491. return Boolean( 'USE_ALPHA_TO_COVERAGE' in this.defines );
  492. },
  493. set: function ( value ) {
  494. if ( Boolean( value ) !== Boolean( 'USE_ALPHA_TO_COVERAGE' in this.defines ) ) {
  495. this.needsUpdate = true;
  496. }
  497. if ( value === true ) {
  498. this.defines.USE_ALPHA_TO_COVERAGE = '';
  499. this.extensions.derivatives = true;
  500. } else {
  501. delete this.defines.USE_ALPHA_TO_COVERAGE;
  502. this.extensions.derivatives = false;
  503. }
  504. }
  505. }
  506. ,
  507. useDepth:{//add
  508. enumerable: true,
  509. get: function () {
  510. return 'useDepth' in this.defines
  511. },
  512. set: function ( value ) {
  513. value = value && !!this.supportExtDepth
  514. if(value != this.useDepth){
  515. if(value){
  516. this.defines.useDepth = ''
  517. this.updateDepthParams()
  518. }else{
  519. delete this.defines.useDepth
  520. }
  521. this.needsUpdate = true
  522. }
  523. }
  524. },
  525. dashWithDepth:{//add
  526. enumerable: true,
  527. get: function () {
  528. return 'DASH_with_depth' in this.defines
  529. },
  530. set: function ( value ) {
  531. value = value && !!this.supportExtDepth
  532. if(value != this.dashWithDepth){
  533. if(value){
  534. this.defines.DASH_with_depth = ''
  535. }else{
  536. delete this.defines.DASH_with_depth
  537. }
  538. this.needsUpdate = true
  539. }
  540. }
  541. },
  542. } );
  543. this.setValues( parameters );
  544. let setSize = (e)=>{
  545. let viewport = e.viewport
  546. let viewportOffset = viewport.offset || new Vector2()
  547. this.uniforms.resolution.value.copy(viewport.resolution2)
  548. this.uniforms.viewportOffset.value.copy(viewportOffset)
  549. this.lineWidth = this.lineWidth_
  550. }
  551. let viewport = viewer.mainViewport;
  552. setSize({viewport})
  553. viewer.addEventListener('resize',(e)=>{
  554. setSize(e)
  555. })
  556. if(this.supportExtDepth){
  557. //add
  558. this.updateDepthParams()
  559. /* viewer.addEventListener('camera_changed', (e)=>{
  560. if(e.viewport.name != 'mapViewport') this.updateDepthParams(e)
  561. }) */
  562. viewer.addEventListener("render.begin", (e)=>{//before render 如果有大于两个viewport的话,不同viewport用不同的depthTex
  563. if(e.viewport.camera.isPerspectiveCamera) this.updateDepthParams(e)
  564. })
  565. }
  566. }
  567. updateDepthParams(e={}){
  568. if(this.useDepth){
  569. var viewport = e.viewport || viewer.mainViewport;
  570. var camera = viewport.camera;
  571. this.uniforms.depthTexture.value = viewer.getPRenderer().getRtEDL(viewport).depthTexture //viewer.getPRenderer().rtEDL.depthTexture
  572. this.uniforms.nearPlane.value = camera.near; //似乎因为这个所以对OrthographicCamera 无效
  573. this.uniforms.farPlane.value = camera.far;
  574. }
  575. }
  576. }
  577. export { LineMaterial };