u-space 0.0.21 → 0.0.23
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.cjs +3 -3
- package/dist/index.js +415 -383
- package/dist/plugins/tiles/ArcgisTilesRenderer.d.ts +1 -0
- package/dist/plugins/tiles/index.cjs +1 -1
- package/dist/plugins/tiles/index.js +60 -57
- package/dist/plugins/u-manager/index.cjs +45 -45
- package/dist/plugins/u-manager/index.js +6719 -6460
- package/dist/plugins/u-manager/semantics/SemanticLoader.d.ts +6 -0
- package/dist/plugins/u-manager/semantics/SemanticParser.d.ts +10 -0
- package/dist/plugins/u-manager/semantics/objects/BuildingGroup.d.ts +5 -1
- package/dist/plugins/u-manager/semantics/objects/FloorMesh.d.ts +34 -1
- package/dist/plugins/u-manager/semantics/semantic.types.d.ts +8 -1
- package/dist/src/viewers/Info.d.ts +1 -0
- package/docs/api-plugin-tiles.md +1 -1
- package/docs/api-plugin-u-manager.md +45 -7
- package/docs/changelog.md +14 -1
- package/docs/examples-guide.md +6 -0
- package/docs/getting-started.md +1 -1
- package/docs/index.md +1 -1
- package/docs/mcp.md +2 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("three/webgpu"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("three/webgpu"),M=require("3d-tiles-renderer"),o=require("3d-tiles-renderer/plugins"),P=require("3d-tiles-renderer/src/three/plugins/fade/FadeMaterialManager.js"),T=require("3d-tiles-renderer/src/three/plugins/fade/wrapFadeMaterial.js"),l=require("three/tsl"),d=require("@takram/three-geospatial"),g=require("@takram/three-geospatial/webgpu"),u=Symbol("FADE_PARAMS"),h=g.FnLayout({name:"bayerDither2x2",type:"float",inputs:[{name:"v",type:"vec2"}]})(([t])=>(d.reinterpretType(t),t.y.mul(3).add(t.x.mul(2)).mod(4))),v=g.FnLayout({name:"bayerDither4x4",type:"float",inputs:[{name:"v",type:"vec2"}]})(([t])=>{d.reinterpretType(t);const e=t.mod(2),i=t.mod(4).mul(.5).floor();return h(e).mul(4).add(h(i))}),f=l.uniform(0).onObjectUpdate(({material:t})=>t!=null?t?.params?.fadeIn.value??0:0),y=l.uniform(0).onObjectUpdate(({material:t})=>t!=null?t?.params?.fadeOut.value??0:0),R=l.Fn(()=>{const i=v(l.screenCoordinate.xy.mod(4).floor()).add(.5).div(16);return l.If(i.greaterThanEqual(f),()=>{l.Discard()}),l.If(i.lessThan(y),()=>{l.Discard()}),l.output})();function w(t){if(d.reinterpretType(t),t[u]!=null)return t[u];const e={fadeIn:{value:0},fadeOut:{value:0},fadeTexture:{value:null}};let i=0;return t.params=e,t.defines={get FEATURE_FADE(){return i},set FEATURE_FADE(s){s!==i&&(i=s,t.outputNode=s===1?R:null)}},e}class _ extends P.FadeMaterialManager{prepareMaterial(e){const i=this._fadeParams;if(i.has(e))return;let s;e instanceof r.NodeMaterial?s=w(e):s=T.wrapFadeMaterial(e,e.onBeforeCompile),i.set(e,s)}}class E extends o.TilesFadePlugin{constructor(...e){super(...e),this._fadeMaterialManager=new _}}function p(t,e){const i=t.material;if(Array.isArray(i))throw new Error("Multiple materials are not supported yet.");const s=new e;"map"in i&&i.map!=null&&"map"in s&&(d.reinterpretType(i.map),d.reinterpretType(s.map),i.map.flipY=!1,s.map=i.map.clone()),t.material=s,i.dispose()}class x{tiles;overrideMaterial;constructor(e=r.MeshBasicNodeMaterial){this.overrideMaterial=e}init(e){this.tiles=e,e.group.traverse(i=>{i instanceof r.Mesh&&p(i,this.overrideMaterial)}),e.addEventListener("load-model",this.handleLoadModel),e.addEventListener("dispose-model",this.handleDisposeModel)}handleLoadModel=({scene:e})=>{e.traverse(i=>{i instanceof r.Mesh&&p(i,this.overrideMaterial)})};handleDisposeModel=({scene:e})=>{e.traverse(i=>{i instanceof r.Mesh&&i.material.dispose()})};dispose(){this.tiles?.removeEventListener("load-model",this.handleLoadModel),this.tiles?.removeEventListener("dispose-model",this.handleDisposeModel)}}class c{tiles;tileCompressionPlugin;updateOnChangePlugin;reorientationPlugin;xyzTilesPlugin;tilesFadePlugin;tileMaterialReplacementPlugin;constructor(){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()}_initTilesRenderer(){const e=new M.TilesRenderer;return e.maxDepth=20,e.errorTarget=1,e}_initTileCompressionPlugin(){const e=new o.TileCompressionPlugin;return this.tiles.registerPlugin(e),e}_initUpdateOnChangePlugin(){const e=new o.UpdateOnChangePlugin;return this.tiles.registerPlugin(e),e}_initReorientationPlugin(){const e=new o.ReorientationPlugin;return this.tiles.registerPlugin(e),e}_initXYZTilesPlugin(){const e=new o.XYZTilesPlugin({center:!0,shape:"ellipsoid",url:"https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"});return this.tiles.registerPlugin(e),e}_initTilesFadePlugin(){const e=new E;return this.tiles.registerPlugin(e),e}_initTileMaterialReplacementPlugin(){const e=new x(r.MeshBasicNodeMaterial);return this.tiles.registerPlugin(e),e}}class F extends c{viewer;loedTilesSets=new Set;gisOrigin=null;_worldToEllipsoidMatrix=new r.Matrix4;_ellipsoidPosition=new r.Vector3;constructor(e){super(),this.viewer=e,this.tiles.addEventListener("needs-render",this.render),this.tiles.addEventListener("needs-update",this.render)}render=()=>{this.viewer.render()};applyGisOrigin(e,i,s){const n=r.MathUtils.degToRad(i),a=r.MathUtils.degToRad(e);this.reorientationPlugin.transformLatLonHeightToOrigin(n,a,s),this.gisOrigin={lon:e,lat:i,height:s},this.render()}beforeRenderHandler=()=>{this.viewer.camera.updateMatrixWorld(),this.tiles.setCamera(this.viewer.camera),this.tiles.setResolutionFromRenderer(this.viewer.camera,this.viewer.renderer),this.tiles.update()};enable(){return this.viewer.scene.add(this.tiles.group),this.viewer.addEventListener("beforeRender",this.beforeRenderHandler),this}disable(){return this.viewer.scene.remove(this.tiles.group),this.viewer.removeEventListener("beforeRender",this.beforeRenderHandler),this}invalidate(e,i,s){const n=()=>{this.applyGisOrigin(e,i,s),a()},a=()=>{this.tiles.removeEventListener("load-root-tileset",n),this.loedTilesSets.delete(n)};return this.tiles.root||(this.tiles.addEventListener("load-root-tileset",n),this.loedTilesSets.add(n)),this.applyGisOrigin(e,i,s),a}lonLatHeightToPosition(e,i,s=0,n=new r.Vector3){const a=r.MathUtils.degToRad(i),m=r.MathUtils.degToRad(e);return this.tiles.ellipsoid.getCartographicToPosition(a,m,s,n),this.tiles.group.updateWorldMatrix(!0,!1),n.applyMatrix4(this.tiles.group.matrixWorld)}positionToLonLatHeight(e,i={lon:0,lat:0,height:0}){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=r.MathUtils.radToDeg(i.lon),i.lat=r.MathUtils.radToDeg(i.lat),i}dispose(){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()}}exports.ArcgisTilesRenderer=F;exports.Globe=c;
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { NodeMaterial as
|
|
2
|
-
import { TilesRenderer as
|
|
3
|
-
import { TilesFadePlugin as
|
|
4
|
-
import { FadeMaterialManager as
|
|
5
|
-
import { wrapFadeMaterial as
|
|
6
|
-
import { uniform as
|
|
7
|
-
import { reinterpretType as
|
|
8
|
-
import { FnLayout as
|
|
9
|
-
const
|
|
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
|
+
import { FnLayout as f } from "@takram/three-geospatial/webgpu";
|
|
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]) => (
|
|
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
|
-
|
|
18
|
+
a(t);
|
|
19
19
|
const e = t.mod(2), i = t.mod(4).mul(0.5).floor();
|
|
20
|
-
return
|
|
21
|
-
}),
|
|
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
|
-
),
|
|
23
|
+
), S = P(0).onObjectUpdate(
|
|
24
24
|
({ material: t }) => t != null ? t?.params?.fadeOut.value ?? 0 : 0
|
|
25
|
-
),
|
|
26
|
-
const i =
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
}),
|
|
30
|
-
|
|
31
|
-
}),
|
|
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
|
|
34
|
-
if (
|
|
35
|
-
return t[
|
|
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 },
|
|
@@ -44,53 +44,53 @@ function W(t) {
|
|
|
44
44
|
return i;
|
|
45
45
|
},
|
|
46
46
|
set FEATURE_FADE(s) {
|
|
47
|
-
s !== i && (i = s, t.outputNode = s === 1 ?
|
|
47
|
+
s !== i && (i = s, t.outputNode = s === 1 ? U : null);
|
|
48
48
|
}
|
|
49
49
|
}, e;
|
|
50
50
|
}
|
|
51
|
-
class
|
|
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
57
|
let s;
|
|
58
|
-
e instanceof
|
|
58
|
+
e instanceof v ? s = H(e) : s = L(e, e.onBeforeCompile), i.set(e, s);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
class
|
|
61
|
+
class I extends y {
|
|
62
62
|
constructor(...e) {
|
|
63
|
-
super(...e), this._fadeMaterialManager = new
|
|
63
|
+
super(...e), this._fadeMaterialManager = new W();
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
function
|
|
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
70
|
const s = new e();
|
|
71
|
-
"map" in i && i.map != null && "map" in s && (
|
|
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
|
-
class
|
|
73
|
+
class N {
|
|
74
74
|
tiles;
|
|
75
75
|
overrideMaterial;
|
|
76
|
-
constructor(e =
|
|
76
|
+
constructor(e = m) {
|
|
77
77
|
this.overrideMaterial = e;
|
|
78
78
|
}
|
|
79
79
|
// Plugin method
|
|
80
80
|
init(e) {
|
|
81
81
|
this.tiles = e, e.group.traverse((i) => {
|
|
82
|
-
i instanceof
|
|
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
|
|
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
|
|
93
|
+
i instanceof o && i.material.dispose();
|
|
94
94
|
});
|
|
95
95
|
};
|
|
96
96
|
// Plugin method
|
|
@@ -98,7 +98,7 @@ class z {
|
|
|
98
98
|
this.tiles?.removeEventListener("load-model", this.handleLoadModel), this.tiles?.removeEventListener("dispose-model", this.handleDisposeModel);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
class
|
|
101
|
+
class z {
|
|
102
102
|
tiles;
|
|
103
103
|
tileCompressionPlugin;
|
|
104
104
|
updateOnChangePlugin;
|
|
@@ -110,23 +110,23 @@ class B {
|
|
|
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
|
|
113
|
+
const e = new R();
|
|
114
114
|
return e.maxDepth = 20, e.errorTarget = 1, e;
|
|
115
115
|
}
|
|
116
116
|
_initTileCompressionPlugin() {
|
|
117
|
-
const e = new
|
|
117
|
+
const e = new w();
|
|
118
118
|
return this.tiles.registerPlugin(e), e;
|
|
119
119
|
}
|
|
120
120
|
_initUpdateOnChangePlugin() {
|
|
121
|
-
const e = new
|
|
121
|
+
const e = new E();
|
|
122
122
|
return this.tiles.registerPlugin(e), e;
|
|
123
123
|
}
|
|
124
124
|
_initReorientationPlugin() {
|
|
125
|
-
const e = new
|
|
125
|
+
const e = new _();
|
|
126
126
|
return this.tiles.registerPlugin(e), e;
|
|
127
127
|
}
|
|
128
128
|
_initXYZTilesPlugin() {
|
|
129
|
-
const e = new
|
|
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}"
|
|
@@ -134,26 +134,30 @@ class B {
|
|
|
134
134
|
return this.tiles.registerPlugin(e), e;
|
|
135
135
|
}
|
|
136
136
|
_initTilesFadePlugin() {
|
|
137
|
-
const e = new
|
|
137
|
+
const e = new I();
|
|
138
138
|
return this.tiles.registerPlugin(e), e;
|
|
139
139
|
}
|
|
140
140
|
_initTileMaterialReplacementPlugin() {
|
|
141
|
-
const e = new
|
|
141
|
+
const e = new N(m);
|
|
142
142
|
return this.tiles.registerPlugin(e), e;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
class
|
|
145
|
+
class k extends z {
|
|
146
146
|
viewer;
|
|
147
147
|
loedTilesSets = /* @__PURE__ */ new Set();
|
|
148
148
|
gisOrigin = null;
|
|
149
|
-
_worldToEllipsoidMatrix = new
|
|
150
|
-
_ellipsoidPosition = new
|
|
149
|
+
_worldToEllipsoidMatrix = new M();
|
|
150
|
+
_ellipsoidPosition = new d();
|
|
151
151
|
constructor(e) {
|
|
152
152
|
super(), this.viewer = e, this.tiles.addEventListener("needs-render", this.render), this.tiles.addEventListener("needs-update", this.render);
|
|
153
153
|
}
|
|
154
154
|
render = () => {
|
|
155
155
|
this.viewer.render();
|
|
156
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
|
+
}
|
|
157
161
|
beforeRenderHandler = () => {
|
|
158
162
|
this.viewer.camera.updateMatrixWorld(), this.tiles.setCamera(this.viewer.camera), this.tiles.setResolutionFromRenderer(this.viewer.camera, this.viewer.renderer), this.tiles.update();
|
|
159
163
|
};
|
|
@@ -165,25 +169,24 @@ class J extends B {
|
|
|
165
169
|
}
|
|
166
170
|
invalidate(e, i, s) {
|
|
167
171
|
const r = () => {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}, a = () => {
|
|
172
|
+
this.applyGisOrigin(e, i, s), n();
|
|
173
|
+
}, n = () => {
|
|
171
174
|
this.tiles.removeEventListener("load-root-tileset", r), this.loedTilesSets.delete(r);
|
|
172
175
|
};
|
|
173
|
-
return this.tiles.addEventListener("load-root-tileset", r), this.loedTilesSets.add(r), this.
|
|
176
|
+
return this.tiles.root || (this.tiles.addEventListener("load-root-tileset", r), this.loedTilesSets.add(r)), this.applyGisOrigin(e, i, s), n;
|
|
174
177
|
}
|
|
175
|
-
lonLatHeightToPosition(e, i, s = 0, r = new
|
|
176
|
-
const
|
|
177
|
-
return this.tiles.ellipsoid.getCartographicToPosition(
|
|
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);
|
|
178
181
|
}
|
|
179
182
|
positionToLonLatHeight(e, i = { lon: 0, lat: 0, height: 0 }) {
|
|
180
|
-
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 =
|
|
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;
|
|
181
184
|
}
|
|
182
185
|
dispose() {
|
|
183
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();
|
|
184
187
|
}
|
|
185
188
|
}
|
|
186
189
|
export {
|
|
187
|
-
|
|
188
|
-
|
|
190
|
+
k as ArcgisTilesRenderer,
|
|
191
|
+
z as Globe
|
|
189
192
|
};
|