@stdex/create 0.0.0-stage → 1.2.0

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.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +66 -2
  3. package/README_EN.md +67 -0
  4. package/package.json +40 -3
  5. package/src/eslint.config.js +2 -0
  6. package/src/index.js +233 -0
  7. package/templates/base/eslint.config.js +2 -0
  8. package/templates/base/index.js +3 -0
  9. package/templates/base/package.json +16 -0
  10. package/templates/miniprogram/README.md +27 -0
  11. package/templates/miniprogram/_gitignore +3 -0
  12. package/templates/miniprogram/eslint.config.cjs +25 -0
  13. package/templates/miniprogram/gulpfile.js +81 -0
  14. package/templates/miniprogram/package.json +22 -0
  15. package/templates/miniprogram/project.config.json +31 -0
  16. package/templates/miniprogram/project.private.config.json +8 -0
  17. package/templates/miniprogram/src/app.json +16 -0
  18. package/templates/miniprogram/src/app.scss +0 -0
  19. package/templates/miniprogram/src/app.ts +6 -0
  20. package/templates/miniprogram/src/lib/app-data.ts +46 -0
  21. package/templates/miniprogram/src/pages/index/index.json +3 -0
  22. package/templates/miniprogram/src/pages/index/index.scss +11 -0
  23. package/templates/miniprogram/src/pages/index/index.ts +13 -0
  24. package/templates/miniprogram/src/pages/index/index.wxml +1 -0
  25. package/templates/miniprogram/src/sitemap.json +9 -0
  26. package/templates/miniprogram/tsconfig.json +11 -0
  27. package/templates/miniprogram/typings/index.d.ts +5 -0
  28. package/templates/miniprogram/typings/types/index.d.ts +1 -0
  29. package/templates/miniprogram/typings/types/wx/index.d.ts +162 -0
  30. package/templates/miniprogram/typings/types/wx/lib.wx.api.d.ts +32387 -0
  31. package/templates/miniprogram/typings/types/wx/lib.wx.app.d.ts +400 -0
  32. package/templates/miniprogram/typings/types/wx/lib.wx.behavior.d.ts +68 -0
  33. package/templates/miniprogram/typings/types/wx/lib.wx.canvas.d.ts +2623 -0
  34. package/templates/miniprogram/typings/types/wx/lib.wx.cloud.d.ts +1016 -0
  35. package/templates/miniprogram/typings/types/wx/lib.wx.component.d.ts +700 -0
  36. package/templates/miniprogram/typings/types/wx/lib.wx.event.d.ts +1436 -0
  37. package/templates/miniprogram/typings/types/wx/lib.wx.page.d.ts +272 -0
  38. package/templates/miniprogram/typings/types/wx/lib.wx.phys3D.d.ts +409 -0
  39. package/templates/miniprogram/typings/types/wx/lib.wx.wasm.d.ts +152 -0
  40. package/templates/miniprogram/typings/types/wx/lib.wx.xr-frame.d.ts +15631 -0
  41. package/templates/miniprogram/variables.json +11 -0
  42. package/templates/service/README.md +64 -0
  43. package/templates/service/_env +1 -0
  44. package/templates/service/_gitignore +5 -0
  45. package/templates/service/eslint.config.js +2 -0
  46. package/templates/service/package.json +48 -0
  47. package/templates/service/prisma/schema.prisma +40 -0
  48. package/templates/service/prisma/sql/demoTypedSql.sql +1 -0
  49. package/templates/service/prisma.config.ts +12 -0
  50. package/templates/service/setup.js +4 -0
  51. package/templates/service/src/cache.ts +28 -0
  52. package/templates/service/src/config.ts +49 -0
  53. package/templates/service/src/controllers/common.ts +43 -0
  54. package/templates/service/src/controllers/demo-school.ts +7 -0
  55. package/templates/service/src/controllers/demo-student.ts +7 -0
  56. package/templates/service/src/controllers/index.ts +15 -0
  57. package/templates/service/src/database.ts +52 -0
  58. package/templates/service/src/index.ts +15 -0
  59. package/templates/service/src/logger.ts +10 -0
  60. package/templates/service/src/routes/demo-school.ts +9 -0
  61. package/templates/service/src/routes/index.ts +3 -0
  62. package/templates/service/src/routes/router.ts +42 -0
  63. package/templates/service/src/tasks/common.ts +25 -0
  64. package/templates/service/src/tasks/demo-school.ts +10 -0
  65. package/templates/service/src/tasks/index.ts +1 -0
  66. package/templates/service/tsconfig.build.json +9 -0
  67. package/templates/service/tsconfig.json +10 -0
  68. package/templates/site/_gitignore +3 -0
  69. package/templates/site/_pnpm-workspace.yaml +4 -0
  70. package/templates/site/eslint.config.js +19 -0
  71. package/templates/site/package.json +41 -0
  72. package/templates/site/public/favicon.png +0 -0
  73. package/templates/site/src/app/header.tsx +31 -0
  74. package/templates/site/src/app/index.tsx +38 -0
  75. package/templates/site/src/app/layout.tsx +63 -0
  76. package/templates/site/src/app/menu.tsx +115 -0
  77. package/templates/site/src/app/router.tsx +50 -0
  78. package/templates/site/src/app/style.css +9 -0
  79. package/templates/site/src/assets/logo.png +0 -0
  80. package/templates/site/src/components/Breadcrumb.tsx +47 -0
  81. package/templates/site/src/components/DevStatus.tsx +14 -0
  82. package/templates/site/src/index.html +13 -0
  83. package/templates/site/src/index.tsx +5 -0
  84. package/templates/site/src/lib/config.ts +6 -0
  85. package/templates/site/src/lib/init-dayjs.ts +8 -0
  86. package/templates/site/src/lib/logging.ts +5 -0
  87. package/templates/site/src/views/dashboard.tsx +7 -0
  88. package/templates/site/src/views/school-detail.tsx +13 -0
  89. package/templates/site/src/views/school-ranking.tsx +7 -0
  90. package/templates/site/src/views/schools.tsx +43 -0
  91. package/templates/site/src/views/setting.tsx +7 -0
  92. package/templates/site/src/views/student-score.tsx +7 -0
  93. package/templates/site/src/views/students.tsx +7 -0
  94. package/templates/site/tsconfig.json +10 -0
  95. package/templates/site/vite.config.js +60 -0
