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>
相关推荐
DsirNg7 小时前
页面栈溢出问题修复总结
前端·微信小程序
小徐_23337 小时前
uni-app 也能远程调试?使用 PageSpy 打开调试的新大门!
前端·微信小程序·uni-app
深红9 小时前
玩转小程序AR-实战篇
前端·微信小程序·webvr
00后程序员张11 小时前
HTTPS Everywhere 时代的抓包挑战,从加密流量解析到底层数据流捕获的全流程方案
网络协议·http·ios·小程序·https·uni-app·iphone
草字11 小时前
uniapp 悬浮按钮支持可拖拽。可移动。
前端·javascript·uni-app
速易达网络12 小时前
Uniapp + Coze智能在线课程平台应用实现方案
uni-app
Qlittleboy14 小时前
uniAPP开发 image 标签的@error事件不被触发调用怎么办
uni-app
我命由我1234516 小时前
微信小程序 - scroll-view 的一些要点(scroll-view 需要设置滚动方向、scroll-view 需要设置高度)
开发语言·前端·javascript·微信小程序·小程序·前端框架·js
吳所畏惧16 小时前
少走弯路:uniapp里将h5链接打包为apk,并设置顶/底部安全区域自动填充显示,阻止webview默认全屏化
android·安全·uni-app·json·html5·webview·js
weixin_4721835417 小时前
微信小程序使用websocket
websocket·微信小程序·小程序