2017-09-14 01:27:29 +00:00
|
|
|
var BuildGameObject = require('../BuildGameObject');
|
2018-01-16 22:28:29 +00:00
|
|
|
var GameObjectCreator = require('../GameObjectCreator');
|
2017-05-16 23:07:52 +00:00
|
|
|
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
|
|
|
var GetValue = require('../../utils/object/GetValue');
|
2017-09-14 01:27:29 +00:00
|
|
|
var Mesh = require('./Mesh');
|
|
|
|
|
|
|
|
// When registering a factory function 'this' refers to the GameObjectCreator context.
|
2017-05-16 23:07:52 +00:00
|
|
|
|
2017-09-14 01:27:29 +00:00
|
|
|
GameObjectCreator.register('mesh', function (config)
|
2017-05-16 23:07:52 +00:00
|
|
|
{
|
|
|
|
var key = GetAdvancedValue(config, 'key', null);
|
|
|
|
var frame = GetAdvancedValue(config, 'frame', null);
|
|
|
|
var vertices = GetValue(config, 'vertices', []);
|
2017-05-18 19:57:05 +00:00
|
|
|
var indices = GetValue(config, 'indices', []);
|
2017-05-22 19:29:27 +00:00
|
|
|
var colors = GetValue(config, 'colors', []);
|
|
|
|
var alphas = GetValue(config, 'alphas', []);
|
2017-05-16 23:07:52 +00:00
|
|
|
var uv = GetValue(config, 'uv', []);
|
|
|
|
|
2017-09-14 01:27:29 +00:00
|
|
|
var mesh = new Mesh(this.scene, 0, 0, vertices, uv, indices, colors, alphas, key, frame);
|
2017-05-16 23:07:52 +00:00
|
|
|
|
2017-09-14 01:27:29 +00:00
|
|
|
BuildGameObject(this.scene, mesh, config);
|
2017-05-16 23:07:52 +00:00
|
|
|
|
|
|
|
return mesh;
|
2017-09-14 01:27:29 +00:00
|
|
|
});
|