1.0 主动加载静态资源
<xr-asset-load asset-id="anim" type="keyframe" src="/static/animation/miku-kawaii-animation.json"/>1.1 手动加载静态资源 和 动态插入模型(gltf)
wxml
// 是一种特殊的节点,开发者**仅可在其下以及子孙挂载自己创建的节点**
<xr-shadow id="shadow-root"></xr-shadow>js
// 场景示例
const scene = this.scene = detail.value;
// 这里是实例包含了文件API[classes]
const xrFrameSystem = wx.getXrFrameSystem();
// 获取挂载元素的节点
this.shadowRoot = scene.getElementById('shadow-root');
// 手动获取静态资源
const {value: model} = await scene.assets.loadAsset({type: 'gltf', assetId: 'damage-helmet', src: 'https://mmbizwxaminiprogram-1258344707.cos.ap-guangzhou.myqcloud.com/xr-frame/demo/damage-helmet/index.glb'});
this.damageModle = model
// 直接创建一个XRGLTF元素,但注意要和`Shadow元素`一起使用
const gltfElement = scene.createElement(xrFrameSystem.XRGLTF);
// 插入到节点下
this.shadowRoot.addChild(gltfElement);
// 获取组件
const gltfComp = gltfElement.getComponent(xrFrameSystem.GLTF);
// 更新组件
gltfComp.setData({model: model});