Skip to content

Commit 55344e1

Browse files
committed
feat: support xr-frame
1 parent 507bdc7 commit 55344e1

File tree

7 files changed

+15313
-4
lines changed

7 files changed

+15313
-4
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = {
4545
}],
4646
'@typescript-eslint/naming-convention': ['error', {
4747
selector: 'enum',
48-
format: ['UPPER_CASE'],
48+
format: ['PascalCase', 'UPPER_CASE'],
4949
leadingUnderscore: 'forbid',
5050
trailingUnderscore: 'forbid',
5151
}, {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "miniprogram-api-typings",
3-
"version": "3.7.1",
3+
"version": "3.8.0",
44
"description": "Type definitions for APIs of Wechat Mini Program in TypeScript",
55
"main": "./index.d.ts",
66
"types": "./index.d.ts",

test/xr-frame.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { expectType } from 'tsd'
2+
3+
import * as XrFrame from 'WechatXrFrame'
4+
5+
const xrFrameSystem = wx.getXrFrameSystem()
6+
7+
expectType<XrFrame.Element>(new xrFrameSystem.Element('test', () => {}))
8+
9+
const AutoRotateTouchableGLTFDefaultComponents: XrFrame.IEntityComponents = Object.assign({
10+
'mesh-shape': {},
11+
'auto-rotate': {}
12+
}, xrFrameSystem.GLTFDefaultComponents)
13+
14+
const AutoRotateTouchableGLTFDataMapping: {[key: string]: string[]} = Object.assign({
15+
speed: ['auto-rotate', 'speed']
16+
}, xrFrameSystem.GLTFDataMapping)
17+
18+
const Element = xrFrameSystem.Element
19+
20+
class XRAutoRotateTouchableGLTF extends Element {
21+
public readonly defaultComponents: XrFrame.IEntityComponents = AutoRotateTouchableGLTFDefaultComponents
22+
public readonly dataMapping: {[key: string]: string[]} = AutoRotateTouchableGLTFDataMapping
23+
}
24+
25+
xrFrameSystem.registerElement('auto-rotate-touchable-gltf', XRAutoRotateTouchableGLTF)
26+
27+
xrFrameSystem.registerMaterial('shining', scene => {
28+
return scene.createMaterial(scene.assets.getAsset<XrFrame.Effect>('effect', 'shining'))
29+
})
30+
31+
const ShiningStarDefaultComponents: XrFrame.IEntityComponents = Object.assign({
32+
mesh: {
33+
geometry: 'star',
34+
material: 'shining'
35+
}
36+
}, xrFrameSystem.NodeDefaultComponents)
37+
38+
const ShiningStarDataMapping: {[key: string]: string[]} = Object.assign({
39+
uniforms: ['mesh', 'uniforms']
40+
}, xrFrameSystem.NodeDataMapping)
41+
42+
xrFrameSystem.registerElement('shining-star', class XRShiningStar extends Element {
43+
public readonly defaultComponents: XrFrame.IEntityComponents = ShiningStarDefaultComponents
44+
public readonly dataMapping: {[key: string]: string[]} = ShiningStarDataMapping
45+
})

types/wx/lib.wx.api.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
SOFTWARE.
2121
***************************************************************************** */
2222

23+
/// <reference path="./lib.wx.xr-frame.d.ts" />
24+
2325
declare namespace WechatMiniprogram {
2426
interface AccessFailCallbackResult {
2527
/** 错误信息
@@ -25940,6 +25942,8 @@ wx.writeBLECharacteristicValue({
2594025942
cloud: WxCloud
2594125943
/** 文件系统中的用户目录路径 */
2594225944
env: { USER_DATA_PATH: string }
25945+
/** 获得 xr-frame 接口系统 */
25946+
getXrFrameSystem(): import('WechatXrFrame').IXrFrameSystem
2594325947
/** 需要基础库: `2.25.2`
2594425948
*
2594525949
* worklet 对象,可以通过 [wx.worklet](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/wx.worklet.html) 获取。 */

0 commit comments

Comments
 (0)