@buerli.io/core 0.7.1 → 0.9.0-beta.1

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.
@@ -201,7 +201,7 @@ class ThreeGeometryCreator {
201
201
  createEdge(edge, container, points, color) {
202
202
  const threePts = [];
203
203
  const graphicId = edge.id;
204
- let type = types_1.GraphicType.EDGE;
204
+ let type = types_1.GraphicType.NURBSCURVE;
205
205
  if (container.type === types_1.ContainerType.CURVEARRAY) {
206
206
  type = types_1.GraphicType.CURVESPLINE;
207
207
  }
@@ -274,7 +274,7 @@ class ThreeGeometryCreator {
274
274
  this.insertPoint(container, `${endId}|point`, endId, end, arc.id, 'end', points);
275
275
  const geometry = new THREE.BufferGeometry().setFromPoints(threePts);
276
276
  return Object.assign(Object.assign({ geometry,
277
- graphicId, type: type }, this.getMetadata(arc, container, color)), { normal: normal.clone(), center: center.clone(), radius: arc.radius, angle: arc.angle });
277
+ graphicId, type: type }, this.getMetadata(arc, container, color)), { normal: normal.clone(), center: center.clone(), start: start.clone(), end: end.clone(), radius: arc.radius, angle: arc.angle });
278
278
  }
