@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,d as G,e as Z,V as E,f as te,g as O,h as $,i as ie,j as I,M as ne,k as B,L as se,m as oe,n as re,G as ae,C as le,D as de,o as ce,P as fe,q as ue,r as pe}from"./rr0-sighting-editor.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};
|