Skip to content

Commit

Permalink
#356 Adding enableHelpTooltips to hide by default the tooltips shown …
Browse files Browse the repository at this point in the history
…when dragging, rotating and measuring
  • Loading branch information
jscastro76 committed Jun 3, 2022
1 parent bb18361 commit 759046f
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 16 deletions.
1 change: 1 addition & 0 deletions ThreeboxSolution.njsproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
<Content Include="LICENSE.txt" />
<Content Include="package.json" />
<Content Include="README.md" />
<Content Include="server.stop.js" />
<Content Include="src\objects\effects\BuildingShadows.js">
<SubType>Code</SubType>
</Content>
Expand Down
10 changes: 6 additions & 4 deletions dist/threebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ Threebox.prototype = {
this.enableRotatingObjects = this.options.enableRotatingObjects || false;
this.enableTooltips = this.options.enableTooltips || false;
this.multiLayer = this.options.multiLayer || false;
this.enableHelpTooltips = this.options.enableHelpTooltips || false;

this.map.on('style.load', function () {
this.tb.zoomLayers = [];
Expand Down Expand Up @@ -610,7 +611,7 @@ Threebox.prototype = {
let rotation = { x: 0, y: 0, z: (Math.round(rotationDiff[2] + (~~((current.x - start.x) / this.tb.rotationStep) % 360 * this.tb.rotationStep) % 360)) };
//now rotate the model depending the axis
this.draggedObject.setRotation(rotation);
this.draggedObject.addHelp("rot: " + rotation.z + "&#176;");
if (map.tb.enableHelpTooltips) this.draggedObject.addHelp("rot: " + rotation.z + "&#176;");
//this.draggedObject.setRotationAxis(rotation);
return;
}
Expand All @@ -626,7 +627,7 @@ Threebox.prototype = {
let coords = e.lngLat;
let options = [Number((coords.lng + lngDiff).toFixed(this.tb.gridStep)), Number((coords.lat + latDiff).toFixed(this.tb.gridStep)), this.draggedObject.modelHeight];
this.draggedObject.setCoords(options);
this.draggedObject.addHelp("lng: " + options[0] + "&#176;, lat: " + options[1] + "&#176;");
if (map.tb.enableHelpTooltips) this.draggedObject.addHelp("lng: " + options[0] + "&#176;, lat: " + options[1] + "&#176;");
return;
}

Expand All @@ -640,7 +641,7 @@ Threebox.prototype = {
let now = (e.point.y * this.tb.altitudeStep);
let options = [this.draggedObject.coordinates[0], this.draggedObject.coordinates[1], Number((- now - altDiff).toFixed(this.tb.gridStep))];
this.draggedObject.setCoords(options);
this.draggedObject.addHelp("alt: " + options[2] + "m");
if (map.tb.enableHelpTooltips) this.draggedObject.addHelp("alt: " + options[2] + "m");
return;
}

Expand Down Expand Up @@ -789,7 +790,7 @@ Threebox.prototype = {
sf = dc(sf, 7);
}

obj.addHelp("size(m): " + dc((s.x / sf), 3) + " W, " + dc((s.y / sf), 3) + " L, " + dc((s.z / sf), 3) + " H");
if (map.tb.enableHelpTooltips) obj.addHelp("size(m): " + dc((s.x / sf), 3) + " W, " + dc((s.y / sf), 3) + " L, " + dc((s.z / sf), 3) + " H");
this.repaint = true;
}
else {
Expand Down Expand Up @@ -1458,6 +1459,7 @@ var defaultOptions = {
enableDraggingObjects: false,
enableRotatingObjects: false,
enableTooltips: false,
enableHelpTooltips: false,
multiLayer: false,
orthographic: false,
fov: ThreeboxConstants.FOV_DEGREES,
Expand Down
2 changes: 1 addition & 1 deletion dist/threebox.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/Threebox.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ Sets up a Threebox scene using an [Mapbox map](https://docs.mapbox.com/mapbox-gl
| `enableSelectingObjects` | no | false | boolean | Enables the Mouseover and Selection of 3D objects. This will fire the event [`SelectedChange`](#SelectedChange). This value will set the `options.bbx` value of the objects created.|
| `enableDraggingObjects` | no | false | boolean | Enables to the option to Drag a 3D object. This will fire the event [`ObjectDragged`](#ObjectDragged) where `draggedAction = 'translate'` or `draggedAction = 'altitude'` |
| `enableRotatingObjects` | no | false | boolean | Enables to the option to Drag a 3D object. This will fire the event [`ObjectDragged`](#ObjectDragged) where `draggedAction = 'rotate'`|
| `enableToltips` | no | false | boolean | Enables the default tooltips on fill-extrusion features and 3D Objects|
| `enableTooltips` | no | false | boolean | Enables the default tooltips on fill-extrusion features and 3D Objects|
| `enableHelpTooltips` | no | false | boolean | Enables the default help tooltips when an object is being moved, rotated or measured. |
| `multiLayer` | no | false | boolean | Enables the option for multi layer pages where a default layer will be created internally that will manage the [`tb.update`](#update) calls |
| `orthographic` | no | false | boolean | Enables the option to set a [`THREE.OrthographicCamera`](https://threejs.org/docs/index.html#api/en/cameras/OrthographicCamera) instead of a `THREE.PerspectiveCamera` which is the default in Mapbox |
| `fov` | no | ThreeboxConstants.FOV_DEGREES | number | Enables to set the FOV of the default [`THREE.PerspectiveCamera`](https://threejs.org/docs/index.html#api/en/cameras/PerspectiveCamera). This value has no effect if `orthographic: true` |
Expand Down
3 changes: 2 additions & 1 deletion examples/03-tube.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
enableSelectingObjects: true, //change this to false to disable 3D objects selection
enableDraggingObjects: true, //change this to false to disable 3D objects drag & move once selected
enableRotatingObjects: true, //change this to false to disable 3D objects rotation once selected
enableTooltips: true // change this to false to disable default tooltips on fill-extrusion and 3D models
enableTooltips: true, // change this to false to disable default tooltips on fill-extrusion and 3D models
enableHelpTooltips: true // remove this to disable default help tooltips for draggin, rotating and measure
}
);

Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ These are the examples included in Threebox.
- Enabled built-in dragging mode for 3D objects through `enableDraggingObjects`, 3D object is dragabble, once selected, using [Shift] key for translation and [Ctrl] for altitude.
- Enabled built-in rotation mode for 3D objects through `enableRotatingObjects`, 3D objects is rotable on it's vertical axis, once selected, using [Alt] key.
- Enabled built-in default Labels on altitude for the 3D object through `enableTooltips`.<br/>
- Enabled built-in default help Labels when dragged, rotated or measured.
- Updated to Mapbox 2.2.0
- - - -

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"dev": "watchify exports.js --verbose -o dist/threebox.js ",
"all": "browserify -p tinyify exports.js > dist/threebox.min.js && watchify exports.js --verbose -o dist/threebox.js ",
"test": "browserify tests/threebox-tests.js > tests/threebox-tests-bundle.js",
"start": "node server.js"
"start": "node server.js",
"stop": "node server.stop.js"
},
"directories": {
"doc": "docs",
Expand Down
13 changes: 13 additions & 0 deletions server.stop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';
var port = 8080 || process.env.PORT || 1337;

const io = require('socket.io-client');
const socketClient = io.connect('http://localhost' + port); // Specify port if your express server is not using default port 80

socketClient.on('connect', () => {
socketClient.emit('npmStop');
setTimeout(() => {
process.exit(0);
}, 1000);
});

10 changes: 6 additions & 4 deletions src/Threebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Threebox.prototype = {
this.enableRotatingObjects = this.options.enableRotatingObjects || false;
this.enableTooltips = this.options.enableTooltips || false;
this.multiLayer = this.options.multiLayer || false;
this.enableHelpTooltips = this.options.enableHelpTooltips || false;

this.map.on('style.load', function () {
this.tb.zoomLayers = [];
Expand Down Expand Up @@ -340,7 +341,7 @@ Threebox.prototype = {
let rotation = { x: 0, y: 0, z: (Math.round(rotationDiff[2] + (~~((current.x - start.x) / this.tb.rotationStep) % 360 * this.tb.rotationStep) % 360)) };
//now rotate the model depending the axis
this.draggedObject.setRotation(rotation);
this.draggedObject.addHelp("rot: " + rotation.z + "&#176;");
if (map.tb.enableHelpTooltips) this.draggedObject.addHelp("rot: " + rotation.z + "&#176;");
//this.draggedObject.setRotationAxis(rotation);
return;
}
Expand All @@ -356,7 +357,7 @@ Threebox.prototype = {
let coords = e.lngLat;
let options = [Number((coords.lng + lngDiff).toFixed(this.tb.gridStep)), Number((coords.lat + latDiff).toFixed(this.tb.gridStep)), this.draggedObject.modelHeight];
this.draggedObject.setCoords(options);
this.draggedObject.addHelp("lng: " + options[0] + "&#176;, lat: " + options[1] + "&#176;");
if (map.tb.enableHelpTooltips) this.draggedObject.addHelp("lng: " + options[0] + "&#176;, lat: " + options[1] + "&#176;");
return;
}

Expand All @@ -370,7 +371,7 @@ Threebox.prototype = {
let now = (e.point.y * this.tb.altitudeStep);
let options = [this.draggedObject.coordinates[0], this.draggedObject.coordinates[1], Number((- now - altDiff).toFixed(this.tb.gridStep))];
this.draggedObject.setCoords(options);
this.draggedObject.addHelp("alt: " + options[2] + "m");
if (map.tb.enableHelpTooltips) this.draggedObject.addHelp("alt: " + options[2] + "m");
return;
}

Expand Down Expand Up @@ -519,7 +520,7 @@ Threebox.prototype = {
sf = dc(sf, 7);
}

obj.addHelp("size(m): " + dc((s.x / sf), 3) + " W, " + dc((s.y / sf), 3) + " L, " + dc((s.z / sf), 3) + " H");
if (map.tb.enableHelpTooltips) obj.addHelp("size(m): " + dc((s.x / sf), 3) + " W, " + dc((s.y / sf), 3) + " L, " + dc((s.z / sf), 3) + " H");
this.repaint = true;
}
else {
Expand Down Expand Up @@ -1188,6 +1189,7 @@ var defaultOptions = {
enableDraggingObjects: false,
enableRotatingObjects: false,
enableTooltips: false,
enableHelpTooltips: false,
multiLayer: false,
orthographic: false,
fov: ThreeboxConstants.FOV_DEGREES,
Expand Down
10 changes: 6 additions & 4 deletions tests/threebox-tests-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11935,6 +11935,7 @@ Threebox.prototype = {
this.enableRotatingObjects = this.options.enableRotatingObjects || false;
this.enableTooltips = this.options.enableTooltips || false;
this.multiLayer = this.options.multiLayer || false;
this.enableHelpTooltips = this.options.enableHelpTooltips || false;

this.map.on('style.load', function () {
this.tb.zoomLayers = [];
Expand Down Expand Up @@ -12167,7 +12168,7 @@ Threebox.prototype = {
let rotation = { x: 0, y: 0, z: (Math.round(rotationDiff[2] + (~~((current.x - start.x) / this.tb.rotationStep) % 360 * this.tb.rotationStep) % 360)) };
//now rotate the model depending the axis
this.draggedObject.setRotation(rotation);
this.draggedObject.addHelp("rot: " + rotation.z + "&#176;");
if (this.enableHelpTooltips) this.draggedObject.addHelp("rot: " + rotation.z + "&#176;");
//this.draggedObject.setRotationAxis(rotation);
return;
}
Expand All @@ -12183,7 +12184,7 @@ Threebox.prototype = {
let coords = e.lngLat;
let options = [Number((coords.lng + lngDiff).toFixed(this.tb.gridStep)), Number((coords.lat + latDiff).toFixed(this.tb.gridStep)), this.draggedObject.modelHeight];
this.draggedObject.setCoords(options);
this.draggedObject.addHelp("lng: " + options[0] + "&#176;, lat: " + options[1] + "&#176;");
if (this.enableHelpTooltips) this.draggedObject.addHelp("lng: " + options[0] + "&#176;, lat: " + options[1] + "&#176;");
return;
}

Expand All @@ -12197,7 +12198,7 @@ Threebox.prototype = {
let now = (e.point.y * this.tb.altitudeStep);
let options = [this.draggedObject.coordinates[0], this.draggedObject.coordinates[1], Number((- now - altDiff).toFixed(this.tb.gridStep))];
this.draggedObject.setCoords(options);
this.draggedObject.addHelp("alt: " + options[2] + "m");
if (this.enableHelpTooltips) this.draggedObject.addHelp("alt: " + options[2] + "m");
return;
}

Expand Down Expand Up @@ -12346,7 +12347,7 @@ Threebox.prototype = {
sf = dc(sf, 7);
}

obj.addHelp("size(m): " + dc((s.x / sf), 3) + " W, " + dc((s.y / sf), 3) + " L, " + dc((s.z / sf), 3) + " H");
if (this.enableHelpTooltips) obj.addHelp("size(m): " + dc((s.x / sf), 3) + " W, " + dc((s.y / sf), 3) + " L, " + dc((s.z / sf), 3) + " H");
this.repaint = true;
}
else {
Expand Down Expand Up @@ -13015,6 +13016,7 @@ var defaultOptions = {
enableDraggingObjects: false,
enableRotatingObjects: false,
enableTooltips: false,
enableHelpTooltips: false,
multiLayer: false,
orthographic: false,
fov: ThreeboxConstants.FOV_DEGREES,
Expand Down

0 comments on commit 759046f

Please sign in to comment.