Skip to content

Commit

Permalink
## 2.0.8
Browse files Browse the repository at this point in the history
Minor version by [@jscastro76](https://github.com/jscastro76), some enhancements and bugs.

#### ✨ Enhancements

- #73 `tb.dispose` must clean `tb.objectsCache`
- #74 Question: Why is this library not available on npm ?
- #75 Publish in npm
- #76 Refactor Objects.prototype._makeGroup
- #78 refactor var to const and let
- #80 Update example [15-performance.html](https://github.com/jscastro76/threebox/blob/master/examples/15-performance.html) Add built-in animation to example 15-performance.html windmill.
- #82 Add a method `tb.getSunTimes`
- #85 We need an object compare method
- #87 Change `tb.getSunPosition` to accept lnglat coords instead of two params
- #88 Add night style change in 12-add3dmodel.html and 13-eiffel.html examples during night hours

#### 🪲 Bug fixes

- #42 Angular and Threebox. Solved an issue using a `mapboxgl.Point`line
- #77 example 05-logistics raises an error removing the line
- #79 Some examples are not using `renderingMode: 3d` in the layer creation
- #86 After #56 the feature that comes in userData is not being updated.

<br>

- - -
  • Loading branch information
jscastro76 committed Nov 14, 2020
1 parent 0d8ba60 commit 0a8b716
Show file tree
Hide file tree
Showing 13 changed files with 243 additions and 54 deletions.
23 changes: 14 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ Minor version by [@jscastro76](https://github.com/jscastro76), some enhancements

#### :sparkles: Enhancements

- [**#73**](https://github.com/jscastro76/threebox/issues/73) `tb.dispose` must clean `tb.objectsCache`
- [**#74**](https://github.com/jscastro76/threebox/issues/74) Question: Why is this library not available on npm ?
- [**#75**](https://github.com/jscastro76/threebox/issues/75) Publish in npm
- [**#76**](https://github.com/jscastro76/threebox/issues/76) Refactor Objects.prototype._makeGroup
- [**#78**](https://github.com/jscastro76/threebox/issues/78) refactor var to const and let
- [**#80**](https://github.com/jscastro76/threebox/issues/80) Update example [15-performance.html](https://github.com/jscastro76/threebox/blob/master/examples/15-performance.html) Add built-in animation to example 15-performance.html windmill.
- #73 `tb.dispose` must clean `tb.objectsCache`
- #74 Question: Why is this library not available on npm ?
- #75 Publish in npm
- #76 Refactor Objects.prototype._makeGroup
- #78 refactor var to const and let
- #80 Update example [15-performance.html](https://github.com/jscastro76/threebox/blob/master/examples/15-performance.html) Add built-in animation to example 15-performance.html windmill.
- #82 Add a method `tb.getSunTimes`
- #85 We need an object compare method
- #87 Change `tb.getSunPosition` to accept lnglat coords instead of two params
- #88 Add night style change in 12-add3dmodel.html and 13-eiffel.html examples during night hours

#### :beetle: Bug fixes

- [**#42**](https://github.com/jscastro76/threebox/issues/77) Angular and Threebox. Solved an issue using a `mapboxgl.Point`line
- [**#77**](https://github.com/jscastro76/threebox/issues/77) example 05-logistics raises an error removing the line
- [**#79**](https://github.com/jscastro76/threebox/issues/79) Some examples are not using `renderingMode: 3d` in the layer creation
- #42 Angular and Threebox. Solved an issue using a `mapboxgl.Point`line
- #77 example 05-logistics raises an error removing the line
- #79 Some examples are not using `renderingMode: 3d` in the layer creation
- #86 After #56 the feature that comes in userData is not being updated.

<br>

Expand Down
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A **[*Three.js*](https://threejs.org/)** plugin for **[*Mapbox GL JS*](https://d
- - -
## Current release

Current release is [**2.0.7**](https://github.com/jscastro76/threebox/releases/tag/v.2.0.7), please review the [**Change log**](https://github.com/jscastro76/threebox/blob/master/CHANGELOG.md#207) for more details.
Current release is [**2.0.8**](https://github.com/jscastro76/threebox/releases/tag/v.2.0.8), please review the [**Change log**](https://github.com/jscastro76/threebox/blob/master/CHANGELOG.md#208) for more details.

Threebox is available as an [nmp package](https://www.npmjs.com/package/threebox-plugin)
```js
Expand Down Expand Up @@ -43,26 +43,25 @@ Only in this fork, there is a list of new features implemented on top of the ama
- Update to Three.js v117.
- Update to Mapbox-gl-js v1.11.1.
- [15 examples](https://github.com/jscastro76/threebox/tree/master/examples) with new features.
- Support for multiple format objects (FBX, GLTF/GLB, Collada + OBJ/MTL).
- Support for multiple 3D format objects (FBX, GLTF/GLB, Collada, OBJ/MTL).
- Support for CSS2D labels supporting rich HTML controls through a new LabelManager.
- Support for CSS2D tooltips/title browser-like and mapbox-like.
- Support for Objects3D auto-centering, bounding box and floor projection.
- Support for built-in shadows and real Sun light positioning for a given datetime and lnglat coords.
- Support for built-in Raycaster in loaded Objects3D and fill-extrusions together.
- Support for built-in Raycaster in loaded Object3D and fill-extrusions together.
- Support for built-in MouseOver/Mouseout, Selected, Drag&Drop, Drag&Rotate, Wireframe in loadedObjects including events.
- Support for GeoJson standard features format import and export in different layers.
- Support for Objects3D embedded animations, and combined animations on AnimationManager (i.e. translate + embedded).
- Support for [GeoJson](https://geojson.org/) standard features format import and export in different layers.
- Support for Object3D embedded animations, and combined animations on AnimationManager (i.e. translate + embedded).
- Support for multi-floor design of spaces.
- Support for style change through `setStyle` and keeping 3D models.
- Support for Non-AABB Non Axes Aligned Bounding Box and real model size.
- Support for wireframing on Objects3D, removing them from the raycast.
- Support for wireframing on Object3D, removing them from the raycast.
- Support for `setLayerZoomRange` and `setLayoutProperty` on Custom Layers (not available in Mapbox).
- Support for `removeLayer` considering 3D objects.
- Support for `removeLayer` considering Object3D.
- Support for style change through `setStyle` and keeping Object3D.
- Support for partial and full dispose of Mapbox, Three and Threebox resources and memory.
- Support for Object3D auto-centering, bounding box and floor projection.
- Optimization for loading thousands of objects through cache.
- Optimization of Camera perspective to have Raycast with pixel-precision level.
- Adjusted positioning for Objects3D to set center and rotation axes by config.
- Check out [v2.0.7 change log](https://github.com/jscastro76/threebox/blob/master/CHANGELOG.md#207) for more detail.
- Check out [v2.0.7 change log](https://github.com/jscastro76/threebox/blob/master/CHANGELOG.md#208) for more detail.

<br>

Expand Down
50 changes: 42 additions & 8 deletions dist/threebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,13 @@ Threebox.prototype = {
},

//[jscastro] get the sun position (azimuth, altitude) from a given datetime, lng, lat
getSunPosition: function (date, lng, lat) {
return SunCalc.getPosition(date, lat, lng);
getSunPosition: function (date, coords) {
return SunCalc.getPosition(date, coords[1], coords[0]);
},

//[jscastro] get the sun times for sunrise, sunset, etc.. from a given datetime, lng, lat and alt
getSunTimes: function (date, coords) {
return SunCalc.getTimes(date, coords[1], coords[0], (coords[2] ? coords[2] : 0));
},

//[jscastro] set shadows for fill-extrusion layers
Expand Down Expand Up @@ -761,7 +766,7 @@ Threebox.prototype = {
this.lightDateTime = date;
this.lightLng = this.mapCenter.lng;
this.lightLat = this.mapCenter.lat
this.sunPosition = this.getSunPosition(date, this.mapCenter.lng, this.mapCenter.lat);
this.sunPosition = this.getSunPosition(date, [this.mapCenter.lng, this.mapCenter.lat]);
let altitude = this.sunPosition.altitude;
let azimuth = Math.PI + this.sunPosition.azimuth;
//console.log("Altitude: " + utils.degreeify(altitude) + ", Azimuth: " + (utils.degreeify(azimuth)));
Expand Down Expand Up @@ -1915,7 +1920,7 @@ class BuildingShadows {
const buildingsLayer = map.getLayer(this.buildingsLayerId);
const context = this.map.painter.context;
const { lng, lat } = this.map.getCenter();
const pos = this.tb.getSunPosition(this.tb.lightDateTime, lng, lat);
const pos = this.tb.getSunPosition(this.tb.lightDateTime, [lng, lat]);
gl.uniform1f(this.uAltitude, (pos.altitude > this.minAltitude ? pos.altitude : 0));
gl.uniform1f(this.uAzimuth, pos.azimuth + 3 * Math.PI / 2);
//this.opacity = Math.sin(Math.max(pos.altitude, 0)) * 0.6;
Expand Down Expand Up @@ -16799,10 +16804,13 @@ Objects.prototype = {

let dupe = obj.clone(true); //clone the whole threebox object
dupe.getObjectByName("model").animations = obj.animations; //we must set this explicitly before addMethods
if (dupe.userData.feature) dupe.userData.feature.properties.uuid = dupe.uuid;
if (dupe.userData.feature) {
if (options && options.feature) dupe.userData.feature = options.feature;
dupe.userData.feature.properties.uuid = dupe.uuid;
}
root._addMethods(dupe); // add methods

if (!options || options.scale == obj.userData.scale) {
if (!options || utils.equal(options.scale, obj.userData.scale)) {
//no options, no changes, just return the same object
dupe.copyAnchor(obj); // copy anchors
//[jscastro] we add by default a tooltip that can be overriden later or hide it with threebox `enableTooltips`
Expand Down Expand Up @@ -17006,8 +17014,7 @@ Objects.prototype = {
htmlElement: null,
cssClass: " label3D",
alwaysVisible: false,
topMargin: -0.5,
feature: null
topMargin: -0.5
},

tooltip: {
Expand Down Expand Up @@ -19058,6 +19065,33 @@ var utils = {
}
},

equal: function (obj1, obj2) {
const keys1 = Object.keys(obj1);
const keys2 = Object.keys(obj2);

if (keys1.length !== keys2.length) {
return false;
}

for (const key of keys1) {
const val1 = obj1[key];
const val2 = obj2[key];
const areObjects = this.isObject(val1) && this.isObject(val2);
if (
areObjects && !deepEqual(val1, val2) ||
!areObjects && val1 !== val2
) {
return false;
}
}

return true;
},

isObject: function (object) {
return object != null && typeof object === 'object';
},

_validate: function (userInputs, defaults) {

userInputs = userInputs || {};
Expand Down
Loading

0 comments on commit 0a8b716

Please sign in to comment.