jscastro76 / threebox

A Three.js plugin for Mapbox GL JS, with support for animations and advanced 3D rendering.
Other
549 stars 145 forks source link
mapbox-gl-js three-js

Threebox

npm npm GitHub release (latest by date) NPM version NPM license

A Three.js plugin for Mapbox GL JS and Azure Maps using the CustomLayerInterface feature. Provides convenient methods to manage objects in lnglat coordinates, and to synchronize the map and scene cameras.

threebox



Latest release

GitHub Release Date
Latest code release is GitHub release (latest by date), please review the Change log for more details.

Threebox is also available as an nmp package NPM version

npm i threebox-plugin



ONLY in this Threebox fork

Models built-in & custom animations Mouse over/out, Selected, Drag&Drop, Drag&Rotate, Wireframe
threebox threebox
Tooltips using altitude Optimization of camera perspective and depth
threebox threebox
Runtime style change Optimized performance through cache
threebox threebox
Customizable FOV Geojson and Points Extrusions
threebox threebox
Sunlight illumination for a given datetime and lnglat Models built-in shadows and sky layer synced with Sunlight
threebox threebox


Only in this fork, there is a list of new features implemented on top of the amazing work from @peterqliu:



Documentation

threebox

All the Threebox Documentation has been completely updated, including all the methods, properties and events implemented in Threebox and objects, but still 'work in progress' adding better documented examples and images to illustrate Threebox capabilities.



Compatibility/Dependencies



Getting started

You can use threebox in three different ways.

NPM install

Add threebox to your project via npm package NPM version :

npm install threebox-plugin

Then you will need to import Threebox object in your code. Depending your javascript framework this might be different.

import { Threebox } from 'threebox-plugin'; 

Depending the framework, wrapper or bundler you ar using, try with this:

import { Threebox } from 'threebox-plugin/dist/threebox'; 


Use the bundle locally

Download the bundle from dist/threebox.js or dist/threebox.min.js and include it in a <script> tag on your page.
If you want to use styles predefined, add the link to the cascade style sheet, just ensure the src and href attributes are pointing to relative or absolute url path.

<script src="https://github.com/jscastro76/threebox/raw/master/./dist/threebox.js" type="text/javascript"></script>
<link href="https://github.com/jscastro76/threebox/blob/master/./dist/threebox.css" rel="stylesheet" />


Public CDNs

Threebox can be also used from different public CDNs:

jsdelivr

This CDN has the particularity that always requires the version of the package to download individual files.

<script src="https://cdn.jsdelivr.net/gh/jscastro76/threebox@v.2.2.2/dist/threebox.min.js" type="text/javascript"></script>
<link href="https://cdn.jsdelivr.net/gh/jscastro76/threebox@v.2.2.2/dist/threebox.css" rel="stylesheet" />


unpkg

Despite this CDN admits version, if omitted, it will download always the last one published.

<script src="https://unpkg.com/threebox-plugin/dist/threebox.min.js" type="text/javascript"></script>
<link href="https://unpkg.com/threebox-plugin/dist/threebox.css" rel="stylesheet" />

For an specific version (i.e. v2.2.1) use the followin:

<script src="https://unpkg.com/threebox-plugin@2.2.1/dist/threebox.min.js" type="text/javascript"></script>
<link href="https://unpkg.com/threebox-plugin@2.2.1/dist/threebox.css" rel="stylesheet" />


Test the samples

Several introductory examples are here.
To run them, create a config.js file with your Mapbox-gl-js access token, alongside and in the format of the template.



Contributing

Unit tests

Tests live here.

How to build the project in Visual Studio

Sample to get a full build from scratch for Visual Studio: