uniapp微信小程序3D XR-FRAME

1.在pages.json中配置展示页面(style中添加下面:)

"usingComponents": {

"xr-start": "../../wxcomponents/xr-start"

}

2.manifest.json中配置mp-weixin

"setting" : {

"urlCheck" : false,

"postcss" : true,

"es6" : true,

"minified" : true

},

"usingComponents" : true,

"lazyCodeLoading" : "requiredComponents",

3.pege文件同级依次建立文件wxcomponenrs/xr-start/(index.js、index/json、index/wxml)

4.index.js

// index.js

Component({

properties: {},

data: {},

methods: {},

});

  1. index.json

{

"component": true,

"renderer": "xr-frame",

"usingComponents":{}

}

  1. index.wxml(页面3d渲染内容,详情参考文档)

<xr-scene>

<xr-assets bind:progress="handleAssetsProgress" bind:loaded="handleAssetsLoaded">

<xr-asset-load type="gltf" asset-id="damage-helmet" src="/static/gltf/lou.gltf" />

</xr-assets>

<xr-light type="ambient" color="1 1 1" intensity="1" />

<xr-light type="directional" rotation="40 70 0" color="1 1 1" intensity="3" cast-shadow />

<xr-gltf node-id="damage-helmet" model="damage-helmet" />

<xr-gltf model="miku" position="-0.15 0.75 0" scale="0.07 0.07 0.07" rotation="0 180 0" anim-autoplay />

<xr-camera

position="0 15 60" target="damage-helmet" background="skybox"

clear-color="0.4 0.8 0.6 1" camera-orbit-control

/>

</xr-scene>

  1. 页面.vue
javascript 复制代码
<template>
  <view style="display: flex; flex-direction: column">
    <xr-start
      id="main-frame"
      disable-scroll
      :width="renderWidth"
      :height="renderHeight"
      :style="'width:' + width + 'px;height:' + height + 'px;'"
    >
    </xr-start>
  </view>
</template>

<script>
export default {
  data() {
    return {
      width: 300,
      height: 300,
      renderWidth: 300,
      renderHeight: 300,
    };
  },
  onLoad(option) {
    this.width = uni.getWindowInfo().windowWidth;
    this.height = uni.getWindowInfo().windowHeight;
    const dpi = uni.getWindowInfo().pixelRatio;
    this.renderWidth = this.width * dpi;
    this.renderHeight = this.height * dpi;
  },
  mounted() {},

  methods: {},
};
</script>
相关推荐
吴传逞8 小时前
记一次uniapp微信小程序开发scss变量失效的问题
微信小程序·uni-app·scss
服务端技术栈16 小时前
历时 1 个多月,我的第一个微信小程序「图片转 Excel」终于上线了!
前端·后端·微信小程序
2501_9159214316 小时前
小团队如何高效完成 uni-app iOS 上架,从分工到工具组合的实战经验
android·ios·小程序·uni-app·cocoa·iphone·webview
2501_9160088918 小时前
uni-app iOS 文件管理与 itools 配合实战,多工具协作的完整流程
android·ios·小程序·https·uni-app·iphone·webview
!win !19 小时前
uni-app项目Tabbar实现切换icon动效
小程序·uni-app
xw519 小时前
uni-app项目Tabbar实现切换icon动效
前端·uni-app
宋辰月19 小时前
微信小程序-day4
微信小程序·小程序
2501_9160074720 小时前
uni-app iOS 文件调试常见问题与解决方案:结合 itools、克魔、iMazing 的实战经验
android·ios·小程序·https·uni-app·iphone·webview
豆豆(设计前端)20 小时前
使用 Uni-app 打包 外链地址APK 及 iOS 注意事项
ios·uni-app
jingling55520 小时前
uniapp | 解决组件样式不生效问题
前端·css·uni-app·html·学习方法