@rr0/ufoathome 0.82.0 → 0.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-embed-scene/GLTFLoader-Czs7cUF3.js +1 -0
- package/dist-embed-scene/TraceSystem-Dp96YLHP.js +393 -0
- package/dist-embed-scene/rr0-scene.mjs +292 -292
- package/{dist-embed-sighting/sightingSchema-DPmD0qU1.js → dist-embed-scene/sightingSchema-DKClwkcL.js} +1 -1
- package/dist-embed-sighting/GLTFLoader-DM7BMbOJ.js +1 -0
- package/dist-embed-sighting/TraceSystem-DnHRjAAa.js +393 -0
- package/dist-embed-sighting/rr0-sighting.mjs +298 -298
- package/{dist-embed-scene/sightingSchema-DPmD0qU1.js → dist-embed-sighting/sightingSchema-DKClwkcL.js} +1 -1
- package/dist-embed-sighting-editor/{BodyEditor-CxM4nkOh.js → BodyEditor-B_FBjZDB.js} +1 -1
- package/dist-embed-sighting-editor/GLTFLoader-CeSfzvnP.js +1 -0
- package/dist-embed-sighting-editor/KmlImport-ByKlq2_E.js +1 -0
- package/dist-embed-sighting-editor/TraceSystem-CpMPdYmA.js +393 -0
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +284 -284
- package/dist-embed-sighting-editor/{sightingSchema-DPmD0qU1.js → sightingSchema-DKClwkcL.js} +1 -1
- package/package.json +1 -1
- package/dist-embed-scene/GLTFLoader-BiWo7Jv-.js +0 -1
- package/dist-embed-scene/TraceSystem-CPyRzYo1.js +0 -393
- package/dist-embed-sighting/GLTFLoader-Chc8N3y_.js +0 -1
- package/dist-embed-sighting/TraceSystem-D2JZ_egI.js +0 -393
- package/dist-embed-sighting-editor/GLTFLoader-Bw5fsIgy.js +0 -1
- package/dist-embed-sighting-editor/KmlImport-BsDWuc4E.js +0 -1
- package/dist-embed-sighting-editor/TraceSystem-zKycyfkp.js +0 -393
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
import{I as Y,F as H,a as j,b as A,W as ee,B as G,d as Z,V as E,e as te,f as O,U as $,g as ie,h as I,M as ne,i as B,L as se,j as oe,k as re,G as ae,C as le,D as de,l as ce,P as fe,m as ue,n as pe}from"./rr0-sighting.mjs";const V=new G,P=new E;class J extends Y{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],i=[-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 H(e,3)),this.setAttribute("uv",new H(i,2))}applyMatrix4(e){const i=this.attributes.instanceStart,n=this.attributes.instanceEnd;return i!==void 0&&(i.applyMatrix4(e),n.applyMatrix4(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let i;e instanceof Float32Array?i=e:Array.isArray(e)&&(i=new Float32Array(e));const n=new j(i,6,1);return this.setAttribute("instanceStart",new A(n,3,0)),this.setAttribute("instanceEnd",new A(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let i;e instanceof Float32Array?i=e:Array.isArray(e)&&(i=new Float32Array(e));const n=new j(i,6,1);return this.setAttribute("instanceColorStart",new A(n,3,0)),this.setAttribute("instanceColorEnd",new A(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 ee(e.geometry)),this}fromLineSegments(e){const i=e.geometry;return this.setPositions(i.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new G);const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;e!==void 0&&i!==void 0&&(this.boundingBox.setFromBufferAttribute(e),V.setFromBufferAttribute(i),this.boundingBox.union(V))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Z),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;if(e!==void 0&&i!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let t=0;for(let a=0,o=e.count;a<o;a++)P.fromBufferAttribute(e,a),t=Math.max(t,n.distanceToSquared(P)),P.fromBufferAttribute(i,a),t=Math.max(t,n.distanceToSquared(P));this.boundingSphere.radius=Math.sqrt(t),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(){}}I.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new ie},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};O.line={uniforms:$.merge([I.common,I.fog,I.line]),vertexShader:`
|
|
2
|
-
#include <common>
|
|
3
|
-
#include <color_pars_vertex>
|
|
4
|
-
#include <fog_pars_vertex>
|
|
5
|
-
#include <logdepthbuf_pars_vertex>
|
|
6
|
-
#include <clipping_planes_pars_vertex>
|
|
7
|
-
|
|
8
|
-
uniform float linewidth;
|
|
9
|
-
uniform vec2 resolution;
|
|
10
|
-
|
|
11
|
-
attribute vec3 instanceStart;
|
|
12
|
-
attribute vec3 instanceEnd;
|
|
13
|
-
|
|
14
|
-
attribute vec3 instanceColorStart;
|
|
15
|
-
attribute vec3 instanceColorEnd;
|
|
16
|
-
|
|
17
|
-
#ifdef WORLD_UNITS
|
|
18
|
-
|
|
19
|
-
varying vec4 worldPos;
|
|
20
|
-
varying vec3 worldStart;
|
|
21
|
-
varying vec3 worldEnd;
|
|
22
|
-
|
|
23
|
-
#ifdef USE_DASH
|
|
24
|
-
|
|
25
|
-
varying vec2 vUv;
|
|
26
|
-
|
|
27
|
-
#endif
|
|
28
|
-
|
|
29
|
-
#else
|
|
30
|
-
|
|
31
|
-
varying vec2 vUv;
|
|
32
|
-
|
|
33
|
-
#endif
|
|
34
|
-
|
|
35
|
-
#ifdef USE_DASH
|
|
36
|
-
|
|
37
|
-
uniform float dashScale;
|
|
38
|
-
attribute float instanceDistanceStart;
|
|
39
|
-
attribute float instanceDistanceEnd;
|
|
40
|
-
varying float vLineDistance;
|
|
41
|
-
|
|
42
|
-
#endif
|
|
43
|
-
|
|
44
|
-
float trimSegmentAlpha( const in vec4 start, const in vec4 end ) {
|
|
45
|
-
|
|
46
|
-
// compute the interpolation factor needed to trim the segment so it terminates
|
|
47
|
-
// between the camera plane and the near plane
|
|
48
|
-
|
|
49
|
-
// conservative estimate of the near plane
|
|
50
|
-
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
|
51
|
-
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
|
52
|
-
|
|
53
|
-
// we need different nearEstimate formula for reversed and default depth buffer
|
|
54
|
-
// a is positive with a reversed depth buffer so it can be used for controlling the code flow
|
|
55
|
-
float nearEstimate = ( a > 0.0 ) ? ( - b / ( a + 1.0 ) ) : ( - 0.5 * b / a );
|
|
56
|
-
|
|
57
|
-
return ( nearEstimate - start.z ) / ( end.z - start.z );
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
void main() {
|
|
62
|
-
|
|
63
|
-
#ifdef USE_COLOR
|
|
64
|
-
|
|
65
|
-
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
|
66
|
-
|
|
67
|
-
#endif
|
|
68
|
-
|
|
69
|
-
float aspect = resolution.x / resolution.y;
|
|
70
|
-
|
|
71
|
-
// camera space
|
|
72
|
-
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
|
73
|
-
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
|
74
|
-
|
|
75
|
-
#ifdef USE_DASH
|
|
76
|
-
|
|
77
|
-
float lineDistanceStart = dashScale * instanceDistanceStart;
|
|
78
|
-
float lineDistanceEnd = dashScale * instanceDistanceEnd;
|
|
79
|
-
|
|
80
|
-
#endif
|
|
81
|
-
|
|
82
|
-
#ifdef WORLD_UNITS
|
|
83
|
-
|
|
84
|
-
worldStart = start.xyz;
|
|
85
|
-
worldEnd = end.xyz;
|
|
86
|
-
|
|
87
|
-
#else
|
|
88
|
-
|
|
89
|
-
vUv = uv;
|
|
90
|
-
|
|
91
|
-
#endif
|
|
92
|
-
|
|
93
|
-
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|
94
|
-
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
95
|
-
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
96
|
-
// perhaps there is a more elegant solution -- WestLangley
|
|
97
|
-
|
|
98
|
-
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
|
99
|
-
|
|
100
|
-
if ( perspective ) {
|
|
101
|
-
|
|
102
|
-
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
|
103
|
-
|
|
104
|
-
float alpha = trimSegmentAlpha( start, end );
|
|
105
|
-
end.xyz = mix( start.xyz, end.xyz, alpha );
|
|
106
|
-
|
|
107
|
-
#ifdef USE_DASH
|
|
108
|
-
|
|
109
|
-
lineDistanceEnd = mix( lineDistanceStart, lineDistanceEnd, alpha );
|
|
110
|
-
|
|
111
|
-
#endif
|
|
112
|
-
|
|
113
|
-
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
|
114
|
-
|
|
115
|
-
float alpha = trimSegmentAlpha( end, start );
|
|
116
|
-
start.xyz = mix( end.xyz, start.xyz, alpha );
|
|
117
|
-
|
|
118
|
-
#ifdef USE_DASH
|
|
119
|
-
|
|
120
|
-
lineDistanceStart = mix( lineDistanceEnd, lineDistanceStart, alpha );
|
|
121
|
-
|
|
122
|
-
#endif
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
#ifdef USE_DASH
|
|
129
|
-
|
|
130
|
-
vLineDistance = ( position.y < 0.5 ) ? lineDistanceStart : lineDistanceEnd;
|
|
131
|
-
vUv = uv;
|
|
132
|
-
|
|
133
|
-
#endif
|
|
134
|
-
|
|
135
|
-
// clip space
|
|
136
|
-
vec4 clipStart = projectionMatrix * start;
|
|
137
|
-
vec4 clipEnd = projectionMatrix * end;
|
|
138
|
-
|
|
139
|
-
// ndc space
|
|
140
|
-
vec3 ndcStart = clipStart.xyz / clipStart.w;
|
|
141
|
-
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
|
|
142
|
-
|
|
143
|
-
// direction
|
|
144
|
-
vec2 dir = ndcEnd.xy - ndcStart.xy;
|
|
145
|
-
|
|
146
|
-
// account for clip-space aspect ratio
|
|
147
|
-
dir.x *= aspect;
|
|
148
|
-
dir = normalize( dir );
|
|
149
|
-
|
|
150
|
-
#ifdef WORLD_UNITS
|
|
151
|
-
|
|
152
|
-
vec3 worldDir = normalize( end.xyz - start.xyz );
|
|
153
|
-
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
|
|
154
|
-
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
|
|
155
|
-
vec3 worldFwd = cross( worldDir, worldUp );
|
|
156
|
-
worldPos = position.y < 0.5 ? start: end;
|
|
157
|
-
|
|
158
|
-
// height offset
|
|
159
|
-
float hw = linewidth * 0.5;
|
|
160
|
-
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
|
|
161
|
-
|
|
162
|
-
// don't extend the line if we're rendering dashes because we
|
|
163
|
-
// won't be rendering the endcaps
|
|
164
|
-
#ifndef USE_DASH
|
|
165
|
-
|
|
166
|
-
// cap extension
|
|
167
|
-
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
|
|
168
|
-
|
|
169
|
-
// add width to the box
|
|
170
|
-
worldPos.xyz += worldFwd * hw;
|
|
171
|
-
|
|
172
|
-
// endcaps
|
|
173
|
-
if ( position.y > 1.0 || position.y < 0.0 ) {
|
|
174
|
-
|
|
175
|
-
worldPos.xyz -= worldFwd * 2.0 * hw;
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
#endif
|
|
180
|
-
|
|
181
|
-
// project the worldpos
|
|
182
|
-
vec4 clip = projectionMatrix * worldPos;
|
|
183
|
-
|
|
184
|
-
// shift the depth of the projected points so the line
|
|
185
|
-
// segments overlap neatly
|
|
186
|
-
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
|
187
|
-
clip.z = clipPose.z * clip.w;
|
|
188
|
-
|
|
189
|
-
#else
|
|
190
|
-
|
|
191
|
-
vec2 offset = vec2( dir.y, - dir.x );
|
|
192
|
-
// undo aspect ratio adjustment
|
|
193
|
-
dir.x /= aspect;
|
|
194
|
-
offset.x /= aspect;
|
|
195
|
-
|
|
196
|
-
// sign flip
|
|
197
|
-
if ( position.x < 0.0 ) offset *= - 1.0;
|
|
198
|
-
|
|
199
|
-
// endcaps
|
|
200
|
-
if ( position.y < 0.0 ) {
|
|
201
|
-
|
|
202
|
-
offset += - dir;
|
|
203
|
-
|
|
204
|
-
} else if ( position.y > 1.0 ) {
|
|
205
|
-
|
|
206
|
-
offset += dir;
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// adjust for linewidth
|
|
211
|
-
offset *= linewidth;
|
|
212
|
-
|
|
213
|
-
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|
214
|
-
offset /= resolution.y;
|
|
215
|
-
|
|
216
|
-
// select end
|
|
217
|
-
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
|
218
|
-
|
|
219
|
-
// back to clip space
|
|
220
|
-
offset *= clip.w;
|
|
221
|
-
|
|
222
|
-
clip.xy += offset;
|
|
223
|
-
|
|
224
|
-
#endif
|
|
225
|
-
|
|
226
|
-
gl_Position = clip;
|
|
227
|
-
|
|
228
|
-
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
|
229
|
-
|
|
230
|
-
#include <logdepthbuf_vertex>
|
|
231
|
-
#include <clipping_planes_vertex>
|
|
232
|
-
#include <fog_vertex>
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
`,fragmentShader:`
|
|
236
|
-
uniform vec3 diffuse;
|
|
237
|
-
uniform float opacity;
|
|
238
|
-
uniform float linewidth;
|
|
239
|
-
|
|
240
|
-
#ifdef USE_DASH
|
|
241
|
-
|
|
242
|
-
uniform float dashOffset;
|
|
243
|
-
uniform float dashSize;
|
|
244
|
-
uniform float gapSize;
|
|
245
|
-
|
|
246
|
-
#endif
|
|
247
|
-
|
|
248
|
-
varying float vLineDistance;
|
|
249
|
-
|
|
250
|
-
#ifdef WORLD_UNITS
|
|
251
|
-
|
|
252
|
-
varying vec4 worldPos;
|
|
253
|
-
varying vec3 worldStart;
|
|
254
|
-
varying vec3 worldEnd;
|
|
255
|
-
|
|
256
|
-
#ifdef USE_DASH
|
|
257
|
-
|
|
258
|
-
varying vec2 vUv;
|
|
259
|
-
|
|
260
|
-
#endif
|
|
261
|
-
|
|
262
|
-
#else
|
|
263
|
-
|
|
264
|
-
varying vec2 vUv;
|
|
265
|
-
|
|
266
|
-
#endif
|
|
267
|
-
|
|
268
|
-
#include <common>
|
|
269
|
-
#include <color_pars_fragment>
|
|
270
|
-
#include <fog_pars_fragment>
|
|
271
|
-
#include <logdepthbuf_pars_fragment>
|
|
272
|
-
#include <clipping_planes_pars_fragment>
|
|
273
|
-
|
|
274
|
-
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
|
275
|
-
|
|
276
|
-
float mua;
|
|
277
|
-
float mub;
|
|
278
|
-
|
|
279
|
-
vec3 p13 = p1 - p3;
|
|
280
|
-
vec3 p43 = p4 - p3;
|
|
281
|
-
|
|
282
|
-
vec3 p21 = p2 - p1;
|
|
283
|
-
|
|
284
|
-
float d1343 = dot( p13, p43 );
|
|
285
|
-
float d4321 = dot( p43, p21 );
|
|
286
|
-
float d1321 = dot( p13, p21 );
|
|
287
|
-
float d4343 = dot( p43, p43 );
|
|
288
|
-
float d2121 = dot( p21, p21 );
|
|
289
|
-
|
|
290
|
-
float denom = d2121 * d4343 - d4321 * d4321;
|
|
291
|
-
|
|
292
|
-
float numer = d1343 * d4321 - d1321 * d4343;
|
|
293
|
-
|
|
294
|
-
mua = numer / denom;
|
|
295
|
-
mua = clamp( mua, 0.0, 1.0 );
|
|
296
|
-
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
|
|
297
|
-
mub = clamp( mub, 0.0, 1.0 );
|
|
298
|
-
|
|
299
|
-
return vec2( mua, mub );
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
void main() {
|
|
304
|
-
|
|
305
|
-
float alpha = opacity;
|
|
306
|
-
vec4 diffuseColor = vec4( diffuse, alpha );
|
|
307
|
-
|
|
308
|
-
#include <clipping_planes_fragment>
|
|
309
|
-
|
|
310
|
-
#ifdef USE_DASH
|
|
311
|
-
|
|
312
|
-
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
|
313
|
-
|
|
314
|
-
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
|
315
|
-
|
|
316
|
-
#endif
|
|
317
|
-
|
|
318
|
-
#ifdef WORLD_UNITS
|
|
319
|
-
|
|
320
|
-
// Find the closest points on the view ray and the line segment
|
|
321
|
-
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
|
|
322
|
-
vec3 lineDir = worldEnd - worldStart;
|
|
323
|
-
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
|
|
324
|
-
|
|
325
|
-
vec3 p1 = worldStart + lineDir * params.x;
|
|
326
|
-
vec3 p2 = rayEnd * params.y;
|
|
327
|
-
vec3 delta = p1 - p2;
|
|
328
|
-
float len = length( delta );
|
|
329
|
-
float norm = len / linewidth;
|
|
330
|
-
|
|
331
|
-
#ifndef USE_DASH
|
|
332
|
-
|
|
333
|
-
#ifdef USE_ALPHA_TO_COVERAGE
|
|
334
|
-
|
|
335
|
-
float dnorm = fwidth( norm );
|
|
336
|
-
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
|
337
|
-
|
|
338
|
-
#else
|
|
339
|
-
|
|
340
|
-
if ( norm > 0.5 ) {
|
|
341
|
-
|
|
342
|
-
discard;
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
#endif
|
|
347
|
-
|
|
348
|
-
#endif
|
|
349
|
-
|
|
350
|
-
#else
|
|
351
|
-
|
|
352
|
-
#ifdef USE_ALPHA_TO_COVERAGE
|
|
353
|
-
|
|
354
|
-
// artifacts appear on some hardware if a derivative is taken within a conditional
|
|
355
|
-
float a = vUv.x;
|
|
356
|
-
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
357
|
-
float len2 = a * a + b * b;
|
|
358
|
-
float dlen = fwidth( len2 );
|
|
359
|
-
|
|
360
|
-
if ( abs( vUv.y ) > 1.0 ) {
|
|
361
|
-
|
|
362
|
-
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
#else
|
|
367
|
-
|
|
368
|
-
if ( abs( vUv.y ) > 1.0 ) {
|
|
369
|
-
|
|
370
|
-
float a = vUv.x;
|
|
371
|
-
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
372
|
-
float len2 = a * a + b * b;
|
|
373
|
-
|
|
374
|
-
if ( len2 > 1.0 ) discard;
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
#endif
|
|
379
|
-
|
|
380
|
-
#endif
|
|
381
|
-
|
|
382
|
-
#include <logdepthbuf_fragment>
|
|
383
|
-
#include <color_fragment>
|
|
384
|
-
|
|
385
|
-
gl_FragColor = vec4( diffuseColor.rgb, alpha );
|
|
386
|
-
|
|
387
|
-
#include <tonemapping_fragment>
|
|
388
|
-
#include <colorspace_fragment>
|
|
389
|
-
#include <fog_fragment>
|
|
390
|
-
#include <premultiplied_alpha_fragment>
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
`};class N extends te{constructor(e){super({type:"LineMaterial",uniforms:$.clone(O.line.uniforms),vertexShader:O.line.vertexShader,fragmentShader:O.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const W=new B,k=new E,q=new E,f=new B,u=new B,w=new B,R=new E,F=new oe,p=new se,X=new E,T=new G,C=new Z,S=new B;let x,z;function K(h,e,i){return S.set(0,0,-e,1).applyMatrix4(h.projectionMatrix),S.multiplyScalar(1/S.w),S.x=z/i.width,S.y=z/i.height,S.applyMatrix4(h.projectionMatrixInverse),S.multiplyScalar(1/S.w),Math.abs(Math.max(S.x,S.y))}function he(h,e){const i=h.matrixWorld,n=h.geometry,t=n.attributes.instanceStart,a=n.attributes.instanceEnd,o=Math.min(n.instanceCount,t.count);for(let s=0,m=o;s<m;s++){p.start.fromBufferAttribute(t,s),p.end.fromBufferAttribute(a,s),p.applyMatrix4(i);const l=new E,d=new E;x.distanceSqToSegment(p.start,p.end,d,l),d.distanceTo(l)<z*.5&&e.push({point:d,pointOnLine:l,distance:x.origin.distanceTo(d),object:h,face:null,faceIndex:s,uv:null,uv1:null})}}function me(h,e,i){const n=e.projectionMatrix,a=h.material.resolution,o=h.matrixWorld,s=h.geometry,m=s.attributes.instanceStart,l=s.attributes.instanceEnd,d=Math.min(s.instanceCount,m.count),r=-e.near;x.at(1,w),w.w=1,w.applyMatrix4(e.matrixWorldInverse),w.applyMatrix4(n),w.multiplyScalar(1/w.w),w.x*=a.x/2,w.y*=a.y/2,w.z=0,R.copy(w),F.multiplyMatrices(e.matrixWorldInverse,o);for(let b=0,c=d;b<c;b++){if(f.fromBufferAttribute(m,b),u.fromBufferAttribute(l,b),f.w=1,u.w=1,f.applyMatrix4(F),u.applyMatrix4(F),f.z>r&&u.z>r)continue;if(f.z>r){const _=f.z-u.z,y=(f.z-r)/_;f.lerp(u,y)}else if(u.z>r){const _=u.z-f.z,y=(u.z-r)/_;u.lerp(f,y)}f.applyMatrix4(n),u.applyMatrix4(n),f.multiplyScalar(1/f.w),u.multiplyScalar(1/u.w),f.x*=a.x/2,f.y*=a.y/2,u.x*=a.x/2,u.y*=a.y/2,p.start.copy(f),p.start.z=0,p.end.copy(u),p.end.z=0;const v=p.closestPointToPointParameter(R,!0);p.at(v,X);const M=re.lerp(f.z,u.z,v),U=M>=-1&&M<=1,L=R.distanceTo(X)<z*.5;if(U&&L){p.start.fromBufferAttribute(m,b),p.end.fromBufferAttribute(l,b),p.start.applyMatrix4(o),p.end.applyMatrix4(o);const _=new E,y=new E;x.distanceSqToSegment(p.start,p.end,y,_),i.push({point:y,pointOnLine:_,distance:x.origin.distanceTo(y),object:h,face:null,faceIndex:b,uv:null,uv1:null})}}}class ge extends ne{constructor(e=new J,i=new N({color:Math.random()*16777215})){super(e,i),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,i=e.attributes.instanceStart,n=e.attributes.instanceEnd,t=new Float32Array(2*i.count);for(let o=0,s=0,m=i.count;o<m;o++,s+=2)k.fromBufferAttribute(i,o),q.fromBufferAttribute(n,o),t[s]=s===0?0:t[s-1],t[s+1]=t[s]+k.distanceTo(q);const a=new j(t,2,1);return e.setAttribute("instanceDistanceStart",new A(a,1,0)),e.setAttribute("instanceDistanceEnd",new A(a,1,1)),this}raycast(e,i){const n=this.material.worldUnits,t=e.camera;if(t===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'),n===!1&&(this.material.resolution.x===0||this.material.resolution.y===0))return;const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;x=e.ray;const o=this.matrixWorld,s=this.geometry,m=this.material;z=m.linewidth+a,s.boundingSphere===null&&s.computeBoundingSphere(),C.copy(s.boundingSphere).applyMatrix4(o);let l;if(n)l=z*.5;else{const r=Math.max(t.near,C.distanceToPoint(x.origin));l=K(t,r,m.resolution)}if(C.radius+=l,x.intersectsSphere(C)===!1)return;s.boundingBox===null&&s.computeBoundingBox(),T.copy(s.boundingBox).applyMatrix4(o);let d;if(n)d=z*.5;else{const r=Math.max(t.near,T.distanceToPoint(x.origin));d=K(t,r,m.resolution)}T.expandByScalar(d),x.intersectsBox(T)!==!1&&(n?he(this,i):me(this,t,i))}onBeforeRender(e){const i=this.material.uniforms;i&&i.resolution&&(e.getViewport(W),this.material.uniforms.resolution.value.set(W.z,W.w))}}class Q extends J{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const i=e.length-3,n=new Float32Array(2*i);for(let t=0;t<i;t+=3)n[2*t]=e[t],n[2*t+1]=e[t+1],n[2*t+2]=e[t+2],n[2*t+3]=e[t+3],n[2*t+4]=e[t+4],n[2*t+5]=e[t+5];return super.setPositions(n),this}setColors(e){const i=e.length-3,n=new Float32Array(2*i);for(let t=0;t<i;t+=3)n[2*t]=e[t],n[2*t+1]=e[t+1],n[2*t+2]=e[t+2],n[2*t+3]=e[t+3],n[2*t+4]=e[t+4],n[2*t+5]=e[t+5];return super.setColors(n),this}setFromPoints(e){const i=e.length-1,n=new Float32Array(6*i);for(let t=0;t<i;t++)n[6*t]=e[t].x,n[6*t+1]=e[t].y,n[6*t+2]=e[t].z||0,n[6*t+3]=e[t+1].x,n[6*t+4]=e[t+1].y,n[6*t+5]=e[t+1].z||0;return super.setPositions(n),this}fromLine(e){const i=e.geometry;return this.setPositions(i.attributes.position.array),this}}class ve extends ge{constructor(e=new Q,i=new N({color:Math.random()*16777215})){super(e,i),this.isLine2=!0,this.type="Line2"}}class D{constructor(e){this.layer=e,this.group.name="traces"}static LINE_WIDTH_PX=2.5;static MARKER_SIZE_PX=9;static STEP_M=15;static LIFT_M=.3;group=new ae;materials=[];pointsMaterials=[];set(e,i,n,t,a){this.empty();for(const o of e){const s=this.positions(o,i,n,t,a),m=new le(o.color??de);if(o.kind==="point"){const l=new ce;l.setAttribute("position",new H(s.slice(0,3),3));const d=new fe({color:m,size:D.MARKER_SIZE_PX,sizeAttenuation:!1,depthTest:!1,fog:!1});this.pointsMaterials.push(d);const r=new ue(l,d);r.name="trace point",r.frustumCulled=!1,r.layers.set(this.layer),this.group.add(r)}else if(s.length>=6){const l=new Q;l.setPositions(o.kind==="polygon"?[...s,s[0],s[1],s[2]]:s);const d=new N({color:m.getHex(),linewidth:D.LINE_WIDTH_PX,worldUnits:!1,transparent:!0,opacity:.92,depthTest:!1,fog:!1});this.materials.push(d);const r=new ve(l,d);r.name=`trace ${o.kind}`,r.frustumCulled=!1,r.layers.set(this.layer),this.group.add(r)}}}setResolution(e){for(const i of this.materials)i.resolution.copy(e)}get any(){return this.group.children.length>0}dispose(){this.empty()}empty(){for(const e of[...this.group.children])this.group.remove(e),e.geometry.dispose();for(const e of this.materials.splice(0))e.dispose();for(const e of this.pointsMaterials.splice(0))e.dispose()}positions(e,i,n,t,a){const o=e.altitude??"ground",s=e.points.map(c=>{const{x:g,z:v}=pe(c.lat,c.lng,i,n);return{x:g,z:v,altM:c.altM??0}}),m=o!=="absolute",l=[],d=(c,g,v)=>o==="absolute"?v-t:a(c,g)+(o==="relative"?v:0)+D.LIFT_M,r=e.kind==="polygon",b=r?s.length:s.length-1;for(let c=0;c<Math.max(b,1);c++){const g=s[c],v=s[(c+1)%s.length],M=m&&e.kind!=="point"?Math.max(1,Math.ceil(Math.hypot(v.x-g.x,v.z-g.z)/D.STEP_M)):1;for(let U=0;U<M;U++){const L=U/M,_=g.x+(v.x-g.x)*L,y=g.z+(v.z-g.z)*L;l.push(_,d(_,y,g.altM+(v.altM-g.altM)*L),y)}}if(!r&&e.kind!=="point"){const c=s[s.length-1];l.push(c.x,d(c.x,c.z,c.altM),c.z)}return l}}export{D as TraceSystem};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{T as Le,t as Q,u as he,v as Se,w as G,x as de,y as w,i as pe,C as F,z as b,A as U,E as ye,H as we,J as be,m as K,K as Ne,V as C,Q as me,O as Ie,R as ge,X as Oe,Y as Ce,Z as V,$ as Fe,a0 as Te,a1 as Pe,a2 as ke,a3 as He,a4 as J,a5 as Re,a6 as Z,a7 as De,a8 as ve,P as Ge,a9 as X,aa as Ue,ab as Ee,ac as Ke,ad as v,ae as Be,o as je,af as Ve,M as Xe,ag as ze,ah as qe,ai as We,q as Ye,G as z,aj as Qe,n as Je,ak as Ze,al as $e,am as en,an as nn,ao as tn,ap as xe,b as sn,aq as ne,ar as te,as as se,at as ie,au as re,av as rn,aw as on,d as an,e as cn}from"./rr0-sighting-editor.mjs";function oe(f,n){if(n===Le)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(n===Q||n===he){let e=f.getIndex();if(e===null){const r=[],a=f.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)r.push(o);f.setIndex(r),e=f.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),f}const s=e.count-2,t=[];if(n===Q)for(let r=1;r<=s;r++)t.push(e.getX(0)),t.push(e.getX(r)),t.push(e.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(t.push(e.getX(r)),t.push(e.getX(r+1)),t.push(e.getX(r+2))):(t.push(e.getX(r+2)),t.push(e.getX(r+1)),t.push(e.getX(r)));t.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=f.clone();return i.setIndex(t),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",n),f}function un(f){const n=new Map,e=new Map,s=f.clone();return Ae(f,s,function(t,i){n.set(i,t),e.set(t,i)}),s.traverse(function(t){if(!t.isSkinnedMesh)return;const i=t,r=n.get(t),a=r.skeleton.bones;i.skeleton=r.skeleton.clone(),i.bindMatrix.copy(r.bindMatrix),i.skeleton.bones=a.map(function(o){return e.get(o)}),i.bind(i.skeleton,i.bindMatrix)}),s}function Ae(f,n,e){e(f,n);for(let s=0;s<f.children.length;s++)Ae(f.children[s],n.children[s],e)}class Vn extends Se{constructor(n){super(n),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new pn(e)}),this.register(function(e){return new mn(e)}),this.register(function(e){return new Ln(e)}),this.register(function(e){return new Sn(e)}),this.register(function(e){return new yn(e)}),this.register(function(e){return new Tn(e)}),this.register(function(e){return new Rn(e)}),this.register(function(e){return new En(e)}),this.register(function(e){return new xn(e)}),this.register(function(e){return new dn(e)}),this.register(function(e){return new An(e)}),this.register(function(e){return new gn(e)}),this.register(function(e){return new Mn(e)}),this.register(function(e){return new _n(e)}),this.register(function(e){return new fn(e)}),this.register(function(e){return new ae(e,g.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new ae(e,g.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new wn(e)})}load(n,e,s,t){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const c=G.extractUrlBase(n);r=G.resolveURL(c,this.path)}else r=G.extractUrlBase(n);this.manager.itemStart(n);const a=function(c){t?t(c):console.error(c),i.manager.itemError(n),i.manager.itemEnd(n)},o=new de(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(n,function(c){try{i.parse(c,r,function(u){e(u),i.manager.itemEnd(n)},a)}catch(u){a(u)}},s,a)}setDRACOLoader(n){return this.dracoLoader=n,this}setKTX2Loader(n){return this.ktx2Loader=n,this}setMeshoptDecoder(n){return this.meshoptDecoder=n,this}register(n){return this.pluginCallbacks.indexOf(n)===-1&&this.pluginCallbacks.push(n),this}unregister(n){return this.pluginCallbacks.indexOf(n)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(n),1),this}parse(n,e,s,t){let i;const r={},a={},o=new TextDecoder;if(typeof n=="string")i=JSON.parse(n);else if(n instanceof ArrayBuffer)if(o.decode(new Uint8Array(n,0,4))===_e){try{r[g.KHR_BINARY_GLTF]=new bn(n)}catch(l){t&&t(l);return}i=JSON.parse(r[g.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(n));else i=n;if(i.asset===void 0||i.asset.version[0]<2){t&&t(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Kn(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const l=this.pluginCallbacks[u](c);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[l.name]=l,r[l.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const l=i.extensionsUsed[u],h=i.extensionsRequired||[];switch(l){case g.KHR_MATERIALS_UNLIT:r[l]=new hn;break;case g.KHR_DRACO_MESH_COMPRESSION:r[l]=new Nn(i,this.dracoLoader);break;case g.KHR_TEXTURE_TRANSFORM:r[l]=new In;break;case g.KHR_MESH_QUANTIZATION:r[l]=new On;break;default:h.indexOf(l)>=0&&a[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(r),c.setPlugins(a),c.parse(s,t)}parseAsync(n,e){const s=this;return new Promise(function(t,i){s.parse(n,e,t,i)})}}function ln(){let f={};return{get:function(n){return f[n]},add:function(n,e){f[n]=e},remove:function(n){delete f[n]},removeAll:function(){f={}}}}function _(f,n,e){const s=f.json.materials[n];return s.extensions&&s.extensions[e]?s.extensions[e]:null}const g={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class fn{constructor(n){this.parser=n,this.name=g.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const n=this.parser,e=this.parser.json.nodes||[];for(let s=0,t=e.length;s<t;s++){const i=e[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&n._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(n){const e=this.parser,s="light:"+n;let t=e.cache.get(s);if(t)return t;const i=e.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[n];let c;const u=new F(16777215);o.color!==void 0&&u.setRGB(o.color[0],o.color[1],o.color[2],b);const l=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new be(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new we(u),c.distance=l;break;case"spot":c=new ye(u),c.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),y(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=e.createUniqueName(o.name||"light_"+n),t=Promise.resolve(c),e.cache.add(s,t),t}getDependency(n,e){if(n==="light")return this._loadLight(e)}createNodeAttachment(n){const e=this,s=this.parser,i=s.json.nodes[n],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return s._getNodeRef(e.cache,a,o)})}}class hn{constructor(){this.name=g.KHR_MATERIALS_UNLIT}getMaterialType(){return v}extendParams(n,e,s){const t=[];n.color=new F(1,1,1),n.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;n.color.setRGB(r[0],r[1],r[2],b),n.opacity=r[3]}i.baseColorTexture!==void 0&&t.push(s.assignTexture(n,"map",i.baseColorTexture,U))}return Promise.all(t)}}class dn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);return s===null||s.emissiveStrength!==void 0&&(e.emissiveIntensity=s.emissiveStrength),Promise.resolve()}}class pn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_CLEARCOAT}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&t.push(this.parser.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&t.push(this.parser.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(t.push(this.parser.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new pe(i,i)}return Promise.all(t)}}class mn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_DISPERSION}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);return s===null||(e.dispersion=s.dispersion!==void 0?s.dispersion:0),Promise.resolve()}}class gn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_IRIDESCENCE}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&t.push(this.parser.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&t.push(this.parser.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(t)}}class Tn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_SHEEN}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];if(e.sheenColor=new F(0,0,0),e.sheenRoughness=0,e.sheen=1,s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;e.sheenColor.setRGB(i[0],i[1],i[2],b)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&t.push(this.parser.assignTexture(e,"sheenColorMap",s.sheenColorTexture,U)),s.sheenRoughnessTexture!==void 0&&t.push(this.parser.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(t)}}class Rn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_TRANSMISSION}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&t.push(this.parser.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(t)}}class En{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_VOLUME}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&t.push(this.parser.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return e.attenuationColor=new F().setRGB(i[0],i[1],i[2],b),Promise.all(t)}}class xn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_IOR}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);return s===null||(e.ior=s.ior!==void 0?s.ior:1.5,e.ior===0&&(e.ior=1e3)),Promise.resolve()}}class An{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_SPECULAR}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&t.push(this.parser.assignTexture(e,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return e.specularColor=new F().setRGB(i[0],i[1],i[2],b),s.specularColorTexture!==void 0&&t.push(this.parser.assignTexture(e,"specularColorMap",s.specularColorTexture,U)),Promise.all(t)}}class _n{constructor(n){this.parser=n,this.name=g.EXT_MATERIALS_BUMP}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&t.push(this.parser.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(t)}}class Mn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_ANISOTROPY}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&t.push(this.parser.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(t)}}class Ln{constructor(n){this.parser=n,this.name=g.KHR_TEXTURE_BASISU}loadTexture(n){const e=this.parser,s=e.json,t=s.textures[n];if(!t.extensions||!t.extensions[this.name])return null;const i=t.extensions[this.name],r=e.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(n,i.source,r)}}class Sn{constructor(n){this.parser=n,this.name=g.EXT_TEXTURE_WEBP}loadTexture(n){const e=this.name,s=this.parser,t=s.json,i=t.textures[n];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=t.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return s.loadTextureImage(n,r.source,o)}}class yn{constructor(n){this.parser=n,this.name=g.EXT_TEXTURE_AVIF}loadTexture(n){const e=this.name,s=this.parser,t=s.json,i=t.textures[n];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=t.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return s.loadTextureImage(n,r.source,o)}}class ae{constructor(n,e){this.name=e,this.parser=n}loadBufferView(n){const e=this.parser.json,s=e.bufferViews[n];if(s.extensions&&s.extensions[this.name]){const t=s.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const o=t.byteOffset||0,c=t.byteLength||0,u=t.count,l=t.byteStride,h=new Uint8Array(a,o,c);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(u,l,h,t.mode,t.filter).then(function(d){return d.buffer}):r.ready.then(function(){const d=new ArrayBuffer(u*l);return r.decodeGltfBuffer(new Uint8Array(d),u,l,h,t.mode,t.filter),d})})}else return null}}class wn{constructor(n){this.name=g.EXT_MESH_GPU_INSTANCING,this.parser=n}createNodeMesh(n){const e=this.parser.json,s=e.nodes[n];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const t=e.meshes[s.mesh];for(const c of t.primitives)if(c.mode!==L.TRIANGLES&&c.mode!==L.TRIANGLE_STRIP&&c.mode!==L.TRIANGLE_FAN&&c.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],o={};for(const c in r)a.push(this.parser.getDependency("accessor",r[c]).then(u=>(o[c]=u,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(n)),Promise.all(a).then(c=>{const u=c.pop(),l=u.isGroup?u.children:[u],h=c[0].count,d=[];for(const p of l){const R=new K,m=new C,T=new me,A=new C(1,1,1),x=new Ne(p.geometry,p.material,h);for(let E=0;E<h;E++)o.TRANSLATION&&m.fromBufferAttribute(o.TRANSLATION,E),o.ROTATION&&T.fromBufferAttribute(o.ROTATION,E),o.SCALE&&A.fromBufferAttribute(o.SCALE,E),x.setMatrixAt(E,R.compose(m,T,A));for(const E in o)if(E==="_COLOR_0"){const M=o[E];x.instanceColor=new Ie(M.array,M.itemSize,M.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&p.geometry.setAttribute(E,o[E]);ge.prototype.copy.call(x,p),this.parser.assignFinalMaterial(x),d.push(x)}return u.isGroup?(u.clear(),u.add(...d),u):d[0]}))}}const _e="glTF",D=12,ce={JSON:1313821514,BIN:5130562};class bn{constructor(n){this.name=g.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(n,0,D),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(n.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==_e)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const t=this.header.length-D,i=new DataView(n,D);let r=0;for(;r<t;){const a=i.getUint32(r,!0);r+=4;const o=i.getUint32(r,!0);if(r+=4,o===ce.JSON){const c=new Uint8Array(n,D+r,a);this.content=s.decode(c)}else if(o===ce.BIN){const c=D+r;this.body=n.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Nn{constructor(n,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=g.KHR_DRACO_MESH_COMPRESSION,this.json=n,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(n,e){const s=this.json,t=this.dracoLoader,i=n.extensions[this.name].bufferView,r=n.extensions[this.name].attributes,a={},o={},c={};for(const u in r){const l=$[u]||u.toLowerCase();a[l]=r[u]}for(const u in n.attributes){const l=$[u]||u.toLowerCase();if(r[u]!==void 0){const h=s.accessors[n.attributes[u]],d=k[h.componentType];c[l]=d.name,o[l]=h.normalized===!0}}return e.getDependency("bufferView",i).then(function(u){return new Promise(function(l,h){t.decodeDracoFile(u,function(d){for(const p in d.attributes){const R=d.attributes[p],m=o[p];m!==void 0&&(R.normalized=m)}l(d)},a,c,b,h)})})}}class In{constructor(){this.name=g.KHR_TEXTURE_TRANSFORM}extendTexture(n,e){return(e.texCoord===void 0||e.texCoord===n.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(n=n.clone(),e.texCoord!==void 0&&(n.channel=e.texCoord),e.offset!==void 0&&n.offset.fromArray(e.offset),e.rotation!==void 0&&(n.rotation=e.rotation),e.scale!==void 0&&n.repeat.fromArray(e.scale),n.needsUpdate=!0),n}}class On{constructor(){this.name=g.KHR_MESH_QUANTIZATION}}class Me extends on{constructor(n,e,s,t){super(n,e,s,t)}copySampleValue_(n){const e=this.resultBuffer,s=this.sampleValues,t=this.valueSize,i=n*t*3+t;for(let r=0;r!==t;r++)e[r]=s[i+r];return e}interpolate_(n,e,s,t){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,u=t-e,l=(s-e)/u,h=l*l,d=h*l,p=n*c,R=p-c,m=-2*d+3*h,T=d-h,A=1-m,x=T-h+l;for(let E=0;E!==a;E++){const M=r[R+E+a],N=r[R+E+o]*u,S=r[p+E+a],H=r[p+E]*u;i[E]=A*M+x*N+m*S+T*H}return i}}const Cn=new me;class Fn extends Me{interpolate_(n,e,s,t){const i=super.interpolate_(n,e,s,t);return Cn.fromArray(i).normalize().toArray(i),i}}const L={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},k={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ue={9728:Re,9729:J,9984:He,9985:ke,9986:Pe,9987:Te},le={33071:ve,33648:De,10497:Z},q={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},$={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},I={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Pn={CUBICSPLINE:void 0,LINEAR:xe,STEP:tn},W={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function kn(f){return f.DefaultMaterial===void 0&&(f.DefaultMaterial=new Ee({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:rn})),f.DefaultMaterial}function O(f,n,e){for(const s in e.extensions)f[s]===void 0&&(n.userData.gltfExtensions=n.userData.gltfExtensions||{},n.userData.gltfExtensions[s]=e.extensions[s])}function y(f,n){n.extras!==void 0&&(typeof n.extras=="object"?Object.assign(f.userData,n.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+n.extras))}function Hn(f,n,e){let s=!1,t=!1,i=!1;for(let c=0,u=n.length;c<u;c++){const l=n[c];if(l.POSITION!==void 0&&(s=!0),l.NORMAL!==void 0&&(t=!0),l.COLOR_0!==void 0&&(i=!0),s&&t&&i)break}if(!s&&!t&&!i)return Promise.resolve(f);const r=[],a=[],o=[];for(let c=0,u=n.length;c<u;c++){const l=n[c];if(s){const h=l.POSITION!==void 0?e.getDependency("accessor",l.POSITION):f.attributes.position;r.push(h)}if(t){const h=l.NORMAL!==void 0?e.getDependency("accessor",l.NORMAL):f.attributes.normal;a.push(h)}if(i){const h=l.COLOR_0!==void 0?e.getDependency("accessor",l.COLOR_0):f.attributes.color;o.push(h)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o)]).then(function(c){const u=c[0],l=c[1],h=c[2];return s&&(f.morphAttributes.position=u),t&&(f.morphAttributes.normal=l),i&&(f.morphAttributes.color=h),f.morphTargetsRelative=!0,f})}function Dn(f,n){if(f.updateMorphTargets(),n.weights!==void 0)for(let e=0,s=n.weights.length;e<s;e++)f.morphTargetInfluences[e]=n.weights[e];if(n.extras&&Array.isArray(n.extras.targetNames)){const e=n.extras.targetNames;if(f.morphTargetInfluences.length===e.length){f.morphTargetDictionary={};for(let s=0,t=e.length;s<t;s++)f.morphTargetDictionary[e[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function vn(f){let n;const e=f.extensions&&f.extensions[g.KHR_DRACO_MESH_COMPRESSION];if(e?n="draco:"+e.bufferView+":"+e.indices+":"+Y(e.attributes):n=f.indices+":"+Y(f.attributes)+":"+f.mode,f.targets!==void 0)for(let s=0,t=f.targets.length;s<t;s++)n+=":"+Y(f.targets[s]);return n}function Y(f){let n="";const e=Object.keys(f).sort();for(let s=0,t=e.length;s<t;s++)n+=e[s]+":"+f[e[s]]+";";return n}function ee(f){switch(f){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Gn(f){return f.search(/\.jpe?g($|\?)/i)>0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Un=new K;class Kn{constructor(n={},e={}){this.json=n,this.extensions={},this.plugins={},this.options=e,this.cache=new ln,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,t=-1,i=!1,r=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);t=s&&o?parseInt(o[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&t<17||i&&r<98?this.textureLoader=new Oe(this.options.manager):this.textureLoader=new Ce(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new de(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(n){this.extensions=n}setPlugins(n){this.plugins=n}parse(n,e){const s=this,t=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][t.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:t.asset,parser:s,userData:{}};return O(i,a,t),y(a,t),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();n(a)})}).catch(e)}_markDefs(){const n=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let t=0,i=e.length;t<i;t++){const r=e[t].joints;for(let a=0,o=r.length;a<o;a++)n[r[a]].isBone=!0}for(let t=0,i=n.length;t<i;t++){const r=n[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(n,e){e!==void 0&&(n.refs[e]===void 0&&(n.refs[e]=n.uses[e]=0),n.refs[e]++)}_getNodeRef(n,e,s){if(n.refs[e]<=1)return s;const t=s.clone(),i=(r,a)=>{const o=this.associations.get(r);o!=null&&this.associations.set(a,o);for(const[c,u]of r.children.entries())i(u,a.children[c])};return i(s,t),t.name+="_instance_"+n.uses[e]++,t}_invokeOne(n){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const t=n(e[s]);if(t)return t}return null}_invokeAll(n){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let t=0;t<e.length;t++){const i=n(e[t]);i&&s.push(i)}return s}getDependency(n,e){const s=n+":"+e;let t=this.cache.get(s);if(!t){switch(n){case"scene":t=this.loadScene(e);break;case"node":t=this._invokeOne(function(i){return i.loadNode&&i.loadNode(e)});break;case"mesh":t=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(e)});break;case"accessor":t=this.loadAccessor(e);break;case"bufferView":t=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(e)});break;case"buffer":t=this.loadBuffer(e);break;case"material":t=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(e)});break;case"texture":t=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(e)});break;case"skin":t=this.loadSkin(e);break;case"animation":t=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(e)});break;case"camera":t=this.loadCamera(e);break;default:if(t=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(n,e)}),!t)throw new Error("Unknown type: "+n);break}this.cache.add(s,t)}return t}getDependencies(n){let e=this.cache.get(n);if(!e){const s=this,t=this.json[n+(n==="mesh"?"es":"s")]||[];e=Promise.all(t.map(function(i,r){return s.getDependency(n,r)})),this.cache.add(n,e)}return e}loadBuffer(n){const e=this.json.buffers[n],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&n===0)return Promise.resolve(this.extensions[g.KHR_BINARY_GLTF].body);const t=this.options;return new Promise(function(i,r){s.load(G.resolveURL(e.uri,t.path),i,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(n){const e=this.json.bufferViews[n];return this.getDependency("buffer",e.buffer).then(function(s){const t=e.byteLength||0,i=e.byteOffset||0;return s.slice(i,i+t)})}loadAccessor(n){const e=this,s=this.json,t=this.json.accessors[n];if(t.bufferView===void 0&&t.sparse===void 0){const r=q[t.type],a=k[t.componentType],o=t.normalized===!0,c=new a(t.count*r);return Promise.resolve(new V(c,r,o))}const i=[];return t.bufferView!==void 0?i.push(this.getDependency("bufferView",t.bufferView)):i.push(null),t.sparse!==void 0&&(i.push(this.getDependency("bufferView",t.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",t.sparse.values.bufferView))),Promise.all(i).then(function(r){const a=r[0],o=q[t.type],c=k[t.componentType],u=c.BYTES_PER_ELEMENT,l=u*o,h=t.byteOffset||0,d=t.bufferView!==void 0?s.bufferViews[t.bufferView].byteStride:void 0,p=t.normalized===!0;let R,m;if(d&&d!==l){const T=Math.floor(h/d),A="InterleavedBuffer:"+t.bufferView+":"+t.componentType+":"+T+":"+t.count;let x=e.cache.get(A);x||(R=new c(a,T*d,t.count*d/u),x=new Fe(R,d/u),e.cache.add(A,x)),m=new sn(x,o,h%d/u,p)}else a===null?R=new c(t.count*o):R=new c(a,h,t.count*o),m=new V(R,o,p);if(t.sparse!==void 0){const T=q.SCALAR,A=k[t.sparse.indices.componentType],x=t.sparse.indices.byteOffset||0,E=t.sparse.values.byteOffset||0,M=new A(r[1],x,t.sparse.count*T),N=new c(r[2],E,t.sparse.count*o);a!==null&&(m=new V(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let S=0,H=M.length;S<H;S++){const P=M[S];if(m.setX(P,N[S*o]),o>=2&&m.setY(P,N[S*o+1]),o>=3&&m.setZ(P,N[S*o+2]),o>=4&&m.setW(P,N[S*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=p}return m})}loadTexture(n){const e=this.json,s=this.options,i=e.textures[n].source,r=e.images[i];let a=this.textureLoader;if(r.uri){const o=s.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(n,i,a)}loadTextureImage(n,e,s){const t=this,i=this.json,r=i.textures[n],a=i.images[e],o=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,s).then(function(u){u.flipY=!1,u.name=r.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const h=(i.samplers||{})[r.sampler]||{};return u.magFilter=ue[h.magFilter]||J,u.minFilter=ue[h.minFilter]||Te,u.wrapS=le[h.wrapS]||Z,u.wrapT=le[h.wrapT]||Z,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==Re&&u.minFilter!==J,t.associations.set(u,{textures:n}),u}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(n,e){const s=this,t=this.json,i=this.options;if(this.sourceCache[n]!==void 0)return this.sourceCache[n].then(l=>l.clone());const r=t.images[n],a=self.URL||self.webkitURL;let o=r.uri||"",c=!1;if(r.bufferView!==void 0)o=s.getDependency("bufferView",r.bufferView).then(function(l){c=!0;const h=new Blob([l],{type:r.mimeType});return o=a.createObjectURL(h),o});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+n+" is missing URI and bufferView");const u=Promise.resolve(o).then(function(l){return new Promise(function(h,d){let p=h;e.isImageBitmapLoader===!0&&(p=function(R){const m=new ne(R);m.needsUpdate=!0,h(m)}),e.load(G.resolveURL(l,i.path),p,void 0,d)})}).then(function(l){return c===!0&&a.revokeObjectURL(o),y(l,r),l.userData.mimeType=r.mimeType||Gn(r.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),l});return this.sourceCache[n]=u,u}assignTexture(n,e,s,t){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[g.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[g.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=i.associations.get(r);r=i.extensions[g.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,o)}}return t!==void 0&&(r.colorSpace=t),n[e]=r,r})}assignFinalMaterial(n){const e=n.geometry;let s=n.material;const t=e.attributes.tangent===void 0,i=e.attributes.color!==void 0,r=e.attributes.normal===void 0;if(n.isPoints){const a="PointsMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new Ge,X.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(a,o)),s=o}else if(n.isLine){const a="LineBasicMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new Ue,X.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(a,o)),s=o}if(t||i||r){let a="ClonedMaterial:"+s.uuid+":";t&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=s.clone(),i&&(o.vertexColors=!0),r&&(o.flatShading=!0),t&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(s))),s=o}n.material=s}getMaterialType(){return Ee}loadMaterial(n){const e=this,s=this.json,t=this.extensions,i=s.materials[n];let r;const a={},o=i.extensions||{},c=[];if(o[g.KHR_MATERIALS_UNLIT]){const l=t[g.KHR_MATERIALS_UNLIT];r=l.getMaterialType(),c.push(l.extendParams(a,i,e))}else{const l=i.pbrMetallicRoughness||{};if(a.color=new F(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){const h=l.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],b),a.opacity=h[3]}l.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",l.baseColorTexture,U)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",l.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",l.metallicRoughnessTexture))),r=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(n)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(n,a)})))}i.doubleSided===!0&&(a.side=Ke);const u=i.alphaMode||W.OPAQUE;if(u===W.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===W.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==v&&(c.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new pe(1,1),i.normalTexture.scale!==void 0)){const l=i.normalTexture.scale;a.normalScale.set(l,l)}if(i.occlusionTexture!==void 0&&r!==v&&(c.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==v){const l=i.emissiveFactor;a.emissive=new F().setRGB(l[0],l[1],l[2],b)}return i.emissiveTexture!==void 0&&r!==v&&c.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture,U)),Promise.all(c).then(function(){const l=new r(a);return i.name&&(l.name=i.name),y(l,i),e.associations.set(l,{materials:n}),i.extensions&&O(t,l,i),l})}createUniqueName(n){const e=Be.sanitizeNodeName(n||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(n){const e=this,s=this.extensions,t=this.primitiveCache;function i(a){return s[g.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return fe(o,a,e)})}const r=[];for(let a=0,o=n.length;a<o;a++){const c=n[a],u=vn(c),l=t[u];if(l)r.push(l.promise);else{let h;c.extensions&&c.extensions[g.KHR_DRACO_MESH_COMPRESSION]?h=i(c):h=fe(new je,c,e),t[u]={primitive:c,promise:h},r.push(h)}}return Promise.all(r)}loadMesh(n){const e=this,s=this.json,t=this.extensions,i=s.meshes[n],r=i.primitives,a=[];for(let o=0,c=r.length;o<c;o++){const u=r[o].material===void 0?kn(this.cache):this.getDependency("material",r[o].material);a.push(u)}return a.push(e.loadGeometries(r)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),u=o[o.length-1],l=[];for(let d=0,p=u.length;d<p;d++){const R=u[d],m=r[d];let T;const A=c[d];if(m.mode===L.TRIANGLES||m.mode===L.TRIANGLE_STRIP||m.mode===L.TRIANGLE_FAN||m.mode===void 0)T=i.isSkinnedMesh===!0?new Ve(R,A):new Xe(R,A),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),m.mode===L.TRIANGLE_STRIP?T.geometry=oe(T.geometry,he):m.mode===L.TRIANGLE_FAN&&(T.geometry=oe(T.geometry,Q));else if(m.mode===L.LINES)T=new ze(R,A);else if(m.mode===L.LINE_STRIP)T=new qe(R,A);else if(m.mode===L.LINE_LOOP)T=new We(R,A);else if(m.mode===L.POINTS)T=new Ye(R,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(T.geometry.morphAttributes).length>0&&Dn(T,i),T.name=e.createUniqueName(i.name||"mesh_"+n),y(T,i),m.extensions&&O(t,T,m),e.assignFinalMaterial(T),l.push(T)}for(let d=0,p=l.length;d<p;d++)e.associations.set(l[d],{meshes:n,primitives:d});if(l.length===1)return i.extensions&&O(t,l[0],i),l[0];const h=new z;i.extensions&&O(t,h,i),e.associations.set(h,{meshes:n});for(let d=0,p=l.length;d<p;d++)h.add(l[d]);return h})}loadCamera(n){let e;const s=this.json.cameras[n],t=s[s.type];if(!t){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?e=new Qe(Je.radToDeg(t.yfov),t.aspectRatio||1,t.znear||1,t.zfar||2e6):s.type==="orthographic"&&(e=new Ze(-t.xmag,t.xmag,t.ymag,-t.ymag,t.znear,t.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),y(e,s),Promise.resolve(e)}loadSkin(n){const e=this.json.skins[n],s=[];for(let t=0,i=e.joints.length;t<i;t++)s.push(this._loadNodeShallow(e.joints[t]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(t){const i=t.pop(),r=t,a=[],o=[];for(let c=0,u=r.length;c<u;c++){const l=r[c];if(l){a.push(l);const h=new K;i!==null&&h.fromArray(i.array,c*16),o.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new $e(a,o)})}loadAnimation(n){const e=this.json,s=this,t=e.animations[n],i=t.name?t.name:"animation_"+n,r=[],a=[],o=[],c=[],u=[];for(let l=0,h=t.channels.length;l<h;l++){const d=t.channels[l],p=t.samplers[d.sampler],R=d.target,m=R.node,T=t.parameters!==void 0?t.parameters[p.input]:p.input,A=t.parameters!==void 0?t.parameters[p.output]:p.output;R.node!==void 0&&(r.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",T)),o.push(this.getDependency("accessor",A)),c.push(p),u.push(R))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(u)]).then(function(l){const h=l[0],d=l[1],p=l[2],R=l[3],m=l[4],T=[];for(let x=0,E=h.length;x<E;x++){const M=h[x],N=d[x],S=p[x],H=R[x],P=m[x];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();const B=s._createAnimationTracks(M,N,S,H,P);if(B)for(let j=0;j<B.length;j++)T.push(B[j])}const A=new en(i,void 0,T);return y(A,t),A})}createNodeMesh(n){const e=this.json,s=this,t=e.nodes[n];return t.mesh===void 0?null:s.getDependency("mesh",t.mesh).then(function(i){const r=s._getNodeRef(s.meshCache,t.mesh,i);return t.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let o=0,c=t.weights.length;o<c;o++)a.morphTargetInfluences[o]=t.weights[o]}),r})}loadNode(n){const e=this.json,s=this,t=e.nodes[n],i=s._loadNodeShallow(n),r=[],a=t.children||[];for(let c=0,u=a.length;c<u;c++)r.push(s.getDependency("node",a[c]));const o=t.skin===void 0?Promise.resolve(null):s.getDependency("skin",t.skin);return Promise.all([i,Promise.all(r),o]).then(function(c){const u=c[0],l=c[1],h=c[2];h!==null&&u.traverse(function(d){d.isSkinnedMesh&&d.bind(h,Un)});for(let d=0,p=l.length;d<p;d++)u.add(l[d]);if(u.userData.pivot!==void 0&&l.length>0){const d=u.userData.pivot,p=l[0];u.pivot=new C().fromArray(d),u.position.x-=d[0],u.position.y-=d[1],u.position.z-=d[2],p.position.set(0,0,0),delete u.userData.pivot}return u})}_loadNodeShallow(n){const e=this.json,s=this.extensions,t=this;if(this.nodeCache[n]!==void 0)return this.nodeCache[n];const i=e.nodes[n],r=i.name?t.createUniqueName(i.name):"",a=[],o=t._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(n)});return o&&a.push(o),i.camera!==void 0&&a.push(t.getDependency("camera",i.camera).then(function(c){return t._getNodeRef(t.cameraCache,i.camera,c)})),t._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(n)}).forEach(function(c){a.push(c)}),this.nodeCache[n]=Promise.all(a).then(function(c){let u;if(i.isBone===!0?u=new nn:c.length>1?u=new z:c.length===1?u=c[0]:u=new ge,u!==c[0])for(let l=0,h=c.length;l<h;l++)u.add(c[l]);if(i.name&&(u.userData.name=i.name,u.name=r),y(u,i),i.extensions&&O(s,u,i),i.matrix!==void 0){const l=new K;l.fromArray(i.matrix),u.applyMatrix4(l)}else i.translation!==void 0&&u.position.fromArray(i.translation),i.rotation!==void 0&&u.quaternion.fromArray(i.rotation),i.scale!==void 0&&u.scale.fromArray(i.scale);if(!t.associations.has(u))t.associations.set(u,{});else if(i.mesh!==void 0&&t.meshCache.refs[i.mesh]>1){const l=t.associations.get(u);t.associations.set(u,{...l})}return t.associations.get(u).nodes=n,u}),this.nodeCache[n]}loadScene(n){const e=this.extensions,s=this.json.scenes[n],t=this,i=new z;s.name&&(i.name=t.createUniqueName(s.name)),y(i,s),s.extensions&&O(e,i,s);const r=s.nodes||[],a=[];for(let o=0,c=r.length;o<c;o++)a.push(t.getDependency("node",r[o]));return Promise.all(a).then(function(o){for(let u=0,l=o.length;u<l;u++){const h=o[u];h.parent!==null?i.add(un(h)):i.add(h)}const c=u=>{const l=new Map;for(const[h,d]of t.associations)(h instanceof X||h instanceof ne)&&l.set(h,d);return u.traverse(h=>{const d=t.associations.get(h);d!=null&&l.set(h,d)}),l};return t.associations=c(i),i})}_createAnimationTracks(n,e,s,t,i){const r=[],a=n.name?n.name:n.uuid,o=[];function c(d){d.morphTargetInfluences&&o.push(d.name?d.name:d.uuid)}I[i.path]===I.weights?(c(n),n.isGroup&&n.children.forEach(c)):o.push(a);let u;switch(I[i.path]){case I.weights:u=se;break;case I.rotation:u=ie;break;case I.translation:case I.scale:u=te;break;default:switch(s.itemSize){case 1:u=se;break;case 2:case 3:default:u=te;break}break}const l=t.interpolation!==void 0?Pn[t.interpolation]:xe,h=this._getArrayFromAccessor(s);for(let d=0,p=o.length;d<p;d++){const R=new u(o[d]+"."+I[i.path],e.array,h,l);t.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(R),r.push(R)}return r}_getArrayFromAccessor(n){let e=n.array;if(n.normalized){const s=ee(e.constructor),t=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)t[i]=e[i]*s;e=t}return e}_createCubicSplineTrackInterpolant(n){n.createInterpolant=function(s){const t=this instanceof ie?Fn:Me;return new t(this.times,this.values,this.getValueSize()/3,s)},n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Bn(f,n,e){const s=n.attributes,t=new an;if(s.POSITION!==void 0){const a=e.json.accessors[s.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(t.set(new C(o[0],o[1],o[2]),new C(c[0],c[1],c[2])),a.normalized){const u=ee(k[a.componentType]);t.min.multiplyScalar(u),t.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=n.targets;if(i!==void 0){const a=new C,o=new C;for(let c=0,u=i.length;c<u;c++){const l=i[c];if(l.POSITION!==void 0){const h=e.json.accessors[l.POSITION],d=h.min,p=h.max;if(d!==void 0&&p!==void 0){if(o.setX(Math.max(Math.abs(d[0]),Math.abs(p[0]))),o.setY(Math.max(Math.abs(d[1]),Math.abs(p[1]))),o.setZ(Math.max(Math.abs(d[2]),Math.abs(p[2]))),h.normalized){const R=ee(k[h.componentType]);o.multiplyScalar(R)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}t.expandByVector(a)}f.boundingBox=t;const r=new cn;t.getCenter(r.center),r.radius=t.min.distanceTo(t.max)/2,f.boundingSphere=r}function fe(f,n,e){const s=n.attributes,t=[];function i(r,a){return e.getDependency("accessor",r).then(function(o){f.setAttribute(a,o)})}for(const r in s){const a=$[r]||r.toLowerCase();a in f.attributes||t.push(i(s[r],a))}if(n.indices!==void 0&&!f.index){const r=e.getDependency("accessor",n.indices).then(function(a){f.setIndex(a)});t.push(r)}return re.workingColorSpace!==b&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${re.workingColorSpace}" not supported.`),y(f,n),Bn(f,n,e),Promise.all(t).then(function(){return n.targets!==void 0?Hn(f,n.targets,e):f})}export{Vn as GLTFLoader};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as h}from"./rr0-sighting-editor.mjs";class t{static ZIP_MAGIC=[80,75,3,4];static GEOMETRY=new Set(["Point","LineString","LinearRing","Polygon","MultiGeometry"]);static UNSUPPORTED=new Set(["GroundOverlay","ScreenOverlay","PhotoOverlay","Model","Tour","NetworkLink","Track","MultiTrack"]);static async fromBytes(e){if(t.ZIP_MAGIC.every((i,o)=>e[o]===i)){const{unzipSync:i,strFromU8:o}=await h(async()=>{const{unzipSync:c,strFromU8:s}=await import("./browser-c3U3mMxj.js");return{unzipSync:c,strFromU8:s}},[],import.meta.url),n=i(e),r=Object.keys(n),a=r.find(c=>c.toLowerCase()==="doc.kml")??r.find(c=>c.toLowerCase().endsWith(".kml"));if(!a)throw new Error("This KMZ holds no KML file.");return t.fromText(o(n[a]))}return t.fromText(new TextDecoder("utf-8").decode(e))}static fromText(e){const i=new DOMParser().parseFromString(e,"application/xml");if(i.getElementsByTagName("parsererror").length>0||!i.documentElement)throw new Error("This is not a readable KML file.");const o=t.styleColours(i),n=[],r=new Set,a=s=>{for(const l of Array.from(s.children)){const f=t.local(l);f==="Placemark"?t.placemark(l,o,n,r):f==="Document"||f==="Folder"?a(l):t.UNSUPPORTED.has(f)&&r.add(f)}};a(i.documentElement);const c=t.text(t.firstChild(t.firstChild(i.documentElement,"Document")??i.documentElement,"name"));return{traces:n,skipped:[...r],documentName:c}}static placemark(e,i,o,n){const r=t.text(t.firstChild(e,"name")),a=t.colourOf(e,i);for(const c of Array.from(e.children)){const s=t.local(c);t.GEOMETRY.has(s)?t.geometry(c,r,a,o):t.UNSUPPORTED.has(s)&&n.add(s)}}static geometry(e,i,o,n){const r=t.local(e);if(r==="MultiGeometry"){for(const u of Array.from(e.children))t.GEOMETRY.has(t.local(u))&&t.geometry(u,i,o,n);return}const a=r==="Polygon"?t.firstChild(t.firstChild(e,"outerBoundaryIs")??e,"LinearRing"):e,c=t.firstChild(a??e,"coordinates"),s=c?t.points(c.textContent??""):[],l=r==="Point"?"point":r==="LineString"?"line":"polygon";if(l==="polygon"&&s.length>1){const u=s[0],d=s[s.length-1];u.lat===d.lat&&u.lng===d.lng&&u.altM===d.altM&&s.pop()}if(s.length===0||l==="line"&&s.length<2||l==="polygon"&&s.length<3)return;const f=t.altitudeOf(e);n.push({kind:l,points:s,...i?{title:i}:{},...f!=="ground"?{altitude:f}:{},...o?{color:o}:{}})}static points(e){const i=[];for(const o of e.trim().split(/\s+/)){const[n,r,a]=o.split(",").map(Number);!Number.isFinite(n)||!Number.isFinite(r)||Math.abs(r)>90||Math.abs(n)>180||i.push(Number.isFinite(a)&&a!==0?{lat:r,lng:n,altM:a}:{lat:r,lng:n})}return i}static altitudeOf(e){const i=t.text(t.firstChild(e,"altitudeMode")??t.firstChild(e,"altitudeMode",!0));return i==="absolute"?"absolute":i==="relativeToGround"?"relative":"ground"}static colourOf(e,i){const o=t.styleColour(t.firstChild(e,"Style"));if(o)return o;const n=t.text(t.firstChild(e,"styleUrl"));return n?i.get(n.replace(/^#/,"")):void 0}static styleColours(e){const i=new Map,o=Array.from(e.getElementsByTagName("*"));for(const n of o){if(t.local(n)!=="Style")continue;const r=n.getAttribute("id"),a=t.styleColour(n);r&&a&&i.set(r,a)}for(const n of o){if(t.local(n)!=="StyleMap")continue;const r=n.getAttribute("id");if(r)for(const a of Array.from(n.children)){if(t.text(t.firstChild(a,"key"))!=="normal")continue;const c=t.text(t.firstChild(a,"styleUrl"))?.replace(/^#/,""),s=c?i.get(c):void 0;s&&i.set(r,s)}}return i}static styleColour(e){if(e)for(const i of["LineStyle","PolyStyle","IconStyle"]){const o=t.text(t.firstChild(t.firstChild(e,i)??e,"color"));if(o)return t.cssColour(o)}}static cssColour(e){const i=/^([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e.trim());return i?`#${i[4]}${i[3]}${i[2]}`.toLowerCase():void 0}static local(e){return e.localName||e.nodeName.replace(/^.*:/,"")}static firstChild(e,i,o=!1){if(e){for(const n of Array.from(o?e.getElementsByTagName("*"):e.children))if(t.local(n)===i)return n}}static text(e){const i=e?.textContent?.trim();return i||void 0}}export{t as KmlImport};
|