Bläddra i källkod

first PR attempt

Patrick Ryan 6 år sedan
förälder
incheckning
d62e441934

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1655 - 1635
Playground/babylon.d.txt


+ 1 - 1
Tools/Gulp/gulpfile.js

@@ -848,7 +848,7 @@ gulp.task("deployLocalDev", function() {
 gulp.task("webserver", function() {
     var options = {
         root: "../../.",
-        port: 1338,
+        port: 8080,
         livereload: false,
         middleware: function() {
             return [cors()];

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1633 - 1633
dist/preview release/babylon.d.ts


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/babylon.js


+ 20 - 1
dist/preview release/babylon.max.js

@@ -100188,6 +100188,25 @@ var BABYLON;
             }
             var joint;
             switch (impostorJoint.joint.type) {
+                case BABYLON.PhysicsJoint.DistanceJoint:
+                    var distance = jointData.maxDistance;
+                    if (distance) {
+                        jointData.mainPivot = new BABYLON.Vector3(0, -distance / 2, 0);
+                        jointData.connectedPivot = new BABYLON.Vector3(0, distance / 2, 0);
+                    }
+                    joint = new Ammo.btPoint2PointConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z));
+                    break;
+                case BABYLON.PhysicsJoint.HingeJoint:
+                    if (!jointData.mainAxis) {
+                        jointData.mainAxis = new BABYLON.Vector3(0, 0, 0);
+                    }
+                    if (!jointData.connectedAxis) {
+                        jointData.connectedAxis = new BABYLON.Vector3(0, 0, 0);
+                    }
+                    var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
+                    var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
+                    joint = new Ammo.btHingeConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z), mainAxis, connectedAxis);
+                    break;
                 case BABYLON.PhysicsJoint.BallAndSocketJoint:
                     joint = new Ammo.btPoint2PointConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z));
                     break;
@@ -100510,7 +100529,7 @@ var BABYLON;
          * @param motorIndex index of the motor
          */
         AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
-            BABYLON.Tools.Warn("setMotor is not currently supported by the Ammo physics plugin");
+            joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
         };
         /**
          * Sets the motors limit

+ 20 - 1
dist/preview release/babylon.no-module.max.js

@@ -100155,6 +100155,25 @@ var BABYLON;
             }
             var joint;
             switch (impostorJoint.joint.type) {
+                case BABYLON.PhysicsJoint.DistanceJoint:
+                    var distance = jointData.maxDistance;
+                    if (distance) {
+                        jointData.mainPivot = new BABYLON.Vector3(0, -distance / 2, 0);
+                        jointData.connectedPivot = new BABYLON.Vector3(0, distance / 2, 0);
+                    }
+                    joint = new Ammo.btPoint2PointConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z));
+                    break;
+                case BABYLON.PhysicsJoint.HingeJoint:
+                    if (!jointData.mainAxis) {
+                        jointData.mainAxis = new BABYLON.Vector3(0, 0, 0);
+                    }
+                    if (!jointData.connectedAxis) {
+                        jointData.connectedAxis = new BABYLON.Vector3(0, 0, 0);
+                    }
+                    var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
+                    var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
+                    joint = new Ammo.btHingeConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z), mainAxis, connectedAxis);
+                    break;
                 case BABYLON.PhysicsJoint.BallAndSocketJoint:
                     joint = new Ammo.btPoint2PointConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z));
                     break;
@@ -100477,7 +100496,7 @@ var BABYLON;
          * @param motorIndex index of the motor
          */
         AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
-            BABYLON.Tools.Warn("setMotor is not currently supported by the Ammo physics plugin");
+            joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
         };
         /**
          * Sets the motors limit

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/babylon.worker.js


+ 20 - 1
dist/preview release/es6.js

@@ -100155,6 +100155,25 @@ var BABYLON;
             }
             var joint;
             switch (impostorJoint.joint.type) {
+                case BABYLON.PhysicsJoint.DistanceJoint:
+                    var distance = jointData.maxDistance;
+                    if (distance) {
+                        jointData.mainPivot = new BABYLON.Vector3(0, -distance / 2, 0);
+                        jointData.connectedPivot = new BABYLON.Vector3(0, distance / 2, 0);
+                    }
+                    joint = new Ammo.btPoint2PointConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z));
+                    break;
+                case BABYLON.PhysicsJoint.HingeJoint:
+                    if (!jointData.mainAxis) {
+                        jointData.mainAxis = new BABYLON.Vector3(0, 0, 0);
+                    }
+                    if (!jointData.connectedAxis) {
+                        jointData.connectedAxis = new BABYLON.Vector3(0, 0, 0);
+                    }
+                    var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
+                    var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
+                    joint = new Ammo.btHingeConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z), mainAxis, connectedAxis);
+                    break;
                 case BABYLON.PhysicsJoint.BallAndSocketJoint:
                     joint = new Ammo.btPoint2PointConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z));
                     break;
@@ -100477,7 +100496,7 @@ var BABYLON;
          * @param motorIndex index of the motor
          */
         AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
