Skip to content

Commit 90bbf33

Browse files
v1.4.1 (#34)
1 parent 4f0645c commit 90bbf33

File tree

10 files changed

+2438
-33
lines changed

10 files changed

+2438
-33
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22

33
[Official Releases](https://github.com/NASA-AMMOS/LithoSphere/releases)
44

5+
## v1.4.1
6+
7+
_May 2, 2022_
8+
9+
#### Added
10+
11+
- New `initialCamera` constructor option
12+
513
## v1.4.0
614

15+
---
16+
717
_Mar 29, 2022_
818

919
#### Added

dist/lithosphere.js

Lines changed: 2312 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/lithosphere.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ interface Private {
1111
rendererWrapper: any;
1212
renderer: any;
1313
cameras: any;
14-
cameraPositionTarget: number[];
1514
tiledWorld: TiledWorld;
1615
events: Events;
1716
maxZoom: number;
@@ -82,6 +81,8 @@ export default class LithoSphere {
8281
firstPerson: any;
8382
orbit: any;
8483
};
84+
_setInitialCameraPositionTarget: () => void;
85+
setCameraPositionTarget: (position?: XYZ, target?: XYZ) => void;
8586
getContainer: () => HTMLElement;
8687
invalidateSize: () => void;
8788
}

docs/favicon.ico

2.38 KB
Binary file not shown.

docs/pages/Constructor/constructor.markdown

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ new LithoSphere(containerId, options)
3030

3131
| Parameter | Type | Default | Description |
3232
| :----------------------: | :--------: | :--------------------------------------------------------------------------------: | :------------------------------------------------------------------------------: |
33-
| **initialView** | _object_ | See [initialView]({{ site.baseurl }}/constructor#optionsinitialview) below | Sets the initial coordinate view of the scene |
33+
| **initialView** | _object_ | See [initialView]({{ site.baseurl }}/constructor#optionsinitialview) below | Sets the initial longitude, latitude, zoom coordinate view of the scene |
34+
| **initialCamera** | _object_ | See [initialCamera]({{ site.baseurl }}/constructor#optionsinitialcamera) below | Sets the initial world-space camera coordinates and look-at |
3435
| **majorRadius** | _integer_ | 6371000 | Major planetary radius in meters |
3536
| **minorRadius** | _integer_ | majorRadius | Minor planetary radius in meters |
3637
| **loadingScreen** | _boolean_ | true | If true, shows a loading screen until all lithosphere content first loads |
@@ -74,6 +75,34 @@ The latitude, longitude, and zoom LithoSphere first starts at.
7475
}
7576
```
7677

78+
### options.initialCamera
79+
80+
Sets the orbit camera's initial position and target. Useful in deeplinks and when a non-top-down camera angle is desired. Note that the camera's look-at target is always along the y-axis.
81+
82+
| Parameter | Type | Default | Description |
83+
| :------------------------: | :---: | :-----: | :------------------------------: |
84+
| **initialCamera.position** | _XYZ_ | null | Sets the initial camera position |
85+
| **initialCamera.target** | _XYZ_ | null | Sets the initial camera target |
86+
87+
#### Example
88+
89+
```javascript
90+
{
91+
initialCamera: {
92+
position: {
93+
x: 1570.8134791640523,
94+
y: 3125.497317531146,
95+
z: 123.76226561404211,
96+
},
97+
target: {
98+
x: 0,
99+
y: 4412.141683964059,
100+
z: 0,
101+
},
102+
},
103+
}
104+
```
105+
77106
### options.demFallback
78107

79108
If a tile layer has a `demPath` set and one of its tile dem request fails for whatever reason (such as a 404) or does not have a `demPath` set, it will try to get the corresponding DEM tile specified in `demFallback`.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lithosphere",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "LithoSphere is a GIS JavaScript library for building 3D tile-based globes in the web browser.",
55
"author": "Tariq Soliman",
66
"license": "Apache-2.0",

public/dist/lithosphere.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/examples/example.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,30 @@
3535
<!--<div id="myCustomCoordDiv"></div>-->
3636
<script>
3737
const Litho = new LithoSphere.default('container', {
38+
/*
3839
initialView: {
3940
lng: 137.358048, // default 0
4041
lat: -4.673226,
4142
zoom: 16,
4243
},
44+
*/
45+
initialView: {
46+
lng: 137.3650974531451,
47+
lat: -4.71480304282526,
48+
zoom: 16,
49+
},
50+
initialCamera: {
51+
position: {
52+
x: 274.50893509606396,
53+
y: 4258.156814585879,
54+
z: -1108.3356496526244,
55+
},
56+
target: {
57+
x: 0,
58+
y: 4293.083639767021,
59+
z: 0,
60+
},
61+
},
4362
majorRadius: 3396190,
4463
loadingScreen: true, // default true
4564
customParsers: {

src/generalTypes.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ export interface LatLngZ {
3131
zoom?: number
3232
}
3333

34+
export interface InitialCamera {
35+
position: {
36+
x: number
37+
y: number
38+
z: number
39+
}
40+
target: {
41+
x: number
42+
y: number
43+
z: number
44+
}
45+
}
46+
3447
export interface XY {
3548
x: number
3649
y: number
@@ -74,6 +87,7 @@ export interface ControlType {
7487

7588
export interface Options {
7689
initialView?: LatLngZ
90+
initialCamera?: InitialCamera
7791
// Whether or not to show the loading screen
7892
loadingScreen?: boolean
7993
majorRadius?: number

src/lithosphere.ts

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ interface Private {
3737
rendererWrapper: any
3838
renderer: any
3939
cameras: any
40-
cameraPositionTarget: number[]
4140
tiledWorld: TiledWorld
4241
events: Events
4342
maxZoom: number
@@ -112,7 +111,6 @@ export default class LithoSphere {
112111
rendererWrapper: null,
113112
renderer: null,
114113
cameras: null,
115-
cameraPositionTarget: null,
116114
tiledWorld: null,
117115
events: null,
118116
maxZoom: 0,
@@ -322,6 +320,7 @@ export default class LithoSphere {
322320

323321
//Set default view
324322
this.setCenter(this.options.initialView)
323+
this._setInitialCameraPositionTarget()
325324

326325
// Action!
327326
this._animate()
@@ -399,40 +398,16 @@ export default class LithoSphere {
399398
this.controls._onOrbitalUpdate()
400399
}
401400

402-
/*
403401
//Globe_.updateTileShaderVars();
404-
THREE.VRController.update()
405-
406-
//set default camera from url if there is one
407-
if (L_.FUTURES.globeCamera != null) {
408-
var c = L_.FUTURES.globeCamera
409-
Cameras.orbit.camera.position.set(c[0], c[1], c[2])
410-
Cameras.orbit.controls.target.x = c[3]
411-
Cameras.orbit.controls.target.y = c[4]
412-
Cameras.orbit.controls.target.z = c[5]
413-
Cameras.orbit.controls.update()
414-
L_.FUTURES.globeCamera = null
415-
}
416-
*/
402+
//THREE.VRController.update()
403+
417404
if (this._.firstUpdate) {
418405
//Set default view
419406
if (this._.firstViewOverride != null)
420407
this.setCenter(this._.firstViewOverride)
421408
else this.setCenter(this.options.initialView, true)
422409

423-
const o = this._.cameras.orbit
424-
const cam = o.camera
425-
const con = o.controls
426-
const pos = cam.position
427-
const tar = con.target
428-
this._.cameraPositionTarget = [
429-
pos.x,
430-
pos.y,
431-
pos.z,
432-
tar.x,
433-
tar.y,
434-
tar.z,
435-
]
410+
this._setInitialCameraPositionTarget()
436411

437412
this._.firstUpdate = false
438413
}
@@ -452,6 +427,7 @@ export default class LithoSphere {
452427
setTimeout(() => {
453428
// Repositions center
454429
this.setCenter(this.options.initialView, false, true)
430+
this._setInitialCameraPositionTarget()
455431
this._.events._onZoom()
456432
this._.loadingScreen.end()
457433
}, 100)
@@ -670,6 +646,50 @@ export default class LithoSphere {
670646
}
671647
}
672648

649+
_setInitialCameraPositionTarget = () => {
650+
const o = this._.cameras.orbit
651+
const cam = o.camera
652+
const con = o.controls
653+
const pos = cam.position
654+
const tar = con.target
655+
656+
let position = { x: pos.x, y: pos.y, z: pos.z }
657+
let target = { x: tar.x, y: tar.y, z: tar.z }
658+
if (this.options.initialCamera) {
659+
const iC = this.options.initialCamera
660+
if (iC.position) {
661+
position = {
662+
x: iC.position.x || position.x,
663+
y: iC.position.y || position.y,
664+
z: iC.position.z || position.z,
665+
}
666+
}
667+
if (iC.target) {
668+
target = {
669+
x: iC.target.x || target.x,
670+
y: iC.target.y || target.y,
671+
z: iC.target.z || target.z,
672+
}
673+
}
674+
this.setCameraPositionTarget(position, target)
675+
}
676+
}
677+
setCameraPositionTarget = (position?: XYZ, target?: XYZ) => {
678+
if (position) {
679+
this._.cameras.orbit.camera.position.set(
680+
position.x || 9,
681+
position.y || 0,
682+
position.z || 0
683+
)
684+
}
685+
if (target) {
686+
this._.cameras.orbit.controls.target.x = target.x || 0
687+
this._.cameras.orbit.controls.target.y = target.y || 0
688+
this._.cameras.orbit.controls.target.z = target.z || 0
689+
}
690+
this._.cameras.orbit.controls.update()
691+
}
692+
673693
// Getter for container
674694
getContainer = () => {
675695
return this._.container

0 commit comments

Comments
 (0)