-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathnode-worker.ts
55 lines (48 loc) · 1.71 KB
/
node-worker.ts
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
import {UVUnwrapper} from "../src/unwrapperNodeWorker";
import {BufferAttribute, SphereGeometry} from "three";
import * as url from "url";
import * as path from "path";
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
async function start(){
const unwrapper = new UVUnwrapper({BufferAttribute: BufferAttribute});
// Default options
unwrapper.chartOptions = {
fixWinding: false,
maxBoundaryLength: 0,
maxChartArea: 0,
maxCost: 2,
maxIterations: 1,
normalDeviationWeight: 2,
normalSeamWeight: 4,
roundnessWeight: 0.009999999776482582,
straightnessWeight: 6,
textureSeamWeight: 0.5,
useInputMeshUvs: false,
}
unwrapper.packOptions = {
bilinear: true,
blockAlign: false,
bruteForce: false,
createImage: false,
maxChartSize: 0,
padding: 0,
resolution: 0,
rotateCharts: true,
rotateChartsToAxis: true,
texelsPerUnit: 0
}
await unwrapper.loadLibrary(
(mode, progress)=>{console.log(mode, progress);},
// 'https://cdn.jsdelivr.net/npm/xatlasjs@0.2.0/dist/node/xatlas.wasm',
// 'https://cdn.jsdelivr.net/npm/xatlasjs@0.2.0/dist/node/worker.mjs',
`${__dirname}/../node_modules/xatlasjs/dist/node/xatlas.wasm`,
`${__dirname}/../node_modules/xatlasjs/dist/node/worker.mjs`,
); // Make sure to wait for the library to load before unwrapping.
console.log('Library loaded', unwrapper);
const geometry = new SphereGeometry(1, 32, 32);
const atlas = await unwrapper.unwrapGeometry(geometry);
console.log(atlas);
await unwrapper.exit();
}
start()