|
| 1 | +import traitlets as t |
| 2 | + |
| 3 | +from lonboard._base import BaseWidget |
| 4 | + |
| 5 | + |
| 6 | +class BaseView(BaseWidget): |
| 7 | + """A deck.gl View. |
| 8 | +
|
| 9 | + The `View` class and its subclasses are used to specify where and how your deck.gl layers should be rendered. Applications typically instantiate at least one `View` subclass. |
| 10 | +
|
| 11 | + """ |
| 12 | + |
| 13 | + x = t.Union([t.Int(), t.Unicode()], allow_none=True, default_value=None).tag( |
| 14 | + sync=True, |
| 15 | + ) |
| 16 | + """The x position of the view. |
| 17 | +
|
| 18 | + A relative (e.g. `'50%'`) or absolute position. Default `0`. |
| 19 | + """ |
| 20 | + |
| 21 | + y = t.Union([t.Int(), t.Unicode()], allow_none=True, default_value=None).tag( |
| 22 | + sync=True, |
| 23 | + ) |
| 24 | + """The y position of the view. |
| 25 | +
|
| 26 | + A relative (e.g. `'50%'`) or absolute position. Default `0`. |
| 27 | + """ |
| 28 | + |
| 29 | + width = t.Union([t.Int(), t.Unicode()], allow_none=True, default_value=None).tag( |
| 30 | + sync=True, |
| 31 | + ) |
| 32 | + """The width of the view. |
| 33 | +
|
| 34 | + A relative (e.g. `'50%'`) or absolute extent. Default `'100%'`. |
| 35 | + """ |
| 36 | + |
| 37 | + height = t.Union([t.Int(), t.Unicode()], allow_none=True, default_value=None).tag( |
| 38 | + sync=True, |
| 39 | + ) |
| 40 | + """The height of the view. |
| 41 | +
|
| 42 | + A relative (e.g. `'50%'`) or absolute extent. Default `'100%'`. |
| 43 | + """ |
| 44 | + |
| 45 | + |
| 46 | +class FirstPersonView(BaseView): |
| 47 | + """A deck.gl FirstPersonView. |
| 48 | +
|
| 49 | + The `FirstPersonView` class is a subclass of `View` that describes a camera placed at a provided location, looking towards the direction and orientation specified by viewState. The behavior is similar to that of a first-person game. |
| 50 | + """ |
| 51 | + |
| 52 | + _view_type = t.Unicode("first-person-view").tag(sync=True) |
| 53 | + |
| 54 | + projection_matrix = t.List( |
| 55 | + t.Float(), |
| 56 | + allow_none=True, |
| 57 | + default_value=None, |
| 58 | + minlen=16, |
| 59 | + maxlen=16, |
| 60 | + ).tag( |
| 61 | + sync=True, |
| 62 | + ) |
| 63 | + """Projection matrix. |
| 64 | +
|
| 65 | + If `projectionMatrix` is not supplied, the `View` class will build a projection matrix from the following parameters: |
| 66 | + """ |
| 67 | + |
| 68 | + fovy = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 69 | + """Field of view covered by camera, in the perspective case. In degrees. |
| 70 | +
|
| 71 | + Default `50`. |
| 72 | + """ |
| 73 | + |
| 74 | + near = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 75 | + """Distance of near clipping plane. |
| 76 | +
|
| 77 | + Default `0.1`. |
| 78 | + """ |
| 79 | + |
| 80 | + far = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 81 | + """Distance of far clipping plane. |
| 82 | +
|
| 83 | + Default `1000`. |
| 84 | + """ |
| 85 | + |
| 86 | + focal_distance = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 87 | + """Modifier of viewport scale. |
| 88 | +
|
| 89 | + Corresponds to the number of pixels per meter. Default `1`. |
| 90 | + """ |
| 91 | + |
| 92 | + |
| 93 | +class GlobeView(BaseView): |
| 94 | + """A deck.gl GlobeView. |
| 95 | +
|
| 96 | + The `GlobeView` class is a subclass of `View`. This view projects the earth into a 3D globe. |
| 97 | + """ |
| 98 | + |
| 99 | + _view_type = t.Unicode("globe-view").tag(sync=True) |
| 100 | + |
| 101 | + resolution = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 102 | + """The resolution at which to turn flat features into 3D meshes, in degrees. |
| 103 | +
|
| 104 | + Smaller numbers will generate more detailed mesh. Default `10`. |
| 105 | + """ |
| 106 | + |
| 107 | + near_z_multiplier = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 108 | + """Scaler for the near plane, 1 unit equals to the height of the viewport. |
| 109 | +
|
| 110 | + Default to `0.1`. Overwrites the `near` parameter. |
| 111 | + """ |
| 112 | + |
| 113 | + far_z_multiplier = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 114 | + """Scaler for the far plane, 1 unit equals to the distance from the camera to the top edge of the screen. |
| 115 | +
|
| 116 | + Default to `2`. Overwrites the `far` parameter. |
| 117 | + """ |
| 118 | + |
| 119 | + |
| 120 | +class MapView(BaseView): |
| 121 | + """A deck.gl MapView. |
| 122 | +
|
| 123 | + The `MapView` class is a subclass of `View`. This viewport creates a camera that looks at a geospatial location on a map from a certain direction. The behavior of `MapView` is generally modeled after that of Mapbox GL JS. |
| 124 | + """ |
| 125 | + |
| 126 | + _view_type = t.Unicode("map-view").tag(sync=True) |
| 127 | + |
| 128 | + repeat = t.Bool(allow_none=True, default_value=None).tag(sync=True) |
| 129 | + """ |
| 130 | + Whether to render multiple copies of the map at low zoom levels. Default `false`. |
| 131 | + """ |
| 132 | + |
| 133 | + near_z_multiplier = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 134 | + """Scaler for the near plane, 1 unit equals to the height of the viewport. |
| 135 | +
|
| 136 | + Default to `0.1`. Overwrites the `near` parameter. |
| 137 | + """ |
| 138 | + |
| 139 | + far_z_multiplier = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 140 | + """Scaler for the far plane, 1 unit equals to the distance from the camera to the top edge of the screen. |
| 141 | +
|
| 142 | + Default to `1.01`. Overwrites the `far` parameter. |
| 143 | + """ |
| 144 | + |
| 145 | + projection_matrix = t.List( |
| 146 | + t.Float(), |
| 147 | + allow_none=True, |
| 148 | + default_value=None, |
| 149 | + minlen=16, |
| 150 | + maxlen=16, |
| 151 | + ).tag( |
| 152 | + sync=True, |
| 153 | + ) |
| 154 | + """Projection matrix. |
| 155 | +
|
| 156 | + If `projectionMatrix` is not supplied, the `View` class will build a projection matrix from the following parameters: |
| 157 | + """ |
| 158 | + |
| 159 | + fovy = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 160 | + """Field of view covered by camera, in the perspective case. In degrees. |
| 161 | +
|
| 162 | + If not supplied, will be calculated from `altitude`. |
| 163 | + """ |
| 164 | + |
| 165 | + altitude = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 166 | + """Distance of the camera relative to viewport height. |
| 167 | +
|
| 168 | + Default `1.5`. |
| 169 | + """ |
| 170 | + |
| 171 | + orthographic = t.Bool(allow_none=True, default_value=None).tag(sync=True) |
| 172 | + """Whether to create an orthographic or perspective projection matrix. |
| 173 | +
|
| 174 | + Default is `false` (perspective projection). |
| 175 | + """ |
| 176 | + |
| 177 | + |
| 178 | +class OrbitView(BaseView): |
| 179 | + """A deck.gl OrbitView. |
| 180 | +
|
| 181 | + The `OrbitView` class is a subclass of `View` that creates a 3D camera that rotates around a target position. It is usually used for the examination of a 3D scene in non-geospatial use cases. |
| 182 | + """ |
| 183 | + |
| 184 | + _view_type = t.Unicode("orbit-view").tag(sync=True) |
| 185 | + |
| 186 | + orbit_axis = t.Unicode(allow_none=True, default_value=None).tag(sync=True) |
| 187 | + """Axis with 360 degrees rotating freedom, either `'Y'` or `'Z'`, default to `'Z'`.""" |
| 188 | + |
| 189 | + projection_matrix = t.List( |
| 190 | + t.Float(), |
| 191 | + allow_none=True, |
| 192 | + default_value=None, |
| 193 | + minlen=16, |
| 194 | + maxlen=16, |
| 195 | + ).tag( |
| 196 | + sync=True, |
| 197 | + ) |
| 198 | + """Projection matrix. |
| 199 | +
|
| 200 | + If `projectionMatrix` is not supplied, the `View` class will build a projection matrix from the following parameters: |
| 201 | + """ |
| 202 | + |
| 203 | + fovy = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 204 | + """Field of view covered by camera, in the perspective case. In degrees. |
| 205 | +
|
| 206 | + Default `50`. |
| 207 | + """ |
| 208 | + |
| 209 | + near = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 210 | + """Distance of near clipping plane. |
| 211 | +
|
| 212 | + Default `0.1`. |
| 213 | + """ |
| 214 | + |
| 215 | + far = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 216 | + """Distance of far clipping plane. |
| 217 | +
|
| 218 | + Default `1000`. |
| 219 | + """ |
| 220 | + |
| 221 | + orthographic = t.Bool(allow_none=True, default_value=None).tag(sync=True) |
| 222 | + """Whether to create an orthographic or perspective projection matrix. |
| 223 | +
|
| 224 | + Default is `false` (perspective projection). |
| 225 | + """ |
| 226 | + |
| 227 | + |
| 228 | +class OrthographicView(BaseView): |
| 229 | + """A deck.gl OrthographicView. |
| 230 | +
|
| 231 | + The `OrthographicView` class is a subclass of `View` that creates a top-down view of the XY plane. It is usually used for rendering 2D charts in non-geospatial use cases. |
| 232 | + """ |
| 233 | + |
| 234 | + _view_type = t.Unicode("orthographic-view").tag(sync=True) |
| 235 | + |
| 236 | + flip_y = t.Bool(allow_none=True, default_value=None).tag(sync=True) |
| 237 | + """ |
| 238 | + Whether to use top-left coordinates (`true`) or bottom-left coordinates (`false`). |
| 239 | +
|
| 240 | + Default `true`. |
| 241 | + """ |
| 242 | + |
| 243 | + near = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 244 | + """Distance of near clipping plane. |
| 245 | +
|
| 246 | + Default `0.1`. |
| 247 | + """ |
| 248 | + |
| 249 | + far = t.Float(allow_none=True, default_value=None).tag(sync=True) |
| 250 | + """Distance of far clipping plane. |
| 251 | +
|
| 252 | + Default `1000`. |
| 253 | + """ |
0 commit comments