Jelajahi Sumber

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

Conflicts:
	Babylon/Mesh/babylon.mesh.vertexData.js
	Babylon/Mesh/babylon.mesh.vertexData.ts
	babylon.2.1-alpha.debug.js
	babylon.2.1-alpha.js
David Catuhe 10 tahun lalu
induk
melakukan
65d53ca3be

+ 89 - 0
Babylon/Math/babylon.math.ts

@@ -3005,4 +3005,93 @@
             return new Path2(x, y);
         }
     }
+
+    export class Path3D {
+        private _curve: Vector3[] = [];
+        private _distances: number[] = [];
+        private _tangents: Vector3[] = [];
+        private _normals: Vector3[] = [];
+        private _binormals: Vector3[] = [];
+
+        constructor(public path: Vector3[]) {
+            this._curve = path.slice();   // copy array         
+            var l: number = this._curve.length;
+            // first and last tangents
+            this._tangents[0] = this._curve[1].subtract(this._curve[0]);
+            this._tangents[0].normalize();
+            this._tangents[l-1] = this._curve[l-1].subtract(this._curve[l-2]);
+            this._tangents[l-1].normalize();
+            // normals and binormals at first point : arbitrary vector with _normalVector()
+            var tg0: Vector3 = this._tangents[0];
+            var pp0: Vector3 = this._normalVector(this._curve[0], tg0);
+            this._normals[0] = pp0;
+            this._normals[0].normalize();
+            this._binormals[0] = BABYLON.Vector3.Cross(tg0, this._normals[0]);
+            this._normals[0].normalize();
+            this._distances[0] = 0;
+            // normals and binormals : next points
+            var prev: Vector3;        // previous vector (segment)
+            var cur: Vector3;         // current vector (segment)
+            var curTang: Vector3;     // current tangent
+            var prevNorm: Vector3;    // previous normal
+            var prevBinor: Vector3;   // previous binormal
+            for(var i: number = 1; i < l; i++) {
+                // tangents
+                prev = this._curve[i].subtract(this._curve[i-1]);
+                if (i < l-1) {
+                    cur = this._curve[i+1].subtract(this._curve[i]);
+                    this._tangents[i] = prev.add(cur);
+                    this._tangents[i].normalize();               
+                }
+                this._distances[i] = this._distances[i-1] + prev.length();         
+                // normals and binormals
+                // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
+                curTang = this._tangents[i];
+                prevNorm = this._normals[i-1];
+                prevBinor = this._binormals[i-1];
+                this._normals[i] = BABYLON.Vector3.Cross(prevBinor, curTang);
+                this._normals[i].normalize();
+                this._binormals[i] = BABYLON.Vector3.Cross(curTang, this._normals[i]);
+                this._binormals[i].normalize();
+            }
+        }
+
+        public getCurve(): Vector3[] {
+            return this._curve;
+        }
+
+        public getTangents(): Vector3[] {
+            return this._tangents;
+        }
+
+        public getNormals(): Vector3[] {
+            return this._normals;
+        }
+
+        public getBinormals(): Vector3[] {
+            return this._binormals;
+        }
+
+        public getDistances(): number[] {
+            return this._distances;
+        }
+
+        // private function normalVector(v0, vt) :
+        // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
+        private _normalVector(v0: Vector3, vt: Vector3): Vector3 {
+            var point: Vector3; 
+            if (vt.x != 1) {     // search for a point in the plane
+                point = new BABYLON.Vector3(1, 0, 0);   
+            }
+            else if (vt.y != 1) {
+                point = new BABYLON.Vector3(0, 1, 0);  
+            }
+            else if (vt.z != 1) {
+                point = new BABYLON.Vector3(0, 0, 1);  
+            }
+            var normal0: Vector3 = BABYLON.Vector3.Cross(vt, point);
+            normal0.normalize();
+            return normal0;        
+        }
+    }
 }

+ 27 - 0
Babylon/Mesh/babylon.geometry.ts

@@ -500,6 +500,33 @@
             }
         }
 
