David Catuhe 7 年之前
父节点
当前提交
57fb2843ea
共有 25 个文件被更改,包括 38505 次插入38433 次删除
  1. 12691 12687
      dist/preview release/babylon.d.ts
  2. 38 38
      dist/preview release/babylon.js
  3. 58 32
      dist/preview release/babylon.max.js
  4. 12691 12687
      dist/preview release/babylon.module.d.ts
  5. 39 39
      dist/preview release/babylon.worker.js
  6. 6293 6289
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  7. 50 50
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  8. 58 32
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  9. 6293 6289
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts
  10. 3 3
      dist/preview release/gui/babylon.gui.min.js
  11. 263 263
      dist/preview release/inspector/babylon.inspector.bundle.js
  12. 3 3
      dist/preview release/inspector/babylon.inspector.min.js
  13. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  14. 2 2
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  15. 3 3
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  16. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  17. 3 3
      dist/preview release/loaders/babylonjs.loaders.min.js
  18. 1 1
      dist/preview release/materialsLibrary/babylon.customMaterial.min.js
  19. 1 1
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js
  20. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  21. 4 4
      dist/preview release/materialsLibrary/babylonjs.materials.min.js
  22. 1 1
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  23. 1 1
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  24. 1 1
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js
  25. 4 0
      src/Mesh/babylon.linesMesh.ts

文件差异内容过多而无法显示
+ 12691 - 12687
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 38 - 38
dist/preview release/babylon.js


+ 58 - 32
dist/preview release/babylon.max.js

@@ -46780,6 +46780,9 @@ var BABYLON;
             get: function () {
                 return this._colorShader;
             },
+            set: function (value) {
+                // Do nothing
+            },
             enumerable: true,
             configurable: true
         });
@@ -65798,8 +65801,9 @@ var BABYLON;
             this._onPhysicsCollideCallbacks = [];
             this._deltaPosition = BABYLON.Vector3.Zero();
             this._isDisposed = false;
-            this._tmpPositionWithDelta = BABYLON.Vector3.Zero();
-            this._tmpRotationWithDelta = new BABYLON.Quaternion();
+            //temp variables for parent rotation calculations
+            this._mats = [new BABYLON.Matrix(), new BABYLON.Matrix()];
+            this._tmpQuat = new BABYLON.Quaternion();
             /**
              * this function is executed by the physics engine.
              */
@@ -65807,25 +65811,18 @@ var BABYLON;
                 if (!_this._physicsEngine) {
                     return;
                 }
-                if (_this._options.ignoreParent && _this.object.parent) {
-                    _this._tmpPositionWithDelta.copyFrom(_this.object.getAbsolutePosition());
-                    //this.object.getAbsolutePosition().subtractToRef(this._deltaPosition, this._tmpPositionWithDelta);
+                _this.object.translate(_this._deltaPosition, -1);
+                _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
+                if (_this.object.parent) {
+                    _this.object.computeWorldMatrix(false).getRotationMatrixToRef(_this._mats[0]);
+                    BABYLON.Quaternion.FromRotationMatrixToRef(_this._mats[0], _this._tmpQuat);
+                    _this._tmpQuat.normalize();
                 }
                 else {
-                    _this.object.position.subtractToRef(_this._deltaPosition, _this._tmpPositionWithDelta);
-                }
-                //conjugate deltaRotation
-                if (_this.object.rotationQuaternion) {
-                    if (_this._deltaRotationConjugated) {
-                        _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this._tmpRotationWithDelta);
-                    }
-                    else {
-                        _this._tmpRotationWithDelta.copyFrom(_this.object.rotationQuaternion);
-                    }
+                    _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new BABYLON.Quaternion());
                 }
-                // Only if not disabled
                 if (!_this._options.disableBidirectionalTransformation) {
-                    _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, _this._tmpPositionWithDelta, _this._tmpRotationWithDelta);
+                    _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePivotPoint(), _this._tmpQuat);
                 }
                 _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
                     func(_this);
@@ -65838,19 +65835,19 @@ var BABYLON;
                 if (!_this._physicsEngine) {
                     return;
                 }
-                _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
-                    func(_this);
-                });
                 _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
