-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update codebase to use Three.js version r88 #202
Changes from 16 commits
8e09982
03bf58c
fde6a14
e3cf789
ff8698d
26f0cd8
b261c28
2c1270a
7c78133
7a35e01
58bb737
d35a129
5adaece
5b6c1d6
49de6cf
c4d1b86
b6341f2
e5d99c2
87df418
1439efb
44f5e34
400c2e8
c727ac9
6d4e87f
7e0c1a7
3d71d5d
1d082a4
49b82d3
587c9ca
3a48e09
0ca58f6
2f93d40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,4 +178,5 @@ ROS3D.InteractiveMarkerMenu.prototype.hide = function(event) { | |
document.body.removeChild(this.menuDomElem); | ||
}; | ||
|
||
THREE.EventDispatcher.prototype.apply( ROS3D.InteractiveMarkerMenu.prototype ); | ||
// THREE.EventDispatcher.prototype.apply( ROS3D.InteractiveMarkerMenu.prototype ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented-out old code |
||
Object.assign(ROS3D.InteractiveMarkerMenu.prototype, THREE.EventDispatcher.prototype); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,11 +41,12 @@ ROS3D.Arrow = function(options) { | |
coneGeometry.applyMatrix(m); | ||
|
||
// put the arrow together | ||
THREE.GeometryUtils.merge(geometry, coneGeometry); | ||
// DEPRECATED: THREE.GeometryUtils.merge(geometry, coneGeometry); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented-out old code |
||
geometry.merge(coneGeometry); | ||
|
||
THREE.Mesh.call(this, geometry, material); | ||
|
||
this.position = origin; | ||
this.position.copy(origin); | ||
this.setDirection(direction); | ||
}; | ||
ROS3D.Arrow.prototype.__proto__ = THREE.Mesh.prototype; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,8 @@ ROS3D.Highlighter = function(options) { | |
* @param event - the event that contains the target of the mouseover | ||
*/ | ||
ROS3D.Highlighter.prototype.onMouseOver = function(event) { | ||
this.hoverObjs.push(event.currentTarget); | ||
// this.hoverObjs.push(event.currentTarget); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented-out old code |
||
this.highlightObject(event.currentTarget, true); | ||
}; | ||
|
||
/** | ||
|
@@ -35,62 +36,43 @@ ROS3D.Highlighter.prototype.onMouseOver = function(event) { | |
* @param event - the event that contains the target of the mouseout | ||
*/ | ||
ROS3D.Highlighter.prototype.onMouseOut = function(event) { | ||
this.hoverObjs.splice(this.hoverObjs.indexOf(event.currentTarget), 1); | ||
// this.hoverObjs.splice(this.hoverObjs.indexOf(event.currentTarget), 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented-out old code |
||
this.highlightObject(event.currentTarget, false); | ||
}; | ||
|
||
|
||
/** | ||
* Add all corresponding webgl objects in the given scene and add them to the given render list. | ||
* Highlight and unhighlight the given object | ||
* | ||
* @param scene - the scene to check for webgl objects | ||
* @param objects - the objects list to check | ||
* @param renderList - the list to add to | ||
* @param object - the target object to (un)highlight | ||
* @param flag - whether to highlight or unhighlight | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these aren't terribly descriptive names - I'd prefer |
||
*/ | ||
ROS3D.Highlighter.prototype.getWebglObjects = function(scene, objects, renderList) { | ||
var objlist = scene.__webglObjects; | ||
// get corresponding webgl objects | ||
for ( var c = 0; c < objects.length; c++) { | ||
if (objects[c]) { | ||
for ( var o = objlist.length - 1; o >= 0; o--) { | ||
if (objlist[o].object === objects[c]) { | ||
renderList.push(objlist[o]); | ||
break; | ||
} | ||
ROS3D.Highlighter.prototype.highlightObject = function (object, flag) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't actually highlight correctly, but instead replaces the highlighted objects' materials with a half-transparent white material: The old implementation rendered that material over the already-rendered scene to achieve the highlighted look. Looks like current Three.js has a couple ways to make highlighting happen: This one (source) simply gives the material a bit of (red) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The second example is the one I referenced to update the highlighting. Thanks for the review. I will take a look again. |
||
if(object.material === undefined) { | ||
if(object.children === undefined) { | ||
return; | ||
} | ||
else { | ||
for(var c = 0 ; c < object.children.length; c++) { | ||
this.highlightObject(object.children[c], flag); | ||
} | ||
// recurse into children | ||
this.getWebglObjects(scene, objects[c].children, renderList); | ||
} | ||
} | ||
}; | ||
|
||
/** | ||
* Render highlighted objects in the scene. | ||
* | ||
* @param renderer - the renderer to use | ||
* @param scene - the scene to use | ||
* @param camera - the camera to use | ||
*/ | ||
ROS3D.Highlighter.prototype.renderHighlight = function(renderer, scene, camera) { | ||
// get webgl objects | ||
var renderList = []; | ||
this.getWebglObjects(scene, this.hoverObjs, renderList); | ||
|
||
// define highlight material | ||
scene.overrideMaterial = new THREE.MeshBasicMaterial({ | ||
fog : false, | ||
opacity : 0.5, | ||
depthTest : true, | ||
depthWrite : false, | ||
polygonOffset : true, | ||
polygonOffsetUnits : -1, | ||
side : THREE.DoubleSide | ||
}); | ||
|
||
// swap render lists, render, undo | ||
var oldWebglObjects = scene.__webglObjects; | ||
scene.__webglObjects = renderList; | ||
|
||
renderer.render(scene, camera); | ||
|
||
scene.__webglObjects = oldWebglObjects; | ||
scene.overrideMaterial = null; | ||
else { | ||
if(flag) { | ||
object.currentMaterial = object.material; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this be something like |
||
object.material = new THREE.MeshBasicMaterial({ | ||
fog : false, | ||
opacity : 0.5, | ||
depthTest : true, | ||
depthWrite : false, | ||
polygonOffset : true, | ||
polygonOffsetUnits : -1, | ||
side : THREE.DoubleSide | ||
}); | ||
} | ||
else { | ||
object.material = object.currentMaterial; | ||
} | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ ROS3D.MouseHandler = function(options) { | |
this.fallbackTarget = options.fallbackTarget; | ||
this.lastTarget = this.fallbackTarget; | ||
this.dragging = false; | ||
this.projector = new THREE.Projector(); | ||
|
||
// listen to DOM events | ||
var eventNames = [ 'contextmenu', 'click', 'dblclick', 'mouseout', 'mousedown', 'mouseup', | ||
|
@@ -69,7 +68,8 @@ ROS3D.MouseHandler.prototype.processDomEvent = function(domEvent) { | |
var deviceX = left / target.clientWidth * 2 - 1; | ||
var deviceY = -top / target.clientHeight * 2 + 1; | ||
var vector = new THREE.Vector3(deviceX, deviceY, 0.5); | ||
this.projector.unprojectVector(vector, this.camera); | ||
// DEPRECATED: this.projector.unprojectVector(vector, this.camera); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented-out old code |
||
vector.unproject(this.camera); | ||
// use the THREE raycaster | ||
var mouseRaycaster = new THREE.Raycaster(this.camera.position.clone(), vector.sub( | ||
this.camera.position).normalize()); | ||
|
@@ -221,4 +221,5 @@ ROS3D.MouseHandler.prototype.notify = function(target, type, event3D) { | |
return 1; // Event Failed | ||
}; | ||
|
||
THREE.EventDispatcher.prototype.apply( ROS3D.MouseHandler.prototype ); | ||
// THREE.EventDispatcher.prototype.apply( ROS3D.MouseHandler.prototype ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented-out old code |
||
Object.assign(ROS3D.MouseHandler.prototype, THREE.EventDispatcher.prototype); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented-out old code