Skip to content
Browse files

Integrating PRs

  • Loading branch information...
1 parent c13801c commit 741c07ab2c5efbbb871ba99bdb3e57d2e47da7c0 @deltakosh deltakosh committed
View
38 dist/preview release/babylon.core.js
19 additions, 19 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
1,758 dist/preview release/babylon.d.ts
930 additions, 828 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
63 dist/preview release/babylon.js
27 additions, 36 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
107 dist/preview release/babylon.max.js
104 additions, 3 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
50 dist/preview release/babylon.noworker.js
25 additions, 25 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
1 dist/preview release/what's new.md
@@ -8,6 +8,7 @@
- StandardMaterial now supports Parallax and Parallax Occlusion Mapping ([nockawa](https://github.com/nockawa))
- Animations blending. See [demo here](http://www.babylonjs-playground.com/#2BLI9T#3). More [info here](NEED DOC!) ([deltakosh](https://github.com/deltakosh))
- New debuger tool: SkeletonViewer. See [demo here](Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8) (Adam & [deltakosh](https://github.com/deltakosh))
+ - Added Camera Inputs Manager to manage camera inputs (mouse, touch, keyboard, gamepad, ...) in a composable way, without relying on class inheritance [gleborgne](https://github.com/gleborgne)
- **Updates**
- Added Camera.ForceAttachControlToAlwaysPreventDefault to help embedding Babylon.js in iFrames ([deltakosh](https://github.com/deltakosh))
- Support for Layer.alphaTest ([deltakosh](https://github.com/deltakosh))
View
60 src/Cameras/Inputs/babylon.arcrotatecamera.input.gamepad.ts
@@ -1,73 +1,73 @@
-module BABYLON {
+module BABYLON {
export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
- camera : ArcRotateCamera;
-
+ camera: ArcRotateCamera;
+
public gamepad: Gamepad;
- private _gamepads: Gamepads;
+ private _gamepads: Gamepads;
@serialize()
public gamepadRotationSensibility = 80;
-
+
@serialize()
public gamepadMoveSensibility = 40;
-
- constructor(){
+
+ constructor() {
this._gamepads = new Gamepads((gamepad: Gamepad) => { this._onNewGameConnected(gamepad); });
}
-
- attachCamera(camera : ArcRotateCamera){
+
+ attachCamera(camera: ArcRotateCamera) {
this.camera = camera;
}
-
- detach(){
+
+ detach() {
this._gamepads.dispose();
}
-
- checkInputs(){
+
+ checkInputs() {
if (this.gamepad) {
var camera = this.camera;
var RSValues = this.gamepad.rightStick;
-
- if (RSValues.x != 0){
- var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
+
+ if (RSValues.x != 0) {
+ var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
camera.inertialAlphaOffset += normalizedRX;
}
}
-
- if (RSValues.y != 0){
+
+ if (RSValues.y != 0) {
var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
camera.inertialBetaOffset += normalizedRY;
}
- }
-
+ }
+
var LSValues = this.gamepad.leftStick;
- if (LSValues.y != 0){
- var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
+ if (LSValues.y != 0) {
+ var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
this.camera.inertialRadiusOffset -= normalizedLY;
}
}
-
+
}
}
-
+
private _onNewGameConnected(gamepad: Gamepad) {
// Only the first gamepad can control the camera
if (gamepad.index === 0) {
this.gamepad = gamepad;
}
}
-
- getTypeName(): string{
+
+ getTypeName(): string {
return "ArcRotateCameraGamepadInput";
}
-
- getSimpleName(){
+
+ getSimpleName() {
return "gamepad";
}
}
-
+
CameraInputTypes["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
-}
+}
View
2 src/Cameras/babylon.camera.js
@@ -541,7 +541,7 @@ var BABYLON;
if (parsedCamera.parentId) {
camera._waitingParentId = parsedCamera.parentId;
}
- //Input manager
+ //If camera has an input manager, let it parse inputs settings
if (camera.inputs) {
camera.inputs.parse(parsedCamera);
}
View
27 src/Cameras/babylon.camera.ts
@@ -1,6 +1,6 @@
module BABYLON {
export class Camera extends Node {
- public inputs : CameraInputsManager<Camera>;
+ public inputs: CameraInputsManager<Camera>;
// Statics
private static _PERSPECTIVE_CAMERA = 0;
@@ -141,19 +141,19 @@
/**
* @param {boolean} fullDetails - support for multiple levels of logging within scene loading
*/
- public toString(fullDetails? : boolean) : string {
+ public toString(fullDetails?: boolean): string {
var ret = "Name: " + this.name;
ret += ", type: " + this.getTypeName();
- if (this.animations){
- for (var i = 0; i < this.animations.length; i++){
- ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
+ if (this.animations) {
+ for (var i = 0; i < this.animations.length; i++) {
+ ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
}
}
- if (fullDetails){
+ if (fullDetails) {
}
return ret;
- }
-
+ }
+
public get globalPosition(): Vector3 {
return this._globalPosition;
}
@@ -587,8 +587,8 @@
if (this.parent) {
serializationObject.parentId = this.parent.id;
}
-
- if (this.inputs){
+
+ if (this.inputs) {
this.inputs.serialize(serializationObject);
}
// Animations
@@ -615,7 +615,7 @@
case "FollowCamera":
return () => new FollowCamera(name, Vector3.Zero(), scene);
case "ArcFollowCamera":
- return () => new ArcFollowCamera(name, 0, 0, 1.0, null, scene);
+ return () => new ArcFollowCamera(name, 0, 0, 1.0, null, scene);
case "GamepadCamera":
return () => new GamepadCamera(name, Vector3.Zero(), scene);
case "TouchCamera":
@@ -652,7 +652,7 @@
public static Parse(parsedCamera: any, scene: Scene): Camera {
var type = parsedCamera.type;
var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
-
+
var camera = SerializationHelper.Parse(construct, parsedCamera, scene);
// Parent
@@ -661,7 +661,7 @@
}
//If camera has an input manager, let it parse inputs settings
- if (camera.inputs){
+ if (camera.inputs) {
camera.inputs.parse(parsedCamera);
}
@@ -698,3 +698,4 @@
}
+
View
49 src/Cameras/babylon.cameraInputsManager.ts
@@ -1,15 +1,15 @@
module BABYLON {
export var CameraInputTypes = {};
-
+
export interface ICameraInput<TCamera extends BABYLON.Camera> {
camera: TCamera;
attachCamera(camera: TCamera);
- detach();
+ detach();
getTypeName(): string;
getSimpleName(): string;
-
- attachElement? : (element: HTMLElement, noPreventDefault?: boolean) => void;
- detachElement? : (element: HTMLElement) => void;
+
+ attachElement?: (element: HTMLElement, noPreventDefault?: boolean) => void;
+ detachElement?: (element: HTMLElement) => void;
checkInputs?: () => void;
}
@@ -45,28 +45,28 @@ module BABYLON {
this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
}
}
-
+
public remove(inputToRemove: ICameraInput<TCamera>) {
for (var cam in this.attached) {
var input = this.attached[cam];
- if (input == inputToRemove){
+ if (input == inputToRemove) {
input.detach();
delete this.attached[cam];
- }
+ }
}
}
-
+
public removeByType(inputType: string) {
for (var cam in this.attached) {
var input = this.attached[cam];
- if (input.getTypeName() == inputType){
+ if (input.getTypeName() == inputType) {
input.detach();
delete this.attached[cam];
- }
+ }
}
}
-
- private _addCheckInputs(fn){
+
+ private _addCheckInputs(fn) {
var current = this.checkInputs;
return () => {
current();
@@ -109,26 +109,26 @@ module BABYLON {
this.attached = {};
this.checkInputs = () => { };
}
-
- public serialize(serializedCamera){
+
+ public serialize(serializedCamera) {
var inputs = {};
for (var cam in this.attached) {
var input = this.attached[cam];
var res = SerializationHelper.Serialize(input, serializedCamera);
inputs[input.getTypeName()] = res;
}
-
+
serializedCamera.inputsmgr = inputs;
}
-
- public parse(parsedCamera){
+
+ public parse(parsedCamera) {
var parsedInputs = parsedCamera.inputsmgr;
- if (parsedInputs){
+ if (parsedInputs) {
this.clear();
-
+
for (var n in parsedInputs) {
var construct = CameraInputTypes[n];
- if (construct){
+ if (construct) {
var parsedinput = parsedInputs[n];
var input = SerializationHelper.Parse(() => { return new construct() }, parsedinput, null);
this.add(input as any);
@@ -136,14 +136,15 @@ module BABYLON {
}
} else {
//2016-03-08 this part is for managing backward compatibility
- for (var n in this.attached) {
+ for (var n in this.attached) {
var construct = CameraInputTypes[this.attached[n].getTypeName()];
- if (construct){
+ if (construct) {
var input = SerializationHelper.Parse(() => { return new construct() }, parsedCamera, null);
this.add(input as any);
}
}
}
- }
+ }
}
}
+
View
101 src/Mesh/babylon.meshBuilder.js
@@ -3,24 +3,68 @@ var BABYLON;
var MeshBuilder = (function () {
function MeshBuilder() {
}
+ /**
+ * Creates a box mesh.
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
+ * The parameter "size" sets the size (float) of each box side (default 1).
+ * You can set some different box dimensions by using the parameters "width", "height" and "depth" (all by default have the same value than "size").
+ * You can set different colors and different images to each box side by using the parameters "faceColors" (an array of 6 Color3 elements) and "faceUV" (an array of 6 Vector4 elements).
+ * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
+ * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
+ * The mesh can be set to updatable with the boolean parameter "updatable" (default false) if its internal geometry is supposed to change once created.
+ */
MeshBuilder.CreateBox = function (name, options, scene) {
var box = new BABYLON.Mesh(name, scene);
var vertexData = BABYLON.VertexData.CreateBox(options);
vertexData.applyToMesh(box, options.updatable);
return box;
};
+ /**
+ * Creates a sphere mesh.
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
+ * The parameter "diameter" sets the diameter size (float) of the sphere (default 1).
+ * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters "diameterX", "diameterY" and "diameterZ" (all by default have the same value than "diameter").
+ * The parameter "segments" sets the sphere number of horizontal stripes (positive integer, default 32).
+ * You can create an unclosed sphere with the parameter "arc" (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
+ * You can create an unclosed sphere on its height with the parameter "slice" (positive float, default1), valued between 0 and 1, what is the height ratio (longitude).
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
+ * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
+ * The mesh can be set to updatable with the boolean parameter "updatable" (default false) if its internal geometry is supposed to change once created.
+ */
MeshBuilder.CreateSphere = function (name, options, scene) {
var sphere = new BABYLON.Mesh(name, scene);
var vertexData = BABYLON.VertexData.CreateSphere(options);
vertexData.applyToMesh(sphere, options.updatable);
return sphere;
};
+ /**
+ * Creates a plane polygonal mesh. By default, this is a disc.
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
+ * The parameter "radius" sets the radius size (float) of the polygon (default 0.5).
+ * The parameter "tessellation" sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc.
+ * You can create an unclosed polygon with the parameter "arc" (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
+ * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
+ * The mesh can be set to updatable with the boolean parameter "updatable" (default false) if its internal geometry is supposed to change once created.
+ */
MeshBuilder.CreateDisc = function (name, options, scene) {
var disc = new BABYLON.Mesh(name, scene);
var vertexData = BABYLON.VertexData.CreateDisc(options);
vertexData.applyToMesh(disc, options.updatable);
return disc;
};
+ /**
+ * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
+ * The parameter "radius" sets the radius size (float) of the icosphere (default 1).
+ * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters "radiusX", "radiusY" and "radiusZ" (all by default have the same value than "radius").
+ * The parameter "subdivisions" sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
+ * The parameter "flat" (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface.
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
+ * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
+ * The mesh can be set to updatable with the boolean parameter "updatable" (default false) if its internal geometry is supposed to change once created.
+ */
MeshBuilder.CreateIcoSphere = function (name, options, scene) {
var sphere = new BABYLON.Mesh(name, scene);
var vertexData = BABYLON.VertexData.CreateIcoSphere(options);
@@ -28,6 +72,19 @@ var BABYLON;
return sphere;
};
;
+ /**
+ * Creates a ribbon mesh.
+ * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
+ *
+ * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
+ * The parameter "pathArray" is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
+ * The parameter "closeArray" (boolean, default false) creates a seam between the first and the last paths of the path array.
+ * The parameter "closePath" (boolean, default false) creates a seam between the first and the last points of each path of the path array.
+ * The parameter "instance" is an instance of an existing Ribbon object to be updated with the passed "pathArray" parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
+ * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
+ * The mesh can be set to updatable with the boolean parameter "updatable" (default false) if its internal geometry is supposed to change once created.
+ */
MeshBuilder.CreateRibbon = function (name, options, scene) {
var pathArray = options.pathArray;
var closeArray = options.closeArray;
@@ -108,18 +165,62 @@ var BABYLON;
return ribbon;
}
};
+ /**
+ * Creates a cylinder or a cone mesh.
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
+ * The parameter "height" sets the height size (float) of the cylinder/cone (float, default 2).
+ * The parameter "diameter" sets the diameter of the top and bottom cap at once (float, default 1).
+ * The parameters "diameterTop" and "diameterBottom" overwrite the parameter "diameter" and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
+ * The parameter "tessellation" sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
+ * The parameter "subdivisions" sets the number of rings along the cylinder height (positive integer, default 1).
+ * The parameter "hasRings" (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
+ * The parameter "enclose" (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
+ * The parameter "arc" (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
+ * You can set different colors and different images to each box side by using the parameters "faceColors" (an array of n Color3 elements) and "faceUV" (an array of n Vector4 elements).
+ * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
+ * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
+ * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
+ * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
+ * If enclose is false, a ring surface is one element.
+ * If enclose true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
+ * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
+ * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
+ * The mesh can be set to updatable with the boolean parameter "updatable" (default false) if its internal geometry is supposed to change once created.
+ */
MeshBuilder.CreateCylinder = function (name, options, scene) {
var cylinder = new BABYLON.Mesh(name, scene);
var vertexData = BABYLON.VertexData.CreateCylinder(options);
vertexData.applyToMesh(cylinder, options.updatable);
return cylinder;
};
+ /**
+ * Creates a torus mesh.
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
+ * The parameter "diameter" sets the diameter size (float) of the torus (default 1).
+ * The parameter "thickness" sets the diameter size of the tube of the torus (float, default 0.5).
+ * The parameter "tessellation" sets the number of torus sides (postive integer, default 16).
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
+ * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
+ * The mesh can be set to updatable with the boolean parameter "updatable" (default false) if its internal geometry is supposed to change once created.
+ */
MeshBuilder.CreateTorus = function (name, options, scene) {
var torus = new BABYLON.Mesh(name, scene);
var vertexData = BABYLON.VertexData.CreateTorus(options);
vertexData.applyToMesh(torus, options.updatable);
return torus;
};
+ /**
+ * Creates a torus knot mesh.
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
+ * The parameter "radius" sets the global radius size (float) of the torus knot (default 2).
+ * The parameter "radialSegments" sets the number of sides on each tube segments (positive integer, default 32).
+ * The parameter "tubularSegments" sets the number of tubes to decompose the knot into (positive integer, default 32).
+ * The parameters "p" and "q" are the number of windings on each axis (positive integers, default 2 and 3).
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
+ * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
+ * The mesh can be set to updatable with the boolean parameter "updatable" (default false) if its internal geometry is supposed to change once created.
+ */
MeshBuilder.CreateTorusKnot = function (name, options, scene) {
var torusKnot = new BABYLON.Mesh(name, scene);
var vertexData = BABYLON.VertexData.CreateTorusKnot(options);
View
1 src/Mesh/babylon.meshBuilder.ts
@@ -926,3 +926,4 @@
}
}
+
View
2 src/babylon.node.js
@@ -142,7 +142,7 @@ var BABYLON;
if (directDecendantsOnly === void 0) { directDecendantsOnly = false; }
for (var index = 0; index < list.length; index++) {
var item = list[index];
- if (((directDecendantsOnly && item.parent === this) || (!directDecendantsOnly && item.isDescendantOf(this))) && (predicate === null || predicate(item))) {
+ if (((directDecendantsOnly && item.parent === this) || (!directDecendantsOnly && item.isDescendantOf(this))) && (!predicate || predicate(item))) {
results.push(item);
}
}
View
1 what's new.md
@@ -77,7 +77,6 @@
- Added panning axis to the ArcRotateCamera [PR](https://github.com/BabylonJS/Babylon.js/pull/913) ([mstdokumaci](https://github.com/mstdokumaci), [RaananW](https://github.com/RaananW))
- Added `Tmp` class for internal use in order to improvement the memory management, [jerome](https://github.com/jbousquie))
- Added `Scene.swithActiveCamera(newCamera, attachControl)` to go from one camera active to another. ([dad72](https://github.com/dad72)) [PR](https://github.com/BabylonJS/Babylon.js/pull/928)
- - Added Camera Inputs Manager to manage camera inputs (mouse, touch, keyboard, gamepad, ...) in a composable way, without relying on class inheritance, [gleborgne](https://github.com/gleborgne)
- **Bug fixes**
- Fixed IDB for offline support ([davrous](https://github.com/davrous))
- Fixed a bug with spherical mapping ([deltakosh](https://github.com/deltakosh))

0 comments on commit 741c07a

Please sign in to comment.
Something went wrong with that request. Please try again.