1 Star 0 Fork 0

viva302/threebox

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Threebox

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

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
Models built-in shadows Sunlight illumination for a given datetime and lnglat
threebox threebox

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

  • Updated to Three.js v117.
  • Updated to Mapbox-gl-js v1.11.1.
  • Updated to Azure Maps v2.0.31.
  • +20 examples with all the new features.
  • Support for multiple 3D format objects (FBX, GLTF/GLB, Collada, OBJ/MTL).
  • Support for 3D extruded shapes from GeoJson features or points array.
  • Support for CSS2D labels and rich HTML controls through a new LabelManager.
  • Support for CSS2D tooltips/title browser-like and mapbox-like.
  • Support for built-in Raycaster in Object3D and fill-extrusions together.
  • Support for built-in MouseOver/Mouseout, Selected, Drag&Drop, Drag&Rotate, Wireframe in loadedObjects including events.
  • Support for wireframing on any Object3D, removing them from the Raycaster.
  • Support for GeoJson standard features format import and export in different layers.
  • Support for Object3D embedded animations, and custom animations on AnimationManager (i.e. embedded animation + translate + rotate).
  • Support for multi-layer and multi-floor design of spaces.
  • Support for built-in shadows and real Sun light positioning for a given datetime and lnglat coords.
  • Support for Non-AABB Non Axes Aligned Bounding Box and real model size, including floor projection.
  • Support for Object3D auto-centering and 9 default anchor positions customizable through adjustments.
  • Support for setLayerZoomRange and setLayoutProperty on Custom Layers (not available in Mapbox).
  • Support for removeLayer considering Object3D.
  • Support for style change through setStyle and keeping Object3D.
  • Support for partial and full dispose of Mapbox, Three and Threebox resources and memory.
  • Support for Orthographic view, customizable Perspective FOV and fixed-size Object3D.
  • Optimization of Camera perspective to have Raycast with pixel-precision level and depth sync between Mapbox and Threebox objects.
  • Optimization for loading thousands of objects through cache.
  • Available as npm package
  • Check out change log for more detail.


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

  • Three.r117 (already bundled into the Threebox build). If desired, other versions can be swapped in and rebuilt here, though compatibility is not guaranteed. (WARNING: v118.3 breaks compatibility in some cases)
  • Mapbox-gl-js v1.11.1.
  • Azure Maps v2.0.31.


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/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="../dist/threebox.js" type="text/javascript"></script>
<link href="../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.1.9/dist/threebox.min.js" type="text/javascript"></script>
<link href="https://cdn.jsdelivr.net/gh/jscastro76/threebox@v.2.1.9/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.1.9) use the followin:

<script src="https://unpkg.com/threebox-plugin@2.1.9/dist/threebox.min.js" type="text/javascript"></script>
<link href="https://unpkg.com/threebox-plugin@2.1.9/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

  • Clone the Github repo.
  • Build the library with npm run build to get the minimized version, or npm run dev to get the development version and rebuild continuously as you develop.
  • Both commands will output a bundle in dist/ folder.

Unit tests

Tests live here.

How to build the project in Visual Studio

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

  • Install Node.js
  • Clone the repo and open a new Project using main.js
  • Install / Update the packages browserify, tape, ncp, uglyfy, watchify.
  • Right click on the project at the Solution Explorer > Open Node.js Interactive Window:
  • execute .npm [ProjectName] init -y
  • execute .npm [ProjectName] install
  • execute .npm [ProjectName] i
  • execute .npm [ProjectName] run dev or .npm run build
v.2.0.1 - v.2.1.9 MIT License Copyright (c) 2020 Jesus Serrano v.0.3.0 MIT License Copyright (c) 2017 Peter Liu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------------------- SunCalc (c) 2011-2015, Vladimir Agafonkin Copyright (c) 2014, Vladimir Agafonkin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------------------- 3D models attributions - Eiffel Tower - Creative Commons License attribution: Eiffel Tower model by https://www.cgtrader.com/lefabshop from https://www.cgtrader.com/items/108594/download-page - Elephant - Creative Commons NonCommercial License attribution: Asian Elephant low poly model by https://sketchfab.com/jeremielouvetz from https://sketchfab.com/3d-models/asian-elephant-2aeeb8958bc64240962b093705abffdf - Liberty Statue - Creative Commons License attribution: Liberty statue model by https://sketchfab.com/hellolucy2 from https://sketchfab.com/3d-models/ellis-island-3cd765a23c5c4c7087acd00624d30590 - Plane - Creative Commons License attribution: Plane model by https://sketchfab.com/ideehochzwei from https://sketchfab.com/3d-models/plane-aa001f5a88f64b16b98356c042f2d5f3 - Radar - Attribution, no License specified: Model by https://github.com/nasa/ from https://nasa3d.arc.nasa.gov/detail/jpl-vtad-dsn34 - Soldier - Attribution: Soldier animated model by T. Choonyung at https://www.mixamo.com from https://www.mixamo.com/#/?page=1&query=vanguard&type=Character - Space Needle - Creative Commons License attribution: Space Needle model by https://sketchfab.com/microsoft from https://sketchfab.com/3d-models/space-needle-1d1325bc1ad745dd9eb34fc76e8f6e87 - Triceratops - Creative Commons NonCommercial License attribution: Dino low poly model by https://sketchfab.com/Blender_Fox1234 from https://sketchfab.com/3d-models/triceratops-lowpoly-76beb95d0b5b41a3aae0d07c3eae99fa - Truck & Car - Royalty Free License: Vehicles by https://www.cgtrader.com/antonmoek from https://www.cgtrader.com/free-3d-models/car/concept/cartoon-low-poly-city-cars-pack - Windmill - Creative Commons License attribution: Windmill animated model by https://sketchfab.com/data3anshow from https://sketchfab.com/3d-models/windmill-animated-6ce5667e8d5c47068ea13196036efd52

简介

A Three.js plugin for Mapbox GL JS 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/viva302/threebox.git
git@gitee.com:viva302/threebox.git
viva302
threebox
threebox
master

搜索帮助

371d5123 14472233 46e8bd33 14472233