279
279
  createPoint(container, key, graphicId, position, ownerId, type) {
280
280
  return Object.assign(Object.assign({ key,
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.solidFilter = exports.loopFilter = exports.planeFilter = exports.meshFilter = exports.pointFilter = exports.arcCircleFilter = exports.circleFilter = exports.arcFilter = exports.lineSegmentsFilter = exports.lineFilter = void 0;
4
- const IGraphicPackage_1 = require("../types/IGraphicPackage");
3
+ exports.solidFilter = exports.loopFilter = exports.planeFilter = exports.meshFilter = exports.pointFilter = exports.arcCircleFilter = exports.circleFilter = exports.arcFilter = exports.edgeFilter = exports.lineFilter = void 0;
5
4
  const selection_1 = require("../store/states/selection");
6
- const lineFilter = (scope, data) => scope === selection_1.BuerliScope && (data === IGraphicPackage_1.GraphicType.LINE || data === IGraphicPackage_1.GraphicType.EDGE);
5
+ const IGraphicPackage_1 = require("../types/IGraphicPackage");
6
+ const lineFilter = (scope, data) => scope === selection_1.BuerliScope && data === IGraphicPackage_1.GraphicType.LINE;
7
7
  exports.lineFilter = lineFilter;
8
- const lineSegmentsFilter = (scope, data) => scope === selection_1.BuerliScope && IGraphicPackage_1.LineSegments.includes(data);
9
- exports.lineSegmentsFilter = lineSegmentsFilter;
8
+ const edgeFilter = (scope, data) => scope === selection_1.BuerliScope && IGraphicPackage_1.EdgeTypes.includes(data);
9
+ exports.edgeFilter = edgeFilter;
10
10
  const arcFilter = (scope, data) => scope === selection_1.BuerliScope && data === IGraphicPackage_1.GraphicType.ARC;
11
11
  exports.arcFilter = arcFilter;
12
12
  const circleFilter = (scope, data) => scope === selection_1.BuerliScope && data === IGraphicPackage_1.GraphicType.CIRCLE;
@@ -15,7 +15,7 @@ const arcCircleFilter = (scope, data) => scope === selection_1.BuerliScope && (d
15
15
  exports.arcCircleFilter = arcCircleFilter;
16
16
  const pointFilter = (scope, data) => scope === selection_1.BuerliScope && data === IGraphicPackage_1.GraphicType.POINT;
17
17
  exports.pointFilter = pointFilter;
18
- const meshFilter = (scope, data) => scope === selection_1.BuerliScope && IGraphicPackage_1.Surfaces.includes(data);
18
+ const meshFilter = (scope, data) => scope === selection_1.BuerliScope && IGraphicPackage_1.MeshTypes.includes(data);
19
19
  exports.meshFilter = meshFilter;
20
20
  const planeFilter = (scope, data) => scope === selection_1.BuerliScope && data === IGraphicPackage_1.GraphicType.PLANE;
21
21
  exports.planeFilter = planeFilter;
@@ -23,7 +23,7 @@ const structure_1 = require("./structure");
23
23
  ////////////////////////////////////////////////////
24
24
  const createDrawingState = (set, get, buerliApi, drawingNumber, name) => {
25
25
  const drawingId = (0, uuid_1.v4)();
26
- return {
26
+ const initialData = () => ({
27
27
  structure: (0, structure_1.structureData)(),
28
28
  selection: (0, selection_1.selectionData)(),
29
29
  interaction: (0, interaction_1.interactionData)(),
@@ -31,7 +31,8 @@ const createDrawingState = (set, get, buerliApi, drawingNumber, name) => {
31
31
  geometry: (0, geometry_1.geometryData)(),
32
32
  graphic: (0, graphic_1.graphicData)(),
33
33
  cad: (0, cad_1.cadData)(),
34
- api: {
34
+ });
35
+ return Object.assign(Object.assign({}, initialData()), { api: {
35
36
  structure: (0, structure_1.structureApi)(set, get, buerliApi),
36
37
  selection: (0, selection_1.selectionApi)(set, get, buerliApi),
37
38
  plugin: (0, plugin_1.pluginApi)(set, get, buerliApi),
@@ -39,9 +40,10 @@ const createDrawingState = (set, get, buerliApi, drawingNumber, name) => {
39
40
  graphic: (0, graphic_1.graphicApi)(set, get, buerliApi),
40
41
  cad: (0, cad_1.cadApi)(set, get, buerliApi),
41
42
  interaction: (0, interaction_1.interactionApi)(set, get, buerliApi),
42
- },
43
- id: drawingId,
44
- name: name || `Drawing #${drawingNumber}`,
45
- };
43
+ reset: () => {
44
+ set(state => (Object.assign(Object.assign({}, state), initialData())));
45
+ buerliApi.getState().options.globalPlugins.forEach(def => get().api.plugin.createPlugin(def));
46
+ },
47
+ }, id: drawingId, name: name || `Drawing #${drawingNumber}` });
46
48
  };
47
49
  exports.createDrawingState = createDrawingState;
@@ -165,7 +165,7 @@ const structureApi = (set, get, buerliApi) => ({
165
165
  //////////
166
166
  // 1. Collect the products
167
167
  //////////
168
- const searchRoot = structure.root; // || structure.currentNode || structure.currentProduct
168
+ const searchRoot = structure.root; // || structure.currentInstance || structure.currentProduct
169
169
  const productIds = api.structure.collectProducts(searchRoot).map(p => p.id);
170
170
  //////////
171
171
  // 2. Collect the solid ids
@@ -29,7 +29,10 @@ function subscribeItem(buerliApi, drawingId, selectorId, item) {
29
29
  }
30
30
  }
31
31
  function unsubscribeItems(buerliApi, drawingId, selectorId, items) {
32
- const items_ = items || buerliApi.getState().drawing.refs[drawingId].selection.refs[selectorId].items;
32
+ var _a, _b, _c, _d;
33
+ // The following line leeds to exceptions if for example the corresponding drawing is going to be reset.
34
+ // To prevent those exceptions, check all properties for existance.
35
+ const items_ = items || ((_d = (_c = (_b = (_a = buerliApi.getState().drawing.refs[drawingId]) === null || _a === void 0 ? void 0 : _a.selection) === null || _b === void 0 ? void 0 : _b.refs) === null || _c === void 0 ? void 0 : _c[selectorId]) === null || _d === void 0 ? void 0 : _d.items) || [];
33
36
  items_.forEach(item => {
34
37
  unsubscribeItem(selectorId, item);
35
38
  });
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PointTypes = exports.EntityTypes = exports.CurveSegments = exports.Primitives = exports.LineSegments = exports.Surfaces = exports.AllTypes = exports.ContainerType = exports.GraphicType = void 0;
3
+ exports.PointTypes = exports.EntityTypes = exports.CurveTypes = exports.EdgeTypes = exports.MeshTypes = exports.ContainerType = exports.GraphicType = void 0;
4
4
  var GraphicType;
5
5
  (function (GraphicType) {
6
6
  // Primitives
7
7
  GraphicType["POINT"] = "point";
8
8
  GraphicType["LINE"] = "line";
9
- GraphicType["EDGE"] = "edge";
10
9
  GraphicType["ARC"] = "arc";
11
10
  GraphicType["CIRCLE"] = "circle";
12
11
  GraphicType["PLANE"] = "plane";
13
12
  GraphicType["CYLINDER"] = "cylinder";
14
13
  GraphicType["CONE"] = "cone";
15
14
  GraphicType["SPHERE"] = "sphere";
16
- GraphicType["NURBS"] = "nurbs";
15
+ GraphicType["NURBSCURVE"] = "nurbsCurve";
17
16
  GraphicType["NURBSSURFACE"] = "nurbsSurface";
18
17
  // Entities
19
18
  GraphicType["NONE"] = "none";
@@ -40,10 +39,8 @@ var ContainerType;
40
39
  // LIGHTWEIGHTBREP = 6, // Not used at the moment
41
40
  })(ContainerType = exports.ContainerType || (exports.ContainerType = {}));
42
41
  const G = GraphicType;
43
- exports.AllTypes = Object.keys(G).map(key => G[key]);
44
- exports.Surfaces = [G.PLANE, G.CYLINDER, G.CONE, G.SPHERE, G.NURBS, G.NURBSSURFACE];
45
- exports.LineSegments = [G.LINE, G.EDGE, G.ARC, G.CIRCLE];
46
- exports.Primitives = exports.Surfaces.concat(exports.LineSegments).concat([G.POINT]);
47
- exports.CurveSegments = [G.CURVELINE, G.CURVESPLINE, G.CURVEARC, G.CURVECIRCLE];
42
+ exports.MeshTypes = [G.PLANE, G.CYLINDER, G.CONE, G.SPHERE, G.NURBSSURFACE];
43
+ exports.EdgeTypes = [G.LINE, G.ARC, G.CIRCLE, G.NURBSCURVE];
44
+ exports.CurveTypes = [G.CURVELINE, G.CURVESPLINE, G.CURVEARC, G.CURVECIRCLE];
48
45
  exports.EntityTypes = [G.BREP, G.POLYBREP, G.CURVEARRAY];
49
46
  exports.PointTypes = [G.POINT, G.CURVEPOINT];
@@ -11,6 +11,7 @@ const DEFAULT_STRUCTURE_TREE = () => {
11
11
  root: exports.NOID,
12
12
  currentProduct: exports.NOID,
13
13
  currentNode: exports.NOID,
14
+ currentInstance: exports.NOID,
14
15
  testRoot: exports.NOID,
15
16
  };
16
17
  };
@@ -82,6 +82,8 @@ exports.Measure = {
82
82
  arc.normal = arc.normal.clone().applyMatrix3(matrix3);
83
83
  arc.normal.normalize();
84
84
  arc.center = arc.center.clone().applyMatrix4(matrix);
85
+ arc.start = arc.start.clone().applyMatrix4(matrix);
86
+ arc.end = arc.end.clone().applyMatrix4(matrix);
85
87
  break;
86
88
  case types_1.GraphicType.CIRCLE:
87
89
  case types_1.GraphicType.CURVECIRCLE:
@@ -89,6 +91,8 @@ exports.Measure = {
89
91
  circle.normal = circle.normal.clone().applyMatrix3(matrix3);
90
92
  circle.normal.normalize();
91
93
  circle.center = circle.center.clone().applyMatrix4(matrix);
94
+ circle.start = circle.start.clone().applyMatrix4(matrix);
95
+ circle.end = circle.end.clone().applyMatrix4(matrix);
92
96
  break;
93
97
  default:
94
98
  break;
@@ -128,7 +132,7 @@ exports.Measure = {
128
132
  measureData: { value: absoluteDistance, start: line.start.clone(), end: line.end.clone() },
129
133
  });
130
134
  break;
131
- case types_1.GraphicType.EDGE:
135
+ case types_1.GraphicType.NURBSCURVE:
132
136
  case types_1.GraphicType.CURVESPLINE:
133
137
  const edge = element;
134
138
  results.push({
@@ -139,7 +143,7 @@ exports.Measure = {
139
143
  results.push({
140
144
  description: 'Edge end',
141
145
  type: MeasureResultType.POSITION,
142
- measureData: { value: edge.start.clone() },
146
+ measureData: { value: edge.end.clone() },
143
147
  });
144
148
  break;
145
149
  case types_1.GraphicType.ARC:
@@ -147,6 +151,16 @@ exports.Measure = {
147
151
  const arc = element;
148
152
  const arcNEnd = arc.center.clone().addScaledVector(arc.normal.clone().normalize(), 40);
149
153
  const pointOnArc = getPointOnCircumference(arc.center, arc.normal, arc.radius);
154
+ results.push({
155
+ description: 'Arc start',
156
+ type: MeasureResultType.POSITION,
157
+ measureData: { value: arc.start.clone() },
158
+ });
159
+ results.push({
160
+ description: 'Arc end',
161
+ type: MeasureResultType.POSITION,
162
+ measureData: { value: arc.end.clone() },
163
+ });
150
164
  results.push({
151
165
  description: 'Arc center',
152
166
  type: MeasureResultType.POSITION,
@@ -183,6 +197,11 @@ exports.Measure = {
183
197
  type: MeasureResultType.DISTANCE,
184
198
  measureData: { value: circle.radius, start: circle.center.clone(), end: pointOnCircle },
185
199
  });
200
+ results.push({
201
+ description: 'Circle start/end',
202
+ type: MeasureResultType.POSITION,
203
+ measureData: { value: circle.start.clone() },
204
+ });
186
205
  break;
187
206
  case types_1.GraphicType.PLANE:
188
207
  const plane = element;
@@ -275,9 +294,6 @@ exports.Measure = {
275
294
  measureData: { value: sphere.radius },
276
295
  });
277
296
  break;
278
- case types_1.GraphicType.NURBS:
279
- results.push({ description: 'NURBS', type: MeasureResultType.NONE });
280
- break;
281
297
  case types_1.GraphicType.NURBSSURFACE:
282
298
  results.push({ description: 'NURBS Surface', type: MeasureResultType.NONE });
283
299
  break;
@@ -175,7 +175,7 @@ export class ThreeGeometryCreator {
175
175
  createEdge(edge, container, points, color) {
176
176
  const threePts = [];
177
177
  const graphicId = edge.id;
178
- let type = GraphicType.EDGE;
178
+ let type = GraphicType.NURBSCURVE;
179
179
  if (container.type === ContainerType.CURVEARRAY) {
180
180
  type = GraphicType.CURVESPLINE;
181
181
  }
@@ -248,7 +248,7 @@ export class ThreeGeometryCreator {
248
248
  this.insertPoint(container, `${endId}|point`, endId, end, arc.id, 'end', points);
249
249
  const geometry = new THREE.BufferGeometry().setFromPoints(threePts);
250
250
  return Object.assign(Object.assign({ geometry,
251
- graphicId, type: type }, this.getMetadata(arc, container, color)), { normal: normal.clone(), center: center.clone(), radius: arc.radius, angle: arc.angle });
251
+ graphicId, type: type }, this.getMetadata(arc, container, color)), { normal: normal.clone(), center: center.clone(), start: start.clone(), end: end.clone(), radius: arc.radius, angle: arc.angle });
252
252
  }
253
253
  createPoint(container, key, graphicId, position, ownerId, type) {
254
254
  return Object.assign(Object.assign({ key,
@@ -1,12 +1,12 @@
1
- import { GraphicType as GT, LineSegments, Surfaces } from '../types/IGraphicPackage';
2
1
  import { BuerliScope } from '../store/states/selection';
3
- export const lineFilter = (scope, data) => scope === BuerliScope && (data === GT.LINE || data === GT.EDGE);
4
- export const lineSegmentsFilter = (scope, data) => scope === BuerliScope && LineSegments.includes(data);
2
+ import { EdgeTypes, GraphicType as GT, MeshTypes } from '../types/IGraphicPackage';
3
+ export const lineFilter = (scope, data) => scope === BuerliScope && data === GT.LINE;
4
+ export const edgeFilter = (scope, data) => scope === BuerliScope && EdgeTypes.includes(data);
5
5
  export const arcFilter = (scope, data) => scope === BuerliScope && data === GT.ARC;
6
6
  export const circleFilter = (scope, data) => scope === BuerliScope && data === GT.CIRCLE;
7
7
  export const arcCircleFilter = (scope, data) => scope === BuerliScope && (data === GT.ARC || data === GT.CIRCLE);
8
8
  export const pointFilter = (scope, data) => scope === BuerliScope && data === GT.POINT;
9
- export const meshFilter = (scope, data) => scope === BuerliScope && Surfaces.includes(data);
9
+ export const meshFilter = (scope, data) => scope === BuerliScope && MeshTypes.includes(data);
10
10
  export const planeFilter = (scope, data) => scope === BuerliScope && data === GT.PLANE;
11
11
  export const loopFilter = (scope, data) => scope === BuerliScope && data === GT.LOOP;
12
12
  export const solidFilter = (scope, data) => scope === BuerliScope && data === GT.BREP;
@@ -20,7 +20,7 @@ import { structureApi, structureData } from './structure';
20
20
  ////////////////////////////////////////////////////
21
21
  export const createDrawingState = (set, get, buerliApi, drawingNumber, name) => {
22
22
  const drawingId = uuidv4();
23
- return {
23
+ const initialData = () => ({
24
24
  structure: structureData(),
25
25
  selection: selectionData(),
26
26
  interaction: interactionData(),
@@ -28,7 +28,8 @@ export const createDrawingState = (set, get, buerliApi, drawingNumber, name) =>
28
28
  geometry: geometryData(),
29
29
  graphic: graphicData(),
30
30
  cad: cadData(),
31
- api: {
31
+ });
32
+ return Object.assign(Object.assign({}, initialData()), { api: {
32
33
  structure: structureApi(set, get, buerliApi),
33
34
  selection: selectionApi(set, get, buerliApi),
34
35
  plugin: pluginApi(set, get, buerliApi),
@@ -36,8 +37,9 @@ export const createDrawingState = (set, get, buerliApi, drawingNumber, name) =>
36
37
  graphic: graphicApi(set, get, buerliApi),
37
38
  cad: cadApi(set, get, buerliApi),
38
39
  interaction: interactionApi(set, get, buerliApi),
39
- },
40
- id: drawingId,
41
- name: name || `Drawing #${drawingNumber}`,
42
- };
40
+ reset: () => {
41
+ set(state => (Object.assign(Object.assign({}, state), initialData())));
42
+ buerliApi.getState().options.globalPlugins.forEach(def => get().api.plugin.createPlugin(def));
43
+ },
44
+ }, id: drawingId, name: name || `Drawing #${drawingNumber}` });
43
45
  };
@@ -135,7 +135,7 @@ export const structureApi = (set, get, buerliApi) => ({
135
135
  //////////
136
136
  // 1. Collect the products
137
137
  //////////
138
- const searchRoot = structure.root; // || structure.currentNode || structure.currentProduct
138
+ const searchRoot = structure.root; // || structure.currentInstance || structure.currentProduct
139
139
  const productIds = api.structure.collectProducts(searchRoot).map(p => p.id);
140
140
  //////////
141
141
  // 2. Collect the solid ids
@@ -25,7 +25,10 @@ function subscribeItem(buerliApi, drawingId, selectorId, item) {
25
25
  }
26
26
  }
27
27
  export function unsubscribeItems(buerliApi, drawingId, selectorId, items) {
28
- const items_ = items || buerliApi.getState().drawing.refs[drawingId].selection.refs[selectorId].items;
28
+ var _a, _b, _c, _d;
29
+ // The following line leeds to exceptions if for example the corresponding drawing is going to be reset.
30
+ // To prevent those exceptions, check all properties for existance.
31
+ const items_ = items || ((_d = (_c = (_b = (_a = buerliApi.getState().drawing.refs[drawingId]) === null || _a === void 0 ? void 0 : _a.selection) === null || _b === void 0 ? void 0 : _b.refs) === null || _c === void 0 ? void 0 : _c[selectorId]) === null || _d === void 0 ? void 0 : _d.items) || [];
29
32
  items_.forEach(item => {
30
33
  unsubscribeItem(selectorId, item);
31
34
  });
@@ -3,14 +3,13 @@ export var GraphicType;
3
3
  // Primitives
4
4
  GraphicType["POINT"] = "point";
5
5
  GraphicType["LINE"] = "line";
6
- GraphicType["EDGE"] = "edge";
7
6
  GraphicType["ARC"] = "arc";
8
7
  GraphicType["CIRCLE"] = "circle";
9
8
  GraphicType["PLANE"] = "plane";
10
9
  GraphicType["CYLINDER"] = "cylinder";
11
10
  GraphicType["CONE"] = "cone";
12
11
  GraphicType["SPHERE"] = "sphere";
13
- GraphicType["NURBS"] = "nurbs";
12
+ GraphicType["NURBSCURVE"] = "nurbsCurve";
14
13
  GraphicType["NURBSSURFACE"] = "nurbsSurface";
15
14
  // Entities
16
15
  GraphicType["NONE"] = "none";
@@ -37,10 +36,8 @@ export var ContainerType;
37
36
  // LIGHTWEIGHTBREP = 6, // Not used at the moment
38
37
  })(ContainerType || (ContainerType = {}));
39
38
  const G = GraphicType;
40
- export const AllTypes = Object.keys(G).map(key => G[key]);
41
- export const Surfaces = [G.PLANE, G.CYLINDER, G.CONE, G.SPHERE, G.NURBS, G.NURBSSURFACE];
42
- export const LineSegments = [G.LINE, G.EDGE, G.ARC, G.CIRCLE];
43
- export const Primitives = Surfaces.concat(LineSegments).concat([G.POINT]);
44
- export const CurveSegments = [G.CURVELINE, G.CURVESPLINE, G.CURVEARC, G.CURVECIRCLE];
39
+ export const MeshTypes = [G.PLANE, G.CYLINDER, G.CONE, G.SPHERE, G.NURBSSURFACE];
40
+ export const EdgeTypes = [G.LINE, G.ARC, G.CIRCLE, G.NURBSCURVE];
41
+ export const CurveTypes = [G.CURVELINE, G.CURVESPLINE, G.CURVEARC, G.CURVECIRCLE];
45
42
  export const EntityTypes = [G.BREP, G.POLYBREP, G.CURVEARRAY];
46
43
  export const PointTypes = [G.POINT, G.CURVEPOINT];
@@ -8,6 +8,7 @@ export const DEFAULT_STRUCTURE_TREE = () => {
8
8
  root: NOID,
9
9
  currentProduct: NOID,
10
10
  currentNode: NOID,
11
+ currentInstance: NOID,
11
12
  testRoot: NOID,
12
13
  };
13
14
  };
@@ -56,6 +56,8 @@ export const Measure = {
56
56
  arc.normal = arc.normal.clone().applyMatrix3(matrix3);
57
57
  arc.normal.normalize();
58
58
  arc.center = arc.center.clone().applyMatrix4(matrix);
59
+ arc.start = arc.start.clone().applyMatrix4(matrix);
60
+ arc.end = arc.end.clone().applyMatrix4(matrix);
59
61
  break;
60
62
  case GraphicType.CIRCLE:
61
63
  case GraphicType.CURVECIRCLE:
@@ -63,6 +65,8 @@ export const Measure = {
63
65
  circle.normal = circle.normal.clone().applyMatrix3(matrix3);
64
66
  circle.normal.normalize();
65
67
  circle.center = circle.center.clone().applyMatrix4(matrix);
68
+ circle.start = circle.start.clone().applyMatrix4(matrix);
69
+ circle.end = circle.end.clone().applyMatrix4(matrix);
66
70
  break;
67
71
  default:
68
72
  break;
@@ -102,7 +106,7 @@ export const Measure = {
102
106
  measureData: { value: absoluteDistance, start: line.start.clone(), end: line.end.clone() },
103
107
  });
104
108
  break;
105
- case GraphicType.EDGE:
109
+ case GraphicType.NURBSCURVE:
106
110
  case GraphicType.CURVESPLINE:
107
111
  const edge = element;
108
112
  results.push({
@@ -113,7 +117,7 @@ export const Measure = {
113
117
  results.push({
114
118
  description: 'Edge end',
115
119
  type: MeasureResultType.POSITION,
116
- measureData: { value: edge.start.clone() },
120
+ measureData: { value: edge.end.clone() },
117
121
  });
118
122
  break;
119
123
  case GraphicType.ARC:
@@ -121,6 +125,16 @@ export const Measure = {
121
125
  const arc = element;
122
126
  const arcNEnd = arc.center.clone().addScaledVector(arc.normal.clone().normalize(), 40);
123
127
  const pointOnArc = getPointOnCircumference(arc.center, arc.normal, arc.radius);
128
+ results.push({
129
+ description: 'Arc start',
130
+ type: MeasureResultType.POSITION,
131
+ measureData: { value: arc.start.clone() },
132
+ });
133
+ results.push({
134
+ description: 'Arc end',
135
+ type: MeasureResultType.POSITION,
136
+ measureData: { value: arc.end.clone() },
137
+ });
124
138
  results.push({
125
139
  description: 'Arc center',
126
140
  type: MeasureResultType.POSITION,
@@ -157,6 +171,11 @@ export const Measure = {
157
171
  type: MeasureResultType.DISTANCE,
158
172
  measureData: { value: circle.radius, start: circle.center.clone(), end: pointOnCircle },
159
173
  });
174
+ results.push({
175
+ description: 'Circle start/end',
176
+ type: MeasureResultType.POSITION,
177
+ measureData: { value: circle.start.clone() },
178
+ });
160
179
  break;
161
180
  case GraphicType.PLANE:
162
181
  const plane = element;
@@ -249,9 +268,6 @@ export const Measure = {
249
268
  measureData: { value: sphere.radius },
250
269
  });
251
270
  break;
252
- case GraphicType.NURBS:
253
- results.push({ description: 'NURBS', type: MeasureResultType.NONE });
254
- break;
255
271
  case GraphicType.NURBSSURFACE:
256
272
  results.push({ description: 'NURBS Surface', type: MeasureResultType.NONE });
257
273
  break;
@@ -30,7 +30,7 @@ export declare class ThreeGeometryCreator {
30
30
  operationId: any;
31
31
  rawGraphic: IGraphicElement | null;
32
32
  isValid: boolean;
33
- geometry: THREE.BufferGeometry;
33
+ geometry: THREE.BufferGeometry<THREE.NormalBufferAttributes>;
34
34
  graphicId: number;
35
35
  type: GraphicType;
36
36
  loops: number[][];
@@ -47,7 +47,7 @@ export declare class ThreeGeometryCreator {
47
47
  operationId: any;
48
48
  rawGraphic: IGraphicElement | null;
49
49
  isValid: boolean;
50
- geometry: THREE.BufferGeometry;
50
+ geometry: THREE.BufferGeometry<THREE.NormalBufferAttributes>;
51
51
  graphicId: number;
52
52
  type: GraphicType;
53
53
  loops: number[][];
@@ -56,6 +56,7 @@ export declare class ThreeGeometryCreator {
56
56
  type: GraphicType;
57
57
  pointOnPlane: THREE.Vector3;
58
58
  normal: THREE.Vector3;
59
+ graphicId: number;
59
60
  color: THREE.Color | undefined;
60
61
  opacity: number;
61
62
  layer: any;
@@ -67,8 +68,7 @@ export declare class ThreeGeometryCreator {
67
68
  operationId: any;
68
69
  rawGraphic: IGraphicElement | null;
69
70
  isValid: boolean;
70
- geometry: THREE.BufferGeometry;
71
- graphicId: number;
71
+ geometry: THREE.BufferGeometry<THREE.NormalBufferAttributes>;
72
72
  loops: number[][];
73
73
  };
74
74
  createCylinder(mesh: IGraphicMesh, meshGeom: MeshGeometry): {
@@ -77,6 +77,7 @@ export declare class ThreeGeometryCreator {
77
77
  axis: THREE.Vector3;
78
78
  height: number;
79
79
  radius: number;
80
+ graphicId: number;
80
81
  color: THREE.Color | undefined;
81
82
  opacity: number;
82
83
  layer: any;
@@ -88,8 +89,7 @@ export declare class ThreeGeometryCreator {
88
89
  operationId: any;
89
90
  rawGraphic: IGraphicElement | null;
90
91
  isValid: boolean;
91
- geometry: THREE.BufferGeometry;
92
- graphicId: number;
92
+ geometry: THREE.BufferGeometry<THREE.NormalBufferAttributes>;
93
93
  loops: number[][];
94
94
  };
95
95
  createCone(mesh: IGraphicMesh, meshGeom: MeshGeometry): {
@@ -99,6 +99,7 @@ export declare class ThreeGeometryCreator {
99
99
  height: number;
100
100
  radiusBottom: number;
101
101
  radiusTop: number;
102
+ graphicId: number;
102
103
  color: THREE.Color | undefined;
103
104
  opacity: number;
104
105
  layer: any;
@@ -110,13 +111,13 @@ export declare class ThreeGeometryCreator {
110
111
  operationId: any;
111
112
  rawGraphic: IGraphicElement | null;
112
113
  isValid: boolean;
113
- geometry: THREE.BufferGeometry;
114
- graphicId: number;
114
+ geometry: THREE.BufferGeometry<THREE.NormalBufferAttributes>;
115
115
  loops: number[][];
116
116
  };
117
117
  createSphere(mesh: IGraphicMesh, meshGeom: MeshGeometry): {
118
118
  type: GraphicType;
119
119
  radius: number;
120
+ graphicId: number;
120
121
  color: THREE.Color | undefined;
121
122
  opacity: number;
122
123
  layer: any;
@@ -128,8 +129,7 @@ export declare class ThreeGeometryCreator {
128
129
  operationId: any;
129
130
  rawGraphic: IGraphicElement | null;
130
131
  isValid: boolean;
131
- geometry: THREE.BufferGeometry;
132
- graphicId: number;
132
+ geometry: THREE.BufferGeometry<THREE.NormalBufferAttributes>;
133
133
  loops: number[][];
134
134
  };
135
135
  createLine(line: IGraphicLine, container: IGraphicContainer, points: PointMap, color?: number[]): {
@@ -145,7 +145,7 @@ export declare class ThreeGeometryCreator {
145
145
  };
146
146
  operationId: any;
147
147
  rawGraphic: IGraphicElement | null;
148
- geometry: THREE.BufferGeometry;
148
+ geometry: THREE.BufferGeometry<THREE.NormalBufferAttributes>;
149
149
  graphicId: number;
150
150
  type: GraphicType;
151
151
  };
@@ -162,13 +162,15 @@ export declare class ThreeGeometryCreator {
162
162
  };
163
163
  operationId: any;
164
164
  rawGraphic: IGraphicElement | null;
165
- geometry: THREE.BufferGeometry;
165
+ geometry: THREE.BufferGeometry<THREE.NormalBufferAttributes>;
166
166
  graphicId: number;
167
167
  type: GraphicType;
168
168
  };
169
169
  createArc(arc: IGraphicArc, container: IGraphicContainer, points: PointMap, color?: number[]): {
170
170
  normal: THREE.Vector3;
171
171
  center: THREE.Vector3;
172
+ start: THREE.Vector3;
173
+ end: THREE.Vector3;
172
174
  radius: number;
173
175
  angle: number;
174
176
  color: THREE.Color | undefined;
@@ -181,7 +183,7 @@ export declare class ThreeGeometryCreator {
181
183
  };
182
184
  operationId: any;
183
185
  rawGraphic: IGraphicElement | null;
184
- geometry: THREE.BufferGeometry;
186
+ geometry: THREE.BufferGeometry<THREE.NormalBufferAttributes>;
185
187
  graphicId: number;
186
188
  type: GraphicType;
187
189
  };
@@ -209,16 +211,21 @@ export declare class ThreeGeometryCreator {
209
211
  private insertPoint;
210
212
  }
211
213
  export declare const EMPTY_CONTAINER_GEOMETRY: () => ContainerGeometryT;
212
- export declare type MeshGeometry = ReturnType<ThreeGeometryCreator['createMesh']>;
213
- export declare type PlaneGeometry = ReturnType<ThreeGeometryCreator['createPlane']>;
214
- export declare type CylinderGeometry = ReturnType<ThreeGeometryCreator['createCylinder']>;
215
- export declare type ConeGeometry = ReturnType<ThreeGeometryCreator['createCone']>;
216
- export declare type SphereGeometry = ReturnType<ThreeGeometryCreator['createSphere']>;
217
- export declare type LineGeometry = ReturnType<ThreeGeometryCreator['createLine']>;
218
- export declare type EdgeGeometry = ReturnType<ThreeGeometryCreator['createEdge']>;
219
- export declare type ArcGeometry = ReturnType<ThreeGeometryCreator['createArc']>;
214
+ declare type CommonProps = {
215
+ graphicId: GraphicID;
216
+ type: GraphicType;
217
+ };
218
+ export declare type Metadata = ReturnType<ThreeGeometryCreator['getMetadata']>;
219
+ export declare type MeshGeometry = CommonProps & ReturnType<ThreeGeometryCreator['createMesh']>;
220
+ export declare type PlaneGeometry = CommonProps & ReturnType<ThreeGeometryCreator['createPlane']>;
221
+ export declare type CylinderGeometry = CommonProps & ReturnType<ThreeGeometryCreator['createCylinder']>;
222
+ export declare type ConeGeometry = CommonProps & ReturnType<ThreeGeometryCreator['createCone']>;
223
+ export declare type SphereGeometry = CommonProps & ReturnType<ThreeGeometryCreator['createSphere']>;
224
+ export declare type LineGeometry = CommonProps & ReturnType<ThreeGeometryCreator['createLine']>;
225
+ export declare type EdgeGeometry = CommonProps & ReturnType<ThreeGeometryCreator['createEdge']>;
226
+ export declare type ArcGeometry = CommonProps & ReturnType<ThreeGeometryCreator['createArc']>;
220
227
  export declare type CircleGeometry = ArcGeometry;
221
- export declare type PointGeometry = ReturnType<ThreeGeometryCreator['createPoint']> & {
228
+ export declare type PointGeometry = CommonProps & ReturnType<ThreeGeometryCreator['createPoint']> & {
222
229
  owners: Array<{
223
230
  ownerId: GraphicID;
224
231
  type: PointType;
@@ -245,5 +252,6 @@ export declare type GeometryElement = MeshGeometry | PlaneGeometry | CylinderGeo
245
252
  export declare type ProductElement = GeometryElement & {
246
253
  productId: ObjectID;
247
254
  };
255
+ export declare type AnyGeometryElement = CommonProps & Metadata & Partial<MeshGeometry> & Partial<PlaneGeometry> & Partial<CylinderGeometry> & Partial<ConeGeometry> & Partial<SphereGeometry> & Partial<LineGeometry> & Partial<EdgeGeometry> & Partial<ArcGeometry> & Partial<CircleGeometry> & Partial<PointGeometry>;
248
256
  export declare const isEqualGeometry: (a: GeometryElement, b: GeometryElement) => boolean;
249
257
  export {};
@@ -1,6 +1,6 @@
1
1
  import { GraphicType as GT } from '../types/IGraphicPackage';
2
2
  export declare const lineFilter: (scope: string, data: GT) => boolean;
3
- export declare const lineSegmentsFilter: (scope: string, data: GT) => boolean;
3
+ export declare const edgeFilter: (scope: string, data: GT) => boolean;
4
4
  export declare const arcFilter: (scope: string, data: GT) => boolean;
5
5
  export declare const circleFilter: (scope: string, data: GT) => boolean;
6
6
  export declare const arcCircleFilter: (scope: string, data: GT) => boolean;
@@ -25,6 +25,7 @@ export declare type DrawingAPI = {
25
25
  geometry: GeometryApi;
26
26
  graphic: GraphicApi;
27
27
  cad: CadApi;
28
+ reset: () => void;
28
29
  };
29
30
  declare type StateData = {
30
31
  id: DrawingID;
@@ -1,7 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import { StoreApi } from 'zustand';
3
3
  import { ContainerGeometryT, GeometryElement } from '../../geometry/ThreeGeometryCreator';
4
- import { GraphicID } from '../../types/IGraphicPackage';
5
4
  import { ObjectID } from '../../types/IStructureTree';
6
5
  import { BuerliState } from './buerli';
7
6
  import { DrawingState } from './drawing';
@@ -26,7 +25,9 @@ export declare type GeometryConfig = {
26
25
  points?: ElementConfig;
27
26
  };
28
27
  export declare type GeometryData = {
29
- cache: Record<GraphicID, ContainerGeometryT & {
28
+ cache: Record<ObjectID, // The id of the CADEntity
29
+ // The id of the CADEntity
30
+ ContainerGeometryT & {
30
31
  /**
31
32
  * The dirty stamp will be updated, as soon as a client side modification of the geometry will happen!
32
33
  * Examples: 'setColor' or 'setOpacity'
@@ -38,7 +39,7 @@ export declare type GeometryData = {
38
39
  stamp: number;
39
40
  bounds: GeometryBounds;
40
41
  config: {
41
- product: Record<ObjectID | GraphicID, GeometryConfig>;
42
+ product: Record<ObjectID, GeometryConfig>;
42
43
  };
43
44
  };
44
45
  export declare type GeometryApi = ReturnType<typeof geometryApi>;
@@ -49,10 +50,10 @@ export declare const geometryApi: (set: StoreApi<DrawingState>['setState'], get:
49
50
  * The update will only happen, if at least one solid of one product is available.
50
51
  */
51
52
  updateBounds: () => void;
52
- createGeometryIfNotCached: (containerId: number, color?: number[]) => ContainerGeometryT | undefined;
53
- setColor: (containerId: GraphicID, r: number, g: number, b: number) => void;
54
- setOpacity: (containerId: GraphicID, opacity: number) => void;
55
- setConfig: (objId: ObjectID | GraphicID, config: Partial<GeometryConfig> | null) => void;
53
+ createGeometryIfNotCached: (containerId: ObjectID, color?: number[]) => ContainerGeometryT | undefined;
54
+ setColor: (containerId: ObjectID, r: number, g: number, b: number) => void;
55
+ setOpacity: (containerId: ObjectID, opacity: number) => void;
56
+ setConfig: (objId: ObjectID, config: Partial<GeometryConfig> | null) => void;
56
57
  findDecorated: () => GeometryElement[];
57
58
  filter: (cb: (elem: GeometryElement) => boolean, options?: {
58
59
  onlyOne?: boolean;
@@ -8,7 +8,9 @@ export interface IGraphicPackageProperties {
8
8
  version: number;
9
9
  }
10
10
  export interface IGraphicContainer {
11
- id: GraphicID;
11
+ /** The CADEntity id */
12
+ id: ObjectID;
13
+ /** The CC_Solid id */
12
14
  owner: ObjectID;
13
15
  type: ContainerType;
14
16
  properties: IGraphicContainerProps;
@@ -87,7 +89,7 @@ export interface IGraphicMeshProperties {
87
89
  material: IGraphicMaterial;
88
90
  }
89
91
  export interface IGraphicSurface {
90
- type: GraphicType.PLANE | GraphicType.CYLINDER | GraphicType.CONE | GraphicType.SPHERE | GraphicType.NURBS | GraphicType.NURBSSURFACE;
92
+ type: GraphicType.PLANE | GraphicType.CYLINDER | GraphicType.CONE | GraphicType.SPHERE | GraphicType.NURBSSURFACE;
91
93
  }
92
94
  export interface IGraphicPlane extends IGraphicSurface {
93
95
  pointOnPlane: number[];
@@ -112,14 +114,13 @@ export interface IGraphicSphere extends IGraphicSurface {
112
114
  export declare enum GraphicType {
113
115
  POINT = "point",
114
116
  LINE = "line",
115
- EDGE = "edge",
116
117
  ARC = "arc",
117
118
  CIRCLE = "circle",
118
119
  PLANE = "plane",
119
120
  CYLINDER = "cylinder",
120
121
  CONE = "cone",
121
122
  SPHERE = "sphere",
122
- NURBS = "nurbs",
123
+ NURBSCURVE = "nurbsCurve",
123
124
  NURBSSURFACE = "nurbsSurface",
124
125
  NONE = "none",
125
126
  BREP = "brep",
@@ -139,11 +140,9 @@ export declare enum ContainerType {
139
140
  POLYBREP = 3
140
141
  }
141
142
  declare type RoA = ReadonlyArray<GraphicType>;
142
- export declare const AllTypes: RoA;
143
- export declare const Surfaces: RoA;
144
- export declare const LineSegments: RoA;
145
- export declare const Primitives: RoA;
146
- export declare const CurveSegments: RoA;
143
+ export declare const MeshTypes: RoA;
144
+ export declare const EdgeTypes: RoA;
145
+ export declare const CurveTypes: RoA;
147
146
  export declare const EntityTypes: RoA;
148
147
  export declare const PointTypes: RoA;
149
148
  export interface IGraphicMaterial {
@@ -18,8 +18,13 @@ export interface IStructureProtocol {
18
18
  root: ObjectID;
19
19
  /** Id of the current product (root or node in part/assembly container). Can be undefined or zero -->> object does not exist! */
20
20
  currentProduct?: ObjectID;
21
- /** Id of the current node in the expanded assembly tree. Can be undefined or zero -->> object does not exist! */
21
+ /**
22
+ * Id of the current node in the expanded assembly tree. Can be undefined or zero -->> object does not exist!
23
+ * @deprecated currentNode will be removed in a future release, use currentInstance instead.
24
+ */
22
25
  currentNode?: ObjectID;
26
+ /** Id of the current instance in the expanded assembly tree. Can be undefined or zero -->> object does not exist! */
27
+ currentInstance?: ObjectID;
23
28
  /** Id of the test root. Can be undefined or zero -->> object does not exist! */
24
29
  testRoot?: ObjectID;
25
30
  }
@@ -14,7 +14,7 @@ export declare type InteractionInfo<T = any> = {
14
14
  */
15
15
  objectId: ObjectID;
16
16
  /**
17
- * Identifies the node of the Assembly (for BaseModeling).
17
+ * Identifies the instance of the Assembly (for BaseModeling).
18
18
  * Needed to identify the location ot the object in the tree.
19
19
  */
20
20
  prodRefId?: ObjectID | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerli.io/core",
3
- "version": "0.7.1",
3
+ "version": "0.9.0-beta.1",
4
4
  "description": "buerli state management",
5
5
  "author": "AWV Informatik AG <info@awv-informatik.ch>",
6
6
  "license": "ISC",
@@ -21,7 +21,7 @@
21
21
  "prettify": "prettier --write \"./{src,tests}/**/*.{js,jsx,ts,tsx,json}\""
22
22
  },
23
23
  "devDependencies": {
24
- "@types/three": "^0.143",
24
+ "@types/three": "^0.152.1",
25
25
  "@babel/preset-env": "^7.10.4",
26
26
  "@babel/preset-typescript": "^7.10.4",
27
27
  "babel-jest": "^26.1.0",
@@ -29,7 +29,7 @@
29
29
  "babel-plugin-transform-class-properties": "^6.24.1",
30
30
  "jest": "^26.1.0",
31
31
  "rimraf": "^2.6.3",
32
- "three": "^0.143",
32
+ "three": "^0.153",
33
33
  "typescript": "4.8.4"
34
34
  },
35
35
  "dependencies": {