Skip to content

Commit bd25dbc

Browse files
committed
Added per-model cull mode
1 parent 0410c9f commit bd25dbc

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/geom/mesh/Model.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,22 @@ var Model = new Class({
239239
*/
240240
this.transformMatrix = new Matrix4();
241241

242+
/**
243+
* The culling mode used by this Model during rendering.
244+
*
245+
* Specifies whether front or back facing polygons are candidates
246+
* for culling. The default value is `gl.BACK`. Possible values are:
247+
*
248+
* `gl.FRONT` (1028)
249+
* `gl.BACK` (1029)
250+
* `gl.FRONT_AND_BACK` (1032)
251+
*
252+
* @name Phaser.Geom.Mesh.Model#cullMode
253+
* @type {GLenum}
254+
* @since 3.50.0
255+
*/
256+
this.cullMode = 1029;
257+
242258
/**
243259
* An internal cache, used to compare position, rotation, scale and verts data
244260
* each frame, to avoid math calculates in `preUpdate`.

src/renderer/webgl/pipelines/MeshPipeline.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ var MeshPipeline = new Class({
105105
-1, -1, -1,
106106
-1
107107
];
108+
109+
this.cullMode = 1029;
108110
},
109111

110112
/**
@@ -266,6 +268,13 @@ var MeshPipeline = new Class({
266268
// All the uniforms are finally bound, so let's buffer our data
267269
var gl = this.gl;
268270

271+
if (model.cullMode !== this.cullMode)
272+
{
273+
this.cullMode = model.cullMode;
274+
275+
gl.cullFace(model.cullMode);
276+
}
277+
269278
// STATIC because the buffer data doesn't change, the uniforms do
270279
gl.bufferData(gl.ARRAY_BUFFER, model.vertexData, gl.STATIC_DRAW);
271280

0 commit comments

Comments
 (0)