Skip to content

Commit

Permalink
#187 Create an option to translate an object based on world coordinat…
Browse files Browse the repository at this point in the history
…es (obj.position)
  • Loading branch information
jscastro76 committed Jan 22, 2021
1 parent 5c3da1c commit ea67aac
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Minor version by [@jscastro76](https://github.com/jscastro76), some enhancements

#### :sparkles: Enhancements
- #182 Resource interpreted as Stylesheet but transferred with MIME type text/plain
- #187 Create an option to translate an object based on world coordinates (obj.position)

#### :pencil: Documentation
- Updated [documentation](/docs/Threebox.md) started to link points and improving documentation descriptions in general.
Expand Down
20 changes: 14 additions & 6 deletions dist/threebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1184,8 +1184,6 @@ AnimationManager.prototype = {
this.stop();
options.rotation = utils.radify(options.rotation);
this._setObject(options);


}

return this
Expand Down Expand Up @@ -1243,7 +1241,8 @@ AnimationManager.prototype = {
let s = options.scale; // custom scale
let w = options.worldCoordinates; //Vector3
let q = options.quaternion; // [axis, angle in rads]
let t = options.translate; //[jscastro] lnglat + height for 3D objects
let t = options.translate; // [jscastro] lnglat + height for 3D objects
let wt = options.worldTranslate; // [jscastro] Vector3 translation

if (p) {
this.coordinates = p;
Expand All @@ -1254,12 +1253,21 @@ AnimationManager.prototype = {
if (t) {
this.coordinates = [this.coordinates[0] + t[0], this.coordinates[1] + t[1], this.coordinates[2] + t[2]];
let c = utils.projectToWorld(t);
this.translateX(c.x);
this.translateY(c.y);
this.translateZ(c.z);
this.position.copy(c)
//this.translateX(c.x);
//this.translateY(c.y);
//this.translateZ(c.z);
options.position = this.coordinates;
}

if (wt) {
this.translateX(wt.x);
this.translateY(wt.y);
this.translateZ(wt.z);
let p = utils.unprojectFromWorld(this.position);
this.coordinates = options.position = p;
}

if (r) {
this.rotation.set(r[0], r[1], r[2]);
options.rotation = new THREE.Vector3(r[0], r[1], r[2]);
Expand Down
Loading

0 comments on commit ea67aac

Please sign in to comment.