在当前项目结构中定义three.js不起作用

时间:2017-01-04 09:43:10

标签: javascript module three.js requirejs

尝试开始使用Three.js。无法让我的项目在本地运行。我试图使用require在我的主脚本中加载three.js。

以下是main.js顶部的代码:

var THREE= {
    REVISION: "79"
};

if(typeof define==="function"&&define.amd) {
    define("three", THREE)
}

else if("undefined"!==typeof exports&&"undefined"!==typeof module) {
    module.exports=THREE
}

我的脚本文件夹

中有tri.js版本79
  index.html 
  scripts/
    main.js
    require.js
    three/
      three.min.js

但是我仍然在我的HTML中收到错误,我在其中调用var obj = new THREE.Object3D();

  

未捕获的ReferenceError:未定义THREE

我对要求不强。所以我不确定require.config在哪里。我下载了require,这里是我认为我应该编辑的代码:

  function newContext(contextName) {
    var inCheckLoaded, Module, context, handlers,
        checkLoadedTimeoutId,
        config = {
            //Defaults. Do not set a default for map
            //config to speed up normalize(), which
            //will run faster if there is no default.
            waitSeconds: 7,
            baseUrl: '',
            paths: {
             "three": "../three/three.min.js"
            },
            bundles: {},
            pkgs: {},
            shim: {
                three: {
                    exports: 'THREE'
                }
            },
            config: {}
        },
        registry = {},
        //registry of just enabled modules, to speed
        //cycle breaking code when lots of modules
        //are registered, but not activated.
        enabledRegistry = {},
        undefEvents = {},
        defQueue = [],
        defined = {},
        urlFetched = {},
        bundlesMap = {},
        requireCounter = 1,
        unnormalizedCounter = 1;

0 个答案:

没有答案