-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
62 lines (58 loc) · 1.17 KB
/
index.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
'use strict';
const addon = require('./build/Release/addon.node');
const mesh = require('./lib/mesh');
module.exports = {
load: addon.load,
triangulatePolygons: mesh.triangulatePolygons,
split: mesh.split,
};
// TODO:
// compress binormals
// since we have normals, tangents and binormals, we compress binormals by:
// vec3 binormal2 = cross(normal, tangent)
// float dir = dot(binormal, binormal2)
// in this way, binormal is saved in one float.
/**
* scene = {
* nodes: [...],
* meshes: [...],
* animations: [...],
* TODO: materials: [...],
* }
*
* node = {
* name: '',
* type: '',
* position: [x, y, z],
* rotation: [x, y, z, w],
* scale: [x, y, z],
* children: [...],
*
* // optional (resource reference ID)
* refID: -1,
* }
*
* mesh = {
* name: '',
* points: [...],
* polygons: [...],
* polygonSizes: [...],
* normals: [...],
* tangents: [...],
* binormals: [...],
* colors: [...],
* uvs0: [...],
* uvs1: [...],
* ...: [...],
* uvs7 [...],
* }
*
* TODO:
* material = {
* name: '',
* diffuse: [r, g, b, a],
* ambient: [r, g, b, a],
* texDiffuse: -1,
* texNormal: -1,
* }
*/