@snaptrude/plugin-core 0.0.2 → 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
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/entity/space.ts","../src/api/entity/index.ts","../src/api/tools/selection.ts","../src/api/tools/transform.ts","../src/api/tools/index.ts","../src/api/index.ts"],"sourcesContent":["import { ComponentId, PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginSpaceApi {\n constructor() {}\n\n public abstract createRectangular({\n position,\n dimensions,\n }: PluginSpaceCreateRectangularArgs): PluginApiReturn<PluginSpaceCreateRectangularResult>\n\n public abstract getAll(): PluginApiReturn<PluginSpaceGetAllResult>;\n \n public abstract getById({\n spaceId,\n properties,\n }: PluginSpaceGetByIdArgs): PluginApiReturn<PluginSpaceGetByIdResult>\n\n public abstract deleteById({\n spaceId,\n }: PluginSpaceDeleteByIdArgs): PluginApiReturn<PluginSpaceDeleteByIdResult>\n}\n\nexport type PluginSpaceCreateRectangularArgs = {\n position: [number, number, number]\n dimensions: [number, number, number]\n}\n\nexport type PluginSpaceCreateRectangularResult = {\n spaceId: ComponentId\n}\n\nexport type PluginSpaceGetByIdArgs = {\n spaceId: ComponentId\n properties: PluginSpaceGetByIdProperty[]\n}\n\nexport type PluginSpaceGetByIdProperty = \"id\" | \"type\" | \"room_type\" | \"name\" | \"area\" | \"height\" | \"department\";\n\nexport type PluginSpaceGetByIdResult = Partial<\n Record<PluginSpaceGetByIdProperty, any>\n>\n\nexport type PluginSpaceGetAllResult = {\n spacesIds: ComponentId[]\n}\n\nexport type PluginSpaceDeleteByIdArgs = {\n spaceId: ComponentId\n}\n\nexport type PluginSpaceDeleteByIdResult = void\n","import { PluginSpaceApi } from \"./space\"\n\nexport abstract class PluginEntityApi {\n public abstract space: PluginSpaceApi\n\n constructor() {}\n}\n\nexport * from \"./space\"\n","import type { ComponentId, PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginSelectionApi {\n constructor() {}\n\n public abstract get(): PluginApiReturn<PluginSelectionGetResult>\n}\n\nexport type PluginSelectionGetResult = {\n selected: ComponentId[]\n}\n","import { PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginTransformApi {\n constructor() {}\n\n public abstract move({\n componentIds,\n displacement,\n }: PluginMoveArgs): PluginApiReturn<void>\n\n public abstract rotate({\n componentIds,\n angle,\n axis,\n pivot,\n }: PluginRotateArgs): PluginApiReturn<void>\n}\n\nexport type PluginMoveArgs = {\n componentIds: string[]\n displacement: [number, number, number]\n}\n\nexport type PluginRotateArgs = {\n componentIds: string[]\n angle: number\n axis: [number, number, number]\n pivot: [number, number, number]\n}\n","import { PluginSelectionApi } from \"./selection\"\nimport { PluginTransformApi } from \"./transform\"\n\nexport abstract class PluginToolsApi {\n public abstract selection: PluginSelectionApi\n public abstract transform: PluginTransformApi\n\n constructor() {}\n}\n\nexport * from \"./selection\"\nexport * from \"./transform\"\n","import { PluginEntityApi } from \"./entity\"\nimport { PluginToolsApi } from \"./tools\"\n\nexport abstract class PluginApi {\n public abstract tools: PluginToolsApi\n public abstract entity: PluginEntityApi\n\n constructor() {}\n}\n\nexport * from \"./entity\"\nexport * from \"./tools\"\n"],"mappings":";AAEO,IAAe,iBAAf,MAA8B;AAAA,EACnC,cAAc;AAAA,EAAC;AAiBjB;;;AClBO,IAAe,kBAAf,MAA+B;AAAA,EAGpC,cAAc;AAAA,EAAC;AACjB;;;ACJO,IAAe,qBAAf,MAAkC;AAAA,EACvC,cAAc;AAAA,EAAC;AAGjB;;;ACJO,IAAe,qBAAf,MAAkC;AAAA,EACvC,cAAc;AAAA,EAAC;AAajB;;;ACbO,IAAe,iBAAf,MAA8B;AAAA,EAInC,cAAc;AAAA,EAAC;AACjB;;;ACLO,IAAe,YAAf,MAAyB;AAAA,EAI9B,cAAc;AAAA,EAAC;AACjB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/api/core/math/vec3.ts","../src/api/core/math/quat.ts","../src/api/core/math/index.ts","../src/api/core/geom/line.ts","../src/api/core/geom/arc.ts","../src/api/core/geom/curve.ts","../src/api/core/geom/profile.ts","../src/api/core/geom/index.ts","../src/api/core/index.ts","../src/api/entity/space.ts","../src/api/entity/story.ts","../src/api/entity/index.ts","../src/api/tools/selection.ts","../src/api/tools/transform.ts","../src/api/tools/index.ts","../src/api/units/index.ts","../src/api/index.ts"],"sourcesContent":["import * as z from \"zod\"\n\nexport abstract class PluginVec3Api {\n constructor() {}\n\n /** Create a new PVec3. */\n new(x: number, y: number, z: number): PVec3 {\n return { x, y, z }\n }\n\n /** Add two vectors. */\n add(a: PVec3, b: PVec3): PVec3 {\n return { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z }\n }\n\n /** Subtract b from a. */\n subtract(a: PVec3, b: PVec3): PVec3 {\n return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z }\n }\n\n /** Scale a vector by a scalar. */\n scale(v: PVec3, scalar: number): PVec3 {\n return { x: v.x * scalar, y: v.y * scalar, z: v.z * scalar }\n }\n\n /** Dot product of two vectors. */\n dot(a: PVec3, b: PVec3): number {\n return a.x * b.x + a.y * b.y + a.z * b.z\n }\n\n /** Cross product of two vectors. */\n cross(a: PVec3, b: PVec3): PVec3 {\n return {\n x: a.y * b.z - a.z * b.y,\n y: a.z * b.x - a.x * b.z,\n z: a.x * b.y - a.y * b.x,\n }\n }\n\n /** Length (magnitude) of a vector. */\n length(v: PVec3): number {\n return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z)\n }\n\n /** Squared length of a vector (avoids sqrt). */\n lengthSquared(v: PVec3): number {\n return v.x * v.x + v.y * v.y + v.z * v.z\n }\n\n /** Normalize a vector to unit length. Returns zero vector if length is 0. */\n normalize(v: PVec3): PVec3 {\n const len = this.length(v)\n if (len === 0) return { x: 0, y: 0, z: 0 }\n return { x: v.x / len, y: v.y / len, z: v.z / len }\n }\n\n /** Distance between two points. */\n distance(a: PVec3, b: PVec3): number {\n return this.length(this.subtract(a, b))\n }\n\n /** Linearly interpolate between two vectors. */\n lerp(a: PVec3, b: PVec3, t: number): PVec3 {\n return {\n x: a.x + (b.x - a.x) * t,\n y: a.y + (b.y - a.y) * t,\n z: a.z + (b.z - a.z) * t,\n }\n }\n\n /** Negate a vector. */\n negate(v: PVec3): PVec3 {\n return { x: -v.x, y: -v.y, z: -v.z }\n }\n\n /** Check if two vectors are equal (exact). */\n equals(a: PVec3, b: PVec3): boolean {\n return a.x === b.x && a.y === b.y && a.z === b.z\n }\n\n /** Check if two vectors are approximately equal within an epsilon. */\n equalsApprox(a: PVec3, b: PVec3, epsilon: number = 1e-6): boolean {\n return (\n Math.abs(a.x - b.x) < epsilon &&\n Math.abs(a.y - b.y) < epsilon &&\n Math.abs(a.z - b.z) < epsilon\n )\n }\n}\n\nexport const PVec3 = z.object({\n x: z.number(),\n y: z.number(),\n z: z.number(),\n})\n\nexport type PVec3 = z.infer<typeof PVec3>\n","import * as z from \"zod\"\nimport type { PVec3 } from \"./vec3\"\n\nexport abstract class PluginQuatApi {\n constructor() {}\n\n /** Create a new PQuat. */\n new(x: number, y: number, z: number, w: number): PQuat {\n return { x, y, z, w }\n }\n\n /** Create an identity quaternion (no rotation). */\n identity(): PQuat {\n return { x: 0, y: 0, z: 0, w: 1 }\n }\n\n /** Create a quaternion from an axis and angle (radians). */\n fromAxisAngle(axis: PVec3, angle: number): PQuat {\n const halfAngle = angle / 2\n const s = Math.sin(halfAngle)\n const len = Math.sqrt(axis.x * axis.x + axis.y * axis.y + axis.z * axis.z)\n if (len === 0) return { x: 0, y: 0, z: 0, w: 1 }\n return {\n x: (axis.x / len) * s,\n y: (axis.y / len) * s,\n z: (axis.z / len) * s,\n w: Math.cos(halfAngle),\n }\n }\n\n /** Create a quaternion from Euler angles (radians, XYZ order). */\n fromEuler(x: number, y: number, z: number): PQuat {\n const cx = Math.cos(x / 2)\n const sx = Math.sin(x / 2)\n const cy = Math.cos(y / 2)\n const sy = Math.sin(y / 2)\n const cz = Math.cos(z / 2)\n const sz = Math.sin(z / 2)\n return {\n x: sx * cy * cz + cx * sy * sz,\n y: cx * sy * cz - sx * cy * sz,\n z: cx * cy * sz + sx * sy * cz,\n w: cx * cy * cz - sx * sy * sz,\n }\n }\n\n /** Multiply two quaternions (a * b). */\n multiply(a: PQuat, b: PQuat): PQuat {\n return {\n x: a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y,\n y: a.w * b.y - a.x * b.z + a.y * b.w + a.z * b.x,\n z: a.w * b.z + a.x * b.y - a.y * b.x + a.z * b.w,\n w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z,\n }\n }\n\n /** Conjugate of a quaternion. */\n conjugate(q: PQuat): PQuat {\n return { x: -q.x, y: -q.y, z: -q.z, w: q.w }\n }\n\n /** Length (magnitude) of a quaternion. */\n length(q: PQuat): number {\n return Math.sqrt(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w)\n }\n\n /** Normalize a quaternion to unit length. Returns identity if length is 0. */\n normalize(q: PQuat): PQuat {\n const len = this.length(q)\n if (len === 0) return { x: 0, y: 0, z: 0, w: 1 }\n return { x: q.x / len, y: q.y / len, z: q.z / len, w: q.w / len }\n }\n\n /** Inverse of a quaternion (conjugate / lengthSquared). */\n inverse(q: PQuat): PQuat {\n const lenSq = q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w\n if (lenSq === 0) return { x: 0, y: 0, z: 0, w: 1 }\n return { x: -q.x / lenSq, y: -q.y / lenSq, z: -q.z / lenSq, w: q.w / lenSq }\n }\n\n /** Rotate a vector by a quaternion. */\n rotateVec3(q: PQuat, v: PVec3): PVec3 {\n const vq: PQuat = { x: v.x, y: v.y, z: v.z, w: 0 }\n const conj = this.conjugate(q)\n const result = this.multiply(this.multiply(q, vq), conj)\n return { x: result.x, y: result.y, z: result.z }\n }\n\n /** Convert a quaternion to axis-angle representation. */\n toAxisAngle(q: PQuat): { axis: PVec3; angle: number } {\n const nq = this.normalize(q)\n const angle = 2 * Math.acos(Math.min(1, Math.max(-1, nq.w)))\n const s = Math.sin(angle / 2)\n if (s < 1e-6) {\n return { axis: { x: 1, y: 0, z: 0 }, angle: 0 }\n }\n return {\n axis: { x: nq.x / s, y: nq.y / s, z: nq.z / s },\n angle,\n }\n }\n\n /** Spherical linear interpolation between two quaternions. */\n slerp(a: PQuat, b: PQuat, t: number): PQuat {\n let cosHalf = a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w\n let bx = b.x, by = b.y, bz = b.z, bw = b.w\n if (cosHalf < 0) {\n cosHalf = -cosHalf\n bx = -bx; by = -by; bz = -bz; bw = -bw\n }\n if (cosHalf >= 1.0) {\n return { x: a.x, y: a.y, z: a.z, w: a.w }\n }\n const halfAngle = Math.acos(cosHalf)\n const sinHalf = Math.sin(halfAngle)\n const ratioA = Math.sin((1 - t) * halfAngle) / sinHalf\n const ratioB = Math.sin(t * halfAngle) / sinHalf\n return {\n x: a.x * ratioA + bx * ratioB,\n y: a.y * ratioA + by * ratioB,\n z: a.z * ratioA + bz * ratioB,\n w: a.w * ratioA + bw * ratioB,\n }\n }\n\n /** Dot product of two quaternions. */\n dot(a: PQuat, b: PQuat): number {\n return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w\n }\n\n /** Check if two quaternions are equal (exact). */\n equals(a: PQuat, b: PQuat): boolean {\n return a.x === b.x && a.y === b.y && a.z === b.z && a.w === b.w\n }\n\n /** Check if two quaternions are approximately equal within an epsilon. */\n equalsApprox(a: PQuat, b: PQuat, epsilon: number = 1e-6): boolean {\n return (\n Math.abs(a.x - b.x) < epsilon &&\n Math.abs(a.y - b.y) < epsilon &&\n Math.abs(a.z - b.z) < epsilon &&\n Math.abs(a.w - b.w) < epsilon\n )\n }\n}\n\nexport const PQuat = z.object({\n x: z.number(),\n y: z.number(),\n z: z.number(),\n w: z.number(),\n})\n\nexport type PQuat = z.infer<typeof PQuat>\n","import { PluginVec3Api } from \"./vec3\"\nimport { PluginQuatApi } from \"./quat\"\n\nexport abstract class PluginMathApi {\n public abstract vec3: PluginVec3Api\n public abstract quat: PluginQuatApi\n\n constructor() {}\n}\n\nexport * from \"./vec3\"\nexport * from \"./quat\"\n","import * as z from \"zod\"\nimport { PVec3 } from \"../math/vec3\"\n\nexport abstract class PluginLineApi {\n constructor() {}\n\n /** Create a new PLine from start and end points. */\n new(startPoint: PVec3, endPoint: PVec3): PLine {\n return { curveType: \"Line\", startPoint, endPoint }\n }\n}\n\nexport const PLine = z.object({\n curveType: z.literal(\"Line\"),\n startPoint: PVec3,\n endPoint: PVec3,\n})\n\nexport type PLine = z.infer<typeof PLine>\n","import * as z from \"zod\"\nimport { PVec3 } from \"../math/vec3\"\n\nexport abstract class PluginArcApi {\n constructor() {}\n\n /** Create a new PArc from start, end, centre and axis. */\n new(startPoint: PVec3, endPoint: PVec3, centrePoint: PVec3, axis: PVec3): PArc {\n return { curveType: \"Arc\", startPoint, endPoint, centrePoint, axis }\n }\n}\n\nexport const PArc = z.object({\n curveType: z.literal(\"Arc\"),\n startPoint: PVec3,\n endPoint: PVec3,\n centrePoint: PVec3,\n axis: PVec3,\n})\n\nexport type PArc = z.infer<typeof PArc>\n","import * as z from \"zod\"\nimport { PLine } from \"./line\"\nimport { PArc } from \"./arc\"\n\nexport abstract class PluginCurveApi {\n constructor() {}\n\n /** Create a PCurve from a PLine or PArc. */\n new(curve: PLine | PArc): PCurve {\n return curve\n }\n}\n\nexport const PCurve = z.discriminatedUnion(\"curveType\", [PLine, PArc])\n\nexport type PCurve = z.infer<typeof PCurve>\n","import * as z from \"zod\"\nimport { PluginApiReturn } from \"../../../types\"\nimport { PVec3 } from \"../math/vec3\"\nimport { PCurve } from \"./curve\"\n\nexport abstract class PluginProfileApi {\n constructor() {}\n\n /** Create a new PProfile from an array of PCurves. */\n new(curves: PCurve[]): PProfile {\n return { curves }\n }\n\n /** Create a PProfile from an array of points, connecting them with lines. */\n public abstract fromLinePoints(\n args: PluginProfileFromLinePointsArgs\n ): PluginApiReturn<PProfile>\n}\n\nexport const PluginProfileFromLinePointsArgs = z.object({\n points: z.array(PVec3),\n})\n\nexport type PluginProfileFromLinePointsArgs = z.infer<typeof PluginProfileFromLinePointsArgs>\n\nexport const PProfile = z.object({\n curves: z.array(PCurve),\n})\n\nexport type PProfile = z.infer<typeof PProfile>\n","import { PluginLineApi } from \"./line\"\nimport { PluginArcApi } from \"./arc\"\nimport { PluginCurveApi } from \"./curve\"\nimport { PluginProfileApi } from \"./profile\"\n\nexport abstract class PluginGeomApi {\n public abstract line: PluginLineApi\n public abstract arc: PluginArcApi\n public abstract curve: PluginCurveApi\n public abstract profile: PluginProfileApi\n\n constructor() {}\n}\n\nexport * from \"./line\"\nexport * from \"./arc\"\nexport * from \"./curve\"\nexport * from \"./profile\"\n","import { PluginMathApi } from \"./math\"\nimport { PluginGeomApi } from \"./geom\"\n\nexport abstract class PluginCoreApi {\n public abstract math: PluginMathApi\n public abstract geom: PluginGeomApi\n\n constructor() {}\n}\n\nexport * from \"./math\"\nexport * from \"./geom\"\n","import * as z from \"zod\"\nimport { PluginApiReturn } from \"../../types\"\nimport { PVec3 } from \"../core/math/vec3\"\nimport { PQuat } from \"../core/math/quat\"\nimport { PProfile } from \"../core/geom/profile\"\n\nexport abstract class PluginSpaceApi {\n constructor() {}\n\n public abstract createRectangular({\n position,\n dimensions,\n }: PluginSpaceCreateRectangularArgs): PluginApiReturn<PluginSpaceCreateRectangularResult>\n\n public abstract createFromProfile({\n profile,\n extrudeHeight,\n position,\n }: PluginSpaceCreateFromProfileArgs): PluginApiReturn<PluginSpaceCreateFromProfileResult>\n\n public abstract getAll(): PluginApiReturn<PluginSpaceGetAllResult>\n\n public abstract get({\n spaceId,\n properties,\n }: PluginSpaceGetArgs): PluginApiReturn<PluginSpaceGetResult>\n\n public abstract deleteById({\n spaceId,\n }: PluginSpaceDeleteByIdArgs): PluginApiReturn<PluginSpaceDeleteByIdResult>\n}\n\nexport const PluginSpaceCreateRectangularArgs = z.object({\n position: PVec3,\n dimensions: z.object({\n width: z.number(),\n height: z.number(),\n depth: z.number(),\n }),\n})\n\nexport type PluginSpaceCreateRectangularArgs = z.infer<typeof PluginSpaceCreateRectangularArgs>\n\nexport const PluginSpaceCreateRectangularResult = z.object({\n spaceId: z.string(),\n})\n\nexport type PluginSpaceCreateRectangularResult = z.infer<typeof PluginSpaceCreateRectangularResult>\n\nexport const PluginSpaceCreateFromProfileArgs = z.object({\n profile: PProfile,\n extrudeHeight: z.number(),\n position: PVec3,\n})\n\nexport type PluginSpaceCreateFromProfileArgs = z.infer<typeof PluginSpaceCreateFromProfileArgs>\n\nexport const PluginSpaceCreateFromProfileResult = z.object({\n spaceId: z.string(),\n})\n\nexport type PluginSpaceCreateFromProfileResult = z.infer<typeof PluginSpaceCreateFromProfileResult>\n\nexport const PluginSpaceGetProperty = z.enum([\n \"id\",\n \"type\",\n \"room_type\",\n \"name\",\n \"area\",\n \"department\",\n \"position\",\n \"absolutePosition\",\n \"rotation\",\n \"rotationQuaternion\",\n])\n\nexport const PluginSpaceGetArgs = z.object({\n spaceId: z.string(),\n properties: z.array(PluginSpaceGetProperty),\n})\n\nexport type PluginSpaceGetArgs = z.infer<typeof PluginSpaceGetArgs>\n\nexport const PluginSpaceGetResult = z\n .object({\n id: z.string(),\n type: z.string(),\n room_type: z.string(),\n name: z.string(),\n area: z.number(),\n department: z.string(),\n position: PVec3,\n absolutePosition: PVec3,\n rotation: PVec3,\n rotationQuaternion: PQuat.nullable(),\n })\n .partial()\n\nexport type PluginSpaceGetResult = z.infer<typeof PluginSpaceGetResult>\n\nexport const PluginSpaceGetAllResult = z.object({\n spacesIds: z.array(z.string()),\n})\n\nexport type PluginSpaceGetAllResult = z.infer<typeof PluginSpaceGetAllResult>\n\nexport const PluginSpaceDeleteByIdArgs = z.object({\n spaceId: z.string(),\n})\n\nexport type PluginSpaceDeleteByIdArgs = z.infer<typeof PluginSpaceDeleteByIdArgs>\n\nexport type PluginSpaceDeleteByIdResult = void\n","import * as z from \"zod\"\nimport { PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginStoryApi {\n constructor() {}\n\n public abstract get({\n storyValue,\n properties,\n }: PluginStoryGetArgs): PluginApiReturn<PluginStoryGetResult>\n\n public abstract getAll(): PluginApiReturn<PluginStoryGetAllResult>\n\n public abstract create({\n storyValue,\n height,\n }: PluginStoryCreateArgs): PluginApiReturn<PluginStoryCreateResult>\n\n public abstract update({\n storyValue,\n height,\n }: PluginStoryUpdateArgs): PluginApiReturn<PluginStoryUpdateResult>\n}\n\nexport const PluginStoryGetProperty = z.enum([\n \"value\",\n \"id\",\n \"name\",\n \"height\",\n \"base\",\n \"hidden\",\n \"spacesCount\",\n \"totalArea\",\n])\n\nexport const PluginStoryGetArgs = z.object({\n storyValue: z.number().int(),\n properties: z.array(PluginStoryGetProperty),\n})\n\nexport type PluginStoryGetArgs = z.infer<typeof PluginStoryGetArgs>\n\nexport const PluginStoryGetResult = z\n .object({\n value: z.number(),\n id: z.string(),\n name: z.string(),\n height: z.number(),\n base: z.number(),\n hidden: z.boolean(),\n spacesCount: z.number(),\n totalArea: z.number(),\n })\n .partial()\n\nexport type PluginStoryGetResult = z.infer<typeof PluginStoryGetResult>\n\nexport const PluginStoryGetAllResult = z.object({\n stories: z.array(\n z.object({\n value: z.number(),\n id: z.string(),\n name: z.string(),\n })\n ),\n})\n\nexport type PluginStoryGetAllResult = z.infer<typeof PluginStoryGetAllResult>\n\nexport const PluginStoryCreateArgs = z.object({\n storyValue: z.number().int(),\n height: z.number().optional(),\n})\n\nexport type PluginStoryCreateArgs = z.infer<typeof PluginStoryCreateArgs>\n\nexport const PluginStoryCreateResult = z.object({\n storyId: z.string(),\n storyValue: z.number(),\n})\n\nexport type PluginStoryCreateResult = z.infer<typeof PluginStoryCreateResult>\n\nexport const PluginStoryUpdateArgs = z.object({\n storyValue: z.number().int(),\n height: z.number(),\n})\n\nexport type PluginStoryUpdateArgs = z.infer<typeof PluginStoryUpdateArgs>\n\nexport const PluginStoryUpdateResult = z.object({\n storyValue: z.number(),\n height: z.number(),\n})\n\nexport type PluginStoryUpdateResult = z.infer<typeof PluginStoryUpdateResult>\n","import { PluginSpaceApi } from \"./space\"\nimport { PluginStoryApi } from \"./story\"\n\nexport abstract class PluginEntityApi {\n public abstract space: PluginSpaceApi\n public abstract story: PluginStoryApi\n\n constructor() {}\n}\n\nexport * from \"./space\"\nexport * from \"./story\"\n","import * as z from \"zod\"\nimport { PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginSelectionApi {\n constructor() {}\n\n public abstract get(): PluginApiReturn<PluginSelectionGetResult>\n}\n\nexport const PluginSelectionGetResult = z.object({\n selected: z.array(z.string()),\n})\n\nexport type PluginSelectionGetResult = z.infer<typeof PluginSelectionGetResult>\n","import * as z from \"zod\"\nimport { PluginApiReturn } from \"../../types\"\nimport { PVec3 } from \"../core/math/vec3\"\n\nexport abstract class PluginTransformApi {\n constructor() {}\n\n public abstract move({\n componentIds,\n displacement,\n }: PluginMoveArgs): PluginApiReturn<void>\n\n public abstract rotate({\n componentIds,\n angle,\n axis,\n pivot,\n }: PluginRotateArgs): PluginApiReturn<void>\n}\n\nexport const PluginMoveArgs = z.object({\n componentIds: z.array(z.string()),\n displacement: PVec3,\n})\n\nexport type PluginMoveArgs = z.infer<typeof PluginMoveArgs>\n\nexport const PluginRotateArgs = z.object({\n componentIds: z.array(z.string()),\n angle: z.number(),\n axis: PVec3,\n pivot: PVec3,\n})\n\nexport type PluginRotateArgs = z.infer<typeof PluginRotateArgs>\n","import { PluginSelectionApi } from \"./selection\"\nimport { PluginTransformApi } from \"./transform\"\n\nexport abstract class PluginToolsApi {\n public abstract selection: PluginSelectionApi\n public abstract transform: PluginTransformApi\n\n constructor() {}\n}\n\nexport * from \"./selection\"\nexport * from \"./transform\"\n","import * as z from \"zod\"\nimport { PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginUnitsApi {\n constructor() {}\n\n /**\n * Convert a value from the given unit to Snaptrude's internal (Babylon) units.\n *\n * Use this when you have a measurement in real-world units (e.g. meters, feet)\n * and need to convert it to the coordinate system used by Snaptrude internally.\n *\n * @param args.unit - The source unit to convert from (e.g. `\"meters\"`, `\"feet-inches\"`)\n * @param args.value - The numeric value in the source unit\n * @returns An object containing the converted `value` in Snaptrude/Babylon units\n *\n * @example\n * ```ts\n * const result = await snaptrude.units.convertFrom({ unit: \"meters\", value: 5 })\n * // result.value is 5 meters expressed in Babylon units\n * ```\n */\n public abstract convertFrom(\n args: PluginUnitsConvertFromArgs,\n ): PluginApiReturn<PluginUnitsConvertFromResult>\n\n /**\n * Convert a value from Snaptrude's internal (Babylon) units to the given unit.\n *\n * Use this when you have a value in Snaptrude's internal coordinate system\n * and need to express it in real-world units (e.g. meters, feet).\n *\n * @param args.unit - The target unit to convert to (e.g. `\"meters\"`, `\"feet-inches\"`)\n * @param args.value - The numeric value in Snaptrude/Babylon units\n * @returns An object containing the converted `value` in the target unit\n *\n * @example\n * ```ts\n * const result = await snaptrude.units.convertTo({ unit: \"feet-inches\", value: 1.2 })\n * // result.value is 1.2 Babylon units expressed in feet\n * ```\n */\n public abstract convertTo(\n args: PluginUnitsConvertToArgs,\n ): PluginApiReturn<PluginUnitsConvertToResult>\n}\n\n/**\n * Supported unit types for conversion.\n *\n * - `meters` — Metric meters\n * - `feet-inches` — Imperial feet (1 foot = 12 inches)\n * - `inches` — Imperial inches\n * - `centimeters` — Metric centimeters\n * - `millimeters` — Metric millimeters\n * - `kilometers` — Metric kilometers\n * - `miles` — Imperial miles\n */\nexport const PUnitType = z.enum([\n \"meters\",\n \"feet-inches\",\n \"inches\",\n \"centimeters\",\n \"millimeters\",\n \"kilometers\",\n \"miles\",\n])\n\nexport type PUnitType = z.infer<typeof PUnitType>\n\nexport const PluginUnitsConvertFromArgs = z.object({\n unit: PUnitType,\n value: z.number(),\n})\n\nexport type PluginUnitsConvertFromArgs = z.infer<typeof PluginUnitsConvertFromArgs>\n\nexport const PluginUnitsConvertFromResult = z.object({\n value: z.number(),\n})\n\nexport type PluginUnitsConvertFromResult = z.infer<typeof PluginUnitsConvertFromResult>\n\nexport const PluginUnitsConvertToArgs = z.object({\n unit: PUnitType,\n value: z.number(),\n})\n\nexport type PluginUnitsConvertToArgs = z.infer<typeof PluginUnitsConvertToArgs>\n\nexport const PluginUnitsConvertToResult = z.object({\n value: z.number(),\n})\n\nexport type PluginUnitsConvertToResult = z.infer<typeof PluginUnitsConvertToResult>\n","import { PluginCoreApi } from \"./core\"\nimport { PluginEntityApi } from \"./entity\"\nimport { PluginToolsApi } from \"./tools\"\nimport { PluginUnitsApi } from \"./units\"\n\nexport abstract class PluginApi {\n public abstract core: PluginCoreApi\n public abstract tools: PluginToolsApi\n public abstract entity: PluginEntityApi\n public abstract units: PluginUnitsApi\n\n constructor() {}\n}\n\nexport * from \"./core\"\nexport * from \"./entity\"\nexport * from \"./tools\"\nexport * from \"./units\"\n"],"mappings":";AAAA,YAAY,OAAO;AAEZ,IAAe,gBAAf,MAA6B;AAAA,EAClC,cAAc;AAAA,EAAC;AAAA;AAAA,EAGf,IAAI,GAAW,GAAWA,KAAkB;AAC1C,WAAO,EAAE,GAAG,GAAG,GAAAA,IAAE;AAAA,EACnB;AAAA;AAAA,EAGA,IAAI,GAAU,GAAiB;AAC7B,WAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,EAAE;AAAA,EACpD;AAAA;AAAA,EAGA,SAAS,GAAU,GAAiB;AAClC,WAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,GAA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O,CAAC;AAAA,EAChC,cAAc;AAChB,CAAC;AAIM,IAAM,mBAAqB,WAAO;AAAA,EACvC,cAAgB,UAAQ,WAAO,CAAC;AAAA,EAChC,OAAS,WAAO;AAAA,EAChB,MAAM;AAAA,EACN,OAAO;AACT,CAAC;;;AC7BM,IAAe,iBAAf,MAA8B;AAAA,EAInC,cAAc;AAAA,EAAC;AACjB;;;ACRA,YAAYC,SAAO;AAGZ,IAAe,iBAAf,MAA8B;AAAA,EACnC,cAAc;AAAA,EAAC;AAyCjB;AAaO,IAAM,YAAc,SAAK;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAIM,IAAM,6BAA+B,WAAO;AAAA,EACjD,MAAM;AAAA,EACN,OAAS,WAAO;AAClB,CAAC;AAIM,IAAM,+BAAiC,WAAO;AAAA,EACnD,OAAS,WAAO;AAClB,CAAC;AAIM,IAAM,2BAA6B,WAAO;AAAA,EAC/C,MAAM;AAAA,EACN,OAAS,WAAO;AAClB,CAAC;AAIM,IAAM,6BAA+B,WAAO;AAAA,EACjD,OAAS,WAAO;AAClB,CAAC;;;ACvFM,IAAe,YAAf,MAAyB;AAAA,EAM9B,cAAc;AAAA,EAAC;AACjB;","names":["z","z","z","z","z","z","z","z","z","z","z"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snaptrude/plugin-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -20,6 +20,12 @@
|
|
|
20
20
|
"tsup": "^8.5.1",
|
|
21
21
|
"typescript": "^5.5.4"
|
|
22
22
|
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"zod": "^4.3.6"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"zod": "^3.25.0 || ^4.0.0"
|
|
28
|
+
},
|
|
23
29
|
"scripts": {
|
|
24
30
|
"check-types": "tsc --noEmit",
|
|
25
31
|
"build": "tsup",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PVec3 } from "../math/vec3"
|
|
3
|
+
|
|
4
|
+
export abstract class PluginArcApi {
|
|
5
|
+
constructor() {}
|
|
6
|
+
|
|
7
|
+
/** Create a new PArc from start, end, centre and axis. */
|
|
8
|
+
new(startPoint: PVec3, endPoint: PVec3, centrePoint: PVec3, axis: PVec3): PArc {
|
|
9
|
+
return { curveType: "Arc", startPoint, endPoint, centrePoint, axis }
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const PArc = z.object({
|
|
14
|
+
curveType: z.literal("Arc"),
|
|
15
|
+
startPoint: PVec3,
|
|
16
|
+
endPoint: PVec3,
|
|
17
|
+
centrePoint: PVec3,
|
|
18
|
+
axis: PVec3,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export type PArc = z.infer<typeof PArc>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PLine } from "./line"
|
|
3
|
+
import { PArc } from "./arc"
|
|
4
|
+
|
|
5
|
+
export abstract class PluginCurveApi {
|
|
6
|
+
constructor() {}
|
|
7
|
+
|
|
8
|
+
/** Create a PCurve from a PLine or PArc. */
|
|
9
|
+
new(curve: PLine | PArc): PCurve {
|
|
10
|
+
return curve
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const PCurve = z.discriminatedUnion("curveType", [PLine, PArc])
|
|
15
|
+
|
|
16
|
+
export type PCurve = z.infer<typeof PCurve>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PluginLineApi } from "./line"
|
|
2
|
+
import { PluginArcApi } from "./arc"
|
|
3
|
+
import { PluginCurveApi } from "./curve"
|
|
4
|
+
import { PluginProfileApi } from "./profile"
|
|
5
|
+
|
|
6
|
+
export abstract class PluginGeomApi {
|
|
7
|
+
public abstract line: PluginLineApi
|
|
8
|
+
public abstract arc: PluginArcApi
|
|
9
|
+
public abstract curve: PluginCurveApi
|
|
10
|
+
public abstract profile: PluginProfileApi
|
|
11
|
+
|
|
12
|
+
constructor() {}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export * from "./line"
|
|
16
|
+
export * from "./arc"
|
|
17
|
+
export * from "./curve"
|
|
18
|
+
export * from "./profile"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PVec3 } from "../math/vec3"
|
|
3
|
+
|
|
4
|
+
export abstract class PluginLineApi {
|
|
5
|
+
constructor() {}
|
|
6
|
+
|
|
7
|
+
/** Create a new PLine from start and end points. */
|
|
8
|
+
new(startPoint: PVec3, endPoint: PVec3): PLine {
|
|
9
|
+
return { curveType: "Line", startPoint, endPoint }
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const PLine = z.object({
|
|
14
|
+
curveType: z.literal("Line"),
|
|
15
|
+
startPoint: PVec3,
|
|
16
|
+
endPoint: PVec3,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
export type PLine = z.infer<typeof PLine>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../../types"
|
|
3
|
+
import { PVec3 } from "../math/vec3"
|
|
4
|
+
import { PCurve } from "./curve"
|
|
5
|
+
|
|
6
|
+
export abstract class PluginProfileApi {
|
|
7
|
+
constructor() {}
|
|
8
|
+
|
|
9
|
+
/** Create a new PProfile from an array of PCurves. */
|
|
10
|
+
new(curves: PCurve[]): PProfile {
|
|
11
|
+
return { curves }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Create a PProfile from an array of points, connecting them with lines. */
|
|
15
|
+
public abstract fromLinePoints(
|
|
16
|
+
args: PluginProfileFromLinePointsArgs
|
|
17
|
+
): PluginApiReturn<PProfile>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const PluginProfileFromLinePointsArgs = z.object({
|
|
21
|
+
points: z.array(PVec3),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export type PluginProfileFromLinePointsArgs = z.infer<typeof PluginProfileFromLinePointsArgs>
|
|
25
|
+
|
|
26
|
+
export const PProfile = z.object({
|
|
27
|
+
curves: z.array(PCurve),
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
export type PProfile = z.infer<typeof PProfile>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PluginMathApi } from "./math"
|
|
2
|
+
import { PluginGeomApi } from "./geom"
|
|
3
|
+
|
|
4
|
+
export abstract class PluginCoreApi {
|
|
5
|
+
public abstract math: PluginMathApi
|
|
6
|
+
public abstract geom: PluginGeomApi
|
|
7
|
+
|
|
8
|
+
constructor() {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export * from "./math"
|
|
12
|
+
export * from "./geom"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PluginVec3Api } from "./vec3"
|
|
2
|
+
import { PluginQuatApi } from "./quat"
|
|
3
|
+
|
|
4
|
+
export abstract class PluginMathApi {
|
|
5
|
+
public abstract vec3: PluginVec3Api
|
|
6
|
+
public abstract quat: PluginQuatApi
|
|
7
|
+
|
|
8
|
+
constructor() {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export * from "./vec3"
|
|
12
|
+
export * from "./quat"
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import type { PVec3 } from "./vec3"
|
|
3
|
+
|
|
4
|
+
export abstract class PluginQuatApi {
|
|
5
|
+
constructor() {}
|
|
6
|
+
|
|
7
|
+
/** Create a new PQuat. */
|
|
8
|
+
new(x: number, y: number, z: number, w: number): PQuat {
|
|
9
|
+
return { x, y, z, w }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Create an identity quaternion (no rotation). */
|
|
13
|
+
identity(): PQuat {
|
|
14
|
+
return { x: 0, y: 0, z: 0, w: 1 }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Create a quaternion from an axis and angle (radians). */
|
|
18
|
+
fromAxisAngle(axis: PVec3, angle: number): PQuat {
|
|
19
|
+
const halfAngle = angle / 2
|
|
20
|
+
const s = Math.sin(halfAngle)
|
|
21
|
+
const len = Math.sqrt(axis.x * axis.x + axis.y * axis.y + axis.z * axis.z)
|
|
22
|
+
if (len === 0) return { x: 0, y: 0, z: 0, w: 1 }
|
|
23
|
+
return {
|
|
24
|
+
x: (axis.x / len) * s,
|
|
25
|
+
y: (axis.y / len) * s,
|
|
26
|
+
z: (axis.z / len) * s,
|
|
27
|
+
w: Math.cos(halfAngle),
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Create a quaternion from Euler angles (radians, XYZ order). */
|
|
32
|
+
fromEuler(x: number, y: number, z: number): PQuat {
|
|
33
|
+
const cx = Math.cos(x / 2)
|
|
34
|
+
const sx = Math.sin(x / 2)
|
|
35
|
+
const cy = Math.cos(y / 2)
|
|
36
|
+
const sy = Math.sin(y / 2)
|
|
37
|
+
const cz = Math.cos(z / 2)
|
|
38
|
+
const sz = Math.sin(z / 2)
|
|
39
|
+
return {
|
|
40
|
+
x: sx * cy * cz + cx * sy * sz,
|
|
41
|
+
y: cx * sy * cz - sx * cy * sz,
|
|
42
|
+
z: cx * cy * sz + sx * sy * cz,
|
|
43
|
+
w: cx * cy * cz - sx * sy * sz,
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Multiply two quaternions (a * b). */
|
|
48
|
+
multiply(a: PQuat, b: PQuat): PQuat {
|
|
49
|
+
return {
|
|
50
|
+
x: a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y,
|
|
51
|
+
y: a.w * b.y - a.x * b.z + a.y * b.w + a.z * b.x,
|
|
52
|
+
z: a.w * b.z + a.x * b.y - a.y * b.x + a.z * b.w,
|
|
53
|
+
w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z,
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Conjugate of a quaternion. */
|
|
58
|
+
conjugate(q: PQuat): PQuat {
|
|
59
|
+
return { x: -q.x, y: -q.y, z: -q.z, w: q.w }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Length (magnitude) of a quaternion. */
|
|
63
|
+
length(q: PQuat): number {
|
|
64
|
+
return Math.sqrt(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Normalize a quaternion to unit length. Returns identity if length is 0. */
|
|
68
|
+
normalize(q: PQuat): PQuat {
|
|
69
|
+
const len = this.length(q)
|
|
70
|
+
if (len === 0) return { x: 0, y: 0, z: 0, w: 1 }
|
|
71
|
+
return { x: q.x / len, y: q.y / len, z: q.z / len, w: q.w / len }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Inverse of a quaternion (conjugate / lengthSquared). */
|
|
75
|
+
inverse(q: PQuat): PQuat {
|
|
76
|
+
const lenSq = q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w
|
|
77
|
+
if (lenSq === 0) return { x: 0, y: 0, z: 0, w: 1 }
|
|
78
|
+
return { x: -q.x / lenSq, y: -q.y / lenSq, z: -q.z / lenSq, w: q.w / lenSq }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Rotate a vector by a quaternion. */
|
|
82
|
+
rotateVec3(q: PQuat, v: PVec3): PVec3 {
|
|
83
|
+
const vq: PQuat = { x: v.x, y: v.y, z: v.z, w: 0 }
|
|
84
|
+
const conj = this.conjugate(q)
|
|
85
|
+
const result = this.multiply(this.multiply(q, vq), conj)
|
|
86
|
+
return { x: result.x, y: result.y, z: result.z }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Convert a quaternion to axis-angle representation. */
|
|
90
|
+
toAxisAngle(q: PQuat): { axis: PVec3; angle: number } {
|
|
91
|
+
const nq = this.normalize(q)
|
|
92
|
+
const angle = 2 * Math.acos(Math.min(1, Math.max(-1, nq.w)))
|
|
93
|
+
const s = Math.sin(angle / 2)
|
|
94
|
+
if (s < 1e-6) {
|
|
95
|
+
return { axis: { x: 1, y: 0, z: 0 }, angle: 0 }
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
axis: { x: nq.x / s, y: nq.y / s, z: nq.z / s },
|
|
99
|
+
angle,
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Spherical linear interpolation between two quaternions. */
|
|
104
|
+
slerp(a: PQuat, b: PQuat, t: number): PQuat {
|
|
105
|
+
let cosHalf = a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w
|
|
106
|
+
let bx = b.x, by = b.y, bz = b.z, bw = b.w
|
|
107
|
+
if (cosHalf < 0) {
|
|
108
|
+
cosHalf = -cosHalf
|
|
109
|
+
bx = -bx; by = -by; bz = -bz; bw = -bw
|
|
110
|
+
}
|
|
111
|
+
if (cosHalf >= 1.0) {
|
|
112
|
+
return { x: a.x, y: a.y, z: a.z, w: a.w }
|
|
113
|
+
}
|
|
114
|
+
const halfAngle = Math.acos(cosHalf)
|
|
115
|
+
const sinHalf = Math.sin(halfAngle)
|
|
116
|
+
const ratioA = Math.sin((1 - t) * halfAngle) / sinHalf
|
|
117
|
+
const ratioB = Math.sin(t * halfAngle) / sinHalf
|
|
118
|
+
return {
|
|
119
|
+
x: a.x * ratioA + bx * ratioB,
|
|
120
|
+
y: a.y * ratioA + by * ratioB,
|
|
121
|
+
z: a.z * ratioA + bz * ratioB,
|
|
122
|
+
w: a.w * ratioA + bw * ratioB,
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Dot product of two quaternions. */
|
|
127
|
+
dot(a: PQuat, b: PQuat): number {
|
|
128
|
+
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Check if two quaternions are equal (exact). */
|
|
132
|
+
equals(a: PQuat, b: PQuat): boolean {
|
|
133
|
+
return a.x === b.x && a.y === b.y && a.z === b.z && a.w === b.w
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Check if two quaternions are approximately equal within an epsilon. */
|
|
137
|
+
equalsApprox(a: PQuat, b: PQuat, epsilon: number = 1e-6): boolean {
|
|
138
|
+
return (
|
|
139
|
+
Math.abs(a.x - b.x) < epsilon &&
|
|
140
|
+
Math.abs(a.y - b.y) < epsilon &&
|
|
141
|
+
Math.abs(a.z - b.z) < epsilon &&
|
|
142
|
+
Math.abs(a.w - b.w) < epsilon
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export const PQuat = z.object({
|
|
148
|
+
x: z.number(),
|
|
149
|
+
y: z.number(),
|
|
150
|
+
z: z.number(),
|
|
151
|
+
w: z.number(),
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
export type PQuat = z.infer<typeof PQuat>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
|
|
3
|
+
export abstract class PluginVec3Api {
|
|
4
|
+
constructor() {}
|
|
5
|
+
|
|
6
|
+
/** Create a new PVec3. */
|
|
7
|
+
new(x: number, y: number, z: number): PVec3 {
|
|
8
|
+
return { x, y, z }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Add two vectors. */
|
|
12
|
+
add(a: PVec3, b: PVec3): PVec3 {
|
|
13
|
+
return { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Subtract b from a. */
|
|
17
|
+
subtract(a: PVec3, b: PVec3): PVec3 {
|
|
18
|
+
return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Scale a vector by a scalar. */
|
|
22
|
+
scale(v: PVec3, scalar: number): PVec3 {
|
|
23
|
+
return { x: v.x * scalar, y: v.y * scalar, z: v.z * scalar }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Dot product of two vectors. */
|
|
27
|
+
dot(a: PVec3, b: PVec3): number {
|
|
28
|
+
return a.x * b.x + a.y * b.y + a.z * b.z
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Cross product of two vectors. */
|
|
32
|
+
cross(a: PVec3, b: PVec3): PVec3 {
|
|
33
|
+
return {
|
|
34
|
+
x: a.y * b.z - a.z * b.y,
|
|
35
|
+
y: a.z * b.x - a.x * b.z,
|
|
36
|
+
z: a.x * b.y - a.y * b.x,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Length (magnitude) of a vector. */
|
|
41
|
+
length(v: PVec3): number {
|
|
42
|
+
return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Squared length of a vector (avoids sqrt). */
|
|
46
|
+
lengthSquared(v: PVec3): number {
|
|
47
|
+
return v.x * v.x + v.y * v.y + v.z * v.z
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Normalize a vector to unit length. Returns zero vector if length is 0. */
|
|
51
|
+
normalize(v: PVec3): PVec3 {
|
|
52
|
+
const len = this.length(v)
|
|
53
|
+
if (len === 0) return { x: 0, y: 0, z: 0 }
|
|
54
|
+
return { x: v.x / len, y: v.y / len, z: v.z / len }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Distance between two points. */
|
|
58
|
+
distance(a: PVec3, b: PVec3): number {
|
|
59
|
+
return this.length(this.subtract(a, b))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Linearly interpolate between two vectors. */
|
|
63
|
+
lerp(a: PVec3, b: PVec3, t: number): PVec3 {
|
|
64
|
+
return {
|
|
65
|
+
x: a.x + (b.x - a.x) * t,
|
|
66
|
+
y: a.y + (b.y - a.y) * t,
|
|
67
|
+
z: a.z + (b.z - a.z) * t,
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Negate a vector. */
|
|
72
|
+
negate(v: PVec3): PVec3 {
|
|
73
|
+
return { x: -v.x, y: -v.y, z: -v.z }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Check if two vectors are equal (exact). */
|
|
77
|
+
equals(a: PVec3, b: PVec3): boolean {
|
|
78
|
+
return a.x === b.x && a.y === b.y && a.z === b.z
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Check if two vectors are approximately equal within an epsilon. */
|
|
82
|
+
equalsApprox(a: PVec3, b: PVec3, epsilon: number = 1e-6): boolean {
|
|
83
|
+
return (
|
|
84
|
+
Math.abs(a.x - b.x) < epsilon &&
|
|
85
|
+
Math.abs(a.y - b.y) < epsilon &&
|
|
86
|
+
Math.abs(a.z - b.z) < epsilon
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const PVec3 = z.object({
|
|
92
|
+
x: z.number(),
|
|
93
|
+
y: z.number(),
|
|
94
|
+
z: z.number(),
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
export type PVec3 = z.infer<typeof PVec3>
|
package/src/api/entity/index.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { PluginSpaceApi } from "./space"
|
|
2
|
+
import { PluginStoryApi } from "./story"
|
|
2
3
|
|
|
3
4
|
export abstract class PluginEntityApi {
|
|
4
5
|
public abstract space: PluginSpaceApi
|
|
6
|
+
public abstract story: PluginStoryApi
|
|
5
7
|
|
|
6
8
|
constructor() {}
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export * from "./space"
|
|
12
|
+
export * from "./story"
|
package/src/api/entity/space.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
import { PVec3 } from "../core/math/vec3"
|
|
4
|
+
import { PQuat } from "../core/math/quat"
|
|
5
|
+
import { PProfile } from "../core/geom/profile"
|
|
2
6
|
|
|
3
7
|
export abstract class PluginSpaceApi {
|
|
4
8
|
constructor() {}
|
|
@@ -8,44 +12,102 @@ export abstract class PluginSpaceApi {
|
|
|
8
12
|
dimensions,
|
|
9
13
|
}: PluginSpaceCreateRectangularArgs): PluginApiReturn<PluginSpaceCreateRectangularResult>
|
|
10
14
|
|
|
11
|
-
public abstract
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
public abstract createFromProfile({
|
|
16
|
+
profile,
|
|
17
|
+
extrudeHeight,
|
|
18
|
+
position,
|
|
19
|
+
}: PluginSpaceCreateFromProfileArgs): PluginApiReturn<PluginSpaceCreateFromProfileResult>
|
|
20
|
+
|
|
21
|
+
public abstract getAll(): PluginApiReturn<PluginSpaceGetAllResult>
|
|
22
|
+
|
|
23
|
+
public abstract get({
|
|
14
24
|
spaceId,
|
|
15
25
|
properties,
|
|
16
|
-
}:
|
|
26
|
+
}: PluginSpaceGetArgs): PluginApiReturn<PluginSpaceGetResult>
|
|
17
27
|
|
|
18
28
|
public abstract deleteById({
|
|
19
29
|
spaceId,
|
|
20
30
|
}: PluginSpaceDeleteByIdArgs): PluginApiReturn<PluginSpaceDeleteByIdResult>
|
|
21
31
|
}
|
|
22
32
|
|
|
23
|
-
export
|
|
24
|
-
position:
|
|
25
|
-
dimensions:
|
|
26
|
-
|
|
33
|
+
export const PluginSpaceCreateRectangularArgs = z.object({
|
|
34
|
+
position: PVec3,
|
|
35
|
+
dimensions: z.object({
|
|
36
|
+
width: z.number(),
|
|
37
|
+
height: z.number(),
|
|
38
|
+
depth: z.number(),
|
|
39
|
+
}),
|
|
40
|
+
})
|
|
27
41
|
|
|
28
|
-
export type
|
|
29
|
-
spaceId: ComponentId
|
|
30
|
-
}
|
|
42
|
+
export type PluginSpaceCreateRectangularArgs = z.infer<typeof PluginSpaceCreateRectangularArgs>
|
|
31
43
|
|
|
32
|
-
export
|
|
33
|
-
spaceId:
|
|
34
|
-
|
|
35
|
-
}
|
|
44
|
+
export const PluginSpaceCreateRectangularResult = z.object({
|
|
45
|
+
spaceId: z.string(),
|
|
46
|
+
})
|
|
36
47
|
|
|
37
|
-
export type
|
|
48
|
+
export type PluginSpaceCreateRectangularResult = z.infer<typeof PluginSpaceCreateRectangularResult>
|
|
38
49
|
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
export const PluginSpaceCreateFromProfileArgs = z.object({
|
|
51
|
+
profile: PProfile,
|
|
52
|
+
extrudeHeight: z.number(),
|
|
53
|
+
position: PVec3,
|
|
54
|
+
})
|
|
42
55
|
|
|
43
|
-
export type
|
|
44
|
-
spacesIds: ComponentId[]
|
|
45
|
-
}
|
|
56
|
+
export type PluginSpaceCreateFromProfileArgs = z.infer<typeof PluginSpaceCreateFromProfileArgs>
|
|
46
57
|
|
|
47
|
-
export
|
|
48
|
-
spaceId:
|
|
49
|
-
}
|
|
58
|
+
export const PluginSpaceCreateFromProfileResult = z.object({
|
|
59
|
+
spaceId: z.string(),
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
export type PluginSpaceCreateFromProfileResult = z.infer<typeof PluginSpaceCreateFromProfileResult>
|
|
63
|
+
|
|
64
|
+
export const PluginSpaceGetProperty = z.enum([
|
|
65
|
+
"id",
|
|
66
|
+
"type",
|
|
67
|
+
"room_type",
|
|
68
|
+
"name",
|
|
69
|
+
"area",
|
|
70
|
+
"department",
|
|
71
|
+
"position",
|
|
72
|
+
"absolutePosition",
|
|
73
|
+
"rotation",
|
|
74
|
+
"rotationQuaternion",
|
|
75
|
+
])
|
|
76
|
+
|
|
77
|
+
export const PluginSpaceGetArgs = z.object({
|
|
78
|
+
spaceId: z.string(),
|
|
79
|
+
properties: z.array(PluginSpaceGetProperty),
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
export type PluginSpaceGetArgs = z.infer<typeof PluginSpaceGetArgs>
|
|
83
|
+
|
|
84
|
+
export const PluginSpaceGetResult = z
|
|
85
|
+
.object({
|
|
86
|
+
id: z.string(),
|
|
87
|
+
type: z.string(),
|
|
88
|
+
room_type: z.string(),
|
|
89
|
+
name: z.string(),
|
|
90
|
+
area: z.number(),
|
|
91
|
+
department: z.string(),
|
|
92
|
+
position: PVec3,
|
|
93
|
+
absolutePosition: PVec3,
|
|
94
|
+
rotation: PVec3,
|
|
95
|
+
rotationQuaternion: PQuat.nullable(),
|
|
96
|
+
})
|
|
97
|
+
.partial()
|
|
98
|
+
|
|
99
|
+
export type PluginSpaceGetResult = z.infer<typeof PluginSpaceGetResult>
|
|
100
|
+
|
|
101
|
+
export const PluginSpaceGetAllResult = z.object({
|
|
102
|
+
spacesIds: z.array(z.string()),
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
export type PluginSpaceGetAllResult = z.infer<typeof PluginSpaceGetAllResult>
|
|
106
|
+
|
|
107
|
+
export const PluginSpaceDeleteByIdArgs = z.object({
|
|
108
|
+
spaceId: z.string(),
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
export type PluginSpaceDeleteByIdArgs = z.infer<typeof PluginSpaceDeleteByIdArgs>
|
|
50
112
|
|
|
51
113
|
export type PluginSpaceDeleteByIdResult = void
|