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

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
@@ -1,226 +0,0 @@
1
- "use strict";
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");
5
- ////////////////////////////////////////////////////
6
- // CONSTANTS
7
- ////////////////////////////////////////////////////
8
- exports.BuerliScope = 'ClassCAD';
9
- const selectionData = () => ({
10
- refs: {},
11
- active: null,
12
- });
13
- exports.selectionData = selectionData;
14
- const selectionApi = (set, get) => ({
15
- unselectAll() {
16
- const drawingId = get().id;
17
- const activeSelector = get().selection.active;
18
- if (activeSelector) {
19
- const unselItems = get().selection.refs[activeSelector].items;
20
- selection_1.unsubscribeItems(drawingId, activeSelector, unselItems);
21
- set(state => {
22
- const selector = state.selection.refs[activeSelector];
23
- return {
24
- selection: Object.assign(Object.assign({}, state.selection), { refs: Object.assign(Object.assign({}, state.selection.refs), { [activeSelector]: Object.assign(Object.assign({}, selector), { items: [] }) }) }),
25
- };
26
- });
27
- }
28
- },
29
- unselect(...unselItems) {
30
- const { selection, id: drawingId } = get();
31
- const activeSelectorId = selection.active;
32
- if (activeSelectorId) {
33
- // Remove unselItems from selector's items
34
- const selector = selection.refs[activeSelectorId];
35
- const newItems = selector.items.filter(item => unselItems.find(uItem => uItem.id === item.id) === undefined);
36
- selection_1.unsubscribeItems(drawingId, activeSelectorId, unselItems);
37
- if (selector.customUnSelect) {
38
- // Find recently unselected items
39
- const diff = selector.items.filter(item1 => {
40
- return newItems.find(item2 => item2.id === item1.id) === undefined;
41
- });
42
- selector.customUnSelect(activeSelectorId, newItems, diff);
43
- }
44
- else {
45
- set(state => {
46
- return {
47
- selection: Object.assign(Object.assign({}, state.selection), { refs: Object.assign(Object.assign({}, state.selection.refs), { [activeSelectorId]: Object.assign(Object.assign({}, state.selection.refs[activeSelectorId]), { items: newItems }) }) }),
48
- };
49
- });
50
- }
51
- this.setHovered(null, activeSelectorId);
52
- }
53
- },
54
- select(...newItems) {
55
- const { selection, api, id: drawingId } = get();
56
- const activeSelectorId = selection.active;
57
- const { isItemSelected } = api.selection;
58
- if (activeSelectorId) {
59
- const selector = selection.refs[activeSelectorId];
60
- const curItems = selector.items;
61
- // Remove duplicates
62
- let filteredItems = newItems.filter((item1, idx) => newItems.findIndex(item2 => item2.id === item1.id) === idx);
63
- // Remove already selected items and duplicates
64
- filteredItems = filteredItems.filter(item => !isItemSelected(item, activeSelectorId));
65
- let unsubItems = [];
66
- let result = [...curItems, ...filteredItems];
67
- if (selector.maxLen > 0) {
68
- if (filteredItems.length === selector.maxLen) {
69
- result = [...filteredItems];
70
- unsubItems = [...curItems];
71
- }
72
- else if (filteredItems.length > selector.maxLen) {
73
- const extraItems = filteredItems.length - selector.maxLen;
74
- // If filteredItems has bigger length then selector.maxLen, remove last few items from filteredItems.
75
- result = filteredItems.slice(0, -extraItems);
76
- unsubItems = [...curItems];
77
- }
78
- else if (filteredItems.length + curItems.length >= selector.maxLen) {
79
- const extraItems = filteredItems.length + curItems.length - selector.maxLen;
80
- const allItems = [...curItems, ...filteredItems];
81
- // If filteredItems.len + curItems.len > selector.maxLen, remove first few items from union of curItems and filteredItems.
82
- result = allItems.slice(extraItems);
83
- unsubItems = allItems.slice(0, extraItems);
84
- }
85
- }
86
- if (selector.customSelect !== undefined) {
87
- // Find items which weren't selected before.
88
- const diff = result.filter(item1 => {
89
- return selector.items.find(item2 => item2.id === item1.id) === undefined;
90
- });
91
- selector.customSelect(activeSelectorId, result, diff);
92
- }
93
- else {
94
- // subscribe items which will be selected
95
- selection_1.subscribeItems(drawingId, activeSelectorId, result);
96
- // unsubscribe items which will be unselected
97
- selection_1.unsubscribeItems(drawingId, activeSelectorId, unsubItems);
98
- set(state => {
99
- return {
100
- selection: Object.assign(Object.assign({}, state.selection), { refs: Object.assign(Object.assign({}, state.selection.refs), { [activeSelectorId]: Object.assign(Object.assign({}, selector), { items: result }) }) }),
101
- };
102
- });
103
- }
104
- this.setHovered(null, activeSelectorId);
105
- }
106
- },
107
- setHovered(item, selectorId) {
108
- const { selection } = get();
109
- if (selection.active === null && selectorId === undefined)
110
- return;
111
- const selId = selection.active || selectorId;
112
- set(state => ({
113
- selection: Object.assign(Object.assign({}, state.selection), { refs: Object.assign(Object.assign({}, state.selection.refs), { [selId]: Object.assign(Object.assign({}, state.selection.refs[selId]), { hoveredItem: item }) }) }),
114
- }));
115
- },
116
- activateSelector(selectorId) {
117
- set(state => {
118
- const refs = state.selection.refs;
119
- const curSelectorId = state.selection.active;
120
- if (curSelectorId) {
121
- // Reset hoveredItem
122
- refs[curSelectorId] = Object.assign(Object.assign({}, refs[curSelectorId]), { hoveredItem: null });
123
- }
124
- return {
125
- selection: Object.assign(Object.assign({}, state.selection), { active: state.selection.active === selectorId ? null : selectorId, refs: Object.assign({}, refs) }),
126
- };
127
- });
128
- },
129
- createSelector(selectorId, filter, activate = false, initialItems = [], maxLen = -1, customSelect, customUnSelect) {
130
- if (maxLen > 0 && initialItems.length > maxLen)
131
- console.error('Number initialItems should be less or equal to selector.maxLen');
132
- set(state => ({
133
- selection: Object.assign(Object.assign({}, state.selection), { active: activate ? selectorId : state.selection.active, refs: Object.assign(Object.assign({}, state.selection.refs), { [selectorId]: {
134
- items: maxLen > 0 && initialItems.length > maxLen ? [] : initialItems,
135
- hoveredItem: null,
136
- isSelectable: filter,
137
- maxLen,
138
- customSelect,
139
- customUnSelect,
140
- } }) }),
141
- }));
142
- return () => {
143
- if (get && get()) {
144
- const drawingId = get().id;
145
- selection_1.unsubscribeItems(drawingId, selectorId);
146
- set(state => {
147
- const refs = state.selection.refs;
148
- delete refs[selectorId];
149
- return {
150
- selection: Object.assign(Object.assign({}, state.selection), { active: state.selection.active === selectorId ? null : state.selection.active, refs }),
151
- };
152
- });
153
- }
154
- };
155
- },
156
- areItemsSelected: (items, selectorId) => {
157
- const { selection } = get();
158
- if (selection.active === null && selectorId === undefined)
159
- return false;
160
- const selId = selection.active || selectorId;
161
- const selector = selection.refs[selId];
162
- let res = true;
163
- items.forEach(item => {
164
- const itemSelected = Boolean(selector.items.find(i => areItemsEqual(i, item)));
165
- if (!itemSelected) {
166
- res = false;
167
- }
168
- });
169
- return res;
170
- },
171
- isItemSelected: (item, selectorId) => {
172
- const { selection } = get();
173
- if (selection.active === null && selectorId === undefined)
174
- return false;
175
- const selId = selection.active || selectorId;
176
- const selector = selection.refs[selId];
177
- return Boolean(selector.items.find(i => areItemsEqual(i, item)));
178
- },
179
- setItems(id, items) {
180
- var _a;
181
- const { selection, id: drawingId } = get();
182
- const curItems = ((_a = selection.refs[id]) === null || _a === void 0 ? void 0 : _a.items) || [];
183
- selection_1.unsubscribeItems(drawingId, id, curItems);
184
- selection_1.subscribeItems(drawingId, id, items);
185
- set(state => {
186
- const selector = state.selection.refs[id];
187
- return {
188
- selection: Object.assign(Object.assign({}, state.selection), { refs: Object.assign(Object.assign({}, state.selection.refs), { [id]: Object.assign(Object.assign({}, selector), { items }) }) }),
189
- };
190
- });
191
- },
192
- getGraphicItem: (productId, containerId, graphicId) => {
193
- const { cache } = get().geometry;
194
- const container = cache[containerId];
195
- if (container) {
196
- if (graphicId === undefined) {
197
- const ids = Object.getOwnPropertyNames(container.map);
198
- graphicId = ids.length > 0 ? Number(ids[0]) : undefined;
199
- }
200
- if (graphicId !== undefined) {
201
- const geomElem = container.map[graphicId];
202
- if (geomElem) {
203
- return exports.createGraphicItem(productId, geomElem);
204
- }
205
- }
206
- }
207
- return null;
208
- },
209
- });
210
- exports.selectionApi = selectionApi;
211
- ////////////////////////////////////////////////////
212
- //#region GLOBAL FUNCTIONS
213
- const areItemsEqual = (a, b) => a.id === b.id && a.scope === b.scope;
214
- const createGraphicIdent = (productId, graphicId, type) => {
215
- return {
216
- id: `${productId}|${graphicId}|${type}`,
217
- scope: exports.BuerliScope,
218
- label: (type[0] + type[1]).toUpperCase(),
219
- };
220
- };
221
- const createGraphicItem = (productId, el) => {
222
- return Object.assign(Object.assign({}, createGraphicIdent(productId, el.graphicId, el.type)), { data: Object.assign(Object.assign({}, el), { productId }) });
223
- };
224
- exports.createGraphicItem = createGraphicItem;
225
- //#endregion GLOBAL FUNCTIONS
226
- ////////////////////////////////////////////////////
@@ -1,203 +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
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.structureApi = exports.structureData = void 0;
26
- const jsonpatch_1 = __importDefault(require("jsonpatch"));
27
- const THREE = __importStar(require("three"));
28
- const types_1 = require("../../types");
29
- const Math_1 = require("../../utils/Math");
30
- ////////////////////////////////////////////////////
31
- // DATA
32
- ////////////////////////////////////////////////////
33
- const structureData = () => {
34
- return Object.assign(Object.assign({}, types_1.DEFAULT_STRUCTURE_TREE()), { visibleContainers: [], products: [] });
35
- };
36
- exports.structureData = structureData;
37
- ////////////////////////////////////////////////////
38
- // API
39
- ////////////////////////////////////////////////////
40
- const structureApi = (set, get) => ({
41
- get: () => {
42
- return get().structure;
43
- },
44
- set: (structure) => {
45
- const { api } = get();
46
- // TODO: clear object selection if needed
47
- // 1. set the state
48
- set({
49
- structure: Object.assign(Object.assign({}, get().structure), structure),
50
- });
51
- // 2. collect and cleanup data
52
- api.graphic.cleanupGraphicRecords();
53
- // console.log('cleanup')
54
- api.structure.postProcessStructureUpdate();
55
- },
56
- applyPatches: (patches) => {
57
- const before = get().structure.products.concat(get().structure.visibleContainers);
58
- // Timing.dump('load', 'received tree patches')
59
- set(state => {
60
- let structure = state.structure;
61
- try {
62
- structure = jsonpatch_1.default.apply_patch(state.structure, patches);
63
- }
64
- catch (e) {
65
- console.error(e);
66
- }
67
- return {
68
- structure: Object.assign(Object.assign({}, get().structure), structure),
69
- };
70
- });
71
- const { api } = get();
72
- api.structure.postProcessStructureUpdate();
73
- // Update the bounds, but only if products or visible containers changed.
74
- const after = get().structure.products.concat(get().structure.visibleContainers);
75
- if (before.sort().join() !== after.sort().join()) {
76
- api.geometry.updateBounds();
77
- }
78
- },
79
- filterTree: (tree, filter) => {
80
- const objs = [];
81
- Object.getOwnPropertyNames(tree).forEach(name => {
82
- const obj = tree[name];
83
- if (filter(obj)) {
84
- objs.push(obj);
85
- }
86
- });
87
- return objs;
88
- },
89
- collectUsedSolidIds: () => {
90
- const { api, structure } = get();
91
- const solidObjs = api.structure.filterTree(structure.tree, obj => typeof obj.geometryIdList !== 'undefined');
92
- const solidIds = [];
93
- solidObjs.forEach(solidObj => solidIds.push(...(solidObj.geometryIdList || [])));
94
- return solidIds;
95
- },
96
- collectProducts: (root) => {
97
- const { structure } = get();
98
- const products = [];
99
- const recursive = (id) => {
100
- const obj = structure.tree[id];
101
- if (obj) {
102
- if ((obj.solids && obj.solids.length > 0) || obj.link) {
103
- products.push(obj);
104
- }
105
- if (obj.children) {
106
- for (const child of obj.children) {
107
- recursive(child);
108
- }
109
- }
110
- }
111
- };
112
- recursive(root);
113
- return products;
114
- },
115
- getProductSolidIds: (productId) => {
116
- const { structure } = get();
117
- let solids;
118
- const product = structure.tree[productId];
119
- if (product.link !== undefined) {
120
- solids = structure.tree[product.link].solids || [];
121
- }
122
- else {
123
- solids = product.solids || [];
124
- }
125
- return [...solids];
126
- },
127
- postProcessStructureUpdate: () => {
128
- const { api, structure } = get();
129
- //////////
130
- // 1. Collect the products
131
- //////////
132
- const searchRoot = structure.root; // || structure.currentNode || structure.currentProduct
133
- const productIds = api.structure.collectProducts(searchRoot).map(p => p.id);
134
- //////////
135
- // 2. Collect the solid ids
136
- //////////
137
- let solidIds = [];
138
- productIds.forEach(prodId => solidIds.push(...(api.structure.getProductSolidIds(prodId) || [])));
139
- // remove duplicates
140
- solidIds = solidIds.filter((item, index) => solidIds.indexOf(item) === index);
141
- //////////
142
- // 3. Add the result to the state
143
- //////////
144
- set(state => ({
145
- structure: Object.assign(Object.assign({}, state.structure), { visibleContainers: solidIds, products: productIds }),
146
- }));
147
- },
148
- /**
149
- * Calculates the global transformation matrix for the given _objectId_.
150
- *
151
- * @param objectId The object to calculate the global transformation for.
152
- * @param matrix The initial matrix (mainly used for recursion). It is an out parameter and in the end, it will contain the same matrix as the return value of this function.
153
- * @returns The global transformation matrix for the given _objectId_.
154
- */
155
- calculateGlobalTransformation: (objectId, matrix = new THREE.Matrix4().identity()) => {
156
- const { structure, api } = get();
157
- const { tree, root } = structure;
158
- const obj = tree[objectId];
159
- if (obj && obj.coordinateSystem) {
160
- const objMatrix = Math_1.MathUtils.convertToMatrix4(obj.coordinateSystem);
161
- matrix = matrix.clone().premultiply(objMatrix);
162
- }
163
- if (objectId !== root && obj.parent) {
164
- matrix = api.structure.calculateGlobalTransformation(obj.parent, matrix);
165
- }
166
- return matrix;
167
- },
168
- calculateProductBounds: (productId, base) => {
169
- const { graphic, api } = get();
170
- const posInf = Number.POSITIVE_INFINITY;
171
- const negInf = Number.NEGATIVE_INFINITY;
172
- const baseMin = base ? base.min.clone() : new THREE.Vector3(posInf, posInf, posInf);
173
- const baseMax = base ? base.max.clone() : new THREE.Vector3(negInf, negInf, negInf);
174
- let box = new THREE.Box3(baseMin, baseMax);
175
- const productIds = api.structure.collectProducts(productId).map(p => p.id);
176
- for (const pId of productIds) {
177
- const matrix = api.structure.calculateGlobalTransformation(pId);
178
- const contIds = api.structure.getProductSolidIds(pId);
179
- for (const contId of contIds) {
180
- const cont = graphic.containers[contId];
181
- if (cont) {
182
- const min = new THREE.Vector3().fromArray(cont.properties.min);
183
- const max = new THREE.Vector3().fromArray(cont.properties.max);
184
- const b = new THREE.Box3(min.clone(), max.clone());
185
- b.applyMatrix4(matrix);
186
- box = box.union(b);
187
- }
188
- }
189
- }
190
- const sphere = new THREE.Sphere();
191
- box.getBoundingSphere(sphere);
192
- return { center: sphere.center, radius: sphere.radius, max: box.max, min: box.min };
193
- },
194
- /**
195
- * This is a workaround to get the corresponding drawing id via API.
196
- *
197
- * > !!! Should not be used in user code !!!
198
- *
199
- * @returns The drawing id.
200
- */
201
- getDrawingId: () => get().id,
202
- });
203
- exports.structureApi = structureApi;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.api = void 0;
7
- const vanilla_1 = __importDefault(require("zustand/vanilla"));
8
- const buerli_1 = require("./states/buerli");
9
- const store = (set, get, buerliApi) => buerli_1.createState(set, get, buerliApi);
10
- const wnd = typeof window !== 'undefined' ? window : null;
11
- const middleware = wnd ? wnd.BUERLI_MIDDLEWARE || (wnd.BUERLI_MIDDLEWARE = []) : [];
12
- const buerliStore = middleware.reduceRight((acc, cur) => cur(acc), store);
13
- const api = vanilla_1.default(buerliStore);
14
- exports.api = api;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- // This is the solution for cases when object was deleted from tree and we need to remove corresponding selectedItem.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.unsubscribeItems = exports.subscribeItems = exports.unsubs = void 0;
5
- const __1 = require("../..");
6
- const subscribeToDrawing_1 = require("./subscribeToDrawing");
7
- // This object contains unsubscibe function for all existing selections in all drawings
8
- exports.unsubs = {};
9
- function getId(selectorId, itemId) {
10
- return `${selectorId}_${itemId}`;
11
- }
12
- function subscribeItems(drawingId, selectorId, items) {
13
- const items_ = items || __1.getDrawing(drawingId).selection.refs[selectorId].items;
14
- items_.forEach(item => {
15
- subscribeItem(drawingId, selectorId, item);
16
- });
17
- }
18
- exports.subscribeItems = subscribeItems;
19
- function subscribeItem(drawingId, selectorId, item) {
20
- if (item.removeCondition && !exports.unsubs[getId(selectorId, item.id)]) {
21
- const selApi = __1.getDrawing(drawingId).api.selection;
22
- exports.unsubs[getId(selectorId, item.id)] = subscribeToDrawing_1.subscribeToDrawing(drawingId, (d) => item.removeCondition && item.removeCondition(d), (removeCond) => {
23
- var _a;
24
- // Unselect item whose removeCondition got true
25
- if (removeCond) {
26
- const newItems = ((_a = __1.getDrawing(drawingId).selection.refs[selectorId]) === null || _a === void 0 ? void 0 : _a.items) || [];
27
- selApi.setItems(selectorId, newItems.filter(item_ => item_.id !== item.id));
28
- }
29
- });
30
- }
31
- }
32
- function unsubscribeItems(drawingId, selectorId, items) {
33
- const items_ = items || __1.getDrawing(drawingId).selection.refs[selectorId].items;
34
- items_.forEach(item => {
35
- unsubscribeItem(selectorId, item);
36
- });
37
- }
38
- exports.unsubscribeItems = unsubscribeItems;
39
- function unsubscribeItem(selectorId, item) {
40
- if (item.removeCondition) {
41
- const id = getId(selectorId, item.id);
42
- if (exports.unsubs[id]) {
43
- exports.unsubs[id]();
44
- delete exports.unsubs[id];
45
- }
46
- }
47
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.subscribeToDrawing = void 0;
4
- const store_1 = require("../store");
5
- function subscribeToDrawing(drawingId, sel, callback) {
6
- const unsub = store_1.api.subscribe(callback, state => state.drawing.refs[drawingId] && sel(state.drawing.refs[drawingId]));
7
- return unsub;
8
- }
9
- exports.subscribeToDrawing = subscribeToDrawing;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Primitives = exports.LineSegments = exports.Surfaces = exports.AllTypes = exports.GraphicType = void 0;
4
- var GraphicType;
5
- (function (GraphicType) {
6
- GraphicType["POINT"] = "point";
7
- GraphicType["LINE"] = "line";
8
- GraphicType["EDGE"] = "edge";
9
- GraphicType["ARC"] = "arc";
10
- GraphicType["CIRCLE"] = "circle";
11
- GraphicType["PLANE"] = "plane";
12
- GraphicType["CYLINDER"] = "cylinder";
13
- GraphicType["CONE"] = "cone";
14
- GraphicType["SPHERE"] = "sphere";
15
- GraphicType["NURBS"] = "nurbs";
16
- GraphicType["NURBSSURFACE"] = "nurbsSurface";
17
- GraphicType["LOOP"] = "loop";
18
- GraphicType["SOLID"] = "solid";
19
- })(GraphicType = exports.GraphicType || (exports.GraphicType = {}));
20
- const G = GraphicType;
21
- exports.AllTypes = Object.keys(G).map(key => G[key]);
22
- exports.Surfaces = [G.PLANE, G.CYLINDER, G.CONE, G.SPHERE, G.NURBS, G.NURBSSURFACE];
23
- exports.LineSegments = [G.LINE, G.EDGE, G.ARC, G.CIRCLE];
24
- exports.Primitives = exports.Surfaces.concat(exports.LineSegments).concat([G.POINT]);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MemberType = exports.NOID = exports.DEFAULT_STRUCTURE_TREE = void 0;
4
- /**
5
- * Defines the default structure tree.
6
- * Should be used to initialize a new structure tree.
7
- */
8
- const DEFAULT_STRUCTURE_TREE = () => {
9
- return {
10
- tree: {},
11
- root: exports.NOID,
12
- currentProduct: exports.NOID,
13
- currentNode: exports.NOID,
14
- testRoot: exports.NOID,
15
- };
16
- };
17
- exports.DEFAULT_STRUCTURE_TREE = DEFAULT_STRUCTURE_TREE;
18
- /** Zero is no Id in classcad, and no object will exist in the CCDatabase for Id === 0! */
19
- exports.NOID = 0;
20
- var MemberType;
21
- (function (MemberType) {
22
- MemberType["ARRAY"] = "array";
23
- MemberType["ID"] = "id";
24
- MemberType["POINT"] = "point";
25
- MemberType["REAL"] = "real";
26
- MemberType["STRING"] = "string";
27
- })(MemberType = exports.MemberType || (exports.MemberType = {}));
@@ -1,16 +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("./ErrorTypes"), exports);
14
- __exportStar(require("./IGraphicPackage"), exports);
15
- __exportStar(require("./IStructurePatch"), exports);
16
- __exportStar(require("./IStructureTree"), exports);
@@ -1,33 +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.MathUtils = void 0;
23
- const THREE = __importStar(require("three"));
24
- exports.MathUtils = {
25
- convertToMatrix4: function (coordinateSystem) {
26
- const [orig, vx, vy, vz] = coordinateSystem.map(row => new THREE.Vector3().fromArray(row));
27
- return new THREE.Matrix4().makeBasis(vx, vy, vz).setPosition(orig);
28
- },
29
- convertToMatrix3: function (coordinateSystem) {
30
- const [, vx, vy, vz] = coordinateSystem;
31
- return new THREE.Matrix3().fromArray([...vx, ...vy, ...vz]);
32
- },
33
- };