Skip to content

Commit

Permalink
Update voxel-plugins, using more straightforward plugin loading scheme
Browse files Browse the repository at this point in the history
Replaces the use of implicit require()'s with an explicit 'loaders'
object, for details see: voxel/voxel-plugins#8
  • Loading branch information
deathcap committed Jan 10, 2016
1 parent b4295ea commit 80d3753
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
26 changes: 12 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ var obsolete = require('obsolete')

var createPlugins = require('voxel-plugins')
var extend = require('extend')
require('voxel-registry')
require('voxel-stitch')
require('voxel-shader')
require('voxel-mesher')
require('game-shell-fps-camera')

module.exports = Game

Expand Down Expand Up @@ -111,17 +106,20 @@ function Game(opts) {
}

// setup plugins
var pluginLoaders = opts.pluginLoaders || {};
extend(pluginLoaders, {
'voxel-engine-stackgl': require('./'),
'voxel-registry': require('voxel-registry'),
'voxel-stitch': require('voxel-stitch'),
'voxel-shader': require('voxel-shader'),
'voxel-mesher': require('voxel-mesher'),
'game-shell-fps-camera': require('game-shell-fps-camera')
})
var plugins = createPlugins(this, {
masterPluginName: 'voxel-engine-stackgl',
require: function(name) {
// we provide the built-in plugins ourselves; otherwise check caller's require, if any
// TODO: allow caller to override built-ins? better way to do this?
if (name in BUILTIN_PLUGIN_OPTS) {
return require(name)
} else {
return opts.require ? opts.require(name) : require(name)
}
}})
loaders: pluginLoaders,
require: opts.require // optional (opts.pluginLoaders favored instead)
})

this.collideVoxels = collisions(
this.getBlock.bind(this),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"game-shell-fps-camera": "^0.7.0",
"voxel-stitch": "^0.10.0",
"voxel-registry": "^0.8.1",
"voxel-plugins": "^0.3.2",
"voxel-plugins": "^0.5.0",
"voxel": "^0.5.0",
"voxel-raycast": "^0.2.1",
"voxel-controls": "^0.1.0",
Expand Down

0 comments on commit 80d3753

Please sign in to comment.