@realsee/five 6.8.0-alpha.17 → 6.8.0-alpha.18

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.
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @license
3
3
  * @realsee/five
4
- * Generated: 3/13/2026
5
- * Version: 6.8.0-alpha.17
4
+ * Generated: 3/17/2026
5
+ * Version: 6.8.0-alpha.18
6
6
  * Terms:
7
7
  * Realsee SDK License Agreement
8
8
  * Update: July 28, 2021
@@ -252,830 +252,430 @@
252
252
  * No amendment to or modification of this Agreement will be binding unless in
253
253
  * writing and signed by Realsee. You and Realsee hereto confirm that this
254
254
  * Agreement and all related documents shall be drafted in English.
255
- */import { CustomShader as F } from "@realsee/five";
256
- import * as l from "three";
257
- var M = function(i, e) {
258
- return M = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, o) {
259
- n.__proto__ = o;
260
- } || function(n, o) {
261
- for (var t in o) Object.prototype.hasOwnProperty.call(o, t) && (n[t] = o[t]);
262
- }, M(i, e);
255
+ */import { CustomShader as e } from "@realsee/five";
256
+ import * as t from "three";
257
+ //#region build/shader-lib/EvenessPlane/index.js
258
+ var n = {
259
+ type: ["pointcloud"],
260
+ fragment: {
261
+ mainBefore: "\n #if defined(USE_PLANE_DISTANCE)\n struct Plane {\n vec3 normal;\n float constant;\n };\n uniform Plane evennessPlanes[6];\n uniform vec3 evennessPlaneNormal;\n uniform float evennessPlaneConstant;\n uniform float evennessPlaneDepth;\n #endif\n",
262
+ mainStart: "",
263
+ mainEnd: "\n #if defined(USE_PLANE_DISTANCE)\n\n bool inside = true;\n for (int i = 0; i < 6; i++) {\n if (dot(evennessPlanes[i].normal, vWorldPosition.xyz) + evennessPlanes[i].constant > 0.0) {\n inside = false;\n break;\n }\n }\n if (inside) {\n float distanceToPlane = (dot(evennessPlaneNormal, vWorldPosition.xyz) + evennessPlaneConstant) / length(evennessPlaneNormal);\n float progress = distanceToPlane * (1.0 / evennessPlaneDepth);\n if(distanceToPlane > 0.0) {\n gl_FragColor = mix(vec4(0.0,1.0,0.0,1.0), vec4(1.0,0.0,0.0,1.0), progress);\n }else{\n gl_FragColor = mix(vec4(0.0,1.0,0.0,1.0), vec4(0.0,0.0,1.0,1.0), progress);\n }\n }\n #endif\n"
264
+ },
265
+ uniforms: {
266
+ evennessPlaneNormal: new t.Uniform(new t.Vector3()),
267
+ evennessPlaneConstant: new t.Uniform(0),
268
+ evennessPlanes: new t.Uniform([]),
269
+ evennessPlaneDepth: new t.Uniform(0)
270
+ },
271
+ defines: { USE_PLANE_DISTANCE: !1 }
272
+ }, r = class extends e {
273
+ constructor() {
274
+ super(n), Object.defineProperties(this, { evennessPlane: {
275
+ get() {
276
+ return {
277
+ depth: this.uniforms.evennessPlaneDepth.value,
278
+ points: this.uniforms.evennessPoints.value
279
+ };
280
+ },
281
+ set(e) {
282
+ let { points: n, depth: r } = e, i = !1;
283
+ if (n.length !== 0 && n.length % 4 == 0) {
284
+ i = !0;
285
+ let e = n[0], a = n[1], o = n[2], s = n[3], c = new t.Vector3().subVectors(a, e), l = new t.Vector3().subVectors(o, e), u = new t.Vector3().crossVectors(c, l).normalize(), d = -u.dot(e), f = r, p = e.clone().add(u.clone().negate().multiplyScalar(f)), m = e.clone().add(u.clone().multiplyScalar(f)), h = a.clone().add(u.clone().negate().multiplyScalar(f)), g = a.clone().add(u.clone().multiplyScalar(f)), _ = o.clone().add(u.clone().negate().multiplyScalar(f)), v = o.clone().add(u.clone().multiplyScalar(f)), y = s.clone().add(u.clone().negate().multiplyScalar(f)), b = s.clone().add(u.clone().multiplyScalar(f)), x = new t.Plane().setFromCoplanarPoints(m, g, v), S = new t.Plane().setFromCoplanarPoints(_, h, p), C = new t.Plane().setFromCoplanarPoints(g, m, p), w = new t.Plane().setFromCoplanarPoints(y, b, v), T = new t.Plane().setFromCoplanarPoints(v, g, h), E = new t.Plane().setFromCoplanarPoints(p, m, b);
286
+ this.uniforms.evennessPlanes.value = [
287
+ {
288
+ normal: x.normal,
289
+ constant: x.constant
290
+ },
291
+ {
292
+ normal: S.normal,
293
+ constant: S.constant
294
+ },
295
+ {
296
+ normal: C.normal,
297
+ constant: C.constant
298
+ },
299
+ {
300
+ normal: w.normal,
301
+ constant: w.constant
302
+ },
303
+ {
304
+ normal: T.normal,
305
+ constant: T.constant
306
+ },
307
+ {
308
+ normal: E.normal,
309
+ constant: E.constant
310
+ }
311
+ ], this.uniforms.evennessPlaneDepth.value = r, this.uniforms.evennessPlaneNormal.value = u, this.uniforms.evennessPlaneConstant.value = d;
312
+ }
313
+ this.defines.USE_PLANE_DISTANCE = i, this.needsUpdate = !0;
314
+ }
315
+ } }), this.evennessPlane = {
316
+ depth: 0,
317
+ points: []
318
+ };
319
+ }
320
+ }, i = "\n #if NUM_SWEEP_OBJECTS > 0\n uniform float sweepProgress;\n uniform float sweepRange;\n uniform float interval; // 直接定义间隔距离\n uniform float threshold; // 绝对线宽值\n\n struct SWEEP_OBJECT {\n vec3 min;\n vec3 max;\n };\n uniform SWEEP_OBJECT sweepBoxs[NUM_SWEEP_OBJECTS];\n #endif\n", a = "\n\n #if NUM_SWEEP_OBJECTS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SWEEP_OBJECTS; i ++ ) {\n vec3 minPos = sweepBoxs[ i ].min;\n vec3 maxPos = sweepBoxs[ i ].max;\n\n // 计算包围盒中心点\n vec3 center = (minPos + maxPos) * 0.5;\n // 计算包围盒半尺寸\n vec3 halfSize = (maxPos - minPos) * 0.5;\n\n // 计算顶点到中心的相对距离(标准化到0-1范围)\n vec3 relativePos = (vWorldPosition.xyz - center) / halfSize;\n float maxDistance = length(relativePos) / sqrt(3.0);\n // 计算扩散不透明度(基于进度和距离)+-sweepRange之间的才有opactiy,其他的为0\n float distanceFromSweep = abs(maxDistance - sweepProgress);\n // 指数衰减:exp(-k*x) 形式\n float k = 5.0 / sweepRange; // 控制衰减速度\n float sweepOpacity = exp(-k * distanceFromSweep) * 0.8;\n if(vWorldPosition.x > minPos.x && vWorldPosition.x < maxPos.x &&\n vWorldPosition.y > minPos.y && vWorldPosition.y < maxPos.y &&\n vWorldPosition.z > minPos.z && vWorldPosition.z < maxPos.z) {\n\n if(maxDistance < sweepProgress + sweepRange && maxDistance > sweepProgress - sweepRange) {\n // 混合颜色\n gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(1.0,1.0,1.0), sweepOpacity);\n }\n }\n }\n #pragma unroll_loop_end\n #endif\n", o = "", s = class extends e {
321
+ constructor() {
322
+ super({
323
+ type: [
324
+ "basic",
325
+ "phong",
326
+ "pointcloud"
327
+ ],
328
+ fragment: {
329
+ mainBefore: i,
330
+ mainStart: o,
331
+ mainEnd: a
332
+ },
333
+ uniforms: {
334
+ sweepProgress: new t.Uniform(0),
335
+ sweepRange: new t.Uniform(0),
336
+ sweepBoxs: new t.Uniform([]),
337
+ interval: new t.Uniform(.04),
338
+ threshold: new t.Uniform(.002)
339
+ },
340
+ defines: { NUM_SWEEP_OBJECTS: 0 }
341
+ }), Object.defineProperties(this, { sweepBoxs: {
342
+ get() {
343
+ return this.uniforms.sweepBoxs.value;
344
+ },
345
+ set(e) {
346
+ let t = e.length;
347
+ t > 0 && (this.defines.NUM_SWEEP_OBJECTS = t, this.needsUpdate = !0, this.uniforms.sweepBoxs.value = e);
348
+ }
349
+ } }), this.sweepBoxs = [];
350
+ }
351
+ onBeforeCompile(e, t) {
352
+ let n = String(this.sweepBoxs.length);
353
+ e.vertexShader = e.vertexShader.replace(/NUM_SWEEP_OBJECTS/g, n), e.fragmentShader = e.fragmentShader.replace(/NUM_SWEEP_OBJECTS/g, n);
354
+ }
355
+ }, c = "\nuniform float pointCloudExpand_progress;\n\nvec4 pointCloudExpand_permute(vec4 x) { return mod(((x * 34.0) + 1.0) * x, 289.0); }\nvec4 pointCloudExpand_taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }\n\nfloat pointCloudExpand_gln_simplex(vec3 v) {\n const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n // First corner\n vec3 i = floor(v + dot(v, C.yyy));\n vec3 x0 = v - i + dot(i, C.xxx);\n\n // Other corners\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min(g.xyz, l.zxy);\n vec3 i2 = max(g.xyz, l.zxy);\n\n // x0 = x0 - 0. + 0.0 * C\n vec3 x1 = x0 - i1 + 1.0 * C.xxx;\n vec3 x2 = x0 - i2 + 2.0 * C.xxx;\n vec3 x3 = x0 - 1. + 3.0 * C.xxx;\n\n // Permutations\n i = mod(i, 289.0);\n vec4 p = pointCloudExpand_permute(pointCloudExpand_permute(pointCloudExpand_permute(i.z + vec4(0.0, i1.z, i2.z, 1.0)) + i.y +\n vec4(0.0, i1.y, i2.y, 1.0)) +\n i.x + vec4(0.0, i1.x, i2.x, 1.0));\n\n // Gradients\n // ( N*N points uniformly over a square, mapped onto an octahedron.)\n float n_ = 1.0 / 7.0; // N=7\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,N*N)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_); // mod(j,N)\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4(x.xy, y.xy);\n vec4 b1 = vec4(x.zw, y.zw);\n\n vec4 s0 = floor(b0) * 2.0 + 1.0;\n vec4 s1 = floor(b1) * 2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n\n vec3 p0 = vec3(a0.xy, h.x);\n vec3 p1 = vec3(a0.zw, h.y);\n vec3 p2 = vec3(a1.xy, h.z);\n vec3 p3 = vec3(a1.zw, h.w);\n\n // Normalise gradients\n vec4 norm =\n pointCloudExpand_taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n // Mix final noise value\n vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n m = m * m;\n return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));\n}\n", l = "\nfloat pointCloudExpand_sizeScale = 1.0;\nfloat pointCloudExpand_sizeBasis = 0.0;\nvec4 pointCloudExpand_basis = vec4((modelBoundingMax + modelBoundingMin) / 2.0, 1.0);\nfloat pointCloudExpand_boundingRadius = length(modelBoundingMax - modelBoundingMin) / 2.0;\nfloat pointCloudExpand_p = length(vWorldPosition - pointCloudExpand_basis) / pointCloudExpand_boundingRadius;\nfloat pointCloudExpand_progress = smoothstep(pointCloudExpand_p, pointCloudExpand_p - 0.03, 1.0 - pointCloudExpand_progress);\nfloat pointCloudExpand_noise = pointCloudExpand_gln_simplex(vWorldPosition.xyz * 10.0);\npointCloudExpand_progress = step(abs(pointCloudExpand_noise), pointCloudExpand_progress);\npointCloudExpand_sizeScale = mix(pointCloudExpand_sizeScale, 0.0, pointCloudExpand_progress);\nfloat pointCloudExpand_progress2 = step(pointCloudExpand_progress, 1.0 - pointCloudExpand_p);\npointCloudExpand_sizeBasis = mix(0.1 * step(abs(pointCloudExpand_noise), 0.5 / pointCloudExpand_boundingRadius), pointCloudExpand_sizeBasis, pointCloudExpand_progress2);\ngl_PointSize = gl_PointSize * pointCloudExpand_sizeScale + pointCloudExpand_sizeBasis;\nvPointSize = gl_PointSize;\n", u = class extends e {
356
+ constructor() {
357
+ super({
358
+ type: ["pointcloud"],
359
+ vertex: {
360
+ mainBefore: c,
361
+ mainEnd: l
362
+ },
363
+ uniforms: { pointCloudExpand_progress: new t.Uniform(0) }
364
+ });
365
+ }
366
+ get progress() {
367
+ return this.uniforms.pointCloudExpand_progress.value;
368
+ }
369
+ set progress(e) {
370
+ this.uniforms.pointCloudExpand_progress.value = e;
371
+ }
263
372
  };
