소스 검색

Integrating Jerome latest PR

David Catuhe 10 년 전
부모
커밋
77d51c86bf

+ 12 - 9
Babylon/Audio/babylon.sound.js

@@ -18,7 +18,7 @@ var BABYLON;
             this.rolloffFactor = 1;
             this.rolloffFactor = 1;
             this.maxDistance = 100;
             this.maxDistance = 100;
             this.distanceModel = "linear";
             this.distanceModel = "linear";
-            this.panningModel = "HRTF";
+            this._panningModel = "equalpower";
             this._playbackRate = 1;
             this._playbackRate = 1;
             this._startTime = 0;
             this._startTime = 0;
             this._startOffset = 0;
             this._startOffset = 0;
@@ -60,7 +60,6 @@ var BABYLON;
                 this.rolloffFactor = options.rolloffFactor || 1;
                 this.rolloffFactor = options.rolloffFactor || 1;
                 this.refDistance = options.refDistance || 1;
                 this.refDistance = options.refDistance || 1;
                 this.distanceModel = options.distanceModel || "linear";
                 this.distanceModel = options.distanceModel || "linear";
-                this.panningModel = options.panningModel || "HRTF";
                 this._playbackRate = options.playbackRate || 1;
                 this._playbackRate = options.playbackRate || 1;
             }
             }
             if (BABYLON.Engine.audioEngine.canUseWebAudio) {
             if (BABYLON.Engine.audioEngine.canUseWebAudio) {
@@ -160,12 +159,14 @@ var BABYLON;
                 this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
                 this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
                 this.refDistance = options.refDistance || this.refDistance;
                 this.refDistance = options.refDistance || this.refDistance;
                 this.distanceModel = options.distanceModel || this.distanceModel;
                 this.distanceModel = options.distanceModel || this.distanceModel;
-                this.panningModel = options.panningModel || this.panningModel;
                 this._playbackRate = options.playbackRate || this._playbackRate;
                 this._playbackRate = options.playbackRate || this._playbackRate;
             }
             }
         };
         };
         Sound.prototype._createSpatialParameters = function () {
         Sound.prototype._createSpatialParameters = function () {
             if (BABYLON.Engine.audioEngine.canUseWebAudio) {
             if (BABYLON.Engine.audioEngine.canUseWebAudio) {
+                if (this._scene.headphone) {
+                    this._panningModel = "HRTF";
+                }
                 this._soundPanner = BABYLON.Engine.audioEngine.audioContext.createPanner();
                 this._soundPanner = BABYLON.Engine.audioEngine.audioContext.createPanner();
                 if (this.useCustomAttenuation) {
                 if (this.useCustomAttenuation) {
                     // Tricks to disable in a way embedded Web Audio attenuation 
                     // Tricks to disable in a way embedded Web Audio attenuation 
@@ -173,28 +174,30 @@ var BABYLON;
                     this._soundPanner.maxDistance = Number.MAX_VALUE;
                     this._soundPanner.maxDistance = Number.MAX_VALUE;
                     this._soundPanner.refDistance = 1;
                     this._soundPanner.refDistance = 1;
                     this._soundPanner.rolloffFactor = 1;
                     this._soundPanner.rolloffFactor = 1;
-                    this._soundPanner.panningModel = "HRTF";
+                    this._soundPanner.panningModel = this._panningModel;
                 }
                 }
                 else {
                 else {
                     this._soundPanner.distanceModel = this.distanceModel;
                     this._soundPanner.distanceModel = this.distanceModel;
                     this._soundPanner.maxDistance = this.maxDistance;
                     this._soundPanner.maxDistance = this.maxDistance;
                     this._soundPanner.refDistance = this.refDistance;
                     this._soundPanner.refDistance = this.refDistance;
                     this._soundPanner.rolloffFactor = this.rolloffFactor;
                     this._soundPanner.rolloffFactor = this.rolloffFactor;
-                    this._soundPanner.panningModel = this.panningModel;
+                    this._soundPanner.panningModel = this._panningModel;
                 }
                 }
                 this._soundPanner.connect(this._ouputAudioNode);
                 this._soundPanner.connect(this._ouputAudioNode);
                 this._inputAudioNode = this._soundPanner;
                 this._inputAudioNode = this._soundPanner;
             }
             }
         };
         };
         Sound.prototype.switchPanningModelToHRTF = function () {
         Sound.prototype.switchPanningModelToHRTF = function () {
-            this._switchPanningModel("HRTF");
+            this._panningModel = "HRTF";
+            this._switchPanningModel();
         };
         };
         Sound.prototype.switchPanningModelToEqualPower = function () {
         Sound.prototype.switchPanningModelToEqualPower = function () {
-            this._switchPanningModel("equalpower");
+            this._panningModel = "equalpower";
+            this._switchPanningModel();
         };
         };
-        Sound.prototype._switchPanningModel = function (newModel) {
+        Sound.prototype._switchPanningModel = function () {
             if (BABYLON.Engine.audioEngine.canUseWebAudio && this.spatialSound) {
             if (BABYLON.Engine.audioEngine.canUseWebAudio && this.spatialSound) {
-                this._soundPanner.panningModel = newModel;
+                this._soundPanner.panningModel = this._panningModel;
             }
             }
         };
         };
         Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
         Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {

+ 12 - 9
Babylon/Audio/babylon.sound.ts

@@ -10,7 +10,7 @@
         public rolloffFactor: number = 1;
         public rolloffFactor: number = 1;
         public maxDistance: number = 100;
         public maxDistance: number = 100;
         public distanceModel: string = "linear";
         public distanceModel: string = "linear";
-        public panningModel: string = "HRTF";
+        private _panningModel: string = "equalpower";
         public onended: () => any;
         public onended: () => any;
         private _playbackRate: number = 1;
         private _playbackRate: number = 1;
         private _startTime: number = 0;
         private _startTime: number = 0;
@@ -73,7 +73,6 @@
                 this.rolloffFactor = options.rolloffFactor || 1;
                 this.rolloffFactor = options.rolloffFactor || 1;
                 this.refDistance = options.refDistance || 1;
                 this.refDistance = options.refDistance || 1;
                 this.distanceModel = options.distanceModel || "linear";
                 this.distanceModel = options.distanceModel || "linear";
-                this.panningModel = options.panningModel || "HRTF";
                 this._playbackRate = options.playbackRate || 1;
                 this._playbackRate = options.playbackRate || 1;
             }
             }
 
 
