Quellcode durchsuchen

Add typedoc comments

Gary Hsu vor 7 Jahren
Ursprung
Commit
ec5cbfcc12

+ 17 - 0
src/Engine/babylon.engine.ts

@@ -2192,6 +2192,11 @@
             this._cachedVertexBuffers = null;
         }
 
+        /**
+         * Creates a vertex buffer
+         * @param data the data for the vertex buffer
+         * @returns the new WebGL static buffer
+         */
         public createVertexBuffer(data: DataArray): WebGLBuffer {
             var vbo = this._gl.createBuffer();
 
@@ -2212,6 +2217,11 @@
             return vbo;
         }
 
+        /**
+         * Creates a dynamic vertex buffer
+         * @param data the data for the dynamic vertex buffer
+         * @returns the new WebGL dynamic buffer
+         */
         public createDynamicVertexBuffer(data: DataArray): WebGLBuffer {
             var vbo = this._gl.createBuffer();
 
@@ -2249,6 +2259,13 @@
             this._resetIndexBufferBinding();
         }
 
+        /**
+         * Updates a dynamic vertex buffer.
+         * @param vertexBuffer the vertex buffer to update
+         * @param data the data used to update the vertex buffer
+         * @param byteOffset the byte offset of the data (optional)
+         * @param byteLength the byte length of the data (optional)
+         */
         public updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void {
             this.bindArrayBuffer(vertexBuffer);
 

+ 8 - 1
src/Engine/babylon.nullEngine.ts

@@ -392,7 +392,14 @@
         public updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset: number = 0): void {
         }
 
-        public updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void {
+        /**
+         * Updates a dynamic vertex buffer.
+         * @param vertexBuffer the vertex buffer to update
+         * @param data the data used to update the vertex buffer
+         * @param byteOffset the byte offset of the data (optional)
+         * @param byteLength the byte length of the data (optional)
+         */
+        public updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void {
         }
 
         protected _bindTextureDirectly(target: number, texture: InternalTexture): void {

+ 17 - 0
src/Mesh/babylon.buffer.ts

@@ -11,6 +11,16 @@
          */
         public readonly byteStride: number;
 
+        /**
+         * Constructor
+         * @param engine the engine
+         * @param data the data to use for this buffer
+         * @param updatable whether the data is updatable
+         * @param stride the stride (optional)
+         * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
+         * @param instanced whether the buffer is instanced (optional)
+         * @param useBytes set to true if the stride in in bytes (optional)
+         */
         constructor(engine: any, data: DataArray, updatable: boolean, stride = 0, postponeInternalCreation = false, instanced = false, useBytes = false) {
             if (engine instanceof Mesh) { // old versions of BABYLON.VertexBuffer accepted 'mesh' instead of 'engine'
                 this._engine = engine.getScene().getEngine();
@@ -96,6 +106,13 @@
             this.create(data);
         }
 
+        /**
+         * Updates the data directly.
+         * @param data the new data
+         * @param offset the new offset
+         * @param vertexCount the vertex count (optional)
+         * @param useBytes set to true if the offset is in bytes
+         */
         public updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes = false): void {
             if (!this._buffer) {
                 return;

+ 63 - 0
src/Mesh/babylon.vertexBuffer.ts

@@ -7,12 +7,39 @@
         private _instanced: boolean;
         private _instanceDivisor: number;
 
+        /**
+         * The byte type.
+         */
         public static readonly BYTE = 5120;
+
+        /**
+         * The unsigned byte type.
+         */
         public static readonly UNSIGNED_BYTE = 5121;
+
+        /**
+         * The short type.
+         */
         public static readonly SHORT = 5122;
+
+        /**
+         * The unsigned short type.
+         */
         public static readonly UNSIGNED_SHORT = 5123;
+
+        /**
+         * The integer type.
+         */
         public static readonly INT = 5124;
+
+        /**
+         * The unsigned integer type.
+         */
         public static readonly UNSIGNED_INT = 5125;
+
+        /**
+         * The float type.
+         */
         public static readonly FLOAT = 5126;
 
         /**
@@ -51,6 +78,21 @@
          */
         public readonly type: number;
 
+        /**
+         * Constructor
+         * @param engine the engine
+         * @param data the data to use for this vertex buffer
+         * @param kind the vertex buffer kind
+         * @param updatable whether the data is updatable
+         * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
+         * @param stride the stride (optional)
+         * @param instanced whether the buffer is instanced (optional)
+         * @param offset the offset of the data (optional)
+         * @param size the number of components (optional)
+         * @param type the type of the component (optional)
+         * @param normalized whether the data contains normalized data (optional)
+         * @param useBytes set to true if stride and offset are in bytes (optional)
+         */
         constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized = false, useBytes = false) {
             if (data instanceof Buffer) {
                 this._buffer = data;
@@ -205,6 +247,11 @@
             }
         }
 
+        /**
+         * Enumerates each value of this vertex buffer as numbers.
+         * @param count the number of values to enumerate
+         * @param callback the callback function called for each value
+         */
         public forEach(count: number, callback: (value: number, index: number) => void): void {
             VertexBuffer.ForEach(this._buffer.getData()!, this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
         }
@@ -310,6 +357,11 @@
             }
         }
 
+        /**
+         * Gets the byte length of the given type.
+         * @param type the type
+         * @returns the number of bytes
+         */
         public static GetTypeByteLength(type: number): number {
             switch (type) {
                 case VertexBuffer.BYTE:
@@ -326,6 +378,17 @@
             }
         }
 
+        /**
+         * Enumerates each value of the given parameters as numbers.
+         * @param data the data to enumerate
+         * @param byteOffset the byte offset of the data
+         * @param byteStride the byte stride of the data
+         * @param componentCount the number of components per element
+         * @param componentType the type of the component
+         * @param count the total number of components
+         * @param normalized whether the data is normalized
+         * @param callback the callback function called for each value
+         */
         public static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void {
             if (data instanceof Array) {
                 let offset = byteOffset / 4;

+ 2 - 0
src/Tools/babylon.tools.ts

@@ -116,6 +116,8 @@
         /**
          * Provides a slice function that will work even on IE
          * @param data defines the array to slice
+         * @param start defines the start of the data (optional)
+         * @param end defines the end of the data (optional)
          * @returns the new sliced array
          */
         public static Slice<T>(data: T, start?: number, end?: number): T {

+ 4 - 0
src/babylon.types.ts

@@ -6,5 +6,9 @@ module BABYLON {
 
     export type FloatArray = number[] | Float32Array;
     export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
+
+    /**
+     * Alias for types that can be used by a Buffer or VertexBuffer.
+     */
     export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
 }