@snaptrude/plugin-core 0.0.3 → 0.0.4
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/api/core/geom/arc.d.ts +32 -0
- package/dist/api/core/geom/arc.d.ts.map +1 -0
- package/dist/api/core/geom/curve.d.ts +45 -0
- package/dist/api/core/geom/curve.d.ts.map +1 -0
- package/dist/api/core/geom/index.d.ts +16 -0
- package/dist/api/core/geom/index.d.ts.map +1 -0
- package/dist/api/core/geom/line.d.ts +22 -0
- package/dist/api/core/geom/line.d.ts.map +1 -0
- package/dist/api/core/geom/profile.d.ts +57 -0
- package/dist/api/core/geom/profile.d.ts.map +1 -0
- package/dist/api/core/index.d.ts +10 -0
- package/dist/api/core/index.d.ts.map +1 -0
- package/dist/api/core/math/index.d.ts +10 -0
- package/dist/api/core/math/index.d.ts.map +1 -0
- package/dist/api/core/math/quat.d.ts +46 -0
- package/dist/api/core/math/quat.d.ts.map +1 -0
- package/dist/api/core/math/vec3.d.ts +39 -0
- package/dist/api/core/math/vec3.d.ts.map +1 -0
- package/dist/api/entity/index.d.ts +3 -0
- package/dist/api/entity/index.d.ts.map +1 -1
- package/dist/api/entity/space.d.ts +137 -21
- package/dist/api/entity/space.d.ts.map +1 -1
- package/dist/api/entity/story.d.ts +73 -0
- package/dist/api/entity/story.d.ts.map +1 -0
- package/dist/api/index.d.ts +6 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/tools/selection.d.ts +6 -4
- package/dist/api/tools/selection.d.ts.map +1 -1
- package/dist/api/tools/transform.d.ts +25 -10
- package/dist/api/tools/transform.d.ts.map +1 -1
- package/dist/api/units/index.d.ts +95 -0
- package/dist/api/units/index.d.ts.map +1 -0
- package/dist/index.cjs +547 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +493 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -1
- package/src/api/core/geom/arc.ts +21 -0
- package/src/api/core/geom/curve.ts +16 -0
- package/src/api/core/geom/index.ts +18 -0
- package/src/api/core/geom/line.ts +19 -0
- package/src/api/core/geom/profile.ts +30 -0
- package/src/api/core/index.ts +12 -0
- package/src/api/core/math/index.ts +12 -0
- package/src/api/core/math/quat.ts +154 -0
- package/src/api/core/math/vec3.ts +97 -0
- package/src/api/entity/index.ts +3 -0
- package/src/api/entity/space.ts +88 -26
- package/src/api/entity/story.ts +96 -0
- package/src/api/index.ts +6 -0
- package/src/api/tools/selection.ts +7 -4
- package/src/api/tools/transform.ts +16 -10
- package/src/api/units/index.ts +95 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
|
|
4
|
+
export abstract class PluginStoryApi {
|
|
5
|
+
constructor() {}
|
|
6
|
+
|
|
7
|
+
public abstract get({
|
|
8
|
+
storyValue,
|
|
9
|
+
properties,
|
|
10
|
+
}: PluginStoryGetArgs): PluginApiReturn<PluginStoryGetResult>
|
|
11
|
+
|
|
12
|
+
public abstract getAll(): PluginApiReturn<PluginStoryGetAllResult>
|
|
13
|
+
|
|
14
|
+
public abstract create({
|
|
15
|
+
storyValue,
|
|
16
|
+
height,
|
|
17
|
+
}: PluginStoryCreateArgs): PluginApiReturn<PluginStoryCreateResult>
|
|
18
|
+
|
|
19
|
+
public abstract update({
|
|
20
|
+
storyValue,
|
|
21
|
+
height,
|
|
22
|
+
}: PluginStoryUpdateArgs): PluginApiReturn<PluginStoryUpdateResult>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const PluginStoryGetProperty = z.enum([
|
|
26
|
+
"value",
|
|
27
|
+
"id",
|
|
28
|
+
"name",
|
|
29
|
+
"height",
|
|
30
|
+
"base",
|
|
31
|
+
"hidden",
|
|
32
|
+
"spacesCount",
|
|
33
|
+
"totalArea",
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
export const PluginStoryGetArgs = z.object({
|
|
37
|
+
storyValue: z.number().int(),
|
|
38
|
+
properties: z.array(PluginStoryGetProperty),
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
export type PluginStoryGetArgs = z.infer<typeof PluginStoryGetArgs>
|
|
42
|
+
|
|
43
|
+
export const PluginStoryGetResult = z
|
|
44
|
+
.object({
|
|
45
|
+
value: z.number(),
|
|
46
|
+
id: z.string(),
|
|
47
|
+
name: z.string(),
|
|
48
|
+
height: z.number(),
|
|
49
|
+
base: z.number(),
|
|
50
|
+
hidden: z.boolean(),
|
|
51
|
+
spacesCount: z.number(),
|
|
52
|
+
totalArea: z.number(),
|
|
53
|
+
})
|
|
54
|
+
.partial()
|
|
55
|
+
|
|
56
|
+
export type PluginStoryGetResult = z.infer<typeof PluginStoryGetResult>
|
|
57
|
+
|
|
58
|
+
export const PluginStoryGetAllResult = z.object({
|
|
59
|
+
stories: z.array(
|
|
60
|
+
z.object({
|
|
61
|
+
value: z.number(),
|
|
62
|
+
id: z.string(),
|
|
63
|
+
name: z.string(),
|
|
64
|
+
})
|
|
65
|
+
),
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
export type PluginStoryGetAllResult = z.infer<typeof PluginStoryGetAllResult>
|
|
69
|
+
|
|
70
|
+
export const PluginStoryCreateArgs = z.object({
|
|
71
|
+
storyValue: z.number().int(),
|
|
72
|
+
height: z.number().optional(),
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
export type PluginStoryCreateArgs = z.infer<typeof PluginStoryCreateArgs>
|
|
76
|
+
|
|
77
|
+
export const PluginStoryCreateResult = z.object({
|
|
78
|
+
storyId: z.string(),
|
|
79
|
+
storyValue: z.number(),
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
export type PluginStoryCreateResult = z.infer<typeof PluginStoryCreateResult>
|
|
83
|
+
|
|
84
|
+
export const PluginStoryUpdateArgs = z.object({
|
|
85
|
+
storyValue: z.number().int(),
|
|
86
|
+
height: z.number(),
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
export type PluginStoryUpdateArgs = z.infer<typeof PluginStoryUpdateArgs>
|
|
90
|
+
|
|
91
|
+
export const PluginStoryUpdateResult = z.object({
|
|
92
|
+
storyValue: z.number(),
|
|
93
|
+
height: z.number(),
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
export type PluginStoryUpdateResult = z.infer<typeof PluginStoryUpdateResult>
|
package/src/api/index.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
import { PluginCoreApi } from "./core"
|
|
1
2
|
import { PluginEntityApi } from "./entity"
|
|
2
3
|
import { PluginToolsApi } from "./tools"
|
|
4
|
+
import { PluginUnitsApi } from "./units"
|
|
3
5
|
|
|
4
6
|
export abstract class PluginApi {
|
|
7
|
+
public abstract core: PluginCoreApi
|
|
5
8
|
public abstract tools: PluginToolsApi
|
|
6
9
|
public abstract entity: PluginEntityApi
|
|
10
|
+
public abstract units: PluginUnitsApi
|
|
7
11
|
|
|
8
12
|
constructor() {}
|
|
9
13
|
}
|
|
10
14
|
|
|
15
|
+
export * from "./core"
|
|
11
16
|
export * from "./entity"
|
|
12
17
|
export * from "./tools"
|
|
18
|
+
export * from "./units"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
2
3
|
|
|
3
4
|
export abstract class PluginSelectionApi {
|
|
4
5
|
constructor() {}
|
|
@@ -6,6 +7,8 @@ export abstract class PluginSelectionApi {
|
|
|
6
7
|
public abstract get(): PluginApiReturn<PluginSelectionGetResult>
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export
|
|
10
|
-
selected:
|
|
11
|
-
}
|
|
10
|
+
export const PluginSelectionGetResult = z.object({
|
|
11
|
+
selected: z.array(z.string()),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export type PluginSelectionGetResult = z.infer<typeof PluginSelectionGetResult>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
1
2
|
import { PluginApiReturn } from "../../types"
|
|
3
|
+
import { PVec3 } from "../core/math/vec3"
|
|
2
4
|
|
|
3
5
|
export abstract class PluginTransformApi {
|
|
4
6
|
constructor() {}
|
|
@@ -16,14 +18,18 @@ export abstract class PluginTransformApi {
|
|
|
16
18
|
}: PluginRotateArgs): PluginApiReturn<void>
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
export
|
|
20
|
-
componentIds: string
|
|
21
|
-
displacement:
|
|
22
|
-
}
|
|
21
|
+
export const PluginMoveArgs = z.object({
|
|
22
|
+
componentIds: z.array(z.string()),
|
|
23
|
+
displacement: PVec3,
|
|
24
|
+
})
|
|
23
25
|
|
|
24
|
-
export type
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
export type PluginMoveArgs = z.infer<typeof PluginMoveArgs>
|
|
27
|
+
|
|
28
|
+
export const PluginRotateArgs = z.object({
|
|
29
|
+
componentIds: z.array(z.string()),
|
|
30
|
+
angle: z.number(),
|
|
31
|
+
axis: PVec3,
|
|
32
|
+
pivot: PVec3,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
export type PluginRotateArgs = z.infer<typeof PluginRotateArgs>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
|
|
4
|
+
export abstract class PluginUnitsApi {
|
|
5
|
+
constructor() {}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Convert a value from the given unit to Snaptrude's internal (Babylon) units.
|
|
9
|
+
*
|
|
10
|
+
* Use this when you have a measurement in real-world units (e.g. meters, feet)
|
|
11
|
+
* and need to convert it to the coordinate system used by Snaptrude internally.
|
|
12
|
+
*
|
|
13
|
+
* @param args.unit - The source unit to convert from (e.g. `"meters"`, `"feet-inches"`)
|
|
14
|
+
* @param args.value - The numeric value in the source unit
|
|
15
|
+
* @returns An object containing the converted `value` in Snaptrude/Babylon units
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const result = await snaptrude.units.convertFrom({ unit: "meters", value: 5 })
|
|
20
|
+
* // result.value is 5 meters expressed in Babylon units
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
public abstract convertFrom(
|
|
24
|
+
args: PluginUnitsConvertFromArgs,
|
|
25
|
+
): PluginApiReturn<PluginUnitsConvertFromResult>
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Convert a value from Snaptrude's internal (Babylon) units to the given unit.
|
|
29
|
+
*
|
|
30
|
+
* Use this when you have a value in Snaptrude's internal coordinate system
|
|
31
|
+
* and need to express it in real-world units (e.g. meters, feet).
|
|
32
|
+
*
|
|
33
|
+
* @param args.unit - The target unit to convert to (e.g. `"meters"`, `"feet-inches"`)
|
|
34
|
+
* @param args.value - The numeric value in Snaptrude/Babylon units
|
|
35
|
+
* @returns An object containing the converted `value` in the target unit
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const result = await snaptrude.units.convertTo({ unit: "feet-inches", value: 1.2 })
|
|
40
|
+
* // result.value is 1.2 Babylon units expressed in feet
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
public abstract convertTo(
|
|
44
|
+
args: PluginUnitsConvertToArgs,
|
|
45
|
+
): PluginApiReturn<PluginUnitsConvertToResult>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Supported unit types for conversion.
|
|
50
|
+
*
|
|
51
|
+
* - `meters` — Metric meters
|
|
52
|
+
* - `feet-inches` — Imperial feet (1 foot = 12 inches)
|
|
53
|
+
* - `inches` — Imperial inches
|
|
54
|
+
* - `centimeters` — Metric centimeters
|
|
55
|
+
* - `millimeters` — Metric millimeters
|
|
56
|
+
* - `kilometers` — Metric kilometers
|
|
57
|
+
* - `miles` — Imperial miles
|
|
58
|
+
*/
|
|
59
|
+
export const PUnitType = z.enum([
|
|
60
|
+
"meters",
|
|
61
|
+
"feet-inches",
|
|
62
|
+
"inches",
|
|
63
|
+
"centimeters",
|
|
64
|
+
"millimeters",
|
|
65
|
+
"kilometers",
|
|
66
|
+
"miles",
|
|
67
|
+
])
|
|
68
|
+
|
|
69
|
+
export type PUnitType = z.infer<typeof PUnitType>
|
|
70
|
+
|
|
71
|
+
export const PluginUnitsConvertFromArgs = z.object({
|
|
72
|
+
unit: PUnitType,
|
|
73
|
+
value: z.number(),
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
export type PluginUnitsConvertFromArgs = z.infer<typeof PluginUnitsConvertFromArgs>
|
|
77
|
+
|
|
78
|
+
export const PluginUnitsConvertFromResult = z.object({
|
|
79
|
+
value: z.number(),
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
export type PluginUnitsConvertFromResult = z.infer<typeof PluginUnitsConvertFromResult>
|
|
83
|
+
|
|
84
|
+
export const PluginUnitsConvertToArgs = z.object({
|
|
85
|
+
unit: PUnitType,
|
|
86
|
+
value: z.number(),
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
export type PluginUnitsConvertToArgs = z.infer<typeof PluginUnitsConvertToArgs>
|
|
90
|
+
|
|
91
|
+
export const PluginUnitsConvertToResult = z.object({
|
|
92
|
+
value: z.number(),
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
export type PluginUnitsConvertToResult = z.infer<typeof PluginUnitsConvertToResult>
|