|
1 | | -import type { Component } from 'vue' |
2 | | - |
3 | | -import BaseCollider from './BaseCollider.vue' |
4 | | -import type { ColliderProps, ColliderShape } from '../../types' |
5 | | - |
6 | | -const shapePrefixes: ColliderShape[] = [ |
7 | | - 'ball', |
8 | | - 'cuboid', |
9 | | - 'capsule', |
10 | | - 'cone', |
11 | | - 'cylinder', |
12 | | - 'hull', |
13 | | - 'trimesh', |
14 | | - 'heightfield', |
15 | | -] |
16 | | -const otherColliders = {} as Record< |
17 | | - Capitalize<`${ColliderShape}Collider`>, |
18 | | - Component<Omit<ColliderProps, 'shape'>> |
19 | | -> |
20 | | - |
21 | | -for (const shape of shapePrefixes) { |
22 | | - otherColliders[ |
23 | | - `${ |
24 | | - (shape.charAt(0).toUpperCase() |
25 | | - + shape.slice(1)) as Capitalize<ColliderShape> |
26 | | - }Collider` |
27 | | - ] = { |
28 | | - extends: BaseCollider, |
29 | | - props: { |
30 | | - ...BaseCollider.props, |
31 | | - shape: undefined, |
32 | | - }, |
33 | | - setup(props, ctx) { |
34 | | - return { |
35 | | - ...BaseCollider?.setup?.( |
36 | | - { ...props, shape } as Parameters< |
37 | | - Exclude<(typeof BaseCollider)['setup'], undefined> |
38 | | - >['0'], |
39 | | - ctx, |
40 | | - ), |
41 | | - } |
42 | | - }, |
43 | | - } |
44 | | -} |
45 | | - |
46 | 1 | /** @description `Collider` with the shape set to `ball` */ |
47 | | -export const BallCollider = otherColliders.BallCollider |
| 2 | +export { default as BallCollider } from './BallCollider.vue' |
| 3 | + |
| 4 | +/** @description `Collider` with no shape set */ |
| 5 | +export { default as Collider } from './BaseCollider.vue' |
48 | 6 |
|
49 | 7 | /** @description `Collider` with the shape set to `capsule` */ |
50 | | -export const CapsuleCollider = otherColliders.CapsuleCollider |
| 8 | +export { default as CapsuleCollider } from './CapsuleCollider.vue' |
51 | 9 |
|
52 | 10 | /** @description `Collider` with the shape set to `cone` */ |
53 | | -export const ConeCollider = otherColliders.ConeCollider |
| 11 | +export { default as ConeCollider } from './ConeCollider.vue' |
54 | 12 |
|
55 | 13 | /** @description `Collider` with the shape set to `cuboid` */ |
56 | | -export const CuboidCollider = otherColliders.CuboidCollider |
| 14 | +export { default as CuboidCollider } from './CuboidCollider.vue' |
57 | 15 |
|
58 | 16 | /** @description `Collider` with the shape set to `cylinder` */ |
59 | | -export const CylinderCollider = otherColliders.CylinderCollider |
| 17 | +export { default as CylinderCollider } from './CylinderCollider.vue' |
60 | 18 |
|
61 | 19 | /** @description `Collider` with the shape set to `heightfield` */ |
62 | | -export const HeightfieldCollider = otherColliders.HeightfieldCollider |
| 20 | +export { default as HeightfieldCollider } from './HeightfieldCollider.vue' |
63 | 21 |
|
64 | 22 | /** @description `Collider` with the shape set to `hull` */ |
65 | | -export const HullCollider = otherColliders.HullCollider |
| 23 | +export { default as HullCollider } from './HullCollider.vue' |
66 | 24 |
|
67 | 25 | /** @description `Collider` with the shape set to `trimesh` */ |
68 | | -export const TrimeshCollider = otherColliders.TrimeshCollider |
69 | | - |
70 | | -export { default as BaseCollider } from './BaseCollider.vue' |
| 26 | +export { default as TrimeshCollider } from './TrimeshCollider.vue' |
0 commit comments