Coder Social home page Coder Social logo

nytimes / three-loader-3dtiles Goto Github PK

View Code? Open in Web Editor NEW
422.0 31.0 59.0 9.93 MB

This is a Three.js loader module for handling OGC 3D Tiles, created by Cesium. It currently supports the two main formats, Batched 3D Model (b3dm) - based on glTF Point cloud.

License: Other

JavaScript 5.35% TypeScript 94.65%
webgl threejs 3d cesium loadersgl

three-loader-3dtiles's Introduction

three-loader-3dtiles

license npm version Build Status

DemosUsageRoadmapContributingDocsAlternatives

This is a Three.js loader module for handling OGC 3D Tiles, created by Cesium. It currently supports the two main formats:

  1. Batched 3D Model (b3dm) - based on glTF.
  2. Point cloud.

Internally, the loader uses the loaders.gl library, which is part of the vis.gl platform, openly governed by the Urban Computing Foundation. Cesium has worked closely with loaders.gl to create a platform-independent implementation of their 3D Tiles viewer.

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 Reporting to Teleporting!


Demos


Basic Usage

Here is a simple example using the Loader3DTiles module to view a tileset.json containing a 3d tile hierarchy.

import { 
  Scene, 
  PerspectiveCamera, 
  WebGLRenderer, 
  Clock 
} from 'three'
import { Loader3DTiles } from 'three-loader-3dtiles';

const scene = new Scene()
const camera = new PerspectiveCamera()
const renderer = new WebGLRenderer()
const clock = new Clock()

renderer.setSize(window.innerWidth, window.innerHeight)
document.body.appendChild(renderer.domElement)

let tilesRuntime = null;

async function loadTileset() {
  const result = await Loader3DTiles.load(
      url: 'https://<TILESET URL>/tileset.json',
      renderer: renderer,
      options: {
        dracoDecoderPath: 'https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/libs/draco',
        basisTranscoderPath: 'https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/libs/basis',
      }
  )
  const {model, runtime} = result
  tilesRuntime = runtime
  scene.add(model)
}

function render() {
  const dt = clock.getDelta()
  if (tilesRuntime) {
    tilesRuntime.update(dt, window.innerHeight, camera)
  }
  renderer.render(scene, camera)
  window.requestAnimationFrame(render)
}

loadTileset()
render()

Installation

The library supports three.js r160 and uses its GLTF, Draco, and KTX2/Basis loaders. Refer to the browserslist field in package.json for target browsers.

1. ES Module

Download dist/three-loader-3dtiles.esm.min.js and use an importmap to import the dependencies. See here for a full example.

index.html

<script type="importmap">
  {
    "imports": {
      "three": "https://unpkg.com/[email protected]/build/three.module.js",
      "three/examples/jsm/": "https://unpkg.com/[email protected]/examples/jsm/",
      "three-loader-3dtiles" : "../../../../dist/lib/three-loader-3dtiles.js"
    }
  }
</script>
<script src='index.js' type='module'>

index.js

import { Scene, PerspectiveCamera } from 'three';
import { Loader3DTiles } from 'three-loader-3dtiles';

3. NPM

If you use a build system such as Webpack / Vite / Rollup etc, you should also install the library along with three.js from npm:

npm install -s three three-loader-3dtiles

The application script would be the same as in the ES Module example (when using importmap).

See here for a complete webpack example.

4. A-Frame

Refer to our dedicated A-Frame component: aframe-loader-3dtiles-component.

5. React-Three-Fiber

Refer to examples/r3f.


Roadmap

Supporting 3D Tiles Next

The 3D Tiles Next specification is in the works, with some of the features already supported in loaders.gl. Supporting the new extensions opens up possibilities for new applications.

Skip-traversal

Implementing the Skip traversal mechanism 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 feature and contributions would be greatly appreciated.

Contributing

Refer to CONTRIBUTING.MD for general contribution instructions.

Developing

The library is built using rollup. To run a simple development server type:

npm run dev

It is also possible to develop the library while developing loaders.gl. Just clone the source of loaders.gl and run:

LOADERS_GL_SRC=<path to loaders.gl> npm run dev

Building

To build the library run:

npm run build

To build the production minified version run:

npm run build:production

And to build the API documentation run:

npm run docs

Tests

A rudimentary test spec is available at ./test. To run it type:

npm run test

Docs

Alternatives

To our knowledge, this is the only loaders.gl-based Three.js library, but there are several implementations of 3D Tiles for Three.js. Notable examples:


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

three-loader-3dtiles's People

Contributors

avnerus avatar dependabot[bot] avatar jconnolly-bond avatar kfarr avatar simongle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

three-loader-3dtiles's Issues

Resulting 3D Object doesn't react to lighting

