u-space 0.0.19 → 0.0.22

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.
Files changed (29) hide show
  1. package/dist/index.cjs +3 -3
  2. package/dist/index.js +415 -383
  3. package/dist/plugins/atmosphere/index.cjs +1 -1
  4. package/dist/plugins/atmosphere/index.js +98 -109
  5. package/dist/plugins/tiles/ArcgisTilesRenderer.d.ts +12 -0
  6. package/dist/plugins/tiles/index.cjs +1 -1
  7. package/dist/plugins/tiles/index.js +61 -48
  8. package/dist/plugins/u-manager/index.cjs +43 -43
  9. package/dist/plugins/u-manager/index.js +7581 -7268
  10. package/dist/plugins/u-manager/semantics/SemanticLoader.d.ts +1 -1
  11. package/dist/plugins/u-manager/semantics/SemanticParser.d.ts +1 -1
  12. package/dist/plugins/u-manager/semantics/index.d.ts +5 -2
  13. package/dist/plugins/u-manager/semantics/{BuildingGroup.d.ts → objects/BuildingGroup.d.ts} +11 -1
  14. package/dist/plugins/u-manager/semantics/objects/ElevatorMesh.d.ts +8 -0
  15. package/dist/plugins/u-manager/semantics/{FloorMesh.d.ts → objects/FloorMesh.d.ts} +2 -1
  16. package/dist/plugins/u-manager/semantics/objects/VentMesh.d.ts +8 -0
  17. package/dist/plugins/u-manager/semantics/objects/VerticalShaftMesh.d.ts +25 -0
  18. package/dist/plugins/u-manager/semantics/semantic.types.d.ts +28 -0
  19. package/dist/plugins/u-manager/semantics/types.d.ts +1 -1
  20. package/dist/src/viewers/Info.d.ts +1 -0
  21. package/docs/api-plugin-atmosphere.md +12 -10
  22. package/docs/api-plugin-tiles.md +38 -6
  23. package/docs/api-plugin-u-manager.md +28 -3
  24. package/docs/changelog.md +20 -1
  25. package/docs/examples-guide.md +8 -1
  26. package/docs/getting-started.md +1 -1
  27. package/docs/index.md +2 -2
  28. package/docs/mcp.md +2 -2
  29. package/package.json +2 -2
@@ -1,38 +1,38 @@
1
- import { NodeMaterial as M, MeshBasicNodeMaterial as m, Mesh as a, MathUtils as o } from "three/webgpu";
2
- import { TilesRenderer as T } from "3d-tiles-renderer";
3
- import { TilesFadePlugin as R, TileCompressionPlugin as E, UpdateOnChangePlugin as w, ReorientationPlugin as y, XYZTilesPlugin as F } from "3d-tiles-renderer/plugins";
4
- import { FadeMaterialManager as _ } from "3d-tiles-renderer/src/three/plugins/fade/FadeMaterialManager.js";
5
- import { wrapFadeMaterial as b } from "3d-tiles-renderer/src/three/plugins/fade/wrapFadeMaterial.js";
6
- import { uniform as c, Fn as L, screenCoordinate as x, If as d, Discard as u, output as A } from "three/tsl";
7
- import { reinterpretType as s } from "@takram/three-geospatial";
1
+ import { NodeMaterial as v, MeshBasicNodeMaterial as m, Mesh as o, Matrix4 as M, Vector3 as d, MathUtils as l } from "three/webgpu";
2
+ import { TilesRenderer as R } from "3d-tiles-renderer";
3
+ import { TilesFadePlugin as y, TileCompressionPlugin as w, UpdateOnChangePlugin as E, ReorientationPlugin as _, XYZTilesPlugin as x } from "3d-tiles-renderer/plugins";
4
+ import { FadeMaterialManager as F } from "3d-tiles-renderer/src/three/plugins/fade/FadeMaterialManager.js";
5
+ import { wrapFadeMaterial as L } from "3d-tiles-renderer/src/three/plugins/fade/wrapFadeMaterial.js";
6
+ import { uniform as P, Fn as b, screenCoordinate as C, If as u, Discard as h, output as O } from "three/tsl";
7
+ import { reinterpretType as a } from "@takram/three-geospatial";
8
8
  import { FnLayout as f } from "@takram/three-geospatial/webgpu";
