three.js - 将 THREE.js 与 aurelia-cli 一起使用,导出为全局
问题描述
安装三个.js:npm install three
配置aurelia.json
:
"dependencies": [
{
"name": "three",
"path": "../node_modules/three/build",
"main": "three.min"
}
导入视图:import * as THREE from 'three';
好的,所以这可行,我可以使用three.js
,但是,我也想使用一些插件。具体来说GPUParticleSystem
。现在这个插件依赖于一个全局THREE
对象。在第一次尝试中,我将其添加到aurelia.json
"dependencies": [
{
"name": "three",
"path": "../node_modules/three/build",
"main": "three.min",
"exports": "THREE" //this should make the library a global object?
}
但它似乎不起作用?我无法从 devTools 中看到全局变量。
解决方案
解决此问题的一种可能方法是使用prepend
in aurelia.json
:
...
"prepend": [
"node_modules/three/build/three.min.js",
"node_modules/three/examples/js/GPUParticleSystem.js"
]
...
推荐阅读
- reactjs - 如何在 Gatsby 中实现 Three.js?
- ios - Authorize.net 支付网关 Charge a Credit Card API for iOS swift
- python - 无法通过 Django 的管理页面登录
- spring - 使用“@Scheduled”运行时 getThreadPoolExecutor().getQueue().size() 返回零
- c# - 如何在控制台窗口中使字符串变为粗体?
- java - 访问堆栈顶部元素以递归比较两个堆栈元素是否相同的方法
- javascript - 我循环了 4 个对象并渲染它们的图像,同时根据属性的真实性应用一个类,但有时 DOM 不会重新渲染
- java - java程序中的Unix域套接字描述符泄漏
- mysql - 我们如何在我的 SQL 中获取列表的计数?
- javascript - 导航到不同路线时组件不会被破坏