Hi,
no matter what is the lighting (direction, color) the 3Dtiles object show exactly the same.
Any idea how to fix this ?
(using R3F)
Here for example with a red up directionallight:

WhatsApp Image 2023-02-02 at 12 13 45

combining 3d tiles and 3d modeling

Hi Avner!
I have a question relating to the library, but not directly. I hope you can help me.
I'm trying to use the library to use LOD to load heavy photogrammetry, but I want to integrate 3D modeling from max or Blender. What is the best way to do that? Do I import the tileset into 3D max and model on top of that to maintain positioning?
I see that the NYT team is occasionally combing photogrammetry and digital modeling
Any tips would help. Thanks:)

A 3D tile failed to load: undefined error parsing gltf

Hi,

I am getting this error

A 3D tile failed to load: undefined error parsing gltf in tile TypeError: Cannot read properties of null (reading 'userData')
_onTileLoadError @ three-loader-3dtiles.js?v=da8a407f:6181
_loadTile @ three-loader-3dtiles.js?v=da8a407f:6173
await in _loadTile (async)
_loadTiles @ three-loader-3dtiles.js?v=da8a407f:6077
_updateTiles @ three-loader-3dtiles.js?v=da8a407f:6066
_onTraversalEnd @ three-loader-3dtiles.js?v=da8a407f:6055
executeTraversal @ three-loader-3dtiles.js?v=da8a407f:5445
traverse @ three-loader-3dtiles.js?v=da8a407f:5430
Le @ three-loader-3dtiles.js?v=da8a407f:12245
update @ three-loader-3dtiles.js?v=da8a407f:12336
animate @ ThreeDViewer.vue:151
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
requestAnimationFrame (async)
animate @ ThreeDViewer.vue:144
(anonymous) @ ThreeDViewer.vue:159
(anonymous) @ chunk-RQPU2HK5.js?v=da8a407f:9233
callWithErrorHandling @ chunk-RQPU2HK5.js?v=da8a407f:1865
callWithAsyncErrorHandling @ chunk-RQPU2HK5.js?v=da8a407f:1872
hook.__weh.hook.__weh @ chunk-RQPU2HK5.js?v=da8a407f:4025
flushPostFlushCbs @ chunk-RQPU2HK5.js?v=da8a407f:2029
flushJobs @ chunk-RQPU2HK5.js?v=da8a407f:2056
Promise.then (async)
queueFlush @ chunk-RQPU2HK5.js?v=da8a407f:1970
queueJob @ chunk-RQPU2HK5.js?v=da8a407f:1964
scheduler @ chunk-RQPU2HK5.js?v=da8a407f:3463
resetScheduling @ chunk-RQPU2HK5.js?v=da8a407f:640
triggerEffects @ chunk-RQPU2HK5.js?v=da8a407f:683
triggerRefValue @ chunk-RQPU2HK5.js?v=da8a407f:1221
set value @ chunk-RQPU2HK5.js?v=da8a407f:1672
set @ chunk-RQPU2HK5.js?v=da8a407f:1511
changeMapMode @ ProjectMap.vue:545
await in changeMapMode (async)
callWithErrorHandling @ chunk-RQPU2HK5.js?v=da8a407f:1865
callWithAsyncErrorHandling @ chunk-RQPU2HK5.js?v=da8a407f:1872
emit @ chunk-RQPU2HK5.js?v=da8a407f:2328
(anonymous) @ chunk-RQPU2HK5.js?v=da8a407f:8354
changeActiveBtnStates @ MapModeBtnGroup.vue:241
btnClicked @ MapModeBtnGroup.vue:197
_createElementVNode.onClick._cache.._cache. @ MapModeBtnGroup.vue:95
callWithErrorHandling @ chunk-RQPU2HK5.js?v=da8a407f:1865
callWithAsyncErrorHandling @ chunk-RQPU2HK5.js?v=da8a407f:1872
invoker @ chunk-RQPU2HK5.js?v=da8a407f:10558
Show 30 more frames
Show less

Point cloud intensity visualisation

Hi there,

I was wondering if there any demos or example datasets that include working intensity visualisation? I can see that there is an implementation for it but I'm not seeing anything except for a flat grey when I turn on the Intensity colouring. When creating the 3D Tiles the 'Intensity' dimension was added but I am not seeing tile.content.attributes.intensity populated with anything.

Looking through the loaders.gl code base I can't see where they are implementing dimensions/attributes other than position, color, normal and batchIds. Are you able to point me to where this information is parsed by loaders.gl? Or any other ideas for why intensity is not being picked up?

Thanks very much.

Loading from Cesium Ion - InvalidCredentials

I am trying out the r3f example. The default model loads correctly. When trying to load an asset from Cesium ION, the access token doesn't seem to get through for fetching the asset files.
Heres my Flow:

  1. GET https://api.cesium.com/v1/assets/<assetId>/endpoint?access_token=<userAccessToken> to fetch assetUrl with corresponding accessToken
  2. in Loader3DTilesR3FAsset component, Setting accessToken in 'cesiumIONToken' prop, assetUrl in url prop

Getting error
ERROR:{"code":"InvalidCredentials","message":"Invalid access token"} when trying to access tileset.json
Also tried setting prop cesium-ion={{accessToken:<accessToken>}}, in which case tileset loads, but fetching first b3dm file returns the above error.

Missplacement of 3d tiles on map

I have noticed a misplacement of my model on the map.

I created the model with Agisoft Metashape and also exported it there as 3D tiles.

Using the export directly as "Cesium 3D Tiles" as well as via Cesium Ion brought the following placement on the map. (only the height was changed to place it above the map)

NY-Times+Ion

However, when used in the Cesium API, the 3d tile is placed correctly.
Cesium+Ion

What can I do to place the 3d tiles correctly? (apart from the manual adjustment of all models)

Thank you for your wonderful work!

A little question about 'TILE SELECTED BUT NOT LOADED!!'

Hello!I've been learning your code recently.And I noticed the code in the tilesetUpdate
image
I have never encountered this error,But I wonder why.
Both the contentLoader and the createGLTFNodes are Asynchronous function,But the tilesetUpdate is not async.
When running to

if (tile.selected) {
if (!renderMap[tile.id]) {

It's very likely to meet the error 'TILE SELECTED BUT NOT LOADED!!'. However,Its current performance is good actually.
I'm so curious.Hope you can guide me if you are free.Thanks!

hosting tilesets not through cesium

Hi, me again:)
I'm trying to stream tileset from my hosting server (rather than Cesium).
Uploaded a tileset (exported from RC) to my web host :
https://eytanmann.xyz/tileset/tileset_RC_model.json
but getting an error:
Access to fetch at 'https://eytanmann.xyz/tileset/tileset_RC_model.json' from origin 'https://www.eytanmann.xyz' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

The same JS with the example URL:
https://int.nyt.com/data/3dscenes/ONA360/TILESET/0731_FREEMAN_ALLEY_10M_A_36x8K__10K-PN_50P_DB/tileset_tileset.json
works fine

What am I missing?
Thanks!

exampleURL
exampleURL_2

browser crash

hi there, time to time there are errors, about "three loader 3dtiles" that can't load textures sporadically
when i wait for full loading, this will not happen, what could be the cause ?
thx

GLTFLoader.js:3296 THREE.GLTFLoader: Couldn't load texture blob:http://localhost:5173/956d8764-64db-4302-a849-47cc82454dc9
(anonymous) @ GLTFLoader.js:3296
tileset-3d.js:527 A 3D tile failed to load: undefined error parsing gltf in tile http://localhost:5173/media/tiles/ct/LOD-1/Mesh-XL-YR-ZL-XR-YR-ZR-XL-YL-ZR.b3dm: TypeError: Cannot set properties of null (setting 'encoding')
 
index.ts:217 Tile error http://localhost:5173/media/tiles/ct/LOD-1/Mesh-XL-YR-ZL-XR-YR-ZR-XL-YL-ZR.b3dm error parsing gltf in tile http://localhost:5173/media/tiles/ct/LOD-1/Mesh-XL-YR-ZL-XR-YR-ZR-XL-YL-ZR.b3dm: TypeError: Cannot set properties of null (setting 'encoding')

TS compiler errors from loaders.gl

This library is great, but at the moment I can't use it without significantly changing my Typescript build flags because of config issues with the loaders.gl library. This issue documents it well.

It seems like the loaders.gl team has been hard at work fixing the issue in version 3.1 of the library, so I'm just leaving a note here requesting that three-loader-3dtiles use the 3.1.X version of loaders.gl as soon as it's ready. Thanks!

Next.js Production Build - Error loading 3d tiles! Error: 3DTileLoader: unknown type

Hi! First of all thank you for this library!

For our project we used it with [email protected], utilizing new 'app' directory, but we tested and realized that the same issue occurs on the earlier versions of Next.js and 'pages' directory. This issue doesn't occur on the development server, but only after production build and after running it on the next production server (next build && next start).

The issue occurs when the library fails to detect 'tileset.json' as a tileset, and tries to fetch and process it as a tile (fails to correctly detect type).

The quick solution was to hardcode here instead of :
const tilesetJson = await load(url, Tiles3DLoader, { ...loadersGLOptions, });
the folowing:
const tilesetJson = await load(url, Tiles3DLoader, { ...loadersGLOptions, '3d-tiles': { isTileset: true }, });

...loadersGLOptions,

We tried to identify the root cause of such behaviour but so far failed. Is it important to leave 'isTileset' property in this place undefined, or maybe you could explicitly specify it in this line of code?

Working with VR

Hi, I'm trying to create an AR experience with 3D tiles, and I'm currently trying using this library in conjunction with react-xr, but I encountered a few problems when entering XR mode:

  • The color of my 3D mesh is a lot darker that it should be (R3F uses srgb workflow by default, perhaps the color encoding got messed up? The color seems correct with my other textured components in XR.)
  • The tile culling / updating is incorrect. react-xr puts the camera in a group, and I made sure the camera's local coordinates within the group was all zeroed.

I will continue investigating the causes of these issues, but in the meantime I would appreciate it if anyone has previous experience dealing with similar problems. Thanks!

multiple tileSet.json

How to solve this tileSet.json?
{
"asset": {
"generatetool": "[email protected]",
"version": "1.0"
},
"geometricError": 163.423444179352,
"refine": "REPLACE",
"root": {
"boundingVolume": {
"box": [0.0132733217906242, -0.00984635506756604, -0.110166843514889, 61.3521311793011, 0, 0, 0, 81.7117220896762, 0, 0, 0, 8.94862092798576]
},
"children": [{
"boundingVolume": {
"box": [-53.4559955280274, -69.769910659641, -4.16934160515666, 7.88286232948303, 0, 0, 0, 10.5832633972168, 0, 0, 0, 1.59637367725372]
},
"content": {
"uri": "./Tile_+000_+000/Tile_+000_+000.json"
},
"geometricError": 0.656753778457642,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-53.184798611328, -44.364070606418, -5.14773012232035, 7.9301905632019, 0, 0, 0, 15.1030941009521, 0, 0, 0, 3.35158121585846]
},
"content": {
"uri": "./Tile_+000_+001/Tile_+000_+001.json"
},
"geometricError": 0.941125631332397,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-52.851690585725, -14.336343433708, -1.28782602213323, 7.9155375957489, 0, 0, 0, 15.1370725631714, 0, 0, 0, 7.20625734329224]
},
"content": {
"uri": "./Tile_+000_+002/Tile_+000_+002.json"
},
"geometricError": 0.941125512123108,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-52.5483602210879, 15.6574861290865, 0.92594285774976, 7.93073105812073, 0, 0, 0, 15.1371788978577, 0, 0, 0, 5.65768194198608]
},
"content": {
"uri": "./Tile_+000_+003/Tile_+000_+003.json"
},
"geometricError": 0.94112554192543,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-52.2272290359251, 45.6514558037743, 1.39478064887226, 7.92812585830688, 0, 0, 0, 15.1374063491821, 0, 0, 0, 5.72855877876282]
},
"content": {
"uri": "./Tile_+000_+004/Tile_+000_+004.json"
},
"geometricError": 0.941125519573689,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-51.9698728001676, 71.1048369887285, 2.23095378372818, 7.89296936988831, 0, 0, 0, 10.5970387458801, 0, 0, 0, 6.01649618148804]
},
"content": {
"uri": "./Tile_+000_+005/Tile_+000_+005.json"
},
"geometricError": 0.657696127891541,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-30.778311887756, -70.0098604816012, -3.91579345334321, 15.1327557563782, 0, 0, 0, 10.6599230766296, 0, 0, 0, 3.638880610466]
},
"content": {
"uri": "./Tile_+001_+000/Tile_+001_+000.json"
},
"geometricError": 0.941125512123108,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-30.4756264681928, -44.4936209553853, -2.25424921605736, 15.2147307395935, 0, 0, 0, 15.1374292373657, 0, 0, 0, 6.66305732727051]
},
"content": {
"uri": "./Tile_+001_+001/Tile_+001_+001.json"
},
"geometricError": 0.941198945045471,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-30.1571086733602, -14.577204181347, -1.53373353835195, 15.2147226333618, 0, 0, 0, 15.2147355079651, 0, 0, 0, 6.51720952987671]
},
"content": {
"uri": "./Tile_+001_+002/Tile_+001_+002.json"
},
"geometricError": 0.941125512123108,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-29.8386258357204, 15.4165389519185, 0.8166773179546, 15.2147507667541, 0, 0, 0, 15.2147445678711, 0, 0, 0, 5.46272993087769]
},
"content": {
"uri": "./Tile_+001_+003/Tile_+001_+003.json"
},
"geometricError": 0.941142797470093,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-29.5201118732803, 45.4102791338228, -0.278657312504947, 15.2147407531738, 0, 0, 0, 15.2147431373596, 0, 0, 0, 6.41488170623779]
},
"content": {
"uri": "./Tile_+001_+004/Tile_+001_+004.json"
},
"geometricError": 0.941125519573689,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-29.2497972878627, 70.8697890085168, 2.30899079330266, 15.1665291786194, 0, 0, 0, 10.6804609298706, 0, 0, 0, 6.52946329116821]
},
"content": {
"uri": "./Tile_+001_+005/Tile_+001_+005.json"
},
"geometricError": 0.941125512123108,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-0.855356467887757, -73.4241715758108, -3.8125839708373, 15.0616374015808, 0, 0, 0, 7.57439017295837, 0, 0, 0, 4.08671593666077]
},
"content": {
"uri": "./Tile_+002_+000/Tile_+002_+000.json"
},
"geometricError": 0.941204071044922,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-0.398486438672988, -44.0380923929624, -2.23665947560221, 15.1313252449036, 0, 0, 0, 14.3633761405945, 0, 0, 0, 6.82212829589844]
},
"content": {
"uri": "./Tile_+002_+001/Tile_+002_+001.json"
},
"geometricError": 0.941125512123108,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-0.16337919794023, -14.8957175784744, 0.508025146089494, 15.2147402763367, 0, 0, 0, 15.2147359848022, 0, 0, 0, 5.7990243434906]
},
"content": {
"uri": "./Tile_+002_+002/Tile_+002_+002.json"
},
"geometricError": 0.941125512123108,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [0.155129320453852, 15.0980218336917, 1.16016330756247, 15.2147402763367, 0, 0, 0, 15.2147393226624, 0, 0, 0, 5.75844407081604]
},
"content": {
"uri": "./Tile_+002_+003/Tile_+002_+003.json"
},
"geometricError": 0.94112554192543,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [0.473643101286141, 45.0917924428359, -0.759381126612425, 15.2147421836853, 0, 0, 0, 15.214759349823, 0, 0, 0, 3.33654916286469]
},
"content": {
"uri": "./Tile_+002_+004/Tile_+002_+004.json"
},
"geometricError": 0.941125519573689,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [0.743820440489797, 70.5474965847097, 0.741478244774044, 15.1664156913757, 0, 0, 0, 10.6767392158508, 0, 0, 0, 4.57918405532837]
},
"content": {
"uri": "./Tile_+002_+005/Tile_+002_+005.json"
},
"geometricError": 0.941125512123108,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [29.2416767254472, -70.6077266163193, -1.58508604485542, 15.1663780212402, 0, 0, 0, 10.5324912071228, 0, 0, 0, 6.84071946144104]
},
"content": {
"uri": "./Tile_+003_+000/Tile_+003_+000.json"
},
"geometricError": 0.94112554192543,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [29.5211104159243, -45.2079589399509, -2.25138338562101, 15.205482006073, 0, 0, 0, 15.214729309082, 0, 0, 0, 6.17254734039307]
},
"content": {
"uri": "./Tile_+003_+001/Tile_+003_+001.json"
},
"geometricError": 0.941621124744415,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [29.8303623036481, -15.2142359400168, 0.547081560827792, 15.2147488594055, 0, 0, 0, 15.2147421836853, 0, 0, 0, 6.44143795967102]
},
"content": {
"uri": "./Tile_+003_+002/Tile_+003_+002.json"
},
"geometricError": 0.941148161888123,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [30.1488593448885, 14.7795144263655, 0.473178651183844, 15.2147364616394, 0, 0, 0, 15.2147440910339, 0, 0, 0, 6.26123666763306]
},
"content": {
"uri": "./Tile_+003_+003/Tile_+003_+003.json"
},
"geometricError": 0.94112554192543,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [30.467378444504, 44.7732545607723, -1.20497709792107, 15.2147336006165, 0, 0, 0, 15.2147507667542, 0, 0, 0, 4.4613139629364]
},
"content": {
"uri": "./Tile_+003_+004/Tile_+003_+004.json"
},
"geometricError": 0.94112554192543,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [30.7377018607222, 70.2293182443827, 1.19441481214017, 15.1665472984314, 0, 0, 0, 10.6770806312561, 0, 0, 0, 5.28653168678284]
},
"content": {
"uri": "./Tile_+003_+005/Tile_+003_+005.json"
},
"geometricError": 0.941217362880707,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [52.0257329232991, -69.9677960211411, -2.61276455782354, 7.83652544021606, 0, 0, 0, 9.66233539581299, 0, 0, 0, 5.77979493141174]
},
"content": {
"uri": "./Tile_+004_+000/Tile_+004_+000.json"
},
"geometricError": 0.594089508056641,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [52.2410178463906, -45.449307219591, -0.0300762644037604, 7.95018720626831, 0, 0, 0, 15.1375541687012, 0, 0, 0, 5.39740228652954]
},
"content": {
"uri": "./Tile_+004_+001/Tile_+004_+001.json"
},
"geometricError": 0.941125631332397,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [52.5595847694203, -15.4554582694545, -2.10604382306337, 7.95021605491638, 0, 0, 0, 15.1374526023865, 0, 0, 0, 3.87414538860321]
},
"content": {
"uri": "./Tile_+004_+002/Tile_+004_+002.json"
},
"geometricError": 0.941125512123108,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [52.874235435389, 14.538137822412, 1.79807408619672, 7.94634747505188, 0, 0, 0, 15.1375913619995, 0, 0, 0, 6.38339471817017]
},
"content": {
"uri": "./Tile_+004_+003/Tile_+004_+003.json"
},
"geometricError": 0.94112554192543,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [53.1962345372885, 44.532022528816, 1.35396588314325, 7.94986248016357, 0, 0, 0, 15.1374382972717, 0, 0, 0, 6.86526989936829]
},
"content": {
"uri": "./Tile_+004_+004/Tile_+004_+004.json"
},
"geometricError": 0.941125519573689,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [53.4651461984031, 69.9879333591089, 1.74625786207616, 7.9002583026886, 0, 0, 0, 10.5999236106873, 0, 0, 0, 6.01971983909607]
},
"content": {
"uri": "./Tile_+004_+005/Tile_+004_+005.json"
},
"geometricError": 0.657795071601868,
"refine": "REPLACE"
}, {
"boundingVolume": {
"box": [-0.702466920018196, -52.5866635832936, -7.560227711685, 60.4319953918457, 0, 0, 0, 29.1349048614502, 0, 0, 0, 0.917813301086426]
},
"content": {
"uri": "./Tile_000_000_+mo-LVBADUI_/Tile_000_000_+mo-LVBADUI_.json"
},
"geometricError": 3.78894376754761,
"refine": "REPLACE"
}],
"geometricError": 163.423444179352,
"refine": "REPLACE",
"transform": [-0.881348596318614, -0.472466561533416, 0.0, 0.0, 0.240618978928741, -0.448855467439181, 0.86059937039789, 0.0, -0.406604425389714, 0.758488047092863, 0.509282557791602, 0.0, -2595659.02024064, 4841994.37646136, 3229365.74793606, 1.0]
}
}

Demo dependency returning 404

Main branch demos on github pages and localhost fail to load from 404.

To reproduce, try one of these URLs in google chrome browser mac os:
http://localhost:8000/examples/demos/realitycapture/index.html (main branch; local repo after running npm run dev)
https://nytimes.github.io/three-loader-3dtiles/examples/demos/realitycapture/

See this console message:

/three-loader-3dtiles/dist/three-loader-3dtiles.esm.js:1 Failed to load resource: the server responded with a status of 404 ()
2es-module-shims.js:481 Uncaught (in promise) Error: 404  https://nytimes.github.io/three-loader-3dtiles/dist/three-loader-3dtiles.esm.js
    at es-module-shims.js:481

Demos do work as expected on feature/aframe-example branch

About Clipping 3dtiles

I want Clip the model,Here is what I tried

const clipPlanes = [
    new THREE.Plane(new THREE.Vector3(1, 0, 0), -50),
    new THREE.Plane(new THREE.Vector3(-1, 0, 0), -50),
    new THREE.Plane(new THREE.Vector3(0, 0, -1), -10),
    new THREE.Plane(new THREE.Vector3(0, 0, 1), -10),
]
const animate = () => {
    deltaTime.value = colck.getDelta()
    if (tilesRuntime.value) {
        console.log(tilesRuntime.value)
        scene.traverse((obj: any) => {
            if (obj.type == "Mesh") {
                if (obj.material.length > 1) {
                    obj.material.forEach((element: any) => {
                        element.clippingPlanes = clipPlanes;
                        element.clipIntersection = true;
                    });
                } else {
                    obj.material.clippingPlanes = clipPlanes;
                    obj.material.clipIntersection = true;
                }
            }
        })
        tilesRuntime.value.update(deltaTime.value, renderer, camera)
    }
    renderer.render(scene, camera);
    requestAnimationFrame(animate);
}

I got the effect I wanted, but I put the clip's code in the animate, This may seem like a poor performance. Is there a better way?@wanyanyan @Avnerus
image

the trouble of raycaster

When I used the raycaster in threejs to get coordinates of some points on 3dtitles-model's surface . But sometimes coordinates witch I got was not on the surface . It seems raycaster get the lower LODs model‘s surface . How can I avoidance the lower LODs model‘s surface ?Or how can I got the right coordinates of points on 3dtitles-model's surface?I need your help!Thanks very much!
@Avnerus
1691681492615

Preload tiles

Is it possible to preload tiles using this library? I'm caching responses using the Cache API so that I can load the LOD's almost instantly, but I'm wondering if it is possible to preload an x-amount of tiles (or LOD's). It is acceptable for me to be in a loading state for like a minute or two, but there doesn't seem to be a method that can be used to preload.

Any thoughts or pointers?

We tried generated 1.1 version tiles data in this viewer. but not able to load tiles data.

We tried generated 1.1 version tiles data in this viewer. but not able to load tiles data.
our viewer and the Cesium js viewer ( with 1.1 support) are not mutually compatible as yet.

Seems the issue is the library are not able to bind {"uri":"tiles/{level}/{x}/{y}/{z}.glb"}
Below tiles.json (1.1) link attached.

{"asset":{"version":"1.1","extras":{"ion":{"georeferenced":true,"movable":true,"terrainId":1}}},"schema":{"id":"cesium-tiling-pipeline","classes":{"tile":{"properties":{"tightBoundingBox":{"name":"Tight Bounding Box","type":"SCALAR","componentType":"FLOAT64","array":true,"count":12,"semantic":"TILE_BOUNDING_BOX"}}}}},"geometricError":20.056809047163423,"root":{"boundingVolume":{"box":[5.246493816375732,-11.81087795346204,5.281450901572764,11.579803943634033,0,0,0,11.579804266996945,0,0,0,11.579804096763194]},"geometricError":0.41705300908603965,"refine":"REPLACE","content":{"uri":"tiles/{level}/{x}/{y}/{z}.glb"},"metadata":{"class":"tile","properties":{"tightBoundingBox":[-0.7740600109100342,-11.8108777506449,-0.8566333773136567,5.559250116348267,0,0,0,11.579804064179806,0,0,0,5.4417197527099965]}},"implicitTiling":{"subdivisionScheme":"OCTREE","subtreeLevels":7,"availableLevels":7,"subtrees":{"uri":"subtrees/{level}/{x}/{y}/{z}.subtree"}},"transform":[0,1,0,0,0,0,1,0,1,0,0,0,6378163,0,0,1]}}

Question:

Can we pass as a parameter in tiles.json for above X,Y,Z and level values to load the tiles data?
Any other alternative where we can generate the content url and subtree url as an absolute URL.
like "uri":"tiles/tiles/1/1/0.glb"} ?

Wrong model culling rendering issues

With version 1.2.1, after zooming the camera several times with "OrbitControls", there is a problem with model culling, it looks like the model is moving away from the camera. There is no good solution at the moment and by the way there is no manual for version 1.2.3, maybe the documentation should be updated. Thanks for your help.

Additional note: The main problem is when moving the viewpoint after zooming in, then restoring the viewpoint and repeating the operation about four times. I restored the viewpoint using the following code

let lastPerspectiveStop: () => void;
export const setPerspective = ([cameraP, controlsP] = Config['perspective'], animate = 500) => {
    lastPerspectiveStop && lastPerspectiveStop();
    const lastCamera = [...camera.position.toArray()];
    const lastControls = [...controls.target.toArray()];
    if (animate) {
        lastPerspectiveStop = tween(animate, (i) => {
            camera.position.fromArray(lastCamera.map((c, k) => c + (cameraP[k] - c) * i));
            controls.target.fromArray(lastControls.map((c, k) => c + (controlsP[k] - c) * i));
            camera.updateMatrix();
            controls.update();
            renderContenxt(i === 1);
        }, Tween.easeInOut);
    }
    else {
        camera.position.fromArray(cameraP);
        controls.target.fromArray(controlsP);
        camera.updateMatrix();
        controls.update();
        renderContenxt();
    }
    return [lastCamera, lastControls] as [[number, number, number], [number, number, number]];
};

Could this be the cause?

Point material configuration

Hi there,
First of all thank you for the great lib.

I was wondering if it would be possible to expose the material used by points or allow for its properties to be updated?

The main use case I have in mind is being able to change the opacity of all the points being rendered dynamically.

Thanks very much.

storing tileset data

