max-mapper / voxel-mesh

generate a three.js mesh from voxel data
https://npmjs.org/package/voxel-mesh
109 stars 28 forks source link

Receive THREE from engine? #12

Open Qard opened 11 years ago

Qard commented 11 years ago

I'm running a basic demo with nothing but this;

var createGame = require('voxel-engine')
  , voxel = require('voxel');

var game = createGame({
  generate: voxel.generator['Valley']
  , chunkSize: 32
  , chunkDistance: 2
  , texturePath: 'some-path'
  , materials: [['grass', 'dirt', 'grass_dirt'], 'brick', 'dirt']
  , controlOptions: { jump: 6 }
});

The problem is, when I build the bundle with browserify, I'm getting three.js included multiple times. It seems to be a result of voxel-mesh requiring it rather than receiving the game instance and grabbing game.THREE like other components usually do.

$ browserify -e index.js --list | grep three
./node_modules/voxel-engine/node_modules/three/three.js
./node_modules/voxel-engine/node_modules/voxel-chunks/node_modules/voxel-mesh/node_modules/three/three.js

Is there perhaps a better way to handle this? Three.js is kind of huge...

max-mapper commented 11 years ago

I think I removed voxel-chunks from the newer voxel-engines for this reason

Qard commented 11 years ago

It's in there as of 0.17.3. I haven't checked 0.18.x, as most of the other voxel-* modules I was trying to install had peerDependency of 0.17.x.