sebavan 6 lat temu
rodzic
commit
bd8e94d5ff

Plik diff jest za duży
+ 9987 - 9983
Playground/babylon.d.txt


Plik diff jest za duży
+ 9993 - 9989
dist/preview release/babylon.d.ts


Plik diff jest za duży
+ 1 - 1
dist/preview release/babylon.js


+ 23 - 17
dist/preview release/babylon.max.js

@@ -103657,6 +103657,10 @@ var BABYLON;
              */
              */
             this.zDragFactor = 3;
             this.zDragFactor = 3;
             /**
             /**
+             * If the object should rotate to face the drag origin
+             */
+            this.rotateDraggedObject = true;
+            /**
              * If the behavior is currently in a dragging state
              * If the behavior is currently in a dragging state
              */
              */
             this.dragging = false;
             this.dragging = false;
@@ -103723,7 +103727,7 @@ var BABYLON;
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
-                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.position);
+                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
                         }
                         }
                         pickedMesh = _this._ownerNode;
                         pickedMesh = _this._ownerNode;
                         BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
                         BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
@@ -103779,7 +103783,7 @@ var BABYLON;
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
                         var zDragFactor = _this.zDragFactor;
                         var zDragFactor = _this.zDragFactor;
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
-                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.position);
+                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
                             zDragFactor = 0;
                             zDragFactor = 0;
                         }
                         }
                         // Calculate controller drag distance in controller space
                         // Calculate controller drag distance in controller space
@@ -103815,21 +103819,23 @@ var BABYLON;
                     BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
                     BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
                     // Slowly move mesh to avoid jitter
                     // Slowly move mesh to avoid jitter
                     pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
                     pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
-                    // Get change in rotation
-                    tmpQuaternion.copyFrom(_this._startingOrientation);
-                    tmpQuaternion.x = -tmpQuaternion.x;
-                    tmpQuaternion.y = -tmpQuaternion.y;
-                    tmpQuaternion.z = -tmpQuaternion.z;
-                    _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
-                    // Convert change in rotation to only y axis rotation
-                    BABYLON.Quaternion.RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
-                    tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
-                    // Slowly move mesh to avoid jitter
-                    var oldParent = pickedMesh.parent;
-                    pickedMesh.setParent(null);
-                    BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
-                    pickedMesh.setParent(oldParent);
-                    BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
+                    if (_this.rotateDraggedObject) {
+                        // Get change in rotation
+                        tmpQuaternion.copyFrom(_this._startingOrientation);
+                        tmpQuaternion.x = -tmpQuaternion.x;
+                        tmpQuaternion.y = -tmpQuaternion.y;
+                        tmpQuaternion.z = -tmpQuaternion.z;
+                        _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
+                        // Convert change in rotation to only y axis rotation
+                        BABYLON.Quaternion.RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
+                        tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
+                        // Slowly move mesh to avoid jitter
+                        var oldParent = pickedMesh.parent;
+                        pickedMesh.setParent(null);
+                        BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
+                        pickedMesh.setParent(oldParent);
+                        BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
+                    }
                 }
                 }
             });
             });
         };
         };

+ 23 - 17
dist/preview release/babylon.no-module.max.js

@@ -103624,6 +103624,10 @@ var BABYLON;
              */
              */
             this.zDragFactor = 3;
             this.zDragFactor = 3;
             /**
             /**
+             * If the object should rotate to face the drag origin
+             */
+            this.rotateDraggedObject = true;
+            /**
              * If the behavior is currently in a dragging state
              * If the behavior is currently in a dragging state
              */
              */
             this.dragging = false;
             this.dragging = false;
@@ -103690,7 +103694,7 @@ var BABYLON;
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
-                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.position);
+                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
                         }
                         }
                         pickedMesh = _this._ownerNode;
                         pickedMesh = _this._ownerNode;
                         BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
                         BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
@@ -103746,7 +103750,7 @@ var BABYLON;
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
                         var zDragFactor = _this.zDragFactor;
                         var zDragFactor = _this.zDragFactor;
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
-                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.position);
+                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
                             zDragFactor = 0;
                             zDragFactor = 0;
                         }
                         }
                         // Calculate controller drag distance in controller space
                         // Calculate controller drag distance in controller space
@@ -103782,21 +103786,23 @@ var BABYLON;
                     BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
                     BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
                     // Slowly move mesh to avoid jitter
                     // Slowly move mesh to avoid jitter
                     pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
                     pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
-                    // Get change in rotation
-                    tmpQuaternion.copyFrom(_this._startingOrientation);
-                    tmpQuaternion.x = -tmpQuaternion.x;
-                    tmpQuaternion.y = -tmpQuaternion.y;
-                    tmpQuaternion.z = -tmpQuaternion.z;
-                    _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
-                    // Convert change in rotation to only y axis rotation
-                    BABYLON.Quaternion.RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
-                    tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
-                    // Slowly move mesh to avoid jitter
-                    var oldParent = pickedMesh.parent;
-                    pickedMesh.setParent(null);
-                    BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
-                    pickedMesh.setParent(oldParent);
-                    BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
+                    if (_this.rotateDraggedObject) {
+                        // Get change in rotation
+                        tmpQuaternion.copyFrom(_this._startingOrientation);
+                        tmpQuaternion.x = -tmpQuaternion.x;
+                        tmpQuaternion.y = -tmpQuaternion.y;
+                        tmpQuaternion.z = -tmpQuaternion.z;
+                        _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
+                        // Convert change in rotation to only y axis rotation
+                        BABYLON.Quaternion.RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
+                        tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
+                        // Slowly move mesh to avoid jitter
+                        var oldParent = pickedMesh.parent;
+                        pickedMesh.setParent(null);
+                        BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
+                        pickedMesh.setParent(oldParent);
+                        BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
+                    }
                 }
                 }
             });
             });
         };
         };

