@buerli.io/core 0.0.35-beta.0 → 0.0.35-beta.4
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.
- package/build/{types/geometry → geometry}/ThreeGeometryCreator.d.ts +0 -0
- package/build/{esm/geometry → geometry}/ThreeGeometryCreator.js +17 -47
- package/build/{types/geometry → geometry}/index.d.ts +0 -0
- package/build/{esm/geometry → geometry}/index.js +0 -0
- package/build/index.d.ts +36 -0
- package/build/{esm/index.js → index.js} +0 -0
- package/build/{types/store → store}/index.d.ts +0 -0
- package/build/{esm/store → store}/index.js +2 -1
- package/build/{types/store → store}/states/buerli.d.ts +0 -0
- package/build/{cjs/store → store}/states/buerli.js +5 -9
- package/build/{types/store → store}/states/canvas.d.ts +0 -0
- package/build/{cjs/store → store}/states/canvas.js +2 -7
- package/build/{types/store → store}/states/drawing.d.ts +2 -0
- package/build/{esm/store → store}/states/drawing.js +4 -0
- package/build/{types/store → store}/states/geometry.d.ts +0 -0
- package/build/{cjs/store → store}/states/geometry.js +5 -29
- package/build/{types/store → store}/states/graphic.d.ts +0 -0
- package/build/{cjs/store → store}/states/graphic.js +2 -7
- package/build/{types/store → store}/states/message.d.ts +0 -0
- package/build/{esm/store → store}/states/message.js +2 -2
- package/build/{types/store → store}/states/plugin.d.ts +0 -0
- package/build/{cjs/store → store}/states/plugin.js +5 -11
- package/build/{types/store → store}/states/selection.d.ts +0 -0
- package/build/{cjs/store → store}/states/selection.js +14 -20
- package/build/{types/store → store}/states/structure.d.ts +0 -0
- package/build/{esm/store → store}/states/structure.js +4 -10
- package/build/{types/store → store}/store.d.ts +0 -0
- package/build/{esm/store → store}/store.js +0 -0
- package/build/{types/store → store}/subscribtion/selection.d.ts +0 -0
- package/build/{esm/store → store}/subscribtion/selection.js +2 -1
- package/build/{types/store → store}/subscribtion/subscribeToDrawing.d.ts +0 -0
- package/build/{esm/store → store}/subscribtion/subscribeToDrawing.js +0 -0
- package/build/types/{types/ErrorTypes.d.ts → ErrorTypes.d.ts} +0 -0
- package/build/{esm/types → types}/ErrorTypes.js +0 -0
- package/build/types/{types/IGraphicPackage.d.ts → IGraphicPackage.d.ts} +0 -0
- package/build/{esm/types → types}/IGraphicPackage.js +0 -0
- package/build/types/{types/IStructurePatch.d.ts → IStructurePatch.d.ts} +0 -0
- package/build/{esm/types → types}/IStructurePatch.js +0 -0
- package/build/types/{types/IStructureTree.d.ts → IStructureTree.d.ts} +0 -0
- package/build/{esm/types → types}/IStructureTree.js +0 -0
- package/build/types/index.d.ts +4 -36
- package/build/{esm/types → types}/index.js +0 -0
- package/build/{types/utils → utils}/Math.d.ts +0 -0
- package/build/{esm/utils → utils}/Math.js +0 -0
- package/build/{types/utils → utils}/Measure.d.ts +0 -0
- package/build/{esm/utils → utils}/Measure.js +1 -1
- package/build/{types/utils → utils}/Timing.d.ts +0 -0
- package/build/{esm/utils → utils}/Timing.js +1 -1
- package/package.json +6 -9
- package/build/cjs/geometry/ThreeGeometryCreator.js +0 -284
- package/build/cjs/geometry/index.js +0 -13
- package/build/cjs/index.js +0 -20
- package/build/cjs/store/index.js +0 -46
- package/build/cjs/store/states/drawing.js +0 -44
- package/build/cjs/store/states/message.js +0 -25
- package/build/cjs/store/states/structure.js +0 -203
- package/build/cjs/store/store.js +0 -14
- package/build/cjs/store/subscribtion/selection.js +0 -47
- package/build/cjs/store/subscribtion/subscribeToDrawing.js +0 -9
- package/build/cjs/types/ErrorTypes.js +0 -2
- package/build/cjs/types/IGraphicPackage.js +0 -24
- package/build/cjs/types/IStructurePatch.js +0 -2
- package/build/cjs/types/IStructureTree.js +0 -27
- package/build/cjs/types/index.js +0 -16
- package/build/cjs/utils/Math.js +0 -33
- package/build/cjs/utils/Measure.js +0 -576
- package/build/cjs/utils/Timing.js +0 -34
- package/build/esm/store/states/buerli.js +0 -116
- package/build/esm/store/states/canvas.js +0 -13
- package/build/esm/store/states/geometry.js +0 -98
- package/build/esm/store/states/graphic.js +0 -82
- package/build/esm/store/states/plugin.js +0 -152
- package/build/esm/store/states/selection.js +0 -269
- package/build/types/types/index.d.ts +0 -4
|
File without changes
|
|
@@ -65,17 +65,14 @@ export class ThreeGeometryCreator {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
const points = Object.values(pointMap);
|
|
68
|
-
return {
|
|
69
|
-
graphicId,
|
|
68
|
+
return Object.assign({ graphicId,
|
|
70
69
|
map,
|
|
71
70
|
meshes,
|
|
72
71
|
lines,
|
|
73
72
|
edges,
|
|
74
73
|
arcs,
|
|
75
74
|
points,
|
|
76
|
-
box,
|
|
77
|
-
...this.getMetadata(null, container, color),
|
|
78
|
-
};
|
|
75
|
+
box }, this.getMetadata(null, container, color));
|
|
79
76
|
}
|
|
80
77
|
createSurface(mesh, container, color = [0, 0, 0]) {
|
|
81
78
|
let meshGeom = this.createMesh(mesh, container, color);
|
|
@@ -103,41 +100,38 @@ export class ThreeGeometryCreator {
|
|
|
103
100
|
geometry.setIndex(mesh.indices);
|
|
104
101
|
geometry.setAttribute('position', new THREE.Float32BufferAttribute(mesh.vertices, 3));
|
|
105
102
|
mesh.normals && geometry.setAttribute('normal', new THREE.Float32BufferAttribute(mesh.normals, 3));
|
|
106
|
-
return {
|
|
103
|
+
return Object.assign({
|
|
107
104
|
// TODO: The server should not send invalid meshes.
|
|
108
|
-
isValid: mesh.vertices && mesh.vertices.length > 0,
|
|
109
|
-
geometry,
|
|
105
|
+
isValid: mesh.vertices && mesh.vertices.length > 0, geometry,
|
|
110
106
|
graphicId,
|
|
111
107
|
type,
|
|
112
|
-
loops,
|
|
113
|
-
...this.getMetadata(mesh, container, color),
|
|
114
|
-
};
|
|
108
|
+
loops }, this.getMetadata(mesh, container, color));
|
|
115
109
|
}
|
|
116
110
|
createPlane(mesh, meshGeom) {
|
|
117
111
|
const type = GraphicType.PLANE;
|
|
118
112
|
const { normal: n, pointOnPlane: p } = mesh.properties.surface;
|
|
119
113
|
const pointOnPlane = new THREE.Vector3(p[0], p[1], p[2]);
|
|
120
114
|
const normal = new THREE.Vector3(n[0], n[1], n[2]).normalize();
|
|
121
|
-
return {
|
|
115
|
+
return Object.assign(Object.assign({}, meshGeom), { type, pointOnPlane, normal });
|
|
122
116
|
}
|
|
123
117
|
createCylinder(mesh, meshGeom) {
|
|
124
118
|
const type = GraphicType.CYLINDER;
|
|
125
119
|
const { origin: o, axis: a, height, radius } = mesh.properties.surface;
|
|
126
120
|
const origin = new THREE.Vector3(o[0], o[1], o[2]);
|
|
127
121
|
const axis = new THREE.Vector3(a[0], a[1], a[2]).normalize();
|
|
128
|
-
return {
|
|
122
|
+
return Object.assign(Object.assign({}, meshGeom), { type, origin, axis, height, radius });
|
|
129
123
|
}
|
|
130
124
|
createCone(mesh, meshGeom) {
|
|
131
125
|
const type = GraphicType.CONE;
|
|
132
126
|
const { origin: o, axis: a, height, radiusBottom, radiusTop } = mesh.properties.surface;
|
|
133
127
|
const origin = new THREE.Vector3(o[0], o[1], o[2]);
|
|
134
128
|
const axis = new THREE.Vector3(a[0], a[1], a[2]).normalize();
|
|
135
|
-
return {
|
|
129
|
+
return Object.assign(Object.assign({}, meshGeom), { type, origin, axis, height, radiusBottom, radiusTop });
|
|
136
130
|
}
|
|
137
131
|
createSphere(mesh, meshGeom) {
|
|
138
132
|
const type = GraphicType.SPHERE;
|
|
139
133
|
const { radius } = mesh.properties.surface;
|
|
140
|
-
return {
|
|
134
|
+
return Object.assign(Object.assign({}, meshGeom), { type, radius });
|
|
141
135
|
}
|
|
142
136
|
createLine(line, container, points, color = [0, 0, 0]) {
|
|
143
137
|
const graphicId = line.id;
|
|
@@ -149,14 +143,9 @@ export class ThreeGeometryCreator {
|
|
|
149
143
|
this.insertPoint(container, `${startId}|point`, startId, start.clone(), line.id, 'start', points);
|
|
150
144
|
this.insertPoint(container, `${endId}|point`, endId, end.clone(), line.id, 'end', points);
|
|
151
145
|
const geometry = new THREE.BufferGeometry().setFromPoints([start.clone(), end.clone()]);
|
|
152
|
-
return {
|
|
153
|
-
geometry,
|
|
146
|
+
return Object.assign(Object.assign({ geometry,
|
|
154
147
|
graphicId,
|
|
155
|
-
type,
|
|
156
|
-
...this.getMetadata(line, container, color),
|
|
157
|
-
start: start.clone(),
|
|
158
|
-
end: end.clone(),
|
|
159
|
-
};
|
|
148
|
+
type }, this.getMetadata(line, container, color)), { start: start.clone(), end: end.clone() });
|
|
160
149
|
}
|
|
161
150
|
createEdge(edge, container, points, color = [0, 0, 0]) {
|
|
162
151
|
const threePts = [];
|
|
@@ -182,14 +171,9 @@ export class ThreeGeometryCreator {
|
|
|
182
171
|
this.insertPoint(container, `${startId}|point`, startId, start, edge.id, 'start', points);
|
|
183
172
|
this.insertPoint(container, `${endId}|point`, endId, end, edge.id, 'end', points);
|
|
184
173
|
const geometry = new THREE.BufferGeometry().setFromPoints(threePts);
|
|
185
|
-
return {
|
|
186
|
-
geometry,
|
|
174
|
+
return Object.assign(Object.assign({ geometry,
|
|
187
175
|
graphicId,
|
|
188
|
-
type,
|
|
189
|
-
...this.getMetadata(edge, container, color),
|
|
190
|
-
start: start.clone(),
|
|
191
|
-
end: end.clone(),
|
|
192
|
-
};
|
|
176
|
+
type }, this.getMetadata(edge, container, color)), { start: start.clone(), end: end.clone() });
|
|
193
177
|
}
|
|
194
178
|
createArc(arc, container, points, color = [0, 0, 0]) {
|
|
195
179
|
const graphicId = arc.id;
|
|
@@ -233,27 +217,13 @@ export class ThreeGeometryCreator {
|
|
|
233
217
|
this.insertPoint(container, `${startId}|point`, startId, start, arc.id, 'start', points);
|
|
234
218
|
this.insertPoint(container, `${endId}|point`, endId, end, arc.id, 'end', points);
|
|
235
219
|
const geometry = new THREE.BufferGeometry().setFromPoints(threePts);
|
|
236
|
-
return {
|
|
237
|
-
geometry,
|
|
220
|
+
return Object.assign(Object.assign({ geometry,
|
|
238
221
|
graphicId,
|
|
239
|
-
type,
|
|
240
|
-
...this.getMetadata(arc, container, color),
|
|
241
|
-
normal: normal.clone(),
|
|
242
|
-
center: center.clone(),
|
|
243
|
-
radius: arc.radius,
|
|
244
|
-
angle: arc.angle,
|
|
245
|
-
};
|
|
222
|
+
type }, this.getMetadata(arc, container, color)), { normal: normal.clone(), center: center.clone(), radius: arc.radius, angle: arc.angle });
|
|
246
223
|
}
|
|
247
224
|
createPoint(container, key, graphicId, position, ownerId, type) {
|
|
248
|
-
return {
|
|
249
|
-
|
|
250
|
-
graphicId,
|
|
251
|
-
type: GraphicType.POINT,
|
|
252
|
-
...this.getMetadata(null, container),
|
|
253
|
-
position: position.clone(),
|
|
254
|
-
geometry: position.clone(),
|
|
255
|
-
owners: [{ ownerId, type }],
|
|
256
|
-
};
|
|
225
|
+
return Object.assign(Object.assign({ key,
|
|
226
|
+
graphicId, type: GraphicType.POINT }, this.getMetadata(null, container)), { position: position.clone(), geometry: position.clone(), owners: [{ ownerId, type }] });
|
|
257
227
|
}
|
|
258
228
|
insertPoint(container, key, graphicId, position, ownerId, type, points) {
|
|
259
229
|
const existingPoint = points[key];
|
|
File without changes
|
|
File without changes
|
package/build/index.d.ts
ADDED
|
@@ -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
|
|
@@ -7,8 +7,9 @@ function getDrawing(id) {
|
|
|
7
7
|
* @returns PluginState or undefined if either drawing or plugin don't exist
|
|
8
8
|
*/
|
|
9
9
|
function getPlugin(drawingId, pluginId) {
|
|
10
|
+
var _a;
|
|
10
11
|
const { drawing } = api.getState();
|
|
11
|
-
return drawing.refs[drawingId]
|
|
12
|
+
return (_a = drawing.refs[drawingId]) === null || _a === void 0 ? void 0 : _a.plugin.refs[pluginId];
|
|
12
13
|
}
|
|
13
14
|
function init(sel) {
|
|
14
15
|
api.getState().api.init(typeof sel === 'function' ? sel(api.getState()) || {} : sel);
|
|
File without changes
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.createState = void 0;
|
|
4
|
-
const drawing_1 = require("./drawing");
|
|
5
|
-
const message_1 = require("./message");
|
|
1
|
+
import { createDrawingState } from './drawing';
|
|
2
|
+
import { getInitialMessageState } from './message';
|
|
6
3
|
const initError = 'Please call the init action before you use the buerli store.';
|
|
7
|
-
const createState = (set, get, api) => (Object.assign({ initDone: false, options: {
|
|
4
|
+
export const createState = (set, get, api) => (Object.assign({ initDone: false, options: {
|
|
8
5
|
url: '',
|
|
9
6
|
elements: {},
|
|
10
7
|
plugins: {},
|
|
@@ -23,8 +20,7 @@ const createState = (set, get, api) => (Object.assign({ initDone: false, options
|
|
|
23
20
|
ids: [],
|
|
24
21
|
refs: {},
|
|
25
22
|
active: null,
|
|
26
|
-
}, api: Object.assign(Object.assign({}, generalApi(set, get)), drawingManagementApi(set, get, api)) },
|
|
27
|
-
exports.createState = createState;
|
|
23
|
+
}, api: Object.assign(Object.assign({}, generalApi(set, get)), drawingManagementApi(set, get, api)) }, getInitialMessageState(set, get, api)));
|
|
28
24
|
const generalApi = (set, get) => ({
|
|
29
25
|
// TODO: rename init to setOptions and remove initDone if everything is ok
|
|
30
26
|
/**
|
|
@@ -42,7 +38,7 @@ const drawingManagementApi = (set, get, api) => ({
|
|
|
42
38
|
const { initDone, drawing } = get();
|
|
43
39
|
if (!initDone)
|
|
44
40
|
throw new Error(initError);
|
|
45
|
-
const drawingState =
|
|
41
|
+
const drawingState = createDrawingState(sel => set(state => {
|
|
46
42
|
const newState = typeof sel === 'function' ? sel(state.drawing.refs[drawingState.id]) : sel;
|
|
47
43
|
return {
|
|
48
44
|
drawing: Object.assign(Object.assign({}, state.drawing), { refs: Object.assign(Object.assign({}, state.drawing.refs), { [drawingState.id]: Object.assign(Object.assign({}, state.drawing.refs[drawingState.id]), newState) }) }),
|
|
File without changes
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.canvasApi = exports.canvasData = void 0;
|
|
4
1
|
////////////////////////////////////////////////////
|
|
5
2
|
// DATA
|
|
6
3
|
////////////////////////////////////////////////////
|
|
7
|
-
const canvasData = () => ({
|
|
4
|
+
export const canvasData = () => ({
|
|
8
5
|
controls: { isInteracting: false, enabled: true },
|
|
9
6
|
});
|
|
10
|
-
exports.canvasData = canvasData;
|
|
11
7
|
////////////////////////////////////////////////////
|
|
12
8
|
// API
|
|
13
9
|
////////////////////////////////////////////////////
|
|
14
|
-
const canvasApi = (set, get) => ({
|
|
10
|
+
export const canvasApi = (set, get) => ({
|
|
15
11
|
setInteraction: (isInteracting) => set(state => ({ canvas: Object.assign(Object.assign({}, state.canvas), { controls: Object.assign(Object.assign({}, state.canvas.controls), { isInteracting }) }) })),
|
|
16
12
|
setControlsEnabled: (enabled) => set(state => ({ canvas: Object.assign(Object.assign({}, state.canvas), { controls: Object.assign(Object.assign({}, state.canvas.controls), { enabled }) }) })),
|
|
17
13
|
});
|
|
18
|
-
exports.canvasApi = canvasApi;
|
|
@@ -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
|
|
@@ -1,31 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.geometryApi = exports.geometryData = void 0;
|
|
23
|
-
const THREE = __importStar(require("three"));
|
|
24
|
-
const ThreeGeometryCreator_1 = require("../../geometry/ThreeGeometryCreator");
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { ThreeGeometryCreator } from '../../geometry/ThreeGeometryCreator';
|
|
25
3
|
////////////////////////////////////////////////////
|
|
26
4
|
// DATA
|
|
27
5
|
////////////////////////////////////////////////////
|
|
28
|
-
const geometryData = () => ({
|
|
6
|
+
export const geometryData = () => ({
|
|
29
7
|
cache: {},
|
|
30
8
|
stamp: -1,
|
|
31
9
|
bounds: {
|
|
@@ -36,11 +14,10 @@ const geometryData = () => ({
|
|
|
36
14
|
},
|
|
37
15
|
config: { product: {} },
|
|
38
16
|
});
|
|
39
|
-
exports.geometryData = geometryData;
|
|
40
17
|
////////////////////////////////////////////////////
|
|
41
18
|
// API
|
|
42
19
|
////////////////////////////////////////////////////
|
|
43
|
-
const geometryApi = (set, get) => ({
|
|
20
|
+
export const geometryApi = (set, get) => ({
|
|
44
21
|
/**
|
|
45
22
|
* Updates the @see geometry.bounds depending on all products of the model.
|
|
46
23
|
* The update will only happen, if at least one solid of one product is available.
|
|
@@ -58,7 +35,7 @@ const geometryApi = (set, get) => ({
|
|
|
58
35
|
if (!geom) {
|
|
59
36
|
const container = graphic.containers[containerId];
|
|
60
37
|
if (container) {
|
|
61
|
-
geom = new
|
|
38
|
+
geom = new ThreeGeometryCreator().createGeometry(container, color);
|
|
62
39
|
set(state => {
|
|
63
40
|
const geometryCache = Object.assign(Object.assign({}, state.geometry.cache), { [containerId]: geom });
|
|
64
41
|
return {
|
|
@@ -107,4 +84,3 @@ const geometryApi = (set, get) => ({
|
|
|
107
84
|
});
|
|
108
85
|
},
|
|
109
86
|
});
|
|
110
|
-
exports.geometryApi = geometryApi;
|
|
File without changes
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.graphicApi = exports.graphicData = void 0;
|
|
4
1
|
////////////////////////////////////////////////////
|
|
5
2
|
// DATA
|
|
6
3
|
////////////////////////////////////////////////////
|
|
7
|
-
const graphicData = () => ({
|
|
4
|
+
export const graphicData = () => ({
|
|
8
5
|
containers: {},
|
|
9
6
|
});
|
|
10
|
-
exports.graphicData = graphicData;
|
|
11
7
|
////////////////////////////////////////////////////
|
|
12
8
|
// API
|
|
13
9
|
////////////////////////////////////////////////////
|
|
14
|
-
const graphicApi = (set, get) => ({
|
|
10
|
+
export const graphicApi = (set, get) => ({
|
|
15
11
|
addPackages: (packages) => {
|
|
16
12
|
// Timing.dump('load', `add graphic packages ${graphic.length} ${graphic[0].containers.length}`)
|
|
17
13
|
let cacheChanged = false;
|
|
@@ -84,4 +80,3 @@ const graphicApi = (set, get) => ({
|
|
|
84
80
|
}
|
|
85
81
|
},
|
|
86
82
|
});
|
|
87
|
-
exports.graphicApi = graphicApi;
|
|
File without changes
|
|
@@ -11,11 +11,11 @@ const messageApi = (set, get, api) => ({
|
|
|
11
11
|
show(message) {
|
|
12
12
|
const newId = uuidv4();
|
|
13
13
|
const msg = get().message;
|
|
14
|
-
set({ message: {
|
|
14
|
+
set({ message: Object.assign(Object.assign({}, msg), { data: Object.assign({ id: newId }, message), timestamp: Date.now() }) });
|
|
15
15
|
return newId;
|
|
16
16
|
},
|
|
17
17
|
update(id, message) {
|
|
18
18
|
const msg = get().message;
|
|
19
|
-
set({ message: {
|
|
19
|
+
set({ message: Object.assign(Object.assign({}, msg), { data: Object.assign({ id }, message), timestamp: Date.now() }) });
|
|
20
20
|
},
|
|
21
21
|
});
|
|
File without changes
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isPromisePlugin = exports.pluginApi = exports.pluginData = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
const pluginData = () => ({
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
export const pluginData = () => ({
|
|
6
3
|
feature: [],
|
|
7
4
|
global: [],
|
|
8
5
|
refs: {},
|
|
@@ -12,8 +9,7 @@ const pluginData = () => ({
|
|
|
12
9
|
},
|
|
13
10
|
visible: [],
|
|
14
11
|
});
|
|
15
|
-
|
|
16
|
-
const pluginApi = (set, get) => ({
|
|
12
|
+
export const pluginApi = (set, get) => ({
|
|
17
13
|
setActiveFeature: (id) => {
|
|
18
14
|
set(state => {
|
|
19
15
|
let plugins = state.plugin.refs;
|
|
@@ -55,7 +51,7 @@ const pluginApi = (set, get) => ({
|
|
|
55
51
|
},
|
|
56
52
|
// TODO remove defaultId and useEmbeddedPlugin ?
|
|
57
53
|
createPlugin: (def, defaultId, drawingId, objectId) => {
|
|
58
|
-
const id = defaultId !== void 0 ? defaultId :
|
|
54
|
+
const id = defaultId !== void 0 ? defaultId : uuidv4();
|
|
59
55
|
function init(definition) {
|
|
60
56
|
const { description, Root = null, View = null } = definition;
|
|
61
57
|
const initialState = description.initialState || {};
|
|
@@ -106,8 +102,6 @@ const pluginApi = (set, get) => ({
|
|
|
106
102
|
};
|
|
107
103
|
},
|
|
108
104
|
});
|
|
109
|
-
|
|
110
|
-
function isPromisePlugin(def) {
|
|
105
|
+
export function isPromisePlugin(def) {
|
|
111
106
|
return def.then !== undefined;
|
|
112
107
|
}
|
|
113
|
-
exports.isPromisePlugin = isPromisePlugin;
|
|
File without changes
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createGraphicItem = exports.selectionApi = exports.selectionData = exports.BuerliScope = void 0;
|
|
4
|
-
const selection_1 = require("../subscribtion/selection");
|
|
1
|
+
import { subscribeItems, unsubscribeItems } from '../subscribtion/selection';
|
|
5
2
|
////////////////////////////////////////////////////
|
|
6
3
|
// CONSTANTS
|
|
7
4
|
////////////////////////////////////////////////////
|
|
8
|
-
|
|
9
|
-
const selectionData = () => ({
|
|
5
|
+
export const BuerliScope = 'ClassCAD';
|
|
6
|
+
export const selectionData = () => ({
|
|
10
7
|
refs: {},
|
|
11
8
|
active: null,
|
|
12
9
|
});
|
|
13
|
-
|
|
14
|
-
const selectionApi = (set, get) => ({
|
|
10
|
+
export const selectionApi = (set, get) => ({
|
|
15
11
|
unselectAll() {
|
|
16
12
|
const drawingId = get().id;
|
|
17
13
|
const activeSelector = get().selection.active;
|
|
18
14
|
if (activeSelector) {
|
|
19
15
|
const unselItems = get().selection.refs[activeSelector].items;
|
|
20
|
-
|
|
16
|
+
unsubscribeItems(drawingId, activeSelector, unselItems);
|
|
21
17
|
set(state => {
|
|
22
18
|
const selector = state.selection.refs[activeSelector];
|
|
23
19
|
return {
|
|
@@ -33,7 +29,7 @@ const selectionApi = (set, get) => ({
|
|
|
33
29
|
// Remove unselItems from selector's items
|
|
34
30
|
const selector = selection.refs[activeSelectorId];
|
|
35
31
|
const newItems = selector.items.filter(item => unselItems.find(uItem => uItem.id === item.id) === undefined);
|
|
36
|
-
|
|
32
|
+
unsubscribeItems(drawingId, activeSelectorId, unselItems);
|
|
37
33
|
if (selector.customUnSelect) {
|
|
38
34
|
// Find recently unselected items
|
|
39
35
|
const diff = selector.items.filter(item1 => {
|
|
@@ -92,9 +88,9 @@ const selectionApi = (set, get) => ({
|
|
|
92
88
|
}
|
|
93
89
|
else {
|
|
94
90
|
// subscribe items which will be selected
|
|
95
|
-
|
|
91
|
+
subscribeItems(drawingId, activeSelectorId, result);
|
|
96
92
|
// unsubscribe items which will be unselected
|
|
97
|
-
|
|
93
|
+
unsubscribeItems(drawingId, activeSelectorId, unsubItems);
|
|
98
94
|
set(state => {
|
|
99
95
|
return {
|
|
100
96
|
selection: Object.assign(Object.assign({}, state.selection), { refs: Object.assign(Object.assign({}, state.selection.refs), { [activeSelectorId]: Object.assign(Object.assign({}, selector), { items: result }) }) }),
|
|
@@ -142,7 +138,7 @@ const selectionApi = (set, get) => ({
|
|
|
142
138
|
return () => {
|
|
143
139
|
if (get && get()) {
|
|
144
140
|
const drawingId = get().id;
|
|
145
|
-
|
|
141
|
+
unsubscribeItems(drawingId, selectorId);
|
|
146
142
|
set(state => {
|
|
147
143
|
const refs = state.selection.refs;
|
|
148
144
|
delete refs[selectorId];
|
|
@@ -180,8 +176,8 @@ const selectionApi = (set, get) => ({
|
|
|
180
176
|
var _a;
|
|
181
177
|
const { selection, id: drawingId } = get();
|
|
182
178
|
const curItems = ((_a = selection.refs[id]) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
183
|
-
|
|
184
|
-
|
|
179
|
+
unsubscribeItems(drawingId, id, curItems);
|
|
180
|
+
subscribeItems(drawingId, id, items);
|
|
185
181
|
set(state => {
|
|
186
182
|
const selector = state.selection.refs[id];
|
|
187
183
|
return {
|
|
@@ -200,27 +196,25 @@ const selectionApi = (set, get) => ({
|
|
|
200
196
|
if (graphicId !== undefined) {
|
|
201
197
|
const geomElem = container.map[graphicId];
|
|
202
198
|
if (geomElem) {
|
|
203
|
-
return
|
|
199
|
+
return createGraphicItem(productId, geomElem);
|
|
204
200
|
}
|
|
205
201
|
}
|
|
206
202
|
}
|
|
207
203
|
return null;
|
|
208
204
|
},
|
|
209
205
|
});
|
|
210
|
-
exports.selectionApi = selectionApi;
|
|
211
206
|
////////////////////////////////////////////////////
|
|
212
207
|
//#region GLOBAL FUNCTIONS
|
|
213
208
|
const areItemsEqual = (a, b) => a.id === b.id && a.scope === b.scope;
|
|
214
209
|
const createGraphicIdent = (productId, graphicId, type) => {
|
|
215
210
|
return {
|
|
216
211
|
id: `${productId}|${graphicId}|${type}`,
|
|
217
|
-
scope:
|
|
212
|
+
scope: BuerliScope,
|
|
218
213
|
label: (type[0] + type[1]).toUpperCase(),
|
|
219
214
|
};
|
|
220
215
|
};
|
|
221
|
-
const createGraphicItem = (productId, el) => {
|
|
216
|
+
export const createGraphicItem = (productId, el) => {
|
|
222
217
|
return Object.assign(Object.assign({}, createGraphicIdent(productId, el.graphicId, el.type)), { data: Object.assign(Object.assign({}, el), { productId }) });
|
|
223
218
|
};
|
|
224
|
-
exports.createGraphicItem = createGraphicItem;
|
|
225
219
|
//#endregion GLOBAL FUNCTIONS
|
|
226
220
|
////////////////////////////////////////////////////
|
|
File without changes
|
|
@@ -6,7 +6,7 @@ import { MathUtils } from '../../utils/Math';
|
|
|
6
6
|
// DATA
|
|
7
7
|
////////////////////////////////////////////////////
|
|
8
8
|
export const structureData = () => {
|
|
9
|
-
return {
|
|
9
|
+
return Object.assign(Object.assign({}, DEFAULT_STRUCTURE_TREE()), { visibleContainers: [], products: [] });
|
|
10
10
|
};
|
|
11
11
|
////////////////////////////////////////////////////
|
|
12
12
|
// API
|
|
@@ -20,10 +20,7 @@ export const structureApi = (set, get) => ({
|
|
|
20
20
|
// TODO: clear object selection if needed
|
|
21
21
|
// 1. set the state
|
|
22
22
|
set({
|
|
23
|
-
structure: {
|
|
24
|
-
...get().structure,
|
|
25
|
-
...structure,
|
|
26
|
-
},
|
|
23
|
+
structure: Object.assign(Object.assign({}, get().structure), structure),
|
|
27
24
|
});
|
|
28
25
|
// 2. collect and cleanup data
|
|
29
26
|
api.graphic.cleanupGraphicRecords();
|
|
@@ -42,10 +39,7 @@ export const structureApi = (set, get) => ({
|
|
|
42
39
|
console.error(e);
|
|
43
40
|
}
|
|
44
41
|
return {
|
|
45
|
-
structure: {
|
|
46
|
-
...get().structure,
|
|
47
|
-
...structure,
|
|
48
|
-
},
|
|
42
|
+
structure: Object.assign(Object.assign({}, get().structure), structure),
|
|
49
43
|
};
|
|
50
44
|
});
|
|
51
45
|
const { api } = get();
|
|
@@ -122,7 +116,7 @@ export const structureApi = (set, get) => ({
|
|
|
122
116
|
// 3. Add the result to the state
|
|
123
117
|
//////////
|
|
124
118
|
set(state => ({
|
|
125
|
-
structure: {
|
|
119
|
+
structure: Object.assign(Object.assign({}, state.structure), { visibleContainers: solidIds, products: productIds }),
|
|
126
120
|
}));
|
|
127
121
|
},
|
|
128
122
|
/**
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -16,9 +16,10 @@ function subscribeItem(drawingId, selectorId, item) {
|
|
|
16
16
|
if (item.removeCondition && !unsubs[getId(selectorId, item.id)]) {
|
|
17
17
|
const selApi = getDrawing(drawingId).api.selection;
|
|
18
18
|
unsubs[getId(selectorId, item.id)] = subscribeToDrawing(drawingId, (d) => item.removeCondition && item.removeCondition(d), (removeCond) => {
|
|
19
|
+
var _a;
|
|
19
20
|
// Unselect item whose removeCondition got true
|
|
20
21
|
if (removeCond) {
|
|
21
|
-
const newItems = getDrawing(drawingId).selection.refs[selectorId]
|
|
22
|
+
const newItems = ((_a = getDrawing(drawingId).selection.refs[selectorId]) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
22
23
|
selApi.setItems(selectorId, newItems.filter(item_ => item_.id !== item.id));
|
|
23
24
|
}
|
|
24
25
|
});
|
|
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
|