-                if (_this._options.ignoreParent && _this.object.parent) {
-                    _this.object.position.subtractInPlace(_this.object.parent.getAbsolutePosition());
-                }
-                else {
-                    _this.object.position.addInPlace(_this._deltaPosition);
-                }
-                if (_this._deltaRotation && _this.object.rotationQuaternion) {
-                    _this.object.rotationQuaternion.multiplyInPlace(_this._deltaRotation);
-                }
+                // object has now its world rotation. needs to be converted to local.
+                if (_this.object.parent && _this.object.rotationQuaternion) {
+                    _this.object.parent.computeWorldMatrix(false).getRotationMatrixToRef(_this._mats[0]);
+                    BABYLON.Quaternion.FromRotationMatrixToRef(_this._mats[0], _this._tmpQuat);
+                    _this._tmpQuat.conjugateInPlace();
+                    _this._tmpQuat.normalize();
+                    _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
+                }
+                // take the position set and make it the absolute position of this object.
+                _this.object.setAbsolutePosition(_this.object.position);
+                _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
+                _this.object.translate(_this._deltaPosition, 1);
             };
             /**
              * Legacy collision detection event support
@@ -66774,10 +66771,31 @@ var BABYLON;
                     returnValue = new this.BJSCANNON.Plane();
                     break;
                 case BABYLON.PhysicsImpostor.MeshImpostor:
+                    // should transform the vertex data to world coordinates!!
                     var rawVerts = object.getVerticesData ? object.getVerticesData(BABYLON.VertexBuffer.PositionKind) : [];
                     var rawFaces = object.getIndices ? object.getIndices() : [];
+                    if (!rawVerts)
+                        return;
+                    // get only scale! so the object could transform correctly.
+                    var oldPosition = object.position.clone();
+                    var oldRotation = object.rotation && object.rotation.clone();
+                    var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
+                    object.position.copyFromFloats(0, 0, 0);
+                    object.rotation && object.rotation.copyFromFloats(0, 0, 0);
+                    object.rotationQuaternion && object.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
+                    var transform = object.computeWorldMatrix(true);
+                    // convert rawVerts to object space
+                    var temp = new Array();
+                    var index;
+                    for (index = 0; index < rawVerts.length; index += 3) {
+                        BABYLON.Vector3.TransformCoordinates(BABYLON.Vector3.FromArray(rawVerts, index), transform).toArray(temp, index);
+                    }
                     BABYLON.Tools.Warn("MeshImpostor only collides against spheres.");
-                    returnValue = new this.BJSCANNON.Trimesh(rawVerts, rawFaces);
+                    returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
+                    //now set back the transformation!
+                    object.position.copyFrom(oldPosition);
+                    oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
+                    oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
                     break;
                 case BABYLON.PhysicsImpostor.HeightmapImpostor:
                     returnValue = this._createHeightmap(object);
@@ -66842,8 +66860,12 @@ var BABYLON;
             //make sure it is updated...
             object.computeWorldMatrix && object.computeWorldMatrix(true);
             // The delta between the mesh position and the mesh bounding box center
+            var bInfo = object.getBoundingInfo();
+            if (!bInfo)
+                return;
             var center = impostor.getObjectCenter();
-            this._tmpDeltaPosition.copyFrom(object.position.subtract(center));
+            //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
+            this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
             this._tmpPosition.copyFrom(center);
             var quaternion = object.rotationQuaternion;
             if (!quaternion) {
@@ -66885,7 +66907,7 @@ var BABYLON;
             }
             else if (impostor.type === BABYLON.PhysicsImpostor.MeshImpostor) {
                 this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
-                this._tmpPosition.copyFrom(object.position);
+                //this._tmpPosition.copyFrom(object.position);
             }
             impostor.setDeltaPosition(this._tmpDeltaPosition);
             //Now update the impostor object
@@ -66896,10 +66918,14 @@ var BABYLON;
             impostor.object.position.copyFrom(impostor.physicsBody.position);
             if (impostor.object.rotationQuaternion) {
                 impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
+                //impostor.object.rotationQuaternion.y *= -1;
+                //impostor.object.rotationQuaternion.z *= -1;
             }
         };
         CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
             impostor.physicsBody.position.copy(newPosition);
+            //newRotation.y *= -1;
+            //newRotation.z *= -1;
             impostor.physicsBody.quaternion.copy(newRotation);
         };
         CannonJSPlugin.prototype.isSupported = function () {

文件差异内容过多而无法显示
+ 12691 - 12687
dist/preview release/babylon.module.d.ts


文件差异内容过多而无法显示
+ 39 - 39
dist/preview release/babylon.worker.js


文件差异内容过多而无法显示
+ 6293 - 6289
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


文件差异内容过多而无法显示
+ 50 - 50
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 58 - 32
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -46626,6 +46626,9 @@ var BABYLON;
             get: function () {
                 return this._colorShader;
             },
+            set: function (value) {
+                // Do nothing
+            },
             enumerable: true,
             configurable: true
         });
@@ -65644,8 +65647,9 @@ var BABYLON;
             this._onPhysicsCollideCallbacks = [];
             this._deltaPosition = BABYLON.Vector3.Zero();
             this._isDisposed = false;
-            this._tmpPositionWithDelta = BABYLON.Vector3.Zero();
-            this._tmpRotationWithDelta = new BABYLON.Quaternion();
+            //temp variables for parent rotation calculations
+            this._mats = [new BABYLON.Matrix(), new BABYLON.Matrix()];
+            this._tmpQuat = new BABYLON.Quaternion();
             /**
              * this function is executed by the physics engine.
              */
