diff --git a/src/mesh/Plane.js b/src/mesh/Plane.js index ff32134..b906b71 100644 --- a/src/mesh/Plane.js +++ b/src/mesh/Plane.js @@ -27,8 +27,9 @@ * @param {PIXI.Texture} texture - The texture to use on the Plane. * @param {number} verticesX - The number of vertices in the x-axis * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} opts - an options object - add meshWidth and meshHeight */ - constructor(texture, verticesX, verticesY, opts) + constructor(texture, verticesX, verticesY, opts = {}) { const geometry = new Geometry(); @@ -58,8 +59,8 @@ this.segmentsX = this.verticesX = verticesX || 10; this.segmentsY = this.verticesY = verticesY || 10; - this.meshWidth = opts.meshWidth; - this.meshHeight = opts.meshHeight; + this.meshWidth = opts.meshWidth || texture.width; + this.meshHeight = opts.meshHeight || texture.height; if (texture.baseTexture.hasLoaded) { diff --git a/src/mesh/Plane.js b/src/mesh/Plane.js index ff32134..b906b71 100644 --- a/src/mesh/Plane.js +++ b/src/mesh/Plane.js @@ -27,8 +27,9 @@ * @param {PIXI.Texture} texture - The texture to use on the Plane. * @param {number} verticesX - The number of vertices in the x-axis * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} opts - an options object - add meshWidth and meshHeight */ - constructor(texture, verticesX, verticesY, opts) + constructor(texture, verticesX, verticesY, opts = {}) { const geometry = new Geometry(); @@ -58,8 +59,8 @@ this.segmentsX = this.verticesX = verticesX || 10; this.segmentsY = this.verticesY = verticesY || 10; - this.meshWidth = opts.meshWidth; - this.meshHeight = opts.meshHeight; + this.meshWidth = opts.meshWidth || texture.width; + this.meshHeight = opts.meshHeight || texture.height; if (texture.baseTexture.hasLoaded) { diff --git a/src/mesh/canvas/CanvasMeshRenderer.js b/src/mesh/canvas/CanvasMeshRenderer.js index 1263170..b4cb86d 100644 --- a/src/mesh/canvas/CanvasMeshRenderer.js +++ b/src/mesh/canvas/CanvasMeshRenderer.js @@ -95,7 +95,7 @@ _renderTriangles(mesh) { // draw triangles!! - const indices = mesh.indices; + const indices = mesh.geometry.getIndex().data; const length = indices.length; for (let i = 0; i < length; i += 3) @@ -121,8 +121,8 @@ _renderDrawTriangle(mesh, index0, index1, index2) { const context = this.renderer.context; - const uvs = mesh.uvs; - const vertices = mesh.vertices; + const uvs = mesh.geometry.getAttribute('aTextureCoord').data; + const vertices = mesh.geometry.getAttribute('aVertexPosition').data; const texture = mesh._texture; if (!texture.valid) @@ -234,7 +234,7 @@ renderMeshFlat(mesh) { const context = this.renderer.context; - const vertices = mesh.vertices; + const vertices = mesh.geometry.getAttribute('aVertexPosition').data; const length = vertices.length / 2; // this.count++;