@buerli.io/core 0.5.0-beta.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,28 +48,26 @@ class ThreeGeometryCreator {
48
48
  constructor() {
49
49
  this.coordHeightTolerance = 0.01;
50
50
  }
51
- getMetadata(geometry, container, color = [0, 0, 0], opacity = 0) {
51
+ getMetadata(geometry, container, color, opacity = 0) {
52
52
  var _a;
53
- const contProps = container.properties; // container has always properties
54
53
  const geomProps = geometry ? geometry.properties : {};
55
- let col = container.properties.material.color || color;
56
- let opa = container.properties.material.opacity || opacity;
57
54
  if (geomProps && geomProps.material) {
58
- col = geomProps.material.color || col;
59
- opa = geomProps.material.opacity || opa;
55
+ color = geomProps.material.color || color;
56
+ opacity = geomProps.material.opacity || opacity;
60
57
  }
61
- const rgbColor = new THREE.Color(col[0] / 255, col[1] / 255, col[2] / 255);
62
- const layer = geomProps && geomProps.layer ? geomProps.layer : contProps.layer;
58
+ const rgbColor = color ? new THREE.Color(color[0] / 255, color[1] / 255, color[2] / 255) : undefined;
59
+ const layer = geomProps && geomProps.layer ? geomProps.layer : container.properties.layer;
63
60
  return {
64
61
  color: rgbColor,
65
- opacity: opa,
62
+ opacity,
66
63
  layer,
67
64
  container: { id: container.id, ownerId: container.owner, type: convertType(container.type) },
68
65
  operationId: (_a = geometry === null || geometry === void 0 ? void 0 : geometry.properties) === null || _a === void 0 ? void 0 : _a.operationId,
69
66
  rawGraphic: geometry,
70
67
  };
71
68
  }
72
- createGeometry(container, color = [0, 0, 0]) {
69
+ createGeometry(container, color) {
70
+ var _a, _b, _c, _d;
73
71
  const { id: graphicId, properties, type: contType } = container;
74
72
  const type = convertType(contType);
75
73
  const box = { min: new THREE.Vector3(...properties.min), max: new THREE.Vector3(...properties.max) };
@@ -122,9 +120,9 @@ class ThreeGeometryCreator {
122
120
  edges,
123
121
  arcs,
124
122
  points,
125
- box }, this.getMetadata(null, container, color));
123
+ box }, this.getMetadata(null, container, (_b = (_a = container.properties) === null || _a === void 0 ? void 0 : _a.material) === null || _b === void 0 ? void 0 : _b.color, (_d = (_c = container.properties) === null || _c === void 0 ? void 0 : _c.material) === null || _d === void 0 ? void 0 : _d.opacity));
126
124
  }