@@ -0,0 +1,272 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) 2023 Tencent, Inc. All rights reserved.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the "Software"), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
+ of the Software, and to permit persons to whom the Software is furnished to do
9
+ so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
21
+ ***************************************************************************** */
22
+
23
+ declare namespace WechatMiniprogram.Page {
24
+ type Instance<
25
+ TData extends DataOption,
26
+ TCustom extends CustomOption
27
+ > = OptionalInterface<ILifetime> &
28
+ InstanceProperties &
29
+ InstanceMethods<TData> &
30
+ Data<TData> &
31
+ TCustom
32
+ type Options<
33
+ TData extends DataOption,
34
+ TCustom extends CustomOption
35
+ > = (TCustom &
36
+ Partial<Data<TData>> &
37
+ Partial<ILifetime> & {
38
+ options?: Component.ComponentOptions
39
+ }) &
40
+ ThisType<Instance<TData, TCustom>>
41
+ type TrivialInstance = Instance<IAnyObject, IAnyObject>
42
+ interface Constructor {
43
+ <TData extends DataOption, TCustom extends CustomOption>(
44
+ options: Options<TData, TCustom>
45
+ ): void
46
+ }
47
+ interface ILifetime {
48
+ /** 生命周期回调—监听页面加载
49
+ *
50
+ * 页面加载时触发。一个页面只会调用一次,可以在 onLoad 的参数中获取打开当前页面路径中的参数。
51
+ */
52
+ onLoad(
53
+ /** 打开当前页面路径中的参数 */
54
+ query: Record<string, string | undefined>
55
+ ): void | Promise<void>
56
+ /** 生命周期回调—监听页面显示
57
+ *
58
+ * 页面显示/切入前台时触发。
59
+ */
60
+ onShow(): void | Promise<void>
61
+ /** 生命周期回调—监听页面初次渲染完成
62
+ *
63
+ * 页面初次渲染完成时触发。一个页面只会调用一次,代表页面已经准备妥当,可以和视图层进行交互。
64
+ *
65
+
66
+ * 注意:对界面内容进行设置的 API 如`wx.setNavigationBarTitle`,请在`onReady`之后进行。
67
+ */
68
+ onReady(): void | Promise<void>
69
+ /** 生命周期回调—监听页面隐藏
70
+ *
71
+ * 页面隐藏/切入后台时触发。 如 `navigateTo` 或底部 `tab` 切换到其他页面,小程序切入后台等。
72
+ */
73
+ onHide(): void | Promise<void>
74
+ /** 生命周期回调—监听页面卸载
75
+ *
76
+ * 页面卸载时触发。如`redirectTo`或`navigateBack`到其他页面时。
77
+ */
78
+ onUnload(): void | Promise<void>
79
+ /** 监听用户下拉动作
80
+ *
81
+ * 监听用户下拉刷新事件。
82
+ * - 需要在`app.json`的`window`选项中或页面配置中开启`enablePullDownRefresh`。
83
+ * - 可以通过`wx.startPullDownRefresh`触发下拉刷新,调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
84
+ * - 当处理完数据刷新后,`wx.stopPullDownRefresh`可以停止当前页面的下拉刷新。
85
+ */
86
+ onPullDownRefresh(): void | Promise<void>
87
+ /** 页面上拉触底事件的处理函数
88
+ *
89
+ * 监听用户上拉触底事件。
90
+ * - 可以在`app.json`的`window`选项中或页面配置中设置触发距离`onReachBottomDistance`。
91
+ * - 在触发距离内滑动期间,本事件只会被触发一次。
92
+ */
93
+ onReachBottom(): void | Promise<void>
94
+ /** 用户点击右上角转发
95
+ *
96
+ * 监听用户点击页面内转发按钮(`<button>` 组件 `open-type="share"`)或右上角菜单“转发”按钮的行为,并自定义转发内容。
97
+ *
98
+ * **注意:只有定义了此事件处理函数,右上角菜单才会显示“转发”按钮**
99
+ *
100
+ * 此事件需要 return 一个 Object,用于自定义转发内容
101
+ */
102
+ onShareAppMessage(
103
+ /** 分享发起来源参数 */
104
+ options: IShareAppMessageOption
105
+ ):
106
+ | ICustomShareContent
107
+ | IAsyncCustomShareContent
108
+ | Promise<ICustomShareContent>
109
+ | void
110
+ | Promise<void>
111
+ /**
112
+ * 监听右上角菜单“分享到朋友圈”按钮的行为,并自定义分享内容
113
+ *
114
+ * 本接口为 Beta 版本,暂只在 Android 平台支持,详见 [分享到朋友圈 (Beta)](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html)
115
+ *
116
+ * 基础库 2.11.3 开始支持,低版本需做兼容处理。
117
+ */
118
+ onShareTimeline(): ICustomTimelineContent | void
119
+
120
+ /** 页面滚动触发事件的处理函数
121
+ *
122
+ * 监听用户滑动页面事件。
123
+ */
124
+ onPageScroll(
125
+ /** 页面滚动参数 */
126
+ options: IPageScrollOption
127
+ ): void | Promise<void>
128
+
129
+ /** 当前是 tab 页时,点击 tab 时触发,最低基础库: `1.9.0` */
130
+ onTabItemTap(
131
+ /** tab 点击参数 */
132
+ options: ITabItemTapOption
133
+ ): void | Promise<void>
134
+
135
+ /** 窗口尺寸改变时触发,最低基础库:`2.4.0` */
136
+ onResize(
137
+ /** 窗口尺寸参数 */
138
+ options: IResizeOption
139
+ ): void | Promise<void>
140
+
141
+ /**
142
+ * 监听用户点击右上角菜单“收藏”按钮的行为,并自定义收藏内容。
143
+ * 基础库 2.10.3,安卓 7.0.15 版本起支持,iOS 暂不支持
144
+ */
145
+ onAddToFavorites(options: IAddToFavoritesOption): IAddToFavoritesContent
146
+ }
147
+ interface InstanceProperties {
148
+ /** 页面的文件路径 */
149
+ is: string
150
+
151
+ /** 到当前页面的路径 */
152
+ route: string
153
+
154
+ /** 打开当前页面路径中的参数 */
155
+ options: Record<string, string | undefined>
156
+ }
157
+
158
+ type DataOption = Record<string, any>
159
+ type CustomOption = Record<string, any>
160
+
161
+ type InstanceMethods<D extends DataOption> = Component.InstanceMethods<D>
162
+
163
+ interface Data<D extends DataOption> {
164
+ /** 页面的初始数据
165
+ *
166
+ * `data` 是页面第一次渲染使用的**初始数据**。
167
+ *
168
+ * 页面加载时,`data` 将会以`JSON`字符串的形式由逻辑层传至渲染层,因此`data`中的数据必须是可以转成`JSON`的类型:字符串,数字,布尔值,对象,数组。
169
+ *
170
+ * 渲染层可以通过 `WXML` 对数据进行绑定。
171
+ */
172
+ data: D
173
+ }
174
+
175
+ interface ICustomShareContent {
176
+ /** 转发标题。默认值:当前小程序名称 */
177
+ title?: string
178
+ /** 转发路径,必须是以 / 开头的完整路径。默认值:当前页面 path */
179
+ path?: string
180
+ /** 自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径。支持PNG及JPG。显示图片长宽比是 5:4,最低基础库: `1.5.0`。默认值:使用默认截图 */
181
+ imageUrl?: string
182
+ }
183
+
184
+ interface IAsyncCustomShareContent extends ICustomShareContent {
185
+ promise: Promise<ICustomShareContent>
186
+ }
187
+
188
+ interface ICustomTimelineContent {
189
+ /** 自定义标题,即朋友圈列表页上显示的标题。默认值:当前小程序名称 */
190
+ title?: string
191
+ /** 自定义页面路径中携带的参数,如 `path?a=1&b=2` 的 “?” 后面部分 默认值:当前页面路径携带的参数 */
192
+ query?: string
193
+ /** 自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径。支持 PNG 及 JPG。显示图片长宽比是 1:1。默认值:默认使用小程序 Logo*/
194
+ imageUrl?: string
195
+ }
196
+
197
+ interface IPageScrollOption {
198
+ /** 页面在垂直方向已滚动的距离(单位px) */
199
+ scrollTop: number
200
+ }
201
+
202
+ interface IShareAppMessageOption {
203
+ /** 转发事件来源。
204
+ *
205
+ * 可选值:
206
+ * - `button`:页面内转发按钮;
207
+ * - `menu`:右上角转发菜单。
208
+ *
209
+ * 最低基础库: `1.2.4`
210
+ */
211
+ from: 'button' | 'menu'
212
+ /** 如果 `from` 值是 `button`,则 `target` 是触发这次转发事件的 `button`,否则为 `undefined`
213
+ *
214
+ * 最低基础库: `1.2.4` */
215
+ target: any
216
+ /** 页面中包含`<web-view>`组件时,返回当前`<web-view>`的url
217
+ *
218
+ * 最低基础库: `1.6.4`
219
+ */
220
+ webViewUrl?: string
221
+ }
222
+
223
+ interface ITabItemTapOption {
224
+ /** 被点击tabItem的序号,从0开始,最低基础库: `1.9.0` */
225
+ index: string
226
+ /** 被点击tabItem的页面路径,最低基础库: `1.9.0` */
227
+ pagePath: string
228
+ /** 被点击tabItem的按钮文字,最低基础库: `1.9.0` */
229
+ text: string
230
+ }
231
+
232
+ interface IResizeOption {
233
+ size: {
234
+ /** 变化后的窗口宽度,单位 px */
235
+ windowWidth: number
236
+ /** 变化后的窗口高度,单位 px */
237
+ windowHeight: number
238
+ }
239
+ }
240
+
241
+ interface IAddToFavoritesOption {
242
+ /** 页面中包含web-view组件时,返回当前web-view的url */
243
+ webviewUrl?: string
244
+ }
245
+
246
+ interface IAddToFavoritesContent {
247
+ /** 自定义标题,默认值:页面标题或账号名称 */
248
+ title?: string
249
+ /** 自定义图片,显示图片长宽比为 1:1,默认值:页面截图 */
250
+ imageUrl?: string
251
+ /** 自定义query字段,默认值:当前页面的query */
252
+ query?: string
253
+ }
254
+
255
+ interface GetCurrentPages {
256
+ (): Array<Instance<IAnyObject, IAnyObject>>
257
+ }
258
+ }
259
+
260
+ /**
261
+ * 注册小程序中的一个页面。接受一个 `Object` 类型参数,其指定页面的初始数据、生命周期回调、事件处理函数等。
262
+ */
263
+ declare let Page: WechatMiniprogram.Page.Constructor
264
+ /**
265
+ * 获取当前页面栈。数组中第一个元素为首页,最后一个元素为当前页面。
266
+
267
+ * __注意:__
268
+
269
+ * - __不要尝试修改页面栈,会导致路由以及页面状态错误。__
270
+ * - 不要在 `App.onLaunch` 的时候调用 `getCurrentPages()`,此时 `page` 还没有生成。
271
+ */
272
+ declare let getCurrentPages: WechatMiniprogram.Page.GetCurrentPages
@@ -0,0 +1,409 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) 2023 Tencent, Inc. All rights reserved.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the "Software"), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
+ of the Software, and to permit persons to whom the Software is furnished to do
9
+ so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
21
+ ***************************************************************************** */
22
+
23
+ declare namespace phys3D {
24
+ // pvd调试配置
25
+ export interface PhysicsDebugConfig {
26
+ isNetwork: boolean // 采用网络的方式
27
+ ip?: string // 如果isNetwork为true,调试信息会通过tcp转发的方式转发到打开了pvd调试软件的电脑,需要注意的是,防火墙要对pvd打开
28
+ port?: 5425 // pvd默认接口
29
+ timeout?: 1000 // 默认耗时
30
+ path?: string // 如果isNetwork为false,调试信息会通过写本地文件的方式落地,文件名建议为xxx.pxd2,导入pvd调试即可
31
+ }
32
+
33
+ export enum QueryTriggerInteraction {
34
+ UseGlobal = 0,
35
+ Ignore = 1,
36
+ Collide = 2
37
+ }
38
+
39
+ export class PhysSystem {
40
+ constructor(config?: PhysicsDebugConfig)
41
+ gravity: RawVec3f
42
+ bounceThreshold: number
43
+ defaultMaxAngularSpeed: number
44
+ defaultSolverIterations: number
45
+ defaultSolverVelocityIterations: number
46
+ sleepThreshold: number
47
+ defaultContactOffset: number
48
+ destroyScene: () => void
49
+ createScene: () => number
50
+ Simulate: (step: number) => void
51
+ SyncFromTransforms: (() => void) | undefined // added in 2021.06
52
+ SetCollisionMask: (mask: ArrayBuffer) => void
53
+ Raycast: (
54
+ origin: RawVec3f,
55
+ unitDir: RawVec3f,
56
+ distance: number,
57
+ hit: RaycastHit,
58
+ layerMask?: number,
59
+ queryTriggerInteraction?: QueryTriggerInteraction
60
+ ) => boolean
61
+ RaycastAll: (
62
+ origin: RawVec3f,
63
+ unitDir: RawVec3f,
64
+ distance: number,
65
+ layerMask?: number,
66
+ queryTriggerInteraction?: QueryTriggerInteraction
67
+ ) => RaycastHit[]
68
+ CapsuleCast(
69
+ p1: RawVec3f,
70
+ p2: RawVec3f,
71
+ radius: number,
72
+ direction: RawVec3f,
73
+ hit: RaycastHit,
74
+ maxDistance: number,
75
+ layerMask?: number,
76
+ queryTriggerInteraction?: QueryTriggerInteraction
77
+ ): void
78
+ CapsuleCastAll: (
79
+ p1: RawVec3f,
80
+ p2: RawVec3f,
81
+ radius: number,
82
+ direction: RawVec3f,
83
+ maxDistance: number,
84
+ layerMask?: number,
85
+ queryTriggerInteraction?: QueryTriggerInteraction
86
+ ) => RaycastHit[]
87
+ BoxCast(
88
+ center: RawVec3f,
89
+ halfExt: RawVec3f,
90
+ direction: RawVec3f,
91
+ hit: RaycastHit,
92
+ orientation: RawQuaternion,
93
+ maxDistance: number,
94
+ layerMask?: number,
95
+ queryTriggerInteraction?: QueryTriggerInteraction
96
+ ): void
97
+ BoxCastAll: (
98
+ center: RawVec3f,
99
+ halfExt: RawVec3f,
100
+ direction: RawVec3f,
101
+ orientation: RawQuaternion,
102
+ maxDistance: number,
103
+ layerMask?: number,
104
+ queryTriggerInteraction?: QueryTriggerInteraction
105
+ ) => RaycastHit[]
106
+ OverlapBox: (
107
+ center: RawVec3f,
108
+ halfExt: RawVec3f,
109
+ orientation: RawQuaternion,
110
+ layermask?: number,
111
+ queryTriggerInteraction?: QueryTriggerInteraction
112
+ ) => Collider[]
113
+ OverlapCapsule: (
114
+ p1: RawVec3f,
115
+ p2: RawVec3f,
116
+ radius: number,
117
+ layermask?: number,
118
+ queryTriggerInteraction?: QueryTriggerInteraction
119
+ ) => Collider[]
120
+ }
121
+
122
+ export class Rigidbody {
123
+ constructor(system: PhysSystem)
124
+ enabled?: boolean // since 2021.06
125
+ position: RawVec3f
126
+ rotation: RawQuaternion
127
+ AttachToEntity: (pollObj: any, id: number) => void
128
+ Remove(): void
129
+ Detach(): void
130
+ IsAttached(): boolean
131
+ }
132
+
133
+ export enum CollisionDetectionMode {
134
+ Discrete = 0,
135
+ Continuous = 1,
136
+ ContinuousDynamic = 2,
137
+ ContinuousSpeculative = 3
138
+ }
139
+
140
+ export enum RigidbodyConstraints {
141
+ None = 0,
142
+ FreezePositionX = 1 << 0,
143
+ FreezePositionY = 1 << 1,
144
+ FreezePositionZ = 1 << 2,
145
+ FreezeRotationX = 1 << 3,
146
+ FreezeRotationY = 1 << 4,
147
+ FreezeRotationZ = 1 << 5,
148
+ FreezePosition = FreezePositionX | FreezePositionY | FreezePositionZ,
149
+ FreezeRotation = FreezeRotationX | FreezeRotationY | FreezeRotationZ,
150
+ FreezeAll = FreezePosition | FreezeRotation
151
+ }
152
+
153
+ export enum ForceMode {
154
+ kForceModeForce = 0,
155
+ kForceModeImpulse = 1 << 0,
156
+ kForceModeVelocityChange = 1 << 1,
157
+ kForceModeAcceleration = 1 << 2
158
+ }
159
+
160
+ export enum CombineMode {
161
+ eAverage = 0,
162
+ eMin,
163
+ eMultiply,
164
+ eMax
165
+ }
166
+
167
+ export enum CookingFlag {
168
+ None = 0,
169
+ CookForFasterSimulation = 1 << 0,
170
+ EnableMeshCleaning = 1 << 1,
171
+ WeldColocatedVertices = 1 << 2
172
+ }
173
+
174
+ export enum CollisionFlags {
175
+ None = 0,
176
+ Sides = 1 << 0,
177
+ Above = 1 << 1,
178
+ Below = 1 << 2
179
+ }
180
+
181
+ export class RawVec3f {
182
+ constructor()
183
+ constructor(x: number, y: number, z: number)
184
+ x: number
185
+ y: number
186
+ z: number
187
+ }
188
+
189
+ export class RawQuaternion {
190
+ constructor()
191
+ constructor(x: number, y: number, z: number, w: number)
192
+ x: number
193
+ y: number
194
+ z: number
195
+ w: number
196
+ }
197
+
198
+ export class Collider {
199
+ attachedRigidbody: Rigidbody
200
+ bounds: Bounds
201
+ name: string
202
+ contactOffset: number
203
+ enabled: boolean
204
+ isTrigger: boolean
205
+ scale: RawVec3f
206
+ material?: Material
207
+ sharedMateiral?: Material
208
+ ClosestPoint: (raw: RawVec3f) => RawVec3f
209
+ ClosestPointOnBounds: (raw: RawVec3f) => RawVec3f
210
+
211
+ onCollisionEnter?: (collision: Collision) => void
212
+ onCollisionExit?: (collision: Collision) => void
213
+ onCollisionStay?: (collision: Collision) => void
214
+ onTriggerEnter?: (collision: Collision) => void
215
+ onTriggerExit?: (collision: Collision) => void
216
+ onTriggerStay?: (collision: Collision) => void
217
+
218
+ dettachRigidbody?: () => void
219
+
220
+ userData?: unknown
221
+ layer: number
222
+ }
223
+
224
+ export class BoxCollider extends Collider {
225
+ constructor(system: PhysSystem, center: RawVec3f, size: RawVec3f)
226
+ center: RawVec3f
227
+ size: RawVec3f
228
+ }
229
+
230
+ export class SphereCollider extends Collider {
231
+ constructor(system: PhysSystem, center: RawVec3f, radius: number)
232
+ center: RawVec3f
233
+ radius: number
234
+ }
235
+
236
+ export class CapsuleCollider extends Collider {
237
+ constructor(
238
+ system: PhysSystem,
239
+ center: RawVec3f,
240
+ height: number,
241
+ radius: number
242
+ )
243
+ center: RawVec3f
244
+ height: number
245
+ radius: number
246
+ }
247
+
248
+ export class MeshCollider extends Collider {
249
+ constructor(
250
+ system: PhysSystem,
251
+ convex: boolean,
252
+ cookingOptions: number,
253
+ sharedMesh: PhysMesh
254
+ )
255
+ cookingOptions: number
256
+ sharedMesh: PhysMesh | null
257
+ convex: boolean
258
+ }
259
+
260
+ export class CharacterController extends Collider {
261
+ constructor(system: PhysSystem)
262
+ position: RawVec3f
263
+ center: RawVec3f
264
+ collisionFlags: CollisionFlags
265
+ detectCollisions: boolean
266
+ enableOverlapRecovery: boolean
267
+ height: number
268
+ isGrounded: boolean
269
+ minMoveDistance: number
270
+ radius: number
271
+ skinWidth: number
272
+ slopeLimit: number
273
+ stepOffset: number
274
+ velocity: RawVec3f
275
+
276
+ Move: (movement: RawVec3f) => CollisionFlags
277
+ SimpleMove: (speed: RawVec3f) => boolean
278
+ AttachToEntity: (pollObj: any, id: number) => void
279
+
280
+ OnControllerColliderHit?: (hit: ControllerColliderHit) => void
281
+ }
282
+
283
+ export interface ContactPoint {
284
+ normal: RawVec3f
285
+ this_collider: Collider
286
+ other_collider: Collider
287
+ point: RawVec3f
288
+ separation: number
289
+ }
290
+
291
+ export interface Collision {
292
+ collider: Collider
293
+ contacts: ContactPoint[]
294
+ impulse: RawVec3f
295
+ relative_velocity: RawVec3f
296
+ }
297
+
298
+ export interface ControllerColliderHit {
299
+ collider: Collider
300
+ controller: CharacterController
301
+ moveDirection: RawVec3f
302
+ normal: RawVec3f
303
+ moveLength: number
304
+ point: RawVec3f
305
+ }
306
+
307
+ export class Bounds {
308
+ constructor(center: RawVec3f, size: RawVec3f)
309
+
310
+ center: RawVec3f
311
+ extents: RawVec3f
312
+ max: RawVec3f
313
+ min: RawVec3f
314
+ size: RawVec3f
315
+
316
+ ClosestPoint: (point: RawVec3f) => RawVec3f
317
+ Contains: (point: RawVec3f) => boolean
318
+ Expand: (amount: number) => void
319
+ Intersects: (bounds: Bounds) => boolean
320
+ SetMinMax: (min: RawVec3f, max: RawVec3f) => void
321
+ SqrDistance: (point: RawVec3f) => number
322
+ }
323
+
324
+ export class Material {
325
+ constructor(system: PhysSystem)
326
+ dynamicFriction: number
327
+ staticFriction: number
328
+ bounciness: number
329
+ frictionCombine: CombineMode
330
+ bounceCombine: CombineMode
331
+ id: number
332
+ }
333
+
334
+ export class DynamicRigidbody extends Rigidbody {
335
+ mass: number
336
+ angularDamping: number
337
+ angularVelocity: RawVec3f
338
+ centerOfMass: RawVec3f
339
+ collisionDetectionMode: CollisionDetectionMode
340
+ constraints: number
341
+ detectCollisions: boolean
342
+ linearDamping: number
343
+ freezeRotation: boolean
344
+ inertiaTensor: number
345
+ // inertiaTensorRotation
346
+ // interpolation
347
+ isKinematic: boolean
348
+ maxAngularVelocity: number
349
+ maxDepenetrationVelocity: number
350
+ sleepThreshold: number
351
+ solverIterations: number
352
+ solverVelocityIterations: number
353
+ useGravity: boolean
354
+ velocity: RawVec3f
355
+ userData?: unknown
356
+
357
+ GetWorldCenterOfMass: () => RawVec3f
358
+ AddForce: (force: RawVec3f, mode: ForceMode) => void
359
+ AddTorque: (torque: RawVec3f, mode: ForceMode) => void
360
+ IsSleeping: () => boolean
361
+ Sleep: () => void
362
+ WakeUp: () => void
363
+ AddExplosionForce: (
364
+ explosionForce: number,
365
+ explosionPosition: RawVec3f,
366
+ explosionRadius: number,
367
+ upwardsModifier: number,
368
+ mode: ForceMode
369
+ ) => void
370
+ AddForceAtPosition: (
371
+ force: RawVec3f,
372
+ position: RawVec3f,
373
+ mode: ForceMode
374
+ ) => void
375
+ AddRelativeForce: (force: RawVec3f, mode: ForceMode) => void
376
+ AddRelativeTorque: (torque: RawVec3f, mode: ForceMode) => void
377
+ ClosestPointOnBounds: (position: RawVec3f) => RawVec3f
378
+ GetPointVelocity: (worldPoint: RawVec3f) => RawVec3f
379
+ GetRelativePointVelocity: (relativePoint: RawVec3f) => RawVec3f
380
+ MovePosition: (position: RawVec3f) => void
381
+ MoveRotation: (rotation: RawQuaternion) => void
382
+ ResetCenterOfMass: () => void
383
+ ResetInertiaTensor: () => void
384
+ SetDensity: (density: number) => void
385
+ // SweepTest: () => void;
386
+ // SweepTestAll: () => void;
387
+ }
388
+
389
+ export class PhysMesh {
390
+ constructor(system: PhysSystem)
391
+ // set vertices
392
+ SetVertices: (buffer: Float32Array, count: number) => void
393
+ // set indices
394
+ SetTriangles: (
395
+ buffer: Uint16Array | Uint32Array,
396
+ count: number,
397
+ useUint16: boolean
398
+ ) => void
399
+ }
400
+
401
+ export class RaycastHit {
402
+ constructor()
403
+ collider: Collider
404
+ distance: number
405
+ normal: RawVec3f
406
+ point: RawVec3f
407
+ rigidbody: Rigidbody
408
+ }
409
+ }