2017-05-16 23:07:52 +00:00
|
|
|
|
|
|
|
var Class = require('../../utils/Class');
|
|
|
|
var GameObject = require('../GameObject');
|
|
|
|
var Components = require('../../components');
|
|
|
|
var MeshRender = require('./MeshRender');
|
|
|
|
|
|
|
|
var Mesh = new Class({
|
|
|
|
|
|
|
|
Extends: GameObject,
|
|
|
|
|
|
|
|
Mixins: [
|
|
|
|
Components.Alpha,
|
|
|
|
Components.BlendMode,
|
|
|
|
Components.Flip,
|
|
|
|
Components.GetBounds,
|
|
|
|
Components.Origin,
|
|
|
|
Components.RenderTarget,
|
|
|
|
Components.ScaleMode,
|
|
|
|
Components.Size,
|
|
|
|
Components.Texture,
|
|
|
|
Components.Transform,
|
|
|
|
Components.Visible,
|
|
|
|
MeshRender
|
|
|
|
],
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2017-05-18 19:57:05 +00:00
|
|
|
function Mesh (state, x, y, vertices, uv, indices, texture, frame)
|
2017-05-16 23:07:52 +00:00
|
|
|
{
|
|
|
|
GameObject.call(this, state, 'Mesh');
|
|
|
|
|
|
|
|
this.setTexture(texture, frame);
|
|
|
|
this.setPosition(x, y);
|
|
|
|
this.setSizeToFrame();
|
|
|
|
this.setOrigin();
|
|
|
|
|
2017-05-17 16:12:17 +00:00
|
|
|
if (vertices.length !== uv.length)
|
|
|
|
{
|
|
|
|
throw new Error('Phaser: Vertex count must match UV count');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.vertices = new Float32Array(vertices);
|
|
|
|
this.uv = new Float32Array(uv);
|
2017-05-18 19:57:05 +00:00
|
|
|
this.indices = new Uint16Array(indices);
|
2017-05-16 23:07:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = Mesh;
|