127
- createSurface(mesh, container, color = [0, 0, 0]) {
125
+ createSurface(mesh, container, color) {
128
126
  let meshGeom = this.createMesh(mesh, container, color);
129
127
  switch (meshGeom.type) {
130
128
  case types_1.GraphicType.PLANE:
@@ -142,7 +140,7 @@ class ThreeGeometryCreator {
142
140
  }
143
141
  return meshGeom;
144
142
  }
145
- createMesh(mesh, container, color = [0, 0, 0]) {
143
+ createMesh(mesh, container, color) {
146
144
  const graphicId = mesh.id;
147
145
  const loops = mesh.loops;
148
146
  const type = mesh.properties.surface.type;
@@ -183,7 +181,7 @@ class ThreeGeometryCreator {
183
181
  const { radius } = mesh.properties.surface;
184
182
  return Object.assign(Object.assign({}, meshGeom), { type, radius });
185
183
  }
186
- createLine(line, container, points, color = [0, 0, 0]) {
184
+ createLine(line, container, points, color) {
187
185
  const graphicId = line.id;
188
186
  let type = types_1.GraphicType.LINE;
189
187
  if (container.type === types_1.ContainerType.CURVEARRAY) {
@@ -199,7 +197,7 @@ class ThreeGeometryCreator {
199
197
  return Object.assign(Object.assign({ geometry,
200
198
  graphicId, type: type }, this.getMetadata(line, container, color)), { start: start.clone(), end: end.clone() });
201
199
  }
202
- createEdge(edge, container, points, color = [0, 0, 0]) {
200
+ createEdge(edge, container, points, color) {
203
201
  const threePts = [];
204
202
  const graphicId = edge.id;
205
203
  let type = types_1.GraphicType.EDGE;
@@ -229,7 +227,7 @@ class ThreeGeometryCreator {
229
227
  return Object.assign(Object.assign({ geometry,
230
228
  graphicId, type: type }, this.getMetadata(edge, container, color)), { start: start.clone(), end: end.clone() });
231
229
  }
232
- createArc(arc, container, points, color = [0, 0, 0]) {
230
+ createArc(arc, container, points, color) {
233
231
  const graphicId = arc.id;
234
232
  let type = arc.isCircle ? types_1.GraphicType.CIRCLE : types_1.GraphicType.ARC;
235
233
  if (container.type === types_1.ContainerType.CURVEARRAY) {
@@ -74,17 +74,14 @@ const geometryApi = (set, get, buerliApi) => ({
74
74
  return geom;
75
75
  },
76
76
  setColor: (containerId, r, g, b) => {
77
- const thCol = new THREE.Color(r, g, b);
78
- const cachedGeom = Object.assign({}, get().geometry.cache[containerId]);
79
- cachedGeom.color = thCol;
80
- cachedGeom.meshes.forEach(mesh => (mesh.color = thCol));
77
+ const color = new THREE.Color(r, g, b);
78
+ const cachedGeom = Object.assign(Object.assign({}, get().geometry.cache[containerId]), { color });
81
79
  set(state => ({
82
80
  geometry: Object.assign(Object.assign({}, state.geometry), { cache: Object.assign(Object.assign({}, state.geometry.cache), { [containerId]: Object.assign(Object.assign({}, cachedGeom), { dirtyStamp: Date.now() }) }) }),
83
81
  }));
84
82
  },
85
83
  setOpacity: (containerId, opacity) => {
86
84
  const cachedGeom = Object.assign(Object.assign({}, get().geometry.cache[containerId]), { opacity });
87
- cachedGeom.meshes.forEach(mesh => (mesh.opacity = opacity));
88
85
  set(state => ({
89
86
  geometry: Object.assign(Object.assign({}, state.geometry), { cache: Object.assign(Object.assign({}, state.geometry.cache), { [containerId]: Object.assign(Object.assign({}, cachedGeom), { dirtyStamp: Date.now() }) }) }),
90
87
  }));
@@ -22,28 +22,26 @@ export class ThreeGeometryCreator {
22
22
  constructor() {
23
23
  this.coordHeightTolerance = 0.01;
24
24
  }
25
- getMetadata(geometry, container, color = [0, 0, 0], opacity = 0) {
25
+ getMetadata(geometry, container, color, opacity = 0) {
26
26
  var _a;
27
- const contProps = container.properties; // container has always properties
28
27
  const geomProps = geometry ? geometry.properties : {};
29
- let col = container.properties.material.color || color;
30
- let opa = container.properties.material.opacity || opacity;
31
28
  if (geomProps && geomProps.material) {
32
- col = geomProps.material.color || col;
33
- opa = geomProps.material.opacity || opa;
29
+ color = geomProps.material.color || color;
30
+ opacity = geomProps.material.opacity || opacity;
34
31
  }
35
- const rgbColor = new THREE.Color(col[0] / 255, col[1] / 255, col[2] / 255);
36
- const layer = geomProps && geomProps.layer ? geomProps.layer : contProps.layer;
32
+ const rgbColor = color ? new THREE.Color(color[0] / 255, color[1] / 255, color[2] / 255) : undefined;
33
+ const layer = geomProps && geomProps.layer ? geomProps.layer : container.properties.layer;
37
34
  return {
38
35
  color: rgbColor,
39
- opacity: opa,
36
+ opacity,
40
37
  layer,
41
38
  container: { id: container.id, ownerId: container.owner, type: convertType(container.type) },
42
39
  operationId: (_a = geometry === null || geometry === void 0 ? void 0 : geometry.properties) === null || _a === void 0 ? void 0 : _a.operationId,
43
40
  rawGraphic: geometry,
44
41
  };
45
42
  }
46
- createGeometry(container, color = [0, 0, 0]) {
43
+ createGeometry(container, color) {
44
+ var _a, _b, _c, _d;
47
45
  const { id: graphicId, properties, type: contType } = container;
48
46
  const type = convertType(contType);
49
47
  const box = { min: new THREE.Vector3(...properties.min), max: new THREE.Vector3(...properties.max) };
@@ -96,9 +94,9 @@ export class ThreeGeometryCreator {
96
94
  edges,
97
95
  arcs,
98
96
  points,
99
- box }, this.getMetadata(null, container, color));
97
+ box }, this.getMetadata(null, container, (_b = (_a = container.properties) === null || _a === void 0 ? void 0 : _a.material) === null || _b === void 0 ? void 0 : _b.color, (_d = (_c = container.properties) === null || _c === void 0 ? void 0 : _c.material) === null || _d === void 0 ? void 0 : _d.opacity));
100
98
  }
101
- createSurface(mesh, container, color = [0, 0, 0]) {
99
+ createSurface(mesh, container, color) {
102
100
  let meshGeom = this.createMesh(mesh, container, color);
103
101
  switch (meshGeom.type) {
104
102
  case GraphicType.PLANE:
@@ -116,7 +114,7 @@ export class ThreeGeometryCreator {
116
114
  }
117
115
  return meshGeom;
118
116
  }
119
- createMesh(mesh, container, color = [0, 0, 0]) {
117
+ createMesh(mesh, container, color) {
120
118
  const graphicId = mesh.id;
121
119
  const loops = mesh.loops;
122
120
  const type = mesh.properties.surface.type;
@@ -157,7 +155,7 @@ export class ThreeGeometryCreator {
157
155
  const { radius } = mesh.properties.surface;
158
156
  return Object.assign(Object.assign({}, meshGeom), { type, radius });
159
157
  }
160
- createLine(line, container, points, color = [0, 0, 0]) {
158
+ createLine(line, container, points, color) {
161
159
  const graphicId = line.id;
162
160
  let type = GraphicType.LINE;
163
161
  if (container.type === ContainerType.CURVEARRAY) {
@@ -173,7 +171,7 @@ export class ThreeGeometryCreator {
173
171
  return Object.assign(Object.assign({ geometry,
174
172
  graphicId, type: type }, this.getMetadata(line, container, color)), { start: start.clone(), end: end.clone() });
175
173
  }
176
- createEdge(edge, container, points, color = [0, 0, 0]) {
174
+ createEdge(edge, container, points, color) {
177
175
  const threePts = [];
178
176
  const graphicId = edge.id;
179
177
  let type = GraphicType.EDGE;
@@ -203,7 +201,7 @@ export class ThreeGeometryCreator {
203
201
  return Object.assign(Object.assign({ geometry,
204
202
  graphicId, type: type }, this.getMetadata(edge, container, color)), { start: start.clone(), end: end.clone() });
205
203
  }
206
- createArc(arc, container, points, color = [0, 0, 0]) {
204
+ createArc(arc, container, points, color) {
207
205
  const graphicId = arc.id;
208
206
  let type = arc.isCircle ? GraphicType.CIRCLE : GraphicType.ARC;
209
207
  if (container.type === ContainerType.CURVEARRAY) {
@@ -47,17 +47,14 @@ export const geometryApi = (set, get, buerliApi) => ({
47
47
  return geom;
48
48
  },
49
49
  setColor: (containerId, r, g, b) => {
50
- const thCol = new THREE.Color(r, g, b);
51
- const cachedGeom = Object.assign({}, get().geometry.cache[containerId]);
52
- cachedGeom.color = thCol;
53
- cachedGeom.meshes.forEach(mesh => (mesh.color = thCol));
50
+ const color = new THREE.Color(r, g, b);
51
+ const cachedGeom = Object.assign(Object.assign({}, get().geometry.cache[containerId]), { color });
54
52
  set(state => ({
55
53
  geometry: Object.assign(Object.assign({}, state.geometry), { cache: Object.assign(Object.assign({}, state.geometry.cache), { [containerId]: Object.assign(Object.assign({}, cachedGeom), { dirtyStamp: Date.now() }) }) }),
56
54
  }));
57
55
  },
58
56
  setOpacity: (containerId, opacity) => {
59
57
  const cachedGeom = Object.assign(Object.assign({}, get().geometry.cache[containerId]), { opacity });
60
- cachedGeom.meshes.forEach(mesh => (mesh.opacity = opacity));
61
58
  set(state => ({
62
59
  geometry: Object.assign(Object.assign({}, state.geometry), { cache: Object.assign(Object.assign({}, state.geometry.cache), { [containerId]: Object.assign(Object.assign({}, cachedGeom), { dirtyStamp: Date.now() }) }) }),
63
60
  }));
@@ -6,7 +6,7 @@ import { GraphicID, GraphicType, IGraphicArc, IGraphicContainer, IGraphicEdge, I
6
6
  export declare class ThreeGeometryCreator {
7
7
  private coordHeightTolerance;
8
8
  protected getMetadata(geometry: IGraphicElement | null, container: IGraphicContainer, color?: number[], opacity?: number): {
9
- color: THREE.Color;
9
+ color: THREE.Color | undefined;
10
10
  opacity: number;
11
11
  layer: any;
12
12
  container: {
@@ -19,7 +19,7 @@ export declare class ThreeGeometryCreator {
19
19
  };
20
20
  createGeometry(container: IGraphicContainer, color?: number[]): ContainerGeometryT;
21
21
  createSurface(mesh: IGraphicMesh, container: IGraphicContainer, color?: number[]): {
22
- color: THREE.Color;
22
+ color: THREE.Color | undefined;
23
23
  opacity: number;
24
24
  layer: any;
25
25
  container: {
@@ -36,7 +36,7 @@ export declare class ThreeGeometryCreator {
36
36
  loops: number[][];
37
37
  };
38
38
  protected createMesh(mesh: IGraphicMesh, container: IGraphicContainer, color?: number[]): {
39
- color: THREE.Color;
39
+ color: THREE.Color | undefined;
40
40
  opacity: number;
41
41
  layer: any;
42
42
  container: {
@@ -56,7 +56,7 @@ export declare class ThreeGeometryCreator {
56
56
  type: GraphicType;
57
57
  pointOnPlane: THREE.Vector3;
58
58
  normal: THREE.Vector3;
59
- color: THREE.Color;
59
+ color: THREE.Color | undefined;
60
60
  opacity: number;
61
61
  layer: any;
62
62
  container: {
@@ -77,7 +77,7 @@ export declare class ThreeGeometryCreator {
77
77
  axis: THREE.Vector3;
78
78
  height: number;
79
79
  radius: number;
80
- color: THREE.Color;
80
+ color: THREE.Color | undefined;
81
81
  opacity: number;
82
82
  layer: any;
83
83
  container: {
@@ -99,7 +99,7 @@ export declare class ThreeGeometryCreator {
99
99
  height: number;
100
100
  radiusBottom: number;
101
101
  radiusTop: number;
102
- color: THREE.Color;
102
+ color: THREE.Color | undefined;
103
103
  opacity: number;
104
104
  layer: any;
105
105
  container: {
@@ -117,7 +117,7 @@ export declare class ThreeGeometryCreator {
117
117
  createSphere(mesh: IGraphicMesh, meshGeom: MeshGeometry): {
118
118
  type: GraphicType;
119
119
  radius: number;
120
- color: THREE.Color;
120
+ color: THREE.Color | undefined;
121
121
  opacity: number;
122
122
  layer: any;
123
123
  container: {
@@ -135,7 +135,7 @@ export declare class ThreeGeometryCreator {
135
135
  createLine(line: IGraphicLine, container: IGraphicContainer, points: PointMap, color?: number[]): {
136
136
  start: THREE.Vector3;
137
137
  end: THREE.Vector3;
138
- color: THREE.Color;
138
+ color: THREE.Color | undefined;
139
139
  opacity: number;
140
140
  layer: any;
141
141
  container: {
@@ -152,7 +152,7 @@ export declare class ThreeGeometryCreator {
152
152
  createEdge(edge: IGraphicEdge, container: IGraphicContainer, points: PointMap, color?: number[]): {
153
153
  start: THREE.Vector3;
154
154
  end: THREE.Vector3;
155
- color: THREE.Color;
155
+ color: THREE.Color | undefined;
156
156
  opacity: number;
157
157
  layer: any;
158
158
  container: {
@@ -171,7 +171,7 @@ export declare class ThreeGeometryCreator {
171
171
  center: THREE.Vector3;
172
172
  radius: number;
173
173
  angle: number;
174
- color: THREE.Color;
174
+ color: THREE.Color | undefined;
175
175
  opacity: number;
176
176
  layer: any;
177
177
  container: {
@@ -192,7 +192,7 @@ export declare class ThreeGeometryCreator {
192
192
  ownerId: number;
193
193
  type: PointType;
194
194
  }[];
195
- color: THREE.Color;
195
+ color: THREE.Color | undefined;
196
196
  opacity: number;
197
197
  layer: any;
198
198
  container: {
@@ -5,6 +5,8 @@
5
5
  export declare const DEFAULT_STRUCTURE_TREE: () => IStructureProtocol;
6
6
  /** Object Id's in classcad are always >= 1. */
7
7
  export declare type ObjectID = number;
8
+ /** Object identifier */
9
+ export declare type ObjectIdent = string;
8
10
  /** Zero is no Id in classcad, and no object will exist in the CCDatabase for Id === 0! */
9
11
  export declare const NOID = 0;
10
12
  export interface IStructureTree {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerli.io/core",
3
- "version": "0.5.0-beta.4",
3
+ "version": "0.6.0",
4
4
  "description": "buerli state management",
5
5
  "author": "AWV Informatik AG <info@awv-informatik.ch>",
6
6
  "license": "ISC",