运行基本教程示例的three.js安装 |
您所在的位置:网站首页 › html中导入js文件 › 运行基本教程示例的three.js安装 |
这是一个three.js设置问题(关于Safari,MacOS Catalina)。 正如threejs.org所建议的: % brew install node % npm install three % ls -sF node_modules/three/build # shows the right things: three.js, three.module.js etc.然后在我的.html文件中: ... import * as THREE from 'three'; const scene = new THREE.Scene(); ...第一个错误:使用THREE.Scene()而不是THREE.scene()。已修复。 第二个错误:在本地文件路径名中使用了带有- not _的节点模块。已修复。 第三个错误:需要打开Safari开发菜单(Safari->Preferences->Advanced-> in菜单栏)。已修复。 第四个错误:无法访问本地文件。修正了Safari->Develop>禁用本地文件限制。 第五个错误:使用“src=”node_modules/3/build/ .js“而不使用最后的".js",接着是对相关问题的另一个堆栈溢出回答。使用.js后缀修复,这是精确的文件路径。 第六个错误:尝试跳过导入语句。结果是“找不到变量3”。通过恢复到包含导入语句来修正。但这并不是真正的解决办法。 第七个错误:尝试用"import *.“中的\ as前缀*就像建议的那样。错误产生的;恢复的 第八次尝试:尝试 { "imports": { "three": "./path_to_three.module.js" } } import * as THREE from 'three'; const scene = new THREE.Scene(); ... with error "Can't find variable THREE"第九、第十等,尝试(使用CDN而不是NPM的本地安装的three.js树): or or { "imports": { "three": "https://unpkg.com/[email protected]/build/three.module.js" } } import * as THREE from 'three'; const scene = new THREE.Scene(); ... Each of these generate the error: "Can't find variable THREE"是否有一种很好的、简单、可靠的方法来合并three.js库和命名空间,以便第一个最基本的教程示例中的第一个API调用能够真正成功地运行?您可能会认为,有了所有这些支持three.js的网站,以及教程和Q&A试图回答如何使用的问题,就会有一些很好的答案了。我还没找到。什么对你有用? |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |