Skip to content

Commit 07bdc42

Browse files
sukanya anejaAvnerus
authored andcommitted
Initial squashed commit!
0 parents  commit 07bdc42

File tree

105 files changed

+48120
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+48120
-0
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.js

.eslintrc.cjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es6: true,
5+
},
6+
parser: '@typescript-eslint/parser',
7+
extends: ['plugin:@typescript-eslint/recommended'],
8+
parserOptions: {
9+
ecmaVersion: 2018,
10+
sourceType: 'module',
11+
},
12+
ignorePatterns: ['dist/**', 'lib/**', 'examples/installation/**']
13+
}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.swp
2+
*.swo
3+
node_modules
4+
lib
5+
temp
6+
etc

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"bracketSpacing": true,
3+
"printWidth": 120,
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"trailingComma": "all"
7+
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## v1.0
2+
3+
### v1.0.0
4+
5+
- First public release!

CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Each line is a file pattern followed by one or more owners.
2+
3+
# These owners will be the default owners for everything in the
4+
# repo. Unless a later match takes precedence, these owners will be
5+
# requested for review when someone opens a pull request.
6+
* @Avnerus

CODE_OF_CONDUCT.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
layout: code-of-conduct
3+
version: v1.0
4+
---
5+
6+
This code of conduct outlines our expectations for participants within **The New York Times** Open Source community, as well as steps to reporting unacceptable behavior. We are committed to providing a welcoming and inspiring community for all and expect our code of conduct to be honored. Anyone who violates this code of conduct may be banned from the community.
7+
8+
Our open source community strives to:
9+
10+
* **Be friendly and patient.**
11+
* **Be welcoming**: We strive to be a community that welcomes and supports people of all backgrounds and identities. This includes, but is not limited to members of any race, ethnicity, culture, national origin, colour, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability.
12+
* **Be considerate**: Your work will be used by other people, and you in turn will depend on the work of others. Any decision you take will affect users and colleagues, and you should take those consequences into account when making decisions. Remember that we're a world-wide community, so you might not be communicating in someone else's primary language.
13+
* **Be respectful**: Not all of us will agree all the time, but disagreement is no excuse for poor behavior and poor manners. We might all experience some frustration now and then, but we cannot allow that frustration to turn into a personal attack. It’s important to remember that a community where people feel uncomfortable or threatened is not a productive one.
14+
* **Be careful in the words that we choose**: we are a community of professionals, and we conduct ourselves professionally. Be kind to others. Do not insult or put down other participants. Harassment and other exclusionary behavior aren't acceptable.
15+
* **Try to understand why we disagree**: Disagreements, both social and technical, happen all the time. It is important that we resolve disagreements and differing views constructively. Remember that we’re different. The strength of our community comes from its diversity, people from a wide range of backgrounds. Different people have different perspectives on issues. Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to err and blaming each other doesn’t get us anywhere. Instead, focus on helping to resolve issues and learning from mistakes.
16+
17+
### Diversity Statement
18+
19+
We encourage everyone to participate and are committed to building a community for all. Although we will fail at times, we seek to treat everyone both as fairly and equally as possible. Whenever a participant has made a mistake, we expect them to take responsibility for it. If someone has been harmed or offended, it is our responsibility to listen carefully and respectfully, and do our best to right the wrong.
20+
21+
Although this list cannot be exhaustive, we explicitly honor diversity in age, gender, gender identity or expression, culture, ethnicity, language, national origin, political beliefs, profession, race, religion, sexual orientation, socioeconomic status, and technical ability. We will not tolerate discrimination based on any of the protected
22+
characteristics above, including participants with disabilities.
23+
24+
### Reporting Issues
25+
26+
If you experience or witness unacceptable behavior—or have any other concerns—please report it by contacting us via **[email protected]**. All reports will be handled with discretion. In your report please include:
27+
28+
- Your contact information.
29+
- Names (real, nicknames, or pseudonyms) of any individuals involved. If there are additional witnesses, please
30+
include them as well. Your account of what occurred, and if you believe the incident is ongoing. If there is a publicly available record (e.g. a mailing list archive or a public IRC logger), please include a link.
31+
- Any additional information that may be helpful.
32+
33+
After filing a report, a representative will contact you personally, review the incident, follow up with any additional questions, and make a decision as to how to respond. If the person who is harassing you is part of the response team, they will recuse themselves from handling your incident. If the complaint originates from a member of the response team, it will be handled by a different member of the response team. We will respect confidentiality requests for the purpose of protecting victims of abuse.
34+
35+
### Attribution & Acknowledgements
36+
37+
We all stand on the shoulders of giants across many open source communities. We'd like to thank the communities and projects that established code of conducts and diversity statements as our inspiration:
38+
39+
* [Django](https://www.djangoproject.com/conduct/reporting/)
40+
* [Python](https://www.python.org/community/diversity/)
41+
* [Ubuntu](http://www.ubuntu.com/about/about-ubuntu/conduct)
42+
* [Contributor Covenant](http://contributor-covenant.org/)
43+
* [Geek Feminism](http://geekfeminism.org/about/code-of-conduct/)
44+
* [Citizen Code of Conduct](http://citizencodeofconduct.org/)
45+
46+
This Code of Conduct was based on https://github.com/todogroup/opencodeofconduct
47+

CONTRIBUTING.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Introduction
2+
3+
Thank you for considering contributing the 3D Tiles loader.
4+
5+
Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue, assessing changes, and helping you finalize your pull requests.
6+
7+
There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests or writing code which can be incorporated into the loader itself.
8+
9+
**HINT**: Check the [Roadmap section](https://github.com/nytimes/threebird-loader-3d-tiles#roadmap) in the README, as well as `//TODO` comments within the code hinting at pending tasks.
10+
11+
# Ground Rules
12+
13+
* Use Typescript and proper typings for all of the code that you write.
14+
* Create a test for any new feature.
15+
* Write [typedoc comments](https://api-extractor.com/pages/tsdoc/doc_comment_syntax/) for new information.
16+
* Ensure cross-browser compatibility for every change. Refer to the `browserslist` field in [package.json](./package.json) for target browsers.
17+
* Keep feature versions as small as possible, preferably one new feature per version.
18+
* Refer to [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md)
19+
20+
21+
# Getting started
22+
23+
Build instructions are available in the main [README](./README.md). To contribute, follow these steps:
24+
25+
1. Create your own fork of the code
26+
2. Do the changes in your fork (**don't forget to write tests and generate documentation!**).
27+
28+
3. If you like the change and think the project could use it. Send a pull request. Thank you!
29+
30+
# How to report a bug
31+
If you find a security vulnerability, do NOT open an issue. Please report the vulnerability to the person or team maintaining the code. (refer to [SECURITY.md](./SECURITY.md)).
32+
33+
When filing an issue, make sure to answer these five questions:
34+
35+
1. What version of Three.js you are using?
36+
2. What browser and operating system are you using? What graphics card?
37+
3. What did you do?
38+
4. What did you expect to see?
39+
5. What did you see instead?
40+
41+
# How to suggest a feature or enhancement
42+
43+
If you find yourself wishing for a feature that doesn't exist in the 3D tiles loader, you are probably not alone. There are bound to be others out there with similar needs. Open an issue on our issues list on GitHub which describes the feature you would like to see, why you need it, and how it should work.
44+
45+
Thank you for contributing!

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copyright (c) 2020 The New York Times Company
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this library except in compliance with the License.
4+
You may obtain a copy of the License at
5+
6+
[www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
7+
8+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

README.md

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# @threebird/loader-3d-tiles
2+
![license](https://img.shields.io/badge/License-Apache%202.0-yellow.svg) ![version](https://img.shields.io/badge/version-1.0.0-blue)
3+
4+
[Demos](#demos) —
5+
[Usage](#basic-usage) —
6+
[Roadmap](#roadmap) —
7+
[Contributing](#contributing) —
8+
[Docs](#docs) —
9+
[Alternatives](#alternatives)
10+
11+
12+
This is a [Three.js](https://threejs.org/) loader module for handling [OGC 3D Tiles](https://www.ogc.org/standards/3DTiles), created by [Cesium](https://github.com/CesiumGS/3d-tiles). It currently supports the two main formats:
13+
14+
1. Batched 3D Model (b3dm) - based on glTF.
15+
2. Point cloud.
16+
17+
Internally, the loader uses the [loaders.gl library](https://github.com/visgl/loaders.gl), which is part of the [vis.gl platform](https://vis.gl/), openly governed by the [Urban Computing Foundation](https://uc.foundation/). Cesium has [worked closely with loaders.gl](https://cesium.com/blog/2019/11/06/cesium-uber/) to create a platform-independent implementation of their 3D Tiles viewer.
18+
19+
Development of this library started at The New York Times R&D as an effort to create a clean bridge between the 3D Tiles specification and the widely used 3D library Three.js. The library helps us deliver massive 3D and Geographical journalism to desktops and mobile readers alike. From **Re**porting to **Tele**porting!
20+
21+
---
22+
23+
## Demos
24+
* [Photogrammetry exported to 3D Tiles in RealityCapture](https://automatic-lamp-fd84a7c4.pages.github.io/examples/demos/realitycapture)
25+
* [LiDAR Point Cloud hosted as 3D Tiles in Cesium ION](https://automatic-lamp-fd84a7c4.pages.github.io/examples/demos/cesium)
26+
27+
---
28+
29+
## Basic Usage
30+
Here is a simple example using the `Loader3DTiles` module to view a `tileset.json` containing a 3d tile hierarchy.
31+
32+
```javascript
33+
import {
34+
Scene,
35+
PerspectiveCamera,
36+
WebGLRenderer,
37+
Clock
38+
} from 'three'
39+
import { Loader3DTiles } from '@threebird/loader-3d-tiles';
40+
41+
const scene = new Scene()
42+
const camera = new PerspectiveCamera()
43+
const renderer = new WebGLRenderer()
44+
const clock = new Clock()
45+
46+
renderer.setSize(window.innerWidth, window.innerHeight)
47+
document.body.appendChild(renderer.domElement)
48+
49+
let tilesRuntime = null;
50+
51+
async function loadTileset() {
52+
const result = await Loader3DTiles.load(
53+
url: 'https://<TILESET URL>/tileset.json',
54+
renderer: renderer,
55+
options: {
56+
dracoDecoderPath: 'https://unpkg.com/[email protected]/examples/js/libs/draco',
57+
basisTranscoderPath: 'https://unpkg.com/[email protected]/examples/js/libs/basis'
58+
}
59+
)
60+
const {model, runtime} = result
61+
tilesRuntime = runtime
62+
scene.add(model)
63+
}
64+
65+
function render(t) {
66+
const dt = clock.getDelta()
67+
if (tilesRuntime) {
68+
tilesRuntime.update(dt, renderer, camera)
69+
}
70+
renderer.render(scene, camera)
71+
window.requestAnimationFrame(render)
72+
}
73+
74+
render()
75+
```
76+
77+
---
78+
79+
## Installation
80+
81+
The library depends on [three.js](https://threejs.org/) r129 and uses its GLTF, Draco, and KTX2/Basis loaders.
82+
Refer to the `browserslist` field in [package.json](./package.json) for target browsers.
83+
84+
### 1. ES Module
85+
Download [dist/threebird-loader-3d-tiles.esm.min.js](dist/threebird-loader-3d-tiles.esm.min.js) and use an `importmap-shim` to import the dependencies. See [here](examples/installation/es-module) for a full example. The [demos](examples/demos) also use this method of installation:
86+
87+
#### **`index.html`**
88+
```html
89+
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
90+
<script type="importmap-shim">
91+
{
92+
"imports": {
93+
"three": "https://cdn.skypack.dev/[email protected]",
94+
"three/examples/jsm/loaders/GLTFLoader": "https://cdn.skypack.dev/[email protected]/examples/jsm/loaders/GLTFLoader",
95+
"three/examples/jsm/loaders/DRACOLoader": "https://cdn.skypack.dev/[email protected]/examples/jsm/loaders/DRACOLoader",
96+
"three/examples/jsm/loaders/KTX2Loader": "https://cdn.skypack.dev/[email protected]/examples/jsm/loaders/KTX2Loader",
97+
"@threebird/loader-3d-tiles" : "./threebird-loader-3d-tiles.esm.min.js"
98+
}
99+
}
100+
</script>
101+
<script src='index.js' type='module-shim'>
102+
103+
```
104+
#### **`index.js`**
105+
```javascript
106+
import { Scene, PerspectiveCamera } from 'three';
107+
import { Loader3DTiles } from '@threebird/loader-3d-tiles';
108+
```
109+
110+
### 3. NPM
111+
If you use a build system such as Webpack / Parcel / Rollup etc, you should also install the library along with three.js from npm:
112+
```
113+
npm install -s three @threebird/loader-3d-tiles
114+
```
115+
The application script would be the same as in the ES Module example (when using `importmap-shim`).
116+
117+
See [here](examples/installation/webpack) for a complete webpack example.
118+
119+
---
120+
## Roadmap
121+
122+
### Geo-referencing and layering: WGS84.
123+
124+
Currently the library does not use geo-referenced locations of tiled models, instead transforming them to Point `[0,0,0]`. We should support maintaining *WGS84* coordinates, so that models could be layered on top of maps and terrains.
125+
126+
## Skip-traversal
127+
Implementing the [Skip traversal mechanism](https://cesium.com/blog/2017/05/05/skipping-levels-of-detail/) could greatly improve performance of b3dm (mesh) tiles, but requires a shader/Stencil buffer-based implementation which manually manges Z-culling. This is a very wanted features and contributions would be greatly appreciated.
128+
129+
130+
## Contributing
131+
132+
Refer to [CONTRIBUTING.MD](./CONTRIBUTING.md) for general contribution instructions.
133+
134+
### Developing
135+
The library is built using rollup. To run a simple development server type:
136+
```
137+
npm run dev
138+
```
139+
It is also possible to develop the library while developing loaders.gl. Just clone the source of loaders.gl and run:
140+
```
141+
LOADERS_GL_SRC=<path to loaders.gl> npm run dev
142+
```
143+
144+
### Building
145+
To build the library run:
146+
```
147+
npm run build
148+
```
149+
To build the production minified version run:
150+
```
151+
npm run build:production
152+
```
153+
And to build the API documentation run:
154+
```
155+
npm run build:docs
156+
```
157+
158+
159+
### Tests
160+
A rudimentary test spec is available at [./test](./test). To run it type:
161+
```
162+
npm run test
163+
```
164+
165+
166+
## Docs
167+
* API documentation is available [here](docs/loader-3d-tiles.md).
168+
* Code for the demos is in [`examples/demos`](examples/demos).
169+
170+
## Alternatives
171+
To our knowledge, this is the only [loaders.gl](https://github.com/visgl/loaders.gl)-based Three.js library, but there are several implementations of 3D Tiles for Three.js. Notable examples:
172+
173+
- [NASSA-AMMOS / 3DTilesRendererJS](https://github.com/NASA-AMMOS/3DTilesRendererJS)
174+
- [ebeaufay / 3DTilesViewer](https://github.com/ebeaufay/3DTilesViewer)
175+
- [iTowns](https://github.com/iTowns/itowns)
176+
177+
---
178+
179+
> This repository is maintained by the Research & Development team at The New York Times and is provided as-is for your own use. For more information about R&D at the Times visit [rd.nytimes.com](https://rd.nytimes.com)

0 commit comments

Comments
 (0)