@soonspacejs/plugin-tiles 2.14.0 → 2.14.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/index.esm.js +29 -37
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TilesRenderer as
|
|
3
|
-
import { GLTFLoader as
|
|
4
|
-
class
|
|
1
|
+
import u from "soonspacejs";
|
|
2
|
+
import { TilesRenderer as h } from "3d-tiles-renderer";
|
|
3
|
+
import { GLTFLoader as m } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
|
+
class p {
|
|
5
5
|
constructor(t) {
|
|
6
6
|
this.parser = t, this.name = "KHR_texture_basisu_patch";
|
|
7
7
|
}
|
|
8
8
|
loadTexture(t) {
|
|
9
|
-
const
|
|
9
|
+
const r = this.parser, a = r.json, s = a.textures[t].source, i = a.images[s];
|
|
10
10
|
if (!i || i.mimeType !== "image/ktx2")
|
|
11
11
|
return null;
|
|
12
|
-
const o =
|
|
12
|
+
const o = r.options.ktx2Loader;
|
|
13
13
|
if (!o)
|
|
14
|
-
throw new Error(`${
|
|
15
|
-
return
|
|
14
|
+
throw new Error(`${u.utils.consoleSspTitle}请使用 setModelKtx2DecoderPath 设置 ktx2 解压库路径`);
|
|
15
|
+
return r.loadTextureImage(t, s, o);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class g {
|
|
19
19
|
constructor(t) {
|
|
20
20
|
this.ssp = t;
|
|
21
|
-
const { controls:
|
|
22
|
-
this._tilesCamera =
|
|
23
|
-
this.cameraTransitionStart = !0,
|
|
24
|
-
}),
|
|
25
|
-
this.cameraTransitionStart = !1, this.needsUpdate = !0,
|
|
21
|
+
const { controls: r, viewport: a } = t;
|
|
22
|
+
this._tilesCamera = a.camera, r.addEventListener("transitionstart", () => {
|
|
23
|
+
this.cameraTransitionStart = !0, a.state.useFreq = 1;
|
|
24
|
+
}), r.addEventListener("rest", () => {
|
|
25
|
+
this.cameraTransitionStart = !1, this.needsUpdate = !0, a.state.useFreq = 60;
|
|
26
26
|
}), t.signals.beforeRender.add(() => {
|
|
27
27
|
this.needsUpdate && (this.needsUpdate = !1, t.viewport.camera.updateMatrixWorld(), this.tilesMap.forEach((e) => {
|
|
28
28
|
e.group.updateMatrixWorld(), e.update();
|
|
@@ -42,37 +42,29 @@ class Q {
|
|
|
42
42
|
downloadQueue = null;
|
|
43
43
|
async loadTiles(t) {
|
|
44
44
|
if (this.tilesMap.has(t)) {
|
|
45
|
-
|
|
45
|
+
u.utils.warn(`${t} already loaded`);
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
const { ssp:
|
|
48
|
+
const { ssp: r, ssp: { viewport: a } } = this, e = new h(t);
|
|
49
49
|
this.lruCache === null ? this.lruCache = e.lruCache : e.lruCache = this.lruCache, this.parseQueue === null ? this.parseQueue = e.parseQueue : e.parseQueue = this.parseQueue, this.downloadQueue === null ? this.downloadQueue = e.downloadQueue : e.downloadQueue = this.downloadQueue;
|
|
50
|
-
const s = new
|
|
51
|
-
s.register((n) => new
|
|
52
|
-
const { dracoLoader: i, ktx2Loader: o, meshoptDecoder:
|
|
53
|
-
i && s.setDRACOLoader(i), o && s.setKTX2Loader(o),
|
|
54
|
-
const
|
|
55
|
-
this.cameraTransitionStart || (this.needsUpdate = !0,
|
|
50
|
+
const s = new m(e.manager);
|
|
51
|
+
s.register((n) => new p(n));
|
|
52
|
+
const { dracoLoader: i, ktx2Loader: o, meshoptDecoder: l } = r.manager.store.modelManager.gltfLoader;
|
|
53
|
+
i && s.setDRACOLoader(i), o && s.setKTX2Loader(o), l && s.setMeshoptDecoder(l), e.manager.addHandler(/\.gltf$/, s), this.tilesMap.set(t, e), e.setCamera(this._tilesCamera), e.setResolutionFromRenderer(this._tilesCamera, a.renderer), e.lruCache.maxSize = 600, e.lruCache.minSize = 300, e.lruCache.unloadPercent = 0.8, r.addObject(e.group);
|
|
54
|
+
const d = () => {
|
|
55
|
+
this.cameraTransitionStart || (this.needsUpdate = !0, r.render());
|
|
56
56
|
};
|
|
57
|
-
return e.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const l = m[d];
|
|
62
|
-
l.mipmaps.length > 0 && (l.mipmaps.length = 0), l.image instanceof ImageBitmap && l.image.close();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, new Promise((n) => {
|
|
66
|
-
e.onLoadTileSet = () => {
|
|
67
|
-
c(), n(e);
|
|
68
|
-
};
|
|
57
|
+
return e.addEventListener("load-model", d), new Promise((n) => {
|
|
58
|
+
e.addEventListener("load-tile-set", () => {
|
|
59
|
+
d(), n(e);
|
|
60
|
+
});
|
|
69
61
|
});
|
|
70
62
|
}
|
|
71
63
|
removeTiles(t) {
|
|
72
|
-
const
|
|
73
|
-
return
|
|
64
|
+
const r = this.tilesMap.get(t);
|
|
65
|
+
return r ? (r.dispose(), this.tilesMap.delete(t), this.ssp.removeObject(r.group), !0) : !1;
|
|
74
66
|
}
|
|
75
67
|
}
|
|
76
68
|
export {
|
|
77
|
-
|
|
69
|
+
g as default
|
|
78
70
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-tiles",
|
|
3
3
|
"pluginName": "TilesPlugin",
|
|
4
|
-
"version": "2.14.
|
|
4
|
+
"version": "2.14.1",
|
|
5
5
|
"description": "3D Tiles plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.esm.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
],
|
|
15
15
|
"author": "xunwei",
|
|
16
16
|
"license": "UNLICENSED",
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "27d5e0bcd79ff71c8e2943a8420c39624ae6f8e6",
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"3d-tiles-renderer": "^0.4.14",
|
|
20
|
-
"soonspacejs": "2.14.
|
|
20
|
+
"soonspacejs": "2.14.1"
|
|
21
21
|
}
|
|
22
22
|
}
|