【微信小程序】【AR】threejs-miniprogram 安装(76/100)

在这里插入图片描述

配置threejs-miniprogram环境

搭建node环境

初始化node工程

npm init

导入threejs-miniprogram

npm i threejs-miniprogram 

注意:安装threejs-miniprogram 后一定要进行 构建npm 否则引用不生效。由于开发工具和版本的关系可能路径有区别已知路径:工具–构建npm;详情-本地设置–启用npm;

threejs-miniprogram 使用

// pages/ar/ar.js
import getBehavior from './behavior'
import yuvBehavior from './yuvBehavior'
const {
   renderExample1} =require('./example1')
const {
   showAR} =require('./threeJSDemos/threeJS_1')
import {
   createScopedThreejs} from 'threejs-miniprogram'


Page({
   
  behaviors: [getBehavior(), yuvBehavior],
  /**
   * 页面的初始数据
   */
  data: {
   
    theme: 'light',
    camera:null,
    scene:null,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
   

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
   
    wx.createSelectorQuery()
    .select('#webgl'
posted @ 2022-08-01 19:00  lichong951  阅读(29)  评论(0编辑  收藏  举报  来源