1
- import * as THREE from 'three' ;
1
+ import { DoubleSide , FloatType , HalfFloatType , Mesh , MeshBasicMaterial , MeshPhongMaterial , PlaneGeometry , Scene , WebGLRenderTarget } from 'three' ;
2
2
import { potpack } from '../libs/potpack.module.js' ;
3
3
4
4
/**
@@ -14,8 +14,8 @@ import { potpack } from '../libs/potpack.module.js';
14
14
* your objects, so you can start jittering lighting to achieve
15
15
* the texture-space effect you're looking for.
16
16
*
17
- * @param {WebGLRenderer } renderer A WebGL Rendering Context
18
- * @param {number } res The side-long dimension of you total lightmap
17
+ * @param {WebGLRenderer } renderer An instance of WebGLRenderer.
18
+ * @param {number } res The side-long dimension of you total lightmap.
19
19
*/
20
20
class ProgressiveLightMap {
21
21
@@ -24,20 +24,20 @@ class ProgressiveLightMap {
24
24
this . renderer = renderer ;
25
25
this . res = res ;
26
26
this . lightMapContainers = [ ] ;
27
- this . scene = new THREE . Scene ( ) ;
27
+ this . scene = new Scene ( ) ;
28
28
this . buffer1Active = false ;
29
29
this . firstUpdate = true ;
30
30
this . labelMesh = null ;
31
31
this . blurringPlane = null ;
32
32
33
33
// Create the Progressive LightMap Texture
34
- const format = / ( A n d r o i d | i P a d | i P h o n e | i P o d ) / g. test ( navigator . userAgent ) ? THREE . HalfFloatType : THREE . FloatType ;
35
- this . progressiveLightMap1 = new THREE . WebGLRenderTarget ( this . res , this . res , { type : format } ) ;
36
- this . progressiveLightMap2 = new THREE . WebGLRenderTarget ( this . res , this . res , { type : format } ) ;
34
+ const format = / ( A n d r o i d | i P a d | i P h o n e | i P o d ) / g. test ( navigator . userAgent ) ? HalfFloatType : FloatType ;
35
+ this . progressiveLightMap1 = new WebGLRenderTarget ( this . res , this . res , { type : format } ) ;
36
+ this . progressiveLightMap2 = new WebGLRenderTarget ( this . res , this . res , { type : format } ) ;
37
37
this . progressiveLightMap2 . texture . channel = 1 ;
38
38
39
39
// Inject some spicy new logic into a standard phong material
40
- this . uvMat = new THREE . MeshPhongMaterial ( ) ;
40
+ this . uvMat = new MeshPhongMaterial ( ) ;
41
41
this . uvMat . uniforms = { } ;
42
42
this . uvMat . onBeforeCompile = ( shader ) => {
43
43
@@ -231,9 +231,9 @@ class ProgressiveLightMap {
231
231
232
232
if ( this . labelMesh === null ) {
233
233
234
- const labelMaterial = new THREE . MeshBasicMaterial ( { map : this . progressiveLightMap1 . texture , side : THREE . DoubleSide } ) ;
235
- const labelGeometry = new THREE . PlaneGeometry ( 100 , 100 ) ;
236
- this . labelMesh = new THREE . Mesh ( labelGeometry , labelMaterial ) ;
234
+ const labelMaterial = new MeshBasicMaterial ( { map : this . progressiveLightMap1 . texture , side : DoubleSide } ) ;
235
+ const labelGeometry = new PlaneGeometry ( 100 , 100 ) ;
236
+ this . labelMesh = new Mesh ( labelGeometry , labelMaterial ) ;
237
237
this . labelMesh . position . y = 250 ;
238
238
this . lightMapContainers [ 0 ] . object . parent . add ( this . labelMesh ) ;
239
239
@@ -256,7 +256,7 @@ class ProgressiveLightMap {
256
256
*/
257
257
_initializeBlurPlane ( res , lightMap = null ) {
258
258
259
- const blurMaterial = new THREE . MeshBasicMaterial ( ) ;
259
+ const blurMaterial = new MeshBasicMaterial ( ) ;
260
260
blurMaterial . uniforms = { previousShadowMap : { value : null } ,
261
261
pixelOffset : { value : 1.0 / res } ,
262
262
polygonOffset : true , polygonOffsetFactor : - 1 , polygonOffsetUnits : 3.0 } ;
@@ -296,7 +296,7 @@ class ProgressiveLightMap {
296
296
297
297
} ;
298
298
299
- this . blurringPlane = new THREE . Mesh ( new THREE . PlaneGeometry ( 1 , 1 ) , blurMaterial ) ;
299
+ this . blurringPlane = new Mesh ( new PlaneGeometry ( 1 , 1 ) , blurMaterial ) ;
300
300
this . blurringPlane . name = 'Blurring Plane' ;
301
301
this . blurringPlane . frustumCulled = false ;
302
302
this . blurringPlane . renderOrder = 0 ;
0 commit comments