Hide menu
Loading...
Searching...
No Matches
Installation

Web Toolkit can be installed with npm and modern build tools, or get started quickly with just static hosting or a CDN. For most users, installing from npm is the best choice.

Install from NPM

To install the Web Toolkit npm module, open your project folder in a terminal and run:

npm install --save @cadexchanger/web-toolkit

The package will be downloaded and installed. Including Web Toolkit will usually look like this:

// Option 1: Import the entire library.
import cadex from '@cadexchanger/web-toolkit';
const model = new cadex.ModelData_Model();
// Option 2: Import just the parts you need.
import { ModelData_Model } from '@cadexchanger/web-toolkit';
const model = new ModelData_Model();

Install from CDN

The Web Toolkit library can be used by loading from existing CDN (skypack.dev, unpkg.com, jsdelivr.com, etc.). The Web Toolkit depends on three.js (r146) library, which should be included before.

<script src="https://cdn.jsdelivr.net/npm/three@0.146.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@cadexchanger/web-toolkit@3/build/cadex.min.js"></script>
<script type="text/javascript">
const model = new cadex.ModelData_Model();
</script>

How to use Web Toolkit locally

CAD Exchanger Web Toolkit loads models data from external files, due to browsers' same origin policy security restrictions, loading from a file system will fail with a security exception.

There are two ways to solve this:

1. Change security for local files in a browser

This allows you to access your page as:

file:///filePath.html

In this case, be aware that you may open yourself to some vulnerabilities if using the same browser for a regular web surfing. You may want to create a separate browser profile / shortcut used just for local development to be safe.

2. Run files from a local web server

This allows you to access your page as:

http://localhost/fileName.html

There are many simple HTTP servers available which have enough functionality to run examples and tutorial.

  • Node.js server

    Node.js has a simple HTTP server package. To run (from your local directory):

    npx http-server . --cors -p 8000
  • Python server

    Python has a built-in http server module. To run (from your local directory):

    # Python 2.x
    python2 -m SimpleHTTPServer
    # Python 3.x
    python3 -m http.server
  • PHP server

    PHP also has a built-in web server. To run (from your local directory):

    # php 5.4.0+
    php -S localhost:8000

For more complex cases, the server part should provide model data as a stream of bytes, such that it can be accepted on client as ArrayBuffer object. For more details please refer to the Web API documentation.

CAD Exchanger SDK

The examples will use CAD Exchanger SDK in order to prepare original 3D files for Web Toolkit.

Follow instructions in the SDK documentation to download and install SDK. Make sure to copy the evaluation license key to the examples directory for your programming language. To check that installation was successful, build and run the CDXWEB Converter Example.