three.js 源碼注釋(二十六)Core/BufferAttribute.js
俺也是剛開始學,好多地兒肯定不對還請見諒.
以下代碼是THREE.JS 源碼檔案中Core/BufferAttribute.js檔案的注釋.
/** * @author mrdoob / http://mrdoob.com/ *//*///BufferAttribute類用來儲存於bufferGeometry相關聯的屬性資料,更多細節可以參考官方的範例http://threejs.org//// 這個類用來儲存內建屬性例如頂點位置,法線,顏色,等,但也可以用於儲存bufferGeometry對象的自訂屬性.///BufferAttribute對象的功能函數採用定義構造的函數原型對象來實現./// TODO:增加一個基類setAttr(index,item,itemSize)根據跟多不同的屬性相長度設定屬性///*////BufferAttribute///屬性數組///屬性相長度///返回新的屬性數組THREE.BufferAttribute = function ( array, itemSize ) {this.array = array;//BufferAttribute的array屬性this.itemSize = itemSize;//BufferAttribute的itemSize屬性};/********************************************下面是BufferAttribute對象提供的功能函數.****************************************/THREE.BufferAttribute.prototype = {constructor: THREE.BufferAttribute,//構造器,返回對建立此對象BufferAttribute函數的引用./*///get length 方法用來擷取BufferAttribute的數組長度///NOTE: get length()BufferAttribute.prototype.length(),這種用法在除ie瀏覽器以外的瀏覽器上可以使用.*////get length///返回BufferAttribute的數組長度get length () {return this.array.length;//返回BufferAttribute的數組長度},/*///set方法用來重新設定BufferAttribute的屬性數組*////set///屬性數組///返回新的BufferAttribute屬性對象set: function ( value ) {this.array.set( value );return this;//返回新的BufferAttribute屬性對象},/*///setX方法用來重新設定含有3個屬性相的BufferAttribute屬性數組的第一個分量/// NOTE:setX方法中,屬性數組的長度是屬性相的長度乘以屬性的個數.比如要存放100個點的座標,座標有3個屬性相,那麼屬性數組的長度是300,如果想改變第30個點的x座標就將index設為30*////setX///屬性數組的索引///屬性數組的第一個分量///返回新的BufferAttribute屬性對象setX: function ( index, x ) {this.array[ index * this.itemSize ] = x;return this;//返回新的BufferAttribute屬性對象},/*///setY方法用來重新設定含有3個屬性相的BufferAttribute屬性數組的第二個分量/// NOTE:setY方法中,屬性數組的長度是屬性相的長度乘以屬性的個數.比如要存放100個點的座標,座標有3個屬性相,那麼屬性數組的長度是300,如果想改變第30個點的Y座標就將index設為30*////setY///屬性數組的索引///屬性數組的第一個分量///返回新的BufferAttribute屬性對象setY: function ( index, y ) {this.array[ index * this.itemSize + 1 ] = y;return this;//返回新的BufferAttribute屬性對象},/*///setZ方法用來重新設定含有3個屬性相的BufferAttribute屬性數組的第三個分量/// NOTE:setY方法中,屬性數組的長度是屬性相的長度乘以屬性的個數.比如要存放100個點的座標,座標有3個屬性相,那麼屬性數組的長度是300,如果想改變第30個點的Z座標就將index設為30*////setZ///屬性數組的索引///屬性數組的第一個分量///返回新的BufferAttribute屬性對象setZ: function ( index, z ) {this.array[ index * this.itemSize + 2 ] = z;return this;//返回新的BufferAttribute屬性對象},/*///setXY方法用來重新設定含有3個屬性相的BufferAttribute屬性數組的第一個和第二個分量/// NOTE:setXY方法中,屬性數組的長度是屬性相的長度乘以屬性的個數.比如要存放100個點的座標,座標有3個屬性相,那麼屬性數組的長度是300,如果想改變第30個點的x,y座標就將index設為30*////setXY///屬性數組的索引///屬性數組的第一個分量///屬性數組的第二個分量///返回新的BufferAttribute屬性對象setXY: function ( index, x, y ) {index *= this.itemSize;this.array[ index ] = x;this.array[ index + 1 ] = y;return this;//返回新的BufferAttribute屬性對象},/*///setXYZ方法用來重新設定含有3個屬性相的BufferAttribute屬性數組的第一個,第二個和第三個分量/// NOTE:setXY方法中,屬性數組的長度是屬性相的長度乘以屬性的個數.比如要存放100個點的座標,座標有3個屬性相,那麼屬性數組的長度是300,如果想改變第30個點的x,y,z座標就將index設為30*////setXYZ///屬性數組的索引///屬性數組的第一個分量///屬性數組的第二個分量///屬性數組的第三個分量///返回新的BufferAttribute屬性對象setXYZ: function ( index, x, y, z ) {index *= this.itemSize;this.array[ index ] = x;this.array[ index + 1 ] = y;this.array[ index + 2 ] = z;return this;//返回新的BufferAttribute屬性對象},/*///setXYZW方法用來重新設定含有3個屬性相的BufferAttribute屬性數組的第一個,第二個和第三個,第四個分量/// NOTE:setXYZW方法中,屬性數組的長度是屬性相的長度乘以屬性的個數.比如要存放100個點的座標,座標有4個屬性相,那麼屬性數組的長度是400,如果想改變第30個點的x,y,z,w座標就將index設為30*////setXYZW///屬性數組的索引///屬性數組的第一個分量///屬性數組的第二個分量///屬性數組的第三個分量///屬性數組的第四個分量///返回新的BufferAttribute屬性對象setXYZW: function ( index, x, y, z, w ) {index *= this.itemSize;this.array[ index ] = x;this.array[ index + 1 ] = y;this.array[ index + 2 ] = z;this.array[ index + 3 ] = w;return this;//返回新的BufferAttribute屬性對象}};/**************************************************************************************下面這些方法是定義不同資料類型的屬性,已經在新版本中刪除,這裡保留是為了向後相容.***********************************************************************************/THREE.Int8Attribute = function ( data, itemSize ) {console.warn( 'THREE.Int8Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );return new THREE.BufferAttribute( data, itemSize );};THREE.Uint8Attribute = function ( data, itemSize ) {console.warn( 'THREE.Uint8Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );return new THREE.BufferAttribute( data, itemSize );};THREE.Uint8ClampedAttribute = function ( data, itemSize ) {console.warn( 'THREE.Uint8ClampedAttribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );return new THREE.BufferAttribute( data, itemSize );};THREE.Int16Attribute = function ( data, itemSize ) {console.warn( 'THREE.Int16Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );return new THREE.BufferAttribute( data, itemSize );};THREE.Uint16Attribute = function ( data, itemSize ) {console.warn( 'THREE.Uint16Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );return new THREE.BufferAttribute( data, itemSize );};THREE.Int32Attribute = function ( data, itemSize ) {console.warn( 'THREE.Int32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );return new THREE.BufferAttribute( data, itemSize );};THREE.Uint32Attribute = function ( data, itemSize ) {console.warn( 'THREE.Uint32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );return new THREE.BufferAttribute( data, itemSize );};THREE.Float32Attribute = function ( data, itemSize ) {console.warn( 'THREE.Float32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );return new THREE.BufferAttribute( data, itemSize );};THREE.Float64Attribute = function ( data, itemSize ) {console.warn( 'THREE.Float64Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );return new THREE.BufferAttribute( data, itemSize );};
商域無疆 (http://blog.csdn.net/omni360/)
本文遵循“署名-非商業用途-保持一致”創作公用協議
轉載請保留此句:商域無疆 - 本部落格專註於 敏捷開發及移動和物聯裝置研究:資料視覺效果、GOLANG、Html5、WEBGL、THREE.JS,否則,出自本部落格的文章拒絕轉載或再轉載,謝謝合作。
以下代碼是THREE.JS 源碼檔案中Core/BufferAttribute.js檔案的注釋.
更多更新在 : https://github.com/omni360/three.js.sourcecode