@@ -170,13 +169,15 @@
                 this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
                 this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
                 this.refDistance = options.refDistance || this.refDistance;
                 this.refDistance = options.refDistance || this.refDistance;
                 this.distanceModel = options.distanceModel || this.distanceModel;
                 this.distanceModel = options.distanceModel || this.distanceModel;
-                this.panningModel = options.panningModel || this.panningModel;
                 this._playbackRate = options.playbackRate || this._playbackRate;
                 this._playbackRate = options.playbackRate || this._playbackRate;
             }
             }
         }
         }
 
 
         private _createSpatialParameters() {
         private _createSpatialParameters() {
             if (Engine.audioEngine.canUseWebAudio) {
             if (Engine.audioEngine.canUseWebAudio) {
+                if (this._scene.headphone) {
+                    this._panningModel = "HRTF";
+                }
                 this._soundPanner = Engine.audioEngine.audioContext.createPanner();
                 this._soundPanner = Engine.audioEngine.audioContext.createPanner();
 
 
                 if (this.useCustomAttenuation) {
                 if (this.useCustomAttenuation) {
@@ -185,14 +186,14 @@
                     this._soundPanner.maxDistance = Number.MAX_VALUE;
                     this._soundPanner.maxDistance = Number.MAX_VALUE;
                     this._soundPanner.refDistance = 1;
                     this._soundPanner.refDistance = 1;
                     this._soundPanner.rolloffFactor = 1;
                     this._soundPanner.rolloffFactor = 1;
-                    this._soundPanner.panningModel = "HRTF";
+                    this._soundPanner.panningModel = this._panningModel;
                 }
                 }
                 else {
                 else {
                     this._soundPanner.distanceModel = this.distanceModel;
                     this._soundPanner.distanceModel = this.distanceModel;
                     this._soundPanner.maxDistance = this.maxDistance;
                     this._soundPanner.maxDistance = this.maxDistance;
                     this._soundPanner.refDistance = this.refDistance;
                     this._soundPanner.refDistance = this.refDistance;
                     this._soundPanner.rolloffFactor = this.rolloffFactor;
                     this._soundPanner.rolloffFactor = this.rolloffFactor;
-                    this._soundPanner.panningModel = this.panningModel;
+                    this._soundPanner.panningModel = this._panningModel;
                 }
                 }
                 this._soundPanner.connect(this._ouputAudioNode);
                 this._soundPanner.connect(this._ouputAudioNode);
                 this._inputAudioNode = this._soundPanner;
                 this._inputAudioNode = this._soundPanner;
@@ -200,16 +201,18 @@
         }
         }
 
 
         public switchPanningModelToHRTF() {
         public switchPanningModelToHRTF() {
-            this._switchPanningModel("HRTF");    
+            this._panningModel = "HRTF";
+            this._switchPanningModel();    
         }
         }
 
 
         public switchPanningModelToEqualPower() {
         public switchPanningModelToEqualPower() {
-            this._switchPanningModel("equalpower");
+            this._panningModel = "equalpower";
+            this._switchPanningModel();
         }
         }
 
 
-        private _switchPanningModel(newModel: string) {
+        private _switchPanningModel() {
             if (Engine.audioEngine.canUseWebAudio && this.spatialSound) {
             if (Engine.audioEngine.canUseWebAudio && this.spatialSound) {
-                this._soundPanner.panningModel = newModel;
+                this._soundPanner.panningModel = this._panningModel;
             }
             }
         }
         }
 
 

+ 4 - 4
Babylon/Debug/babylon.debugLayer.js

@@ -582,14 +582,14 @@ var BABYLON;
                 if (BABYLON.Engine.audioEngine.canUseWebAudio) {
                 if (BABYLON.Engine.audioEngine.canUseWebAudio) {
                     this._optionsSubsetDiv.appendChild(document.createElement("br"));
                     this._optionsSubsetDiv.appendChild(document.createElement("br"));
                     this._generateTexBox(this._optionsSubsetDiv, "<b>Audio:</b>", this.accentColor);
                     this._generateTexBox(this._optionsSubsetDiv, "<b>Audio:</b>", this.accentColor);
-                    this._generateRadio(this._optionsSubsetDiv, "Headphones", "panningModel", true, function (element) {
+                    this._generateRadio(this._optionsSubsetDiv, "Headphones", "panningModel", this._scene.headphone, function (element) {
                         if (element.checked) {
                         if (element.checked) {
-                            _this._scene.switchAudioModeForHeadphones();
+                            _this._scene.headphone = true;
                         }
                         }
                     });
                     });
-                    this._generateRadio(this._optionsSubsetDiv, "Normal Speakers", "panningModel", false, function (element) {
+                    this._generateRadio(this._optionsSubsetDiv, "Normal Speakers", "panningModel", !this._scene.headphone, function (element) {
                         if (element.checked) {
                         if (element.checked) {
-                            _this._scene.switchAudioModeForNormalSpeakers();
+                            _this._scene.headphone = false;
                         }
                         }
                     });
                     });
                     this._generateCheckBox(this._optionsSubsetDiv, "Disable audio", !this._scene.audioEnabled, function (element) {
                     this._generateCheckBox(this._optionsSubsetDiv, "Disable audio", !this._scene.audioEnabled, function (element) {

+ 4 - 4
Babylon/Debug/babylon.debugLayer.ts

@@ -674,14 +674,14 @@
                 if (Engine.audioEngine.canUseWebAudio) {
                 if (Engine.audioEngine.canUseWebAudio) {
                     this._optionsSubsetDiv.appendChild(document.createElement("br"));
                     this._optionsSubsetDiv.appendChild(document.createElement("br"));
                     this._generateTexBox(this._optionsSubsetDiv, "<b>Audio:</b>", this.accentColor);
                     this._generateTexBox(this._optionsSubsetDiv, "<b>Audio:</b>", this.accentColor);
-                    this._generateRadio(this._optionsSubsetDiv, "Headphones", "panningModel", true, (element) => {
+                    this._generateRadio(this._optionsSubsetDiv, "Headphones", "panningModel", this._scene.headphone, (element) => {
                         if (element.checked) {
                         if (element.checked) {
-                            this._scene.switchAudioModeForHeadphones();
+                            this._scene.headphone = true;
                         }
                         }
                     });
                     });
-                    this._generateRadio(this._optionsSubsetDiv, "Normal Speakers", "panningModel", false, (element) => {
+                    this._generateRadio(this._optionsSubsetDiv, "Normal Speakers", "panningModel", !this._scene.headphone, (element) => {
                         if (element.checked) {
                         if (element.checked) {
-                            this._scene.switchAudioModeForNormalSpeakers();
+                            this._scene.headphone = false;
                         }
                         }
                     });
                     });
                     this._generateCheckBox(this._optionsSubsetDiv, "Disable audio", !this._scene.audioEnabled, (element) => {
                     this._generateCheckBox(this._optionsSubsetDiv, "Disable audio", !this._scene.audioEnabled, (element) => {

+ 0 - 1
Babylon/Loading/Plugins/babylon.babylonFileLoader.js

@@ -788,7 +788,6 @@ var BABYLON;
                 rolloffFactor: parsedSound.rolloffFactor,
                 rolloffFactor: parsedSound.rolloffFactor,
                 refDistance: parsedSound.refDistance,
                 refDistance: parsedSound.refDistance,
                 distanceModel: parsedSound.distanceModel,
                 distanceModel: parsedSound.distanceModel,
-                panningModel: parsedSound.panningModel,
                 playbackRate: parsedSound.playbackRate
                 playbackRate: parsedSound.playbackRate
             };
             };
             var newSound = new BABYLON.Sound(soundName, soundUrl, scene, function () {
             var newSound = new BABYLON.Sound(soundName, soundUrl, scene, function () {

+ 0 - 1
Babylon/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -979,7 +979,6 @@
             rolloffFactor: parsedSound.rolloffFactor,
             rolloffFactor: parsedSound.rolloffFactor,
             refDistance: parsedSound.refDistance,
             refDistance: parsedSound.refDistance,
             distanceModel: parsedSound.distanceModel,
             distanceModel: parsedSound.distanceModel,
-            panningModel: parsedSound.panningModel,
             playbackRate: parsedSound.playbackRate
             playbackRate: parsedSound.playbackRate
         };
         };
 
 

+ 44 - 6
Babylon/Math/babylon.math.js

@@ -2323,7 +2323,7 @@ var BABYLON;
     BABYLON.PathCursor = PathCursor;
     BABYLON.PathCursor = PathCursor;
     var Path2 = (function () {
     var Path2 = (function () {
         function Path2(x, y) {
         function Path2(x, y) {
-            this._points = [];
+            this._points = new Array();
             this._length = 0;
             this._length = 0;
             this.closed = false;
             this.closed = false;
             this._points.push(new Vector2(x, y));
             this._points.push(new Vector2(x, y));
@@ -2409,11 +2409,11 @@ var BABYLON;
     var Path3D = (function () {
     var Path3D = (function () {
         function Path3D(path) {
         function Path3D(path) {
             this.path = path;
             this.path = path;
-            this._curve = [];
-            this._distances = [];
-            this._tangents = [];
-            this._normals = [];
-            this._binormals = [];
+            this._curve = new Array();
+            this._distances = new Array();
+            this._tangents = new Array();
+            this._normals = new Array();
+            this._binormals = new Array();
             this._curve = path.slice(); // copy array         
             this._curve = path.slice(); // copy array         
             var l = this._curve.length;
             var l = this._curve.length;
             // first and last tangents
             // first and last tangents
@@ -2490,5 +2490,43 @@ var BABYLON;
         return Path3D;
         return Path3D;
     })();
     })();
     BABYLON.Path3D = Path3D;
     BABYLON.Path3D = Path3D;
+    var Curve3 = (function () {
+        function Curve3(points) {
+            this._points = points;
+        }
+        // QuadraticBezier(origin_V3, control_V3, destination_V3 )
+        Curve3.QuadraticBezier = function (v0, v1, v2, nbPoints) {
+            nbPoints = nbPoints > 2 ? nbPoints : 3;
+            var bez = new Array();
+            var step = 1 / nbPoints;
+            var equation = function (t, val0, val1, val2) {
+                var res = (1 - t) * (1 - t) * val0 + 2 * t * (1 - t) * val1 + t * t * val2;
+                return res;
+            };
+            for (var i = 0; i <= 1; i += step) {
+                bez.push(new Vector3(equation(i, v0.x, v1.x, v2.x), equation(i, v0.y, v1.y, v2.y), equation(i, v0.z, v1.z, v2.z)));
+            }
+            return new Curve3(bez);
+        };
+        // CubicBezier(origin_V3, control1_V3, control2_V3, destination_V3)
+        Curve3.CubicBezier = function (v0, v1, v2, v3, nbPoints) {
+            nbPoints = nbPoints > 3 ? nbPoints : 4;
+            var bez = new Array();
+            var step = 1 / nbPoints;
+            var equation = function (t, val0, val1, val2, val3) {
+                var res = (1 - t) * (1 - t) * (1 - t) * val0 + 3 * t * (1 - t) * (1 - t) * val1 + 3 * t * t * (1 - t) * val2 + t * t * t * val3;
+                return res;
+            };
+            for (var i = 0; i <= 1; i += step) {
+                bez.push(new Vector3(equation(i, v0.x, v1.x, v2.x, v3.x), equation(i, v0.y, v1.y, v2.y, v3.y), equation(i, v0.z, v1.z, v2.z, v3.z)));
+            }
+            return new Curve3(bez);
+        };
+        Curve3.prototype.getPoints = function () {
+            return this._points;
+        };
+        return Curve3;
+    })();
+    BABYLON.Curve3 = Curve3;
 })(BABYLON || (BABYLON = {}));
 })(BABYLON || (BABYLON = {}));
 //# sourceMappingURL=babylon.math.js.map
 //# sourceMappingURL=babylon.math.js.map

+ 71 - 28
Babylon/Math/babylon.math.ts

@@ -2911,9 +2911,10 @@
     }
     }
 
 
     export class Path2 {
     export class Path2 {
-        private _points: Vector2[] = [];
-        private _length: number = 0;
-        closed: boolean = false;
+        private _points = new Array<Vector2>();
+        private _length = 0;
+
+        public closed = false;
 
 
         constructor(x: number, y: number) {
         constructor(x: number, y: number) {
             this._points.push(new Vector2(x, y));
             this._points.push(new Vector2(x, y));
@@ -3015,25 +3016,25 @@
     }
     }
 
 
     export class Path3D {
     export class Path3D {
-        private _curve: Vector3[] = [];
-        private _distances: number[] = [];
-        private _tangents: Vector3[] = [];
-        private _normals: Vector3[] = [];
-        private _binormals: Vector3[] = [];
+        private _curve = new Array<Vector3>();
+        private _distances = new Array<number>();
+        private _tangents = new Array<Vector3>();
+        private _normals = new Array<Vector3>();
+        private _binormals = new Array<Vector3>();
 
 
         constructor(public path: Vector3[]) {
         constructor(public path: Vector3[]) {
             this._curve = path.slice();   // copy array         
             this._curve = path.slice();   // copy array         
-            var l: number = this._curve.length;
+            var l = this._curve.length;
 
 
             // first and last tangents
             // first and last tangents
             this._tangents[0] = this._curve[1].subtract(this._curve[0]);
             this._tangents[0] = this._curve[1].subtract(this._curve[0]);
             this._tangents[0].normalize();
             this._tangents[0].normalize();
-            this._tangents[l-1] = this._curve[l-1].subtract(this._curve[l-2]);
+            this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
             this._tangents[l - 1].normalize();
             this._tangents[l - 1].normalize();
-            
+
             // normals and binormals at first point : arbitrary vector with _normalVector()
             // 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);
+            var tg0 = this._tangents[0];
+            var pp0 = this._normalVector(this._curve[0], tg0);
             this._normals[0] = pp0;
             this._normals[0] = pp0;
             this._normals[0].normalize();
             this._normals[0].normalize();
             this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
             this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
@@ -3047,21 +3048,21 @@
             var prevNorm: Vector3;    // previous normal
             var prevNorm: Vector3;    // previous normal
             var prevBinor: Vector3;   // previous binormal
             var prevBinor: Vector3;   // previous binormal
 
 
-            for(var i: number = 1; i < l; i++) {
+            for (var i = 1; i < l; i++) {
                 // tangents
                 // tangents
-                prev = this._curve[i].subtract(this._curve[i-1]);
-                if (i < l-1) {
-                    cur = this._curve[i+1].subtract(this._curve[i]);
+                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] = prev.add(cur);
-                    this._tangents[i].normalize();               
+                    this._tangents[i].normalize();
                 }
                 }
-                this._distances[i] = this._distances[i - 1] + prev.length();   
-                      
+                this._distances[i] = this._distances[i - 1] + prev.length();
+
                 // normals and binormals
                 // normals and binormals
                 // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
                 // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
                 curTang = this._tangents[i];
                 curTang = this._tangents[i];
-                prevNorm = this._normals[i-1];
-                prevBinor = this._binormals[i-1];
+                prevNorm = this._normals[i - 1];
+                prevBinor = this._binormals[i - 1];
                 this._normals[i] = Vector3.Cross(prevBinor, curTang);
                 this._normals[i] = Vector3.Cross(prevBinor, curTang);
                 this._normals[i].normalize();
                 this._normals[i].normalize();
                 this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
                 this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
@@ -3092,20 +3093,62 @@
         // private function normalVector(v0, vt) :
         // 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
         // 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 {
         private _normalVector(v0: Vector3, vt: Vector3): Vector3 {
-            var point: Vector3; 
+            var point: Vector3;
 
 
             if (vt.x !== 1) {     // search for a point in the plane
             if (vt.x !== 1) {     // search for a point in the plane
-                point = new Vector3(1, 0, 0);   
+                point = new Vector3(1, 0, 0);
             }
             }
             else if (vt.y !== 1) {
             else if (vt.y !== 1) {
-                point = new Vector3(0, 1, 0);  
+                point = new Vector3(0, 1, 0);
             }
             }
             else if (vt.z !== 1) {
             else if (vt.z !== 1) {
-                point = new Vector3(0, 0, 1);  
+                point = new Vector3(0, 0, 1);
             }
             }
             var normal0: Vector3 = Vector3.Cross(vt, point);
             var normal0: Vector3 = Vector3.Cross(vt, point);
             normal0.normalize();
             normal0.normalize();
-            return normal0;        
+            return normal0;
+        }
+    }
+
+    export class Curve3 {
+        private _points: Vector3[];
+
+        // QuadraticBezier(origin_V3, control_V3, destination_V3 )
+        public static QuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3 {
+            nbPoints = nbPoints > 2 ? nbPoints : 3;
+            var bez = new Array<Vector3>();
+            var step = 1 / nbPoints;
+            var equation = (t: number, val0: number, val1: number, val2: number) => {
+                var res = (1 - t) * (1 - t) * val0 + 2 * t * (1 - t) * val1 + t * t * val2;
+                return res;
+            }
+            for (var i = 0; i <= 1; i += step) {
+                bez.push(new Vector3(equation(i, v0.x, v1.x, v2.x), equation(i, v0.y, v1.y, v2.y), equation(i, v0.z, v1.z, v2.z)));
+            }
+            return new Curve3(bez);
+        }
+
+        // CubicBezier(origin_V3, control1_V3, control2_V3, destination_V3)
+        public static CubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3 {
+            nbPoints = nbPoints > 3 ? nbPoints : 4;
+            var bez = new Array<Vector3>();
+            var step = 1 / nbPoints;
+            var equation = (t: number, val0: number, val1: number, val2: number, val3: number) => {
+                var res = (1 - t) * (1 - t) * (1 - t) * val0 + 3 * t * (1 - t) * (1 - t) * val1 + 3 * t * t * (1 - t) * val2 + t * t * t * val3;
+                return res;
+            }
+            for (var i = 0; i <= 1; i += step) {
+                bez.push(new Vector3(equation(i, v0.x, v1.x, v2.x, v3.x), equation(i, v0.y, v1.y, v2.y, v3.y), equation(i, v0.z, v1.z, v2.z, v3.z)));
+            }
+            return new Curve3(bez);
+        }
+
+        constructor(points: Vector3[]) {
+            this._points = points;
+        }
+
+        public getPoints() {
+            return this._points;
         }
         }
     }
     }
-}
+}

+ 6 - 34
Babylon/Mesh/babylon.mesh.js

@@ -959,42 +959,14 @@ var BABYLON;
             var extruded = Mesh._ExtrudeShapeGeneric(name, shape, path, scale, rotation, null, null, false, false, false, scene, updatable, sideOrientation);
             var extruded = Mesh._ExtrudeShapeGeneric(name, shape, path, scale, rotation, null, null, false, false, false, scene, updatable, sideOrientation);
             return extruded;
             return extruded;
         };
         };
-        Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotateFunction, ribbonCloseArray, ribbonClosePath, scene, updatable, sideOrientation) {
+        Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, scene, updatable, sideOrientation) {
             if (sideOrientation === void 0) { sideOrientation = Mesh.DEFAULTSIDE; }
             if (sideOrientation === void 0) { sideOrientation = Mesh.DEFAULTSIDE; }
-            ribbonCloseArray = ribbonCloseArray || false;
-            ribbonClosePath = ribbonClosePath || false;
-            var extrudedCustom = Mesh._ExtrudeShapeGeneric(name, shape, path, null, null, scaleFunction, rotateFunction, ribbonCloseArray, ribbonClosePath, true, scene, updatable, sideOrientation);
+            var extrudedCustom = Mesh._ExtrudeShapeGeneric(name, shape, path, null, null, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, true, scene, updatable, sideOrientation);
             return extrudedCustom;
             return extrudedCustom;
         };
         };
-        Mesh._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, custom, scene, updtbl, side) {
+        Mesh._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotationFunction, rbCA, rbCP, custom, scene, updtbl, side) {
             var path3D = new BABYLON.Path3D(curve);
             var path3D = new BABYLON.Path3D(curve);
-            var tangents = path3D.getTangents();
-            var normals = path3D.getNormals();
-            var binormals = path3D.getBinormals();
-            var distances = path3D.getDistances();
-            var shapePaths = new Array();
-            var angle = 0;
-            var returnScale = function (i, distance) {
-                return scale;
-            };
-            var returnRotation = function (i, distance) {
-                return rotation;
-            };
-            var rotate = custom ? rotateFunction : returnRotation;
-            var scl = custom ? scaleFunction : returnScale;
-            for (var i = 0; i < curve.length; i++) {
-                var shapePath = new Array();
-                var angleStep = rotate(i, distances[i]);
-                var scaleRatio = scl(i, distances[i]);
-                var rotationMatrix = BABYLON.Matrix.RotationAxis(tangents[i], angle);
-                for (var p = 0; p < shape.length; p++) {
-                    var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
-                    var rotated = BABYLON.Vector3.TransformCoordinates(planed, rotationMatrix).scaleInPlace(scaleRatio).add(curve[i]);
-                    shapePath.push(rotated);
-                }
-                shapePaths.push(shapePath);
-                angle += angleStep;
-            }
+            var shapePaths = [];
             var extrudedGeneric = Mesh.CreateRibbon(name, shapePaths, rbCA, rbCP, 0, scene, updtbl, side);
             var extrudedGeneric = Mesh.CreateRibbon(name, shapePaths, rbCA, rbCP, 0, scene, updtbl, side);
             return extrudedGeneric;
             return extrudedGeneric;
         };
         };
@@ -1059,7 +1031,7 @@ var BABYLON;
             var step = pi2 / tesselation;
             var step = pi2 / tesselation;
             var returnRadius = function (i, distance) { return radius; };
             var returnRadius = function (i, distance) { return radius; };
             var radiusFunctionFinal = radiusFunction || returnRadius;
             var radiusFunctionFinal = radiusFunction || returnRadius;
-            var circlePaths = [];
+            var circlePaths = new Array();
             var circlePath;
             var circlePath;
             var rad;
             var rad;
             var normal;
             var normal;
@@ -1067,7 +1039,7 @@ var BABYLON;
             var rotationMatrix;
             var rotationMatrix;
             for (var i = 0; i < path.length; i++) {
             for (var i = 0; i < path.length; i++) {
                 rad = radiusFunctionFinal(i, distances[i]); // current radius
                 rad = radiusFunctionFinal(i, distances[i]); // current radius
-                circlePath = []; // current circle array
+                circlePath = Array(); // current circle array
                 normal = normals[i]; // current normal  
                 normal = normals[i]; // current normal  
                 for (var ang = 0; ang < pi2; ang += step) {
                 for (var ang = 0; ang < pi2; ang += step) {
                     rotationMatrix = BABYLON.Matrix.RotationAxis(tangents[i], ang);
                     rotationMatrix = BABYLON.Matrix.RotationAxis(tangents[i], ang);

+ 17 - 41
Babylon/Mesh/babylon.mesh.ts

@@ -1175,42 +1175,18 @@
             return extruded;
             return extruded;
         }
         }
 
 
-        public static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction, rotateFunction, ribbonCloseArray: boolean, ribbonClosePath: boolean, scene: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE): Mesh {
-            ribbonCloseArray = ribbonCloseArray || false;
-            ribbonClosePath = ribbonClosePath || false;
-            var extrudedCustom = Mesh._ExtrudeShapeGeneric(name, shape, path, null, null, scaleFunction, rotateFunction, ribbonCloseArray, ribbonClosePath, true, scene, updatable, sideOrientation);
+        public static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction, rotationFunction, ribbonCloseArray: boolean, ribbonClosePath: boolean, scene: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE): Mesh {
+            var extrudedCustom = Mesh._ExtrudeShapeGeneric(name, shape, path, null, null, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, true, scene, updatable, sideOrientation);
             return extrudedCustom;
             return extrudedCustom;
         }
         }
 
 
-        private static _ExtrudeShapeGeneric(name: string, shape: Vector3[], curve: Vector3[], scale: number, rotation: number, scaleFunction: { (i: number, distance: number): number; }, rotateFunction: { (i: number, distance: number): number; }, rbCA: boolean, rbCP: boolean, custom: boolean, scene: Scene, updtbl: boolean, side: number): Mesh {
+        private static _ExtrudeShapeGeneric(name: string, shape: Vector3[], curve: Vector3[], scale: number, rotation: number, scaleFunction, rotationFunction, rbCA: boolean, rbCP: boolean, custom: boolean, scene: Scene, updtbl: boolean, side: number): Mesh {
             var path3D = new Path3D(curve);
             var path3D = new Path3D(curve);
-            var tangents = path3D.getTangents();
-            var normals = path3D.getNormals();
-            var binormals = path3D.getBinormals();
-            var distances = path3D.getDistances();
-            var shapePaths = new Array<Array<Vector3>>();
-            var angle = 0;
-            var returnScale: { (i: number, distance: number): number; } = function (i, distance) { return scale; };
-            var returnRotation: { (i: number, distance: number): number; } = function (i, distance) { return rotation; };
-            var rotate: { (i: number, distance: number): number; } = custom ? rotateFunction : returnRotation;
-            var scl: { (i: number, distance: number): number; } = custom ? scaleFunction : returnScale;
-
-            for (var i: number = 0; i < curve.length; i++) {
-                var shapePath = new Array<Vector3>();
-                var angleStep = rotate(i, distances[i]);
-                var scaleRatio = scl(i, distances[i]);
-                var rotationMatrix = Matrix.RotationAxis(tangents[i], angle);
-                for (var p = 0; p < shape.length; p++) {
-                    var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
-                    var rotated = Vector3.TransformCoordinates(planed, rotationMatrix).scaleInPlace(scaleRatio).add(curve[i]);
-                    shapePath.push(rotated);
-                }
-                shapePaths.push(shapePath);
-                angle += angleStep;
-            }
 
 
+            var shapePaths: Vector3[][] = [];
             var extrudedGeneric = Mesh.CreateRibbon(name, shapePaths, rbCA, rbCP, 0, scene, updtbl, side);
             var extrudedGeneric = Mesh.CreateRibbon(name, shapePaths, rbCA, rbCP, 0, scene, updtbl, side);
             return extrudedGeneric;
             return extrudedGeneric;
+
         }
         }
 
 
         // Plane & ground
         // Plane & ground
@@ -1285,26 +1261,26 @@
         }
         }
 
 
         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 {
         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 path3D: Path3D = new 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 path3D = new Path3D(path);
+            var tangents = path3D.getTangents();
+            var normals = path3D.getNormals();
+            var distances = path3D.getDistances();
+            var pi2 = Math.PI * 2;
+            var step = pi2 / tesselation;
             var returnRadius: { (i: number, distance: number): number; } = (i, distance) => radius;
             var returnRadius: { (i: number, distance: number): number; } = (i, distance) => radius;
             var radiusFunctionFinal: { (i: number, distance: number): number; } = radiusFunction || returnRadius;
             var radiusFunctionFinal: { (i: number, distance: number): number; } = radiusFunction || returnRadius;
 
 
-            var circlePaths: Vector3[][] = [];
+            var circlePaths = new Array<Array<Vector3>>();
             var circlePath: Vector3[];
             var circlePath: Vector3[];
             var rad: number;
             var rad: number;
             var normal: Vector3;
             var normal: Vector3;
             var rotated: Vector3;
             var rotated: Vector3;
             var rotationMatrix: Matrix;
             var rotationMatrix: Matrix;
-            for (var i: number = 0; i < path.length; i++) {
-                rad = radiusFunctionFinal(i, distances[i]);      // current radius
-                circlePath = [];                            // current circle array
+            for (var i = 0; i < path.length; i++) {
+                rad = radiusFunctionFinal(i, distances[i]); // current radius
+                circlePath = Array<Vector3>();              // current circle array
                 normal = normals[i];                        // current normal  
                 normal = normals[i];                        // current normal  
-                for (var ang: number = 0; ang < pi2; ang += step) {
+                for (var ang = 0; ang < pi2; ang += step) {
                     rotationMatrix = Matrix.RotationAxis(tangents[i], ang);
                     rotationMatrix = Matrix.RotationAxis(tangents[i], ang);
                     rotated = Vector3.TransformCoordinates(normal, rotationMatrix).scaleInPlace(rad).add(path[i]);
                     rotated = Vector3.TransformCoordinates(normal, rotationMatrix).scaleInPlace(rad).add(path[i]);
                     circlePath.push(rotated);
                     circlePath.push(rotated);
@@ -1390,4 +1366,4 @@
             return newMesh;
             return newMesh;
         }
         }
     }
     }
-} 
+} 

+ 4 - 3
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.js

@@ -73,7 +73,7 @@ var BABYLON;
             if (material) {
             if (material) {
                 if (material.needAlphaTesting() || mesh === this.mesh)
                 if (material.needAlphaTesting() || mesh === this.mesh)
                     defines.push("#define ALPHATEST");
                     defines.push("#define ALPHATEST");
-                if (material.opacityTexture !== undefined)
+                if (material.opacityTexture !== undefined && mesh === this.mesh)
                     defines.push("#define OPACITY");
                     defines.push("#define OPACITY");
                 if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
                 if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
                     attribs.push(BABYLON.VertexBuffer.UVKind);
                     attribs.push(BABYLON.VertexBuffer.UVKind);
@@ -103,7 +103,7 @@ var BABYLON;
             var join = defines.join("\n");
             var join = defines.join("\n");
             if (this._cachedDefines !== join) {
             if (this._cachedDefines !== join) {
                 this._cachedDefines = join;
                 this._cachedDefines = join;
-                this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "far"], ["diffuseSampler", "opacitySampler"], join);
+                this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler", "opacitySampler"], join);
             }
             }
             return this._volumetricLightScatteringPass.isReady();
             return this._volumetricLightScatteringPass.isReady();
         };
         };
@@ -180,8 +180,9 @@ var BABYLON;
                     if (material && (mesh === _this.mesh || material.needAlphaTesting() || material.opacityTexture !== undefined)) {
                     if (material && (mesh === _this.mesh || material.needAlphaTesting() || material.opacityTexture !== undefined)) {
                         var alphaTexture = material.getAlphaTestTexture();
                         var alphaTexture = material.getAlphaTestTexture();
                         _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
                         _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
-                        if (_this.mesh.material && alphaTexture)
+                        if (alphaTexture) {
                             _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
                             _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
+                        }
                         if (material.opacityTexture !== undefined)
                         if (material.opacityTexture !== undefined)
                             _this._volumetricLightScatteringPass.setTexture("opacitySampler", material.opacityTexture);
                             _this._volumetricLightScatteringPass.setTexture("opacitySampler", material.opacityTexture);
                     }
                     }

+ 5 - 3
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.ts

@@ -87,7 +87,7 @@
                 if (material.needAlphaTesting() || mesh === this.mesh)
                 if (material.needAlphaTesting() || mesh === this.mesh)
                     defines.push("#define ALPHATEST");
                     defines.push("#define ALPHATEST");
 
 
-                if (material.opacityTexture !== undefined)
+                if (material.opacityTexture !== undefined && mesh === this.mesh)
                     defines.push("#define OPACITY");
                     defines.push("#define OPACITY");
 
 
                 if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
                 if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
@@ -124,7 +124,7 @@
                 this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect(
                 this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect(
                     { vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" },
                     { vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" },
                     attribs,
                     attribs,
-                    ["world", "mBones", "viewProjection", "diffuseMatrix", "far"],
+                    ["world", "mBones", "viewProjection", "diffuseMatrix"],
                     ["diffuseSampler", "opacitySampler"], join);
                     ["diffuseSampler", "opacitySampler"], join);
             }
             }
 
 
@@ -220,8 +220,10 @@
                     if (material && (mesh === this.mesh || material.needAlphaTesting() || material.opacityTexture !== undefined)) {
                     if (material && (mesh === this.mesh || material.needAlphaTesting() || material.opacityTexture !== undefined)) {
                         var alphaTexture = material.getAlphaTestTexture();
                         var alphaTexture = material.getAlphaTestTexture();
                         this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
                         this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
-                        if (this.mesh.material && alphaTexture)
+
+                        if (alphaTexture) {
                             this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
                             this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
+                        }
 
 
                         if (material.opacityTexture !== undefined)
                         if (material.opacityTexture !== undefined)
                             this._volumetricLightScatteringPass.setTexture("opacitySampler", material.opacityTexture);
                             this._volumetricLightScatteringPass.setTexture("opacitySampler", material.opacityTexture);

+ 2 - 2
Babylon/Shaders/depth.vertex.fx

@@ -24,7 +24,7 @@ uniform mat4 viewProjection;
 uniform mat4 mBones[BonesPerMesh];
 uniform mat4 mBones[BonesPerMesh];
 #endif
 #endif
 
 
-#ifdef ALPHATEST
+#if defined(ALPHATEST) || defined(BASIC_RENDER)
 varying vec2 vUV;
 varying vec2 vUV;
 uniform mat4 diffuseMatrix;
 uniform mat4 diffuseMatrix;
 #ifdef UV1
 #ifdef UV1
@@ -54,7 +54,7 @@ void main(void)
 	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 #endif
 #endif
 
 
-#ifdef ALPHATEST
+#if defined(ALPHATEST) || defined(BASIC_RENDER)
 #ifdef UV1
 #ifdef UV1
 	vUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
 	vUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
 #endif
 #endif

+ 5 - 5
Babylon/Shaders/volumetricLightScatteringPass.fragment.fx

@@ -26,11 +26,11 @@ void main(void)
 #endif
 #endif
 
 
 #ifdef BASIC_RENDER
 #ifdef BASIC_RENDER
-#ifdef OPACITY
-	gl_FragColor = diffuseColor * texture2D(opacitySampler, vUV);
-#else
-	gl_FragColor = diffuseColor;
-#endif
+	#ifdef OPACITY
+		gl_FragColor = diffuseColor * texture2D(opacitySampler, vUV);
+	#else
+		gl_FragColor = diffuseColor;
+	#endif
 #else
 #else
 	gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
 	gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
 #endif
 #endif

+ 30 - 13
Babylon/babylon.scene.js

@@ -102,6 +102,7 @@ var BABYLON;
             this._proceduralTextures = new Array();
             this._proceduralTextures = new Array();
             this.soundTracks = new Array();
             this.soundTracks = new Array();
             this._audioEnabled = true;
             this._audioEnabled = true;
+            this._headphone = false;
             this._totalVertices = 0;
             this._totalVertices = 0;
             this._activeVertices = 0;
             this._activeVertices = 0;
             this._activeParticles = 0;
             this._activeParticles = 0;
@@ -1195,6 +1196,7 @@ var BABYLON;
             }
             }
         };
         };
         Object.defineProperty(Scene.prototype, "audioEnabled", {
         Object.defineProperty(Scene.prototype, "audioEnabled", {
+            // Audio
             get: function () {
             get: function () {
                 return this._audioEnabled;
                 return this._audioEnabled;
             },
             },
@@ -1234,6 +1236,34 @@ var BABYLON;
                 }
                 }
             }
             }
         };
         };
+        Object.defineProperty(Scene.prototype, "headphone", {
+            get: function () {
+                return this._headphone;
+            },
+            set: function (value) {
+                this._headphone = value;
+                if (this._headphone) {
+                    this._switchAudioModeForHeadphones();
+                }
+                else {
+                    this._switchAudioModeForNormalSpeakers();
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Scene.prototype._switchAudioModeForHeadphones = function () {
+            this.mainSoundTrack.switchPanningModelToHRTF();
+            for (var i = 0; i < this.soundTracks.length; i++) {
+                this.soundTracks[i].switchPanningModelToHRTF();
+            }
+        };
+        Scene.prototype._switchAudioModeForNormalSpeakers = function () {
+            this.mainSoundTrack.switchPanningModelToEqualPower();
+            for (var i = 0; i < this.soundTracks.length; i++) {
+                this.soundTracks[i].switchPanningModelToEqualPower();
+            }
+        };
         Scene.prototype.enableDepthRenderer = function () {
         Scene.prototype.enableDepthRenderer = function () {
             if (this._depthRenderer) {
             if (this._depthRenderer) {
                 return this._depthRenderer;
                 return this._depthRenderer;
@@ -1565,19 +1595,6 @@ var BABYLON;
         Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
         Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
             return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
             return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
         };
         };
-        // Audio
-        Scene.prototype.switchAudioModeForHeadphones = function () {
-            this.mainSoundTrack.switchPanningModelToHRTF();
-            for (var i = 0; i < this.soundTracks.length; i++) {
-                this.soundTracks[i].switchPanningModelToHRTF();
-            }
-        };
-        Scene.prototype.switchAudioModeForNormalSpeakers = function () {
-            this.mainSoundTrack.switchPanningModelToEqualPower();
-            for (var i = 0; i < this.soundTracks.length; i++) {
-                this.soundTracks[i].switchPanningModelToEqualPower();
-            }
-        };
         // Statics
         // Statics
         Scene._FOGMODE_NONE = 0;
         Scene._FOGMODE_NONE = 0;
         Scene._FOGMODE_EXP = 1;
         Scene._FOGMODE_EXP = 1;

+ 32 - 17
Babylon/babylon.scene.ts

@@ -191,6 +191,7 @@
         public mainSoundTrack: SoundTrack;
         public mainSoundTrack: SoundTrack;
         public soundTracks = new Array<SoundTrack>();
         public soundTracks = new Array<SoundTrack>();
         private _audioEnabled = true;
         private _audioEnabled = true;
+        private _headphone = false;
 
 
         //Simplification Queue
         //Simplification Queue
         public simplificationQueue: SimplificationQueue;
         public simplificationQueue: SimplificationQueue;
@@ -1528,6 +1529,7 @@
             }
             }
         }
         }
 
 
+        // Audio
         public get audioEnabled(): boolean {
         public get audioEnabled(): boolean {
             return this._audioEnabled;
             return this._audioEnabled;
         }
         }
@@ -1568,6 +1570,36 @@
             }
             }
         }
         }
 
 
