Skip to content

Commit

Permalink
ProgressiveLightMap: Remove usage of THREE namespace. (#29747)
Browse files Browse the repository at this point in the history
* ProgressiveLightMap: Remove usage of `THREE` namespace.

* ProgressiveLightMap: Fix docs.
  • Loading branch information
Mugen87 authored Oct 25, 2024
1 parent e7e4ceb commit 1978cad
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions examples/jsm/misc/ProgressiveLightMap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as THREE from 'three';
import { DoubleSide, FloatType, HalfFloatType, Mesh, MeshBasicMaterial, MeshPhongMaterial, PlaneGeometry, Scene, WebGLRenderTarget } from 'three';
import { potpack } from '../libs/potpack.module.js';

/**
Expand All @@ -14,8 +14,8 @@ import { potpack } from '../libs/potpack.module.js';
* your objects, so you can start jittering lighting to achieve
* the texture-space effect you're looking for.
*
* @param {WebGLRenderer} renderer A WebGL Rendering Context
* @param {number} res The side-long dimension of you total lightmap
* @param {WebGLRenderer} renderer An instance of WebGLRenderer.
* @param {number} res The side-long dimension of you total lightmap.
*/
class ProgressiveLightMap {

Expand All @@ -24,20 +24,20 @@ class ProgressiveLightMap {
this.renderer = renderer;
this.res = res;
this.lightMapContainers = [];
this.scene = new THREE.Scene();
this.scene = new Scene();
this.buffer1Active = false;
this.firstUpdate = true;
this.labelMesh = null;
this.blurringPlane = null;

// Create the Progressive LightMap Texture
const format = /(Android|iPad|iPhone|iPod)/g.test( navigator.userAgent ) ? THREE.HalfFloatType : THREE.FloatType;
this.progressiveLightMap1 = new THREE.WebGLRenderTarget( this.res, this.res, { type: format } );
this.progressiveLightMap2 = new THREE.WebGLRenderTarget( this.res, this.res, { type: format } );
const format = /(Android|iPad|iPhone|iPod)/g.test( navigator.userAgent ) ? HalfFloatType : FloatType;
this.progressiveLightMap1 = new WebGLRenderTarget( this.res, this.res, { type: format } );
this.progressiveLightMap2 = new WebGLRenderTarget( this.res, this.res, { type: format } );
this.progressiveLightMap2.texture.channel = 1;

// Inject some spicy new logic into a standard phong material
this.uvMat = new THREE.MeshPhongMaterial();
this.uvMat = new MeshPhongMaterial();
this.uvMat.uniforms = {};
this.uvMat.onBeforeCompile = ( shader ) => {

Expand Down Expand Up @@ -231,9 +231,9 @@ class ProgressiveLightMap {

if ( this.labelMesh === null ) {

const labelMaterial = new THREE.MeshBasicMaterial( { map: this.progressiveLightMap1.texture, side: THREE.DoubleSide } );
const labelGeometry = new THREE.PlaneGeometry( 100, 100 );
this.labelMesh = new THREE.Mesh( labelGeometry, labelMaterial );
const labelMaterial = new MeshBasicMaterial( { map: this.progressiveLightMap1.texture, side: DoubleSide } );
const labelGeometry = new PlaneGeometry( 100, 100 );
this.labelMesh = new Mesh( labelGeometry, labelMaterial );
this.labelMesh.position.y = 250;
this.lightMapContainers[ 0 ].object.parent.add( this.labelMesh );

Expand All @@ -256,7 +256,7 @@ class ProgressiveLightMap {
*/
_initializeBlurPlane( res, lightMap = null ) {

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

};

this.blurringPlane = new THREE.Mesh( new THREE.PlaneGeometry( 1, 1 ), blurMaterial );
this.blurringPlane = new Mesh( new PlaneGeometry( 1, 1 ), blurMaterial );
this.blurringPlane.name = 'Blurring Plane';
this.blurringPlane.frustumCulled = false;
this.blurringPlane.renderOrder = 0;
Expand Down

0 comments on commit 1978cad

Please sign in to comment.