-
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
Conversation
Well.. three@0.64.0 doesn't exist. The closest version is 0.66.0. Check if it is compatible. |
Well.. let's bump the codebase to r88 instead of sticking with old version. |
Hello @viktorku @sevenbitbyte , I have updated codebase to work with three.js r88. Please check if you have a time. |
I have confirmed that marker, interactive marker, and urdf demos are working with this change. |
build/ros3d.js
Outdated
@@ -791,8 +790,8 @@ ROS3D.InteractiveMarker.prototype.onServerSetPose = function(event) { | |||
this.position.y = pose.position.y; | |||
this.position.z = pose.position.z; | |||
|
|||
this.quaternion = new THREE.Quaternion(pose.orientation.x, pose.orientation.y, | |||
pose.orientation.z, pose.orientation.w); | |||
this.quaternion.copy(new THREE.Quaternion(pose.orientation.x, pose.orientation.y, |
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.
you could probably use set() here, as you did with the other quaternions further down
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.
Mostly cleanup, but you should fix highlighting :)
(And the one instance of quaternion.copy(new...
where quaternion.set(...
would have been nicer.)
scene.overrideMaterial = null; | ||
else { | ||
if(flag) { | ||
object.currentMaterial = object.material; |
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.
shouldn't this be something like originalMaterial
?
* @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 comment
The reason will be displayed to describe this comment to others. Learn more.
these aren't terribly descriptive names - I'd prefer target_object
and highlight
instead
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented-out old code
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented-out old code
@@ -320,4 +321,5 @@ ROS3D.InteractiveMarker.prototype.dispose = function() { | |||
}); | |||
}; | |||
|
|||
THREE.EventDispatcher.prototype.apply( ROS3D.InteractiveMarker.prototype ); | |||
// THREE.EventDispatcher.prototype.apply( ROS3D.InteractiveMarker.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
src/models/Arrow.js
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented-out old code
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented-out old code
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented-out old code
@@ -501,4 +503,5 @@ ROS3D.OrbitControls.prototype.update = function() { | |||
} | |||
}; | |||
|
|||
THREE.EventDispatcher.prototype.apply( ROS3D.OrbitControls.prototype ); | |||
// THREE.EventDispatcher.prototype.apply( ROS3D.OrbitControls.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
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 comment
The 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 demo (source) uses an OutlinePass
to draw outlines, which looks really nice but is slightly more involved (here's a StackOverflow question with some very concise example code).
This one (source) simply gives the material a bit of (red) emissive
lighting to achieve about the same effect we were using before (note they use currentHex
to save the old value – I'd prefer to use originalHex
).
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.
The second example is the one I referenced to update the highlighting. Thanks for the review. I will take a look again.
Hello @DLu, @jstnhuang, and @rctoris, I am trying to update the codebase to the latest three.js(r88) and found out that fetch_description isn't loadable due to this error in three.js. Could you help me to fix this issue? I have confirmed that I can visualize our robot, turtlebot2, and turtlebot3 with no problem. |
I went ahead and sent some quick PRs to those repos - but of course, we should still be compatible with RViz' behavior. For future reference, the command I used to automatically remove all up_axis tags was
in the top-level workspace directory. |
}); | ||
} | ||
else { | ||
target_object.material = target_object.originalMaterial; |
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.
One more thing: We should probably be defensive here and check for the existence of originalMaterial
.
If highlightObject(false)
is ever called on an object where highlight(true)
has not been called, we'd be in trouble!
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.
Yeah, I agree. I would improve this logic with another PR.
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.
Please don't. Merging this PR as-is would introduce a serious bug (see the screen shot I attached to the issue), and fixing it would be trivial (just give the existing material an emissive component instead of switching the material completely).
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.
It is not as easy as you described and it doesn't introduce serious bug while I was testing. This PR is already pretty large and getting longer and I am running out of time. Since it is already a big change which covers most of use cases. I will move on and start to patch small stuffs. I don't see any serious reason that this should not go into the develop branch.
Summary
|
examples/js/ColladaLoader2.js
Outdated
* Also it is renamed as ColladaLoader2.js | ||
*/ | ||
|
||
THREE.ColladaLoader2 = function ( manager ) { |
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.
Why did you name it ColladaLoader2? It's ColladaLoader, and we actually want it to replace THREE.ColladaLoader completely, don't we?
On a higher level, do we even still need to support two loaders? Looks like what was once ColladaLoader2 has replaced the original ColladaLoader completely by now anyway.
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.
Why do we need to replace it completely? It needs to be explicitly kept separate so that it indicates it is a modified version just for backward compatibility. Users should know that they use the modified version because their collada isn't following the standard.
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.
I disagree.
My opinion is that users shouldn't have to care about what loader is used at all – de facto, we're not dealing with the Collada standard, but instead with the one set by RViz. From that perspective, all models that work in RViz are correct and we should display them the same way RViz does.
Either way, renaming the module to ColladaLoader2 is confusing because that's not what it is. It has the exact same interface as THREE.ColladaLoader
.
Because of that, we could actually remove all the loader
options from ros3djs
and instead just use a different script tag to load either the official ColladaLoader version or this patched one:
<!-- Uncomment this whenever RViz starts handling up_axis
<script src="http://static.robotwebtools.org/threejs/current/ColladaLoader.js"></script>
-->
<!-- Remove this when RViz starts handling up_axis -->
<script src="http://static.robotwebtools.org/fixes/ColladaLoader.js"></script>
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.
Ok. reasonable. Also, I removed all loader option because it doesn't seem necessary.
<script src="http://cdn.robotwebtools.org/threejs/current/three.js"></script> | ||
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script> | ||
<script src="http://cdn.robotwebtools.org/roslibjs/current/roslib.js"></script> | ||
<script src="http://static.robotwebtools.org/threejs/current/three.js"></script> |
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.
these changes should really go in a separate PR - the CDN has already migrated, and we should reflect that in our code ASAP
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.
It has been already requested to @rctoris. And it doesn't matter as long as it doesn't go in to master branch. It is a development branch. Of course, it will only go into master when it gets released after proper tests.
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.
I'm not sure I understand what you're saying. The new URLs (with static in them) already work.
Why don't we make a separate pull request to update them in examples and Readme files right now, while we're still discussing the move to ThreeJS r88?
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.
What I am saying is that our stable branch is master
where we should keep the working code. I am moving on. We need to create a PR to fix some links example anyway when CDN is updated.
Small details will be addressed with latter PRs. This PR has reached enough level to be merged in to development branch for this such huge structural change.
@T045T sorry Nils. I had to proceed this PR because it was a definitely needed movement. Otherwise, this PR would hang for another year considering the recent year's activities in this repo. |
RViz doesn't respect it anyway ( ros-visualization/rviz#1045 ), but current versions of three.js' ColladaLoader (used in the RobotWebTools, see RobotWebTools/ros3djs#202 ) do! (Since RViz doesn't respect the tag, this does not break the model)
No description provided.