@maucwerk/glimmer 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist/environment/sun.d.ts +5 -0
- package/dist/vite/glimmer.mjs +14 -1
- package/dist/vite/glimmer.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -847,7 +847,7 @@ Access-Control-Allow-Methods: GET
|
|
|
847
847
|
## Package Structure
|
|
848
848
|
|
|
849
849
|
```
|
|
850
|
-
@maucwerk/glimmer@1.1.
|
|
850
|
+
@maucwerk/glimmer@1.1.1
|
|
851
851
|
├── dist/
|
|
852
852
|
│ ├── index.d.ts # Main TypeScript declarations
|
|
853
853
|
│ ├── vite/
|
|
@@ -862,7 +862,11 @@ The package supports both ESM and CommonJS with complete TypeScript declarations
|
|
|
862
862
|
|
|
863
863
|
## Version History
|
|
864
864
|
|
|
865
|
-
### v1.1.
|
|
865
|
+
### v1.1.1 (Current)
|
|
866
|
+
|
|
867
|
+
- ✅ Sky dome sun disc follows the light (solar, explicit or HDR-inferred position)
|
|
868
|
+
|
|
869
|
+
### v1.1.0
|
|
866
870
|
|
|
867
871
|
- ✅ **Solar sun** - True sun position from latitude/longitude/datetime via SunCalc; intensity dims and color warms toward the horizon, off at night
|
|
868
872
|
- ✅ Sun keeps its configured position when no HDR environment is loaded
|
|
@@ -13,6 +13,11 @@ export declare class Sun {
|
|
|
13
13
|
private environment;
|
|
14
14
|
constructor(viewer: Viewer, settings: Settings, environment: Environment, model_manager: ModelManager);
|
|
15
15
|
update(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Point the procedural sky dome at the same sun the light uses, so the
|
|
18
|
+
* visible sun disc and the lighting direction stay in agreement.
|
|
19
|
+
*/
|
|
20
|
+
private sync_sky;
|
|
16
21
|
sun_fit_object(fit_object?: THREE.Object3D): void;
|
|
17
22
|
sun_fit_shadow(): void;
|
|
18
23
|
/**
|
package/dist/vite/glimmer.mjs
CHANGED
|
@@ -4891,9 +4891,22 @@ class gl {
|
|
|
4891
4891
|
const t = this._infer_sun_position_from_env_map();
|
|
4892
4892
|
t && (j.debug("Inferred Sun position from env map:", t), this.sun_settings.position = [t.x, t.y, t.z]);
|
|
4893
4893
|
}
|
|
4894
|
-
this.sun_create(e ?? void 0);
|
|
4894
|
+
this.sun_create(e ?? void 0), this.sun_settings && this.sync_sky((e == null ? void 0 : e.position) ?? this.sun_settings.position);
|
|
4895
4895
|
});
|
|
4896
4896
|
}
|
|
4897
|
+
/**
|
|
4898
|
+
* Point the procedural sky dome at the same sun the light uses, so the
|
|
4899
|
+
* visible sun disc and the lighting direction stay in agreement.
|
|
4900
|
+
*/
|
|
4901
|
+
sync_sky(e) {
|
|
4902
|
+
if (!e) return;
|
|
4903
|
+
const t = this.environment.sky;
|
|
4904
|
+
if (!t) return;
|
|
4905
|
+
const n = t.material.uniforms;
|
|
4906
|
+
n != null && n.sunPosition && n.sunPosition.value.copy(
|
|
4907
|
+
new p.Vector3(e[0], e[1], e[2]).normalize()
|
|
4908
|
+
);
|
|
4909
|
+
}
|
|
4897
4910
|
sun_fit_object(e = this.scene) {
|
|
4898
4911
|
const t = lr(e);
|
|
4899
4912
|
let n = new p.Vector3(0, 1, 0).normalize();
|
package/dist/vite/glimmer.umd.js
CHANGED
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
#include <tonemapping_fragment>
|
|
156
156
|
#include <colorspace_fragment>
|
|
157
157
|
|
|
158
|
-
}`};class ra extends u.Scene{constructor(){super();const e=new u.BoxGeometry;e.deleteAttribute("uv");const t=new u.MeshStandardMaterial({side:u.BackSide}),n=new u.MeshStandardMaterial,s=new u.PointLight(16777215,900,28,2);s.position.set(.418,16.199,.3),this.add(s);const i=new u.Mesh(e,t);i.position.set(-.757,13.219,.717),i.scale.set(31.713,28.305,28.591),this.add(i);const o=new u.Mesh(e,n);o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),this.add(o);const a=new u.Mesh(e,n);a.position.set(-5.607,-.754,-.758),a.rotation.set(0,.994,0),a.scale.set(1.97,1.534,3.955),this.add(a);const c=new u.Mesh(e,n);c.position.set(6.167,.857,7.803),c.rotation.set(0,.561,0),c.scale.set(3.927,6.285,3.687),this.add(c);const l=new u.Mesh(e,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);const d=new u.Mesh(e,n);d.position.set(2.291,-.756,-2.621),d.rotation.set(0,-.286,0),d.scale.set(1.546,1.552,1.496),this.add(d);const h=new u.Mesh(e,n);h.position.set(-2.193,-.369,-5.547),h.rotation.set(0,.516,0),h.scale.set(3.875,3.487,2.986),this.add(h);const f=new u.Mesh(e,Ot(50));f.position.set(-16.116,14.37,8.208),f.scale.set(.1,2.428,2.739),this.add(f);const p=new u.Mesh(e,Ot(50));p.position.set(-16.109,18.021,-8.207),p.scale.set(.1,2.425,2.751),this.add(p);const y=new u.Mesh(e,Ot(17));y.position.set(14.904,12.198,-1.832),y.scale.set(.15,4.265,6.331),this.add(y);const v=new u.Mesh(e,Ot(43));v.position.set(-.462,8.89,14.52),v.scale.set(4.38,5.441,.088),this.add(v);const b=new u.Mesh(e,Ot(20));b.position.set(3.235,11.486,-12.541),b.scale.set(2.5,2,.1),this.add(b);const w=new u.Mesh(e,Ot(100));w.position.set(0,20,0),w.scale.set(1,.1,1),this.add(w)}dispose(){const e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(const t of e)t.dispose()}}function Ot(r){const e=new u.MeshBasicMaterial;return e.color.setScalar(r),e}class ve extends Error{constructor(e,t,n,s){super(e),this.component=t,this.code=n,this.details=s,this.name="GlimmerError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ve)}toJSON(){return{name:this.name,message:this.message,component:this.component,code:this.code,details:this.details,stack:this.stack}}toString(){return`${this.name} [${this.component}:${this.code}]: ${this.message}`}}const Le={INITIALIZATION_FAILED:"INITIALIZATION_FAILED",HDR_LOAD_FAILED:"HDR_LOAD_FAILED",ENVIRONMENT_UPDATE_FAILED:"ENVIRONMENT_UPDATE_FAILED",MODEL_LOAD_FAILED:"MODEL_LOAD_FAILED",MODEL_NOT_FOUND:"MODEL_NOT_FOUND",INVALID_STORY_JSON:"INVALID_STORY_JSON",INVALID_SLIDE_INDEX:"INVALID_SLIDE_INDEX"};class mi extends EventTarget{constructor(t,n){super();g(this,"settings");g(this,"renderer");g(this,"scene");g(this,"viewer");g(this,"ready");g(this,"texture",null);g(this,"ambient",null);g(this,"room",null);g(this,"env_map",null);g(this,"sky",null);g(this,"Sun",null);this.viewer=t,this.settings=n,this.renderer=t.renderer,this.scene=t.scene,this.settings.addEventListener("update",s=>{const i=s.detail;this.update(i.environment)}),this.ready=this.update(this.settings.get("environment"))}async update(t){V.info("Updating environment settings:",t);const{type:n,url:s}=t;this.dispatchEvent(new CustomEvent("loading",{detail:{type:n,url:s}}));try{if(n==="hdr"||n==="ultra"){if(this.clear_environment(),!s)return;await this.set_hdr_environment(s,n==="ultra")}else n==="sky"?(this.clear_environment(),this.set_sky_environment()):n==="room"?(this.clear_environment(),this.set_room_environment()):n==="none"?(this.clear_environment(),this.set_color_environment()):this.clear_environment();this.dispatchEvent(new CustomEvent("loaded",{detail:{type:n,url:s}}))}catch(i){V.error("Error updating environment:",i),this.clear_environment(),this.set_color_environment();const o=new ve(`Failed to update environment: ${i instanceof Error?i.message:i}`,"Environment",Le.ENVIRONMENT_UPDATE_FAILED,{type:n,url:s,error:i});throw this.dispatchEvent(new CustomEvent("error",{detail:{error:o}})),o}}clear_environment(){this.scene.background=null,this.scene.environment=null,this.sky=null,this.texture=null}set_sky_environment(){const t=new Dn;t.scale.setScalar(45e4);const n=_.MathUtils.degToRad(90),s=_.MathUtils.degToRad(180),i=new _.Vector3().setFromSphericalCoords(1,n,s);t.material.uniforms.sunPosition.value=i,this.sky=t,this.scene.add(this.sky)}set_room_environment(){const t=new ra,s=new _.PMREMGenerator(this.renderer).fromScene(t).texture;this.scene.background=s,this.scene.environment=s}set_color_environment(t=16777215){this.scene.background=new _.Color(t)}async set_hdr_environment(t,n=!1){const s=new _.PMREMGenerator(this.renderer);s.compileEquirectangularShader();const i=n?new ia:new na;await new Promise((o,a)=>{i.load(t,c=>{try{this.texture=c;const l=s.fromEquirectangular(c).texture;this.scene.background=l,this.scene.environment=l,c.dispose(),s.dispose(),this.dispatchEvent(new CustomEvent("textureloaded",{detail:{texture:c}})),this.settings.dispatchEvent(new CustomEvent("environmentTextureLoaded",{detail:{texture:c}})),o()}catch(l){a(l)}},void 0,c=>{V.error("Error loading HDR texture:",c),a(new ve(`Failed to load HDR texture from ${t}`,"Environment",Le.HDR_LOAD_FAILED,{url:t,ultra:n,error:c}))})})}set_ambient_lighting(t=14544639,n=2){this.ambient=new _.AmbientLight(t,n),this.scene.add(this.ambient)}dispose(){var t,n;this.clear_environment(),this.ambient&&(this.scene.remove(this.ambient),(n=(t=this.ambient).dispose)==null||n.call(t),this.ambient=null),this.env_map&&(this.env_map.dispose(),this.env_map=null),this.texture&&(this.texture.dispose(),this.texture=null),this.sky&&(this.scene.remove(this.sky),this.sky=null)}}function _i(r){const t=new _.Box3().setFromObject(r).getSize(new _.Vector3);return Math.max(10,Math.max(t.x,t.y,t.z))}const oa=512,aa=100,ca=30,la=-.001,da=3,ua=16,{PI:ha,sin:Je,cos:Qe,tan:gi,asin:yi,atan2:vi}=Math,Ee=ha/180,fa=1e3*60*60*24,pa=2440588,ma=2451545;function _a(r){return r.valueOf()/fa-.5+pa-ma}function ga(r){const e=2e3+r/365.2425;let t;return e<1920?(t=e-1900,-2.79+t*(1.494119+t*(-.0598939+t*(.0061966-t*197e-6)))):e<1941?(t=e-1920,21.2+t*(.84493+t*(-.0761+t*.0020936))):e<1961?(t=e-1950,29.07+t*(.407+t*(-1/233+t/2547))):e<1986?(t=e-1975,45.45+t*(1.067+t*(-1/260-t/718))):e<2005?(t=e-2e3,63.86+t*(.3345+t*(-.060374+t*(.0017275+t*(651814e-9+t*2373599e-11))))):e<2050?(t=e-2e3,62.92+t*(.32217+t*.005589)):(t=(e-1820)/100,-20+32*t*t-.5628*(2150-e))}function ya(r){return r+ga(r)/86400}function va(r,e,t){return(vi(Je(r),Qe(r)*Je(e)-gi(t)*Qe(e))/Ee+540)%360}function xa(r,e,t){return yi(Je(e)*Je(t)+Qe(e)*Qe(t)*Qe(r))}function ba(r,e){return Ee*(280.46061837+360.98564736629*r)-e}function wa(r){return r<0&&(r=0),2967e-7/gi(r+.00312536/(r+.08901179))}function Aa(r){const e=r/36525,t=Ee*(280.46646+e*(36000.76983+e*3032e-7)),n=Ee*(357.52911+e*(35999.05029-e*1537e-7)),s=Je(n),i=Qe(n),o=Ee*((1.914602-e*(.004817+e*14e-6))*s+(.019993-101e-6*e)*2*s*i+289e-6*s*(3-4*s*s)),a=Ee*(125.04-1934.136*e),c=t+o-Ee*(.00569+.00478*Je(a)),l=Ee*(23.439291-e*(.0130042+e*(16e-8-e*504e-9)))+Ee*.00256*Qe(a);return{ra:vi(Qe(l)*Je(c),Qe(c)),dec:yi(Je(l)*Je(c)),lon:c}}function Sa(r,e,t){const n=Ee*-t,s=Ee*e,i=_a(r),o=Aa(ya(i)),a=ba(i,n)-o.ra,c=xa(a,s,o.dec);return{azimuth:va(a,s,o.dec),altitude:(c+wa(c))/Ee}}const os=Math.PI/180;function Ta(r,e,t){const n=Sa(t,r,e),s=n.altitude,i=(n.azimuth%360+360)%360,o=s*os,a=i*os,c=new _.Vector3(Math.cos(o)*Math.sin(a),Math.sin(o),-Math.cos(o)*Math.cos(a));return{altitude_deg:s,azimuth_deg:i,direction:c}}const Ma=-6;function La(r,e,t){const n=new _.Color(t);if(r<=Ma)return{intensity:0,color:new _.Color(0)};const s=Math.max(0,r),i=Math.sin(Math.min(s,90)*os),o=e*(.12+.88*i),a=1-Math.min(s/30,1),l=new _.Color(16747586).lerp(n,1-a*.85);return{intensity:o,color:l}}class xi{constructor(e,t,n,s){g(this,"viewer");g(this,"scene");g(this,"settings");g(this,"sun_settings");g(this,"model_manager");g(this,"sun",null);g(this,"environment");this.viewer=e,this.scene=e.scene,this.settings=t,this.environment=n,this.model_manager=s,this.sun_settings=this.settings.get("environment").sun,this.settings.addEventListener("update",i=>{const o=i.detail;this.sun_settings=o.environment.sun,this.update()}),this.settings.addEventListener("environmentTextureLoaded",i=>{const o=i.detail.texture;if(this.environment.texture=o,this.sun&&this.sun_settings){const a=this._infer_sun_position_from_env_map();a&&(V.debug("Texture loaded event call; inferred Sun position from env map:",a),this.sun_settings.position=[a.x,a.y,a.z],this.update())}}),this.update()}update(){if(!this.sun_settings){this.sun&&(this.scene.remove(this.sun),this.sun=null);return}this.model_manager.ready.then(()=>{if(!this.sun_settings)return;const e=this.apply_solar();if(!e){const t=this._infer_sun_position_from_env_map();t&&(V.debug("Inferred Sun position from env map:",t),this.sun_settings.position=[t.x,t.y,t.z])}this.sun_create(e??void 0)})}sun_fit_object(e=this.scene){const t=_i(e);let n=new _.Vector3(0,1,0).normalize();n=n.multiplyScalar(t*2),this.sun&&(n=this.sun.position.clone())}sun_fit_shadow(){const e=new _.Object3D;if(!this.model_manager){V.warn("No model manager found.");return}for(const o of this.model_manager.models.values())o.settings.shadow&&e.add(o.group.clone());e.children.length===0&&V.warn("No models with shadows found to fit shadow map."),V.debug("Models in fit_object:",e);const t=_i(e),n=oa,s=Math.ceil(t/aa),i=Math.min(Math.pow(2,Math.ceil(Math.log2(n*s))),this.viewer.renderer.capabilities.maxTextureSize);if(V.debug("Shadow map size:",i),this.sun){this.sun.shadow.mapSize.width=i,this.sun.shadow.mapSize.height=i;const o=ca;this.sun.shadow.camera.left=-(t/2+o),this.sun.shadow.camera.right=t/2+o,this.sun.shadow.camera.top=t/2+o,this.sun.shadow.camera.bottom=-(t/2+o),this.sun.shadow.camera.near=.1,this.sun.shadow.camera.far=t*2,this.sun.shadow.bias=la,this.sun.shadow.radius=da,this.sun.shadow.blurSamples=ua,V.info(`Recreated sun with shadow map size: ${i}x${i}`)}}resolve_solar(){const e=this.sun_settings.solar,t=Ta(e.latitude,e.longitude,new Date(e.datetime)),n=La(t.altitude_deg,this.sun_settings.intensity,this.sun_settings.color),s=t.direction.multiplyScalar(100);let i=0;return n.intensity>0&&(i=+`0x${n.color.getHexString()}`),V.debug(`Solar sun: lat ${e.latitude}, lon ${e.longitude}, alt ${t.altitude_deg.toFixed(1)}°, az ${t.azimuth_deg.toFixed(1)}°`),{position:[s.x,s.y,s.z],intensity:n.intensity,color:i}}apply_solar(){var e;if((e=this.sun_settings)!=null&&e.solar)try{return this.resolve_solar()}catch(t){V.warn("Failed to resolve solar sun, falling back to configured values:",t);return}}sun_create(e){if(!this.sun_settings)return;this.sun&&(this.scene.remove(this.sun),this.sun.dispose(),this.sun=null);const t=(e==null?void 0:e.color)??this.sun_settings.color,n=(e==null?void 0:e.intensity)??this.sun_settings.intensity;this.sun=new _.DirectionalLight(t,n),this.sun_settings.shadow&&(this.viewer.renderer.shadowMap.enabled=!0,this.sun.castShadow=!0,this.sun_fit_shadow()),this.sun.position.set(...(e==null?void 0:e.position)??this.sun_settings.position),this.scene.add(this.sun)}_infer_sun_position_from_env_map(){if(!this.environment)return V.warn("No environment map available."),null;const e=this.environment.texture,t=e==null?void 0:e.image;if(!t||!t.width||!t.height||!t.data)return V.warn("No environment map texture found."),null;const n=t.width,s=t.height,i=t.data;let o=0;const a=[];for(let p=0;p<i.length;p+=4){const y=i[p],v=i[p+1],b=i[p+2],w=.2126*y+.7152*v+.0722*b;if(w>o){o=w,a.length=0;const A=p/4;a.push({x:A%n,y:Math.floor(A/n)})}else if(w===o){const A=p/4;a.push({x:A%n,y:Math.floor(A/n)})}}let c=0,l=0;a.forEach(p=>{c+=p.x,l+=p.y}),c/=a.length,l/=a.length;let d=c/n*2*Math.PI;d=(d+Math.PI)%(2*Math.PI);const h=l/s*Math.PI,f=new _.Vector3(Math.sin(h)*Math.cos(d),Math.cos(h),Math.sin(h)*Math.sin(d));return f.normalize(),f.multiplyScalar(100)}dispose(){var e,t;this.sun&&(this.scene.remove(this.sun),(t=(e=this.sun).dispose)==null||t.call(e),this.sun=null)}}const he=[];for(let r=0;r<256;++r)he.push((r+256).toString(16).slice(1));function Ca(r,e=0){return(he[r[e+0]]+he[r[e+1]]+he[r[e+2]]+he[r[e+3]]+"-"+he[r[e+4]]+he[r[e+5]]+"-"+he[r[e+6]]+he[r[e+7]]+"-"+he[r[e+8]]+he[r[e+9]]+"-"+he[r[e+10]]+he[r[e+11]]+he[r[e+12]]+he[r[e+13]]+he[r[e+14]]+he[r[e+15]]).toLowerCase()}let as;const Oa=new Uint8Array(16);function ka(){if(!as){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");as=crypto.getRandomValues.bind(crypto)}return as(Oa)}const bi={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Da(r,e,t){var s;if(bi.randomUUID&&!r)return bi.randomUUID();r=r||{};const n=r.random??((s=r.rng)==null?void 0:s.call(r))??ka();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Ca(n)}function Ia(r,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},n=r.getIndex(),s=r.getAttribute("position"),i=n?n.count:s.count;let o=0;const a=Object.keys(r.attributes),c={},l={},d=[],h=["getX","getY","getZ","getW"],f=["setX","setY","setZ","setW"];for(let A=0,M=a.length;A<M;A++){const x=a[A],z=r.attributes[x];c[x]=new z.constructor(new z.array.constructor(z.count*z.itemSize),z.itemSize,z.normalized);const Z=r.morphAttributes[x];Z&&(l[x]||(l[x]=[]),Z.forEach((j,k)=>{const C=new j.array.constructor(j.count*j.itemSize);l[x][k]=new j.constructor(C,j.itemSize,j.normalized)}))}const p=e*.5,y=Math.log10(1/e),v=Math.pow(10,y),b=p*v;for(let A=0;A<i;A++){const M=n?n.getX(A):A;let x="";for(let z=0,Z=a.length;z<Z;z++){const j=a[z],k=r.getAttribute(j),C=k.itemSize;for(let I=0;I<C;I++)x+=`${~~(k[h[I]](M)*v+b)},`}if(x in t)d.push(t[x]);else{for(let z=0,Z=a.length;z<Z;z++){const j=a[z],k=r.getAttribute(j),C=r.morphAttributes[j],I=k.itemSize,R=c[j],W=l[j];for(let $=0;$<I;$++){const E=h[$],ee=f[$];if(R[ee](o,k[E](M)),C)for(let Y=0,Te=C.length;Y<Te;Y++)W[Y][ee](o,C[Y][E](M))}}t[x]=o,d.push(o),o++}}const w=r.clone();for(const A in r.attributes){const M=c[A];if(w.setAttribute(A,new M.constructor(M.array.slice(0,o*M.itemSize),M.itemSize,M.normalized)),A in l)for(let x=0;x<l[A].length;x++){const z=l[A][x];w.morphAttributes[A][x]=new z.constructor(z.array.slice(0,o*z.itemSize),z.itemSize,z.normalized)}}return w.setIndex(d),w}function wi(r,e){if(e===u.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===u.TriangleFanDrawMode||e===u.TriangleStripDrawMode){let t=r.getIndex();if(t===null){const o=[],a=r.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,s=[];if(e===u.TriangleFanDrawMode)for(let o=1;o<=n;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=r.clone();return i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}const Ai=new u.Box3,In=new u.Vector3;class cs extends u.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new u.Float32BufferAttribute(e,3)),this.setAttribute("uv",new u.Float32BufferAttribute(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new u.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new u.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new u.InterleavedBufferAttribute(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new u.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new u.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new u.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new u.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new u.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Ai.setFromBufferAttribute(t),this.boundingBox.union(Ai))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new u.Sphere),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let s=0;for(let i=0,o=e.count;i<o;i++)In.fromBufferAttribute(e,i),s=Math.max(s,n.distanceToSquared(In)),In.fromBufferAttribute(t,i),s=Math.max(s,n.distanceToSquared(In));this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}u.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new u.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},u.ShaderLib.line={uniforms:u.UniformsUtils.merge([u.UniformsLib.common,u.UniformsLib.fog,u.UniformsLib.line]),vertexShader:`
|
|
158
|
+
}`};class ra extends u.Scene{constructor(){super();const e=new u.BoxGeometry;e.deleteAttribute("uv");const t=new u.MeshStandardMaterial({side:u.BackSide}),n=new u.MeshStandardMaterial,s=new u.PointLight(16777215,900,28,2);s.position.set(.418,16.199,.3),this.add(s);const i=new u.Mesh(e,t);i.position.set(-.757,13.219,.717),i.scale.set(31.713,28.305,28.591),this.add(i);const o=new u.Mesh(e,n);o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),this.add(o);const a=new u.Mesh(e,n);a.position.set(-5.607,-.754,-.758),a.rotation.set(0,.994,0),a.scale.set(1.97,1.534,3.955),this.add(a);const c=new u.Mesh(e,n);c.position.set(6.167,.857,7.803),c.rotation.set(0,.561,0),c.scale.set(3.927,6.285,3.687),this.add(c);const l=new u.Mesh(e,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);const d=new u.Mesh(e,n);d.position.set(2.291,-.756,-2.621),d.rotation.set(0,-.286,0),d.scale.set(1.546,1.552,1.496),this.add(d);const h=new u.Mesh(e,n);h.position.set(-2.193,-.369,-5.547),h.rotation.set(0,.516,0),h.scale.set(3.875,3.487,2.986),this.add(h);const f=new u.Mesh(e,Ot(50));f.position.set(-16.116,14.37,8.208),f.scale.set(.1,2.428,2.739),this.add(f);const p=new u.Mesh(e,Ot(50));p.position.set(-16.109,18.021,-8.207),p.scale.set(.1,2.425,2.751),this.add(p);const y=new u.Mesh(e,Ot(17));y.position.set(14.904,12.198,-1.832),y.scale.set(.15,4.265,6.331),this.add(y);const v=new u.Mesh(e,Ot(43));v.position.set(-.462,8.89,14.52),v.scale.set(4.38,5.441,.088),this.add(v);const b=new u.Mesh(e,Ot(20));b.position.set(3.235,11.486,-12.541),b.scale.set(2.5,2,.1),this.add(b);const w=new u.Mesh(e,Ot(100));w.position.set(0,20,0),w.scale.set(1,.1,1),this.add(w)}dispose(){const e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(const t of e)t.dispose()}}function Ot(r){const e=new u.MeshBasicMaterial;return e.color.setScalar(r),e}class ve extends Error{constructor(e,t,n,s){super(e),this.component=t,this.code=n,this.details=s,this.name="GlimmerError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ve)}toJSON(){return{name:this.name,message:this.message,component:this.component,code:this.code,details:this.details,stack:this.stack}}toString(){return`${this.name} [${this.component}:${this.code}]: ${this.message}`}}const Le={INITIALIZATION_FAILED:"INITIALIZATION_FAILED",HDR_LOAD_FAILED:"HDR_LOAD_FAILED",ENVIRONMENT_UPDATE_FAILED:"ENVIRONMENT_UPDATE_FAILED",MODEL_LOAD_FAILED:"MODEL_LOAD_FAILED",MODEL_NOT_FOUND:"MODEL_NOT_FOUND",INVALID_STORY_JSON:"INVALID_STORY_JSON",INVALID_SLIDE_INDEX:"INVALID_SLIDE_INDEX"};class mi extends EventTarget{constructor(t,n){super();g(this,"settings");g(this,"renderer");g(this,"scene");g(this,"viewer");g(this,"ready");g(this,"texture",null);g(this,"ambient",null);g(this,"room",null);g(this,"env_map",null);g(this,"sky",null);g(this,"Sun",null);this.viewer=t,this.settings=n,this.renderer=t.renderer,this.scene=t.scene,this.settings.addEventListener("update",s=>{const i=s.detail;this.update(i.environment)}),this.ready=this.update(this.settings.get("environment"))}async update(t){V.info("Updating environment settings:",t);const{type:n,url:s}=t;this.dispatchEvent(new CustomEvent("loading",{detail:{type:n,url:s}}));try{if(n==="hdr"||n==="ultra"){if(this.clear_environment(),!s)return;await this.set_hdr_environment(s,n==="ultra")}else n==="sky"?(this.clear_environment(),this.set_sky_environment()):n==="room"?(this.clear_environment(),this.set_room_environment()):n==="none"?(this.clear_environment(),this.set_color_environment()):this.clear_environment();this.dispatchEvent(new CustomEvent("loaded",{detail:{type:n,url:s}}))}catch(i){V.error("Error updating environment:",i),this.clear_environment(),this.set_color_environment();const o=new ve(`Failed to update environment: ${i instanceof Error?i.message:i}`,"Environment",Le.ENVIRONMENT_UPDATE_FAILED,{type:n,url:s,error:i});throw this.dispatchEvent(new CustomEvent("error",{detail:{error:o}})),o}}clear_environment(){this.scene.background=null,this.scene.environment=null,this.sky=null,this.texture=null}set_sky_environment(){const t=new Dn;t.scale.setScalar(45e4);const n=_.MathUtils.degToRad(90),s=_.MathUtils.degToRad(180),i=new _.Vector3().setFromSphericalCoords(1,n,s);t.material.uniforms.sunPosition.value=i,this.sky=t,this.scene.add(this.sky)}set_room_environment(){const t=new ra,s=new _.PMREMGenerator(this.renderer).fromScene(t).texture;this.scene.background=s,this.scene.environment=s}set_color_environment(t=16777215){this.scene.background=new _.Color(t)}async set_hdr_environment(t,n=!1){const s=new _.PMREMGenerator(this.renderer);s.compileEquirectangularShader();const i=n?new ia:new na;await new Promise((o,a)=>{i.load(t,c=>{try{this.texture=c;const l=s.fromEquirectangular(c).texture;this.scene.background=l,this.scene.environment=l,c.dispose(),s.dispose(),this.dispatchEvent(new CustomEvent("textureloaded",{detail:{texture:c}})),this.settings.dispatchEvent(new CustomEvent("environmentTextureLoaded",{detail:{texture:c}})),o()}catch(l){a(l)}},void 0,c=>{V.error("Error loading HDR texture:",c),a(new ve(`Failed to load HDR texture from ${t}`,"Environment",Le.HDR_LOAD_FAILED,{url:t,ultra:n,error:c}))})})}set_ambient_lighting(t=14544639,n=2){this.ambient=new _.AmbientLight(t,n),this.scene.add(this.ambient)}dispose(){var t,n;this.clear_environment(),this.ambient&&(this.scene.remove(this.ambient),(n=(t=this.ambient).dispose)==null||n.call(t),this.ambient=null),this.env_map&&(this.env_map.dispose(),this.env_map=null),this.texture&&(this.texture.dispose(),this.texture=null),this.sky&&(this.scene.remove(this.sky),this.sky=null)}}function _i(r){const t=new _.Box3().setFromObject(r).getSize(new _.Vector3);return Math.max(10,Math.max(t.x,t.y,t.z))}const oa=512,aa=100,ca=30,la=-.001,da=3,ua=16,{PI:ha,sin:Je,cos:Qe,tan:gi,asin:yi,atan2:vi}=Math,Ee=ha/180,fa=1e3*60*60*24,pa=2440588,ma=2451545;function _a(r){return r.valueOf()/fa-.5+pa-ma}function ga(r){const e=2e3+r/365.2425;let t;return e<1920?(t=e-1900,-2.79+t*(1.494119+t*(-.0598939+t*(.0061966-t*197e-6)))):e<1941?(t=e-1920,21.2+t*(.84493+t*(-.0761+t*.0020936))):e<1961?(t=e-1950,29.07+t*(.407+t*(-1/233+t/2547))):e<1986?(t=e-1975,45.45+t*(1.067+t*(-1/260-t/718))):e<2005?(t=e-2e3,63.86+t*(.3345+t*(-.060374+t*(.0017275+t*(651814e-9+t*2373599e-11))))):e<2050?(t=e-2e3,62.92+t*(.32217+t*.005589)):(t=(e-1820)/100,-20+32*t*t-.5628*(2150-e))}function ya(r){return r+ga(r)/86400}function va(r,e,t){return(vi(Je(r),Qe(r)*Je(e)-gi(t)*Qe(e))/Ee+540)%360}function xa(r,e,t){return yi(Je(e)*Je(t)+Qe(e)*Qe(t)*Qe(r))}function ba(r,e){return Ee*(280.46061837+360.98564736629*r)-e}function wa(r){return r<0&&(r=0),2967e-7/gi(r+.00312536/(r+.08901179))}function Aa(r){const e=r/36525,t=Ee*(280.46646+e*(36000.76983+e*3032e-7)),n=Ee*(357.52911+e*(35999.05029-e*1537e-7)),s=Je(n),i=Qe(n),o=Ee*((1.914602-e*(.004817+e*14e-6))*s+(.019993-101e-6*e)*2*s*i+289e-6*s*(3-4*s*s)),a=Ee*(125.04-1934.136*e),c=t+o-Ee*(.00569+.00478*Je(a)),l=Ee*(23.439291-e*(.0130042+e*(16e-8-e*504e-9)))+Ee*.00256*Qe(a);return{ra:vi(Qe(l)*Je(c),Qe(c)),dec:yi(Je(l)*Je(c)),lon:c}}function Sa(r,e,t){const n=Ee*-t,s=Ee*e,i=_a(r),o=Aa(ya(i)),a=ba(i,n)-o.ra,c=xa(a,s,o.dec);return{azimuth:va(a,s,o.dec),altitude:(c+wa(c))/Ee}}const os=Math.PI/180;function Ta(r,e,t){const n=Sa(t,r,e),s=n.altitude,i=(n.azimuth%360+360)%360,o=s*os,a=i*os,c=new _.Vector3(Math.cos(o)*Math.sin(a),Math.sin(o),-Math.cos(o)*Math.cos(a));return{altitude_deg:s,azimuth_deg:i,direction:c}}const Ma=-6;function La(r,e,t){const n=new _.Color(t);if(r<=Ma)return{intensity:0,color:new _.Color(0)};const s=Math.max(0,r),i=Math.sin(Math.min(s,90)*os),o=e*(.12+.88*i),a=1-Math.min(s/30,1),l=new _.Color(16747586).lerp(n,1-a*.85);return{intensity:o,color:l}}class xi{constructor(e,t,n,s){g(this,"viewer");g(this,"scene");g(this,"settings");g(this,"sun_settings");g(this,"model_manager");g(this,"sun",null);g(this,"environment");this.viewer=e,this.scene=e.scene,this.settings=t,this.environment=n,this.model_manager=s,this.sun_settings=this.settings.get("environment").sun,this.settings.addEventListener("update",i=>{const o=i.detail;this.sun_settings=o.environment.sun,this.update()}),this.settings.addEventListener("environmentTextureLoaded",i=>{const o=i.detail.texture;if(this.environment.texture=o,this.sun&&this.sun_settings){const a=this._infer_sun_position_from_env_map();a&&(V.debug("Texture loaded event call; inferred Sun position from env map:",a),this.sun_settings.position=[a.x,a.y,a.z],this.update())}}),this.update()}update(){if(!this.sun_settings){this.sun&&(this.scene.remove(this.sun),this.sun=null);return}this.model_manager.ready.then(()=>{if(!this.sun_settings)return;const e=this.apply_solar();if(!e){const t=this._infer_sun_position_from_env_map();t&&(V.debug("Inferred Sun position from env map:",t),this.sun_settings.position=[t.x,t.y,t.z])}this.sun_create(e??void 0),this.sun_settings&&this.sync_sky((e==null?void 0:e.position)??this.sun_settings.position)})}sync_sky(e){if(!e)return;const t=this.environment.sky;if(!t)return;const n=t.material.uniforms;n!=null&&n.sunPosition&&n.sunPosition.value.copy(new _.Vector3(e[0],e[1],e[2]).normalize())}sun_fit_object(e=this.scene){const t=_i(e);let n=new _.Vector3(0,1,0).normalize();n=n.multiplyScalar(t*2),this.sun&&(n=this.sun.position.clone())}sun_fit_shadow(){const e=new _.Object3D;if(!this.model_manager){V.warn("No model manager found.");return}for(const o of this.model_manager.models.values())o.settings.shadow&&e.add(o.group.clone());e.children.length===0&&V.warn("No models with shadows found to fit shadow map."),V.debug("Models in fit_object:",e);const t=_i(e),n=oa,s=Math.ceil(t/aa),i=Math.min(Math.pow(2,Math.ceil(Math.log2(n*s))),this.viewer.renderer.capabilities.maxTextureSize);if(V.debug("Shadow map size:",i),this.sun){this.sun.shadow.mapSize.width=i,this.sun.shadow.mapSize.height=i;const o=ca;this.sun.shadow.camera.left=-(t/2+o),this.sun.shadow.camera.right=t/2+o,this.sun.shadow.camera.top=t/2+o,this.sun.shadow.camera.bottom=-(t/2+o),this.sun.shadow.camera.near=.1,this.sun.shadow.camera.far=t*2,this.sun.shadow.bias=la,this.sun.shadow.radius=da,this.sun.shadow.blurSamples=ua,V.info(`Recreated sun with shadow map size: ${i}x${i}`)}}resolve_solar(){const e=this.sun_settings.solar,t=Ta(e.latitude,e.longitude,new Date(e.datetime)),n=La(t.altitude_deg,this.sun_settings.intensity,this.sun_settings.color),s=t.direction.multiplyScalar(100);let i=0;return n.intensity>0&&(i=+`0x${n.color.getHexString()}`),V.debug(`Solar sun: lat ${e.latitude}, lon ${e.longitude}, alt ${t.altitude_deg.toFixed(1)}°, az ${t.azimuth_deg.toFixed(1)}°`),{position:[s.x,s.y,s.z],intensity:n.intensity,color:i}}apply_solar(){var e;if((e=this.sun_settings)!=null&&e.solar)try{return this.resolve_solar()}catch(t){V.warn("Failed to resolve solar sun, falling back to configured values:",t);return}}sun_create(e){if(!this.sun_settings)return;this.sun&&(this.scene.remove(this.sun),this.sun.dispose(),this.sun=null);const t=(e==null?void 0:e.color)??this.sun_settings.color,n=(e==null?void 0:e.intensity)??this.sun_settings.intensity;this.sun=new _.DirectionalLight(t,n),this.sun_settings.shadow&&(this.viewer.renderer.shadowMap.enabled=!0,this.sun.castShadow=!0,this.sun_fit_shadow()),this.sun.position.set(...(e==null?void 0:e.position)??this.sun_settings.position),this.scene.add(this.sun)}_infer_sun_position_from_env_map(){if(!this.environment)return V.warn("No environment map available."),null;const e=this.environment.texture,t=e==null?void 0:e.image;if(!t||!t.width||!t.height||!t.data)return V.warn("No environment map texture found."),null;const n=t.width,s=t.height,i=t.data;let o=0;const a=[];for(let p=0;p<i.length;p+=4){const y=i[p],v=i[p+1],b=i[p+2],w=.2126*y+.7152*v+.0722*b;if(w>o){o=w,a.length=0;const A=p/4;a.push({x:A%n,y:Math.floor(A/n)})}else if(w===o){const A=p/4;a.push({x:A%n,y:Math.floor(A/n)})}}let c=0,l=0;a.forEach(p=>{c+=p.x,l+=p.y}),c/=a.length,l/=a.length;let d=c/n*2*Math.PI;d=(d+Math.PI)%(2*Math.PI);const h=l/s*Math.PI,f=new _.Vector3(Math.sin(h)*Math.cos(d),Math.cos(h),Math.sin(h)*Math.sin(d));return f.normalize(),f.multiplyScalar(100)}dispose(){var e,t;this.sun&&(this.scene.remove(this.sun),(t=(e=this.sun).dispose)==null||t.call(e),this.sun=null)}}const he=[];for(let r=0;r<256;++r)he.push((r+256).toString(16).slice(1));function Ca(r,e=0){return(he[r[e+0]]+he[r[e+1]]+he[r[e+2]]+he[r[e+3]]+"-"+he[r[e+4]]+he[r[e+5]]+"-"+he[r[e+6]]+he[r[e+7]]+"-"+he[r[e+8]]+he[r[e+9]]+"-"+he[r[e+10]]+he[r[e+11]]+he[r[e+12]]+he[r[e+13]]+he[r[e+14]]+he[r[e+15]]).toLowerCase()}let as;const Oa=new Uint8Array(16);function ka(){if(!as){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");as=crypto.getRandomValues.bind(crypto)}return as(Oa)}const bi={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Da(r,e,t){var s;if(bi.randomUUID&&!r)return bi.randomUUID();r=r||{};const n=r.random??((s=r.rng)==null?void 0:s.call(r))??ka();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Ca(n)}function Ia(r,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},n=r.getIndex(),s=r.getAttribute("position"),i=n?n.count:s.count;let o=0;const a=Object.keys(r.attributes),c={},l={},d=[],h=["getX","getY","getZ","getW"],f=["setX","setY","setZ","setW"];for(let A=0,M=a.length;A<M;A++){const x=a[A],z=r.attributes[x];c[x]=new z.constructor(new z.array.constructor(z.count*z.itemSize),z.itemSize,z.normalized);const Z=r.morphAttributes[x];Z&&(l[x]||(l[x]=[]),Z.forEach((j,k)=>{const C=new j.array.constructor(j.count*j.itemSize);l[x][k]=new j.constructor(C,j.itemSize,j.normalized)}))}const p=e*.5,y=Math.log10(1/e),v=Math.pow(10,y),b=p*v;for(let A=0;A<i;A++){const M=n?n.getX(A):A;let x="";for(let z=0,Z=a.length;z<Z;z++){const j=a[z],k=r.getAttribute(j),C=k.itemSize;for(let I=0;I<C;I++)x+=`${~~(k[h[I]](M)*v+b)},`}if(x in t)d.push(t[x]);else{for(let z=0,Z=a.length;z<Z;z++){const j=a[z],k=r.getAttribute(j),C=r.morphAttributes[j],I=k.itemSize,R=c[j],W=l[j];for(let $=0;$<I;$++){const E=h[$],ee=f[$];if(R[ee](o,k[E](M)),C)for(let Y=0,Te=C.length;Y<Te;Y++)W[Y][ee](o,C[Y][E](M))}}t[x]=o,d.push(o),o++}}const w=r.clone();for(const A in r.attributes){const M=c[A];if(w.setAttribute(A,new M.constructor(M.array.slice(0,o*M.itemSize),M.itemSize,M.normalized)),A in l)for(let x=0;x<l[A].length;x++){const z=l[A][x];w.morphAttributes[A][x]=new z.constructor(z.array.slice(0,o*z.itemSize),z.itemSize,z.normalized)}}return w.setIndex(d),w}function wi(r,e){if(e===u.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===u.TriangleFanDrawMode||e===u.TriangleStripDrawMode){let t=r.getIndex();if(t===null){const o=[],a=r.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,s=[];if(e===u.TriangleFanDrawMode)for(let o=1;o<=n;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=r.clone();return i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}const Ai=new u.Box3,In=new u.Vector3;class cs extends u.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new u.Float32BufferAttribute(e,3)),this.setAttribute("uv",new u.Float32BufferAttribute(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new u.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new u.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new u.InterleavedBufferAttribute(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new u.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new u.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new u.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new u.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new u.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Ai.setFromBufferAttribute(t),this.boundingBox.union(Ai))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new u.Sphere),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let s=0;for(let i=0,o=e.count;i<o;i++)In.fromBufferAttribute(e,i),s=Math.max(s,n.distanceToSquared(In)),In.fromBufferAttribute(t,i),s=Math.max(s,n.distanceToSquared(In));this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}u.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new u.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},u.ShaderLib.line={uniforms:u.UniformsUtils.merge([u.UniformsLib.common,u.UniformsLib.fog,u.UniformsLib.line]),vertexShader:`
|
|
159
159
|
#include <common>
|
|
160
160
|
#include <color_pars_vertex>
|
|
161
161
|
#include <fog_pars_vertex>
|
package/package.json
CHANGED