These examples aim to demonstrate how to address various issues using sigma.js, and to showcase its API.
Each example is a valid mini project usable as a standalone application. This allows opening an example in CodeSandbox.com using their GitHubBox.com feature:
github.com
by githubbox.com
in the URL bar then validateIt will create a new working code sandbox where you can live edit the code to see better how it works.
Since each example declares "sigma": "latest"
in its dependencies, if you want to edit an example using local sigma source code, you need to bypass this declaration.
Our solution to this problem is that you can run an example from this directory:
cd path/to/sigma/examples
npm install
to install examples dependenciesnpm start --example=my-example
, with my-example
being the name of an example subdirectoryYou should see the example live, using local sigma sources.
template
directory (let's say as my-example
)examples/my-example/package.json
value for "name"
examples/my-example/index.html
value for html > head > title
examples/my-example/index.ts
so that it does what you wantexamples/my-example/package.json
to this directory's examples/package.json
(so that it can be started with local sigma code)If you need public files, accessible from the example through a permalink, you need to put them in a my-example/public
subfolder.
The examples rely on kotatsu
because of its out-of-the-box compatibility with webpack
which is also used in this repository to build the sources (especially to handle shaders).
However, since it is not completely straightforward to serve static file in a CodeSandbox example which does not use a well-known tool such as create-react-app
we have to cheat a little by using the following sandbox.config.json
file to force CodeSandbox to consider our examples as using create-react-app
just so our public
files are correctly served:
{ "infiniteLoopProtection": true, "hardReloadOnChange": false, "view": "browser", "template": "create-react-app" }
Note that this is not required for examples that don't rely on static assets.