@buerli.io/core 0.0.35-beta.1 → 0.0.35

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.
Files changed (74) hide show
  1. package/build/{types/geometry → geometry}/ThreeGeometryCreator.d.ts +0 -0
  2. package/build/{esm/geometry → geometry}/ThreeGeometryCreator.js +0 -0
  3. package/build/{types/geometry → geometry}/index.d.ts +0 -0
  4. package/build/{esm/geometry → geometry}/index.js +0 -0
  5. package/build/index.d.ts +36 -0
  6. package/build/{esm/index.js → index.js} +0 -0
  7. package/build/{types/store → store}/index.d.ts +0 -0
  8. package/build/{esm/store → store}/index.js +0 -0
  9. package/build/{types/store → store}/states/buerli.d.ts +0 -0
  10. package/build/{esm/store → store}/states/buerli.js +0 -0
  11. package/build/{types/store → store}/states/canvas.d.ts +0 -0
  12. package/build/{esm/store → store}/states/canvas.js +0 -0
  13. package/build/{types/store → store}/states/drawing.d.ts +2 -0
  14. package/build/{esm/store → store}/states/drawing.js +4 -0
  15. package/build/{types/store → store}/states/geometry.d.ts +0 -0
  16. package/build/{esm/store → store}/states/geometry.js +0 -0
  17. package/build/{types/store → store}/states/graphic.d.ts +0 -0
  18. package/build/{esm/store → store}/states/graphic.js +0 -0
  19. package/build/{types/store → store}/states/message.d.ts +0 -0
  20. package/build/{esm/store → store}/states/message.js +0 -0
  21. package/build/{types/store → store}/states/plugin.d.ts +0 -0
  22. package/build/{esm/store → store}/states/plugin.js +0 -0
  23. package/build/{types/store → store}/states/selection.d.ts +0 -0
  24. package/build/{esm/store → store}/states/selection.js +0 -0
  25. package/build/{types/store → store}/states/structure.d.ts +0 -0
  26. package/build/{esm/store → store}/states/structure.js +0 -0
  27. package/build/{types/store → store}/store.d.ts +0 -0
  28. package/build/{esm/store → store}/store.js +0 -0
  29. package/build/{types/store → store}/subscribtion/selection.d.ts +0 -0
  30. package/build/{esm/store → store}/subscribtion/selection.js +0 -0
  31. package/build/{types/store → store}/subscribtion/subscribeToDrawing.d.ts +0 -0
  32. package/build/{esm/store → store}/subscribtion/subscribeToDrawing.js +0 -0
  33. package/build/types/{types/ErrorTypes.d.ts → ErrorTypes.d.ts} +0 -0
  34. package/build/{esm/types → types}/ErrorTypes.js +0 -0
  35. package/build/types/{types/IGraphicPackage.d.ts → IGraphicPackage.d.ts} +0 -0
  36. package/build/{esm/types → types}/IGraphicPackage.js +0 -0
  37. package/build/types/{types/IStructurePatch.d.ts → IStructurePatch.d.ts} +0 -0
  38. package/build/{esm/types → types}/IStructurePatch.js +0 -0
  39. package/build/types/{types/IStructureTree.d.ts → IStructureTree.d.ts} +0 -0
  40. package/build/{esm/types → types}/IStructureTree.js +0 -0
  41. package/build/types/index.d.ts +4 -36
  42. package/build/{esm/types → types}/index.js +0 -0
  43. package/build/{types/utils → utils}/Math.d.ts +0 -0
  44. package/build/{esm/utils → utils}/Math.js +0 -0
  45. package/build/{types/utils → utils}/Measure.d.ts +0 -0
  46. package/build/{esm/utils → utils}/Measure.js +0 -0
  47. package/build/{types/utils → utils}/Timing.d.ts +0 -0
  48. package/build/{esm/utils → utils}/Timing.js +0 -0
  49. package/package.json +6 -9
  50. package/build/cjs/geometry/ThreeGeometryCreator.js +0 -284
  51. package/build/cjs/geometry/index.js +0 -13
  52. package/build/cjs/index.js +0 -20
  53. package/build/cjs/store/index.js +0 -46
  54. package/build/cjs/store/states/buerli.js +0 -97
  55. package/build/cjs/store/states/canvas.js +0 -18
  56. package/build/cjs/store/states/drawing.js +0 -44
  57. package/build/cjs/store/states/geometry.js +0 -110
  58. package/build/cjs/store/states/graphic.js +0 -87
  59. package/build/cjs/store/states/message.js +0 -25
  60. package/build/cjs/store/states/plugin.js +0 -113
  61. package/build/cjs/store/states/selection.js +0 -226
  62. package/build/cjs/store/states/structure.js +0 -203
  63. package/build/cjs/store/store.js +0 -14
  64. package/build/cjs/store/subscribtion/selection.js +0 -47
  65. package/build/cjs/store/subscribtion/subscribeToDrawing.js +0 -9
  66. package/build/cjs/types/ErrorTypes.js +0 -2
  67. package/build/cjs/types/IGraphicPackage.js +0 -24
  68. package/build/cjs/types/IStructurePatch.js +0 -2
  69. package/build/cjs/types/IStructureTree.js +0 -27
  70. package/build/cjs/types/index.js +0 -16
  71. package/build/cjs/utils/Math.js +0 -33
  72. package/build/cjs/utils/Measure.js +0 -576
  73. package/build/cjs/utils/Timing.js +0 -34
  74. package/build/types/types/index.d.ts +0 -4
