How can I use Three.js extensions with Volo?

55 views
Skip to first unread message

Luiz Francisco Artigas de Prá

unread,
Jul 4, 2013, 1:15:25 PM7/4/13
to vol...@googlegroups.com
Hello,

I'm using Volo to manager a game project made with Three.js and need to put some extensions and shaders files in the project.
The problem is: extensions aren't in AMD format. So how can I use it with Volo and require,js?

Here is a example extension: http://learningthreejs.com/data/THREEx/THREEx.FullScreen.js

James Burke

unread,
Jul 4, 2013, 5:49:02 PM7/4/13
to vol...@googlegroups.com
You have a couple of options.

1) If your project has amd: {} in its package.json:
https://github.com/volojs/volo/wiki/Library-best-practices#wiki-amd

then when you install it, volo will ask you for its dependencies and
exports, and will try to wrap the file in a define() call.

2) If that fails, then you can do the `volo add` with -amdoff which
will just install the dependency, no file conversion attempted. Then
in the requirejs.config() call, you can use the shim config to set up
that the plugin depends on three.js:

http://requirejs.org/docs/api.html#config-shim

https://github.com/volojs/volo/blob/master/commands/add/doc.md

James
> --
> You received this message because you are subscribed to the Google Groups
> "volojs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to volojs+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

James Burke

unread,
Jul 4, 2013, 5:49:48 PM7/4/13
to vol...@googlegroups.com
The other option, if your project does not actually use AMD modules,
is to make sure amd: {} is not in your project's package.json, and no
special wrapping is attempted.

James

Luiz Francisco Artigas de Prá

unread,
Jul 5, 2013, 8:33:32 AM7/5/13
to vol...@googlegroups.com
My project uses AMD Modules.

So, can I add a single file via "volo add"? I don't think tehre is a dedicated git repository for some extensions.
And if I use "volo amdify" command with the extension file?

James Burke

unread,
Jul 5, 2013, 12:14:35 PM7/5/13
to vol...@googlegroups.com
If it is part of a github repo, you can use the # syntax to refer to
it and just extract that file from the repo. So:

volo add owner/repo#path/to/THREEx.FullScreen.js

If it is not stored in any repo, then volo can just fetch any zip or
JS file at an URL, so this should work too:

volo add http://learningthreejs.com/data/THREEx/THREEx.FullScreen.js

If your project has "amd": {} in its package.json, then `volo add`
will automatically run the amdify command as part of the add.

James


On Fri, Jul 5, 2013 at 5:33 AM, Luiz Francisco Artigas de Prá
Reply all
Reply to author
Forward
0 new messages