Skip to content
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

Merged
merged 32 commits into from
Dec 15, 2017
Merged

Conversation

jihoonl
Copy link
Member

@jihoonl jihoonl commented Dec 6, 2017

No description provided.

@jihoonl jihoonl changed the title Ffix dependencies. and bump patch version Fix dependencies. and bump patch version Dec 6, 2017
@jihoonl
Copy link
Member Author

jihoonl commented Dec 6, 2017

Well.. three@0.64.0 doesn't exist. The closest version is 0.66.0. Check if it is compatible.

@jihoonl jihoonl changed the title Fix dependencies. and bump patch version Use Three.js version 0.88.0 Dec 8, 2017
@jihoonl jihoonl changed the title Use Three.js version 0.88.0 Update codebase to use Three.js version 0.88.0 Dec 8, 2017
@jihoonl jihoonl changed the title Update codebase to use Three.js version 0.88.0 Update codebase to use Three.js version r88 Dec 8, 2017
@jihoonl
Copy link
Member Author

jihoonl commented Dec 8, 2017

Well.. let's bump the codebase to r88 instead of sticking with old version.

@jihoonl
Copy link
Member Author

jihoonl commented Dec 8, 2017

Hello @viktorku @sevenbitbyte , I have updated codebase to work with three.js r88. Please check if you have a time.

@jihoonl
Copy link
Member Author

jihoonl commented Dec 8, 2017

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,
Copy link
Contributor

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

T045T
T045T previously requested changes Dec 11, 2017
Copy link
Contributor

@T045T T045T left a 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;
Copy link
Contributor

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
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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 );
Copy link
Contributor

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

@@ -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);
Copy link
Contributor

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);
Copy link
Contributor

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 );
Copy link
Contributor

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 );
Copy link
Contributor

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) {
Copy link
Contributor

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:
screen shot 2017-12-11 at 15 04 47

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).

Copy link
Member Author

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.

@jihoonl
Copy link
Member Author

jihoonl commented Dec 11, 2017

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.

@T045T
Copy link
Contributor

T045T commented Dec 12, 2017

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

find . -iname *.dae | xargs sed -i '/up_axis/d'

in the top-level workspace directory.

});
}
else {
target_object.material = target_object.originalMaterial;
Copy link
Contributor

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!

Copy link
Member Author

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.

Copy link
Contributor

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).

Copy link
Member Author

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.

@jihoonl jihoonl changed the title Update codebase to use Three.js version r88 Update codebase to use Three.js version r89 Dec 14, 2017
@jihoonl jihoonl changed the title Update codebase to use Three.js version r89 WIP: Update codebase to use Three.js version r89 Dec 14, 2017
@jihoonl jihoonl changed the title WIP: Update codebase to use Three.js version r89 Update codebase to use Three.js version r88 Dec 14, 2017
@jihoonl
Copy link
Member Author

jihoonl commented Dec 15, 2017

Summary

  • the forked collada loader is in examples/js/ColladaLoader2.js. It includes z_axis hack to avoid rviz issue that ignoring up_axis, and cherry-picked this commit
  • three.js version r88
  • Highlighter logic is fied to compatibly with r88. It still needs some more improvements. This will be fixed with the following PRs.
  • Note that browser doesn't support tif format. This needs to be converted to png format.
#!/bin/bash

for f in $(find -name *.tif); do
  echo "Converting $f"; convert "$f"  "$(dirname "$f")/$(basename "$f" .tif).png";
done

for f in $(find -name *.dae); do
  echo "Replacing $f"; sed -i -- 's/.tif/.png/g' $f
done

* Also it is renamed as ColladaLoader2.js
*/

THREE.ColladaLoader2 = function ( manager ) {
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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>

Copy link
Member Author

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>
Copy link
Contributor

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

Copy link
Member Author

@jihoonl jihoonl Dec 15, 2017

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

@jihoonl jihoonl dismissed T045T’s stale review December 15, 2017 16:14

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.

@jihoonl jihoonl merged commit c7a85b5 into develop Dec 15, 2017
@jihoonl jihoonl deleted the fix_dependencies branch December 15, 2017 16:15
@jihoonl
Copy link
Member Author

jihoonl commented Dec 15, 2017

@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.

@jihoonl jihoonl mentioned this pull request Mar 6, 2018
corot pushed a commit to corot/kobuki that referenced this pull request Mar 13, 2019
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants