浏览代码

Merge remote-tracking branch 'refs/remotes/BabylonJS/master'

Arthur Gallouin 8 年之前
父节点
当前提交
808ce80da6

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


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

@@ -26,6 +26,7 @@
  - Text2D super sampling to enhance quality in World Space Canvas
  - World Space Canvas is now rendering in an adaptive way for its resolution to fit the on screen projected one to achieve a good rendering quality
  - Transparent Primitives are now drawn with Instanced Array when supported
+ - New property in Canvas2D (instances) that contains all instances of canvas2d [Temechon](https://github.com/Temechon)
 - WebVR Camera was updated to be conform with the current specs. ([RaananW](https://github.com/RaananW)) 
 
 ### Exporters

+ 16 - 5
src/Canvas2d/babylon.canvas2d.ts

@@ -53,6 +53,8 @@
          */
         public static CACHESTRATEGY_DONTCACHE = 4;
 
+        private static _INSTANCES : Array<Canvas2D> = [];
+
         constructor(scene: Scene, settings?: {
             id?: string,
             children?: Array<Prim2DBase>,
@@ -183,6 +185,9 @@
                         //this._supprtInstancedArray = false; // TODO REMOVE!!!
 
             this._setupInteraction(enableInteraction);
+
+            // Register this instance
+            Canvas2D._INSTANCES.push(this);
         }
 
         public get drawCallsOpaqueCounter(): PerfCounter {
@@ -233,6 +238,10 @@
             return this._boundingInfoRecomputeCounter;
         }
 
+        public static get instances() : Array<Canvas2D> {
+            return Canvas2D._INSTANCES;
+        }
+
         protected _canvasPreInit(settings: any) {
             let cachingStrategy = (settings.cachingStrategy == null) ? Canvas2D.CACHESTRATEGY_DONTCACHE : settings.cachingStrategy;
             this._cachingStrategy = cachingStrategy;
@@ -543,10 +552,6 @@
             this._previousOverPrimitive = this._actualOverPrimitive;
             this._actualOverPrimitive = ii.topMostIntersectedPrimitive;
 
-            if (this._previousOverPrimitive && this._actualOverPrimitive && this._previousOverPrimitive.prim !== this._actualOverPrimitive.prim) {
-                console.log("changed");
-            }
-
             this._intersectionRenderId = this.scene.getRenderId();
         }
 
@@ -817,7 +822,13 @@
             if (this._groupCacheMaps) {
                 this._groupCacheMaps.forEach((k, m) => m.forEach(e => e.dispose()));
                 this._groupCacheMaps = null;
-            }
+            }       
+
+            // Unregister this instance
+            let index = Canvas2D._INSTANCES.indexOf(this);
+            if (index > -1) {
+                Canvas2D._INSTANCES.splice(index, 1);
+            }  
         }
 
         /**

+ 3 - 3
src/Math/babylon.math.ts

@@ -2426,13 +2426,13 @@
                 return false;
             }
 
-            var rotationMatrix = Matrix.FromValues(
+            Matrix.FromValuesToRef(
                 this.m[0] / scale.x, this.m[1] / scale.x, this.m[2] / scale.x, 0,
                 this.m[4] / scale.y, this.m[5] / scale.y, this.m[6] / scale.y, 0,
                 this.m[8] / scale.z, this.m[9] / scale.z, this.m[10] / scale.z, 0,
-                0, 0, 0, 1);
+                0, 0, 0, 1, Tmp.Matrix[0]);
 
-            Quaternion.FromRotationMatrixToRef(rotationMatrix, rotation);
+            Quaternion.FromRotationMatrixToRef(Tmp.Matrix[0], rotation);
 
             return true;
         }

+ 14 - 15
src/Particles/babylon.solidParticleSystem.ts

@@ -106,6 +106,8 @@
         private _w: number = 0.0;
         private _minimum: Vector3 = Tmp.Vector3[0];
         private _maximum: Vector3 = Tmp.Vector3[1];
+        private _scale: Vector3 = Tmp.Vector3[2];
+        private _translation: Vector3 = Tmp.Vector3[3];
 
 
         /**
@@ -526,21 +528,18 @@
             // if the particles will always face the camera
             if (this.billboard) {
                 // compute the camera position and un-rotate it by the current mesh rotation
-                this._yaw = this.mesh.rotation.y;
-                this._pitch = this.mesh.rotation.x;
-                this._roll = this.mesh.rotation.z;
-                this._quaternionRotationYPR();
-                this._quaternionToRotationMatrix();
-                this._rotMatrix.invertToRef(this._invertMatrix);
-                this._camera._currentTarget.subtractToRef(this._camera.globalPosition, this._camDir);
-                Vector3.TransformCoordinatesToRef(this._camDir, this._invertMatrix, this._cam_axisZ);
-                this._cam_axisZ.normalize();
-
-                // set two orthogonal vectors (_cam_axisX and and _cam_axisY) to the rotated camDir axis (_cam_axisZ)
-                Vector3.CrossToRef(this._cam_axisZ, this._axisX, this._cam_axisY);
-                Vector3.CrossToRef(this._cam_axisY, this._cam_axisZ, this._cam_axisX);
-                this._cam_axisY.normalize();
-                this._cam_axisX.normalize();             
+                if (this.mesh._worldMatrix.decompose(this._scale, this._quaternion, this._translation)) {
+                    this._quaternionToRotationMatrix();
+                    this._rotMatrix.invertToRef(this._invertMatrix);
+                    this._camera._currentTarget.subtractToRef(this._camera.globalPosition, this._camDir);
+                    Vector3.TransformCoordinatesToRef(this._camDir, this._invertMatrix, this._cam_axisZ);
+                    this._cam_axisZ.normalize();
+                    // set two orthogonal vectors (_cam_axisX and and _cam_axisY) to the rotated camDir axis (_cam_axisZ)
+                    Vector3.CrossToRef(this._cam_axisZ, this._axisX, this._cam_axisY);
+                    Vector3.CrossToRef(this._cam_axisY, this._cam_axisZ, this._cam_axisX);
+                    this._cam_axisY.normalize();
+                    this._cam_axisX.normalize();
+                }             
             }
 
             Matrix.IdentityToRef(this._rotMatrix);