Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat Gadgets Tool Library Class threejs


May 21, 2021 WeChat Mini Program Development Document


Table of contents


threejs-miniprogram

The .js a suitable version of the small program WebGL.

Use

You can refer to the sample project in the example directory or to the following process:

  1. Installed by npm
npm install --save threejs-miniprogram

Once installed, click Build npm in the WeChat Developer Tool.

  1. Import a fitted version of The Three .js
import {createScopedThreejs} from 'threejs-miniprogram'

Page({
  onReady() {
    wx.createSelectorQuery()
      .select('#webgl')
      .node()
      .exec((res) => {
        const canvas = res[0].node
        // 创建一个与 canvas 绑定的 three.js
        const THREE = createScopedThreejs(canvas)
        // 传递并使用 THREE 变量
      })
  }
})

Description

  • The version number of The .js currently in use for this project is 0.108.0, which can be modified by PR or fork if you want to update the threejs version.
  • This fitted version of THREE is not in the global environment, such as other companion class libraries that use The3.js, and needs to be passed into the class library itself.
  • If a mating problem is found during use, it can be fixed with issue feedback or a PR.