微信小程序解决引入绝对路径js

App({
    // 真的就这一行
    require : function($uri){return require($uri)},
    onLaunch : function(){
    }
});

然后其他任何路径下的 js 如下

// pages/admin/order/list/page.js
const app = getApp(); // 
// 除了不是 / 开头,这真的就是个绝对路径,让那些 ../../.. 见鬼去吧
const Api = app.require('lib/api.js');

Page({
    onLoad : function(){
    }
});
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
是的,微信小程序可以引入带动画的3D模型。以下是一种实现方式: 1. 将3D模型(包含动画)转换为gltf格式。你可以使用3D建模软件(如Blender、Maya、3ds Max等)导出模型为gltf格式,确保动画被正确导出。 2. 在微信小程序的项目中创建一个Canvas用于渲染3D场景。可以在页面的wxml文件中添加一个Canvas元素: ```html <canvas canvas-id="webgl" style="width: 100%; height: 100%;"></canvas> ``` 3. 在页面的js文件中引入Three.js和gltf加载器,并编写相关代码: ```javascript // 引入Three.js和GLTFLoader import * as THREE from 'three' import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader' Page({ onReady() { const canvas = wx.createSelectorQuery().select('#webgl') canvas.node().exec((res) => { const width = res[0].width const height = res[0].height const renderer = new THREE.WebGLRenderer({ canvas: canvas.node(), antialias: true }) renderer.setSize(width, height) const scene = new THREE.Scene() const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000) camera.position.z = 5 // 创建GLTFLoader实例 const loader = new GLTFLoader() // 加载gltf模型 loader.load('path/to/model.gltf', (gltf) => { const model = gltf.scene scene.add(model) // 获取模型的动画 const animations = gltf.animations // 创建动画混合器 const mixer = new THREE.AnimationMixer(model) // 添加动画到混合器 for (let i = 0; i < animations.length; i++) { const animation = animations[i] mixer.clipAction(animation).play() } // 渲染动画 function animate() { requestAnimationFrame(animate) mixer.update(0.01) renderer.render(scene, camera) } animate() }) }) } }) ``` 其中,`path/to/model.gltf`是你要加载的3D模型的路径。 这样,你就可以在微信小程序引入带动画的3D模型了。确保根据你的项目需求进行相应的调整和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值