Skip to content

Commit 459bf8a

Browse files
committed
initial import
0 parents  commit 459bf8a

File tree

6 files changed

+460
-0
lines changed

6 files changed

+460
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

build.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict';
2+
3+
var fs = require('fs');
4+
var path = require('path');
5+
var request = require('sync-request');
6+
var beautify = require('js-beautify').js_beautify;
7+
var uglify = require("uglify-js");
8+
9+
var revision = 'r83';
10+
11+
var cdnurl = 'https://cdn.rawgit.com/mrdoob/three.js/' + revision + '/';
12+
13+
var modules = [
14+
'examples/js/loaders',
15+
'examples/js/controls',
16+
'examples/js/renderers',
17+
'examples/js/shaders'
18+
];
19+
20+
var config = {};
21+
config.paths = {};
22+
config.shim = {};
23+
24+
modules.forEach(function(m) {
25+
var res = request('GET', 'https://api.github.com/repos/mrdoob/three.js/contents/' + m + '?ref=' + revision, {
26+
'headers': {
27+
'user-agent': 'UA'
28+
}
29+
});
30+
var data = JSON.parse(res.body.toString('utf-8'));
31+
data.forEach(function(d) {
32+
if (path.extname(d.name) == '.js') {
33+
var name = d.name.replace(/\.js$/, '');
34+
var fpath = d.path.replace(/\.js$/, '');
35+
config.paths[name] = cdnurl + fpath;
36+
config.shim[name] = { deps: ['THREE_global'] };
37+
}
38+
});
39+
});
40+
41+
var out = fs.readFileSync('threejs-requirejs.tmpl.js', 'utf-8');
42+
out = out.replace('{cdnurl}', cdnurl);
43+
out = out.replace('{config}', JSON.stringify(config));
44+
var formatted = beautify(out);
45+
var minified = uglify.minify(out, {fromString: true}).code;
46+
fs.writeFileSync('build/threejs-requirejs.js', formatted, 'utf-8');
47+
fs.writeFileSync('build/threejs-requirejs.min.js', minified, 'utf-8');

0 commit comments

Comments
 (0)