+        export class Ribbon extends _Primitive {
+            // Members
+            public pathArray: Vector3[][];
+            public closeArray: boolean;
+            public closePath: boolean;
+            public offset: number;
+            public side: number;
+
+            constructor(id: string, scene: Scene, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, canBeRegenerated?: boolean, mesh?: Mesh, side: number = Mesh.DEFAULTSIDE) {
+                this.pathArray = pathArray;
+                this.closeArray = closeArray;
+                this.closePath = closePath;
+                this.offset = offset;
+                this.side = side;
+
+                super(id, scene, this._regenerateVertexData(), canBeRegenerated, mesh);
+            }
+
+            public _regenerateVertexData(): VertexData {
+                return VertexData.CreateRibbon(this.pathArray, this.closeArray, this.closePath, this.offset, this.side);
+            }
+
+            public copy(id: string): Geometry {
+                return new Ribbon(id, this.getScene(), this.pathArray, this.closeArray, this.closePath, this.offset, this.canBeRegenerated(), null, this.side);
+            }
+        }
+
         export class Box extends _Primitive {
             // Members
             public size: number;

+ 5 - 5
Babylon/Mesh/babylon.mesh.js

@@ -251,7 +251,7 @@ var BABYLON;
         // Methods  
         Mesh.prototype._preActivate = function () {
             var sceneRenderId = this.getScene().getRenderId();
-            if (this._preActivateId == sceneRenderId) {
+            if (this._preActivateId === sceneRenderId) {
                 return;
             }
             this._preActivateId = sceneRenderId;
@@ -527,7 +527,7 @@ var BABYLON;
                 return;
             }
             for (var callbackIndex = 0; callbackIndex < this._onBeforeRenderCallbacks.length; callbackIndex++) {
-                this._onBeforeRenderCallbacks[callbackIndex]();
+                this._onBeforeRenderCallbacks[callbackIndex](this);
             }
             var engine = scene.getEngine();
             var hardwareInstancedRendering = (engine.getCaps().instancedArrays !== null) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
@@ -573,7 +573,7 @@ var BABYLON;
                 engine.setAlphaMode(currentMode);
             }
             for (callbackIndex = 0; callbackIndex < this._onAfterRenderCallbacks.length; callbackIndex++) {
-                this._onAfterRenderCallbacks[callbackIndex]();
+                this._onAfterRenderCallbacks[callbackIndex](this);
             }
         };
         Mesh.prototype.getEmittedParticleSystems = function () {
@@ -618,7 +618,7 @@ var BABYLON;
             else if (that.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {
                 that.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_LOADING;
                 scene._addPendingData(that);
-                var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1) ? true : false;
+                var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
                 BABYLON.Tools.LoadFile(this.delayLoadingFile, function (data) {
                     if (data instanceof ArrayBuffer) {
                         _this._delayLoadingFunction(data, _this);
@@ -1015,7 +1015,7 @@ var BABYLON;
                 canvas.height = heightMapHeight;
                 context.drawImage(img, 0, 0);
                 // Create VertexData from map data
-                //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949 
+                // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949 
                 var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
                 var vertexData = BABYLON.VertexData.CreateGroundFromHeightMap(width, height, subdivisions, minHeight, maxHeight, buffer, heightMapWidth, heightMapHeight);
                 vertexData.applyToMesh(ground, updatable);

+ 42 - 11
Babylon/Mesh/babylon.mesh.ts

@@ -38,8 +38,8 @@
 
         // Private
         public _geometry: Geometry;
-        private _onBeforeRenderCallbacks = new Array<() => void>();
-        private _onAfterRenderCallbacks = new Array<() => void>();
+        private _onBeforeRenderCallbacks = new Array<(mesh: AbstractMesh) => void>();
+        private _onAfterRenderCallbacks = new Array<(mesh: AbstractMesh) => void>();
         public _delayInfo; //ANY
         public _delayLoadingFunction: (any, Mesh) => void;
         public _visibleInstances: any = {};
@@ -276,7 +276,7 @@
         // Methods  
         public _preActivate(): void {
             var sceneRenderId = this.getScene().getRenderId();
-            if (this._preActivateId == sceneRenderId) {
+            if (this._preActivateId === sceneRenderId) {
                 return;
             }
 
@@ -467,11 +467,11 @@
             }
         }
 
-        public registerBeforeRender(func: () => void): void {
+        public registerBeforeRender(func: (mesh: AbstractMesh) => void): void {
             this._onBeforeRenderCallbacks.push(func);
         }
 
-        public unregisterBeforeRender(func: () => void): void {
+        public unregisterBeforeRender(func: (mesh: AbstractMesh) => void): void {
             var index = this._onBeforeRenderCallbacks.indexOf(func);
 
             if (index > -1) {
@@ -627,7 +627,7 @@
             }
 
             for (var callbackIndex = 0; callbackIndex < this._onBeforeRenderCallbacks.length; callbackIndex++) {
-                this._onBeforeRenderCallbacks[callbackIndex]();
+                this._onBeforeRenderCallbacks[callbackIndex](this);
             }
 
             var engine = scene.getEngine();
@@ -687,7 +687,7 @@
             }
 
             for (callbackIndex = 0; callbackIndex < this._onAfterRenderCallbacks.length; callbackIndex++) {
-                this._onAfterRenderCallbacks[callbackIndex]();
+                this._onAfterRenderCallbacks[callbackIndex](this);
             }
         }
 
@@ -742,7 +742,7 @@
 
                 scene._addPendingData(that);
 
-                var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1) ? true : false;
+                var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
 
                 Tools.LoadFile(this.delayLoadingFile, data => {
 
@@ -1246,7 +1246,7 @@
                 context.drawImage(img, 0, 0);
 
                 // Create VertexData from map data
-                //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949 
+                // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949 
                 var buffer = <Uint8Array> (<any>context.getImageData(0, 0, heightMapWidth, heightMapHeight).data);
                 var vertexData = VertexData.CreateGroundFromHeightMap(width, height, subdivisions, minHeight, maxHeight, buffer, heightMapWidth, heightMapHeight);
 
@@ -1265,10 +1265,41 @@
             return ground;
         }
 
+        public static CreateTube(name: string, path: Vector3[], radius: number, tesselation: number, radiusFunction: { (i: number, distance: number): number; }, scene: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE): Mesh {
+            var tube: Mesh;
+            var path3D: Path3D = new BABYLON.Path3D(path);
+            var tangents: Vector3[] = path3D.getTangents();
+            var normals: Vector3[] = path3D.getNormals();
+            var distances: number[] = path3D.getDistances();
+            var pi2: number = Math.PI * 2;
+            var step: number = pi2 / tesselation;
+            var returnRadius: { (i: number, distance: number): number; } = function(i, distance) { return radius };
+            var radiusFunction: { (i: number, distance: number): number; } = radiusFunction || returnRadius; 
+            var circlePaths: Vector3[][] = [];
+            var circlePath: Vector3[];
+            var rad: number;
+            var normal: Vector3;
+            var rotated: Vector3;
+            var rotationMatrix: Matrix;
+            for (var i: number = 0; i < path.length; i++) {
+                rad = radiusFunction(i, distances[i]);      // current radius
+                circlePath = [];                            // current circle array
+                normal =  normals[i]                        // current normal  
+                for( var ang: number = 0; ang < pi2; ang += step) {
+                    rotationMatrix = BABYLON.Matrix.RotationAxis(tangents[i], ang);
+                    rotated = BABYLON.Vector3.TransformCoordinates(normal, rotationMatrix).scaleInPlace(rad).add(path[i]);
+                    circlePath.push(rotated);
+                }
+                circlePaths.push(circlePath);
+            }
+            tube = BABYLON.Mesh.CreateRibbon(name, circlePaths, false, true, 0, scene, updatable, sideOrientation);
+            return tube;
+        }
+
         // Tools
         public static MinMax(meshes: AbstractMesh[]): { min: Vector3; max: Vector3 } {
-            var minVector = null;
-            var maxVector = null;
+            var minVector: Vector3 = null;
+            var maxVector: Vector3 = null;
             for (var i in meshes) {
                 var mesh = meshes[i];
                 var boundingBox = mesh.getBoundingInfo().boundingBox;

+ 8 - 8
Babylon/Mesh/babylon.mesh.vertexData.js

@@ -352,7 +352,7 @@ var BABYLON;
             // normals
             VertexData.ComputeNormals(positions, indices, normals);
             // sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -408,7 +408,7 @@ var BABYLON;
                 uvs.push(1.0, 0.0);
             }
             // sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -457,7 +457,7 @@ var BABYLON;
                 }
             }
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -554,7 +554,7 @@ var BABYLON;
             // Normals
             VertexData.ComputeNormals(positions, indices, normals);
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -603,7 +603,7 @@ var BABYLON;
                 }
             }
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -800,7 +800,7 @@ var BABYLON;
             indices.push(2);
             indices.push(3);
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -874,7 +874,7 @@ var BABYLON;
             // Normals
             VertexData.ComputeNormals(positions, indices, normals);
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -921,7 +921,7 @@ var BABYLON;
                 normals[index * 3 + 2] = normal.z;
             }
         };
-        VertexData.ComputeSides = function (sideOrientation, positions, indices, normals, uvs) {
+        VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs) {
             var li = indices.length;
             var ln = normals.length;
             var i;

+ 9 - 10
Babylon/Mesh/babylon.mesh.vertexData.ts

@@ -431,7 +431,7 @@
             VertexData.ComputeNormals(positions, indices, normals);
 
             // sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
 
             // Result
             var vertexData = new VertexData();
@@ -502,7 +502,7 @@
             }
 
             // sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
 
             // Result
             var vertexData = new VertexData();
@@ -567,7 +567,7 @@
             }
 
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
 
             // Result
             var vertexData = new VertexData();
