Skip to content

Commit 371fb5e

Browse files
committed
Added normals, removed Vec3
1 parent 0e2911c commit 371fb5e

1 file changed

Lines changed: 37 additions & 47 deletions

File tree

src/geom/mesh/Vertex.js

Lines changed: 37 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66

77
var Class = require('../../utils/Class');
8-
var Vector3 = require('../../math/Vector3');
9-
var Utils = require('../../renderer/webgl/Utils');
108

119
/**
1210
* @classdesc
@@ -17,7 +15,6 @@ var Utils = require('../../renderer/webgl/Utils');
1715
*
1816
* @class Vertex
1917
* @memberof Phaser.Geom.Mesh
20-
* @extends Phaser.Math.Vector3
2118
* @constructor
2219
* @since 3.50.0
2320
*
@@ -31,43 +28,69 @@ var Utils = require('../../renderer/webgl/Utils');
3128
*/
3229
var Vertex = new Class({
3330

34-
Extends: Vector3,
35-
3631
initialize:
3732

38-
function Vertex (x, y, z, u, v, color, alpha)
33+
function Vertex (x, y, z, u, v, normalX, normalY, normalZ, color, alpha)
3934
{
35+
if (normalX === undefined) { normalX = 0; }
36+
if (normalY === undefined) { normalY = 0; }
37+
if (normalZ === undefined) { normalZ = 0; }
4038
if (color === undefined) { color = 0xffffff; }
4139
if (alpha === undefined) { alpha = 1; }
4240

43-
Vector3.call(this, x, y, z);
44-
4541
/**
46-
* The projected x coordinate of this vertex.
42+
* The x coordinate of this vertex.
4743
*
4844
* @name Phaser.Geom.Mesh.Vertex#vx
4945
* @type {number}
5046
* @since 3.50.0
5147
*/
52-
this.vx = 0;
48+
this.x = x;
5349

5450
/**
55-
* The projected y coordinate of this vertex.
51+
* The y coordinate of this vertex.
5652
*
5753
* @name Phaser.Geom.Mesh.Vertex#vy
5854
* @type {number}
5955
* @since 3.50.0
6056
*/
61-
this.vy = 0;
57+
this.y = y;
6258

6359
/**
64-
* The projected z coordinate of this vertex.
60+
* The z coordinate of this vertex.
6561
*
6662
* @name Phaser.Geom.Mesh.Vertex#vz
6763
* @type {number}
6864
* @since 3.50.0
6965
*/
70-
this.vz = 0;
66+
this.z = z;
67+
68+
/**
69+
* The x normal of this vertex.
70+
*
71+
* @name Phaser.Geom.Mesh.Vertex#nx
72+
* @type {number}
73+
* @since 3.50.0
74+
*/
75+
this.nx = normalX;
76+
77+
/**
78+
* The y normal of this vertex.
79+
*
80+
* @name Phaser.Geom.Mesh.Vertex#ny
81+
* @type {number}
82+
* @since 3.50.0
83+
*/
84+
this.ny = normalY;
85+
86+
/**
87+
* The z normal of this vertex.
88+
*
89+
* @name Phaser.Geom.Mesh.Vertex#nz
90+
* @type {number}
91+
* @since 3.50.0
92+
*/
93+
this.nz = normalZ;
7194

7295
/**
7396
* UV u coordinate of this vertex.
@@ -115,7 +138,6 @@ var Vertex = new Class({
115138
* @param {Phaser.Math.Matrix4} transformMatrix - The transform matrix to apply to this vertex.
116139
* @param {number} width - The width of the parent Mesh.
117140
* @param {number} height - The height of the parent Mesh.
118-
*/
119141
transformCoordinatesLocal: function (transformMatrix, width, height)
120142
{
121143
var x = this.x;
@@ -133,39 +155,7 @@ var Vertex = new Class({
133155
this.vy = -(ty / tw) * height;
134156
this.vz = (tz / tw);
135157
},
136-
137-
/**
138-
* Loads this vertex into the given Typed Arrays.
139-
*
140-
* @method Phaser.Geom.Mesh.Model#load
141-
* @since 3.50.0
142-
*
143-
* @param {Float32Array} F32 - The Float32 Array to put the position data in.
144-
* @param {Uint32Array} U32 - The Uint32 Array to put the color data in.
145-
* @param {number} offset - The vertex offset to place the data at.
146-
* @param {number} textureUnit - The currently bound texture unit.
147-
* @param {number} alpha - The alpha value.
148-
* @param {number} a - The transform matrix a value.
149-
* @param {number} b - The transform matrix b value.
150-
* @param {number} c - The transform matrix c value.
151-
* @param {number} d - The transform matrix d value.
152-
* @param {number} e - The transform matrix e value.
153-
* @param {number} f - The transform matrix f value.
154-
*
155-
* @return {number} The new vertex offset.
156158
*/
157-
load: function (F32, U32, offset, textureUnit, tintEffect, alpha, a, b, c, d, e, f)
158-
{
159-
F32[++offset] = this.vx * a + this.vy * c + e;
160-
F32[++offset] = this.vx * b + this.vy * d + f;
161-
F32[++offset] = this.u;
162-
F32[++offset] = this.v;
163-
F32[++offset] = textureUnit;
164-
F32[++offset] = tintEffect;
165-
U32[++offset] = Utils.getTintAppendFloatAlpha(this.color, alpha * this.alpha);
166-
167-
return offset;
168-
}
169159

170160
});
171161

0 commit comments

Comments
 (0)