From 84deae15c8944717fe5d874f1246c4d2959303c8 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Wed, 16 Sep 2020 23:21:06 -0700 Subject: [PATCH 1/4] Add threshold option to Line2 raycast --- examples/jsm/lines/LineSegments2.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/jsm/lines/LineSegments2.js b/examples/jsm/lines/LineSegments2.js index 85d2f9ade57500..6859237c0f1a64 100644 --- a/examples/jsm/lines/LineSegments2.js +++ b/examples/jsm/lines/LineSegments2.js @@ -81,6 +81,13 @@ LineSegments2.prototype = Object.assign( Object.create( Mesh.prototype ), { } + var threshold = 0; + if ( 'Line2' in raycaster.params ) { + + threshold = raycaster.params.Lines2.threshold || 0.0 + + } + var ray = raycaster.ray; var camera = raycaster.camera; var projectionMatrix = camera.projectionMatrix; @@ -88,7 +95,7 @@ LineSegments2.prototype = Object.assign( Object.create( Mesh.prototype ), { var geometry = this.geometry; var material = this.material; var resolution = material.resolution; - var lineWidth = material.linewidth; + var lineWidth = material.linewidth + threshold; var instanceStart = geometry.attributes.instanceStart; var instanceEnd = geometry.attributes.instanceEnd; From d65c123dcd969a2f8c717eed1e5c64f0cc482ab0 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Thu, 17 Sep 2020 12:37:54 -0700 Subject: [PATCH 2/4] update js --- examples/js/lines/LineSegments2.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/js/lines/LineSegments2.js b/examples/js/lines/LineSegments2.js index 476fd1f5933022..1a4e5679d8ddcf 100644 --- a/examples/js/lines/LineSegments2.js +++ b/examples/js/lines/LineSegments2.js @@ -70,6 +70,13 @@ THREE.LineSegments2.prototype = Object.assign( Object.create( THREE.Mesh.prototy } + var threshold = 0; + if ( 'Line2' in raycaster.params ) { + + threshold = raycaster.params.Line2.threshold || 0.0; + + } + var ray = raycaster.ray; var camera = raycaster.camera; var projectionMatrix = camera.projectionMatrix; @@ -77,7 +84,7 @@ THREE.LineSegments2.prototype = Object.assign( Object.create( THREE.Mesh.prototy var geometry = this.geometry; var material = this.material; var resolution = material.resolution; - var lineWidth = material.linewidth; + var lineWidth = material.linewidth + threshold; var instanceStart = geometry.attributes.instanceStart; var instanceEnd = geometry.attributes.instanceEnd; From 6134b59edbfcd84957745152196c0145a3060893 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Thu, 17 Sep 2020 12:38:37 -0700 Subject: [PATCH 3/4] modularize --- examples/jsm/lines/LineSegments2.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/jsm/lines/LineSegments2.js b/examples/jsm/lines/LineSegments2.js index 6859237c0f1a64..991d6bd73cff8e 100644 --- a/examples/jsm/lines/LineSegments2.js +++ b/examples/jsm/lines/LineSegments2.js @@ -83,11 +83,11 @@ LineSegments2.prototype = Object.assign( Object.create( Mesh.prototype ), { var threshold = 0; if ( 'Line2' in raycaster.params ) { - - threshold = raycaster.params.Lines2.threshold || 0.0 - + + threshold = raycaster.params.Line2.threshold || 0.0; + } - + var ray = raycaster.ray; var camera = raycaster.camera; var projectionMatrix = camera.projectionMatrix; From 706a375a06e963e32b9ad86af405a5170514d3ae Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Fri, 18 Sep 2020 13:05:48 -0700 Subject: [PATCH 4/4] Change conditon style --- examples/js/lines/LineSegments2.js | 7 +------ examples/jsm/lines/LineSegments2.js | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/examples/js/lines/LineSegments2.js b/examples/js/lines/LineSegments2.js index 1a4e5679d8ddcf..8f61f0ff7c9244 100644 --- a/examples/js/lines/LineSegments2.js +++ b/examples/js/lines/LineSegments2.js @@ -70,12 +70,7 @@ THREE.LineSegments2.prototype = Object.assign( Object.create( THREE.Mesh.prototy } - var threshold = 0; - if ( 'Line2' in raycaster.params ) { - - threshold = raycaster.params.Line2.threshold || 0.0; - - } + var threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0; var ray = raycaster.ray; var camera = raycaster.camera; diff --git a/examples/jsm/lines/LineSegments2.js b/examples/jsm/lines/LineSegments2.js index 991d6bd73cff8e..64e56b94149ab9 100644 --- a/examples/jsm/lines/LineSegments2.js +++ b/examples/jsm/lines/LineSegments2.js @@ -81,12 +81,7 @@ LineSegments2.prototype = Object.assign( Object.create( Mesh.prototype ), { } - var threshold = 0; - if ( 'Line2' in raycaster.params ) { - - threshold = raycaster.params.Line2.threshold || 0.0; - - } + var threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0; var ray = raycaster.ray; var camera = raycaster.camera;