abstract-3d 2.7.32 → 2.7.33
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 +1 -1
- package/lib/abstract-3d.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-color.js +2 -2
- package/lib/renderers/dxf/dxf-encoding/dxf-color.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-common.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-common.js +9 -4
- package/lib/renderers/dxf/dxf-encoding/dxf-common.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-footer.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-footer.js +2 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-footer.js.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-header.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-header.js +2 -1
- package/lib/renderers/dxf/dxf-encoding/dxf-header.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-geometries/dxf-dimension.d.ts.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-dimension.js +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-dimension.js.map +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-image.js +3 -8
- package/lib/renderers/dxf/dxf-geometries/dxf-image.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 +2 -2
- 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 +1 -1
- package/lib/renderers/dxf/dxf-geometries/dxf-shape.js.map +1 -1
- package/lib/renderers/react/react-camera.js +1 -1
- package/lib/renderers/react/react-camera.js.map +1 -1
- package/lib/renderers/react/react-image-material.js +4 -5
- package/lib/renderers/react/react-image-material.js.map +1 -1
- package/lib/renderers/react/react-material.js.map +1 -1
- package/lib/renderers/react/react-mesh.js +1 -1
- package/lib/renderers/react/react-mesh.js.map +1 -1
- package/lib/renderers/react/react.js +1 -1
- package/lib/renderers/react/react.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-image.js.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/abstract-3d.ts +2 -2
- package/src/renderers/dxf/dxf-encoding/dxf-3dface.ts +1 -1
- package/src/renderers/dxf/dxf-encoding/dxf-color.ts +26 -26
- package/src/renderers/dxf/dxf-encoding/dxf-common.ts +23 -9
- package/src/renderers/dxf/dxf-encoding/dxf-footer.ts +3 -2
- package/src/renderers/dxf/dxf-encoding/dxf-header.ts +15 -4
- package/src/renderers/dxf/dxf-encoding/dxf-line.ts +1 -1
- 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 +2 -3
- package/src/renderers/dxf/dxf-encoding/dxf-solid.ts +1 -1
- package/src/renderers/dxf/dxf-encoding/dxf-triangle.ts +1 -1
- package/src/renderers/dxf/dxf-geometries/dxf-box.ts +1 -1
- package/src/renderers/dxf/dxf-geometries/dxf-dimension.ts +18 -4
- package/src/renderers/dxf/dxf-geometries/dxf-image.ts +8 -20
- package/src/renderers/dxf/dxf-geometries/dxf-polygon.ts +16 -28
- package/src/renderers/dxf/dxf-geometries/dxf-shape.ts +13 -5
- package/src/renderers/react/react-camera.tsx +4 -4
- package/src/renderers/react/react-image-material.tsx +6 -7
- package/src/renderers/react/react-material.tsx +6 -6
- package/src/renderers/react/react-mesh.tsx +1 -1
- package/src/renderers/react/react.tsx +1 -1
- package/src/renderers/svg/svg-geometries/svg-cone.ts +1 -1
- package/src/renderers/svg/svg-geometries/svg-cylinder.ts +1 -1
- package/src/renderers/svg/svg-geometries/svg-image.ts +2 -2
- package/src/utils.ts +4 -4
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type Shape,
|
|
3
|
+
type Material,
|
|
4
|
+
type Vec3,
|
|
5
|
+
vec3TransRot,
|
|
6
|
+
vec3RotCombine,
|
|
7
|
+
vec3Zero,
|
|
8
|
+
vec3,
|
|
9
|
+
} from "../../../abstract-3d.js";
|
|
2
10
|
import type { Handle } from "../dxf-encoding/dxf-common.js";
|
|
3
11
|
import { dxfEnc3DFace } from "../dxf-encoding/dxf-3dface.js";
|
|
4
12
|
import { dxfEnc3DFaceTriangle } from "../dxf-encoding/dxf-triangle.js";
|
|
@@ -18,7 +26,7 @@ export function dxfPolygon(s: Shape, m: Material, parentPos: Vec3, parentRot: Ve
|
|
|
18
26
|
const p2 = points[i + 1];
|
|
19
27
|
const p3 = points[i + 2];
|
|
20
28
|
const p4 = points[i + 3];
|
|
21
|
-
if(p1 && p2 && p3 && p4) {
|
|
29
|
+
if (p1 && p2 && p3 && p4) {
|
|
22
30
|
polygonString += dxfEnc3DFace(p1, p2, p3, p4, m.normal, handleRef);
|
|
23
31
|
}
|
|
24
32
|
}
|
|
@@ -31,7 +39,7 @@ export function dxfPolygon(s: Shape, m: Material, parentPos: Vec3, parentRot: Ve
|
|
|
31
39
|
const p1 = points[i - 2];
|
|
32
40
|
const p2 = points[i - 1];
|
|
33
41
|
const p3 = points[i];
|
|
34
|
-
if(p1 && p2 && p3) {
|
|
42
|
+
if (p1 && p2 && p3) {
|
|
35
43
|
polygonString += dxfEnc3DFaceTriangle(p1, p2, p3, m.normal, handleRef);
|
|
36
44
|
}
|
|
37
45
|
break;
|
|
@@ -40,7 +48,7 @@ export function dxfPolygon(s: Shape, m: Material, parentPos: Vec3, parentRot: Ve
|
|
|
40
48
|
const p1 = points[i - 1];
|
|
41
49
|
const p2 = points[i];
|
|
42
50
|
const p3 = points[i + 1];
|
|
43
|
-
if(p1 && p2 && p3) {
|
|
51
|
+
if (p1 && p2 && p3) {
|
|
44
52
|
polygonString += dxfEnc3DFaceTriangle(p1, p2, p3, m.normal, handleRef);
|
|
45
53
|
}
|
|
46
54
|
break;
|
|
@@ -49,7 +57,7 @@ export function dxfPolygon(s: Shape, m: Material, parentPos: Vec3, parentRot: Ve
|
|
|
49
57
|
const p1 = points[i];
|
|
50
58
|
const p2 = points[i + 1];
|
|
51
59
|
const p3 = points[i + 2];
|
|
52
|
-
if(p1 && p2 && p3) {
|
|
60
|
+
if (p1 && p2 && p3) {
|
|
53
61
|
polygonString += dxfEnc3DFaceTriangle(p1, p2, p3, m.normal, handleRef);
|
|
54
62
|
}
|
|
55
63
|
break;
|
|
@@ -63,9 +63,9 @@ export function ReactCamera({
|
|
|
63
63
|
readonly bufferZones?: BufferZones;
|
|
64
64
|
readonly fitPadding?: number;
|
|
65
65
|
}): React.JSX.Element {
|
|
66
|
-
const [controls, setControls] = useState<any
|
|
67
|
-
const perspectiveRef = useRef<any
|
|
68
|
-
const orthographicRef = useRef<any
|
|
66
|
+
const [controls, setControls] = useState<any>(null);
|
|
67
|
+
const perspectiveRef = useRef<any>(undefined);
|
|
68
|
+
const orthographicRef = useRef<any>(undefined);
|
|
69
69
|
|
|
70
70
|
const initialDistRef = useRef<number | null>(null);
|
|
71
71
|
const initialTargetRef = useRef(new Vector3());
|
|
@@ -115,7 +115,7 @@ export function ReactCamera({
|
|
|
115
115
|
const screenW = size.x;
|
|
116
116
|
const screenH = size.y;
|
|
117
117
|
|
|
118
|
-
const fov = camera.type === "Perspective" ? camera.fov ?? 45 : 45;
|
|
118
|
+
const fov = camera.type === "Perspective" ? (camera.fov ?? 45) : 45;
|
|
119
119
|
|
|
120
120
|
// Buffer zones in CSS pixels
|
|
121
121
|
const bufLeft = bufferZones.left ?? 0;
|
|
@@ -48,15 +48,15 @@ export function ImageMaterial({
|
|
|
48
48
|
materialState === "Error" && materialStateImages?.[ERROR_IMG_KEY]
|
|
49
49
|
? materialStateImages[ERROR_IMG_KEY]
|
|
50
50
|
: image.type === "AbstractImage"
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
? `data:image/svg+xml,${createSVG(image.image)}`
|
|
52
|
+
: image.url;
|
|
53
53
|
const texture = suspend(urlIsSvg(url) ? loadSvg(url, filter) : loadNormal(url, filter), [url]) as Texture | null;
|
|
54
54
|
|
|
55
55
|
return (
|
|
56
56
|
<meshBasicMaterial
|
|
57
57
|
color={getColor(selected, hovered, material, selectMat)}
|
|
58
58
|
side={DoubleSide}
|
|
59
|
-
alphaTest={useAlphaTest ?? true ? 0.8 : undefined}
|
|
59
|
+
alphaTest={(useAlphaTest ?? true) ? 0.8 : undefined}
|
|
60
60
|
map={texture}
|
|
61
61
|
{...(material.opacity !== undefined && material.opacity < 1 ? { opacity: material.opacity } : materialDefaults)}
|
|
62
62
|
transparent
|
|
@@ -77,8 +77,7 @@ function loadSvg(url: string, filter: TextureFilter): Promise<Texture | null> {
|
|
|
77
77
|
const maxSize = 512;
|
|
78
78
|
const img = new Image();
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
img.onload = (): void => {
|
|
80
|
+
img.addEventListener("load", (): void => {
|
|
82
81
|
const canvas = document.createElement("canvas");
|
|
83
82
|
const imgW = img.naturalWidth;
|
|
84
83
|
const imgH = img.naturalHeight;
|
|
@@ -108,9 +107,9 @@ function loadSvg(url: string, filter: TextureFilter): Promise<Texture | null> {
|
|
|
108
107
|
|
|
109
108
|
res(texture);
|
|
110
109
|
textureCache.set(url, texture);
|
|
111
|
-
};
|
|
110
|
+
});
|
|
112
111
|
|
|
113
|
-
img.
|
|
112
|
+
img.addEventListener("error", () => res(null));
|
|
114
113
|
img.src = url;
|
|
115
114
|
});
|
|
116
115
|
}
|
|
@@ -30,10 +30,10 @@ export function ReactMaterial({
|
|
|
30
30
|
const mat = !materialState
|
|
31
31
|
? material
|
|
32
32
|
: materialState === "Accept"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
? acceptMat
|
|
34
|
+
: materialState === "Error"
|
|
35
|
+
? errorMar
|
|
36
|
+
: warningMat;
|
|
37
37
|
|
|
38
38
|
const opacity = material.opacity !== undefined ? material.opacity : materialDefaults.opacity!;
|
|
39
39
|
if (isText) {
|
|
@@ -103,6 +103,6 @@ export function getColor(
|
|
|
103
103
|
? shade(-0.4, selectedMat.normal)
|
|
104
104
|
: selectedMat.normal
|
|
105
105
|
: hovered
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
? shade(-0.4, mat.normal)
|
|
107
|
+
: mat.normal;
|
|
108
108
|
}
|
|
@@ -394,7 +394,7 @@ function ExcrudeCylinder({
|
|
|
394
394
|
return (
|
|
395
395
|
// Doesn't seem to adjust for excrude z size directly???
|
|
396
396
|
<mesh rotation={[cyl.rot?.x ?? 0, cyl.rot?.y ?? 0, cyl.rot?.z ?? 0]} position={[cyl.pos.x, cyl.pos.y, cyl.pos.z]}>
|
|
397
|
-
<mesh geometry={excrudeGeometry} rotation-x={Math.PI / 2} position-y={
|
|
397
|
+
<mesh geometry={excrudeGeometry} rotation-x={Math.PI / 2} position-y={cyl.length / 2} castShadow receiveShadow>
|
|
398
398
|
{children}
|
|
399
399
|
</mesh>
|
|
400
400
|
</mesh>
|
|
@@ -50,7 +50,7 @@ export function cone(
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// Add circle if direcly facing camera
|
|
53
|
-
const cylTop = vec3tr(vec3(0,
|
|
53
|
+
const cylTop = vec3tr(vec3(0, half.y, 0));
|
|
54
54
|
const cylBottom = vec3tr(vec3(0, -half.y, 0));
|
|
55
55
|
if (equals(cylTop.x, cylBottom.x, 0.1) && equals(cylTop.y, cylBottom.y, 0.1)) {
|
|
56
56
|
zOrderComponents.push(
|
|
@@ -56,7 +56,7 @@ export function cylinder(
|
|
|
56
56
|
}
|
|
57
57
|
if (!c.open) {
|
|
58
58
|
// Add circle if direcly facing camera
|
|
59
|
-
const circleTop = vec3tr(vec3(0,
|
|
59
|
+
const circleTop = vec3tr(vec3(0, half.y, 0));
|
|
60
60
|
const circleBottom = vec3tr(vec3(0, -half.y, 0));
|
|
61
61
|
if (equals(circleTop.x, circleBottom.x, 0.1) && equals(circleTop.y, circleBottom.y, 0.1)) {
|
|
62
62
|
const circlePos = circleTop.z > circleBottom.z ? circleTop : circleBottom;
|
|
@@ -50,8 +50,8 @@ export function image(
|
|
|
50
50
|
),
|
|
51
51
|
}
|
|
52
52
|
: i.image.url
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
? { type: "url", url: imageData ?? i.image.url }
|
|
54
|
+
: undefined;
|
|
55
55
|
|
|
56
56
|
if (image) {
|
|
57
57
|
const img = svgImage(point(v4.x, v4.y), i.size, rot, image, opts.imageBg ? opts.background : undefined);
|
package/src/utils.ts
CHANGED
|
@@ -140,10 +140,10 @@ export function shade(p: number, from: string, to?: string): string | undefined
|
|
|
140
140
|
(f[3]! > -1 && t[3]! > -1
|
|
141
141
|
? r(((t[3]! - f[3]!) * p + f[3]!) * 255)
|
|
142
142
|
: t[3]! > -1
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
? r(t[3]! * 255)
|
|
144
|
+
: f[3]! > -1
|
|
145
|
+
? r(f[3]! * 255)
|
|
146
|
+
: 255)
|
|
147
147
|
)
|
|
148
148
|
.toString(16)
|
|
149
149
|
.slice(1, f[3]! > -1 || t[3]! > -1 ? undefined : -2)
|