@equinor/videx-3d 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,69 @@
1
+ import { Shape, Vector2 } from 'three';
2
+ import { Vec2 } from '../types/common';
3
+ export type PlanarGeometryType = 'point2d' | 'line2d' | 'polygon2d';
4
+ export type Coordinates2D = Vec2[];
5
+ export type PlanarPointCoordinates = Coordinates2D;
6
+ export type PlanarLineCoordinates = Coordinates2D[];
7
+ export type PlanarPolygonCoordinates = Coordinates2D[][];
8
+ export type PlanarGeometryCoordinates = PlanarPointCoordinates | PlanarLineCoordinates | PlanarPolygonCoordinates;
9
+ export type CoordinatesTransformFunction = (coord: Vec2) => Vec2;
10
+ /**
11
+ * A simple abstraction for defining 2D points, lines or polygons,
12
+ * primarily for making it easier to work with GeoJson in videx-3d.
13
+ */
14
+ export declare abstract class PlanarGeometry {
15
+ type: PlanarGeometryType;
16
+ coordinates: PlanarGeometryCoordinates;
17
+ private _min;
18
+ private _max;
19
+ private _size;
20
+ protected _offset: Vec2;
21
+ constructor(type: PlanarGeometryType, coordinates: PlanarGeometryCoordinates, offset?: Vec2);
22
+ static fromPointCoordinates(coordinates: PlanarPointCoordinates, transform?: CoordinatesTransformFunction): PlanarPointGeometry;
23
+ static fromLineCoordinates(coordinates: PlanarLineCoordinates, transform?: CoordinatesTransformFunction): PlanarLineGeometry;
24
+ static fromPolygonCoordinates(coordinates: PlanarPolygonCoordinates, transform?: CoordinatesTransformFunction): PlanarPolygonGeometry;
25
+ abstract forEachCoordinate(callback: (pos: Vec2) => void): void;
26
+ private _calculateBounds;
27
+ get min(): Vec2;
28
+ get max(): Vec2;
29
+ get center(): Vec2;
30
+ get size(): Vec2;
31
+ get offset(): Vec2;
32
+ setOffset(offset: Vec2): void;
33
+ removeOffset(): void;
34
+ centralize(): void;
35
+ normalize(scale?: Vec2, offset?: Vec2): void;
36
+ transform(transformFunc: CoordinatesTransformFunction): void;
37
+ abstract clone(): PlanarGeometry;
38
+ toObject(): {
39
+ type: string;
40
+ coordinates: PlanarGeometryCoordinates;
41
+ offset: Vec2;
42
+ };
43
+ abstract getPoints(): Vector2[][];
44
+ getPointsFlattened(): Vector2[];
45
+ getBounds(): {
46
+ min: Vec2;
47
+ max: Vec2;
48
+ size: Vec2;
49
+ };
50
+ }
51
+ export declare class PlanarPointGeometry extends PlanarGeometry {
52
+ constructor(coordinates: PlanarPointCoordinates, offset?: Vec2);
53
+ forEachCoordinate(callback: (pos: Vec2) => void): void;
54
+ getPoints(): Vector2[][];
55
+ clone(): PlanarPointGeometry;
56
+ }
57
+ export declare class PlanarLineGeometry extends PlanarGeometry {
58
+ constructor(coordinates: PlanarLineCoordinates, offset?: Vec2);
59
+ forEachCoordinate(callback: (pos: Vec2) => void): void;
60
+ getPoints(): Vector2[][];
61
+ clone(): PlanarLineGeometry;
62
+ }
63
+ export declare class PlanarPolygonGeometry extends PlanarGeometry {
64
+ constructor(coordinates: PlanarPolygonCoordinates, offset?: Vec2);
65
+ forEachCoordinate(callback: (pos: Vec2) => void): void;
66
+ getPoints(): Vector2[][];
67
+ clone(): PlanarPolygonGeometry;
68
+ toShapes(): Shape[];
69
+ }
@@ -0,0 +1,15 @@
1
+ import { CoordinatesTransformFunction, PlanarGeometry } from '../geometries/planar-geometry';
2
+ export type GeoJsonFeature = {
3
+ properties: Record<string, any>;
4
+ geometry: PlanarGeometry;
5
+ };
6
+ /**
7
+ * Simple helper function to parse a GeoJSON feature into a videx-3d GeoJsonFeature type,
8
+ * where the geometry is represented as an instance of PlanarGeometry.
9
+ * @param feature GeoJSON feature object
10
+ * @param transform Coordinate conversion function (i.e. from wgs84 to 3D world coordinates)
11
+ * @returns GeoJsonFeature type
12
+ *
13
+ * @see PlanarGeometry
14
+ */
15
+ export declare function parseGeoJsonFeature(feature: any, transform?: CoordinatesTransformFunction): GeoJsonFeature;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/videx-3d",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",