Quellcode durchsuchen

Merging last changes

David catuhe vor 10 Jahren
Ursprung
Commit
cdefcfa7f0

Datei-Diff unterdrückt, da er zu groß ist
+ 854 - 854
dist/preview release/babylon.d.ts


Datei-Diff unterdrückt, da er zu groß ist
+ 15 - 15
dist/preview release/babylon.js


Datei-Diff unterdrückt, da er zu groß ist
+ 22 - 5
dist/preview release/babylon.max.js


Datei-Diff unterdrückt, da er zu groß ist
+ 14 - 14
dist/preview release/babylon.noworker.js


+ 7 - 6
src/Collisions/babylon.collisionCoordinator.ts

@@ -54,7 +54,7 @@ module BABYLON {
 
 
     export interface BabylonMessage {
     export interface BabylonMessage {
         taskType: WorkerTaskType;
         taskType: WorkerTaskType;
-        payload: InitPayload|CollidePayload|UpdatePayload /*any for TS under 1.4*/;
+        payload: InitPayload | CollidePayload | UpdatePayload /*any for TS under 1.4*/;
     }
     }
 
 
     export interface SerializedColliderToWorker {
     export interface SerializedColliderToWorker {
@@ -288,9 +288,9 @@ module BABYLON {
             for (var id in payload.updatedGeometries) {
             for (var id in payload.updatedGeometries) {
                 if (payload.updatedGeometries.hasOwnProperty(id)) {
                 if (payload.updatedGeometries.hasOwnProperty(id)) {
                     //prepare transferables
                     //prepare transferables
-                    serializable.push((<UpdatePayload> message.payload).updatedGeometries[id].indices.buffer);
-                    serializable.push((<UpdatePayload> message.payload).updatedGeometries[id].normals.buffer);
-                    serializable.push((<UpdatePayload> message.payload).updatedGeometries[id].positions.buffer);
+                    serializable.push((<UpdatePayload>message.payload).updatedGeometries[id].indices.buffer);
+                    serializable.push((<UpdatePayload>message.payload).updatedGeometries[id].normals.buffer);
+                    serializable.push((<UpdatePayload>message.payload).updatedGeometries[id].positions.buffer);
                 }
                 }
             }
             }
 
 
@@ -302,7 +302,7 @@ module BABYLON {
         }
         }
 
 
         private _onMessageFromWorker = (e: MessageEvent) => {
         private _onMessageFromWorker = (e: MessageEvent) => {
-            var returnData = <WorkerReply> e.data;
+            var returnData = <WorkerReply>e.data;
             if (returnData.error != WorkerReplyType.SUCCESS) {
             if (returnData.error != WorkerReplyType.SUCCESS) {
                 //TODO what errors can be returned from the worker?
                 //TODO what errors can be returned from the worker?
                 Tools.Warn("error returned from worker!");
                 Tools.Warn("error returned from worker!");
@@ -350,7 +350,7 @@ module BABYLON {
         public getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void {
         public getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void {
             position.divideToRef(collider.radius, this._scaledPosition);
             position.divideToRef(collider.radius, this._scaledPosition);
             velocity.divideToRef(collider.radius, this._scaledVelocity);
             velocity.divideToRef(collider.radius, this._scaledVelocity);
-			collider.collidedMesh = null;
+            collider.collidedMesh = null;
             collider.retry = 0;
             collider.retry = 0;
             collider.initialVelocity = this._scaledVelocity;
             collider.initialVelocity = this._scaledVelocity;
             collider.initialPosition = this._scaledPosition;
             collider.initialPosition = this._scaledPosition;
@@ -415,3 +415,4 @@ module BABYLON {
     }
     }
 }
 }
 
 
+

+ 8 - 0
src/Mesh/babylon.mesh.js

@@ -1201,6 +1201,14 @@ var BABYLON;
                 updatable = options.updatable;
                 updatable = options.updatable;
             }
             }
             else {
             else {
+                if (scene === undefined || !(scene instanceof BABYLON.Scene)) {
+                    if (scene !== undefined) {
+                        sideOrientation = updatable || Mesh.DEFAULTSIDE;
+                        updatable = scene;
+                    }
+                    scene = subdivisions;
+                    subdivisions = 1;
+                }
                 var height = options;
                 var height = options;
                 options = {
                 options = {
                     height: height,
                     height: height,

+ 51 - 42
src/Mesh/babylon.mesh.ts

@@ -1005,7 +1005,7 @@
 
 
                 // Create VertexData from map data
                 // 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 buffer = <Uint8Array>(<any>context.getImageData(0, 0, heightMapWidth, heightMapHeight).data);
 
 
                 this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight);
                 this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight);
                 //execute success callback, if set
                 //execute success callback, if set
@@ -1247,7 +1247,7 @@
 
 
         // Statics
         // Statics
         public static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
         public static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
-        public static CreateRibbon(name: string, options: {pathArray?: Vector3[][], closeArray?: boolean, closePath?: boolean, offset?: number, updatable?: boolean, sideOrientation?: number, instance?: Mesh}, scene: Scene): Mesh;
+        public static CreateRibbon(name: string, options: { pathArray?: Vector3[][], closeArray?: boolean, closePath?: boolean, offset?: number, updatable?: boolean, sideOrientation?: number, instance?: Mesh }, scene: Scene): Mesh;
         public static CreateRibbon(name: string, options: any, closeArrayOrScene: any, closePath?: boolean, offset?: number, scene?: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE, instance: Mesh = null): Mesh {
         public static CreateRibbon(name: string, options: any, closeArrayOrScene: any, closePath?: boolean, offset?: number, scene?: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE, instance: Mesh = null): Mesh {
             var pathArray;
             var pathArray;
             if (closeArrayOrScene instanceof Scene) {
             if (closeArrayOrScene instanceof Scene) {
@@ -1359,7 +1359,7 @@
         }
         }
 
 
         public static CreateBox(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
         public static CreateBox(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
-        public static CreateBox(name: string, options: { width?: number, height?: number, depth?: number, faceUV?: Vector4[], faceColors?: Color4[], sideOrientation?: number, updatable?: boolean}, scene: Scene): Mesh;
+        public static CreateBox(name: string, options: { width?: number, height?: number, depth?: number, faceUV?: Vector4[], faceColors?: Color4[], sideOrientation?: number, updatable?: boolean }, scene: Scene): Mesh;
         public static CreateBox(name: string, options: any, scene: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE): Mesh {
         public static CreateBox(name: string, options: any, scene: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE): Mesh {
             // Check parameters
             // Check parameters
             updatable = updatable || options.updatable;
             updatable = updatable || options.updatable;
@@ -1373,7 +1373,7 @@
         }
         }
 
 
         public static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
         public static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
-        public static CreateSphere(name: string, options: { segments?: number, diameterX?: number, diameterY?: number, diameterZ?: number, sideOrientation?: number, updatable?: boolean}, scene: any): Mesh;
+        public static CreateSphere(name: string, options: { segments?: number, diameterX?: number, diameterY?: number, diameterZ?: number, sideOrientation?: number, updatable?: boolean }, scene: any): Mesh;
         public static CreateSphere(name: string, options: any, diameterOrScene: any, scene?: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE): Mesh {
         public static CreateSphere(name: string, options: any, diameterOrScene: any, scene?: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE): Mesh {
             if (diameterOrScene instanceof Scene) {
             if (diameterOrScene instanceof Scene) {
                 scene = diameterOrScene;
                 scene = diameterOrScene;
@@ -1399,14 +1399,22 @@
         }
         }
 
 
         // Cylinder and cone
         // Cylinder and cone
-        public static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
-        public static CreateCylinder(name: string, options: {height?: number, diameterTop?: number, diameterBottom?: number, tessellation?: number, subdivisions?: number, updatable?: boolean, sideOrientation?: number}, scene: any): Mesh
-        public static CreateCylinder(name: string, options: any, diameterTopOrScene: any, diameterBottom?: number, tessellation?: number, subdivisions?: number, scene?: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE): Mesh {
-        
-            if (diameterTopOrScene instanceof Scene ) {
+        public static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene: Scene, updatable?: any, sideOrientation?: number): Mesh;
+        public static CreateCylinder(name: string, options: { height?: number, diameterTop?: number, diameterBottom?: number, tessellation?: number, subdivisions?: number, updatable?: boolean, sideOrientation?: number }, scene: any): Mesh;
+        public static CreateCylinder(name: string, options: any, diameterTopOrScene: any, diameterBottom?: number, tessellation?: number, subdivisions?: any, scene?: Scene, updatable?: any, sideOrientation: number = Mesh.DEFAULTSIDE): Mesh {
+
+            if (diameterTopOrScene instanceof Scene) {
                 scene = diameterTopOrScene;
                 scene = diameterTopOrScene;
                 updatable = options.updatable;
                 updatable = options.updatable;
             } else {
             } else {
+                if (scene === undefined || !(scene instanceof Scene)) {
+                    if (scene !== undefined) {
+                        sideOrientation = updatable || Mesh.DEFAULTSIDE;
+                        updatable = scene;
+                    }
+                    scene = <Scene>subdivisions;
+                    subdivisions = 1;
+                }
                 var height = options;
                 var height = options;
                 options = {
                 options = {
                     height: height,
                     height: height,
@@ -1582,20 +1590,20 @@
                     return pointCap;
                     return pointCap;
                 };
                 };
                 switch (cap) {
                 switch (cap) {
-                case Mesh.NO_CAP:
-                    break;
-                case Mesh.CAP_START:
-                    shapePaths.unshift(capPath(shapePaths[0]));
-                    break;
-                case Mesh.CAP_END:
-                    shapePaths.push(capPath(shapePaths[shapePaths.length - 1]));
-                    break;
-                case Mesh.CAP_ALL:
-                    shapePaths.unshift(capPath(shapePaths[0]));
-                    shapePaths.push(capPath(shapePaths[shapePaths.length - 1]));
-                    break;
-                default:
-                    break;
+                    case Mesh.NO_CAP:
+                        break;
+                    case Mesh.CAP_START:
+                        shapePaths.unshift(capPath(shapePaths[0]));
+                        break;
+                    case Mesh.CAP_END:
+                        shapePaths.push(capPath(shapePaths[shapePaths.length - 1]));
+                        break;
+                    case Mesh.CAP_ALL:
+                        shapePaths.unshift(capPath(shapePaths[0]));
+                        shapePaths.push(capPath(shapePaths[shapePaths.length - 1]));
+                        break;
+                    default:
+                        break;
                 }
                 }
                 return shapePaths;
                 return shapePaths;
             };
             };
@@ -1657,7 +1665,7 @@
 
 
         // Plane & ground
         // Plane & ground
         public static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
         public static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
-        public static CreatePlane(name: string, options: { width?: number, height?: number, sideOrientation?: number, updatable?: boolean}, scene: Scene): Mesh;
+        public static CreatePlane(name: string, options: { width?: number, height?: number, sideOrientation?: number, updatable?: boolean }, scene: Scene): Mesh;
         public static CreatePlane(name: string, options: any, scene: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE): Mesh {
         public static CreatePlane(name: string, options: any, scene: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE): Mesh {
             var plane = new Mesh(name, scene);
             var plane = new Mesh(name, scene);
 
 
@@ -1726,7 +1734,7 @@
 
 
                 // Create VertexData from map data
                 // 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 buffer = <Uint8Array>(<any>context.getImageData(0, 0, heightMapWidth, heightMapHeight).data);
                 var vertexData = VertexData.CreateGroundFromHeightMap(width, height, subdivisions, minHeight, maxHeight, buffer, heightMapWidth, heightMapHeight);
                 var vertexData = VertexData.CreateGroundFromHeightMap(width, height, subdivisions, minHeight, maxHeight, buffer, heightMapWidth, heightMapHeight);
 
 
                 vertexData.applyToMesh(ground, updatable);
                 vertexData.applyToMesh(ground, updatable);
@@ -1783,20 +1791,20 @@
                     return pointCap;
                     return pointCap;
                 };
                 };
                 switch (cap) {
                 switch (cap) {
-                case Mesh.NO_CAP:
-                    break;
-                case Mesh.CAP_START:
-                    circlePaths.unshift(capPath(tessellation + 1, 0));
-                    break;
-                case Mesh.CAP_END:
-                    circlePaths.push(capPath(tessellation + 1, path.length - 1));
-                    break;
-                case Mesh.CAP_ALL:
-                    circlePaths.unshift(capPath(tessellation + 1, 0));
-                    circlePaths.push(capPath(tessellation + 1, path.length - 1));
-                    break;
-                default:
-                    break;
+                    case Mesh.NO_CAP:
+                        break;
+                    case Mesh.CAP_START:
+                        circlePaths.unshift(capPath(tessellation + 1, 0));
+                        break;
+                    case Mesh.CAP_END:
+                        circlePaths.push(capPath(tessellation + 1, path.length - 1));
+                        break;
+                    case Mesh.CAP_ALL:
+                        circlePaths.unshift(capPath(tessellation + 1, 0));
+                        circlePaths.push(capPath(tessellation + 1, path.length - 1));
+                        break;
+                    default:
+                        break;
                 }
                 }
                 return circlePaths;
                 return circlePaths;
             };
             };
@@ -1883,7 +1891,7 @@
                     return new PositionNormalVertex(
                     return new PositionNormalVertex(
                         Vector3.Lerp(v0.position, v1.position, clipFactor),
                         Vector3.Lerp(v0.position, v1.position, clipFactor),
                         Vector3.Lerp(v0.normal, v1.normal, clipFactor)
                         Vector3.Lerp(v0.normal, v1.normal, clipFactor)
-                        );
+                    );
                 };
                 };
                 var result = new Array<PositionNormalVertex>();
                 var result = new Array<PositionNormalVertex>();
 
 
@@ -2081,13 +2089,13 @@
                 var matricesWeight1 = matricesWeightsData[index4 + 1];
                 var matricesWeight1 = matricesWeightsData[index4 + 1];
                 var matricesWeight2 = matricesWeightsData[index4 + 2];
                 var matricesWeight2 = matricesWeightsData[index4 + 2];
                 var matricesWeight3 = matricesWeightsData[index4 + 3];
                 var matricesWeight3 = matricesWeightsData[index4 + 3];
-                
+
                 if (matricesWeight0 > 0) {
                 if (matricesWeight0 > 0) {
                     Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[index4] * 16, matricesWeight0, tempMatrix);
                     Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[index4] * 16, matricesWeight0, tempMatrix);
                     finalMatrix.addToSelf(tempMatrix);
                     finalMatrix.addToSelf(tempMatrix);
                 }
                 }
 
 
-                if (matricesWeight1> 0) {
+                if (matricesWeight1 > 0) {
                     Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[index4 + 1] * 16, matricesWeight1, tempMatrix);
                     Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[index4 + 1] * 16, matricesWeight1, tempMatrix);
                     finalMatrix.addToSelf(tempMatrix);
                     finalMatrix.addToSelf(tempMatrix);
                 }
                 }
@@ -2213,3 +2221,4 @@
 }
 }
 
 
 
 
+

+ 12 - 3
src/Mesh/babylon.mesh.vertexData.js

@@ -638,13 +638,22 @@ var BABYLON;
             return vertexData;
             return vertexData;
         };
         };
         VertexData.CreateCylinder = function (options, diameterTop, diameterBottom, tessellation, subdivisions, sideOrientation) {
         VertexData.CreateCylinder = function (options, diameterTop, diameterBottom, tessellation, subdivisions, sideOrientation) {
-            if (sideOrientation === void 0) { sideOrientation = BABYLON.Mesh.DEFAULTSIDE; }
             var height = height || options.height || 3;
             var height = height || options.height || 3;
-            diameterTop = diameterTop || options.diameterTop || 1;
+            if (diameterTop === 0 || options.diameterTop === 0) {
+                diameterTop = 0;
+            }
+            else {
+                diameterTop = diameterTop || options.diameterTop || 1;
+            }
             diameterBottom = diameterBottom || options.diameterBottom || 1;
             diameterBottom = diameterBottom || options.diameterBottom || 1;
             tessellation = tessellation || options.tessellation || 24;
             tessellation = tessellation || options.tessellation || 24;
             subdivisions = subdivisions || options.subdivisions || 1;
             subdivisions = subdivisions || options.subdivisions || 1;
-            sideOrientation = sideOrientation || options.sideOrientation || BABYLON.Mesh.DEFAULTSIDE;
+            if (sideOrientation === 0 || options.sideOrientation === 0) {
+                sideOrientation = 0;
+            }
+            else {
+                sideOrientation = sideOrientation || options.sideOrientation || BABYLON.Mesh.DEFAULTSIDE;
+            }
             var indices = [];
             var indices = [];
             var positions = [];
             var positions = [];
             var normals = [];
             var normals = [];

+ 15 - 7
src/Mesh/babylon.mesh.vertexData.ts

@@ -382,7 +382,7 @@
         }
         }
 
 
         public static CreateRibbon(pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, sideOrientation?: number): VertexData;
         public static CreateRibbon(pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, sideOrientation?: number): VertexData;
-        public static CreateRibbon(options: {pathArray?: Vector3[][], closeArray?: boolean, closePath?: boolean, offset?: number, sideOrientation?: number}): VertexData;
+        public static CreateRibbon(options: { pathArray?: Vector3[][], closeArray?: boolean, closePath?: boolean, offset?: number, sideOrientation?: number }): VertexData;
         public static CreateRibbon(options: any, closeArray?: boolean, closePath?: boolean, offset?: number, sideOrientation: number = Mesh.DEFAULTSIDE): VertexData {
         public static CreateRibbon(options: any, closeArray?: boolean, closePath?: boolean, offset?: number, sideOrientation: number = Mesh.DEFAULTSIDE): VertexData {
 
 
             var pathArray = pathArray || options.pathArray;
             var pathArray = pathArray || options.pathArray;
@@ -783,16 +783,23 @@
         }
         }
 
 
         // Cylinder and cone 
         // Cylinder and cone 
-        public static CreateCylinder(options: {height?: number, diameterTop?: number, diameterBottom?: number, tessellation?: number, subdivisions?: number, sideOrientation?: number}): VertexData;
+        public static CreateCylinder(options: { height?: number, diameterTop?: number, diameterBottom?: number, tessellation?: number, subdivisions?: number, sideOrientation?: number }): VertexData;
         public static CreateCylinder(height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: number, sideOrientation?: number): VertexData;
         public static CreateCylinder(height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: number, sideOrientation?: number): VertexData;
-        public static CreateCylinder(options: any, diameterTop?: number, diameterBottom?: number, tessellation?: number, subdivisions?: number, sideOrientation: number = Mesh.DEFAULTSIDE): VertexData {
+        public static CreateCylinder(options: any, diameterTop?: number, diameterBottom?: number, tessellation?: number, subdivisions?: number, sideOrientation?: number): VertexData {
             var height = height || options.height || 3;
             var height = height || options.height || 3;
-            diameterTop = diameterTop || options.diameterTop || 1;
+            if (diameterTop === 0 || options.diameterTop === 0) {
+                diameterTop = 0;
+            } else {
+                diameterTop = diameterTop || options.diameterTop || 1;
+            }
             diameterBottom = diameterBottom || options.diameterBottom || 1;
             diameterBottom = diameterBottom || options.diameterBottom || 1;
             tessellation = tessellation || options.tessellation || 24;
             tessellation = tessellation || options.tessellation || 24;
             subdivisions = subdivisions || options.subdivisions || 1;
             subdivisions = subdivisions || options.subdivisions || 1;
-                
-            sideOrientation = sideOrientation || options.sideOrientation || Mesh.DEFAULTSIDE;
+            if (sideOrientation === 0 || options.sideOrientation === 0) {
+                sideOrientation = 0;
+            } else {
+                sideOrientation = sideOrientation || options.sideOrientation || Mesh.DEFAULTSIDE;
+            }
 
 
             var indices = [];
             var indices = [];
             var positions = [];
             var positions = [];
@@ -1151,7 +1158,7 @@
                         zmin + tileRow * tileSize.h,
                         zmin + tileRow * tileSize.h,
                         xmin + (tileCol + 1) * tileSize.w,
                         xmin + (tileCol + 1) * tileSize.w,
                         zmin + (tileRow + 1) * tileSize.h
                         zmin + (tileRow + 1) * tileSize.h
-                        );
+                    );
                 }
                 }
             }
             }
 
 
@@ -1541,3 +1548,4 @@
 
 
 
 
 
 
+