File without changes
File without changes
@@ -0,0 +1,36 @@
1
+ export * from './store';
2
+ export * from './geometry';
3
+ export * from './types';
4
+ export * from './utils/Math';
5
+ export * from './utils/Measure';
6
+ export * from './utils/Timing';
7
+ export * from './store/subscribtion/subscribeToDrawing';
8
+ /**
9
+ * Because babel typescript tools can not handle the type definitions
10
+ * in an other way, they have to be re-exported as you can see in this code region.
11
+ *
12
+ * Please have a look at https://github.com/awv-informatik/buerli/pull/129 for more information.
13
+ */
14
+ import { BuerliState as BS } from './store/states/buerli';
15
+ export declare type BuerliState = BS;
16
+ import { DrawingAPI as DrawingAPI1, DrawingID as DrawingID1, DrawingState as DrawingState1 } from './store/states/drawing';
17
+ export declare type DrawingID = DrawingID1;
18
+ export declare type DrawingState = DrawingState1;
19
+ export declare type DrawingAPI = DrawingAPI1;
20
+ import { GeometryConfig as GeometryConfig1, GeometryBounds as GeometryBounds1 } from './store/states/geometry';
21
+ export declare type GeometryConfig = GeometryConfig1;
22
+ export declare type GeometryBounds = GeometryBounds1;
23
+ import { Plugin as Plugin1, PluginDescription as PluginDescription1, PluginID as PluginID1, PluginState as PluginState1 } from './store/states/plugin';
24
+ export declare type Plugin = Plugin1;
25
+ export declare type PluginDescription<InternalState = any> = PluginDescription1<InternalState>;
26
+ export declare type PluginID = PluginID1;
27
+ export declare type PluginState<InternalState = any> = PluginState1<InternalState>;
28
+ import { SeletedItemData, SelectedItem as SelectedItem1, SelectionFilter as SelectionFilter1, SelectionScope as SelectionScope1, Selector as Selector1, SelectorID as SelectorID1, CustomSelect as CustomSelect1 } from './store/states/selection';
29
+ export declare type SelectedItem<T extends SeletedItemData<any> = any> = SelectedItem1<T>;
30
+ export declare type SelectionFilter = SelectionFilter1;
31
+ export declare type SelectionScope = SelectionScope1;
32
+ export declare type Selector<T extends SeletedItemData<any> = any> = Selector1<T>;
33
+ export declare type SelectorID = SelectorID1;
34
+ export declare type CustomSelect = CustomSelect1;
35
+ import { Message as Message1 } from './store/states/message';
36
+ export declare type Message = Message1;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -22,6 +22,7 @@ export declare type DrawingAPI = {
22
22
  geometry: GeometryApi;
23
23
  graphic: GraphicApi;
24
24
  canvas: CanvasApi;
25
+ setCustom: (key: string, value: Record<string, any>) => void;
25
26
  };
