mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
Remove TypesWebGL
This commit is contained in:
@@ -1,676 +0,0 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011-2012 cocos2d-x.org
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
// define some types with ArrayBuffer for WebGL
|
||||
|
||||
/**
|
||||
* @class WebGLColor
|
||||
*/
|
||||
/**
|
||||
* @method constructor
|
||||
* @param {Number} r
|
||||
* @param {Number} g
|
||||
* @param {Number} b
|
||||
* @param {Number} a
|
||||
* @param {Array} arrayBuffer
|
||||
* @param {Number} offset
|
||||
*/
|
||||
cc.WebGLColor = function (r, g, b, a, arrayBuffer, offset) {
|
||||
this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.WebGLColor.BYTES_PER_ELEMENT);
|
||||
this._offset = offset || 0;
|
||||
|
||||
var locArrayBuffer = this._arrayBuffer, locOffset = this._offset;
|
||||
this._view = new Uint8Array(locArrayBuffer, locOffset, 4);
|
||||
|
||||
this._view[0] = r || 0;
|
||||
this._view[1] = g || 0;
|
||||
this._view[2] = b || 0;
|
||||
|
||||
if (typeof a === 'number') {
|
||||
this._view[3] = a;
|
||||
}
|
||||
else {
|
||||
this._view[3] = 255;
|
||||
this.a_undefined = true;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @property BYTES_PER_ELEMENT
|
||||
* @final
|
||||
* @type {Number}
|
||||
*/
|
||||
cc.WebGLColor.BYTES_PER_ELEMENT = 4;
|
||||
var _p = cc.WebGLColor.prototype;
|
||||
_p._getR = function () {
|
||||
return this._view[0];
|
||||
};
|
||||
_p._setR = function (value) {
|
||||
this._view[0] = value < 0 ? 0 : value;
|
||||
};
|
||||
_p._getG = function () {
|
||||
return this._view[1];
|
||||
};
|
||||
_p._setG = function (value) {
|
||||
this._view[1] = value < 0 ? 0 : value;
|
||||
};
|
||||
_p._getB = function () {
|
||||
return this._view[2];
|
||||
};
|
||||
_p._setB = function (value) {
|
||||
this._view[2] = value < 0 ? 0 : value;
|
||||
};
|
||||
_p._getA = function () {
|
||||
return this._view[3];
|
||||
};
|
||||
_p._setA = function (value) {
|
||||
this._view[3] = value < 0 ? 0 : value;
|
||||
};
|
||||
/** @expose */
|
||||
_p.r;
|
||||
cc.js.getset(_p, "r", _p._getR, _p._setR);
|
||||
/** @expose */
|
||||
_p.g;
|
||||
cc.js.getset(_p, "g", _p._getG, _p._setG);
|
||||
/** @expose */
|
||||
_p.b;
|
||||
cc.js.getset(_p, "b", _p._getB, _p._setB);
|
||||
/** @expose */
|
||||
_p.a;
|
||||
cc.js.getset(_p, "a", _p._getA, _p._setA);
|
||||
|
||||
//redefine cc.Vertex2F
|
||||
/**
|
||||
* @class Vertex2F
|
||||
* @contructor
|
||||
*/
|
||||
/**
|
||||
* @method constructor
|
||||
* @param {Number} x
|
||||
* @param {Number}y
|
||||
* @param {Array} arrayBuffer
|
||||
* @param {Number}offset
|
||||
*/
|
||||
cc.Vertex2F = function (x, y, arrayBuffer, offset) {
|
||||
this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT);
|
||||
this._offset = offset || 0;
|
||||
|
||||
this._view = new Float32Array(this._arrayBuffer, this._offset, 2);
|
||||
this._view[0] = x || 0;
|
||||
this._view[1] = y || 0;
|
||||
};
|
||||
/**
|
||||
* @property BYTES_PER_ELEMENT
|
||||
* @final
|
||||
* @type {Number}
|
||||
*/
|
||||
cc.Vertex2F.BYTES_PER_ELEMENT = 8;
|
||||
|
||||
var _p = cc.Vertex2F.prototype;
|
||||
_p._getX = function () {
|
||||
return this._view[0];
|
||||
};
|
||||
_p._setX = function (xValue) {
|
||||
this._view[0] = xValue;
|
||||
};
|
||||
_p._getY = function () {
|
||||
return this._view[1];
|
||||
};
|
||||
_p._setY = function (yValue) {
|
||||
this._view[1] = yValue;
|
||||
};
|
||||
cc.js.getset(_p, "x", _p._getX, _p._setX);
|
||||
cc.js.getset(_p, "y", _p._getY, _p._setY);
|
||||
|
||||
// redefine cc.Vertex3F
|
||||
/**
|
||||
* @class Vertex3F
|
||||
*/
|
||||
/**
|
||||
* @method constructor
|
||||
* @param {Number} x
|
||||
* @param {Number} y
|
||||
* @param {Number}z
|
||||
* @param {Array} arrayBuffer
|
||||
* @param {Number} offset
|
||||
*/
|
||||
cc.Vertex3F = function (x, y, z, arrayBuffer, offset) {
|
||||
this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT);
|
||||
this._offset = offset || 0;
|
||||
|
||||
var locArrayBuffer = this._arrayBuffer, locOffset = this._offset;
|
||||
this._view = new Float32Array(locArrayBuffer, locOffset, 3);
|
||||
this._view[0] = x || 0;
|
||||
this._view[1] = y || 0;
|
||||
this._view[2] = z || 0;
|
||||
};
|
||||
/**
|
||||
* @property BYTES_PER_ELEMENT
|
||||
* @final
|
||||
* @type {Number}
|
||||
*/
|
||||
cc.Vertex3F.BYTES_PER_ELEMENT = 12;
|
||||
|
||||
_p = cc.Vertex3F.prototype;
|
||||
_p._getX = function () {
|
||||
return this._view[0];
|
||||
};
|
||||
_p._setX = function (xValue) {
|
||||
this._view[0] = xValue;
|
||||
};
|
||||
_p._getY = function () {
|
||||
return this._view[1];
|
||||
};
|
||||
_p._setY = function (yValue) {
|
||||
this._view[1] = yValue;
|
||||
};
|
||||
_p._getZ = function () {
|
||||
return this._view[2];
|
||||
};
|
||||
_p._setZ = function (zValue) {
|
||||
this._view[2] = zValue;
|
||||
};
|
||||
cc.js.getset(_p, "x", _p._getX, _p._setX);
|
||||
cc.js.getset(_p, "y", _p._getY, _p._setY);
|
||||
cc.js.getset(_p, "z", _p._getZ, _p._setZ);
|
||||
|
||||
// redefine cc.Tex2F
|
||||
/**
|
||||
* @class Tex2F
|
||||
*/
|
||||
/**
|
||||
* @method constructor
|
||||
* @param {Number} u
|
||||
* @param {Number} v
|
||||
* @param {Array} arrayBuffer
|
||||
* @param {Number} offset
|
||||
*/
|
||||
cc.Tex2F = function (u, v, arrayBuffer, offset) {
|
||||
this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT);
|
||||
this._offset = offset || 0;
|
||||
|
||||
this._view = new Float32Array(this._arrayBuffer, this._offset, 2);
|
||||
this._view[0] = u || 0;
|
||||
this._view[1] = v || 0;
|
||||
};
|
||||
/**
|
||||
* @property BYTES_PER_ELEMENT
|
||||
* @final
|
||||
* @type {Number}
|
||||
*/
|
||||
cc.Tex2F.BYTES_PER_ELEMENT = 8;
|
||||
|
||||
_p = cc.Tex2F.prototype;
|
||||
_p._getU = function () {
|
||||
return this._view[0];
|
||||
};
|
||||
_p._setU = function (xValue) {
|
||||
this._view[0] = xValue;
|
||||
};
|
||||
_p._getV = function () {
|
||||
return this._view[1];
|
||||
};
|
||||
_p._setV = function (yValue) {
|
||||
this._view[1] = yValue;
|
||||
};
|
||||
cc.js.getset(_p, "u", _p._getU, _p._setU);
|
||||
cc.js.getset(_p, "v", _p._getV, _p._setV);
|
||||
|
||||
//redefine cc.Quad2
|
||||
/**
|
||||
* @class Quad2
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method constructor
|
||||
* @param {Vertex2F} tl
|
||||
* @param {Vertex2F} tr
|
||||
* @param {Vertex2F} bl
|
||||
* @param {Vertex2F} br
|
||||
* @param {Array} arrayBuffer
|
||||
* @param {Number} offset
|
||||
*/
|
||||
cc.Quad2 = function (tl, tr, bl, br, arrayBuffer, offset) {
|
||||
this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT);
|
||||
this._offset = offset || 0;
|
||||
|
||||
var locArrayBuffer = this._arrayBuffer, locOffset = this._offset, locElementLen = cc.Vertex2F.BYTES_PER_ELEMENT;
|
||||
this._tl = tl ? new cc.Vertex2F(tl.x, tl.y, locArrayBuffer, locOffset) : new cc.Vertex2F(0, 0, locArrayBuffer, locOffset);
|
||||
locOffset += locElementLen;
|
||||
this._tr = tr ? new cc.Vertex2F(tr.x, tr.y, locArrayBuffer, locOffset) : new cc.Vertex2F(0, 0, locArrayBuffer, locOffset);
|
||||
locOffset += locElementLen;
|
||||
this._bl = bl ? new cc.Vertex2F(bl.x, bl.y, locArrayBuffer, locOffset) : new cc.Vertex2F(0, 0, locArrayBuffer, locOffset);
|
||||
locOffset += locElementLen;
|
||||
this._br = br ? new cc.Vertex2F(br.x, br.y, locArrayBuffer, locOffset) : new cc.Vertex2F(0, 0, locArrayBuffer, locOffset);
|
||||
};
|
||||
/**
|
||||
* @property BYTES_PER_ELEMENT
|
||||
* @final
|
||||
* @type {number}
|
||||
*/
|
||||
cc.Quad2.BYTES_PER_ELEMENT = 32;
|
||||
|
||||
_p = cc.Quad2.prototype;
|
||||
_p._getTL = function () {
|
||||
return this._tl;
|
||||
};
|
||||
_p._setTL = function (tlValue) {
|
||||
this._tl._view[0] = tlValue.x;
|
||||
this._tl._view[1] = tlValue.y;
|
||||
};
|
||||
_p._getTR = function () {
|
||||
return this._tr;
|
||||
};
|
||||
_p._setTR = function (trValue) {
|
||||
this._tr._view[0] = trValue.x;
|
||||
this._tr._view[1] = trValue.y;
|
||||
};
|
||||
_p._getBL = function() {
|
||||
return this._bl;
|
||||
};
|
||||
_p._setBL = function (blValue) {
|
||||
this._bl._view[0] = blValue.x;
|
||||
this._bl._view[1] = blValue.y;
|
||||
};
|
||||
_p._getBR = function () {
|
||||
return this._br;
|
||||
};
|
||||
_p._setBR = function (brValue) {
|
||||
this._br._view[0] = brValue.x;
|
||||
this._br._view[1] = brValue.y;
|
||||
};
|
||||
|
||||
cc.js.getset(_p, "tl", _p._getTL, _p._setTL);
|
||||
cc.js.getset(_p, "tr", _p._getTR, _p._setTR);
|
||||
cc.js.getset(_p, "bl", _p._getBL, _p._setBL);
|
||||
cc.js.getset(_p, "br", _p._getBR, _p._setBR);
|
||||
|
||||
/**
|
||||
* A 3D Quad. 4 * 3 floats
|
||||
* @class Quad3
|
||||
* @constructor
|
||||
*/
|
||||
/**
|
||||
* @method constructor
|
||||
* @param {Vertex3F} bl1
|
||||
* @param {Vertex3F} br1
|
||||
* @param {Vertex3F} tl1
|
||||
* @param {Vertex3F} tr1
|
||||
* @param {Array} arrayBuffer
|
||||
* @param {Number} offset
|
||||
*/
|
||||
cc.Quad3 = function (bl1, br1, tl1, tr1, arrayBuffer, offset) {
|
||||
this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.Quad3.BYTES_PER_ELEMENT);
|
||||
this._offset = offset || 0;
|
||||
|
||||
var locArrayBuffer = this._arrayBuffer, locOffset = this._offset, locElementLen = cc.Vertex3F.BYTES_PER_ELEMENT;
|
||||
this.bl = bl ? new cc.Vertex3F(bl.x, bl.y, bl.z, locArrayBuffer, locOffset) : new cc.Vertex3F(0, 0, 0, locArrayBuffer, locOffset);
|
||||
locOffset += locElementLen;
|
||||
this.br = br ? new cc.Vertex3F(br.x, br.y, br.z, locArrayBuffer, locOffset) : new cc.Vertex3F(0, 0, 0, locArrayBuffer, locOffset);
|
||||
locOffset += locElementLen;
|
||||
this.tl = tl ? new cc.Vertex3F(tl.x, tl.y, tl.z, locArrayBuffer, locOffset) : new cc.Vertex3F(0, 0, 0, locArrayBuffer, locOffset);
|
||||
locOffset += locElementLen;
|
||||
this.tr = tr ? new cc.Vertex3F(tr.x, tr.y, tr.z, locArrayBuffer, locOffset) : new cc.Vertex3F(0, 0, 0, locArrayBuffer, locOffset);
|
||||
};
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
cc.Quad3.BYTES_PER_ELEMENT = 48;
|
||||
|
||||
//redefine cc.V3F_C4B_T2F
|
||||
/**
|
||||
* @class V3F_C4B_T2F
|
||||
*/
|
||||
/**
|
||||
* @method constructor
|
||||
* @param {Vertex3F} vertices
|
||||
* @param {Color} colors
|
||||
* @param {Tex2F} texCoords
|
||||
* @param {Array} arrayBuffer
|
||||
* @param {Number} offset
|
||||
*/
|
||||
cc.V3F_C4B_T2F = function (vertices, colors, texCoords, arrayBuffer, offset) {
|
||||
this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT);
|
||||
this._offset = offset || 0;
|
||||
|
||||
var locArrayBuffer = this._arrayBuffer, locOffset = this._offset;
|
||||
this._vertices = vertices ? new cc.Vertex3F(vertices.x, vertices.y, vertices.z, locArrayBuffer, locOffset) :
|
||||
new cc.Vertex3F(0, 0, 0, locArrayBuffer, locOffset);
|
||||
|
||||
locOffset += cc.Vertex3F.BYTES_PER_ELEMENT;
|
||||
this._colors = colors ? new cc.WebGLColor(colors.r, colors.g, colors.b, colors.a, locArrayBuffer, locOffset) :
|
||||
new cc.WebGLColor(0, 0, 0, 0, locArrayBuffer, locOffset);
|
||||
|
||||
locOffset += cc.WebGLColor.BYTES_PER_ELEMENT;
|
||||
this._texCoords = texCoords ? new cc.Tex2F(texCoords.u, texCoords.v, locArrayBuffer, locOffset) :
|
||||
new cc.Tex2F(0, 0, locArrayBuffer, locOffset);
|
||||
};
|
||||
/**
|
||||
* @method BYTES_PER_ELEMENT
|
||||
* @final
|
||||
* @type {Number}
|
||||
*/
|
||||
cc.V3F_C4B_T2F.BYTES_PER_ELEMENT = 24;
|
||||
|
||||
_p = cc.V3F_C4B_T2F.prototype;
|
||||
_p._getVertices = function () {
|
||||
return this._vertices;
|
||||
};
|
||||
_p._setVertices = function (verticesValue) {
|
||||
var locVertices = this._vertices;
|
||||
locVertices._view[0] = verticesValue.x;
|
||||
locVertices._view[1] = verticesValue.y;
|
||||
locVertices._view[2] = verticesValue.z;
|
||||
};
|
||||
_p._getColor = function () {
|
||||
return this._colors;
|
||||
};
|
||||
_p._setColor = function (colorValue) {
|
||||
var locColors = this._colors;
|
||||
locColors._view[0] = colorValue.r;
|
||||
locColors._view[1] = colorValue.g;
|
||||
locColors._view[2] = colorValue.b;
|
||||
locColors._view[3] = colorValue.a;
|
||||
};
|
||||
_p._getTexCoords = function () {
|
||||
return this._texCoords;
|
||||
};
|
||||
_p._setTexCoords = function (texValue) {
|
||||
this._texCoords._view[0] = texValue.u;
|
||||
this._texCoords._view[1] = texValue.v;
|
||||
};
|
||||
cc.js.getset(_p, "vertices", _p._getVertices, _p._setVertices);
|
||||
cc.js.getset(_p, "colors", _p._getColor, _p._setColor);
|
||||
cc.js.getset(_p, "texCoords", _p._getTexCoords, _p._setTexCoords);
|
||||
|
||||
//redefine cc.V3F_C4B_T2F_Quad
|
||||
/**
|
||||
* @class V3F_C4B_T2F_Quad
|
||||
*/
|
||||
/**
|
||||
* @method constructor
|
||||
* @param {V3F_C4B_T2F} tl
|
||||
* @param {V3F_C4B_T2F} bl
|
||||
* @param {V3F_C4B_T2F} tr
|
||||
* @param {V3F_C4B_T2F} br
|
||||
* @param {Array} arrayBuffer
|
||||
* @param {Number} offset
|
||||
*/
|
||||
cc.V3F_C4B_T2F_Quad = function (tl, bl, tr, br, arrayBuffer, offset) {
|
||||
this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT);
|
||||
this._offset = offset || 0;
|
||||
|
||||
var locArrayBuffer = this._arrayBuffer, locOffset = this._offset, locElementLen = cc.V3F_C4B_T2F.BYTES_PER_ELEMENT;
|
||||
this._tl = tl ? new cc.V3F_C4B_T2F(tl.vertices, tl.colors, tl.texCoords, locArrayBuffer, locOffset) :
|
||||
new cc.V3F_C4B_T2F(null, null, null, locArrayBuffer, locOffset);
|
||||
locOffset += locElementLen;
|
||||
this._bl = bl ? new cc.V3F_C4B_T2F(bl.vertices, bl.colors, bl.texCoords, locArrayBuffer, locOffset) :
|
||||
new cc.V3F_C4B_T2F(null, null, null, locArrayBuffer, locOffset);
|
||||
locOffset += locElementLen;
|
||||
this._tr = tr ? new cc.V3F_C4B_T2F(tr.vertices, tr.colors, tr.texCoords, locArrayBuffer, locOffset) :
|
||||
new cc.V3F_C4B_T2F(null, null, null, locArrayBuffer, locOffset);
|
||||
locOffset += locElementLen;
|
||||
this._br = br ? new cc.V3F_C4B_T2F(br.vertices, br.colors, br.texCoords, locArrayBuffer, locOffset) :
|
||||
new cc.V3F_C4B_T2F(null, null, null, locArrayBuffer, locOffset);
|
||||
};
|
||||
/**
|
||||
* @property BYTES_PER_ELEMENT
|
||||
* @final
|
||||
* @type {Number}
|
||||
*/
|
||||
cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT = 96;
|
||||
_p = cc.V3F_C4B_T2F_Quad.prototype;
|
||||
_p._getTL = function () {
|
||||
return this._tl;
|
||||
};
|
||||
_p._setTL = function (tlValue) {
|
||||
var locTl = this._tl;
|
||||
locTl.vertices = tlValue.vertices;
|
||||
locTl.colors = tlValue.colors;
|
||||
locTl.texCoords = tlValue.texCoords;
|
||||
};
|
||||
_p._getBL = function () {
|
||||
return this._bl;
|
||||
};
|
||||
_p._setBL = function (blValue) {
|
||||
var locBl = this._bl;
|
||||
locBl.vertices = blValue.vertices;
|
||||
locBl.colors = blValue.colors;
|
||||
locBl.texCoords = blValue.texCoords;
|
||||
};
|
||||
_p._getTR = function () {
|
||||
return this._tr;
|
||||
};
|
||||
_p._setTR = function (trValue) {
|
||||
var locTr = this._tr;
|
||||
locTr.vertices = trValue.vertices;
|
||||
locTr.colors = trValue.colors;
|
||||
locTr.texCoords = trValue.texCoords;
|
||||
};
|
||||
_p._getBR = function () {
|
||||
return this._br;
|
||||
};
|
||||
_p._setBR = function (brValue) {
|
||||
var locBr = this._br;
|
||||
locBr.vertices = brValue.vertices;
|
||||
locBr.colors = brValue.colors;
|
||||
locBr.texCoords = brValue.texCoords;
|
||||
};
|
||||
_p._getArrayBuffer = function () {
|
||||
return this._arrayBuffer;
|
||||
};
|
||||
|
||||
cc.js.getset(_p, "tl", _p._getTL, _p._setTL);
|
||||
cc.js.getset(_p, "tr", _p._getTR, _p._setTR);
|
||||
cc.js.getset(_p, "bl", _p._getBL, _p._setBL);
|
||||
cc.js.getset(_p, "br", _p._getBR, _p._setBR);
|
||||
cc.js.get(_p, "arrayBuffer", _p._getArrayBuffer);
|
||||
|
||||
/**
|
||||
*
|
||||
* @module cc
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method V3F_C4B_T2F_QuadZero
|
||||
* @returns {V3F_C4B_T2F_Quad}
|
||||
*/
|
||||
cc.V3F_C4B_T2F_QuadZero = function () {
|
||||
return new cc.V3F_C4B_T2F_Quad();
|
||||
};
|
||||
|
||||
/**
|
||||
* @method V3F_C4B_T2F_QuadCopy
|
||||
* @param {V3F_C4B_T2F_Quad} sourceQuad
|
||||
* @return {V3F_C4B_T2F_Quad}
|
||||
*/
|
||||
cc.V3F_C4B_T2F_QuadCopy = function (sourceQuad) {
|
||||
if (!sourceQuad)
|
||||
return cc.V3F_C4B_T2F_QuadZero();
|
||||
|
||||
//return new cc.V3F_C4B_T2F_Quad(sourceQuad,tl,sourceQuad,bl,sourceQuad.tr,sourceQuad.br,null,0);
|
||||
var srcTL = sourceQuad.tl, srcBL = sourceQuad.bl, srcTR = sourceQuad.tr, srcBR = sourceQuad.br;
|
||||
return {
|
||||
tl: {vertices: {x: srcTL.vertices.x, y: srcTL.vertices.y, z: srcTL.vertices.z},
|
||||
colors: {r: srcTL.colors.r, g: srcTL.colors.g, b: srcTL.colors.b, a: srcTL.colors.a},
|
||||
texCoords: {u: srcTL.texCoords.u, v: srcTL.texCoords.v}},
|
||||
bl: {vertices: {x: srcBL.vertices.x, y: srcBL.vertices.y, z: srcBL.vertices.z},
|
||||
colors: {r: srcBL.colors.r, g: srcBL.colors.g, b: srcBL.colors.b, a: srcBL.colors.a},
|
||||
texCoords: {u: srcBL.texCoords.u, v: srcBL.texCoords.v}},
|
||||
tr: {vertices: {x: srcTR.vertices.x, y: srcTR.vertices.y, z: srcTR.vertices.z},
|
||||
colors: {r: srcTR.colors.r, g: srcTR.colors.g, b: srcTR.colors.b, a: srcTR.colors.a},
|
||||
texCoords: {u: srcTR.texCoords.u, v: srcTR.texCoords.v}},
|
||||
br: {vertices: {x: srcBR.vertices.x, y: srcBR.vertices.y, z: srcBR.vertices.z},
|
||||
colors: {r: srcBR.colors.r, g: srcBR.colors.g, b: srcBR.colors.b, a: srcBR.colors.a},
|
||||
texCoords: {u: srcBR.texCoords.u, v: srcBR.texCoords.v}}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @method V3F_C4B_T2F_QuadsCopy
|
||||
* @param {Array} sourceQuads
|
||||
* @returns {Array}
|
||||
*/
|
||||
cc.V3F_C4B_T2F_QuadsCopy = function (sourceQuads) {
|
||||
if (!sourceQuads)
|
||||
return [];
|
||||
|
||||
var retArr = [];
|
||||
for (var i = 0; i < sourceQuads.length; i++) {
|
||||
retArr.push(cc.V3F_C4B_T2F_QuadCopy(sourceQuads[i]));
|
||||
}
|
||||
return retArr;
|
||||
};
|
||||
|
||||
//redefine cc.V2F_C4B_T2F
|
||||
/**
|
||||
* @class V2F_C4B_T2F
|
||||
*/
|
||||
/**
|
||||
* @method constructor
|
||||
* @param {Vertex2F} vertices
|
||||
* @param {Color} colors
|
||||
* @param {Tex2F} texCoords
|
||||
* @param {Array} arrayBuffer
|
||||
* @param {Number} offset
|
||||
*/
|
||||
cc.V2F_C4B_T2F = function (vertices, colors, texCoords, arrayBuffer, offset) {
|
||||
this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.V2F_C4B_T2F.BYTES_PER_ELEMENT);
|
||||
this._offset = offset || 0;
|
||||
|
||||
var locArrayBuffer = this._arrayBuffer, locOffset = this._offset;
|
||||
this._vertices = vertices ? new cc.Vertex2F(vertices.x, vertices.y, locArrayBuffer, locOffset) :
|
||||
new cc.Vertex2F(0, 0, locArrayBuffer, locOffset);
|
||||
locOffset += cc.Vertex2F.BYTES_PER_ELEMENT;
|
||||
this._colors = colors ? new cc.WebGLColor(colors.r, colors.g, colors.b, colors.a, locArrayBuffer, locOffset) :
|
||||
new cc.WebGLColor(0, 0, 0, 0, locArrayBuffer, locOffset);
|
||||
locOffset += cc.WebGLColor.BYTES_PER_ELEMENT;
|
||||
this._texCoords = texCoords ? new cc.Tex2F(texCoords.u, texCoords.v, locArrayBuffer, locOffset) :
|
||||
new cc.Tex2F(0, 0, locArrayBuffer, locOffset);
|
||||
};
|
||||
|
||||
/**
|
||||
* @property BYTES_PER_ELEMENT
|
||||
* @final
|
||||
* @type {Number}
|
||||
*/
|
||||
cc.V2F_C4B_T2F.BYTES_PER_ELEMENT = 20;
|
||||
_p = cc.V2F_C4B_T2F.prototype;
|
||||
_p._getVertices = function () {
|
||||
return this._vertices;
|
||||
};
|
||||
_p._setVertices = function (verticesValue) {
|
||||
this._vertices._view[0] = verticesValue.x;
|
||||
this._vertices._view[1] = verticesValue.y;
|
||||
};
|
||||
_p._getColor = function () {
|
||||
return this._colors;
|
||||
};
|
||||
_p._setColor = function (colorValue) {
|
||||
var locColors = this._colors;
|
||||
locColors._view[0] = colorValue.r;
|
||||
locColors._view[1] = colorValue.g;
|
||||
locColors._view[2] = colorValue.b;
|
||||
locColors._view[3] = colorValue.a;
|
||||
};
|
||||
_p._getTexCoords = function () {
|
||||
return this._texCoords;
|
||||
};
|
||||
_p._setTexCoords = function (texValue) {
|
||||
this._texCoords._view[0] = texValue.u;
|
||||
this._texCoords._view[1] = texValue.v;
|
||||
};
|
||||
|
||||
cc.js.getset(_p, "vertices", _p._getVertices, _p._setVertices);
|
||||
cc.js.getset(_p, "colors", _p._getColor, _p._setColor);
|
||||
cc.js.getset(_p, "texCoords", _p._getTexCoords, _p._setTexCoords);
|
||||
|
||||
//redefine cc.V2F_C4B_T2F_Triangle
|
||||
/**
|
||||
* @class V2F_C4B_T2F_Triangle
|
||||
*/
|
||||
/**
|
||||
* @method constructor
|
||||
* @param {V2F_C4B_T2F} a
|
||||
* @param {V2F_C4B_T2F} b
|
||||
* @param {V2F_C4B_T2F} c
|
||||
* @param {Array} arrayBuffer
|
||||
* @param {Number} offset
|
||||
*/
|
||||
cc.V2F_C4B_T2F_Triangle = function (a, b, c, arrayBuffer, offset) {
|
||||
this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT);
|
||||
this._offset = offset || 0;
|
||||
|
||||
var locArrayBuffer = this._arrayBuffer, locOffset = this._offset, locElementLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
|
||||
this._a = a ? new cc.V2F_C4B_T2F(a.vertices, a.colors, a.texCoords, locArrayBuffer, locOffset) :
|
||||
new cc.V2F_C4B_T2F(null, null, null, locArrayBuffer, locOffset);
|
||||
locOffset += locElementLen;
|
||||
this._b = b ? new cc.V2F_C4B_T2F(b.vertices, b.colors, b.texCoords, locArrayBuffer, locOffset) :
|
||||
new cc.V2F_C4B_T2F(null, null, null, locArrayBuffer, locOffset);
|
||||
locOffset += locElementLen;
|
||||
this._c = c ? new cc.V2F_C4B_T2F(c.vertices, c.colors, c.texCoords, locArrayBuffer, locOffset) :
|
||||
new cc.V2F_C4B_T2F(null, null, null, locArrayBuffer, locOffset);
|
||||
};
|
||||
/**
|
||||
* property BYTES_PER_ELEMENT
|
||||
* @final
|
||||
* @type {Number}
|
||||
*/
|
||||
cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT = 60;
|
||||
_p = cc.V2F_C4B_T2F_Triangle.prototype;
|
||||
_p._getA = function () {
|
||||
return this._a;
|
||||
};
|
||||
_p._setA = function (aValue) {
|
||||
var locA = this._a;
|
||||
locA.vertices = aValue.vertices;
|
||||
locA.colors = aValue.colors;
|
||||
locA.texCoords = aValue.texCoords;
|
||||
};
|
||||
_p._getB = function () {
|
||||
return this._b;
|
||||
};
|
||||
_p._setB = function (bValue) {
|
||||
var locB = this._b;
|
||||
locB.vertices = bValue.vertices;
|
||||
locB.colors = bValue.colors;
|
||||
locB.texCoords = bValue.texCoords;
|
||||
};
|
||||
_p._getC = function () {
|
||||
return this._c;
|
||||
};
|
||||
_p._setC = function (cValue) {
|
||||
var locC = this._c;
|
||||
locC.vertices = cValue.vertices;
|
||||
locC.colors = cValue.colors;
|
||||
locC.texCoords = cValue.texCoords;
|
||||
};
|
||||
|
||||
cc.js.getset(_p, "a", _p._getA, _p._setA);
|
||||
cc.js.getset(_p, "b", _p._getB, _p._setB);
|
||||
cc.js.getset(_p, "c", _p._getC, _p._setC);
|
||||
@@ -34,6 +34,5 @@ require('./CCRect');
|
||||
require('./CCColor');
|
||||
require('./CCTypes');
|
||||
require('./CCAffineTransform');
|
||||
require('./CCTypesWebGL');
|
||||
|
||||
cc.vmath = require('../renderer/render-engine').math;
|
||||
|
||||
Reference in New Issue
Block a user