我正在尝试用我的流星项目加载Dat-GUI:https : //github.com/dataarts/dat.gui 我在客户端/ lib文件夹中添加了dat-GUI源。这是我的代码:
Template.EditorControllbar.rendered = function () {
var controllBar = document.getElementById('controllbar'),
gui, folder, controller;
// Create GUI
gui = new dat.GUI({autoPlace:false});
controllBar.appendChild(gui.domElement);
// Create folders
var renderFolder = gui.addFolder('Render'),
meshFolder = gui.addFolder('Mesh'),
lightFolder = gui.addFolder('Light'),
exportFolder = gui.addFolder('Export');
};
当我运行服务器时,出现以下错误:
Exception from Deps afterFlush function function: ReferenceError: dat is not defined
at Object.Template.EditorControllbar.rendered (http://localhost:3000/client/views/toons/toon_edit/editor_controllbar/editor_controllbar.js?5613eb3f7dfe2c5aed33925dfe2970dcc11a04b4:33:15)
at http://localhost:3000/packages/ui.js?9419ac08328918a04e7a49464a988d45f851e1b0:439:23
at _assign.flush (http://localhost:3000/packages/deps.js?4a82362ae66e863a1c1a8b0a5fec6f665e2038d1:348:13) debug.js:4
相同的代码可在Codepen上使用:http ://codepen.io/praneybehl/pen/DabKv
有谁知道如何用Meteor加载Dat-GUI。任何帮助将不胜感激。
在此先感谢,Praney
您在?中添加了文件https://github.com/dataarts/dat.gui/blob/master/build/dat.gui.min.jsclient/lib
。流星会将所有js文件包装在一个函数中,因此js文件中的var
-variables在其他文件中将不可见,因此,dat
如果您以这种方式添加文件,则无法使用该变量。相反,您需要在文件client/compatibility
夹中添加文件。此文件夹中的js文件不会包装在函数中,因此var变量将是全局变量,您可以在其他文件中使用它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句