@threepipe/plugin-3d-tiles-renderer 0.2.0 → 0.2.1
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/dist/TilesRendererPlugin.d.ts +1 -1
- package/dist/TilesRendererPlugin.d.ts.map +1 -1
- package/dist/index.js +63 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/TilesRendererPlugin.ts +6 -1
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @threepipe/plugin-3d-tiles-renderer v0.2.
|
|
3
|
+
* @threepipe/plugin-3d-tiles-renderer v0.2.1
|
|
4
4
|
* Copyright 2022-2025 repalash <palash@shaders.app>
|
|
5
5
|
* Apache-2.0 License
|
|
6
6
|
* See ./dependencies.txt for any bundled third-party dependencies and licenses.
|
|
7
7
|
*/
|
|
8
|
-
var _a;
|
|
9
8
|
import * as THREE from "threepipe";
|
|
10
|
-
import { DefaultLoadingManager, Matrix4, GLTFLoader, Vector3, Vector2, MathUtils, PointsMaterial, BufferGeometry, BufferAttribute, Color, Points, Spherical, Sphere, Ray, Euler, InstancedMesh, Quaternion, Group, Box3, Plane, Frustum, Matrix3, estimateBytesUsed as estimateBytesUsed$1, LoadingManager, EventDispatcher, Mesh, PlaneGeometry, ShaderMaterial, Raycaster, Clock, Texture, SRGBColorSpace, MeshBasicMaterial, MeshStandardMaterial, DataTexture, RGFormat, UnsignedByteType, LinearMipMapLinearFilter, LinearFilter, Triangle, Matrix2, Vector4, WebGLRenderer, WebGLRenderTarget, FullScreenQuad, OneFactor, ZeroFactor, CustomBlending, Box2, FileLoader, LineSegments, LineBasicMaterial, EdgesGeometry, BoxGeometry, Box3Helper, AViewerPluginSync, Importer, generateUUID,
|
|
9
|
+
import { DefaultLoadingManager, Matrix4, GLTFLoader, Vector3, Vector2, MathUtils, PointsMaterial, BufferGeometry, BufferAttribute, Color, Points, Spherical, Sphere, Ray, Euler, InstancedMesh, Quaternion, Group, Box3, Plane, Frustum, Matrix3, estimateBytesUsed as estimateBytesUsed$1, LoadingManager, EventDispatcher, Mesh, PlaneGeometry, ShaderMaterial, Raycaster, Clock, Texture, SRGBColorSpace, MeshBasicMaterial, MeshStandardMaterial, DataTexture, RGFormat, UnsignedByteType, LinearMipMapLinearFilter, LinearFilter, Triangle, Matrix2, Vector4, WebGLRenderer, WebGLRenderTarget, FullScreenQuad, OneFactor, ZeroFactor, CustomBlending, Box2, FileLoader, LineSegments, LineBasicMaterial, EdgesGeometry, BoxGeometry, Box3Helper, uiButton, uiFolderContainer, AViewerPluginSync, Importer, generateUUID, DropzonePlugin, Loader, iObjectCommons, Box3B, BaseImporterPlugin, GLTFLoader2, LoaderUtils, ACameraControlsPlugin, uiToggle, serialize, uiInput, uiVector } from "threepipe";
|
|
11
10
|
function getUrlExtension(url) {
|
|
12
11
|
if (!url) {
|
|
13
12
|
return null;
|
|
@@ -881,7 +880,7 @@ class TilesRendererBase {
|
|
|
881
880
|
}
|
|
882
881
|
}
|
|
883
882
|
preprocessNode(tile, tileSetDir, parentTile = null) {
|
|
884
|
-
var
|
|
883
|
+
var _a;
|
|
885
884
|
if (tile.content) {
|
|
886
885
|
if (!("uri" in tile.content) && "url" in tile.content) {
|
|
887
886
|
tile.content.uri = tile.content.url;
|
|
@@ -893,7 +892,7 @@ class TilesRendererBase {
|
|
|
893
892
|
}
|
|
894
893
|
tile.parent = parentTile;
|
|
895
894
|
tile.children = tile.children || [];
|
|
896
|
-
if ((
|
|
895
|
+
if ((_a = tile.content) == null ? void 0 : _a.uri) {
|
|
897
896
|
const extension = getUrlExtension(tile.content.uri);
|
|
898
897
|
tile.__hasContent = true;
|
|
899
898
|
tile.__hasUnrenderableContent = Boolean(extension && /json$/.test(extension));
|
|
@@ -7566,8 +7565,8 @@ class StructuralMetadata {
|
|
|
7566
7565
|
}
|
|
7567
7566
|
const EXT_NAME$1 = "EXT_structural_metadata";
|
|
7568
7567
|
function getRelevantTextures(parser, propertyTextures = []) {
|
|
7569
|
-
var
|
|
7570
|
-
const textureCount = ((
|
|
7568
|
+
var _a;
|
|
7569
|
+
const textureCount = ((_a = parser.json.textures) == null ? void 0 : _a.length) || 0;
|
|
7571
7570
|
const result = new Array(textureCount).fill(null);
|
|
7572
7571
|
propertyTextures.forEach(({ properties }) => {
|
|
7573
7572
|
for (const key in properties) {
|
|
@@ -7580,8 +7579,8 @@ function getRelevantTextures(parser, propertyTextures = []) {
|
|
|
7580
7579
|
return Promise.all(result);
|
|
7581
7580
|
}
|
|
7582
7581
|
function getRelevantBuffers(parser, propertyTables = []) {
|
|
7583
|
-
var
|
|
7584
|
-
const textureCount = ((
|
|
7582
|
+
var _a;
|
|
7583
|
+
const textureCount = ((_a = parser.json.bufferViews) == null ? void 0 : _a.length) || 0;
|
|
7585
7584
|
const result = new Array(textureCount).fill(null);
|
|
7586
7585
|
propertyTables.forEach(({ properties }) => {
|
|
7587
7586
|
for (const key in properties) {
|
|
@@ -7630,10 +7629,10 @@ class GLTFStructuralMetadataExtension {
|
|
|
7630
7629
|
const rootMetadata = new StructuralMetadata(rootExtension, textures, buffers);
|
|
7631
7630
|
scene.userData.structuralMetadata = rootMetadata;
|
|
7632
7631
|
scene.traverse((child) => {
|
|
7633
|
-
var
|
|
7632
|
+
var _a;
|
|
7634
7633
|
if (parser.associations.has(child)) {
|
|
7635
7634
|
const { meshes, primitives } = parser.associations.get(child);
|
|
7636
|
-
const primitive = (
|
|
7635
|
+
const primitive = (_a = parser.json.meshes[meshes]) == null ? void 0 : _a.primitives[primitives];
|
|
7637
7636
|
if (primitive && primitive.extensions && primitive.extensions[EXT_NAME$1]) {
|
|
7638
7637
|
const extension = primitive.extensions[EXT_NAME$1];
|
|
7639
7638
|
child.userData.structuralMetadata = new StructuralMetadata(rootExtension, textures, buffers, extension, child);
|
|
@@ -7768,10 +7767,10 @@ class MeshFeatures {
|
|
|
7768
7767
|
const EXT_NAME = "EXT_mesh_features";
|
|
7769
7768
|
function forEachPrimitiveExtension(scene, parser, callback) {
|
|
7770
7769
|
scene.traverse((c) => {
|
|
7771
|
-
var
|
|
7770
|
+
var _a;
|
|
7772
7771
|
if (parser.associations.has(c)) {
|
|
7773
7772
|
const { meshes, primitives } = parser.associations.get(c);
|
|
7774
|
-
const primitive = (
|
|
7773
|
+
const primitive = (_a = parser.json.meshes[meshes]) == null ? void 0 : _a.primitives[primitives];
|
|
7775
7774
|
if (primitive && primitive.extensions && primitive.extensions[EXT_NAME]) {
|
|
7776
7775
|
callback(c, primitive.extensions[EXT_NAME]);
|
|
7777
7776
|
}
|
|
@@ -7784,12 +7783,12 @@ class GLTFMeshFeaturesExtension {
|
|
|
7784
7783
|
this.name = EXT_NAME;
|
|
7785
7784
|
}
|
|
7786
7785
|
async afterRoot({ scene, parser }) {
|
|
7787
|
-
var
|
|
7786
|
+
var _a;
|
|
7788
7787
|
const extensionsUsed = parser.json.extensionsUsed;
|
|
7789
7788
|
if (!extensionsUsed || !extensionsUsed.includes(EXT_NAME)) {
|
|
7790
7789
|
return;
|
|
7791
7790
|
}
|
|
7792
|
-
const textureCount = ((
|
|
7791
|
+
const textureCount = ((_a = parser.json.textures) == null ? void 0 : _a.length) || 0;
|
|
7793
7792
|
const promises = new Array(textureCount).fill(null);
|
|
7794
7793
|
forEachPrimitiveExtension(scene, parser, (child, { featureIds }) => {
|
|
7795
7794
|
featureIds.forEach((info) => {
|
|
@@ -8664,8 +8663,8 @@ class TilesFadePlugin {
|
|
|
8664
8663
|
}
|
|
8665
8664
|
// initializes the batched mesh if it needs to be, dispose if it it's no longer needed
|
|
8666
8665
|
initBatchedMesh() {
|
|
8667
|
-
var
|
|
8668
|
-
const otherBatchedMesh = (
|
|
8666
|
+
var _a;
|
|
8667
|
+
const otherBatchedMesh = (_a = this.tiles.getPluginByName("BATCHED_TILES_PLUGIN")) == null ? void 0 : _a.batchedMesh;
|
|
8669
8668
|
if (otherBatchedMesh) {
|
|
8670
8669
|
if (this.batchedMesh === null) {
|
|
8671
8670
|
this._onBatchedMeshDispose = () => {
|
|
@@ -9378,7 +9377,7 @@ class DebugTilesPlugin {
|
|
|
9378
9377
|
}
|
|
9379
9378
|
}
|
|
9380
9379
|
dispose() {
|
|
9381
|
-
var
|
|
9380
|
+
var _a, _b, _c;
|
|
9382
9381
|
const tiles = this.tiles;
|
|
9383
9382
|
if (tiles) {
|
|
9384
9383
|
tiles.removeEventListener("load-tile-set", this._onLoadTileSetCB);
|
|
@@ -9392,7 +9391,7 @@ class DebugTilesPlugin {
|
|
|
9392
9391
|
this._onDisposeModel(tile);
|
|
9393
9392
|
});
|
|
9394
9393
|
}
|
|
9395
|
-
(
|
|
9394
|
+
(_a = this.boxGroup) == null ? void 0 : _a.removeFromParent();
|
|
9396
9395
|
(_b = this.sphereGroup) == null ? void 0 : _b.removeFromParent();
|
|
9397
9396
|
(_c = this.regionGroup) == null ? void 0 : _c.removeFromParent();
|
|
9398
9397
|
}
|
|
@@ -10042,7 +10041,7 @@ class ImplicitTilingPlugin {
|
|
|
10042
10041
|
this.tiles = tiles;
|
|
10043
10042
|
}
|
|
10044
10043
|
preprocessNode(tile, tileSetDir, parentTile) {
|
|
10045
|
-
var
|
|
10044
|
+
var _a;
|
|
10046
10045
|
if (tile.implicitTiling) {
|
|
10047
10046
|
tile.__hasUnrenderableContent = true;
|
|
10048
10047
|
tile.__hasRenderableContent = false;
|
|
@@ -10052,7 +10051,7 @@ class ImplicitTilingPlugin {
|
|
|
10052
10051
|
tile.__y = 0;
|
|
10053
10052
|
tile.__z = 0;
|
|
10054
10053
|
tile.__level = 0;
|
|
10055
|
-
} else if (/.subtree$/i.test((
|
|
10054
|
+
} else if (/.subtree$/i.test((_a = tile.content) == null ? void 0 : _a.uri)) {
|
|
10056
10055
|
tile.__hasUnrenderableContent = true;
|
|
10057
10056
|
tile.__hasRenderableContent = false;
|
|
10058
10057
|
}
|
|
@@ -10073,8 +10072,8 @@ class ImplicitTilingPlugin {
|
|
|
10073
10072
|
return url;
|
|
10074
10073
|
}
|
|
10075
10074
|
disposeTile(tile) {
|
|
10076
|
-
var
|
|
10077
|
-
if (/.subtree$/i.test((
|
|
10075
|
+
var _a;
|
|
10076
|
+
if (/.subtree$/i.test((_a = tile.content) == null ? void 0 : _a.uri)) {
|
|
10078
10077
|
tile.children.length = 0;
|
|
10079
10078
|
tile.__childrenProcessed = 0;
|
|
10080
10079
|
}
|
|
@@ -10113,23 +10112,23 @@ const gltfMeshFeaturesExtension = {
|
|
|
10113
10112
|
var __defProp$2 = Object.defineProperty;
|
|
10114
10113
|
var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
|
|
10115
10114
|
var __decorateClass$2 = (decorators, target, key, kind) => {
|
|
10116
|
-
var result = __getOwnPropDesc$2(target, key);
|
|
10115
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
|
|
10117
10116
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10118
10117
|
if (decorator = decorators[i])
|
|
10119
|
-
result = decorator(target, key, result) || result;
|
|
10120
|
-
if (result) __defProp$2(target, key, result);
|
|
10118
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
10119
|
+
if (kind && result) __defProp$2(target, key, result);
|
|
10121
10120
|
return result;
|
|
10122
10121
|
};
|
|
10123
|
-
|
|
10122
|
+
let TilesRendererPlugin = class extends AViewerPluginSync {
|
|
10124
10123
|
constructor() {
|
|
10125
10124
|
super();
|
|
10126
10125
|
this.enabled = true;
|
|
10127
10126
|
this.dependencies = [];
|
|
10128
10127
|
this.objects = [];
|
|
10129
|
-
this._importer = new Importer(TilesRendererLoader, [
|
|
10128
|
+
this._importer = new Importer(TilesRendererLoader, [TilesRendererPlugin.DUMMY_EXT, TilesRendererPlugin.DUMMY_EXT + ".json"], [], false);
|
|
10130
10129
|
this._preRender = () => {
|
|
10131
|
-
var
|
|
10132
|
-
const camera = (
|
|
10130
|
+
var _a;
|
|
10131
|
+
const camera = (_a = this._viewer) == null ? void 0 : _a.scene.renderCamera;
|
|
10133
10132
|
if (!this._viewer || !camera) return;
|
|
10134
10133
|
if (this._viewer.renderManager.frameCount > 0) return;
|
|
10135
10134
|
camera.updateProjectionMatrix();
|
|
@@ -10186,7 +10185,7 @@ const _TilesRendererPlugin = (_a = class extends AViewerPluginSync {
|
|
|
10186
10185
|
console.warn("TilesRendererPlugin: viewer not set");
|
|
10187
10186
|
return;
|
|
10188
10187
|
}
|
|
10189
|
-
const temp = generateUUID() + "." +
|
|
10188
|
+
const temp = generateUUID() + "." + TilesRendererPlugin.DUMMY_EXT;
|
|
10190
10189
|
const importer = this._viewer.assetManager.importer.registerFile(temp);
|
|
10191
10190
|
if (!importer.isTilesRendererLoader) {
|
|
10192
10191
|
console.warn("TilesRendererPlugin: TilesRendererLoader not registered");
|
|
@@ -10194,12 +10193,15 @@ const _TilesRendererPlugin = (_a = class extends AViewerPluginSync {
|
|
|
10194
10193
|
}
|
|
10195
10194
|
return await this._viewer.load(url, {
|
|
10196
10195
|
...options,
|
|
10197
|
-
fileExtension:
|
|
10196
|
+
fileExtension: TilesRendererPlugin.DUMMY_EXT,
|
|
10198
10197
|
fileHandler: importer
|
|
10198
|
+
}).finally(() => {
|
|
10199
|
+
var _a;
|
|
10200
|
+
(_a = this._viewer) == null ? void 0 : _a.assetManager.importer.unregisterFile(temp);
|
|
10199
10201
|
});
|
|
10200
10202
|
}
|
|
10201
10203
|
async loadCesiumIon(info, options) {
|
|
10202
|
-
const file = generateUUID() + "." +
|
|
10204
|
+
const file = generateUUID() + "." + TilesRendererPlugin.DUMMY_EXT;
|
|
10203
10205
|
return this.load(file, {
|
|
10204
10206
|
...options,
|
|
10205
10207
|
tiles: {
|
|
@@ -10233,16 +10235,21 @@ const _TilesRendererPlugin = (_a = class extends AViewerPluginSync {
|
|
|
10233
10235
|
super.onRemove(viewer);
|
|
10234
10236
|
}
|
|
10235
10237
|
async promptForURL() {
|
|
10236
|
-
var
|
|
10237
|
-
const url = await ((
|
|
10238
|
+
var _a, _b;
|
|
10239
|
+
const url = await ((_a = this._viewer) == null ? void 0 : _a.dialog.prompt("TilesRendererPlugin: Enter URL for the root tileset", "", true));
|
|
10238
10240
|
if (!url) return;
|
|
10239
|
-
|
|
10241
|
+
const loader = ((_b = this._viewer) == null ? void 0 : _b.getPlugin(DropzonePlugin)) ?? this._viewer ?? this;
|
|
10242
|
+
return await loader.load(url, { fileExtension: TilesRendererPlugin.DUMMY_EXT });
|
|
10240
10243
|
}
|
|
10241
|
-
}
|
|
10244
|
+
};
|
|
10245
|
+
TilesRendererPlugin.PluginType = "TilesRendererPlugin";
|
|
10246
|
+
TilesRendererPlugin.DUMMY_EXT = "tileset";
|
|
10242
10247
|
__decorateClass$2([
|
|
10243
10248
|
uiButton()
|
|
10244
|
-
],
|
|
10245
|
-
|
|
10249
|
+
], TilesRendererPlugin.prototype, "promptForURL", 1);
|
|
10250
|
+
TilesRendererPlugin = __decorateClass$2([
|
|
10251
|
+
uiFolderContainer("3D Tiles")
|
|
10252
|
+
], TilesRendererPlugin);
|
|
10246
10253
|
class TilesRendererLoader extends Loader {
|
|
10247
10254
|
constructor(manager) {
|
|
10248
10255
|
super(manager);
|
|
@@ -10263,11 +10270,11 @@ class TilesRendererLoader extends Loader {
|
|
|
10263
10270
|
return tiles;
|
|
10264
10271
|
}
|
|
10265
10272
|
load(url, onLoad, _onProgress, _onError) {
|
|
10266
|
-
var
|
|
10273
|
+
var _a;
|
|
10267
10274
|
const tiles = this._createTilesRenderer(url);
|
|
10268
10275
|
const group = iObjectCommons.upgradeObject3D.call(tiles.group);
|
|
10269
10276
|
group.autoUpgradeChildren = false;
|
|
10270
|
-
const opts = ((
|
|
10277
|
+
const opts = ((_a = this.importOptions) == null ? void 0 : _a.tiles) ?? {};
|
|
10271
10278
|
tiles.errorTarget = opts.errorTarget ?? 1;
|
|
10272
10279
|
const plugins = [...this.plugins, ...opts.plugins ?? []];
|
|
10273
10280
|
for (const plugin of plugins) {
|
|
@@ -10358,16 +10365,16 @@ class B3DMLoader2 extends GLTFLoader2 {
|
|
|
10358
10365
|
return super.transform(res, options);
|
|
10359
10366
|
}
|
|
10360
10367
|
parse(data, _path, onLoad, onError, _url) {
|
|
10361
|
-
var
|
|
10368
|
+
var _a;
|
|
10362
10369
|
if (!this.ai) {
|
|
10363
10370
|
console.error("[B3DMLoader] load failed, IAssetImporter not set");
|
|
10364
10371
|
}
|
|
10365
10372
|
const tmpFile = generateUUID() + ".gltf";
|
|
10366
|
-
(
|
|
10373
|
+
(_a = this.ai) == null ? void 0 : _a.registerFile(tmpFile);
|
|
10367
10374
|
this.loader.workingPath = _path;
|
|
10368
10375
|
this.loader.parse(data).then(onLoad).catch(onError).finally(() => {
|
|
10369
|
-
var
|
|
10370
|
-
if (tmpFile) (
|
|
10376
|
+
var _a2;
|
|
10377
|
+
if (tmpFile) (_a2 = this.ai) == null ? void 0 : _a2.unregisterFile(tmpFile);
|
|
10371
10378
|
});
|
|
10372
10379
|
}
|
|
10373
10380
|
}
|
|
@@ -10395,16 +10402,16 @@ class I3DMLoader2 extends GLTFLoader2 {
|
|
|
10395
10402
|
return super.transform(res, options);
|
|
10396
10403
|
}
|
|
10397
10404
|
parse(data, _path, onLoad, onError, _url) {
|
|
10398
|
-
var
|
|
10405
|
+
var _a;
|
|
10399
10406
|
if (!this.ai) {
|
|
10400
10407
|
console.error("[I3DMLoader] load failed, IAssetImporter not set");
|
|
10401
10408
|
}
|
|
10402
10409
|
const tmpFile = generateUUID() + ".gltf";
|
|
10403
|
-
(
|
|
10410
|
+
(_a = this.ai) == null ? void 0 : _a.registerFile(tmpFile);
|
|
10404
10411
|
this.loader.workingPath = _path;
|
|
10405
10412
|
this.loader.parse(data).then(onLoad).catch(onError).finally(() => {
|
|
10406
|
-
var
|
|
10407
|
-
if (tmpFile) (
|
|
10413
|
+
var _a2;
|
|
10414
|
+
if (tmpFile) (_a2 = this.ai) == null ? void 0 : _a2.unregisterFile(tmpFile);
|
|
10408
10415
|
});
|
|
10409
10416
|
}
|
|
10410
10417
|
}
|
|
@@ -10468,16 +10475,16 @@ class PNTSLoader2 extends Loader {
|
|
|
10468
10475
|
return res.scene;
|
|
10469
10476
|
}
|
|
10470
10477
|
parse(data, _path, onLoad, onError, _url) {
|
|
10471
|
-
var
|
|
10478
|
+
var _a;
|
|
10472
10479
|
if (!this.ai) {
|
|
10473
10480
|
console.error("[PNTSLoader] load failed, IAssetImporter not set");
|
|
10474
10481
|
}
|
|
10475
10482
|
const tmpFile = generateUUID() + ".drc";
|
|
10476
|
-
(
|
|
10483
|
+
(_a = this.ai) == null ? void 0 : _a.registerFile(tmpFile);
|
|
10477
10484
|
this.loader.workingPath = _path;
|
|
10478
10485
|
this.loader.parse(data).then(onLoad).catch(onError).finally(() => {
|
|
10479
|
-
var
|
|
10480
|
-
if (tmpFile) (
|
|
10486
|
+
var _a2;
|
|
10487
|
+
if (tmpFile) (_a2 = this.ai) == null ? void 0 : _a2.unregisterFile(tmpFile);
|
|
10481
10488
|
});
|
|
10482
10489
|
}
|
|
10483
10490
|
}
|
|
@@ -10541,12 +10548,12 @@ class CMPTLoader2 extends Loader {
|
|
|
10541
10548
|
return res.scene;
|
|
10542
10549
|
}
|
|
10543
10550
|
parse(data, _path, onLoad, onError, _url) {
|
|
10544
|
-
var
|
|
10551
|
+
var _a, _b;
|
|
10545
10552
|
if (!this.ai) {
|
|
10546
10553
|
console.error("[CMPTLoader] load failed, IAssetImporter not set");
|
|
10547
10554
|
}
|
|
10548
10555
|
const tmpFile = generateUUID();
|
|
10549
|
-
(
|
|
10556
|
+
(_a = this.ai) == null ? void 0 : _a.registerFile(tmpFile + ".gltf");
|
|
10550
10557
|
(_b = this.ai) == null ? void 0 : _b.registerFile(tmpFile + ".drc");
|
|
10551
10558
|
this.loader.workingPath = _path;
|
|
10552
10559
|
this.loader.parse(data).then(onLoad).catch(onError).finally(() => {
|