@@ -65653,25 +65657,18 @@ var BABYLON;
                 if (!_this._physicsEngine) {
                     return;
                 }
-                if (_this._options.ignoreParent && _this.object.parent) {
-                    _this._tmpPositionWithDelta.copyFrom(_this.object.getAbsolutePosition());
-                    //this.object.getAbsolutePosition().subtractToRef(this._deltaPosition, this._tmpPositionWithDelta);
+                _this.object.translate(_this._deltaPosition, -1);
+                _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
+                if (_this.object.parent) {
+                    _this.object.computeWorldMatrix(false).getRotationMatrixToRef(_this._mats[0]);
+                    BABYLON.Quaternion.FromRotationMatrixToRef(_this._mats[0], _this._tmpQuat);
+                    _this._tmpQuat.normalize();
                 }
                 else {
-                    _this.object.position.subtractToRef(_this._deltaPosition, _this._tmpPositionWithDelta);
-                }
-                //conjugate deltaRotation
-                if (_this.object.rotationQuaternion) {
-                    if (_this._deltaRotationConjugated) {
-                        _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this._tmpRotationWithDelta);
-                    }
-                    else {
-                        _this._tmpRotationWithDelta.copyFrom(_this.object.rotationQuaternion);
-                    }
+                    _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new BABYLON.Quaternion());
                 }
-                // Only if not disabled
                 if (!_this._options.disableBidirectionalTransformation) {
-                    _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, _this._tmpPositionWithDelta, _this._tmpRotationWithDelta);
+                    _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePivotPoint(), _this._tmpQuat);
                 }
                 _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
                     func(_this);
@@ -65684,19 +65681,19 @@ var BABYLON;
                 if (!_this._physicsEngine) {
                     return;
                 }
-                _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
-                    func(_this);
-                });
                 _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