@@ -691,7 +691,7 @@
             VertexData.ComputeNormals(positions, indices, normals);
 
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
 
             // Result
             var vertexData = new VertexData();
@@ -757,7 +757,7 @@
             }
 
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
 
             // Result
             var vertexData = new VertexData();
@@ -1010,7 +1010,7 @@
             indices.push(3);
 
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
 
             // Result
             var vertexData = new VertexData();
@@ -1099,7 +1099,7 @@
             VertexData.ComputeNormals(positions, indices, normals);
 
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
 
             // Result
             var vertexData = new VertexData();
@@ -1159,7 +1159,7 @@
             }
         }
 
-        public static ComputeSides(sideOrientation: number, positions: number[], indices: number[], normals: number[], uvs: number[]) {
+        private static _ComputeSides(sideOrientation: number, positions: number[], indices: number[], normals: number[], uvs: number[]) {
             var li: number = indices.length;
             var ln: number = normals.length;
             var i: number;
@@ -1174,7 +1174,6 @@
 
                 case Mesh.BACKSIDE:
                     var tmp: number;
-                    // positions unchanged
                     // indices
                     for (i = 0; i < li; i += 3) {
                         tmp = indices[i];
@@ -1185,7 +1184,6 @@
                     for (n = 0; n < ln; n++) {
                         normals[n] = -normals[n];
                     }
-                    // uvs unchanged                    
                     break;
 
                 case Mesh.DOUBLESIDE:
@@ -1205,6 +1203,7 @@
                     for (n = 0; n < ln; n++) {
                         normals[ln + n] = -normals[n];
                     }
+
                     // uvs
                     var lu: number = uvs.length;
                     for (var u: number = 0; u < lu; u++) {

+ 13 - 13
babylon.2.1-alpha.debug.js

@@ -10247,7 +10247,7 @@ var BABYLON;
         // Methods  
         Mesh.prototype._preActivate = function () {
             var sceneRenderId = this.getScene().getRenderId();
-            if (this._preActivateId == sceneRenderId) {
+            if (this._preActivateId === sceneRenderId) {
                 return;
             }
             this._preActivateId = sceneRenderId;
@@ -10523,7 +10523,7 @@ var BABYLON;
                 return;
             }
             for (var callbackIndex = 0; callbackIndex < this._onBeforeRenderCallbacks.length; callbackIndex++) {
-                this._onBeforeRenderCallbacks[callbackIndex]();
+                this._onBeforeRenderCallbacks[callbackIndex](this);
             }
             var engine = scene.getEngine();
             var hardwareInstancedRendering = (engine.getCaps().instancedArrays !== null) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
@@ -10569,7 +10569,7 @@ var BABYLON;
                 engine.setAlphaMode(currentMode);
             }
             for (callbackIndex = 0; callbackIndex < this._onAfterRenderCallbacks.length; callbackIndex++) {
-                this._onAfterRenderCallbacks[callbackIndex]();
+                this._onAfterRenderCallbacks[callbackIndex](this);
             }
         };
         Mesh.prototype.getEmittedParticleSystems = function () {
@@ -10614,7 +10614,7 @@ var BABYLON;
             else if (that.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {
                 that.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_LOADING;
                 scene._addPendingData(that);
-                var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1) ? true : false;
+                var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
                 BABYLON.Tools.LoadFile(this.delayLoadingFile, function (data) {
                     if (data instanceof ArrayBuffer) {
                         _this._delayLoadingFunction(data, _this);
@@ -11011,7 +11011,7 @@ var BABYLON;
                 canvas.height = heightMapHeight;
                 context.drawImage(img, 0, 0);
                 // Create VertexData from map data
-                //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949 
+                // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949 
                 var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
                 var vertexData = BABYLON.VertexData.CreateGroundFromHeightMap(width, height, subdivisions, minHeight, maxHeight, buffer, heightMapWidth, heightMapHeight);
                 vertexData.applyToMesh(ground, updatable);
@@ -21151,7 +21151,7 @@ var BABYLON;
             // normals
             VertexData.ComputeNormals(positions, indices, normals);
             // sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -21207,7 +21207,7 @@ var BABYLON;
                 uvs.push(1.0, 0.0);
             }
             // sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -21256,7 +21256,7 @@ var BABYLON;
                 }
             }
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -21353,7 +21353,7 @@ var BABYLON;
             // Normals
             VertexData.ComputeNormals(positions, indices, normals);
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -21402,7 +21402,7 @@ var BABYLON;
                 }
             }
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -21599,7 +21599,7 @@ var BABYLON;
             indices.push(2);
             indices.push(3);
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -21673,7 +21673,7 @@ var BABYLON;
             // Normals
             VertexData.ComputeNormals(positions, indices, normals);
             // Sides
-            VertexData.ComputeSides(sideOrientation, positions, indices, normals, uvs);
+            VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -21720,7 +21720,7 @@ var BABYLON;
                 normals[index * 3 + 2] = normal.z;
             }
         };
-        VertexData.ComputeSides = function (sideOrientation, positions, indices, normals, uvs) {
+        VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs) {
             var li = indices.length;
             var ln = normals.length;
             var i;

File diff ditekan karena terlalu besar
+ 8 - 8
babylon.2.1-alpha.js


+ 43 - 24
babylon.2.1.d.ts

@@ -535,6 +535,7 @@ declare module BABYLON {
         textures: BaseTexture[];
         particlesEnabled: boolean;
         particleSystems: ParticleSystem[];
+        spritesEnabled: boolean;
         spriteManagers: SpriteManager[];
         layers: Layer[];
         skeletonsEnabled: boolean;
@@ -587,7 +588,7 @@ declare module BABYLON {
         private _renderTargets;
         _activeParticleSystems: SmartArray<ParticleSystem>;
         private _activeSkeletons;
-        private _activeBones;
+        _activeBones: number;
         private _renderingManager;
         private _physicsEngine;
         _activeAnimatables: Animatable[];
@@ -1522,7 +1523,10 @@ declare module BABYLON {
         private _worldMatrix;
         _postProcesses: PostProcess[];
         _postProcessesTakenIndices: any[];
+        _activeMeshes: SmartArray<Mesh>;
         constructor(name: string, position: Vector3, scene: Scene);
+        getActiveMeshes(): SmartArray<Mesh>;
+        isActiveMesh(mesh: Mesh): boolean;
         _initCache(): void;
         _updateCache(ignoreParentClass?: boolean): void;
         _updateFromScene(): void;
@@ -3381,14 +3385,16 @@ declare module BABYLON {
         }
         class Box extends _Primitive {
             size: number;
-            constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh);
+            side: number;
+            constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
             _regenerateVertexData(): VertexData;
             copy(id: string): Geometry;
         }
         class Sphere extends _Primitive {
             segments: number;
             diameter: number;
-            constructor(id: string, scene: Scene, segments: number, diameter: number, canBeRegenerated?: boolean, mesh?: Mesh);
+            side: number;
+            constructor(id: string, scene: Scene, segments: number, diameter: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
             _regenerateVertexData(): VertexData;
             copy(id: string): Geometry;
         }
@@ -3398,7 +3404,8 @@ declare module BABYLON {
             diameterBottom: number;
             tessellation: number;
             subdivisions: number;
-            constructor(id: string, scene: Scene, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, canBeRegenerated?: boolean, mesh?: Mesh);
+            side: number;
+            constructor(id: string, scene: Scene, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
             _regenerateVertexData(): VertexData;
             copy(id: string): Geometry;
         }
@@ -3406,7 +3413,8 @@ declare module BABYLON {
             diameter: number;
             thickness: number;
             tessellation: number;
-            constructor(id: string, scene: Scene, diameter: number, thickness: number, tessellation: number, canBeRegenerated?: boolean, mesh?: Mesh);
+            side: number;
+            constructor(id: string, scene: Scene, diameter: number, thickness: number, tessellation: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
             _regenerateVertexData(): VertexData;
             copy(id: string): Geometry;
         }
@@ -3443,7 +3451,8 @@ declare module BABYLON {
         }
         class Plane extends _Primitive {
             size: number;
-            constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh);
+            side: number;
+            constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
             _regenerateVertexData(): VertexData;
             copy(id: string): Geometry;
         }
@@ -3454,7 +3463,8 @@ declare module BABYLON {
             tubularSegments: number;
             p: number;
             q: number;
-            constructor(id: string, scene: Scene, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, canBeRegenerated?: boolean, mesh?: Mesh);
+            side: number;
+            constructor(id: string, scene: Scene, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
             _regenerateVertexData(): VertexData;
             copy(id: string): Geometry;
         }
@@ -3524,6 +3534,14 @@ declare module BABYLON {
         renderSelf: boolean[];
     }
     class Mesh extends AbstractMesh implements IGetSetVerticesData {
+        static _FRONTSIDE: number;
+        static _BACKSIDE: number;
+        static _DOUBLESIDE: number;
+        static _DEFAULTSIDE: number;
+        static FRONTSIDE: number;
+        static BACKSIDE: number;
+        static DOUBLESIDE: number;
+        static DEFAULTSIDE: number;
         delayLoadState: number;
         instances: InstancedMesh[];
         delayLoadingFile: string;
@@ -3592,8 +3610,8 @@ declare module BABYLON {
         setIndices(indices: number[], totalVertices?: number): void;
         _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
         _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
-        registerBeforeRender(func: () => void): void;
-        unregisterBeforeRender(func: () => void): void;
+        registerBeforeRender(func: (mesh: AbstractMesh) => void): void;
+        unregisterBeforeRender(func: (mesh: AbstractMesh) => void): void;
         registerAfterRender(func: () => void): void;
         unregisterAfterRender(func: () => void): void;
         _getInstancesRenderList(subMeshId: number): _InstancesBatch;
@@ -3626,14 +3644,14 @@ declare module BABYLON {
          * successCallback optional success callback to be called after the simplification finished processing all settings.
          */
         simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, type?: SimplificationType, successCallback?: () => void): void;
-        static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene: Scene, updatable?: boolean): Mesh;
-        static CreateBox(name: string, size: number, scene: Scene, updatable?: boolean): Mesh;
-        static CreateSphere(name: string, segments: number, diameter: number, scene: Scene, updatable?: boolean): Mesh;
-        static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene: Scene, updatable?: any): Mesh;
-        static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene: Scene, updatable?: boolean): Mesh;
-        static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene: Scene, updatable?: boolean): Mesh;
+        static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
+        static CreateBox(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
+        static CreateSphere(name: string, segments: number, diameter: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
+        static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene: Scene, updatable?: any, sideOrientation?: number): Mesh;
+        static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
+        static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
         static CreateLines(name: string, points: Vector3[], scene: Scene, updatable?: boolean): LinesMesh;
-        static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean): Mesh;
+        static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
         static CreateGround(name: string, width: number, height: number, subdivisions: number, scene: Scene, updatable?: boolean): Mesh;
         static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
             w: number;
@@ -3681,11 +3699,11 @@ declare module BABYLON {
         static ExtractFromMesh(mesh: Mesh): VertexData;
         static ExtractFromGeometry(geometry: Geometry): VertexData;
         private static _ExtractFrom(meshOrGeometry);
-        static CreateRibbon(pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number): VertexData;
-        static CreateBox(size: number): VertexData;
-        static CreateSphere(segments: number, diameter: number): VertexData;
-        static CreateCylinder(height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number): VertexData;
-        static CreateTorus(diameter: any, thickness: any, tessellation: any): VertexData;
+        static CreateRibbon(pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, sideOrientation?: number): VertexData;
+        static CreateBox(size: number, sideOrientation?: number): VertexData;
+        static CreateSphere(segments: number, diameter: number, sideOrientation?: number): VertexData;
+        static CreateCylinder(height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, sideOrientation?: number): VertexData;
+        static CreateTorus(diameter: any, thickness: any, tessellation: any, sideOrientation?: number): VertexData;
         static CreateLines(points: Vector3[]): VertexData;
         static CreateGround(width: number, height: number, subdivisions: number): VertexData;
         static CreateTiledGround(xmin: number, zmin: number, xmax: number, zmax: number, subdivisions?: {
@@ -3696,9 +3714,10 @@ declare module BABYLON {
             h: number;
         }): VertexData;
         static CreateGroundFromHeightMap(width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, buffer: Uint8Array, bufferWidth: number, bufferHeight: number): VertexData;
-        static CreatePlane(size: number): VertexData;
-        static CreateTorusKnot(radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number): VertexData;
+        static CreatePlane(size: number, sideOrientation?: number): VertexData;
+        static CreateTorusKnot(radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, sideOrientation?: number): VertexData;
         static ComputeNormals(positions: number[], indices: number[], normals: number[]): void;
+        private static _ComputeSides(sideOrientation, positions, indices, normals, uvs);
     }
 }
 declare module BABYLON.Internals {
@@ -4769,7 +4788,7 @@ declare module BABYLON {
         private elementToMonitor;
         static FilesTextures: any[];
         static FilesToLoad: any[];
-        constructor(p_engine: BABYLON.Engine, p_scene: BABYLON.Scene, p_canvas: HTMLCanvasElement, p_sceneLoadedCallback: any, p_progressCallback: any, p_additionnalRenderLoopLogicCallback: any, p_textureLoadingCallback: any, p_startingProcessingFilesCallback: any);
+        constructor(p_engine: Engine, p_scene: Scene, p_canvas: HTMLCanvasElement, p_sceneLoadedCallback: any, p_progressCallback: any, p_additionnalRenderLoopLogicCallback: any, p_textureLoadingCallback: any, p_startingProcessingFilesCallback: any);
         monitorElementForDragNDrop(p_elementToMonitor: HTMLElement): void;
         private renderFunction();
         private drag(e);