Skip to content

Commit 1978cad

Browse files
authored
ProgressiveLightMap: Remove usage of THREE namespace. (#29747)
* ProgressiveLightMap: Remove usage of `THREE` namespace. * ProgressiveLightMap: Fix docs.
1 parent e7e4ceb commit 1978cad

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

examples/jsm/misc/ProgressiveLightMap.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as THREE from 'three';
1+
import { DoubleSide, FloatType, HalfFloatType, Mesh, MeshBasicMaterial, MeshPhongMaterial, PlaneGeometry, Scene, WebGLRenderTarget } from 'three';
22
import { potpack } from '../libs/potpack.module.js';
33

44
/**
@@ -14,8 +14,8 @@ import { potpack } from '../libs/potpack.module.js';
1414
* your objects, so you can start jittering lighting to achieve
1515
* the texture-space effect you're looking for.
1616
*
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.
1919
*/
2020
class ProgressiveLightMap {
2121

@@ -24,20 +24,20 @@ class ProgressiveLightMap {
2424
this.renderer = renderer;
2525
this.res = res;
2626
this.lightMapContainers = [];
27-
this.scene = new THREE.Scene();
27+
this.scene = new Scene();
2828
this.buffer1Active = false;
2929
this.firstUpdate = true;
3030
this.labelMesh = null;
3131
this.blurringPlane = null;
3232

3333
// Create the Progressive LightMap Texture
34-
const format = /(Android|iPad|iPhone|iPod)/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 = /(Android|iPad|iPhone|iPod)/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 } );
3737
this.progressiveLightMap2.texture.channel = 1;
3838

3939
// Inject some spicy new logic into a standard phong material
40-
this.uvMat = new THREE.MeshPhongMaterial();
40+
this.uvMat = new MeshPhongMaterial();
4141
this.uvMat.uniforms = {};
4242
this.uvMat.onBeforeCompile = ( shader ) => {
4343

@@ -231,9 +231,9 @@ class ProgressiveLightMap {
231231

232232
if ( this.labelMesh === null ) {
233233

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 );
237237
this.labelMesh.position.y = 250;
238238
this.lightMapContainers[ 0 ].object.parent.add( this.labelMesh );
239239

@@ -256,7 +256,7 @@ class ProgressiveLightMap {
256256
*/
257257
_initializeBlurPlane( res, lightMap = null ) {
258258

259-
const blurMaterial = new THREE.MeshBasicMaterial();
259+
const blurMaterial = new MeshBasicMaterial();
260260
blurMaterial.uniforms = { previousShadowMap: { value: null },
261261
pixelOffset: { value: 1.0 / res },
262262
polygonOffset: true, polygonOffsetFactor: - 1, polygonOffsetUnits: 3.0 };
@@ -296,7 +296,7 @@ class ProgressiveLightMap {
296296

297297
};
298298

299-
this.blurringPlane = new THREE.Mesh( new THREE.PlaneGeometry( 1, 1 ), blurMaterial );
299+
this.blurringPlane = new Mesh( new PlaneGeometry( 1, 1 ), blurMaterial );
300300
this.blurringPlane.name = 'Blurring Plane';
301301
this.blurringPlane.frustumCulled = false;
302302
this.blurringPlane.renderOrder = 0;

0 commit comments

Comments
 (0)