@buerli.io/core 0.12.0 → 0.13.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.
package/CHANGELOG.md
CHANGED
|
@@ -73,7 +73,27 @@ const geometryApi = (set, get, buerliApi) => ({
|
|
|
73
73
|
}
|
|
74
74
|
return geom;
|
|
75
75
|
},
|
|
76
|
-
|
|
76
|
+
setGraphicColor: (containerId, graphicId, r, g, b) => {
|
|
77
|
+
// Provide values as a CSS color string, which will be gamma corrected by three.js
|
|
78
|
+
const color = new THREE.Color(`rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(b * 255)})`);
|
|
79
|
+
set(state => {
|
|
80
|
+
// If container cache is empty return
|
|
81
|
+
if (!state.geometry.cache[containerId])
|
|
82
|
+
return state;
|
|
83
|
+
// Shallow clone meshes
|
|
84
|
+
const meshes = [...state.geometry.cache[containerId].meshes];
|
|
85
|
+
// Find graphic Object
|
|
86
|
+
const graphic = meshes.find(mesh => mesh.graphicId === graphicId);
|
|
87
|
+
if (!graphic)
|
|
88
|
+
return state;
|
|
89
|
+
// Apply color
|
|
90
|
+
meshes[meshes.indexOf(graphic)] = Object.assign(Object.assign({}, graphic), { color });
|
|
91
|
+
return {
|
|
92
|
+
geometry: Object.assign(Object.assign({}, state.geometry), { cache: Object.assign(Object.assign({}, state.geometry.cache), { [containerId]: Object.assign(Object.assign({}, state.geometry.cache[containerId]), { meshes, dirtyStamp: Date.now() }) }) }),
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
setContainerColor: (containerId, r, g, b) => {
|
|
77
97
|
// Provide values as a CSS color string, which will be gamma corrected by three.js
|
|
78
98
|
const color = new THREE.Color(`rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(b * 255)})`);
|
|
79
99
|
const cachedGeom = Object.assign(Object.assign({}, get().geometry.cache[containerId]), { color });
|
|
@@ -46,7 +46,27 @@ export const geometryApi = (set, get, buerliApi) => ({
|
|
|
46
46
|
}
|
|
47
47
|
return geom;
|
|
48
48
|
},
|
|
49
|
-
|
|
49
|
+
setGraphicColor: (containerId, graphicId, r, g, b) => {
|
|
50
|
+
// Provide values as a CSS color string, which will be gamma corrected by three.js
|
|
51
|
+
const color = new THREE.Color(`rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(b * 255)})`);
|
|
52
|
+
set(state => {
|
|
53
|
+
// If container cache is empty return
|
|
54
|
+
if (!state.geometry.cache[containerId])
|
|
55
|
+
return state;
|
|
56
|
+
// Shallow clone meshes
|
|
57
|
+
const meshes = [...state.geometry.cache[containerId].meshes];
|
|
58
|
+
// Find graphic Object
|
|
59
|
+
const graphic = meshes.find(mesh => mesh.graphicId === graphicId);
|
|
60
|
+
if (!graphic)
|
|
61
|
+
return state;
|
|
62
|
+
// Apply color
|
|
63
|
+
meshes[meshes.indexOf(graphic)] = Object.assign(Object.assign({}, graphic), { color });
|
|
64
|
+
return {
|
|
65
|
+
geometry: Object.assign(Object.assign({}, state.geometry), { cache: Object.assign(Object.assign({}, state.geometry.cache), { [containerId]: Object.assign(Object.assign({}, state.geometry.cache[containerId]), { meshes, dirtyStamp: Date.now() }) }) }),
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
setContainerColor: (containerId, r, g, b) => {
|
|
50
70
|
// Provide values as a CSS color string, which will be gamma corrected by three.js
|
|
51
71
|
const color = new THREE.Color(`rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(b * 255)})`);
|
|
52
72
|
const cachedGeom = Object.assign(Object.assign({}, get().geometry.cache[containerId]), { color });
|
|
@@ -2,6 +2,7 @@ import * as THREE from 'three';
|
|
|
2
2
|
import { StoreApi } from 'zustand';
|
|
3
3
|
import { ContainerGeometryT, GeometryElement } from '../../geometry/ThreeGeometryCreator';
|
|
4
4
|
import { ObjectID } from '../../types/IStructureTree';
|
|
5
|
+
import { GraphicID } from '../../types/IGraphicPackage';
|
|
5
6
|
import { BuerliState } from './buerli';
|
|
6
7
|
import { DrawingState } from './drawing';
|
|
7
8
|
export declare type GeometryBounds = {
|
|
@@ -51,7 +52,8 @@ export declare const geometryApi: (set: StoreApi<DrawingState>['setState'], get:
|
|
|
51
52
|
*/
|
|
52
53
|
updateBounds: () => void;
|
|
53
54
|
createGeometryIfNotCached: (containerId: ObjectID, color?: number[]) => ContainerGeometryT | undefined;
|
|
54
|
-
|
|
55
|
+
setGraphicColor: (containerId: ObjectID, graphicId: GraphicID, r: number, g: number, b: number) => void;
|
|
56
|
+
setContainerColor: (containerId: ObjectID, r: number, g: number, b: number) => void;
|
|
55
57
|
setOpacity: (containerId: ObjectID, opacity: number) => void;
|
|
56
58
|
setConfig: (objId: ObjectID, config: Partial<GeometryConfig> | null) => void;
|
|
57
59
|
findDecorated: () => GeometryElement[];
|
|
@@ -77,6 +77,7 @@ export interface IGraphicLine extends IGraphicElement {
|
|
|
77
77
|
}
|
|
78
78
|
export interface IGraphicLineProperties {
|
|
79
79
|
material: IGraphicMaterial;
|
|
80
|
+
importName: string;
|
|
80
81
|
}
|
|
81
82
|
export interface IGraphicMesh extends IGraphicElement {
|
|
82
83
|
vertices: number[];
|
|
@@ -89,6 +90,8 @@ export interface IGraphicMeshProperties {
|
|
|
89
90
|
operationId: number;
|
|
90
91
|
surface: IGraphicSurface | IGraphicPlane | IGraphicCylinder | IGraphicCone | IGraphicSphere;
|
|
91
92
|
material: IGraphicMaterial;
|
|
93
|
+
importId: string;
|
|
94
|
+
importName: string;
|
|
92
95
|
}
|
|
93
96
|
export interface IGraphicSurface {
|
|
94
97
|
type: GraphicType.PLANE | GraphicType.CYLINDER | GraphicType.CONE | GraphicType.SPHERE | GraphicType.NURBSSURFACE;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buerli.io/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "buerli state management",
|
|
5
5
|
"author": "AWV Informatik AG <info@awv-informatik.ch>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -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.
|
|
32
|
+
"three": "^0.165",
|
|
33
33
|
"typescript": "4.8.4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|