9
- const h = /* @__PURE__ */ Symbol("FADE_PARAMS"), p = f({
9
+ const p = /* @__PURE__ */ Symbol("FADE_PARAMS"), g = f({
10
10
  name: "bayerDither2x2",
11
11
  type: "float",
12
12
  inputs: [{ name: "v", type: "vec2" }]
13
- })(([t]) => (s(t), t.y.mul(3).add(t.x.mul(2)).mod(4))), C = f({
13
+ })(([t]) => (a(t), t.y.mul(3).add(t.x.mul(2)).mod(4))), D = f({
14
14
  name: "bayerDither4x4",
15
15
  type: "float",
16
16
  inputs: [{ name: "v", type: "vec2" }]
17
17
  })(([t]) => {
18
- s(t);
18
+ a(t);
19
19
  const e = t.mod(2), i = t.mod(4).mul(0.5).floor();
20
- return p(e).mul(4).add(p(i));
21
- }), D = c(0).onObjectUpdate(
20
+ return g(e).mul(4).add(g(i));
21
+ }), A = P(0).onObjectUpdate(
22
22
  ({ material: t }) => t != null ? t?.params?.fadeIn.value ?? 0 : 0
23
- ), O = c(0).onObjectUpdate(
23
+ ), S = P(0).onObjectUpdate(
24
24
  ({ material: t }) => t != null ? t?.params?.fadeOut.value ?? 0 : 0
25
- ), S = L(() => {
26
- const i = C(x.xy.mod(4).floor()).add(0.5).div(16);
27
- return d(i.greaterThanEqual(D), () => {
28
- u();
29
- }), d(i.lessThan(O), () => {
30
- u();
31
- }), A;
25
+ ), U = b(() => {
26
+ const i = D(C.xy.mod(4).floor()).add(0.5).div(16);
27
+ return u(i.greaterThanEqual(A), () => {
28
+ h();
29
+ }), u(i.lessThan(S), () => {
30
+ h();
31
+ }), O;
32
32
  })();
33
- function U(t) {
34
- if (s(t), t[h] != null)
35
- return t[h];
33
+ function H(t) {
34
+ if (a(t), t[p] != null)
35
+ return t[p];
36
36
  const e = {
37
37
  fadeIn: { value: 0 },
38
38
  fadeOut: { value: 0 },
@@ -43,32 +43,32 @@ function U(t) {
43
43
  get FEATURE_FADE() {
44
44
  return i;
45
45
  },
46
- set FEATURE_FADE(n) {
47
- n !== i && (i = n, t.outputNode = n === 1 ? S : null);
46
+ set FEATURE_FADE(s) {
47
+ s !== i && (i = s, t.outputNode = s === 1 ? U : null);
48
48
  }
49
49
  }, e;
50
50
  }
51
- class H extends _ {
51
+ class W extends F {
52
52
  // HACK: Override "wrapFadeMaterial" to support NodeMaterial:
53
53
  prepareMaterial(e) {
54
54
  const i = this._fadeParams;
55
55
  if (i.has(e))
56
56
  return;
57
- let n;
58
- e instanceof M ? n = U(e) : n = b(e, e.onBeforeCompile), i.set(e, n);
57
+ let s;
58
+ e instanceof v ? s = H(e) : s = L(e, e.onBeforeCompile), i.set(e, s);
59
59
  }
60
60
  }
61
- class I extends R {
61
+ class I extends y {
62
62
  constructor(...e) {
63
- super(...e), this._fadeMaterialManager = new H();
63
+ super(...e), this._fadeMaterialManager = new W();
64
64
  }
65
65
  }
66
- function g(t, e) {
66
+ function c(t, e) {
67
67
  const i = t.material;
68
68
  if (Array.isArray(i))
69
69
  throw new Error("Multiple materials are not supported yet.");
70
- const n = new e();
71
- "map" in i && i.map != null && "map" in n && (s(i.map), s(n.map), i.map.flipY = !1, n.map = i.map.clone()), t.material = n, i.dispose();
70
+ const s = new e();
71
+ "map" in i && i.map != null && "map" in s && (a(i.map), a(s.map), i.map.flipY = !1, s.map = i.map.clone()), t.material = s, i.dispose();
72
72
  }
73
73
  class N {
74
74
  tiles;
@@ -79,18 +79,18 @@ class N {
79
79
  // Plugin method
80
80
  init(e) {
81
81
  this.tiles = e, e.group.traverse((i) => {
82
- i instanceof a && g(i, this.overrideMaterial);
82
+ i instanceof o && c(i, this.overrideMaterial);
83
83
  }), e.addEventListener("load-model", this.handleLoadModel), e.addEventListener("dispose-model", this.handleDisposeModel);
84
84
  }
85
85
  handleLoadModel = ({ scene: e }) => {
86
86
  e.traverse((i) => {
87
- i instanceof a && g(i, this.overrideMaterial);
87
+ i instanceof o && c(i, this.overrideMaterial);
88
88
  });
89
89
  };
90
90
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
91
91
  handleDisposeModel = ({ scene: e }) => {
92
92
  e.traverse((i) => {
93
- i instanceof a && i.material.dispose();
93
+ i instanceof o && i.material.dispose();
94
94
  });
95
95
  };
96
96
  // Plugin method
@@ -110,23 +110,23 @@ class z {
110
110
  this.tiles = this._initTilesRenderer(), this.tileCompressionPlugin = this._initTileCompressionPlugin(), this.updateOnChangePlugin = this._initUpdateOnChangePlugin(), this.reorientationPlugin = this._initReorientationPlugin(), this.xyzTilesPlugin = this._initXYZTilesPlugin(), this.tilesFadePlugin = this._initTilesFadePlugin(), this.tileMaterialReplacementPlugin = this._initTileMaterialReplacementPlugin();
111
111
  }
112
112
  _initTilesRenderer() {
113
- const e = new T();
113
+ const e = new R();
114
114
  return e.maxDepth = 20, e.errorTarget = 1, e;
115
115
  }
116
116
  _initTileCompressionPlugin() {
117
- const e = new E();
117
+ const e = new w();
118
118
  return this.tiles.registerPlugin(e), e;
119
119
  }
120
120
  _initUpdateOnChangePlugin() {
121
- const e = new w();
121
+ const e = new E();
122
122
  return this.tiles.registerPlugin(e), e;
123
123
  }
124
124
  _initReorientationPlugin() {
125
- const e = new y();
125
+ const e = new _();
126
126
  return this.tiles.registerPlugin(e), e;
127
127
  }
128
128
  _initXYZTilesPlugin() {
129
- const e = new F({
129
+ const e = new x({
130
130
  center: !0,
131
131
  shape: "ellipsoid",
132
132
  url: "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
@@ -142,15 +142,22 @@ class z {
142
142
  return this.tiles.registerPlugin(e), e;
143
143
  }
144
144
  }
145
- class G extends z {
145
+ class k extends z {
146
146
  viewer;
147
147
  loedTilesSets = /* @__PURE__ */ new Set();
148
+ gisOrigin = null;
149
+ _worldToEllipsoidMatrix = new M();
150
+ _ellipsoidPosition = new d();
148
151
  constructor(e) {
149
152
  super(), this.viewer = e, this.tiles.addEventListener("needs-render", this.render), this.tiles.addEventListener("needs-update", this.render);
150
153
  }
151
154
  render = () => {
152
155
  this.viewer.render();
153
156
  };
157
+ applyGisOrigin(e, i, s) {
158
+ const r = l.degToRad(i), n = l.degToRad(e);
159
+ this.reorientationPlugin.transformLatLonHeightToOrigin(r, n, s), this.gisOrigin = { lon: e, lat: i, height: s }, this.render();
160
+ }
154
161
  beforeRenderHandler = () => {
155
162
  this.viewer.camera.updateMatrixWorld(), this.tiles.setCamera(this.viewer.camera), this.tiles.setResolutionFromRenderer(this.viewer.camera, this.viewer.renderer), this.tiles.update();
156
163
  };
@@ -160,20 +167,26 @@ class G extends z {
160
167
  disable() {
161
168
  return this.viewer.scene.remove(this.tiles.group), this.viewer.removeEventListener("beforeRender", this.beforeRenderHandler), this;
162
169
  }
163
- invalidate(e, i, n) {
170
+ invalidate(e, i, s) {
164
171
  const r = () => {
165
- const P = o.degToRad(i), v = o.degToRad(e);
166
- this.reorientationPlugin.transformLatLonHeightToOrigin(P, v, n), this.render(), l();
167
- }, l = () => {
172
+ this.applyGisOrigin(e, i, s), n();
173
+ }, n = () => {
168
174
  this.tiles.removeEventListener("load-root-tileset", r), this.loedTilesSets.delete(r);
169
175
  };
170
- return this.tiles.addEventListener("load-root-tileset", r), this.loedTilesSets.add(r), this.tiles.root && r(), l;
176
+ return this.tiles.root || (this.tiles.addEventListener("load-root-tileset", r), this.loedTilesSets.add(r)), this.applyGisOrigin(e, i, s), n;
177
+ }
178
+ lonLatHeightToPosition(e, i, s = 0, r = new d()) {
179
+ const n = l.degToRad(i), T = l.degToRad(e);
180
+ return this.tiles.ellipsoid.getCartographicToPosition(n, T, s, r), this.tiles.group.updateWorldMatrix(!0, !1), r.applyMatrix4(this.tiles.group.matrixWorld);
181
+ }
182
+ positionToLonLatHeight(e, i = { lon: 0, lat: 0, height: 0 }) {
183
+ return this.tiles.group.updateWorldMatrix(!0, !1), this._worldToEllipsoidMatrix.copy(this.tiles.group.matrixWorld).invert(), this._ellipsoidPosition.copy(e).applyMatrix4(this._worldToEllipsoidMatrix), this.tiles.ellipsoid.getPositionToCartographic(this._ellipsoidPosition, i), i.lon = l.radToDeg(i.lon), i.lat = l.radToDeg(i.lat), i;
171
184
  }
172
185
  dispose() {
173
186
  this.disable(), this.loedTilesSets.forEach((e) => this.tiles.removeEventListener("load-root-tileset", e)), this.loedTilesSets.clear(), this.tiles.removeEventListener("needs-render", this.render), this.tiles.removeEventListener("needs-update", this.render), this.tiles.dispose();
174
187
  }
175
188
  }
176
189
  export {
177
- G as ArcgisTilesRenderer,
190
+ k as ArcgisTilesRenderer,
178
191
  z as Globe
179
192
  };