|
@@ -311,10 +311,6 @@ var BABYLON;
|
|
|
}
|
|
|
else if (targetPath === "rotationQuaternion") {
|
|
|
rotationQuaternion = value;
|
|
|
- // Y is Up
|
|
|
- if (GLTFFileLoader.MakeYUP) {
|
|
|
- rotationQuaternion = rotationQuaternion.multiply(new BABYLON.Quaternion(-0.707107, 0, 0, 0.707107));
|
|
|
- }
|
|
|
}
|
|
|
else {
|
|
|
scaling = value;
|
|
@@ -352,9 +348,11 @@ var BABYLON;
|
|
|
var rotation = BABYLON.Quaternion.FromArray(node.rotation || [0, 0, 0, 1]);
|
|
|
var position = BABYLON.Vector3.FromArray(node.translation || [0, 0, 0]);
|
|
|
// Y is Up
|
|
|
+ /*
|
|
|
if (GLTFFileLoader.MakeYUP) {
|
|
|
- rotation = rotation.multiply(new BABYLON.Quaternion(-0.707107, 0, 0, 0.707107));
|
|
|
+ rotation = rotation.multiply(new Quaternion(-0.707107, 0, 0, 0.707107));
|
|
|
}
|
|
|
+ */
|
|
|
mat = BABYLON.Matrix.Compose(scale, rotation, position);
|
|
|
}
|
|
|
else {
|
|
@@ -733,7 +731,7 @@ var BABYLON;
|
|
|
/**
|
|
|
* Configures node from transformation matrix
|
|
|
*/
|
|
|
- var configureNodeFromMatrix = function (newNode, node) {
|
|
|
+ var configureNodeFromMatrix = function (newNode, node, parent) {
|
|
|
if (node.matrix) {
|
|
|
var position = new BABYLON.Vector3(0, 0, 0);
|
|
|
var rotation = new BABYLON.Quaternion();
|
|
@@ -741,7 +739,7 @@ var BABYLON;
|
|
|
var mat = BABYLON.Matrix.FromArray(node.matrix);
|
|
|
mat.decompose(scaling, rotation, position);
|
|
|
// Y is Up
|
|
|
- if (GLTFFileLoader.MakeYUP) {
|
|
|
+ if (GLTFFileLoader.MakeYUP && !parent) {
|
|
|
rotation = rotation.multiply(new BABYLON.Quaternion(-0.707107, 0, 0, 0.707107));
|
|
|
}
|
|
|
configureNode(newNode, position, rotation, scaling);
|
|
@@ -756,7 +754,7 @@ var BABYLON;
|
|
|
/**
|
|
|
* Imports a node
|
|
|
*/
|
|
|
- var importNode = function (gltfRuntime, node, id) {
|
|
|
+ var importNode = function (gltfRuntime, node, id, parent) {
|
|
|
var lastNode = null;
|
|
|
if (gltfRuntime.importOnlyMeshes && (node.skin || node.meshes)) {
|
|
|
if (gltfRuntime.importMeshesNames.length > 0 && gltfRuntime.importMeshesNames.indexOf(node.name) === -1) {
|
|
@@ -775,8 +773,6 @@ var BABYLON;
|
|
|
skin.babylonSkeleton = newMesh.skeleton;
|
|
|
}
|
|
|
}
|
|
|
- if (newMesh.skeleton !== null) {
|
|
|
- }
|
|
|
lastNode = newMesh;
|
|
|
}
|
|
|
}
|
|
@@ -874,7 +870,7 @@ var BABYLON;
|
|
|
}
|
|
|
if (lastNode !== null) {
|
|
|
if (node.matrix) {
|
|
|
- configureNodeFromMatrix(lastNode, node);
|
|
|
+ configureNodeFromMatrix(lastNode, node, parent);
|
|
|
}
|
|
|
else {
|
|
|
var translation = node.translation || [0, 0, 0];
|
|
@@ -905,7 +901,7 @@ var BABYLON;
|
|
|
meshIncluded = true;
|
|
|
}
|
|
|
if (!node.jointName && meshIncluded) {
|
|
|
- newNode = importNode(gltfRuntime, node, id);
|
|
|
+ newNode = importNode(gltfRuntime, node, id, parent);
|
|
|
if (newNode !== null) {
|
|
|
newNode.id = id;
|
|
|
newNode.parent = parent;
|
|
@@ -1424,9 +1420,12 @@ var BABYLON;
|
|
|
_this._loadShadersAsync(gltfRuntime, function () {
|
|
|
importMaterials(gltfRuntime);
|
|
|
postLoad(gltfRuntime);
|
|
|
+ if (!GLTFFileLoader.IncrementalLoading && onSuccess) {
|
|
|
+ onSuccess(meshes, null, skeletons);
|
|
|
+ }
|
|
|
});
|
|
|
});
|
|
|
- if (onSuccess) {
|
|
|
+ if (GLTFFileLoader.IncrementalLoading && onSuccess) {
|
|
|
onSuccess(meshes, null, skeletons);
|
|
|
}
|
|
|
}, onError);
|
|
@@ -1446,9 +1445,14 @@ var BABYLON;
|
|
|
_this._loadShadersAsync(gltfRuntime, function () {
|
|
|
importMaterials(gltfRuntime);
|
|
|
postLoad(gltfRuntime);
|
|
|
+ if (!GLTFFileLoader.IncrementalLoading) {
|
|
|
+ onSuccess();
|
|
|
+ }
|
|
|
});
|
|
|
});
|
|
|
- onSuccess();
|
|
|
+ if (GLTFFileLoader.IncrementalLoading) {
|
|
|
+ onSuccess();
|
|
|
+ }
|
|
|
}, onError);
|
|
|
return true;
|
|
|
};
|
|
@@ -1544,6 +1548,7 @@ var BABYLON;
|
|
|
*/
|
|
|
GLTFFileLoader.MakeYUP = false;
|
|
|
GLTFFileLoader.HomogeneousCoordinates = false;
|
|
|
+ GLTFFileLoader.IncrementalLoading = true;
|
|
|
GLTFFileLoader.Extensions = {};
|
|
|
BABYLON.GLTFFileLoader = GLTFFileLoader;
|
|
|
;
|
|
@@ -1750,25 +1755,25 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Returns the default material of gltf. Related to
|
|
|
- *
|
|
|
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
|
|
|
* @param scene: the Babylon.js scene
|
|
|
*/
|
|
|
GLTFUtils.GetDefaultMaterial = function (scene) {
|
|
|
if (!GLTFUtils._DefaultMaterial) {
|
|
|
- BABYLON.Effect.ShadersStore["GLTFDefaultVertexShader"] = [
|
|
|
+ BABYLON.Effect.ShadersStore["GLTFDefaultMaterialVertexShader"] = [
|
|
|
"precision highp float;",
|
|
|
"",
|
|
|
- "uniform mat4 u_modelViewMatrix;",
|
|
|
- "uniform mat4 u_projectionMatrix;",
|
|
|
+ "uniform mat4 worldView;",
|
|
|
+ "uniform mat4 projection;",
|
|
|
"",
|
|
|
- "attribute vec3 a_position;",
|
|
|
+ "attribute vec3 position;",
|
|
|
"",
|
|
|
"void main(void)",
|
|
|
"{",
|
|
|
- " gl_Position = u_projectionMatrix * u_modelViewMatrix * vec4(a_position,1.0);",
|
|
|
+ " gl_Position = projection * worldView * vec4(position, 1.0);",
|
|
|
"}"
|
|
|
].join("\n");
|
|
|
- BABYLON.Effect.ShadersStore["GLTFDefaultVertexShader"] = [
|
|
|
+ BABYLON.Effect.ShadersStore["GLTFDefaultMaterialPixelShader"] = [
|
|
|
"precision highp float;",
|
|
|
"",
|
|
|
"uniform vec4 u_emission;",
|
|
@@ -1784,7 +1789,7 @@ var BABYLON;
|
|
|
};
|
|
|
var options = {
|
|
|
attributes: ["position"],
|
|
|
- uniforms: ["modelView", "projection", "u_emission"],
|
|
|
+ uniforms: ["worldView", "projection", "u_emission"],
|
|
|
samplers: [],
|
|
|
needAlphaBlending: false
|
|
|
};
|
|
@@ -1795,6 +1800,7 @@ var BABYLON;
|
|
|
};
|
|
|
return GLTFUtils;
|
|
|
}());
|
|
|
+ // The GLTF default material
|
|
|
GLTFUtils._DefaultMaterial = null;
|
|
|
BABYLON.GLTFUtils = GLTFUtils;
|
|
|
})(BABYLON || (BABYLON = {}));
|