diff --git a/src/core/renderers/webgl/ShaderManager.js b/src/core/renderers/webgl/ShaderManager.js index 7a45e6a..19d5913 100644 --- a/src/core/renderers/webgl/ShaderManager.js +++ b/src/core/renderers/webgl/ShaderManager.js @@ -64,7 +64,7 @@ const shader = this.shader; const glShader = shader.glShaders[this.renderer.CONTEXT_UID]; - shader.syncUniforms(glShader.uniformData, uniforms, this.gl); + shader.syncUniforms(glShader.uniformData, uniforms, this.renderer); } /** diff --git a/src/core/renderers/webgl/ShaderManager.js b/src/core/renderers/webgl/ShaderManager.js index 7a45e6a..19d5913 100644 --- a/src/core/renderers/webgl/ShaderManager.js +++ b/src/core/renderers/webgl/ShaderManager.js @@ -64,7 +64,7 @@ const shader = this.shader; const glShader = shader.glShaders[this.renderer.CONTEXT_UID]; - shader.syncUniforms(glShader.uniformData, uniforms, this.gl); + shader.syncUniforms(glShader.uniformData, uniforms, this.renderer); } /** diff --git a/src/core/renderers/webgl/State.js b/src/core/renderers/webgl/State.js index be5b166..4ee6b56 100644 --- a/src/core/renderers/webgl/State.js +++ b/src/core/renderers/webgl/State.js @@ -24,6 +24,8 @@ this.blendMode = 0; this.polygonOffset = 0; + + this.blend = true; } /** diff --git a/src/core/renderers/webgl/ShaderManager.js b/src/core/renderers/webgl/ShaderManager.js index 7a45e6a..19d5913 100644 --- a/src/core/renderers/webgl/ShaderManager.js +++ b/src/core/renderers/webgl/ShaderManager.js @@ -64,7 +64,7 @@ const shader = this.shader; const glShader = shader.glShaders[this.renderer.CONTEXT_UID]; - shader.syncUniforms(glShader.uniformData, uniforms, this.gl); + shader.syncUniforms(glShader.uniformData, uniforms, this.renderer); } /** diff --git a/src/core/renderers/webgl/State.js b/src/core/renderers/webgl/State.js index be5b166..4ee6b56 100644 --- a/src/core/renderers/webgl/State.js +++ b/src/core/renderers/webgl/State.js @@ -24,6 +24,8 @@ this.blendMode = 0; this.polygonOffset = 0; + + this.blend = true; } /** diff --git a/src/core/shader/generateUniformsSync.js b/src/core/shader/generateUniformsSync.js index 8c01351..b0e6fa8 100644 --- a/src/core/shader/generateUniformsSync.js +++ b/src/core/shader/generateUniformsSync.js @@ -41,7 +41,9 @@ export default function generateUniformsSync(uniformData) { let textureCount = 1; - let func = 'var value = null; var cacheValue = null'; + let func = `var value = null; + var cacheValue = null + var gl = renderer.gl`; for (const i in uniformData) { @@ -121,5 +123,5 @@ // console.log(' --------------- ') // console.log(func); - return new Function('uniformData', 'uniformValues', 'gl', func); // eslint-disable-line no-new-func + return new Function('uniformData', 'uniformValues', 'renderer', func); // eslint-disable-line no-new-func } diff --git a/src/core/renderers/webgl/ShaderManager.js b/src/core/renderers/webgl/ShaderManager.js index 7a45e6a..19d5913 100644 --- a/src/core/renderers/webgl/ShaderManager.js +++ b/src/core/renderers/webgl/ShaderManager.js @@ -64,7 +64,7 @@ const shader = this.shader; const glShader = shader.glShaders[this.renderer.CONTEXT_UID]; - shader.syncUniforms(glShader.uniformData, uniforms, this.gl); + shader.syncUniforms(glShader.uniformData, uniforms, this.renderer); } /** diff --git a/src/core/renderers/webgl/State.js b/src/core/renderers/webgl/State.js index be5b166..4ee6b56 100644 --- a/src/core/renderers/webgl/State.js +++ b/src/core/renderers/webgl/State.js @@ -24,6 +24,8 @@ this.blendMode = 0; this.polygonOffset = 0; + + this.blend = true; } /** diff --git a/src/core/shader/generateUniformsSync.js b/src/core/shader/generateUniformsSync.js index 8c01351..b0e6fa8 100644 --- a/src/core/shader/generateUniformsSync.js +++ b/src/core/shader/generateUniformsSync.js @@ -41,7 +41,9 @@ export default function generateUniformsSync(uniformData) { let textureCount = 1; - let func = 'var value = null; var cacheValue = null'; + let func = `var value = null; + var cacheValue = null + var gl = renderer.gl`; for (const i in uniformData) { @@ -121,5 +123,5 @@ // console.log(' --------------- ') // console.log(func); - return new Function('uniformData', 'uniformValues', 'gl', func); // eslint-disable-line no-new-func + return new Function('uniformData', 'uniformValues', 'renderer', func); // eslint-disable-line no-new-func } diff --git a/src/mesh/Mesh.js b/src/mesh/Mesh.js index 7c16ebb..192c65a 100644 --- a/src/mesh/Mesh.js +++ b/src/mesh/Mesh.js @@ -36,7 +36,7 @@ /** * the geometry the mesh will use - * @type {PIXI.Geometry} + * @type {PIXI.mesh.Geometry} */ this.geometry = geometry; diff --git a/src/core/renderers/webgl/ShaderManager.js b/src/core/renderers/webgl/ShaderManager.js index 7a45e6a..19d5913 100644 --- a/src/core/renderers/webgl/ShaderManager.js +++ b/src/core/renderers/webgl/ShaderManager.js @@ -64,7 +64,7 @@ const shader = this.shader; const glShader = shader.glShaders[this.renderer.CONTEXT_UID]; - shader.syncUniforms(glShader.uniformData, uniforms, this.gl); + shader.syncUniforms(glShader.uniformData, uniforms, this.renderer); } /** diff --git a/src/core/renderers/webgl/State.js b/src/core/renderers/webgl/State.js index be5b166..4ee6b56 100644 --- a/src/core/renderers/webgl/State.js +++ b/src/core/renderers/webgl/State.js @@ -24,6 +24,8 @@ this.blendMode = 0; this.polygonOffset = 0; + + this.blend = true; } /** diff --git a/src/core/shader/generateUniformsSync.js b/src/core/shader/generateUniformsSync.js index 8c01351..b0e6fa8 100644 --- a/src/core/shader/generateUniformsSync.js +++ b/src/core/shader/generateUniformsSync.js @@ -41,7 +41,9 @@ export default function generateUniformsSync(uniformData) { let textureCount = 1; - let func = 'var value = null; var cacheValue = null'; + let func = `var value = null; + var cacheValue = null + var gl = renderer.gl`; for (const i in uniformData) { @@ -121,5 +123,5 @@ // console.log(' --------------- ') // console.log(func); - return new Function('uniformData', 'uniformValues', 'gl', func); // eslint-disable-line no-new-func + return new Function('uniformData', 'uniformValues', 'renderer', func); // eslint-disable-line no-new-func } diff --git a/src/mesh/Mesh.js b/src/mesh/Mesh.js index 7c16ebb..192c65a 100644 --- a/src/mesh/Mesh.js +++ b/src/mesh/Mesh.js @@ -36,7 +36,7 @@ /** * the geometry the mesh will use - * @type {PIXI.Geometry} + * @type {PIXI.mesh.Geometry} */ this.geometry = geometry; diff --git a/src/mesh/Plane.js b/src/mesh/Plane.js index c6fafbb..ff32134 100644 --- a/src/mesh/Plane.js +++ b/src/mesh/Plane.js @@ -28,7 +28,7 @@ * @param {number} verticesX - The number of vertices in the x-axis * @param {number} verticesY - The number of vertices in the y-axis */ - constructor(texture, verticesX, verticesY) + constructor(texture, verticesX, verticesY, opts) { const geometry = new Geometry(); @@ -58,6 +58,9 @@ this.segmentsX = this.verticesX = verticesX || 10; this.segmentsY = this.verticesY = verticesY || 10; + this.meshWidth = opts.meshWidth; + this.meshHeight = opts.meshHeight; + if (texture.baseTexture.hasLoaded) { this.refresh(); @@ -132,8 +135,8 @@ const segmentsX = this.verticesX - 1; const segmentsY = this.verticesY - 1; - const sizeX = texture.width / segmentsX; - const sizeY = texture.height / segmentsY; + const sizeX = this.meshWidth / segmentsX; + const sizeY = this.meshHeight / segmentsY; for (let i = 0; i < total; i++) { diff --git a/src/core/renderers/webgl/ShaderManager.js b/src/core/renderers/webgl/ShaderManager.js index 7a45e6a..19d5913 100644 --- a/src/core/renderers/webgl/ShaderManager.js +++ b/src/core/renderers/webgl/ShaderManager.js @@ -64,7 +64,7 @@ const shader = this.shader; const glShader = shader.glShaders[this.renderer.CONTEXT_UID]; - shader.syncUniforms(glShader.uniformData, uniforms, this.gl); + shader.syncUniforms(glShader.uniformData, uniforms, this.renderer); } /** diff --git a/src/core/renderers/webgl/State.js b/src/core/renderers/webgl/State.js index be5b166..4ee6b56 100644 --- a/src/core/renderers/webgl/State.js +++ b/src/core/renderers/webgl/State.js @@ -24,6 +24,8 @@ this.blendMode = 0; this.polygonOffset = 0; + + this.blend = true; } /** diff --git a/src/core/shader/generateUniformsSync.js b/src/core/shader/generateUniformsSync.js index 8c01351..b0e6fa8 100644 --- a/src/core/shader/generateUniformsSync.js +++ b/src/core/shader/generateUniformsSync.js @@ -41,7 +41,9 @@ export default function generateUniformsSync(uniformData) { let textureCount = 1; - let func = 'var value = null; var cacheValue = null'; + let func = `var value = null; + var cacheValue = null + var gl = renderer.gl`; for (const i in uniformData) { @@ -121,5 +123,5 @@ // console.log(' --------------- ') // console.log(func); - return new Function('uniformData', 'uniformValues', 'gl', func); // eslint-disable-line no-new-func + return new Function('uniformData', 'uniformValues', 'renderer', func); // eslint-disable-line no-new-func } diff --git a/src/mesh/Mesh.js b/src/mesh/Mesh.js index 7c16ebb..192c65a 100644 --- a/src/mesh/Mesh.js +++ b/src/mesh/Mesh.js @@ -36,7 +36,7 @@ /** * the geometry the mesh will use - * @type {PIXI.Geometry} + * @type {PIXI.mesh.Geometry} */ this.geometry = geometry; diff --git a/src/mesh/Plane.js b/src/mesh/Plane.js index c6fafbb..ff32134 100644 --- a/src/mesh/Plane.js +++ b/src/mesh/Plane.js @@ -28,7 +28,7 @@ * @param {number} verticesX - The number of vertices in the x-axis * @param {number} verticesY - The number of vertices in the y-axis */ - constructor(texture, verticesX, verticesY) + constructor(texture, verticesX, verticesY, opts) { const geometry = new Geometry(); @@ -58,6 +58,9 @@ this.segmentsX = this.verticesX = verticesX || 10; this.segmentsY = this.verticesY = verticesY || 10; + this.meshWidth = opts.meshWidth; + this.meshHeight = opts.meshHeight; + if (texture.baseTexture.hasLoaded) { this.refresh(); @@ -132,8 +135,8 @@ const segmentsX = this.verticesX - 1; const segmentsY = this.verticesY - 1; - const sizeX = texture.width / segmentsX; - const sizeY = texture.height / segmentsY; + const sizeX = this.meshWidth / segmentsX; + const sizeY = this.meshHeight / segmentsY; for (let i = 0; i < total; i++) { diff --git a/src/mesh/geometry/Attribute.js b/src/mesh/geometry/Attribute.js index 71c153b..c2db4b5 100644 --- a/src/mesh/geometry/Attribute.js +++ b/src/mesh/geometry/Attribute.js @@ -2,11 +2,11 @@ /** * holds the information for a single attribute structure required to render geometry. - * this does not conatina the actul data, but instead has a buffer id that maps to a {PIXI.Buffer} + * this does not conatina the actul data, but instead has a buffer id that maps to a {PIXI.mesh.Buffer} * This can include anything from positions, uvs, normals, colors etc.. * * @class - * @memberof PIXI.Attribute + * @memberof PIXI.mesh.Attribute */ class Attribute { @@ -45,7 +45,7 @@ * @param {Number} [start=0] How far into the array to start reading values (used for interleaving data) * @param {Boolean} [normalised=false] should the data be normalised. * - * @returns {PIXI.Attribute} A new {PIXI.Attribute} based on the information provided + * @returns {PIXI.mesh.Attribute} A new {PIXI.mesh.Attribute} based on the information provided */ static from(buffer, size, stride, start, normalised) { diff --git a/src/core/renderers/webgl/ShaderManager.js b/src/core/renderers/webgl/ShaderManager.js index 7a45e6a..19d5913 100644 --- a/src/core/renderers/webgl/ShaderManager.js +++ b/src/core/renderers/webgl/ShaderManager.js @@ -64,7 +64,7 @@ const shader = this.shader; const glShader = shader.glShaders[this.renderer.CONTEXT_UID]; - shader.syncUniforms(glShader.uniformData, uniforms, this.gl); + shader.syncUniforms(glShader.uniformData, uniforms, this.renderer); } /** diff --git a/src/core/renderers/webgl/State.js b/src/core/renderers/webgl/State.js index be5b166..4ee6b56 100644 --- a/src/core/renderers/webgl/State.js +++ b/src/core/renderers/webgl/State.js @@ -24,6 +24,8 @@ this.blendMode = 0; this.polygonOffset = 0; + + this.blend = true; } /** diff --git a/src/core/shader/generateUniformsSync.js b/src/core/shader/generateUniformsSync.js index 8c01351..b0e6fa8 100644 --- a/src/core/shader/generateUniformsSync.js +++ b/src/core/shader/generateUniformsSync.js @@ -41,7 +41,9 @@ export default function generateUniformsSync(uniformData) { let textureCount = 1; - let func = 'var value = null; var cacheValue = null'; + let func = `var value = null; + var cacheValue = null + var gl = renderer.gl`; for (const i in uniformData) { @@ -121,5 +123,5 @@ // console.log(' --------------- ') // console.log(func); - return new Function('uniformData', 'uniformValues', 'gl', func); // eslint-disable-line no-new-func + return new Function('uniformData', 'uniformValues', 'renderer', func); // eslint-disable-line no-new-func } diff --git a/src/mesh/Mesh.js b/src/mesh/Mesh.js index 7c16ebb..192c65a 100644 --- a/src/mesh/Mesh.js +++ b/src/mesh/Mesh.js @@ -36,7 +36,7 @@ /** * the geometry the mesh will use - * @type {PIXI.Geometry} + * @type {PIXI.mesh.Geometry} */ this.geometry = geometry; diff --git a/src/mesh/Plane.js b/src/mesh/Plane.js index c6fafbb..ff32134 100644 --- a/src/mesh/Plane.js +++ b/src/mesh/Plane.js @@ -28,7 +28,7 @@ * @param {number} verticesX - The number of vertices in the x-axis * @param {number} verticesY - The number of vertices in the y-axis */ - constructor(texture, verticesX, verticesY) + constructor(texture, verticesX, verticesY, opts) { const geometry = new Geometry(); @@ -58,6 +58,9 @@ this.segmentsX = this.verticesX = verticesX || 10; this.segmentsY = this.verticesY = verticesY || 10; + this.meshWidth = opts.meshWidth; + this.meshHeight = opts.meshHeight; + if (texture.baseTexture.hasLoaded) { this.refresh(); @@ -132,8 +135,8 @@ const segmentsX = this.verticesX - 1; const segmentsY = this.verticesY - 1; - const sizeX = texture.width / segmentsX; - const sizeY = texture.height / segmentsY; + const sizeX = this.meshWidth / segmentsX; + const sizeY = this.meshHeight / segmentsY; for (let i = 0; i < total; i++) { diff --git a/src/mesh/geometry/Attribute.js b/src/mesh/geometry/Attribute.js index 71c153b..c2db4b5 100644 --- a/src/mesh/geometry/Attribute.js +++ b/src/mesh/geometry/Attribute.js @@ -2,11 +2,11 @@ /** * holds the information for a single attribute structure required to render geometry. - * this does not conatina the actul data, but instead has a buffer id that maps to a {PIXI.Buffer} + * this does not conatina the actul data, but instead has a buffer id that maps to a {PIXI.mesh.Buffer} * This can include anything from positions, uvs, normals, colors etc.. * * @class - * @memberof PIXI.Attribute + * @memberof PIXI.mesh.Attribute */ class Attribute { @@ -45,7 +45,7 @@ * @param {Number} [start=0] How far into the array to start reading values (used for interleaving data) * @param {Boolean} [normalised=false] should the data be normalised. * - * @returns {PIXI.Attribute} A new {PIXI.Attribute} based on the information provided + * @returns {PIXI.mesh.Attribute} A new {PIXI.mesh.Attribute} based on the information provided */ static from(buffer, size, stride, start, normalised) { diff --git a/src/mesh/geometry/Buffer.js b/src/mesh/geometry/Buffer.js index 2a42938..5492687 100644 --- a/src/mesh/geometry/Buffer.js +++ b/src/mesh/geometry/Buffer.js @@ -61,7 +61,7 @@ * * @static * @param {TypedArray| Array} data the TypedArray that the buffer will store. If this is a regular Array it will be converted to a Float32Array. - * @return {PIXI.Buffer} A new Buffer based on the data provided. + * @return {PIXI.mesh.Buffer} A new Buffer based on the data provided. */ static from(data) { diff --git a/src/core/renderers/webgl/ShaderManager.js b/src/core/renderers/webgl/ShaderManager.js index 7a45e6a..19d5913 100644 --- a/src/core/renderers/webgl/ShaderManager.js +++ b/src/core/renderers/webgl/ShaderManager.js @@ -64,7 +64,7 @@ const shader = this.shader; const glShader = shader.glShaders[this.renderer.CONTEXT_UID]; - shader.syncUniforms(glShader.uniformData, uniforms, this.gl); + shader.syncUniforms(glShader.uniformData, uniforms, this.renderer); } /** diff --git a/src/core/renderers/webgl/State.js b/src/core/renderers/webgl/State.js index be5b166..4ee6b56 100644 --- a/src/core/renderers/webgl/State.js +++ b/src/core/renderers/webgl/State.js @@ -24,6 +24,8 @@ this.blendMode = 0; this.polygonOffset = 0; + + this.blend = true; } /** diff --git a/src/core/shader/generateUniformsSync.js b/src/core/shader/generateUniformsSync.js index 8c01351..b0e6fa8 100644 --- a/src/core/shader/generateUniformsSync.js +++ b/src/core/shader/generateUniformsSync.js @@ -41,7 +41,9 @@ export default function generateUniformsSync(uniformData) { let textureCount = 1; - let func = 'var value = null; var cacheValue = null'; + let func = `var value = null; + var cacheValue = null + var gl = renderer.gl`; for (const i in uniformData) { @@ -121,5 +123,5 @@ // console.log(' --------------- ') // console.log(func); - return new Function('uniformData', 'uniformValues', 'gl', func); // eslint-disable-line no-new-func + return new Function('uniformData', 'uniformValues', 'renderer', func); // eslint-disable-line no-new-func } diff --git a/src/mesh/Mesh.js b/src/mesh/Mesh.js index 7c16ebb..192c65a 100644 --- a/src/mesh/Mesh.js +++ b/src/mesh/Mesh.js @@ -36,7 +36,7 @@ /** * the geometry the mesh will use - * @type {PIXI.Geometry} + * @type {PIXI.mesh.Geometry} */ this.geometry = geometry; diff --git a/src/mesh/Plane.js b/src/mesh/Plane.js index c6fafbb..ff32134 100644 --- a/src/mesh/Plane.js +++ b/src/mesh/Plane.js @@ -28,7 +28,7 @@ * @param {number} verticesX - The number of vertices in the x-axis * @param {number} verticesY - The number of vertices in the y-axis */ - constructor(texture, verticesX, verticesY) + constructor(texture, verticesX, verticesY, opts) { const geometry = new Geometry(); @@ -58,6 +58,9 @@ this.segmentsX = this.verticesX = verticesX || 10; this.segmentsY = this.verticesY = verticesY || 10; + this.meshWidth = opts.meshWidth; + this.meshHeight = opts.meshHeight; + if (texture.baseTexture.hasLoaded) { this.refresh(); @@ -132,8 +135,8 @@ const segmentsX = this.verticesX - 1; const segmentsY = this.verticesY - 1; - const sizeX = texture.width / segmentsX; - const sizeY = texture.height / segmentsY; + const sizeX = this.meshWidth / segmentsX; + const sizeY = this.meshHeight / segmentsY; for (let i = 0; i < total; i++) { diff --git a/src/mesh/geometry/Attribute.js b/src/mesh/geometry/Attribute.js index 71c153b..c2db4b5 100644 --- a/src/mesh/geometry/Attribute.js +++ b/src/mesh/geometry/Attribute.js @@ -2,11 +2,11 @@ /** * holds the information for a single attribute structure required to render geometry. - * this does not conatina the actul data, but instead has a buffer id that maps to a {PIXI.Buffer} + * this does not conatina the actul data, but instead has a buffer id that maps to a {PIXI.mesh.Buffer} * This can include anything from positions, uvs, normals, colors etc.. * * @class - * @memberof PIXI.Attribute + * @memberof PIXI.mesh.Attribute */ class Attribute { @@ -45,7 +45,7 @@ * @param {Number} [start=0] How far into the array to start reading values (used for interleaving data) * @param {Boolean} [normalised=false] should the data be normalised. * - * @returns {PIXI.Attribute} A new {PIXI.Attribute} based on the information provided + * @returns {PIXI.mesh.Attribute} A new {PIXI.mesh.Attribute} based on the information provided */ static from(buffer, size, stride, start, normalised) { diff --git a/src/mesh/geometry/Buffer.js b/src/mesh/geometry/Buffer.js index 2a42938..5492687 100644 --- a/src/mesh/geometry/Buffer.js +++ b/src/mesh/geometry/Buffer.js @@ -61,7 +61,7 @@ * * @static * @param {TypedArray| Array} data the TypedArray that the buffer will store. If this is a regular Array it will be converted to a Float32Array. - * @return {PIXI.Buffer} A new Buffer based on the data provided. + * @return {PIXI.mesh.Buffer} A new Buffer based on the data provided. */ static from(data) { diff --git a/src/mesh/geometry/Geometry.js b/src/mesh/geometry/Geometry.js index f1e090c..95ff4fd 100644 --- a/src/mesh/geometry/Geometry.js +++ b/src/mesh/geometry/Geometry.js @@ -15,7 +15,7 @@ * Geometry can be defined without passing in a style or data if required (thats how I prefer!) * * ```js - * let geometry = new PIXI.Geometry(); + * let geometry = new PIXI.mesh.Geometry(); * * geometry.addAttribute('positions', [0, 0, 100, 0, 100, 100, 0, 100], 2); * geometry.addAttribute('uvs', [0,0,1,0,1,1,0,1],2) @@ -23,25 +23,25 @@ * * ``` * @class - * @memberof PIXI.Geometry + * @memberof PIXI.mesh.Geometry */ export default class Geometry { /** - * @param {PIXI.GeometryData} data optional structure of the model such as the attributes layout - * @param {PIXI.GeometryStyle} style optional data of the model, this consists of buffers. + * @param {PIXI.mesh.GeometryData} data optional structure of the model such as the attributes layout + * @param {PIXI.mesh.GeometryStyle} style optional data of the model, this consists of buffers. */ constructor(data, style) { /** * the style of the geometry - * @type {PIXI.GeometryStyle} + * @type {PIXI.mesh.GeometryStyle} */ this.style = style || new GeometryStyle(); /** * the data of the geometry - * @type {PIXI.GeometryData} + * @type {PIXI.mesh.GeometryData} */ this.data = data || new GeometryData(); @@ -59,13 +59,13 @@ * Adds an attribute to the geometry * * @param {String} id - the name of the attribute (matching up to a shader) - * @param {PIXI.Buffer} [buffer] the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it. + * @param {PIXI.mesh.Buffer} [buffer] the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it. * @param {Number} [size=2] the size of the attribute. If you hava 2 floats per vertex (eg position x and y) this would be 2 * @param {Number} [stride=0] How far apart (in floats) the start of each value is. (used for interleaving data) * @param {Number} [start=0] How far into the array to start reading values (used for interleaving data) * @param {Boolean} [normalised=false] should the data be normalised. * - * @return {PIXI.Geometry} returns self, useful for chaining. + * @return {PIXI.mesh.Geometry} returns self, useful for chaining. */ addAttribute(id, buffer, size = 2, stride = 0, start = 0, normalised = false) { @@ -91,7 +91,7 @@ * returns the requested attribute * * @param {String} id the name of the attribute required - * @return {PIXI.Attribute} the attribute requested. + * @return {PIXI.mesh.Attribute} the attribute requested. */ getAttribute(id) { @@ -103,8 +103,8 @@ * Adds an index buffer to the geometry * The index buffer contains integers, three for each triangle in the geometry, which reference the various attribute buffers (position, colour, UV coordinates, other UV coordinates, normal, …). There is only ONE index buffer. * - * @param {PIXI.Buffer} [buffer] the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. - * @return {PIXI.Geometry} returns self, useful for chaining. + * @param {PIXI.mesh.Buffer} [buffer] the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. + * @return {PIXI.mesh.Geometry} returns self, useful for chaining. */ addIndex(buffer) { @@ -116,7 +116,7 @@ /** * returns the index buffer * - * @return {PIXI.Buffer} the index buffer. + * @return {PIXI.mesh.Buffer} the index buffer. */ getIndex() { diff --git a/src/core/renderers/webgl/ShaderManager.js b/src/core/renderers/webgl/ShaderManager.js index 7a45e6a..19d5913 100644 --- a/src/core/renderers/webgl/ShaderManager.js +++ b/src/core/renderers/webgl/ShaderManager.js @@ -64,7 +64,7 @@ const shader = this.shader; const glShader = shader.glShaders[this.renderer.CONTEXT_UID]; - shader.syncUniforms(glShader.uniformData, uniforms, this.gl); + shader.syncUniforms(glShader.uniformData, uniforms, this.renderer); } /** diff --git a/src/core/renderers/webgl/State.js b/src/core/renderers/webgl/State.js index be5b166..4ee6b56 100644 --- a/src/core/renderers/webgl/State.js +++ b/src/core/renderers/webgl/State.js @@ -24,6 +24,8 @@ this.blendMode = 0; this.polygonOffset = 0; + + this.blend = true; } /** diff --git a/src/core/shader/generateUniformsSync.js b/src/core/shader/generateUniformsSync.js index 8c01351..b0e6fa8 100644 --- a/src/core/shader/generateUniformsSync.js +++ b/src/core/shader/generateUniformsSync.js @@ -41,7 +41,9 @@ export default function generateUniformsSync(uniformData) { let textureCount = 1; - let func = 'var value = null; var cacheValue = null'; + let func = `var value = null; + var cacheValue = null + var gl = renderer.gl`; for (const i in uniformData) { @@ -121,5 +123,5 @@ // console.log(' --------------- ') // console.log(func); - return new Function('uniformData', 'uniformValues', 'gl', func); // eslint-disable-line no-new-func + return new Function('uniformData', 'uniformValues', 'renderer', func); // eslint-disable-line no-new-func } diff --git a/src/mesh/Mesh.js b/src/mesh/Mesh.js index 7c16ebb..192c65a 100644 --- a/src/mesh/Mesh.js +++ b/src/mesh/Mesh.js @@ -36,7 +36,7 @@ /** * the geometry the mesh will use - * @type {PIXI.Geometry} + * @type {PIXI.mesh.Geometry} */ this.geometry = geometry; diff --git a/src/mesh/Plane.js b/src/mesh/Plane.js index c6fafbb..ff32134 100644 --- a/src/mesh/Plane.js +++ b/src/mesh/Plane.js @@ -28,7 +28,7 @@ * @param {number} verticesX - The number of vertices in the x-axis * @param {number} verticesY - The number of vertices in the y-axis */ - constructor(texture, verticesX, verticesY) + constructor(texture, verticesX, verticesY, opts) { const geometry = new Geometry(); @@ -58,6 +58,9 @@ this.segmentsX = this.verticesX = verticesX || 10; this.segmentsY = this.verticesY = verticesY || 10; + this.meshWidth = opts.meshWidth; + this.meshHeight = opts.meshHeight; + if (texture.baseTexture.hasLoaded) { this.refresh(); @@ -132,8 +135,8 @@ const segmentsX = this.verticesX - 1; const segmentsY = this.verticesY - 1; - const sizeX = texture.width / segmentsX; - const sizeY = texture.height / segmentsY; + const sizeX = this.meshWidth / segmentsX; + const sizeY = this.meshHeight / segmentsY; for (let i = 0; i < total; i++) { diff --git a/src/mesh/geometry/Attribute.js b/src/mesh/geometry/Attribute.js index 71c153b..c2db4b5 100644 --- a/src/mesh/geometry/Attribute.js +++ b/src/mesh/geometry/Attribute.js @@ -2,11 +2,11 @@ /** * holds the information for a single attribute structure required to render geometry. - * this does not conatina the actul data, but instead has a buffer id that maps to a {PIXI.Buffer} + * this does not conatina the actul data, but instead has a buffer id that maps to a {PIXI.mesh.Buffer} * This can include anything from positions, uvs, normals, colors etc.. * * @class - * @memberof PIXI.Attribute + * @memberof PIXI.mesh.Attribute */ class Attribute { @@ -45,7 +45,7 @@ * @param {Number} [start=0] How far into the array to start reading values (used for interleaving data) * @param {Boolean} [normalised=false] should the data be normalised. * - * @returns {PIXI.Attribute} A new {PIXI.Attribute} based on the information provided + * @returns {PIXI.mesh.Attribute} A new {PIXI.mesh.Attribute} based on the information provided */ static from(buffer, size, stride, start, normalised) { diff --git a/src/mesh/geometry/Buffer.js b/src/mesh/geometry/Buffer.js index 2a42938..5492687 100644 --- a/src/mesh/geometry/Buffer.js +++ b/src/mesh/geometry/Buffer.js @@ -61,7 +61,7 @@ * * @static * @param {TypedArray| Array} data the TypedArray that the buffer will store. If this is a regular Array it will be converted to a Float32Array. - * @return {PIXI.Buffer} A new Buffer based on the data provided. + * @return {PIXI.mesh.Buffer} A new Buffer based on the data provided. */ static from(data) { diff --git a/src/mesh/geometry/Geometry.js b/src/mesh/geometry/Geometry.js index f1e090c..95ff4fd 100644 --- a/src/mesh/geometry/Geometry.js +++ b/src/mesh/geometry/Geometry.js @@ -15,7 +15,7 @@ * Geometry can be defined without passing in a style or data if required (thats how I prefer!) * * ```js - * let geometry = new PIXI.Geometry(); + * let geometry = new PIXI.mesh.Geometry(); * * geometry.addAttribute('positions', [0, 0, 100, 0, 100, 100, 0, 100], 2); * geometry.addAttribute('uvs', [0,0,1,0,1,1,0,1],2) @@ -23,25 +23,25 @@ * * ``` * @class - * @memberof PIXI.Geometry + * @memberof PIXI.mesh.Geometry */ export default class Geometry { /** - * @param {PIXI.GeometryData} data optional structure of the model such as the attributes layout - * @param {PIXI.GeometryStyle} style optional data of the model, this consists of buffers. + * @param {PIXI.mesh.GeometryData} data optional structure of the model such as the attributes layout + * @param {PIXI.mesh.GeometryStyle} style optional data of the model, this consists of buffers. */ constructor(data, style) { /** * the style of the geometry - * @type {PIXI.GeometryStyle} + * @type {PIXI.mesh.GeometryStyle} */ this.style = style || new GeometryStyle(); /** * the data of the geometry - * @type {PIXI.GeometryData} + * @type {PIXI.mesh.GeometryData} */ this.data = data || new GeometryData(); @@ -59,13 +59,13 @@ * Adds an attribute to the geometry * * @param {String} id - the name of the attribute (matching up to a shader) - * @param {PIXI.Buffer} [buffer] the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it. + * @param {PIXI.mesh.Buffer} [buffer] the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it. * @param {Number} [size=2] the size of the attribute. If you hava 2 floats per vertex (eg position x and y) this would be 2 * @param {Number} [stride=0] How far apart (in floats) the start of each value is. (used for interleaving data) * @param {Number} [start=0] How far into the array to start reading values (used for interleaving data) * @param {Boolean} [normalised=false] should the data be normalised. * - * @return {PIXI.Geometry} returns self, useful for chaining. + * @return {PIXI.mesh.Geometry} returns self, useful for chaining. */ addAttribute(id, buffer, size = 2, stride = 0, start = 0, normalised = false) { @@ -91,7 +91,7 @@ * returns the requested attribute * * @param {String} id the name of the attribute required - * @return {PIXI.Attribute} the attribute requested. + * @return {PIXI.mesh.Attribute} the attribute requested. */ getAttribute(id) { @@ -103,8 +103,8 @@ * Adds an index buffer to the geometry * The index buffer contains integers, three for each triangle in the geometry, which reference the various attribute buffers (position, colour, UV coordinates, other UV coordinates, normal, …). There is only ONE index buffer. * - * @param {PIXI.Buffer} [buffer] the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. - * @return {PIXI.Geometry} returns self, useful for chaining. + * @param {PIXI.mesh.Buffer} [buffer] the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. + * @return {PIXI.mesh.Geometry} returns self, useful for chaining. */ addIndex(buffer) { @@ -116,7 +116,7 @@ /** * returns the index buffer * - * @return {PIXI.Buffer} the index buffer. + * @return {PIXI.mesh.Buffer} the index buffer. */ getIndex() { diff --git a/src/mesh/geometry/GeometryData.js b/src/mesh/geometry/GeometryData.js index 487cc19..65321e2 100644 --- a/src/mesh/geometry/GeometryData.js +++ b/src/mesh/geometry/GeometryData.js @@ -7,7 +7,7 @@ * This can include anything from positions, uvs, normals, colors etc.. * * ```js - * let geometryData = new PIXI.GeometryData(); + * let geometryData = new PIXI.mesh.GeometryData(); * * geometryData.add('positions', [0,1,0,2,3]); * geometryData.add('uvs', [0,0,1,0,1,1,0,1]); @@ -15,7 +15,7 @@ * * ``` * @class - * @memberof PIXI.GeometryData + * @memberof PIXI.mesh.GeometryData */ export default class GeometryData { @@ -25,14 +25,14 @@ constructor() { /** - * an array of {PIXI.Buffer} belonging to the geometryData + * an array of {PIXI.mesh.Buffer} belonging to the geometryData * @type {Array} */ this.buffers = []; /** * the index buffer data for the geometry - * @type {PIXI.Buffer} + * @type {PIXI.mesh.Buffer} */ this.indexBuffer = null; } @@ -42,9 +42,9 @@ * Adds an buffer to the geometryData * * @param {String} id - the name of the buffer (matching up to a geometry style) - * @param {PIXI.Buffer} [buffer] the buffer that holds the data mapping to a geometry attribute. You can also provide an Array and a buffer will be created from it. + * @param {PIXI.mesh.Buffer} [buffer] the buffer that holds the data mapping to a geometry attribute. You can also provide an Array and a buffer will be created from it. * - * @return {PIXI.GeometryData} returns self, useful for chaining. + * @return {PIXI.mesh.GeometryData} returns self, useful for chaining. */ add(id, buffer) { @@ -75,8 +75,8 @@ * Adds an index buffer to the geometryData * The index buffer contains integers, three for each triangle in the geometry, which reference the various attribute buffers (position, colour, UV coordinates, other UV coordinates, normal, …). There is only ONE index buffer. * - * @param {PIXI.Buffer} [buffer] the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. - * @return {PIXI.GeometryData} returns self, useful for chaining. + * @param {PIXI.mesh.Buffer} [buffer] the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. + * @return {PIXI.mesh.GeometryData} returns self, useful for chaining. */ addIndex(buffer) { diff --git a/src/core/renderers/webgl/ShaderManager.js b/src/core/renderers/webgl/ShaderManager.js index 7a45e6a..19d5913 100644 --- a/src/core/renderers/webgl/ShaderManager.js +++ b/src/core/renderers/webgl/ShaderManager.js @@ -64,7 +64,7 @@ const shader = this.shader; const glShader = shader.glShaders[this.renderer.CONTEXT_UID]; - shader.syncUniforms(glShader.uniformData, uniforms, this.gl); + shader.syncUniforms(glShader.uniformData, uniforms, this.renderer); } /** diff --git a/src/core/renderers/webgl/State.js b/src/core/renderers/webgl/State.js index be5b166..4ee6b56 100644 --- a/src/core/renderers/webgl/State.js +++ b/src/core/renderers/webgl/State.js @@ -24,6 +24,8 @@ this.blendMode = 0; this.polygonOffset = 0; + + this.blend = true; } /** diff --git a/src/core/shader/generateUniformsSync.js b/src/core/shader/generateUniformsSync.js index 8c01351..b0e6fa8 100644 --- a/src/core/shader/generateUniformsSync.js +++ b/src/core/shader/generateUniformsSync.js @@ -41,7 +41,9 @@ export default function generateUniformsSync(uniformData) { let textureCount = 1; - let func = 'var value = null; var cacheValue = null'; + let func = `var value = null; + var cacheValue = null + var gl = renderer.gl`; for (const i in uniformData) { @@ -121,5 +123,5 @@ // console.log(' --------------- ') // console.log(func); - return new Function('uniformData', 'uniformValues', 'gl', func); // eslint-disable-line no-new-func + return new Function('uniformData', 'uniformValues', 'renderer', func); // eslint-disable-line no-new-func } diff --git a/src/mesh/Mesh.js b/src/mesh/Mesh.js index 7c16ebb..192c65a 100644 --- a/src/mesh/Mesh.js +++ b/src/mesh/Mesh.js @@ -36,7 +36,7 @@ /** * the geometry the mesh will use - * @type {PIXI.Geometry} + * @type {PIXI.mesh.Geometry} */ this.geometry = geometry; diff --git a/src/mesh/Plane.js b/src/mesh/Plane.js index c6fafbb..ff32134 100644 --- a/src/mesh/Plane.js +++ b/src/mesh/Plane.js @@ -28,7 +28,7 @@ * @param {number} verticesX - The number of vertices in the x-axis * @param {number} verticesY - The number of vertices in the y-axis */ - constructor(texture, verticesX, verticesY) + constructor(texture, verticesX, verticesY, opts) { const geometry = new Geometry(); @@ -58,6 +58,9 @@ this.segmentsX = this.verticesX = verticesX || 10; this.segmentsY = this.verticesY = verticesY || 10; + this.meshWidth = opts.meshWidth; + this.meshHeight = opts.meshHeight; + if (texture.baseTexture.hasLoaded) { this.refresh(); @@ -132,8 +135,8 @@ const segmentsX = this.verticesX - 1; const segmentsY = this.verticesY - 1; - const sizeX = texture.width / segmentsX; - const sizeY = texture.height / segmentsY; + const sizeX = this.meshWidth / segmentsX; + const sizeY = this.meshHeight / segmentsY; for (let i = 0; i < total; i++) { diff --git a/src/mesh/geometry/Attribute.js b/src/mesh/geometry/Attribute.js index 71c153b..c2db4b5 100644 --- a/src/mesh/geometry/Attribute.js +++ b/src/mesh/geometry/Attribute.js @@ -2,11 +2,11 @@ /** * holds the information for a single attribute structure required to render geometry. - * this does not conatina the actul data, but instead has a buffer id that maps to a {PIXI.Buffer} + * this does not conatina the actul data, but instead has a buffer id that maps to a {PIXI.mesh.Buffer} * This can include anything from positions, uvs, normals, colors etc.. * * @class - * @memberof PIXI.Attribute + * @memberof PIXI.mesh.Attribute */ class Attribute { @@ -45,7 +45,7 @@ * @param {Number} [start=0] How far into the array to start reading values (used for interleaving data) * @param {Boolean} [normalised=false] should the data be normalised. * - * @returns {PIXI.Attribute} A new {PIXI.Attribute} based on the information provided + * @returns {PIXI.mesh.Attribute} A new {PIXI.mesh.Attribute} based on the information provided */ static from(buffer, size, stride, start, normalised) { diff --git a/src/mesh/geometry/Buffer.js b/src/mesh/geometry/Buffer.js index 2a42938..5492687 100644 --- a/src/mesh/geometry/Buffer.js +++ b/src/mesh/geometry/Buffer.js @@ -61,7 +61,7 @@ * * @static * @param {TypedArray| Array} data the TypedArray that the buffer will store. If this is a regular Array it will be converted to a Float32Array. - * @return {PIXI.Buffer} A new Buffer based on the data provided. + * @return {PIXI.mesh.Buffer} A new Buffer based on the data provided. */ static from(data) { diff --git a/src/mesh/geometry/Geometry.js b/src/mesh/geometry/Geometry.js index f1e090c..95ff4fd 100644 --- a/src/mesh/geometry/Geometry.js +++ b/src/mesh/geometry/Geometry.js @@ -15,7 +15,7 @@ * Geometry can be defined without passing in a style or data if required (thats how I prefer!) * * ```js - * let geometry = new PIXI.Geometry(); + * let geometry = new PIXI.mesh.Geometry(); * * geometry.addAttribute('positions', [0, 0, 100, 0, 100, 100, 0, 100], 2); * geometry.addAttribute('uvs', [0,0,1,0,1,1,0,1],2) @@ -23,25 +23,25 @@ * * ``` * @class - * @memberof PIXI.Geometry + * @memberof PIXI.mesh.Geometry */ export default class Geometry { /** - * @param {PIXI.GeometryData} data optional structure of the model such as the attributes layout - * @param {PIXI.GeometryStyle} style optional data of the model, this consists of buffers. + * @param {PIXI.mesh.GeometryData} data optional structure of the model such as the attributes layout + * @param {PIXI.mesh.GeometryStyle} style optional data of the model, this consists of buffers. */ constructor(data, style) { /** * the style of the geometry - * @type {PIXI.GeometryStyle} + * @type {PIXI.mesh.GeometryStyle} */ this.style = style || new GeometryStyle(); /** * the data of the geometry - * @type {PIXI.GeometryData} + * @type {PIXI.mesh.GeometryData} */ this.data = data || new GeometryData(); @@ -59,13 +59,13 @@ * Adds an attribute to the geometry * * @param {String} id - the name of the attribute (matching up to a shader) - * @param {PIXI.Buffer} [buffer] the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it. + * @param {PIXI.mesh.Buffer} [buffer] the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it. * @param {Number} [size=2] the size of the attribute. If you hava 2 floats per vertex (eg position x and y) this would be 2 * @param {Number} [stride=0] How far apart (in floats) the start of each value is. (used for interleaving data) * @param {Number} [start=0] How far into the array to start reading values (used for interleaving data) * @param {Boolean} [normalised=false] should the data be normalised. * - * @return {PIXI.Geometry} returns self, useful for chaining. + * @return {PIXI.mesh.Geometry} returns self, useful for chaining. */ addAttribute(id, buffer, size = 2, stride = 0, start = 0, normalised = false) { @@ -91,7 +91,7 @@ * returns the requested attribute * * @param {String} id the name of the attribute required - * @return {PIXI.Attribute} the attribute requested. + * @return {PIXI.mesh.Attribute} the attribute requested. */ getAttribute(id) { @@ -103,8 +103,8 @@ * Adds an index buffer to the geometry * The index buffer contains integers, three for each triangle in the geometry, which reference the various attribute buffers (position, colour, UV coordinates, other UV coordinates, normal, …). There is only ONE index buffer. * - * @param {PIXI.Buffer} [buffer] the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. - * @return {PIXI.Geometry} returns self, useful for chaining. + * @param {PIXI.mesh.Buffer} [buffer] the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. + * @return {PIXI.mesh.Geometry} returns self, useful for chaining. */ addIndex(buffer) { @@ -116,7 +116,7 @@ /** * returns the index buffer * - * @return {PIXI.Buffer} the index buffer. + * @return {PIXI.mesh.Buffer} the index buffer. */ getIndex() { diff --git a/src/mesh/geometry/GeometryData.js b/src/mesh/geometry/GeometryData.js index 487cc19..65321e2 100644 --- a/src/mesh/geometry/GeometryData.js +++ b/src/mesh/geometry/GeometryData.js @@ -7,7 +7,7 @@ * This can include anything from positions, uvs, normals, colors etc.. * * ```js - * let geometryData = new PIXI.GeometryData(); + * let geometryData = new PIXI.mesh.GeometryData(); * * geometryData.add('positions', [0,1,0,2,3]); * geometryData.add('uvs', [0,0,1,0,1,1,0,1]); @@ -15,7 +15,7 @@ * * ``` * @class - * @memberof PIXI.GeometryData + * @memberof PIXI.mesh.GeometryData */ export default class GeometryData { @@ -25,14 +25,14 @@ constructor() { /** - * an array of {PIXI.Buffer} belonging to the geometryData + * an array of {PIXI.mesh.Buffer} belonging to the geometryData * @type {Array} */ this.buffers = []; /** * the index buffer data for the geometry - * @type {PIXI.Buffer} + * @type {PIXI.mesh.Buffer} */ this.indexBuffer = null; } @@ -42,9 +42,9 @@ * Adds an buffer to the geometryData * * @param {String} id - the name of the buffer (matching up to a geometry style) - * @param {PIXI.Buffer} [buffer] the buffer that holds the data mapping to a geometry attribute. You can also provide an Array and a buffer will be created from it. + * @param {PIXI.mesh.Buffer} [buffer] the buffer that holds the data mapping to a geometry attribute. You can also provide an Array and a buffer will be created from it. * - * @return {PIXI.GeometryData} returns self, useful for chaining. + * @return {PIXI.mesh.GeometryData} returns self, useful for chaining. */ add(id, buffer) { @@ -75,8 +75,8 @@ * Adds an index buffer to the geometryData * The index buffer contains integers, three for each triangle in the geometry, which reference the various attribute buffers (position, colour, UV coordinates, other UV coordinates, normal, …). There is only ONE index buffer. * - * @param {PIXI.Buffer} [buffer] the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. - * @return {PIXI.GeometryData} returns self, useful for chaining. + * @param {PIXI.mesh.Buffer} [buffer] the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. + * @return {PIXI.mesh.GeometryData} returns self, useful for chaining. */ addIndex(buffer) { diff --git a/src/mesh/geometry/GeometryStyle.js b/src/mesh/geometry/GeometryStyle.js index f18bd6b..a2efa88 100644 --- a/src/mesh/geometry/GeometryStyle.js +++ b/src/mesh/geometry/GeometryStyle.js @@ -2,14 +2,14 @@ * GeometryStyle represents the structure of the geometry such as the attributes layout. * * ```js - * let geometryStyle = new PIXI.GeometryStyle(); + * let geometryStyle = new PIXI.mesh.GeometryStyle(); * - * geometryStyle.addAttribute('positions, new PIXI.Attribute('positionBuffer', 2)); - * geometryStyle.addAttribute('uvs', new PIXI.Attribute('uvsBuffer', 2); + * geometryStyle.addAttribute('positions, new PIXI.mesh.Attribute('positionBuffer', 2)); + * geometryStyle.addAttribute('uvs', new PIXI.mesh.Attribute('uvsBuffer', 2); * * ``` * @class - * @memberof PIXI.GeometryStyle + * @memberof PIXI.mesh.GeometryStyle */ export default class GeometryStyle { @@ -33,9 +33,9 @@ * Adds an attribute to the geometryStyle * * @param {String} id - the name of the attribute (matching up to a shader) - * @param {PIXI.Attribute} [attribute] the Attribute that you would like to add to the style. + * @param {PIXI.mesh.Attribute} [attribute] the Attribute that you would like to add to the style. * - * @return {PIXI.GeometryStyle} returns self, useful for chaining. + * @return {PIXI.mesh.GeometryStyle} returns self, useful for chaining. */ addAttribute(id, attribute) {