项目作者: mrdoob

项目描述 :
片段着色器的在线实时编辑器。
高级语言: JavaScript
项目地址: git://github.com/mrdoob/glsl-sandbox.git
创建时间: 2011-11-09T15:29:49Z
项目社区:https://github.com/mrdoob/glsl-sandbox

开源协议:MIT License

下载


glsl-sandbox

Server development

Setup

  • Fork repository
  • Download repository and create new development branch:
  1. $ git clone git@github.com:<your user>/glsl-sandbox
  2. $ cd glsl-sandbox
  3. $ git checkout -b <feature name>
  • Download and uncompress test data:
  1. $ curl -O https://downloads.zooloo.org/glslsandbox-data.tar.gz
  2. $ tar xvf glslsandbox-data.tar.gz
  • Build server binary needs go compiler:
  1. $ go build ./server/cmd/glslsandbox
  1. $ ./glslsandbox

Template and javascript modifications

The server reloads templates and assets on each query. This eases the development as you can modify the files and changes will take effect reloading the page.

There’s only one template that is used for both the gallery (index) and admin page. The file is server/assets/gallery.html and uses go language templates. You can find more information about its syntax here:

Currently the page receives this data:

  1. // galleryEffect has information about each effect displayed in the gallery.
  2. type galleryEffect struct {
  3. // ID is the effect identifyier.
  4. ID int
  5. // Version is the latest effect version.
  6. Version int
  7. // Image holds the thumbnail name.
  8. Image string
  9. // Hidden tells if the effect has been moderated.
  10. Hidden bool
  11. }
  12. // galleryData has information about the current gallery page.
  13. type galleryData struct {
  14. // Effects is an array with all the effects for the page.
  15. Effects []galleryEffect
  16. // URL is the path of the gallery. Can be "/" or "/admin".
  17. URL string
  18. // Page holds the current page number.
  19. Page int
  20. // IsPrevious is true if there is a previous page.
  21. IsPrevious bool
  22. // PreviousPage is the previous page number.
  23. PreviousPage int
  24. // IsNext is true if there is a next page.
  25. IsNext bool
  26. // NextPage is the next page number.
  27. NextPage int
  28. // Admin is true when accessing "/admin" path.
  29. Admin bool
  30. }

This is, galleryData for the page and galleryEffect for each effect. For example, to print all the effect IDs you can use:

  1. <ul>
  2. {{ range .Effects }}
  3. <li>{{ .ID }}</li>
  4. {{ end }}
  5. <ul>

The following directories are accessible from the server and can be modified if needed:

  • server/assets/css -> /css
  • server/assets/js -> /js

By default the data files are read from ./data. This path can be hanged with the environment variable DATA_PATH. For example:

  1. $ DATA_PATH=/my/data/directory ./glslsandbox

The data directory contains the sqlite database (glslsandbox.db) and the thumbnails (thumbs directory).