abstract-3d 0.1.26 → 0.2.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/lib/abstract-3d.d.ts +2 -6
- package/lib/abstract-3d.d.ts.map +1 -1
- package/lib/abstract-3d.js.map +1 -1
- package/lib/renderers/dxf/color.d.ts +2 -0
- package/lib/renderers/dxf/color.d.ts.map +1 -0
- package/lib/renderers/dxf/color.js +6 -0
- package/lib/renderers/dxf/color.js.map +1 -0
- package/lib/renderers/dxf/dxf-geometries/dxf-box.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-box.js +8 -6
- package/lib/renderers/dxf/dxf-geometries/dxf-box.js.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-cone.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-cone.js +3 -2
- package/lib/renderers/dxf/dxf-geometries/dxf-cone.js.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-cylinder.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-cylinder.js +5 -3
- package/lib/renderers/dxf/dxf-geometries/dxf-cylinder.js.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-plane.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-plane.js +2 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-plane.js.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-polygon.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-polygon.js +5 -4
- package/lib/renderers/dxf/dxf-geometries/dxf-polygon.js.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-shape.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-shape.js +6 -4
- package/lib/renderers/dxf/dxf-geometries/dxf-shape.js.map +1 -1
- package/lib/renderers/react/react-dimension.js +1 -1
- package/lib/renderers/react/react-dimension.js.map +1 -1
- package/lib/renderers/react/react-group.d.ts.map +1 -1
- package/lib/renderers/react/react-group.js +1 -1
- package/lib/renderers/react/react-group.js.map +1 -1
- package/lib/renderers/react/react-hotspot.js +1 -1
- package/lib/renderers/react/react-hotspot.js.map +1 -1
- package/lib/renderers/react/react-material.d.ts +2 -1
- package/lib/renderers/react/react-material.d.ts.map +1 -1
- package/lib/renderers/react/react-material.js +22 -53
- package/lib/renderers/react/react-material.js.map +1 -1
- package/lib/renderers/shared.d.ts +18 -1
- package/lib/renderers/shared.d.ts.map +1 -1
- package/lib/renderers/shared.js +130 -9
- package/lib/renderers/shared.js.map +1 -1
- package/lib/renderers/step/step-encoding.d.ts +5 -3
- package/lib/renderers/step/step-encoding.d.ts.map +1 -1
- package/lib/renderers/step/step-encoding.js +8 -4
- package/lib/renderers/step/step-encoding.js.map +1 -1
- package/lib/renderers/step/step-geometries/step-box.d.ts.map +1 -1
- package/lib/renderers/step/step-geometries/step-box.js +6 -6
- package/lib/renderers/step/step-geometries/step-box.js.map +1 -1
- package/lib/renderers/step/step-geometries/step-cylinder.d.ts +3 -0
- package/lib/renderers/step/step-geometries/step-cylinder.d.ts.map +1 -1
- package/lib/renderers/step/step-geometries/step-cylinder.js +38 -157
- package/lib/renderers/step/step-geometries/step-cylinder.js.map +1 -1
- package/lib/renderers/step/step-geometries/step-plane.d.ts.map +1 -1
- package/lib/renderers/step/step-geometries/step-plane.js +1 -1
- package/lib/renderers/step/step-geometries/step-plane.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-box.js +1 -1
- package/lib/renderers/svg/svg-geometries/svg-box.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-cone.js +1 -1
- package/lib/renderers/svg/svg-geometries/svg-cone.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-cylinder.js +1 -1
- package/lib/renderers/svg/svg-geometries/svg-cylinder.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-line.js +1 -1
- package/lib/renderers/svg/svg-geometries/svg-line.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-plane.js +1 -1
- package/lib/renderers/svg/svg-geometries/svg-plane.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-polygon.js +1 -1
- package/lib/renderers/svg/svg-geometries/svg-polygon.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-shape.js +1 -1
- package/lib/renderers/svg/svg-geometries/svg-shape.js.map +1 -1
- package/package.json +2 -2
- package/src/abstract-3d.ts +2 -8
- package/src/renderers/dxf/color.ts +1 -0
- package/src/renderers/dxf/dxf-geometries/dxf-box.ts +8 -7
- package/src/renderers/dxf/dxf-geometries/dxf-cone.ts +3 -3
- package/src/renderers/dxf/dxf-geometries/dxf-cylinder.ts +5 -4
- package/src/renderers/dxf/dxf-geometries/dxf-plane.ts +2 -1
- package/src/renderers/dxf/dxf-geometries/dxf-polygon.ts +5 -4
- package/src/renderers/dxf/dxf-geometries/dxf-shape.ts +6 -4
- package/src/renderers/react/react-dimension.tsx +1 -1
- package/src/renderers/react/react-group.tsx +1 -0
- package/src/renderers/react/react-hotspot.tsx +1 -1
- package/src/renderers/react/react-material.tsx +38 -74
- package/src/renderers/shared.ts +136 -1
- package/src/renderers/step/step-encoding.ts +15 -6
- package/src/renderers/step/step-geometries/step-box.ts +6 -0
- package/src/renderers/step/step-geometries/step-cylinder.ts +192 -159
- package/src/renderers/step/step-geometries/step-plane.ts +5 -1
- package/src/renderers/svg/svg-geometries/svg-box.ts +2 -2
- package/src/renderers/svg/svg-geometries/svg-cone.ts +2 -2
- package/src/renderers/svg/svg-geometries/svg-cylinder.ts +2 -2
- package/src/renderers/svg/svg-geometries/svg-line.ts +2 -2
- package/src/renderers/svg/svg-geometries/svg-plane.ts +2 -2
- package/src/renderers/svg/svg-geometries/svg-polygon.ts +2 -2
- package/src/renderers/svg/svg-geometries/svg-shape.ts +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as A3D from "../../../abstract-3d";
|
|
2
|
+
import { color } from "../color";
|
|
2
3
|
import { dxf3DFACE } from "../dxf-encoding";
|
|
3
4
|
|
|
4
5
|
const chunkSize = 4;
|
|
@@ -8,10 +9,11 @@ export function dxfPolygon(s: A3D.Shape, m: A3D.Material, parentPos: A3D.Vec3, p
|
|
|
8
9
|
const pos = A3D.vec3TransRot(s.pos, parentPos, parentRot);
|
|
9
10
|
const rot = A3D.vec3RotCombine(parentRot, s.rot ?? A3D.vec3Zero);
|
|
10
11
|
const points = s.points.map((p) => A3D.vec3TransRot(A3D.vec3(p.x, p.y, 0), pos, rot));
|
|
12
|
+
const mat = color(m.normal);
|
|
11
13
|
let i = 0;
|
|
12
14
|
if (points.length >= chunkSize) {
|
|
13
15
|
for (i; i < points.length; i += chunkSize) {
|
|
14
|
-
polygonString += dxf3DFACE(points[i]!, points[i + 1]!, points[i + 2]!, points[i + 3]!,
|
|
16
|
+
polygonString += dxf3DFACE(points[i]!, points[i + 1]!, points[i + 2]!, points[i + 3]!, mat);
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
|
|
@@ -19,13 +21,13 @@ export function dxfPolygon(s: A3D.Shape, m: A3D.Material, parentPos: A3D.Vec3, p
|
|
|
19
21
|
const lastArrayLength = points.length - i;
|
|
20
22
|
switch (lastArrayLength) {
|
|
21
23
|
case 1:
|
|
22
|
-
polygonString += dxf3DFACE(points[i - 2]!, points[i - 1]!, points[i]!, points[i]!,
|
|
24
|
+
polygonString += dxf3DFACE(points[i - 2]!, points[i - 1]!, points[i]!, points[i]!, mat);
|
|
23
25
|
break;
|
|
24
26
|
case 2:
|
|
25
|
-
polygonString += dxf3DFACE(points[i - 1]!, points[i]!, points[i + 1]!, points[i + 1]!,
|
|
27
|
+
polygonString += dxf3DFACE(points[i - 1]!, points[i]!, points[i + 1]!, points[i + 1]!, mat);
|
|
26
28
|
break;
|
|
27
29
|
case 3:
|
|
28
|
-
polygonString += dxf3DFACE(points[i]!, points[i + 1]!, points[i + 2]!, points[i + 2]!,
|
|
30
|
+
polygonString += dxf3DFACE(points[i]!, points[i + 1]!, points[i + 2]!, points[i + 2]!, mat);
|
|
29
31
|
break;
|
|
30
32
|
default:
|
|
31
33
|
break;
|
|
@@ -18,7 +18,7 @@ export const ReactDimensions = React.memo(
|
|
|
18
18
|
readonly sceneCenter: A3d.Vec3 | undefined;
|
|
19
19
|
}): JSX.Element => {
|
|
20
20
|
const dimensionMaterial = React.useMemo(
|
|
21
|
-
() => (dimensions?.material ? <ReactMaterial material={dimensions?.material} /> : <></>),
|
|
21
|
+
() => (dimensions?.material ? <ReactMaterial isText={true} material={dimensions?.material} /> : <></>),
|
|
22
22
|
[]
|
|
23
23
|
);
|
|
24
24
|
return (
|
|
@@ -101,7 +101,7 @@ export function ReactHotSpot({
|
|
|
101
101
|
})}
|
|
102
102
|
>
|
|
103
103
|
<ReactMesh mesh={h.mesh}>
|
|
104
|
-
<ReactMaterial id={h.id} material={h.mesh.material} hoveredId={hoveredId} />
|
|
104
|
+
<ReactMaterial id={h.id} isText={false} material={h.mesh.material} hoveredId={hoveredId} />
|
|
105
105
|
</ReactMesh>
|
|
106
106
|
</group>
|
|
107
107
|
{hotSpotTexts && text && (
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { Color, DoubleSide, MaterialParameters, SRGBColorSpace, Texture, TextureLoader } from "three";
|
|
3
3
|
import { suspend } from "suspend-react";
|
|
4
4
|
import * as A3d from "../../abstract-3d";
|
|
5
|
+
import { shade } from "../shared";
|
|
5
6
|
|
|
6
7
|
const decreasedOpacity = 0.2;
|
|
7
8
|
|
|
@@ -16,6 +17,7 @@ export function ReactMaterial({
|
|
|
16
17
|
disabled,
|
|
17
18
|
materialStateImages,
|
|
18
19
|
state,
|
|
20
|
+
isText,
|
|
19
21
|
}: {
|
|
20
22
|
readonly material: A3d.Material;
|
|
21
23
|
readonly id?: string;
|
|
@@ -24,16 +26,24 @@ export function ReactMaterial({
|
|
|
24
26
|
readonly disabled?: boolean;
|
|
25
27
|
readonly materialStateImages?: Record<string, string>;
|
|
26
28
|
readonly state?: MaterialState | undefined;
|
|
29
|
+
readonly isText: boolean;
|
|
27
30
|
}): JSX.Element {
|
|
28
31
|
const mat =
|
|
29
32
|
!state || material.image?.type === "UrlImage"
|
|
30
33
|
? material
|
|
31
34
|
: state === "Accept"
|
|
32
|
-
?
|
|
35
|
+
? acceptMat
|
|
33
36
|
: state === "Error"
|
|
34
|
-
?
|
|
35
|
-
:
|
|
36
|
-
const color =
|
|
37
|
+
? errorMar
|
|
38
|
+
: warningMat;
|
|
39
|
+
const color =
|
|
40
|
+
selectedId === id
|
|
41
|
+
? hoveredId === id
|
|
42
|
+
? shade(-0.4, selectMat.normal)
|
|
43
|
+
: selectMat.normal
|
|
44
|
+
: hoveredId === id
|
|
45
|
+
? shade(-0.4, mat.normal)
|
|
46
|
+
: mat.normal;
|
|
37
47
|
const opacity = material.opacity !== undefined ? material.opacity : materialDefaults.opacity!;
|
|
38
48
|
if (material.image?.type === "UrlImage") {
|
|
39
49
|
return (
|
|
@@ -44,51 +54,27 @@ export function ReactMaterial({
|
|
|
44
54
|
/>
|
|
45
55
|
);
|
|
46
56
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/>
|
|
57
|
-
);
|
|
58
|
-
case "Phong":
|
|
59
|
-
return (
|
|
60
|
-
<meshPhongMaterial
|
|
61
|
-
color={color}
|
|
62
|
-
shininess={(mat.shininess ?? 70) * 2}
|
|
63
|
-
side={DoubleSide}
|
|
64
|
-
{...(opacity < 1 || disabled
|
|
65
|
-
? { transparent: true, opacity: disabled ? opacity * decreasedOpacity : opacity }
|
|
66
|
-
: materialDefaults)}
|
|
67
|
-
/>
|
|
68
|
-
);
|
|
69
|
-
// return (
|
|
70
|
-
// <meshStandardMaterial
|
|
71
|
-
// color={color}
|
|
72
|
-
// roughness={0.45}
|
|
73
|
-
// metalness={0.55}
|
|
74
|
-
// side={DoubleSide}
|
|
75
|
-
// {...(mat.opacity < 1 || disabled
|
|
76
|
-
// ? { transparent: true, opacity: disabled ? mat.opacity * decreasedOpacity : mat.opacity }
|
|
77
|
-
// : materialDefaults)}
|
|
78
|
-
// />
|
|
79
|
-
// );
|
|
80
|
-
case "Lambert":
|
|
81
|
-
default:
|
|
82
|
-
return (
|
|
83
|
-
<meshLambertMaterial
|
|
84
|
-
color={color}
|
|
85
|
-
side={DoubleSide}
|
|
86
|
-
{...(opacity < 1 || disabled
|
|
87
|
-
? { transparent: true, opacity: disabled ? opacity * decreasedOpacity : opacity }
|
|
88
|
-
: materialDefaults)}
|
|
89
|
-
/>
|
|
90
|
-
);
|
|
57
|
+
if (isText) {
|
|
58
|
+
return (
|
|
59
|
+
<meshBasicMaterial
|
|
60
|
+
color={color}
|
|
61
|
+
side={DoubleSide}
|
|
62
|
+
transparent
|
|
63
|
+
{...(opacity < 1 ? { opacity } : materialDefaults)}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
91
66
|
}
|
|
67
|
+
return (
|
|
68
|
+
<meshStandardMaterial
|
|
69
|
+
color={color}
|
|
70
|
+
roughness={mat.roughness}
|
|
71
|
+
metalness={mat.metalness}
|
|
72
|
+
side={DoubleSide}
|
|
73
|
+
{...(opacity < 1 || disabled
|
|
74
|
+
? { transparent: true, opacity: disabled ? opacity * decreasedOpacity : opacity }
|
|
75
|
+
: materialDefaults)}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
92
78
|
}
|
|
93
79
|
|
|
94
80
|
function TextureMaterial({
|
|
@@ -131,29 +117,7 @@ const textureLoader = new TextureLoader();
|
|
|
131
117
|
|
|
132
118
|
const materialDefaults: MaterialParameters = { transparent: false, opacity: 1.0, depthWrite: true, depthTest: true };
|
|
133
119
|
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
selected: "rgb(1,88,55)",
|
|
139
|
-
opacity: 1.0,
|
|
140
|
-
shininess: 50,
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const errorMaterial: A3d.Material = {
|
|
144
|
-
type: "Phong",
|
|
145
|
-
normal: "#b82f3a",
|
|
146
|
-
hover: "#991c31",
|
|
147
|
-
selected: "#991c31",
|
|
148
|
-
opacity: 1.0,
|
|
149
|
-
shininess: 50,
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const warningMaterial: A3d.Material = {
|
|
153
|
-
type: "Phong",
|
|
154
|
-
normal: "rgb(240, 197, 48)",
|
|
155
|
-
hover: "rgb(221, 181, 38)",
|
|
156
|
-
selected: "rgb(182, 147, 20)",
|
|
157
|
-
opacity: 1.0,
|
|
158
|
-
shininess: 50,
|
|
159
|
-
};
|
|
120
|
+
const acceptMat: A3d.Material = { normal: "rgb(0,148,91)", opacity: 1.0, metalness: 0.5, roughness: 0.5 };
|
|
121
|
+
const selectMat: A3d.Material = { normal: "rgb(14,82,184)", opacity: 1.0, metalness: 0.5, roughness: 0.5 };
|
|
122
|
+
const errorMar: A3d.Material = { normal: "#b82f3a", opacity: 1.0, metalness: 0.5, roughness: 0.5 };
|
|
123
|
+
const warningMat: A3d.Material = { normal: "rgb(240, 197, 48)", opacity: 1.0, metalness: 0.5, roughness: 0.5 };
|
package/src/renderers/shared.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
1
2
|
import {
|
|
2
3
|
Vec3,
|
|
3
4
|
View,
|
|
@@ -56,8 +57,142 @@ export function parseRgb(color: string): { readonly r: number; readonly g: numbe
|
|
|
56
57
|
return rgb;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
export function
|
|
60
|
+
export function parseColorString(s: string): { readonly r: number; readonly g: number; readonly b: number } {
|
|
61
|
+
if (s.startsWith("#")) {
|
|
62
|
+
if (s.length === 9) {
|
|
63
|
+
return {
|
|
64
|
+
// a: parseInt(s.slice(1, 3), 16),
|
|
65
|
+
r: parseInt(s.slice(3, 5), 16),
|
|
66
|
+
g: parseInt(s.slice(5, 7), 16),
|
|
67
|
+
b: parseInt(s.slice(7, 9), 16),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return { r: parseInt(s.slice(1, 3), 16), g: parseInt(s.slice(3, 5), 16), b: parseInt(s.slice(5, 7), 16) };
|
|
71
|
+
}
|
|
72
|
+
if (s.startsWith("rgb")) {
|
|
73
|
+
const [r, g, b, _a] = s.split("(")[1]?.split(")")[0]?.split(",") ?? [];
|
|
74
|
+
return { r: Number(r ?? 0), g: Number(g ?? 0), b: Number(b ?? 0) };
|
|
75
|
+
}
|
|
76
|
+
if (s === "white") {
|
|
77
|
+
return white;
|
|
78
|
+
}
|
|
79
|
+
if (s === "black") {
|
|
80
|
+
return black;
|
|
81
|
+
}
|
|
82
|
+
return white;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const white = { r: 255, g: 255, b: 255 };
|
|
86
|
+
const black = { r: 0, g: 0, b: 0 };
|
|
87
|
+
|
|
88
|
+
export function rgbGrayScale(color: string): string {
|
|
60
89
|
const parts = color.split("(")[1]?.slice(0, -1).split(",");
|
|
61
90
|
const c = Number(parts?.[0] ?? 416) * 0.3 + Number(parts?.[1] ?? 212) * 0.587 + Number(parts?.[2] ?? 1100) * 0.114;
|
|
62
91
|
return `rgb(${c},${c},${c})`;
|
|
63
92
|
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* This will take a HEX or RGB web color. pSBC can shade it darker or lighter,
|
|
96
|
+
* or blend it with a second color, and can also pass it right thru but convert
|
|
97
|
+
* from Hex to RGB (Hex2RGB) or RGB to Hex (RGB2Hex).
|
|
98
|
+
* All without you even knowing what color format you are using.
|
|
99
|
+
*
|
|
100
|
+
* @param {number} p - From 0 to 1 Percentage float (Required).
|
|
101
|
+
* @param {string} from - The starting color in HEX or RGB format.
|
|
102
|
+
* @param {string} [to] - The ending color in HEX or RGB format, optional.
|
|
103
|
+
* @returns {string|null} Either Hex or RGB color. Null if invalid color or percentage number.
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
export function shade(p: number, from: string, to?: string): string | undefined {
|
|
107
|
+
if (
|
|
108
|
+
typeof p !== "number" ||
|
|
109
|
+
p < -1 ||
|
|
110
|
+
p > 1 ||
|
|
111
|
+
typeof from !== "string" ||
|
|
112
|
+
(from[0] !== "r" && from[0] !== "#") ||
|
|
113
|
+
(to && typeof to !== "string")
|
|
114
|
+
) {
|
|
115
|
+
return undefined; // ErrorCheck
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const sbcRip = (d: string): Record<number, number> | null => {
|
|
119
|
+
const l = d.length;
|
|
120
|
+
const RGB: Record<number, number> = {};
|
|
121
|
+
|
|
122
|
+
if (l > 9) {
|
|
123
|
+
const dArr = d.split(",");
|
|
124
|
+
if (dArr.length < 3 || dArr.length > 4) return null; // ErrorCheck
|
|
125
|
+
RGB[0] = i(dArr[0].split("(")[1]);
|
|
126
|
+
RGB[1] = i(dArr[1]);
|
|
127
|
+
RGB[2] = i(dArr[2]);
|
|
128
|
+
RGB[3] = dArr[3] ? parseFloat(dArr[3]) : -1;
|
|
129
|
+
} else {
|
|
130
|
+
if (l === 8 || l === 6 || l < 4) return null; // ErrorCheck
|
|
131
|
+
if (l < 6) {
|
|
132
|
+
d = "#" + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (l > 4 ? String(d[4]) + d[4] : ""); // 3 or 4 digit
|
|
133
|
+
}
|
|
134
|
+
const dInt = i(d.slice(1), 16);
|
|
135
|
+
RGB[0] = (dInt >> 16) & 255;
|
|
136
|
+
RGB[1] = (dInt >> 8) & 255;
|
|
137
|
+
RGB[2] = dInt & 255;
|
|
138
|
+
RGB[3] = -1;
|
|
139
|
+
|
|
140
|
+
if (l === 9 || l === 5) {
|
|
141
|
+
RGB[3] = r((RGB[2] / 255) * 10000) / 10000;
|
|
142
|
+
RGB[2] = RGB[1];
|
|
143
|
+
RGB[1] = RGB[0];
|
|
144
|
+
RGB[0] = (dInt >> 24) & 255;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return RGB;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const i = parseInt;
|
|
151
|
+
const r = Math.round;
|
|
152
|
+
|
|
153
|
+
let h = from.length > 9;
|
|
154
|
+
h = typeof to === "string" ? (to.length > 9 ? true : to === "c" ? !h : false) : h;
|
|
155
|
+
const b = p < 0;
|
|
156
|
+
p = b ? p * -1 : p;
|
|
157
|
+
to = to && to !== "c" ? to : b ? "#000000" : "#FFFFFF";
|
|
158
|
+
|
|
159
|
+
const f = sbcRip(from);
|
|
160
|
+
const t = sbcRip(to);
|
|
161
|
+
if (!f || !t) {
|
|
162
|
+
return undefined; // ErrorCheck
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (h) {
|
|
166
|
+
return (
|
|
167
|
+
"rgb" +
|
|
168
|
+
(f[3] > -1 || t[3] > -1 ? "a(" : "(") +
|
|
169
|
+
r((t[0] - f[0]) * p + f[0]) +
|
|
170
|
+
"," +
|
|
171
|
+
r((t[1] - f[1]) * p + f[1]) +
|
|
172
|
+
"," +
|
|
173
|
+
r((t[2] - f[2]) * p + f[2]) +
|
|
174
|
+
(f[3] < 0 && t[3] < 0
|
|
175
|
+
? ")"
|
|
176
|
+
: "," + (f[3] > -1 && t[3] > -1 ? r(((t[3] - f[3]) * p + f[3]) * 10000) / 10000 : t[3] < 0 ? f[3] : t[3]) + ")")
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
"#" +
|
|
182
|
+
(
|
|
183
|
+
0x100000000 +
|
|
184
|
+
r((t[0] - f[0]) * p + f[0]) * 0x1000000 +
|
|
185
|
+
r((t[1] - f[1]) * p + f[1]) * 0x10000 +
|
|
186
|
+
r((t[2] - f[2]) * p + f[2]) * 0x100 +
|
|
187
|
+
(f[3] > -1 && t[3] > -1
|
|
188
|
+
? r(((t[3] - f[3]) * p + f[3]) * 255)
|
|
189
|
+
: t[3] > -1
|
|
190
|
+
? r(t[3] * 255)
|
|
191
|
+
: f[3] > -1
|
|
192
|
+
? r(f[3] * 255)
|
|
193
|
+
: 255)
|
|
194
|
+
)
|
|
195
|
+
.toString(16)
|
|
196
|
+
.slice(1, f[3] > -1 || t[3] > -1 ? undefined : -2)
|
|
197
|
+
);
|
|
198
|
+
}
|
|
@@ -63,6 +63,12 @@ export const EDGE_CURVE = (VERTEX_POINT_FROM: number, VERTEX_POINT_TO: number, L
|
|
|
63
63
|
export const ORIENTED_EDGE = (EDGE_CURVE: number, m: MutableStep): number =>
|
|
64
64
|
mutate(`ORIENTED_EDGE('',*,*,#${EDGE_CURVE},.F.)`, m);
|
|
65
65
|
|
|
66
|
+
export const SURFACE_CURVE = (CIRCLE: number, PCURVE1: number, PCURVE2: number, m: MutableStep): number =>
|
|
67
|
+
mutate(`SURFACE_CURVE('',#${CIRCLE},(#${PCURVE1},#${PCURVE2}),.PCURVE_S1.)`, m);
|
|
68
|
+
|
|
69
|
+
export const SEAM_CURVE = (LINE: number, PCURVE1: number, PCURVE2: number, m: MutableStep): number =>
|
|
70
|
+
mutate(`SEAM_CURVE('',#${LINE},(#${PCURVE1},#${PCURVE2}),.PCURVE_S1.)`, m);
|
|
71
|
+
|
|
66
72
|
export const ADVANCED_FACE = (
|
|
67
73
|
faceRef: number,
|
|
68
74
|
planeOrPcurveRef: number,
|
|
@@ -73,8 +79,8 @@ export const ADVANCED_FACE = (
|
|
|
73
79
|
export const OPEN_SHELL = (ADVANCED_FACE: number, m: MutableStep): number =>
|
|
74
80
|
mutate(`OPEN_SHELL('',(#${ADVANCED_FACE}))`, m);
|
|
75
81
|
|
|
76
|
-
export const FACE_BOUND = (EDGE_CURVE: number, m: MutableStep): number =>
|
|
77
|
-
mutate(`FACE_BOUND('',#${EDGE_CURVE}
|
|
82
|
+
export const FACE_BOUND = (EDGE_CURVE: number, type: "T" | "F", m: MutableStep): number =>
|
|
83
|
+
mutate(`FACE_BOUND('',#${EDGE_CURVE},.${type}.)`, m);
|
|
78
84
|
|
|
79
85
|
export const EDGE_LOOP = (ORIENTED_EDGE: ReadonlyArray<number>, m: MutableStep): number =>
|
|
80
86
|
mutate(`EDGE_LOOP('',(${ORIENTED_EDGE.map((af) => `#${af}`).join(",")}))`, m);
|
|
@@ -82,14 +88,17 @@ export const EDGE_LOOP = (ORIENTED_EDGE: ReadonlyArray<number>, m: MutableStep):
|
|
|
82
88
|
export const PLANE = (AXIS2_PLACEMENT_3D: number, m: MutableStep): number =>
|
|
83
89
|
mutate(`PLANE('',#${AXIS2_PLACEMENT_3D})`, m);
|
|
84
90
|
|
|
85
|
-
export const PCURVE = (
|
|
86
|
-
|
|
91
|
+
export const PCURVE = (
|
|
92
|
+
CYLINDRICAL_SURFACE_or_PLANE: number,
|
|
93
|
+
DEFINITIONAL_REPRESENTATION: number,
|
|
94
|
+
m: MutableStep
|
|
95
|
+
): number => mutate(`PCURVE('',#${CYLINDRICAL_SURFACE_or_PLANE},#${DEFINITIONAL_REPRESENTATION})`, m);
|
|
87
96
|
|
|
88
97
|
export const CYLINDRICAL_SURFACE = (AXIS2_PLACEMENT_3D: number, m: MutableStep): number =>
|
|
89
98
|
mutate(`CYLINDRICAL_SURFACE('',#${AXIS2_PLACEMENT_3D},2.)`, m);
|
|
90
99
|
|
|
91
|
-
export const DEFINITIONAL_REPRESENTATION = (
|
|
92
|
-
mutate(`DEFINITIONAL_REPRESENTATION('',(#${
|
|
100
|
+
export const DEFINITIONAL_REPRESENTATION = (LINEorCircle: number, m: MutableStep): number =>
|
|
101
|
+
mutate(`DEFINITIONAL_REPRESENTATION('',(#${LINEorCircle}),#7)`, m);
|
|
93
102
|
|
|
94
103
|
export const SHELL_BASED_SURFACE_MODEL = (OPEN_SHELL: number, m: MutableStep): number =>
|
|
95
104
|
mutate(`SHELL_BASED_SURFACE_MODEL('',(#${OPEN_SHELL}))`, m);
|
|
@@ -80,6 +80,7 @@ export function stepBox(b: Box, mat: Material, parentPos: Vec3, parentRot: Vec3,
|
|
|
80
80
|
],
|
|
81
81
|
m
|
|
82
82
|
),
|
|
83
|
+
"T",
|
|
83
84
|
m
|
|
84
85
|
),
|
|
85
86
|
PLANE(AXIS2_PLACEMENT_3D(c0, d3, d1, m), m),
|
|
@@ -97,6 +98,7 @@ export function stepBox(b: Box, mat: Material, parentPos: Vec3, parentRot: Vec3,
|
|
|
97
98
|
],
|
|
98
99
|
m
|
|
99
100
|
),
|
|
101
|
+
"T",
|
|
100
102
|
m
|
|
101
103
|
),
|
|
102
104
|
PLANE(AXIS2_PLACEMENT_3D(c0, d6, d4, m), m),
|
|
@@ -114,6 +116,7 @@ export function stepBox(b: Box, mat: Material, parentPos: Vec3, parentRot: Vec3,
|
|
|
114
116
|
],
|
|
115
117
|
m
|
|
116
118
|
),
|
|
119
|
+
"T",
|
|
117
120
|
m
|
|
118
121
|
),
|
|
119
122
|
PLANE(AXIS2_PLACEMENT_3D(c0, d4, d3, m), m),
|
|
@@ -131,6 +134,7 @@ export function stepBox(b: Box, mat: Material, parentPos: Vec3, parentRot: Vec3,
|
|
|
131
134
|
],
|
|
132
135
|
m
|
|
133
136
|
),
|
|
137
|
+
"T",
|
|
134
138
|
m
|
|
135
139
|
),
|
|
136
140
|
PLANE(AXIS2_PLACEMENT_3D(c0, d1, d6, m), m),
|
|
@@ -148,6 +152,7 @@ export function stepBox(b: Box, mat: Material, parentPos: Vec3, parentRot: Vec3,
|
|
|
148
152
|
],
|
|
149
153
|
m
|
|
150
154
|
),
|
|
155
|
+
"T",
|
|
151
156
|
m
|
|
152
157
|
),
|
|
153
158
|
PLANE(AXIS2_PLACEMENT_3D(c0, d2, d1, m), m),
|
|
@@ -165,6 +170,7 @@ export function stepBox(b: Box, mat: Material, parentPos: Vec3, parentRot: Vec3,
|
|
|
165
170
|
],
|
|
166
171
|
m
|
|
167
172
|
),
|
|
173
|
+
"T",
|
|
168
174
|
m
|
|
169
175
|
),
|
|
170
176
|
PLANE(AXIS2_PLACEMENT_3D(c0, d5, d4, m), m),
|