收藏
回答

AR图像识别 首次加载问题

问题类型 插件 AppID 插件版本号 AppID 操作系统 微信版本 基础库版本
Bug wx3bbab3920eabccb2 2.16.3 wxcb9851f364e58b98 Android 8.0.53 3.7.8

首次进入页面加载时白屏状态。下载完模型后才恢复正常。

 <kivicube-scene 

    wx:if="{{sceneShow}}" 

    class="kivicube

    scene-id="{{sceneId}}" 

    camera-position="{{cameraPosition}}" 

    bindready="ready

    binderror="error

    binddownloadAssetStart="downloadStart

    binddownloadAssetProgress="downloadProgress

    binddownloadAssetEnd="downloadEnd

    bindloadSceneStart="loadStart

    bindloadSceneEnd="loadEnd

    bindsceneStart="sceneStart

    bindopenUrl="openUrl

    bindphoto="photo

  />

  onLoad: function (options) {

    let id = options.id;

    this.setData({

      sceneId: id

    });

    

    // 开始加载状态

    this.setData({ isLoading: true });

    downloadSceneAsset(this.data.sceneId, (progress) => {

      console.log("progress", progress);

    }).then(() => {

      this.setData({ isLoading: false, isSceneReady: true }); // 下载完成,更新状态

    }).catch((error) => {

      this.setData({ isLoading: false, isSceneReady: false }); // 下载失败,更新状态

    });

  },

  ready({ detail }) {

    console.log("当前场景基础信息", detail);

    if (detail && detail.sceneInfo{

      this.scene = detail.sceneInfo; // 确保正确获取场景实例

    }

  },

  

  downloadStart() {},

  downloadProgress() {},

  downloadEnd() {

    this.setData({

      isSceneReady: true // 下载完成后设置场景准备好

    });

  },

  

  sceneStart() {

    wx.showToast({

      title: "可开始体验场景",

      icon: "none"

    });

  },

  

  photo({ detail: photoPath }) {

    wx.showLoading({

      title: "拍照中",

      mask: true,

    });

    wx.saveImageToPhotosAlbum({

      filePath: photoPath,

      success() {

        wx.hideLoading();

        console.log("保存照片成功");

      },

      fail(e) {

        wx.hideLoading();

        console.error("保存照片失败", e);

      },

    });

  },

  

  onUnload() {},


回答关注问题邀请回答
收藏
登录 后发表内容