Explorar o código

add docs and whats new

Trevor Baron %!s(int64=7) %!d(string=hai) anos
pai
achega
82437d5a88

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

@@ -21,6 +21,7 @@
 - UtilityLayer class to render another scene as a layer on top of an existing scene ([TrevorDev](https://github.com/TrevorDev))
 - AnimationGroup has now onAnimationGroupEnd observable ([RaananW](https://github.com/RaananW))
 - Pointer drag behavior to enable drag and drop with mouse or 6dof controller on a mesh ([TrevorDev](https://github.com/TrevorDev))
+- Gizmo class used to manipulate meshes in a scene, position gizmo ([TrevorDev](https://github.com/TrevorDev))
 
 ### glTF Loader
 

+ 1 - 1
gui/src/3D/gui3DManager.ts

@@ -71,7 +71,7 @@ module BABYLON.GUI {
             new BABYLON.HemisphericLight("hemi", Vector3.Up(), this._utilityLayer.utilityLayerScene);
         }
 
-        private _doPicking(type: number, pointerEvent: PointerEvent, ray?:Ray): boolean {
+        private _doPicking(type: number, pointerEvent: PointerEvent, ray?:Nullable<Ray>): boolean {
             if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
                 return false;                
             }

+ 36 - 2
src/Gizmos/babylon.gizmo.ts

@@ -3,10 +3,20 @@ module BABYLON {
      * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
      */
     export class Gizmo implements IDisposable {
+        /**
+         * The root mesh of the gizmo
+         */
         protected _rootMesh:Mesh;
+        /**
+         * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
+         */
         public attachedMesh:Nullable<Mesh>;
         private _beforeRenderObserver:Nullable<Observer<Scene>>;
-        constructor(public gizmoLayer:UtilityLayerRenderer){
+        /**
+         * Creates a gizmo
+         * @param gizmoLayer The utility layer the gizmo will be added to
+         */
+        constructor(/** The utility layer the gizmo will be added to */ public gizmoLayer:UtilityLayerRenderer){
             this._rootMesh = new BABYLON.Mesh("gizmoRootNode",gizmoLayer.utilityLayerScene);
             this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(()=>{
                 if(this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh){
@@ -18,6 +28,9 @@ module BABYLON {
                 }
             })
         }
+        /**
+         * Disposes of the gizmo
+         */
         public dispose(){
             this._rootMesh.dispose()
             if(this._beforeRenderObserver){
@@ -26,8 +39,17 @@ module BABYLON {
         }
     }
 
+    /**
+     * Single axis drag gizmo
+     */
     export class AxisDragGizmo extends Gizmo {
         private _dragBehavior:PointerDragBehavior;
+        /**
+         * Creates an AxisDragGizmo
+         * @param gizmoLayer The utility layer the gizmo will be added to
+         * @param dragAxis The axis which the gizmo will be able to drag on
+         * @param color The color of the gizmo
+         */
         constructor(gizmoLayer:UtilityLayerRenderer, dragAxis:Vector3, color:Color3){
             super(gizmoLayer);
 
@@ -62,12 +84,18 @@ module BABYLON {
                 }
             })
         }
+        /**
+         * Disposes of the gizmo
+         */
         public dispose(){
             this._dragBehavior.detach();
             super.dispose();
         } 
     }
 
+    /**
+     * Gizmo that enables dragging a mesh along 3 axis
+     */
     export class PositionGizmo extends Gizmo {
         private _xDrag:AxisDragGizmo;
         private _yDrag:AxisDragGizmo;
@@ -78,7 +106,10 @@ module BABYLON {
             this._yDrag.attachedMesh = mesh;
             this._zDrag.attachedMesh = mesh;
         }
-
+        /**
+         * Creates a PositionGizmo
+         * @param gizmoLayer The utility layer the gizmo will be added to
+         */
         constructor(gizmoLayer:UtilityLayerRenderer){
             super(gizmoLayer);
             this._xDrag = new AxisDragGizmo(gizmoLayer, new Vector3(1,0,0), BABYLON.Color3.FromHexString("#00b894"));
@@ -86,6 +117,9 @@ module BABYLON {
             this._zDrag = new AxisDragGizmo(gizmoLayer, new Vector3(0,0,1), BABYLON.Color3.FromHexString("#0984e3"));
         }
 
+        /**
+         * Disposes of the gizmo
+         */
         public dispose(){
             this._xDrag.dispose();
             this._yDrag.dispose();