@jdultra/threedtiles 11.1.5 → 11.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -12
- package/dist/threedtiles.min.js +1 -1
- package/dist/threedtiles.min.js.map +1 -1
- package/dist/tileset/OGC3DTile.d.ts +12 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -471,7 +471,7 @@ for (let i = 0; i < 100; i++) {
|
|
|
471
471
|
});
|
|
472
472
|
|
|
473
473
|
tileset.translateOnAxis(new THREE.Vector3(1, 0, 0), 50 * i);
|
|
474
|
-
tileset.
|
|
474
|
+
tileset.updateMatrices(); // important when static property is true (different from the Object3D#updateMatrix API)
|
|
475
475
|
scene.add(tileset);
|
|
476
476
|
instancedTilesets.push(tileset);
|
|
477
477
|
}
|
|
@@ -524,12 +524,11 @@ const ogc3DTile = new OGC3DTile({
|
|
|
524
524
|
setTimeout(()=>{
|
|
525
525
|
|
|
526
526
|
ogc3DTile.rotateOnAxis(new THREE.Vector3(1, 0, 0), Math.PI * -0.5);
|
|
527
|
-
ogc3DTile.
|
|
528
|
-
ogc3DTile.updateMatrixWorld(true);
|
|
527
|
+
ogc3DTile.updateMatrices(); // different from the Object3D#updateMatrix API
|
|
529
528
|
},1000)
|
|
530
529
|
```
|
|
531
530
|
|
|
532
|
-
For InstancedOGC3DTile objects, You
|
|
531
|
+
For InstancedOGC3DTile objects, You need to call instancedOgc3DTile#updateMatrix() and the gains will be much less significant.
|
|
533
532
|
|
|
534
533
|
```
|
|
535
534
|
const ogc3DTile = new InstancedOGC3DTile({
|
|
@@ -633,22 +632,47 @@ you'll want to avoid updating every single tileset on every frame.
|
|
|
633
632
|
This is especially important for iOS that limits the memory per tab quite harshly and doesn't allow growing the memory allocated to a tab.
|
|
634
633
|
|
|
635
634
|
Once a mesh is loaded, the mesh and texture data stays in CPU memory which isn't necessary unless one intends to modify it.
|
|
636
|
-
A nice trick is to allow this data to be garbage collected.
|
|
635
|
+
A nice trick is to allow this data to be garbage collected. However, three.js doesn't have API for this and the internal references are hard to find but this code
|
|
636
|
+
seems to free a limited amount of memory:
|
|
637
637
|
|
|
638
638
|
```
|
|
639
639
|
const tileLoader = new TileLoader({
|
|
640
640
|
...
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
if(mesh.geometry.attributes.
|
|
646
|
-
|
|
641
|
+
const previousOnAfterRender = mesh.onAfterRender;
|
|
642
|
+
mesh.onAfterRender = () => {
|
|
643
|
+
if(previousOnAfterRender) previousOnAfterRender();
|
|
644
|
+
if(mesh.geometry && mesh.geometry.attributes){
|
|
645
|
+
if (mesh.geometry.attributes.position) {
|
|
646
|
+
mesh.geometry.attributes.position.array = undefined;
|
|
647
|
+
if (mesh.geometry.attributes.position.data) {
|
|
648
|
+
mesh.geometry.attributes.position.data.array = undefined;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
if (mesh.geometry.attributes.uv){
|
|
652
|
+
mesh.geometry.attributes.uv.array = undefined;
|
|
653
|
+
if (mesh.geometry.attributes.uv.data) {
|
|
654
|
+
mesh.geometry.attributes.uv.data.array = undefined;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if (mesh.geometry.attributes.normal) {
|
|
658
|
+
mesh.geometry.attributes.normal.array = undefined;
|
|
659
|
+
if (mesh.geometry.attributes.normal.data) {
|
|
660
|
+
mesh.geometry.attributes.normal.data.array = undefined;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
647
663
|
}
|
|
664
|
+
if (mesh.material && mesh.material.map) {
|
|
665
|
+
mesh.material.map.mipmaps = undefined;
|
|
666
|
+
if (mesh.material.map.source) {
|
|
667
|
+
mesh.material.map.source.data = undefined;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
mesh.onAfterRender = previousOnAfterRender;
|
|
648
672
|
}
|
|
649
673
|
});
|
|
650
674
|
```
|
|
651
675
|
|
|
652
|
-
Be sure to call this in the mesh onAfterRender callback to make sure the data is on
|
|
676
|
+
Be sure to call this in the mesh onAfterRender callback to make sure the data is already on GPU.
|
|
653
677
|
|
|
654
678
|
Depending on the mesh and texture type, different properties might hold data to be nullified so it can be garbage collected. It's up to the user to debug and see what geometry or material properties hold references to large data.
|