Hi!
I'm not a web dev and need some pointer -
I've exported a tileset from Reality Capture (fodlder+JSON file),
now I want to store it, and to call the json from the script (like in your example) - Where should I store the data? is it in a tiling service (like-https://www.maptiler.com/server/pricing/) or just regular web storage?. For development can I store it locally?:
async function loadTileset() { const result = await Loader3DTiles.load( { url: queryParams.get('tilesetUrl') ?? 'https://int.nyt.com/data/3dscenes/ONA360/TILESET/0731_FREEMAN_ALLEY_10M_A_36x8K__10K-PN_50P_DB/tileset_tileset.json', renderer: renderer, options: { dracoDecoderPath: 'https://unpkg.com/[email protected]/examples/js/libs/draco', basisTranscoderPath: 'https://unpkg.com/[email protected]/examples/js/libs/basis', maximumScreenSpaceError: queryParams.get('sse') ?? 48, } } );

Thank you!

The problem of plug-in loading on mapbox

Use plug-ins to load tilt photography on the mapbox, but tilt photography appears dark no matter how you try it. I tried to add directional light global light point light source and mapbox's own light with three

Batch table

Hello, is possible to access feature table data of b3dm? if yes, how?

the Problem of resetTransform in Loadoptions

when I used the version1.1.17, the loadoptions had a parameter-geoTransform. I set this parameter to 1, my tileset model can be in 0,0,0. but now I use the version1.2.3 the parameter-geoTransform can't be find,and there is a new parameter-resetTransform. I set this parameter to true,my tileset model can't be find. but when I use the example's model(https://int.nyt.com/data/3dscenes/ONA360/TILESET/0731_FREEMAN_ALLEY_10M_A_36x8K__10K-PN_50P_DB/tileset_tileset.json),it's can also be find in 0,0,0.
I can't find the problem.I need u help! @wanyanyan @Avnerus
this is my code:

    async loadTileset() {
      const result = await Loader3DTiles.load({
        url: './models/terra_b3dms/tileset.json',
        renderer: this.renderer,
        options: {
          dracoDecoderPath: './draco',
          basisTranscoderPath: './basis',
          maximumMemoryUsage: 4096,
          maximumScreenSpaceError: 1, 
          viewDistanceScale: 1,  
          geoTransform: 1, 	
          // resetTransform: true,
        },
      }
      )
      const { model, runtime } = result;
      model.rotation.set(-Math.PI / 2, 0, Math.PI / 2);
      this.tilesRuntime = runtime;
      this.scene.add(model);
    }

rotated model

Hello,
I'm trying to load 3Dtiles from https://github.com/VCityTeam/py3dtilers but the result is weirdly rotated
image
I don't know if its relevant but py3dtilers allows choosing EPSG projection - they also document which projetion to use for cesiumJS, itowns and their own UD-Viz viewer. https://github.com/VCityTeam/UD-SV/blob/master/ImplementationKnowHow/Visualize3DTiles.md
I don't know which projection to use for three-loader-3dtiles. I guess it has something to do with that this project is not visualizing globe, but I'm not really expert in this area.

LOADERS_GL_SRC=/Users/yuyanglei/Downloads/loaders.gl-master npm run dev

Hello: I want to modify the loaderGL dependent code, but LOADERS_GL_SRC error

bundles src/index.ts → dist/three-loader-3dtiles.js...
[0] [!] (plugin rpt2) Error: /Users/yuyanglei/Downloads/three-loader-3dtiles-1.1.12/src/index.ts(334,9): semantic error TS2739: Type 'Matrix4' is missing the following properties from type 'Matrix4': fromObject, validate
[0] src/index.ts
[0] Error: /Users/yuyanglei/Downloads/three-loader-3dtiles-1.1.12/src/index.ts(334,9): semantic error TS2739: Type 'Matrix4' is missing the following properties from type 'Matrix4': fromObject, validate
[0] at error (/Users/yuyanglei/Downloads/three-loader-3dtiles-1.1.12/node_modules/rollup/dist/shared/rollup.js:164:30)

3d model not rotating properly

I have 3d tileset data (tileset.json),I am loading this tiles into three js scene using three-loader-3dtiles. it loads properly but its rotation is not working properly, can anybody help in this ? I attached code snippet for the same.
const result = await Loader3DTiles.load(
{
url: ./tiles/pointcloud/tileset.json,
renderer: renderer,
options: {
dracoDecoderPath: 'https://cdn.jsdelivr.net/npm/[email protected]/examples/js/libs/draco',
basisTranscoderPath: 'https://cdn.jsdelivr.net/npm/[email protected]/examples/js/libs/basis',
pointCloudColoring: PointCloudColoring.RGB,
shading:Shading.ShadedNoTexture,
maximumScreenSpaceError: 6
}
}
);
console.log(result)
const {model, runtime} = result;

model.rotation.set(-Math.PI / 2 , 0 ,0);

tilesRuntime = runtime;
scene.add(model);

}

maintaining cesium coordinate system

Is there a way to plot a model from cesium so it maintains its coordinates system?
for example, bringing in another map layer under my model? or another layer of photogrammetry that maintains the world positioning?

Issues with RealityCapture dataset

I'm using the RealityCapture demo which works fine out of the box. I've exported my own LoD model from RealityCapture in .b3dm, uploaded them to a webserver, and tried loading them in the viewer. Sadly, it's throwing errors and I can't seem to figure out why.

image

The root .json file of my own export is (coincidentally?) the same as the example one provided.

"asset": {
    "extras": {
        "createdWith": "RealityCapture 1.2.0.16813"
    },
    "version": "1.0"
}

Am I doing something wrong or is this an issue in the loader?
Just for fun, I uploaded my .b3md files to Cesium Ion, and to my surprise, it loads just fine there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.