u-space 0.0.21 → 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.
@@ -14,6 +14,7 @@ declare class ArcgisTilesRenderer extends Globe {
14
14
  private _ellipsoidPosition;
15
15
  constructor(viewer: Viewer);
16
16
  render: () => void;
17
+ private applyGisOrigin;
17
18
  beforeRenderHandler: () => void;
18
19
  enable(): this;
19
20
  disable(): this;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("three/webgpu"),P=require("3d-tiles-renderer"),a=require("3d-tiles-renderer/plugins"),T=require("3d-tiles-renderer/src/three/plugins/fade/FadeMaterialManager.js"),v=require("3d-tiles-renderer/src/three/plugins/fade/wrapFadeMaterial.js"),n=require("three/tsl"),o=require("@takram/three-geospatial"),c=require("@takram/three-geospatial/webgpu"),h=Symbol("FADE_PARAMS"),p=c.FnLayout({name:"bayerDither2x2",type:"float",inputs:[{name:"v",type:"vec2"}]})(([t])=>(o.reinterpretType(t),t.y.mul(3).add(t.x.mul(2)).mod(4))),f=c.FnLayout({name:"bayerDither4x4",type:"float",inputs:[{name:"v",type:"vec2"}]})(([t])=>{o.reinterpretType(t);const e=t.mod(2),i=t.mod(4).mul(.5).floor();return p(e).mul(4).add(p(i))}),y=n.uniform(0).onObjectUpdate(({material:t})=>t!=null?t?.params?.fadeIn.value??0:0),R=n.uniform(0).onObjectUpdate(({material:t})=>t!=null?t?.params?.fadeOut.value??0:0),w=n.Fn(()=>{const i=f(n.screenCoordinate.xy.mod(4).floor()).add(.5).div(16);return n.If(i.greaterThanEqual(y),()=>{n.Discard()}),n.If(i.lessThan(R),()=>{n.Discard()}),n.output})();function _(t){if(o.reinterpretType(t),t[h]!=null)return t[h];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?w:null)}},e}class E extends T.FadeMaterialManager{prepareMaterial(e){const i=this._fadeParams;if(i.has(e))return;let s;e instanceof r.NodeMaterial?s=_(e):s=v.wrapFadeMaterial(e,e.onBeforeCompile),i.set(e,s)}}class x extends a.TilesFadePlugin{constructor(...e){super(...e),this._fadeMaterialManager=new E}}function g(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&&(o.reinterpretType(i.map),o.reinterpretType(s.map),i.map.flipY=!1,s.map=i.map.clone()),t.material=s,i.dispose()}class F{tiles;overrideMaterial;constructor(e=r.MeshBasicNodeMaterial){this.overrideMaterial=e}init(e){this.tiles=e,e.group.traverse(i=>{i instanceof r.Mesh&&g(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&&g(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 m{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 P.TilesRenderer;return e.maxDepth=20,e.errorTarget=1,e}_initTileCompressionPlugin(){const e=new a.TileCompressionPlugin;return this.tiles.registerPlugin(e),e}_initUpdateOnChangePlugin(){const e=new a.UpdateOnChangePlugin;return this.tiles.registerPlugin(e),e}_initReorientationPlugin(){const e=new a.ReorientationPlugin;return this.tiles.registerPlugin(e),e}_initXYZTilesPlugin(){const e=new a.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 x;return this.tiles.registerPlugin(e),e}_initTileMaterialReplacementPlugin(){const e=new F(r.MeshBasicNodeMaterial);return this.tiles.registerPlugin(e),e}}class b extends m{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()};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 l=()=>{const u=r.MathUtils.degToRad(i),M=r.MathUtils.degToRad(e);this.reorientationPlugin.transformLatLonHeightToOrigin(u,M,s),this.gisOrigin={lon:e,lat:i,height:s},this.render(),d()},d=()=>{this.tiles.removeEventListener("load-root-tileset",l),this.loedTilesSets.delete(l)};return this.tiles.addEventListener("load-root-tileset",l),this.loedTilesSets.add(l),this.tiles.root&&l(),d}lonLatHeightToPosition(e,i,s=0,l=new r.Vector3){const d=r.MathUtils.degToRad(i),u=r.MathUtils.degToRad(e);return this.tiles.ellipsoid.getCartographicToPosition(d,u,s,l),this.tiles.group.updateWorldMatrix(!0,!1),l.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=b;exports.Globe=m;
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 M, MeshBasicNodeMaterial as P, Mesh as d, Matrix4 as R, Vector3 as u, MathUtils as n } from "three/webgpu";
2
- import { TilesRenderer as w } from "3d-tiles-renderer";
3
- import { TilesFadePlugin as E, TileCompressionPlugin as y, UpdateOnChangePlugin as _, ReorientationPlugin as x, XYZTilesPlugin as F } from "3d-tiles-renderer/plugins";
4
- import { FadeMaterialManager as L } 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 f, Fn as C, screenCoordinate as D, If as h, Discard as p, output as A } from "three/tsl";
7
- import { reinterpretType as l } from "@takram/three-geospatial";
8
- import { FnLayout as T } from "@takram/three-geospatial/webgpu";
9
- const g = /* @__PURE__ */ Symbol("FADE_PARAMS"), c = T({
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]) => (l(t), t.y.mul(3).add(t.x.mul(2)).mod(4))), O = 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
- l(t);
18
+ a(t);
19
19
  const e = t.mod(2), i = t.mod(4).mul(0.5).floor();
20
- return c(e).mul(4).add(c(i));
21
- }), S = f(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
- ), U = f(0).onObjectUpdate(
23
+ ), S = P(0).onObjectUpdate(
24
24
  ({ material: t }) => t != null ? t?.params?.fadeOut.value ?? 0 : 0
25
- ), H = C(() => {
26
- const i = O(D.xy.mod(4).floor()).add(0.5).div(16);
27
- return h(i.greaterThanEqual(S), () => {
28
- p();
29
- }), h(i.lessThan(U), () => {
30
- p();
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 W(t) {
34
- if (l(t), t[g] != null)
35
- return t[g];
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 ? H : null);
47
+ s !== i && (i = s, t.outputNode = s === 1 ? U : null);
48
48
  }
49
49
  }, e;
50
50
  }
51
- class I extends L {
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 M ? s = W(e) : s = b(e, e.onBeforeCompile), i.set(e, s);
58
+ e instanceof v ? s = H(e) : s = L(e, e.onBeforeCompile), i.set(e, s);
59
59
  }
60
60
  }
