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 Three from r89 to r123 #670

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/continuousmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />

<script src="https://cdn.jsdelivr.net/npm/three@0.89.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.123.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/eventemitter2.js"></script>
<script src="https://cdn.jsdelivr.net/npm/roslib@1/build/roslib.js"></script>
<script src="../build/ros3d.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/depthcloud.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />

<script src="https://cdn.jsdelivr.net/npm/three@0.89.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.123.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/eventemitter2.js"></script>
<script src="https://cdn.jsdelivr.net/npm/roslib@1/build/roslib.js"></script>
<script src="../build/ros3d.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/interactivemarkers.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />

<script src="https://cdn.jsdelivr.net/npm/three@0.89.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.123.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/eventemitter2.js"></script>
<script src="https://cdn.jsdelivr.net/npm/roslib@1/build/roslib.js"></script>
<script src="../build/ros3d.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/kitti.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />

<script src="https://cdn.jsdelivr.net/npm/three@0.89.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.123.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/eventemitter2.js"></script>
<script src="https://cdn.jsdelivr.net/npm/roslib@1/build/roslib.js"></script>
<script src="../build/ros3d.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />

<script src="https://cdn.jsdelivr.net/npm/three@0.89.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.123.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/eventemitter2.js"></script>
<script src="https://cdn.jsdelivr.net/npm/roslib@1/build/roslib.js"></script>
<script src="../build/ros3d.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/markers.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />

<script src="https://cdn.jsdelivr.net/npm/three@0.89.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.123.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/eventemitter2.js"></script>
<script src="https://cdn.jsdelivr.net/npm/roslib@1/build/roslib.js"></script>
<script src="../build/ros3d.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/navsatfix.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />

<script src="https://cdn.jsdelivr.net/npm/three@0.89.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.123.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/eventemitter2.js"></script>
<script src="https://cdn.jsdelivr.net/npm/roslib@1/build/roslib.js"></script>
<script src="../build/ros3d.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/octree.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />

<script src="https://cdn.jsdelivr.net/npm/three@0.89.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.123.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/eventemitter2.js"></script>
<script src="https://cdn.jsdelivr.net/npm/roslib@1/build/roslib.js"></script>
<script src="../build/ros3d.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/pointcloud2.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />

<script src="https://cdn.jsdelivr.net/npm/three@0.89.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.123.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/eventemitter2.js"></script>
<script src="https://cdn.jsdelivr.net/npm/roslib@1/build/roslib.js"></script>
<script src="../build/ros3d.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/urdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />

