فهرست منبع

Sprites and particles scheduler updated to be resolved before transparent objects

David catuhe 9 سال پیش
والد
کامیت
b21ed62c24

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 12 - 12
dist/preview release/babylon.core.js


+ 441 - 425
dist/preview release/babylon.d.ts

@@ -1196,6 +1196,172 @@ declare module BABYLON {
 }
 
 declare module BABYLON {
+    class Analyser {
+        SMOOTHING: number;
+        FFT_SIZE: number;
+        BARGRAPHAMPLITUDE: number;
+        DEBUGCANVASPOS: {
+            x: number;
+            y: number;
+        };
+        DEBUGCANVASSIZE: {
+            width: number;
+            height: number;
+        };
+        private _byteFreqs;
+        private _byteTime;
+        private _floatFreqs;
+        private _webAudioAnalyser;
+        private _debugCanvas;
+        private _debugCanvasContext;
+        private _scene;
+        private _registerFunc;
+        private _audioEngine;
+        constructor(scene: Scene);
+        getFrequencyBinCount(): number;
+        getByteFrequencyData(): Uint8Array;
+        getByteTimeDomainData(): Uint8Array;
+        getFloatFrequencyData(): Uint8Array;
+        drawDebugCanvas(): void;
+        stopDebugCanvas(): void;
+        connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
+        dispose(): void;
+    }
+}
+
+declare module BABYLON {
+    class AudioEngine {
+        private _audioContext;
+        private _audioContextInitialized;
+        canUseWebAudio: boolean;
+        masterGain: GainNode;
+        private _connectedAnalyser;
+        WarnedWebAudioUnsupported: boolean;
+        audioContext: AudioContext;
+        constructor();
+        private _initializeAudioContext();
+        dispose(): void;
+        getGlobalVolume(): number;
+        setGlobalVolume(newVolume: number): void;
+        connectToAnalyser(analyser: Analyser): void;
+    }
+}
+
+declare module BABYLON {
+    class Sound {
+        name: string;
+        autoplay: boolean;
+        loop: boolean;
+        useCustomAttenuation: boolean;
+        soundTrackId: number;
+        spatialSound: boolean;
+        refDistance: number;
+        rolloffFactor: number;
+        maxDistance: number;
+        distanceModel: string;
+        private _panningModel;
+        onended: () => any;
+        private _playbackRate;
+        private _startTime;
+        private _startOffset;
+        private _position;
+        private _localDirection;
+        private _volume;
+        private _isLoaded;
+        private _isReadyToPlay;
+        isPlaying: boolean;
+        isPaused: boolean;
+        private _isDirectional;
+        private _readyToPlayCallback;
+        private _audioBuffer;
+        private _soundSource;
+        private _soundPanner;
+        private _soundGain;
+        private _inputAudioNode;
+        private _ouputAudioNode;
+        private _coneInnerAngle;
+        private _coneOuterAngle;
+        private _coneOuterGain;
+        private _scene;
+        private _connectedMesh;
+        private _customAttenuationFunction;
+        private _registerFunc;
+        private _isOutputConnected;
+        /**
+        * Create a sound and attach it to a scene
+        * @param name Name of your sound
+        * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
+        * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
+        * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel
+        */
+        constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: () => void, options?: any);
+        dispose(): void;
+        private _soundLoaded(audioData);
+        setAudioBuffer(audioBuffer: AudioBuffer): void;
+        updateOptions(options: any): void;
+        private _createSpatialParameters();
+        private _updateSpatialParameters();
+        switchPanningModelToHRTF(): void;
+        switchPanningModelToEqualPower(): void;
+        private _switchPanningModel();
+        connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
+        /**
+        * Transform this sound into a directional source
+        * @param coneInnerAngle Size of the inner cone in degree
+        * @param coneOuterAngle Size of the outer cone in degree
+        * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
+        */
+        setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
+        setPosition(newPosition: Vector3): void;
+        setLocalDirectionToMesh(newLocalDirection: Vector3): void;
+        private _updateDirection();
+        updateDistanceFromListener(): void;
+        setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
+        /**
+        * Play the sound
+        * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
+        */
+        play(time?: number): void;
+        private _onended();
+        /**
+        * Stop the sound
+        * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
+        */
+        stop(time?: number): void;
+        pause(): void;
+        setVolume(newVolume: number, time?: number): void;
+        setPlaybackRate(newPlaybackRate: number): void;
+        getVolume(): number;
+        attachToMesh(meshToConnectTo: AbstractMesh): void;
+        private _onRegisterAfterWorldMatrixUpdate(connectedMesh);
+    }
+}
+
+declare module BABYLON {
+    class SoundTrack {
+        private _outputAudioNode;
+        private _inputAudioNode;
+        private _trackConvolver;
+        private _scene;
+        id: number;
+        soundCollection: Array<Sound>;
+        private _isMainTrack;
+        private _connectedAnalyser;
+        private _options;
+        private _isInitialized;
+        constructor(scene: Scene, options?: any);
+        private _initializeSoundTrackAudioGraph();
+        dispose(): void;
+        AddSound(sound: Sound): void;
+        RemoveSound(sound: Sound): void;
+        setVolume(newVolume: number): void;
+        switchPanningModelToHRTF(): void;
+        switchPanningModelToEqualPower(): void;
+        connectToAnalyser(analyser: Analyser): void;
+    }
+}
+
+declare module BABYLON {
     class Animatable {
         target: any;
         fromFrame: number;
@@ -1359,168 +1525,52 @@ declare module BABYLON {
 }
 
 declare module BABYLON {
-    class Analyser {
-        SMOOTHING: number;
-        FFT_SIZE: number;
-        BARGRAPHAMPLITUDE: number;
-        DEBUGCANVASPOS: {
-            x: number;
-            y: number;
-        };
-        DEBUGCANVASSIZE: {
-            width: number;
-            height: number;
-        };
-        private _byteFreqs;
-        private _byteTime;
-        private _floatFreqs;
-        private _webAudioAnalyser;
-        private _debugCanvas;
-        private _debugCanvasContext;
-        private _scene;
-        private _registerFunc;
-        private _audioEngine;
-        constructor(scene: Scene);
-        getFrequencyBinCount(): number;
-        getByteFrequencyData(): Uint8Array;
-        getByteTimeDomainData(): Uint8Array;
-        getFloatFrequencyData(): Uint8Array;
-        drawDebugCanvas(): void;
-        stopDebugCanvas(): void;
-        connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
-        dispose(): void;
-    }
-}
-
-declare module BABYLON {
-    class AudioEngine {
-        private _audioContext;
-        private _audioContextInitialized;
-        canUseWebAudio: boolean;
-        masterGain: GainNode;
-        private _connectedAnalyser;
-        WarnedWebAudioUnsupported: boolean;
-        audioContext: AudioContext;
-        constructor();
-        private _initializeAudioContext();
-        dispose(): void;
-        getGlobalVolume(): number;
-        setGlobalVolume(newVolume: number): void;
-        connectToAnalyser(analyser: Analyser): void;
-    }
-}
-
-declare module BABYLON {
-    class Sound {
+    class Bone extends Node {
         name: string;
-        autoplay: boolean;
-        loop: boolean;
-        useCustomAttenuation: boolean;
-        soundTrackId: number;
-        spatialSound: boolean;
-        refDistance: number;
-        rolloffFactor: number;
-        maxDistance: number;
-        distanceModel: string;
-        private _panningModel;
-        onended: () => any;
-        private _playbackRate;
-        private _startTime;
-        private _startOffset;
-        private _position;
-        private _localDirection;
-        private _volume;
-        private _isLoaded;
-        private _isReadyToPlay;
-        isPlaying: boolean;
-        isPaused: boolean;
-        private _isDirectional;
-        private _readyToPlayCallback;
-        private _audioBuffer;
-        private _soundSource;
-        private _soundPanner;
-        private _soundGain;
-        private _inputAudioNode;
-        private _ouputAudioNode;
-        private _coneInnerAngle;
-        private _coneOuterAngle;
-        private _coneOuterGain;
-        private _scene;
-        private _connectedMesh;
-        private _customAttenuationFunction;
-        private _registerFunc;
-        private _isOutputConnected;
-        /**
-        * Create a sound and attach it to a scene
-        * @param name Name of your sound
-        * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
-        * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
-        * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel
-        */
-        constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: () => void, options?: any);
-        dispose(): void;
-        private _soundLoaded(audioData);
-        setAudioBuffer(audioBuffer: AudioBuffer): void;
-        updateOptions(options: any): void;
-        private _createSpatialParameters();
-        private _updateSpatialParameters();
-        switchPanningModelToHRTF(): void;
-        switchPanningModelToEqualPower(): void;
-        private _switchPanningModel();
-        connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
-        /**
-        * Transform this sound into a directional source
-        * @param coneInnerAngle Size of the inner cone in degree
-        * @param coneOuterAngle Size of the outer cone in degree
-        * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
-        */
-        setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
-        setPosition(newPosition: Vector3): void;
-        setLocalDirectionToMesh(newLocalDirection: Vector3): void;
-        private _updateDirection();
-        updateDistanceFromListener(): void;
-        setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
-        /**
-        * Play the sound
-        * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
-        */
-        play(time?: number): void;
-        private _onended();
-        /**
-        * Stop the sound
-        * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
-        */
-        stop(time?: number): void;
-        pause(): void;
-        setVolume(newVolume: number, time?: number): void;
-        setPlaybackRate(newPlaybackRate: number): void;
-        getVolume(): number;
-        attachToMesh(meshToConnectTo: AbstractMesh): void;
-        private _onRegisterAfterWorldMatrixUpdate(connectedMesh);
+        children: Bone[];
+        animations: Animation[];
+        private _skeleton;
+        private _matrix;
+        private _baseMatrix;
+        private _worldTransform;
+        private _absoluteTransform;
+        private _invertedAbsoluteTransform;
+        private _parent;
+        constructor(name: string, skeleton: Skeleton, parentBone: Bone, matrix: Matrix);
+        getParent(): Bone;
+        getLocalMatrix(): Matrix;
+        getBaseMatrix(): Matrix;
+        getWorldMatrix(): Matrix;
+        getInvertedAbsoluteTransform(): Matrix;
+        getAbsoluteMatrix(): Matrix;
+        updateMatrix(matrix: Matrix): void;
+        private _updateDifferenceMatrix();
+        markAsDirty(): void;
     }
 }
 
 declare module BABYLON {
-    class SoundTrack {
-        private _outputAudioNode;
-        private _inputAudioNode;
-        private _trackConvolver;
+    class Skeleton {
+        name: string;
+        id: string;
+        bones: Bone[];
         private _scene;
-        id: number;
-        soundCollection: Array<Sound>;
-        private _isMainTrack;
-        private _connectedAnalyser;
-        private _options;
-        private _isInitialized;
-        constructor(scene: Scene, options?: any);
-        private _initializeSoundTrackAudioGraph();
-        dispose(): void;
-        AddSound(sound: Sound): void;
-        RemoveSound(sound: Sound): void;
-        setVolume(newVolume: number): void;
-        switchPanningModelToHRTF(): void;
-        switchPanningModelToEqualPower(): void;
-        connectToAnalyser(analyser: Analyser): void;
+        private _isDirty;
+        private _transformMatrices;
+        private _animatables;
+        private _identity;
+        private _ranges;
+        constructor(name: string, id: string, scene: Scene);
+        getTransformMatrices(): Float32Array;
+        getScene(): Scene;
+        createAnimationRange(name: string, from: number, to: number): void;
+        deleteAnimationRange(name: string): void;
+        getAnimationRange(name: string): AnimationRange;
+        beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): void;
+        _markAsDirty(): void;
+        prepare(): void;
+        getAnimatables(): IAnimatable[];
+        clone(name: string, id: string): Skeleton;
     }
 }
 
@@ -1916,56 +1966,6 @@ declare module BABYLON {
 }
 
 declare module BABYLON {
-    class Bone extends Node {
-        name: string;
-        children: Bone[];
-        animations: Animation[];
-        private _skeleton;
-        private _matrix;
-        private _baseMatrix;
-        private _worldTransform;
-        private _absoluteTransform;
-        private _invertedAbsoluteTransform;
-        private _parent;
-        constructor(name: string, skeleton: Skeleton, parentBone: Bone, matrix: Matrix);
-        getParent(): Bone;
-        getLocalMatrix(): Matrix;
-        getBaseMatrix(): Matrix;
-        getWorldMatrix(): Matrix;
-        getInvertedAbsoluteTransform(): Matrix;
-        getAbsoluteMatrix(): Matrix;
-        updateMatrix(matrix: Matrix): void;
-        private _updateDifferenceMatrix();
-        markAsDirty(): void;
-    }
-}
-
-declare module BABYLON {
-    class Skeleton {
-        name: string;
-        id: string;
-        bones: Bone[];
-        private _scene;
-        private _isDirty;
-        private _transformMatrices;
-        private _animatables;
-        private _identity;
-        private _ranges;
-        constructor(name: string, id: string, scene: Scene);
-        getTransformMatrices(): Float32Array;
-        getScene(): Scene;
-        createAnimationRange(name: string, from: number, to: number): void;
-        deleteAnimationRange(name: string): void;
-        getAnimationRange(name: string): AnimationRange;
-        beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): void;
-        _markAsDirty(): void;
-        prepare(): void;
-        getAnimatables(): IAnimatable[];
-        clone(name: string, id: string): Skeleton;
-    }
-}
-
-declare module BABYLON {
     class Collider {
         radius: Vector3;
         retry: number;
@@ -2568,6 +2568,7 @@ declare module BABYLON {
         _bindTexture(channel: string, texture: WebGLTexture): void;
         setTexture(channel: string, texture: BaseTexture): void;
         setTextureFromPostProcess(channel: string, postProcess: PostProcess): void;
+        _cacheMatrix(uniformName: any, matrix: any): void;
         _cacheFloat2(uniformName: string, x: number, y: number): void;
         _cacheFloat3(uniformName: string, x: number, y: number, z: number): void;
         _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
@@ -2778,6 +2779,7 @@ declare module BABYLON {
         needAlphaTesting(): boolean;
         private _shouldUseAlphaFromDiffuseTexture();
         getAlphaTestTexture(): BaseTexture;
+        private _checkCache(scene, mesh?);
         isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
         unbind(): void;
         bindOnlyWorldMatrix(world: Matrix): void;
@@ -3324,6 +3326,203 @@ declare module BABYLON {
 }
 
 declare module BABYLON {
+    class Particle {
+        position: Vector3;
+        direction: Vector3;
+        color: Color4;
+        colorStep: Color4;
+        lifeTime: number;
+        age: number;
+        size: number;
+        angle: number;
+        angularSpeed: number;
+        copyTo(other: Particle): void;
+    }
+}
+
+declare module BABYLON {
+    class ParticleSystem implements IDisposable {
+        name: string;
+        static BLENDMODE_ONEONE: number;
+        static BLENDMODE_STANDARD: number;
+        id: string;
+        renderingGroupId: number;
+        emitter: any;
+        emitRate: number;
+        manualEmitCount: number;
+        updateSpeed: number;
+        targetStopDuration: number;
+        disposeOnStop: boolean;
+        minEmitPower: number;
+        maxEmitPower: number;
+        minLifeTime: number;
+        maxLifeTime: number;
+        minSize: number;
+        maxSize: number;
+        minAngularSpeed: number;
+        maxAngularSpeed: number;
+        particleTexture: Texture;
+        layerMask: number;
+        onDispose: () => void;
+        updateFunction: (particles: Particle[]) => void;
+        blendMode: number;
+        forceDepthWrite: boolean;
+        gravity: Vector3;
+        direction1: Vector3;
+        direction2: Vector3;
+        minEmitBox: Vector3;
+        maxEmitBox: Vector3;
+        color1: Color4;
+        color2: Color4;
+        colorDead: Color4;
+        textureMask: Color4;
+        startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3) => void;
+        startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3) => void;
+        private particles;
+        private _capacity;
+        private _scene;
+        private _vertexDeclaration;
+        private _vertexStrideSize;
+        private _stockParticles;
+        private _newPartsExcess;
+        private _vertexBuffer;
+        private _indexBuffer;
+        private _vertices;
+        private _effect;
+        private _customEffect;
+        private _cachedDefines;
+        private _scaledColorStep;
+        private _colorDiff;
+        private _scaledDirection;
+        private _scaledGravity;
+        private _currentRenderId;
+        private _alive;
+        private _started;
+        private _stopped;
+        private _actualFrame;
+        private _scaledUpdateSpeed;
+        constructor(name: string, capacity: number, scene: Scene, customEffect?: Effect);
+        recycleParticle(particle: Particle): void;
+        getCapacity(): number;
+        isAlive(): boolean;
+        isStarted(): boolean;
+        start(): void;
+        stop(): void;
+        _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
+        private _update(newParticles);
+        private _getEffect();
+        animate(): void;
+        render(): number;
+        dispose(): void;
+        clone(name: string, newEmitter: any): ParticleSystem;
+    }
+}
+
+declare module BABYLON {
+    class SolidParticle {
+        idx: number;
+        color: Color4;
+        position: Vector3;
+        rotation: Vector3;
+        quaternion: Vector4;
+        scale: Vector3;
+        uvs: Vector4;
+        velocity: Vector3;
+        alive: boolean;
+        _pos: number;
+        _shape: Vector3[];
+        _shapeUV: number[];
+        shapeId: number;
+        previous: SolidParticle;
+        next: SolidParticle;
+        idxInShape: number;
+        constructor(particleIndex: number, positionIndex: number, shape: Vector3[], shapeUV: number[], shapeId: number, idxInShape: number);
+    }
+}
+
+declare module BABYLON {
+    class SolidParticleSystem implements IDisposable {
+        particles: SolidParticle[];
+        nbParticles: number;
+        billboard: boolean;
+        counter: number;
+        name: string;
+        mesh: Mesh;
+        private _scene;
+        private _positions;
+        private _indices;
+        private _normals;
+        private _colors;
+        private _uvs;
+        private _positions32;
+        private _normals32;
+        private _colors32;
+        private _uvs32;
+        private _index;
+        private _shapeCounter;
+        private _copy;
+        private _color;
+        private _computeParticleColor;
+        private _computeParticleTexture;
+        private _computeParticleRotation;
+        private _computeParticleVertex;
+        private _cam_axisZ;
+        private _cam_axisY;
+        private _cam_axisX;
+        private _axisX;
+        private _axisY;
+        private _axisZ;
+        private _camera;
+        private _particle;
+        private _previousParticle;
+        private _fakeCamPos;
+        private _rotMatrix;
+        private _invertedMatrix;
+        private _rotated;
+        private _quaternion;
+        private _vertex;
+        private _yaw;
+        private _pitch;
+        private _roll;
+        private _halfroll;
+        private _halfpitch;
+        private _halfyaw;
+        private _sinRoll;
+        private _cosRoll;
+        private _sinPitch;
+        private _cosPitch;
+        private _sinYaw;
+        private _cosYaw;
+        constructor(name: string, scene: Scene);
+        buildMesh(upgradable?: boolean): Mesh;
+        private _resetCopy();
+        private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, idxInShape, options);
+        private _posToShape(positions);
+        private _uvsToShapeUV(uvs);
+        private _addParticle(p, idxpos, shape, shapeUV, shapeId, idxInShape);
+        addShape(mesh: Mesh, nb: number, options?: {
+            positionFunction?: any;
+            vertexFunction?: any;
+        }): number;
+        resetParticle(particle: SolidParticle): void;
+        setParticles(start?: number, end?: number, update?: boolean): void;
+        private _quaternionRotationYPR();
+        private _quaternionToRotationMatrix();
+        dispose(): void;
+        computeParticleRotation: boolean;
+        computeParticleColor: boolean;
+        computeParticleTexture: boolean;
+        computeParticleVertex: boolean;
+        initParticles(): void;
+        recycleParticle(particle: SolidParticle): SolidParticle;
+        updateParticle(particle: SolidParticle): SolidParticle;
+        updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
+        beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
+        afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
+    }
+}
+
+declare module BABYLON {
     class AbstractMesh extends Node implements IDisposable {
         private static _BILLBOARDMODE_NONE;
         private static _BILLBOARDMODE_X;
@@ -4118,6 +4317,7 @@ declare module BABYLON {
         static CreateDisc(options: {
             radius?: number;
             tessellation?: number;
+            arc?: number;
             sideOrientation?: number;
         }): VertexData;
         static CreatePolyhedron(options: {
@@ -4129,6 +4329,7 @@ declare module BABYLON {
             custom?: any;
             faceUV?: Vector4[];
             faceColors?: Color4[];
+            singleFace?: boolean;
             sideOrientation?: number;
         }): VertexData;
         static CreateTorusKnot(options: {
@@ -4173,8 +4374,9 @@ declare module BABYLON {
             updatable?: boolean;
         }, scene: any): Mesh;
         static CreateDisc(name: string, options: {
-            radius: number;
-            tessellation: number;
+            radius?: number;
+            tessellation?: number;
+            arc?: number;
             updatable?: boolean;
             sideOrientation?: number;
         }, scene: Scene): Mesh;
@@ -4320,6 +4522,7 @@ declare module BABYLON {
             custom?: any;
             faceUV?: Vector4[];
             faceColors?: Color4[];
+            singleFace?: boolean;
             updatable?: boolean;
             sideOrientation?: number;
         }, scene: Scene): Mesh;
@@ -4568,199 +4771,6 @@ declare module BABYLON {
 }
 
 declare module BABYLON {
-    class Particle {
-        position: Vector3;
-        direction: Vector3;
-        color: Color4;
-        colorStep: Color4;
-        lifeTime: number;
-        age: number;
-        size: number;
-        angle: number;
-        angularSpeed: number;
-        copyTo(other: Particle): void;
-    }
-}
-
-declare module BABYLON {
-    class ParticleSystem implements IDisposable {
-        name: string;
-        static BLENDMODE_ONEONE: number;
-        static BLENDMODE_STANDARD: number;
-        id: string;
-        renderingGroupId: number;
-        emitter: any;
-        emitRate: number;
-        manualEmitCount: number;
-        updateSpeed: number;
-        targetStopDuration: number;
-        disposeOnStop: boolean;
-        minEmitPower: number;
-        maxEmitPower: number;
-        minLifeTime: number;
-        maxLifeTime: number;
-        minSize: number;
-        maxSize: number;
-        minAngularSpeed: number;
-        maxAngularSpeed: number;
-        particleTexture: Texture;
-        layerMask: number;
-        onDispose: () => void;
-        updateFunction: (particles: Particle[]) => void;
-        blendMode: number;
-        forceDepthWrite: boolean;
-        gravity: Vector3;
-        direction1: Vector3;
-        direction2: Vector3;
-        minEmitBox: Vector3;
-        maxEmitBox: Vector3;
-        color1: Color4;
-        color2: Color4;
-        colorDead: Color4;
-        textureMask: Color4;
-        startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3) => void;
-        startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3) => void;
-        private particles;
-        private _capacity;
-        private _scene;
-        private _vertexDeclaration;
-        private _vertexStrideSize;
-        private _stockParticles;
-        private _newPartsExcess;
-        private _vertexBuffer;
-        private _indexBuffer;
-        private _vertices;
-        private _effect;
-        private _customEffect;
-        private _cachedDefines;
-        private _scaledColorStep;
-        private _colorDiff;
-        private _scaledDirection;
-        private _scaledGravity;
-        private _currentRenderId;
-        private _alive;
-        private _started;
-        private _stopped;
-        private _actualFrame;
-        private _scaledUpdateSpeed;
-        constructor(name: string, capacity: number, scene: Scene, customEffect?: Effect);
-        recycleParticle(particle: Particle): void;
-        getCapacity(): number;
-        isAlive(): boolean;
-        isStarted(): boolean;
-        start(): void;
-        stop(): void;
-        _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
-        private _update(newParticles);
-        private _getEffect();
-        animate(): void;
-        render(): number;
-        dispose(): void;
-        clone(name: string, newEmitter: any): ParticleSystem;
-    }
-}
-
-declare module BABYLON {
-    class SolidParticle {
-        shapeId: number;
-        idx: number;
-        color: Color4;
-        position: Vector3;
-        rotation: Vector3;
-        quaternion: Vector4;
-        scale: Vector3;
-        uvs: Vector4;
-        velocity: Vector3;
-        alive: boolean;
-        _pos: number;
-        _shape: Vector3[];
-        _shapeUV: number[];
-        previous: SolidParticle;
-        next: SolidParticle;
-        constructor(particleIndex: number, positionIndex: number, shape: Vector3[], shapeUV: number[], shapeId: number);
-    }
-}
-
-declare module BABYLON {
-    class SolidParticleSystem implements IDisposable {
-        particles: SolidParticle[];
-        nbParticles: number;
-        billboard: boolean;
-        counter: number;
-        name: string;
-        mesh: Mesh;
-        private _scene;
-        private _positions;
-        private _indices;
-        private _normals;
-        private _colors;
-        private _uvs;
-        private _positions32;
-        private _normals32;
-        private _colors32;
-        private _uvs32;
-        private _index;
-        private _shapeCounter;
-        private _copy;
-        private _color;
-        private _computeParticleColor;
-        private _computeParticleTexture;
-        private _computeParticleRotation;
-        private _computeParticleVertex;
-        private _cam_axisZ;
-        private _cam_axisY;
-        private _cam_axisX;
-        private _axisX;
-        private _axisY;
-        private _axisZ;
-        private _camera;
-        private _particle;
-        private _previousParticle;
-        private _fakeCamPos;
-        private _rotMatrix;
-        private _invertedMatrix;
-        private _rotated;
-        private _quaternion;
-        private _vertex;
-        private _yaw;
-        private _pitch;
-        private _roll;
-        private _halfroll;
-        private _halfpitch;
-        private _halfyaw;
-        private _sinRoll;
-        private _cosRoll;
-        private _sinPitch;
-        private _cosPitch;
-        private _sinYaw;
-        private _cosYaw;
-        constructor(name: string, scene: Scene);
-        buildMesh(upgradable?: boolean): Mesh;
-        private _resetCopy();
-        private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, customBuilder);
-        private _posToShape(positions);
-        private _uvsToShapeUV(uvs);
-        private _addParticle(p, idxpos, shape, shapeUV, shapeId);
-        addShape(mesh: Mesh, nb: number, customBuilder?: any): number;
-        resetParticle(particle: SolidParticle): void;
-        setParticles(start?: number, end?: number, update?: boolean): void;
-        private _quaternionRotationYPR();
-        private _quaternionToRotationMatrix();
-        dispose(): void;
-        computeParticleRotation: boolean;
-        computeParticleColor: boolean;
-        computeParticleTexture: boolean;
-        computeParticleVertex: boolean;
-        initParticles(): void;
-        recycleParticle(particle: SolidParticle): SolidParticle;
-        updateParticle(particle: SolidParticle): SolidParticle;
-        updateParticleVertex(particle: SolidParticle, vertex: Vector3, i: number): Vector3;
-        beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
-        afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
-    }
-}
-
-declare module BABYLON {
     interface IPhysicsEnginePlugin {
         initialize(iterations?: number): any;
         setGravity(gravity: Vector3): void;
@@ -4815,6 +4825,27 @@ declare module BABYLON {
 }
 
 declare module BABYLON {
+    class ReflectionProbe {
+        name: string;
+        private _scene;
+        private _renderTargetTexture;
+        private _projectionMatrix;
+        private _viewMatrix;
+        private _target;
+        private _add;
+        private _attachedMesh;
+        position: Vector3;
+        constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
+        refreshRate: number;
+        getScene(): Scene;
+        cubeTexture: RenderTargetTexture;
+        renderList: AbstractMesh[];
+        attachToMesh(mesh: AbstractMesh): void;
+        dispose(): void;
+    }
+}
+
+declare module BABYLON {
     class AnaglyphPostProcess extends PostProcess {
         constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
     }
@@ -5368,27 +5399,6 @@ declare module BABYLON {
 }
 
 declare module BABYLON {
-    class ReflectionProbe {
-        name: string;
-        private _scene;
-        private _renderTargetTexture;
-        private _projectionMatrix;
-        private _viewMatrix;
-        private _target;
-        private _add;
-        private _attachedMesh;
-        position: Vector3;
-        constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
-        refreshRate: number;
-        getScene(): Scene;
-        cubeTexture: RenderTargetTexture;
-        renderList: AbstractMesh[];
-        attachToMesh(mesh: AbstractMesh): void;
-        dispose(): void;
-    }
-}
-
-declare module BABYLON {
     class BoundingBoxRenderer {
         frontColor: Color3;
         backColor: Color3;
@@ -5467,6 +5477,7 @@ declare module BABYLON {
         private _transparentSubMeshes;
         private _alphaTestSubMeshes;
         private _activeVertices;
+        onBeforeTransparentRendering: () => void;
         constructor(index: number, scene: Scene);
         render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void): boolean;
         prepare(): void;
@@ -5480,10 +5491,15 @@ declare module BABYLON {
         private _scene;
         private _renderingGroups;
         private _depthBufferAlreadyCleaned;
+        private _currentIndex;
+        private _currentActiveMeshes;
+        private _currentRenderParticles;
+        private _currentRenderSprites;
         constructor(scene: Scene);
         private _renderParticles(index, activeMeshes);
         private _renderSprites(index);
         private _clearDepthBuffer();
+        private _renderSpritesAndParticles();
         render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void, activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void;
         reset(): void;
         dispatch(subMesh: SubMesh): void;
@@ -6292,9 +6308,6 @@ declare module BABYLON {
     }
 }
 
-declare module BABYLON.Internals {
-}
-
 declare module BABYLON {
     class ShadowGenerator {
         private static _FILTER_NONE;
@@ -6348,6 +6361,9 @@ declare module BABYLON {
     }
 }
 
+declare module BABYLON.Internals {
+}
+
 declare module BABYLON {
     class BaseTexture {
         name: string;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 23 - 23
dist/preview release/babylon.js


+ 148 - 87
dist/preview release/babylon.max.js

@@ -5109,7 +5109,7 @@ var BABYLON;
             this._caps.highPrecisionShaderSupported = true;
             if (this._gl.getShaderPrecisionFormat) {
                 var highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
-                this._caps.highPrecisionShaderSupported = highp.precision != 0;
+                this._caps.highPrecisionShaderSupported = highp.precision !== 0;
             }
             // Depth buffer
             this.setDepthBuffer(true);
@@ -11307,23 +11307,36 @@ var BABYLON;
             this._scene.getEngine().clear(0, false, true);
             this._depthBufferAlreadyCleaned = true;
         };
+        RenderingManager.prototype._renderSpritesAndParticles = function () {
+            if (this._currentRenderSprites) {
+                this._renderSprites(this._currentIndex);
+            }
+            if (this._currentRenderParticles) {
+                this._renderParticles(this._currentIndex, this._currentActiveMeshes);
+            }
+        };
         RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
+            this._currentActiveMeshes = activeMeshes;
+            this._currentRenderParticles = renderParticles;
+            this._currentRenderSprites = renderSprites;
             for (var index = 0; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
                 this._depthBufferAlreadyCleaned = false;
                 var renderingGroup = this._renderingGroups[index];
                 var needToStepBack = false;
+                this._currentIndex = index;
                 if (renderingGroup) {
                     this._clearDepthBuffer();
+                    if (!renderingGroup.onBeforeTransparentRendering) {
+                        renderingGroup.onBeforeTransparentRendering = this._renderSpritesAndParticles.bind(this);
+                    }
                     if (!renderingGroup.render(customRenderFunction)) {
                         this._renderingGroups.splice(index, 1);
                         needToStepBack = true;
+                        this._renderSpritesAndParticles();
                     }
                 }
-                if (renderSprites) {
-                    this._renderSprites(index);
-                }
-                if (renderParticles) {
-                    this._renderParticles(index, activeMeshes);
+                else {
+                    this._renderSpritesAndParticles();
                 }
                 if (needToStepBack) {
                     index--;
@@ -11367,6 +11380,9 @@ var BABYLON;
                 return true;
             }
             if (this._opaqueSubMeshes.length === 0 && this._alphaTestSubMeshes.length === 0 && this._transparentSubMeshes.length === 0) {
+                if (this.onBeforeTransparentRendering) {
+                    this.onBeforeTransparentRendering();
+                }
                 return false;
             }
             var engine = this._scene.getEngine();
@@ -11384,6 +11400,9 @@ var BABYLON;
                 submesh.render(false);
             }
             engine.setAlphaTesting(false);
+            if (this.onBeforeTransparentRendering) {
+                this.onBeforeTransparentRendering();
+            }
             // Transparent
             if (this._transparentSubMeshes.length) {
                 // Sorting
@@ -15233,8 +15252,10 @@ var BABYLON;
             }
             var indices = this._renderingMesh.getIndices();
             var extend;
+            //is this the only submesh?
             if (this.indexStart === 0 && this.indexCount === indices.length) {
-                extend = BABYLON.Tools.ExtractMinAndMax(data, this.verticesStart, this.verticesCount);
+                //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
+                extend = { minimum: this._renderingMesh.getBoundingInfo().minimum.clone(), maximum: this._renderingMesh.getBoundingInfo().maximum.clone() };
             }
             else {
                 extend = BABYLON.Tools.ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount);
@@ -17869,14 +17890,15 @@ var BABYLON;
         Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
             this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
         };
-        //public _cacheMatrix(uniformName, matrix) {
-        //    if (!this._valueCache[uniformName]) {
-        //        this._valueCache[uniformName] = new BABYLON.Matrix();
-        //    }
-        //    for (var index = 0; index < 16; index++) {
-        //        this._valueCache[uniformName].m[index] = matrix.m[index];
-        //    }
-        //};
+        Effect.prototype._cacheMatrix = function (uniformName, matrix) {
+            if (!this._valueCache[uniformName]) {
+                this._valueCache[uniformName] = new BABYLON.Matrix();
+            }
+            for (var index = 0; index < 16; index++) {
+                this._valueCache[uniformName].m[index] = matrix.m[index];
+            }
+        };
+        ;
         Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
             if (!this._valueCache[uniformName]) {
                 this._valueCache[uniformName] = [x, y];
@@ -17925,9 +17947,9 @@ var BABYLON;
             return this;
         };
         Effect.prototype.setMatrix = function (uniformName, matrix) {
-            //if (this._valueCache[uniformName] && this._valueCache[uniformName].equals(matrix))
-            //    return;
-            //this._cacheMatrix(uniformName, matrix);
+            if (this._valueCache[uniformName] && this._valueCache[uniformName].equals(matrix))
+                return this;
+            this._cacheMatrix(uniformName, matrix);
             this._engine.setMatrix(this.getUniform(uniformName), matrix);
             return this;
         };
@@ -18407,6 +18429,15 @@ var BABYLON;
             return this.diffuseTexture;
         };
         // Methods   
+        StandardMaterial.prototype._checkCache = function (scene, mesh) {
+            if (!mesh) {
+                return true;
+            }
+            if (mesh._materialDefines && mesh._materialDefines.isEqual(this._defines)) {
+                return true;
+            }
+            return false;
+        };
         StandardMaterial.prototype.isReady = function (mesh, useInstances) {
             if (this.checkReadyOnlyOnce) {
                 if (this._wasPreviouslyReady) {
@@ -18416,10 +18447,7 @@ var BABYLON;
             var scene = this.getScene();
             if (!this.checkReadyOnEveryCall) {
                 if (this._renderId === scene.getRenderId()) {
-                    if (!mesh) {
-                        return true;
-                    }
-                    if (mesh._materialDefines && mesh._materialDefines.isEqual(this._defines)) {
+                    if (this._checkCache(scene, mesh)) {
                         return true;
                     }
                 }
@@ -23819,12 +23847,14 @@ var BABYLON;
             var uvs = [];
             var radius = options.radius || 0.5;
             var tessellation = options.tessellation || 64;
+            var arc = (options.arc <= 0) ? 1.0 : options.arc || 1.0;
             var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || BABYLON.Mesh.DEFAULTSIDE;
             // positions and uvs
             positions.push(0, 0, 0); // disc center first
             uvs.push(0.5, 0.5);
-            var step = Math.PI * 2 / tessellation;
-            for (var a = 0; a < Math.PI * 2; a += step) {
+            var theta = Math.PI * 2 * arc;
+            var step = theta / tessellation;
+            for (var a = 0; a < theta; a += step) {
                 var x = Math.cos(a);
                 var y = Math.sin(a);
                 var u = (x + 1) / 2;
@@ -23832,8 +23862,10 @@ var BABYLON;
                 positions.push(radius * x, radius * y, 0);
                 uvs.push(u, v);
             }
-            positions.push(positions[3], positions[4], positions[5]); // close the circle
-            uvs.push(uvs[2], uvs[3]);
+            if (arc === 1) {
+                positions.push(positions[3], positions[4], positions[5]); // close the circle
+                uvs.push(uvs[2], uvs[3]);
+            }
             //indices
             var vertexNb = positions.length / 3;
             for (var i = 1; i < vertexNb - 1; i++) {
@@ -23891,6 +23923,7 @@ var BABYLON;
             var nbfaces = data.face.length;
             var faceUV = options.faceUV || new Array(nbfaces);
             var faceColors = options.faceColors;
+            var singleFace = options.singleFace;
             var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || BABYLON.Mesh.DEFAULTSIDE;
             var positions = [];
             var indices = [];
@@ -23904,42 +23937,57 @@ var BABYLON;
             var f = 0;
             var u, v, ang, x, y, tmp;
             // default face colors and UV if undefined
-            for (f = 0; f < nbfaces; f++) {
-                if (faceColors && faceColors[f] === undefined) {
-                    faceColors[f] = new BABYLON.Color4(1, 1, 1, 1);
-                }
-                if (faceUV && faceUV[f] === undefined) {
-                    faceUV[f] = new BABYLON.Vector4(0, 0, 1, 1);
+            if (!singleFace) {
+                for (f = 0; f < nbfaces; f++) {
+                    if (faceColors && faceColors[f] === undefined) {
+                        faceColors[f] = new BABYLON.Color4(1, 1, 1, 1);
+                    }
+                    if (faceUV && faceUV[f] === undefined) {
+                        faceUV[f] = new BABYLON.Vector4(0, 0, 1, 1);
+                    }
                 }
             }
-            for (f = 0; f < nbfaces; f++) {
-                var fl = data.face[f].length; // number of vertices of the current face
-                ang = 2 * Math.PI / fl;
-                x = 0.5 * Math.tan(ang / 2);
-                y = 0.5;
-                // positions, uvs, colors
-                for (i = 0; i < fl; i++) {
-                    // positions
-                    positions.push(data.vertex[data.face[f][i]][0] * sizeX, data.vertex[data.face[f][i]][1] * sizeY, data.vertex[data.face[f][i]][2] * sizeZ);
-                    indexes.push(index);
-                    index++;
-                    // uvs
-                    u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
-                    v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
-                    uvs.push(u, v);
-                    tmp = x * Math.cos(ang) - y * Math.sin(ang);
-                    y = x * Math.sin(ang) + y * Math.cos(ang);
-                    x = tmp;
-                    // colors
-                    if (faceColors) {
-                        colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
+            if (singleFace) {
+                for (i = 0; i < data.vertex.length; i++) {
+                    positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
+                    uvs.push(0, 0);
+                }
+                for (f = 0; f < nbfaces; f++) {
+                    for (i = 0; i < data.face[f].length - 2; i++) {
+                        indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
                     }
                 }
-                // indices from indexes
-                for (i = 0; i < fl - 2; i++) {
-                    indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
+            }
+            else {
+                for (f = 0; f < nbfaces; f++) {
+                    var fl = data.face[f].length; // number of vertices of the current face
+                    ang = 2 * Math.PI / fl;
+                    x = 0.5 * Math.tan(ang / 2);
+                    y = 0.5;
+                    // positions, uvs, colors
+                    for (i = 0; i < fl; i++) {
+                        // positions
+                        positions.push(data.vertex[data.face[f][i]][0] * sizeX, data.vertex[data.face[f][i]][1] * sizeY, data.vertex[data.face[f][i]][2] * sizeZ);
+                        indexes.push(index);
+                        index++;
+                        // uvs
+                        u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
+                        v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
+                        uvs.push(u, v);
+                        tmp = x * Math.cos(ang) - y * Math.sin(ang);
+                        y = x * Math.sin(ang) + y * Math.cos(ang);
+                        x = tmp;
+                        // colors
+                        if (faceColors) {
+                            colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
+                        }
+                    }
+                    // indices from indexes
+                    for (i = 0; i < fl - 2; i++) {
+                        indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
+                    }
+                    faceIdx += fl;
                 }
-                faceIdx += fl;
             }
             VertexData.ComputeNormals(positions, indices, normals);
             VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
@@ -23948,7 +23996,7 @@ var BABYLON;
             vertexData.indices = indices;
             vertexData.normals = normals;
             vertexData.uvs = uvs;
-            if (faceColors) {
+            if (faceColors && !singleFace) {
                 vertexData.colors = colors;
             }
             return vertexData;
@@ -35647,19 +35695,20 @@ var BABYLON;
 var BABYLON;
 (function (BABYLON) {
     var SolidParticle = (function () {
-        function SolidParticle(particleIndex, positionIndex, shape, shapeUV, shapeId) {
-            this.shapeId = shapeId;
-            this.color = new BABYLON.Color4(1, 1, 1, 1);
-            this.position = BABYLON.Vector3.Zero();
-            this.rotation = BABYLON.Vector3.Zero();
-            this.scale = new BABYLON.Vector3(1, 1, 1);
-            this.uvs = new BABYLON.Vector4(0, 0, 1, 1);
-            this.velocity = BABYLON.Vector3.Zero();
-            this.alive = true;
+        function SolidParticle(particleIndex, positionIndex, shape, shapeUV, shapeId, idxInShape) {
+            this.color = new BABYLON.Color4(1, 1, 1, 1); // color
+            this.position = BABYLON.Vector3.Zero(); // position
+            this.rotation = BABYLON.Vector3.Zero(); // rotation
+            this.scale = new BABYLON.Vector3(1, 1, 1); // scale
+            this.uvs = new BABYLON.Vector4(0, 0, 1, 1); // uvs
+            this.velocity = BABYLON.Vector3.Zero(); // velocity
+            this.alive = true; // alive
             this.idx = particleIndex;
             this._pos = positionIndex;
             this._shape = shape;
             this._shapeUV = shapeUV;
+            this.shapeId = shapeId;
+            this.idxInShape = idxInShape;
         }
         return SolidParticle;
     })();
@@ -35682,7 +35731,7 @@ var BABYLON;
             this._uvs = new Array();
             this._index = 0; // indices index
             this._shapeCounter = 0;
-            this._copy = { position: BABYLON.Vector3.Zero(), rotation: BABYLON.Vector3.Zero(), scale: new BABYLON.Vector3(1, 1, 1), quaternion: null, uvs: new BABYLON.Vector4(0, 0, 1, 1), colors: null };
+            this._copy = new BABYLON.SolidParticle(null, null, null, null, null, null);
             this._color = new BABYLON.Color4(0, 0, 0, 0);
             this._computeParticleColor = true;
             this._computeParticleTexture = true;
@@ -35766,16 +35815,16 @@ var BABYLON;
             this._copy.uvs.y = 0;
             this._copy.uvs.z = 1;
             this._copy.uvs.w = 1;
-            this._copy.colors = null;
+            this._copy.color = null;
         };
         // _meshBuilder : inserts the shape model in the global SPS mesh
-        SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, customBuilder) {
+        SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, idxInShape, options) {
             var i;
             var u = 0;
             var c = 0;
-            if (customBuilder) {
-                this._resetCopy();
-                customBuilder(this._copy, p);
+            this._resetCopy();
+            if (options && options.positionFunction) {
+                options.positionFunction(this._copy, p, idxInShape);
             }
             if (this._copy.quaternion) {
                 this._quaternion.x = this._copy.quaternion.x;
@@ -35791,17 +35840,23 @@ var BABYLON;
             }
             this._quaternionToRotationMatrix();
             for (i = 0; i < shape.length; i++) {
-                this._vertex.x = shape[i].x * this._copy.scale.x;
-                this._vertex.y = shape[i].y * this._copy.scale.y;
-                this._vertex.z = shape[i].z * this._copy.scale.z;
+                this._vertex.x = shape[i].x;
+                this._vertex.y = shape[i].y;
+                this._vertex.z = shape[i].z;
+                if (options && options.vertexFunction) {
+                    options.vertexFunction(this._copy, this._vertex, i);
+                }
+                this._vertex.x *= this._copy.scale.x;
+                this._vertex.y *= this._copy.scale.y;
+                this._vertex.z *= this._copy.scale.z;
                 BABYLON.Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
                 positions.push(this._copy.position.x + this._rotated.x, this._copy.position.y + this._rotated.y, this._copy.position.z + this._rotated.z);
                 if (meshUV) {
                     uvs.push((this._copy.uvs.z - this._copy.uvs.x) * meshUV[u] + this._copy.uvs.x, (this._copy.uvs.w - this._copy.uvs.y) * meshUV[u + 1] + this._copy.uvs.y);
                     u += 2;
                 }
-                if (this._copy.colors) {
-                    this._color = this._copy.colors;
+                if (this._copy.color) {
+                    this._color = this._copy.color;
                 }
                 else if (meshCol && meshCol[c]) {
                     this._color.r = meshCol[c];
@@ -35840,8 +35895,8 @@ var BABYLON;
             return shapeUV;
         };
         // adds a new particle object in the particles array and double links the particle (next/previous)
-        SolidParticleSystem.prototype._addParticle = function (p, idxpos, shape, shapeUV, shapeId) {
-            this._particle = new BABYLON.SolidParticle(p, idxpos, shape, shapeUV, shapeId);
+        SolidParticleSystem.prototype._addParticle = function (p, idxpos, shape, shapeUV, shapeId, idxInShape) {
+            this._particle = new BABYLON.SolidParticle(p, idxpos, shape, shapeUV, shapeId, idxInShape);
             this.particles.push(this._particle);
             this._particle.previous = this._previousParticle;
             if (this._previousParticle) {
@@ -35850,7 +35905,7 @@ var BABYLON;
             this._previousParticle = this._particle;
         };
         // add solid particles from a shape model in the particles array
-        SolidParticleSystem.prototype.addShape = function (mesh, nb, customBuilder) {
+        SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
             var meshPos = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             var meshInd = mesh.getIndices();
             var meshUV = mesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
@@ -35859,8 +35914,8 @@ var BABYLON;
             var shapeUV = this._uvsToShapeUV(meshUV);
             // particles
             for (var i = 0; i < nb; i++) {
-                this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, customBuilder);
-                this._addParticle(this.nbParticles + i, this._positions.length, shape, shapeUV, this._shapeCounter);
+                this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, i, options);
+                this._addParticle(this.nbParticles + i, this._positions.length, shape, shapeUV, this._shapeCounter, i);
                 this._index += shape.length;
             }
             this.nbParticles += nb;
@@ -35945,12 +36000,15 @@ var BABYLON;
                     idx = index + pt * 3;
                     colidx = colorIndex + pt * 4;
                     uvidx = uvIndex + pt * 2;
-                    this._vertex.x = this._particle._shape[pt].x * this._particle.scale.x;
-                    this._vertex.y = this._particle._shape[pt].y * this._particle.scale.y;
-                    this._vertex.z = this._particle._shape[pt].z * this._particle.scale.z;
+                    this._vertex.x = this._particle._shape[pt].x;
+                    this._vertex.y = this._particle._shape[pt].y;
+                    this._vertex.z = this._particle._shape[pt].z;
                     if (this._computeParticleVertex) {
                         this.updateParticleVertex(this._particle, this._vertex, pt);
                     }
+                    this._vertex.x *= this._particle.scale.x;
+                    this._vertex.y *= this._particle.scale.y;
+                    this._vertex.z *= this._particle.scale.z;
                     BABYLON.Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
                     this._positions32[idx] = this._particle.position.x + this._cam_axisX.x * this._rotated.x + this._cam_axisY.x * this._rotated.y + this._cam_axisZ.x * this._rotated.z;
                     this._positions32[idx + 1] = this._particle.position.y + this._cam_axisX.y * this._rotated.x + this._cam_axisY.y * this._rotated.y + this._cam_axisZ.y * this._rotated.z;
@@ -36083,8 +36141,11 @@ var BABYLON;
         };
         // updates a vertex of a particle : can be overwritten by the user
         // will be called on each vertex particle by setParticles() :
+        // particle : the current particle
+        // vertex : the current index of the current particle
+        // pt : the index of the current vertex in the particle shape
         // ex : just set a vertex particle position
-        SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, i) {
+        SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
             return vertex;
         };
         // will be called before any other treatment by setParticles()

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 24 - 24
dist/preview release/babylon.noworker.js


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

@@ -10,6 +10,7 @@
     - New `Mesh.CreatePolygon()` method ([jerome](https://github.com/jbousquie))
     - Introducing [babylon.core.js](http://doc.babylonjs.com/generals/Framework_versions) ([deltakosh](https://github.com/deltakosh))
   - **Updates**
+    - Sprites and particles scheduler updated to be resolved before transparent objects ([deltakosh](https://github.com/deltakosh))
     - Added `DirectionalLight.autoUpdateExtends` to prevent directional lights to adapt to scene extends ([deltakosh](https://github.com/deltakosh))
     - Added a new parameter to `debugLayer.show()` to define root element to use ([deltakosh](https://github.com/deltakosh))
     - New `MeshBuilder` class used to create all kind of mesh shapes ([deltakosh](https://github.com/deltakosh))

+ 1 - 1
src/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -247,7 +247,7 @@
     var parseParticleSystem = (parsedParticleSystem, scene, rootUrl) => {
         var emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
 
-        var particleSystem = new BABYLON.ParticleSystem(parsedParticlesSysten.name || "particles#" + emitter.name, parsedParticleSystem.capacity, scene);
+        var particleSystem = new BABYLON.ParticleSystem("particles#" + emitter.name, parsedParticleSystem.capacity, scene);
         if (parsedParticleSystem.textureName) {
             particleSystem.particleTexture = new BABYLON.Texture(rootUrl + parsedParticleSystem.textureName, scene);
             particleSystem.particleTexture.name = parsedParticleSystem.textureName;

+ 12 - 11
src/Materials/babylon.effect.js

@@ -225,14 +225,15 @@ var BABYLON;
         Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
             this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
         };
-        //public _cacheMatrix(uniformName, matrix) {
-        //    if (!this._valueCache[uniformName]) {
-        //        this._valueCache[uniformName] = new BABYLON.Matrix();
-        //    }
-        //    for (var index = 0; index < 16; index++) {
-        //        this._valueCache[uniformName].m[index] = matrix.m[index];
-        //    }
-        //};
+        Effect.prototype._cacheMatrix = function (uniformName, matrix) {
+            if (!this._valueCache[uniformName]) {
+                this._valueCache[uniformName] = new BABYLON.Matrix();
+            }
+            for (var index = 0; index < 16; index++) {
+                this._valueCache[uniformName].m[index] = matrix.m[index];
+            }
+        };
+        ;
         Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
             if (!this._valueCache[uniformName]) {
                 this._valueCache[uniformName] = [x, y];
@@ -281,9 +282,9 @@ var BABYLON;
             return this;
         };
         Effect.prototype.setMatrix = function (uniformName, matrix) {
-            //if (this._valueCache[uniformName] && this._valueCache[uniformName].equals(matrix))
-            //    return;
-            //this._cacheMatrix(uniformName, matrix);
+            if (this._valueCache[uniformName] && this._valueCache[uniformName].equals(matrix))
+                return this;
+            this._cacheMatrix(uniformName, matrix);
             this._engine.setMatrix(this.getUniform(uniformName), matrix);
             return this;
         };

+ 11 - 11
src/Materials/babylon.effect.ts

@@ -278,15 +278,15 @@
             this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
         }
 
-        //public _cacheMatrix(uniformName, matrix) {
-        //    if (!this._valueCache[uniformName]) {
-        //        this._valueCache[uniformName] = new BABYLON.Matrix();
-        //    }
+        public _cacheMatrix(uniformName, matrix) {
+            if (!this._valueCache[uniformName]) {
+                this._valueCache[uniformName] = new Matrix();
+            }
 
-        //    for (var index = 0; index < 16; index++) {
-        //        this._valueCache[uniformName].m[index] = matrix.m[index];
-        //    }
-        //};
+            for (var index = 0; index < 16; index++) {
+                this._valueCache[uniformName].m[index] = matrix.m[index];
+            }
+        };
 
         public _cacheFloat2(uniformName: string, x: number, y: number): void {
             if (!this._valueCache[uniformName]) {
@@ -352,10 +352,10 @@
         }
 
         public setMatrix(uniformName: string, matrix: Matrix): Effect {
-            //if (this._valueCache[uniformName] && this._valueCache[uniformName].equals(matrix))
-            //    return;
+            if (this._valueCache[uniformName] && this._valueCache[uniformName].equals(matrix))
+                return this;
 
-            //this._cacheMatrix(uniformName, matrix);
+            this._cacheMatrix(uniformName, matrix);
             this._engine.setMatrix(this.getUniform(uniformName), matrix);
 
             return this;

+ 10 - 4
src/Materials/babylon.standardMaterial.js

@@ -148,6 +148,15 @@ var BABYLON;
             return this.diffuseTexture;
         };
         // Methods   
+        StandardMaterial.prototype._checkCache = function (scene, mesh) {
+            if (!mesh) {
+                return true;
+            }
+            if (mesh._materialDefines && mesh._materialDefines.isEqual(this._defines)) {
+                return true;
+            }
+            return false;
+        };
         StandardMaterial.prototype.isReady = function (mesh, useInstances) {
             if (this.checkReadyOnlyOnce) {
                 if (this._wasPreviouslyReady) {
@@ -157,10 +166,7 @@ var BABYLON;
             var scene = this.getScene();
             if (!this.checkReadyOnEveryCall) {
                 if (this._renderId === scene.getRenderId()) {
-                    if (!mesh) {
-                        return true;
-                    }
-                    if (mesh._materialDefines && mesh._materialDefines.isEqual(this._defines)) {
+                    if (this._checkCache(scene, mesh)) {
                         return true;
                     }
                 }

+ 17 - 10
src/Materials/babylon.standardMaterial.ts

@@ -171,6 +171,18 @@
         }
 
         // Methods   
+        private _checkCache(scene: Scene, mesh?: AbstractMesh): boolean {
+            if (!mesh) {
+                return true;
+            }
+
+            if (mesh._materialDefines && mesh._materialDefines.isEqual(this._defines)) {
+                return true;
+            }
+
+            return false;
+        }
+
         public isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean {
             if (this.checkReadyOnlyOnce) {
                 if (this._wasPreviouslyReady) {
@@ -182,12 +194,7 @@
 
             if (!this.checkReadyOnEveryCall) {
                 if (this._renderId === scene.getRenderId()) {
-
-                    if (!mesh) {
-                        return true;
-                    }
-
-                    if (mesh._materialDefines && mesh._materialDefines.isEqual(this._defines)) {
+                    if (this._checkCache(scene, mesh)) {
                         return true;
                     }
                 }
@@ -259,16 +266,16 @@
                                 break;
                             case Texture.PLANAR_MODE:
                                 this._defines.REFLECTIONMAP_PLANAR = true;
-                                break;    
+                                break;
                             case Texture.PROJECTION_MODE:
                                 this._defines.REFLECTIONMAP_PROJECTION = true;
-                                break;  
+                                break;
                             case Texture.SKYBOX_MODE:
                                 this._defines.REFLECTIONMAP_SKYBOX = true;
-                                break;      
+                                break;
                             case Texture.SPHERICAL_MODE:
                                 this._defines.REFLECTIONMAP_SPHERICAL = true;
-                                break;  
+                                break;
                         }
                     }
                 }

+ 56 - 36
src/Mesh/babylon.mesh.vertexData.js

@@ -1058,12 +1058,14 @@ var BABYLON;
             var uvs = [];
             var radius = options.radius || 0.5;
             var tessellation = options.tessellation || 64;
+            var arc = (options.arc <= 0) ? 1.0 : options.arc || 1.0;
             var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || BABYLON.Mesh.DEFAULTSIDE;
             // positions and uvs
             positions.push(0, 0, 0); // disc center first
             uvs.push(0.5, 0.5);
-            var step = Math.PI * 2 / tessellation;
-            for (var a = 0; a < Math.PI * 2; a += step) {
+            var theta = Math.PI * 2 * arc;
+            var step = theta / tessellation;
+            for (var a = 0; a < theta; a += step) {
                 var x = Math.cos(a);
                 var y = Math.sin(a);
                 var u = (x + 1) / 2;
@@ -1071,8 +1073,10 @@ var BABYLON;
                 positions.push(radius * x, radius * y, 0);
                 uvs.push(u, v);
             }
-            positions.push(positions[3], positions[4], positions[5]); // close the circle
-            uvs.push(uvs[2], uvs[3]);
+            if (arc === 1) {
+                positions.push(positions[3], positions[4], positions[5]); // close the circle
+                uvs.push(uvs[2], uvs[3]);
+            }
             //indices
             var vertexNb = positions.length / 3;
             for (var i = 1; i < vertexNb - 1; i++) {
@@ -1130,6 +1134,7 @@ var BABYLON;
             var nbfaces = data.face.length;
             var faceUV = options.faceUV || new Array(nbfaces);
             var faceColors = options.faceColors;
+            var singleFace = options.singleFace;
             var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || BABYLON.Mesh.DEFAULTSIDE;
             var positions = [];
             var indices = [];
@@ -1143,42 +1148,57 @@ var BABYLON;
             var f = 0;
             var u, v, ang, x, y, tmp;
             // default face colors and UV if undefined
-            for (f = 0; f < nbfaces; f++) {
-                if (faceColors && faceColors[f] === undefined) {
-                    faceColors[f] = new BABYLON.Color4(1, 1, 1, 1);
-                }
-                if (faceUV && faceUV[f] === undefined) {
-                    faceUV[f] = new BABYLON.Vector4(0, 0, 1, 1);
+            if (!singleFace) {
+                for (f = 0; f < nbfaces; f++) {
+                    if (faceColors && faceColors[f] === undefined) {
+                        faceColors[f] = new BABYLON.Color4(1, 1, 1, 1);
+                    }
+                    if (faceUV && faceUV[f] === undefined) {
+                        faceUV[f] = new BABYLON.Vector4(0, 0, 1, 1);
+                    }
                 }
             }
-            for (f = 0; f < nbfaces; f++) {
-                var fl = data.face[f].length; // number of vertices of the current face
-                ang = 2 * Math.PI / fl;
-                x = 0.5 * Math.tan(ang / 2);
-                y = 0.5;
-                // positions, uvs, colors
-                for (i = 0; i < fl; i++) {
-                    // positions
-                    positions.push(data.vertex[data.face[f][i]][0] * sizeX, data.vertex[data.face[f][i]][1] * sizeY, data.vertex[data.face[f][i]][2] * sizeZ);
-                    indexes.push(index);
-                    index++;
-                    // uvs
-                    u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
-                    v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
-                    uvs.push(u, v);
-                    tmp = x * Math.cos(ang) - y * Math.sin(ang);
-                    y = x * Math.sin(ang) + y * Math.cos(ang);
-                    x = tmp;
-                    // colors
-                    if (faceColors) {
-                        colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
+            if (singleFace) {
+                for (i = 0; i < data.vertex.length; i++) {
+                    positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
+                    uvs.push(0, 0);
+                }
+                for (f = 0; f < nbfaces; f++) {
+                    for (i = 0; i < data.face[f].length - 2; i++) {
+                        indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
                     }
                 }
-                // indices from indexes
-                for (i = 0; i < fl - 2; i++) {
-                    indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
+            }
+            else {
+                for (f = 0; f < nbfaces; f++) {
+                    var fl = data.face[f].length; // number of vertices of the current face
+                    ang = 2 * Math.PI / fl;
+                    x = 0.5 * Math.tan(ang / 2);
+                    y = 0.5;
+                    // positions, uvs, colors
+                    for (i = 0; i < fl; i++) {
+                        // positions
+                        positions.push(data.vertex[data.face[f][i]][0] * sizeX, data.vertex[data.face[f][i]][1] * sizeY, data.vertex[data.face[f][i]][2] * sizeZ);
+                        indexes.push(index);
+                        index++;
+                        // uvs
+                        u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
+                        v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
+                        uvs.push(u, v);
+                        tmp = x * Math.cos(ang) - y * Math.sin(ang);
+                        y = x * Math.sin(ang) + y * Math.cos(ang);
+                        x = tmp;
+                        // colors
+                        if (faceColors) {
+                            colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
+                        }
+                    }
+                    // indices from indexes
+                    for (i = 0; i < fl - 2; i++) {
+                        indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
+                    }
+                    faceIdx += fl;
                 }
-                faceIdx += fl;
             }
             VertexData.ComputeNormals(positions, indices, normals);
             VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs);
@@ -1187,7 +1207,7 @@ var BABYLON;
             vertexData.indices = indices;
             vertexData.normals = normals;
             vertexData.uvs = uvs;
-            if (faceColors) {
+            if (faceColors && !singleFace) {
                 vertexData.colors = colors;
             }
             return vertexData;

+ 29 - 28
src/Mesh/babylon.mesh.vertexData.ts

@@ -1302,7 +1302,7 @@
 
             var theta = Math.PI * 2 * arc;
             var step = theta / tessellation;
-            for (var a = 0; a < theta ; a += step) {
+            for (var a = 0; a < theta; a += step) {
                 var x = Math.cos(a);
                 var y = Math.sin(a);
                 var u = (x + 1) / 2;
@@ -1310,7 +1310,7 @@
                 positions.push(radius * x, radius * y, 0);
                 uvs.push(u, v);
             }
-            if (arc == 1) {
+            if (arc === 1) {
                 positions.push(positions[3], positions[4], positions[5]); // close the circle
                 uvs.push(uvs[2], uvs[3]);
             }
@@ -1391,7 +1391,7 @@
             var indexes = [];
             var i = 0;
             var f = 0;
-            var u, v, ang, x, y, tmp;
+            var u: number, v: number, ang: number, x: number, y: number, tmp: number;
 
 
             // default face colors and UV if undefined
@@ -1404,7 +1404,7 @@
                         faceUV[f] = new Vector4(0, 0, 1, 1);
                     }
                 }
-            }   
+            }
 
             if (singleFace) {
 
@@ -1412,38 +1412,38 @@
                     positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
                     uvs.push(0, 0);
                 }
-                for (var f = 0; f < nbfaces; f++) {
+                for (f = 0; f < nbfaces; f++) {
                     for (i = 0; i < data.face[f].length - 2; i++) {
                         indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
                     }
                 }
-                
+
             } else {
 
                 for (f = 0; f < nbfaces; f++) {
-                        var fl = data.face[f].length;  // number of vertices of the current face
-                        ang = 2 * Math.PI / fl;
-                        x = 0.5 * Math.tan(ang / 2);
-                        y = 0.5;
-
-                        // positions, uvs, colors
-                        for (i = 0; i < fl; i++) {
-                            // positions
-                            positions.push(data.vertex[data.face[f][i]][0] * sizeX, data.vertex[data.face[f][i]][1] * sizeY, data.vertex[data.face[f][i]][2] * sizeZ);
-                            indexes.push(index);
-                            index++;
-                            // uvs
-                            u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
-                            v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
-                            uvs.push(u, v);
-                            tmp = x * Math.cos(ang) - y * Math.sin(ang);
-                            y = x * Math.sin(ang) + y * Math.cos(ang);
-                            x = tmp;
-                            // colors
-                            if (faceColors) {
-                                colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
-                            }
+                    var fl = data.face[f].length;  // number of vertices of the current face
+                    ang = 2 * Math.PI / fl;
+                    x = 0.5 * Math.tan(ang / 2);
+                    y = 0.5;
+
+                    // positions, uvs, colors
+                    for (i = 0; i < fl; i++) {
+                        // positions
+                        positions.push(data.vertex[data.face[f][i]][0] * sizeX, data.vertex[data.face[f][i]][1] * sizeY, data.vertex[data.face[f][i]][2] * sizeZ);
+                        indexes.push(index);
+                        index++;
+                        // uvs
+                        u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
+                        v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
+                        uvs.push(u, v);
+                        tmp = x * Math.cos(ang) - y * Math.sin(ang);
+                        y = x * Math.sin(ang) + y * Math.cos(ang);
+                        x = tmp;
+                        // colors
+                        if (faceColors) {
+                            colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
                         }
+                    }
 
                     // indices from indexes
                     for (i = 0; i < fl - 2; i++) {
@@ -1675,3 +1675,4 @@
 }
 
 
+

+ 1 - 1
src/Mesh/babylon.meshBuilder.ts

@@ -781,4 +781,4 @@
             return extrudedGeneric;
         }
     }
-}
+}

+ 3 - 1
src/Mesh/babylon.subMesh.js

@@ -48,8 +48,10 @@ var BABYLON;
             }
             var indices = this._renderingMesh.getIndices();
             var extend;
+            //is this the only submesh?
             if (this.indexStart === 0 && this.indexCount === indices.length) {
-                extend = BABYLON.Tools.ExtractMinAndMax(data, this.verticesStart, this.verticesCount);
+                //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
+                extend = { minimum: this._renderingMesh.getBoundingInfo().minimum.clone(), maximum: this._renderingMesh.getBoundingInfo().maximum.clone() };
             }
             else {
                 extend = BABYLON.Tools.ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount);

+ 1 - 1
src/Mesh/babylon.subMesh.ts

@@ -189,4 +189,4 @@
             return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
         }
     }
-}
+}

+ 10 - 9
src/Particles/babylon.solidParticle.js

@@ -1,19 +1,20 @@
 var BABYLON;
 (function (BABYLON) {
     var SolidParticle = (function () {
-        function SolidParticle(particleIndex, positionIndex, shape, shapeUV, shapeId) {
-            this.shapeId = shapeId;
-            this.color = new BABYLON.Color4(1, 1, 1, 1);
-            this.position = BABYLON.Vector3.Zero();
-            this.rotation = BABYLON.Vector3.Zero();
-            this.scale = new BABYLON.Vector3(1, 1, 1);
-            this.uvs = new BABYLON.Vector4(0, 0, 1, 1);
-            this.velocity = BABYLON.Vector3.Zero();
-            this.alive = true;
+        function SolidParticle(particleIndex, positionIndex, shape, shapeUV, shapeId, idxInShape) {
+            this.color = new BABYLON.Color4(1, 1, 1, 1); // color
+            this.position = BABYLON.Vector3.Zero(); // position
+            this.rotation = BABYLON.Vector3.Zero(); // rotation
+            this.scale = new BABYLON.Vector3(1, 1, 1); // scale
+            this.uvs = new BABYLON.Vector4(0, 0, 1, 1); // uvs
+            this.velocity = BABYLON.Vector3.Zero(); // velocity
+            this.alive = true; // alive
             this.idx = particleIndex;
             this._pos = positionIndex;
             this._shape = shape;
             this._shapeUV = shapeUV;
+            this.shapeId = shapeId;
+            this.idxInShape = idxInShape;
         }
         return SolidParticle;
     })();

+ 1 - 0
src/Particles/babylon.solidParticle.ts

@@ -28,3 +28,4 @@ module BABYLON {
         }
     }
 }
+

+ 32 - 20
src/Particles/babylon.solidParticleSystem.js

@@ -14,7 +14,7 @@ var BABYLON;
             this._uvs = new Array();
             this._index = 0; // indices index
             this._shapeCounter = 0;
-            this._copy = { position: BABYLON.Vector3.Zero(), rotation: BABYLON.Vector3.Zero(), scale: new BABYLON.Vector3(1, 1, 1), quaternion: null, uvs: new BABYLON.Vector4(0, 0, 1, 1), colors: null };
+            this._copy = new BABYLON.SolidParticle(null, null, null, null, null, null);
             this._color = new BABYLON.Color4(0, 0, 0, 0);
             this._computeParticleColor = true;
             this._computeParticleTexture = true;
@@ -98,16 +98,16 @@ var BABYLON;
             this._copy.uvs.y = 0;
             this._copy.uvs.z = 1;
             this._copy.uvs.w = 1;
-            this._copy.colors = null;
+            this._copy.color = null;
         };
         // _meshBuilder : inserts the shape model in the global SPS mesh
-        SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, customBuilder) {
+        SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, idxInShape, options) {
             var i;
             var u = 0;
             var c = 0;
-            if (customBuilder) {
-                this._resetCopy();
-                customBuilder(this._copy, p);
+            this._resetCopy();
+            if (options && options.positionFunction) {
+                options.positionFunction(this._copy, p, idxInShape);
             }
             if (this._copy.quaternion) {
                 this._quaternion.x = this._copy.quaternion.x;
@@ -123,17 +123,23 @@ var BABYLON;
             }
             this._quaternionToRotationMatrix();
             for (i = 0; i < shape.length; i++) {
-                this._vertex.x = shape[i].x * this._copy.scale.x;
-                this._vertex.y = shape[i].y * this._copy.scale.y;
-                this._vertex.z = shape[i].z * this._copy.scale.z;
+                this._vertex.x = shape[i].x;
+                this._vertex.y = shape[i].y;
+                this._vertex.z = shape[i].z;
+                if (options && options.vertexFunction) {
+                    options.vertexFunction(this._copy, this._vertex, i);
+                }
+                this._vertex.x *= this._copy.scale.x;
+                this._vertex.y *= this._copy.scale.y;
+                this._vertex.z *= this._copy.scale.z;
                 BABYLON.Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
                 positions.push(this._copy.position.x + this._rotated.x, this._copy.position.y + this._rotated.y, this._copy.position.z + this._rotated.z);
                 if (meshUV) {
                     uvs.push((this._copy.uvs.z - this._copy.uvs.x) * meshUV[u] + this._copy.uvs.x, (this._copy.uvs.w - this._copy.uvs.y) * meshUV[u + 1] + this._copy.uvs.y);
                     u += 2;
                 }
-                if (this._copy.colors) {
-                    this._color = this._copy.colors;
+                if (this._copy.color) {
+                    this._color = this._copy.color;
                 }
                 else if (meshCol && meshCol[c]) {
                     this._color.r = meshCol[c];
@@ -172,8 +178,8 @@ var BABYLON;
             return shapeUV;
         };
         // adds a new particle object in the particles array and double links the particle (next/previous)
-        SolidParticleSystem.prototype._addParticle = function (p, idxpos, shape, shapeUV, shapeId) {
-            this._particle = new BABYLON.SolidParticle(p, idxpos, shape, shapeUV, shapeId);
+        SolidParticleSystem.prototype._addParticle = function (p, idxpos, shape, shapeUV, shapeId, idxInShape) {
+            this._particle = new BABYLON.SolidParticle(p, idxpos, shape, shapeUV, shapeId, idxInShape);
             this.particles.push(this._particle);
             this._particle.previous = this._previousParticle;
             if (this._previousParticle) {
@@ -182,7 +188,7 @@ var BABYLON;
             this._previousParticle = this._particle;
         };
         // add solid particles from a shape model in the particles array
-        SolidParticleSystem.prototype.addShape = function (mesh, nb, customBuilder) {
+        SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
             var meshPos = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             var meshInd = mesh.getIndices();
             var meshUV = mesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
@@ -191,8 +197,8 @@ var BABYLON;
             var shapeUV = this._uvsToShapeUV(meshUV);
             // particles
             for (var i = 0; i < nb; i++) {
-                this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, customBuilder);
-                this._addParticle(this.nbParticles + i, this._positions.length, shape, shapeUV, this._shapeCounter);
+                this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, i, options);
+                this._addParticle(this.nbParticles + i, this._positions.length, shape, shapeUV, this._shapeCounter, i);
                 this._index += shape.length;
             }
             this.nbParticles += nb;
@@ -277,12 +283,15 @@ var BABYLON;
                     idx = index + pt * 3;
                     colidx = colorIndex + pt * 4;
                     uvidx = uvIndex + pt * 2;
-                    this._vertex.x = this._particle._shape[pt].x * this._particle.scale.x;
-                    this._vertex.y = this._particle._shape[pt].y * this._particle.scale.y;
-                    this._vertex.z = this._particle._shape[pt].z * this._particle.scale.z;
+                    this._vertex.x = this._particle._shape[pt].x;
+                    this._vertex.y = this._particle._shape[pt].y;
+                    this._vertex.z = this._particle._shape[pt].z;
                     if (this._computeParticleVertex) {
                         this.updateParticleVertex(this._particle, this._vertex, pt);
                     }
+                    this._vertex.x *= this._particle.scale.x;
+                    this._vertex.y *= this._particle.scale.y;
+                    this._vertex.z *= this._particle.scale.z;
                     BABYLON.Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
                     this._positions32[idx] = this._particle.position.x + this._cam_axisX.x * this._rotated.x + this._cam_axisY.x * this._rotated.y + this._cam_axisZ.x * this._rotated.z;
                     this._positions32[idx + 1] = this._particle.position.y + this._cam_axisX.y * this._rotated.x + this._cam_axisY.y * this._rotated.y + this._cam_axisZ.y * this._rotated.z;
@@ -415,8 +424,11 @@ var BABYLON;
         };
         // updates a vertex of a particle : can be overwritten by the user
         // will be called on each vertex particle by setParticles() :
+        // particle : the current particle
+        // vertex : the current index of the current particle
+        // pt : the index of the current vertex in the particle shape
         // ex : just set a vertex particle position
-        SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, i) {
+        SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
             return vertex;
         };
         // will be called before any other treatment by setParticles()

+ 2 - 2
src/Particles/babylon.solidParticleSystem.ts

@@ -215,7 +215,7 @@ module BABYLON {
         }
 
         // add solid particles from a shape model in the particles array
-        public addShape(mesh: Mesh, nb: number, options? : {positionFunction?: any, vertexFunction?: any}): number {
+        public addShape(mesh: Mesh, nb: number, options?: { positionFunction?: any, vertexFunction?: any }): number {
             var meshPos = mesh.getVerticesData(VertexBuffer.PositionKind);
             var meshInd = mesh.getIndices();
             var meshUV = mesh.getVerticesData(VertexBuffer.UVKind);
@@ -444,7 +444,6 @@ module BABYLON {
         public get computeParticleVertex(): boolean {
             return this._computeParticleVertex;
         } 
-       
 
         // =======================================================================
         // Particle behavior logic
@@ -488,3 +487,4 @@ module BABYLON {
     }
 }
 
+

+ 6 - 0
src/Rendering/babylon.renderingGroup.js

@@ -14,6 +14,9 @@ var BABYLON;
                 return true;
             }
             if (this._opaqueSubMeshes.length === 0 && this._alphaTestSubMeshes.length === 0 && this._transparentSubMeshes.length === 0) {
+                if (this.onBeforeTransparentRendering) {
+                    this.onBeforeTransparentRendering();
+                }
                 return false;
             }
             var engine = this._scene.getEngine();
@@ -31,6 +34,9 @@ var BABYLON;
                 submesh.render(false);
             }
             engine.setAlphaTesting(false);
+            if (this.onBeforeTransparentRendering) {
+                this.onBeforeTransparentRendering();
+            }
             // Transparent
             if (this._transparentSubMeshes.length) {
                 // Sorting

+ 9 - 0
src/Rendering/babylon.renderingGroup.ts

@@ -6,6 +6,8 @@
         private _alphaTestSubMeshes = new SmartArray<SubMesh>(256);
         private _activeVertices: number;
 
+        public onBeforeTransparentRendering: () => void;
+
         constructor(public index: number, scene: Scene) {
             this._scene = scene;
         }
@@ -17,6 +19,9 @@
             }
 
             if (this._opaqueSubMeshes.length === 0 && this._alphaTestSubMeshes.length === 0 && this._transparentSubMeshes.length === 0) {
+                if (this.onBeforeTransparentRendering) {
+                    this.onBeforeTransparentRendering();
+                }
                 return false;
             }
             var engine = this._scene.getEngine();
@@ -39,6 +44,10 @@
             }
             engine.setAlphaTesting(false);
 
+            if (this.onBeforeTransparentRendering) {
+                this.onBeforeTransparentRendering();
+            }
+
             // Transparent
             if (this._transparentSubMeshes.length) {
                 // Sorting

+ 18 - 5
src/Rendering/babylon.renderingManager.js

@@ -50,23 +50,36 @@ var BABYLON;
             this._scene.getEngine().clear(0, false, true);
             this._depthBufferAlreadyCleaned = true;
         };
+        RenderingManager.prototype._renderSpritesAndParticles = function () {
+            if (this._currentRenderSprites) {
+                this._renderSprites(this._currentIndex);
+            }
+            if (this._currentRenderParticles) {
+                this._renderParticles(this._currentIndex, this._currentActiveMeshes);
+            }
+        };
         RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
+            this._currentActiveMeshes = activeMeshes;
+            this._currentRenderParticles = renderParticles;
+            this._currentRenderSprites = renderSprites;
             for (var index = 0; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
                 this._depthBufferAlreadyCleaned = false;
                 var renderingGroup = this._renderingGroups[index];
                 var needToStepBack = false;
+                this._currentIndex = index;
                 if (renderingGroup) {
                     this._clearDepthBuffer();
+                    if (!renderingGroup.onBeforeTransparentRendering) {
+                        renderingGroup.onBeforeTransparentRendering = this._renderSpritesAndParticles.bind(this);
+                    }
                     if (!renderingGroup.render(customRenderFunction)) {
                         this._renderingGroups.splice(index, 1);
                         needToStepBack = true;
+                        this._renderSpritesAndParticles();
                     }
                 }
-                if (renderSprites) {
-                    this._renderSprites(index);
-                }
-                if (renderParticles) {
-                    this._renderParticles(index, activeMeshes);
+                else {
+                    this._renderSpritesAndParticles();
                 }
                 if (needToStepBack) {
                     index--;

+ 31 - 9
src/Rendering/babylon.renderingManager.ts

@@ -6,6 +6,11 @@
         private _renderingGroups = new Array<RenderingGroup>();
         private _depthBufferAlreadyCleaned: boolean;
 
+        private _currentIndex: number;
+        private _currentActiveMeshes: AbstractMesh[];
+        private _currentRenderParticles: boolean;
+        private _currentRenderSprites: boolean;
+
         constructor(scene: Scene) {
             this._scene = scene;
         }
@@ -66,27 +71,44 @@
             this._depthBufferAlreadyCleaned = true;
         }
 
+        private _renderSpritesAndParticles() {
+            if (this._currentRenderSprites) {
+                this._renderSprites(this._currentIndex);
+            }
+
+            if (this._currentRenderParticles) {
+                this._renderParticles(this._currentIndex, this._currentActiveMeshes);
+            }
+        }
+
         public render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void,
             activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void {
+
+            this._currentActiveMeshes = activeMeshes;
+            this._currentRenderParticles = renderParticles;
+            this._currentRenderSprites = renderSprites;
+
             for (var index = 0; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
                 this._depthBufferAlreadyCleaned = false;
                 var renderingGroup = this._renderingGroups[index];
                 var needToStepBack = false;
 
+                this._currentIndex = index;
+
                 if (renderingGroup) {
                     this._clearDepthBuffer();
+
+                    if (!renderingGroup.onBeforeTransparentRendering) {
+                        renderingGroup.onBeforeTransparentRendering = this._renderSpritesAndParticles.bind(this);
+                    }
+
                     if (!renderingGroup.render(customRenderFunction)) {
                         this._renderingGroups.splice(index, 1);
                         needToStepBack = true;
+                        this._renderSpritesAndParticles();
                     }
-                }
-
-                if (renderSprites) {
-                    this._renderSprites(index);
-                }
-
-                if (renderParticles) {
-                    this._renderParticles(index, activeMeshes);
+                } else {
+                    this._renderSpritesAndParticles();
                 }
 
                 if (needToStepBack) {
@@ -96,7 +118,7 @@
         }
 
         public reset(): void {
-            this._renderingGroups.forEach(function (renderingGroup, index, array) {
+            this._renderingGroups.forEach((renderingGroup, index, array) => {
                 if (renderingGroup) {
                     renderingGroup.prepare();
                 }

+ 0 - 1
src/Tools/babylon.sceneSerializer.ts

@@ -377,7 +377,6 @@
     var serializeParticleSystem = (particleSystem: ParticleSystem): any => {
         var serializationObject: any = {};
 
-        serializationObject.name = particleSystem.name;
         serializationObject.emitterId = particleSystem.emitter.id;
         serializationObject.capacity = particleSystem.getCapacity();
 

+ 1 - 1
src/babylon.engine.js

@@ -439,7 +439,7 @@ var BABYLON;
             this._caps.highPrecisionShaderSupported = true;
             if (this._gl.getShaderPrecisionFormat) {
                 var highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
-                this._caps.highPrecisionShaderSupported = highp.precision != 0;
+                this._caps.highPrecisionShaderSupported = highp.precision !== 0;
             }
             // Depth buffer
             this.setDepthBuffer(true);

+ 1 - 1
src/babylon.engine.ts

@@ -638,7 +638,7 @@
 
             if (this._gl.getShaderPrecisionFormat) {
                 var highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
-                this._caps.highPrecisionShaderSupported = highp.precision != 0;
+                this._caps.highPrecisionShaderSupported = highp.precision !== 0;
             }
 
             // Depth buffer