|
@@ -517,12 +517,26 @@ var BABYLON;
|
|
var vertex = vertices_1[_i];
|
|
var vertex = vertices_1[_i];
|
|
if (this._convertToRightHandedSystem && !(vertexAttributeKind === BABYLON.VertexBuffer.ColorKind) && !(vertex instanceof BABYLON.Vector2)) {
|
|
if (this._convertToRightHandedSystem && !(vertexAttributeKind === BABYLON.VertexBuffer.ColorKind) && !(vertex instanceof BABYLON.Vector2)) {
|
|
if (vertex instanceof BABYLON.Vector3) {
|
|
if (vertex instanceof BABYLON.Vector3) {
|
|
- (vertexAttributeKind === BABYLON.VertexBuffer.PositionKind) ? GLTF2._GLTFUtilities.GetRightHandedPositionVector3FromRef(vertex) : GLTF2._GLTFUtilities.GetRightHandedNormalVector3FromRef(vertex);
|
|
|
|
|
|
+ if (vertexAttributeKind === BABYLON.VertexBuffer.NormalKind) {
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedNormalVector3FromRef(vertex);
|
|
|
|
+ }
|
|
|
|
+ else if (vertexAttributeKind === BABYLON.VertexBuffer.PositionKind) {
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedPositionVector3FromRef(vertex);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ BABYLON.Tools.Error('Unsupported vertex attribute kind!');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- GLTF2._GLTFUtilities.GetRightHandedVector4FromRef(vertex);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedVector4FromRef(vertex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (vertexAttributeKind === BABYLON.VertexBuffer.NormalKind) {
|
|
|
|
+ vertex.normalize();
|
|
|
|
+ }
|
|
|
|
+ else if (vertexAttributeKind === BABYLON.VertexBuffer.TangentKind && vertex instanceof BABYLON.Vector4) {
|
|
|
|
+ GLTF2._GLTFUtilities._NormalizeTangentFromRef(vertex);
|
|
|
|
+ }
|
|
for (var _a = 0, _b = vertex.asArray(); _a < _b.length; _a++) {
|
|
for (var _a = 0, _b = vertex.asArray(); _a < _b.length; _a++) {
|
|
var component = _b[_a];
|
|
var component = _b[_a];
|
|
binaryWriter.setFloat32(component, byteOffset);
|
|
binaryWriter.setFloat32(component, byteOffset);
|
|
@@ -548,7 +562,7 @@ var BABYLON;
|
|
index = k * stride;
|
|
index = k * stride;
|
|
var vertexData = BABYLON.Vector3.FromArray(meshAttributeArray, index);
|
|
var vertexData = BABYLON.Vector3.FromArray(meshAttributeArray, index);
|
|
if (this._convertToRightHandedSystem) {
|
|
if (this._convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedPositionVector3FromRef(vertexData);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedPositionVector3FromRef(vertexData);
|
|
}
|
|
}
|
|
vertexAttributes.push(vertexData.asArray());
|
|
vertexAttributes.push(vertexData.asArray());
|
|
}
|
|
}
|
|
@@ -559,8 +573,9 @@ var BABYLON;
|
|
index = k * stride;
|
|
index = k * stride;
|
|
var vertexData = BABYLON.Vector3.FromArray(meshAttributeArray, index);
|
|
var vertexData = BABYLON.Vector3.FromArray(meshAttributeArray, index);
|
|
if (this._convertToRightHandedSystem) {
|
|
if (this._convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedNormalVector3FromRef(vertexData);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedNormalVector3FromRef(vertexData);
|
|
}
|
|
}
|
|
|
|
+ vertexData.normalize();
|
|
vertexAttributes.push(vertexData.asArray());
|
|
vertexAttributes.push(vertexData.asArray());
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -570,8 +585,9 @@ var BABYLON;
|
|
index = k * stride;
|
|
index = k * stride;
|
|
var vertexData = BABYLON.Vector4.FromArray(meshAttributeArray, index);
|
|
var vertexData = BABYLON.Vector4.FromArray(meshAttributeArray, index);
|
|
if (this._convertToRightHandedSystem) {
|
|
if (this._convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedVector4FromRef(vertexData);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedVector4FromRef(vertexData);
|
|
}
|
|
}
|
|
|
|
+ GLTF2._GLTFUtilities._NormalizeTangentFromRef(vertexData);
|
|
vertexAttributes.push(vertexData.asArray());
|
|
vertexAttributes.push(vertexData.asArray());
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -663,7 +679,7 @@ var BABYLON;
|
|
if (image.uri) {
|
|
if (image.uri) {
|
|
imageData = _this._imageData[image.uri];
|
|
imageData = _this._imageData[image.uri];
|
|
imageName = image.uri.split('.')[0] + " image";
|
|
imageName = image.uri.split('.')[0] + " image";
|
|
- bufferView = GLTF2._GLTFUtilities.CreateBufferView(0, byteOffset, imageData.data.length, undefined, imageName);
|
|
|
|
|
|
+ bufferView = GLTF2._GLTFUtilities._CreateBufferView(0, byteOffset, imageData.data.length, undefined, imageName);
|
|
byteOffset += imageData.data.buffer.byteLength;
|
|
byteOffset += imageData.data.buffer.byteLength;
|
|
_this._bufferViews.push(bufferView);
|
|
_this._bufferViews.push(bufferView);
|
|
image.bufferView = _this._bufferViews.length - 1;
|
|
image.bufferView = _this._bufferViews.length - 1;
|
|
@@ -813,7 +829,7 @@ var BABYLON;
|
|
*/
|
|
*/
|
|
_Exporter.prototype.setNodeTransformation = function (node, babylonTransformNode) {
|
|
_Exporter.prototype.setNodeTransformation = function (node, babylonTransformNode) {
|
|
if (!babylonTransformNode.position.equalsToFloats(0, 0, 0)) {
|
|
if (!babylonTransformNode.position.equalsToFloats(0, 0, 0)) {
|
|
- node.translation = this._convertToRightHandedSystem ? GLTF2._GLTFUtilities.GetRightHandedPositionVector3(babylonTransformNode.position).asArray() : babylonTransformNode.position.asArray();
|
|
|
|
|
|
+ node.translation = this._convertToRightHandedSystem ? GLTF2._GLTFUtilities._GetRightHandedPositionVector3(babylonTransformNode.position).asArray() : babylonTransformNode.position.asArray();
|
|
}
|
|
}
|
|
if (!babylonTransformNode.scaling.equalsToFloats(1, 1, 1)) {
|
|
if (!babylonTransformNode.scaling.equalsToFloats(1, 1, 1)) {
|
|
node.scale = babylonTransformNode.scaling.asArray();
|
|
node.scale = babylonTransformNode.scaling.asArray();
|
|
@@ -824,7 +840,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
if (!(rotationQuaternion.x === 0 && rotationQuaternion.y === 0 && rotationQuaternion.z === 0 && rotationQuaternion.w === 1)) {
|
|
if (!(rotationQuaternion.x === 0 && rotationQuaternion.y === 0 && rotationQuaternion.z === 0 && rotationQuaternion.w === 1)) {
|
|
if (this._convertToRightHandedSystem) {
|
|
if (this._convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedQuaternionFromRef(rotationQuaternion);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedQuaternionFromRef(rotationQuaternion);
|
|
}
|
|
}
|
|
node.rotation = rotationQuaternion.normalize().asArray();
|
|
node.rotation = rotationQuaternion.normalize().asArray();
|
|
}
|
|
}
|
|
@@ -852,7 +868,7 @@ var BABYLON;
|
|
var vertexData = bufferMesh.getVerticesData(kind);
|
|
var vertexData = bufferMesh.getVerticesData(kind);
|
|
if (vertexData) {
|
|
if (vertexData) {
|
|
var byteLength = vertexData.length * 4;
|
|
var byteLength = vertexData.length * 4;
|
|
- var bufferView = GLTF2._GLTFUtilities.CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, kind + " - " + bufferMesh.name);
|
|
|
|
|
|
+ var bufferView = GLTF2._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, kind + " - " + bufferMesh.name);
|
|
this._bufferViews.push(bufferView);
|
|
this._bufferViews.push(bufferView);
|
|
this.writeAttributeData(kind, vertexData, byteStride, binaryWriter);
|
|
this.writeAttributeData(kind, vertexData, byteStride, binaryWriter);
|
|
}
|
|
}
|
|
@@ -993,7 +1009,7 @@ var BABYLON;
|
|
var indices = bufferMesh.getIndices();
|
|
var indices = bufferMesh.getIndices();
|
|
if (indices) {
|
|
if (indices) {
|
|
var byteLength = indices.length * 4;
|
|
var byteLength = indices.length * 4;
|
|
- bufferView = GLTF2._GLTFUtilities.CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "Indices - " + bufferMesh.name);
|
|
|
|
|
|
+ bufferView = GLTF2._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "Indices - " + bufferMesh.name);
|
|
this._bufferViews.push(bufferView);
|
|
this._bufferViews.push(bufferView);
|
|
indexBufferViewIndex = this._bufferViews.length - 1;
|
|
indexBufferViewIndex = this._bufferViews.length - 1;
|
|
for (var k = 0, length_7 = indices.length; k < length_7; ++k) {
|
|
for (var k = 0, length_7 = indices.length; k < length_7; ++k) {
|
|
@@ -1052,9 +1068,9 @@ var BABYLON;
|
|
if (bufferViewIndex != undefined) { // check to see if bufferviewindex has a numeric value assigned.
|
|
if (bufferViewIndex != undefined) { // check to see if bufferviewindex has a numeric value assigned.
|
|
minMax = { min: null, max: null };
|
|
minMax = { min: null, max: null };
|
|
if (attributeKind == BABYLON.VertexBuffer.PositionKind) {
|
|
if (attributeKind == BABYLON.VertexBuffer.PositionKind) {
|
|
- minMax = GLTF2._GLTFUtilities.CalculateMinMaxPositions(vertexData, 0, vertexData.length / stride, this._convertToRightHandedSystem);
|
|
|
|
|
|
+ minMax = GLTF2._GLTFUtilities._CalculateMinMaxPositions(vertexData, 0, vertexData.length / stride, this._convertToRightHandedSystem);
|
|
}
|
|
}
|
|
- var accessor = GLTF2._GLTFUtilities.CreateAccessor(bufferViewIndex, attributeKind + " - " + babylonTransformNode.name, attribute.accessorType, 5126 /* FLOAT */, vertexData.length / stride, 0, minMax.min, minMax.max);
|
|
|
|
|
|
+ var accessor = GLTF2._GLTFUtilities._CreateAccessor(bufferViewIndex, attributeKind + " - " + babylonTransformNode.name, attribute.accessorType, 5126 /* FLOAT */, vertexData.length / stride, 0, minMax.min, minMax.max);
|
|
this._accessors.push(accessor);
|
|
this._accessors.push(accessor);
|
|
this.setAttributeKind(meshPrimitive, attributeKind);
|
|
this.setAttributeKind(meshPrimitive, attributeKind);
|
|
if (meshPrimitive.attributes.TEXCOORD_0 != null || meshPrimitive.attributes.TEXCOORD_1 != null) {
|
|
if (meshPrimitive.attributes.TEXCOORD_0 != null || meshPrimitive.attributes.TEXCOORD_1 != null) {
|
|
@@ -1066,7 +1082,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
if (indexBufferViewIndex) {
|
|
if (indexBufferViewIndex) {
|
|
// Create accessor
|
|
// Create accessor
|
|
- var accessor = GLTF2._GLTFUtilities.CreateAccessor(indexBufferViewIndex, "indices - " + babylonTransformNode.name, "SCALAR" /* SCALAR */, 5125 /* UNSIGNED_INT */, submesh.indexCount, submesh.indexStart * 4, null, null);
|
|
|
|
|
|
+ var accessor = GLTF2._GLTFUtilities._CreateAccessor(indexBufferViewIndex, "indices - " + babylonTransformNode.name, "SCALAR" /* SCALAR */, 5125 /* UNSIGNED_INT */, submesh.indexCount, submesh.indexStart * 4, null, null);
|
|
this._accessors.push(accessor);
|
|
this._accessors.push(accessor);
|
|
meshPrimitive.indices = this._accessors.length - 1;
|
|
meshPrimitive.indices = this._accessors.length - 1;
|
|
}
|
|
}
|
|
@@ -2120,7 +2136,7 @@ var BABYLON;
|
|
* @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
|
|
* @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
|
|
* @returns glTF PBR Metallic Roughness factors
|
|
* @returns glTF PBR Metallic Roughness factors
|
|
*/
|
|
*/
|
|
- _GLTFMaterialExporter.prototype._gonvertMetalRoughFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) {
|
|
|
|
|
|
+ _GLTFMaterialExporter.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) {
|
|
var promises = [];
|
|
var promises = [];
|
|
var metallicRoughness = {
|
|
var metallicRoughness = {
|
|
baseColor: babylonPBRMaterial.albedoColor,
|
|
baseColor: babylonPBRMaterial.albedoColor,
|
|
@@ -2252,39 +2268,41 @@ var BABYLON;
|
|
* @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
|
|
* @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
|
|
* @returns glTF PBR Metallic Roughness factors
|
|
* @returns glTF PBR Metallic Roughness factors
|
|
*/
|
|
*/
|
|
- _GLTFMaterialExporter.prototype._convertSpecGlossFactorsToMetallicRoughness = function (babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) {
|
|
|
|
|
|
+ _GLTFMaterialExporter.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) {
|
|
var _this = this;
|
|
var _this = this;
|
|
- var samplers = this._exporter._samplers;
|
|
|
|
- var textures = this._exporter._textures;
|
|
|
|
- var specGloss = {
|
|
|
|
- diffuseColor: babylonPBRMaterial.albedoColor || BABYLON.Color3.White(),
|
|
|
|
- specularColor: babylonPBRMaterial.reflectivityColor || BABYLON.Color3.White(),
|
|
|
|
- glossiness: babylonPBRMaterial.microSurface || 1,
|
|
|
|
- };
|
|
|
|
- var samplerIndex = null;
|
|
|
|
- var sampler = this._getGLTFTextureSampler(babylonPBRMaterial.albedoTexture);
|
|
|
|
- if (sampler.magFilter != null && sampler.minFilter != null && sampler.wrapS != null && sampler.wrapT != null) {
|
|
|
|
- samplers.push(sampler);
|
|
|
|
- samplerIndex = samplers.length - 1;
|
|
|
|
- }
|
|
|
|
- if (babylonPBRMaterial.reflectivityTexture && !babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha) {
|
|
|
|
- return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported");
|
|
|
|
- }
|
|
|
|
- return this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(babylonPBRMaterial.albedoTexture, babylonPBRMaterial.reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) {
|
|
|
|
- if (hasTextureCoords) {
|
|
|
|
- if (metallicRoughnessFactors.baseColorTextureBase64) {
|
|
|
|
- var glTFBaseColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.albedoTexture ? babylonPBRMaterial.albedoTexture.coordinatesIndex : null, samplerIndex);
|
|
|
|
- if (glTFBaseColorTexture) {
|
|
|
|
- glTFPbrMetallicRoughness.baseColorTexture = glTFBaseColorTexture;
|
|
|
|
|
|
+ return Promise.resolve().then(function () {
|
|
|
|
+ var samplers = _this._exporter._samplers;
|
|
|
|
+ var textures = _this._exporter._textures;
|
|
|
|
+ var specGloss = {
|
|
|
|
+ diffuseColor: babylonPBRMaterial.albedoColor || BABYLON.Color3.White(),
|
|
|
|
+ specularColor: babylonPBRMaterial.reflectivityColor || BABYLON.Color3.White(),
|
|
|
|
+ glossiness: babylonPBRMaterial.microSurface || 1,
|
|
|
|
+ };
|
|
|
|
+ var samplerIndex = null;
|
|
|
|
+ var sampler = _this._getGLTFTextureSampler(babylonPBRMaterial.albedoTexture);
|
|
|
|
+ if (sampler.magFilter != null && sampler.minFilter != null && sampler.wrapS != null && sampler.wrapT != null) {
|
|
|
|
+ samplers.push(sampler);
|
|
|
|
+ samplerIndex = samplers.length - 1;
|
|
|
|
+ }
|
|
|
|
+ if (babylonPBRMaterial.reflectivityTexture && !babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha) {
|
|
|
|
+ return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported");
|
|
|
|
+ }
|
|
|
|
+ if ((babylonPBRMaterial.albedoTexture || babylonPBRMaterial.reflectivityTexture) && hasTextureCoords) {
|
|
|
|
+ return _this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(babylonPBRMaterial.albedoTexture, babylonPBRMaterial.reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) {
|
|
|
|
+ if (metallicRoughnessFactors.baseColorTextureBase64) {
|
|
|
|
+ var glTFBaseColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.albedoTexture ? babylonPBRMaterial.albedoTexture.coordinatesIndex : null, samplerIndex);
|
|
|
|
+ if (glTFBaseColorTexture) {
|
|
|
|
+ glTFPbrMetallicRoughness.baseColorTexture = glTFBaseColorTexture;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (metallicRoughnessFactors.metallicRoughnessTextureBase64) {
|
|
|
|
- var glTFMRColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.reflectivityTexture ? babylonPBRMaterial.reflectivityTexture.coordinatesIndex : null, samplerIndex);
|
|
|
|
- if (glTFMRColorTexture) {
|
|
|
|
- glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFMRColorTexture;
|
|
|
|
|
|
+ if (metallicRoughnessFactors.metallicRoughnessTextureBase64) {
|
|
|
|
+ var glTFMRColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.reflectivityTexture ? babylonPBRMaterial.reflectivityTexture.coordinatesIndex : null, samplerIndex);
|
|
|
|
+ if (glTFMRColorTexture) {
|
|
|
|
+ glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFMRColorTexture;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- return metallicRoughnessFactors;
|
|
|
|
|
|
+ return metallicRoughnessFactors;
|
|
|
|
+ });
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
return _this._convertSpecularGlossinessToMetallicRoughness(specGloss);
|
|
return _this._convertSpecularGlossinessToMetallicRoughness(specGloss);
|
|
@@ -2317,12 +2335,12 @@ var BABYLON;
|
|
babylonPBRMaterial.alpha
|
|
babylonPBRMaterial.alpha
|
|
];
|
|
];
|
|
}
|
|
}
|
|
- return this._gonvertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(function (metallicRoughness) {
|
|
|
|
|
|
+ return this._convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(function (metallicRoughness) {
|
|
return _this.setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords);
|
|
return _this.setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- return this._convertSpecGlossFactorsToMetallicRoughness(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(function (metallicRoughness) {
|
|
|
|
|
|
+ return this._convertSpecGlossFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(function (metallicRoughness) {
|
|
return _this.setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords);
|
|
return _this.setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -2748,26 +2766,26 @@ var BABYLON;
|
|
var nodeIndex = nodeMap[babylonTransformNode.uniqueId];
|
|
var nodeIndex = nodeMap[babylonTransformNode.uniqueId];
|
|
// Creates buffer view and accessor for key frames.
|
|
// Creates buffer view and accessor for key frames.
|
|
var byteLength = animationData.inputs.length * 4;
|
|
var byteLength = animationData.inputs.length * 4;
|
|
- bufferView = GLTF2._GLTFUtilities.CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, name + " keyframe data view");
|
|
|
|
|
|
+ bufferView = GLTF2._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, name + " keyframe data view");
|
|
bufferViews.push(bufferView);
|
|
bufferViews.push(bufferView);
|
|
animationData.inputs.forEach(function (input) {
|
|
animationData.inputs.forEach(function (input) {
|
|
binaryWriter.setFloat32(input);
|
|
binaryWriter.setFloat32(input);
|
|
});
|
|
});
|
|
- accessor = GLTF2._GLTFUtilities.CreateAccessor(bufferViews.length - 1, name + " keyframes", "SCALAR" /* SCALAR */, 5126 /* FLOAT */, animationData.inputs.length, null, [animationData.inputsMin], [animationData.inputsMax]);
|
|
|
|
|
|
+ accessor = GLTF2._GLTFUtilities._CreateAccessor(bufferViews.length - 1, name + " keyframes", "SCALAR" /* SCALAR */, 5126 /* FLOAT */, animationData.inputs.length, null, [animationData.inputsMin], [animationData.inputsMax]);
|
|
accessors.push(accessor);
|
|
accessors.push(accessor);
|
|
keyframeAccessorIndex = accessors.length - 1;
|
|
keyframeAccessorIndex = accessors.length - 1;
|
|
// create bufferview and accessor for keyed values.
|
|
// create bufferview and accessor for keyed values.
|
|
outputLength = animationData.outputs.length;
|
|
outputLength = animationData.outputs.length;
|
|
byteLength = dataAccessorType === "VEC3" /* VEC3 */ ? animationData.outputs.length * 12 : animationData.outputs.length * 16;
|
|
byteLength = dataAccessorType === "VEC3" /* VEC3 */ ? animationData.outputs.length * 12 : animationData.outputs.length * 16;
|
|
// check for in and out tangents
|
|
// check for in and out tangents
|
|
- bufferView = GLTF2._GLTFUtilities.CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, name + " data view");
|
|
|
|
|
|
+ bufferView = GLTF2._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, name + " data view");
|
|
bufferViews.push(bufferView);
|
|
bufferViews.push(bufferView);
|
|
animationData.outputs.forEach(function (output) {
|
|
animationData.outputs.forEach(function (output) {
|
|
output.forEach(function (entry) {
|
|
output.forEach(function (entry) {
|
|
binaryWriter.setFloat32(entry);
|
|
binaryWriter.setFloat32(entry);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
- accessor = GLTF2._GLTFUtilities.CreateAccessor(bufferViews.length - 1, name + " data", dataAccessorType, 5126 /* FLOAT */, outputLength, null, null, null);
|
|
|
|
|
|
+ accessor = GLTF2._GLTFUtilities._CreateAccessor(bufferViews.length - 1, name + " data", dataAccessorType, 5126 /* FLOAT */, outputLength, null, null, null);
|
|
accessors.push(accessor);
|
|
accessors.push(accessor);
|
|
dataAccessorIndex = accessors.length - 1;
|
|
dataAccessorIndex = accessors.length - 1;
|
|
// create sampler
|
|
// create sampler
|
|
@@ -2907,7 +2925,7 @@ var BABYLON;
|
|
BABYLON.Quaternion.RotationYawPitchRollToRef(cacheValue.y, cacheValue.x, cacheValue.z, quaternionCache);
|
|
BABYLON.Quaternion.RotationYawPitchRollToRef(cacheValue.y, cacheValue.x, cacheValue.z, quaternionCache);
|
|
}
|
|
}
|
|
if (convertToRightHandedSystem) {
|
|
if (convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedQuaternionFromRef(quaternionCache);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedQuaternionFromRef(quaternionCache);
|
|
if (!babylonTransformNode.parent) {
|
|
if (!babylonTransformNode.parent) {
|
|
quaternionCache = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(quaternionCache);
|
|
quaternionCache = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(quaternionCache);
|
|
}
|
|
}
|
|
@@ -2917,7 +2935,7 @@ var BABYLON;
|
|
else {
|
|
else {
|
|
cacheValue = value;
|
|
cacheValue = value;
|
|
if (convertToRightHandedSystem && (animationChannelTargetPath !== "scale" /* SCALE */)) {
|
|
if (convertToRightHandedSystem && (animationChannelTargetPath !== "scale" /* SCALE */)) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedPositionVector3FromRef(cacheValue);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedPositionVector3FromRef(cacheValue);
|
|
if (!babylonTransformNode.parent) {
|
|
if (!babylonTransformNode.parent) {
|
|
cacheValue.x *= -1;
|
|
cacheValue.x *= -1;
|
|
cacheValue.z *= -1;
|
|
cacheValue.z *= -1;
|
|
@@ -2972,7 +2990,7 @@ var BABYLON;
|
|
if (babylonTransformNode.rotationQuaternion) {
|
|
if (babylonTransformNode.rotationQuaternion) {
|
|
basePositionRotationOrScale = babylonTransformNode.rotationQuaternion.asArray();
|
|
basePositionRotationOrScale = babylonTransformNode.rotationQuaternion.asArray();
|
|
if (convertToRightHandedSystem) {
|
|
if (convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedQuaternionArrayFromRef(basePositionRotationOrScale);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedQuaternionArrayFromRef(basePositionRotationOrScale);
|
|
if (!babylonTransformNode.parent) {
|
|
if (!babylonTransformNode.parent) {
|
|
basePositionRotationOrScale = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(BABYLON.Quaternion.FromArray(basePositionRotationOrScale)).asArray();
|
|
basePositionRotationOrScale = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(BABYLON.Quaternion.FromArray(basePositionRotationOrScale)).asArray();
|
|
}
|
|
}
|
|
@@ -2984,13 +3002,13 @@ var BABYLON;
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
basePositionRotationOrScale = babylonTransformNode.rotation.asArray();
|
|
basePositionRotationOrScale = babylonTransformNode.rotation.asArray();
|
|
- GLTF2._GLTFUtilities.GetRightHandedNormalArray3FromRef(basePositionRotationOrScale);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedNormalArray3FromRef(basePositionRotationOrScale);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (animationChannelTargetPath === "translation" /* TRANSLATION */) {
|
|
else if (animationChannelTargetPath === "translation" /* TRANSLATION */) {
|
|
basePositionRotationOrScale = babylonTransformNode.position.asArray();
|
|
basePositionRotationOrScale = babylonTransformNode.position.asArray();
|
|
if (convertToRightHandedSystem) {
|
|
if (convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedPositionArray3FromRef(basePositionRotationOrScale);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedPositionArray3FromRef(basePositionRotationOrScale);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else { // scale
|
|
else { // scale
|
|
@@ -3018,7 +3036,7 @@ var BABYLON;
|
|
var array = BABYLON.Vector3.FromArray(value);
|
|
var array = BABYLON.Vector3.FromArray(value);
|
|
var rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(array.y, array.x, array.z);
|
|
var rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(array.y, array.x, array.z);
|
|
if (convertToRightHandedSystem) {
|
|
if (convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedQuaternionFromRef(rotationQuaternion);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedQuaternionFromRef(rotationQuaternion);
|
|
if (!babylonTransformNode.parent) {
|
|
if (!babylonTransformNode.parent) {
|
|
rotationQuaternion = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(rotationQuaternion);
|
|
rotationQuaternion = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(rotationQuaternion);
|
|
}
|
|
}
|
|
@@ -3027,7 +3045,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
else if (animationChannelTargetPath === "translation" /* TRANSLATION */) {
|
|
else if (animationChannelTargetPath === "translation" /* TRANSLATION */) {
|
|
if (convertToRightHandedSystem) {
|
|
if (convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedNormalArray3FromRef(value);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedNormalArray3FromRef(value);
|
|
if (!babylonTransformNode.parent) {
|
|
if (!babylonTransformNode.parent) {
|
|
value[0] *= -1;
|
|
value[0] *= -1;
|
|
value[2] *= -1;
|
|
value[2] *= -1;
|
|
@@ -3042,7 +3060,7 @@ var BABYLON;
|
|
if (animationChannelTargetPath === "rotation" /* ROTATION */) {
|
|
if (animationChannelTargetPath === "rotation" /* ROTATION */) {
|
|
var posRotScale = useQuaternion ? newPositionRotationOrScale : BABYLON.Quaternion.RotationYawPitchRoll(newPositionRotationOrScale.y, newPositionRotationOrScale.x, newPositionRotationOrScale.z).normalize();
|
|
var posRotScale = useQuaternion ? newPositionRotationOrScale : BABYLON.Quaternion.RotationYawPitchRoll(newPositionRotationOrScale.y, newPositionRotationOrScale.x, newPositionRotationOrScale.z).normalize();
|
|
if (convertToRightHandedSystem) {
|
|
if (convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedQuaternionFromRef(posRotScale);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedQuaternionFromRef(posRotScale);
|
|
if (!babylonTransformNode.parent) {
|
|
if (!babylonTransformNode.parent) {
|
|
posRotScale = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(posRotScale);
|
|
posRotScale = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(posRotScale);
|
|
}
|
|
}
|
|
@@ -3051,7 +3069,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
else if (animationChannelTargetPath === "translation" /* TRANSLATION */) {
|
|
else if (animationChannelTargetPath === "translation" /* TRANSLATION */) {
|
|
if (convertToRightHandedSystem) {
|
|
if (convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedNormalVector3FromRef(newPositionRotationOrScale);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedNormalVector3FromRef(newPositionRotationOrScale);
|
|
if (!babylonTransformNode.parent) {
|
|
if (!babylonTransformNode.parent) {
|
|
newPositionRotationOrScale.x *= -1;
|
|
newPositionRotationOrScale.x *= -1;
|
|
newPositionRotationOrScale.z *= -1;
|
|
newPositionRotationOrScale.z *= -1;
|
|
@@ -3064,7 +3082,7 @@ var BABYLON;
|
|
else if (animationType === BABYLON.Animation.ANIMATIONTYPE_QUATERNION) {
|
|
else if (animationType === BABYLON.Animation.ANIMATIONTYPE_QUATERNION) {
|
|
value = keyFrame.value.normalize().asArray();
|
|
value = keyFrame.value.normalize().asArray();
|
|
if (convertToRightHandedSystem) {
|
|
if (convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedQuaternionArrayFromRef(value);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedQuaternionArrayFromRef(value);
|
|
if (!babylonTransformNode.parent) {
|
|
if (!babylonTransformNode.parent) {
|
|
value = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(BABYLON.Quaternion.FromArray(value)).asArray();
|
|
value = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(BABYLON.Quaternion.FromArray(value)).asArray();
|
|
}
|
|
}
|
|
@@ -3152,7 +3170,7 @@ var BABYLON;
|
|
tangent = BABYLON.Quaternion.RotationYawPitchRoll(array.y, array.x, array.z).asArray();
|
|
tangent = BABYLON.Quaternion.RotationYawPitchRoll(array.y, array.x, array.z).asArray();
|
|
}
|
|
}
|
|
if (convertToRightHandedSystem) {
|
|
if (convertToRightHandedSystem) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedQuaternionArrayFromRef(tangent);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedQuaternionArrayFromRef(tangent);
|
|
if (!babylonTransformNode.parent) {
|
|
if (!babylonTransformNode.parent) {
|
|
tangent = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(BABYLON.Quaternion.FromArray(tangent)).asArray();
|
|
tangent = BABYLON.Quaternion.FromArray([0, 1, 0, 0]).multiply(BABYLON.Quaternion.FromArray(tangent)).asArray();
|
|
}
|
|
}
|
|
@@ -3167,7 +3185,7 @@ var BABYLON;
|
|
tangent = tangentValue.scale(frameDelta).asArray();
|
|
tangent = tangentValue.scale(frameDelta).asArray();
|
|
if (convertToRightHandedSystem) {
|
|
if (convertToRightHandedSystem) {
|
|
if (animationChannelTargetPath === "translation" /* TRANSLATION */) {
|
|
if (animationChannelTargetPath === "translation" /* TRANSLATION */) {
|
|
- GLTF2._GLTFUtilities.GetRightHandedPositionArray3FromRef(tangent);
|
|
|
|
|
|
+ GLTF2._GLTFUtilities._GetRightHandedPositionArray3FromRef(tangent);
|
|
if (!babylonTransformNode.parent) {
|
|
if (!babylonTransformNode.parent) {
|
|
tangent[0] *= -1; // x
|
|
tangent[0] *= -1; // x
|
|
tangent[2] *= -1; // z
|
|
tangent[2] *= -1; // z
|
|
@@ -3224,7 +3242,7 @@ var BABYLON;
|
|
* @param name name of the buffer view
|
|
* @param name name of the buffer view
|
|
* @returns bufferView for glTF
|
|
* @returns bufferView for glTF
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.CreateBufferView = function (bufferIndex, byteOffset, byteLength, byteStride, name) {
|
|
|
|
|
|
+ _GLTFUtilities._CreateBufferView = function (bufferIndex, byteOffset, byteLength, byteStride, name) {
|
|
var bufferview = { buffer: bufferIndex, byteLength: byteLength };
|
|
var bufferview = { buffer: bufferIndex, byteLength: byteLength };
|
|
if (byteOffset) {
|
|
if (byteOffset) {
|
|
bufferview.byteOffset = byteOffset;
|
|
bufferview.byteOffset = byteOffset;
|
|
@@ -3249,7 +3267,7 @@ var BABYLON;
|
|
* @param max Maximum value of each component in this attribute
|
|
* @param max Maximum value of each component in this attribute
|
|
* @returns accessor for glTF
|
|
* @returns accessor for glTF
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.CreateAccessor = function (bufferviewIndex, name, type, componentType, count, byteOffset, min, max) {
|
|
|
|
|
|
+ _GLTFUtilities._CreateAccessor = function (bufferviewIndex, name, type, componentType, count, byteOffset, min, max) {
|
|
var accessor = { name: name, bufferView: bufferviewIndex, componentType: componentType, count: count, type: type };
|
|
var accessor = { name: name, bufferView: bufferviewIndex, componentType: componentType, count: count, type: type };
|
|
if (min != null) {
|
|
if (min != null) {
|
|
accessor.min = min;
|
|
accessor.min = min;
|
|
@@ -3269,7 +3287,7 @@ var BABYLON;
|
|
* @param vertexCount Number of vertices to check for min and max values
|
|
* @param vertexCount Number of vertices to check for min and max values
|
|
* @returns min number array and max number array
|
|
* @returns min number array and max number array
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.CalculateMinMaxPositions = function (positions, vertexStart, vertexCount, convertToRightHandedSystem) {
|
|
|
|
|
|
+ _GLTFUtilities._CalculateMinMaxPositions = function (positions, vertexStart, vertexCount, convertToRightHandedSystem) {
|
|
var min = [Infinity, Infinity, Infinity];
|
|
var min = [Infinity, Infinity, Infinity];
|
|
var max = [-Infinity, -Infinity, -Infinity];
|
|
var max = [-Infinity, -Infinity, -Infinity];
|
|
var positionStrideSize = 3;
|
|
var positionStrideSize = 3;
|
|
@@ -3281,7 +3299,7 @@ var BABYLON;
|
|
indexOffset = positionStrideSize * i;
|
|
indexOffset = positionStrideSize * i;
|
|
position = BABYLON.Vector3.FromArray(positions, indexOffset);
|
|
position = BABYLON.Vector3.FromArray(positions, indexOffset);
|
|
if (convertToRightHandedSystem) {
|
|
if (convertToRightHandedSystem) {
|
|
- _GLTFUtilities.GetRightHandedPositionVector3FromRef(position);
|
|
|
|
|
|
+ _GLTFUtilities._GetRightHandedPositionVector3FromRef(position);
|
|
}
|
|
}
|
|
vector = position.asArray();
|
|
vector = position.asArray();
|
|
for (var j = 0; j < positionStrideSize; ++j) {
|
|
for (var j = 0; j < positionStrideSize; ++j) {
|
|
@@ -3303,21 +3321,21 @@ var BABYLON;
|
|
* @param vector vector3 array
|
|
* @param vector vector3 array
|
|
* @returns right-handed Vector3
|
|
* @returns right-handed Vector3
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.GetRightHandedPositionVector3 = function (vector) {
|
|
|
|
|
|
+ _GLTFUtilities._GetRightHandedPositionVector3 = function (vector) {
|
|
return new BABYLON.Vector3(vector.x, vector.y, -vector.z);
|
|
return new BABYLON.Vector3(vector.x, vector.y, -vector.z);
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Converts a Vector3 to right-handed
|
|
* Converts a Vector3 to right-handed
|
|
* @param vector Vector3 to convert to right-handed
|
|
* @param vector Vector3 to convert to right-handed
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.GetRightHandedPositionVector3FromRef = function (vector) {
|
|
|
|
|
|
+ _GLTFUtilities._GetRightHandedPositionVector3FromRef = function (vector) {
|
|
vector.z *= -1;
|
|
vector.z *= -1;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Converts a three element number array to right-handed
|
|
* Converts a three element number array to right-handed
|
|
* @param vector number array to convert to right-handed
|
|
* @param vector number array to convert to right-handed
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.GetRightHandedPositionArray3FromRef = function (vector) {
|
|
|
|
|
|
+ _GLTFUtilities._GetRightHandedPositionArray3FromRef = function (vector) {
|
|
vector[2] *= -1;
|
|
vector[2] *= -1;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -3325,28 +3343,28 @@ var BABYLON;
|
|
* @param vector vector3 array
|
|
* @param vector vector3 array
|
|
* @returns right-handed Vector3
|
|
* @returns right-handed Vector3
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.GetRightHandedNormalVector3 = function (vector) {
|
|
|
|
|
|
+ _GLTFUtilities._GetRightHandedNormalVector3 = function (vector) {
|
|
return new BABYLON.Vector3(vector.x, vector.y, -vector.z);
|
|
return new BABYLON.Vector3(vector.x, vector.y, -vector.z);
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Converts a Vector3 to right-handed
|
|
* Converts a Vector3 to right-handed
|
|
* @param vector Vector3 to convert to right-handed
|
|
* @param vector Vector3 to convert to right-handed
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.GetRightHandedNormalVector3FromRef = function (vector) {
|
|
|
|
|
|
+ _GLTFUtilities._GetRightHandedNormalVector3FromRef = function (vector) {
|
|
vector.z *= -1;
|
|
vector.z *= -1;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Converts a three element number array to right-handed
|
|
* Converts a three element number array to right-handed
|
|
* @param vector number array to convert to right-handed
|
|
* @param vector number array to convert to right-handed
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.GetRightHandedNormalArray3FromRef = function (vector) {
|
|
|
|
|
|
+ _GLTFUtilities._GetRightHandedNormalArray3FromRef = function (vector) {
|
|
vector[2] *= -1;
|
|
vector[2] *= -1;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Converts a Vector4 to right-handed
|
|
* Converts a Vector4 to right-handed
|
|
* @param vector Vector4 to convert to right-handed
|
|
* @param vector Vector4 to convert to right-handed
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.GetRightHandedVector4FromRef = function (vector) {
|
|
|
|
|
|
+ _GLTFUtilities._GetRightHandedVector4FromRef = function (vector) {
|
|
vector.z *= -1;
|
|
vector.z *= -1;
|
|
vector.w *= -1;
|
|
vector.w *= -1;
|
|
};
|
|
};
|
|
@@ -3354,7 +3372,7 @@ var BABYLON;
|
|
* Converts a Vector4 to right-handed
|
|
* Converts a Vector4 to right-handed
|
|
* @param vector Vector4 to convert to right-handed
|
|
* @param vector Vector4 to convert to right-handed
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.GetRightHandedArray4FromRef = function (vector) {
|
|
|
|
|
|
+ _GLTFUtilities._GetRightHandedArray4FromRef = function (vector) {
|
|
vector[2] *= -1;
|
|
vector[2] *= -1;
|
|
vector[3] *= -1;
|
|
vector[3] *= -1;
|
|
};
|
|
};
|
|
@@ -3362,7 +3380,7 @@ var BABYLON;
|
|
* Converts a Quaternion to right-handed
|
|
* Converts a Quaternion to right-handed
|
|
* @param quaternion Source quaternion to convert to right-handed
|
|
* @param quaternion Source quaternion to convert to right-handed
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.GetRightHandedQuaternionFromRef = function (quaternion) {
|
|
|
|
|
|
+ _GLTFUtilities._GetRightHandedQuaternionFromRef = function (quaternion) {
|
|
quaternion.x *= -1;
|
|
quaternion.x *= -1;
|
|
quaternion.y *= -1;
|
|
quaternion.y *= -1;
|
|
};
|
|
};
|
|
@@ -3370,10 +3388,16 @@ var BABYLON;
|
|
* Converts a Quaternion to right-handed
|
|
* Converts a Quaternion to right-handed
|
|
* @param quaternion Source quaternion to convert to right-handed
|
|
* @param quaternion Source quaternion to convert to right-handed
|
|
*/
|
|
*/
|
|
- _GLTFUtilities.GetRightHandedQuaternionArrayFromRef = function (quaternion) {
|
|
|
|
|
|
+ _GLTFUtilities._GetRightHandedQuaternionArrayFromRef = function (quaternion) {
|
|
quaternion[0] *= -1;
|
|
quaternion[0] *= -1;
|
|
quaternion[1] *= -1;
|
|
quaternion[1] *= -1;
|
|
};
|
|
};
|
|
|
|
+ _GLTFUtilities._NormalizeTangentFromRef = function (tangent) {
|
|
|
|
+ var length = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y + tangent.z + tangent.z);
|
|
|
|
+ tangent.x /= length;
|
|
|
|
+ tangent.y /= length;
|
|
|
|
+ tangent.z /= length;
|
|
|
|
+ };
|
|
return _GLTFUtilities;
|
|
return _GLTFUtilities;
|
|
}());
|
|
}());
|
|
GLTF2._GLTFUtilities = _GLTFUtilities;
|
|
GLTF2._GLTFUtilities = _GLTFUtilities;
|