+        public get headphone(): boolean {
+            return this._headphone;
+        }
+
+        public set headphone(value: boolean) {
+            this._headphone = value;
+            if (this._headphone) {
+                this._switchAudioModeForHeadphones();
+            }
+            else {
+                this._switchAudioModeForNormalSpeakers();
+            }
+        }
+
+        private _switchAudioModeForHeadphones() {
+            this.mainSoundTrack.switchPanningModelToHRTF();
+
+            for (var i = 0; i < this.soundTracks.length; i++) {
+                this.soundTracks[i].switchPanningModelToHRTF();
+            }
+        }
+
+        private _switchAudioModeForNormalSpeakers() {
+            this.mainSoundTrack.switchPanningModelToEqualPower();
+
+            for (var i = 0; i < this.soundTracks.length; i++) {
+                this.soundTracks[i].switchPanningModelToEqualPower();
+            }
+        }
+
         public enableDepthRenderer(): DepthRenderer {
         public enableDepthRenderer(): DepthRenderer {
             if (this._depthRenderer) {
             if (this._depthRenderer) {
                 return this._depthRenderer;
                 return this._depthRenderer;
@@ -1998,22 +2030,5 @@
         public getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[] {
         public getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[] {
             return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
             return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
         }
         }
-
-        // Audio
-        public switchAudioModeForHeadphones() {
-            this.mainSoundTrack.switchPanningModelToHRTF();
-
-            for (var i = 0; i < this.soundTracks.length; i++) {
-                this.soundTracks[i].switchPanningModelToHRTF();
-            }
-        }
-
-        public switchAudioModeForNormalSpeakers() {
-            this.mainSoundTrack.switchPanningModelToEqualPower();
-
-            for (var i = 0; i < this.soundTracks.length; i++) {
-                this.soundTracks[i].switchPanningModelToEqualPower();
-            }
-        }
     }
     }
 } 
 } 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 102 - 72
babylon.2.1-alpha.debug.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 13 - 13
babylon.2.1-alpha.js