@soonspacejs/plugin-fds 2.15.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.
@@ -0,0 +1,1230 @@
1
+ import { Matrix4 as Ne, Vector3 as y, Box3 as fe, CanvasTexture as Se, Mesh as Re, Data3DTexture as Le, RedFormat as Ve, UnsignedByteType as Pe, LinearFilter as ye, ShaderMaterial as Be, BackSide as $e, BoxGeometry as qe, MathUtils as le, EventDispatcher as We } from "three";
2
+ import { Lut as Xe } from "three/examples/jsm/math/Lut.js";
3
+ const re = new Ne();
4
+ re.makeBasis(
5
+ new y(1, 0, 0),
6
+ new y(0, 0, -1),
7
+ new y(0, 1, 0)
8
+ );
9
+ const De = re.clone().invert();
10
+ class Te {
11
+ ijk;
12
+ xb;
13
+ origin;
14
+ size;
15
+ cellSize;
16
+ constructor(e, r) {
17
+ this.ijk = new y(e.x, e.y, e.z), this.xb = new fe(
18
+ new y(r.minX, r.minY, r.minZ),
19
+ new y(r.maxX, r.maxY, r.maxZ)
20
+ ), this.origin = this.xb.min.clone(), this.size = this.xb.getSize(new y()), this.cellSize = new y(
21
+ this.size.x / this.ijk.x,
22
+ this.size.y / this.ijk.y,
23
+ this.size.z / this.ijk.z
24
+ );
25
+ }
26
+ getPositionByCell(e, r = "threejs") {
27
+ const a = new y(e.x, e.y, e.z).multiply(this.cellSize).add(this.origin);
28
+ return r === "threejs" && a.applyMatrix4(re), a;
29
+ }
30
+ getCellByPosition(e, r = "threejs") {
31
+ const t = new y(e.x, e.y, e.z);
32
+ return r === "threejs" && t.applyMatrix4(De), t.sub(this.origin).divide(this.cellSize).round();
33
+ }
34
+ }
35
+ const Je = (
36
+ /* glsl */
37
+ `
38
+ #include <common>
39
+ #include <logdepthbuf_pars_vertex>
40
+
41
+ uniform vec3 cameraPos;
42
+
43
+ out vec3 vOrigin;
44
+ out vec3 vDirection;
45
+
46
+ void main() {
47
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
48
+
49
+ vOrigin = vec3( inverse( modelMatrix ) * vec4( cameraPos, 1.0 ) ).xyz;
50
+ vDirection = position - vOrigin;
51
+
52
+ gl_Position = projectionMatrix * mvPosition;
53
+
54
+ #include <logdepthbuf_vertex>
55
+ }
56
+ `
57
+ ), He = (
58
+ /* glsl */
59
+ `
60
+ precision highp float;
61
+ precision highp sampler3D;
62
+
63
+ #include <common>
64
+ #include <logdepthbuf_pars_fragment>
65
+
66
+ in vec3 vOrigin;
67
+ in vec3 vDirection;
68
+
69
+ vec4 color;
70
+
71
+ uniform sampler3D map;
72
+ uniform sampler2D lutMap;
73
+ uniform float isSoot;
74
+ uniform float threshold;
75
+ uniform float steps;
76
+
77
+ vec2 hitBox( vec3 orig, vec3 dir ) {
78
+ const vec3 box_min = vec3( - 0.5 );
79
+ const vec3 box_max = vec3( 0.5 );
80
+ vec3 inv_dir = 1.0 / dir;
81
+ vec3 tmin_tmp = ( box_min - orig ) * inv_dir;
82
+ vec3 tmax_tmp = ( box_max - orig ) * inv_dir;
83
+ vec3 tmin = min( tmin_tmp, tmax_tmp );
84
+ vec3 tmax = max( tmin_tmp, tmax_tmp );
85
+ float t0 = max( tmin.x, max( tmin.y, tmin.z ) );
86
+ float t1 = min( tmax.x, min( tmax.y, tmax.z ) );
87
+ return vec2( t0, t1 );
88
+ }
89
+
90
+ vec4 sample2( vec3 p ) {
91
+ float v = texture( map, p ).r;
92
+ v = v > 0.5 ? 1.0 : v;
93
+ vec4 lutColor = texture( lutMap, vec2( 0.5, v ) );
94
+
95
+ if(isSoot == 1.0) lutColor.a = v;
96
+ if(isSoot == 0.0) lutColor.a = v > 0.01 ? 1.0 : 0.0;
97
+
98
+ return lutColor;
99
+ }
100
+
101
+ vec4 BlendUnder(vec4 color, vec4 newColor)
102
+ {
103
+ color.rgb += (1.0 - color.a) * newColor.a * newColor.rgb;
104
+ color.a += (1.0 - color.a) * newColor.a;
105
+ return color;
106
+ }
107
+
108
+ void main(){
109
+ vec3 rayDir = normalize( vDirection );
110
+ vec2 bounds = hitBox( vOrigin, rayDir );
111
+
112
+ if ( bounds.x > bounds.y ) discard;
113
+
114
+ bounds.x = max( bounds.x, 0.0 );
115
+
116
+ vec3 p = vOrigin + bounds.x * rayDir;
117
+ vec3 inc = 1.0 / abs( rayDir );
118
+ float delta = min( inc.x, min( inc.y, inc.z ) );
119
+ delta /= steps;
120
+
121
+ for ( float t = bounds.x; t < bounds.y; t += delta ) {
122
+ vec4 samplerColor = sample2( p + 0.5 );
123
+ samplerColor.a *= .06;
124
+ color = BlendUnder(color, samplerColor);
125
+
126
+ p += rayDir * delta;
127
+ }
128
+
129
+ if ( color.a == 0.0 ) discard;
130
+
131
+ gl_FragColor = color;
132
+
133
+ #include <logdepthbuf_fragment>
134
+ }
135
+ `
136
+ ), G = new Xe();
137
+ G.addColorMap("soot", [
138
+ [0, 4473924],
139
+ [0.2, 3355443],
140
+ [0.4, 2236962],
141
+ [0.8, 1118481],
142
+ [1, 0]
143
+ ]);
144
+ G.setColorMap("soot", 256);
145
+ const ke = new Se(G.createCanvas());
146
+ G.setColorMap("rainbow", 256);
147
+ const Ye = new Se(G.createCanvas());
148
+ class Ze extends Re {
149
+ texture;
150
+ constructor(e) {
151
+ super();
152
+ const r = new Le(
153
+ null,
154
+ e.width,
155
+ e.height,
156
+ e.depth
157
+ );
158
+ r.format = Ve, r.type = Pe, r.minFilter = ye, r.magFilter = ye, r.unpackAlignment = 1, r.needsUpdate = !0, this.texture = r;
159
+ const t = new Be({
160
+ uniforms: {
161
+ map: { value: r },
162
+ lutMap: { value: ke },
163
+ isSoot: { value: 1 },
164
+ cameraPos: { value: new y() },
165
+ steps: { value: 100 },
166
+ threshold: { value: 0 }
167
+ },
168
+ vertexShader: Je,
169
+ fragmentShader: He,
170
+ side: $e,
171
+ transparent: !0,
172
+ depthTest: !1
173
+ });
174
+ this.material = t;
175
+ const a = new qe(1, 1, 1);
176
+ this.geometry = a, this.renderOrder = 1;
177
+ }
178
+ updateData(e) {
179
+ const { image: r } = this.texture;
180
+ r.data ? r.data.set(e) : r.data = e, this.texture.needsUpdate = !0;
181
+ }
182
+ updateCamera(e) {
183
+ this.material.uniforms.cameraPos.value.copy(e);
184
+ }
185
+ dispose() {
186
+ this.texture.dispose(), this.material.dispose(), this.geometry.dispose();
187
+ }
188
+ }
189
+ const Me = '(function(){"use strict";function br(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var R,K;function mr(){if(K)return R;K=1;function e(r){for(var t=new Array(r),o=0;o<r;++o)t[o]=o;return t}return R=e,R}var L,Q;function Ar(){if(Q)return L;Q=1,L=function(t){return t!=null&&(e(t)||r(t)||!!t._isBuffer)};function e(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function r(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&e(t.slice(0,0))}return L}var P,Y;function jr(){if(Y)return P;Y=1;var e=mr(),r=Ar(),t=typeof Float64Array<"u";function o(h,s){return h[0]-s[0]}function a(){var h=this.stride,s=new Array(h.length),n;for(n=0;n<s.length;++n)s[n]=[Math.abs(h[n]),n];s.sort(o);var f=new Array(s.length);for(n=0;n<f.length;++n)f[n]=s[n][1];return f}function u(h,s){var n=["View",s,"d",h].join("");s<0&&(n="View_Nil"+h);var f=h==="generic";if(s===-1){var i="function "+n+"(a){this.data=a;}; var proto="+n+".prototype; proto.dtype=\'"+h+"\'; proto.index=function(){return -1}; proto.size=0; proto.dimension=-1; proto.shape=proto.stride=proto.order=[]; proto.lo=proto.hi=proto.transpose=proto.step= function(){return new "+n+"(this.data);}; proto.get=proto.set=function(){}; proto.pick=function(){return null}; return function construct_"+n+"(a){return new "+n+"(a);}",S=new Function(i);return S()}else if(s===0){var i="function "+n+"(a,d) { this.data = a; this.offset = d }; var proto="+n+".prototype; proto.dtype=\'"+h+"\'; proto.index=function(){return this.offset}; proto.dimension=0; proto.size=1; proto.shape= proto.stride= proto.order=[]; proto.lo= proto.hi= proto.transpose= proto.step=function "+n+"_copy() { return new "+n+"(this.data,this.offset) }; proto.pick=function "+n+"_pick(){ return TrivialArray(this.data); }; proto.valueOf=proto.get=function "+n+"_get(){ return "+(f?"this.data.get(this.offset)":"this.data[this.offset]")+"}; proto.set=function "+n+"_set(v){ return "+(f?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+" }; return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}",S=new Function("TrivialArray",i);return S(l[h][0])}var i=["\'use strict\'"],p=e(s),g=p.map(function(c){return"i"+c}),b="this.offset+"+p.map(function(c){return"this.stride["+c+"]*i"+c}).join("+"),j=p.map(function(c){return"b"+c}).join(","),_=p.map(function(c){return"c"+c}).join(",");i.push("function "+n+"(a,"+j+","+_+",d){this.data=a","this.shape=["+j+"]","this.stride=["+_+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype=\'"+h+"\'","proto.dimension="+s),i.push("Object.defineProperty(proto,\'size\',{get:function "+n+"_size(){ return "+p.map(function(c){return"this.shape["+c+"]"}).join("*"),"}})"),s===1?i.push("proto.order=[0]"):(i.push("Object.defineProperty(proto,\'order\',{get:"),s<4?(i.push("function "+n+"_order(){"),s===2?i.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):s===3&&i.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]); if(s0>s1){ if(s1>s2){ return [2,1,0]; }else if(s0>s2){ return [1,2,0]; }else{ return [1,0,2]; } }else if(s0>s2){ return [2,0,1]; }else if(s2>s1){ return [0,1,2]; }else{ return [0,2,1]; }}})")):i.push("ORDER})")),i.push("proto.set=function "+n+"_set("+g.join(",")+",v){"),f?i.push("return this.data.set("+b+",v)}"):i.push("return this.data["+b+"]=v}"),i.push("proto.get=function "+n+"_get("+g.join(",")+"){"),f?i.push("return this.data.get("+b+")}"):i.push("return this.data["+b+"]}"),i.push("proto.index=function "+n+"_index(",g.join(),"){return "+b+"}"),i.push("proto.hi=function "+n+"_hi("+g.join(",")+"){return new "+n+"(this.data,"+p.map(function(c){return["(typeof i",c,"!==\'number\'||i",c,"<0)?this.shape[",c,"]:i",c,"|0"].join("")}).join(",")+","+p.map(function(c){return"this.stride["+c+"]"}).join(",")+",this.offset)}");var m=p.map(function(c){return"a"+c+"=this.shape["+c+"]"}),k=p.map(function(c){return"c"+c+"=this.stride["+c+"]"});i.push("proto.lo=function "+n+"_lo("+g.join(",")+"){var b=this.offset,d=0,"+m.join(",")+","+k.join(","));for(var v=0;v<s;++v)i.push("if(typeof i"+v+"===\'number\'&&i"+v+">=0){ d=i"+v+"|0; b+=c"+v+"*d; a"+v+"-=d}");i.push("return new "+n+"(this.data,"+p.map(function(c){return"a"+c}).join(",")+","+p.map(function(c){return"c"+c}).join(",")+",b)}"),i.push("proto.step=function "+n+"_step("+g.join(",")+"){var "+p.map(function(c){return"a"+c+"=this.shape["+c+"]"}).join(",")+","+p.map(function(c){return"b"+c+"=this.stride["+c+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var v=0;v<s;++v)i.push("if(typeof i"+v+"===\'number\'){ d=i"+v+"|0; if(d<0){ c+=b"+v+"*(a"+v+"-1); a"+v+"=ceil(-a"+v+"/d) }else{ a"+v+"=ceil(a"+v+"/d) } b"+v+"*=d }");i.push("return new "+n+"(this.data,"+p.map(function(c){return"a"+c}).join(",")+","+p.map(function(c){return"b"+c}).join(",")+",c)}");for(var T=new Array(s),z=new Array(s),v=0;v<s;++v)T[v]="a[i"+v+"]",z[v]="b[i"+v+"]";i.push("proto.transpose=function "+n+"_transpose("+g+"){"+g.map(function(c,I){return c+"=("+c+"===undefined?"+I+":"+c+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+T.join(",")+","+z.join(",")+",this.offset)}"),i.push("proto.pick=function "+n+"_pick("+g+"){var a=[],b=[],c=this.offset");for(var v=0;v<s;++v)i.push("if(typeof i"+v+"===\'number\'&&i"+v+">=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");i.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),i.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+p.map(function(c){return"shape["+c+"]"}).join(",")+","+p.map(function(c){return"stride["+c+"]"}).join(",")+",offset)}");var S=new Function("CTOR_LIST","ORDER",i.join(`\n`));return S(l[h],a)}function d(h){if(r(h))return"buffer";if(t)switch(Object.prototype.toString.call(h)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(h)?"array":"generic"}var l={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function w(h,s,n,f){if(h===void 0){var _=l.array[0];return _([])}else typeof h=="number"&&(h=[h]);s===void 0&&(s=[h.length]);var i=s.length;if(n===void 0){n=new Array(i);for(var p=i-1,g=1;p>=0;--p)n[p]=g,g*=s[p]}if(f===void 0){f=0;for(var p=0;p<i;++p)n[p]<0&&(f-=(s[p]-1)*n[p])}for(var b=d(h),j=l[b];j.length<=i+1;)j.push(u(b,j.length-1));var _=j[i+1];return _(h,s,n,f)}return P=w,P}var _r=jr(),Er=br(_r),A=Uint8Array,O=Uint16Array,Fr=Int32Array,Z=new A([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),rr=new A([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Nr=new A([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),er=function(e,r){for(var t=new O(31),o=0;o<31;++o)t[o]=r+=1<<e[o-1];for(var a=new Fr(t[30]),o=1;o<30;++o)for(var u=t[o];u<t[o+1];++u)a[u]=u-t[o]<<5|o;return{b:t,r:a}},tr=er(Z,2),nr=tr.b,kr=tr.r;nr[28]=258,kr[258]=28;for(var xr=er(rr,0),Sr=xr.b,q=new O(32768),y=0;y<32768;++y){var x=(y&43690)>>1|(y&21845)<<1;x=(x&52428)>>2|(x&13107)<<2,x=(x&61680)>>4|(x&3855)<<4,q[y]=((x&65280)>>8|(x&255)<<8)>>1}for(var M=(function(e,r,t){for(var o=e.length,a=0,u=new O(r);a<o;++a)e[a]&&++u[e[a]-1];var d=new O(r);for(a=1;a<r;++a)d[a]=d[a-1]+u[a-1]<<1;var l;if(t){l=new O(1<<r);var w=15-r;for(a=0;a<o;++a)if(e[a])for(var h=a<<4|e[a],s=r-e[a],n=d[e[a]-1]++<<s,f=n|(1<<s)-1;n<=f;++n)l[q[n]>>w]=h}else for(l=new O(o),a=0;a<o;++a)e[a]&&(l[a]=q[d[e[a]-1]++]>>15-e[a]);return l}),$=new A(288),y=0;y<144;++y)$[y]=8;for(var y=144;y<256;++y)$[y]=9;for(var y=256;y<280;++y)$[y]=7;for(var y=280;y<288;++y)$[y]=8;for(var ar=new A(32),y=0;y<32;++y)ar[y]=5;var Dr=M($,9,1),Or=M(ar,5,1),H=function(e){for(var r=e[0],t=1;t<e.length;++t)e[t]>r&&(r=e[t]);return r},F=function(e,r,t){var o=r/8|0;return(e[o]|e[o+1]<<8)>>(r&7)&t},W=function(e,r){var t=r/8|0;return(e[t]|e[t+1]<<8|e[t+2]<<16)>>(r&7)},Tr=function(e){return(e+7)/8|0},Br=function(e,r,t){return(t==null||t>e.length)&&(t=e.length),new A(e.subarray(r,t))},Cr=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],N=function(e,r,t){var o=new Error(r||Cr[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,N),!t)throw o;return o},Mr=function(e,r,t,o){var a=e.length,u=0;if(!a||r.f&&!r.l)return t||new A(0);var d=!t,l=d||r.i!=2,w=r.i;d&&(t=new A(a*3));var h=function(wr){var yr=t.length;if(wr>yr){var gr=new A(Math.max(yr*2,wr));gr.set(t),t=gr}},s=r.f||0,n=r.p||0,f=r.b||0,i=r.l,p=r.d,g=r.m,b=r.n,j=a*8;do{if(!i){s=F(e,n,1);var _=F(e,n+1,3);if(n+=3,_)if(_==1)i=Dr,p=Or,g=9,b=5;else if(_==2){var T=F(e,n,31)+257,z=F(e,n+10,15)+4,S=T+F(e,n+5,31)+1;n+=14;for(var c=new A(S),I=new A(19),E=0;E<z;++E)I[Nr[E]]=F(e,n+E*3,7);n+=z*3;for(var cr=H(I),Zr=(1<<cr)-1,re=M(I,cr,1),E=0;E<S;){var hr=re[F(e,n,Zr)];n+=hr&15;var m=hr>>4;if(m<16)c[E++]=m;else{var B=0,V=0;for(m==16?(V=3+F(e,n,3),n+=2,B=c[E-1]):m==17?(V=3+F(e,n,7),n+=3):m==18&&(V=11+F(e,n,127),n+=7);V--;)c[E++]=B}}var pr=c.subarray(0,T),D=c.subarray(T);g=H(pr),b=H(D),i=M(pr,g,1),p=M(D,b,1)}else N(1);else{var m=Tr(n)+4,k=e[m-4]|e[m-3]<<8,v=m+k;if(v>a){w&&N(0);break}l&&h(f+k),t.set(e.subarray(m,v),f),r.b=f+=k,r.p=n=v*8,r.f=s;continue}if(n>j){w&&N(0);break}}l&&h(f+131072);for(var ee=(1<<g)-1,te=(1<<b)-1,G=n;;G=n){var B=i[W(e,n)&ee],C=B>>4;if(n+=B&15,n>j){w&&N(0);break}if(B||N(2),C<256)t[f++]=C;else if(C==256){G=n,i=null;break}else{var lr=C-254;if(C>264){var E=C-257,U=Z[E];lr=F(e,n,(1<<U)-1)+nr[E],n+=U}var J=p[W(e,n)&te],X=J>>4;J||N(3),n+=J&15;var D=Sr[X];if(X>3){var U=rr[X];D+=W(e,n)&(1<<U)-1,n+=U}if(n>j){w&&N(0);break}l&&h(f+131072);var dr=f+lr;if(f<D){var vr=u-D,ne=Math.min(D,dr);for(vr+f<0&&N(3);f<ne;++f)t[f]=o[vr+f]}for(;f<dr;++f)t[f]=t[f-D]}}r.l=i,r.p=G,r.b=f,r.f=s,i&&(s=1,r.m=g,r.d=p,r.n=b)}while(!s);return f!=t.length&&d?Br(t,0,f):t.subarray(0,f)},$r=new A(0),zr=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&N(6,"invalid gzip data");var r=e[3],t=10;r&4&&(t+=(e[10]|e[11]<<8)+2);for(var o=(r>>3&1)+(r>>4&1);o>0;o-=!e[t++]);return t+(r&2)},Ir=function(e){var r=e.length;return(e[r-4]|e[r-3]<<8|e[r-2]<<16|e[r-1]<<24)>>>0};function or(e,r){var t=zr(e);return t+8>e.length&&N(6,"invalid gzip data"),Mr(e.subarray(t,-8),{i:2},new A(Ir(e)),r)}var Ur=typeof TextDecoder<"u"&&new TextDecoder,Vr=0;try{Ur.decode($r,{stream:!0}),Vr=1}catch{}function Rr(e){return e.length>=2&&e[0]===31&&e[1]===139}function Lr(e){try{return or(new Uint8Array(e))}catch(r){throw new Error(`gunzip: ${r instanceof Error?r.message:String(r)}`)}}const Pr=new TextEncoder().encode("NDAV2");function qr(e){if(e.length<5)return!1;for(let r=0;r<5;r++)if(e[r]!==Pr[r])return!1;return!0}function ir(e){let r=new Uint8Array(e);const t=8;for(let o=0;o<t;o++){if(qr(r))return r;if(Rr(r))try{r=or(r);continue}catch(u){throw new Error(`prepareNdav2ChunkPayload: gunzip layer ${o}: ${u instanceof Error?u.message:String(u)}`)}const a=r.length?[...r.subarray(0,Math.min(16,r.length))].map(u=>u.toString(16).padStart(2,"0")).join(" "):"empty";throw new Error(`prepareNdav2ChunkPayload: expected gzip or NDAV2, got bytes: ${a}`)}throw new Error("prepareNdav2ChunkPayload: too many gzip layers")}async function Hr(e){let r=e;return e[0]===31&&e[1]===139&&(r=Lr(new Uint8Array(e).buffer)),Wr(r)}async function Wr(e){const r=new TextDecoder;if(!r.decode(e.slice(0,8)).startsWith("NDA"))return;const o=[];let a,u;for(let i=8;i<1024;i++){if(u=e[i],u===10){a=i+1;break}o.push(u)}if(a===void 0)return;const d=r.decode(new Uint8Array(o)),l=JSON.parse(d),w=l.shape;let h=1;for(const i of w)h*=i;const s=new DataView(e.buffer,e.byteOffset+a),n=l.endian!=="little";let f=new Float32Array;switch(l.dataType){case"float32":{f=new Float32Array(h);for(let i=0;i<h;i++)f[i]=s.getFloat32(i*4,!n);break}}return Er(f,w)}function Gr(e){const r=Math.min(e.length,128);let t="";for(let o=0;o<r;o++)t+=String.fromCharCode(e[o]);return/^\\s*</.test(t)}async function sr(e){let r;try{r=await fetch(e,{credentials:"omit",mode:"cors",cache:"no-store",headers:{Accept:"*/*","Accept-Encoding":"identity"}})}catch(a){const u=/myhuaweicloud|amazonaws|aliyuncs|qcloud|obs\\./i.test(e)||e.includes(".obs."),d=a instanceof Error?a.message:String(a);throw u||/failed to fetch|networkerror|aborted|canceled/i.test(d)?new Error(d):a}if(!r.ok)throw new Error(`HTTP ${r.status} ${r.statusText}: ${e}`);const t=await r.arrayBuffer(),o=new Uint8Array(t);if(Gr(o)){const a=new TextDecoder("utf-8",{fatal:!1}).decode(o.subarray(0,256));throw new Error(`fetch chunk: expected binary, got HTML/XML: ${a.slice(0,120)}`)}return t}function fr(e,r){const t=r||self.location.origin;return new URL(e,t+"/").href}self.onmessage=async e=>{const r=e.data;try{if(r.mode==="single"){const{shape:u,frames:d,transfers:l}=await Kr(r.url,r.pageOrigin);self.postMessage({uuid:r.uuid,shape:u,frames:d,startFrameIndex:0},{transfer:l});return}if(r.mode==="chunkBytes"){const{shape:u,frames:d,transfers:l}=ur(r.arrayBuffer,r.grids,r.chunkFrameCount,r.xs,r.ys,r.zs);self.postMessage({uuid:r.uuid,shape:u,frames:d,startFrameIndex:r.startFrameIndex},{transfer:l});return}if(r.mode==="chunkFrameBytes"){const{shape:u,frame:d,transfers:l}=Qr(r.arrayBuffer,r.grids,r.chunkFrameCount,r.xs,r.ys,r.zs,r.localFrameIndex);self.postMessage({uuid:r.uuid,shape:u,frame:d,startFrameIndex:r.startFrameIndex},{transfer:l});return}const{shape:t,frames:o,transfers:a}=await Yr(r.chunkUrl,r.grids,r.chunkFrameCount,r.xs,r.ys,r.zs,r.pageOrigin);self.postMessage({uuid:r.uuid,shape:t,frames:o,startFrameIndex:r.startFrameIndex},{transfer:a})}catch(t){self.postMessage({uuid:r.uuid,error:t instanceof Error?t.message:String(t)})}};function Jr(e,r,t,o,a){const u={width:e,height:r,depth:t},d=[],l=[],w=e*r*t;for(let h=0;h<o;h++){const s=new Uint8ClampedArray(w);let n=0;for(let f=0;f<t;f++)for(let i=0;i<r;i++)for(let p=0;p<e;p++)s[n++]=a(p,i,f,h);l.push(s.buffer),d.push(s)}return{shape:u,frames:d,transfers:l}}function Xr(e,r,t,o){const a={width:e,height:r,depth:t},u=new Uint8ClampedArray(e*r*t),d=[u.buffer];let l=0;for(let w=0;w<t;w++)for(let h=0;h<r;h++)for(let s=0;s<e;s++)u[l++]=o(s,h,w);return{shape:a,frame:u,transfers:d}}async function Kr(e,r){const t=fr(e,r),o=new Uint8Array(await sr(t)),a=await Hr(o);if(!a)throw new Error("readNdaSingle: not a valid NDA v1 (after optional gunzip)");const[u,d,l,w]=a.shape;return Jr(u,d,l,w,(h,s,n,f)=>a.get(h,s,n,f))}function ur(e,r,t,o,a,u){const d=ir(e);if(r!==t*o*a*u)throw new Error(`chunk: grids ${r} !== frames*nx*ny*nz ${t*o*a*u}`);const l=new TextDecoder().decode(d.subarray(0,8));if(!l.startsWith("NDAV2"))throw new Error(`NDAV2: bad magic ${JSON.stringify(l)}`);const w=8+r*4;if(d.byteLength!==w)throw new Error(`NDAV2: size mismatch need ${w} bytes, got ${d.byteLength}`);const h={width:o,height:a,depth:u},s=o*a*u,n=Array.from({length:t},()=>new Uint8ClampedArray(s)),f=n.map(p=>p.buffer),i=new DataView(d.buffer,d.byteOffset,d.byteLength);for(let p=0;p<o;p++)for(let g=0;g<a;g++)for(let b=0;b<u;b++){const j=b+u*(g+a*p),_=p+o*(g+a*b),m=8+t*j*4;for(let k=0;k<t;k++)n[k][_]=i.getFloat32(m+k*4,!1)}return{shape:h,frames:n,transfers:f}}function Qr(e,r,t,o,a,u,d){const l=ir(e);if(r!==t*o*a*u)throw new Error(`chunk: grids ${r} !== frames*nx*ny*nz ${t*o*a*u}`);if(d<0||d>=t)throw new Error(`chunk: localFrameIndex ${d} out of [0, ${t})`);const w=new TextDecoder().decode(l.subarray(0,8));if(!w.startsWith("NDAV2"))throw new Error(`NDAV2: bad magic ${JSON.stringify(w)}`);const h=8+r*4;if(l.byteLength!==h)throw new Error(`NDAV2: size mismatch need ${h} bytes, got ${l.byteLength}`);const s=new DataView(l.buffer,l.byteOffset,l.byteLength),n=(f,i,p)=>p+u*(i+a*f);return Xr(o,a,u,(f,i,p)=>{const g=d+t*n(f,i,p);return s.getFloat32(8+g*4,!1)})}async function Yr(e,r,t,o,a,u,d){const l=fr(e,d),w=await sr(l);return ur(w,r,t,o,a,u)}})();\n//# sourceMappingURL=read-simulate.worker-DoU45WSm.js.map\n', be = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", Me], { type: "text/javascript;charset=utf-8" });
190
+ function Ge(n) {
191
+ let e;
192
+ try {
193
+ if (e = be && (self.URL || self.webkitURL).createObjectURL(be), !e) throw "";
194
+ const r = new Worker(e, {
195
+ name: n?.name
196
+ });
197
+ return r.addEventListener("error", () => {
198
+ (self.URL || self.webkitURL).revokeObjectURL(e);
199
+ }), r;
200
+ } catch {
201
+ return new Worker(
202
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(Me),
203
+ {
204
+ name: n?.name
205
+ }
206
+ );
207
+ }
208
+ }
209
+ const Ke = 4.07, Qe = 282, ie = 1;
210
+ function er(n) {
211
+ return n.replaceAll("\\", "/").replace(/^\.?\//, "");
212
+ }
213
+ function Ee(n) {
214
+ return [...n.items].sort((e, r) => e.seq - r.seq);
215
+ }
216
+ function xe(n, e) {
217
+ const r = n.headers.shape[3];
218
+ if (e < 0 || e >= r || !Number.isInteger(e))
219
+ throw new Error(
220
+ `globalFrameIndex ${e} out of [0, ${r})`
221
+ );
222
+ const t = Ee(n);
223
+ let a = 0;
224
+ for (const i of t) {
225
+ if (e < a + i.frames)
226
+ return { item: i, chunkStartFrame: a };
227
+ a += i.frames;
228
+ }
229
+ throw new Error(`no chunk for globalFrameIndex ${e}`);
230
+ }
231
+ function rr(n, e, r) {
232
+ for (let t = 0; t < r; t++)
233
+ if (n[e + t] === void 0) return !1;
234
+ return !0;
235
+ }
236
+ function tr(n, e, r) {
237
+ const t = n.headers.shape[3];
238
+ if (t <= 0) return [];
239
+ const a = Math.max(0, Math.min(Math.min(e, r), t - 1)), i = Math.max(0, Math.min(Math.max(e, r), t - 1)), s = [], d = Ee(n);
240
+ let f = 0;
241
+ for (const c of d) {
242
+ const h = f + c.frames - 1;
243
+ i >= f && a <= h && s.push(f), f += c.frames;
244
+ }
245
+ return s;
246
+ }
247
+ function nr(n, e) {
248
+ const r = Math.min(
249
+ Math.max(e, 0),
250
+ Math.max(0, n.length - 1)
251
+ );
252
+ for (let t = r; t >= 0; t--)
253
+ if (n[t] !== void 0) return t;
254
+ for (let t = r + 1; t < n.length; t++)
255
+ if (n[t] !== void 0) return t;
256
+ return -1;
257
+ }
258
+ function he(n) {
259
+ return [...n.frames ?? []].sort((e, r) => e.seq - r.seq);
260
+ }
261
+ function ar(n, e, r, t) {
262
+ if (typeof t == "number" && t > 0 && Number.isFinite(t))
263
+ return t;
264
+ const a = n.simulationDurationSec;
265
+ if (typeof a == "number" && a > 0 && Number.isFinite(a))
266
+ return a;
267
+ if (r <= 1) return 0;
268
+ const i = he(e), s = i[i.length - 1];
269
+ return s && typeof s.time == "number" && s.time > 0 && Number.isFinite(s.time) ? s.time : (r - 1) * Ke / Math.max(1, Qe - 1);
270
+ }
271
+ function R(n, e) {
272
+ return Math.min(
273
+ Math.max(Number.isFinite(n) ? Math.floor(n) : 0, 0),
274
+ Math.max(0, e - 1)
275
+ );
276
+ }
277
+ function se(n, e, r, t) {
278
+ if (r <= 1) return 0;
279
+ const a = R(n, r), i = he(t ?? {}).find((s) => s.seq === a);
280
+ return i && typeof i.time == "number" && i.time >= 0 && Number.isFinite(i.time) ? i.time : le.mapLinear(a, 0, r - 1, 0, e);
281
+ }
282
+ function X(n, e, r, t) {
283
+ if (r <= 1) return 0;
284
+ const a = Math.min(
285
+ Math.max(Number.isFinite(n) ? n : 0, 0),
286
+ Math.max(0, e)
287
+ ), i = he(t ?? {});
288
+ if (i.length) {
289
+ let s = R(i[0].seq, r), d = Math.abs((i[0].time ?? 0) - a);
290
+ for (const f of i) {
291
+ if (typeof f.time != "number" || !Number.isFinite(f.time)) continue;
292
+ const c = Math.abs(f.time - a);
293
+ if (c <= d && (d = c, s = R(f.seq, r)), f.time > a && c > d) break;
294
+ }
295
+ return s;
296
+ }
297
+ return Math.min(
298
+ Math.max(Math.floor(le.mapLinear(a, 0, e, 0, r - 1)), 0),
299
+ r - 1
300
+ );
301
+ }
302
+ function ir(n) {
303
+ if (n.buffer instanceof ArrayBuffer && n.byteOffset === 0 && n.byteLength === n.buffer.byteLength)
304
+ return n.buffer;
305
+ const e = new ArrayBuffer(n.byteLength);
306
+ return new Uint8Array(e).set(n), e;
307
+ }
308
+ function sr(n) {
309
+ const e = new Ge(), r = /* @__PURE__ */ new Map();
310
+ let t = !1;
311
+ const a = (f) => {
312
+ r.forEach((c) => c.reject(f)), r.clear();
313
+ }, i = (f) => {
314
+ const c = f.data;
315
+ if (!c.uuid) return;
316
+ const h = r.get(c.uuid);
317
+ if (h) {
318
+ if (r.delete(c.uuid), c.error) {
319
+ h.reject(new Error(c.error));
320
+ return;
321
+ }
322
+ if (!c.frames || c.startFrameIndex === void 0) {
323
+ h.reject(new Error("fds worker: invalid response"));
324
+ return;
325
+ }
326
+ h.resolve({
327
+ frames: c.frames,
328
+ startFrameIndex: c.startFrameIndex
329
+ });
330
+ }
331
+ }, s = (f) => {
332
+ a(
333
+ f.error instanceof Error ? f.error : new Error(
334
+ [
335
+ f.message || "fds worker: unknown error",
336
+ f.filename,
337
+ f.lineno,
338
+ f.colno
339
+ ].filter(Boolean).join(" @ ")
340
+ )
341
+ );
342
+ }, d = () => {
343
+ a(new Error("fds worker: messageerror"));
344
+ };
345
+ return e.addEventListener("message", i), e.addEventListener("error", s), e.addEventListener("messageerror", d), {
346
+ /** 解码已经从 zip 中读出的分片字节。 */
347
+ readChunk(f, c, h) {
348
+ return t ? Promise.reject(new Error("fds worker: disposed")) : new Promise((o, l) => {
349
+ const g = le.generateUUID();
350
+ r.set(g, { resolve: o, reject: l }), e.postMessage(
351
+ {
352
+ uuid: g,
353
+ mode: "chunkBytes",
354
+ arrayBuffer: f,
355
+ grids: c.grids,
356
+ chunkFrameCount: c.frames,
357
+ xs: n.width,
358
+ ys: n.height,
359
+ zs: n.depth,
360
+ startFrameIndex: h
361
+ },
362
+ [f]
363
+ );
364
+ });
365
+ },
366
+ /** 终止 worker,并让所有挂起请求立刻失败。 */
367
+ dispose() {
368
+ t || (t = !0, a(new Error("fds worker: disposed")), e.removeEventListener("message", i), e.removeEventListener("error", s), e.removeEventListener("messageerror", d), e.terminate());
369
+ }
370
+ };
371
+ }
372
+ function or(n, e = n.viewport.scene) {
373
+ const r = new fe(), t = new fe(), a = n.viewport.scene;
374
+ return e.updateWorldMatrix(!0, !0), e.traverseVisible((i) => {
375
+ if (e === a && i === a) return;
376
+ let s = i;
377
+ for (; s; ) {
378
+ if (s.userData?.renderType === "FDS") return;
379
+ s = s.parent;
380
+ }
381
+ const d = i;
382
+ !d.isMesh && !d.isPoints && !d.isLine || (t.makeEmpty(), t.setFromObject(i), t.isEmpty() || r.union(t));
383
+ }), r;
384
+ }
385
+ function ur(n, e, r = n.viewport.scene) {
386
+ const t = n.viewport.scene, a = or(n, r), i = r !== t, s = new y();
387
+ r.updateWorldMatrix(!0, !0), i && r.getWorldPosition(s);
388
+ const d = i ? s.clone() : a.isEmpty() ? new y() : a.getCenter(new y()), f = new y(
389
+ e.width,
390
+ e.height,
391
+ e.depth
392
+ ), c = d.applyMatrix4(De), h = f.clone().multiplyScalar(0.5);
393
+ return new Te(
394
+ { x: e.width, y: e.height, z: e.depth },
395
+ {
396
+ minX: c.x - h.x,
397
+ minY: c.y - h.y,
398
+ minZ: c.z - h.z,
399
+ maxX: c.x + h.x,
400
+ maxY: c.y + h.y,
401
+ maxZ: c.z + h.z
402
+ }
403
+ );
404
+ }
405
+ var S = Uint8Array, J = Uint16Array, cr = Int32Array, Ae = new S([
406
+ 0,
407
+ 0,
408
+ 0,
409
+ 0,
410
+ 0,
411
+ 0,
412
+ 0,
413
+ 0,
414
+ 1,
415
+ 1,
416
+ 1,
417
+ 1,
418
+ 2,
419
+ 2,
420
+ 2,
421
+ 2,
422
+ 3,
423
+ 3,
424
+ 3,
425
+ 3,
426
+ 4,
427
+ 4,
428
+ 4,
429
+ 4,
430
+ 5,
431
+ 5,
432
+ 5,
433
+ 5,
434
+ 0,
435
+ /* unused */
436
+ 0,
437
+ 0,
438
+ /* impossible */
439
+ 0
440
+ ]), Ie = new S([
441
+ 0,
442
+ 0,
443
+ 0,
444
+ 0,
445
+ 1,
446
+ 1,
447
+ 2,
448
+ 2,
449
+ 3,
450
+ 3,
451
+ 4,
452
+ 4,
453
+ 5,
454
+ 5,
455
+ 6,
456
+ 6,
457
+ 7,
458
+ 7,
459
+ 8,
460
+ 8,
461
+ 9,
462
+ 9,
463
+ 10,
464
+ 10,
465
+ 11,
466
+ 11,
467
+ 12,
468
+ 12,
469
+ 13,
470
+ 13,
471
+ /* unused */
472
+ 0,
473
+ 0
474
+ ]), fr = new S([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), je = function(n, e) {
475
+ for (var r = new J(31), t = 0; t < 31; ++t)
476
+ r[t] = e += 1 << n[t - 1];
477
+ for (var a = new cr(r[30]), t = 1; t < 30; ++t)
478
+ for (var i = r[t]; i < r[t + 1]; ++i)
479
+ a[i] = i - r[t] << 5 | t;
480
+ return { b: r, r: a };
481
+ }, Ce = je(Ae, 2), ze = Ce.b, dr = Ce.r;
482
+ ze[28] = 258, dr[258] = 28;
483
+ var lr = je(Ie, 0), hr = lr.b, de = new J(32768);
484
+ for (var v = 0; v < 32768; ++v) {
485
+ var z = (v & 43690) >> 1 | (v & 21845) << 1;
486
+ z = (z & 52428) >> 2 | (z & 13107) << 2, z = (z & 61680) >> 4 | (z & 3855) << 4, de[v] = ((z & 65280) >> 8 | (z & 255) << 8) >> 1;
487
+ }
488
+ var Z = (function(n, e, r) {
489
+ for (var t = n.length, a = 0, i = new J(e); a < t; ++a)
490
+ n[a] && ++i[n[a] - 1];
491
+ var s = new J(e);
492
+ for (a = 1; a < e; ++a)
493
+ s[a] = s[a - 1] + i[a - 1] << 1;
494
+ var d;
495
+ if (r) {
496
+ d = new J(1 << e);
497
+ var f = 15 - e;
498
+ for (a = 0; a < t; ++a)
499
+ if (n[a])
500
+ for (var c = a << 4 | n[a], h = e - n[a], o = s[n[a] - 1]++ << h, l = o | (1 << h) - 1; o <= l; ++o)
501
+ d[de[o] >> f] = c;
502
+ } else
503
+ for (d = new J(t), a = 0; a < t; ++a)
504
+ n[a] && (d[a] = de[s[n[a] - 1]++] >> 15 - n[a]);
505
+ return d;
506
+ }), K = new S(288);
507
+ for (var v = 0; v < 144; ++v)
508
+ K[v] = 8;
509
+ for (var v = 144; v < 256; ++v)
510
+ K[v] = 9;
511
+ for (var v = 256; v < 280; ++v)
512
+ K[v] = 7;
513
+ for (var v = 280; v < 288; ++v)
514
+ K[v] = 8;
515
+ var Oe = new S(32);
516
+ for (var v = 0; v < 32; ++v)
517
+ Oe[v] = 5;
518
+ var mr = /* @__PURE__ */ Z(K, 9, 1), pr = /* @__PURE__ */ Z(Oe, 5, 1), oe = function(n) {
519
+ for (var e = n[0], r = 1; r < n.length; ++r)
520
+ n[r] > e && (e = n[r]);
521
+ return e;
522
+ }, T = function(n, e, r) {
523
+ var t = e / 8 | 0;
524
+ return (n[t] | n[t + 1] << 8) >> (e & 7) & r;
525
+ }, ue = function(n, e) {
526
+ var r = e / 8 | 0;
527
+ return (n[r] | n[r + 1] << 8 | n[r + 2] << 16) >> (e & 7);
528
+ }, vr = function(n) {
529
+ return (n + 7) / 8 | 0;
530
+ }, gr = function(n, e, r) {
531
+ return (r == null || r > n.length) && (r = n.length), new S(n.subarray(e, r));
532
+ }, wr = [
533
+ "unexpected EOF",
534
+ "invalid block type",
535
+ "invalid length/literal",
536
+ "invalid distance",
537
+ "stream finished",
538
+ "no stream handler",
539
+ ,
540
+ "no callback",
541
+ "invalid UTF-8 data",
542
+ "extra field too long",
543
+ "date not in range 1980-2099",
544
+ "filename too long",
545
+ "stream finishing",
546
+ "invalid zip data"
547
+ // determined by unknown compression method
548
+ ], A = function(n, e, r) {
549
+ var t = new Error(e || wr[n]);
550
+ if (t.code = n, Error.captureStackTrace && Error.captureStackTrace(t, A), !r)
551
+ throw t;
552
+ return t;
553
+ }, yr = function(n, e, r, t) {
554
+ var a = n.length, i = 0;
555
+ if (!a || e.f && !e.l)
556
+ return r || new S(0);
557
+ var s = !r, d = s || e.i != 2, f = e.i;
558
+ s && (r = new S(a * 3));
559
+ var c = function(ve) {
560
+ var ge = r.length;
561
+ if (ve > ge) {
562
+ var we = new S(Math.max(ge * 2, ve));
563
+ we.set(r), r = we;
564
+ }
565
+ }, h = e.f || 0, o = e.p || 0, l = e.b || 0, g = e.l, k = e.d, _ = e.m, M = e.n, L = a * 8;
566
+ do {
567
+ if (!g) {
568
+ h = T(n, o, 1);
569
+ var D = T(n, o + 1, 3);
570
+ if (o += 3, D)
571
+ if (D == 1)
572
+ g = mr, k = pr, _ = 9, M = 5;
573
+ else if (D == 2) {
574
+ var P = T(n, o, 31) + 257, B = T(n, o + 10, 15) + 4, $ = P + T(n, o + 5, 31) + 1;
575
+ o += 14;
576
+ for (var I = new S($), q = new S(19), b = 0; b < B; ++b)
577
+ q[fr[b]] = T(n, o + b * 3, 7);
578
+ o += B * 3;
579
+ for (var Q = oe(q), ee = (1 << Q) - 1, p = Z(q, Q, 1), b = 0; b < $; ) {
580
+ var w = p[T(n, o, ee)];
581
+ o += w & 15;
582
+ var u = w >> 4;
583
+ if (u < 16)
584
+ I[b++] = u;
585
+ else {
586
+ var m = 0, x = 0;
587
+ for (u == 16 ? (x = 3 + T(n, o, 3), o += 2, m = I[b - 1]) : u == 17 ? (x = 3 + T(n, o, 7), o += 3) : u == 18 && (x = 11 + T(n, o, 127), o += 7); x--; )
588
+ I[b++] = m;
589
+ }
590
+ }
591
+ var O = I.subarray(0, P), F = I.subarray(P);
592
+ _ = oe(O), M = oe(F), g = Z(O, _, 1), k = Z(F, M, 1);
593
+ } else
594
+ A(1);
595
+ else {
596
+ var u = vr(o) + 4, E = n[u - 4] | n[u - 3] << 8, V = u + E;
597
+ if (V > a) {
598
+ f && A(0);
599
+ break;
600
+ }
601
+ d && c(l + E), r.set(n.subarray(u, V), l), e.b = l += E, e.p = o = V * 8, e.f = h;
602
+ continue;
603
+ }
604
+ if (o > L) {
605
+ f && A(0);
606
+ break;
607
+ }
608
+ }
609
+ d && c(l + 131072);
610
+ for (var te = (1 << _) - 1, ne = (1 << M) - 1, W = o; ; W = o) {
611
+ var m = g[ue(n, o) & te], j = m >> 4;
612
+ if (o += m & 15, o > L) {
613
+ f && A(0);
614
+ break;
615
+ }
616
+ if (m || A(2), j < 256)
617
+ r[l++] = j;
618
+ else if (j == 256) {
619
+ W = o, g = null;
620
+ break;
621
+ } else {
622
+ var H = j - 254;
623
+ if (j > 264) {
624
+ var b = j - 257, U = Ae[b];
625
+ H = T(n, o, (1 << U) - 1) + ze[b], o += U;
626
+ }
627
+ var C = k[ue(n, o) & ne], ae = C >> 4;
628
+ C || A(3), o += C & 15;
629
+ var F = hr[ae];
630
+ if (ae > 3) {
631
+ var U = Ie[ae];
632
+ F += ue(n, o) & (1 << U) - 1, o += U;
633
+ }
634
+ if (o > L) {
635
+ f && A(0);
636
+ break;
637
+ }
638
+ d && c(l + 131072);
639
+ var me = l + H;
640
+ if (l < F) {
641
+ var pe = i - F, Ue = Math.min(F, me);
642
+ for (pe + l < 0 && A(3); l < Ue; ++l)
643
+ r[l] = t[pe + l];
644
+ }
645
+ for (; l < me; ++l)
646
+ r[l] = r[l - F];
647
+ }
648
+ }
649
+ e.l = g, e.p = W, e.b = l, e.f = h, g && (h = 1, e.m = _, e.d = k, e.n = M);
650
+ } while (!h);
651
+ return l != r.length && s ? gr(r, 0, l) : r.subarray(0, l);
652
+ }, br = /* @__PURE__ */ new S(0);
653
+ function xr(n, e) {
654
+ return yr(n, { i: 2 }, e, e);
655
+ }
656
+ var _r = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), Fr = 0;
657
+ try {
658
+ _r.decode(br, { stream: !0 }), Fr = 1;
659
+ } catch {
660
+ }
661
+ const _e = new TextDecoder();
662
+ function ce(n) {
663
+ return n.replaceAll("\\", "/").replace(/^\.?\//, "");
664
+ }
665
+ function N(n, e) {
666
+ return n.getUint16(e, !0);
667
+ }
668
+ function Y(n, e) {
669
+ return n.getUint32(e, !0);
670
+ }
671
+ function Sr(n) {
672
+ const e = Math.max(0, n.length - 65535 - 22);
673
+ for (let r = n.length - 22; r >= e; r--)
674
+ if (n[r] === 80 && n[r + 1] === 75 && n[r + 2] === 5 && n[r + 3] === 6)
675
+ return r;
676
+ throw new Error("zip: end of central directory not found");
677
+ }
678
+ class Dr {
679
+ #r;
680
+ #e;
681
+ #t = /* @__PURE__ */ new Map();
682
+ constructor(e) {
683
+ this.#r = e instanceof Uint8Array ? e : new Uint8Array(e), this.#e = new DataView(
684
+ this.#r.buffer,
685
+ this.#r.byteOffset,
686
+ this.#r.byteLength
687
+ ), this.#n();
688
+ }
689
+ /** 判断指定文件是否存在于 zip 包中。 */
690
+ has(e) {
691
+ return this.#t.has(ce(e));
692
+ }
693
+ /** 读取并按压缩方式解出指定文件的原始字节。 */
694
+ read(e) {
695
+ const r = ce(e), t = this.#t.get(r);
696
+ if (!t)
697
+ throw new Error(`zip: entry not found: ${r}`);
698
+ const a = t.localHeaderOffset;
699
+ if (Y(this.#e, a) !== 67324752)
700
+ throw new Error(`zip: invalid local header for ${r}`);
701
+ const s = N(this.#e, a + 26), d = N(this.#e, a + 28), f = a + 30 + s + d, c = f + t.compressedSize, h = this.#r.slice(f, c);
702
+ if (t.compressionMethod === 0)
703
+ return h;
704
+ if (t.compressionMethod === 8)
705
+ return xr(h);
706
+ throw new Error(
707
+ `zip: unsupported compression method ${t.compressionMethod} for ${r}`
708
+ );
709
+ }
710
+ /** 读取文本文件。 */
711
+ readText(e) {
712
+ return _e.decode(this.read(e));
713
+ }
714
+ /** 读取 JSON 文件并直接反序列化。 */
715
+ readJson(e) {
716
+ return JSON.parse(this.readText(e));
717
+ }
718
+ /** 扫描中央目录并建立文件名到条目的索引。 */
719
+ #n() {
720
+ const e = Sr(this.#r), r = N(this.#e, e + 10);
721
+ let a = Y(this.#e, e + 16);
722
+ for (let i = 0; i < r; i++) {
723
+ if (Y(this.#e, a) !== 33639248)
724
+ throw new Error("zip: invalid central directory entry");
725
+ const d = N(this.#e, a + 10), f = Y(this.#e, a + 20), c = N(this.#e, a + 28), h = N(this.#e, a + 30), o = N(this.#e, a + 32), l = Y(this.#e, a + 42), g = a + 46, k = g + c, _ = ce(
726
+ _e.decode(this.#r.slice(g, k))
727
+ );
728
+ this.#t.set(_, {
729
+ name: _,
730
+ compressionMethod: d,
731
+ compressedSize: f,
732
+ localHeaderOffset: l
733
+ }), a = k + h + o;
734
+ }
735
+ }
736
+ }
737
+ async function Tr(n, e, r, t = {}) {
738
+ const a = ["temperature", "soot_density", "hrrpuv"], i = await fetch(e);
739
+ if (!i.ok)
740
+ throw new Error(`HTTP ${i.status} ${i.statusText}: ${e}`);
741
+ const s = new Dr(await i.arrayBuffer()), d = t.field ? s.has(`${t.field}/simulates.json`) ? t.field : void 0 : a.find((p) => s.has(`${p}/simulates.json`));
742
+ if (!d)
743
+ throw new Error(
744
+ t.field ? `fds zip: field not found: ${t.field}` : "fds zip: no supported field found"
745
+ );
746
+ const f = s.readJson(`${d}/simulates.json`), c = s.readJson(`${d}/slice.json`), h = {
747
+ width: f.headers.shape[0],
748
+ height: f.headers.shape[1],
749
+ depth: f.headers.shape[2]
750
+ }, o = f.headers.shape[3], l = ar(
751
+ f,
752
+ c,
753
+ o,
754
+ t.simulationDurationSec
755
+ ), g = Math.min(
756
+ Math.max(t.initialTimeSec ?? 0, 0),
757
+ Math.max(0, l)
758
+ ), k = X(
759
+ g,
760
+ l,
761
+ o,
762
+ c
763
+ ), _ = Array.from({ length: o }, () => {
764
+ }), M = /* @__PURE__ */ new Map(), L = sr(h);
765
+ let D = !1, u = null;
766
+ const E = () => {
767
+ if (D || !u) return u;
768
+ const p = Math.min(
769
+ Math.max(Number(u.userData.fdsCurrentTimeSec ?? g), 0),
770
+ l
771
+ ), w = X(
772
+ p,
773
+ l,
774
+ o,
775
+ c
776
+ ), m = nr(_, w);
777
+ if (m < 0) return u;
778
+ const x = _[m];
779
+ return x && (u.userData.fdsRenderedTimeSec = se(
780
+ m,
781
+ l,
782
+ o,
783
+ c
784
+ ), u.userData.fdsRenderedFrameIndex = m, u.userData.frameIndex !== m && (u.userData.frameIndex = m, u.updateData(x), n.render())), u;
785
+ }, V = (p) => {
786
+ if (D) return Promise.resolve();
787
+ const w = R(p, o), { item: m, chunkStartFrame: x } = xe(
788
+ f,
789
+ w
790
+ );
791
+ if (rr(_, x, m.frames))
792
+ return Promise.resolve();
793
+ const O = M.get(x);
794
+ if (O) return O;
795
+ const F = (async () => {
796
+ try {
797
+ const te = er(`${d}/${m.url}`), ne = s.read(te), { frames: W, startFrameIndex: j } = await L.readChunk(
798
+ ir(ne),
799
+ m,
800
+ x
801
+ );
802
+ if (D) return;
803
+ const H = R(j, o), U = Math.min(
804
+ W.length,
805
+ o - H
806
+ );
807
+ for (let C = 0; C < U; C++)
808
+ _[H + C] = W[C];
809
+ E();
810
+ } finally {
811
+ M.delete(x);
812
+ }
813
+ })();
814
+ return M.set(x, F), F;
815
+ }, P = (p) => {
816
+ const w = R(p, o), { chunkStartFrame: m } = xe(
817
+ f,
818
+ w
819
+ );
820
+ return V(m);
821
+ }, B = (p, w) => {
822
+ if (D) return Promise.resolve();
823
+ const m = X(
824
+ p,
825
+ l,
826
+ o,
827
+ c
828
+ ), x = X(
829
+ w,
830
+ l,
831
+ o,
832
+ c
833
+ ), O = tr(
834
+ f,
835
+ m,
836
+ x
837
+ );
838
+ return Promise.all(
839
+ O.map((F) => V(F))
840
+ ).then(() => {
841
+ });
842
+ }, $ = (p) => {
843
+ const w = Math.min(
844
+ p + ie,
845
+ l
846
+ );
847
+ B(p, w).catch((m) => console.error("[loadFDS] prefetch failed", m));
848
+ };
849
+ await B(
850
+ g,
851
+ Math.min(
852
+ g + ie,
853
+ l
854
+ )
855
+ );
856
+ const I = _[k], q = k;
857
+ if (!I)
858
+ throw new Error("fds: no renderable frame found");
859
+ const b = t.meshIjk && t.meshXb ? new Te(t.meshIjk, t.meshXb) : ur(
860
+ n,
861
+ h,
862
+ r ?? n.viewport.scene
863
+ ), Q = b.xb.getCenter(new y());
864
+ u = new Ze(h), u.name = `fds/${d}`, u.userData.renderType = "FDS", u.userData.stype = "FDS", u.userData.fdsField = d, u.userData.fdsUrl = e, u.userData.frameIndex = q, u.userData.fdsCurrentTimeSec = g, u.userData.fdsRenderedFrameIndex = q, u.userData.fdsRenderedTimeSec = g, u.userData.fdsTotalFrames = o, u.userData.fdsSimulationDurationSec = l, u.userData.fdsInitialTimeSec = g, u.userData.fdsFrameToTime = (p) => se(p, l, o, c), u.userData.fdsTimeToFrame = (p) => X(p, l, o, c), u.userData.fdsPrefetchTimeWindow = (p, w = p + ie) => B(p, w), u.updateData(I), u.scale.copy(b.size), u.position.copy(Q), u.applyMatrix4(re), u.material.uniforms.lutMap.value = d === "soot_density" ? ke : Ye, u.material.uniforms.isSoot.value = d === "soot_density" ? 1 : 0, u.onBeforeRender = (p, w, m) => {
865
+ u.updateCamera(m.position);
866
+ };
867
+ const ee = () => {
868
+ D || (D = !0, M.clear(), L.dispose());
869
+ };
870
+ return u.addEventListener("removed", ee), u.userData.fdsDispose = ee, u.userData.fdsSetFrame = async (p) => {
871
+ if (D) return u;
872
+ const w = R(p, o), m = se(
873
+ w,
874
+ l,
875
+ o,
876
+ c
877
+ );
878
+ return u.userData.fdsCurrentTimeSec = m, $(m), E(), await P(w), E(), n.render(), u;
879
+ }, u.userData.fdsSetTime = async (p) => {
880
+ const w = Math.min(
881
+ Math.max(Number.isFinite(p) ? p : 0, 0),
882
+ l
883
+ ), m = X(
884
+ w,
885
+ l,
886
+ o,
887
+ c
888
+ );
889
+ return u.userData.fdsCurrentTimeSec = w, $(w), E(), await P(m), E(), n.render(), u;
890
+ }, $(g), n.attachObject(u, r), n.render(), u;
891
+ }
892
+ let kr = 0;
893
+ function Fe(n) {
894
+ const e = Number(n);
895
+ return Number.isFinite(e) ? e : void 0;
896
+ }
897
+ class Ar extends We {
898
+ constructor(e, r = {}) {
899
+ super(), this.ssp = e, this._options = { ...r };
900
+ }
901
+ _options;
902
+ _volumes = [];
903
+ _activeVolume = null;
904
+ _playing = !1;
905
+ _rafId = 0;
906
+ _playStartedAt = 0;
907
+ _playStartedTime = 0;
908
+ _lastRequestedFrameIndex = -1;
909
+ _lastRenderedFrameIndex = -1;
910
+ _readonlyId = `fds-manager-${++kr}`;
911
+ get id() {
912
+ return this._readonlyId;
913
+ }
914
+ get volumes() {
915
+ return [...this._volumes];
916
+ }
917
+ get activeVolume() {
918
+ return this._activeVolume;
919
+ }
920
+ get isPlaying() {
921
+ return this._playing;
922
+ }
923
+ setOptions(e) {
924
+ return this._options = {
925
+ ...this._options,
926
+ ...e
927
+ }, this;
928
+ }
929
+ getState() {
930
+ const e = this._activeVolume, r = this._getRenderedTime(
931
+ e,
932
+ this._getCurrentTime(e)
933
+ );
934
+ return {
935
+ activeVolume: e,
936
+ activeIndex: e ? this._volumes.indexOf(e) : -1,
937
+ volumes: [...this._volumes],
938
+ count: this._volumes.length,
939
+ playing: this._playing,
940
+ field: e?.userData?.fdsField,
941
+ source: e?.userData?.fdsSource ?? null,
942
+ currentTimeSec: this._getCurrentTime(e, r),
943
+ renderedTimeSec: r,
944
+ durationSec: this._getDuration(e),
945
+ totalFrames: Number(e?.userData?.fdsTotalFrames || 0),
946
+ renderedFrameIndex: this._getRenderedFrameIndex(e)
947
+ };
948
+ }
949
+ async load(e, r = {}) {
950
+ const t = await this._resolveLoadSources(e);
951
+ this.pause(), r.clearBeforeLoad !== !1 && this._clear(!1);
952
+ const a = await Promise.all(
953
+ t.map((d) => this._loadOne(d, r))
954
+ ), i = Math.min(
955
+ Math.max(r.activeIndex ?? 0, 0),
956
+ Math.max(a.length - 1, 0)
957
+ );
958
+ this._setActiveVolume(a[i] ?? this._volumes[0] ?? null, !1);
959
+ const s = this.getState();
960
+ return this.dispatchEvent({
961
+ type: "loaded",
962
+ sources: t,
963
+ volumes: a,
964
+ state: s
965
+ }), this.dispatchEvent({
966
+ type: "statechange",
967
+ state: s
968
+ }), a;
969
+ }
970
+ clear() {
971
+ return this._clear(!0);
972
+ }
973
+ setActiveVolume(e) {
974
+ const r = this._resolveVolume(e);
975
+ return this._setActiveVolume(r);
976
+ }
977
+ async setTime(e, r = {}) {
978
+ const t = this._resolveVolume(r.volume), a = t?.userData?.fdsSetTime;
979
+ if (!t || typeof a != "function") return t ?? null;
980
+ const i = Math.min(
981
+ Math.max(Number(e || 0), 0),
982
+ this._getDuration(t)
983
+ );
984
+ try {
985
+ const s = a(i);
986
+ return r.wait === !1 ? Promise.resolve(s).then(async () => {
987
+ await this.ssp.render(), this.dispatchEvent({
988
+ type: "statechange",
989
+ state: this.getState()
990
+ });
991
+ }).catch((d) => {
992
+ this.pause(), this.dispatchEvent({
993
+ type: "error",
994
+ error: d
995
+ });
996
+ }) : (await s, await this.ssp.render(), this.dispatchEvent({
997
+ type: "statechange",
998
+ state: this.getState()
999
+ })), t;
1000
+ } catch (s) {
1001
+ throw this.pause(), this.dispatchEvent({
1002
+ type: "error",
1003
+ error: s
1004
+ }), s;
1005
+ }
1006
+ }
1007
+ play(e) {
1008
+ const r = this._resolveVolume(e);
1009
+ if (!r) return !1;
1010
+ const t = this._getDuration(r);
1011
+ if (t <= 0)
1012
+ return this.pause(), !1;
1013
+ this._setActiveVolume(r, !1), this._playing && this.pause();
1014
+ const a = this._getRenderedTime(
1015
+ r,
1016
+ this._getCurrentTime(r)
1017
+ );
1018
+ this._playing = !0, this._playStartedAt = performance.now(), this._playStartedTime = a >= t ? 0 : a, this._lastRequestedFrameIndex = -1, this._lastRenderedFrameIndex = this._getRenderedFrameIndex(r), a >= t && this.setTime(0), this.dispatchEvent({
1019
+ type: "statechange",
1020
+ state: this.getState()
1021
+ });
1022
+ const i = () => {
1023
+ const s = this._activeVolume;
1024
+ if (!this._playing || !s) return;
1025
+ const d = this._getDuration(s);
1026
+ if (d <= 0) {
1027
+ this.pause();
1028
+ return;
1029
+ }
1030
+ const f = (performance.now() - this._playStartedAt) / 1e3, c = Math.min(
1031
+ d,
1032
+ this._playStartedTime + f
1033
+ ), h = this._getTimeFrameIndex(
1034
+ s,
1035
+ c
1036
+ );
1037
+ h !== this._lastRequestedFrameIndex && (this._lastRequestedFrameIndex = h, this.setTime(c, {
1038
+ wait: !1,
1039
+ volume: s
1040
+ }));
1041
+ const o = this._getRenderedFrameIndex(s), l = this._getRenderedTime(
1042
+ s,
1043
+ c
1044
+ );
1045
+ if (o !== this._lastRenderedFrameIndex && (this._lastRenderedFrameIndex = o, this.dispatchEvent({
1046
+ type: "statechange",
1047
+ state: this.getState()
1048
+ }), this.ssp.render()), c >= d && l >= d - 1e-3) {
1049
+ this.pause();
1050
+ return;
1051
+ }
1052
+ this._rafId = globalThis.requestAnimationFrame(i);
1053
+ };
1054
+ return this._rafId = globalThis.requestAnimationFrame(i), !0;
1055
+ }
1056
+ pause() {
1057
+ return !this._playing && !this._rafId ? !1 : (this._playing = !1, this._rafId && (globalThis.cancelAnimationFrame(this._rafId), this._rafId = 0), this.dispatchEvent({
1058
+ type: "statechange",
1059
+ state: this.getState()
1060
+ }), !0);
1061
+ }
1062
+ togglePlay(e) {
1063
+ return this._playing ? !this.pause() : this.play(e);
1064
+ }
1065
+ dispose() {
1066
+ this.pause(), this._clear(!1);
1067
+ }
1068
+ async _loadOne(e, r) {
1069
+ const t = this._getSourcePath(e);
1070
+ if (!t)
1071
+ throw new Error("fds: source path is required");
1072
+ const a = this._resolveUrl(t, e);
1073
+ this._removeDuplicates(a, e);
1074
+ const i = await Tr(
1075
+ this.ssp,
1076
+ a,
1077
+ this._resolveParent(e),
1078
+ {
1079
+ field: r.field,
1080
+ meshIjk: e.meshIjk,
1081
+ meshXb: e.meshXb,
1082
+ simulationDurationSec: Fe(e.simulationTime) ?? r.simulationDurationSec,
1083
+ initialTimeSec: Fe(e.initialTimeSec) ?? r.initialTimeSec ?? 0
1084
+ }
1085
+ );
1086
+ i.name = e.name || i.name, i.visible = e.visible !== !1, i.userData.fdsManagerId = this.id, i.userData.fdsSource = e, i.userData.fdsNodeId = e.nodeId, i.userData.id = e.id, i.userData.sid = e.sid;
1087
+ const s = () => {
1088
+ i.removeEventListener("removed", s), Reflect.deleteProperty(i.userData, "fdsManagerOnRemoved"), this._untrackVolume(i);
1089
+ };
1090
+ return i.userData.fdsManagerOnRemoved = s, i.addEventListener("removed", s), this._trackVolume(i), i;
1091
+ }
1092
+ _resolveUrl(e, r) {
1093
+ return this._options.resolveUrl?.(e, r) ?? e;
1094
+ }
1095
+ _resolveParent(e) {
1096
+ return e && Reflect.has(e, "parent") ? e.parent : this._options.resolveParent?.(e) ?? null;
1097
+ }
1098
+ async _resolveLoadSources(e) {
1099
+ if (e != null)
1100
+ return this._normalizeSources(e);
1101
+ let r = [];
1102
+ try {
1103
+ r = (await this._options.getSources?.() ?? []).filter((a) => a.visible !== !1 && !!this._getSourcePath(a)).sort((a, i) => (a.order ?? 0) - (i.order ?? 0));
1104
+ } catch (t) {
1105
+ if (!this._options.fallbackUrl)
1106
+ throw t;
1107
+ }
1108
+ return r.length ? r : this._options.fallbackUrl ? [{ path: this._options.fallbackUrl }] : [];
1109
+ }
1110
+ _normalizeSources(e) {
1111
+ return (Array.isArray(e) ? e : [e]).map(
1112
+ (t) => typeof t == "string" ? { path: t } : t
1113
+ ).filter((t) => !!this._getSourcePath(t));
1114
+ }
1115
+ _getSourcePath(e) {
1116
+ return e?.url || e?.path || "";
1117
+ }
1118
+ _trackVolume(e) {
1119
+ this._volumes.includes(e) || this._volumes.push(e);
1120
+ }
1121
+ _untrackVolume(e) {
1122
+ const r = this._volumes.indexOf(e);
1123
+ if (r >= 0 && this._volumes.splice(r, 1), this._activeVolume === e) {
1124
+ this.pause(), this._activeVolume = this._volumes[0] ?? null;
1125
+ const t = this.getState();
1126
+ this.dispatchEvent({
1127
+ type: "activechange",
1128
+ volume: this._activeVolume,
1129
+ state: t
1130
+ }), this.dispatchEvent({
1131
+ type: "statechange",
1132
+ state: t
1133
+ });
1134
+ }
1135
+ }
1136
+ _setActiveVolume(e, r = !0) {
1137
+ if (this._activeVolume === e) return e;
1138
+ if (this._playing && this.pause(), this._activeVolume = e, r) {
1139
+ const t = this.getState();
1140
+ this.dispatchEvent({
1141
+ type: "activechange",
1142
+ volume: e,
1143
+ state: t
1144
+ }), this.dispatchEvent({
1145
+ type: "statechange",
1146
+ state: t
1147
+ });
1148
+ }
1149
+ return e;
1150
+ }
1151
+ _resolveVolume(e) {
1152
+ return e == null ? this._activeVolume : typeof e == "number" ? this._volumes[e] ?? null : typeof e == "string" ? this._volumes.find(
1153
+ (r) => r.userData?.id === e || r.userData?.sid === e || r.userData?.fdsUrl === e || r.name === e
1154
+ ) ?? null : e;
1155
+ }
1156
+ _removeDuplicates(e, r) {
1157
+ const t = /* @__PURE__ */ new Set(), a = (i) => {
1158
+ i.filter((s) => s.userData?.renderType === "FDS").forEach((s) => t.add(s));
1159
+ };
1160
+ a(
1161
+ this.ssp.getObjectByUserDataProperty("fdsUrl", e)
1162
+ ), r.id && a(
1163
+ this.ssp.getObjectByUserDataProperty("id", r.id)
1164
+ ), r.sid && a(
1165
+ this.ssp.getObjectByUserDataProperty("sid", r.sid)
1166
+ ), t.forEach((i) => this.ssp.removeObject(i));
1167
+ }
1168
+ _clear(e) {
1169
+ this.pause();
1170
+ const r = [...this._volumes];
1171
+ if (this._volumes = [], this._activeVolume = null, r.forEach((t) => {
1172
+ const a = t.userData?.fdsManagerOnRemoved;
1173
+ a && (t.removeEventListener("removed", a), Reflect.deleteProperty(t.userData, "fdsManagerOnRemoved")), t.parent && this.ssp.removeObject(t);
1174
+ }), this.ssp.render(), e) {
1175
+ const t = this.getState();
1176
+ this.dispatchEvent({
1177
+ type: "clear",
1178
+ count: r.length,
1179
+ state: t
1180
+ }), this.dispatchEvent({
1181
+ type: "statechange",
1182
+ state: t
1183
+ });
1184
+ }
1185
+ return r.length;
1186
+ }
1187
+ _getDuration(e) {
1188
+ return Math.max(
1189
+ 0,
1190
+ Number(e?.userData?.fdsSimulationDurationSec || 0)
1191
+ );
1192
+ }
1193
+ _getCurrentTime(e, r = 0) {
1194
+ const t = Number(e?.userData?.fdsCurrentTimeSec);
1195
+ return Number.isFinite(t) ? t : r;
1196
+ }
1197
+ _getRenderedTime(e, r = 0) {
1198
+ const t = Number(e?.userData?.fdsRenderedTimeSec);
1199
+ if (Number.isFinite(t))
1200
+ return t;
1201
+ const a = Number(e?.userData?.frameIndex || 0), i = e?.userData?.fdsFrameToTime;
1202
+ return typeof i == "function" ? Number(i(a) || 0) : r;
1203
+ }
1204
+ _getRenderedFrameIndex(e) {
1205
+ const r = Number(
1206
+ e?.userData?.fdsRenderedFrameIndex ?? e?.userData?.frameIndex
1207
+ );
1208
+ return Number.isFinite(r) ? r : -1;
1209
+ }
1210
+ _getTimeFrameIndex(e, r) {
1211
+ const t = e?.userData?.fdsTimeToFrame;
1212
+ if (typeof t == "function") {
1213
+ const a = Number(t(r));
1214
+ if (Number.isFinite(a))
1215
+ return a;
1216
+ }
1217
+ return Math.floor(Number(r || 0) * 10);
1218
+ }
1219
+ }
1220
+ export {
1221
+ Ar as FdsManager,
1222
+ Te as FdsMesh,
1223
+ Ze as VolumePoints,
1224
+ re as fdsSpaceMatrix,
1225
+ Tr as loadFDS,
1226
+ Ye as rainbowCanvasTexture,
1227
+ ke as sootCanvasTexture,
1228
+ De as threeToFdsSpaceMatrix
1229
+ };
1230
+ //# sourceMappingURL=index.esm.js.map