264
- function B(i, e) {
265
- if (typeof e != "function" && e !== null)
266
- throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
267
- M(i, e);
268
- function n() {
269
- this.constructor = i;
270
- }
271
- i.prototype = e === null ? Object.create(e) : (n.prototype = e.prototype, new n());
373
+ //#endregion
374
+ //#region node_modules/tslib/tslib.es6.mjs
375
+ function d(e, t, n, r) {
376
+ function i(e) {
377
+ return e instanceof n ? e : new n(function(t) {
378
+ t(e);
379
+ });
380
+ }
381
+ return new (n || (n = Promise))(function(n, a) {
382
+ function o(e) {
383
+ try {
384
+ c(r.next(e));
385
+ } catch (e) {
386
+ a(e);
387
+ }
388
+ }
389
+ function s(e) {
390
+ try {
391
+ c(r.throw(e));
392
+ } catch (e) {
393
+ a(e);
394
+ }
395
+ }
396
+ function c(e) {
397
+ e.done ? n(e.value) : i(e.value).then(o, s);
398
+ }
399
+ c((r = r.apply(e, t || [])).next());
400
+ });
272
401
  }
273
- function A(i, e, n, o) {
274
- function t(r) {
275
- return r instanceof n ? r : new n(function(s) {
276
- s(r);
277
- });
278
- }
279
- return new (n || (n = Promise))(function(r, s) {
280
- function f(u) {
281
- try {
282
- a(o.next(u));
283
- } catch (v) {
284
- s(v);
285
- }
286
- }
287
- function c(u) {
288
- try {
289
- a(o.throw(u));
290
- } catch (v) {
291
- s(v);
292
- }
293
- }
294
- function a(u) {
295
- u.done ? r(u.value) : t(u.value).then(f, c);
296
- }
297
- a((o = o.apply(i, e || [])).next());
298
- });
402
+ //#endregion
403
+ //#region build/shader-lib/PolygonCuter/worker.js?worker&inline
404
+ var f = "(function(){function e(e){onmessage=t=>{Promise.resolve(t.data).then(t=>e(t)).then(({output:e,transfer:t})=>postMessage(e,t)).catch(e=>postMessage({$$error:e}))}}function t(e,t,n){let r=new OffscreenCanvas(t,n).getContext(`2d`);if(!r)throw Error(`Failed to get canvas context`);r.clearRect(0,0,t,n),r.fillStyle=`rgba(0,0,0,1.0)`,r.beginPath();let i=e[0][0],a=e[0][0],o=e[0][1],s=e[0][1];e.forEach(e=>{let t=e[0],n=e[1];i=Math.min(i,t),a=Math.max(a,t),o=Math.min(o,n),s=Math.max(s,n)});let c=a-i,l=s-o,u=c>=l?t/c:t/l;return e.map(e=>[e[0]-i,e[1]-o]).map(e=>[e[0]*u,e[1]*u]).forEach((e,t)=>{let[n,i]=e;t===0?r.moveTo(n,i):r.lineTo(n,i)}),r.closePath(),r.fill(),r.getImageData(0,0,t,n)}function n(e,n,r){let i=new ImageData(n,r),a=e.map(e=>t(e.polygon,e.width,e.height));for(let e=0;e<n;e++)for(let t=0;t<r;t++){let r=0,o=0,s=0;for(let i=0;i<a.length;i++)if(a[i].data[(e+t*n)*4+3]===255){let e=i%8,t=Math.floor(i/8);t===0?r|=1<<e:t===1?o|=1<<e:t===2&&(s|=1<<e)}let c=(e+t*n)*4;i.data[c]=r,i.data[c+1]=o,i.data[c+2]=s,i.data[c+3]=255}return i}e(e=>Promise.resolve(e).then(({canvasDataList:e,width:t,height:r})=>{let i=n(e,t,r);return{output:{imageData:i},transfer:[i.data.buffer]}}))})();", p = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", f], { type: "text/javascript;charset=utf-8" });
405
+ function m(e) {
406
+ let t;
407
+ try {
408
+ if (t = p && (self.URL || self.webkitURL).createObjectURL(p), !t) throw "";
409
+ let n = new Worker(t, { name: e == null ? void 0 : e.name });
410
+ return n.addEventListener("error", () => {
411
+ (self.URL || self.webkitURL).revokeObjectURL(t);
412
+ }), n;
413
+ } catch (t) {
414
+ return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(f), { name: e == null ? void 0 : e.name });
415
+ }
299
416
  }
300
- function k(i, e) {
301
- var n = { label: 0, sent: function() {
302
- if (r[0] & 1) throw r[1];
303
- return r[1];
304
- }, trys: [], ops: [] }, o, t, r, s = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
305
- return s.next = f(0), s.throw = f(1), s.return = f(2), typeof Symbol == "function" && (s[Symbol.iterator] = function() {
306
- return this;
307
- }), s;
308
- function f(a) {
309
- return function(u) {
310
- return c([a, u]);
311
- };
312
- }
313
- function c(a) {
314
- if (o) throw new TypeError("Generator is already executing.");
315
- for (; s && (s = 0, a[0] && (n = 0)), n; ) try {
316
- if (o = 1, t && (r = a[0] & 2 ? t.return : a[0] ? t.throw || ((r = t.return) && r.call(t), 0) : t.next) && !(r = r.call(t, a[1])).done) return r;
317
- switch (t = 0, r && (a = [a[0] & 2, r.value]), a[0]) {
318
- case 0:
319
- case 1:
320
- r = a;
321
- break;
322
- case 4:
323
- return n.label++, { value: a[1], done: !1 };
324
- case 5:
325
- n.label++, t = a[1], a = [0];
326
- continue;
327
- case 7:
328
- a = n.ops.pop(), n.trys.pop();
329
- continue;
330
- default:
331
- if (r = n.trys, !(r = r.length > 0 && r[r.length - 1]) && (a[0] === 6 || a[0] === 2)) {
332
- n = 0;
333
- continue;
334
- }
335
- if (a[0] === 3 && (!r || a[1] > r[0] && a[1] < r[3])) {
336
- n.label = a[1];
337
- break;
338
- }
339
- if (a[0] === 6 && n.label < r[1]) {
340
- n.label = r[1], r = a;
341
- break;
342
- }
343
- if (r && n.label < r[2]) {
344
- n.label = r[2], n.ops.push(a);
345
- break;
346
- }
347
- r[2] && n.ops.pop(), n.trys.pop();
348
- continue;
349
- }
350
- a = e.call(i, n);
351
- } catch (u) {
352
- a = [6, u], t = 0;
353
- } finally {
354
- o = r = 0;
355
- }
356
- if (a[0] & 5) throw a[1];
357
- return { value: a[0] ? a[1] : void 0, done: !0 };
358
- }
359
- }
360
- function I(i, e, n) {
361
- if (n || arguments.length === 2) for (var o = 0, t = e.length, r; o < t; o++)
362
- (r || !(o in e)) && (r || (r = Array.prototype.slice.call(e, 0, o)), r[o] = e[o]);
363
- return i.concat(r || Array.prototype.slice.call(e));
364
- }
365
- var R = `
366
- #if defined(USE_PLANE_DISTANCE)
367
- struct Plane {
368
- vec3 normal;
369
- float constant;
370
- };
371
- uniform Plane evennessPlanes[6];
372
- uniform vec3 evennessPlaneNormal;
373
- uniform float evennessPlaneConstant;
374
- uniform float evennessPlaneDepth;
375
- #endif
376
- `, V = `
377
- #if defined(USE_PLANE_DISTANCE)
378
-
379
- bool inside = true;
380
- for (int i = 0; i < 6; i++) {
381
- if (dot(evennessPlanes[i].normal, vWorldPosition.xyz) + evennessPlanes[i].constant > 0.0) {
382
- inside = false;
383
- break;
384
- }
385
- }
386
- if (inside) {
387
- float distanceToPlane = (dot(evennessPlaneNormal, vWorldPosition.xyz) + evennessPlaneConstant) / length(evennessPlaneNormal);
388
- float progress = distanceToPlane * (1.0 / evennessPlaneDepth);
389
- if(distanceToPlane > 0.0) {
390
- gl_FragColor = mix(vec4(0.0,1.0,0.0,1.0), vec4(1.0,0.0,0.0,1.0), progress);
391
- }else{
392
- gl_FragColor = mix(vec4(0.0,1.0,0.0,1.0), vec4(0.0,0.0,1.0,1.0), progress);
393
- }
394
- }
395
- #endif
396
- `, W = "", L = {
397
- type: ["pointcloud"],
398
- fragment: {
399
- mainBefore: R,
400
- mainStart: W,
401
- mainEnd: V
402
- },
403
- uniforms: {
404
- evennessPlaneNormal: new l.Uniform(new l.Vector3()),
405
- evennessPlaneConstant: new l.Uniform(0),
406
- evennessPlanes: new l.Uniform([]),
407
- evennessPlaneDepth: new l.Uniform(0)
408
- },
409
- defines: {
410
- USE_PLANE_DISTANCE: !1
411
- }
412
- }, tn = (
413
- /** @class */
414
- (function(i) {
415
- B(e, i);
416
- function e() {
417
- var n = i.call(this, L) || this;
418
- return Object.defineProperties(n, {
419
- evennessPlane: {
420
- get: function() {
421
- return {
422
- depth: this.uniforms.evennessPlaneDepth.value,
423
- points: this.uniforms.evennessPoints.value
424
- };
425
- },
426
- set: function(o) {
427
- var t = o.points, r = o.depth, s = !1;
428
- if (t.length !== 0 && t.length % 4 === 0) {
429
- s = !0;
430
- var f = t[0], c = t[1], a = t[2], u = t[3], v = new l.Vector3().subVectors(c, f), h = new l.Vector3().subVectors(a, f), m = new l.Vector3().crossVectors(v, h).normalize(), y = -m.dot(f), p = r, g = f.clone().add(m.clone().negate().multiplyScalar(p)), d = f.clone().add(m.clone().multiplyScalar(p)), x = c.clone().add(m.clone().negate().multiplyScalar(p)), P = c.clone().add(m.clone().multiplyScalar(p)), w = a.clone().add(m.clone().negate().multiplyScalar(p)), E = a.clone().add(m.clone().multiplyScalar(p)), b = u.clone().add(m.clone().negate().multiplyScalar(p)), C = u.clone().add(m.clone().multiplyScalar(p)), S = new l.Plane().setFromCoplanarPoints(d, P, E), _ = new l.Plane().setFromCoplanarPoints(w, x, g), z = new l.Plane().setFromCoplanarPoints(P, d, g), N = new l.Plane().setFromCoplanarPoints(b, C, E), D = new l.Plane().setFromCoplanarPoints(E, P, x), O = new l.Plane().setFromCoplanarPoints(g, d, C);
431
- this.uniforms.evennessPlanes.value = [
432
- { normal: S.normal, constant: S.constant },
433
- { normal: _.normal, constant: _.constant },
434
- { normal: z.normal, constant: z.constant },
435
- { normal: N.normal, constant: N.constant },
436
- { normal: D.normal, constant: D.constant },
437
- { normal: O.normal, constant: O.constant }
438
- ], this.uniforms.evennessPlaneDepth.value = r, this.uniforms.evennessPlaneNormal.value = m, this.uniforms.evennessPlaneConstant.value = y;
439
- }
440
- this.defines.USE_PLANE_DISTANCE = s, this.needsUpdate = !0;
441
- }
442
- }
443
- }), n.evennessPlane = {
444
- depth: 0,
445
- points: []
446
- }, n;
447
- }
448
- return e;
449
- })(F)
450
- ), j = `
451
- #if NUM_SWEEP_OBJECTS > 0
452
- uniform float sweepProgress;
453
- uniform float sweepRange;
454
- uniform float interval; // 直接定义间隔距离
455
- uniform float threshold; // 绝对线宽值
456
-
457
- struct SWEEP_OBJECT {
458
- vec3 min;
459
- vec3 max;
460
- };
461
- uniform SWEEP_OBJECT sweepBoxs[NUM_SWEEP_OBJECTS];
462
- #endif
463
- `, J = `
464
-
465
- #if NUM_SWEEP_OBJECTS > 0
466
- #pragma unroll_loop_start
467
- for ( int i = 0; i < NUM_SWEEP_OBJECTS; i ++ ) {
468
- vec3 minPos = sweepBoxs[ i ].min;
469
- vec3 maxPos = sweepBoxs[ i ].max;
470
-
471
- // 计算包围盒中心点
472
- vec3 center = (minPos + maxPos) * 0.5;
473
- // 计算包围盒半尺寸
474
- vec3 halfSize = (maxPos - minPos) * 0.5;
475
-
476
- // 计算顶点到中心的相对距离(标准化到0-1范围)
477
- vec3 relativePos = (vWorldPosition.xyz - center) / halfSize;
478
- float maxDistance = length(relativePos) / sqrt(3.0);
479
- // 计算扩散不透明度(基于进度和距离)+-sweepRange之间的才有opactiy,其他的为0
480
- float distanceFromSweep = abs(maxDistance - sweepProgress);
481
- // 指数衰减:exp(-k*x) 形式
482
- float k = 5.0 / sweepRange; // 控制衰减速度
483
- float sweepOpacity = exp(-k * distanceFromSweep) * 0.8;
484
- if(vWorldPosition.x > minPos.x && vWorldPosition.x < maxPos.x &&
485
- vWorldPosition.y > minPos.y && vWorldPosition.y < maxPos.y &&
486
- vWorldPosition.z > minPos.z && vWorldPosition.z < maxPos.z) {
487
-
488
- if(maxDistance < sweepProgress + sweepRange && maxDistance > sweepProgress - sweepRange) {
489
- // 混合颜色
490
- gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(1.0,1.0,1.0), sweepOpacity);
491
- }
492
- }
493
- }
494
- #pragma unroll_loop_end
495
- #endif
496
- `, H = "", rn = (
497
- /** @class */
498
- (function(i) {
499
- B(e, i);
500
- function e() {
501
- var n = i.call(this, {
502
- type: ["basic", "phong", "pointcloud"],
503
- fragment: {
504
- mainBefore: j,
505
- mainStart: H,
506
- mainEnd: J
507
- },
508
- uniforms: {
509
- sweepProgress: new l.Uniform(0),
510
- sweepRange: new l.Uniform(0),
511
- sweepBoxs: new l.Uniform([]),
512
- interval: new l.Uniform(0.04),
513
- // 线间距
514
- threshold: new l.Uniform(2e-3)
515
- // 线宽
516
- },
517
- defines: {
518
- NUM_SWEEP_OBJECTS: 0
519
- }
520
- }) || this;
521
- return Object.defineProperties(n, {
522
- sweepBoxs: {
523
- get: function() {
524
- return this.uniforms.sweepBoxs.value;
525
- },
526
- set: function(o) {
527
- var t = o.length;
528
- t > 0 && (this.defines.NUM_SWEEP_OBJECTS = t, this.needsUpdate = !0, this.uniforms.sweepBoxs.value = o);
529
- }
530
- }
531
- }), n.sweepBoxs = [], n;
532
- }
533
- return e.prototype.onBeforeCompile = function(n, o) {
534
- var t = String(this.sweepBoxs.length);
535
- n.vertexShader = n.vertexShader.replace(/NUM_SWEEP_OBJECTS/g, t), n.fragmentShader = n.fragmentShader.replace(/NUM_SWEEP_OBJECTS/g, t);
536
- }, e;
537
- })(F)
538
- ), G = `
539
- uniform float pointCloudExpand_progress;
540
-
541
- vec4 pointCloudExpand_permute(vec4 x) { return mod(((x * 34.0) + 1.0) * x, 289.0); }
542
- vec4 pointCloudExpand_taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }
543
-
544
- float pointCloudExpand_gln_simplex(vec3 v) {
545
- const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);
546
- const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
547
-
548
- // First corner
549
- vec3 i = floor(v + dot(v, C.yyy));
550
- vec3 x0 = v - i + dot(i, C.xxx);
551
-
552
- // Other corners
553
- vec3 g = step(x0.yzx, x0.xyz);
554
- vec3 l = 1.0 - g;
555
- vec3 i1 = min(g.xyz, l.zxy);
556
- vec3 i2 = max(g.xyz, l.zxy);
557
-
558
- // x0 = x0 - 0. + 0.0 * C
559
- vec3 x1 = x0 - i1 + 1.0 * C.xxx;
560
- vec3 x2 = x0 - i2 + 2.0 * C.xxx;
561
- vec3 x3 = x0 - 1. + 3.0 * C.xxx;
562
-
563
- // Permutations
564
- i = mod(i, 289.0);
565
- vec4 p = pointCloudExpand_permute(pointCloudExpand_permute(pointCloudExpand_permute(i.z + vec4(0.0, i1.z, i2.z, 1.0)) + i.y +
566
- vec4(0.0, i1.y, i2.y, 1.0)) +
567
- i.x + vec4(0.0, i1.x, i2.x, 1.0));
568
-
569
- // Gradients
570
- // ( N*N points uniformly over a square, mapped onto an octahedron.)
571
- float n_ = 1.0 / 7.0; // N=7
572
- vec3 ns = n_ * D.wyz - D.xzx;
573
-
574
- vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,N*N)
575
-
576
- vec4 x_ = floor(j * ns.z);
577
- vec4 y_ = floor(j - 7.0 * x_); // mod(j,N)
578
-
579
- vec4 x = x_ * ns.x + ns.yyyy;
580
- vec4 y = y_ * ns.x + ns.yyyy;
581
- vec4 h = 1.0 - abs(x) - abs(y);
582
-
583
- vec4 b0 = vec4(x.xy, y.xy);
584
- vec4 b1 = vec4(x.zw, y.zw);
585
-
586
- vec4 s0 = floor(b0) * 2.0 + 1.0;
587
- vec4 s1 = floor(b1) * 2.0 + 1.0;
588
- vec4 sh = -step(h, vec4(0.0));
589
-
590
- vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;
591
- vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;
592
-
593
- vec3 p0 = vec3(a0.xy, h.x);
594
- vec3 p1 = vec3(a0.zw, h.y);
595
- vec3 p2 = vec3(a1.xy, h.z);
596
- vec3 p3 = vec3(a1.zw, h.w);
597
-
598
- // Normalise gradients
599
- vec4 norm =
600
- pointCloudExpand_taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));
601
- p0 *= norm.x;
602
- p1 *= norm.y;
603
- p2 *= norm.z;
604
- p3 *= norm.w;
605
-
606
- // Mix final noise value
607
- vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);
608
- m = m * m;
609
- return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));
610
- }
611
- `, q = `
612
- float pointCloudExpand_sizeScale = 1.0;
613
- float pointCloudExpand_sizeBasis = 0.0;
614
- vec4 pointCloudExpand_basis = vec4((modelBoundingMax + modelBoundingMin) / 2.0, 1.0);
615
- float pointCloudExpand_boundingRadius = length(modelBoundingMax - modelBoundingMin) / 2.0;
616
- float pointCloudExpand_p = length(vWorldPosition - pointCloudExpand_basis) / pointCloudExpand_boundingRadius;
617
- float pointCloudExpand_progress = smoothstep(pointCloudExpand_p, pointCloudExpand_p - 0.03, 1.0 - pointCloudExpand_progress);
618
- float pointCloudExpand_noise = pointCloudExpand_gln_simplex(vWorldPosition.xyz * 10.0);
619
- pointCloudExpand_progress = step(abs(pointCloudExpand_noise), pointCloudExpand_progress);
620
- pointCloudExpand_sizeScale = mix(pointCloudExpand_sizeScale, 0.0, pointCloudExpand_progress);
621
- float pointCloudExpand_progress2 = step(pointCloudExpand_progress, 1.0 - pointCloudExpand_p);
622
- pointCloudExpand_sizeBasis = mix(0.1 * step(abs(pointCloudExpand_noise), 0.5 / pointCloudExpand_boundingRadius), pointCloudExpand_sizeBasis, pointCloudExpand_progress2);
623
- gl_PointSize = gl_PointSize * pointCloudExpand_sizeScale + pointCloudExpand_sizeBasis;
624
- vPointSize = gl_PointSize;
625
- `, an = (
626
- /** @class */
627
- (function(i) {
628
- B(e, i);
629
- function e() {
630
- return i.call(this, {
631
- type: ["pointcloud"],
632
- vertex: {
633
- mainBefore: G,
634
- mainEnd: q
635
- },
636
- uniforms: {
637
- pointCloudExpand_progress: new l.Uniform(0)
638
- }
639
- }) || this;
640
- }
641
- return Object.defineProperty(e.prototype, "progress", {
642
- get: function() {
643
- return this.uniforms.pointCloudExpand_progress.value;
644
- },
645
- set: function(n) {
646
- this.uniforms.pointCloudExpand_progress.value = n;
647
- },
648
- enumerable: !1,
649
- configurable: !0
650
- }), e;
651
- })(F)
652
- );
653
- const U = `(function(){"use strict";function P(n){onmessage=function(a){Promise.resolve(a.data).then(function(t){return n(t)}).then(function(t){var v=t.output,r=t.transfer;return postMessage(v,r)}).catch(function(t){return postMessage({$$error:t})})}}function y(n,a,t){var v=new OffscreenCanvas(a,t),r=v.getContext("2d");if(!r)throw new Error("Failed to get canvas context");r.clearRect(0,0,a,t),r.fillStyle="rgba(0,0,0,1.0)",r.beginPath();var o=n[0][0],i=n[0][0],u=n[0][1],m=n[0][1];n.forEach(function(e){var f=e[0],s=e[1];o=Math.min(o,f),i=Math.max(i,f),u=Math.min(u,s),m=Math.max(m,s)});var g=i-o,c=m-u,h=g>=c?a/g:a/c,x=n.map(function(e){var f=e[0]-o,s=e[1]-u;return[f,s]}),l=x.map(function(e){return[e[0]*h,e[1]*h]});return l.forEach(function(e,f){var s=e[0],D=e[1];f===0?r.moveTo(s,D):r.lineTo(s,D)}),r.closePath(),r.fill(),r.getImageData(0,0,a,t)}function M(n,a,t){for(var v=new ImageData(a,t),r=n.map(function(s){return y(s.polygon,s.width,s.height)}),o=0;o<a;o++)for(var i=0;i<t;i++){for(var u=0,m=0,g=0,c=0;c<r.length;c++){var h=r[c].data,x=(o+i*a)*4;if(h[x+3]===255){var l=c%8,e=Math.floor(c/8);e===0?u=u|1<<l:e===1?m=m|1<<l:e===2&&(g=g|1<<l)}}var f=(o+i*a)*4;v.data[f]=u,v.data[f+1]=m,v.data[f+2]=g,v.data[f+3]=255}return v}P(function(n){return Promise.resolve(n).then(function(a){var t=a.canvasDataList,v=a.width,r=a.height,o=M(t,v,r);return{output:{imageData:o},transfer:[o.data.buffer]}})})})();
654
- `, T = typeof self != "undefined" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", U], { type: "text/javascript;charset=utf-8" });
655
- function $(i) {
656
- let e;
657
- try {
658
- if (e = T && (self.URL || self.webkitURL).createObjectURL(T), !e) throw "";
659
- const n = new Worker(e, {
660
- name: i == null ? void 0 : i.name
661
- });
662
- return n.addEventListener("error", () => {
663
- (self.URL || self.webkitURL).revokeObjectURL(e);
664
- }), n;
665
- } catch (n) {
666
- return new Worker(
667
- "data:text/javascript;charset=utf-8," + encodeURIComponent(U),
668
- {
669
- name: i == null ? void 0 : i.name
670
- }
671
- );
672
- }
673
- }
674
- var Y = (
675
- /** @class */
676
- (function() {
677
- function i(e, n) {
678
- this.disposed = !1, this.pool = n, this.workerCreator = e, this.queue = [], this.workers = [], this.workerResolvers = [], this.workerStatus = 0;
679
- }
680
- return i.prototype.setWorkerCreator = function(e) {
681
- this.workerCreator = e;
682
- }, i.prototype.initWorker = function(e) {
683
- if (!this.workerCreator)
684
- throw new Error("workerCreator is not defined");
685
- if (!this.workers[e]) {
686
- var n = this.workerCreator(e);
687
- n.addEventListener("message", this.onMessage.bind(this, e)), this.workers[e] = n;
688
- }
689
- }, i.prototype.getIdleWorker = function() {
690
- for (var e = 0; e < this.pool; e++)
691
- if (!(this.workerStatus & 1 << e))
692
- return e;
693
- return -1;
694
- }, i.prototype.onMessage = function(e, n) {
695
- var o = this.workerResolvers[e];
696
- if (n.data && "$$error" in n.data ? o == null || o.reject(n.data.$$error) : o == null || o.resolve(n.data), this.workerResolvers[e] = void 0, this.queue.length) {
697
- var t = this.queue.shift(), r = t.resolve, s = t.reject, f = t.input, c = t.transfer;
698
- this.workerResolvers[e] = { resolve: r, reject: s }, this.workers[e].postMessage(f, c);
699
- } else
700
- this.workerStatus ^= 1 << e;
701
- }, i.prototype.postMessage = function(e, n) {
702
- var o = this;
703
- return n === void 0 && (n = []), new Promise(function(t, r) {
704
- if (o.disposed) {
705
- r(new Error("disposed"));
706
- return;
707
- }
708
- var s = o.getIdleWorker();
709
- s !== -1 ? (o.initWorker(s), o.workerStatus |= 1 << s, o.workerResolvers[s] = { resolve: t, reject: r }, o.workers[s].postMessage(e, n)) : o.queue.push({ resolve: t, reject: r, input: e, transfer: n });
710
- });
711
- }, i.prototype.dispose = function() {
712
- this.disposed = !0, this.workers.forEach(function(e) {
713
- e.terminate();
714
- }), this.workers.length = 0, this.workerResolvers.forEach(function(e) {
715
- e == null || e.reject(new Error("disposed"));
716
- }), this.workerResolvers.length = 0, this.queue.forEach(function(e) {
717
- e.reject(new Error("disposed"));
718
- }), this.queue.length = 0, this.workerStatus = 0;
719
- }, i;
720
- })()
721
- );
722
- function sn(i) {
723
- if (i.length < 3)
724
- throw new Error("At least 3 points are required to compute alignment matrix");
725
- var e = i[0], n = i[1], o = i[2], t = new l.Vector3().subVectors(n, e), r = new l.Vector3().subVectors(o, e), s = new l.Vector3().crossVectors(t, r);
726
- if (s.lengthSq() < 1e-4)
727
- for (var f = 3; f < i.length && (o = i[f], r = new l.Vector3().subVectors(o, e), s = new l.Vector3().crossVectors(t, r), !(s.lengthSq() >= 1e-4)); f++)
728
- ;
729
- if (s.lengthSq() < 1e-4)
730
- throw new Error("All points are collinear, cannot compute normal");
731
- s.normalize();
732
- var c = new l.Vector3();
733
- i.forEach(function(w) {
734
- return c.add(w);
735
- }), c.divideScalar(i.length);
736
- var a = new l.Vector3(0, 1, 0), u = new l.Quaternion(), v = s.dot(a);
737
- if (!(Math.abs(v - 1) < 1e-4)) if (Math.abs(v + 1) < 1e-4) {
738
- var h = new l.Vector3(1, 0, 0);
739
- u.setFromAxisAngle(h, Math.PI);
740
- } else {
741
- var h = new l.Vector3().crossVectors(s, a).normalize(), m = Math.acos(v);
742
- u.setFromAxisAngle(h, m);
743
- }
744
- var y = new l.Matrix4().makeTranslation(-c.x, -c.y, -c.z), p = new l.Matrix4().makeRotationFromQuaternion(u), g = new l.Matrix4();
745
- g.multiplyMatrices(p, y);
746
- var d = i.map(function(w) {
747
- var E = w.clone().applyMatrix4(g);
748
- return [E.x, E.z];
749
- });
750
- if (d.length > 0) {
751
- var x = d[0], P = d[d.length - 1];
752
- (x[0] !== P[0] || x[1] !== P[1]) && d.push([x[0], x[1]]);
753
- }
754
- return {
755
- transformMatrix: g,
756
- points2D: d
757
- };
417
+ //#endregion
418
+ //#region build/five/utils/worker.js
419
+ var h = class {
420
+ constructor(e, t) {
421
+ this.disposed = !1, this.pool = t, this.workerCreator = e, this.queue = [], this.workers = [], this.workerResolvers = [], this.workerStatus = 0;
422
+ }
423
+ setWorkerCreator(e) {
424
+ this.workerCreator = e;
425
+ }
426
+ initWorker(e) {
427
+ if (!this.workerCreator) throw Error("workerCreator is not defined");
428
+ if (!this.workers[e]) {
429
+ let t = this.workerCreator(e);
430
+ t.addEventListener("message", this.onMessage.bind(this, e)), this.workers[e] = t;
431
+ }
432
+ }
433
+ getIdleWorker() {
434
+ for (let e = 0; e < this.pool; e++) if (!(this.workerStatus & 1 << e)) return e;
435
+ return -1;
436
+ }
437
+ onMessage(e, t) {
438
+ let n = this.workerResolvers[e];
439
+ if (t.data && "$$error" in t.data ? n == null || n.reject(t.data.$$error) : n == null || n.resolve(t.data), this.workerResolvers[e] = void 0, this.queue.length) {
440
+ let { resolve: t, reject: n, input: r, transfer: i } = this.queue.shift();
441
+ this.workerResolvers[e] = {
442
+ resolve: t,
443
+ reject: n
444
+ }, this.workers[e].postMessage(r, i);
445
+ } else this.workerStatus ^= 1 << e;
446
+ }
447
+ postMessage(e, t = []) {
448
+ return new Promise((n, r) => {
449
+ if (this.disposed) {
450
+ r(/* @__PURE__ */ Error("disposed"));
451
+ return;
452
+ }
453
+ let i = this.getIdleWorker();
454
+ i === -1 ? this.queue.push({
455
+ resolve: n,
456
+ reject: r,
457
+ input: e,
458
+ transfer: t
459
+ }) : (this.initWorker(i), this.workerStatus |= 1 << i, this.workerResolvers[i] = {
460
+ resolve: n,
461
+ reject: r
462
+ }, this.workers[i].postMessage(e, t));
463
+ });
464
+ }
465
+ dispose() {
466
+ this.disposed = !0, this.workers.forEach((e) => {
467
+ e.terminate();
468
+ }), this.workers.length = 0, this.workerResolvers.forEach((e) => {
469
+ e == null || e.reject(/* @__PURE__ */ Error("disposed"));
470
+ }), this.workerResolvers.length = 0, this.queue.forEach((e) => {
471
+ e.reject(/* @__PURE__ */ Error("disposed"));
472
+ }), this.queue.length = 0, this.workerStatus = 0;
473
+ }
474
+ };
475
+ //#endregion
476
+ //#region build/shader-lib/PolygonCuter/index.js
477
+ function g(e) {
478
+ if (e.length < 3) throw Error("At least 3 points are required to compute alignment matrix");
479
+ let n = e[0], r = e[1], i = e[2], a = new t.Vector3().subVectors(r, n), o = new t.Vector3().subVectors(i, n), s = new t.Vector3().crossVectors(a, o);
480
+ if (s.lengthSq() < 1e-4) for (let r = 3; r < e.length && (i = e[r], o = new t.Vector3().subVectors(i, n), s = new t.Vector3().crossVectors(a, o), !(s.lengthSq() >= 1e-4)); r++);
481
+ if (s.lengthSq() < 1e-4) throw Error("All points are collinear, cannot compute normal");
482
+ s.normalize();
483
+ let c = new t.Vector3();
484
+ e.forEach((e) => c.add(e)), c.divideScalar(e.length);
485
+ let l = new t.Vector3(0, 1, 0), u = new t.Quaternion(), d = s.dot(l);
486
+ if (!(Math.abs(d - 1) < 1e-4)) if (Math.abs(d + 1) < 1e-4) {
487
+ let e = new t.Vector3(1, 0, 0);
488
+ u.setFromAxisAngle(e, Math.PI);
489
+ } else {
490
+ let e = new t.Vector3().crossVectors(s, l).normalize(), n = Math.acos(d);
491
+ u.setFromAxisAngle(e, n);
492
+ }
493
+ let f = new t.Matrix4().makeTranslation(-c.x, -c.y, -c.z), p = new t.Matrix4().makeRotationFromQuaternion(u), m = new t.Matrix4();
494
+ m.multiplyMatrices(p, f);
495
+ let h = e.map((e) => {
496
+ let t = e.clone().applyMatrix4(m);
497
+ return [t.x, t.z];
498
+ });
499
+ if (h.length > 0) {
500
+ let e = h[0], t = h[h.length - 1];
501
+ (e[0] !== t[0] || e[1] !== t[1]) && h.push([e[0], e[1]]);
502
+ }
503
+ return {
504
+ transformMatrix: m,
505
+ points2D: h
506
+ };
758
507
  }
759
- var Q = `
760
- uniform sampler2D polygonTexture;
761
-
762
- struct PolygonClipper {
763
- mat4 polygonTransformInverse;
764
- float polygonHeight;
765
- vec2 minPos;
766
- float polygonScale;
767
- bool cutOutSide;
768
- float floorIndex;
769
- };
770
-
771
- #if NUM_POLYGON_CLIPPER > 0
772
- uniform PolygonClipper polygonClippers[NUM_POLYGON_CLIPPER];
773
- #endif
774
- `, K = `
775
-
776
- for(int i = 0; i < NUM_POLYGON_CLIPPER; i++){
777
- PolygonClipper polygonClipper = polygonClippers[i];
778
- mat4 polygonTransformInverse = polygonClipper.polygonTransformInverse;
779
- float polygonHeight = polygonClipper.polygonHeight;
780
- vec2 minPos = polygonClipper.minPos;
781
- float polygonScale = polygonClipper.polygonScale;
782
- bool cutOutSide = polygonClipper.cutOutSide;
783
- float clipperFloorIndex = polygonClipper.floorIndex;
784
-
785
- // 楼层判断:如果 floorIndex < 0,对所有楼层生效;否则只对特定楼层生效
786
- bool isFloorMatch = clipperFloorIndex < 0.0 || abs(floorIndex - clipperFloorIndex) < 1.0;
787
- if (!isFloorMatch) {
788
- continue;
789
- }
790
-
791
- vec4 worldPosition = vFinalPosition;
792
- vec4 positionInPolygonSpace = polygonTransformInverse * worldPosition;
793
-
794
- vec2 normalizedPos = vec2(
795
- (positionInPolygonSpace.x - minPos.x) / polygonScale,
796
- (positionInPolygonSpace.z - minPos.y) / polygonScale
797
- );
798
-
799
- if(cutOutSide) {
800
- if (normalizedPos.x < 0.0 || normalizedPos.x > 1.0 || normalizedPos.y < 0.0 || normalizedPos.y > 1.0 || positionInPolygonSpace.y < 0.0 || positionInPolygonSpace.y > polygonHeight) {
801
- discard;
802
- }else{
803
- vec2 uv = vec2(normalizedPos.x, 1.0 - normalizedPos.y);
804
- vec4 color = texture2D(polygonTexture, uv);
805
- int channel = i / 8;
806
- float bit = (float(i) / 8.0 - floor(float(i) / 8.0)) * 8.0;
807
- float power = pow(2.0, bit);
808
-
809
- float channelValue;
810
- if(i < 8) { // 使用r通道
811
- channelValue = color.r * 255.0;
812
- } else if(i < 16) { // 使用g通道
813
- channelValue = color.g * 255.0;
814
- } else if(i < 24) { // 使用b通道
815
- channelValue = color.b * 255.0;
816
- } else { // 使用a通道
817
- channelValue = color.a * 255.0;
818
- }
819
-
820
- float masked = floor(channelValue / power + 0.001);
821
- if(mod(masked, 2.0) < 0.5) {
822
- discard;
823
- }
824
- }
825
- }else{
826
- if (normalizedPos.x > 0.0 && normalizedPos.x < 1.0 && normalizedPos.y > 0.0 && normalizedPos.y < 1.0 && positionInPolygonSpace.y > 0.0 && positionInPolygonSpace.y < polygonHeight) {
827
- vec2 uv = vec2(normalizedPos.x, 1.0 - normalizedPos.y);
828
- vec4 color = texture2D(polygonTexture, uv);
829
- int channel = i / 8;
830
-
831
- float bit = (float(i) / 8.0 - floor(float(i) / 8.0)) * 8.0;
832
- float power = pow(2.0, bit);
833
- float channelValue;
834
- if(i < 8) { // 使用r通道
835
- channelValue = color.r * 255.0;
836
- } else if(i < 16) { // 使用g通道
837
- channelValue = color.g * 255.0;
838
- } else if(i < 24) { // 使用b通道
839
- channelValue = color.b * 255.0;
840
- } else { // 使用a通道
841
- channelValue = color.a * 255.0;
842
- }
843
- float masked = floor(channelValue / power + 0.001);
844
- if(mod(masked, 2.0) > 0.0) {
845
- discard;
846
- }
847
- }
848
- }
849
- }
850
-
851
- `, Z = (
852
- /** @class */
853
- (function() {
854
- function i() {
855
- this.canvasCache = /* @__PURE__ */ new Map(), this.canvas = document.createElement("canvas"), this.canvas.width = 512, this.canvas.height = 512, this.polygonTexture = new l.CanvasTexture(this.canvas), this.polygonCount = 0;
856
- }
857
- return i.prototype.setSize = function(e) {
858
- this.canvas.width = e, this.canvas.height = e;
859
- }, i.prototype.generatePolygonCanvas = function(e) {
860
- var n = JSON.stringify(e);
861
- if (this.canvasCache.has(n))
862
- return this.canvasCache.get(n);
863
- var o = document.createElement("canvas");
864
- o.width = this.canvas.width, o.height = this.canvas.height;
865
- var t = o.getContext("2d");
866
- if (!t)
867
- throw new Error("Failed to get canvas context");
868
- if (this.polygonCount >= 24)
869
- throw new Error("polygon count exceed 24, please clear the canvas");
870
- t.clearRect(0, 0, this.canvas.width, this.canvas.height), t.fillStyle = "rgba(0,0,0,1.0)", t.beginPath();
871
- var r = e[0][0], s = e[0][0], f = e[0][1], c = e[0][1];
872
- e.forEach(function(p) {
873
- var g = p[0], d = p[1];
874
- r = Math.min(r, g), s = Math.max(s, g), f = Math.min(f, d), c = Math.max(c, d);
875
- });
876
- var a = s - r, u = c - f, v = this.canvas.width, h = a >= u ? v / a : v / u, m = e.map(function(p) {
877
- var g = p[0] - r, d = p[1] - f;
878
- return [g, d];
879
- }), y = m.map(function(p) {
880
- return [p[0] * h, p[1] * h];
881
- });
882
- return y.forEach(function(p, g) {
883
- var d = p[0], x = p[1];
884
- g === 0 ? t.moveTo(d, x) : t.lineTo(d, x);
885
- }), t.closePath(), t.fill(), this.polygonCount++, this.canvasCache.set(n, o), o;
886
- }, i.generatePolygonGeometry = function(e, n) {
887
- for (var o = new l.BufferGeometry(), t = e.slice(0, -1), r = t.map(function(h) {
888
- return [h[0], 0, h[1]];
889
- }), s = t.map(function(h) {
890
- return [h[0], n, h[1]];
891
- }), f = I(I([], r, !0), s, !0), c = t.length, a = [], u = 1; u < c - 1; u++)
892
- a.push(0, u, u + 1);
893
- for (var u = 1; u < c - 1; u++)
894
- a.push(c, c + u, c + u + 1);
895
- for (var u = 0; u < c; u++) {
896
- var v = (u + 1) % c;
897
- a.push(u, v, c + u), a.push(v, c + v, c + u);
898
- }
899
- return o.setAttribute("position", new l.Float32BufferAttribute(f.flat(), 3)), o.setIndex(a), o.computeVertexNormals(), o;
900
- }, i.prototype.generatePolygonTexture = function(e) {
901
- var n = this.canvas.getContext("2d", {
902
- willReadFrequently: !0
903
- });
904
- if (!n)
905
- throw new Error("Failed to get canvas context");
906
- for (var o = n.createImageData(this.canvas.width, this.canvas.height), t = 0; t < this.canvas.width; t++)
907
- for (var r = 0; r < this.canvas.height; r++) {
908
- for (var s = 0, f = 0, c = 0, a = 0; a < e.length; a++) {
909
- var u = e[a].getContext("2d", { willReadFrequently: !0 });
910
- if (!u)
911
- throw new Error("Failed to get canvas context");
912
- var v = u.getImageData(t, r, 1, 1).data;
913
- if (v[3] === 255) {
914
- var h = a % 8, m = Math.floor(a / 8);
915
- m === 0 ? s = s | 1 << h : m === 1 ? f = f | 1 << h : m === 2 && (c = c | 1 << h);
916
- }
917
- }
918
- var y = (t + r * this.canvas.width) * 4;
919
- o.data[y] = s, o.data[y + 1] = f, o.data[y + 2] = c, o.data[y + 3] = 255;
920
- }
921
- return n.putImageData(o, 0, 0), new l.CanvasTexture(this.canvas);
922
- }, i;
923
- })()
924
- ), ln = (
925
- /** @class */
926
- (function(i) {
927
- B(e, i);
928
- function e(n) {
929
- n === void 0 && (n = 512);
930
- var o = i.call(this, {
931
- type: ["basic", "phong", "pointcloud"],
932
- fragment: {
933
- mainBefore: Q,
934
- mainEnd: K
935
- },
936
- uniforms: {
937
- polygonClippers: new l.Uniform([]),
938
- polygonTexture: new l.Uniform(null)
939
- }
940
- }) || this;
941
- return o._polygonClippers = [], o.polygonGenerater = new Z(), o._radio = 512, o.radio = n, o.workerPool = new Y(function() {
942
- return new $();
943
- }, 1), o;
944
- }
945
- return e.prototype.setPolygonClippersAsync = function(n) {
946
- return A(this, void 0, void 0, function() {
947
- var o, t, r, s, f, c, a = this;
948
- return k(this, function(u) {
949
- switch (u.label) {
950
- case 0:
951
- return this._polygonClippers = n, o = this.uniforms, o.polygonClippers.value = n.map(function(v) {
952
- var h = new l.Matrix4().getInverse(v.polygonTransform), m = v.polygonHeight, y = v.cutOutSide, p = v.polygon, g = v.floorIndex !== void 0 ? v.floorIndex : -1, d = p[0][0], x = p[0][0], P = p[0][1], w = p[0][1];
953
- p.forEach(function(C) {
954
- var S = C[0], _ = C[1];
955
- d = Math.min(d, S), x = Math.max(x, S), P = Math.min(P, _), w = Math.max(w, _);
956
- });
957
- var E = new l.Vector2(d, P), b = x - d >= w - P ? x - d : w - P;
958
- return {
959
- polygonTransformInverse: h,
960
- polygonHeight: m,
961
- minPos: E,
962
- polygonScale: b,
963
- cutOutSide: y,
964
- floorIndex: g
965
- };
966
- }), t = n.map(function(v) {
967
- return {
968
- polygon: v.polygon,
969
- width: a.polygonGenerater.canvas.width,
970
- height: a.polygonGenerater.canvas.height
971
- };
972
- }), [4, this.workerPool.postMessage({
973
- canvasDataList: t,
974
- width: this.polygonGenerater.canvas.width,
975
- height: this.polygonGenerater.canvas.height
976
- })];
977
- case 1:
978
- return r = u.sent(), s = document.createElement("canvas"), s.width = this.polygonGenerater.canvas.width, s.height = this.polygonGenerater.canvas.height, f = s.getContext("2d"), f && (f.putImageData(r.imageData, 0, 0), c = new l.CanvasTexture(s), c.minFilter = l.NearestFilter, c.magFilter = l.NearestFilter, this.uniforms.polygonTexture.value = c, this.needsUpdate = !0), [
979
- 2
980
- /*return*/
981
- ];
982
- }
983
- });
984
- });
985
- }, Object.defineProperty(e.prototype, "polygonClippers", {
986
- get: function() {
987
- return this._polygonClippers;
988
- },
989
- set: function(n) {
990
- this._polygonClippers = n;
991
- },
992
- enumerable: !1,
993
- configurable: !0
994
- }), Object.defineProperty(e.prototype, "radio", {
995
- get: function() {
996
- return this._radio;
997
- },
998
- set: function(n) {
999
- this._radio = n, this.polygonGenerater.setSize(n);
1000
- },
1001
- enumerable: !1,
1002
- configurable: !0
1003
- }), e.prototype.dispose = function() {
1004
- this.workerPool.dispose();
1005
- }, e.prototype.onBeforeCompile = function(n, o) {
1006
- var t = String(this.polygonClippers.length);
1007
- n.vertexShader = n.vertexShader.replace(/NUM_POLYGON_CLIPPER/g, t), n.fragmentShader = n.fragmentShader.replace(/NUM_POLYGON_CLIPPER/g, t);
1008
- }, e;
1009
- })(F)
1010
- ), X = `
1011
- #if NUM_SHINE_OBJECTS > 0
1012
- uniform float shineProgress;
1013
- struct SHINE_OBJECT {
1014
- vec3 min;
1015
- vec3 max;
1016
- };
1017
- uniform SHINE_OBJECT shineBoxes[NUM_SHINE_OBJECTS];
1018
- #endif
1019
- `, nn = `
1020
- #if NUM_SHINE_OBJECTS > 0
1021
- #pragma unroll_loop_start
1022
- for ( int i = 0; i < NUM_SHINE_OBJECTS; i ++ ) {
1023
- vec3 min = shineBoxes[ i ].min;
1024
- vec3 max = shineBoxes[ i ].max;
1025
- vec3 boxCenter = 0.5 * (min + max);
1026
- if(vFinalPosition.x > min.x && vFinalPosition.x < max.x && vFinalPosition.y > min.y && vFinalPosition.y < max.y && vFinalPosition.z > min.z && vFinalPosition.z < max.z) {
1027
- //如果在盒子里,就整体按照progress进行透明度变化
1028
- vec3 shineColor = vec3(1.0,0.0,0.0);
1029
- float mixProgress = shineProgress * shineProgress * shineProgress * 0.4;
1030
- gl_FragColor.rgb = mix(gl_FragColor.rgb, shineColor, mixProgress);
1031
- }
1032
- }
1033
- #pragma unroll_loop_end
1034
- #endif
1035
- `, en = "", un = (
1036
- /** @class */
1037
- (function(i) {
1038
- B(e, i);
1039
- function e() {
1040
- var n = i.call(this, {
1041
- type: ["basic", "phong", "none"],
1042
- fragment: {
1043
- mainBefore: X,
1044
- mainStart: en,
1045
- mainEnd: nn
1046
- },
1047
- uniforms: {
1048
- shineProgress: new l.Uniform(0),
1049
- shineBoxes: new l.Uniform([])
1050
- },
1051
- defines: {
1052
- NUM_SHINE_OBJECTS: 0
1053
- }
1054
- }) || this;
1055
- return Object.defineProperties(n, {
1056
- shineBoxes: {
1057
- get: function() {
1058
- return this.uniforms.shineBoxes.value;
1059
- },
1060
- set: function(o) {
1061
- var t = o.length;
1062
- t > 0 && (this.defines.NUM_SHINE_OBJECTS = t, this.uniforms.shineBoxes.value = o);
1063
- }
1064
- }
1065
- }), n.shineBoxes = [], n;
1066
- }
1067
- return e.prototype.onBeforeCompile = function(n, o) {
1068
- var t = String(this.shineBoxes.length);
1069
- n.vertexShader = n.vertexShader.replace(/NUM_SHINE_OBJECTS/g, t), n.fragmentShader = n.fragmentShader.replace(/NUM_SHINE_OBJECTS/g, t);
1070
- }, e;
1071
- })(F)
1072
- );
1073
- export {
1074
- tn as EvenessPlaneShader,
1075
- an as PointCloudExpandShader,
1076
- ln as PolygonCuterShader,
1077
- Z as PolygonGenerater,
1078
- un as ShineModelShader,
1079
- rn as SweepModelShader,
1080
- sn as computeAlignmentMatrix
508
+ var _ = "\n uniform sampler2D polygonTexture;\n\n struct PolygonClipper {\n mat4 polygonTransformInverse;\n float polygonHeight;\n vec2 minPos;\n float polygonScale;\n bool cutOutSide;\n float floorIndex;\n };\n\n #if NUM_POLYGON_CLIPPER > 0\n uniform PolygonClipper polygonClippers[NUM_POLYGON_CLIPPER];\n #endif\n", v = "\n\n for(int i = 0; i < NUM_POLYGON_CLIPPER; i++){\n PolygonClipper polygonClipper = polygonClippers[i];\n mat4 polygonTransformInverse = polygonClipper.polygonTransformInverse;\n float polygonHeight = polygonClipper.polygonHeight;\n vec2 minPos = polygonClipper.minPos;\n float polygonScale = polygonClipper.polygonScale;\n bool cutOutSide = polygonClipper.cutOutSide;\n float clipperFloorIndex = polygonClipper.floorIndex;\n\n // 楼层判断:如果 floorIndex < 0,对所有楼层生效;否则只对特定楼层生效\n bool isFloorMatch = clipperFloorIndex < 0.0 || abs(floorIndex - clipperFloorIndex) < 1.0;\n if (!isFloorMatch) {\n continue;\n }\n\n vec4 worldPosition = vFinalPosition;\n vec4 positionInPolygonSpace = polygonTransformInverse * worldPosition;\n\n vec2 normalizedPos = vec2(\n (positionInPolygonSpace.x - minPos.x) / polygonScale,\n (positionInPolygonSpace.z - minPos.y) / polygonScale\n );\n\n if(cutOutSide) {\n if (normalizedPos.x < 0.0 || normalizedPos.x > 1.0 || normalizedPos.y < 0.0 || normalizedPos.y > 1.0 || positionInPolygonSpace.y < 0.0 || positionInPolygonSpace.y > polygonHeight) {\n discard;\n }else{\n vec2 uv = vec2(normalizedPos.x, 1.0 - normalizedPos.y);\n vec4 color = texture2D(polygonTexture, uv);\n int channel = i / 8;\n float bit = (float(i) / 8.0 - floor(float(i) / 8.0)) * 8.0;\n float power = pow(2.0, bit);\n\n float channelValue;\n if(i < 8) { // 使用r通道\n channelValue = color.r * 255.0;\n } else if(i < 16) { // 使用g通道\n channelValue = color.g * 255.0;\n } else if(i < 24) { // 使用b通道\n channelValue = color.b * 255.0;\n } else { // 使用a通道\n channelValue = color.a * 255.0;\n }\n\n float masked = floor(channelValue / power + 0.001);\n if(mod(masked, 2.0) < 0.5) {\n discard;\n }\n }\n }else{\n if (normalizedPos.x > 0.0 && normalizedPos.x < 1.0 && normalizedPos.y > 0.0 && normalizedPos.y < 1.0 && positionInPolygonSpace.y > 0.0 && positionInPolygonSpace.y < polygonHeight) {\n vec2 uv = vec2(normalizedPos.x, 1.0 - normalizedPos.y);\n vec4 color = texture2D(polygonTexture, uv);\n int channel = i / 8;\n\n float bit = (float(i) / 8.0 - floor(float(i) / 8.0)) * 8.0;\n float power = pow(2.0, bit);\n float channelValue;\n if(i < 8) { // 使用r通道\n channelValue = color.r * 255.0;\n } else if(i < 16) { // 使用g通道\n channelValue = color.g * 255.0;\n } else if(i < 24) { // 使用b通道\n channelValue = color.b * 255.0;\n } else { // 使用a通道\n channelValue = color.a * 255.0;\n }\n float masked = floor(channelValue / power + 0.001);\n if(mod(masked, 2.0) > 0.0) {\n discard;\n }\n }\n }\n }\n\n", y = class {
509
+ constructor() {
510
+ this.canvasCache = /* @__PURE__ */ new Map(), this.canvas = document.createElement("canvas"), this.canvas.width = 512, this.canvas.height = 512, this.polygonTexture = new t.CanvasTexture(this.canvas), this.polygonCount = 0;
511
+ }
512
+ setSize(e) {
513
+ this.canvas.width = e, this.canvas.height = e;
514
+ }
515
+ generatePolygonCanvas(e) {
516
+ let t = JSON.stringify(e);
517
+ if (this.canvasCache.has(t)) return this.canvasCache.get(t);
518
+ {
519
+ let n = document.createElement("canvas");
520
+ n.width = this.canvas.width, n.height = this.canvas.height;
521
+ let r = n.getContext("2d");
522
+ if (!r) throw Error("Failed to get canvas context");
523
+ if (this.polygonCount >= 24) throw Error("polygon count exceed 24, please clear the canvas");
524
+ r.clearRect(0, 0, this.canvas.width, this.canvas.height), r.fillStyle = "rgba(0,0,0,1.0)", r.beginPath();
525
+ let i = e[0][0], a = e[0][0], o = e[0][1], s = e[0][1];
526
+ e.forEach((e) => {
527
+ let t = e[0], n = e[1];
528
+ i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, n), s = Math.max(s, n);
529
+ });
530
+ let c = a - i, l = s - o, u = this.canvas.width, d = c >= l ? u / c : u / l;
531
+ return e.map((e) => [e[0] - i, e[1] - o]).map((e) => [e[0] * d, e[1] * d]).forEach((e, t) => {
532
+ let [n, i] = e;
533
+ t === 0 ? r.moveTo(n, i) : r.lineTo(n, i);
534
+ }), r.closePath(), r.fill(), this.polygonCount++, this.canvasCache.set(t, n), n;
535
+ }
536
+ }
537
+ static generatePolygonGeometry(e, n) {
538
+ let r = new t.BufferGeometry(), i = e.slice(0, -1), a = i.map((e) => [
539
+ e[0],
540
+ 0,
541
+ e[1]
542
+ ]), o = i.map((e) => [
543
+ e[0],
544
+ n,
545
+ e[1]
546
+ ]), s = [...a, ...o], c = i.length, l = [];
547
+ for (let e = 1; e < c - 1; e++) l.push(0, e, e + 1);
548
+ for (let e = 1; e < c - 1; e++) l.push(c, c + e, c + e + 1);
549
+ for (let e = 0; e < c; e++) {
550
+ let t = (e + 1) % c;
551
+ l.push(e, t, c + e), l.push(t, c + t, c + e);
552
+ }
553
+ return r.setAttribute("position", new t.Float32BufferAttribute(s.flat(), 3)), r.setIndex(l), r.computeVertexNormals(), r;
554
+ }
555
+ generatePolygonTexture(e) {
556
+ let n = this.canvas.getContext("2d", { willReadFrequently: !0 });
557
+ if (!n) throw Error("Failed to get canvas context");
558
+ let r = n.createImageData(this.canvas.width, this.canvas.height);
559
+ for (let t = 0; t < this.canvas.width; t++) for (let n = 0; n < this.canvas.height; n++) {
560
+ let i = 0, a = 0, o = 0;
561
+ for (let r = 0; r < e.length; r++) {
562
+ let s = e[r].getContext("2d", { willReadFrequently: !0 });
563
+ if (!s) throw Error("Failed to get canvas context");
564
+ if (s.getImageData(t, n, 1, 1).data[3] === 255) {
565
+ let e = r % 8, t = Math.floor(r / 8);
566
+ t === 0 ? i |= 1 << e : t === 1 ? a |= 1 << e : t === 2 && (o |= 1 << e);
567
+ }
568
+ }
569
+ let s = (t + n * this.canvas.width) * 4;
570
+ r.data[s] = i, r.data[s + 1] = a, r.data[s + 2] = o, r.data[s + 3] = 255;
571
+ }
572
+ return n.putImageData(r, 0, 0), new t.CanvasTexture(this.canvas);
573
+ }
574
+ }, b = class extends e {
575
+ constructor(e = 512) {
576
+ super({
577
+ type: [
578
+ "basic",
579
+ "phong",
580
+ "pointcloud"
581
+ ],
582
+ fragment: {
583
+ mainBefore: _,
584
+ mainEnd: v
585
+ },
586
+ uniforms: {
587
+ polygonClippers: new t.Uniform([]),
588
+ polygonTexture: new t.Uniform(null)
589
+ }
590
+ }), this._polygonClippers = [], this.polygonGenerater = new y(), this._radio = 512, this.radio = e, this.workerPool = new h(() => new m(), 1);
591
+ }
592
+ setPolygonClippersAsync(e) {
593
+ return d(this, void 0, void 0, function* () {
594
+ this._polygonClippers = e;
595
+ let n = this.uniforms;
596
+ n.polygonClippers.value = e.map((e) => {
597
+ let n = new t.Matrix4().getInverse(e.polygonTransform), r = e.polygonHeight, i = e.cutOutSide, a = e.polygon, o = e.floorIndex === void 0 ? -1 : e.floorIndex, s = a[0][0], c = a[0][0], l = a[0][1], u = a[0][1];
598
+ return a.forEach((e) => {
599
+ let t = e[0], n = e[1];
600
+ s = Math.min(s, t), c = Math.max(c, t), l = Math.min(l, n), u = Math.max(u, n);
601
+ }), {
602
+ polygonTransformInverse: n,
603
+ polygonHeight: r,
604
+ minPos: new t.Vector2(s, l),
605
+ polygonScale: c - s >= u - l ? c - s : u - l,
606
+ cutOutSide: i,
607
+ floorIndex: o
608
+ };
609
+ });
610
+ let r = e.map((e) => ({
611
+ polygon: e.polygon,
612
+ width: this.polygonGenerater.canvas.width,
613
+ height: this.polygonGenerater.canvas.height
614
+ })), i = yield this.workerPool.postMessage({
615
+ canvasDataList: r,
616
+ width: this.polygonGenerater.canvas.width,
617
+ height: this.polygonGenerater.canvas.height
618
+ }), a = document.createElement("canvas");
619
+ a.width = this.polygonGenerater.canvas.width, a.height = this.polygonGenerater.canvas.height;
620
+ let o = a.getContext("2d");
621
+ if (o) {
622
+ o.putImageData(i.imageData, 0, 0);
623
+ let e = new t.CanvasTexture(a);
624
+ e.minFilter = t.NearestFilter, e.magFilter = t.NearestFilter, this.uniforms.polygonTexture.value = e, this.needsUpdate = !0;
625
+ }
626
+ });
627
+ }
628
+ get polygonClippers() {
629
+ return this._polygonClippers;
630
+ }
631
+ set polygonClippers(e) {
632
+ this._polygonClippers = e;
633
+ }
634
+ get radio() {
635
+ return this._radio;
636
+ }
637
+ set radio(e) {
638
+ this._radio = e, this.polygonGenerater.setSize(e);
639
+ }
640
+ dispose() {
641
+ this.workerPool.dispose();
642
+ }
643
+ onBeforeCompile(e, t) {
644
+ let n = String(this.polygonClippers.length);
645
+ e.vertexShader = e.vertexShader.replace(/NUM_POLYGON_CLIPPER/g, n), e.fragmentShader = e.fragmentShader.replace(/NUM_POLYGON_CLIPPER/g, n);
646
+ }
647
+ }, x = "\n #if NUM_SHINE_OBJECTS > 0\n uniform float shineProgress;\n struct SHINE_OBJECT {\n vec3 min;\n vec3 max;\n };\n uniform SHINE_OBJECT shineBoxes[NUM_SHINE_OBJECTS];\n #endif\n", S = "\n #if NUM_SHINE_OBJECTS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SHINE_OBJECTS; i ++ ) {\n vec3 min = shineBoxes[ i ].min;\n vec3 max = shineBoxes[ i ].max;\n vec3 boxCenter = 0.5 * (min + max);\n if(vFinalPosition.x > min.x && vFinalPosition.x < max.x && vFinalPosition.y > min.y && vFinalPosition.y < max.y && vFinalPosition.z > min.z && vFinalPosition.z < max.z) {\n //如果在盒子里,就整体按照progress进行透明度变化\n vec3 shineColor = vec3(1.0,0.0,0.0);\n float mixProgress = shineProgress * shineProgress * shineProgress * 0.4;\n gl_FragColor.rgb = mix(gl_FragColor.rgb, shineColor, mixProgress);\n }\n }\n #pragma unroll_loop_end\n #endif\n", C = "", w = class extends e {
648
+ constructor() {
649
+ super({
650
+ type: [
651
+ "basic",
652
+ "phong",
653
+ "none"
654
+ ],
655
+ fragment: {
656
+ mainBefore: x,
657
+ mainStart: C,
658
+ mainEnd: S
659
+ },
660
+ uniforms: {
661
+ shineProgress: new t.Uniform(0),
662
+ shineBoxes: new t.Uniform([])
663
+ },
664
+ defines: { NUM_SHINE_OBJECTS: 0 }
665
+ }), Object.defineProperties(this, { shineBoxes: {
666
+ get() {
667
+ return this.uniforms.shineBoxes.value;
668
+ },
669
+ set(e) {
670
+ let t = e.length;
671
+ t > 0 && (this.defines.NUM_SHINE_OBJECTS = t, this.uniforms.shineBoxes.value = e);
672
+ }
673
+ } }), this.shineBoxes = [];
674
+ }
675
+ onBeforeCompile(e, t) {
676
+ let n = String(this.shineBoxes.length);
677
+ e.vertexShader = e.vertexShader.replace(/NUM_SHINE_OBJECTS/g, n), e.fragmentShader = e.fragmentShader.replace(/NUM_SHINE_OBJECTS/g, n);
678
+ }
1081
679
  };
680
+ //#endregion
681
+ export { r as EvenessPlaneShader, u as PointCloudExpandShader, b as PolygonCuterShader, y as PolygonGenerater, w as ShineModelShader, s as SweepModelShader, g as computeAlignmentMatrix };