瀏覽代碼

This PR corrects the logic used to determine when to bake textures when exporting the KHR_texture_transform extension for the glTF serializer.

Nicholas Barlow 5 年之前
父節點
當前提交
2dff0b68be
共有 2 個文件被更改,包括 12 次插入20 次删除
  1. 1 0
      dist/preview release/what's new.md
  2. 11 20
      serializers/src/glTF/2.0/Extensions/KHR_texture_transform.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -34,6 +34,7 @@
 - Fix infinite loop in `GlowLayer.unReferenceMeshFromUsingItsOwnMaterial` ([Popov72](https://github.com/Popov72)
 - `QuadraticErrorSimplification` was not exported ([RaananW](https://github.com/Raananw)
 - Fix NME Frames bug where collapsing and moving a frame removed the nodes inside ([Kyle Belfort](https://github.com/belfortk)
+- Remove texture baking from `KHR_texture_transform` serializer. ([drigax](https://github.com/Drigax))
 
 
 ## Breaking changes

+ 11 - 20
serializers/src/glTF/2.0/Extensions/KHR_texture_transform.ts

@@ -98,28 +98,19 @@ export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
                 reject(`${context}: "scene" is not defined for Babylon texture ${babylonTexture.name}!`);
                 return;
             }
-
-            let transformIsRequired = false;
-
-            if (babylonTexture.uOffset !== 0 || babylonTexture.vOffset !== 0) {
-                transformIsRequired = true;
-            }
-
-            if (babylonTexture.uScale !== 1 || babylonTexture.vScale !== 1) {
-                transformIsRequired = true;
-            }
-
-            if (babylonTexture.wAng !== 0) {
-                transformIsRequired = true;
-            }
-
-            if (!transformIsRequired) {
-                resolve(babylonTexture);
-                return;
+            // 
+            let bakeTextureTransform = false;
+
+            /*
+            * The KHR_texture_transform schema only supports rotation around the origin.
+            * the texture must be baked to preserve appearance.
+            * see: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates
+            */
+            if ( (babylonTexture.uAng !== 0 || babylonTexture.wAng !== 0 || babylonTexture.vAng !== 0) && (babylonTexture.uRotationCenter !== 0 || babylonTexture.vRotationCenter !== 0)) {
+                bakeTextureTransform = true;
             }
 
-            // Do we need to flatten the transform?
-            if (babylonTexture.uRotationCenter === 0 && babylonTexture.vRotationCenter === 0) {
+            if (!bakeTextureTransform) {
                 resolve(babylonTexture);
                 return;
             }