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>
相关推荐
渲吧云渲染2 小时前
3ds Max 渲染技术突破:一键解锁照片级真实感!
3d
Tiffany_Ho2 小时前
【threejs】每天一个小案例讲解:创建基本的3D场景
3d·three
alphaair3 小时前
【一步步开发AI运动APP】十、微调优化内置运动分析器,灵活适配不同的应用场景
uni-app·ai运动·ai运动识别·ai健身·ai体测·ai运动app·ai运动检测·工会云上运动会·ai人体检测·ai姿态识别
moxiaoran57534 小时前
uni-app学习笔记二十三--交互反馈showToast用法
笔记·学习·uni-app
Angindem13 小时前
从零搭建uniapp项目
前端·vue.js·uni-app
Uyker13 小时前
微信小程序动态效果实战指南:从悬浮云朵到丝滑列表加载
前端·微信小程序·小程序
happyCoder17 小时前
uniapp 微信小程序实现定时消息订阅提醒(前后端)
微信小程序
Bug从此不上门18 小时前
【无标题】
前端·javascript·uni-app·vue
耶啵奶膘21 小时前
uniapp+vue2解构赋值和直接赋值的优缺点
uni-app
疯狂的沙粒21 小时前
uni-app 项目支持 vue 3.0 详解及版本升级方案?
前端·vue.js·uni-app