David Catuhe 8 years ago
parent
commit
28a76b5c87

File diff suppressed because it is too large
+ 1590 - 1590
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 1590 - 1590
dist/preview release/babylon.module.d.ts


File diff suppressed because it is too large
+ 2703 - 2703
dist/preview release/customConfigurations/minimalViewer/babylon.d.ts


File diff suppressed because it is too large
+ 2703 - 2703
dist/preview release/customConfigurations/minimalViewer/babylon.module.d.ts


+ 6 - 0
dist/preview release/loaders/babylon.glTF1FileLoader.d.ts

@@ -1,5 +1,10 @@
 
 
 declare module BABYLON {
 declare module BABYLON {
+    enum GLTFLoaderCoordinateSystemMode {
+        AUTO = 0,
+        PASS_THROUGH = 1,
+        FORCE_RIGHT_HANDED = 2,
+    }
     interface IGLTFLoaderData {
     interface IGLTFLoaderData {
         json: Object;
         json: Object;
         bin: ArrayBufferView;
         bin: ArrayBufferView;
@@ -13,6 +18,7 @@ declare module BABYLON {
         static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
         static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
         static HomogeneousCoordinates: boolean;
         static HomogeneousCoordinates: boolean;
         static IncrementalLoading: boolean;
         static IncrementalLoading: boolean;
+        coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
         onTextureLoaded: (texture: BaseTexture) => void;
         onTextureLoaded: (texture: BaseTexture) => void;
         onMaterialLoaded: (material: Material) => void;
         onMaterialLoaded: (material: Material) => void;
         onComplete: () => void;
         onComplete: () => void;

+ 12 - 0
dist/preview release/loaders/babylon.glTF1FileLoader.js

@@ -1,8 +1,20 @@
 /// <reference path="../../../dist/preview release/babylon.d.ts"/>
 /// <reference path="../../../dist/preview release/babylon.d.ts"/>
 var BABYLON;
 var BABYLON;
 (function (BABYLON) {
 (function (BABYLON) {
+    var GLTFLoaderCoordinateSystemMode;
+    (function (GLTFLoaderCoordinateSystemMode) {
+        // Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene (scene.useRightHandedSystem).
+        // NOTE: When scene.useRightHandedSystem is false, an additional transform will be added to the root to transform the data from right-handed to left-handed.
+        GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["AUTO"] = 0] = "AUTO";
+        // The glTF right-handed data is not transformed in any form and is loaded directly.
+        GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["PASS_THROUGH"] = 1] = "PASS_THROUGH";
+        // Sets the useRightHandedSystem flag on the scene.
+        GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["FORCE_RIGHT_HANDED"] = 2] = "FORCE_RIGHT_HANDED";
+    })(GLTFLoaderCoordinateSystemMode = BABYLON.GLTFLoaderCoordinateSystemMode || (BABYLON.GLTFLoaderCoordinateSystemMode = {}));
     var GLTFFileLoader = (function () {
     var GLTFFileLoader = (function () {
         function GLTFFileLoader() {
         function GLTFFileLoader() {
+            // V2 options
+            this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;
             this.extensions = {
             this.extensions = {
                 ".gltf": { isBinary: false },
                 ".gltf": { isBinary: false },
                 ".glb": { isBinary: true }
                 ".glb": { isBinary: true }

File diff suppressed because it is too large
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


+ 9 - 10
dist/preview release/loaders/babylon.glTF2FileLoader.d.ts

@@ -1,5 +1,10 @@
 
 
 declare module BABYLON {
 declare module BABYLON {
+    enum GLTFLoaderCoordinateSystemMode {
+        AUTO = 0,
+        PASS_THROUGH = 1,
+        FORCE_RIGHT_HANDED = 2,
+    }
     interface IGLTFLoaderData {
     interface IGLTFLoaderData {
         json: Object;
         json: Object;
         bin: ArrayBufferView;
         bin: ArrayBufferView;
@@ -13,6 +18,7 @@ declare module BABYLON {
         static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
         static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
         static HomogeneousCoordinates: boolean;
         static HomogeneousCoordinates: boolean;
         static IncrementalLoading: boolean;
         static IncrementalLoading: boolean;
+        coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
         onTextureLoaded: (texture: BaseTexture) => void;
         onTextureLoaded: (texture: BaseTexture) => void;
         onMaterialLoaded: (material: Material) => void;
         onMaterialLoaded: (material: Material) => void;
         onComplete: () => void;
         onComplete: () => void;
@@ -299,6 +305,7 @@ declare module BABYLON.GLTF2 {
         private _onRenderReady();
         private _onRenderReady();
         private _onLoaderComplete();
         private _onLoaderComplete();
         private _loadData(data);
         private _loadData(data);
+        private _addRightHandToLeftHandRootTransform();
         private _showMeshes();
         private _showMeshes();
         private _startAnimations();
         private _startAnimations();
         private _clear();
         private _clear();
@@ -351,21 +358,13 @@ declare module BABYLON.GLTF2 {
         */
         */
         static DecodeBase64(uri: string): ArrayBuffer;
         static DecodeBase64(uri: string): ArrayBuffer;
         static ForEach(view: Uint16Array | Uint32Array | Float32Array, func: (nvalue: number, index: number) => void): void;
         static ForEach(view: Uint16Array | Uint32Array | Float32Array, func: (nvalue: number, index: number) => void): void;
-        /**
-        * Returns the wrap mode of the texture
-        * @param mode: the mode value
-        */
-        static GetWrapMode(mode: number): number;
+        static GetTextureWrapMode(mode: ETextureWrapMode): number;
         /**
         /**
          * Returns the byte stride giving an accessor
          * Returns the byte stride giving an accessor
          * @param accessor: the GLTF accessor objet
          * @param accessor: the GLTF accessor objet
          */
          */
         static GetByteStrideFromType(accessor: IGLTFAccessor): number;
         static GetByteStrideFromType(accessor: IGLTFAccessor): number;
-        /**
-         * Returns the texture filter mode giving a mode value
-         * @param mode: the filter mode value
-         */
-        static GetTextureFilterMode(mode: number): ETextureMinFilter;
+        static GetTextureSamplingMode(magFilter: ETextureMagFilter, minFilter: ETextureMinFilter): number;
         /**
         /**
          * Decodes a buffer view into a string
          * Decodes a buffer view into a string
          * @param view: the buffer view
          * @param view: the buffer view

+ 77 - 23
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -1,8 +1,20 @@
 /// <reference path="../../../dist/preview release/babylon.d.ts"/>
 /// <reference path="../../../dist/preview release/babylon.d.ts"/>
 var BABYLON;
 var BABYLON;
 (function (BABYLON) {
 (function (BABYLON) {
+    var GLTFLoaderCoordinateSystemMode;
+    (function (GLTFLoaderCoordinateSystemMode) {
+        // Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene (scene.useRightHandedSystem).
+        // NOTE: When scene.useRightHandedSystem is false, an additional transform will be added to the root to transform the data from right-handed to left-handed.
+        GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["AUTO"] = 0] = "AUTO";
+        // The glTF right-handed data is not transformed in any form and is loaded directly.
+        GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["PASS_THROUGH"] = 1] = "PASS_THROUGH";
+        // Sets the useRightHandedSystem flag on the scene.
+        GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["FORCE_RIGHT_HANDED"] = 2] = "FORCE_RIGHT_HANDED";
+    })(GLTFLoaderCoordinateSystemMode = BABYLON.GLTFLoaderCoordinateSystemMode || (BABYLON.GLTFLoaderCoordinateSystemMode = {}));
     var GLTFFileLoader = (function () {
     var GLTFFileLoader = (function () {
         function GLTFFileLoader() {
         function GLTFFileLoader() {
+            // V2 options
+            this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;
             this.extensions = {
             this.extensions = {
                 ".gltf": { isBinary: false },
                 ".gltf": { isBinary: false },
                 ".glb": { isBinary: true }
                 ".glb": { isBinary: true }
@@ -349,7 +361,6 @@ var BABYLON;
                 this._loadAsync(null, scene, data, rootUrl, onSuccess, onError);
                 this._loadAsync(null, scene, data, rootUrl, onSuccess, onError);
             };
             };
             GLTFLoader.prototype._loadAsync = function (nodeNames, scene, data, rootUrl, onSuccess, onError) {
             GLTFLoader.prototype._loadAsync = function (nodeNames, scene, data, rootUrl, onSuccess, onError) {
-                scene.useRightHandedSystem = true;
                 this._clear();
                 this._clear();
                 this._loadData(data);
                 this._loadData(data);
                 this._babylonScene = scene;
                 this._babylonScene = scene;
@@ -362,6 +373,22 @@ var BABYLON;
                 this.removePendingData(this);
                 this.removePendingData(this);
             };
             };
             GLTFLoader.prototype._onRenderReady = function () {
             GLTFLoader.prototype._onRenderReady = function () {
+                switch (this._parent.coordinateSystemMode) {
+                    case BABYLON.GLTFLoaderCoordinateSystemMode.AUTO:
+                        if (!this._babylonScene.useRightHandedSystem) {
+                            this._addRightHandToLeftHandRootTransform();
+                        }
+                        break;
+                    case BABYLON.GLTFLoaderCoordinateSystemMode.PASS_THROUGH:
+                        // do nothing
+                        break;
+                    case BABYLON.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:
+                        this._babylonScene.useRightHandedSystem = true;
+                        break;
+                    default:
+                        BABYLON.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();
@@ -402,6 +429,18 @@ var BABYLON;
                     binaryBuffer.loadedData = data.bin;
                     binaryBuffer.loadedData = data.bin;
                 }
                 }
             };
             };
+            GLTFLoader.prototype._addRightHandToLeftHandRootTransform = function () {
+                var rootMesh = new BABYLON.Mesh("root", this._babylonScene);
+                rootMesh.scaling = new BABYLON.Vector3(1, 1, -1);
+                rootMesh.rotationQuaternion = new BABYLON.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;
+                    }
+                }
+            };
             GLTFLoader.prototype._showMeshes = function () {
             GLTFLoader.prototype._showMeshes = function () {
                 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++) {
@@ -1144,7 +1183,7 @@ var BABYLON;
                 }
                 }
                 var sampler = (texture.sampler === undefined ? {} : this._gltf.samplers[texture.sampler]);
                 var sampler = (texture.sampler === undefined ? {} : this._gltf.samplers[texture.sampler]);
                 var noMipMaps = (sampler.minFilter === GLTF2.ETextureMinFilter.NEAREST || sampler.minFilter === GLTF2.ETextureMinFilter.LINEAR);
                 var noMipMaps = (sampler.minFilter === GLTF2.ETextureMinFilter.NEAREST || sampler.minFilter === GLTF2.ETextureMinFilter.LINEAR);
-                var samplingMode = GLTF2.GLTFUtils.GetTextureFilterMode(sampler.minFilter);
+                var samplingMode = GLTF2.GLTFUtils.GetTextureSamplingMode(sampler.magFilter, sampler.minFilter);
                 this.addPendingData(texture);
                 this.addPendingData(texture);
                 var babylonTexture = new BABYLON.Texture(url, this._babylonScene, noMipMaps, false, samplingMode, function () {
                 var babylonTexture = new BABYLON.Texture(url, this._babylonScene, noMipMaps, false, samplingMode, function () {
                     _this.removePendingData(texture);
                     _this.removePendingData(texture);
@@ -1153,8 +1192,8 @@ var BABYLON;
                     _this.removePendingData(texture);
                     _this.removePendingData(texture);
                 });
                 });
                 babylonTexture.coordinatesIndex = texCoord;
                 babylonTexture.coordinatesIndex = texCoord;
-                babylonTexture.wrapU = GLTF2.GLTFUtils.GetWrapMode(sampler.wrapS);
-                babylonTexture.wrapV = GLTF2.GLTFUtils.GetWrapMode(sampler.wrapT);
+                babylonTexture.wrapU = GLTF2.GLTFUtils.GetTextureWrapMode(sampler.wrapS);
+                babylonTexture.wrapV = GLTF2.GLTFUtils.GetTextureWrapMode(sampler.wrapT);
                 babylonTexture.name = texture.name || "texture" + textureInfo.index;
                 babylonTexture.name = texture.name || "texture" + textureInfo.index;
                 // Cache the texture
                 // Cache the texture
                 texture.babylonTextures = texture.babylonTextures || [];
                 texture.babylonTextures = texture.babylonTextures || [];
@@ -1210,16 +1249,14 @@ var BABYLON;
                     func(view[index], index);
                     func(view[index], index);
                 }
                 }
             };
             };
-            /**
-            * Returns the wrap mode of the texture
-            * @param mode: the mode value
-            */
-            GLTFUtils.GetWrapMode = function (mode) {
+            GLTFUtils.GetTextureWrapMode = function (mode) {
                 switch (mode) {
                 switch (mode) {
-                    case GLTF2.ETextureWrapMode.CLAMP_TO_EDGE: return BABYLON.Texture.CLAMP_ADDRESSMODE;
+                    case GLTF2.ETextureWrapMode.CLAMP_TO_EDGE: BABYLON.Texture.CLAMP_ADDRESSMODE;
                     case GLTF2.ETextureWrapMode.MIRRORED_REPEAT: return BABYLON.Texture.MIRROR_ADDRESSMODE;
                     case GLTF2.ETextureWrapMode.MIRRORED_REPEAT: return BABYLON.Texture.MIRROR_ADDRESSMODE;
                     case GLTF2.ETextureWrapMode.REPEAT: return BABYLON.Texture.WRAP_ADDRESSMODE;
                     case GLTF2.ETextureWrapMode.REPEAT: return BABYLON.Texture.WRAP_ADDRESSMODE;
-                    default: return BABYLON.Texture.WRAP_ADDRESSMODE;
+                    default:
+                        BABYLON.Tools.Warn("Invalid texture wrap mode (" + mode + ")");
+                        return BABYLON.Texture.WRAP_ADDRESSMODE;
                 }
                 }
             };
             };
             /**
             /**
@@ -1239,18 +1276,35 @@ var BABYLON;
                     default: return 1;
                     default: return 1;
                 }
                 }
             };
             };
-            /**
-             * Returns the texture filter mode giving a mode value
-             * @param mode: the filter mode value
-             */
-            GLTFUtils.GetTextureFilterMode = function (mode) {
-                switch (mode) {
-                    case GLTF2.ETextureMinFilter.LINEAR:
-                    case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_NEAREST:
-                    case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_LINEAR: return BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
-                    case GLTF2.ETextureMinFilter.NEAREST:
-                    case GLTF2.ETextureMinFilter.NEAREST_MIPMAP_NEAREST: return BABYLON.Texture.NEAREST_SAMPLINGMODE;
-                    default: return BABYLON.Texture.BILINEAR_SAMPLINGMODE;
+            GLTFUtils.GetTextureSamplingMode = function (magFilter, minFilter) {
+                if (magFilter === GLTF2.ETextureMagFilter.LINEAR) {
+                    switch (minFilter) {
+                        case GLTF2.ETextureMinFilter.NEAREST: return BABYLON.Texture.LINEAR_NEAREST;
+                        case GLTF2.ETextureMinFilter.LINEAR: return BABYLON.Texture.LINEAR_LINEAR;
+                        case GLTF2.ETextureMinFilter.NEAREST_MIPMAP_NEAREST: return BABYLON.Texture.LINEAR_NEAREST_MIPNEAREST;
+                        case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_NEAREST: return BABYLON.Texture.LINEAR_LINEAR_MIPNEAREST;
+                        case GLTF2.ETextureMinFilter.NEAREST_MIPMAP_LINEAR: return BABYLON.Texture.LINEAR_NEAREST_MIPLINEAR;
+                        case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_LINEAR: return BABYLON.Texture.LINEAR_LINEAR_MIPLINEAR;
+                        default:
+                            BABYLON.Tools.Warn("Invalid texture minification filter (" + minFilter + ")");
+                            return BABYLON.Texture.LINEAR_LINEAR_MIPLINEAR;
+                    }
+                }
+                else {
+                    if (magFilter !== GLTF2.ETextureMagFilter.NEAREST) {
+                        BABYLON.Tools.Warn("Invalid texture magnification filter (" + magFilter + ")");
+                    }
+                    switch (minFilter) {
+                        case GLTF2.ETextureMinFilter.NEAREST: return BABYLON.Texture.NEAREST_NEAREST;
+                        case GLTF2.ETextureMinFilter.LINEAR: return BABYLON.Texture.NEAREST_LINEAR;
+                        case GLTF2.ETextureMinFilter.NEAREST_MIPMAP_NEAREST: return BABYLON.Texture.NEAREST_NEAREST_MIPNEAREST;
+                        case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_NEAREST: return BABYLON.Texture.NEAREST_LINEAR_MIPNEAREST;
+                        case GLTF2.ETextureMinFilter.NEAREST_MIPMAP_LINEAR: return BABYLON.Texture.NEAREST_NEAREST_MIPLINEAR;
+                        case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_LINEAR: return BABYLON.Texture.NEAREST_LINEAR_MIPLINEAR;
+                        default:
+                            BABYLON.Tools.Warn("Invalid texture minification filter (" + minFilter + ")");
+                            return BABYLON.Texture.NEAREST_NEAREST_MIPNEAREST;
+                    }
                 }
                 }
             };
             };
             /**
             /**

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 9 - 10
dist/preview release/loaders/babylon.glTFFileLoader.d.ts

@@ -1,5 +1,10 @@
 
 
 declare module BABYLON {
 declare module BABYLON {
+    enum GLTFLoaderCoordinateSystemMode {
+        AUTO = 0,
+        PASS_THROUGH = 1,
+        FORCE_RIGHT_HANDED = 2,
+    }
     interface IGLTFLoaderData {
     interface IGLTFLoaderData {
         json: Object;
         json: Object;
         bin: ArrayBufferView;
         bin: ArrayBufferView;
@@ -13,6 +18,7 @@ declare module BABYLON {
         static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
         static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
         static HomogeneousCoordinates: boolean;
         static HomogeneousCoordinates: boolean;
         static IncrementalLoading: boolean;
         static IncrementalLoading: boolean;
+        coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
         onTextureLoaded: (texture: BaseTexture) => void;
         onTextureLoaded: (texture: BaseTexture) => void;
         onMaterialLoaded: (material: Material) => void;
         onMaterialLoaded: (material: Material) => void;
         onComplete: () => void;
         onComplete: () => void;
@@ -794,6 +800,7 @@ declare module BABYLON.GLTF2 {
         private _onRenderReady();
         private _onRenderReady();
         private _onLoaderComplete();
         private _onLoaderComplete();
         private _loadData(data);
         private _loadData(data);
+        private _addRightHandToLeftHandRootTransform();
         private _showMeshes();
         private _showMeshes();
         private _startAnimations();
         private _startAnimations();
         private _clear();
         private _clear();
@@ -846,21 +853,13 @@ declare module BABYLON.GLTF2 {
         */
         */
         static DecodeBase64(uri: string): ArrayBuffer;
         static DecodeBase64(uri: string): ArrayBuffer;
         static ForEach(view: Uint16Array | Uint32Array | Float32Array, func: (nvalue: number, index: number) => void): void;
         static ForEach(view: Uint16Array | Uint32Array | Float32Array, func: (nvalue: number, index: number) => void): void;
-        /**
-        * Returns the wrap mode of the texture
-        * @param mode: the mode value
-        */
-        static GetWrapMode(mode: number): number;
+        static GetTextureWrapMode(mode: ETextureWrapMode): number;
         /**
         /**
          * Returns the byte stride giving an accessor
          * Returns the byte stride giving an accessor
          * @param accessor: the GLTF accessor objet
          * @param accessor: the GLTF accessor objet
          */
          */
         static GetByteStrideFromType(accessor: IGLTFAccessor): number;
         static GetByteStrideFromType(accessor: IGLTFAccessor): number;
-        /**
-         * Returns the texture filter mode giving a mode value
-         * @param mode: the filter mode value
-         */
-        static GetTextureFilterMode(mode: number): ETextureMinFilter;
+        static GetTextureSamplingMode(magFilter: ETextureMagFilter, minFilter: ETextureMinFilter): number;
         /**
         /**
          * Decodes a buffer view into a string
          * Decodes a buffer view into a string
          * @param view: the buffer view
          * @param view: the buffer view

+ 77 - 23
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -1,8 +1,20 @@
 /// <reference path="../../../dist/preview release/babylon.d.ts"/>
 /// <reference path="../../../dist/preview release/babylon.d.ts"/>
 var BABYLON;
 var BABYLON;
 (function (BABYLON) {
 (function (BABYLON) {
+    var GLTFLoaderCoordinateSystemMode;
+    (function (GLTFLoaderCoordinateSystemMode) {
+        // Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene (scene.useRightHandedSystem).
+        // NOTE: When scene.useRightHandedSystem is false, an additional transform will be added to the root to transform the data from right-handed to left-handed.
+        GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["AUTO"] = 0] = "AUTO";
+        // The glTF right-handed data is not transformed in any form and is loaded directly.
+        GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["PASS_THROUGH"] = 1] = "PASS_THROUGH";
+        // Sets the useRightHandedSystem flag on the scene.
+        GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["FORCE_RIGHT_HANDED"] = 2] = "FORCE_RIGHT_HANDED";
+    })(GLTFLoaderCoordinateSystemMode = BABYLON.GLTFLoaderCoordinateSystemMode || (BABYLON.GLTFLoaderCoordinateSystemMode = {}));
     var GLTFFileLoader = (function () {
     var GLTFFileLoader = (function () {
         function GLTFFileLoader() {
         function GLTFFileLoader() {
+            // V2 options
+            this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;
             this.extensions = {
             this.extensions = {
                 ".gltf": { isBinary: false },
                 ".gltf": { isBinary: false },
                 ".glb": { isBinary: true }
                 ".glb": { isBinary: true }
@@ -2502,7 +2514,6 @@ var BABYLON;
                 this._loadAsync(null, scene, data, rootUrl, onSuccess, onError);
                 this._loadAsync(null, scene, data, rootUrl, onSuccess, onError);
             };
             };
             GLTFLoader.prototype._loadAsync = function (nodeNames, scene, data, rootUrl, onSuccess, onError) {
             GLTFLoader.prototype._loadAsync = function (nodeNames, scene, data, rootUrl, onSuccess, onError) {
-                scene.useRightHandedSystem = true;
                 this._clear();
                 this._clear();
                 this._loadData(data);
                 this._loadData(data);
                 this._babylonScene = scene;
                 this._babylonScene = scene;
@@ -2515,6 +2526,22 @@ var BABYLON;
                 this.removePendingData(this);
                 this.removePendingData(this);
             };
             };
             GLTFLoader.prototype._onRenderReady = function () {
             GLTFLoader.prototype._onRenderReady = function () {
+                switch (this._parent.coordinateSystemMode) {
+                    case BABYLON.GLTFLoaderCoordinateSystemMode.AUTO:
+                        if (!this._babylonScene.useRightHandedSystem) {
+                            this._addRightHandToLeftHandRootTransform();
+                        }
+                        break;
+                    case BABYLON.GLTFLoaderCoordinateSystemMode.PASS_THROUGH:
+                        // do nothing
+                        break;
+                    case BABYLON.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:
+                        this._babylonScene.useRightHandedSystem = true;
+                        break;
+                    default:
+                        BABYLON.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();
@@ -2555,6 +2582,18 @@ var BABYLON;
                     binaryBuffer.loadedData = data.bin;
                     binaryBuffer.loadedData = data.bin;
                 }
                 }
             };
             };
+            GLTFLoader.prototype._addRightHandToLeftHandRootTransform = function () {
+                var rootMesh = new BABYLON.Mesh("root", this._babylonScene);
+                rootMesh.scaling = new BABYLON.Vector3(1, 1, -1);
+                rootMesh.rotationQuaternion = new BABYLON.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;
+                    }
+                }
+            };
             GLTFLoader.prototype._showMeshes = function () {
             GLTFLoader.prototype._showMeshes = function () {
                 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++) {
@@ -3297,7 +3336,7 @@ var BABYLON;
                 }
                 }
                 var sampler = (texture.sampler === undefined ? {} : this._gltf.samplers[texture.sampler]);
                 var sampler = (texture.sampler === undefined ? {} : this._gltf.samplers[texture.sampler]);
                 var noMipMaps = (sampler.minFilter === GLTF2.ETextureMinFilter.NEAREST || sampler.minFilter === GLTF2.ETextureMinFilter.LINEAR);
                 var noMipMaps = (sampler.minFilter === GLTF2.ETextureMinFilter.NEAREST || sampler.minFilter === GLTF2.ETextureMinFilter.LINEAR);
-                var samplingMode = GLTF2.GLTFUtils.GetTextureFilterMode(sampler.minFilter);
+                var samplingMode = GLTF2.GLTFUtils.GetTextureSamplingMode(sampler.magFilter, sampler.minFilter);
                 this.addPendingData(texture);
                 this.addPendingData(texture);
                 var babylonTexture = new BABYLON.Texture(url, this._babylonScene, noMipMaps, false, samplingMode, function () {
                 var babylonTexture = new BABYLON.Texture(url, this._babylonScene, noMipMaps, false, samplingMode, function () {
                     _this.removePendingData(texture);
                     _this.removePendingData(texture);
@@ -3306,8 +3345,8 @@ var BABYLON;
                     _this.removePendingData(texture);
                     _this.removePendingData(texture);
                 });
                 });
                 babylonTexture.coordinatesIndex = texCoord;
                 babylonTexture.coordinatesIndex = texCoord;
-                babylonTexture.wrapU = GLTF2.GLTFUtils.GetWrapMode(sampler.wrapS);
-                babylonTexture.wrapV = GLTF2.GLTFUtils.GetWrapMode(sampler.wrapT);
+                babylonTexture.wrapU = GLTF2.GLTFUtils.GetTextureWrapMode(sampler.wrapS);
+                babylonTexture.wrapV = GLTF2.GLTFUtils.GetTextureWrapMode(sampler.wrapT);
                 babylonTexture.name = texture.name || "texture" + textureInfo.index;
                 babylonTexture.name = texture.name || "texture" + textureInfo.index;
                 // Cache the texture
                 // Cache the texture
                 texture.babylonTextures = texture.babylonTextures || [];
                 texture.babylonTextures = texture.babylonTextures || [];
@@ -3363,16 +3402,14 @@ var BABYLON;
                     func(view[index], index);
                     func(view[index], index);
                 }
                 }
             };
             };
-            /**
-            * Returns the wrap mode of the texture
-            * @param mode: the mode value
-            */
-            GLTFUtils.GetWrapMode = function (mode) {
+            GLTFUtils.GetTextureWrapMode = function (mode) {
                 switch (mode) {
                 switch (mode) {
-                    case GLTF2.ETextureWrapMode.CLAMP_TO_EDGE: return BABYLON.Texture.CLAMP_ADDRESSMODE;
+                    case GLTF2.ETextureWrapMode.CLAMP_TO_EDGE: BABYLON.Texture.CLAMP_ADDRESSMODE;
                     case GLTF2.ETextureWrapMode.MIRRORED_REPEAT: return BABYLON.Texture.MIRROR_ADDRESSMODE;
                     case GLTF2.ETextureWrapMode.MIRRORED_REPEAT: return BABYLON.Texture.MIRROR_ADDRESSMODE;
                     case GLTF2.ETextureWrapMode.REPEAT: return BABYLON.Texture.WRAP_ADDRESSMODE;
                     case GLTF2.ETextureWrapMode.REPEAT: return BABYLON.Texture.WRAP_ADDRESSMODE;
-                    default: return BABYLON.Texture.WRAP_ADDRESSMODE;
+                    default:
+                        BABYLON.Tools.Warn("Invalid texture wrap mode (" + mode + ")");
+                        return BABYLON.Texture.WRAP_ADDRESSMODE;
                 }
                 }
             };
             };
             /**
             /**
@@ -3392,18 +3429,35 @@ var BABYLON;
                     default: return 1;
                     default: return 1;
                 }
                 }
             };
             };
-            /**
-             * Returns the texture filter mode giving a mode value
-             * @param mode: the filter mode value
-             */
-            GLTFUtils.GetTextureFilterMode = function (mode) {
-                switch (mode) {
-                    case GLTF2.ETextureMinFilter.LINEAR:
-                    case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_NEAREST:
-                    case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_LINEAR: return BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
-                    case GLTF2.ETextureMinFilter.NEAREST:
-                    case GLTF2.ETextureMinFilter.NEAREST_MIPMAP_NEAREST: return BABYLON.Texture.NEAREST_SAMPLINGMODE;
-                    default: return BABYLON.Texture.BILINEAR_SAMPLINGMODE;
+            GLTFUtils.GetTextureSamplingMode = function (magFilter, minFilter) {
+                if (magFilter === GLTF2.ETextureMagFilter.LINEAR) {
+                    switch (minFilter) {
+                        case GLTF2.ETextureMinFilter.NEAREST: return BABYLON.Texture.LINEAR_NEAREST;
+                        case GLTF2.ETextureMinFilter.LINEAR: return BABYLON.Texture.LINEAR_LINEAR;
+                        case GLTF2.ETextureMinFilter.NEAREST_MIPMAP_NEAREST: return BABYLON.Texture.LINEAR_NEAREST_MIPNEAREST;
+                        case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_NEAREST: return BABYLON.Texture.LINEAR_LINEAR_MIPNEAREST;
+                        case GLTF2.ETextureMinFilter.NEAREST_MIPMAP_LINEAR: return BABYLON.Texture.LINEAR_NEAREST_MIPLINEAR;
+                        case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_LINEAR: return BABYLON.Texture.LINEAR_LINEAR_MIPLINEAR;
+                        default:
+                            BABYLON.Tools.Warn("Invalid texture minification filter (" + minFilter + ")");
+                            return BABYLON.Texture.LINEAR_LINEAR_MIPLINEAR;
+                    }
+                }
+                else {
+                    if (magFilter !== GLTF2.ETextureMagFilter.NEAREST) {
+                        BABYLON.Tools.Warn("Invalid texture magnification filter (" + magFilter + ")");
+                    }
+                    switch (minFilter) {
+                        case GLTF2.ETextureMinFilter.NEAREST: return BABYLON.Texture.NEAREST_NEAREST;
+                        case GLTF2.ETextureMinFilter.LINEAR: return BABYLON.Texture.NEAREST_LINEAR;
+                        case GLTF2.ETextureMinFilter.NEAREST_MIPMAP_NEAREST: return BABYLON.Texture.NEAREST_NEAREST_MIPNEAREST;
+                        case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_NEAREST: return BABYLON.Texture.NEAREST_LINEAR_MIPNEAREST;
+                        case GLTF2.ETextureMinFilter.NEAREST_MIPMAP_LINEAR: return BABYLON.Texture.NEAREST_NEAREST_MIPLINEAR;
+                        case GLTF2.ETextureMinFilter.LINEAR_MIPMAP_LINEAR: return BABYLON.Texture.NEAREST_LINEAR_MIPLINEAR;
+                        default:
+                            BABYLON.Tools.Warn("Invalid texture minification filter (" + minFilter + ")");
+                            return BABYLON.Texture.NEAREST_NEAREST_MIPNEAREST;
+                    }
                 }
                 }
             };
             };
             /**
             /**

File diff suppressed because it is too large
+ 2 - 2
dist/preview release/loaders/babylon.glTFFileLoader.min.js