-            BABYLON.Tools.Warn("setMotor is not currently supported by the Ammo physics plugin");
+            joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
         };
         /**
          * Sets the motors limit

+ 8 - 5
dist/preview release/gui/babylon.gui.d.ts

@@ -1,7 +1,7 @@
 /*Babylon.js GUI*/
 // Dependencies for this module:
-//   ../../../../Tools/Gulp/babylonjs
-//   ../../../../Tools/Gulp/2D
+//   ../../../../tools/gulp/babylonjs
+//   ../../../../tools/gulp/2D
 declare module BABYLON.GUI {
 }
 declare module BABYLON.GUI {
@@ -775,16 +775,19 @@ declare module BABYLON.GUI {
             _onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
             _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
             /**
-                *
+                * This function expands the color picker by creating a color picker dialog with manual
+                * color value input and the ability to save colors into an array to be used later in
+                * subsequent launches of the dialogue.
                 * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
-                * @param options
+                * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
+                * @returns picked color as a hex string and the saved colors array as hex strings.
                 */
             static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
                     pickerWidth?: string;
                     pickerHeight?: string;
+                    headerHeight?: string;
                     lastColor?: string;
                     swatchLimit?: number;
-                    swatchSize?: number;
                     numSwatchesPerLine?: number;
                     savedColors?: Array<string>;
             }): Promise<{

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/gui/babylon.gui.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js.map


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 6152 - 6147
dist/preview release/gui/babylon.gui.module.d.ts


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/inspector/babylon.inspector.bundle.js.map


+ 1 - 1
dist/preview release/inspector/babylon.inspector.d.ts

@@ -1,6 +1,6 @@
 /*Babylon.js Inspector*/
 // Dependencies for this module:
-//   ../../../../Tools/Gulp/babylonjs
+//   ../../../../tools/gulp/babylonjs
 declare module INSPECTOR {
 }
 export declare class Inspector {

+ 2 - 2
dist/preview release/inspector/babylon.inspector.module.d.ts

@@ -1,6 +1,6 @@
 /*Babylon.js Inspector*/
 // Dependencies for this module:
-//   ../../../../Tools/Gulp/babylonjs
+//   ../../../../tools/gulp/babylonjs
 
 declare module 'babylonjs-inspector' {
     export * from "babylonjs-inspector/inspector";
@@ -29,7 +29,7 @@ declare module 'babylonjs-inspector/components/propertyChangedEvent' {
 
 /*Babylon.js Inspector*/
 // Dependencies for this module:
-//   ../../../../Tools/Gulp/babylonjs
+//   ../../../../tools/gulp/babylonjs
 declare module INSPECTOR {
 }
 export declare class Inspector {

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/loaders/babylon.glTFFileLoader.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/loaders/babylonjs.loaders.min.js


+ 2 - 2
dist/preview release/viewer/babylon.viewer.d.ts

@@ -4,8 +4,8 @@
 declare module "babylonjs-loaders"{ export=BABYLON;}
 // Generated by dts-bundle v0.7.3
 // Dependencies for this module:
-//   ../../../../../Tools/Gulp/babylonjs
-//   ../../../../../Tools/Gulp/babylonjs-loaders
+//   ../../../../../tools/gulp/babylonjs
+//   ../../../../../tools/gulp/babylonjs-loaders
 declare module BabylonViewer {
     /**
         * BabylonJS Viewer

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 3 - 3
dist/preview release/viewer/babylon.viewer.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 15 - 15
dist/preview release/viewer/babylon.viewer.max.js


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

@@ -5,8 +5,8 @@ declare module "babylonjs-loaders"{ export=BABYLON;}
 
 // Generated by dts-bundle v0.7.3
 // Dependencies for this module:
-//   ../../../../../Tools/Gulp/babylonjs
-//   ../../../../../Tools/Gulp/babylonjs-loaders
+//   ../../../../../tools/gulp/babylonjs
+//   ../../../../../tools/gulp/babylonjs-loaders
 
 declare module 'babylonjs-viewer' {
     import { mapperManager } from 'babylonjs-viewer/configuration/mappers';

+ 24 - 23
gui/src/2D/controls/colorpicker.ts

@@ -7,7 +7,6 @@ import { Button } from "./button";
 import { Grid } from "./grid";
 import { AdvancedDynamicTexture } from "../advancedDynamicTexture";
 import { TextBlock } from ".";
-import { parse } from "url";
 
 /** Class used to create color pickers */
 export class ColorPicker extends Control {
@@ -494,7 +493,9 @@ export class ColorPicker extends Control {
     }
 
     /**
-     *
+     * This function expands the color picker by creating a color picker dialog with manual
+     * color value input and the ability to save colors into an array to be used later in
+     * subsequent launches of the dialogue.
      * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
      * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
      * @returns picked color as a hex string and the saved colors array as hex strings.
@@ -518,7 +519,7 @@ export class ColorPicker extends Control {
             // Default options
             options.pickerWidth = options.pickerWidth || "640px";
             options.pickerHeight = options.pickerHeight || "400px";
-            options.headerHeight = options.headerHeight || "35px"
+            options.headerHeight = options.headerHeight || "35px";
             options.lastColor = options.lastColor || "#000000";
             options.swatchLimit = options.swatchLimit || 20;
             options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
@@ -530,7 +531,7 @@ export class ColorPicker extends Control {
             var colGutters: number = gutterSize * (options.numSwatchesPerLine + 1);
             var swatchSize: number = Math.floor((parseFloat(<string>options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
             var drawerMaxSize: number = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
-            var containerSize: string = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";  
+            var containerSize: string = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
 
             // Button Colors
             var buttonColor: string = "#c0c0c0";
@@ -685,10 +686,10 @@ export class ColorPicker extends Control {
                 if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
                     newValue = parseFloat(newValue).toString();
                     field.text = newValue;
-                }          
+                }
                 else {
                     newValue = "0.0";
-                }          
+                }
                 var newSwatchRGB = BABYLON.Color3.FromHexString(newSwatch.background);
                 if (activeField == field.name) {
                     if (channel == "r") {
@@ -784,7 +785,7 @@ export class ColorPicker extends Control {
                     }
                     if (butEdit !== undefined) {
                         butEdit.textBlock!.text = "Done";
-                    }    
+                    }
                 }
                 else {
                     for (var i = 0; i < swatchDrawer.children.length; i++) {
@@ -821,7 +822,7 @@ export class ColorPicker extends Control {
                     if (swatchDrawer.rowCount != rowCount + gutterCount) {
                         var currentRows: number = swatchDrawer.rowCount;
                         for (var i = 0; i < currentRows; i++) {
-                            swatchDrawer.removeRowDefinition(0);                           
+                            swatchDrawer.removeRowDefinition(0);
                         }
                         for (var i = 0; i < rowCount + gutterCount; i++) {
                             if (i % 2) {
@@ -912,18 +913,18 @@ export class ColorPicker extends Control {
 
             // Called when the user hits the limit of saved colors in the drawer.
             function disableButton(button: Button, disabled: boolean) {
-                if(disabled) {
+                if (disabled) {
                     button.color = buttonDisabledColor;
-                    button.background = buttonDisabledBackgroundColor;    
+                    button.background = buttonDisabledBackgroundColor;
                 }
-                else {        
+                else {
                     button.color = buttonColor;
-                    button.background = buttonBackgroundColor;    
+                    button.background = buttonBackgroundColor;
                 }
-            }            
+            }
 
             // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
-            function closePicker (color: string) {
+            function closePicker(color: string) {
                 if (options.savedColors && options.savedColors.length > 0) {
                     resolve({
                         savedColors: options.savedColors,
@@ -985,7 +986,7 @@ export class ColorPicker extends Control {
                     else {
                         swatchDrawer.addColumnDefinition(gutterSize, true);
                     }
-                }    
+                }
                 dialogContainer.addControl(swatchDrawer, 1, 0);
             }
 
@@ -994,7 +995,7 @@ export class ColorPicker extends Control {
             pickerPanel.name = "Picker Panel";
             pickerPanel.height = options.pickerHeight;
             var panelHead: number = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
-            var pickerPanelRows: number[] = [panelHead, 1.0 - panelHead]
+            var pickerPanelRows: number[] = [panelHead, 1.0 - panelHead];
             pickerPanel.addRowDefinition(pickerPanelRows[0], false);
             pickerPanel.addRowDefinition(pickerPanelRows[1], false);
             dialogContainer.addControl(pickerPanel, 0, 0);
@@ -1089,7 +1090,7 @@ export class ColorPicker extends Control {
             // Picker container swatches and buttons
             var pickerSwatchesButtons: Grid = new Grid();
             pickerSwatchesButtons.name = "Swatches and Buttons";
-            var pickerButtonsCol: number[] = [0.417, 0.583] 
+            var pickerButtonsCol: number[] = [0.417, 0.583];
             pickerSwatchesButtons.addRowDefinition(1.0, false);
             pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
             pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
@@ -1111,10 +1112,10 @@ export class ColorPicker extends Control {
             activeSwatches.width = 0.67;
             activeSwatches.addRowDefinition(0.5, false);
             activeSwatches.addRowDefinition(0.5, false);
-            pickerSwatches.addControl(activeSwatches, 2, 0)
+            pickerSwatches.addControl(activeSwatches, 2, 0);
 
             var labelWidth: number = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
-            var labelHeight: number = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));   
+            var labelHeight: number = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
 
             if (options.pickerWidth > options.pickerHeight) {
                 var labelTextSize: number = labelHeight;
@@ -1177,14 +1178,14 @@ export class ColorPicker extends Control {
 
             // Determine pixel width and height for all buttons from overall panel dimensions
             buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
-            buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";   
- 
+            buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
+
             // Determine button type size
             if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
                 buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
             }
             else {
-                buttonFontSize= Math.floor(parseFloat(buttonWidth) * 0.11);
+                buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
             }
 
             // Panel Buttons
@@ -1282,7 +1283,7 @@ export class ColorPicker extends Control {
                         if (options.savedColors.length < options.swatchLimit!) {
                             updateSwatches(newSwatch.background, butSave);
                         }
-                        editSwatches(false);                        
+                        editSwatches(false);
                     }
                 });
                 if (options.savedColors.length > 0) {