61
- class N extends E {
61
+ class I extends y {
62
62
  constructor(...e) {
63
- super(...e), this._fadeMaterialManager = new I();
63
+ super(...e), this._fadeMaterialManager = new W();
64
64
  }
65
65
  }
66
- function m(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
70
  const s = new e();
71
- "map" in i && i.map != null && "map" in s && (l(i.map), l(s.map), i.map.flipY = !1, s.map = i.map.clone()), t.material = s, i.dispose();
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 z {
73
+ class N {
74
74
  tiles;
75
75
  overrideMaterial;
76
- constructor(e = P) {
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 d && m(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 d && m(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 d && i.material.dispose();
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 B {
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 w();
113
+ const e = new R();
114
114
  return e.maxDepth = 20, e.errorTarget = 1, e;
115
115
  }
116
116
  _initTileCompressionPlugin() {
117
- const e = new y();
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 x();
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}"
@@ -134,26 +134,30 @@ class B {
134
134
  return this.tiles.registerPlugin(e), e;
135
135
  }
136
136
  _initTilesFadePlugin() {
137
- const e = new N();
137
+ const e = new I();
138
138
  return this.tiles.registerPlugin(e), e;
139
139
  }
140
140
  _initTileMaterialReplacementPlugin() {
141
- const e = new z(P);
141
+ const e = new N(m);
142
142
  return this.tiles.registerPlugin(e), e;
143
143
  }
144
144
  }
145
- class J extends B {
145
+ class k extends z {
146
146
  viewer;
147
147
  loedTilesSets = /* @__PURE__ */ new Set();
148
148
  gisOrigin = null;
149
- _worldToEllipsoidMatrix = new R();
150
- _ellipsoidPosition = new u();
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
- const o = n.degToRad(i), v = n.degToRad(e);
169
- this.reorientationPlugin.transformLatLonHeightToOrigin(o, v, s), this.gisOrigin = { lon: e, lat: i, height: s }, this.render(), a();
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.tiles.root && r(), a;
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 u()) {
176
- const a = n.degToRad(i), o = n.degToRad(e);
177
- return this.tiles.ellipsoid.getCartographicToPosition(a, o, s, r), this.tiles.group.updateWorldMatrix(!0, !1), r.applyMatrix4(this.tiles.group.matrixWorld);
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 = n.radToDeg(i.lon), i.lat = n.radToDeg(i.lat), i;
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
- J as ArcgisTilesRenderer,
188
- B as Globe
190
+ k as ArcgisTilesRenderer,
191
+ z as Globe
189
192
  };
@@ -1,5 +1,6 @@
1
1
  import { type WebGPURenderer } from 'three/webgpu';
2
2
  export declare class Info {
3
+ #private;
3
4
  el: HTMLElement;
4
5
  renderer: WebGPURenderer;
5
6
  container: HTMLElement;
@@ -55,4 +55,4 @@ const { lon, lat, height } = arcgisTilesRenderer.positionToLonLatHeight(worldPos
55
55
 
56
56
  传给 `positionToLonLatHeight()` 的 `position` 必须是场景世界坐标。如果坐标来自某个对象的局部空间,先通过 `object.localToWorld(localPosition)` 或 `object.getWorldPosition()` 转成世界坐标。
57
57
 
58
- 如果在瓦片 root tileset 加载前调用 `invalidate()`,重定位会等到 root tileset 加载后才真正应用。需要在业务逻辑中立即使用转换结果时,应确保 `invalidate()` 已经完成,或在瓦片加载完成后再调用转换方法。
58
+ 如果在瓦片 root tileset 加载前调用 `invalidate()`,会先基于当前 WGS84 椭球立即应用一次重定位,保证后续坐标转换可用;root tileset 加载完成后会按最终 ellipsoid 再应用一次。
package/docs/changelog.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## 未发布
4
4
 
5
+ 暂无。
6
+
7
+ ## 0.0.21
8
+
5
9
  ### 新增
6
10
 
7
11
  - **u-manager semantics** — `SemanticLoader` 支持解析建筑级 `Elevators` 和 `Vents`,以 `Polygon.shape` 作为底面轮廓、`Elevation` 作为底面高度、`TotalHeight` 作为拉伸高度生成 `ExtrudeMesh`,并通过 `BuildingGroup.elevatorMeshes`、`BuildingGroup.ventMeshes` 及 add/get/remove 方法管理。
@@ -11,6 +15,10 @@
11
15
  - **透明语义体块渲染** — 电梯井/通风井在渲染阶段沿法线轻微内收,`Spaces` 实例使用稳定 per-instance 渲染偏移抖动,缓解与墙体或完全重叠空间共面时的 z-fighting。
12
16
  - **atmosphere 插件** — 后处理链移除 aerial perspective 节点,保留 lens flare、tone mapping、temporal antialias 和 dithering;`scene.backgroundNode` 使用 `skyBackground()`,`scene.environmentNode` 使用 `skyEnvironment()`,并继续在关闭插件时恢复启用前的背景和环境节点。
13
17
 
18
+ ### 示例与文档
19
+
20
+ - **在线示例** — `examples/importmap.js` 的 CDN fallback 版本更新为 `0.0.21`,部署流程仍会优先按 `package.json` 注入当前版本。
21
+
14
22
  ## 0.0.18
15
23
 
16
24
  ### 变更
@@ -27,7 +35,7 @@
27
35
  ### 变更
28
36
 
29
37
  - **大气状态更新** — 大气插件在 `beforeRender` 中刷新相机 ECEF 位置、太阳/月亮方向和阴影 target,相机控制器驱动的移动也能逐帧更新大气状态。
30
- - **MCP 发布** — 根目录 MCP 发布入口合并为 `pnpm publish:mcp`,命令会先构建 `u-space-mcp` 文档索引,再发布 npm 包。
38
+ - **MCP 发布** — 根目录 MCP 发布入口合并为 `pnpm publish:mcp`,命令会先递增 `u-space-mcp` patch 版本,再构建文档索引并发布 npm 包。
31
39
 
32
40
  ## 0.0.16
33
41
 
@@ -2,6 +2,12 @@
2
2
 
3
3
  `u-space` 的 `examples/` 目录中包含了大量演示引擎功能的示例。以下是几个关键示例及其所展示的系统特性。
4
4
 
5
+ ## 运行方式与版本
6
+
7
+ 示例统一通过 `examples/importmap.js` 注入 Import Map。本地通过 `localhost`、`127.0.0.1` 或 `0.0.0.0` 访问时会加载仓库里的 `../dist/` 构建产物;在线部署或非本地域名访问时会从 jsDelivr 加载当前发布版本 `u-space@0.0.21`。Vercel 文档部署会继续把 `__VERSION__` 占位符替换为 `package.json` 中的版本号,源码里的 `0.0.21` 作为直接托管 `examples/` 时的 fallback。
8
+
9
+ 插件示例可以在页面加载 `importmap.js` 前通过 `window.__IMPORTS__` 声明额外依赖。将 `u-space/plugins/<name>` 的值设为 `true` 时,`importmap.js` 会自动在本地和 CDN 路径之间切换。
10
+
5
11
  ## 1. `demo01.html`:基础配置与交互
6
12
 
7
13
  该示例演示了通过 WebGPU 渲染 3D 场景所需的最少配置,与 [快速上手](./getting-started.md) 指南中的内容一致。
@@ -125,7 +125,7 @@ box.addEventListener('pointerleave', (e) => {
125
125
 
126
126
  ```typescript
127
127
  import { version } from 'u-space';
128
- console.log(version); // e.g. '0.0.5'
128
+ console.log(version); // e.g. '0.0.21'
129
129
 
130
130
  // 也可以通过全局变量访问
131
131
  console.log(window.__USPACE__.version);
package/docs/mcp.md CHANGED
@@ -86,7 +86,7 @@ export const codingAgent = new Agent({
86
86
 
87
87
  ## 包结构
88
88
 
89
- 源码位于 `packages/u-space-mcp`。根目录只保留一个 MCP 发布入口;执行时会先从 `docs/*.md` 生成内置文档索引,编译 MCP 包,然后发布到 npm:
89
+ 源码位于 `packages/u-space-mcp`。根目录只保留一个 MCP 发布入口;执行时会先递增 `u-space-mcp` 的 patch 版本,再从 `docs/*.md` 生成内置文档索引,编译 MCP 包,然后发布到 npm:
90
90
 
91
91
  ```bash
92
92
  pnpm publish:mcp
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u-space",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "docs:build": "vitepress build docs",
30
30
  "docs:preview": "vitepress preview docs",
31
31
  "docs:deploy": "pnpm docs:build && vercel --prod",
32
- "publish:mcp": "pnpm --filter u-space-mcp build && npm publish ./packages/u-space-mcp --access public --ignore-scripts",
32
+ "publish:mcp": "npm --prefix ./packages/u-space-mcp version patch --no-git-tag-version && pnpm --filter u-space-mcp build && npm publish ./packages/u-space-mcp --access public --ignore-scripts",
33
33
  "release": "npm version patch && pnpm build && npm publish --access=public"
34
34
  },
35
35
  "files": [