Plik diff jest za duży
+ 1 - 1
dist/preview release/babylon.worker.js


+ 23 - 17
dist/preview release/es6.js

@@ -103624,6 +103624,10 @@ var BABYLON;
              */
              */
             this.zDragFactor = 3;
             this.zDragFactor = 3;
             /**
             /**
+             * If the object should rotate to face the drag origin
+             */
+            this.rotateDraggedObject = true;
+            /**
              * If the behavior is currently in a dragging state
              * If the behavior is currently in a dragging state
              */
              */
             this.dragging = false;
             this.dragging = false;
@@ -103690,7 +103694,7 @@ var BABYLON;
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                 if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
                     if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
-                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.position);
+                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
                         }
                         }
                         pickedMesh = _this._ownerNode;
                         pickedMesh = _this._ownerNode;
                         BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
                         BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
@@ -103746,7 +103750,7 @@ var BABYLON;
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
                     if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
                         var zDragFactor = _this.zDragFactor;
                         var zDragFactor = _this.zDragFactor;
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
                         if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
-                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.position);
+                            pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
                             zDragFactor = 0;
                             zDragFactor = 0;
                         }
                         }
                         // Calculate controller drag distance in controller space
                         // Calculate controller drag distance in controller space
@@ -103782,21 +103786,23 @@ var BABYLON;
                     BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
                     BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
                     // Slowly move mesh to avoid jitter
                     // Slowly move mesh to avoid jitter
                     pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
                     pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
-                    // Get change in rotation
-                    tmpQuaternion.copyFrom(_this._startingOrientation);
-                    tmpQuaternion.x = -tmpQuaternion.x;
-                    tmpQuaternion.y = -tmpQuaternion.y;
-                    tmpQuaternion.z = -tmpQuaternion.z;
-                    _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
-                    // Convert change in rotation to only y axis rotation
-                    BABYLON.Quaternion.RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
-                    tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
-                    // Slowly move mesh to avoid jitter
-                    var oldParent = pickedMesh.parent;
-                    pickedMesh.setParent(null);
-                    BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
-                    pickedMesh.setParent(oldParent);
-                    BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
+                    if (_this.rotateDraggedObject) {
+                        // Get change in rotation
+                        tmpQuaternion.copyFrom(_this._startingOrientation);
+                        tmpQuaternion.x = -tmpQuaternion.x;
+                        tmpQuaternion.y = -tmpQuaternion.y;
+                        tmpQuaternion.z = -tmpQuaternion.z;
+                        _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
+                        // Convert change in rotation to only y axis rotation
+                        BABYLON.Quaternion.RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
+                        tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
+                        // Slowly move mesh to avoid jitter
+                        var oldParent = pickedMesh.parent;
+                        pickedMesh.setParent(null);
+                        BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
+                        pickedMesh.setParent(oldParent);
+                        BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
+                    }
                 }
                 }
             });
             });
         };
         };

+ 15 - 1
dist/preview release/viewer/babylon.viewer.d.ts

@@ -924,7 +924,7 @@ declare module BabylonViewer {
       * @param name the name of the custom optimizer configuration
       * @param name the name of the custom optimizer configuration
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       */
       */
-    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 }
 declare module BabylonViewer {
 declare module BabylonViewer {
@@ -1558,6 +1558,20 @@ declare module BabylonViewer {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 }
 declare module BabylonViewer {
 declare module BabylonViewer {
+    /**
+        * A custom upgrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedUpgrade(sceneManager: SceneManager): boolean;
+    /**
+        * A custom degrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedDegrade(sceneManager: SceneManager): boolean;
+}
+declare module BabylonViewer {
 }
 }
 declare module BabylonViewer {
 declare module BabylonViewer {
     export interface IEnvironmentMapConfiguration {
     export interface IEnvironmentMapConfiguration {

Plik diff jest za duży
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


Plik diff jest za duży
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 18 - 1
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -985,13 +985,14 @@ declare module 'babylonjs-viewer/templating/viewerTemplatePlugin' {
 }
 }
 
 
 declare module 'babylonjs-viewer/optimizer/custom' {
 declare module 'babylonjs-viewer/optimizer/custom' {
+    import { extendedUpgrade } from "babylonjs-viewer/optimizer/custom/extended";
     import { SceneManager } from "babylonjs-viewer/managers/sceneManager";
     import { SceneManager } from "babylonjs-viewer/managers/sceneManager";
     /**
     /**
       *
       *
       * @param name the name of the custom optimizer configuration
       * @param name the name of the custom optimizer configuration
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       */
       */
-    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 }
 
 
@@ -1662,6 +1663,22 @@ declare module 'babylonjs-viewer/loader/plugins' {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 }
 
 
+declare module 'babylonjs-viewer/optimizer/custom/extended' {
+    import { SceneManager } from 'babylonjs-viewer/managers/sceneManager';
+    /**
+        * A custom upgrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedUpgrade(sceneManager: SceneManager): boolean;
+    /**
+        * A custom degrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedDegrade(sceneManager: SceneManager): boolean;
+}
+
 declare module 'babylonjs-viewer/configuration/interfaces' {
 declare module 'babylonjs-viewer/configuration/interfaces' {
     export * from 'babylonjs-viewer/configuration/interfaces/cameraConfiguration';
     export * from 'babylonjs-viewer/configuration/interfaces/cameraConfiguration';
     export * from 'babylonjs-viewer/configuration/interfaces/colorGradingConfiguration';
     export * from 'babylonjs-viewer/configuration/interfaces/colorGradingConfiguration';