<script src="https://cdn.jsdelivr.net/npm/three@0.89.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.123.0/build/three.min.js"></script>
<!-- <script src="https://static.robotwebtools.org/threejs/current/ColladaLoader.js"></script> --><!-- CDN is gone -->
<!-- <script src="https://static.robotwebtools.org/threejs/current/STLLoader.js"></script> --><!-- CDN is gone -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/eventemitter2.js"></script>
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"eventemitter2": "^6.4.0",
"roslib": "^1.0.0",
"three": "^0.89.0"
"three": "~0.120.0"
},
"devDependencies": {
"@rollup/plugin-buble": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/interactivemarkers/InteractiveMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ ROS3D.InteractiveMarker.prototype.rotateAxis = function(control, origOrientation

// rotates from world to plane coords
var orientationWorld = this.dragStart.orientationWorld.clone().multiply(orientation);
var orientationWorldInv = orientationWorld.clone().inverse();
var orientationWorldInv = orientationWorld.clone().invert();

// rotate original and current intersection into local coords
intersection.sub(rotOrigin);
Expand Down
6 changes: 3 additions & 3 deletions src/interactivemarkers/InteractiveMarkerControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ ROS3D.InteractiveMarkerControl = function(options) {
var posInv = this.parent.position.clone().multiplyScalar(-1);
switch (message.orientation_mode) {
case ROS3D.INTERACTIVE_MARKER_INHERIT:
rotInv = this.parent.quaternion.clone().inverse();
rotInv = this.parent.quaternion.clone().invert();
break;
case ROS3D.INTERACTIVE_MARKER_FIXED:
break;
Expand Down Expand Up @@ -231,7 +231,7 @@ ROS3D.InteractiveMarkerControl.prototype.updateMatrixWorld = function (force) {
that.currentControlOri.normalize();
break;
case ROS3D.INTERACTIVE_MARKER_FIXED:
that.quaternion.copy(that.parent.quaternion.clone().inverse());
that.quaternion.copy(that.parent.quaternion.clone().invert());
that.updateMatrix();
that.matrixWorldNeedsUpdate = true;
ROS3D.InteractiveMarkerControl.prototype.updateMatrixWorld.call(that, force);
Expand All @@ -247,7 +247,7 @@ ROS3D.InteractiveMarkerControl.prototype.updateMatrixWorld = function (force) {
ros2Gl.makeRotationFromEuler(rv);

var worldToLocal = new THREE.Matrix4();
worldToLocal.getInverse(that.parent.matrixWorld);
worldToLocal.copy(that.parent.matrixWorld).invert();

cameraRot.multiplyMatrices(cameraRot, ros2Gl);
cameraRot.multiplyMatrices(worldToLocal, cameraRot);
Expand Down
4 changes: 2 additions & 2 deletions src/models/Arrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ ROS3D.Arrow = function(options) {
12, 1);
var m = new THREE.Matrix4();
m.setPosition(new THREE.Vector3(0, shaftLength * 0.5, 0));
geometry.applyMatrix(m);
geometry.applyMatrix4(m);

// create the head
var coneGeometry = new THREE.CylinderGeometry(0, headDiameter * 0.5, headLength, 12, 1);
m.setPosition(new THREE.Vector3(0, shaftLength + (headLength * 0.5), 0));
coneGeometry.applyMatrix(m);
coneGeometry.applyMatrix4(m);

// put the arrow together
geometry.merge(coneGeometry);
Expand Down
4 changes: 2 additions & 2 deletions src/models/TriangleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ ROS3D.TriangleList = function(options) {
}
geometry.faces.push(faceVert);
}
material.vertexColors = THREE.VertexColors;
material.vertexColors = true;
} else if (colors.length === vertices.length / 3) {
// use per-triangle color
for (i = 0; i < vertices.length; i += 3) {
var faceTri = new THREE.Face3(i, i + 1, i + 2);
faceTri.color.setRGB(colors[i / 3].r, colors[i / 3].g, colors[i / 3].b);
geometry.faces.push(faceTri);
}
material.vertexColors = THREE.FaceColors;
material.vertexColors = true;
} else {
// use marker color
for (i = 0; i < vertices.length; i += 3) {
Expand Down
8 changes: 4 additions & 4 deletions src/navigation/OcTreeBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,14 @@ ROS3D.OcTreeBase.prototype.buildGeometry = function () {
const material = new THREE.MeshBasicMaterial({
color: 'white',
flatShading: true,
vertexColors: THREE.VertexColors,
vertexColors: true,
transparent: this.opacity < 1.0,
opacity: this.opacity
});

geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(vertices), 3));
geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(normals), 3));
geometry.addAttribute('color', new THREE.BufferAttribute(new Float32Array(colors), 3));
geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(vertices), 3));
geometry.setAttribute('normal', new THREE.BufferAttribute(new Float32Array(normals), 3));
geometry.setAttribute('color', new THREE.BufferAttribute(new Float32Array(colors), 3));

geometry.setIndex(indices);

Expand Down
2 changes: 1 addition & 1 deletion src/navigation/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ ROS3D.Path.prototype.processMessage = function(message){
lineGeometry.vertices.push(v3);
}

lineGeometry.computeLineDistances();
var lineMaterial = new THREE.LineBasicMaterial( { color: this.color } );
var line = new THREE.Line( lineGeometry, lineMaterial );
// line.computeLineDistances(); // Only needed for LineDashedMaterial

this.sn = new ROS3D.SceneNode({
frameID : message.header.frame_id,
Expand Down
4 changes: 3 additions & 1 deletion src/navigation/Polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ ROS3D.Polygon.prototype.processMessage = function(message){
v3 = new THREE.Vector3( message.polygon.points[0].x, message.polygon.points[0].y,
message.polygon.points[0].z);
lineGeometry.vertices.push(v3);
lineGeometry.computeLineDistances();

var lineMaterial = new THREE.LineBasicMaterial( { color: this.color } );
var line = new THREE.Line( lineGeometry, lineMaterial );
line.computeLineDistances();
// line.computeLineDistances(); // Only needed for LineDashedMaterial

this.sn = new ROS3D.SceneNode({
frameID : message.header.frame_id,
Expand Down
3 changes: 1 addition & 2 deletions src/navigation/PoseArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,9 @@ ROS3D.PoseArray.prototype.processMessage = function(message){
lineGeometry.vertices.push(side1.add(v3));
lineGeometry.vertices.push(side2.add(v3));
lineGeometry.vertices.push(tip);

lineGeometry.computeLineDistances();
var lineMaterial = new THREE.LineBasicMaterial( { color: this.color } );
line = new THREE.Line( lineGeometry, lineMaterial );
// line.computeLineDistances(); // Only needed for LineDashedMaterial

group.add(line);
}
Expand Down
2 changes: 1 addition & 1 deletion src/sensors/NavSatFix.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ROS3D.NavSatFix = function(options) {

this.geom = new THREE.BufferGeometry();
this.vertices = new THREE.BufferAttribute(new Float32Array( 6 * this.keep ), 3 );
this.geom.addAttribute( 'position', this.vertices);
this.geom.setAttribute('position', this.vertices);
this.material = material.isMaterial ? material : new THREE.LineBasicMaterial( material );
this.line = new THREE.Line( this.geom, this.material );
this.rootObject.add(this.object3d);
Expand Down
6 changes: 3 additions & 3 deletions src/sensors/Points.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ROS3D.Points.prototype.setup = function(frame, point_step, fields)
this.geom = new THREE.BufferGeometry();

this.positions = new THREE.BufferAttribute( new Float32Array( this.max_pts * 3), 3, false );
this.geom.addAttribute( 'position', this.positions.setDynamic(true) );
this.geom.setAttribute('position', this.positions.setDynamic(true) );

if(!this.colorsrc && this.fields.rgb) {
this.colorsrc = 'rgb';
Expand All @@ -66,7 +66,7 @@ ROS3D.Points.prototype.setup = function(frame, point_step, fields)
var field = this.fields[this.colorsrc];
if (field) {
this.colors = new THREE.BufferAttribute( new Float32Array( this.max_pts * 3), 3, false );
this.geom.addAttribute( 'color', this.colors.setDynamic(true) );
this.geom.setAttribute('color', this.colors.setDynamic(true) );
var offset = field.offset;
this.getColor = [
function(dv,base,le){return dv.getInt8(base+offset,le);},
Expand All @@ -86,7 +86,7 @@ ROS3D.Points.prototype.setup = function(frame, point_step, fields)

if(!this.material.isMaterial) { // if it is an option, apply defaults and pass it to a PointsMaterial
if(this.colors && this.material.vertexColors === undefined) {
this.material.vertexColors = THREE.VertexColors;
this.material.vertexColors = true;
}
this.material = new THREE.PointsMaterial(this.material);
}
Expand Down
2 changes: 2 additions & 0 deletions src/visualization/SceneNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ROS3D.SceneNode = function(options) {

// Do not render this object until we receive a TF update
this.visible = false;
this.layers.disable(0);

// add the model
this.add(object);
Expand All @@ -43,6 +44,7 @@ ROS3D.SceneNode = function(options) {
// update the world
this.updatePose(poseTransformed);
this.visible = true;
this.layers.enable(0);
};

// listen for TF updates
Expand Down
8 changes: 8 additions & 0 deletions src/visualization/interaction/Highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ ROS3D.Highlighter.prototype.makeEverythingInvisible = function (scene) {
|| currentObject instanceof THREE.Sprite ) {
currentObject.previousVisibility = currentObject.visible;
currentObject.visible = false;
currentObject.layers.disable(0); // Invisible
}
});
};
Expand All @@ -113,13 +114,15 @@ ROS3D.Highlighter.prototype.makeHighlightedVisible = function (scene) {
if ( currentObject instanceof THREE.Mesh || currentObject instanceof THREE.Line
|| currentObject instanceof THREE.Sprite ) {
currentObject.visible = true;
currentObject.layers.enable(0); // Visible
}
};

for (var uuid in this.hoverObjs) {
var selectedObject = this.hoverObjs[uuid];
// Make each selected object and all of its children visible
selectedObject.visible = true;
selectedObject.layers.enable(0); // Visible
selectedObject.traverse(makeVisible);
}
};
Expand All @@ -134,6 +137,11 @@ ROS3D.Highlighter.prototype.restoreVisibility = function (scene) {
scene.traverse(function(currentObject) {
if (currentObject.hasOwnProperty('previousVisibility')) {
currentObject.visible = currentObject.previousVisibility;
if (currentObject.visible) {
currentObject.layers.enable(0); // Visible
} else {
currentObject.layers.disable(0); // Invisible
}
}
}.bind(this));
};
2 changes: 1 addition & 1 deletion src/visualization/interaction/MouseHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ROS3D.MouseHandler.prototype.processDomEvent = function(domEvent) {
var mousePos = new THREE.Vector2(deviceX, deviceY);

var mouseRaycaster = new THREE.Raycaster();
mouseRaycaster.linePrecision = 0.001;
mouseRaycaster.params.Line.threshold = 0.001;
mouseRaycaster.setFromCamera(mousePos, this.camera);
var mouseRay = mouseRaycaster.ray;

Expand Down
3 changes: 3 additions & 0 deletions src/visualization/interaction/OrbitControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ ROS3D.OrbitControls = function(options) {
scene.add(this.axes);
this.axes.traverse(function(obj) {
obj.visible = false;
obj.layers.disable(0); // Invisible
});
}

Expand Down Expand Up @@ -376,13 +377,15 @@ ROS3D.OrbitControls.prototype.showAxes = function() {

this.axes.traverse(function(obj) {
obj.visible = true;
obj.layers.enable(0); // Visible
});
if (this.hideTimeout) {
clearTimeout(this.hideTimeout);
}
this.hideTimeout = setTimeout(function() {
that.axes.traverse(function(obj) {
obj.visible = false;
obj.layers.disable(0); // Invisible
});
that.hideTimeout = false;
}, 1000);
Expand Down