Ver Fonte

WebGLMaterials also requires properties, pixelRatio and screen height

Filipp Keks há 5 anos atrás
pai
commit
0ec36acdb8

+ 2 - 2
src/renderers/WebGLRenderer.js

@@ -282,7 +282,7 @@ function WebGLRenderer( parameters ) {
 		objects = parameters.objects !== undefined ? parameters.objects : new WebGLObjects( _gl, geometries, attributes, info );
 		morphtargets = parameters.morphtargets !== undefined ? parameters.morphtargets : new WebGLMorphtargets( _gl );
 		programCache = parameters.programCache !== undefined ? parameters.programCache : new WebGLPrograms( _this, extensions, capabilities );
-		materials = parameters.materials !== undefined ? parameters.materials : new WebGLMaterials();
+		materials = parameters.materials !== undefined ? parameters.materials : new WebGLMaterials( properties );
 		renderLists = parameters.renderLists !== undefined ? parameters.renderLists : new WebGLRenderLists();
 		renderStates = parameters.renderStates !== undefined ? parameters.renderStates : new WebGLRenderStates();
 
@@ -1865,7 +1865,7 @@ function WebGLRenderer( parameters ) {
 
 			}
 
-			materials.refreshUniforms( m_uniforms, material, environment );
+			materials.refreshUniforms( m_uniforms, material, environment, _pixelRatio, _height );
 
 			// RectAreaLight Texture
 			// TODO (mrdoob): Find a nicer implementation

+ 3 - 2
src/renderers/webgl/WebGLMaterials.d.ts

@@ -1,12 +1,13 @@
 import { Material } from "../../materials/Material";
 import { Texture } from "../../textures/Texture";
 import { IFog } from "../../scenes/Fog";
+import { WebGLProperties } from "./WebGLProperties";
 
 export class WebGLMaterials {
 
-	constructor();
+	constructor( properties: WebGLProperties );
 
-	refreshUniforms( uniforms: object, material: Material, environment: Texture );
+	refreshUniforms( uniforms: object, material: Material, environment: Texture, pixelRatio: number, height: number );
 	refreshUniformsFog( uniforms: object, fog: IFog );
 
 }

+ 12 - 7
src/renderers/webgl/WebGLMaterials.js

@@ -7,10 +7,15 @@ import { BackSide } from "../../constants";
  * i.e. uniforms refresh before material is being rendered
  */
 
-function WebGLMaterials() {
+var _properties;
+
+function WebGLMaterials( properties ) {
+
+	_properties = properties;
+
 }
 
-WebGLMaterials.prototype.refreshUniforms = function ( uniforms, material, environment ) {
+WebGLMaterials.prototype.refreshUniforms = function ( uniforms, material, environment, pixelRatio, height ) {
 
 	if ( material.isMeshBasicMaterial ) {
 
@@ -77,7 +82,7 @@ WebGLMaterials.prototype.refreshUniforms = function ( uniforms, material, enviro
 
 	} else if ( material.isPointsMaterial ) {
 
-		this.refreshUniformsPoints( uniforms, material );
+		this.refreshUniformsPoints( uniforms, material, pixelRatio, height );
 
 	} else if ( material.isSpriteMaterial ) {
 
@@ -143,7 +148,7 @@ WebGLMaterials.prototype.refreshUniformsCommon = function ( uniforms, material,
 		uniforms.reflectivity.value = material.reflectivity;
 		uniforms.refractionRatio.value = material.refractionRatio;
 
-		uniforms.maxMipLevel.value = properties.get( envMap ).__maxMipLevel;
+		uniforms.maxMipLevel.value = _properties.get( envMap ).__maxMipLevel;
 
 	}
 
@@ -280,12 +285,12 @@ WebGLMaterials.prototype.refreshUniformsDash = function ( uniforms, material ) {
 
 };
 
-WebGLMaterials.prototype.refreshUniformsPoints = function ( uniforms, material ) {
+WebGLMaterials.prototype.refreshUniformsPoints = function ( uniforms, material, pixelRatio, height ) {
 
 	uniforms.diffuse.value.copy( material.color );
 	uniforms.opacity.value = material.opacity;
-	uniforms.size.value = material.size * _pixelRatio;
-	uniforms.scale.value = _height * 0.5;
+	uniforms.size.value = material.size * pixelRatio;
+	uniforms.scale.value = height * 0.5;
 
 	if ( material.map ) {