@babylonjs/serializers 5.0.0-beta.8 → 5.0.0-beta.8-snapshot
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +20 -105
- package/OBJ/index.d.ts +0 -1
- package/OBJ/index.js +0 -2
- package/OBJ/index.js.map +0 -1
- package/OBJ/objSerializer.d.ts +0 -21
- package/OBJ/objSerializer.js +0 -160
- package/OBJ/objSerializer.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +0 -38
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +0 -174
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +0 -24
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +0 -91
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +0 -24
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +0 -74
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +0 -21
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +0 -52
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +0 -34
- package/glTF/2.0/Extensions/KHR_texture_transform.js +0 -137
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +0 -1
- package/glTF/2.0/Extensions/index.d.ts +0 -5
- package/glTF/2.0/Extensions/index.js +0 -6
- package/glTF/2.0/Extensions/index.js.map +0 -1
- package/glTF/2.0/glTFAnimation.d.ts +0 -200
- package/glTF/2.0/glTFAnimation.js +0 -840
- package/glTF/2.0/glTFAnimation.js.map +0 -1
- package/glTF/2.0/glTFData.d.ts +0 -19
- package/glTF/2.0/glTFData.js +0 -53
- package/glTF/2.0/glTFData.js.map +0 -1
- package/glTF/2.0/glTFExporter.d.ts +0 -445
- package/glTF/2.0/glTFExporter.js +0 -1943
- package/glTF/2.0/glTFExporter.js.map +0 -1
- package/glTF/2.0/glTFExporterExtension.d.ts +0 -74
- package/glTF/2.0/glTFExporterExtension.js +0 -3
- package/glTF/2.0/glTFExporterExtension.js.map +0 -1
- package/glTF/2.0/glTFMaterialExporter.d.ts +0 -230
- package/glTF/2.0/glTFMaterialExporter.js +0 -1143
- package/glTF/2.0/glTFMaterialExporter.js.map +0 -1
- package/glTF/2.0/glTFSerializer.d.ts +0 -60
- package/glTF/2.0/glTFSerializer.js +0 -63
- package/glTF/2.0/glTFSerializer.js.map +0 -1
- package/glTF/2.0/glTFUtilities.d.ts +0 -96
- package/glTF/2.0/glTFUtilities.js +0 -196
- package/glTF/2.0/glTFUtilities.js.map +0 -1
- package/glTF/2.0/index.d.ts +0 -8
- package/glTF/2.0/index.js +0 -9
- package/glTF/2.0/index.js.map +0 -1
- package/glTF/2.0/shaders/textureTransform.fragment.d.ts +0 -5
- package/glTF/2.0/shaders/textureTransform.fragment.js +0 -7
- package/glTF/2.0/shaders/textureTransform.fragment.js.map +0 -1
- package/glTF/glTFFileExporter.d.ts +0 -20
- package/glTF/glTFFileExporter.js +0 -3
- package/glTF/glTFFileExporter.js.map +0 -1
- package/glTF/index.d.ts +0 -2
- package/glTF/index.js +0 -3
- package/glTF/index.js.map +0 -1
- package/index.d.ts +0 -3
- package/index.js.map +0 -1
- package/legacy/legacy-glTF2Serializer.d.ts +0 -2
- package/legacy/legacy-glTF2Serializer.js +0 -44
- package/legacy/legacy-glTF2Serializer.js.map +0 -1
- package/legacy/legacy-objSerializer.d.ts +0 -1
- package/legacy/legacy-objSerializer.js +0 -13
- package/legacy/legacy-objSerializer.js.map +0 -1
- package/legacy/legacy-stlSerializer.d.ts +0 -1
- package/legacy/legacy-stlSerializer.js +0 -13
- package/legacy/legacy-stlSerializer.js.map +0 -1
- package/legacy/legacy.d.ts +0 -4
- package/legacy/legacy.js +0 -5
- package/legacy/legacy.js.map +0 -1
- package/readme.md +0 -29
- package/stl/index.d.ts +0 -1
- package/stl/index.js +0 -2
- package/stl/index.js.map +0 -1
- package/stl/stlSerializer.d.ts +0 -17
- package/stl/stlSerializer.js +0 -108
- package/stl/stlSerializer.js.map +0 -1
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
2
|
-
/**
|
|
3
|
-
* @hidden
|
|
4
|
-
*/
|
|
5
|
-
var _GLTFUtilities = /** @class */ (function () {
|
|
6
|
-
function _GLTFUtilities() {
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Creates a buffer view based on the supplied arguments
|
|
10
|
-
* @param bufferIndex index value of the specified buffer
|
|
11
|
-
* @param byteOffset byte offset value
|
|
12
|
-
* @param byteLength byte length of the bufferView
|
|
13
|
-
* @param byteStride byte distance between conequential elements
|
|
14
|
-
* @param name name of the buffer view
|
|
15
|
-
* @returns bufferView for glTF
|
|
16
|
-
*/
|
|
17
|
-
_GLTFUtilities._CreateBufferView = function (bufferIndex, byteOffset, byteLength, byteStride, name) {
|
|
18
|
-
var bufferview = { buffer: bufferIndex, byteLength: byteLength };
|
|
19
|
-
if (byteOffset) {
|
|
20
|
-
bufferview.byteOffset = byteOffset;
|
|
21
|
-
}
|
|
22
|
-
if (name) {
|
|
23
|
-
bufferview.name = name;
|
|
24
|
-
}
|
|
25
|
-
if (byteStride) {
|
|
26
|
-
bufferview.byteStride = byteStride;
|
|
27
|
-
}
|
|
28
|
-
return bufferview;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Creates an accessor based on the supplied arguments
|
|
32
|
-
* @param bufferviewIndex The index of the bufferview referenced by this accessor
|
|
33
|
-
* @param name The name of the accessor
|
|
34
|
-
* @param type The type of the accessor
|
|
35
|
-
* @param componentType The datatype of components in the attribute
|
|
36
|
-
* @param count The number of attributes referenced by this accessor
|
|
37
|
-
* @param byteOffset The offset relative to the start of the bufferView in bytes
|
|
38
|
-
* @param min Minimum value of each component in this attribute
|
|
39
|
-
* @param max Maximum value of each component in this attribute
|
|
40
|
-
* @returns accessor for glTF
|
|
41
|
-
*/
|
|
42
|
-
_GLTFUtilities._CreateAccessor = function (bufferviewIndex, name, type, componentType, count, byteOffset, min, max) {
|
|
43
|
-
var accessor = { name: name, bufferView: bufferviewIndex, componentType: componentType, count: count, type: type };
|
|
44
|
-
if (min != null) {
|
|
45
|
-
accessor.min = min;
|
|
46
|
-
}
|
|
47
|
-
if (max != null) {
|
|
48
|
-
accessor.max = max;
|
|
49
|
-
}
|
|
50
|
-
if (byteOffset != null) {
|
|
51
|
-
accessor.byteOffset = byteOffset;
|
|
52
|
-
}
|
|
53
|
-
return accessor;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Calculates the minimum and maximum values of an array of position floats
|
|
57
|
-
* @param positions Positions array of a mesh
|
|
58
|
-
* @param vertexStart Starting vertex offset to calculate min and max values
|
|
59
|
-
* @param vertexCount Number of vertices to check for min and max values
|
|
60
|
-
* @returns min number array and max number array
|
|
61
|
-
*/
|
|
62
|
-
_GLTFUtilities._CalculateMinMaxPositions = function (positions, vertexStart, vertexCount, convertToRightHandedSystem) {
|
|
63
|
-
var min = [Infinity, Infinity, Infinity];
|
|
64
|
-
var max = [-Infinity, -Infinity, -Infinity];
|
|
65
|
-
var positionStrideSize = 3;
|
|
66
|
-
var indexOffset;
|
|
67
|
-
var position;
|
|
68
|
-
var vector;
|
|
69
|
-
if (vertexCount) {
|
|
70
|
-
for (var i = vertexStart, length_1 = vertexStart + vertexCount; i < length_1; ++i) {
|
|
71
|
-
indexOffset = positionStrideSize * i;
|
|
72
|
-
position = Vector3.FromArray(positions, indexOffset);
|
|
73
|
-
if (convertToRightHandedSystem) {
|
|
74
|
-
_GLTFUtilities._GetRightHandedPositionVector3FromRef(position);
|
|
75
|
-
}
|
|
76
|
-
vector = position.asArray();
|
|
77
|
-
for (var j = 0; j < positionStrideSize; ++j) {
|
|
78
|
-
var num = vector[j];
|
|
79
|
-
if (num < min[j]) {
|
|
80
|
-
min[j] = num;
|
|
81
|
-
}
|
|
82
|
-
if (num > max[j]) {
|
|
83
|
-
max[j] = num;
|
|
84
|
-
}
|
|
85
|
-
++indexOffset;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return { min: min, max: max };
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Converts a new right-handed Vector3
|
|
93
|
-
* @param vector vector3 array
|
|
94
|
-
* @returns right-handed Vector3
|
|
95
|
-
*/
|
|
96
|
-
_GLTFUtilities._GetRightHandedPositionVector3 = function (vector) {
|
|
97
|
-
return new Vector3(vector.x, vector.y, -vector.z);
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Converts a Vector3 to right-handed
|
|
101
|
-
* @param vector Vector3 to convert to right-handed
|
|
102
|
-
*/
|
|
103
|
-
_GLTFUtilities._GetRightHandedPositionVector3FromRef = function (vector) {
|
|
104
|
-
vector.z *= -1;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Converts a three element number array to right-handed
|
|
108
|
-
* @param vector number array to convert to right-handed
|
|
109
|
-
*/
|
|
110
|
-
_GLTFUtilities._GetRightHandedPositionArray3FromRef = function (vector) {
|
|
111
|
-
vector[2] *= -1;
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* Converts a new right-handed Vector3
|
|
115
|
-
* @param vector vector3 array
|
|
116
|
-
* @returns right-handed Vector3
|
|
117
|
-
*/
|
|
118
|
-
_GLTFUtilities._GetRightHandedNormalVector3 = function (vector) {
|
|
119
|
-
return new Vector3(vector.x, vector.y, -vector.z);
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Converts a Vector3 to right-handed
|
|
123
|
-
* @param vector Vector3 to convert to right-handed
|
|
124
|
-
*/
|
|
125
|
-
_GLTFUtilities._GetRightHandedNormalVector3FromRef = function (vector) {
|
|
126
|
-
vector.z *= -1;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Converts a three element number array to right-handed
|
|
130
|
-
* @param vector number array to convert to right-handed
|
|
131
|
-
*/
|
|
132
|
-
_GLTFUtilities._GetRightHandedNormalArray3FromRef = function (vector) {
|
|
133
|
-
vector[2] *= -1;
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Converts a Vector4 to right-handed
|
|
137
|
-
* @param vector Vector4 to convert to right-handed
|
|
138
|
-
*/
|
|
139
|
-
_GLTFUtilities._GetRightHandedVector4FromRef = function (vector) {
|
|
140
|
-
vector.z *= -1;
|
|
141
|
-
vector.w *= -1;
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* Converts a Vector4 to right-handed
|
|
145
|
-
* @param vector Vector4 to convert to right-handed
|
|
146
|
-
*/
|
|
147
|
-
_GLTFUtilities._GetRightHandedArray4FromRef = function (vector) {
|
|
148
|
-
vector[2] *= -1;
|
|
149
|
-
vector[3] *= -1;
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* Converts a Quaternion to right-handed
|
|
153
|
-
* @param quaternion Source quaternion to convert to right-handed
|
|
154
|
-
*/
|
|
155
|
-
_GLTFUtilities._GetRightHandedQuaternionFromRef = function (quaternion) {
|
|
156
|
-
quaternion.x *= -1;
|
|
157
|
-
quaternion.y *= -1;
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Converts a Quaternion to right-handed
|
|
161
|
-
* @param quaternion Source quaternion to convert to right-handed
|
|
162
|
-
*/
|
|
163
|
-
_GLTFUtilities._GetRightHandedQuaternionArrayFromRef = function (quaternion) {
|
|
164
|
-
quaternion[0] *= -1;
|
|
165
|
-
quaternion[1] *= -1;
|
|
166
|
-
};
|
|
167
|
-
_GLTFUtilities._NormalizeTangentFromRef = function (tangent) {
|
|
168
|
-
var length = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y + tangent.z * tangent.z);
|
|
169
|
-
if (length > 0) {
|
|
170
|
-
tangent.x /= length;
|
|
171
|
-
tangent.y /= length;
|
|
172
|
-
tangent.z /= length;
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
_GLTFUtilities._GetDataAccessorElementCount = function (accessorType) {
|
|
176
|
-
switch (accessorType) {
|
|
177
|
-
case "MAT2" /* MAT2 */:
|
|
178
|
-
return 4;
|
|
179
|
-
case "MAT3" /* MAT3 */:
|
|
180
|
-
return 9;
|
|
181
|
-
case "MAT4" /* MAT4 */:
|
|
182
|
-
return 16;
|
|
183
|
-
case "SCALAR" /* SCALAR */:
|
|
184
|
-
return 1;
|
|
185
|
-
case "VEC2" /* VEC2 */:
|
|
186
|
-
return 2;
|
|
187
|
-
case "VEC3" /* VEC3 */:
|
|
188
|
-
return 3;
|
|
189
|
-
case "VEC4" /* VEC4 */:
|
|
190
|
-
return 4;
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
return _GLTFUtilities;
|
|
194
|
-
}());
|
|
195
|
-
export { _GLTFUtilities };
|
|
196
|
-
//# sourceMappingURL=glTFUtilities.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"glTFUtilities.js","sourceRoot":"","sources":["../../../../sourceES6/serializers/src/glTF/2.0/glTFUtilities.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAuB,MAAM,mCAAmC,CAAC;AAEjF;;GAEG;AACH;IAAA;IA8MA,CAAC;IA7MG;;;;;;;;OAQG;IACW,gCAAiB,GAA/B,UAAgC,WAAmB,EAAE,UAAkB,EAAE,UAAkB,EAAE,UAAmB,EAAE,IAAa;QAC3H,IAAI,UAAU,GAAgB,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;QAC9E,IAAI,UAAU,EAAE;YACZ,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC;SACtC;QACD,IAAI,IAAI,EAAE;YACN,UAAU,CAAC,IAAI,GAAG,IAAI,CA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O,CAAC,CAAC,IAAI,MAAM,CAAC;YACpB,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC;YACpB,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC;SACvB;IACL,CAAC;IAEa,2CAA4B,GAA1C,UAA2C,YAA0B;QACjE,QAAQ,YAAY,EAAE;YAClB;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,EAAE,CAAC;YACd;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;SAChB;IACL,CAAC;IACL,qBAAC;AAAD,CAAC,AA9MD,IA8MC","sourcesContent":["import { IBufferView, AccessorType, AccessorComponentType, IAccessor } from \"babylonjs-gltf2interface\";\r\n\r\nimport { FloatArray, Nullable } from \"@babylonjs/core/types\";\r\nimport { Vector3, Vector4, Quaternion } from \"@babylonjs/core/Maths/math.vector\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class _GLTFUtilities {\r\n /**\r\n * Creates a buffer view based on the supplied arguments\r\n * @param bufferIndex index value of the specified buffer\r\n * @param byteOffset byte offset value\r\n * @param byteLength byte length of the bufferView\r\n * @param byteStride byte distance between conequential elements\r\n * @param name name of the buffer view\r\n * @returns bufferView for glTF\r\n */\r\n public static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView {\r\n let bufferview: IBufferView = { buffer: bufferIndex, byteLength: byteLength };\r\n if (byteOffset) {\r\n bufferview.byteOffset = byteOffset;\r\n }\r\n if (name) {\r\n bufferview.name = name;\r\n }\r\n if (byteStride) {\r\n bufferview.byteStride = byteStride;\r\n }\r\n\r\n return bufferview;\r\n }\r\n\r\n /**\r\n * Creates an accessor based on the supplied arguments\r\n * @param bufferviewIndex The index of the bufferview referenced by this accessor\r\n * @param name The name of the accessor\r\n * @param type The type of the accessor\r\n * @param componentType The datatype of components in the attribute\r\n * @param count The number of attributes referenced by this accessor\r\n * @param byteOffset The offset relative to the start of the bufferView in bytes\r\n * @param min Minimum value of each component in this attribute\r\n * @param max Maximum value of each component in this attribute\r\n * @returns accessor for glTF\r\n */\r\n public static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor {\r\n let accessor: IAccessor = { name: name, bufferView: bufferviewIndex, componentType: componentType, count: count, type: type };\r\n\r\n if (min != null) {\r\n accessor.min = min;\r\n }\r\n if (max != null) {\r\n accessor.max = max;\r\n }\r\n if (byteOffset != null) {\r\n accessor.byteOffset = byteOffset;\r\n }\r\n\r\n return accessor;\r\n }\r\n\r\n /**\r\n * Calculates the minimum and maximum values of an array of position floats\r\n * @param positions Positions array of a mesh\r\n * @param vertexStart Starting vertex offset to calculate min and max values\r\n * @param vertexCount Number of vertices to check for min and max values\r\n * @returns min number array and max number array\r\n */\r\n public static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): { min: number[], max: number[] } {\r\n const min = [Infinity, Infinity, Infinity];\r\n const max = [-Infinity, -Infinity, -Infinity];\r\n const positionStrideSize = 3;\r\n let indexOffset: number;\r\n let position: Vector3;\r\n let vector: number[];\r\n\r\n if (vertexCount) {\r\n for (let i = vertexStart, length = vertexStart + vertexCount; i < length; ++i) {\r\n indexOffset = positionStrideSize * i;\r\n\r\n position = Vector3.FromArray(positions, indexOffset);\r\n if (convertToRightHandedSystem) {\r\n _GLTFUtilities._GetRightHandedPositionVector3FromRef(position);\r\n }\r\n vector = position.asArray();\r\n\r\n for (let j = 0; j < positionStrideSize; ++j) {\r\n let num = vector[j];\r\n if (num < min[j]) {\r\n min[j] = num;\r\n }\r\n if (num > max[j]) {\r\n max[j] = num;\r\n }\r\n ++indexOffset;\r\n }\r\n }\r\n }\r\n return { min, max };\r\n }\r\n\r\n /**\r\n * Converts a new right-handed Vector3\r\n * @param vector vector3 array\r\n * @returns right-handed Vector3\r\n */\r\n public static _GetRightHandedPositionVector3(vector: Vector3): Vector3 {\r\n return new Vector3(vector.x, vector.y, -vector.z);\r\n }\r\n\r\n /**\r\n * Converts a Vector3 to right-handed\r\n * @param vector Vector3 to convert to right-handed\r\n */\r\n public static _GetRightHandedPositionVector3FromRef(vector: Vector3) {\r\n vector.z *= -1;\r\n }\r\n\r\n /**\r\n * Converts a three element number array to right-handed\r\n * @param vector number array to convert to right-handed\r\n */\r\n public static _GetRightHandedPositionArray3FromRef(vector: number[]) {\r\n vector[2] *= -1;\r\n }\r\n\r\n /**\r\n * Converts a new right-handed Vector3\r\n * @param vector vector3 array\r\n * @returns right-handed Vector3\r\n */\r\n public static _GetRightHandedNormalVector3(vector: Vector3): Vector3 {\r\n return new Vector3(vector.x, vector.y, -vector.z);\r\n }\r\n\r\n /**\r\n * Converts a Vector3 to right-handed\r\n * @param vector Vector3 to convert to right-handed\r\n */\r\n public static _GetRightHandedNormalVector3FromRef(vector: Vector3) {\r\n vector.z *= -1;\r\n }\r\n\r\n /**\r\n * Converts a three element number array to right-handed\r\n * @param vector number array to convert to right-handed\r\n */\r\n public static _GetRightHandedNormalArray3FromRef(vector: number[]) {\r\n vector[2] *= -1;\r\n }\r\n\r\n /**\r\n * Converts a Vector4 to right-handed\r\n * @param vector Vector4 to convert to right-handed\r\n */\r\n public static _GetRightHandedVector4FromRef(vector: Vector4) {\r\n vector.z *= -1;\r\n vector.w *= -1;\r\n }\r\n\r\n /**\r\n * Converts a Vector4 to right-handed\r\n * @param vector Vector4 to convert to right-handed\r\n */\r\n public static _GetRightHandedArray4FromRef(vector: number[]) {\r\n vector[2] *= -1;\r\n vector[3] *= -1;\r\n }\r\n\r\n /**\r\n * Converts a Quaternion to right-handed\r\n * @param quaternion Source quaternion to convert to right-handed\r\n */\r\n public static _GetRightHandedQuaternionFromRef(quaternion: Quaternion) {\r\n quaternion.x *= -1;\r\n quaternion.y *= -1;\r\n }\r\n\r\n /**\r\n * Converts a Quaternion to right-handed\r\n * @param quaternion Source quaternion to convert to right-handed\r\n */\r\n public static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]) {\r\n quaternion[0] *= -1;\r\n quaternion[1] *= -1;\r\n }\r\n\r\n public static _NormalizeTangentFromRef(tangent: Vector4) {\r\n const length = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y + tangent.z * tangent.z);\r\n if (length > 0) {\r\n tangent.x /= length;\r\n tangent.y /= length;\r\n tangent.z /= length;\r\n }\r\n }\r\n\r\n public static _GetDataAccessorElementCount(accessorType: AccessorType) {\r\n switch (accessorType) {\r\n case AccessorType.MAT2:\r\n return 4;\r\n case AccessorType.MAT3:\r\n return 9;\r\n case AccessorType.MAT4:\r\n return 16;\r\n case AccessorType.SCALAR:\r\n return 1;\r\n case AccessorType.VEC2:\r\n return 2;\r\n case AccessorType.VEC3:\r\n return 3;\r\n case AccessorType.VEC4:\r\n return 4;\r\n }\r\n }\r\n}"]}
|
package/glTF/2.0/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from "./glTFAnimation";
|
|
2
|
-
export * from "./glTFData";
|
|
3
|
-
export * from "./glTFExporter";
|
|
4
|
-
export * from "./glTFExporterExtension";
|
|
5
|
-
export * from "./glTFMaterialExporter";
|
|
6
|
-
export * from "./glTFSerializer";
|
|
7
|
-
export * from "./glTFUtilities";
|
|
8
|
-
export * from "./Extensions/index";
|
package/glTF/2.0/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./glTFAnimation.js";
|
|
2
|
-
export * from "./glTFData.js";
|
|
3
|
-
export * from "./glTFExporter.js";
|
|
4
|
-
export * from "./glTFExporterExtension.js";
|
|
5
|
-
export * from "./glTFMaterialExporter.js";
|
|
6
|
-
export * from "./glTFSerializer.js";
|
|
7
|
-
export * from "./glTFUtilities.js";
|
|
8
|
-
export * from "./Extensions/index.js";
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
package/glTF/2.0/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../sourceES6/serializers/src/glTF/2.0/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./glTFAnimation\";\r\nexport * from \"./glTFData\";\r\nexport * from \"./glTFExporter\";\r\nexport * from \"./glTFExporterExtension\";\r\nexport * from \"./glTFMaterialExporter\";\r\nexport * from \"./glTFSerializer\";\r\nexport * from \"./glTFUtilities\";\r\nexport * from \"./Extensions/index\";"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
|
|
2
|
-
var name = 'textureTransformPixelShader';
|
|
3
|
-
var shader = "precision highp float;\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 textureTransformMat;\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec2 uvTransformed=(textureTransformMat*vec4(vUV.xy,1,1)).xy;\ngl_FragColor=texture2D(textureSampler,uvTransformed);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
|
|
4
|
-
ShaderStore.ShadersStore[name] = shader;
|
|
5
|
-
/** @hidden */
|
|
6
|
-
export var textureTransformPixelShader = { name: name, shader: shader };
|
|
7
|
-
//# sourceMappingURL=textureTransform.fragment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"textureTransform.fragment.js","sourceRoot":"","sources":["../../../../../sourceES6/serializers/src/glTF/2.0/shaders/textureTransform.fragment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,IAAI,IAAI,GAAG,6BAA6B,CAAC;AACzC,IAAI,MAAM,GAAG,mUASX,CAAC;AAEH,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,IAAI,2BAA2B,GAAG,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,CAAC","sourcesContent":["import { ShaderStore } from \"@babylonjs/core/Engines/shaderStore\";\n\nlet name = 'textureTransformPixelShader';\nlet shader = `precision highp float;\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 textureTransformMat;\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec2 uvTransformed=(textureTransformMat*vec4(vUV.xy,1,1)).xy;\ngl_FragColor=texture2D(textureSampler,uvTransformed);\n#define CUSTOM_FRAGMENT_MAIN_END\n}`;\n\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport var textureTransformPixelShader = { name, shader };\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/** @hidden */
|
|
2
|
-
export declare var __IGLTFExporterExtension: number;
|
|
3
|
-
/**
|
|
4
|
-
* Interface for extending the exporter
|
|
5
|
-
* @hidden
|
|
6
|
-
*/
|
|
7
|
-
export interface IGLTFExporterExtension {
|
|
8
|
-
/**
|
|
9
|
-
* The name of this extension
|
|
10
|
-
*/
|
|
11
|
-
readonly name: string;
|
|
12
|
-
/**
|
|
13
|
-
* Defines whether this extension is enabled
|
|
14
|
-
*/
|
|
15
|
-
enabled: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Defines whether this extension is required
|
|
18
|
-
*/
|
|
19
|
-
required: boolean;
|
|
20
|
-
}
|
package/glTF/glTFFileExporter.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"glTFFileExporter.js","sourceRoot":"","sources":["../../../sourceES6/serializers/src/glTF/glTFFileExporter.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,MAAM,CAAC,IAAI,wBAAwB,GAAG,CAAC,CAAC,CAAC,uCAAuC","sourcesContent":["/** @hidden */\r\nexport var __IGLTFExporterExtension = 0; // I am here to allow dts to be created\r\n\r\n/**\r\n * Interface for extending the exporter\r\n * @hidden\r\n */\r\nexport interface IGLTFExporterExtension {\r\n /**\r\n * The name of this extension\r\n */\r\n readonly name: string;\r\n /**\r\n * Defines whether this extension is enabled\r\n */\r\n enabled: boolean;\r\n\r\n /**\r\n * Defines whether this extension is required\r\n */\r\n required: boolean;\r\n}"]}
|
package/glTF/index.d.ts
DELETED
package/glTF/index.js
DELETED
package/glTF/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../sourceES6/serializers/src/glTF/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC","sourcesContent":["export * from \"./glTFFileExporter\";\r\nexport * from \"./2.0/index\";"]}
|
package/index.d.ts
DELETED
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../sourceES6/serializers/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC","sourcesContent":["export * from \"./OBJ/index\";\r\nexport * from \"./glTF/index\";\r\nexport * from \"./stl/index\";"]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as Exporters from "../glTF/glTFFileExporter.js";
|
|
2
|
-
import * as Datas from "../glTF/2.0/glTFData.js";
|
|
3
|
-
import * as Serializers from "../glTF/2.0/glTFSerializer.js";
|
|
4
|
-
import * as Extensions from "../glTF/2.0/Extensions/index.js";
|
|
5
|
-
import * as GLTF2 from "../glTF/2.0/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* This is the entry point for the UMD module.
|
|
8
|
-
* The entry point for a future ESM package should be index.ts
|
|
9
|
-
*/
|
|
10
|
-
var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
|
|
11
|
-
if (typeof globalObject !== "undefined") {
|
|
12
|
-
globalObject.BABYLON = globalObject.BABYLON || {};
|
|
13
|
-
var BABYLON = globalObject.BABYLON;
|
|
14
|
-
BABYLON.GLTF2 = BABYLON.GLTF2 || {};
|
|
15
|
-
BABYLON.GLTF2.Exporter = BABYLON.GLTF2.Exporter || {};
|
|
16
|
-
BABYLON.GLTF2.Exporter.Extensions = BABYLON.GLTF2.Exporter.Extensions || {};
|
|
17
|
-
var keys = [];
|
|
18
|
-
for (var key in Exporters) {
|
|
19
|
-
BABYLON[key] = Exporters[key];
|
|
20
|
-
keys.push(key);
|
|
21
|
-
}
|
|
22
|
-
for (var key in Datas) {
|
|
23
|
-
BABYLON[key] = Datas[key];
|
|
24
|
-
keys.push(key);
|
|
25
|
-
}
|
|
26
|
-
for (var key in Serializers) {
|
|
27
|
-
BABYLON[key] = Serializers[key];
|
|
28
|
-
keys.push(key);
|
|
29
|
-
}
|
|
30
|
-
for (var key in Extensions) {
|
|
31
|
-
BABYLON.GLTF2.Exporter.Extensions[key] = Extensions[key];
|
|
32
|
-
keys.push(key);
|
|
33
|
-
}
|
|
34
|
-
for (var key in GLTF2) {
|
|
35
|
-
// Prevent Reassignment.
|
|
36
|
-
if (keys.indexOf(key) > -1) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
BABYLON.GLTF2.Exporter[key] = GLTF2[key];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export * from "../glTF/glTFFileExporter.js";
|
|
43
|
-
export * from "../glTF/2.0/index.js";
|
|
44
|
-
//# sourceMappingURL=legacy-glTF2Serializer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-glTF2Serializer.js","sourceRoot":"","sources":["../../../sourceES6/serializers/src/legacy/legacy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C,IAAI,CAAC,GAAG,CAAC,CAAC;KAClB;IACD,KAAK,IAAI,GAAG,IAAI,WAAW,EAAE;QACzB,OAAO,CAAC,GAAG,CAAC,GAAS,WAAY,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAClB;IAED,KAAK,IAAI,GAAG,IAAI,UAAU,EAAE;QACxB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,GAAS,UAAW,CAAC,GAAG,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAClB;IAED,KAAK,IAAI,GAAG,IAAI,KAAK,EAAE;QACnB,wBAAwB;QACxB,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;YACxB,SAAS;SACZ;QAED,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAS,KAAM,CAAC,GAAG,CAAC,CAAC;KACnD;CACJ;AAED,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC","sourcesContent":["import * as Exporters from \"../glTF/glTFFileExporter\";\r\nimport * as Datas from \"../glTF/2.0/glTFData\";\r\nimport * as Serializers from \"../glTF/2.0/glTFSerializer\";\r\nimport * as Extensions from \"../glTF/2.0/Extensions/index\";\r\nimport * as GLTF2 from \"../glTF/2.0/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nvar globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);\r\nif (typeof globalObject !== \"undefined\") {\r\n (<any>globalObject).BABYLON = (<any>globalObject).BABYLON || {};\r\n var BABYLON = (<any>globalObject).BABYLON;\r\n BABYLON.GLTF2 = BABYLON.GLTF2 || {};\r\n BABYLON.GLTF2.Exporter = BABYLON.GLTF2.Exporter || {};\r\n BABYLON.GLTF2.Exporter.Extensions = BABYLON.GLTF2.Exporter.Extensions || {};\r\n\r\n const keys = [];\r\n for (var key in Exporters) {\r\n BABYLON[key] = (<any>Exporters)[key];\r\n keys.push(key);\r\n }\r\n for (var key in Datas) {\r\n BABYLON[key] = (<any>Datas)[key];\r\n keys.push(key);\r\n }\r\n for (var key in Serializers) {\r\n BABYLON[key] = (<any>Serializers)[key];\r\n keys.push(key);\r\n }\r\n\r\n for (var key in Extensions) {\r\n BABYLON.GLTF2.Exporter.Extensions[key] = (<any>Extensions)[key];\r\n keys.push(key);\r\n }\r\n\r\n for (var key in GLTF2) {\r\n // Prevent Reassignment.\r\n if (keys.indexOf(key) > -1) {\r\n continue;\r\n }\r\n\r\n BABYLON.GLTF2.Exporter[key] = (<any>GLTF2)[key];\r\n }\r\n}\r\n\r\nexport * from \"../glTF/glTFFileExporter\";\r\nexport * from \"../glTF/2.0/index\";"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../OBJ/index";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as Serializers from "../OBJ/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* This is the entry point for the UMD module.
|
|
4
|
-
* The entry point for a future ESM package should be index.ts
|
|
5
|
-
*/
|
|
6
|
-
var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
|
|
7
|
-
if (typeof globalObject !== "undefined") {
|
|
8
|
-
for (var serializer in Serializers) {
|
|
9
|
-
globalObject.BABYLON[serializer] = Serializers[serializer];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export * from "../OBJ/index.js";
|
|
13
|
-
//# sourceMappingURL=legacy-objSerializer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-objSerializer.js","sourceRoot":"","sources":["../../../sourceES6/serializers/src/legacy/legacy-objSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C;;;GAGG;AACH,IAAI,YAAY,GAAG,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACrH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;IACrC,KAAK,IAAI,UAAU,IAAI,WAAW,EAAE;QAC1B,YAAa,CAAC,OAAO,CAAC,UAAU,CAAC,GAAS,WAAY,CAAC,UAAU,CAAC,CAAC;KAC5E;CACJ;AAED,cAAc,cAAc,CAAC","sourcesContent":["import * as Serializers from \"../OBJ/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nvar globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);\r\nif (typeof globalObject !== \"undefined\") {\r\n for (var serializer in Serializers) {\r\n (<any>globalObject).BABYLON[serializer] = (<any>Serializers)[serializer];\r\n }\r\n}\r\n\r\nexport * from \"../OBJ/index\";"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../stl/index";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as Serializers from "../stl/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* This is the entry point for the UMD module.
|
|
4
|
-
* The entry point for a future ESM package should be index.ts
|
|
5
|
-
*/
|
|
6
|
-
var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
|
|
7
|
-
if (typeof globalObject !== "undefined") {
|
|
8
|
-
for (var serializer in Serializers) {
|
|
9
|
-
globalObject.BABYLON[serializer] = Serializers[serializer];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export * from "../stl/index.js";
|
|
13
|
-
//# sourceMappingURL=legacy-stlSerializer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-stlSerializer.js","sourceRoot":"","sources":["../../../sourceES6/serializers/src/legacy/legacy-stlSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C;;;GAGG;AACH,IAAI,YAAY,GAAG,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACrH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;IACrC,KAAK,IAAI,UAAU,IAAI,WAAW,EAAE;QAC1B,YAAa,CAAC,OAAO,CAAC,UAAU,CAAC,GAAS,WAAY,CAAC,UAAU,CAAC,CAAC;KAC5E;CACJ;AAED,cAAc,cAAc,CAAC","sourcesContent":["import * as Serializers from \"../stl/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nvar globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);\r\nif (typeof globalObject !== \"undefined\") {\r\n for (var serializer in Serializers) {\r\n (<any>globalObject).BABYLON[serializer] = (<any>Serializers)[serializer];\r\n }\r\n}\r\n\r\nexport * from \"../stl/index\";"]}
|
package/legacy/legacy.d.ts
DELETED
package/legacy/legacy.js
DELETED
package/legacy/legacy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../../sourceES6/serializers/src/legacy/legacy.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,CAAC;AAClB,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC","sourcesContent":["import \"../index\";\r\nexport * from \"./legacy-glTF2Serializer\";\r\nexport * from \"./legacy-objSerializer\";\r\nexport * from \"./legacy-stlSerializer\";"]}
|
package/readme.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
Babylon.js Serializers
|
|
2
|
-
=====================
|
|
3
|
-
|
|
4
|
-
# Installation instructions
|
|
5
|
-
|
|
6
|
-
To install using npm :
|
|
7
|
-
|
|
8
|
-
```
|
|
9
|
-
npm install --save @babylonjs/core @babylonjs/serializers
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
# How to use
|
|
13
|
-
|
|
14
|
-
Afterwards it can be imported to the your project using:
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
import { GLTF2Export } from '@babylonjs/serializers/glTF';
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
And used as usual:
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
GLTF2Export.GLTFAsync(scene, "fileName").then((gltf) => {
|
|
24
|
-
gltf.downloadFiles();
|
|
25
|
-
});
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
For more information you can have a look at our [our ES6 dedicated documentation](https://doc.babylonjs.com/features/es6_support) and the [gltf exporter documentation](https://doc.babylonjs.com/extensions/gltfexporter).
|
|
29
|
-
|
package/stl/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./stlSerializer";
|
package/stl/index.js
DELETED
package/stl/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../sourceES6/serializers/src/stl/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC","sourcesContent":["export * from \"./stlSerializer\";"]}
|
package/stl/stlSerializer.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Mesh } from "@babylonjs/core/Meshes/mesh";
|
|
2
|
-
/**
|
|
3
|
-
* Class for generating STL data from a Babylon scene.
|
|
4
|
-
*/
|
|
5
|
-
export declare class STLExport {
|
|
6
|
-
/**
|
|
7
|
-
* Exports the geometry of a Mesh array in .STL file format (ASCII)
|
|
8
|
-
* @param meshes list defines the mesh to serialize
|
|
9
|
-
* @param download triggers the automatic download of the file.
|
|
10
|
-
* @param fileName changes the downloads fileName.
|
|
11
|
-
* @param binary changes the STL to a binary type.
|
|
12
|
-
* @param isLittleEndian toggle for binary type exporter.
|
|
13
|
-
* @param doNotBakeTransform toggle if meshes transforms should be baked or not.
|
|
14
|
-
* @returns the STL as UTF8 string
|
|
15
|
-
*/
|
|
16
|
-
static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
|
|
17
|
-
}
|
package/stl/stlSerializer.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
|
2
|
-
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
3
|
-
/**
|
|
4
|
-
* Class for generating STL data from a Babylon scene.
|
|
5
|
-
*/
|
|
6
|
-
var STLExport = /** @class */ (function () {
|
|
7
|
-
function STLExport() {
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Exports the geometry of a Mesh array in .STL file format (ASCII)
|
|
11
|
-
* @param meshes list defines the mesh to serialize
|
|
12
|
-
* @param download triggers the automatic download of the file.
|
|
13
|
-
* @param fileName changes the downloads fileName.
|
|
14
|
-
* @param binary changes the STL to a binary type.
|
|
15
|
-
* @param isLittleEndian toggle for binary type exporter.
|
|
16
|
-
* @param doNotBakeTransform toggle if meshes transforms should be baked or not.
|
|
17
|
-
* @returns the STL as UTF8 string
|
|
18
|
-
*/
|
|
19
|
-
STLExport.CreateSTL = function (meshes, download, fileName, binary, isLittleEndian, doNotBakeTransform) {
|
|
20
|
-
//Binary support adapted from https://gist.github.com/paulkaplan/6d5f0ab2c7e8fdc68a61
|
|
21
|
-
if (download === void 0) { download = true; }
|
|
22
|
-
if (fileName === void 0) { fileName = 'stlmesh'; }
|
|
23
|
-
if (binary === void 0) { binary = false; }
|
|
24
|
-
if (isLittleEndian === void 0) { isLittleEndian = true; }
|
|
25
|
-
if (doNotBakeTransform === void 0) { doNotBakeTransform = false; }
|
|
26
|
-
var getFaceData = function (indices, vertices, i) {
|
|
27
|
-
var id = [indices[i] * 3, indices[i + 1] * 3, indices[i + 2] * 3];
|
|
28
|
-
var v = [
|
|
29
|
-
new Vector3(vertices[id[0]], vertices[id[0] + 2], vertices[id[0] + 1]),
|
|
30
|
-
new Vector3(vertices[id[1]], vertices[id[1] + 2], vertices[id[1] + 1]),
|
|
31
|
-
new Vector3(vertices[id[2]], vertices[id[2] + 2], vertices[id[2] + 1])
|
|
32
|
-
];
|
|
33
|
-
var p1p2 = v[0].subtract(v[1]);
|
|
34
|
-
var p3p2 = v[2].subtract(v[1]);
|
|
35
|
-
var n = (Vector3.Cross(p3p2, p1p2)).normalize();
|
|
36
|
-
return { v: v, n: n };
|
|
37
|
-
};
|
|
38
|
-
var writeVector = function (dataview, offset, vector, isLittleEndian) {
|
|
39
|
-
offset = writeFloat(dataview, offset, vector.x, isLittleEndian);
|
|
40
|
-
offset = writeFloat(dataview, offset, vector.y, isLittleEndian);
|
|
41
|
-
return writeFloat(dataview, offset, vector.z, isLittleEndian);
|
|
42
|
-
};
|
|
43
|
-
var writeFloat = function (dataview, offset, value, isLittleEndian) {
|
|
44
|
-
dataview.setFloat32(offset, value, isLittleEndian);
|
|
45
|
-
return offset + 4;
|
|
46
|
-
};
|
|
47
|
-
var data;
|
|
48
|
-
var faceCount = 0;
|
|
49
|
-
var offset = 0;
|
|
50
|
-
if (binary) {
|
|
51
|
-
for (var i = 0; i < meshes.length; i++) {
|
|
52
|
-
var mesh = meshes[i];
|
|
53
|
-
var indices = mesh.getIndices();
|
|
54
|
-
faceCount += indices ? indices.length / 3 : 0;
|
|
55
|
-
}
|
|
56
|
-
var bufferSize = 84 + (50 * faceCount);
|
|
57
|
-
var buffer = new ArrayBuffer(bufferSize);
|
|
58
|
-
data = new DataView(buffer);
|
|
59
|
-
offset += 80;
|
|
60
|
-
data.setUint32(offset, faceCount, isLittleEndian);
|
|
61
|
-
offset += 4;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
data = 'solid stlmesh\r\n';
|
|
65
|
-
}
|
|
66
|
-
for (var i = 0; i < meshes.length; i++) {
|
|
67
|
-
var mesh = meshes[i];
|
|
68
|
-
if (!doNotBakeTransform) {
|
|
69
|
-
mesh.bakeCurrentTransformIntoVertices();
|
|
70
|
-
}
|
|
71
|
-
var vertices = mesh.getVerticesData(VertexBuffer.PositionKind) || [];
|
|
72
|
-
var indices = mesh.getIndices() || [];
|
|
73
|
-
for (var i_1 = 0; i_1 < indices.length; i_1 += 3) {
|
|
74
|
-
var fd = getFaceData(indices, vertices, i_1);
|
|
75
|
-
if (binary) {
|
|
76
|
-
offset = writeVector(data, offset, fd.n, isLittleEndian);
|
|
77
|
-
offset = writeVector(data, offset, fd.v[0], isLittleEndian);
|
|
78
|
-
offset = writeVector(data, offset, fd.v[1], isLittleEndian);
|
|
79
|
-
offset = writeVector(data, offset, fd.v[2], isLittleEndian);
|
|
80
|
-
offset += 2;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
data += 'facet normal ' + fd.n.x + ' ' + fd.n.y + ' ' + fd.n.z + '\r\n';
|
|
84
|
-
data += '\touter loop\r\n';
|
|
85
|
-
data += '\t\tvertex ' + fd.v[0].x + ' ' + fd.v[0].y + ' ' + fd.v[0].z + '\r\n';
|
|
86
|
-
data += '\t\tvertex ' + fd.v[1].x + ' ' + fd.v[1].y + ' ' + fd.v[1].z + '\r\n';
|
|
87
|
-
data += '\t\tvertex ' + fd.v[2].x + ' ' + fd.v[2].y + ' ' + fd.v[2].z + '\r\n';
|
|
88
|
-
data += '\tendloop\r\n';
|
|
89
|
-
data += 'endfacet\r\n';
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (!binary) {
|
|
94
|
-
data += 'endsolid stlmesh';
|
|
95
|
-
}
|
|
96
|
-
if (download) {
|
|
97
|
-
var a = document.createElement('a');
|
|
98
|
-
var blob = new Blob([data], { 'type': 'application/octet-stream' });
|
|
99
|
-
a.href = window.URL.createObjectURL(blob);
|
|
100
|
-
a.download = fileName + ".stl";
|
|
101
|
-
a.click();
|
|
102
|
-
}
|
|
103
|
-
return data;
|
|
104
|
-
};
|
|
105
|
-
return STLExport;
|
|
106
|
-
}());
|
|
107
|
-
export { STLExport };
|
|
108
|
-
//# sourceMappingURL=stlSerializer.js.map
|
package/stl/stlSerializer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stlSerializer.js","sourceRoot":"","sources":["../../../sourceES6/serializers/src/stl/stlSerializer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAE5D;;EAEE;AACF;IAAA;IA4GA,CAAC;IA3GG;;;;;;;;;MASE;IACY,mBAAS,GAAvB,UAAwB,MAAc,EAAE,QAAwB,EAAE,QAA4B,EAAE,MAAuB,EAAE,cAA8B,EAAE,kBAAmC;QAExL,qFAAqF;QAFjD,yBAAA,EAAA,eAAwB;QAAE,yBAAA,EAAA,oBAA4B;QAAE,uBAAA,EAAA,cAAuB;QAAE,+BAAA,EAAA,qBAA8B;QAAE,mCAAA,EAAA,0BAAmC;QAIxL,IAAI,WAAW,GAAG,UAAU,OAAY,EAAE,QAAa,EAAE,CAAS;YAC9D,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAClE,IAAI,CAAC,GAAG;gBACJ,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG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\"@babylonjs/core/Buffers/buffer\";\nimport { Vector3 } from \"@babylonjs/core/Maths/math.vector\";\n\n/**\n* Class for generating STL data from a Babylon scene.\n*/\nexport class STLExport {\n /**\n * Exports the geometry of a Mesh array in .STL file format (ASCII)\n * @param meshes list defines the mesh to serialize\n * @param download triggers the automatic download of the file.\n * @param fileName changes the downloads fileName.\n * @param binary changes the STL to a binary type.\n * @param isLittleEndian toggle for binary type exporter.\n * @param doNotBakeTransform toggle if meshes transforms should be baked or not.\n * @returns the STL as UTF8 string\n */\n public static CreateSTL(meshes: Mesh[], download: boolean = true, fileName: string = 'stlmesh', binary: boolean = false, isLittleEndian: boolean = true, doNotBakeTransform: boolean = false): any {\n\n //Binary support adapted from https://gist.github.com/paulkaplan/6d5f0ab2c7e8fdc68a61\n\n let getFaceData = function (indices: any, vertices: any, i: number) {\n let id = [indices[i] * 3, indices[i + 1] * 3, indices[i + 2] * 3];\n let v = [\n new Vector3(vertices[id[0]], vertices[id[0] + 2], vertices[id[0] + 1]),\n new Vector3(vertices[id[1]], vertices[id[1] + 2], vertices[id[1] + 1]),\n new Vector3(vertices[id[2]], vertices[id[2] + 2], vertices[id[2] + 1])\n ];\n let p1p2 = v[0].subtract(v[1]);\n let p3p2 = v[2].subtract(v[1]);\n let n = (Vector3.Cross(p3p2, p1p2)).normalize();\n\n return { v, n };\n };\n\n let writeVector = function (dataview: any, offset: number, vector: Vector3, isLittleEndian: boolean) {\n offset = writeFloat(dataview, offset, vector.x, isLittleEndian);\n offset = writeFloat(dataview, offset, vector.y, isLittleEndian);\n return writeFloat(dataview, offset, vector.z, isLittleEndian);\n };\n\n let writeFloat = function (dataview: any, offset: number, value: number, isLittleEndian: boolean) {\n dataview.setFloat32(offset, value, isLittleEndian);\n return offset + 4;\n };\n\n let data;\n\n let faceCount = 0;\n let offset = 0;\n\n if (binary) {\n for (let i = 0; i < meshes.length; i++) {\n let mesh = meshes[i];\n let indices = mesh.getIndices();\n faceCount += indices ? indices.length / 3 : 0;\n }\n\n let bufferSize = 84 + (50 * faceCount);\n let buffer = new ArrayBuffer(bufferSize);\n data = new DataView(buffer);\n\n offset += 80;\n data.setUint32(offset, faceCount, isLittleEndian);\n offset += 4;\n\n } else {\n data = 'solid stlmesh\\r\\n';\n }\n\n for (let i = 0; i < meshes.length; i++) {\n let mesh = meshes[i];\n if (!doNotBakeTransform) {\n mesh.bakeCurrentTransformIntoVertices();\n }\n let vertices = mesh.getVerticesData(VertexBuffer.PositionKind) || [];\n let indices = mesh.getIndices() || [];\n\n for (let i = 0; i < indices.length; i += 3) {\n let fd = getFaceData(indices, vertices, i);\n\n if (binary) {\n offset = writeVector(data, offset, fd.n, isLittleEndian);\n offset = writeVector(data, offset, fd.v[0], isLittleEndian);\n offset = writeVector(data, offset, fd.v[1], isLittleEndian);\n offset = writeVector(data, offset, fd.v[2], isLittleEndian);\n offset += 2;\n } else {\n data += 'facet normal ' + fd.n.x + ' ' + fd.n.y + ' ' + fd.n.z + '\\r\\n';\n data += '\\touter loop\\r\\n';\n data += '\\t\\tvertex ' + fd.v[0].x + ' ' + fd.v[0].y + ' ' + fd.v[0].z + '\\r\\n';\n data += '\\t\\tvertex ' + fd.v[1].x + ' ' + fd.v[1].y + ' ' + fd.v[1].z + '\\r\\n';\n data += '\\t\\tvertex ' + fd.v[2].x + ' ' + fd.v[2].y + ' ' + fd.v[2].z + '\\r\\n';\n data += '\\tendloop\\r\\n';\n data += 'endfacet\\r\\n';\n }\n\n }\n }\n\n if (!binary) {\n data += 'endsolid stlmesh';\n }\n\n if (download) {\n let a = document.createElement('a');\n let blob = new Blob([data], { 'type': 'application/octet-stream' });\n a.href = window.URL.createObjectURL(blob);\n a.download = fileName + \".stl\";\n a.click();\n }\n\n return data;\n }\n}\n"]}
|