New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babylonjs-serializers

Package Overview
Dependencies
Maintainers
1
Versions
685
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babylonjs-serializers - npm Package Compare versions

Comparing version

to
3.2.0-alpha2

662

babylonjs.serializers.js

@@ -146,2 +146,664 @@ var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : this);

var BABYLON;
(function (BABYLON) {
var GLTF2Export = /** @class */ (function () {
function GLTF2Export() {
}
/**
* Exports the geometry of a Mesh array in .gltf file format.
* If glb is set to true, exports as .glb.
* @param meshes
* @param materials
*
* @returns {[fileName: string]: string | Blob} Returns an object with a .gltf, .glb and associates textures
* as keys and their data and paths as values.
*/
GLTF2Export.GLTF = function (scene, filename) {
var glTFPrefix = filename.replace(/\.[^/.]+$/, "");
var gltfGenerator = new BABYLON._GLTF2Exporter(scene);
return gltfGenerator._generateGLTF(glTFPrefix);
};
/**
*
* @param meshes
* @param filename
*
* @returns {[fileName: string]: string | Blob} Returns an object with a .glb filename as key and data as value
*/
GLTF2Export.GLB = function (scene, filename) {
var glTFPrefix = filename.replace(/\.[^/.]+$/, "");
var gltfGenerator = new BABYLON._GLTF2Exporter(scene);
return gltfGenerator._generateGLB(glTFPrefix);
};
return GLTF2Export;
}());
BABYLON.GLTF2Export = GLTF2Export;
})(BABYLON || (BABYLON = {}));
//# sourceMappingURL=babylon.glTFSerializer.js.map
var BABYLON;
(function (BABYLON) {
var _GLTF2Exporter = /** @class */ (function () {
function _GLTF2Exporter(babylonScene) {
this.asset = { generator: "BabylonJS", version: "2.0" };
this.babylonScene = babylonScene;
this.bufferViews = new Array();
this.accessors = new Array();
this.meshes = new Array();
this.scenes = new Array();
this.nodes = new Array();
var totalByteLength = 0;
totalByteLength = this.createScene(this.babylonScene, totalByteLength);
this.totalByteLength = totalByteLength;
}
/**
* Creates a buffer view based on teh supplied arguments
* @param bufferIndex
* @param byteOffset
* @param byteLength
*
* @returns {_IGLTFBufferView}
*/
_GLTF2Exporter.prototype.createBufferView = function (bufferIndex, byteOffset, byteLength) {
var bufferview = { buffer: bufferIndex, byteLength: byteLength };
if (byteOffset > 0) {
bufferview.byteOffset = byteOffset;
}
return bufferview;
};
/**
* Creates an accessor based on the supplied arguments
* @param bufferviewIndex
* @param name
* @param type
* @param componentType
* @param count
* @param min
* @param max
*
* @returns {_IGLTFAccessor}
*/
_GLTF2Exporter.prototype.createAccessor = function (bufferviewIndex, name, type, componentType, count, min, max) {
var accessor = { name: name, bufferView: bufferviewIndex, componentType: componentType, count: count, type: type };
if (min) {
accessor.min = min;
}
if (max) {
accessor.max = max;
}
return accessor;
};
/**
* Calculates the minimum and maximum values of an array of floats, based on stride
* @param buff
* @param vertexStart
* @param vertexCount
* @param arrayOffset
* @param stride
*
* @returns {min: number[], max: number[]} min number array and max number array
*/
_GLTF2Exporter.prototype.calculateMinMax = function (buff, vertexStart, vertexCount, arrayOffset, stride) {
var min = [Infinity, Infinity, Infinity];
var max = [-Infinity, -Infinity, -Infinity];
var end = vertexStart + vertexCount;
if (vertexCount > 0) {
for (var i = vertexStart; i < end; ++i) {
var index = stride * i;
for (var j = 0; j < stride; ++j) {
if (buff[index] < min[j]) {
min[j] = buff[index];
}
if (buff[index] > max[j]) {
max[j] = buff[index];
}
++index;
}
}
}
return { min: min, max: max };
};
/**
* Write mesh attribute data to buffer.
* Returns the bytelength of the data.
* @param vertexBufferType
* @param submesh
* @param meshAttributeArray
* @param strideSize
* @param byteOffset
* @param dataBuffer
* @param useRightHandedSystem
*
* @returns {number} byte length
*/
_GLTF2Exporter.prototype.writeAttributeData = function (vertexBufferType, submesh, meshAttributeArray, strideSize, byteOffset, dataBuffer, useRightHandedSystem) {
var byteOff = byteOffset;
var end = submesh.verticesStart + submesh.verticesCount;
var byteLength = 0;
switch (vertexBufferType) {
case BABYLON.VertexBuffer.PositionKind: {
for (var k = submesh.verticesStart; k < end; ++k) {
var index = k * strideSize;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index], true);
byteOff += 4;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 1], true);
byteOff += 4;
if (useRightHandedSystem) {
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 2], true);
}
else {
dataBuffer.setFloat32(byteOff, -meshAttributeArray[index + 2], true);
}
byteOff += 4;
}
byteLength = submesh.verticesCount * 12;
break;
}
case BABYLON.VertexBuffer.NormalKind: {
for (var k = submesh.verticesStart; k < end; ++k) {
var index = k * strideSize;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index], true);
byteOff += 4;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 1], true);
byteOff += 4;
if (useRightHandedSystem) {
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 2], true);
}
else {
dataBuffer.setFloat32(byteOff, -meshAttributeArray[index + 2], true);
}
byteOff += 4;
}
byteLength = submesh.verticesCount * 12;
break;
}
case BABYLON.VertexBuffer.TangentKind: {
for (var k = submesh.indexStart; k < end; ++k) {
var index = k * strideSize;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index], true);
byteOff += 4;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 1], true);
byteOff += 4;
if (useRightHandedSystem) {
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 2], true);
}
else {
dataBuffer.setFloat32(byteOff, -meshAttributeArray[index + 2], true);
}
byteOff += 4;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 3], true);
byteOff += 4;
}
byteLength = submesh.verticesCount * 16;
break;
}
case BABYLON.VertexBuffer.ColorKind: {
for (var k = submesh.verticesStart; k < end; ++k) {
var index = k * strideSize;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index], true);
byteOff += 4;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 1], true);
byteOff += 4;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 2], true);
byteOff += 4;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 3], true);
byteOff += 4;
}
byteLength = submesh.verticesCount * 16;
break;
}
case BABYLON.VertexBuffer.UVKind: {
for (var k = submesh.verticesStart; k < end; ++k) {
var index = k * strideSize;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index], true);
byteOff += 4;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 1], true);
byteOff += 4;
}
byteLength = submesh.verticesCount * 8;
break;
}
case BABYLON.VertexBuffer.UV2Kind: {
for (var k = submesh.verticesStart; k < end; ++k) {
var index = k * strideSize;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index], true);
byteOff += 4;
dataBuffer.setFloat32(byteOff, meshAttributeArray[index + 1], true);
byteOff += 4;
}
byteLength = submesh.verticesCount * 8;
break;
}
default: {
throw new Error("Unsupported vertex buffer type: " + vertexBufferType);
}
}
return byteLength;
};
/**
* Generates glTF json data
* @param glb
* @param glTFPrefix
* @param prettyPrint
*
* @returns {string} json data as string
*/
_GLTF2Exporter.prototype.generateJSON = function (glb, glTFPrefix, prettyPrint) {
var buffer = { byteLength: this.totalByteLength };
var glTF = {
buffers: [buffer],
asset: this.asset,
meshes: this.meshes,
scenes: this.scenes,
nodes: this.nodes,
bufferViews: this.bufferViews,
accessors: this.accessors
};
if (this.scenes.length > 0) {
glTF.scene = 0;
}
if (!glb) {
buffer.uri = glTFPrefix + ".bin";
}
var jsonText = prettyPrint ? JSON.stringify(glTF, null, 2) : JSON.stringify(glTF);
return jsonText;
};
/**
* Generates data for .gltf and .bin files based on the glTF prefix string
* @param glTFPrefix
*
* @returns {[x: string]: string | Blob} object with glTF json tex filename
* and binary file name as keys and their data as values
*/
_GLTF2Exporter.prototype._generateGLTF = function (glTFPrefix) {
var jsonText = this.generateJSON(false, glTFPrefix, true);
var binaryBuffer = this.generateBinary();
var bin = new Blob([binaryBuffer], { type: 'application/octet-stream' });
var glTFFileName = glTFPrefix + '.gltf';
var glTFBinFile = glTFPrefix + '.bin';
var container = new BABYLON._GLTFData();
container._glTFFiles[glTFFileName] = jsonText;
container._glTFFiles[glTFBinFile] = bin;
return container;
};
/**
* Creates a binary buffer for glTF
*
* @returns {ArrayBuffer}
*/
_GLTF2Exporter.prototype.generateBinary = function () {
var byteOffset = 0;
var binaryBuffer = new ArrayBuffer(this.totalByteLength);
var dataBuffer = new DataView(binaryBuffer);
byteOffset = this.createScene(this.babylonScene, byteOffset, dataBuffer);
return binaryBuffer;
};
/**
* Generates a glb file from the json and binary data.
* Returns an object with the glb file name as the key and data as the value.
* @param jsonText
* @param binaryBuffer
* @param glTFPrefix
*
* @returns {[glbFileName: string]: Blob} object with glb filename as key and data as value
*/
_GLTF2Exporter.prototype._generateGLB = function (glTFPrefix) {
var jsonText = this.generateJSON(true);
var binaryBuffer = this.generateBinary();
var glbFileName = glTFPrefix + '.glb';
var headerLength = 12;
var chunkLengthPrefix = 8;
var jsonLength = jsonText.length;
var jsonRemainder = jsonLength % 4;
var binRemainder = binaryBuffer.byteLength % 4;
var jsonPadding = jsonRemainder === 0 ? jsonRemainder : 4 - jsonRemainder;
var binPadding = binRemainder === 0 ? binRemainder : 4 - binRemainder;
var byteLength = headerLength + (2 * chunkLengthPrefix) + jsonLength + jsonPadding + binaryBuffer.byteLength + binPadding;
//header
var headerBuffer = new ArrayBuffer(headerLength);
var headerBufferView = new DataView(headerBuffer);
headerBufferView.setUint32(0, 0x46546C67, true); //glTF
headerBufferView.setUint32(4, 2, true); // version
headerBufferView.setUint32(8, byteLength, true); // total bytes in file
//json chunk
var jsonChunkBuffer = new ArrayBuffer(chunkLengthPrefix + jsonLength + jsonPadding);
var jsonChunkBufferView = new DataView(jsonChunkBuffer);
jsonChunkBufferView.setUint32(0, jsonLength + jsonPadding, true);
jsonChunkBufferView.setUint32(4, 0x4E4F534A, true);
//json chunk bytes
var jsonData = new Uint8Array(jsonChunkBuffer, chunkLengthPrefix);
for (var i = 0; i < jsonLength; ++i) {
jsonData[i] = jsonText.charCodeAt(i);
}
//json padding
var jsonPaddingView = new Uint8Array(jsonChunkBuffer, chunkLengthPrefix + jsonLength);
for (var i = 0; i < jsonPadding; ++i) {
jsonPaddingView[i] = 0x20;
}
//binary chunk
var binaryChunkBuffer = new ArrayBuffer(chunkLengthPrefix);
var binaryChunkBufferView = new DataView(binaryChunkBuffer);
binaryChunkBufferView.setUint32(0, binaryBuffer.byteLength, true);
binaryChunkBufferView.setUint32(4, 0x004E4942, true);
// binary padding
var binPaddingBuffer = new ArrayBuffer(binPadding);
var binPaddingView = new Uint8Array(binPaddingBuffer);
for (var i = 0; i < binPadding; ++i) {
binPaddingView[i] = 0;
}
// binary data
var glbFile = new Blob([headerBuffer, jsonChunkBuffer, binaryChunkBuffer, binaryBuffer, binPaddingBuffer], { type: 'application/octet-stream' });
var container = new BABYLON._GLTFData();
container._glTFFiles[glbFileName] = glbFile;
return container;
};
/**
* Sets the TRS for each node
* @param node
* @param babylonMesh
* @param useRightHandedSystem
*/
_GLTF2Exporter.prototype.setNodeTransformation = function (node, babylonMesh, useRightHandedSystem) {
if (!(babylonMesh.position.x === 0 && babylonMesh.position.y === 0 && babylonMesh.position.z === 0)) {
if (useRightHandedSystem) {
node.translation = babylonMesh.position.asArray();
}
else {
node.translation = [babylonMesh.position.x, babylonMesh.position.y, -babylonMesh.position.z];
}
}
if (!(babylonMesh.scaling.x === 1 && babylonMesh.scaling.y === 1 && babylonMesh.scaling.z === 1)) {
if (useRightHandedSystem) {
node.scale = babylonMesh.scaling.asArray();
}
else {
node.scale = [babylonMesh.scaling.x, babylonMesh.scaling.y, -babylonMesh.scaling.z];
}
}
var rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(babylonMesh.rotation.y, babylonMesh.rotation.x, babylonMesh.rotation.z);
if (babylonMesh.rotationQuaternion) {
rotationQuaternion = rotationQuaternion.multiply(babylonMesh.rotationQuaternion);
}
if (!(rotationQuaternion.x === 0 && rotationQuaternion.y === 0 && rotationQuaternion.z === 0 && rotationQuaternion.w === 1)) {
if (useRightHandedSystem) {
node.rotation = rotationQuaternion.asArray();
}
else {
node.rotation = [-rotationQuaternion.x, -rotationQuaternion.y, rotationQuaternion.z, rotationQuaternion.w];
}
}
};
/**
* Sets data for the primitive attributes of each submesh
* @param mesh
* @param babylonMesh
* @param byteOffset
* @param useRightHandedSystem
* @param dataBuffer
*
* @returns {number} bytelength of the primitive attributes plus the passed in byteOffset
*/
_GLTF2Exporter.prototype.setPrimitiveAttributes = function (mesh, babylonMesh, byteOffset, useRightHandedSystem, dataBuffer) {
// go through all mesh primitives (submeshes)
for (var j = 0; j < babylonMesh.subMeshes.length; ++j) {
var bufferMesh = null;
var submesh = babylonMesh.subMeshes[j];
var meshPrimitive = { attributes: {} };
if (babylonMesh instanceof BABYLON.Mesh) {
bufferMesh = babylonMesh;
}
else if (babylonMesh instanceof BABYLON.InstancedMesh) {
bufferMesh = babylonMesh.sourceMesh;
}
// Loop through each attribute of the submesh (mesh primitive)
if (bufferMesh.isVerticesDataPresent(BABYLON.VertexBuffer.PositionKind)) {
var positionVertexBuffer = bufferMesh.getVertexBuffer(BABYLON.VertexBuffer.PositionKind);
var positionVertexBufferOffset = positionVertexBuffer.getOffset();
var positions = positionVertexBuffer.getData();
var positionStrideSize = positionVertexBuffer.getStrideSize();
if (dataBuffer) {
byteOffset += this.writeAttributeData(BABYLON.VertexBuffer.PositionKind, submesh, positions, positionStrideSize, byteOffset, dataBuffer, useRightHandedSystem);
}
else {
// Create bufferview
var byteLength = submesh.verticesCount * 12;
var bufferview = this.createBufferView(0, byteOffset, byteLength);
byteOffset += byteLength;
this.bufferViews.push(bufferview);
// Create accessor
var result = this.calculateMinMax(positions, submesh.verticesStart, submesh.verticesCount, positionVertexBufferOffset, positionStrideSize);
var accessor = this.createAccessor(this.bufferViews.length - 1, "Position", "VEC3", 5126, submesh.verticesCount, result.min, result.max);
this.accessors.push(accessor);
meshPrimitive.attributes.POSITION = this.accessors.length - 1;
}
}
if (bufferMesh.isVerticesDataPresent(BABYLON.VertexBuffer.NormalKind)) {
var normalVertexBuffer = bufferMesh.getVertexBuffer(BABYLON.VertexBuffer.NormalKind);
var normals = normalVertexBuffer.getData();
var normalStrideSize = normalVertexBuffer.getStrideSize();
if (dataBuffer) {
byteOffset += this.writeAttributeData(BABYLON.VertexBuffer.NormalKind, submesh, normals, normalStrideSize, byteOffset, dataBuffer, useRightHandedSystem);
}
else {
// Create bufferview
var byteLength = submesh.verticesCount * 12;
var bufferview = this.createBufferView(0, byteOffset, byteLength);
byteOffset += byteLength;
this.bufferViews.push(bufferview);
// Create accessor
var accessor = this.createAccessor(this.bufferViews.length - 1, "Normal", "VEC3", 5126, submesh.verticesCount);
this.accessors.push(accessor);
meshPrimitive.attributes.NORMAL = this.accessors.length - 1;
}
}
if (bufferMesh.isVerticesDataPresent(BABYLON.VertexBuffer.TangentKind)) {
var tangentVertexBuffer = bufferMesh.getVertexBuffer(BABYLON.VertexBuffer.TangentKind);
var tangents = tangentVertexBuffer.getData();
var tangentStrideSize = tangentVertexBuffer.getStrideSize();
if (dataBuffer) {
byteOffset += this.writeAttributeData(BABYLON.VertexBuffer.TangentKind, submesh, tangents, tangentStrideSize, byteOffset, dataBuffer, useRightHandedSystem);
}
else {
// Create bufferview
var byteLength = submesh.verticesCount * 16;
var bufferview = this.createBufferView(0, byteOffset, byteLength);
byteOffset += byteLength;
this.bufferViews.push(bufferview);
// Create accessor
var accessor = this.createAccessor(this.bufferViews.length - 1, "Tangent", "VEC4", 5126, submesh.verticesCount);
this.accessors.push(accessor);
meshPrimitive.attributes.TANGENT = this.accessors.length - 1;
}
}
if (bufferMesh.isVerticesDataPresent(BABYLON.VertexBuffer.ColorKind)) {
var colorVertexBuffer = bufferMesh.getVertexBuffer(BABYLON.VertexBuffer.ColorKind);
var colors = colorVertexBuffer.getData();
var colorStrideSize = colorVertexBuffer.getStrideSize();
if (dataBuffer) {
byteOffset += this.writeAttributeData(BABYLON.VertexBuffer.ColorKind, submesh, colors, colorStrideSize, byteOffset, dataBuffer, useRightHandedSystem);
}
else {
// Create bufferview
var byteLength = submesh.verticesCount * 16;
var bufferview = this.createBufferView(0, byteOffset, byteLength);
byteOffset += byteLength;
this.bufferViews.push(bufferview);
// Create accessor
var accessor = this.createAccessor(this.bufferViews.length - 1, "Color", "VEC4", 5126, submesh.verticesCount);
this.accessors.push(accessor);
meshPrimitive.attributes.COLOR_0 = this.accessors.length - 1;
}
}
if (bufferMesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
var texCoord0VertexBuffer = bufferMesh.getVertexBuffer(BABYLON.VertexBuffer.UVKind);
var texCoords0 = texCoord0VertexBuffer.getData();
var texCoord0StrideSize = texCoord0VertexBuffer.getStrideSize();
if (dataBuffer) {
byteOffset += this.writeAttributeData(BABYLON.VertexBuffer.UVKind, submesh, texCoords0, texCoord0StrideSize, byteOffset, dataBuffer, useRightHandedSystem);
}
else {
// Create bufferview
var byteLength = submesh.verticesCount * 8;
var bufferview = this.createBufferView(0, byteOffset, byteLength);
byteOffset += byteLength;
this.bufferViews.push(bufferview);
// Create accessor
var accessor = this.createAccessor(this.bufferViews.length - 1, "Texture Coords", "VEC2", 5126, submesh.verticesCount);
this.accessors.push(accessor);
meshPrimitive.attributes.TEXCOORD_0 = this.accessors.length - 1;
}
}
if (bufferMesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind)) {
var texCoord1VertexBuffer = bufferMesh.getVertexBuffer(BABYLON.VertexBuffer.UV2Kind);
var texCoords1 = texCoord1VertexBuffer.getData();
var texCoord1StrideSize = texCoord1VertexBuffer.getStrideSize();
if (dataBuffer) {
byteOffset += this.writeAttributeData(BABYLON.VertexBuffer.UV2Kind, submesh, texCoords1, texCoord1StrideSize, byteOffset, dataBuffer, useRightHandedSystem);
}
else {
// Create bufferview
var byteLength = submesh.verticesCount * 8;
var bufferview = this.createBufferView(0, byteOffset, byteLength);
byteOffset += byteLength;
this.bufferViews.push(bufferview);
// Create accessor
var accessor = this.createAccessor(this.bufferViews.length - 1, "Texture Coords", "VEC2", 5126, submesh.verticesCount);
this.accessors.push(accessor);
meshPrimitive.attributes.TEXCOORD_1 = this.accessors.length - 1;
}
}
if (bufferMesh.getTotalIndices() > 0) {
if (dataBuffer) {
var indices = bufferMesh.getIndices();
var start = submesh.indexStart;
var end = submesh.indexCount + start;
var byteOff = byteOffset;
for (var k = start; k < end; k = k + 3) {
dataBuffer.setUint32(byteOff, indices[k], true);
byteOff += 4;
dataBuffer.setUint32(byteOff, indices[k + 1], true);
byteOff += 4;
dataBuffer.setUint32(byteOff, indices[k + 2], true);
byteOff += 4;
}
var byteLength = submesh.indexCount * 4;
byteOffset += byteLength;
}
else {
// Create bufferview
var indicesCount = submesh.indexCount;
var byteLength = indicesCount * 4;
var bufferview = this.createBufferView(0, byteOffset, byteLength);
byteOffset += byteLength;
this.bufferViews.push(bufferview);
// Create accessor
var accessor = this.createAccessor(this.bufferViews.length - 1, "Indices", "SCALAR", 5125, indicesCount);
this.accessors.push(accessor);
meshPrimitive.indices = this.accessors.length - 1;
}
}
if (bufferMesh.material) {
//TODO: Implement Material
}
mesh.primitives.push(meshPrimitive);
}
return byteOffset;
};
/**
* Creates a glTF scene based on the array of meshes.
* Returns the the total byte offset.
* @param gltf
* @param byteOffset
* @param buffer
* @param dataBuffer
*
* @returns {number} bytelength + byteoffset
*/
_GLTF2Exporter.prototype.createScene = function (babylonScene, byteOffset, dataBuffer) {
if (babylonScene.meshes.length > 0) {
var babylonMeshes = babylonScene.meshes;
var scene = { nodes: new Array() };
for (var i = 0; i < babylonMeshes.length; ++i) {
// create node to hold translation/rotation/scale and the mesh
var node = { mesh: -1 };
var babylonMesh = babylonMeshes[i];
var useRightHandedSystem = babylonMesh.getScene().useRightHandedSystem;
// Set transformation
this.setNodeTransformation(node, babylonMesh, useRightHandedSystem);
// create mesh
var mesh = { primitives: new Array() };
mesh.primitives = [];
byteOffset = this.setPrimitiveAttributes(mesh, babylonMesh, byteOffset, useRightHandedSystem, dataBuffer);
// go through all mesh primitives (submeshes)
this.meshes.push(mesh);
node.mesh = this.meshes.length - 1;
if (babylonMesh.name) {
node.name = babylonMesh.name;
}
this.nodes.push(node);
scene.nodes.push(this.nodes.length - 1);
}
this.scenes.push(scene);
}
return byteOffset;
};
return _GLTF2Exporter;
}());
BABYLON._GLTF2Exporter = _GLTF2Exporter;
})(BABYLON || (BABYLON = {}));
//# sourceMappingURL=babylon.glTFExporter.js.map
var BABYLON;
(function (BABYLON) {
/**
* Class for holding and downloading glTF file data
*/
var _GLTFData = /** @class */ (function () {
function _GLTFData() {
this._glTFFiles = {};
}
/**
* Downloads glTF data.
*/
_GLTFData.prototype.downloadFiles = function () {
/**
* Checks for a matching suffix at the end of a string (for ES5 and lower)
* @param str
* @param suffix
*
* @returns {boolean} indicating whether the suffix matches or not
*/
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
for (var key in this._glTFFiles) {
var link = document.createElement('a');
document.body.appendChild(link);
link.setAttribute("type", "hidden");
link.download = key;
var blob = this._glTFFiles[key];
var mimeType = void 0;
if (endsWith(key, ".glb")) {
mimeType = { type: "model/gltf-binary" };
}
else if (endsWith(key, ".bin")) {
mimeType = { type: "application/octet-stream" };
}
else if (endsWith(key, ".gltf")) {
mimeType = { type: "model/gltf+json" };
}
link.href = window.URL.createObjectURL(new Blob([blob], mimeType));
link.click();
}
};
return _GLTFData;
}());
BABYLON._GLTFData = _GLTFData;
})(BABYLON || (BABYLON = {}));
//# sourceMappingURL=babylon.glTFData.js.map
(function universalModuleDefinition(root, factory) {

@@ -148,0 +810,0 @@ var f = factory();

2

babylonjs.serializers.min.js

@@ -1,1 +0,1 @@

var globalObject="undefined"!=typeof global?global:"undefined"!=typeof window?window:this,babylonDependency=globalObject&&globalObject.BABYLON||BABYLON||"undefined"!=typeof require&&require("babylonjs"),BABYLON=babylonDependency,__decorate=this&&this.__decorate||function(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])};return function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}})(),BABYLON;!(function(e){var t=(function(){function t(){}return t.OBJ=function(t,o,r,i){var n=[],a=1;o&&(r||(r="mat"),n.push("mtllib "+r+".mtl"));for(var s=0;s<t.length;s++){n.push("g object"+s),n.push("o object_"+s);var u=null;if(i){var p=e.Matrix.Translation(t[s].position.x,t[s].position.y,t[s].position.z);u=e.Matrix.Translation(-t[s].position.x,-t[s].position.y,-t[s].position.z),t[s].bakeTransformIntoVertices(p)}if(o){var l=t[s].material;l&&n.push("usemtl "+l.id)}var f=t[s].geometry;if(f){var c=f.getVerticesData("position"),d=f.getVerticesData("normal"),h=f.getVerticesData("uv"),b=f.getIndices(),m=0;if(c&&d&&h&&b){for(var x=0;x<c.length;x+=3)n.push("v "+c[x]+" "+c[x+1]+" "+c[x+2]),m++;for(x=0;x<d.length;x+=3)n.push("vn "+d[x]+" "+d[x+1]+" "+d[x+2]);for(x=0;x<h.length;x+=2)n.push("vt "+h[x]+" "+h[x+1]);for(x=0;x<b.length;x+=3)n.push("f "+(b[x+2]+a)+"/"+(b[x+2]+a)+"/"+(b[x+2]+a)+" "+(b[x+1]+a)+"/"+(b[x+1]+a)+"/"+(b[x+1]+a)+" "+(b[x]+a)+"/"+(b[x]+a)+"/"+(b[x]+a));i&&u&&t[s].bakeTransformIntoVertices(u),a+=m}}}return n.join("\n")},t.MTL=function(e){var t=[],o=e.material;t.push("newmtl mat1"),t.push(" Ns "+o.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+o.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+o.ambientColor.r.toFixed(4)+" "+o.ambientColor.g.toFixed(4)+" "+o.ambientColor.b.toFixed(4)),t.push(" Kd "+o.diffuseColor.r.toFixed(4)+" "+o.diffuseColor.g.toFixed(4)+" "+o.diffuseColor.b.toFixed(4)),t.push(" Ks "+o.specularColor.r.toFixed(4)+" "+o.specularColor.g.toFixed(4)+" "+o.specularColor.b.toFixed(4)),t.push(" Ke "+o.emissiveColor.r.toFixed(4)+" "+o.emissiveColor.g.toFixed(4)+" "+o.emissiveColor.b.toFixed(4));return o.ambientTexture&&t.push(" map_Ka "+o.ambientTexture.name),o.diffuseTexture&&t.push(" map_Kd "+o.diffuseTexture.name),o.specularTexture&&t.push(" map_Ks "+o.specularTexture.name),o.bumpTexture&&t.push(" map_bump -imfchan z "+o.bumpTexture.name),o.opacityTexture&&t.push(" map_d "+o.opacityTexture.name),t.join("\n")},t})();e.OBJExport=t})(BABYLON||(BABYLON={})),(function(e,t){var o=t();e&&e.BABYLON||("object"==typeof exports&&"object"==typeof module?module.exports=o:"function"==typeof define&&define.amd?define(["BJSSerializers"],t):"object"==typeof exports?exports.BJSSerializers=o:e.BABYLON=o)})(this,(function(){return BABYLON}));
var globalObject="undefined"!=typeof global?global:"undefined"!=typeof window?window:this,babylonDependency=globalObject&&globalObject.BABYLON||BABYLON||"undefined"!=typeof require&&require("babylonjs"),BABYLON=babylonDependency,__decorate=this&&this.__decorate||function(e,t,r,i){var s,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(a=(n<3?s(a):n>3?s(t,r,a):s(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}})(),BABYLON;!(function(e){var t=(function(){function t(){}return t.OBJ=function(t,r,i,s){var n=[],a=1;r&&(i||(i="mat"),n.push("mtllib "+i+".mtl"));for(var o=0;o<t.length;o++){n.push("g object"+o),n.push("o object_"+o);var u=null;if(s){var f=e.Matrix.Translation(t[o].position.x,t[o].position.y,t[o].position.z);u=e.Matrix.Translation(-t[o].position.x,-t[o].position.y,-t[o].position.z),t[o].bakeTransformIntoVertices(f)}if(r){var c=t[o].material;c&&n.push("usemtl "+c.id)}var h=t[o].geometry;if(h){var l=h.getVerticesData("position"),p=h.getVerticesData("normal"),d=h.getVerticesData("uv"),v=h.getIndices(),g=0;if(l&&p&&d&&v){for(var b=0;b<l.length;b+=3)n.push("v "+l[b]+" "+l[b+1]+" "+l[b+2]),g++;for(b=0;b<p.length;b+=3)n.push("vn "+p[b]+" "+p[b+1]+" "+p[b+2]);for(b=0;b<d.length;b+=2)n.push("vt "+d[b]+" "+d[b+1]);for(b=0;b<v.length;b+=3)n.push("f "+(v[b+2]+a)+"/"+(v[b+2]+a)+"/"+(v[b+2]+a)+" "+(v[b+1]+a)+"/"+(v[b+1]+a)+"/"+(v[b+1]+a)+" "+(v[b]+a)+"/"+(v[b]+a)+"/"+(v[b]+a));s&&u&&t[o].bakeTransformIntoVertices(u),a+=g}}}return n.join("\n")},t.MTL=function(e){var t=[],r=e.material;t.push("newmtl mat1"),t.push(" Ns "+r.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+r.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+r.ambientColor.r.toFixed(4)+" "+r.ambientColor.g.toFixed(4)+" "+r.ambientColor.b.toFixed(4)),t.push(" Kd "+r.diffuseColor.r.toFixed(4)+" "+r.diffuseColor.g.toFixed(4)+" "+r.diffuseColor.b.toFixed(4)),t.push(" Ks "+r.specularColor.r.toFixed(4)+" "+r.specularColor.g.toFixed(4)+" "+r.specularColor.b.toFixed(4)),t.push(" Ke "+r.emissiveColor.r.toFixed(4)+" "+r.emissiveColor.g.toFixed(4)+" "+r.emissiveColor.b.toFixed(4));return r.ambientTexture&&t.push(" map_Ka "+r.ambientTexture.name),r.diffuseTexture&&t.push(" map_Kd "+r.diffuseTexture.name),r.specularTexture&&t.push(" map_Ks "+r.specularTexture.name),r.bumpTexture&&t.push(" map_bump -imfchan z "+r.bumpTexture.name),r.opacityTexture&&t.push(" map_d "+r.opacityTexture.name),t.join("\n")},t})();e.OBJExport=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.GLTF=function(t,r){var i=r.replace(/\.[^\/.]+$/,"");return new e._GLTF2Exporter(t)._generateGLTF(i)},t.GLB=function(t,r){var i=r.replace(/\.[^\/.]+$/,"");return new e._GLTF2Exporter(t)._generateGLB(i)},t})();e.GLTF2Export=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this.asset={generator:"BabylonJS",version:"2.0"},this.babylonScene=e,this.bufferViews=new Array,this.accessors=new Array,this.meshes=new Array,this.scenes=new Array,this.nodes=new Array;var t=0;t=this.createScene(this.babylonScene,t),this.totalByteLength=t}return t.prototype.createBufferView=function(e,t,r){var i={buffer:e,byteLength:r};return t>0&&(i.byteOffset=t),i},t.prototype.createAccessor=function(e,t,r,i,s,n,a){var o={name:t,bufferView:e,componentType:i,count:s,type:r};return n&&(o.min=n),a&&(o.max=a),o},t.prototype.calculateMinMax=function(e,t,r,i,s){var n=[1/0,1/0,1/0],a=[-1/0,-1/0,-1/0],o=t+r;if(r>0)for(var u=t;u<o;++u)for(var f=s*u,c=0;c<s;++c)e[f]<n[c]&&(n[c]=e[f]),e[f]>a[c]&&(a[c]=e[f]),++f;return{min:n,max:a}},t.prototype.writeAttributeData=function(t,r,i,s,n,a,o){var u=n,f=r.verticesStart+r.verticesCount,c=0;switch(t){case e.VertexBuffer.PositionKind:case e.VertexBuffer.NormalKind:for(var h=r.verticesStart;h<f;++h){var l=h*s;a.setFloat32(u,i[l],!0),u+=4,a.setFloat32(u,i[l+1],!0),u+=4,o?a.setFloat32(u,i[l+2],!0):a.setFloat32(u,-i[l+2],!0),u+=4}c=12*r.verticesCount;break;case e.VertexBuffer.TangentKind:for(var h=r.indexStart;h<f;++h){var l=h*s;a.setFloat32(u,i[l],!0),u+=4,a.setFloat32(u,i[l+1],!0),u+=4,o?a.setFloat32(u,i[l+2],!0):a.setFloat32(u,-i[l+2],!0),u+=4,a.setFloat32(u,i[l+3],!0),u+=4}c=16*r.verticesCount;break;case e.VertexBuffer.ColorKind:for(var h=r.verticesStart;h<f;++h){var l=h*s;a.setFloat32(u,i[l],!0),u+=4,a.setFloat32(u,i[l+1],!0),u+=4,a.setFloat32(u,i[l+2],!0),u+=4,a.setFloat32(u,i[l+3],!0),u+=4}c=16*r.verticesCount;break;case e.VertexBuffer.UVKind:case e.VertexBuffer.UV2Kind:for(var h=r.verticesStart;h<f;++h){var l=h*s;a.setFloat32(u,i[l],!0),u+=4,a.setFloat32(u,i[l+1],!0),u+=4}c=8*r.verticesCount;break;default:throw new Error("Unsupported vertex buffer type: "+t)}return c},t.prototype.generateJSON=function(e,t,r){var i={byteLength:this.totalByteLength},s={buffers:[i],asset:this.asset,meshes:this.meshes,scenes:this.scenes,nodes:this.nodes,bufferViews:this.bufferViews,accessors:this.accessors};return this.scenes.length>0&&(s.scene=0),e||(i.uri=t+".bin"),r?JSON.stringify(s,null,2):JSON.stringify(s)},t.prototype._generateGLTF=function(t){var r=this.generateJSON(!1,t,!0),i=this.generateBinary(),s=new Blob([i],{type:"application/octet-stream"}),n=t+".gltf",a=t+".bin",o=new e._GLTFData;return o._glTFFiles[n]=r,o._glTFFiles[a]=s,o},t.prototype.generateBinary=function(){var e=0,t=new ArrayBuffer(this.totalByteLength),r=new DataView(t);return e=this.createScene(this.babylonScene,e,r),t},t.prototype._generateGLB=function(t){var r=this.generateJSON(!0),i=this.generateBinary(),s=t+".glb",n=r.length,a=n%4,o=i.byteLength%4,u=0===a?a:4-a,f=0===o?o:4-o,c=28+n+u+i.byteLength+f,h=new ArrayBuffer(12),l=new DataView(h);l.setUint32(0,1179937895,!0),l.setUint32(4,2,!0),l.setUint32(8,c,!0);var p=new ArrayBuffer(8+n+u),d=new DataView(p);d.setUint32(0,n+u,!0),d.setUint32(4,1313821514,!0);for(var v=new Uint8Array(p,8),g=0;g<n;++g)v[g]=r.charCodeAt(g);for(var b=new Uint8Array(p,8+n),g=0;g<u;++g)b[g]=32;var B=new ArrayBuffer(8),y=new DataView(B);y.setUint32(0,i.byteLength,!0),y.setUint32(4,5130562,!0);for(var x=new ArrayBuffer(f),V=new Uint8Array(x),g=0;g<f;++g)V[g]=0;var w=new Blob([h,p,B,i,x],{type:"application/octet-stream"}),m=new e._GLTFData;return m._glTFFiles[s]=w,m},t.prototype.setNodeTransformation=function(t,r,i){0===r.position.x&&0===r.position.y&&0===r.position.z||(t.translation=i?r.position.asArray():[r.position.x,r.position.y,-r.position.z]),1===r.scaling.x&&1===r.scaling.y&&1===r.scaling.z||(t.scale=i?r.scaling.asArray():[r.scaling.x,r.scaling.y,-r.scaling.z]);var s=e.Quaternion.RotationYawPitchRoll(r.rotation.y,r.rotation.x,r.rotation.z);r.rotationQuaternion&&(s=s.multiply(r.rotationQuaternion)),0===s.x&&0===s.y&&0===s.z&&1===s.w||(t.rotation=i?s.asArray():[-s.x,-s.y,s.z,s.w])},t.prototype.setPrimitiveAttributes=function(t,r,i,s,n){for(var a=0;a<r.subMeshes.length;++a){var o=null,u=r.subMeshes[a],f={attributes:{}};if(r instanceof e.Mesh?o=r:r instanceof e.InstancedMesh&&(o=r.sourceMesh),o.isVerticesDataPresent(e.VertexBuffer.PositionKind)){var c=o.getVertexBuffer(e.VertexBuffer.PositionKind),h=c.getOffset(),l=c.getData(),p=c.getStrideSize();if(n)i+=this.writeAttributeData(e.VertexBuffer.PositionKind,u,l,p,i,n,s);else{var d=12*u.verticesCount,v=this.createBufferView(0,i,d);i+=d,this.bufferViews.push(v);var g=this.calculateMinMax(l,u.verticesStart,u.verticesCount,h,p),b=this.createAccessor(this.bufferViews.length-1,"Position","VEC3",5126,u.verticesCount,g.min,g.max);this.accessors.push(b),f.attributes.POSITION=this.accessors.length-1}}if(o.isVerticesDataPresent(e.VertexBuffer.NormalKind)){var B=o.getVertexBuffer(e.VertexBuffer.NormalKind),y=B.getData(),x=B.getStrideSize();if(n)i+=this.writeAttributeData(e.VertexBuffer.NormalKind,u,y,x,i,n,s);else{var d=12*u.verticesCount,v=this.createBufferView(0,i,d);i+=d,this.bufferViews.push(v);var b=this.createAccessor(this.bufferViews.length-1,"Normal","VEC3",5126,u.verticesCount);this.accessors.push(b),f.attributes.NORMAL=this.accessors.length-1}}if(o.isVerticesDataPresent(e.VertexBuffer.TangentKind)){var V=o.getVertexBuffer(e.VertexBuffer.TangentKind),w=V.getData(),m=V.getStrideSize();if(n)i+=this.writeAttributeData(e.VertexBuffer.TangentKind,u,w,m,i,n,s);else{var d=16*u.verticesCount,v=this.createBufferView(0,i,d);i+=d,this.bufferViews.push(v);var b=this.createAccessor(this.bufferViews.length-1,"Tangent","VEC4",5126,u.verticesCount);this.accessors.push(b),f.attributes.TANGENT=this.accessors.length-1}}if(o.isVerticesDataPresent(e.VertexBuffer.ColorKind)){var A=o.getVertexBuffer(e.VertexBuffer.ColorKind),C=A.getData(),F=A.getStrideSize();if(n)i+=this.writeAttributeData(e.VertexBuffer.ColorKind,u,C,F,i,n,s);else{var d=16*u.verticesCount,v=this.createBufferView(0,i,d);i+=d,this.bufferViews.push(v);var b=this.createAccessor(this.bufferViews.length-1,"Color","VEC4",5126,u.verticesCount);this.accessors.push(b),f.attributes.COLOR_0=this.accessors.length-1}}if(o.isVerticesDataPresent(e.VertexBuffer.UVKind)){var T=o.getVertexBuffer(e.VertexBuffer.UVKind),O=T.getData(),L=T.getStrideSize();if(n)i+=this.writeAttributeData(e.VertexBuffer.UVKind,u,O,L,i,n,s);else{var d=8*u.verticesCount,v=this.createBufferView(0,i,d);i+=d,this.bufferViews.push(v);var b=this.createAccessor(this.bufferViews.length-1,"Texture Coords","VEC2",5126,u.verticesCount);this.accessors.push(b),f.attributes.TEXCOORD_0=this.accessors.length-1}}if(o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)){var _=o.getVertexBuffer(e.VertexBuffer.UV2Kind),S=_.getData(),N=_.getStrideSize();if(n)i+=this.writeAttributeData(e.VertexBuffer.UV2Kind,u,S,N,i,n,s);else{var d=8*u.verticesCount,v=this.createBufferView(0,i,d);i+=d,this.bufferViews.push(v);var b=this.createAccessor(this.bufferViews.length-1,"Texture Coords","VEC2",5126,u.verticesCount);this.accessors.push(b),f.attributes.TEXCOORD_1=this.accessors.length-1}}if(o.getTotalIndices()>0)if(n){for(var D=o.getIndices(),K=u.indexStart,U=u.indexCount+K,P=i,Y=K;Y<U;Y+=3)n.setUint32(P,D[Y],!0),P+=4,n.setUint32(P,D[Y+1],!0),P+=4,n.setUint32(P,D[Y+2],!0),P+=4;var d=4*u.indexCount;i+=d}else{var j=u.indexCount,d=4*j,v=this.createBufferView(0,i,d);i+=d,this.bufferViews.push(v);var b=this.createAccessor(this.bufferViews.length-1,"Indices","SCALAR",5125,j);this.accessors.push(b),f.indices=this.accessors.length-1}o.material,t.primitives.push(f)}return i},t.prototype.createScene=function(e,t,r){if(e.meshes.length>0){for(var i=e.meshes,s={nodes:new Array},n=0;n<i.length;++n){var a={mesh:-1},o=i[n],u=o.getScene().useRightHandedSystem;this.setNodeTransformation(a,o,u);var f={primitives:new Array};f.primitives=[],t=this.setPrimitiveAttributes(f,o,t,u,r),this.meshes.push(f),a.mesh=this.meshes.length-1,o.name&&(a.name=o.name),this.nodes.push(a),s.nodes.push(this.nodes.length-1)}this.scenes.push(s)}return t},t})();e._GLTF2Exporter=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._glTFFiles={}}return e.prototype.downloadFiles=function(){function e(e,t){return-1!==e.indexOf(t,e.length-t.length)}for(var t in this._glTFFiles){var r=document.createElement("a");document.body.appendChild(r),r.setAttribute("type","hidden"),r.download=t;var i=this._glTFFiles[t],s=void 0;e(t,".glb")?s={type:"model/gltf-binary"}:e(t,".bin")?s={type:"application/octet-stream"}:e(t,".gltf")&&(s={type:"model/gltf+json"}),r.href=window.URL.createObjectURL(new Blob([i],s)),r.click()}},e})();e._GLTFData=t})(BABYLON||(BABYLON={})),(function(e,t){var r=t();e&&e.BABYLON||("object"==typeof exports&&"object"==typeof module?module.exports=r:"function"==typeof define&&define.amd?define(["BJSSerializers"],t):"object"==typeof exports?exports.BJSSerializers=r:e.BABYLON=r)})(this,(function(){return BABYLON}));
/// <reference types="babylonjs"/>
declare module 'babylonjs-serializers' {

@@ -13,1 +14,164 @@ export = BABYLON;

}
declare module BABYLON {
class GLTF2Export {
/**
* Exports the geometry of a Mesh array in .gltf file format.
* If glb is set to true, exports as .glb.
* @param meshes
* @param materials
*
* @returns {[fileName: string]: string | Blob} Returns an object with a .gltf, .glb and associates textures
* as keys and their data and paths as values.
*/
static GLTF(scene: BABYLON.Scene, filename: string): _GLTFData;
/**
*
* @param meshes
* @param filename
*
* @returns {[fileName: string]: string | Blob} Returns an object with a .glb filename as key and data as value
*/
static GLB(scene: BABYLON.Scene, filename: string): _GLTFData;
}
}
declare module BABYLON {
class _GLTF2Exporter {
private bufferViews;
private accessors;
private nodes;
private asset;
private scenes;
private meshes;
private totalByteLength;
private babylonScene;
constructor(babylonScene: BABYLON.Scene);
/**
* Creates a buffer view based on teh supplied arguments
* @param bufferIndex
* @param byteOffset
* @param byteLength
*
* @returns {_IGLTFBufferView}
*/
private createBufferView(bufferIndex, byteOffset, byteLength);
/**
* Creates an accessor based on the supplied arguments
* @param bufferviewIndex
* @param name
* @param type
* @param componentType
* @param count
* @param min
* @param max
*
* @returns {_IGLTFAccessor}
*/
private createAccessor(bufferviewIndex, name, type, componentType, count, min?, max?);
/**
* Calculates the minimum and maximum values of an array of floats, based on stride
* @param buff
* @param vertexStart
* @param vertexCount
* @param arrayOffset
* @param stride
*
* @returns {min: number[], max: number[]} min number array and max number array
*/
private calculateMinMax(buff, vertexStart, vertexCount, arrayOffset, stride);
/**
* Write mesh attribute data to buffer.
* Returns the bytelength of the data.
* @param vertexBufferType
* @param submesh
* @param meshAttributeArray
* @param strideSize
* @param byteOffset
* @param dataBuffer
* @param useRightHandedSystem
*
* @returns {number} byte length
*/
private writeAttributeData(vertexBufferType, submesh, meshAttributeArray, strideSize, byteOffset, dataBuffer, useRightHandedSystem);
/**
* Generates glTF json data
* @param glb
* @param glTFPrefix
* @param prettyPrint
*
* @returns {string} json data as string
*/
private generateJSON(glb, glTFPrefix?, prettyPrint?);
/**
* Generates data for .gltf and .bin files based on the glTF prefix string
* @param glTFPrefix
*
* @returns {[x: string]: string | Blob} object with glTF json tex filename
* and binary file name as keys and their data as values
*/
_generateGLTF(glTFPrefix: string): _GLTFData;
/**
* Creates a binary buffer for glTF
*
* @returns {ArrayBuffer}
*/
private generateBinary();
/**
* Generates a glb file from the json and binary data.
* Returns an object with the glb file name as the key and data as the value.
* @param jsonText
* @param binaryBuffer
* @param glTFPrefix
*
* @returns {[glbFileName: string]: Blob} object with glb filename as key and data as value
*/
_generateGLB(glTFPrefix: string): _GLTFData;
/**
* Sets the TRS for each node
* @param node
* @param babylonMesh
* @param useRightHandedSystem
*/
private setNodeTransformation(node, babylonMesh, useRightHandedSystem);
/**
* Sets data for the primitive attributes of each submesh
* @param mesh
* @param babylonMesh
* @param byteOffset
* @param useRightHandedSystem
* @param dataBuffer
*
* @returns {number} bytelength of the primitive attributes plus the passed in byteOffset
*/
private setPrimitiveAttributes(mesh, babylonMesh, byteOffset, useRightHandedSystem, dataBuffer?);
/**
* Creates a glTF scene based on the array of meshes.
* Returns the the total byte offset.
* @param gltf
* @param byteOffset
* @param buffer
* @param dataBuffer
*
* @returns {number} bytelength + byteoffset
*/
private createScene(babylonScene, byteOffset, dataBuffer?);
}
}
declare module BABYLON {
/**
* Class for holding and downloading glTF file data
*/
class _GLTFData {
_glTFFiles: {
[fileName: string]: string | Blob;
};
constructor();
/**
* Downloads glTF data.
*/
downloadFiles(): void;
}
}

@@ -7,3 +7,3 @@ {

"description": "The Babylon.js serializers library is an extension you can use to serialize Babylon scenes.",
"version": "3.2.0-alpha0",
"version": "3.2.0-alpha2",
"repository": {

@@ -31,3 +31,3 @@ "type": "git",

"peerDependencies": {
"babylonjs": ">=3.1.0-alpha"
"babylonjs": ">=3.2.0-alpha"
},

@@ -34,0 +34,0 @@ "engines": {