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>
相关推荐
coder what1 小时前
小说阅读书城微信小程序
微信小程序·小程序
你的眼睛會笑2 小时前
uniapp H5 打开地图 并选中标记点
uni-app
苍风的心上人2 小时前
uniapp(H5)设置反向代理,设置成功后页面报错
uni-app
她似晚风般温柔7892 小时前
Uniapp + Vue3 + Vite +Uview + Pinia 实现购物车功能(最新附源码保姆级)
开发语言·javascript·uni-app
2401_845937535 小时前
PHP即刻送达同城派送小程序系统
微信·微信小程序·小程序·微信公众平台·微信开放平台
新拓三维5 小时前
三维数字图像相关法(3D-DIC)用于复合材料力学性能测试
人工智能·3d
阿利同学5 小时前
基于姿态估计的运动打卡健身系统-AI健身教练-3d姿态估计-摔倒检测应用-姿态估计与计数
人工智能·3d·健康医疗·智能监控·3d姿态估计·ai健身打卡系统·健身教练
用你的胜利博我一笑吧5 小时前
supermap Iclient3d for cesium加载地形并夸大地形
前端·javascript·3d
工业互联网专业6 小时前
基于ssm+vue+uniapp的智能停车场管理系统小程序
vue.js·小程序·uni-app·毕业设计·ssm·源码·课程设计
宇珩前端踩坑日记9 小时前
微信小程序能不能有一种公共的分包,能被普通的分包引用其资源?(内有解决方案)
微信小程序·小程序