瀏覽代碼

deleted dynamic buffer

Benjamin Guignabert 8 年之前
父節點
當前提交
dfe9ca1eea

+ 164 - 171
dist/preview release/babylon.d.ts

@@ -339,7 +339,7 @@ declare module BABYLON {
         generateMipMapsForCubemap(texture: WebGLTexture): void;
         flushFramebuffer(): void;
         restoreDefaultFramebuffer(): void;
-        createUniformBuffer(formattedUniforms: number[] | Float32Array): WebGLBuffer;
+        createUniformBuffer(size: number): WebGLBuffer;
         private _resetVertexBufferBinding();
         createVertexBuffer(vertices: number[] | Float32Array): WebGLBuffer;
         createDynamicVertexBuffer(vertices: number[] | Float32Array): WebGLBuffer;
@@ -382,7 +382,7 @@ declare module BABYLON {
         bindUniformBlock(shaderProgram: WebGLProgram): void;
         getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
         enableEffect(effect: Effect): void;
-        setUniformBuffer(ubo: WebGLBuffer, array: Float32Array): void;
+        updateUniformBuffer(ubo: WebGLBuffer, array: Float32Array): void;
         setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
         setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
         setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
@@ -3959,6 +3959,102 @@ declare module BABYLON {
     }
 }
 
+declare module BABYLON.Debug {
+    class AxesViewer {
+        private _xline;
+        private _yline;
+        private _zline;
+        private _xmesh;
+        private _ymesh;
+        private _zmesh;
+        scene: Scene;
+        scaleLines: number;
+        constructor(scene: Scene, scaleLines?: number);
+        update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
+        dispose(): void;
+    }
+}
+
+declare module BABYLON.Debug {
+    class BoneAxesViewer extends Debug.AxesViewer {
+        mesh: Mesh;
+        bone: Bone;
+        pos: Vector3;
+        xaxis: Vector3;
+        yaxis: Vector3;
+        zaxis: Vector3;
+        constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
+        update(): void;
+        dispose(): void;
+    }
+}
+
+declare module BABYLON {
+    class DebugLayer {
+        private _scene;
+        static InspectorURL: string;
+        private _inspector;
+        constructor(scene: Scene);
+        /** Creates the inspector window. */
+        private _createInspector(config?);
+        isVisible(): boolean;
+        hide(): void;
+        show(config?: {
+            popup?: boolean;
+            initialTab?: number;
+            parentElement?: HTMLElement;
+        }): void;
+    }
+}
+
+declare module BABYLON {
+    class RayHelper {
+        ray: Ray;
+        private _renderPoints;
+        private _renderLine;
+        private _renderFunction;
+        private _scene;
+        private _updateToMeshFunction;
+        private _attachedToMesh;
+        private _meshSpaceDirection;
+        private _meshSpaceOrigin;
+        static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
+        constructor(ray: Ray);
+        show(scene: Scene, color: Color3): void;
+        hide(): void;
+        private _render();
+        attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
+        detachFromMesh(): void;
+        private _updateToMesh();
+        dispose(): void;
+    }
+}
+
+declare module BABYLON.Debug {
+    /**
+    * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
+    */
+    class SkeletonViewer {
+        skeleton: Skeleton;
+        mesh: AbstractMesh;
+        autoUpdateBonesMatrices: boolean;
+        renderingGroupId: number;
+        color: Color3;
+        private _scene;
+        private _debugLines;
+        private _debugMesh;
+        private _isEnabled;
+        private _renderFunction;
+        constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
+        isEnabled: boolean;
+        private _getBonePosition(position, bone, meshMat, x?, y?, z?);
+        private _getLinesForBonesWithLength(bones, meshMat);
+        private _getLinesForBonesNoLength(bones, meshMat);
+        update(): void;
+        dispose(): void;
+    }
+}
+
 declare module BABYLON {
     /**
      * Highlight layer options. This helps customizing the behaviour
@@ -4214,102 +4310,6 @@ declare module BABYLON {
     }
 }
 
-declare module BABYLON.Debug {
-    class AxesViewer {
-        private _xline;
-        private _yline;
-        private _zline;
-        private _xmesh;
-        private _ymesh;
-        private _zmesh;
-        scene: Scene;
-        scaleLines: number;
-        constructor(scene: Scene, scaleLines?: number);
-        update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
-        dispose(): void;
-    }
-}
-
-declare module BABYLON.Debug {
-    class BoneAxesViewer extends Debug.AxesViewer {
-        mesh: Mesh;
-        bone: Bone;
-        pos: Vector3;
-        xaxis: Vector3;
-        yaxis: Vector3;
-        zaxis: Vector3;
-        constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
-        update(): void;
-        dispose(): void;
-    }
-}
-
-declare module BABYLON {
-    class DebugLayer {
-        private _scene;
-        static InspectorURL: string;
-        private _inspector;
-        constructor(scene: Scene);
-        /** Creates the inspector window. */
-        private _createInspector(config?);
-        isVisible(): boolean;
-        hide(): void;
-        show(config?: {
-            popup?: boolean;
-            initialTab?: number;
-            parentElement?: HTMLElement;
-        }): void;
-    }
-}
-
-declare module BABYLON {
-    class RayHelper {
-        ray: Ray;
-        private _renderPoints;
-        private _renderLine;
-        private _renderFunction;
-        private _scene;
-        private _updateToMeshFunction;
-        private _attachedToMesh;
-        private _meshSpaceDirection;
-        private _meshSpaceOrigin;
-        static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
-        constructor(ray: Ray);
-        show(scene: Scene, color: Color3): void;
-        hide(): void;
-        private _render();
-        attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
-        detachFromMesh(): void;
-        private _updateToMesh();
-        dispose(): void;
-    }
-}
-
-declare module BABYLON.Debug {
-    /**
-    * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
-    */
-    class SkeletonViewer {
-        skeleton: Skeleton;
-        mesh: AbstractMesh;
-        autoUpdateBonesMatrices: boolean;
-        renderingGroupId: number;
-        color: Color3;
-        private _scene;
-        private _debugLines;
-        private _debugMesh;
-        private _isEnabled;
-        private _renderFunction;
-        constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
-        isEnabled: boolean;
-        private _getBonePosition(position, bone, meshMat, x?, y?, z?);
-        private _getLinesForBonesWithLength(bones, meshMat);
-        private _getLinesForBonesNoLength(bones, meshMat);
-        update(): void;
-        dispose(): void;
-    }
-}
-
 declare module BABYLON {
     class LensFlare {
         size: number;
@@ -4726,58 +4726,6 @@ declare module BABYLON {
 }
 
 declare module BABYLON {
-    interface ISceneLoaderPluginExtensions {
-        [extension: string]: {
-            isBinary: boolean;
-        };
-    }
-    interface ISceneLoaderPlugin {
-        extensions: string | ISceneLoaderPluginExtensions;
-        importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean;
-        load: (scene: Scene, data: string, rootUrl: string) => boolean;
-    }
-    interface ISceneLoaderPluginAsync {
-        extensions: string | ISceneLoaderPluginExtensions;
-        importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror?: () => void) => void;
-        loadAsync: (scene: Scene, data: string, rootUrl: string, onsuccess: () => void, onerror: () => void) => boolean;
-    }
-    class SceneLoader {
-        private static _ForceFullSceneLoadingForIncremental;
-        private static _ShowLoadingScreen;
-        static readonly NO_LOGGING: number;
-        static readonly MINIMAL_LOGGING: number;
-        static readonly SUMMARY_LOGGING: number;
-        static readonly DETAILED_LOGGING: number;
-        private static _loggingLevel;
-        static ForceFullSceneLoadingForIncremental: boolean;
-        static ShowLoadingScreen: boolean;
-        static loggingLevel: number;
-        private static _registeredPlugins;
-        private static _getDefaultPlugin();
-        private static _getPluginForExtension(extension);
-        private static _getPluginForFilename(sceneFilename);
-        private static _getDirectLoad(sceneFilename);
-        static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
-        static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
-        static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: Scene, message: string, exception?: any) => void): void;
-        /**
-        * Load a scene
-        * @param rootUrl a string that defines the root url for scene and resources
-        * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
-        * @param engine is the instance of BABYLON.Engine to use to create the scene
-        */
-        static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
-        /**
-        * Append a scene
-        * @param rootUrl a string that defines the root url for scene and resources
-        * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
-        * @param scene is the instance of BABYLON.Scene to append to
-        */
-        static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
-    }
-}
-
-declare module BABYLON {
     /**
      * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
      * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
@@ -5035,16 +4983,11 @@ declare module BABYLON {
         private static _uniqueIdSeed;
         private _engine;
         private _uniformsNames;
-        private _uniformBufferDynamic;
-        private _uniformBufferStatic;
-        private _uniformBufferDynamicCache;
-        private _uniformBufferStaticCache;
-        private _uniformBufferDynamicNames;
-        private _uniformBufferDynamicLocations;
-        private _uniformBufferStaticNames;
-        private _uniformBufferStaticLocations;
-        private _uniformCurrentStaticPointer;
-        private _uniformCurrentDynamicPointer;
+        private _uniformBuffer;
+        private _uniformBufferCache;
+        private _uniformBufferNames;
+        private _uniformBufferLocations;
+        private _uniformCurrentPointer;
         private _uniformOrder;
         private _samplers;
         private _isReady;
@@ -5066,8 +5009,7 @@ declare module BABYLON {
         getAttributesCount(): number;
         getUniformIndex(uniformName: string): number;
         getUniform(uniformName: string): WebGLUniformLocation;
-        getUniformWithinDynamicUbo(uniformName: string): number;
-        getUniformWithinStaticUbo(uniformName: string): number;
+        getUniformWithinUbo(uniformName: string): number;
         getSamplers(): string[];
         getCompilationError(): string;
         getVertexShaderSource(): string;
@@ -5078,6 +5020,7 @@ declare module BABYLON {
         private _processShaderConversion(sourceCode, isFragment, callback);
         private _processIncludes(sourceCode, callback);
         private _processPrecision(source);
+        buildUniformlayout(): void;
         private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?);
         readonly isSupported: boolean;
         _bindTexture(channel: string, texture: WebGLTexture): void;
@@ -5088,11 +5031,9 @@ declare module BABYLON {
         _cacheFloat2(uniformName: string, x: number, y: number): boolean;
         _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
         _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
-        formatUniforms(length: number): Float32Array;
-        addUniform(name: string, size: number, dynamic: boolean): void;
-        updateUniformBufferStatic(): void;
-        updateUniformBufferDynamic(): void;
-        bindUniformBuffers(): void;
+        addUniform(name: string, size: number): void;
+        updateUniformBuffer(): void;
+        bindUniformBuffer(): void;
         bindUniformBlock(): void;
         setIntArray(uniformName: string, array: Int32Array): Effect;
         setIntArray2(uniformName: string, array: Int32Array): Effect;
@@ -5793,6 +5734,58 @@ declare module BABYLON {
 }
 
 declare module BABYLON {
+    interface ISceneLoaderPluginExtensions {
+        [extension: string]: {
+            isBinary: boolean;
+        };
+    }
+    interface ISceneLoaderPlugin {
+        extensions: string | ISceneLoaderPluginExtensions;
+        importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean;
+        load: (scene: Scene, data: string, rootUrl: string) => boolean;
+    }
+    interface ISceneLoaderPluginAsync {
+        extensions: string | ISceneLoaderPluginExtensions;
+        importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror?: () => void) => void;
+        loadAsync: (scene: Scene, data: string, rootUrl: string, onsuccess: () => void, onerror: () => void) => boolean;
+    }
+    class SceneLoader {
+        private static _ForceFullSceneLoadingForIncremental;
+        private static _ShowLoadingScreen;
+        static readonly NO_LOGGING: number;
+        static readonly MINIMAL_LOGGING: number;
+        static readonly SUMMARY_LOGGING: number;
+        static readonly DETAILED_LOGGING: number;
+        private static _loggingLevel;
+        static ForceFullSceneLoadingForIncremental: boolean;
+        static ShowLoadingScreen: boolean;
+        static loggingLevel: number;
+        private static _registeredPlugins;
+        private static _getDefaultPlugin();
+        private static _getPluginForExtension(extension);
+        private static _getPluginForFilename(sceneFilename);
+        private static _getDirectLoad(sceneFilename);
+        static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
+        static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
+        static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: Scene, message: string, exception?: any) => void): void;
+        /**
+        * Load a scene
+        * @param rootUrl a string that defines the root url for scene and resources
+        * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
+        * @param engine is the instance of BABYLON.Engine to use to create the scene
+        */
+        static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
+        /**
+        * Append a scene
+        * @param rootUrl a string that defines the root url for scene and resources
+        * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
+        * @param scene is the instance of BABYLON.Scene to append to
+        */
+        static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
+    }
+}
+
+declare module BABYLON {
     class SIMDHelper {
         private static _isEnabled;
         static readonly IsEnabled: boolean;
@@ -6658,7 +6651,7 @@ declare module BABYLON {
          * Populates the passed array from the passed index with the Vector4 coordinates.
          * Returns the Vector4.
          */
-        toArray(array: number[], index?: number): Vector4;
+        toArray(array: number[] | Float32Array, index?: number): Vector4;
         /**
          * Adds the passed vector to the current Vector4.
          * Returns the updated Vector4.
@@ -14581,9 +14574,6 @@ declare module BABYLON {
     }
 }
 
-declare module BABYLON.Internals {
-}
-
 declare module BABYLON {
     class BaseTexture {
         name: string;
@@ -15122,6 +15112,9 @@ declare module BABYLON {
     }
 }
 
+declare module BABYLON.Internals {
+}
+
 declare module BABYLON {
     class CannonJSPlugin implements IPhysicsEnginePlugin {
         private _useDeltaForWorldStep;

+ 164 - 171
dist/preview release/babylon.module.d.ts

@@ -339,7 +339,7 @@ declare module BABYLON {
         generateMipMapsForCubemap(texture: WebGLTexture): void;
         flushFramebuffer(): void;
         restoreDefaultFramebuffer(): void;
-        createUniformBuffer(formattedUniforms: number[] | Float32Array): WebGLBuffer;
+        createUniformBuffer(size: number): WebGLBuffer;
         private _resetVertexBufferBinding();
         createVertexBuffer(vertices: number[] | Float32Array): WebGLBuffer;
         createDynamicVertexBuffer(vertices: number[] | Float32Array): WebGLBuffer;
@@ -382,7 +382,7 @@ declare module BABYLON {
         bindUniformBlock(shaderProgram: WebGLProgram): void;
         getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
         enableEffect(effect: Effect): void;
-        setUniformBuffer(ubo: WebGLBuffer, array: Float32Array): void;
+        updateUniformBuffer(ubo: WebGLBuffer, array: Float32Array): void;
         setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
         setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
         setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
@@ -3959,6 +3959,102 @@ declare module BABYLON {
     }
 }
 
+declare module BABYLON.Debug {
+    class AxesViewer {
+        private _xline;
+        private _yline;
+        private _zline;
+        private _xmesh;
+        private _ymesh;
+        private _zmesh;
+        scene: Scene;
+        scaleLines: number;
+        constructor(scene: Scene, scaleLines?: number);
+        update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
+        dispose(): void;
+    }
+}
+
+declare module BABYLON.Debug {
+    class BoneAxesViewer extends Debug.AxesViewer {
+        mesh: Mesh;
+        bone: Bone;
+        pos: Vector3;
+        xaxis: Vector3;
+        yaxis: Vector3;
+        zaxis: Vector3;
+        constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
+        update(): void;
+        dispose(): void;
+    }
+}
+
+declare module BABYLON {
+    class DebugLayer {
+        private _scene;
+        static InspectorURL: string;
+        private _inspector;
+        constructor(scene: Scene);
+        /** Creates the inspector window. */
+        private _createInspector(config?);
+        isVisible(): boolean;
+        hide(): void;
+        show(config?: {
+            popup?: boolean;
+            initialTab?: number;
+            parentElement?: HTMLElement;
+        }): void;
+    }
+}
+
+declare module BABYLON {
+    class RayHelper {
+        ray: Ray;
+        private _renderPoints;
+        private _renderLine;
+        private _renderFunction;
+        private _scene;
+        private _updateToMeshFunction;
+        private _attachedToMesh;
+        private _meshSpaceDirection;
+        private _meshSpaceOrigin;
+        static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
+        constructor(ray: Ray);
+        show(scene: Scene, color: Color3): void;
+        hide(): void;
+        private _render();
+        attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
+        detachFromMesh(): void;
+        private _updateToMesh();
+        dispose(): void;
+    }
+}
+
+declare module BABYLON.Debug {
+    /**
+    * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
+    */
+    class SkeletonViewer {
+        skeleton: Skeleton;
+        mesh: AbstractMesh;
+        autoUpdateBonesMatrices: boolean;
+        renderingGroupId: number;
+        color: Color3;
+        private _scene;
+        private _debugLines;
+        private _debugMesh;
+        private _isEnabled;
+        private _renderFunction;
+        constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
+        isEnabled: boolean;
+        private _getBonePosition(position, bone, meshMat, x?, y?, z?);
+        private _getLinesForBonesWithLength(bones, meshMat);
+        private _getLinesForBonesNoLength(bones, meshMat);
+        update(): void;
+        dispose(): void;
+    }
+}
+
 declare module BABYLON {
     /**
      * Highlight layer options. This helps customizing the behaviour
@@ -4214,102 +4310,6 @@ declare module BABYLON {
     }
 }
 
-declare module BABYLON.Debug {
-    class AxesViewer {
-        private _xline;
-        private _yline;
-        private _zline;
-        private _xmesh;
-        private _ymesh;
-        private _zmesh;
-        scene: Scene;
-        scaleLines: number;
-        constructor(scene: Scene, scaleLines?: number);
-        update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
-        dispose(): void;
-    }
-}
-
-declare module BABYLON.Debug {
-    class BoneAxesViewer extends Debug.AxesViewer {
-        mesh: Mesh;
-        bone: Bone;
-        pos: Vector3;
-        xaxis: Vector3;
-        yaxis: Vector3;
-        zaxis: Vector3;
-        constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
-        update(): void;
-        dispose(): void;
-    }
-}
-
-declare module BABYLON {
-    class DebugLayer {
-        private _scene;
-        static InspectorURL: string;
-        private _inspector;
-        constructor(scene: Scene);
-        /** Creates the inspector window. */
-        private _createInspector(config?);
-        isVisible(): boolean;
-        hide(): void;
-        show(config?: {
-            popup?: boolean;
-            initialTab?: number;
-            parentElement?: HTMLElement;
-        }): void;
-    }
-}
-
-declare module BABYLON {
-    class RayHelper {
-        ray: Ray;
-        private _renderPoints;
-        private _renderLine;
-        private _renderFunction;
-        private _scene;
-        private _updateToMeshFunction;
-        private _attachedToMesh;
-        private _meshSpaceDirection;
-        private _meshSpaceOrigin;
-        static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
-        constructor(ray: Ray);
-        show(scene: Scene, color: Color3): void;
-        hide(): void;
-        private _render();
-        attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
-        detachFromMesh(): void;
-        private _updateToMesh();
-        dispose(): void;
-    }
-}
-
-declare module BABYLON.Debug {
-    /**
-    * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
-    */
-    class SkeletonViewer {
-        skeleton: Skeleton;
-        mesh: AbstractMesh;
-        autoUpdateBonesMatrices: boolean;
-        renderingGroupId: number;
-        color: Color3;
-        private _scene;
-        private _debugLines;
-        private _debugMesh;
-        private _isEnabled;
-        private _renderFunction;
-        constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
-        isEnabled: boolean;
-        private _getBonePosition(position, bone, meshMat, x?, y?, z?);
-        private _getLinesForBonesWithLength(bones, meshMat);
-        private _getLinesForBonesNoLength(bones, meshMat);
-        update(): void;
-        dispose(): void;
-    }
-}
-
 declare module BABYLON {
     class LensFlare {
         size: number;
@@ -4726,58 +4726,6 @@ declare module BABYLON {
 }
 
 declare module BABYLON {
-    interface ISceneLoaderPluginExtensions {
-        [extension: string]: {
-            isBinary: boolean;
-        };
-    }
-    interface ISceneLoaderPlugin {
-        extensions: string | ISceneLoaderPluginExtensions;
-        importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean;
-        load: (scene: Scene, data: string, rootUrl: string) => boolean;
-    }
-    interface ISceneLoaderPluginAsync {
-        extensions: string | ISceneLoaderPluginExtensions;
-        importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror?: () => void) => void;
-        loadAsync: (scene: Scene, data: string, rootUrl: string, onsuccess: () => void, onerror: () => void) => boolean;
-    }
-    class SceneLoader {
-        private static _ForceFullSceneLoadingForIncremental;
-        private static _ShowLoadingScreen;
-        static readonly NO_LOGGING: number;
-        static readonly MINIMAL_LOGGING: number;
-        static readonly SUMMARY_LOGGING: number;
-        static readonly DETAILED_LOGGING: number;
-        private static _loggingLevel;
-        static ForceFullSceneLoadingForIncremental: boolean;
-        static ShowLoadingScreen: boolean;
-        static loggingLevel: number;
-        private static _registeredPlugins;
-        private static _getDefaultPlugin();
-        private static _getPluginForExtension(extension);
-        private static _getPluginForFilename(sceneFilename);
-        private static _getDirectLoad(sceneFilename);
-        static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
-        static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
-        static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: Scene, message: string, exception?: any) => void): void;
-        /**
-        * Load a scene
-        * @param rootUrl a string that defines the root url for scene and resources
-        * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
-        * @param engine is the instance of BABYLON.Engine to use to create the scene
-        */
-        static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
-        /**
-        * Append a scene
-        * @param rootUrl a string that defines the root url for scene and resources
-        * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
-        * @param scene is the instance of BABYLON.Scene to append to
-        */
-        static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
-    }
-}
-
-declare module BABYLON {
     /**
      * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
      * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
@@ -5035,16 +4983,11 @@ declare module BABYLON {
         private static _uniqueIdSeed;
         private _engine;
         private _uniformsNames;
-        private _uniformBufferDynamic;
-        private _uniformBufferStatic;
-        private _uniformBufferDynamicCache;
-        private _uniformBufferStaticCache;
-        private _uniformBufferDynamicNames;
-        private _uniformBufferDynamicLocations;
-        private _uniformBufferStaticNames;
-        private _uniformBufferStaticLocations;
-        private _uniformCurrentStaticPointer;
-        private _uniformCurrentDynamicPointer;
+        private _uniformBuffer;
+        private _uniformBufferCache;
+        private _uniformBufferNames;
+        private _uniformBufferLocations;
+        private _uniformCurrentPointer;
         private _uniformOrder;
         private _samplers;
         private _isReady;
@@ -5066,8 +5009,7 @@ declare module BABYLON {
         getAttributesCount(): number;
         getUniformIndex(uniformName: string): number;
         getUniform(uniformName: string): WebGLUniformLocation;
-        getUniformWithinDynamicUbo(uniformName: string): number;
-        getUniformWithinStaticUbo(uniformName: string): number;
+        getUniformWithinUbo(uniformName: string): number;
         getSamplers(): string[];
         getCompilationError(): string;
         getVertexShaderSource(): string;
@@ -5078,6 +5020,7 @@ declare module BABYLON {
         private _processShaderConversion(sourceCode, isFragment, callback);
         private _processIncludes(sourceCode, callback);
         private _processPrecision(source);
+        buildUniformlayout(): void;
         private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?);
         readonly isSupported: boolean;
         _bindTexture(channel: string, texture: WebGLTexture): void;
@@ -5088,11 +5031,9 @@ declare module BABYLON {
         _cacheFloat2(uniformName: string, x: number, y: number): boolean;
         _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
         _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
-        formatUniforms(length: number): Float32Array;
-        addUniform(name: string, size: number, dynamic: boolean): void;
-        updateUniformBufferStatic(): void;
-        updateUniformBufferDynamic(): void;
-        bindUniformBuffers(): void;
+        addUniform(name: string, size: number): void;
+        updateUniformBuffer(): void;
+        bindUniformBuffer(): void;
         bindUniformBlock(): void;
         setIntArray(uniformName: string, array: Int32Array): Effect;
         setIntArray2(uniformName: string, array: Int32Array): Effect;
@@ -5793,6 +5734,58 @@ declare module BABYLON {
 }
 
 declare module BABYLON {
+    interface ISceneLoaderPluginExtensions {
+        [extension: string]: {
+            isBinary: boolean;
+        };
+    }
+    interface ISceneLoaderPlugin {
+        extensions: string | ISceneLoaderPluginExtensions;
+        importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean;
+        load: (scene: Scene, data: string, rootUrl: string) => boolean;
+    }
+    interface ISceneLoaderPluginAsync {
+        extensions: string | ISceneLoaderPluginExtensions;
+        importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror?: () => void) => void;
+        loadAsync: (scene: Scene, data: string, rootUrl: string, onsuccess: () => void, onerror: () => void) => boolean;
+    }
+    class SceneLoader {
+        private static _ForceFullSceneLoadingForIncremental;
+        private static _ShowLoadingScreen;
+        static readonly NO_LOGGING: number;
+        static readonly MINIMAL_LOGGING: number;
+        static readonly SUMMARY_LOGGING: number;
+        static readonly DETAILED_LOGGING: number;
+        private static _loggingLevel;
+        static ForceFullSceneLoadingForIncremental: boolean;
+        static ShowLoadingScreen: boolean;
+        static loggingLevel: number;
+        private static _registeredPlugins;
+        private static _getDefaultPlugin();
+        private static _getPluginForExtension(extension);
+        private static _getPluginForFilename(sceneFilename);
+        private static _getDirectLoad(sceneFilename);
+        static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
+        static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
+        static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: Scene, message: string, exception?: any) => void): void;
+        /**
+        * Load a scene
+        * @param rootUrl a string that defines the root url for scene and resources
+        * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
+        * @param engine is the instance of BABYLON.Engine to use to create the scene
+        */
+        static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
+        /**
+        * Append a scene
+        * @param rootUrl a string that defines the root url for scene and resources
+        * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
+        * @param scene is the instance of BABYLON.Scene to append to
+        */
+        static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
+    }
+}
+
+declare module BABYLON {
     class SIMDHelper {
         private static _isEnabled;
         static readonly IsEnabled: boolean;
@@ -6658,7 +6651,7 @@ declare module BABYLON {
          * Populates the passed array from the passed index with the Vector4 coordinates.
          * Returns the Vector4.
          */
-        toArray(array: number[], index?: number): Vector4;
+        toArray(array: number[] | Float32Array, index?: number): Vector4;
         /**
          * Adds the passed vector to the current Vector4.
          * Returns the updated Vector4.
@@ -14581,9 +14574,6 @@ declare module BABYLON {
     }
 }
 
-declare module BABYLON.Internals {
-}
-
 declare module BABYLON {
     class BaseTexture {
         name: string;
@@ -15122,6 +15112,9 @@ declare module BABYLON {
     }
 }
 
+declare module BABYLON.Internals {
+}
+
 declare module BABYLON {
     class CannonJSPlugin implements IPhysicsEnginePlugin {
         private _useDeltaForWorldStep;

+ 16 - 13
index.html

@@ -54,19 +54,22 @@
 					light.intensity = .5;
 
 					// Let's try our built-in 'sphere' shape. Params: name, subdivisions, size, scene
-					var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);
-
-					// Move the sphere upward 1/2 its height
-					sphere.position.y = 1;
-					sphere.material = new BABYLON.StandardMaterial("test");
-					sphere.material.diffuseColor = new BABYLON.Color3(1, 1, 1);
-					sphere.material.diffuseTexture = new BABYLON.Texture("test.jpeg", scene);
-					var t = 0;
-					scene.registerAfterRender(function() {
-						// sphere.material.specularColor = new BABYLON.Color3(0, 0, Math.sin(t/100));
-						// sphere.material.diffuseColor = new BABYLON.Color3(Math.abs(Math.sin(t/100)), Math.abs(Math.cos(t/200)), Math.abs(Math.sin(t/50)));
-						t++;
-					})
+					for (var i = 0; i < 500; i++) {
+						var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);
+
+						// Move the sphere upward 1/2 its height
+						sphere.position.y = 1 + i / 250;
+						sphere.material = new BABYLON.StandardMaterial("test");
+						sphere.material.diffuseColor = new BABYLON.Color3(Math.random(), Math.random(), Math.random());
+						// sphere.material.diffuseTexture = new BABYLON.Texture("test.jpeg", scene);
+						// sphere.material.freeze();
+						var t = 0;/*
+						scene.registerAfterRender(function() {
+							sphere.material.specularColor = new BABYLON.Color3(0, 0, Math.sin(t/100));
+							sphere.material.diffuseColor = new BABYLON.Color3(Math.abs(Math.sin(t/100)), Math.abs(Math.cos(t/200)), Math.abs(Math.sin(t/50)));
+							t++;
+						})*/
+					}
 
 					// Let's try our built-in 'ground' shape.  Params: name, width, depth, subdivisions, scene
 					var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);

+ 41 - 95
src/Materials/babylon.effect.ts

@@ -82,16 +82,11 @@
         private static _uniqueIdSeed = 0;
         private _engine: Engine;
         private _uniformsNames: string[];
-        private _uniformBufferDynamic: WebGLBuffer;
-        private _uniformBufferStatic: WebGLBuffer;
-        private _uniformBufferDynamicCache: Float32Array;
-        private _uniformBufferStaticCache: Float32Array;
-        private _uniformBufferDynamicNames: string[] = [];
-        private _uniformBufferDynamicLocations: number[] = [];
-        private _uniformBufferStaticNames: string[] = [];
-        private _uniformBufferStaticLocations: number[] = [];
-        private _uniformCurrentStaticPointer: number = 0;
-        private _uniformCurrentDynamicPointer: number = 0;
+        private _uniformBuffer: WebGLBuffer;
+        private _uniformBufferCache: Float32Array;
+        private _uniformBufferNames: string[] = [];
+        private _uniformBufferLocations: number[] = [];
+        private _uniformCurrentPointer: number = 0;
         private _uniformOrder: string[];
         private _samplers: string[];
         private _isReady = false;
@@ -197,22 +192,11 @@
             return this._uniforms[this._uniformsNames.indexOf(uniformName)];
         }
 
