فهرست منبع

Merge pull request #5454 from TrevorDev/boundingBoxRotateThroughBox

Bounding box rotate through box
David Catuhe 6 سال پیش
والد
کامیت
c493e0938b

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

@@ -79,7 +79,7 @@
 - CreateScreenshotUsingRenderTarget stretches mirror textures when setting both width and height ([TrevorDev](https://github.com/TrevorDev))
 - VR helper only updating vr cameras position when entering vr, rotation was missing ([TrevorDev](https://github.com/TrevorDev))
 - Fix VR controllers after gltfLoader transformNode change ([TrevorDev](https://github.com/TrevorDev))
-- Bounding Box fixedDragMeshScreenSize stopped working ([TrevorDev](https://github.com/TrevorDev))
+- Bounding Box fixedDragMeshScreenSize stopped working and allow rotating through bounding box ([TrevorDev](https://github.com/TrevorDev))
 - VR helper would rotate non vr camera while in VR ([TrevorDev](https://github.com/TrevorDev))
 
 ### Core Engine

+ 1 - 1
src/Gizmos/babylon.boundingBoxGizmo.ts

@@ -176,7 +176,7 @@ module BABYLON {
                         var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
 
                         // project drag delta on to the resulting drag axis and rotate based on that
-                        var projectDist = -Vector3.Dot(dragAxis, event.delta);
+                        var projectDist = Vector3.Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
 
                         // Make rotation relative to size of mesh.
                         projectDist = (projectDist / this._boundingDimensions.length()) * this._anchorMesh.scaling.length();

+ 6 - 1
src/Rendering/babylon.utilityLayerRenderer.ts

@@ -7,6 +7,11 @@ module BABYLON {
         private _lastPointerEvents: { [pointerId: number]: boolean } = {};
         private static _DefaultUtilityLayer: Nullable<UtilityLayerRenderer> = null;
         private static _DefaultKeepDepthUtilityLayer: Nullable<UtilityLayerRenderer> = null;
+
+        /**
+         * If the picking should be done on the utility layer prior to the actual scene (Default: true)
+         */
+        public pickUtilitySceneFirst = true;
         /**
          * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
          */
@@ -113,7 +118,7 @@ module BABYLON {
                     return;
                 }
 
-                if (this.utilityLayerScene.autoClearDepthAndStencil) {
+                if (this.utilityLayerScene.autoClearDepthAndStencil || this.pickUtilitySceneFirst) {
                     // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
                     if (utilityScenePick && utilityScenePick.hit) {