-                if (_this._options.ignoreParent && _this.object.parent) {
-                    _this.object.position.subtractInPlace(_this.object.parent.getAbsolutePosition());
-                }
-                else {
-                    _this.object.position.addInPlace(_this._deltaPosition);
-                }
-                if (_this._deltaRotation && _this.object.rotationQuaternion) {
-                    _this.object.rotationQuaternion.multiplyInPlace(_this._deltaRotation);
-                }
+                // object has now its world rotation. needs to be converted to local.
+                if (_this.object.parent && _this.object.rotationQuaternion) {
+                    _this.object.parent.computeWorldMatrix(false).getRotationMatrixToRef(_this._mats[0]);
+                    BABYLON.Quaternion.FromRotationMatrixToRef(_this._mats[0], _this._tmpQuat);
+                    _this._tmpQuat.conjugateInPlace();
+                    _this._tmpQuat.normalize();
+                    _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
+                }
+                // take the position set and make it the absolute position of this object.
+                _this.object.setAbsolutePosition(_this.object.position);
+                _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
+                _this.object.translate(_this._deltaPosition, 1);
             };
             /**
              * Legacy collision detection event support
@@ -66620,10 +66617,31 @@ var BABYLON;
                     returnValue = new this.BJSCANNON.Plane();
                     break;
                 case BABYLON.PhysicsImpostor.MeshImpostor:
+                    // should transform the vertex data to world coordinates!!
                     var rawVerts = object.getVerticesData ? object.getVerticesData(BABYLON.VertexBuffer.PositionKind) : [];
                     var rawFaces = object.getIndices ? object.getIndices() : [];
+                    if (!rawVerts)
+                        return;
+                    // get only scale! so the object could transform correctly.
+                    var oldPosition = object.position.clone();
+                    var oldRotation = object.rotation && object.rotation.clone();
+                    var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
+                    object.position.copyFromFloats(0, 0, 0);
+                    object.rotation && object.rotation.copyFromFloats(0, 0, 0);
+                    object.rotationQuaternion && object.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
+                    var transform = object.computeWorldMatrix(true);
+                    // convert rawVerts to object space
+                    var temp = new Array();
+                    var index;
+                    for (index = 0; index < rawVerts.length; index += 3) {
+                        BABYLON.Vector3.TransformCoordinates(BABYLON.Vector3.FromArray(rawVerts, index), transform).toArray(temp, index);
+                    }
                     BABYLON.Tools.Warn("MeshImpostor only collides against spheres.");
-                    returnValue = new this.BJSCANNON.Trimesh(rawVerts, rawFaces);
+                    returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
+                    //now set back the transformation!
+                    object.position.copyFrom(oldPosition);
+                    oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
+                    oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
                     break;
                 case BABYLON.PhysicsImpostor.HeightmapImpostor:
                     returnValue = this._createHeightmap(object);
@@ -66688,8 +66706,12 @@ var BABYLON;
             //make sure it is updated...
             object.computeWorldMatrix && object.computeWorldMatrix(true);
             // The delta between the mesh position and the mesh bounding box center
+            var bInfo = object.getBoundingInfo();
+            if (!bInfo)
+                return;
             var center = impostor.getObjectCenter();
-            this._tmpDeltaPosition.copyFrom(object.position.subtract(center));
+            //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
+            this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
             this._tmpPosition.copyFrom(center);
             var quaternion = object.rotationQuaternion;
             if (!quaternion) {
@@ -66731,7 +66753,7 @@ var BABYLON;
             }
             else if (impostor.type === BABYLON.PhysicsImpostor.MeshImpostor) {
                 this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
-                this._tmpPosition.copyFrom(object.position);
+                //this._tmpPosition.copyFrom(object.position);
             }
             impostor.setDeltaPosition(this._tmpDeltaPosition);
             //Now update the impostor object
@@ -66742,10 +66764,14 @@ var BABYLON;
             impostor.object.position.copyFrom(impostor.physicsBody.position);
             if (impostor.object.rotationQuaternion) {
                 impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
+                //impostor.object.rotationQuaternion.y *= -1;
+                //impostor.object.rotationQuaternion.z *= -1;
             }
         };
         CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
             impostor.physicsBody.position.copy(newPosition);
+            //newRotation.y *= -1;
+            //newRotation.z *= -1;
             impostor.physicsBody.quaternion.copy(newRotation);
         };
         CannonJSPlugin.prototype.isSupported = function () {

文件差异内容过多而无法显示
+ 6293 - 6289
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/gui/babylon.gui.min.js


文件差异内容过多而无法显示
+ 263 - 263
dist/preview release/inspector/babylon.inspector.bundle.js


文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/inspector/babylon.inspector.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/loaders/babylon.glTFFileLoader.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/loaders/babylonjs.loaders.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/materialsLibrary/babylon.customMaterial.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/materialsLibrary/babylon.waterMaterial.min.js


文件差异内容过多而无法显示
+ 4 - 4
dist/preview release/materialsLibrary/babylonjs.materials.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js


+ 4 - 0
src/Mesh/babylon.linesMesh.ts

@@ -68,6 +68,10 @@
             return this._colorShader;
         }
 
+        public set material(value: Material) {
+            // Do nothing
+        }
+
         public get checkCollisions(): boolean {
             return false;
         }