|
@@ -89,8 +89,6 @@ module BABYLON.GLTF2 {
|
|
}
|
|
}
|
|
|
|
|
|
private _loadAsync(nodeNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onError: () => void): void {
|
|
private _loadAsync(nodeNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onError: () => void): void {
|
|
- scene.useRightHandedSystem = true;
|
|
|
|
-
|
|
|
|
this._clear();
|
|
this._clear();
|
|
|
|
|
|
this._loadData(data);
|
|
this._loadData(data);
|
|
@@ -107,6 +105,23 @@ module BABYLON.GLTF2 {
|
|
}
|
|
}
|
|
|
|
|
|
private _onRenderReady(): void {
|
|
private _onRenderReady(): void {
|
|
|
|
+ switch (this._parent.coordinateSystemMode) {
|
|
|
|
+ case GLTFLoaderCoordinateSystemMode.AUTO:
|
|
|
|
+ if (!this._babylonScene.useRightHandedSystem) {
|
|
|
|
+ this._addRightHandToLeftHandRootTransform();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case GLTFLoaderCoordinateSystemMode.PASS_THROUGH:
|
|
|
|
+ // do nothing
|
|
|
|
+ break;
|
|
|
|
+ case GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:
|
|
|
|
+ this._babylonScene.useRightHandedSystem = true;
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ Tools.Error("Invalid coordinate system mode (" + this._parent.coordinateSystemMode + ")");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
this._succeeded = (this._errors.length === 0);
|
|
this._succeeded = (this._errors.length === 0);
|
|
if (this._succeeded) {
|
|
if (this._succeeded) {
|
|
this._showMeshes();
|
|
this._showMeshes();
|
|
@@ -155,6 +170,20 @@ module BABYLON.GLTF2 {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private _addRightHandToLeftHandRootTransform(): void {
|
|
|
|
+ var rootMesh = new Mesh("root", this._babylonScene);
|
|
|
|
+ rootMesh.scaling = new Vector3(1, 1, -1);
|
|
|
|
+ rootMesh.rotationQuaternion = new Quaternion(0, 1, 0, 0);
|
|
|
|
+
|
|
|
|
+ var nodes = this._gltf.nodes;
|
|
|
|
+ for (var i = 0; i < nodes.length; i++) {
|
|
|
|
+ var mesh = nodes[i].babylonMesh;
|
|
|
|
+ if (mesh && !mesh.parent) {
|
|
|
|
+ mesh.parent = rootMesh;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private _showMeshes(): void {
|
|
private _showMeshes(): void {
|
|
var nodes = this._gltf.nodes;
|
|
var nodes = this._gltf.nodes;
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
for (var i = 0; i < nodes.length; i++) {
|