26
27
  declare type StateData = {
27
28
  id: DrawingID;
@@ -32,6 +33,7 @@ declare type StateData = {
32
33
  canvas: CanvasData;
33
34
  selection: SelectionData;
34
35
  plugin: PluginData;
36
+ custom: any;
35
37
  };
36
38
  export declare type DrawingState = Readonly<StateData> & Readonly<{
37
39
  api: DrawingAPI;
@@ -26,6 +26,7 @@ export const createDrawingState = (set, get, api, drawingNumber, name) => {
26
26
  geometry: geometryData(),
27
27
  graphic: graphicData(),
28
28
  canvas: canvasData(),
29
+ custom: {},
29
30
  api: {
30
31
  structure: structureApi(set, get),
31
32
  selection: selectionApi(set, get),
@@ -33,6 +34,9 @@ export const createDrawingState = (set, get, api, drawingNumber, name) => {
33
34
  geometry: geometryApi(set, get),
34
35
  graphic: graphicApi(set, get),
35
36
  canvas: canvasApi(set, get),
37
+ setCustom: (key, value) => {
38
+ set(state => (Object.assign(Object.assign({}, state), { custom: Object.assign(Object.assign({}, state.custom), { [key]: Object.assign(Object.assign({}, state.custom[key]), value) }) })));
39
+ },
36
40
  },
37
41
  id: drawingId,
38
42
  name: name || `Drawing #${drawingNumber}`,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,36 +1,4 @@
1
- export * from './store';
2
- export * from './geometry';
3
- export * from './types';
4
- export * from './utils/Math';
5
- export * from './utils/Measure';
6
- export * from './utils/Timing';
7
- export * from './store/subscribtion/subscribeToDrawing';
8
- /**
9
- * Because babel typescript tools can not handle the type definitions
10
- * in an other way, they have to be re-exported as you can see in this code region.
11
- *
12
- * Please have a look at https://github.com/awv-informatik/buerli/pull/129 for more information.
13
- */
14
- import { BuerliState as BS } from './store/states/buerli';
15
- export declare type BuerliState = BS;
16
- import { DrawingAPI as DrawingAPI1, DrawingID as DrawingID1, DrawingState as DrawingState1 } from './store/states/drawing';
17
- export declare type DrawingID = DrawingID1;
18
- export declare type DrawingState = DrawingState1;
19
- export declare type DrawingAPI = DrawingAPI1;
20
- import { GeometryConfig as GeometryConfig1, GeometryBounds as GeometryBounds1 } from './store/states/geometry';
21
- export declare type GeometryConfig = GeometryConfig1;
22
- export declare type GeometryBounds = GeometryBounds1;
23
- import { Plugin as Plugin1, PluginDescription as PluginDescription1, PluginID as PluginID1, PluginState as PluginState1 } from './store/states/plugin';
24
- export declare type Plugin = Plugin1;
25
- export declare type PluginDescription<InternalState = any> = PluginDescription1<InternalState>;
26
- export declare type PluginID = PluginID1;
27
- export declare type PluginState<InternalState = any> = PluginState1<InternalState>;
28
- import { SeletedItemData, SelectedItem as SelectedItem1, SelectionFilter as SelectionFilter1, SelectionScope as SelectionScope1, Selector as Selector1, SelectorID as SelectorID1, CustomSelect as CustomSelect1 } from './store/states/selection';
29
- export declare type SelectedItem<T extends SeletedItemData<any> = any> = SelectedItem1<T>;
30
- export declare type SelectionFilter = SelectionFilter1;
31
- export declare type SelectionScope = SelectionScope1;
32
- export declare type Selector<T extends SeletedItemData<any> = any> = Selector1<T>;
33
- export declare type SelectorID = SelectorID1;
34
- export declare type CustomSelect = CustomSelect1;
35
- import { Message as Message1 } from './store/states/message';
36
- export declare type Message = Message1;
1
+ export * from './ErrorTypes';
2
+ export * from './IGraphicPackage';
3
+ export * from './IStructurePatch';
4
+ export * from './IStructureTree';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,22 +1,19 @@
1
1
  {
2
2
  "name": "@buerli.io/core",
3
- "version": "0.0.35-beta.1",
3
+ "version": "0.0.35",
4
4
  "description": "buerli state management",
5
5
  "author": "AWV Informatik AG <info@awv-informatik.ch>",
6
6
  "repository": {},
7
- "main": "build/cjs/index.js",
8
- "module": "build/esm/index.js",
9
- "types": "build/types/index.d.ts",
7
+ "main": "build/index.js",
8
+ "module": "build/index.js",
9
+ "types": "build/index.d.ts",
10
10
  "sideEffects": false,
11
11
  "scripts": {
12
12
  "ver": "npm version",
13
13
  "prepack": "npm run build:dist",
14
14
  "clean": "rimraf ./build && rimraf ./coverage",
15
- "build": "npm run build:esm -- --sourceMap true --declaration true --declarationDir ./build/types",
16
- "build:dist": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:types && echo DONE",
17
- "build:esm": "tsc --target es2017 --module esNext --declaration false --declarationDir null --sourceMap false --outDir ./build/esm",
18
- "build:cjs": "tsc --target es2017 --module commonjs --declaration false --declarationDir null --sourceMap false --outDir ./build/cjs",
19
- "build:types": "tsc --declaration --emitDeclarationOnly --outDir ./build/types",
15
+ "build": "echo Typescript: && tsc --version && tsc && echo DONE",
16
+ "build:dist": "npm run clean && echo Typescript: && tsc --version && tsc --sourceMap false && echo DONE",
20
17
  "lint": "eslint \"./src/**/*.ts?(x)\"",
21
18
  "test": "jest",
22
19
  "coverage": "npm run clean && npm run build && npm run jestLite -- --coverage",
@@ -1,284 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.isEqualGeometry = exports.EMPTY_CONTAINER_GEOMETRY = exports.ThreeGeometryCreator = void 0;
23
- const THREE = __importStar(require("three"));
24
- const types_1 = require("./../types");
25
- /**
26
- * Creates THREE geometry based on the data within a @see IGraphicContainer.
27
- */
28
- class ThreeGeometryCreator {
29
- constructor() {
30
- this.coordHeightTolerance = 0.01;
31
- }
32
- getMetadata(geometry, container, color = [0, 0, 0], opacity = 0) {
33
- const contProps = container.properties; // container has always properties
34
- const geomProps = geometry ? geometry.properties : {};
35
- let col = container.properties.material.color || color;
36
- let opa = container.properties.material.opacity || opacity;
37
- if (geomProps && geomProps.material) {
38
- col = geomProps.material.color || col;
39
- opa = geomProps.material.opacity || opa;
40
- }
41
- const rgbColor = new THREE.Color(col[0] / 255, col[1] / 255, col[2] / 255);
42
- const layer = geomProps && geomProps.layer ? geomProps.layer : contProps.layer;
43
- return { color: rgbColor, opacity: opa, layer, container: { id: container.id, ownerId: container.owner } };
44
- }
45
- createGeometry(container, color = [0, 0, 0]) {
46
- const graphicId = container.id;
47
- const { properties } = container;
48
- const box = { min: new THREE.Vector3(...properties.min), max: new THREE.Vector3(...properties.max) };
49
- const meshes = [];
50
- const lines = [];
51
- const edges = [];
52
- const arcs = [];
53
- const pointMap = {};
54
- const map = {};
55
- if (container.meshes) {
56
- container.meshes.forEach(mesh => {
57
- const elem = this.createSurface(mesh, container, color);
58
- if (elem.isValid) {
59
- meshes.push(elem);
60
- map[mesh.id] = elem;
61
- }
62
- else {
63
- // TODO: The server should not send invalid meshes.
64
- console.warn(`Invalid mesh detected`);
65
- }
66
- });
67
- }
68
- if (container.lines) {
69
- container.lines.forEach(line => {
70
- const elem = this.createLine(line, container, pointMap, color);
71
- lines.push(elem);
72
- map[line.id] = elem;
73
- });
74
- }
75
- if (container.edges) {
76
- container.edges.forEach(edge => {
77
- const elem = this.createEdge(edge, container, pointMap, color);
78
- edges.push(elem);
79
- map[edge.id] = elem;
80
- });
81
- }
82
- if (container.arcs) {
83
- container.arcs.forEach(arc => {
84
- const elem = this.createArc(arc, container, pointMap, color);
85
- arcs.push(elem);
86
- map[arc.id] = elem;
87
- });
88
- }
89
- const points = Object.values(pointMap);
90
- return Object.assign({ graphicId,
91
- map,
92
- meshes,
93
- lines,
94
- edges,
95
- arcs,
96
- points,
97
- box }, this.getMetadata(null, container, color));
98
- }
99
- createSurface(mesh, container, color = [0, 0, 0]) {
100
- let meshGeom = this.createMesh(mesh, container, color);
101
- switch (meshGeom.type) {
102
- case types_1.GraphicType.PLANE:
103
- meshGeom = this.createPlane(mesh, meshGeom);
104
- break;
105
- case types_1.GraphicType.CYLINDER:
106
- meshGeom = this.createCylinder(mesh, meshGeom);
107
- break;
108
- case types_1.GraphicType.CONE:
109
- meshGeom = this.createCone(mesh, meshGeom);
110
- break;
111
- case types_1.GraphicType.SPHERE:
112
- meshGeom = this.createSphere(mesh, meshGeom);
113
- break;
114
- }
115
- return meshGeom;
116
- }
117
- createMesh(mesh, container, color = [0, 0, 0]) {
118
- const graphicId = mesh.id;
119
- const loops = mesh.loops;
120
- const type = mesh.properties.surface.type;
121
- const geometry = new THREE.BufferGeometry();
122
- geometry.setIndex(mesh.indices);
123
- geometry.setAttribute('position', new THREE.Float32BufferAttribute(mesh.vertices, 3));
124
- mesh.normals && geometry.setAttribute('normal', new THREE.Float32BufferAttribute(mesh.normals, 3));
125
- return Object.assign({
126
- // TODO: The server should not send invalid meshes.
127
- isValid: mesh.vertices && mesh.vertices.length > 0, geometry,
128
- graphicId,
129
- type,
130
- loops }, this.getMetadata(mesh, container, color));
131
- }
132
- createPlane(mesh, meshGeom) {
133
- const type = types_1.GraphicType.PLANE;
134
- const { normal: n, pointOnPlane: p } = mesh.properties.surface;
135
- const pointOnPlane = new THREE.Vector3(p[0], p[1], p[2]);
136
- const normal = new THREE.Vector3(n[0], n[1], n[2]).normalize();
137
- return Object.assign(Object.assign({}, meshGeom), { type, pointOnPlane, normal });
138
- }
139
- createCylinder(mesh, meshGeom) {
140
- const type = types_1.GraphicType.CYLINDER;
141
- const { origin: o, axis: a, height, radius } = mesh.properties.surface;
142
- const origin = new THREE.Vector3(o[0], o[1], o[2]);
143
- const axis = new THREE.Vector3(a[0], a[1], a[2]).normalize();
144
- return Object.assign(Object.assign({}, meshGeom), { type, origin, axis, height, radius });
145
- }
146
- createCone(mesh, meshGeom) {
147
- const type = types_1.GraphicType.CONE;
148
- const { origin: o, axis: a, height, radiusBottom, radiusTop } = mesh.properties.surface;
149
- const origin = new THREE.Vector3(o[0], o[1], o[2]);
150
- const axis = new THREE.Vector3(a[0], a[1], a[2]).normalize();
151
- return Object.assign(Object.assign({}, meshGeom), { type, origin, axis, height, radiusBottom, radiusTop });
152
- }
153
- createSphere(mesh, meshGeom) {
154
- const type = types_1.GraphicType.SPHERE;
155
- const { radius } = mesh.properties.surface;
156
- return Object.assign(Object.assign({}, meshGeom), { type, radius });
157
- }
158
- createLine(line, container, points, color = [0, 0, 0]) {
159
- const graphicId = line.id;
160
- const type = types_1.GraphicType.LINE;
161
- const pts = line.points;
162
- const [startId, endId] = line.pointIds;
163
- const start = new THREE.Vector3(pts[0], pts[1], pts[2]);
164
- const end = new THREE.Vector3(pts[3], pts[4], pts[5]);
165
- this.insertPoint(container, `${startId}|point`, startId, start.clone(), line.id, 'start', points);
166
- this.insertPoint(container, `${endId}|point`, endId, end.clone(), line.id, 'end', points);
167
- const geometry = new THREE.BufferGeometry().setFromPoints([start.clone(), end.clone()]);
168
- return Object.assign(Object.assign({ geometry,
169
- graphicId,
170
- type }, this.getMetadata(line, container, color)), { start: start.clone(), end: end.clone() });
171
- }
172
- createEdge(edge, container, points, color = [0, 0, 0]) {
173
- const threePts = [];
174
- const graphicId = edge.id;
175
- const type = types_1.GraphicType.EDGE;
176
- const pts = edge.points;
177
- for (let i = 0, length = pts.length / 3; i < length; i++) {
178
- threePts.push(new THREE.Vector3(pts[i * 3], pts[i * 3 + 1], pts[i * 3 + 2]));
179
- // Each segment has to be defined with start and end to use it for BufferGeometry
180
- if (i > 0) {
181
- threePts.push(new THREE.Vector3(pts[i * 3], pts[i * 3 + 1], pts[i * 3 + 2]));
182
- }
183
- }
184
- // Seems like the three BufferGeometryUtils expect an edge to have an even number of points.
185
- // Just add the end point twice if this is not the case.
186
- if (threePts.length % 2 !== 0) {
187
- threePts.push(threePts[threePts.length - 1].clone());
188
- }
189
- const start = threePts[0].clone();
190
- const end = threePts[threePts.length - 1].clone();
191
- const startId = edge.pointIds[0];
192
- const endId = edge.pointIds[edge.pointIds.length - 1];
193
- this.insertPoint(container, `${startId}|point`, startId, start, edge.id, 'start', points);
194
- this.insertPoint(container, `${endId}|point`, endId, end, edge.id, 'end', points);
195
- const geometry = new THREE.BufferGeometry().setFromPoints(threePts);
196
- return Object.assign(Object.assign({ geometry,
197
- graphicId,
198
- type }, this.getMetadata(edge, container, color)), { start: start.clone(), end: end.clone() });
199
- }
200
- createArc(arc, container, points, color = [0, 0, 0]) {
201
- const graphicId = arc.id;
202
- const type = arc.isCircle ? types_1.GraphicType.CIRCLE : types_1.GraphicType.ARC;
203
- // take half of coordHeightTolerance used for faces, as classcad does it in the tessellation process
204
- const coordHeight = this.coordHeightTolerance / 2;
205
- const radius = arc.radius;
206
- const center = new THREE.Vector3(arc.center[0], arc.center[1], arc.center[2]);
207
- const normal = new THREE.Vector3(arc.zAxis[0], arc.zAxis[1], arc.zAxis[2]).normalize();
208
- const startVector = new THREE.Vector3(arc.xAxis[0], arc.xAxis[1], arc.xAxis[2]).normalize().multiplyScalar(radius);
209
- const theta = arc.isCircle ? Math.PI * 2 : arc.angle;
210
- // calculate angle for one segment to fulfill coordHeight tolerance
211
- let alpha = 2 * Math.acos(1 - coordHeight / radius);
212
- // calculate number of segments
213
- let segments = Math.ceil(Math.abs(arc.angle) / alpha);
214
- // choose at minimum three segments
215
- segments = Math.max(3, segments);
216
- // adjust angle to match with number of segments, still fulfilling coordHeigth tolerance
217
- alpha = theta / segments;
218
- const threePts = [];
219
- const matrix = new THREE.Matrix4().makeRotationAxis(normal, alpha);
220
- const startPoint = center.clone();
221
- startPoint.add(startVector);
222
- threePts.push(startPoint);
223
- for (let i = 0; i < segments; i++) {
224
- startVector.applyMatrix4(matrix);
225
- const nextPoint = center.clone();
226
- nextPoint.add(startVector);
227
- threePts.push(nextPoint.clone());
228
- // Each segment has to be defined with start and end to use it for BufferGeometry
229
- threePts.push(nextPoint.clone());
230
- }
231
- // Seems like the three BufferGeometryUtils expect an edge to have an even number of points.
232
- // Just add the end point twice if this is not the case.
233
- if (threePts.length % 2 !== 0) {
234
- threePts.push(threePts[threePts.length - 1].clone());
235
- }
236
- const [startId, endId] = arc.pointIds;
237
- const start = threePts[0].clone();
238
- const end = threePts[threePts.length - 1].clone();
239
- this.insertPoint(container, `${startId}|point`, startId, start, arc.id, 'start', points);
240
- this.insertPoint(container, `${endId}|point`, endId, end, arc.id, 'end', points);
241
- const geometry = new THREE.BufferGeometry().setFromPoints(threePts);
242
- return Object.assign(Object.assign({ geometry,
243
- graphicId,
244
- type }, this.getMetadata(arc, container, color)), { normal: normal.clone(), center: center.clone(), radius: arc.radius, angle: arc.angle });
245
- }
246
- createPoint(container, key, graphicId, position, ownerId, type) {
247
- return Object.assign(Object.assign({ key,
248
- graphicId, type: types_1.GraphicType.POINT }, this.getMetadata(null, container)), { position: position.clone(), geometry: position.clone(), owners: [{ ownerId, type }] });
249
- }
250
- insertPoint(container, key, graphicId, position, ownerId, type, points) {
251
- const existingPoint = points[key];
252
- if (existingPoint) {
253
- const filteredOwners = existingPoint.owners.filter(gr => gr.ownerId === ownerId && gr.type === type);
254
- if (filteredOwners.length <= 0) {
255
- existingPoint.owners.push({ ownerId, type });
256
- }
257
- }
258
- else {
259
- points[key] = this.createPoint(container, key, graphicId, position, ownerId, type);
260
- }
261
- }
262
- }
263
- exports.ThreeGeometryCreator = ThreeGeometryCreator;
264
- const EMPTY_CONTAINER_GEOMETRY = () => {
265
- return {
266
- graphicId: Number.NaN,
267
- map: {},
268
- meshes: [],
269
- lines: [],
270
- edges: [],
271
- arcs: [],
272
- points: [],
273
- box: { min: new THREE.Vector3(), max: new THREE.Vector3() },
274
- container: { id: NaN, ownerId: NaN },
275
- color: new THREE.Color(),
276
- opacity: 1.0,
277
- layer: null,
278
- };
279
- };
280
- exports.EMPTY_CONTAINER_GEOMETRY = EMPTY_CONTAINER_GEOMETRY;
281
- const isEqualGeometry = (a, b) => {
282
- return a.graphicId === b.graphicId && a.type === b.type;
283
- };
284
- exports.isEqualGeometry = isEqualGeometry;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./ThreeGeometryCreator"), exports);
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./store"), exports);
14
- __exportStar(require("./geometry"), exports);
15
- __exportStar(require("./types"), exports);
16
- __exportStar(require("./utils/Math"), exports);
17
- __exportStar(require("./utils/Measure"), exports);
18
- __exportStar(require("./utils/Timing"), exports);
19
- __exportStar(require("./store/subscribtion/subscribeToDrawing"), exports);
20
- //#endregion Re-export type definitions
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.updateMessage = exports.showMessage = exports.init = exports.getPlugin = exports.getDrawing = exports.createGraphicItem = exports.BuerliScope = exports.BuerliMessageScope = void 0;
14
- const store_1 = require("./store");
15
- function getDrawing(id) {
16
- const { drawing } = store_1.api.getState();
17
- return drawing.refs[id];
18
- }
19
- exports.getDrawing = getDrawing;
20
- /**
21
- * @returns PluginState or undefined if either drawing or plugin don't exist
22
- */
23
- function getPlugin(drawingId, pluginId) {
24
- var _a;
25
- const { drawing } = store_1.api.getState();
26
- return (_a = drawing.refs[drawingId]) === null || _a === void 0 ? void 0 : _a.plugin.refs[pluginId];
27
- }
28
- exports.getPlugin = getPlugin;
29
- function init(sel) {
30
- store_1.api.getState().api.init(typeof sel === 'function' ? sel(store_1.api.getState()) || {} : sel);
31
- }
32
- exports.init = init;
33
- function showMessage(message) {
34
- return store_1.api.getState().message.api.show(message);
35
- }
36
- exports.showMessage = showMessage;
37
- function updateMessage(id, message) {
38
- store_1.api.getState().message.api.update(id, message);
39
- }
40
- exports.updateMessage = updateMessage;
41
- var message_1 = require("./states/message");
42
- Object.defineProperty(exports, "BuerliMessageScope", { enumerable: true, get: function () { return message_1.BuerliMessageScope; } });
43
- var selection_1 = require("./states/selection");
44
- Object.defineProperty(exports, "BuerliScope", { enumerable: true, get: function () { return selection_1.BuerliScope; } });
45
- Object.defineProperty(exports, "createGraphicItem", { enumerable: true, get: function () { return selection_1.createGraphicItem; } });
46
- __exportStar(require("./store"), exports);