Installation
============
There are several installation options that are detailed below.
As a library under a global variable
------------------------------------
When using this method, you must ensure that the three.js library is available
as a global variable under the name :code:`THREE`. In the simplest form this
can be achieved by including the minified library code from a CDN by including
it in your html. For example to include the version 0.118.0 from CDNJS, include
the following script tag:
.. code-block:: html
After this script (order is important, also see the `defer
`_ attribute for script
elements), you will want to include the minified library for :code:`materia`.
You can `get the newest version from the GitHub repository
`_
or `install and use a specific version from npm
`_. Then place the minified
file (:code:`materia.min.js`) in your server and include it as a script element:
.. code-block:: html
All functionality will then be available under the
:code:`materia` variable, e.g.
.. code-block:: javascript
let structureViewer = new materia.StructureViewer();
As a module
-----------
The library is distributed as an `npm package
`_ and can be installed
with:
.. code-block:: sh
npm install @lauri-codes/materia
This command will also install the `three.js `_ library
as a dependency. With the npm installation you have direct access to individual
modules that can also be tree-shaked in your own build. For example:
.. code-block:: javascript
import { StructureViewer } from "@lauri-codes/materia"