@thatopen/components 2.3.6 → 2.3.7

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.
@@ -6,7 +6,7 @@ export declare class Components implements Disposable {
6
6
  /**
7
7
  * The version of the @thatopen/components library.
8
8
  */
9
- static readonly release = "2.3.6";
9
+ static readonly release = "2.3.7";
10
10
  /** {@link Disposable.onDisposed} */
11
11
  readonly onDisposed: Event<void>;
12
12
  /**
@@ -19,5 +19,6 @@ export declare class Mouse implements Disposable {
19
19
  private getPositionY;
20
20
  private getPositionX;
21
21
  private updateMouseInfo;
22
+ private getDataObject;
22
23
  private setupEvents;
23
24
  }
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  - If you're the tool creator, you can take one from https://www.uuidgenerator.net/.
4
4
 
5
- - If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};C(Lt,"_pattern",/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/),C(Lt,"_lut",["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"]);let Kt=Lt;class ic extends mt{constructor(t,e){super(t);C(this,"onDisposed",new j);C(this,"onVertexFound",new j);C(this,"onVertexLost",new j);C(this,"onEnabled",new j);C(this,"components");C(this,"workingPlane",null);C(this,"_pickedPoint",null);C(this,"_config");C(this,"_enabled",!1);this.components=t,this.config={snapDistance:.25,showOnlyVertex:!1,...e},this.enabled=!1}set enabled(t){this._enabled=t,t||(this._pickedPoint=null),this.onEnabled.trigger(t)}get enabled(){return this._enabled}set config(t){this._config={...this._config,...t}}get config(){return this._config}dispose(){this.onVertexFound.reset(),this.onVertexLost.reset(),this.components=null,this.onDisposed.trigger(),this.onDisposed.reset()}get(t){if(!this.enabled)return this._pickedPoint;const n=this.components.get(be).get(t).castRay();if(!n)return this._pickedPoint!==null&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint;const r=this.getClosestVertex(n);return r?(this.workingPlane?Math.abs(this.workingPlane.distanceToPoint(r))<.001:!0)?((this._pickedPoint===null||!this._pickedPoint.equals(r))&&(this._pickedPoint=r.clone(),this.onVertexFound.trigger(this._pickedPoint)),this._pickedPoint):(this._pickedPoint=null,this._pickedPoint):(this._pickedPoint!==null&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint)}getClosestVertex(t){let e=new b.Vector3,s=!1,n=Number.MAX_SAFE_INTEGER;const r=this.getVertices(t);if(r===null)return null;for(const o of r){if(!o)continue;const a=t.point.distanceTo(o);a>n||a>this._config.snapDistance||(s=!0,e=o,n=t.point.distanceTo(o))}return s?e:this.config.showOnlyVertex?null:t.point}getVertices(t){const e=t.object;if(!t.face||!e)return null;const s=e.geometry,n=new b.Matrix4,{instanceId:r}=t,o=r!==void 0,a=e instanceof b.InstancedMesh;return a&&o&&e.getMatrixAt(r,n),[this.getVertex(t.face.a,s),this.getVertex(t.face.b,s),this.getVertex(t.face.c,s)].map(l=>(l&&(a&&o&&l.applyMatrix4(n),l.applyMatrix4(e.matrixWorld)),l))}getVertex(t,e){if(t===void 0)return null;const s=e.attributes.position;return new b.Vector3(s.getX(t),s.getY(t),s.getZ(t))}}const Rs=class Rs{constructor(){C(this,"onDisposed",new j);C(this,"list",new Map);C(this,"enabled",!1);C(this,"_clock");C(this,"onInit",new j);C(this,"update",()=>{if(!this.enabled)return;const i=this._clock.getDelta();for(const[t,e]of this.list)e.enabled&&e.isUpdateable()&&e.update(i);requestAnimationFrame(this.update)});this._clock=new b.Clock,Rs.setupBVH()}add(i,t){if(this.list.has(i))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");Kt.validate(i),this.list.set(i,t)}get(i){const t=i.uuid;if(!this.list.has(t)){const e=new i(this);return this.list.has(t)||this.add(t,e),e}return this.list.get(t)}init(){this.enabled=!0,this._clock.start(),this.update(),this.onInit.trigger()}dispose(){this.enabled=!1;for(const[i,t]of this.list)t.enabled=!1,t.isDisposeable()&&t.dispose();this._clock.stop(),this.onDisposed.trigger(),this.onDisposed.reset()}static setupBVH(){b.BufferGeometry.prototype.computeBoundsTree=Ha,b.BufferGeometry.prototype.disposeBoundsTree=Wa,b.Mesh.prototype.raycast=ka}};C(Rs,"release","2.3.6");let Li=Rs;class Hr extends Vs{constructor(){super(...arguments);C(this,"meshes",new Set);C(this,"onAfterUpdate",new j);C(this,"onBeforeUpdate",new j);C(this,"onDisposed",new j);C(this,"isDisposing",!1);C(this,"enabled",!0);C(this,"uuid",Kt.create());C(this,"name");C(this,"_scene");C(this,"_camera");C(this,"_renderer",null)}get scene(){if(!this._scene)throw new Error("No scene initialized!");return this._scene}set scene(t){this._scene=t,t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"})}get camera(){if(!this._camera)throw new Error("No camera initialized!");return this._camera}set camera(t){this._camera=t,t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"})}get renderer(){return this._renderer}set renderer(t){this._renderer=t,t&&(t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"}))}update(t){this.enabled&&(!this._scene||!this._camera||(this.scene.currentWorld=this,this.camera.currentWorld=this,this.renderer&&(this.renderer.currentWorld=this),this.onBeforeUpdate.trigger(),this.scene.isUpdateable()&&this.scene.update(t),this.camera.isUpdateable()&&this.camera.update(t),this.renderer&&this.renderer.update(t),this.onAfterUpdate.trigger()))}dispose(t=!0){if(this.enabled=!1,this.isDisposing=!0,this.scene.onWorldChanged.trigger({world:this,action:"removed"}),this.camera.onWorldChanged.trigger({world:this,action:"removed"}),this.renderer&&this.renderer.onWorldChanged.trigger({world:this,action:"removed"}),t){const s=this.components.get(pe);this.scene.dispose(),this.camera.isDisposeable()&&this.camera.dispose(),this.renderer&&this.renderer.dispose();for(const n of this.meshes)s.destroy(n);this.meshes.clear()}this._scene=null,this._camera=null,this._renderer=null,this.components.get(Pi).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class Ne{constructor(i,t,e,s){C(this,"_component");C(this,"name");C(this,"uuid");this._component=i,this.name=e,this.uuid=s??Kt.create(),t.get(Oe).list.set(this.uuid,this)}get controls(){const i={};for(const t in this._config){const e=this._config[t];i[t]=this.copyEntry(e)}return i}copyEntry(i){if(i.type==="Boolean"){const t=i;return{type:t.type,value:t.value}}if(i.type==="Color"){const t=i;return{type:t.type,value:t.value.clone()}}if(i.type==="Text"){const t=i;return{type:t.type,value:t.value}}if(i.type==="Number"){const t=i;return{type:t.type,value:t.value,min:t.min,max:t.max,interpolable:t.interpolable}}if(i.type==="Select"){const t=i;return{type:t.type,value:t.value,multiple:t.multiple,options:new Set(t.options)}}if(i.type==="Vector3"){const t=i;return{type:t.type,value:t.value.clone()}}if(i.type==="TextSet"){const t=i;return{type:t.type,value:new Set(t.value)}}if(i.type==="None"){const t=i;return{type:t.type,value:t.value}}throw new Error("Invalid entry!")}}const gs=class gs extends mt{constructor(t){super(t);C(this,"list",new Qt);C(this,"enabled",!0);t.add(gs.uuid,this)}};C(gs,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let Oe=gs;class sc{constructor(i,t){C(this,"_list");C(this,"_scene");this._list=i,this._scene=t}get color(){return this._list.directionalLight.color.value}set color(i){this._list.directionalLight.color.value=i;for(const[,t]of this._scene.directionalLights)t.color.copy(i)}get intensity(){return this._list.directionalLight.intensity.value}set intensity(i){this._list.directionalLight.intensity.value=i;for(const[,t]of this._scene.directionalLights)t.intensity=i}get position(){return this._list.directionalLight.position.value.clone()}set position(i){this._list.directionalLight.position.value=i;for(const[,t]of this._scene.directionalLights)t.position.copy(i)}}class nc{constructor(i,t){C(this,"_list");C(this,"_scene");this._list=i,this._scene=t}get color(){return this._list.ambientLight.color.value}set color(i){this._list.ambientLight.color.value=i;for(const[,t]of this._scene.ambientLights)t.color.copy(i)}get intensity(){return this._list.ambientLight.intensity.value}set intensity(i){this._list.ambientLight.intensity.value=i;for(const[,t]of this._scene.ambientLights)t.intensity=i}}class Wr extends Ne{constructor(){super(...arguments);C(this,"_config",{backgroundColor:{value:new b.Color,type:"Color"},ambientLight:{color:{type:"Color",value:new b.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2}},directionalLight:{color:{type:"Color",value:new b.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2},position:{type:"Vector3",value:new b.Vector3}}});C(this,"ambientLight",new nc(this._config,this._component));C(this,"directionalLight",new sc(this._config,this._component))}get backgroundColor(){return this._config.backgroundColor.value}set backgroundColor(t){this._config.backgroundColor.value=t,this._component.three.background=t}}class Xr extends zr{constructor(t){super(t);C(this,"onSetup",new j);C(this,"isSetup",!1);C(this,"three");C(this,"config",new Wr(this,this.components,"Scene"));C(this,"_defaultConfig",{backgroundColor:new b.Color(2107698),directionalLight:{color:new b.Color("white"),intensity:1.5,position:new b.Vector3(5,10,3)},ambientLight:{color:new b.Color("white"),intensity:1}});this.three=new b.Scene,this.three.background=new b.Color(2107698)}setup(t){const e={...this._defaultConfig,...t};this.config.backgroundColor=e.backgroundColor;const s=e.ambientLight;this.config.ambientLight.color=s.color,this.config.ambientLight.intensity=s.intensity;const n=e.directionalLight;this.config.directionalLight.color=n.color,this.config.directionalLight.intensity=n.intensity,this.config.directionalLight.position=n.position,this.deleteAllLights();const{color:r,intensity:o}=this.config.directionalLight,a=new b.DirectionalLight(r,o);a.position.copy(n.position);const{color:l,intensity:h}=this.config.directionalLight,f=new b.AmbientLight(l,h);this.three.add(a,f),this.directionalLights.set(a.uuid,a),this.ambientLights.set(f.uuid,f),this.isSetup=!0,this.onSetup.trigger()}dispose(){super.dispose(),this.components.get(Oe).list.delete(this.config.uuid)}}class rc extends Gr{constructor(t,e,s){super(t);C(this,"enabled",!0);C(this,"container");C(this,"three");C(this,"_canvas");C(this,"_parameters");C(this,"_resizeObserver",null);C(this,"onContainerUpdated",new j);C(this,"_resizing",!1);C(this,"resize",t=>{if(this._resizing)return;this._resizing=!0,this.onContainerUpdated.trigger();const e=t?t.x:this.container.clientWidth,s=t?t.y:this.container.clientHeight;this.three.setSize(e,s),this.onResize.trigger(new b.Vector2(e,s)),this._resizing=!1});C(this,"resizeEvent",()=>{this.resize()});C(this,"onContextLost",t=>{t.preventDefault(),this.enabled=!1});C(this,"onContextBack",()=>{this.three.setRenderTarget(null),this.three.dispose(),this.three=new b.WebGLRenderer({canvas:this._canvas,antialias:!0,alpha:!0,...this._parameters}),this.enabled=!0});this.container=e,this._parameters=s,this.three=new b.WebGLRenderer({antialias:!0,alpha:!0,...s}),this.three.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.setupRenderer(),this.setupEvents(!0),this.resize(),this._canvas=this.three.domElement;const n=this.three.getContext(),{canvas:r}=n;r.addEventListener("webglcontextlost",this.onContextLost,!1),r.addEventListener("webglcontextrestored",this.onContextBack,!1)}update(){if(!this.enabled||!this.currentWorld)return;this.onBeforeUpdate.trigger(this);const t=this.currentWorld.scene.three,e=this.currentWorld.camera.three;this.three.render(t,e),this.onAfterUpdate.trigger(this)}dispose(){this.enabled=!1,this.setupEvents(!1),this.three.domElement.remove(),this.three.forceContextLoss(),this.three.dispose(),this.onResize.reset(),this.onAfterUpdate.reset(),this.onBeforeUpdate.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}getSize(){return new b.Vector2(this.three.domElement.clientWidth,this.three.domElement.clientHeight)}setupEvents(t){const e=this.three.domElement.parentElement;if(!e)throw new Error("This renderer needs to have an HTML container!");this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),window.removeEventListener("resize",this.resizeEvent),t&&(this._resizeObserver=new ResizeObserver(this.resizeEvent),this._resizeObserver.observe(e),window.addEventListener("resize",this.resizeEvent))}setupRenderer(){this.three.localClippingEnabled=!0,this.container&&this.container.appendChild(this.three.domElement),this.onContainerUpdated.trigger()}}/*!
5
+ - If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};C(Lt,"_pattern",/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/),C(Lt,"_lut",["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"]);let Kt=Lt;class ic extends mt{constructor(t,e){super(t);C(this,"onDisposed",new j);C(this,"onVertexFound",new j);C(this,"onVertexLost",new j);C(this,"onEnabled",new j);C(this,"components");C(this,"workingPlane",null);C(this,"_pickedPoint",null);C(this,"_config");C(this,"_enabled",!1);this.components=t,this.config={snapDistance:.25,showOnlyVertex:!1,...e},this.enabled=!1}set enabled(t){this._enabled=t,t||(this._pickedPoint=null),this.onEnabled.trigger(t)}get enabled(){return this._enabled}set config(t){this._config={...this._config,...t}}get config(){return this._config}dispose(){this.onVertexFound.reset(),this.onVertexLost.reset(),this.components=null,this.onDisposed.trigger(),this.onDisposed.reset()}get(t){if(!this.enabled)return this._pickedPoint;const n=this.components.get(be).get(t).castRay();if(!n)return this._pickedPoint!==null&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint;const r=this.getClosestVertex(n);return r?(this.workingPlane?Math.abs(this.workingPlane.distanceToPoint(r))<.001:!0)?((this._pickedPoint===null||!this._pickedPoint.equals(r))&&(this._pickedPoint=r.clone(),this.onVertexFound.trigger(this._pickedPoint)),this._pickedPoint):(this._pickedPoint=null,this._pickedPoint):(this._pickedPoint!==null&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint)}getClosestVertex(t){let e=new b.Vector3,s=!1,n=Number.MAX_SAFE_INTEGER;const r=this.getVertices(t);if(r===null)return null;for(const o of r){if(!o)continue;const a=t.point.distanceTo(o);a>n||a>this._config.snapDistance||(s=!0,e=o,n=t.point.distanceTo(o))}return s?e:this.config.showOnlyVertex?null:t.point}getVertices(t){const e=t.object;if(!t.face||!e)return null;const s=e.geometry,n=new b.Matrix4,{instanceId:r}=t,o=r!==void 0,a=e instanceof b.InstancedMesh;return a&&o&&e.getMatrixAt(r,n),[this.getVertex(t.face.a,s),this.getVertex(t.face.b,s),this.getVertex(t.face.c,s)].map(l=>(l&&(a&&o&&l.applyMatrix4(n),l.applyMatrix4(e.matrixWorld)),l))}getVertex(t,e){if(t===void 0)return null;const s=e.attributes.position;return new b.Vector3(s.getX(t),s.getY(t),s.getZ(t))}}const Rs=class Rs{constructor(){C(this,"onDisposed",new j);C(this,"list",new Map);C(this,"enabled",!1);C(this,"_clock");C(this,"onInit",new j);C(this,"update",()=>{if(!this.enabled)return;const i=this._clock.getDelta();for(const[t,e]of this.list)e.enabled&&e.isUpdateable()&&e.update(i);requestAnimationFrame(this.update)});this._clock=new b.Clock,Rs.setupBVH()}add(i,t){if(this.list.has(i))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");Kt.validate(i),this.list.set(i,t)}get(i){const t=i.uuid;if(!this.list.has(t)){const e=new i(this);return this.list.has(t)||this.add(t,e),e}return this.list.get(t)}init(){this.enabled=!0,this._clock.start(),this.update(),this.onInit.trigger()}dispose(){this.enabled=!1;for(const[i,t]of this.list)t.enabled=!1,t.isDisposeable()&&t.dispose();this._clock.stop(),this.onDisposed.trigger(),this.onDisposed.reset()}static setupBVH(){b.BufferGeometry.prototype.computeBoundsTree=Ha,b.BufferGeometry.prototype.disposeBoundsTree=Wa,b.Mesh.prototype.raycast=ka}};C(Rs,"release","2.3.7");let Li=Rs;class Hr extends Vs{constructor(){super(...arguments);C(this,"meshes",new Set);C(this,"onAfterUpdate",new j);C(this,"onBeforeUpdate",new j);C(this,"onDisposed",new j);C(this,"isDisposing",!1);C(this,"enabled",!0);C(this,"uuid",Kt.create());C(this,"name");C(this,"_scene");C(this,"_camera");C(this,"_renderer",null)}get scene(){if(!this._scene)throw new Error("No scene initialized!");return this._scene}set scene(t){this._scene=t,t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"})}get camera(){if(!this._camera)throw new Error("No camera initialized!");return this._camera}set camera(t){this._camera=t,t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"})}get renderer(){return this._renderer}set renderer(t){this._renderer=t,t&&(t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"}))}update(t){this.enabled&&(!this._scene||!this._camera||(this.scene.currentWorld=this,this.camera.currentWorld=this,this.renderer&&(this.renderer.currentWorld=this),this.onBeforeUpdate.trigger(),this.scene.isUpdateable()&&this.scene.update(t),this.camera.isUpdateable()&&this.camera.update(t),this.renderer&&this.renderer.update(t),this.onAfterUpdate.trigger()))}dispose(t=!0){if(this.enabled=!1,this.isDisposing=!0,this.scene.onWorldChanged.trigger({world:this,action:"removed"}),this.camera.onWorldChanged.trigger({world:this,action:"removed"}),this.renderer&&this.renderer.onWorldChanged.trigger({world:this,action:"removed"}),t){const s=this.components.get(pe);this.scene.dispose(),this.camera.isDisposeable()&&this.camera.dispose(),this.renderer&&this.renderer.dispose();for(const n of this.meshes)s.destroy(n);this.meshes.clear()}this._scene=null,this._camera=null,this._renderer=null,this.components.get(Pi).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class Ne{constructor(i,t,e,s){C(this,"_component");C(this,"name");C(this,"uuid");this._component=i,this.name=e,this.uuid=s??Kt.create(),t.get(Oe).list.set(this.uuid,this)}get controls(){const i={};for(const t in this._config){const e=this._config[t];i[t]=this.copyEntry(e)}return i}copyEntry(i){if(i.type==="Boolean"){const t=i;return{type:t.type,value:t.value}}if(i.type==="Color"){const t=i;return{type:t.type,value:t.value.clone()}}if(i.type==="Text"){const t=i;return{type:t.type,value:t.value}}if(i.type==="Number"){const t=i;return{type:t.type,value:t.value,min:t.min,max:t.max,interpolable:t.interpolable}}if(i.type==="Select"){const t=i;return{type:t.type,value:t.value,multiple:t.multiple,options:new Set(t.options)}}if(i.type==="Vector3"){const t=i;return{type:t.type,value:t.value.clone()}}if(i.type==="TextSet"){const t=i;return{type:t.type,value:new Set(t.value)}}if(i.type==="None"){const t=i;return{type:t.type,value:t.value}}throw new Error("Invalid entry!")}}const gs=class gs extends mt{constructor(t){super(t);C(this,"list",new Qt);C(this,"enabled",!0);t.add(gs.uuid,this)}};C(gs,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let Oe=gs;class sc{constructor(i,t){C(this,"_list");C(this,"_scene");this._list=i,this._scene=t}get color(){return this._list.directionalLight.color.value}set color(i){this._list.directionalLight.color.value=i;for(const[,t]of this._scene.directionalLights)t.color.copy(i)}get intensity(){return this._list.directionalLight.intensity.value}set intensity(i){this._list.directionalLight.intensity.value=i;for(const[,t]of this._scene.directionalLights)t.intensity=i}get position(){return this._list.directionalLight.position.value.clone()}set position(i){this._list.directionalLight.position.value=i;for(const[,t]of this._scene.directionalLights)t.position.copy(i)}}class nc{constructor(i,t){C(this,"_list");C(this,"_scene");this._list=i,this._scene=t}get color(){return this._list.ambientLight.color.value}set color(i){this._list.ambientLight.color.value=i;for(const[,t]of this._scene.ambientLights)t.color.copy(i)}get intensity(){return this._list.ambientLight.intensity.value}set intensity(i){this._list.ambientLight.intensity.value=i;for(const[,t]of this._scene.ambientLights)t.intensity=i}}class Wr extends Ne{constructor(){super(...arguments);C(this,"_config",{backgroundColor:{value:new b.Color,type:"Color"},ambientLight:{color:{type:"Color",value:new b.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2}},directionalLight:{color:{type:"Color",value:new b.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2},position:{type:"Vector3",value:new b.Vector3}}});C(this,"ambientLight",new nc(this._config,this._component));C(this,"directionalLight",new sc(this._config,this._component))}get backgroundColor(){return this._config.backgroundColor.value}set backgroundColor(t){this._config.backgroundColor.value=t,this._component.three.background=t}}class Xr extends zr{constructor(t){super(t);C(this,"onSetup",new j);C(this,"isSetup",!1);C(this,"three");C(this,"config",new Wr(this,this.components,"Scene"));C(this,"_defaultConfig",{backgroundColor:new b.Color(2107698),directionalLight:{color:new b.Color("white"),intensity:1.5,position:new b.Vector3(5,10,3)},ambientLight:{color:new b.Color("white"),intensity:1}});this.three=new b.Scene,this.three.background=new b.Color(2107698)}setup(t){const e={...this._defaultConfig,...t};this.config.backgroundColor=e.backgroundColor;const s=e.ambientLight;this.config.ambientLight.color=s.color,this.config.ambientLight.intensity=s.intensity;const n=e.directionalLight;this.config.directionalLight.color=n.color,this.config.directionalLight.intensity=n.intensity,this.config.directionalLight.position=n.position,this.deleteAllLights();const{color:r,intensity:o}=this.config.directionalLight,a=new b.DirectionalLight(r,o);a.position.copy(n.position);const{color:l,intensity:h}=this.config.directionalLight,f=new b.AmbientLight(l,h);this.three.add(a,f),this.directionalLights.set(a.uuid,a),this.ambientLights.set(f.uuid,f),this.isSetup=!0,this.onSetup.trigger()}dispose(){super.dispose(),this.components.get(Oe).list.delete(this.config.uuid)}}class rc extends Gr{constructor(t,e,s){super(t);C(this,"enabled",!0);C(this,"container");C(this,"three");C(this,"_canvas");C(this,"_parameters");C(this,"_resizeObserver",null);C(this,"onContainerUpdated",new j);C(this,"_resizing",!1);C(this,"resize",t=>{if(this._resizing)return;this._resizing=!0,this.onContainerUpdated.trigger();const e=t?t.x:this.container.clientWidth,s=t?t.y:this.container.clientHeight;this.three.setSize(e,s),this.onResize.trigger(new b.Vector2(e,s)),this._resizing=!1});C(this,"resizeEvent",()=>{this.resize()});C(this,"onContextLost",t=>{t.preventDefault(),this.enabled=!1});C(this,"onContextBack",()=>{this.three.setRenderTarget(null),this.three.dispose(),this.three=new b.WebGLRenderer({canvas:this._canvas,antialias:!0,alpha:!0,...this._parameters}),this.enabled=!0});this.container=e,this._parameters=s,this.three=new b.WebGLRenderer({antialias:!0,alpha:!0,...s}),this.three.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.setupRenderer(),this.setupEvents(!0),this.resize(),this._canvas=this.three.domElement;const n=this.three.getContext(),{canvas:r}=n;r.addEventListener("webglcontextlost",this.onContextLost,!1),r.addEventListener("webglcontextrestored",this.onContextBack,!1)}update(){if(!this.enabled||!this.currentWorld)return;this.onBeforeUpdate.trigger(this);const t=this.currentWorld.scene.three,e=this.currentWorld.camera.three;this.three.render(t,e),this.onAfterUpdate.trigger(this)}dispose(){this.enabled=!1,this.setupEvents(!1),this.three.domElement.remove(),this.three.forceContextLoss(),this.three.dispose(),this.onResize.reset(),this.onAfterUpdate.reset(),this.onBeforeUpdate.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}getSize(){return new b.Vector2(this.three.domElement.clientWidth,this.three.domElement.clientHeight)}setupEvents(t){const e=this.three.domElement.parentElement;if(!e)throw new Error("This renderer needs to have an HTML container!");this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),window.removeEventListener("resize",this.resizeEvent),t&&(this._resizeObserver=new ResizeObserver(this.resizeEvent),this._resizeObserver.observe(e),window.addEventListener("resize",this.resizeEvent))}setupRenderer(){this.three.localClippingEnabled=!0,this.container&&this.container.appendChild(this.three.domElement),this.onContainerUpdated.trigger()}}/*!
6
6
  * camera-controls
7
7
  * https://github.com/yomotsu/camera-controls
8
8
  * (c) 2017 @yomotsu
@@ -64,7 +64,7 @@ void main() {
64
64
  }
65
65
  postMessage({ colors });
66
66
  });
67
- `,r=new Blob([n],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(r)),this.worker.addEventListener("message",this.handleWorkerMessage)}dispose(){this.enabled=!1,this.onDistanceComputed.reset(),this.worker.terminate(),this.renderer.forceContextLoss(),this.renderer.dispose(),this.tempRT.dispose(),this.resultRT.dispose();const i=[...this.scene.children];this.excludedObjects.clear();for(const t of i)t.removeFromParent();this._postQuad.geometry.dispose(),this._postQuad.removeFromParent(),this._buffer=null,this.onDisposed.reset()}}class dc extends Xr{constructor(){super(...arguments);C(this,"_distanceRenderer");C(this,"autoBias",!0);C(this,"_defaultShadowConfig",{cascade:1,resolution:512});C(this,"_lightsWithShadow",new Map);C(this,"_isComputingShadows",!1);C(this,"_shadowsEnabled",!0);C(this,"_bias",0);C(this,"recomputeShadows",t=>{if(!this._shadowsEnabled)return;if(this.autoBias&&(this.bias=t/-1e5),t*=1.5,!this.currentWorld)throw new Error("A world needs to be assigned to the scene before computing shadows!");if(!this._lightsWithShadow.size)throw new Error("No shadows found!");const s=this.currentWorld.camera.three;if(!(s instanceof b.PerspectiveCamera)&&!(s instanceof b.OrthographicCamera))throw new Error("Invalid camera type!");const n=new b.Vector3;s.getWorldDirection(n);let r=t;const o=new b.Vector3;o.copy(this.config.directionalLight.position),o.normalize();for(const[a,l]of this._lightsWithShadow){const h=this.directionalLights.get(l);if(!h)throw new Error("Light not found.");const f=new b.Vector3;f.copy(n);const I=a===this._lightsWithShadow.size-1,u=I?r/2:r*2/3;f.multiplyScalar(u),f.add(s.position);const d=r-u,E=new b.Vector3;E.copy(o),E.multiplyScalar(d),h.target.position.copy(f),h.position.copy(f),h.position.add(E),h.shadow.camera.right=d,h.shadow.camera.left=-d,h.shadow.camera.top=d,h.shadow.camera.bottom=-d,h.shadow.camera.far=d*2,h.shadow.camera.updateProjectionMatrix(),h.shadow.camera.updateMatrix(),I||(r/=3)}this._isComputingShadows=!1})}get bias(){return this._bias}set bias(t){this._bias=t;for(const[,e]of this._lightsWithShadow){const s=this.directionalLights.get(e);s&&(s.shadow.bias=t)}}get shadowsEnabled(){return this._shadowsEnabled}set shadowsEnabled(t){this._shadowsEnabled=t;for(const[,e]of this.directionalLights)e.castShadow=t}get distanceRenderer(){if(!this._distanceRenderer)throw new Error("You must set up this component before accessing the distance renderer!");return this._distanceRenderer}setup(t){super.setup(t);const e={...this._defaultConfig,...this._defaultShadowConfig,...t};if(e.cascade<=0)throw new Error("Config.shadows.cascade must be a natural number greater than 0!");if(e.cascade>1)throw new Error("Multiple shadows not supported yet!");if(!this.currentWorld)throw new Error("A world needs to be assigned to the scene before setting it up!");for(const[,s]of this.directionalLights)s.target.removeFromParent(),s.removeFromParent(),s.dispose();this.directionalLights.clear(),this._distanceRenderer||(this._distanceRenderer=new Ic(this.components,this.currentWorld),this._distanceRenderer.onDistanceComputed.add(this.recomputeShadows)),this._lightsWithShadow.clear();for(let s=0;s<e.cascade;s++){const n=new b.DirectionalLight;n.intensity=this.config.directionalLight.intensity,n.color=this.config.directionalLight.color,n.position.copy(this.config.directionalLight.position),n.shadow.mapSize.width=e.resolution,n.shadow.mapSize.height=e.resolution,this.three.add(n,n.target),this.directionalLights.set(n.uuid,n),this._lightsWithShadow.set(s,n.uuid),n.castShadow=!0,n.shadow.bias=this._bias}}dispose(){super.dispose(),this._distanceRenderer&&this._distanceRenderer.dispose(),this._lightsWithShadow.clear()}async updateShadows(){this._isComputingShadows||!this._shadowsEnabled||(this._isComputingShadows=!0,await this.distanceRenderer.compute())}}class Qr{constructor(i){C(this,"_event");C(this,"_position",new b.Vector2);C(this,"onDisposed",new j);C(this,"updateMouseInfo",i=>{this._event=i});this.dom=i,this.setupEvents(!0)}get position(){if(this._event){const i=this.dom.getBoundingClientRect();this._position.x=this.getPositionX(i,this._event),this._position.y=this.getPositionY(i,this._event)}return this._position}dispose(){this.setupEvents(!1),this.onDisposed.trigger(),this.onDisposed.reset()}getPositionY(i,t){return-((t.clientY-i.top)/(i.bottom-i.top))*2+1}getPositionX(i,t){return(t.clientX-i.left)/(i.right-i.left)*2-1}setupEvents(i){i?this.dom.addEventListener("pointermove",this.updateMouseInfo):this.dom.removeEventListener("pointermove",this.updateMouseInfo)}}class Kr{constructor(i,t){C(this,"enabled",!0);C(this,"components");C(this,"onDisposed",new j);C(this,"mouse");C(this,"three",new b.Raycaster);C(this,"world");const e=t.renderer;if(!e)throw new Error("A renderer is needed for the raycaster to work!");this.world=t,this.mouse=new Qr(e.three.domElement),this.components=i}dispose(){this.mouse.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}castRay(i=Array.from(this.world.meshes)){if(!this.world)throw new Error("A world is needed to cast rays!");const t=this.world.camera.three;return this.three.setFromCamera(this.mouse.position,t),this.intersect(i)}castRayFromVector(i,t,e=Array.from(this.world.meshes)){return this.three.set(i,t),this.intersect(e)}intersect(i=Array.from(this.world.meshes)){const t=this.three.intersectObjects(i),e=this.filterClippingPlanes(t);return e.length>0?e[0]:null}filterClippingPlanes(i){if(!this.world.renderer)throw new Error("Renderer not found!");const t=this.world.renderer.three;if(!t.clippingPlanes)return i;const e=t.clippingPlanes;return i.length<=0||!e||(e==null?void 0:e.length)<=0?i:i.filter(s=>e.every(n=>n.distanceToPoint(s.point)>0))}}const Fs=class Fs extends mt{constructor(t){super(t);C(this,"enabled",!0);C(this,"list",new Map);C(this,"onDisposed",new j);t.add(Fs.uuid,this)}get(t){if(this.list.has(t.uuid))return this.list.get(t.uuid);const e=new Kr(this.components,t);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}};C(Fs,"uuid","d5d8bdf0-db25-4952-b951-b643af207ace");let be=Fs;class Jr extends Ne{constructor(){super(...arguments);C(this,"_config",{visible:{value:!0,type:"Boolean"},color:{value:new b.Color,type:"Color"},primarySize:{type:"Number",interpolable:!0,value:1,min:0,max:1e3},secondarySize:{type:"Number",interpolable:!0,value:10,min:0,max:1e3},distance:{type:"Number",interpolable:!0,value:500,min:0,max:500}})}get visible(){return this._config.visible.value}set visible(t){this._config.visible.value=t,this._component.visible=t}get color(){return this._config.color.value}set color(t){this._config.color.value=t,this._component.material.uniforms.uColor.value=t,this._component.material.uniformsNeedUpdate=!0}get primarySize(){return this._config.primarySize.value}set primarySize(t){this._config.primarySize.value=t,this._component.material.uniforms.uSize1.value=t,this._component.material.uniformsNeedUpdate=!0}get secondarySize(){return this._config.secondarySize.value}set secondarySize(t){this._config.secondarySize.value=t,this._component.material.uniforms.uSize2.value=t,this._component.material.uniformsNeedUpdate=!0}get distance(){return this._config.distance.value}set distance(t){this._config.distance.value=t,this._component.material.uniforms.uDistance.value=t,this._component.material.uniformsNeedUpdate=!0}}class to{constructor(i,t){C(this,"onDisposed",new j);C(this,"onSetup",new j);C(this,"isSetup",!1);C(this,"world");C(this,"components");C(this,"config");C(this,"_defaultConfig",{visible:!0,color:new b.Color(12303291),primarySize:1,secondarySize:10,distance:500});C(this,"three");C(this,"_fade",3);C(this,"updateZoom",()=>{this.world.camera instanceof Ke&&(this.material.uniforms.uZoom.value=this.world.camera.three.zoom)});this.world=t;const{color:e,primarySize:s,secondarySize:n,distance:r}=this._defaultConfig;this.components=i,this.config=new Jr(this,this.components,"Grid");const o=new b.PlaneGeometry(2,2,1,1),a=new b.ShaderMaterial({side:b.DoubleSide,uniforms:{uSize1:{value:s},uSize2:{value:n},uColor:{value:e},uDistance:{value:r},uFade:{value:this._fade},uZoom:{value:1}},transparent:!0,vertexShader:`
67
+ `,r=new Blob([n],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(r)),this.worker.addEventListener("message",this.handleWorkerMessage)}dispose(){this.enabled=!1,this.onDistanceComputed.reset(),this.worker.terminate(),this.renderer.forceContextLoss(),this.renderer.dispose(),this.tempRT.dispose(),this.resultRT.dispose();const i=[...this.scene.children];this.excludedObjects.clear();for(const t of i)t.removeFromParent();this._postQuad.geometry.dispose(),this._postQuad.removeFromParent(),this._buffer=null,this.onDisposed.reset()}}class dc extends Xr{constructor(){super(...arguments);C(this,"_distanceRenderer");C(this,"autoBias",!0);C(this,"_defaultShadowConfig",{cascade:1,resolution:512});C(this,"_lightsWithShadow",new Map);C(this,"_isComputingShadows",!1);C(this,"_shadowsEnabled",!0);C(this,"_bias",0);C(this,"recomputeShadows",t=>{if(!this._shadowsEnabled)return;if(this.autoBias&&(this.bias=t/-1e5),t*=1.5,!this.currentWorld)throw new Error("A world needs to be assigned to the scene before computing shadows!");if(!this._lightsWithShadow.size)throw new Error("No shadows found!");const s=this.currentWorld.camera.three;if(!(s instanceof b.PerspectiveCamera)&&!(s instanceof b.OrthographicCamera))throw new Error("Invalid camera type!");const n=new b.Vector3;s.getWorldDirection(n);let r=t;const o=new b.Vector3;o.copy(this.config.directionalLight.position),o.normalize();for(const[a,l]of this._lightsWithShadow){const h=this.directionalLights.get(l);if(!h)throw new Error("Light not found.");const f=new b.Vector3;f.copy(n);const I=a===this._lightsWithShadow.size-1,u=I?r/2:r*2/3;f.multiplyScalar(u),f.add(s.position);const d=r-u,E=new b.Vector3;E.copy(o),E.multiplyScalar(d),h.target.position.copy(f),h.position.copy(f),h.position.add(E),h.shadow.camera.right=d,h.shadow.camera.left=-d,h.shadow.camera.top=d,h.shadow.camera.bottom=-d,h.shadow.camera.far=d*2,h.shadow.camera.updateProjectionMatrix(),h.shadow.camera.updateMatrix(),I||(r/=3)}this._isComputingShadows=!1})}get bias(){return this._bias}set bias(t){this._bias=t;for(const[,e]of this._lightsWithShadow){const s=this.directionalLights.get(e);s&&(s.shadow.bias=t)}}get shadowsEnabled(){return this._shadowsEnabled}set shadowsEnabled(t){this._shadowsEnabled=t;for(const[,e]of this.directionalLights)e.castShadow=t}get distanceRenderer(){if(!this._distanceRenderer)throw new Error("You must set up this component before accessing the distance renderer!");return this._distanceRenderer}setup(t){super.setup(t);const e={...this._defaultConfig,...this._defaultShadowConfig,...t};if(e.cascade<=0)throw new Error("Config.shadows.cascade must be a natural number greater than 0!");if(e.cascade>1)throw new Error("Multiple shadows not supported yet!");if(!this.currentWorld)throw new Error("A world needs to be assigned to the scene before setting it up!");for(const[,s]of this.directionalLights)s.target.removeFromParent(),s.removeFromParent(),s.dispose();this.directionalLights.clear(),this._distanceRenderer||(this._distanceRenderer=new Ic(this.components,this.currentWorld),this._distanceRenderer.onDistanceComputed.add(this.recomputeShadows)),this._lightsWithShadow.clear();for(let s=0;s<e.cascade;s++){const n=new b.DirectionalLight;n.intensity=this.config.directionalLight.intensity,n.color=this.config.directionalLight.color,n.position.copy(this.config.directionalLight.position),n.shadow.mapSize.width=e.resolution,n.shadow.mapSize.height=e.resolution,this.three.add(n,n.target),this.directionalLights.set(n.uuid,n),this._lightsWithShadow.set(s,n.uuid),n.castShadow=!0,n.shadow.bias=this._bias}}dispose(){super.dispose(),this._distanceRenderer&&this._distanceRenderer.dispose(),this._lightsWithShadow.clear()}async updateShadows(){this._isComputingShadows||!this._shadowsEnabled||(this._isComputingShadows=!0,await this.distanceRenderer.compute())}}class Qr{constructor(i){C(this,"_event");C(this,"_position",new b.Vector2);C(this,"onDisposed",new j);C(this,"updateMouseInfo",i=>{this._event=i});this.dom=i,this.setupEvents(!0)}get position(){if(this._event){const i=this.dom.getBoundingClientRect();this._position.x=this.getPositionX(i,this._event),this._position.y=this.getPositionY(i,this._event)}return this._position}dispose(){this.setupEvents(!1),this.onDisposed.trigger(),this.onDisposed.reset()}getPositionY(i,t){return-((this.getDataObject(t).clientY-i.top)/(i.bottom-i.top))*2+1}getPositionX(i,t){return(this.getDataObject(t).clientX-i.left)/(i.right-i.left)*2-1}getDataObject(i){return i instanceof MouseEvent?i:i.touches[0]}setupEvents(i){i?(this.dom.addEventListener("pointermove",this.updateMouseInfo),this.dom.addEventListener("touchstart",this.updateMouseInfo)):(this.dom.removeEventListener("pointermove",this.updateMouseInfo),this.dom.removeEventListener("touchstart",this.updateMouseInfo))}}class Kr{constructor(i,t){C(this,"enabled",!0);C(this,"components");C(this,"onDisposed",new j);C(this,"mouse");C(this,"three",new b.Raycaster);C(this,"world");const e=t.renderer;if(!e)throw new Error("A renderer is needed for the raycaster to work!");this.world=t,this.mouse=new Qr(e.three.domElement),this.components=i}dispose(){this.mouse.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}castRay(i=Array.from(this.world.meshes)){if(!this.world)throw new Error("A world is needed to cast rays!");const t=this.world.camera.three;return this.three.setFromCamera(this.mouse.position,t),this.intersect(i)}castRayFromVector(i,t,e=Array.from(this.world.meshes)){return this.three.set(i,t),this.intersect(e)}intersect(i=Array.from(this.world.meshes)){const t=this.three.intersectObjects(i),e=this.filterClippingPlanes(t);return e.length>0?e[0]:null}filterClippingPlanes(i){if(!this.world.renderer)throw new Error("Renderer not found!");const t=this.world.renderer.three;if(!t.clippingPlanes)return i;const e=t.clippingPlanes;return i.length<=0||!e||(e==null?void 0:e.length)<=0?i:i.filter(s=>e.every(n=>n.distanceToPoint(s.point)>0))}}const Fs=class Fs extends mt{constructor(t){super(t);C(this,"enabled",!0);C(this,"list",new Map);C(this,"onDisposed",new j);t.add(Fs.uuid,this)}get(t){if(this.list.has(t.uuid))return this.list.get(t.uuid);const e=new Kr(this.components,t);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}};C(Fs,"uuid","d5d8bdf0-db25-4952-b951-b643af207ace");let be=Fs;class Jr extends Ne{constructor(){super(...arguments);C(this,"_config",{visible:{value:!0,type:"Boolean"},color:{value:new b.Color,type:"Color"},primarySize:{type:"Number",interpolable:!0,value:1,min:0,max:1e3},secondarySize:{type:"Number",interpolable:!0,value:10,min:0,max:1e3},distance:{type:"Number",interpolable:!0,value:500,min:0,max:500}})}get visible(){return this._config.visible.value}set visible(t){this._config.visible.value=t,this._component.visible=t}get color(){return this._config.color.value}set color(t){this._config.color.value=t,this._component.material.uniforms.uColor.value=t,this._component.material.uniformsNeedUpdate=!0}get primarySize(){return this._config.primarySize.value}set primarySize(t){this._config.primarySize.value=t,this._component.material.uniforms.uSize1.value=t,this._component.material.uniformsNeedUpdate=!0}get secondarySize(){return this._config.secondarySize.value}set secondarySize(t){this._config.secondarySize.value=t,this._component.material.uniforms.uSize2.value=t,this._component.material.uniformsNeedUpdate=!0}get distance(){return this._config.distance.value}set distance(t){this._config.distance.value=t,this._component.material.uniforms.uDistance.value=t,this._component.material.uniformsNeedUpdate=!0}}class to{constructor(i,t){C(this,"onDisposed",new j);C(this,"onSetup",new j);C(this,"isSetup",!1);C(this,"world");C(this,"components");C(this,"config");C(this,"_defaultConfig",{visible:!0,color:new b.Color(12303291),primarySize:1,secondarySize:10,distance:500});C(this,"three");C(this,"_fade",3);C(this,"updateZoom",()=>{this.world.camera instanceof Ke&&(this.material.uniforms.uZoom.value=this.world.camera.three.zoom)});this.world=t;const{color:e,primarySize:s,secondarySize:n,distance:r}=this._defaultConfig;this.components=i,this.config=new Jr(this,this.components,"Grid");const o=new b.PlaneGeometry(2,2,1,1),a=new b.ShaderMaterial({side:b.DoubleSide,uniforms:{uSize1:{value:s},uSize2:{value:n},uColor:{value:e},uDistance:{value:r},uFade:{value:this._fade},uZoom:{value:1}},transparent:!0,vertexShader:`
68
68
 
69
69
  varying vec3 worldPosition;
70
70
 
package/dist/index.mjs CHANGED
@@ -3137,7 +3137,7 @@ const Fs = class Fs {
3137
3137
  /**
3138
3138
  * The version of the @thatopen/components library.
3139
3139
  */
3140
- C(Fs, "release", "2.3.6");
3140
+ C(Fs, "release", "2.3.7");
3141
3141
  let Cs = Fs;
3142
3142
  class Qa extends xn {
3143
3143
  constructor() {
@@ -5979,13 +5979,16 @@ class fc {
5979
5979
  this.setupEvents(!1), this.onDisposed.trigger(), this.onDisposed.reset();
5980
5980
  }
5981
5981
  getPositionY(i, t) {
5982
- return -((t.clientY - i.top) / (i.bottom - i.top)) * 2 + 1;
5982
+ return -((this.getDataObject(t).clientY - i.top) / (i.bottom - i.top)) * 2 + 1;
5983
5983
  }
5984
5984
  getPositionX(i, t) {
5985
- return (t.clientX - i.left) / (i.right - i.left) * 2 - 1;
5985
+ return (this.getDataObject(t).clientX - i.left) / (i.right - i.left) * 2 - 1;
5986
+ }
5987
+ getDataObject(i) {
5988
+ return i instanceof MouseEvent ? i : i.touches[0];
5986
5989
  }
5987
5990
  setupEvents(i) {
5988
- i ? this.dom.addEventListener("pointermove", this.updateMouseInfo) : this.dom.removeEventListener("pointermove", this.updateMouseInfo);
5991
+ i ? (this.dom.addEventListener("pointermove", this.updateMouseInfo), this.dom.addEventListener("touchstart", this.updateMouseInfo)) : (this.dom.removeEventListener("pointermove", this.updateMouseInfo), this.dom.removeEventListener("touchstart", this.updateMouseInfo));
5989
5992
  }
5990
5993
  }
5991
5994
  class Ic {