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>
相关推荐
游戏开发爱好者81 小时前
抓包工具推荐 2026,网络调试、代理抓包、请求拦截
android·ios·小程序·https·uni-app·iphone·webview
KeroroLX1 小时前
uniapp项目中使用echarts
javascript·uni-app·echarts
脾气有点小暴1 小时前
uniapp APP 上传PDF文件
uni-app
不含硫jun1 小时前
windows中高斯泼建(gaussian-splatting)库安装 兼容vs2022 cuda11.8 UE5.3.2
pytorch·3d·ue5·visual studio
Ulyanov2 小时前
基于Impress.js的3D概念地图设计与实现
开发语言·前端·javascript·3d·ecmascript
星图易码3 小时前
DevMate.SCADA操作指引|3D组态管道创建
3d
Renderbus瑞云渲染农场3 小时前
V-Ray与Corona渲染效果对比及云渲染优选
3d·3dsmax
那些免费的砖4 小时前
Uni ECharts - 基于 ECharts 开发的 uni-app 跨端图表解决方案,和 Vue ECharts 用法几乎一致
vue.js·uni-app·echarts
CG_MAGIC4 小时前
ZBrush 细节优化:笔刷组合与拓扑重构避坑指南
3d·zbrush·建模教程·渲云渲染·3d软件
木子啊4 小时前
Uni-app rpx布局终极指南
uni-app·rpx·微信小程序rpx