@remotion/svg-3d-engine 4.0.363 → 4.0.365
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/dist/cjs/3d-svg.d.ts +22 -0
- package/dist/cjs/3d-svg.js +26 -0
- package/dist/cjs/elements.d.ts +8 -0
- package/dist/cjs/elements.js +10 -0
- package/dist/cjs/extrude-element.d.ts +15 -0
- package/dist/cjs/extrude-element.js +105 -0
- package/dist/cjs/fix-z.d.ts +3 -0
- package/dist/cjs/fix-z.js +44 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/make-id.d.ts +1 -0
- package/dist/cjs/make-id.js +7 -0
- package/dist/cjs/map-face.d.ts +25 -0
- package/dist/cjs/map-face.js +124 -0
- package/dist/cjs/matrix.d.ts +66 -0
- package/dist/cjs/matrix.js +308 -0
- package/dist/cjs/subdivide-instructions.d.ts +4 -0
- package/dist/cjs/subdivide-instructions.js +180 -0
- package/dist/cjs/truthy.d.ts +3 -0
- package/dist/cjs/truthy.js +6 -0
- package/dist/esm/index.mjs +1378 -0
- package/package.json +3 -3
- package/.turbo/turbo-lint.log +0 -15
- package/.turbo/turbo-make.log +0 -3
- package/bundle.ts +0 -23
- package/eslint.config.mjs +0 -7
- package/src/3d-svg.ts +0 -59
- package/src/elements.ts +0 -18
- package/src/extrude-element.ts +0 -147
- package/src/fix-z.ts +0 -45
- package/src/index.ts +0 -22
- package/src/make-id.ts +0 -3
- package/src/map-face.ts +0 -167
- package/src/matrix.ts +0 -425
- package/src/subdivide-instructions.ts +0 -238
- package/src/truthy.ts +0 -4
- package/tsconfig.json +0 -14
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/svg-3d-engine",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"@remotion/paths": "4.0.
|
|
4
|
+
"@remotion/paths": "4.0.365"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
7
|
+
"@remotion/eslint-config-internal": "4.0.365",
|
|
8
8
|
"eslint": "9.19.0"
|
|
9
9
|
},
|
|
10
10
|
"main": "dist/cjs/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"require": "./dist/cjs/index.js"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
-
"version": "4.0.
|
|
26
|
+
"version": "4.0.365",
|
|
27
27
|
"repository": {
|
|
28
28
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/svg-3d-engine"
|
|
29
29
|
},
|
package/.turbo/turbo-lint.log
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
[0m[2m[35m$[0m [2m[1meslint src[0m
|
|
3
|
-
=============
|
|
4
|
-
|
|
5
|
-
WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.
|
|
6
|
-
|
|
7
|
-
You may find that it works just fine, or you may not.
|
|
8
|
-
|
|
9
|
-
SUPPORTED TYPESCRIPT VERSIONS: >=4.7.4 <5.7.0
|
|
10
|
-
|
|
11
|
-
YOUR TYPESCRIPT VERSION: 5.8.2
|
|
12
|
-
|
|
13
|
-
Please only submit bug reports when using the officially supported version.
|
|
14
|
-
|
|
15
|
-
=============
|
package/.turbo/turbo-make.log
DELETED
package/bundle.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {build} from 'bun';
|
|
2
|
-
|
|
3
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4
|
-
throw new Error('This script must be run using NODE_ENV=production');
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const output = await build({
|
|
8
|
-
entrypoints: ['src/index.ts'],
|
|
9
|
-
naming: '[name].mjs',
|
|
10
|
-
external: ['remotion', 'remotion/no-react'],
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
if (!output.success) {
|
|
14
|
-
throw new Error(output.logs.join('\n'));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const [file] = output.outputs;
|
|
18
|
-
const text = await file.text();
|
|
19
|
-
|
|
20
|
-
await Bun.write('dist/esm/index.mjs', text);
|
|
21
|
-
|
|
22
|
-
export {};
|
|
23
|
-
console.log('Generated.');
|
package/eslint.config.mjs
DELETED
package/src/3d-svg.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type {Vector4D} from './matrix';
|
|
2
|
-
|
|
3
|
-
export type ThreeDReducedInstruction =
|
|
4
|
-
| {
|
|
5
|
-
type: 'M';
|
|
6
|
-
point: Vector4D;
|
|
7
|
-
}
|
|
8
|
-
| {
|
|
9
|
-
type: 'L';
|
|
10
|
-
point: Vector4D;
|
|
11
|
-
}
|
|
12
|
-
| {
|
|
13
|
-
type: 'C';
|
|
14
|
-
cp1: Vector4D;
|
|
15
|
-
cp2: Vector4D;
|
|
16
|
-
point: Vector4D;
|
|
17
|
-
}
|
|
18
|
-
| {
|
|
19
|
-
type: 'Q';
|
|
20
|
-
cp: Vector4D;
|
|
21
|
-
point: Vector4D;
|
|
22
|
-
}
|
|
23
|
-
| {
|
|
24
|
-
type: 'Z';
|
|
25
|
-
point: Vector4D;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const serializeThreeDReducedInstruction = (
|
|
29
|
-
instruction: ThreeDReducedInstruction,
|
|
30
|
-
): string => {
|
|
31
|
-
if (instruction.type === 'M') {
|
|
32
|
-
return `M ${instruction.point[0]} ${instruction.point[1]}`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (instruction.type === 'L') {
|
|
36
|
-
return `L ${instruction.point[0]} ${instruction.point[1]}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (instruction.type === 'C') {
|
|
40
|
-
return `C ${instruction.cp1[0]} ${instruction.cp1[1]} ${instruction.cp2[0]} ${instruction.cp2[1]} ${instruction.point[0]} ${instruction.point[1]}`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (instruction.type === 'Q') {
|
|
44
|
-
return `Q ${instruction.cp[0]} ${instruction.cp[1]} ${instruction.point[0]} ${instruction.point[1]}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (instruction.type === 'Z') {
|
|
48
|
-
return 'Z';
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
throw new Error('Unknown instruction type');
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const threeDIntoSvgPath = (
|
|
55
|
-
instructions: ThreeDReducedInstruction[],
|
|
56
|
-
): string =>
|
|
57
|
-
instructions
|
|
58
|
-
.map((instruction) => serializeThreeDReducedInstruction(instruction))
|
|
59
|
-
.join(' ');
|
package/src/elements.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type {FaceType} from './map-face';
|
|
2
|
-
import {transformFace} from './map-face';
|
|
3
|
-
import type {MatrixTransform4D} from './matrix';
|
|
4
|
-
|
|
5
|
-
export type ThreeDElement = {
|
|
6
|
-
faces: FaceType[];
|
|
7
|
-
id: string;
|
|
8
|
-
description: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const transformFaces = (
|
|
12
|
-
faces: FaceType[],
|
|
13
|
-
transformations: MatrixTransform4D[],
|
|
14
|
-
): FaceType[] => {
|
|
15
|
-
return faces.map((face) => {
|
|
16
|
-
return transformFace(face, transformations);
|
|
17
|
-
});
|
|
18
|
-
};
|
package/src/extrude-element.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import type {Instruction} from '@remotion/paths';
|
|
2
|
-
import type {ThreeDReducedInstruction} from './3d-svg';
|
|
3
|
-
import {turnInto3D} from './fix-z';
|
|
4
|
-
import type {FaceType} from './map-face';
|
|
5
|
-
import {transformFace, translateSvgInstruction} from './map-face';
|
|
6
|
-
import type {MatrixTransform4D, Vector4D} from './matrix';
|
|
7
|
-
import {translateZ} from './matrix';
|
|
8
|
-
import {subdivideInstructions} from './subdivide-instructions';
|
|
9
|
-
import {truthy} from './truthy';
|
|
10
|
-
|
|
11
|
-
const inverseInstruction = (
|
|
12
|
-
instruction: ThreeDReducedInstruction,
|
|
13
|
-
comingFrom: Vector4D,
|
|
14
|
-
): ThreeDReducedInstruction => {
|
|
15
|
-
if (instruction.type === 'M') {
|
|
16
|
-
return {
|
|
17
|
-
type: 'M',
|
|
18
|
-
point: comingFrom,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (instruction.type === 'L') {
|
|
23
|
-
return {
|
|
24
|
-
type: 'L',
|
|
25
|
-
point: comingFrom,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (instruction.type === 'C') {
|
|
30
|
-
return {
|
|
31
|
-
type: 'C',
|
|
32
|
-
point: comingFrom,
|
|
33
|
-
cp1: instruction.cp2,
|
|
34
|
-
cp2: instruction.cp1,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (instruction.type === 'Q') {
|
|
39
|
-
return {
|
|
40
|
-
type: 'Q',
|
|
41
|
-
point: comingFrom,
|
|
42
|
-
cp: instruction.cp,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (instruction.type === 'Z') {
|
|
47
|
-
return {
|
|
48
|
-
type: 'L',
|
|
49
|
-
point: comingFrom,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
throw new Error('Unknown instruction type');
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
type ExtrudeElementOptions = {
|
|
57
|
-
depth: number;
|
|
58
|
-
sideColor: string;
|
|
59
|
-
points: Instruction[];
|
|
60
|
-
description?: string;
|
|
61
|
-
crispEdges: boolean;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const extrudeElement = ({
|
|
65
|
-
depth,
|
|
66
|
-
sideColor,
|
|
67
|
-
points,
|
|
68
|
-
crispEdges,
|
|
69
|
-
}: ExtrudeElementOptions): FaceType[] => {
|
|
70
|
-
const threeD = turnInto3D(points);
|
|
71
|
-
const instructions: FaceType = {
|
|
72
|
-
centerPoint: [0, 0, 0, 1],
|
|
73
|
-
points: subdivideInstructions(
|
|
74
|
-
subdivideInstructions(subdivideInstructions(threeD)),
|
|
75
|
-
),
|
|
76
|
-
color: 'black',
|
|
77
|
-
crispEdges,
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const unscaledBackFace = transformFace(instructions, [translateZ(depth / 2)]);
|
|
81
|
-
|
|
82
|
-
const inbetween = unscaledBackFace.points.map((t, i): FaceType => {
|
|
83
|
-
const nextInstruction =
|
|
84
|
-
i === unscaledBackFace.points.length - 1
|
|
85
|
-
? unscaledBackFace.points[0]
|
|
86
|
-
: unscaledBackFace.points[i + 1];
|
|
87
|
-
|
|
88
|
-
const currentPoint = t.point;
|
|
89
|
-
const nextPoint = nextInstruction.point;
|
|
90
|
-
const movingOver: Vector4D = [
|
|
91
|
-
nextPoint[0],
|
|
92
|
-
nextPoint[1],
|
|
93
|
-
nextPoint[2] - depth,
|
|
94
|
-
nextPoint[3],
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
const translatedInstruction = translateSvgInstruction(
|
|
98
|
-
inverseInstruction(nextInstruction, currentPoint),
|
|
99
|
-
0,
|
|
100
|
-
0,
|
|
101
|
-
-depth,
|
|
102
|
-
);
|
|
103
|
-
const newInstructions: ThreeDReducedInstruction[] = [
|
|
104
|
-
{
|
|
105
|
-
type: 'M' as const,
|
|
106
|
-
point: currentPoint,
|
|
107
|
-
},
|
|
108
|
-
nextInstruction,
|
|
109
|
-
nextInstruction.type === 'Z'
|
|
110
|
-
? {
|
|
111
|
-
type: 'M' as const,
|
|
112
|
-
point: nextInstruction.point,
|
|
113
|
-
}
|
|
114
|
-
: null,
|
|
115
|
-
{
|
|
116
|
-
type: 'L' as const,
|
|
117
|
-
point: movingOver,
|
|
118
|
-
},
|
|
119
|
-
translatedInstruction,
|
|
120
|
-
{
|
|
121
|
-
type: 'L' as const,
|
|
122
|
-
point: currentPoint,
|
|
123
|
-
},
|
|
124
|
-
].filter(truthy);
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
points: newInstructions,
|
|
128
|
-
color: sideColor,
|
|
129
|
-
centerPoint: [0, 0, 0, 1],
|
|
130
|
-
crispEdges: true,
|
|
131
|
-
};
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
return inbetween;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export const extrudeAndTransformElement = (
|
|
138
|
-
options: ExtrudeElementOptions & {
|
|
139
|
-
transformations: MatrixTransform4D;
|
|
140
|
-
},
|
|
141
|
-
): FaceType[] => {
|
|
142
|
-
const inbetween = extrudeElement(options);
|
|
143
|
-
|
|
144
|
-
return inbetween.map((face) => ({
|
|
145
|
-
...transformFace(face, [options.transformations]),
|
|
146
|
-
}));
|
|
147
|
-
};
|
package/src/fix-z.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type {Instruction} from '@remotion/paths';
|
|
2
|
-
import {reduceInstructions} from '@remotion/paths';
|
|
3
|
-
import type {ThreeDReducedInstruction} from './3d-svg';
|
|
4
|
-
import type {Vector4D} from './matrix';
|
|
5
|
-
|
|
6
|
-
export const turnInto3D = (
|
|
7
|
-
instructions: Instruction[],
|
|
8
|
-
): ThreeDReducedInstruction[] => {
|
|
9
|
-
let lastMove: Vector4D = [0, 0, 0, 1];
|
|
10
|
-
const newInstructions: ThreeDReducedInstruction[] = [];
|
|
11
|
-
const reduced = reduceInstructions(instructions);
|
|
12
|
-
|
|
13
|
-
for (let i = 0; i < reduced.length; i++) {
|
|
14
|
-
const instruction = reduced[i];
|
|
15
|
-
|
|
16
|
-
if (instruction.type === 'Z') {
|
|
17
|
-
newInstructions.push({
|
|
18
|
-
type: 'Z',
|
|
19
|
-
point: lastMove,
|
|
20
|
-
});
|
|
21
|
-
} else if (instruction.type === 'M') {
|
|
22
|
-
lastMove = [instruction.x, instruction.y, 0, 1];
|
|
23
|
-
newInstructions.push({
|
|
24
|
-
point: [instruction.x, instruction.y, 0, 1],
|
|
25
|
-
type: 'M',
|
|
26
|
-
});
|
|
27
|
-
} else if (instruction.type === 'L') {
|
|
28
|
-
newInstructions.push({
|
|
29
|
-
type: 'L',
|
|
30
|
-
point: [instruction.x, instruction.y, 0, 1],
|
|
31
|
-
});
|
|
32
|
-
} else if (instruction.type === 'C') {
|
|
33
|
-
newInstructions.push({
|
|
34
|
-
type: 'C',
|
|
35
|
-
point: [instruction.x, instruction.y, 0, 1],
|
|
36
|
-
cp1: [instruction.cp1x, instruction.cp1y, 0, 1],
|
|
37
|
-
cp2: [instruction.cp2x, instruction.cp2y, 0, 1],
|
|
38
|
-
});
|
|
39
|
-
} else {
|
|
40
|
-
throw new Error('unknown');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return newInstructions;
|
|
45
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export {MatrixTransform4D, Vector4D} from './matrix';
|
|
2
|
-
|
|
3
|
-
export type {ThreeDReducedInstruction} from './3d-svg';
|
|
4
|
-
|
|
5
|
-
export {threeDIntoSvgPath} from './3d-svg';
|
|
6
|
-
export {extrudeAndTransformElement, extrudeElement} from './extrude-element';
|
|
7
|
-
export {transformPath, type FaceType} from './map-face';
|
|
8
|
-
export {
|
|
9
|
-
aroundCenterPoint,
|
|
10
|
-
interpolateMatrix4d,
|
|
11
|
-
makeMatrix3dTransform,
|
|
12
|
-
reduceMatrices,
|
|
13
|
-
rotateX,
|
|
14
|
-
rotateY,
|
|
15
|
-
rotateZ,
|
|
16
|
-
scaleX,
|
|
17
|
-
scaleY,
|
|
18
|
-
scaled,
|
|
19
|
-
translateX,
|
|
20
|
-
translateY,
|
|
21
|
-
translateZ,
|
|
22
|
-
} from './matrix';
|
package/src/make-id.ts
DELETED
package/src/map-face.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import {parsePath, reduceInstructions} from '@remotion/paths';
|
|
2
|
-
import {threeDIntoSvgPath, type ThreeDReducedInstruction} from './3d-svg';
|
|
3
|
-
import {turnInto3D} from './fix-z';
|
|
4
|
-
import type {MatrixTransform4D, Vector4D} from './matrix';
|
|
5
|
-
import {multiplyMatrix, multiplyMatrixAndSvgInstruction} from './matrix';
|
|
6
|
-
|
|
7
|
-
export type FaceType = {
|
|
8
|
-
color: string;
|
|
9
|
-
points: ThreeDReducedInstruction[];
|
|
10
|
-
centerPoint: Vector4D;
|
|
11
|
-
crispEdges: boolean;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const translateSvgInstruction = (
|
|
15
|
-
instruction: ThreeDReducedInstruction,
|
|
16
|
-
x: number,
|
|
17
|
-
y: number,
|
|
18
|
-
z: number,
|
|
19
|
-
): ThreeDReducedInstruction => {
|
|
20
|
-
if (instruction.type === 'M') {
|
|
21
|
-
return {
|
|
22
|
-
type: 'M',
|
|
23
|
-
point: [
|
|
24
|
-
instruction.point[0] + x,
|
|
25
|
-
instruction.point[1] + y,
|
|
26
|
-
instruction.point[2] + z,
|
|
27
|
-
instruction.point[3],
|
|
28
|
-
],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (instruction.type === 'L') {
|
|
33
|
-
return {
|
|
34
|
-
type: 'L',
|
|
35
|
-
point: [
|
|
36
|
-
instruction.point[0] + x,
|
|
37
|
-
instruction.point[1] + y,
|
|
38
|
-
instruction.point[2] + z,
|
|
39
|
-
instruction.point[3],
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (instruction.type === 'C') {
|
|
45
|
-
return {
|
|
46
|
-
type: 'C',
|
|
47
|
-
point: [
|
|
48
|
-
instruction.point[0] + x,
|
|
49
|
-
instruction.point[1] + y,
|
|
50
|
-
instruction.point[2] + z,
|
|
51
|
-
instruction.point[3],
|
|
52
|
-
],
|
|
53
|
-
cp1: [
|
|
54
|
-
instruction.cp1[0] + x,
|
|
55
|
-
instruction.cp1[1] + y,
|
|
56
|
-
instruction.cp1[2] + z,
|
|
57
|
-
instruction.cp1[3],
|
|
58
|
-
],
|
|
59
|
-
cp2: [
|
|
60
|
-
instruction.cp2[0] + x,
|
|
61
|
-
instruction.cp2[1] + y,
|
|
62
|
-
instruction.cp2[2] + z,
|
|
63
|
-
instruction.cp2[3],
|
|
64
|
-
],
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (instruction.type === 'Q') {
|
|
69
|
-
return {
|
|
70
|
-
type: 'Q',
|
|
71
|
-
point: [
|
|
72
|
-
instruction.point[0] + x,
|
|
73
|
-
instruction.point[1] + y,
|
|
74
|
-
instruction.point[2] + z,
|
|
75
|
-
instruction.point[3],
|
|
76
|
-
],
|
|
77
|
-
cp: [
|
|
78
|
-
instruction.cp[0] + x,
|
|
79
|
-
instruction.cp[1] + y,
|
|
80
|
-
instruction.cp[2] + z,
|
|
81
|
-
instruction.cp[3],
|
|
82
|
-
],
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (instruction.type === 'Z') {
|
|
87
|
-
return {
|
|
88
|
-
type: 'Z',
|
|
89
|
-
point: [
|
|
90
|
-
instruction.point[0] + x,
|
|
91
|
-
instruction.point[1] + y,
|
|
92
|
-
instruction.point[2] + z,
|
|
93
|
-
instruction.point[3],
|
|
94
|
-
],
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
throw new Error('Unknown instruction type: ' + JSON.stringify(instruction));
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export const transformPath = ({
|
|
102
|
-
path,
|
|
103
|
-
transformation,
|
|
104
|
-
}: {
|
|
105
|
-
path: string;
|
|
106
|
-
transformation: MatrixTransform4D;
|
|
107
|
-
}): string => {
|
|
108
|
-
const parsed = parsePath(path);
|
|
109
|
-
const reduced = reduceInstructions(parsed);
|
|
110
|
-
const threeD = turnInto3D(reduced);
|
|
111
|
-
return threeDIntoSvgPath(
|
|
112
|
-
threeD.map((p) => {
|
|
113
|
-
return multiplyMatrixAndSvgInstruction(transformation, p);
|
|
114
|
-
}),
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export const transformFace = (
|
|
119
|
-
face: FaceType,
|
|
120
|
-
transformations: MatrixTransform4D[],
|
|
121
|
-
): FaceType => {
|
|
122
|
-
return {
|
|
123
|
-
...face,
|
|
124
|
-
points: face.points.map((p) => {
|
|
125
|
-
return transformations.reduce((acc, t) => {
|
|
126
|
-
return multiplyMatrixAndSvgInstruction(t, acc);
|
|
127
|
-
}, p);
|
|
128
|
-
}),
|
|
129
|
-
centerPoint: transformations.reduce((acc, t) => {
|
|
130
|
-
const result = multiplyMatrix(t, acc);
|
|
131
|
-
return result;
|
|
132
|
-
}, face.centerPoint),
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export const transformFaces = ({
|
|
137
|
-
faces,
|
|
138
|
-
transformations,
|
|
139
|
-
}: {
|
|
140
|
-
faces: FaceType[];
|
|
141
|
-
transformations: MatrixTransform4D[];
|
|
142
|
-
}) => {
|
|
143
|
-
return faces.map((face) => {
|
|
144
|
-
return transformFace(face, transformations);
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export const makeFace = ({
|
|
149
|
-
points,
|
|
150
|
-
fill,
|
|
151
|
-
crispEdges,
|
|
152
|
-
}: {
|
|
153
|
-
points: string | ThreeDReducedInstruction[];
|
|
154
|
-
strokeWidth: number;
|
|
155
|
-
strokeColor: string;
|
|
156
|
-
fill: string;
|
|
157
|
-
crispEdges: boolean;
|
|
158
|
-
}): FaceType => {
|
|
159
|
-
const centerPoint: Vector4D = [0, 0, 0, 1];
|
|
160
|
-
|
|
161
|
-
return {
|
|
162
|
-
centerPoint,
|
|
163
|
-
color: fill,
|
|
164
|
-
points: typeof points === 'string' ? turnInto3D(parsePath(points)) : points,
|
|
165
|
-
crispEdges,
|
|
166
|
-
};
|
|
167
|
-
};
|