abstract-3d 2.7.32 → 2.8.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/README.md +1 -1
- package/lib/abstract-3d.d.ts +1 -1
- package/lib/abstract-3d.d.ts.map +1 -1
- package/lib/abstract-3d.js +46 -29
- package/lib/abstract-3d.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-build.d.ts +4 -0
- package/lib/renderers/dxf/dxf-encoding/dxf-build.d.ts.map +1 -0
- package/lib/renderers/dxf/dxf-encoding/dxf-build.js +8 -0
- package/lib/renderers/dxf/dxf-encoding/dxf-build.js.map +1 -0
- package/lib/renderers/dxf/dxf-encoding/dxf-color.js +3 -2
- package/lib/renderers/dxf/dxf-encoding/dxf-color.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-common.d.ts +1 -3
- package/lib/renderers/dxf/dxf-encoding/dxf-common.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-common.js +3 -10
- package/lib/renderers/dxf/dxf-encoding/dxf-common.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-dimension.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-dimension.js +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-dimension.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-footer.js +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-header.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-header.js +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-header.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-line.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-line.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-lwpolyline.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-lwpolyline.js +1 -3
- package/lib/renderers/dxf/dxf-encoding/dxf-lwpolyline.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-mtext.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-mtext.js +0 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-mtext.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-polyline.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-polyline.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-solid.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-solid.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-triangle.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-triangle.js.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-box.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-box.js +1 -1
- 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 +2 -3
- 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 +2 -3
- package/lib/renderers/dxf/dxf-geometries/dxf-cylinder.js.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-dimension.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-dimension.js.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-image.d.ts +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-image.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-image.js +4 -9
- package/lib/renderers/dxf/dxf-geometries/dxf-image.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 +1 -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 +1 -1
- 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.map +1 -1
- package/lib/renderers/dxf/dxf.d.ts +1 -1
- package/lib/renderers/dxf/dxf.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf.js +6 -5
- package/lib/renderers/dxf/dxf.js.map +1 -1
- package/lib/renderers/react/react-camera.d.ts +1 -1
- package/lib/renderers/react/react-camera.d.ts.map +1 -1
- package/lib/renderers/react/react-camera.js +13 -18
- package/lib/renderers/react/react-camera.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 +1 -1
- package/lib/renderers/react/react-group.d.ts.map +1 -1
- package/lib/renderers/react/react-group.js +4 -3
- package/lib/renderers/react/react-group.js.map +1 -1
- package/lib/renderers/react/react-hotspot.d.ts +1 -1
- package/lib/renderers/react/react-hotspot.d.ts.map +1 -1
- package/lib/renderers/react/react-hotspot.js +2 -2
- package/lib/renderers/react/react-hotspot.js.map +1 -1
- package/lib/renderers/react/react-image-material.d.ts.map +1 -1
- package/lib/renderers/react/react-image-material.js +5 -6
- package/lib/renderers/react/react-image-material.js.map +1 -1
- package/lib/renderers/react/react-material.d.ts.map +1 -1
- package/lib/renderers/react/react-material.js +3 -15
- package/lib/renderers/react/react-material.js.map +1 -1
- package/lib/renderers/react/react-mesh.d.ts +1 -1
- package/lib/renderers/react/react-mesh.d.ts.map +1 -1
- package/lib/renderers/react/react-mesh.js +10 -9
- package/lib/renderers/react/react-mesh.js.map +1 -1
- package/lib/renderers/react/react-scene.d.ts +1 -1
- package/lib/renderers/react/react-scene.d.ts.map +1 -1
- package/lib/renderers/react/react-scene.js +3 -11
- package/lib/renderers/react/react-scene.js.map +1 -1
- package/lib/renderers/react/react.d.ts +2 -2
- package/lib/renderers/react/react.d.ts.map +1 -1
- package/lib/renderers/react/react.js +4 -4
- package/lib/renderers/react/react.js.map +1 -1
- package/lib/renderers/step/step-encoding.d.ts.map +1 -1
- 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 +1 -1
- package/lib/renderers/step/step-geometries/step-box.js.map +1 -1
- package/lib/renderers/step/step-geometries/step-cylinder.d.ts.map +1 -1
- package/lib/renderers/step/step-geometries/step-cylinder.js.map +1 -1
- package/lib/renderers/stl/stl-geometries/stl-cone.d.ts.map +1 -1
- package/lib/renderers/stl/stl-geometries/stl-cone.js +1 -2
- package/lib/renderers/stl/stl-geometries/stl-cone.js.map +1 -1
- package/lib/renderers/stl/stl-geometries/stl-cylinder.d.ts.map +1 -1
- package/lib/renderers/stl/stl-geometries/stl-cylinder.js +1 -2
- package/lib/renderers/stl/stl-geometries/stl-cylinder.js.map +1 -1
- package/lib/renderers/stl/stl-geometries/stl-plane.d.ts.map +1 -1
- package/lib/renderers/stl/stl-geometries/stl-plane.js +1 -6
- package/lib/renderers/stl/stl-geometries/stl-plane.js.map +1 -1
- package/lib/renderers/stl/stl.d.ts.map +1 -1
- package/lib/renderers/stl/stl.js +3 -4
- package/lib/renderers/stl/stl.js.map +1 -1
- package/lib/renderers/svg/svg-encoding.d.ts.map +1 -1
- package/lib/renderers/svg/svg-encoding.js +3 -3
- package/lib/renderers/svg/svg-encoding.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/shared.d.ts.map +1 -1
- package/lib/renderers/svg/svg-geometries/shared.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-box.d.ts.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-box.js +2 -2
- package/lib/renderers/svg/svg-geometries/svg-box.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-cone.d.ts.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-cone.js +4 -9
- package/lib/renderers/svg/svg-geometries/svg-cone.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-cylinder.d.ts.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-cylinder.js +4 -9
- package/lib/renderers/svg/svg-geometries/svg-cylinder.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-image.d.ts.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-image.js +2 -2
- package/lib/renderers/svg/svg-geometries/svg-image.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-line.d.ts.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-line.js +3 -5
- package/lib/renderers/svg/svg-geometries/svg-line.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-plane.d.ts.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-plane.js +3 -5
- package/lib/renderers/svg/svg-geometries/svg-plane.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-polygon.d.ts.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-polygon.js +3 -5
- package/lib/renderers/svg/svg-geometries/svg-polygon.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-shape.d.ts.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-shape.js +2 -2
- package/lib/renderers/svg/svg-geometries/svg-shape.js.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-text.d.ts.map +1 -1
- package/lib/renderers/svg/svg-geometries/svg-text.js +1 -1
- package/lib/renderers/svg/svg-geometries/svg-text.js.map +1 -1
- package/lib/renderers/svg/svg.d.ts +1 -1
- package/lib/renderers/svg/svg.d.ts.map +1 -1
- package/lib/renderers/svg/svg.js +5 -5
- package/lib/renderers/svg/svg.js.map +1 -1
- package/lib/utils.d.ts +3 -5
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +12 -20
- package/lib/utils.js.map +1 -1
- package/package.json +17 -17
- package/src/abstract-3d.ts +70 -151
- package/src/custom_typings/react-three-fiber.d.ts +1 -1
- package/src/renderers/dxf/dxf-encoding/dxf-3dface.ts +1 -1
- package/src/renderers/dxf/dxf-encoding/dxf-build.ts +10 -0
- package/src/renderers/dxf/dxf-encoding/dxf-color.ts +27 -26
- package/src/renderers/dxf/dxf-encoding/dxf-common.ts +9 -17
- package/src/renderers/dxf/dxf-encoding/dxf-dimension.ts +3 -26
- package/src/renderers/dxf/dxf-encoding/dxf-footer.ts +2 -2
- package/src/renderers/dxf/dxf-encoding/dxf-header.ts +14 -4
- package/src/renderers/dxf/dxf-encoding/dxf-line.ts +2 -8
- package/src/renderers/dxf/dxf-encoding/dxf-lwpolyline.ts +21 -17
- package/src/renderers/dxf/dxf-encoding/dxf-mtext.ts +12 -3
- package/src/renderers/dxf/dxf-encoding/dxf-polyline.ts +3 -10
- package/src/renderers/dxf/dxf-encoding/dxf-solid.ts +2 -10
- package/src/renderers/dxf/dxf-encoding/dxf-triangle.ts +4 -16
- package/src/renderers/dxf/dxf-geometries/dxf-box.ts +2 -11
- package/src/renderers/dxf/dxf-geometries/dxf-cone.ts +3 -19
- package/src/renderers/dxf/dxf-geometries/dxf-cylinder.ts +4 -22
- package/src/renderers/dxf/dxf-geometries/dxf-dimension.ts +10 -3
- package/src/renderers/dxf/dxf-geometries/dxf-image.ts +11 -33
- package/src/renderers/dxf/dxf-geometries/dxf-plane.ts +3 -19
- package/src/renderers/dxf/dxf-geometries/dxf-polygon.ts +9 -28
- package/src/renderers/dxf/dxf-geometries/dxf-shape.ts +5 -5
- package/src/renderers/dxf/dxf.ts +10 -25
- package/src/renderers/react/react-camera.tsx +27 -26
- package/src/renderers/react/react-dimension.tsx +1 -7
- package/src/renderers/react/react-group.tsx +6 -16
- package/src/renderers/react/react-hotspot.tsx +4 -10
- package/src/renderers/react/react-image-material.tsx +7 -8
- package/src/renderers/react/react-material.tsx +4 -21
- package/src/renderers/react/react-mesh.tsx +15 -69
- package/src/renderers/react/react-scene.tsx +7 -21
- package/src/renderers/react/react.tsx +4 -4
- package/src/renderers/step/step-encoding.ts +36 -100
- package/src/renderers/step/step-geometries/step-box.ts +2 -17
- package/src/renderers/step/step-geometries/step-cylinder.ts +6 -36
- package/src/renderers/stl/stl-geometries/stl-cone.ts +1 -2
- package/src/renderers/stl/stl-geometries/stl-cylinder.ts +1 -2
- package/src/renderers/stl/stl-geometries/stl-plane.ts +1 -6
- package/src/renderers/stl/stl.ts +3 -7
- package/src/renderers/svg/svg-encoding.ts +12 -44
- package/src/renderers/svg/svg-geometries/shared.ts +1 -4
- package/src/renderers/svg/svg-geometries/svg-box.ts +2 -2
- package/src/renderers/svg/svg-geometries/svg-cone.ts +6 -15
- package/src/renderers/svg/svg-geometries/svg-cylinder.ts +6 -18
- package/src/renderers/svg/svg-geometries/svg-image.ts +7 -17
- package/src/renderers/svg/svg-geometries/svg-line.ts +3 -8
- package/src/renderers/svg/svg-geometries/svg-plane.ts +3 -8
- package/src/renderers/svg/svg-geometries/svg-polygon.ts +3 -8
- package/src/renderers/svg/svg-geometries/svg-shape.ts +2 -2
- package/src/renderers/svg/svg-geometries/svg-text.ts +1 -1
- package/src/renderers/svg/svg.ts +8 -18
- package/src/utils.ts +13 -18
- package/CHANGELOG.md +0 -92
|
@@ -5,51 +5,51 @@ export type DxfColor = DxfDynamicColor | string;
|
|
|
5
5
|
|
|
6
6
|
export function dxfColor(color: DxfColor): string {
|
|
7
7
|
return typeof color === "number"
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
? `62\n7`
|
|
9
|
+
: `62
|
|
10
10
|
256
|
|
11
11
|
420
|
|
12
12
|
${dxfBitShiftColor(color)}`;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export function dxfApproximateAciFromRealColor(colorNormal: string | undefined): number {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
16
|
+
const ERROR_COLOR = 6; //magenta
|
|
17
|
+
const ACI_COLOR_COUNT = 256;
|
|
18
|
+
if (DXF_ACI_COLOR_TABLE.length !== ACI_COLOR_COUNT || colorNormal === undefined) {
|
|
19
|
+
return ERROR_COLOR; //magenta
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const originalColor = colorNormalToVec3Color(colorNormal);
|
|
23
|
+
let closestColor = 0;
|
|
24
|
+
let smallestDistance = Number.POSITIVE_INFINITY;
|
|
25
|
+
for (let i = 0; i < ACI_COLOR_COUNT; i++) {
|
|
26
|
+
const color = DXF_ACI_COLOR_TABLE[i];
|
|
27
|
+
if (color !== undefined) {
|
|
28
|
+
const distance = vec3DistSquared(originalColor, color);
|
|
29
|
+
if (distance < smallestDistance) {
|
|
30
|
+
smallestDistance = distance;
|
|
31
|
+
closestColor = i;
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
|
-
|
|
34
|
+
}
|
|
35
|
+
return closestColor;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function colorNormalToVec3Color(colorNormal: string): Vec3 {
|
|
39
39
|
const errorColor = vec3(255, 0, 255); // #ff00ff, magenta
|
|
40
40
|
const paranthesisRegex = /(?<=\().+?(?=\))/;
|
|
41
41
|
const inside = paranthesisRegex.exec(colorNormal);
|
|
42
|
-
if(inside === null || inside.length < 1) {
|
|
42
|
+
if (inside === null || inside.length < 1) {
|
|
43
43
|
return errorColor;
|
|
44
44
|
}
|
|
45
45
|
const values = inside[0].replaceAll(" ", "").split(",");
|
|
46
|
-
if(values.length < 3) {
|
|
46
|
+
if (values.length < 3) {
|
|
47
47
|
return errorColor;
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
49
|
const r = parseInt(values[0] ?? "", 10);
|
|
50
50
|
const g = parseInt(values[1] ?? "", 10);
|
|
51
51
|
const b = parseInt(values[2] ?? "", 10);
|
|
52
|
-
if(Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
52
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
53
53
|
return errorColor;
|
|
54
54
|
}
|
|
55
55
|
return vec3(r % 256, g % 256, b % 256);
|
|
@@ -58,8 +58,9 @@ function colorNormalToVec3Color(colorNormal: string): Vec3 {
|
|
|
58
58
|
function dxfBitShiftColor(color: string): number {
|
|
59
59
|
const originalColor = colorNormalToVec3Color(color);
|
|
60
60
|
|
|
61
|
+
// oxlint-disable-next-line no-bitwise
|
|
61
62
|
const colorAsInt = (originalColor.x << 16) + (originalColor.y << 8) + originalColor.z;
|
|
62
|
-
if(Number.isNaN(colorAsInt)) {
|
|
63
|
+
if (Number.isNaN(colorAsInt)) {
|
|
63
64
|
return 0;
|
|
64
65
|
}
|
|
65
66
|
return colorAsInt;
|
|
@@ -321,5 +322,5 @@ const DXF_ACI_COLOR_TABLE: ReadonlyArray<Vec3> = [
|
|
|
321
322
|
vec3(128, 128, 128),
|
|
322
323
|
vec3(64, 64, 64),
|
|
323
324
|
vec3(0, 0, 0),
|
|
324
|
-
vec3(0, 0, 0)
|
|
325
|
+
vec3(0, 0, 0),
|
|
325
326
|
];
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { vec3, vec3Cross, vec3Normalize, type Bounds3, type Vec3 } from "../../../abstract-3d.js";
|
|
3
|
-
import type { DxfDimensionDefinition } from "./dxf-dimension.js";
|
|
4
|
-
import { dxfEncFooter } from "./dxf-footer.js";
|
|
5
|
-
import { dxfEncHeader } from "./dxf-header.js";
|
|
1
|
+
import { vec3, vec3Cross, vec3Normalize, type Vec3 } from "../../../abstract-3d.js";
|
|
6
2
|
|
|
7
3
|
export const DEFAULT_CIRCLE_SIDE_COUNT = 16;
|
|
8
4
|
export const DXF_FONT_SIZE_RATIO: number = 11.0 / 20.0;
|
|
@@ -28,11 +24,6 @@ export function dxfRound(n: number): number {
|
|
|
28
24
|
return Math.round((n + Number.EPSILON) * 10 ** d) / 10 ** d;
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
export function dxfBuild(groups: string, dimensions: DxfDimensionDefinition, bounds: Bounds3, size: Vec3, center: Vec3): string {
|
|
32
|
-
const id = generateUUID();
|
|
33
|
-
return dxfEncHeader(bounds, center, id, size, dimensions.block, dimensions.blockRecord) + groups + dimensions.entity + dxfEncFooter(id);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
27
|
/*
|
|
37
28
|
given an extrusion vector(normal; tags 210/220/230),
|
|
38
29
|
calculate the dxf OCS x and y axises used to project
|
|
@@ -42,13 +33,14 @@ export function dxfOCSXYAxis(normalizedExtrusionVector: Vec3): {
|
|
|
42
33
|
readonly xAxis: Vec3;
|
|
43
34
|
readonly yAxis: Vec3;
|
|
44
35
|
} {
|
|
45
|
-
const THRESHOLD =
|
|
46
|
-
const xAxis =
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
const THRESHOLD = 1.0 / 64.0; //dxf spec
|
|
37
|
+
const xAxis =
|
|
38
|
+
Math.abs(normalizedExtrusionVector.x) < THRESHOLD && Math.abs(normalizedExtrusionVector.y) < THRESHOLD
|
|
39
|
+
? vec3Normalize(vec3Cross(vec3(0.0, 1.0, 0.0), normalizedExtrusionVector))
|
|
40
|
+
: vec3Normalize(vec3Cross(vec3(0.0, 0.0, 1.0), normalizedExtrusionVector));
|
|
49
41
|
|
|
50
42
|
return {
|
|
51
43
|
xAxis,
|
|
52
|
-
yAxis: vec3Normalize(vec3Cross(normalizedExtrusionVector, xAxis))
|
|
53
|
-
}
|
|
54
|
-
}
|
|
44
|
+
yAxis: vec3Normalize(vec3Cross(normalizedExtrusionVector, xAxis)),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { dimensionMeshifyAlignedDimension } from "../../../abstract-3d.js";
|
|
2
2
|
import type { DimensionAligned, View, Material, Vec3 } from "../../../abstract-3d.js";
|
|
3
3
|
import { type DxfColor, dxfColor } from "./dxf-color.js";
|
|
4
|
-
import {
|
|
5
|
-
DXF_BLOCK_RECORD_TABLE_HANDLE,
|
|
6
|
-
DXF_MODEL_SPACE_HANDLE,
|
|
7
|
-
dxfHandleNext,
|
|
8
|
-
dxfRound,
|
|
9
|
-
type Handle,
|
|
10
|
-
} from "./dxf-common.js";
|
|
4
|
+
import { DXF_BLOCK_RECORD_TABLE_HANDLE, DXF_MODEL_SPACE_HANDLE, dxfHandleNext, dxfRound, type Handle } from "./dxf-common.js";
|
|
11
5
|
import { dxfEncLine } from "./dxf-line.js";
|
|
12
6
|
import { DxfMTextAttachment, dxfEncMText, encodeDxfFormattedText } from "./dxf-mtext.js";
|
|
13
7
|
import { dxfEncSolidTriangle } from "./dxf-triangle.js";
|
|
@@ -207,25 +201,8 @@ function dxfEncodeDimensionGeometry(
|
|
|
207
201
|
const onCreateLine = (start: Vec3, end: Vec3, _norm: Vec3, _thickness: number, _mat: Material): void => {
|
|
208
202
|
entities += dxfEncLine(start, end, col, handleRef, blockRecordHandle);
|
|
209
203
|
};
|
|
210
|
-
const onCreateText = (
|
|
211
|
-
pos
|
|
212
|
-
measurement: string,
|
|
213
|
-
fontSize: number,
|
|
214
|
-
_mat: Material,
|
|
215
|
-
_rot: Vec3,
|
|
216
|
-
dir: Vec3,
|
|
217
|
-
norm: Vec3
|
|
218
|
-
): void => {
|
|
219
|
-
entities += dxfEncMText(
|
|
220
|
-
pos,
|
|
221
|
-
measurement,
|
|
222
|
-
dir,
|
|
223
|
-
norm,
|
|
224
|
-
fontSize,
|
|
225
|
-
handleRef,
|
|
226
|
-
DxfMTextAttachment.MiddleCenter,
|
|
227
|
-
blockRecordHandle
|
|
228
|
-
);
|
|
204
|
+
const onCreateText = (pos: Vec3, measurement: string, fontSize: number, _mat: Material, _rot: Vec3, dir: Vec3, norm: Vec3): void => {
|
|
205
|
+
entities += dxfEncMText(pos, measurement, dir, norm, fontSize, handleRef, DxfMTextAttachment.MiddleCenter, blockRecordHandle);
|
|
229
206
|
};
|
|
230
207
|
const onCreatePolygon = (p1: Vec3, p2: Vec3, p3: Vec3, _mat: Material): void => {
|
|
231
208
|
entities += dxfEncSolidTriangle(p1, p2, p3, col, handleRef, blockRecordHandle);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DXF_MODEL_SPACE_HANDLE } from "./dxf-common.js";
|
|
2
2
|
|
|
3
|
-
/*
|
|
3
|
+
/* oxlint-disable max-lines */
|
|
4
4
|
export const dxfEncFooter = (blockId: string): string => ` 0
|
|
5
5
|
ENDBLK
|
|
6
6
|
5
|
|
@@ -16648,4 +16648,4 @@ RTVSPost2010PropOp57
|
|
|
16648
16648
|
0
|
|
16649
16649
|
ENDSEC
|
|
16650
16650
|
0
|
|
16651
|
-
EOF`;
|
|
16651
|
+
EOF`;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* oxlint-disable max-lines */
|
|
2
2
|
import type { Bounds3, Vec3 } from "../../../abstract-3d.js";
|
|
3
3
|
import { DXF_BLOCK_RECORD_TABLE_HANDLE, DXF_MODEL_SPACE_HANDLE } from "./dxf-common.js";
|
|
4
4
|
|
|
5
5
|
const DXF_MAKER = "DXF Generated from Divid Abstract 3D";
|
|
6
6
|
const DXF_STANDARD = "AC1015";
|
|
7
7
|
|
|
8
|
-
export const dxfEncHeader = (
|
|
8
|
+
export const dxfEncHeader = (
|
|
9
|
+
bounds: Bounds3,
|
|
10
|
+
center: Vec3,
|
|
11
|
+
blockId: string,
|
|
12
|
+
size: Vec3,
|
|
13
|
+
dimBlocks: string,
|
|
14
|
+
dimBlockRecords: string,
|
|
15
|
+
dimScale: number = 44.0,
|
|
16
|
+
dimArrowSize: number = 1.0,
|
|
17
|
+
dimTextHeight: number = 1.0
|
|
18
|
+
): string =>
|
|
9
19
|
` 999
|
|
10
20
|
${DXF_MAKER}
|
|
11
21
|
0
|
|
@@ -1093,7 +1103,7 @@ AcDbViewportTableRecord
|
|
|
1093
1103
|
12
|
|
1094
1104
|
${-size.x / 2}
|
|
1095
1105
|
22
|
|
1096
|
-
|
|
1106
|
+
0
|
|
1097
1107
|
13
|
|
1098
1108
|
0.0
|
|
1099
1109
|
23
|
|
@@ -1654,4 +1664,4 @@ ${blockId}
|
|
|
1654
1664
|
${blockId}
|
|
1655
1665
|
1
|
|
1656
1666
|
|
|
1657
|
-
`;
|
|
1667
|
+
`;
|
|
@@ -2,13 +2,7 @@ import type { Vec3 } from "../../../abstract-3d.js";
|
|
|
2
2
|
import { type DxfColor, dxfColor } from "./dxf-color.js";
|
|
3
3
|
import { DXF_MODEL_SPACE_HANDLE, dxfHandleNext, dxfRound, type Handle } from "./dxf-common.js";
|
|
4
4
|
|
|
5
|
-
export function dxfEncLine(
|
|
6
|
-
vecStart: Vec3,
|
|
7
|
-
vecEnd: Vec3,
|
|
8
|
-
col: DxfColor,
|
|
9
|
-
handleRef: Handle,
|
|
10
|
-
blockRefHandle?: string
|
|
11
|
-
): string {
|
|
5
|
+
export function dxfEncLine(vecStart: Vec3, vecEnd: Vec3, col: DxfColor, handleRef: Handle, blockRefHandle?: string): string {
|
|
12
6
|
return ` 0
|
|
13
7
|
LINE
|
|
14
8
|
5
|
|
@@ -33,4 +27,4 @@ ${dxfRound(vecEnd.y)}
|
|
|
33
27
|
31
|
|
34
28
|
${dxfRound(vecEnd.z)}
|
|
35
29
|
`;
|
|
36
|
-
}
|
|
30
|
+
}
|
|
@@ -28,18 +28,15 @@ export function dxfEncLwPolyline(
|
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
if(points.length === 2) {
|
|
31
|
+
if (points.length === 2) {
|
|
32
32
|
const a = points[0];
|
|
33
33
|
const b = points[1];
|
|
34
|
-
if(a === undefined || b === undefined) {
|
|
34
|
+
if (a === undefined || b === undefined) {
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const direction = vec3Normalize(vec3Sub(b, a));
|
|
39
|
-
const reference =
|
|
40
|
-
Math.abs(direction.z) < 0.9
|
|
41
|
-
? vec3(0, 0, 1)
|
|
42
|
-
: vec3(0, 1, 0);
|
|
39
|
+
const reference = Math.abs(direction.z) < 0.9 ? vec3(0, 0, 1) : vec3(0, 1, 0);
|
|
43
40
|
const normal = vec3Normalize(vec3Cross(direction, reference));
|
|
44
41
|
|
|
45
42
|
const plane: LwPolylinePlane = {
|
|
@@ -52,13 +49,20 @@ export function dxfEncLwPolyline(
|
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
const plane = findPlane(planePos, points);
|
|
55
|
-
if(!plane || !isCoplanar(points, plane)) {
|
|
52
|
+
if (!plane || !isCoplanar(points, plane)) {
|
|
56
53
|
return undefined;
|
|
57
54
|
}
|
|
58
55
|
return encodeLwPolyline(points, plane, col, closed, handleRef, blockRefHandle);
|
|
59
56
|
}
|
|
60
57
|
|
|
61
|
-
function encodeLwPolyline(
|
|
58
|
+
function encodeLwPolyline(
|
|
59
|
+
points: ReadonlyArray<Vec3>,
|
|
60
|
+
plane: LwPolylinePlane,
|
|
61
|
+
col: DxfColor,
|
|
62
|
+
closed: boolean,
|
|
63
|
+
handleRef: Handle,
|
|
64
|
+
blockRefHandle?: string
|
|
65
|
+
): string {
|
|
62
66
|
let dxf = "";
|
|
63
67
|
const planeElevation = vec3Dot(plane.pos, plane.normal);
|
|
64
68
|
|
|
@@ -73,7 +77,7 @@ function encodeLwPolyline(points: ReadonlyArray<Vec3>, plane: LwPolylinePlane, c
|
|
|
73
77
|
dxf += `70\n${closed ? 1 : 0}\n`;
|
|
74
78
|
dxf += `38\n${planeElevation}\n`;
|
|
75
79
|
|
|
76
|
-
for(const point of points) {
|
|
80
|
+
for (const point of points) {
|
|
77
81
|
dxf += `10\n${vec3Dot(point, plane.xAxis)}\n`;
|
|
78
82
|
dxf += `20\n${vec3Dot(point, plane.yAxis)}\n`;
|
|
79
83
|
}
|
|
@@ -86,29 +90,29 @@ function encodeLwPolyline(points: ReadonlyArray<Vec3>, plane: LwPolylinePlane, c
|
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
function findPlane(planePos: Vec3, points: ReadonlyArray<Vec3>): LwPolylinePlane | undefined {
|
|
89
|
-
if(points.length < 3) {
|
|
93
|
+
if (points.length < 3) {
|
|
90
94
|
return undefined;
|
|
91
95
|
}
|
|
92
|
-
for(let i = 1; i < points.length; i++) {
|
|
96
|
+
for (let i = 1; i < points.length; i++) {
|
|
93
97
|
const aRaw = points[i];
|
|
94
|
-
if(aRaw === undefined) {
|
|
98
|
+
if (aRaw === undefined) {
|
|
95
99
|
continue;
|
|
96
100
|
}
|
|
97
101
|
const a = vec3Sub(aRaw, planePos);
|
|
98
|
-
for(let j = i + 1; j < points.length; j++) {
|
|
102
|
+
for (let j = i + 1; j < points.length; j++) {
|
|
99
103
|
const bRaw = points[j];
|
|
100
|
-
if(bRaw === undefined) {
|
|
104
|
+
if (bRaw === undefined) {
|
|
101
105
|
continue;
|
|
102
106
|
}
|
|
103
107
|
const b = vec3Sub(bRaw, planePos);
|
|
104
108
|
const normal = vec3Cross(a, b);
|
|
105
|
-
if(vec3Length(normal) > EPSILON) {
|
|
109
|
+
if (vec3Length(normal) > EPSILON) {
|
|
106
110
|
const normalizedNormal = vec3Normalize(normal);
|
|
107
111
|
return {
|
|
108
112
|
normal: normalizedNormal,
|
|
109
113
|
pos: planePos,
|
|
110
114
|
...dxfOCSXYAxis(normalizedNormal),
|
|
111
|
-
}
|
|
115
|
+
};
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
}
|
|
@@ -120,4 +124,4 @@ function isCoplanar(points: ReadonlyArray<Vec3>, plane: LwPolylinePlane): boolea
|
|
|
120
124
|
const distance = vec3Dot(vec3Sub(p, plane.pos), plane.normal);
|
|
121
125
|
return Math.abs(distance) < EPSILON;
|
|
122
126
|
});
|
|
123
|
-
}
|
|
127
|
+
}
|
|
@@ -11,9 +11,18 @@ export enum DxfMTextAttachment {
|
|
|
11
11
|
BottomLeft = 7,
|
|
12
12
|
BottomCenter = 8,
|
|
13
13
|
BottomRight = 9,
|
|
14
|
-
}
|
|
14
|
+
}
|
|
15
15
|
|
|
16
|
-
export function dxfEncMText(
|
|
16
|
+
export function dxfEncMText(
|
|
17
|
+
pos: Vec3,
|
|
18
|
+
text: string,
|
|
19
|
+
dir: Vec3,
|
|
20
|
+
normal: Vec3,
|
|
21
|
+
fontSize: number,
|
|
22
|
+
handleRef: Handle,
|
|
23
|
+
attachment: DxfMTextAttachment = DxfMTextAttachment.MiddleCenter,
|
|
24
|
+
blockRefHandle?: string
|
|
25
|
+
): string {
|
|
17
26
|
return `0
|
|
18
27
|
MTEXT
|
|
19
28
|
5
|
|
@@ -55,4 +64,4 @@ ${encodeDxfFormattedText(text)}
|
|
|
55
64
|
|
|
56
65
|
export function encodeDxfFormattedText(text: string): string {
|
|
57
66
|
return text.replace(/\r\n|\r|\n/g, "\\P");
|
|
58
|
-
}
|
|
67
|
+
}
|
|
@@ -2,13 +2,7 @@ import type { Vec3 } from "../../../abstract-3d.js";
|
|
|
2
2
|
import { type DxfColor, dxfColor } from "./dxf-color.js";
|
|
3
3
|
import { DXF_MODEL_SPACE_HANDLE, dxfHandleNext, dxfRound, type Handle } from "./dxf-common.js";
|
|
4
4
|
|
|
5
|
-
export function dxfEncPolyline(
|
|
6
|
-
points: ReadonlyArray<Vec3>,
|
|
7
|
-
col: DxfColor,
|
|
8
|
-
closed: boolean,
|
|
9
|
-
handleRef: Handle,
|
|
10
|
-
blockRefHandle?: string
|
|
11
|
-
): string {
|
|
5
|
+
export function dxfEncPolyline(points: ReadonlyArray<Vec3>, col: DxfColor, closed: boolean, handleRef: Handle, blockRefHandle?: string): string {
|
|
12
6
|
if (points.length < 2) {
|
|
13
7
|
return "";
|
|
14
8
|
}
|
|
@@ -17,7 +11,7 @@ export function dxfEncPolyline(
|
|
|
17
11
|
const seqEndHandle = dxfHandleNext(handleRef);
|
|
18
12
|
const vertices = points
|
|
19
13
|
.map((p) => {
|
|
20
|
-
|
|
14
|
+
return ` 0
|
|
21
15
|
VERTEX
|
|
22
16
|
5
|
|
23
17
|
${dxfHandleNext(handleRef)}
|
|
@@ -42,7 +36,6 @@ ${dxfRound(p.z)}
|
|
|
42
36
|
32`;
|
|
43
37
|
})
|
|
44
38
|
.join("\n");
|
|
45
|
-
|
|
46
39
|
|
|
47
40
|
return ` 0
|
|
48
41
|
POLYLINE
|
|
@@ -79,4 +72,4 @@ AcDbEntity
|
|
|
79
72
|
8
|
|
80
73
|
0
|
|
81
74
|
`;
|
|
82
|
-
}
|
|
75
|
+
}
|
|
@@ -2,15 +2,7 @@ import type { Vec3 } from "../../../abstract-3d.js";
|
|
|
2
2
|
import { type DxfColor, dxfColor } from "./dxf-color.js";
|
|
3
3
|
import { DXF_MODEL_SPACE_HANDLE, dxfHandleNext, dxfRound, type Handle } from "./dxf-common.js";
|
|
4
4
|
|
|
5
|
-
export const dxfEncSolid = (
|
|
6
|
-
vec1: Vec3,
|
|
7
|
-
vec2: Vec3,
|
|
8
|
-
vec3: Vec3,
|
|
9
|
-
vec4: Vec3,
|
|
10
|
-
col: DxfColor,
|
|
11
|
-
handleRef: Handle,
|
|
12
|
-
blockRefHandle?: string
|
|
13
|
-
): string => ` 0
|
|
5
|
+
export const dxfEncSolid = (vec1: Vec3, vec2: Vec3, vec3: Vec3, vec4: Vec3, col: DxfColor, handleRef: Handle, blockRefHandle?: string): string => ` 0
|
|
14
6
|
SOLID
|
|
15
7
|
5
|
|
16
8
|
${dxfHandleNext(handleRef)}
|
|
@@ -45,4 +37,4 @@ ${dxfRound(vec4.x)}
|
|
|
45
37
|
${dxfRound(vec4.y)}
|
|
46
38
|
33
|
|
47
39
|
${dxfRound(vec4.z)}
|
|
48
|
-
`;
|
|
40
|
+
`;
|
|
@@ -4,20 +4,8 @@ import type { DxfColor } from "./dxf-color.js";
|
|
|
4
4
|
import type { Handle } from "./dxf-common.js";
|
|
5
5
|
import { dxfEncSolid } from "./dxf-solid.js";
|
|
6
6
|
|
|
7
|
-
export const dxfEnc3DFaceTriangle = (
|
|
8
|
-
vec1
|
|
9
|
-
vec2: Vec3,
|
|
10
|
-
vec3: Vec3,
|
|
11
|
-
col: DxfColor,
|
|
12
|
-
handleRef: Handle,
|
|
13
|
-
blockRefHandle?: string
|
|
14
|
-
): string => dxfEnc3DFace(vec1, vec2, vec3, vec3, col, handleRef, blockRefHandle);
|
|
7
|
+
export const dxfEnc3DFaceTriangle = (vec1: Vec3, vec2: Vec3, vec3: Vec3, col: DxfColor, handleRef: Handle, blockRefHandle?: string): string =>
|
|
8
|
+
dxfEnc3DFace(vec1, vec2, vec3, vec3, col, handleRef, blockRefHandle);
|
|
15
9
|
|
|
16
|
-
export const dxfEncSolidTriangle = (
|
|
17
|
-
vec1
|
|
18
|
-
vec2: Vec3,
|
|
19
|
-
vec3: Vec3,
|
|
20
|
-
col: DxfColor,
|
|
21
|
-
handleRef: Handle,
|
|
22
|
-
blockRefHandle?: string
|
|
23
|
-
): string => dxfEncSolid(vec1, vec2, vec3, vec3, col, handleRef, blockRefHandle);
|
|
10
|
+
export const dxfEncSolidTriangle = (vec1: Vec3, vec2: Vec3, vec3: Vec3, col: DxfColor, handleRef: Handle, blockRefHandle?: string): string =>
|
|
11
|
+
dxfEncSolid(vec1, vec2, vec3, vec3, col, handleRef, blockRefHandle);
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Box,
|
|
3
|
-
type Material,
|
|
4
|
-
type Vec3,
|
|
5
|
-
vec3,
|
|
6
|
-
vec3RotCombine,
|
|
7
|
-
vec3Scale,
|
|
8
|
-
vec3TransRot,
|
|
9
|
-
vec3Zero,
|
|
10
|
-
} from "../../../abstract-3d.js";
|
|
11
|
-
import type { Handle } from "../dxf-encoding/dxf-common.js";
|
|
1
|
+
import { type Box, type Material, type Vec3, vec3, vec3RotCombine, vec3Scale, vec3TransRot, vec3Zero } from "../../../abstract-3d.js";
|
|
12
2
|
import { dxfEnc3DFace } from "../dxf-encoding/dxf-3dface.js";
|
|
3
|
+
import type { Handle } from "../dxf-encoding/dxf-common.js";
|
|
13
4
|
|
|
14
5
|
export function dxfBox(b: Box, m: Material, parentPos: Vec3, parentRot: Vec3, handleRef: Handle): string {
|
|
15
6
|
const pos = vec3TransRot(b.pos, parentPos, parentRot);
|
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Cone,
|
|
3
|
-
type Material,
|
|
4
|
-
type Vec3,
|
|
5
|
-
vec3,
|
|
6
|
-
vec3RotCombine,
|
|
7
|
-
vec3TransRot,
|
|
8
|
-
vec3Zero,
|
|
9
|
-
} from "../../../abstract-3d.js";
|
|
1
|
+
import { type Cone, type Material, type Vec3, vec3, vec3RotCombine, vec3TransRot, vec3Zero } from "../../../abstract-3d.js";
|
|
10
2
|
import type { Handle } from "../dxf-encoding/dxf-common.js";
|
|
11
3
|
import { dxfEnc3DFaceTriangle } from "../dxf-encoding/dxf-triangle.js";
|
|
12
4
|
|
|
13
|
-
export function dxfCone(
|
|
14
|
-
c: Cone,
|
|
15
|
-
m: Material,
|
|
16
|
-
sides: number,
|
|
17
|
-
parentPos: Vec3,
|
|
18
|
-
parentRot: Vec3,
|
|
19
|
-
handleRef: Handle
|
|
20
|
-
): string {
|
|
5
|
+
export function dxfCone(c: Cone, m: Material, sides: number, parentPos: Vec3, parentRot: Vec3, handleRef: Handle): string {
|
|
21
6
|
let dxfString = "";
|
|
22
7
|
const pos = vec3TransRot(c.pos, parentPos, parentRot);
|
|
23
8
|
const rot = vec3RotCombine(parentRot, c.rot ?? vec3Zero);
|
|
@@ -37,8 +22,7 @@ export function dxfCone(
|
|
|
37
22
|
if (i !== 0) {
|
|
38
23
|
const prevBot = botVec3Array[i - 1]!;
|
|
39
24
|
dxfString +=
|
|
40
|
-
dxfEnc3DFaceTriangle(botPos, prevBot, currBot, m.normal, handleRef) +
|
|
41
|
-
dxfEnc3DFaceTriangle(currBot, prevBot, topPos, m.normal, handleRef);
|
|
25
|
+
dxfEnc3DFaceTriangle(botPos, prevBot, currBot, m.normal, handleRef) + dxfEnc3DFaceTriangle(currBot, prevBot, topPos, m.normal, handleRef);
|
|
42
26
|
}
|
|
43
27
|
currentAngle += angleStep;
|
|
44
28
|
}
|
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Cylinder,
|
|
3
|
-
type Material,
|
|
4
|
-
type Vec3,
|
|
5
|
-
equals,
|
|
6
|
-
vec3,
|
|
7
|
-
vec3RotCombine,
|
|
8
|
-
vec3Scale,
|
|
9
|
-
vec3TransRot,
|
|
10
|
-
vec3Zero,
|
|
11
|
-
} from "../../../abstract-3d.js";
|
|
12
|
-
import type { Handle } from "../dxf-encoding/dxf-common.js";
|
|
1
|
+
import { type Cylinder, type Material, type Vec3, equals, vec3, vec3RotCombine, vec3Scale, vec3TransRot, vec3Zero } from "../../../abstract-3d.js";
|
|
13
2
|
import { dxfEnc3DFace } from "../dxf-encoding/dxf-3dface.js";
|
|
3
|
+
import type { Handle } from "../dxf-encoding/dxf-common.js";
|
|
14
4
|
import { dxfEnc3DFaceTriangle } from "../dxf-encoding/dxf-triangle.js";
|
|
15
5
|
import { dxfPlane } from "./dxf-plane.js";
|
|
16
6
|
|
|
17
|
-
export function dxfCylinder(
|
|
18
|
-
c: Cylinder,
|
|
19
|
-
m: Material,
|
|
20
|
-
sides: number,
|
|
21
|
-
parentPos: Vec3,
|
|
22
|
-
parentRot: Vec3,
|
|
23
|
-
handleRef: Handle
|
|
24
|
-
): string {
|
|
7
|
+
export function dxfCylinder(c: Cylinder, m: Material, sides: number, parentPos: Vec3, parentRot: Vec3, handleRef: Handle): string {
|
|
25
8
|
const pos = vec3TransRot(c.pos, parentPos, parentRot);
|
|
26
9
|
const rot = vec3RotCombine(parentRot, c.rot ?? vec3Zero);
|
|
27
10
|
const vec3tr = (x: number, y: number, z: number): Vec3 => vec3TransRot(vec3(x, y, z), pos, rot);
|
|
@@ -47,8 +30,7 @@ export function dxfCylinder(
|
|
|
47
30
|
if (i !== 0 && prevBot && prevTop) {
|
|
48
31
|
if (!c.open) {
|
|
49
32
|
dxfString +=
|
|
50
|
-
dxfEnc3DFaceTriangle(botPos, prevBot, currBot, m.normal, handleRef) +
|
|
51
|
-
dxfEnc3DFaceTriangle(topPos, prevTop, currTop, m.normal, handleRef);
|
|
33
|
+
dxfEnc3DFaceTriangle(botPos, prevBot, currBot, m.normal, handleRef) + dxfEnc3DFaceTriangle(topPos, prevTop, currTop, m.normal, handleRef);
|
|
52
34
|
}
|
|
53
35
|
dxfString += dxfEnc3DFace(currBot, prevBot, prevTop, currTop, m.normal, handleRef);
|
|
54
36
|
}
|
|
@@ -2,8 +2,15 @@ import { type Dimension, dimensionIsOfTypeMesh, type Vec3, vec3Length, vec3Sub,
|
|
|
2
2
|
import type { Handle } from "../dxf-encoding/dxf-common.js";
|
|
3
3
|
import { type DxfDimensionDefinition, dxfEncDimension } from "../dxf-encoding/dxf-dimension.js";
|
|
4
4
|
|
|
5
|
-
export function dxfDimension(
|
|
6
|
-
|
|
5
|
+
export function dxfDimension(
|
|
6
|
+
dimension: Dimension,
|
|
7
|
+
parentPos: Vec3,
|
|
8
|
+
parentRot: Vec3,
|
|
9
|
+
sceneRotation: Vec3,
|
|
10
|
+
viewRotation: Vec3,
|
|
11
|
+
handleRef: Handle
|
|
12
|
+
): DxfDimensionDefinition {
|
|
13
|
+
if (dimensionIsOfTypeMesh(dimension)) {
|
|
7
14
|
return {
|
|
8
15
|
block: "",
|
|
9
16
|
entity: "",
|
|
@@ -15,4 +22,4 @@ export function dxfDimension(dimension: Dimension, parentPos: Vec3, parentRot: V
|
|
|
15
22
|
const lp = vec3TransRot(dimension.linePosition, parentPos, parentRot);
|
|
16
23
|
const text = dimension.text ?? `${vec3Length(vec3Sub(me, ms))}`;
|
|
17
24
|
return dxfEncDimension(ms, me, lp, text, 7, sceneRotation, viewRotation, dimension.views ?? ["front"], handleRef);
|
|
18
|
-
}
|
|
25
|
+
}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
+
import type { AbstractImage, Component } from "abstract-image";
|
|
2
|
+
import { type ImageMesh, type Vec3, vec2Scale, vec3, vec3Add, vec3Rot, vec3RotCombine, vec3TransRot, vec3Zero } from "../../../abstract-3d.js";
|
|
3
|
+
import type { DxfDynamicColor } from "../dxf-encoding/dxf-color.js";
|
|
1
4
|
import { DEFAULT_CIRCLE_SIDE_COUNT, type Handle } from "../dxf-encoding/dxf-common.js";
|
|
2
5
|
import { dxfEncLine } from "../dxf-encoding/dxf-line.js";
|
|
3
6
|
import { dxfEncLwPolyline } from "../dxf-encoding/dxf-lwpolyline.js";
|
|
4
|
-
import type { AbstractImage, Component } from "abstract-image";
|
|
5
|
-
import type { DxfDynamicColor } from "../dxf-encoding/dxf-color.js";
|
|
6
|
-
import {
|
|
7
|
-
type ImageMesh,
|
|
8
|
-
type Vec3,
|
|
9
|
-
vec2Scale,
|
|
10
|
-
vec3,
|
|
11
|
-
vec3Add,
|
|
12
|
-
vec3Rot,
|
|
13
|
-
vec3RotCombine,
|
|
14
|
-
vec3TransRot,
|
|
15
|
-
vec3Zero,
|
|
16
|
-
} from "../../../abstract-3d.js";
|
|
17
7
|
|
|
18
8
|
export function dxfImage(i: ImageMesh, parentPos: Vec3, parentRot: Vec3, handleRef: Handle): string {
|
|
19
9
|
const half = vec2Scale(i.size, 0.5);
|
|
@@ -35,29 +25,17 @@ export function dxfImage(i: ImageMesh, parentPos: Vec3, parentRot: Vec3, handleR
|
|
|
35
25
|
}
|
|
36
26
|
|
|
37
27
|
function abstractImageToDxf3D(image: AbstractImage, pos: Vec3, rot: Vec3, scale: Vec3, handleRef: Handle): string {
|
|
38
|
-
|
|
39
|
-
return image.components
|
|
40
|
-
.map((comp) => abstractImageComponentToDxf3D(comp, pos, rot, scale, strokeScale, handleRef))
|
|
41
|
-
.join("");
|
|
28
|
+
return image.components.map((comp) => abstractImageComponentToDxf3D(comp, pos, rot, scale, handleRef)).join("");
|
|
42
29
|
}
|
|
43
30
|
|
|
44
|
-
function abstractImageComponentToDxf3D(
|
|
45
|
-
comp: Component,
|
|
46
|
-
pos: Vec3,
|
|
47
|
-
rot: Vec3,
|
|
48
|
-
scale: Vec3,
|
|
49
|
-
strokeScale: number,
|
|
50
|
-
handleRef: Handle
|
|
51
|
-
): string {
|
|
31
|
+
function abstractImageComponentToDxf3D(comp: Component, pos: Vec3, rot: Vec3, scale: Vec3, handleRef: Handle): string {
|
|
52
32
|
const vec3tr = (x: number, y: number): Vec3 => vec3TransRot(vec3(x * scale.x, y * scale.y, 0), pos, rot);
|
|
53
33
|
const strokeColor: DxfDynamicColor = 7;
|
|
54
34
|
|
|
55
35
|
let dxf = "";
|
|
56
36
|
switch (comp.type) {
|
|
57
37
|
case "group": {
|
|
58
|
-
dxf += comp.children
|
|
59
|
-
.map((child) => abstractImageComponentToDxf3D(child, pos, rot, scale, strokeScale, handleRef))
|
|
60
|
-
.join("");
|
|
38
|
+
dxf += comp.children.map((child) => abstractImageComponentToDxf3D(child, pos, rot, scale, handleRef)).join("");
|
|
61
39
|
break;
|
|
62
40
|
}
|
|
63
41
|
case "line": {
|
|
@@ -89,11 +67,11 @@ function abstractImageComponentToDxf3D(
|
|
|
89
67
|
}
|
|
90
68
|
case "rectangle": {
|
|
91
69
|
const points = [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
70
|
+
//these points form a loop
|
|
71
|
+
vec3tr(comp.topLeft.x, comp.topLeft.y),
|
|
72
|
+
vec3tr(comp.bottomRight.x, comp.topLeft.y),
|
|
73
|
+
vec3tr(comp.bottomRight.x, comp.bottomRight.y),
|
|
74
|
+
vec3tr(comp.topLeft.x, comp.bottomRight.y),
|
|
97
75
|
];
|
|
98
76
|
dxf += dxfEncLwPolyline(pos, points, strokeColor, true, handleRef) ?? "";
|
|
99
77
|
break;
|