-        public getUniformWithinDynamicUbo(uniformName: string): number {
+        public getUniformWithinUbo(uniformName: string): number {
             var index;
             var location;
-            if ((index = this._uniformBufferDynamicNames.indexOf(uniformName)) !== -1) {
-                location = this._uniformBufferDynamicLocations[index]
-                return location;
-            } else {
-                return -1;
-            }
-        }
-
-        public getUniformWithinStaticUbo(uniformName: string): number {
-            var index;
-            var location;
-            if ((index = this._uniformBufferStaticNames.indexOf(uniformName)) !== -1) {
-                location = this._uniformBufferStaticLocations[index]
+            if ((index = this._uniformBufferNames.indexOf(uniformName)) !== -1) {
+                location = this._uniformBufferLocations[index]
                 return location;
             } else {
                 return -1;
@@ -437,6 +421,9 @@
 
             return source;
         }
+        public buildUniformlayout(): void {
+            this._uniformBuffer = this._engine.createUniformBuffer(this._uniformCurrentPointer);
+        }
 
         private _prepareEffect(vertexSourceCode: string, fragmentSourceCode: string, attributesNames: string[], defines: string, fallbacks?: EffectFallbacks): void {
             try {
@@ -446,8 +433,6 @@
                 this.bindUniformBlock();
 
                 this._uniforms = engine.getUniforms(this._program, this._uniformsNames);
-                this._uniformBufferDynamic = engine.createUniformBuffer(this.formatUniforms(8));
-                this._uniformBufferStatic = engine.createUniformBuffer(this.formatUniforms(4));
 
                 this._attributes = engine.getAttributes(this._program, attributesNames);
 
@@ -613,48 +598,28 @@
             return changed;
         }
 
-
-        public formatUniforms(length: number): Float32Array {
-            return new Float32Array(length);
-        };
-
-        public addUniform(name: string, size: number, dynamic: boolean): void {
+        public addUniform(name: string, size: number): void {
             var uniformNames, uniformLocations, index;
-            if (dynamic) {
-                uniformNames = this._uniformBufferDynamicNames;
-                uniformLocations = this._uniformBufferDynamicLocations;
-                index = this._uniformCurrentDynamicPointer;
-            } else {
-                uniformNames = this._uniformBufferStaticNames;
-                uniformLocations = this._uniformBufferStaticLocations;                
-                index = this._uniformCurrentStaticPointer;
-            }
+            uniformNames = this._uniformBufferNames;
+            uniformLocations = this._uniformBufferLocations;                
+            index = this._uniformCurrentPointer;
+
             uniformNames.push(name);
             uniformLocations.push(index);
 
             // std140 layout forces uniform to be multiple of 16 bytes (4 floats)
             var correctedSize = Math.ceil(size / 4) * 4;
 
-            if (dynamic) {
-                this._uniformCurrentDynamicPointer += correctedSize;
-                this._uniformBufferDynamicCache = new Float32Array(this._uniformCurrentDynamicPointer);
-            } else {
-                this._uniformCurrentStaticPointer += correctedSize;
-                this._uniformBufferStaticCache = new Float32Array(this._uniformCurrentStaticPointer); 
-            }
+            this._uniformCurrentPointer += correctedSize;
+            this._uniformBufferCache = new Float32Array(this._uniformCurrentPointer); 
         };
 
-        public updateUniformBufferStatic(): void {
-            this._engine.setUniformBuffer(this._uniformBufferStatic, this._uniformBufferStaticCache);
-        }
-
-        public updateUniformBufferDynamic(): void {
-            this._engine.setUniformBuffer(this._uniformBufferDynamic, this._uniformBufferDynamicCache);
+        public updateUniformBuffer(): void {
+            this._engine.updateUniformBuffer(this._uniformBuffer, this._uniformBufferCache);
         }
 
-        public bindUniformBuffers(): void {
-            this._engine.bindUniformBufferBase(this._uniformBufferDynamic, 0);
-            this._engine.bindUniformBufferBase(this._uniformBufferStatic, 1);
+        public bindUniformBuffer(): void {
+            this._engine.bindUniformBufferBase(this._uniformBuffer, 0);
         }
 
         public bindUniformBlock(): void {
@@ -754,11 +719,9 @@
 
         public setMatrix(uniformName: string, matrix: Matrix): Effect {
             if (this._cacheMatrix(uniformName, matrix)) {
-                var location = this.getUniformWithinStaticUbo(uniformName);
+                var location = this.getUniformWithinUbo(uniformName);
                 if (location !== -1) {
-                    this._uniformBufferStaticCache.set(matrix.toArray(), location);
-                } else if ((location = this.getUniformWithinDynamicUbo(uniformName)) !== -1) {
-                    this._uniformBufferDynamicCache.set(matrix.toArray(), location);
+                    this._uniformBufferCache.set(matrix.toArray(), location);
                 } else {
                     this._engine.setMatrix(this.getUniform(uniformName), matrix);
                 }
@@ -806,11 +769,9 @@
 
         public setVector2(uniformName: string, vector2: Vector2): Effect {
             if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
-                var location = this.getUniformWithinStaticUbo(uniformName);
+                var location = this.getUniformWithinUbo(uniformName);
                 if (location !== -1) {
-                    vector2.toArray(this._uniformBufferStaticCache, location);
-                } else if ((location = this.getUniformWithinDynamicUbo(uniformName)) !== -1) {
-                    vector2.toArray(this._uniformBufferDynamicCache, location);
+                    vector2.toArray(this._uniformBufferCache, location);
                 } else {
                     this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
                 }
@@ -820,11 +781,9 @@
 
         public setFloat2(uniformName: string, x: number, y: number): Effect {
             if (this._cacheFloat2(uniformName, x, y)) {
-                var location = this.getUniformWithinStaticUbo(uniformName);
+                var location = this.getUniformWithinUbo(uniformName);
                 if (location !== -1) {
-                    this._uniformBufferStaticCache.set([x, y], location);
-                } else if ((location = this.getUniformWithinDynamicUbo(uniformName)) !== -1) {
-                    this._uniformBufferDynamicCache.set([x, y], location);
+                    this._uniformBufferCache.set([x, y], location);
                 } else {
                     this._engine.setFloat2(this.getUniform(uniformName), x, y);
                 }
@@ -834,11 +793,9 @@
 
         public setVector3(uniformName: string, vector3: Vector3): Effect {
             if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
-                var location = this.getUniformWithinStaticUbo(uniformName);
+                var location = this.getUniformWithinUbo(uniformName);
                 if (location !== -1) {
-                    vector3.toArray(this._uniformBufferStaticCache, location);
-                } else if ((location = this.getUniformWithinDynamicUbo(uniformName)) !== -1) {
-                    vector3.toArray(this._uniformBufferDynamicCache, location);
+                    vector3.toArray(this._uniformBufferCache, location);
                 } else {
                     this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
                 }
@@ -848,11 +805,9 @@
 
         public setFloat3(uniformName: string, x: number, y: number, z: number): Effect {
             if (this._cacheFloat3(uniformName, x, y, z)) {
-                var location = this.getUniformWithinStaticUbo(uniformName);
+                var location = this.getUniformWithinUbo(uniformName);
                 if (location !== -1) {
-                    this._uniformBufferStaticCache.set([x, y, z], location);
-                } else if ((location = this.getUniformWithinDynamicUbo(uniformName)) !== -1) {
-                    this._uniformBufferDynamicCache.set([x, y, z], location);
+                    this._uniformBufferCache.set([x, y, z], location);
                 } else {
                     this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
                 }
@@ -862,11 +817,9 @@
 
         public setVector4(uniformName: string, vector4: Vector4): Effect {
             if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
-                var location = this.getUniformWithinStaticUbo(uniformName);
+                var location = this.getUniformWithinUbo(uniformName);
                 if (location !== -1) {
-                    vector4.toArray(this._uniformBufferStaticCache, location);
-                } else if ((location = this.getUniformWithinDynamicUbo(uniformName)) !== -1) {
-                    vector4.toArray(this._uniformBufferDynamicCache, location);
+                    vector4.toArray(this._uniformBufferCache, location);
                 } else {
                     this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
                 }
@@ -876,11 +829,9 @@
 
         public setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect {
             if (this._cacheFloat4(uniformName, x, y, z, w)) {
-                var location = this.getUniformWithinStaticUbo(uniformName);
+                var location = this.getUniformWithinUbo(uniformName);
                 if (location !== -1) {
-                    this._uniformBufferStaticCache.set([x, y, z, w], location);
-                } else if ((location = this.getUniformWithinDynamicUbo(uniformName)) !== -1) {
-                    this._uniformBufferDynamicCache.set([x, y, z, w], location);
+                    this._uniformBufferCache.set([x, y, z, w], location);
                 } else {
                     this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
                 }
@@ -891,11 +842,9 @@
         public setColor3(uniformName: string, color3: Color3): Effect {
 
             if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
-                var location = this.getUniformWithinStaticUbo(uniformName);
+                var location = this.getUniformWithinUbo(uniformName);
                 if (location !== -1) {
-                    color3.toArray(this._uniformBufferStaticCache, location);
-                } else if ((location = this.getUniformWithinDynamicUbo(uniformName)) !== -1) {
-                    color3.toArray(this._uniformBufferDynamicCache, location);
+                    color3.toArray(this._uniformBufferCache, location);
                 } else {
                     this._engine.setColor3(this.getUniform(uniformName), color3);
                 }
@@ -905,13 +854,10 @@
 
         public setColor4(uniformName: string, color3: Color3, alpha: number): Effect {
             if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
-                var location = this.getUniformWithinStaticUbo(uniformName);
+                var location = this.getUniformWithinUbo(uniformName);
                 if (location !== -1) {
-                    color3.toArray(this._uniformBufferStaticCache, location);
-                    this._uniformBufferStaticCache[location + 3] = alpha;
-                } else if ((location = this.getUniformWithinDynamicUbo(uniformName)) !== -1) {
-                    color3.toArray(this._uniformBufferDynamicCache, location);
-                    this._uniformBufferDynamicCache[location + 3] = alpha;
+                    color3.toArray(this._uniformBufferCache, location);
+                    this._uniformBufferCache[location + 3] = alpha;
                 } else {
                     this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
                 }

+ 21 - 18
src/Materials/babylon.standardMaterial.ts

@@ -704,11 +704,18 @@ module BABYLON {
                 }
                 MaterialHelper.PrepareUniformsAndSamplersList(uniforms, samplers, this._defines, this.maxSimultaneousLights);
 
+                var onCompiled = function(effect) {
+                    if (this.onCompiled) {
+                        this.onCompiled(effect);
+                    }
+                    
+                    this.buildUniformLayout();
+                }.bind(this);
+
                 this._effect = scene.getEngine().createEffect(shaderName,
                     attribs, uniforms, samplers,
-                    join, fallbacks, this.onCompiled, this.onError, { maxSimultaneousLights: this.maxSimultaneousLights - 1 });
+                    join, fallbacks, onCompiled, this.onError, { maxSimultaneousLights: this.maxSimultaneousLights - 1 });
 
-                this.buildUniformLayout();
             }
             if (!this._effect.isReady()) {
                 return false;
@@ -730,27 +737,23 @@ module BABYLON {
 
         public buildUniformLayout(): void {
             // Order is important !
-            this._effect.addUniform("vDiffuseColor", 4, false);
+            this._effect.addUniform("vDiffuseColor", 4);
 
             if (this._defines.DIFFUSE) {
-                this._effect.addUniform("vDiffuseInfos", 2, false);
-                this._effect.addUniform("diffuseMatrix", 16, false);
+                this._effect.addUniform("vDiffuseInfos", 2);
+                this._effect.addUniform("diffuseMatrix", 16);
             }
 
-            this._effect.addUniform("vAmbientColor", 3, false);
+            this._effect.addUniform("vAmbientColor", 3);
+
 
             if (this._defines.SPECULARTERM) {
-                this._effect.addUniform("vSpecularColor", 3, false);
+                this._effect.addUniform("vSpecularColor", 3);
             }
 
-            this._effect.addUniform("vEmissiveColor", 3, false);
-            
-            // Dynamic uniforms
-            this._effect.addUniform("vEyePosition", 3, true);
-            // this._effect.addUniform("world", 16, true);
-            // this._effect.addUniform("view", 16, true);
-            // this._effect.addUniform("viewProjection", 16, true);
-            // "world", "view", "viewProjection"
+            this._effect.addUniform("vEmissiveColor", 3);
+
+            this._effect.buildUniformlayout();
         }
 
         public unbind(): void {
@@ -779,6 +782,8 @@ module BABYLON {
             MaterialHelper.BindBonesParameters(mesh, this._effect);
 
             if (scene.getCachedMaterial() !== this) {
+                this._effect.bindUniformBuffer();
+
                 this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
 
                 if (StandardMaterial.FresnelEnabled) {
@@ -909,8 +914,6 @@ module BABYLON {
                 }
                 this._effect.setColor3("vEmissiveColor", this.emissiveColor);
 
-                this._effect.updateUniformBufferDynamic();
-                this._effect.bindUniformBuffers();
             }
 
             if (scene.getCachedMaterial() !== this || !this.isFrozen) {
@@ -937,9 +940,9 @@ module BABYLON {
                 if (this.cameraColorCurves) {
                     ColorCurves.Bind(this.cameraColorCurves, this._effect);
                 }
-                this._effect.updateUniformBufferStatic();
             }
 
+            this._effect.updateUniformBuffer();
             super.bind(world, mesh);
         }
 

+ 1 - 1
src/Math/babylon.math.ts

@@ -1834,7 +1834,7 @@
          * Populates the passed array from the passed index with the Vector4 coordinates.  
          * Returns the Vector4.  
          */
-        public toArray(array: number[], index?: number): Vector4 {
+        public toArray(array: number[] | Float32Array, index?: number): Vector4 {
             if (index === undefined) {
                 index = 0;
             }

+ 14 - 21
src/Shaders/default.fragment.fx

@@ -4,7 +4,7 @@ struct Camera {
 	vec3 vEyePosition;
 };
 
-struct Material
+uniform Material
 {
 	vec4 vDiffuseColor;
 
@@ -18,19 +18,12 @@ struct Material
   	#ifdef SPECULARTERM
   	vec4 vSpecularColor;
   	#endif
-  	
-  	vec3 vEmissiveColor;
-
-};
 
-uniform Dynamic {
-	Camera camera;
-}  uDynamic;
+  	vec3 vEmissiveColor;
 
-uniform Static {
-	Material material;
-}  uStatic;
+} uMaterial;
 
+uniform vec3 vEyePosition;
 
 #ifdef BUMP
 #extension GL_OES_standard_derivatives : enable
@@ -185,14 +178,14 @@ uniform vec4 reflectionRightColor;
 void main(void) {
 #include<clipPlaneFragment>
 
-	vec3 viewDirectionW = normalize(uDynamic.camera.vEyePosition - vPositionW);
+	vec3 viewDirectionW = normalize(vEyePosition - vPositionW);
 
 	// Base color
 	vec4 baseColor = vec4(1., 1., 1., 1.);
-	vec3 diffuseColor = uStatic.material.vDiffuseColor.rgb;
+	vec3 diffuseColor = uMaterial.vDiffuseColor.rgb;
 
 	// Alpha
-	float alpha = uStatic.material.vDiffuseColor.a;
+	float alpha = uMaterial.vDiffuseColor.a;
 
 	// Bump
 #ifdef NORMAL
@@ -219,7 +212,7 @@ void main(void) {
 	alpha *= baseColor.a;
 #endif
 
-	baseColor.rgb *= uStatic.material.vDiffuseInfos.y;
+	baseColor.rgb *= uMaterial.vDiffuseInfos.y;
 #endif
 
 #ifdef VERTEXCOLOR
@@ -235,8 +228,8 @@ void main(void) {
 
 	// Specular map
 #ifdef SPECULARTERM
-	float glossiness = uStatic.material.vSpecularColor.a;
-	vec3 specularColor = uStatic.material.vSpecularColor.rgb;
+	float glossiness = uMaterial.vSpecularColor.a;
+	vec3 specularColor = uMaterial.vSpecularColor.rgb;
 
 #ifdef SPECULAR
 	vec4 specularMapColor = texture2D(specularSampler, vSpecularUV + uvOffset);
@@ -366,7 +359,7 @@ void main(void) {
 #endif
 
 	// Emissive
-	vec3 emissiveColor = uStatic.material.vEmissiveColor;
+	vec3 emissiveColor = uMaterial.vEmissiveColor;
 #ifdef EMISSIVE
 	emissiveColor += texture2D(emissiveSampler, vEmissiveUV + uvOffset).rgb * vEmissiveInfos.y;
 #endif
@@ -386,12 +379,12 @@ void main(void) {
 
 	// Composition
 #ifdef EMISSIVEASILLUMINATION
-	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + uStatic.material.vAmbientColor, 0.0, 1.0) * baseColor.rgb;
+	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + uMaterial.vAmbientColor, 0.0, 1.0) * baseColor.rgb;
 #else
 #ifdef LINKEMISSIVEWITHDIFFUSE
-	vec3 finalDiffuse = clamp((diffuseBase + emissiveColor) * diffuseColor + uStatic.material.vAmbientColor, 0.0, 1.0) * baseColor.rgb;
+	vec3 finalDiffuse = clamp((diffuseBase + emissiveColor) * diffuseColor + uMaterial.vAmbientColor, 0.0, 1.0) * baseColor.rgb;
 #else
-	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + uStatic.material.vAmbientColor, 0.0, 1.0) * baseColor.rgb;
+	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + uMaterial.vAmbientColor, 0.0, 1.0) * baseColor.rgb;
 #endif
 #endif
 

+ 5 - 14
src/Shaders/default.vertex.fx

@@ -4,7 +4,7 @@ struct Camera {
 	vec3 vEyePosition;
 };
 
-struct Material
+uniform Material
 {
 	vec4 vDiffuseColor;
 
@@ -21,16 +21,7 @@ struct Material
   	
   	vec3 vEmissiveColor;
 
-};
-
-uniform Dynamic {
-	Camera camera;
-}  uDynamic;
-
-uniform Static {
-	Material material;
-}  uStatic;
-
+} uMaterial;
 
 // Attributes
 attribute vec3 position;
@@ -157,13 +148,13 @@ void main(void) {
 #endif
 
 #ifdef DIFFUSE
-	if (uStatic.material.vDiffuseInfos.x == 0.)
+	if (uMaterial.vDiffuseInfos.x == 0.)
 	{
-		vDiffuseUV = vec2(uStatic.material.diffuseMatrix * vec4(uv, 1.0, 0.0));
+		vDiffuseUV = vec2(uMaterial.diffuseMatrix * vec4(uv, 1.0, 0.0));
 	}
 	else
 	{
-		vDiffuseUV = vec2(uStatic.material.diffuseMatrix * vec4(uv2, 1.0, 0.0));
+		vDiffuseUV = vec2(uMaterial.diffuseMatrix * vec4(uv2, 1.0, 0.0));
 	}
 #endif
 

+ 5 - 15
src/babylon.engine.ts

@@ -1300,15 +1300,11 @@
         }
 
         // UBOs
-        public createUniformBuffer(formattedUniforms: number[] | Float32Array): WebGLBuffer {
+        public createUniformBuffer(size: number): WebGLBuffer {
             var ubo = this._gl.createBuffer();
             this.bindUniformBuffer(ubo);
 
-            if (formattedUniforms instanceof Float32Array) {
-                this._gl.bufferData(this._gl.UNIFORM_BUFFER, <Float32Array>formattedUniforms, this._gl.STATIC_DRAW);
-            } else {
-                this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(<number[]>formattedUniforms), this._gl.STATIC_DRAW);
-            }
+            this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(size), this._gl.STATIC_DRAW);
 
             this.bindUniformBuffer(null);
             ubo.references = 1;
@@ -1818,12 +1814,9 @@
         }
 
         public bindUniformBlock(shaderProgram: WebGLProgram): void {
-            var uniformDynamicLocation = this._gl.getUniformBlockIndex(shaderProgram, 'Dynamic');
-            var uniformStaticLocation = this._gl.getUniformBlockIndex(shaderProgram, 'Static');
-
-            this._gl.uniformBlockBinding(shaderProgram, uniformDynamicLocation, 0);
-            this._gl.uniformBlockBinding(shaderProgram, uniformStaticLocation, 1);
+            var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, 'Material');
 
+            this._gl.uniformBlockBinding(shaderProgram, uniformLocation, 0);
         };
 
         public getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[] {
@@ -1851,12 +1844,9 @@
             }
         }
 
-        public setUniformBuffer(ubo: WebGLBuffer, array: Float32Array): void {
+        public updateUniformBuffer(ubo: WebGLBuffer, array: Float32Array): void {
             this.bindUniformBuffer(ubo);
-
-            this._gl.bufferData(this._gl.UNIFORM_BUFFER, array, this._gl.STATIC_DRAW);
             this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, array);
-
             this.bindUniformBuffer(null);
         }