forked from gchoqueux/potree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
197 lines (150 loc) · 4.13 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
const path = require('path');
const gulp = require('gulp');
const exec = require('child_process').exec;
const fs = require("fs");
const fsp = fs.promises;
const concat = require('gulp-concat');
const connect = require('gulp-connect');
const {watch} = gulp;
const {createExamplesPage} = require("./src/tools/create_potree_page");
const {createGithubPage} = require("./src/tools/create_github_page");
const {createIconsPage} = require("./src/tools/create_icons_page");
let paths = {
laslaz: [
"build/workers/laslaz-worker.js",
"build/workers/lasdecoder-worker.js",
],
html: [
"src/viewer/potree.css",
"src/viewer/sidebar.html",
"src/viewer/profile.html"
],
resources: [
"resources/**/*"
]
};
let workers = {
"LASLAZWorker": [
"libs/plasio/workers/laz-perf.js",
"libs/plasio/workers/laz-loader-worker.js"
],
"LASDecoderWorker": [
"src/workers/LASDecoderWorker.js"
],
"EptLaszipDecoderWorker": [
"src/workers/EptLaszipDecoderWorker.js"
],
"EptBinaryDecoderWorker": [
"src/workers/EptBinaryDecoderWorker.js"
],
"EptZstandardDecoderWorker": [
"src/workers/EptZstandardDecoderWorker.js"
]
};
// these libs are lazily loaded
// in order for the lazy loader to find them, independent of the path of the html file,
// we package them together with potree
let lazyLibs = {
"geopackage": "libs/geopackage",
"sql.js": "libs/sql.js"
};
let shaders = [
"src/materials/shaders/pointcloud.vs",
"src/materials/shaders/pointcloud.fs",
"src/materials/shaders/pointcloud_sm.vs",
"src/materials/shaders/pointcloud_sm.fs",
"src/materials/shaders/normalize.vs",
"src/materials/shaders/normalize.fs",
"src/materials/shaders/normalize_and_edl.fs",
"src/materials/shaders/edl.vs",
"src/materials/shaders/edl.fs",
"src/materials/shaders/blur.vs",
"src/materials/shaders/blur.fs",
];
// For development, it is now possible to use 'gulp webserver'
// from the command line to start the server (default port is 8080)
gulp.task('webserver', gulp.series(async function() {
server = connect.server({
port: 1234,
https: false,
});
}));
gulp.task('examples_page', async function(done) {
await Promise.all([
createExamplesPage(),
createGithubPage(),
]);
done();
});
gulp.task('icons_viewer', async function(done) {
await createIconsPage();
done();
});
gulp.task('test', async function() {
console.log("asdfiae8ofh");
});
gulp.task("workers", async function(done){
for(let workerName of Object.keys(workers)){
gulp.src(workers[workerName])
.pipe(concat(`${workerName}.js`))
.pipe(gulp.dest('build/potree/workers'));
}
done();
});
gulp.task("lazylibs", async function(done){
for(let libname of Object.keys(lazyLibs)){
const libpath = lazyLibs[libname];
gulp.src([`${libpath}/**/*`])
.pipe(gulp.dest(`build/potree/lazylibs/${libname}`));
}
done();
});
gulp.task("shaders", async function(){
const components = [
"let Shaders = {};"
];
for(let file of shaders){
const filename = path.basename(file);
const content = await fsp.readFile(file);
const prep = `Shaders["${filename}"] = \`${content}\``;
components.push(prep);
}
components.push("export {Shaders};");
const content = components.join("\n\n");
const targetPath = `./build/shaders/shaders.js`;
if(!fs.existsSync("build/shaders")){
fs.mkdirSync("build/shaders");
}
fs.writeFileSync(targetPath, content, {flag: "w"});
});
gulp.task('build',
gulp.series(
gulp.parallel("workers", "lazylibs", "shaders", "icons_viewer", "examples_page"),
async function(done){
gulp.src(paths.html).pipe(gulp.dest('build/potree'));
gulp.src(paths.resources).pipe(gulp.dest('build/potree/resources'));
gulp.src(["LICENSE"]).pipe(gulp.dest('build/potree'));
done();
}
)
);
gulp.task("pack", async function(){
exec('rollup -c', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
});
});
gulp.task('watch', gulp.parallel("build", "pack", "webserver", async function() {
let watchlist = [
'src/**/*.js',
'src/**/**/*.js',
'src/**/*.css',
'src/**/*.html',
'src/**/*.vs',
'src/**/*.fs',
'resources/**/*',
'examples//**/*.json',
'!resources/icons/index.html',
];
watch(watchlist, gulp.series("build", "pack"));
}));