Skip to content

Commit

Permalink
Remove need for assigning line2 material resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed May 11, 2024
1 parent 4ec57f5 commit 5c960c8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
11 changes: 10 additions & 1 deletion examples/jsm/lines/LineMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import {
ShaderMaterial,
UniformsLib,
UniformsUtils,
Vector2
Vector2,
Vector4,
} from 'three';

const _viewport = new Vector4();

UniformsLib.line = {

Expand Down Expand Up @@ -440,6 +442,13 @@ class LineMaterial extends ShaderMaterial {

}

onBeforeRender( renderer ) {

renderer.getCurrentViewport( _viewport );
this.uniforms.resolution.value.set( _viewport.z, _viewport.w );

}

get color() {

return this.uniforms.diffuse.value;
Expand Down
3 changes: 0 additions & 3 deletions examples/webgl_lines_fat.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@

controls.update();

// renderer will set this eventually
matLine.resolution.set( window.innerWidth, window.innerHeight ); // resolution of the viewport

gpuPanel.startQuery();
renderer.render( scene, camera );
gpuPanel.endQuery();
Expand Down
4 changes: 0 additions & 4 deletions examples/webgl_lines_fat_raycasting.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,6 @@

renderer.setSize( window.innerWidth, window.innerHeight );

// renderer will set this eventually
matLine.resolution.set( window.innerWidth, window.innerHeight );
matThresholdLine.resolution.set( window.innerWidth, window.innerHeight );

}

function onPointerMove( event ) {
Expand Down
6 changes: 0 additions & 6 deletions examples/webgl_lines_fat_wireframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@

renderer.setViewport( 0, 0, window.innerWidth, window.innerHeight );

// renderer will set this eventually
matLine.resolution.set( window.innerWidth, window.innerHeight ); // resolution of the viewport

renderer.render( scene, camera );

// inset scene
Expand All @@ -156,9 +153,6 @@
camera2.position.copy( camera.position );
camera2.quaternion.copy( camera.quaternion );

// renderer will set this eventually
matLine.resolution.set( insetWidth, insetHeight ); // resolution of the inset viewport

renderer.render( scene, camera2 );

renderer.setScissorTest( false );
Expand Down

0 comments on commit 5c960c8

Please sign in to comment.