@threepipe/webgi-plugins 0.5.2 → 0.5.4
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/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +186 -324
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/extras/AdvancedGroundPlugin.d.ts +2 -3
- package/dist/plugins/extras/AdvancedGroundPlugin.d.ts.map +1 -1
- package/dist/plugins/extras/WatchHandsPlugin.d.ts.map +1 -1
- package/dist/plugins/postprocessing/BloomPlugin.d.ts.map +1 -1
- package/dist/plugins/postprocessing/OutlinePlugin.d.ts +2 -4
- package/dist/plugins/postprocessing/OutlinePlugin.d.ts.map +1 -1
- package/dist/plugins/postprocessing/SSGIPlugin.d.ts.map +1 -1
- package/dist/plugins/postprocessing/SSReflectionPlugin.d.ts.map +1 -1
- package/dist/plugins/postprocessing/TemporalAAPlugin.d.ts.map +1 -1
- package/dist/utils/Reflector2.d.ts +3 -6
- package/dist/utils/Reflector2.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +5 -4
- package/tsconfig.json +1 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @threepipe/webgi-plugins v0.5.
|
|
3
|
+
* @threepipe/webgi-plugins v0.5.4
|
|
4
4
|
* Copyright 2022-2025 repalash <palash@shaders.app> (https://repalash.com)
|
|
5
5
|
* SEE LICENSE IN LICENSE
|
|
6
6
|
*/
|
|
@@ -69,8 +69,7 @@ const _TemporalAAPlugin = class _TemporalAAPlugin extends PipelinePassPlugin {
|
|
|
69
69
|
this.setDirty = this.setDirty.bind(this);
|
|
70
70
|
}
|
|
71
71
|
get stableNoise() {
|
|
72
|
-
|
|
73
|
-
return ((_a2 = this._viewer) == null ? void 0 : _a2.renderManager.stableNoise) ?? this._stableNoise;
|
|
72
|
+
return this._viewer?.renderManager.stableNoise ?? this._stableNoise;
|
|
74
73
|
}
|
|
75
74
|
set stableNoise(v) {
|
|
76
75
|
if (this._viewer) this._viewer.renderManager.stableNoise = v;
|
|
@@ -81,10 +80,7 @@ const _TemporalAAPlugin = class _TemporalAAPlugin extends PipelinePassPlugin {
|
|
|
81
80
|
if (!this._viewer.renderManager.gbufferTarget || !this._viewer.renderManager.gbufferUnpackExtension)
|
|
82
81
|
throw new Error("TemporalAAPlugin: GBuffer target not created. GBufferPlugin is required.");
|
|
83
82
|
const applyOnBackground = !!this._viewer.renderManager.msaa;
|
|
84
|
-
const t2 = new TemporalAAPluginPass(this.passId, () =>
|
|
85
|
-
var _a2, _b2;
|
|
86
|
-
return (_b2 = (_a2 = this._viewer) == null ? void 0 : _a2.getPlugin(ProgressivePlugin)) == null ? void 0 : _b2.target;
|
|
87
|
-
}, applyOnBackground);
|
|
83
|
+
const t2 = new TemporalAAPluginPass(this.passId, () => this._viewer?.getPlugin(ProgressivePlugin)?.target, applyOnBackground);
|
|
88
84
|
return t2;
|
|
89
85
|
}
|
|
90
86
|
// todo use gbufferUnpackExtension from render manager to support depth buffer plugin as well.
|
|
@@ -167,11 +163,10 @@ __decorateClass$f([
|
|
|
167
163
|
uiToggle("Stable Noise (Total frame count)")
|
|
168
164
|
], TemporalAAPlugin.prototype, "stableNoise", 1);
|
|
169
165
|
__decorateClass$f([
|
|
170
|
-
uiConfig()
|
|
166
|
+
uiConfig(void 0, { unwrapContents: true })
|
|
171
167
|
], TemporalAAPlugin.prototype, "_pass", 2);
|
|
172
168
|
class TemporalAAPluginPass extends ExtendedShaderPass {
|
|
173
169
|
constructor(pid, target, applyOnBackground = false) {
|
|
174
|
-
var _a2;
|
|
175
170
|
super({
|
|
176
171
|
vertexShader: CopyShader.vertexShader,
|
|
177
172
|
fragmentShader: getShaders().temporalAA,
|
|
@@ -210,7 +205,7 @@ class TemporalAAPluginPass extends ExtendedShaderPass {
|
|
|
210
205
|
property: [this, "enabled"],
|
|
211
206
|
onChange: () => this.onSizeUpdate()
|
|
212
207
|
},
|
|
213
|
-
...
|
|
208
|
+
...generateUiConfig(this)?.filter((c) => c && c.label !== "Enabled") || []
|
|
214
209
|
]
|
|
215
210
|
};
|
|
216
211
|
this.passId = pid;
|
|
@@ -220,13 +215,12 @@ class TemporalAAPluginPass extends ExtendedShaderPass {
|
|
|
220
215
|
this.needsSwap = true;
|
|
221
216
|
}
|
|
222
217
|
render(renderer, writeBuffer, readBuffer, deltaTime, maskActive) {
|
|
223
|
-
var _a2;
|
|
224
218
|
if (!this.taaEnabled || !this.enabled) {
|
|
225
219
|
this.needsSwap = false;
|
|
226
220
|
return;
|
|
227
221
|
}
|
|
228
222
|
this.needsSwap = true;
|
|
229
|
-
this.uniforms.previousRT.value =
|
|
223
|
+
this.uniforms.previousRT.value = getOrCall(this.target)?.texture ?? null;
|
|
230
224
|
super.render(renderer, writeBuffer, readBuffer, deltaTime, maskActive);
|
|
231
225
|
this.uniforms.lastProjectionViewMatrix.value.copy(this.uniforms.currentProjectionViewMatrix.value);
|
|
232
226
|
this.uniforms.firstFrame.value = false;
|
|
@@ -280,16 +274,10 @@ let VelocityBufferPlugin = class extends PipelinePassPlugin {
|
|
|
280
274
|
},
|
|
281
275
|
computeCacheKey: () => this.isDisabled() ? "" : "vb",
|
|
282
276
|
extraUniforms: {
|
|
283
|
-
tVelocity: () => {
|
|
284
|
-
var _a2;
|
|
285
|
-
return { value: !this.isDisabled() ? (_a2 = this.target) == null ? void 0 : _a2.texture : null };
|
|
286
|
-
}
|
|
277
|
+
tVelocity: () => ({ value: !this.isDisabled() ? this.target?.texture : null })
|
|
287
278
|
},
|
|
288
279
|
extraDefines: {
|
|
289
|
-
["HAS_VELOCITY_BUFFER"]: () =>
|
|
290
|
-
var _a2;
|
|
291
|
-
return !this.isDisabled() && ((_a2 = this.target) == null ? void 0 : _a2.texture) ? 1 : void 0;
|
|
292
|
-
}
|
|
280
|
+
["HAS_VELOCITY_BUFFER"]: () => !this.isDisabled() && this.target?.texture ? 1 : void 0
|
|
293
281
|
},
|
|
294
282
|
priority: 100,
|
|
295
283
|
isCompatible: () => true
|
|
@@ -350,10 +338,7 @@ let VelocityBufferPlugin = class extends PipelinePassPlugin {
|
|
|
350
338
|
}
|
|
351
339
|
}(this.passId, this.target, this.material, new Color(0.5, 0.5, 0.5), 1);
|
|
352
340
|
const preprocessMaterial = pass.preprocessMaterial;
|
|
353
|
-
pass.preprocessMaterial = (m) =>
|
|
354
|
-
var _a2;
|
|
355
|
-
return preprocessMaterial(m, (_a2 = m.userData[VelocityBufferPlugin.PluginType]) == null ? void 0 : _a2.disabled);
|
|
356
|
-
};
|
|
341
|
+
pass.preprocessMaterial = (m) => preprocessMaterial(m, m.userData[VelocityBufferPlugin.PluginType]?.disabled);
|
|
357
342
|
pass.before = ["render"];
|
|
358
343
|
pass.after = [];
|
|
359
344
|
pass.required = ["render"];
|
|
@@ -362,11 +347,9 @@ let VelocityBufferPlugin = class extends PipelinePassPlugin {
|
|
|
362
347
|
onAdded(viewer) {
|
|
363
348
|
super.onAdded(viewer);
|
|
364
349
|
viewer.forPlugin(TemporalAAPlugin, (taa) => {
|
|
365
|
-
|
|
366
|
-
this._attachToTaa && ((_a2 = taa.pass) == null ? void 0 : _a2.material.registerMaterialExtensions([this.unpackExtension]));
|
|
350
|
+
this._attachToTaa && taa.pass?.material.registerMaterialExtensions([this.unpackExtension]);
|
|
367
351
|
}, (taa) => {
|
|
368
|
-
|
|
369
|
-
(_b2 = (_a2 = taa.pass) == null ? void 0 : _a2.material) == null ? void 0 : _b2.unregisterMaterialExtensions([this.unpackExtension]);
|
|
352
|
+
taa.pass?.material?.unregisterMaterialExtensions([this.unpackExtension]);
|
|
370
353
|
});
|
|
371
354
|
}
|
|
372
355
|
onRemove(viewer) {
|
|
@@ -374,9 +357,8 @@ let VelocityBufferPlugin = class extends PipelinePassPlugin {
|
|
|
374
357
|
return super.onRemove(viewer);
|
|
375
358
|
}
|
|
376
359
|
setDirty() {
|
|
377
|
-
var _a2, _b2;
|
|
378
360
|
super.setDirty();
|
|
379
|
-
|
|
361
|
+
this.unpackExtension.setDirty?.();
|
|
380
362
|
}
|
|
381
363
|
_beforeRender(scene, camera, renderManager) {
|
|
382
364
|
if (!super._beforeRender(scene, camera, renderManager)) return false;
|
|
@@ -431,7 +413,7 @@ class SSVelocityMaterial extends ShaderMaterial {
|
|
|
431
413
|
if (Array.isArray(mat)) {
|
|
432
414
|
mat = mat[0];
|
|
433
415
|
}
|
|
434
|
-
this.uniforms.alphaMap.value =
|
|
416
|
+
this.uniforms.alphaMap.value = mat?.alphaMap ?? null;
|
|
435
417
|
this.uniforms.alphaTest.value = !mat || !mat.alphaTest || mat.alphaTest < 1e-7 ? 1e-3 : mat.alphaTest;
|
|
436
418
|
let x = this.uniforms.alphaMap.value ? 1 : void 0;
|
|
437
419
|
if (x !== this.defines.USE_ALPHAMAP) {
|
|
@@ -439,13 +421,13 @@ class SSVelocityMaterial extends ShaderMaterial {
|
|
|
439
421
|
else this.defines.USE_ALPHAMAP = x;
|
|
440
422
|
this.needsUpdate = true;
|
|
441
423
|
}
|
|
442
|
-
x =
|
|
424
|
+
x = mat?.userData.ALPHA_I_RGBA_PACKING ? 1 : void 0;
|
|
443
425
|
if (x !== this.defines.ALPHA_I_RGBA_PACKING) {
|
|
444
426
|
if (x === void 0) delete this.defines.ALPHA_I_RGBA_PACKING;
|
|
445
427
|
else this.defines.ALPHA_I_RGBA_PACKING = x;
|
|
446
428
|
this.needsUpdate = true;
|
|
447
429
|
}
|
|
448
|
-
this.side =
|
|
430
|
+
this.side = mat?.side ?? DoubleSide;
|
|
449
431
|
}
|
|
450
432
|
}
|
|
451
433
|
const hdrBloom = "#include <packing>\nuniform float intensity;uniform float opacity;uniform vec2 tDiffuseSize;varying vec2 vUv;uniform float weight;\n#if PASS_STEP == 0\nuniform vec4 prefilter;vec4 Prefilter(vec4 c){\n#ifdef HAS_GBUFFER\n#if !BACKGROUND_BLOOM\nif(getDepth(vUv)>0.999){return vec4(0.0);}\n#endif\n#endif\nfloat brightness=max(c.r,max(c.g,c.b));float soft=brightness+prefilter.x*(prefilter.y-1.);soft=clamp(soft,0.,prefilter.z);soft=soft*soft*prefilter.w;float contribution=max(soft,brightness-prefilter.x);contribution/=max(brightness,0.001);return vec4(c.rgb*contribution,c.a);}\n#endif\nvec4 Sample(vec2 uv){return min(vec4(MAX_INTENSITY,MAX_INTENSITY,MAX_INTENSITY,1.),tDiffuseTexelToLinear(texture2D(tDiffuse,uv)));}vec4 SampleBox(vec2 uv,float delta){vec4 o=vec2(-delta,delta).xxyy/tDiffuseSize.xyxy;vec4 s=Sample(uv+o.xy)+Sample(uv+o.zy)+Sample(uv+o.xw)+Sample(uv+o.zw);return s*0.25;}int getBloomBit(in int number){\n#ifdef WebGL2Context\nreturn(number/4)% 2;\n#else\nreturn int(mod(floor(float(number)/4.),2.));\n#endif\n}void main(){\n#if PASS_STEP == 0\n#ifdef GBUFFER_HAS_FLAGS\nint doBloom=getBloomBit(getGBufferFlags(vUv).a);\n#else\nint doBloom=1;\n#endif\ngl_FragColor=float(doBloom)*weight*Prefilter(SampleBox(vUv,1.));gl_FragColor.a=1.;\n#elif PASS_STEP == 1\ngl_FragColor=weight*(SampleBox(vUv,1.));gl_FragColor.a=1.;\n#elif PASS_STEP == 2\ngl_FragColor=(SampleBox(vUv,0.5));gl_FragColor.a=1.;\n#elif PASS_STEP == 3\nvec4 texel=tSourceTexelToLinear(texture2D(tSource,vUv));vec4 bloom=intensity*SampleBox(vUv,0.5).rgba;float brightness=max(bloom.r,max(bloom.g,bloom.b));texel.rgb+=bloom.rgb;texel.a=min(1.,texel.a+brightness);gl_FragColor=texel;\n#elif PASS_STEP == 4\nvec4 texel=vec4(0.);texel.rgb+=intensity*SampleBox(vUv,0.5).rgb;texel.a=1.;gl_FragColor=texel;\n#endif\n#include <colorspace_fragment>\n}";
|
|
@@ -467,12 +449,11 @@ const _BloomPlugin = (_a = class extends PipelinePassPlugin {
|
|
|
467
449
|
this.materialExtension = uiConfigMaterialExtension(this._getUiConfig.bind(this), _a.PluginType);
|
|
468
450
|
this.dependencies = [GBufferPlugin];
|
|
469
451
|
this._onPluginAdd = (e2) => {
|
|
470
|
-
|
|
471
|
-
if (((_b2 = (_a2 = e2.plugin) == null ? void 0 : _a2.constructor) == null ? void 0 : _b2.PluginType) !== GBufferPlugin.PluginType) return;
|
|
452
|
+
if (e2.plugin?.constructor?.PluginType !== GBufferPlugin.PluginType) return;
|
|
472
453
|
const gbuffer = e2.plugin;
|
|
473
454
|
gbuffer.registerGBufferUpdater(this.constructor.PluginType, this.updateGBufferFlags.bind(this));
|
|
474
|
-
|
|
475
|
-
|
|
455
|
+
this._pass?.material.registerMaterialExtensions([gbuffer.unpackExtension]);
|
|
456
|
+
this._viewer?.removeEventListener("addPlugin", this._onPluginAdd);
|
|
476
457
|
};
|
|
477
458
|
this.uiConfig = {
|
|
478
459
|
type: "folder",
|
|
@@ -484,8 +465,7 @@ const _BloomPlugin = (_a = class extends PipelinePassPlugin {
|
|
|
484
465
|
};
|
|
485
466
|
}
|
|
486
467
|
_createPass() {
|
|
487
|
-
|
|
488
|
-
const pass = new BloomPluginPass(this.passId, Math.min(8, ((_a2 = this._viewer) == null ? void 0 : _a2.renderManager.maxHDRIntensity) || 8));
|
|
468
|
+
const pass = new BloomPluginPass(this.passId, Math.min(8, this._viewer?.renderManager.maxHDRIntensity || 8));
|
|
489
469
|
return pass;
|
|
490
470
|
}
|
|
491
471
|
onAdded(viewer) {
|
|
@@ -498,23 +478,21 @@ const _BloomPlugin = (_a = class extends PipelinePassPlugin {
|
|
|
498
478
|
viewer.materialManager.registerMaterialExtension(this.materialExtension);
|
|
499
479
|
}
|
|
500
480
|
onRemove(viewer) {
|
|
501
|
-
var _a2;
|
|
502
481
|
viewer.removeEventListener("addPlugin", this._onPluginAdd);
|
|
503
482
|
const gbuffer = viewer.getPlugin(GBufferPlugin);
|
|
504
|
-
gbuffer
|
|
505
|
-
gbuffer &&
|
|
483
|
+
gbuffer?.unregisterGBufferUpdater(this.constructor.PluginType);
|
|
484
|
+
gbuffer && this._pass?.material.unregisterMaterialExtensions([gbuffer.unpackExtension]);
|
|
506
485
|
viewer.materialManager.unregisterMaterialExtension(this.materialExtension);
|
|
507
486
|
super.onRemove(viewer);
|
|
508
487
|
}
|
|
509
488
|
updateGBufferFlags(data, c) {
|
|
510
|
-
var _a2;
|
|
511
489
|
if (!c.material || !c.material.userData) return;
|
|
512
|
-
const disabled =
|
|
490
|
+
const disabled = c.material.userData[_a.PluginType]?.enable === false || c.material.userData.pluginsDisabled;
|
|
513
491
|
const x = disabled ? 0 : 1;
|
|
514
492
|
data.w = updateBit(data.w, 2, x);
|
|
515
493
|
}
|
|
516
494
|
static AddBloomData(material, params, setDirty = true) {
|
|
517
|
-
const ud = material
|
|
495
|
+
const ud = material?.userData;
|
|
518
496
|
if (!ud) return null;
|
|
519
497
|
if (!ud[_a.PluginType]) {
|
|
520
498
|
ud[_a.PluginType] = {};
|
|
@@ -539,17 +517,15 @@ const _BloomPlugin = (_a = class extends PipelinePassPlugin {
|
|
|
539
517
|
type: "checkbox",
|
|
540
518
|
label: "Enabled",
|
|
541
519
|
get value() {
|
|
542
|
-
|
|
543
|
-
return ((_a2 = material.userData[_a.PluginType]) == null ? void 0 : _a2.enable) ?? true;
|
|
520
|
+
return material.userData[_a.PluginType]?.enable ?? true;
|
|
544
521
|
},
|
|
545
522
|
set value(v) {
|
|
546
|
-
var _a2;
|
|
547
523
|
let data = material.userData[_a.PluginType];
|
|
548
|
-
if (v ===
|
|
524
|
+
if (v === data?.enable) return;
|
|
549
525
|
if (!data) data = _a.AddBloomData(material, void 0, false);
|
|
550
526
|
data.enable = v;
|
|
551
527
|
material.setDirty();
|
|
552
|
-
|
|
528
|
+
config.uiRefresh?.(true, "postFrame");
|
|
553
529
|
},
|
|
554
530
|
onChange: this.setDirty
|
|
555
531
|
}
|
|
@@ -559,7 +535,7 @@ const _BloomPlugin = (_a = class extends PipelinePassPlugin {
|
|
|
559
535
|
}
|
|
560
536
|
}, _a.PluginType = "Bloom", _a.OldPluginType = "BloomPlugin", _a);
|
|
561
537
|
__decorateClass$d([
|
|
562
|
-
uiConfig()
|
|
538
|
+
uiConfig(void 0, { unwrapContents: true })
|
|
563
539
|
], _BloomPlugin.prototype, "_pass", 2);
|
|
564
540
|
let BloomPlugin = _BloomPlugin;
|
|
565
541
|
let BloomPluginPass = class extends ExtendedShaderPass {
|
|
@@ -606,11 +582,10 @@ let BloomPluginPass = class extends ExtendedShaderPass {
|
|
|
606
582
|
this.clear = true;
|
|
607
583
|
}
|
|
608
584
|
_thresholdsUpdated() {
|
|
609
|
-
var _a2;
|
|
610
585
|
this.prefilter.x = this.threshold;
|
|
611
586
|
this.prefilter.y = this.softThreshold;
|
|
612
587
|
this.prefilter.z = 2 * this.prefilter.x * this.prefilter.y;
|
|
613
|
-
this.prefilter.w =
|
|
588
|
+
this.prefilter.w = this.uniforms?.prefilter ? 0.125 / (this.uniforms.prefilter.value.z + 1e-5) : 0;
|
|
614
589
|
}
|
|
615
590
|
render(renderer, writeBuffer, readBuffer, deltaTime, maskActive) {
|
|
616
591
|
const renderManager = renderer.renderManager;
|
|
@@ -777,31 +752,29 @@ const _DepthOfFieldPlugin = class _DepthOfFieldPlugin extends PipelinePassPlugin
|
|
|
777
752
|
this._focalPointHitTime = 0;
|
|
778
753
|
this.dependencies = [GBufferPlugin];
|
|
779
754
|
this._onPluginAdd = (e2) => {
|
|
780
|
-
var _a2, _b2, _c, _d, _e;
|
|
781
755
|
const plugin = e2.plugin;
|
|
782
756
|
if (!plugin) return;
|
|
783
|
-
if (
|
|
757
|
+
if (plugin.constructor?.PluginType === GBufferPlugin.PluginType) {
|
|
784
758
|
const gbuffer = plugin;
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
759
|
+
this._pass?.material.registerMaterialExtensions([gbuffer.unpackExtension]);
|
|
760
|
+
this._pass?.computeCocMaterial.registerMaterialExtensions([gbuffer.unpackExtension]);
|
|
761
|
+
this._pass?.expandCocMaterial.registerMaterialExtensions([gbuffer.unpackExtension]);
|
|
788
762
|
}
|
|
789
|
-
if (
|
|
763
|
+
if (plugin.constructor?.PluginType === PickingPlugin.PluginType) {
|
|
790
764
|
const picking = plugin;
|
|
791
765
|
picking.addEventListener("hitObject", this._onObjectHit);
|
|
792
766
|
}
|
|
793
767
|
};
|
|
794
768
|
this._onPluginRemove = (e2) => {
|
|
795
|
-
var _a2, _b2, _c, _d, _e;
|
|
796
769
|
const plugin = e2.plugin;
|
|
797
770
|
if (!plugin) return;
|
|
798
|
-
if (
|
|
771
|
+
if (plugin.constructor?.PluginType === GBufferPlugin.PluginType) {
|
|
799
772
|
const gbuffer = e2.plugin;
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
773
|
+
this._pass?.material.unregisterMaterialExtensions([gbuffer.unpackExtension]);
|
|
774
|
+
this._pass?.computeCocMaterial.unregisterMaterialExtensions([gbuffer.unpackExtension]);
|
|
775
|
+
this._pass?.expandCocMaterial.unregisterMaterialExtensions([gbuffer.unpackExtension]);
|
|
803
776
|
}
|
|
804
|
-
if (
|
|
777
|
+
if (plugin.constructor?.PluginType === PickingPlugin.PluginType) {
|
|
805
778
|
const picking = e2.plugin;
|
|
806
779
|
picking.removeEventListener("hitObject", this._onObjectHit);
|
|
807
780
|
}
|
|
@@ -812,10 +785,7 @@ const _DepthOfFieldPlugin = class _DepthOfFieldPlugin extends PipelinePassPlugin
|
|
|
812
785
|
onChange: this.setDirty.bind(this),
|
|
813
786
|
children: [
|
|
814
787
|
...generateUiConfig(this) || [],
|
|
815
|
-
() =>
|
|
816
|
-
var _a2;
|
|
817
|
-
return (_a2 = this._pass) == null ? void 0 : _a2.uiConfig;
|
|
818
|
-
}
|
|
788
|
+
() => this._pass?.uiConfig
|
|
819
789
|
]
|
|
820
790
|
};
|
|
821
791
|
this._tempVec = new Vector3();
|
|
@@ -829,9 +799,8 @@ const _DepthOfFieldPlugin = class _DepthOfFieldPlugin extends PipelinePassPlugin
|
|
|
829
799
|
}
|
|
830
800
|
// todo make this a property.
|
|
831
801
|
setFocalPoint(p, fade = true, showGizmo = false) {
|
|
832
|
-
var _a2, _b2;
|
|
833
802
|
this._focalPointHit.copy(p);
|
|
834
|
-
if (fade)
|
|
803
|
+
if (fade) this._viewer?.getPlugin("FrameFadePlugin")?.startTransition(this._frameFadeTime);
|
|
835
804
|
if (showGizmo) this._focalPointHitTime = now();
|
|
836
805
|
this.setDirty();
|
|
837
806
|
}
|
|
@@ -839,12 +808,11 @@ const _DepthOfFieldPlugin = class _DepthOfFieldPlugin extends PipelinePassPlugin
|
|
|
839
808
|
return this._focalPointHit;
|
|
840
809
|
}
|
|
841
810
|
_onObjectHit(e2) {
|
|
842
|
-
var _a2, _b2;
|
|
843
811
|
if (!this._pass || !e2.intersects.intersect || this.isDisabled() || !this.enableEdit) return;
|
|
844
812
|
this._focalPointHit.copy(e2.intersects.intersect.point);
|
|
845
813
|
this._focalPointHitTime = e2.time;
|
|
846
814
|
e2.intersects.selectedObject = null;
|
|
847
|
-
|
|
815
|
+
this._viewer?.getPlugin(FrameFadePlugin)?.startTransition(this._frameFadeTime);
|
|
848
816
|
this.setDirty();
|
|
849
817
|
}
|
|
850
818
|
_createPass() {
|
|
@@ -871,7 +839,7 @@ const _DepthOfFieldPlugin = class _DepthOfFieldPlugin extends PipelinePassPlugin
|
|
|
871
839
|
const pass = this.pass;
|
|
872
840
|
if (!pass) return false;
|
|
873
841
|
if (pass.dofBlurMaterial.uniforms.frameCount)
|
|
874
|
-
renderManager
|
|
842
|
+
renderManager?.updateShaderProperties(pass.dofBlurMaterial);
|
|
875
843
|
const cam = camera;
|
|
876
844
|
if (!cam) return false;
|
|
877
845
|
cam.updateMatrixWorld(true);
|
|
@@ -1176,7 +1144,6 @@ let SSContactShadowsPlugin = class extends AViewerPluginSync {
|
|
|
1176
1144
|
uuid: SSContactShadowsPlugin.PluginType,
|
|
1177
1145
|
priority: 5,
|
|
1178
1146
|
shaderExtender: (shader, _material, _renderer) => {
|
|
1179
|
-
var _a2, _b2;
|
|
1180
1147
|
if (!shader.defines.SSCS_ENABLED) return;
|
|
1181
1148
|
const rsS = "float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {";
|
|
1182
1149
|
const lsS = glsl`
|
|
@@ -1228,11 +1195,10 @@ let SSContactShadowsPlugin = class extends AViewerPluginSync {
|
|
|
1228
1195
|
"directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;",
|
|
1229
1196
|
"directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ], directLight.direction ) : 1.0;"
|
|
1230
1197
|
);
|
|
1231
|
-
|
|
1198
|
+
this._gbufferUnpackExtension?.shaderExtender?.(shader, _material, _renderer);
|
|
1232
1199
|
},
|
|
1233
1200
|
onObjectRender: (_, material, renderer) => {
|
|
1234
|
-
|
|
1235
|
-
const enabled2 = this.enabled && renderer.userData.screenSpaceRendering !== false && !((_a2 = material.userData) == null ? void 0 : _a2.pluginsDisabled) && !((_b2 = material.userData) == null ? void 0 : _b2.sscsDisabled) ? 1 : 0;
|
|
1201
|
+
const enabled2 = this.enabled && renderer.userData.screenSpaceRendering !== false && !material.userData?.pluginsDisabled && !material.userData?.sscsDisabled ? 1 : 0;
|
|
1236
1202
|
updateMaterialDefines({
|
|
1237
1203
|
...this._defines,
|
|
1238
1204
|
["SSCS_ENABLED"]: enabled2
|
|
@@ -1302,16 +1268,13 @@ let SSContactShadowsPlugin = class extends AViewerPluginSync {
|
|
|
1302
1268
|
// }
|
|
1303
1269
|
// return config
|
|
1304
1270
|
// },
|
|
1305
|
-
updaters: () =>
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
(_d = this._viewer) == null ? void 0 : _d.scene
|
|
1313
|
-
];
|
|
1314
|
-
}
|
|
1271
|
+
updaters: () => [
|
|
1272
|
+
// this._viewer?.getPlugin(GBufferPlugin),
|
|
1273
|
+
this._viewer?.getPlugin(ProgressivePlugin),
|
|
1274
|
+
this._viewer?.scene.renderCamera,
|
|
1275
|
+
this._viewer?.renderManager,
|
|
1276
|
+
this._viewer?.scene
|
|
1277
|
+
]
|
|
1315
1278
|
};
|
|
1316
1279
|
this._gbufferUnpackExtension = void 0;
|
|
1317
1280
|
this._gbufferUnpackExtensionChanged = () => {
|
|
@@ -1326,9 +1289,8 @@ let SSContactShadowsPlugin = class extends AViewerPluginSync {
|
|
|
1326
1289
|
this.enabled = enabled;
|
|
1327
1290
|
}
|
|
1328
1291
|
setDirty() {
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
(_c = this._viewer) == null ? void 0 : _c.setDirty();
|
|
1292
|
+
this.materialExtension?.setDirty?.();
|
|
1293
|
+
this._viewer?.setDirty();
|
|
1332
1294
|
}
|
|
1333
1295
|
onAdded(v) {
|
|
1334
1296
|
super.onAdded(v);
|
|
@@ -1338,8 +1300,7 @@ let SSContactShadowsPlugin = class extends AViewerPluginSync {
|
|
|
1338
1300
|
v.renderManager.addEventListener("gbufferUnpackExtensionChanged", this._gbufferUnpackExtensionChanged);
|
|
1339
1301
|
}
|
|
1340
1302
|
onRemove(v) {
|
|
1341
|
-
|
|
1342
|
-
(_a2 = v.assetManager.materials) == null ? void 0 : _a2.unregisterMaterialExtension(this.materialExtension);
|
|
1303
|
+
v.assetManager.materials?.unregisterMaterialExtension(this.materialExtension);
|
|
1343
1304
|
v.renderManager.removeEventListener("gbufferUnpackExtensionChanged", this._gbufferUnpackExtensionChanged);
|
|
1344
1305
|
return super.onRemove(v);
|
|
1345
1306
|
}
|
|
@@ -1475,11 +1436,9 @@ let SSReflectionPlugin = class extends PipelinePassPlugin {
|
|
|
1475
1436
|
this._gbufferUnpackExtensionChanged();
|
|
1476
1437
|
viewer.renderManager.addEventListener("gbufferUnpackExtensionChanged", this._gbufferUnpackExtensionChanged);
|
|
1477
1438
|
viewer.forPlugin(VelocityBufferPlugin, (vbp) => {
|
|
1478
|
-
|
|
1479
|
-
(_a2 = this._pass) == null ? void 0 : _a2.material.registerMaterialExtensions([vbp.unpackExtension]);
|
|
1439
|
+
this._pass?.material.registerMaterialExtensions([vbp.unpackExtension]);
|
|
1480
1440
|
}, (vbp) => {
|
|
1481
|
-
|
|
1482
|
-
(_b2 = (_a2 = this._pass) == null ? void 0 : _a2.material) == null ? void 0 : _b2.unregisterMaterialExtensions([vbp.unpackExtension]);
|
|
1441
|
+
this._pass?.material?.unregisterMaterialExtensions([vbp.unpackExtension]);
|
|
1483
1442
|
});
|
|
1484
1443
|
}
|
|
1485
1444
|
onRemove(viewer) {
|
|
@@ -1488,12 +1447,11 @@ let SSReflectionPlugin = class extends PipelinePassPlugin {
|
|
|
1488
1447
|
return super.onRemove(viewer);
|
|
1489
1448
|
}
|
|
1490
1449
|
_beforeRender(_, _1, _2) {
|
|
1491
|
-
var _a2;
|
|
1492
1450
|
if (!this._viewer) return false;
|
|
1493
1451
|
const e2 = super._beforeRender(_, _1, _2);
|
|
1494
1452
|
if (!e2) return e2;
|
|
1495
1453
|
const progressive = this._viewer.getPlugin(ProgressivePlugin);
|
|
1496
|
-
|
|
1454
|
+
this._pass?.updateShaderProperties([progressive]);
|
|
1497
1455
|
return e2;
|
|
1498
1456
|
}
|
|
1499
1457
|
/**
|
|
@@ -1504,8 +1462,7 @@ let SSReflectionPlugin = class extends PipelinePassPlugin {
|
|
|
1504
1462
|
return this.target;
|
|
1505
1463
|
}
|
|
1506
1464
|
fromJSON(data, meta) {
|
|
1507
|
-
|
|
1508
|
-
if ((_a2 = data.passes) == null ? void 0 : _a2.ssr) {
|
|
1465
|
+
if (data.passes?.ssr) {
|
|
1509
1466
|
data = { ...data };
|
|
1510
1467
|
data.pass = data.passes.ssr;
|
|
1511
1468
|
delete data.passes;
|
|
@@ -1520,7 +1477,7 @@ __decorateClass$a([
|
|
|
1520
1477
|
uiImage("SSReflection Buffer", { readOnly: true, hideOnEmpty: true })
|
|
1521
1478
|
], SSReflectionPlugin.prototype, "texture", 2);
|
|
1522
1479
|
__decorateClass$a([
|
|
1523
|
-
uiConfig()
|
|
1480
|
+
uiConfig(void 0, { unwrapContents: true })
|
|
1524
1481
|
], SSReflectionPlugin.prototype, "_pass", 2);
|
|
1525
1482
|
SSReflectionPlugin = __decorateClass$a([
|
|
1526
1483
|
uiFolderContainer("SSReflection Plugin")
|
|
@@ -1617,10 +1574,7 @@ ${ssrShaderMain}
|
|
|
1617
1574
|
this.split = 0;
|
|
1618
1575
|
this.materialExtension = {
|
|
1619
1576
|
extraUniforms: {
|
|
1620
|
-
tSSReflMap: () => {
|
|
1621
|
-
var _a2;
|
|
1622
|
-
return { value: ((_a2 = getOrCall(this.target)) == null ? void 0 : _a2.texture) ?? null };
|
|
1623
|
-
},
|
|
1577
|
+
tSSReflMap: () => ({ value: getOrCall(this.target)?.texture ?? null }),
|
|
1624
1578
|
ssrPower: this.material.uniforms.power,
|
|
1625
1579
|
ssrIntensity: this.material.uniforms.intensity,
|
|
1626
1580
|
ssrMaskFrontFactor: this.material.uniforms.maskFrontFactor,
|
|
@@ -1637,8 +1591,7 @@ ${ssrShaderMain}
|
|
|
1637
1591
|
// todo gbuffer stuff
|
|
1638
1592
|
},
|
|
1639
1593
|
shaderExtender: (shader, _material, _renderer) => {
|
|
1640
|
-
|
|
1641
|
-
if (!shader.defines.SSREFL_ENABLED) return;
|
|
1594
|
+
if (!shader.defines?.SSREFL_ENABLED) return;
|
|
1642
1595
|
const ls = `
|
|
1643
1596
|
|
|
1644
1597
|
${ssreflPatch}
|
|
@@ -1655,24 +1608,21 @@ ${ssrShaderMain}
|
|
|
1655
1608
|
ls,
|
|
1656
1609
|
{ prepend: true }
|
|
1657
1610
|
);
|
|
1658
|
-
|
|
1611
|
+
this._gbufferUnpackExtension?.shaderExtender?.(shader, _material, _renderer);
|
|
1659
1612
|
},
|
|
1660
1613
|
onObjectRender: (_object, material, renderer) => {
|
|
1661
|
-
|
|
1662
|
-
let x = this.enabled && renderer.userData.screenSpaceRendering !== false && !((_a2 = material.userData) == null ? void 0 : _a2.pluginsDisabled) && !((_b2 = material.userData) == null ? void 0 : _b2.ssreflDisabled) ? this.split > 0 ? 2 : 1 : 0;
|
|
1614
|
+
let x = this.enabled && renderer.userData.screenSpaceRendering !== false && !material.userData?.pluginsDisabled && !material.userData?.ssreflDisabled ? this.split > 0 ? 2 : 1 : 0;
|
|
1663
1615
|
if (material.defines.SSREFL_ENABLED !== x) {
|
|
1664
1616
|
material.defines.SSREFL_ENABLED = x;
|
|
1665
1617
|
material.needsUpdate = true;
|
|
1666
1618
|
}
|
|
1667
|
-
x =
|
|
1619
|
+
x = material.userData?.ssreflNonPhysical ? 1 : 0;
|
|
1668
1620
|
if (material.defines.SSR_NON_PHYSICAL !== x) {
|
|
1669
1621
|
material.defines.SSR_NON_PHYSICAL = x;
|
|
1670
1622
|
material.needsUpdate = true;
|
|
1671
1623
|
}
|
|
1672
1624
|
},
|
|
1673
|
-
parsFragmentSnippet: () =>
|
|
1674
|
-
var _a2, _b2;
|
|
1675
|
-
return glsl`
|
|
1625
|
+
parsFragmentSnippet: () => glsl`
|
|
1676
1626
|
#if defined(SSREFL_ENABLED) && SSREFL_ENABLED > 0
|
|
1677
1627
|
uniform float ssrPower;
|
|
1678
1628
|
uniform float ssrIntensity;
|
|
@@ -1680,8 +1630,8 @@ ${ssrShaderMain}
|
|
|
1680
1630
|
uniform vec3 ssrBoost;
|
|
1681
1631
|
uniform sampler2D tSSReflMap;
|
|
1682
1632
|
uniform sampler2D tLastFrame;
|
|
1683
|
-
${getTexelDecoding("tSSReflMap",
|
|
1684
|
-
${getTexelDecoding("tLastFrame",
|
|
1633
|
+
${getTexelDecoding("tSSReflMap", getOrCall(this.target)?.texture.colorSpace)}
|
|
1634
|
+
${getTexelDecoding("tLastFrame", this.material.uniforms.tLastFrame.value?.colorSpace)}
|
|
1685
1635
|
${!this.inlineShaderRayTrace ? "" : `
|
|
1686
1636
|
#define THREE_PACKING_INCLUDED // by threejs
|
|
1687
1637
|
#include <cameraHelpers>
|
|
@@ -1692,11 +1642,9 @@ ${getShaders().ssReflection}
|
|
|
1692
1642
|
`}
|
|
1693
1643
|
#include <simpleCameraHelpers>
|
|
1694
1644
|
#endif
|
|
1695
|
-
|
|
1696
|
-
},
|
|
1645
|
+
`,
|
|
1697
1646
|
computeCacheKey: () => {
|
|
1698
|
-
|
|
1699
|
-
return (this.enabled ? "1" : "0") + ((_b2 = (_a2 = getOrCall(this.target)) == null ? void 0 : _a2.texture) == null ? void 0 : _b2.colorSpace) + Object.values(this.material.defines).map((v) => v + "").join(",");
|
|
1647
|
+
return (this.enabled ? "1" : "0") + getOrCall(this.target)?.texture?.colorSpace + Object.values(this.material.defines).map((v) => v + "").join(",");
|
|
1700
1648
|
},
|
|
1701
1649
|
uuid: SSReflectionPlugin.PluginType,
|
|
1702
1650
|
...uiConfigMaterialExtension(this._getUiConfig.bind(this), SSReflectionPlugin.PluginType),
|
|
@@ -1730,8 +1678,7 @@ ${getShaders().ssReflection}
|
|
|
1730
1678
|
}
|
|
1731
1679
|
}
|
|
1732
1680
|
setDirty() {
|
|
1733
|
-
|
|
1734
|
-
(_b2 = (_a2 = this.materialExtension) == null ? void 0 : _a2.setDirty) == null ? void 0 : _b2.call(_a2);
|
|
1681
|
+
this.materialExtension?.setDirty?.();
|
|
1735
1682
|
super.setDirty();
|
|
1736
1683
|
}
|
|
1737
1684
|
render(renderer, writeBuffer, readBuffer, deltaTime, maskActive) {
|
|
@@ -1945,23 +1892,22 @@ let OutlinePlugin = class extends AScreenPassExtensionPlugin {
|
|
|
1945
1892
|
side: DoubleSide
|
|
1946
1893
|
});
|
|
1947
1894
|
this._getSelectedObject = () => {
|
|
1948
|
-
|
|
1949
|
-
if (!this._viewer) return;
|
|
1895
|
+
if (!this._viewer) return null;
|
|
1950
1896
|
const picking = this._viewer.getPlugin(PickingPlugin);
|
|
1951
1897
|
if (this.highlightSelectedMaterials) {
|
|
1952
|
-
const mat =
|
|
1898
|
+
const mat = picking?.getSelectedObject()?.material || null;
|
|
1953
1899
|
if (this.highlightMaterialSameNames && mat) {
|
|
1954
1900
|
const names = Array.isArray(mat) ? mat.map((m) => m.name) : [mat.name];
|
|
1955
1901
|
const mats = /* @__PURE__ */ new Set();
|
|
1956
1902
|
for (const name of names) {
|
|
1957
|
-
const mats1 =
|
|
1958
|
-
mats1
|
|
1903
|
+
const mats1 = this._viewer?.assetManager?.materials?.findMaterialsByName(name);
|
|
1904
|
+
mats1?.forEach((m) => mats.add(m));
|
|
1959
1905
|
}
|
|
1960
1906
|
return [...mats];
|
|
1961
1907
|
}
|
|
1962
1908
|
return mat;
|
|
1963
1909
|
}
|
|
1964
|
-
return picking
|
|
1910
|
+
return picking?.getSelectedObject() || null;
|
|
1965
1911
|
};
|
|
1966
1912
|
this._viewerListeners = {
|
|
1967
1913
|
preRender: () => {
|
|
@@ -1977,8 +1923,8 @@ let OutlinePlugin = class extends AScreenPassExtensionPlugin {
|
|
|
1977
1923
|
setDirty() {
|
|
1978
1924
|
super.setDirty();
|
|
1979
1925
|
if (!this._viewer) return;
|
|
1980
|
-
const enabled = !this.isDisabled();
|
|
1981
1926
|
const picking = this._viewer.getPlugin(PickingPlugin);
|
|
1927
|
+
const enabled = !this.isDisabled() && !picking?.getSelectedObject()?.type?.includes("Line");
|
|
1982
1928
|
if (picking) {
|
|
1983
1929
|
if (enabled && picking.widgetEnabled) {
|
|
1984
1930
|
picking.widgetEnabled = false;
|
|
@@ -1991,16 +1937,15 @@ let OutlinePlugin = class extends AScreenPassExtensionPlugin {
|
|
|
1991
1937
|
this._viewer.setDirty();
|
|
1992
1938
|
}
|
|
1993
1939
|
onAdded(viewer) {
|
|
1994
|
-
var _a2;
|
|
1995
1940
|
super.onAdded(viewer);
|
|
1996
1941
|
this.setDirty();
|
|
1997
1942
|
this._pass = this._createPass();
|
|
1998
|
-
|
|
1943
|
+
this._pass.onDirty?.push(viewer.setDirty);
|
|
1999
1944
|
viewer.renderManager.registerPass(this._pass);
|
|
2000
1945
|
const pickingPlugin = viewer.getPlugin(PickingPlugin);
|
|
2001
|
-
pickingPlugin
|
|
1946
|
+
pickingPlugin?.addEventListener("selectedObjectChanged", () => {
|
|
2002
1947
|
if (!this._animationCallBack && this) {
|
|
2003
|
-
if (pickingPlugin
|
|
1948
|
+
if (pickingPlugin?.getSelectedObject()) {
|
|
2004
1949
|
if (this.enableDynamicSelection) {
|
|
2005
1950
|
this.transparency = 1;
|
|
2006
1951
|
this._animationCallBack = this._startTransparencyAnimation(1, this.highlightTransparency, 400);
|
|
@@ -2016,7 +1961,7 @@ let OutlinePlugin = class extends AScreenPassExtensionPlugin {
|
|
|
2016
1961
|
if (!this) return;
|
|
2017
1962
|
if (!this.mouseInOutAnimationEnabled) return;
|
|
2018
1963
|
if (!this.enableHighlight) return;
|
|
2019
|
-
const selectedObject = pickingPlugin
|
|
1964
|
+
const selectedObject = pickingPlugin?.getSelectedObject();
|
|
2020
1965
|
if (selectedObject && this.enableDynamicSelection) {
|
|
2021
1966
|
if (e2.target !== viewer.canvas) {
|
|
2022
1967
|
if (!this._animationCallBack && this._state === "in") {
|
|
@@ -2190,7 +2135,7 @@ let OutlineRenderPass = class extends RenderPass {
|
|
|
2190
2135
|
* @param maskActive
|
|
2191
2136
|
*/
|
|
2192
2137
|
render(renderer, writeBuffer, _1, deltaTime, maskActive) {
|
|
2193
|
-
if (!this.scene || !this.camera) return;
|
|
2138
|
+
if (!this.scene || !this.camera || !this.enabled) return;
|
|
2194
2139
|
const t2 = renderer.getRenderTarget();
|
|
2195
2140
|
const activeCubeFace = renderer.getActiveCubeFace();
|
|
2196
2141
|
const activeMipLevel = renderer.getActiveMipmapLevel();
|
|
@@ -2208,14 +2153,11 @@ let OutlineRenderPass = class extends RenderPass {
|
|
|
2208
2153
|
renderer.setRenderTarget(t2, activeCubeFace, activeMipLevel);
|
|
2209
2154
|
}
|
|
2210
2155
|
_renderSelectedObject(renderer, selectedObject, writeBuffer, deltaTime, maskActive) {
|
|
2211
|
-
if (!this.camera) return;
|
|
2156
|
+
if (!this.camera || !selectedObject) return;
|
|
2212
2157
|
const selectionLayer = 6;
|
|
2213
|
-
const objs = (Array.isArray(selectedObject) ? selectedObject : [selectedObject]).
|
|
2214
|
-
var _a2;
|
|
2215
|
-
return (o == null ? void 0 : o.isMaterial) ? [...(_a2 = o.appliedMeshes) == null ? void 0 : _a2.values()] : o;
|
|
2216
|
-
}).flat();
|
|
2158
|
+
const objs = (Array.isArray(selectedObject) ? selectedObject : [selectedObject]).flatMap((o) => o?.isTexture ? [...o.appliedObjects?.values() || []] : o).flatMap((o) => o?.isMaterial ? [...o.appliedMeshes?.values() || []] : o?.isBufferGeometry ? [...o.appliedMeshes?.values() || []] : o);
|
|
2217
2159
|
for (const o1 of objs) {
|
|
2218
|
-
o1.traverse((o) => {
|
|
2160
|
+
o1 && o1.traverse((o) => {
|
|
2219
2161
|
o.layers.enable(selectionLayer);
|
|
2220
2162
|
});
|
|
2221
2163
|
}
|
|
@@ -2239,11 +2181,10 @@ let OutlineRenderPass = class extends RenderPass {
|
|
|
2239
2181
|
this.camera.layers.mask = mask;
|
|
2240
2182
|
}
|
|
2241
2183
|
dispose() {
|
|
2242
|
-
var _a2;
|
|
2243
2184
|
this.onDirty = [];
|
|
2244
2185
|
this.scene = void 0;
|
|
2245
2186
|
this.camera = void 0;
|
|
2246
|
-
|
|
2187
|
+
super.dispose?.();
|
|
2247
2188
|
}
|
|
2248
2189
|
setDirty() {
|
|
2249
2190
|
this.onDirty.forEach((v) => v());
|
|
@@ -2299,17 +2240,16 @@ class BilateralFilterPass extends ExtendedShaderPass {
|
|
|
2299
2240
|
this.needsSwap = false;
|
|
2300
2241
|
}
|
|
2301
2242
|
render(renderer, writeBuffer, _readBuffer, deltaTime, maskActive) {
|
|
2302
|
-
var _a2, _b2, _c, _d;
|
|
2303
2243
|
if (!this.enabled) return;
|
|
2304
2244
|
const target = getOrCall(this.target);
|
|
2305
2245
|
if (!target) return;
|
|
2306
2246
|
this.uniforms.bilDirection.value.set(1, 0);
|
|
2307
2247
|
this.uniforms.tDiffuse.value = target.texture;
|
|
2308
|
-
this.uniforms.tDiffuseSize.value.set(
|
|
2248
|
+
this.uniforms.tDiffuseSize.value.set(this.uniforms.tDiffuse.value?.image.width || 0, this.uniforms.tDiffuse.value?.image.height || 0);
|
|
2309
2249
|
super.render(renderer, writeBuffer, target, deltaTime, maskActive);
|
|
2310
2250
|
this.uniforms.bilDirection.value.set(0, 1);
|
|
2311
2251
|
this.uniforms.tDiffuse.value = writeBuffer.texture;
|
|
2312
|
-
this.uniforms.tDiffuseSize.value.set(
|
|
2252
|
+
this.uniforms.tDiffuseSize.value.set(this.uniforms.tDiffuse.value?.image.width || 0, this.uniforms.tDiffuse.value?.image.height || 0);
|
|
2313
2253
|
super.render(renderer, target, writeBuffer, deltaTime, maskActive);
|
|
2314
2254
|
}
|
|
2315
2255
|
}
|
|
@@ -2391,11 +2331,9 @@ let SSGIPlugin = class extends PipelinePassPlugin {
|
|
|
2391
2331
|
this._gbufferUnpackExtensionChanged();
|
|
2392
2332
|
viewer.renderManager.addEventListener("gbufferUnpackExtensionChanged", this._gbufferUnpackExtensionChanged);
|
|
2393
2333
|
viewer.forPlugin(VelocityBufferPlugin, (vbp) => {
|
|
2394
|
-
|
|
2395
|
-
(_a2 = this._pass) == null ? void 0 : _a2.material.registerMaterialExtensions([vbp.unpackExtension]);
|
|
2334
|
+
this._pass?.material.registerMaterialExtensions([vbp.unpackExtension]);
|
|
2396
2335
|
}, (vbp) => {
|
|
2397
|
-
|
|
2398
|
-
(_b2 = (_a2 = this._pass) == null ? void 0 : _a2.material) == null ? void 0 : _b2.unregisterMaterialExtensions([vbp.unpackExtension]);
|
|
2336
|
+
this._pass?.material?.unregisterMaterialExtensions([vbp.unpackExtension]);
|
|
2399
2337
|
});
|
|
2400
2338
|
}
|
|
2401
2339
|
onRemove(viewer) {
|
|
@@ -2404,8 +2342,7 @@ let SSGIPlugin = class extends PipelinePassPlugin {
|
|
|
2404
2342
|
return super.onRemove(viewer);
|
|
2405
2343
|
}
|
|
2406
2344
|
fromJSON(data, meta) {
|
|
2407
|
-
|
|
2408
|
-
if ((_a2 = data.passes) == null ? void 0 : _a2.ssrtgi) {
|
|
2345
|
+
if (data.passes?.ssrtgi) {
|
|
2409
2346
|
data = { ...data };
|
|
2410
2347
|
data.pass = data.passes.ssrtgi;
|
|
2411
2348
|
delete data.passes;
|
|
@@ -2414,18 +2351,17 @@ let SSGIPlugin = class extends PipelinePassPlugin {
|
|
|
2414
2351
|
return super.fromJSON(data, meta);
|
|
2415
2352
|
}
|
|
2416
2353
|
_beforeRender(_, _1, _2) {
|
|
2417
|
-
var _a2, _b2;
|
|
2418
2354
|
if (!this._viewer) return false;
|
|
2419
2355
|
const e2 = super._beforeRender(_, _1, _2);
|
|
2420
2356
|
if (e2) {
|
|
2421
|
-
const ssao =
|
|
2357
|
+
const ssao = this._viewer?.getPlugin("SSAOPlugin");
|
|
2422
2358
|
if (ssao && !ssao.isDisabled()) {
|
|
2423
2359
|
ssao.disable(SSGIPlugin.PluginType);
|
|
2424
2360
|
}
|
|
2425
2361
|
}
|
|
2426
2362
|
if (!e2) return e2;
|
|
2427
2363
|
const progressive = this._viewer.getPlugin(ProgressivePlugin);
|
|
2428
|
-
|
|
2364
|
+
this._pass?.updateShaderProperties([progressive]);
|
|
2429
2365
|
return e2;
|
|
2430
2366
|
}
|
|
2431
2367
|
/**
|
|
@@ -2442,7 +2378,7 @@ __decorateClass$7([
|
|
|
2442
2378
|
uiImage("SSGI Buffer", { readOnly: true })
|
|
2443
2379
|
], SSGIPlugin.prototype, "texture", 2);
|
|
2444
2380
|
__decorateClass$7([
|
|
2445
|
-
uiConfig()
|
|
2381
|
+
uiConfig(void 0, { unwrapContents: true })
|
|
2446
2382
|
], SSGIPlugin.prototype, "_pass", 2);
|
|
2447
2383
|
SSGIPlugin = __decorateClass$7([
|
|
2448
2384
|
uiFolderContainer("SSGI Plugin")
|
|
@@ -2538,10 +2474,7 @@ ${getShaders().calculateGI}
|
|
|
2538
2474
|
this.materialExtension = {
|
|
2539
2475
|
// todo set priority wrt ssr etc
|
|
2540
2476
|
extraUniforms: {
|
|
2541
|
-
tSSGIMap: () => {
|
|
2542
|
-
var _a2;
|
|
2543
|
-
return { value: ((_a2 = getOrCall(this.target)) == null ? void 0 : _a2.texture) ?? null };
|
|
2544
|
-
},
|
|
2477
|
+
tSSGIMap: () => ({ value: getOrCall(this.target)?.texture ?? null }),
|
|
2545
2478
|
ssaoPower: this.material.uniforms.power,
|
|
2546
2479
|
ssgiIntensity: this.material.uniforms.intensity,
|
|
2547
2480
|
ssrtaoSplitX: this.material.uniforms.ssrtaoSplitX
|
|
@@ -2556,7 +2489,7 @@ ${getShaders().calculateGI}
|
|
|
2556
2489
|
// todo gbuffer stuff
|
|
2557
2490
|
},
|
|
2558
2491
|
shaderExtender: (shader, _material, _renderer) => {
|
|
2559
|
-
if (!shader.defines
|
|
2492
|
+
if (!shader.defines?.SSRTAO_ENABLED) return;
|
|
2560
2493
|
const ls = `
|
|
2561
2494
|
|
|
2562
2495
|
${ssgiPatch}
|
|
@@ -2577,16 +2510,13 @@ ${getShaders().calculateGI}
|
|
|
2577
2510
|
shader.fragmentShader = shaderReplaceString(shader.fragmentShader, "#include <aomap_fragment>", "");
|
|
2578
2511
|
},
|
|
2579
2512
|
onObjectRender: (_object, material, renderer) => {
|
|
2580
|
-
|
|
2581
|
-
let x = this.enabled && (this.renderWithCamera || renderer.renderManager.frameCount > 1) && renderer.userData.screenSpaceRendering !== false && !((_a2 = material.userData) == null ? void 0 : _a2.pluginsDisabled) && !((_b2 = material.userData) == null ? void 0 : _b2.ssrtaoDisabled) && !((_c = material.userData) == null ? void 0 : _c.ssaoDisabled) ? this.split > 0 ? 2 : 1 : 0;
|
|
2513
|
+
let x = this.enabled && (this.renderWithCamera || renderer.renderManager.frameCount > 1) && renderer.userData.screenSpaceRendering !== false && !material.userData?.pluginsDisabled && !material.userData?.ssrtaoDisabled && !material.userData?.ssaoDisabled ? this.split > 0 ? 2 : 1 : 0;
|
|
2582
2514
|
if (material.defines.SSRTAO_ENABLED !== x) {
|
|
2583
2515
|
material.defines.SSRTAO_ENABLED = x;
|
|
2584
2516
|
material.needsUpdate = true;
|
|
2585
2517
|
}
|
|
2586
2518
|
},
|
|
2587
|
-
parsFragmentSnippet: (_renderer) =>
|
|
2588
|
-
var _a2;
|
|
2589
|
-
return glsl`
|
|
2519
|
+
parsFragmentSnippet: (_renderer) => glsl`
|
|
2590
2520
|
#if defined(SSRTAO_ENABLED) && SSRTAO_ENABLED > 0
|
|
2591
2521
|
uniform float ssaoPower;
|
|
2592
2522
|
uniform float ssgiIntensity;
|
|
@@ -2594,20 +2524,18 @@ ${getShaders().calculateGI}
|
|
|
2594
2524
|
#if defined(SSRTAO_ENABLED) && SSRTAO_ENABLED == 2
|
|
2595
2525
|
uniform float ssrtaoSplitX;
|
|
2596
2526
|
#endif
|
|
2597
|
-
${getTexelDecoding("tSSGIMap",
|
|
2527
|
+
${getTexelDecoding("tSSGIMap", getOrCall(this.target)?.texture.colorSpace)}
|
|
2598
2528
|
${/*tLastFrame not requried in material extension
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2529
|
+
// uniform sampler2D tLastFrame;
|
|
2530
|
+
${getTexelDecoding('tLastFrame', this.material.uniforms!.tLastFrame.value?.colorSpace)}
|
|
2531
|
+
*/
|
|
2532
|
+
""}
|
|
2603
2533
|
#include <simpleCameraHelpers>
|
|
2604
2534
|
#endif
|
|
2605
|
-
|
|
2606
|
-
},
|
|
2535
|
+
`,
|
|
2607
2536
|
computeCacheKey: () => {
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
return (this.enabled ? "1" : "0") + (tex == null ? void 0 : tex.colorSpace) + (tex == null ? void 0 : tex.uuid) + Object.values(this.material.defines).map((v) => v + "").join(",");
|
|
2537
|
+
const tex = getOrCall(this.target)?.texture;
|
|
2538
|
+
return (this.enabled ? "1" : "0") + tex?.colorSpace + tex?.uuid + Object.values(this.material.defines).map((v) => v + "").join(",");
|
|
2611
2539
|
},
|
|
2612
2540
|
uuid: SSGIPlugin.PluginType,
|
|
2613
2541
|
...uiConfigMaterialExtension(this._getUiConfig.bind(this), SSGIPlugin.PluginType),
|
|
@@ -2711,8 +2639,7 @@ ${getShaders().calculateGI}
|
|
|
2711
2639
|
}
|
|
2712
2640
|
// todo update gbuffer flag like in AO?
|
|
2713
2641
|
setDirty() {
|
|
2714
|
-
|
|
2715
|
-
(_b2 = (_a2 = this.materialExtension) == null ? void 0 : _a2.setDirty) == null ? void 0 : _b2.call(_a2);
|
|
2642
|
+
this.materialExtension?.setDirty?.();
|
|
2716
2643
|
super.setDirty();
|
|
2717
2644
|
}
|
|
2718
2645
|
};
|
|
@@ -2816,9 +2743,8 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
2816
2743
|
priority: 10,
|
|
2817
2744
|
// more than sscs(which is 5)
|
|
2818
2745
|
shaderExtender: (shader, material, _renderer) => {
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
const rotMap = (_a2 = material.userData) == null ? void 0 : _a2._anisotropyDirectionMap;
|
|
2746
|
+
if (this.isDisabled() || !material?.userData._isAnisotropic) return;
|
|
2747
|
+
const rotMap = material.userData?._anisotropyDirectionMap;
|
|
2822
2748
|
const bsdfs = glsl`
|
|
2823
2749
|
//#if ANISOTROPY_ENABLED
|
|
2824
2750
|
#include <randomHelpers>
|
|
@@ -2826,7 +2752,7 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
2826
2752
|
#define D_frameCount
|
|
2827
2753
|
uniform float frameCount;
|
|
2828
2754
|
#endif
|
|
2829
|
-
${rotMap ? getTexelDecoding("anisotropyDirectionMap", rotMap
|
|
2755
|
+
${rotMap ? getTexelDecoding("anisotropyDirectionMap", rotMap?.colorSpace) : ""}\n
|
|
2830
2756
|
`;
|
|
2831
2757
|
shader.fragmentShader = shaderReplaceString(shader.fragmentShader, "#include <common>", bsdfs, { append: true });
|
|
2832
2758
|
shader.fragmentShader = shader.fragmentShader.replace("#include <lights_fragment_begin>", ShaderChunk.lights_fragment_begin);
|
|
@@ -2901,22 +2827,22 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
2901
2827
|
`,
|
|
2902
2828
|
{ prepend: true }
|
|
2903
2829
|
);
|
|
2830
|
+
if (!shader.defines) shader.defines = {};
|
|
2904
2831
|
shader.defines.USE_ANISOTROPY_BRDF = "";
|
|
2905
2832
|
shader.defines.USE_UV = "";
|
|
2906
2833
|
shader.vertexTangents = true;
|
|
2907
2834
|
},
|
|
2908
2835
|
onObjectRender: (object, material) => {
|
|
2909
|
-
var _a2, _b2;
|
|
2910
2836
|
const userData = material.userData;
|
|
2911
|
-
if (!
|
|
2837
|
+
if (!userData?._isAnisotropic) return;
|
|
2912
2838
|
if (!object.isMesh || !object.geometry) return;
|
|
2913
2839
|
if (!object.geometry.attributes.tangent) {
|
|
2914
|
-
|
|
2840
|
+
this._viewer?.console.error("AnisotropyPlugin - No tangents on the geometry, cannot use anisotropy. Make sure the tangents are computed before rendering the model. The model will render as black.", object);
|
|
2915
2841
|
}
|
|
2916
2842
|
this._uniforms.anisotropyFactor.value = userData._anisotropyFactor ?? 1;
|
|
2917
2843
|
this._uniforms.anisotropyNoise.value = userData._anisotropyNoise ?? 0;
|
|
2918
2844
|
this._uniforms.anisotropyDirection.value = userData._anisotropyDirection ?? 1;
|
|
2919
|
-
const tex =
|
|
2845
|
+
const tex = userData._anisotropyDirectionMap?.isTexture ? userData._anisotropyDirectionMap : null;
|
|
2920
2846
|
this._uniforms.anisotropyDirectionMap.value = tex;
|
|
2921
2847
|
if (tex) {
|
|
2922
2848
|
tex.updateMatrix();
|
|
@@ -2933,18 +2859,14 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
2933
2859
|
// ...this._uniforms, // done in constructor
|
|
2934
2860
|
},
|
|
2935
2861
|
computeCacheKey: (material1) => {
|
|
2936
|
-
|
|
2937
|
-
return (this.enabled ? "1" : "0") + (((_a2 = material1.userData) == null ? void 0 : _a2._isAnisotropic) ? "1" : "0") + ((_c = (_b2 = material1.userData) == null ? void 0 : _b2._anisotropyDirectionMap) == null ? void 0 : _c.uuid);
|
|
2862
|
+
return (this.enabled ? "1" : "0") + (material1.userData?._isAnisotropic ? "1" : "0") + material1.userData?._anisotropyDirectionMap?.uuid;
|
|
2938
2863
|
},
|
|
2939
2864
|
isCompatible: (material1) => material1.isPhysicalMaterial,
|
|
2940
|
-
updaters: () =>
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
(_a2 = this._viewer) == null ? void 0 : _a2.renderManager
|
|
2946
|
-
];
|
|
2947
|
-
},
|
|
2865
|
+
updaters: () => [
|
|
2866
|
+
// this._viewer?.getPlugin(ProgressivePlugin),
|
|
2867
|
+
// this._viewer?.scene.mainCamera,
|
|
2868
|
+
this._viewer?.renderManager
|
|
2869
|
+
],
|
|
2948
2870
|
getUiConfig: (material) => {
|
|
2949
2871
|
const viewer = this._viewer;
|
|
2950
2872
|
const enableAnisotropy = this.enableAnisotropy.bind(this);
|
|
@@ -2964,7 +2886,6 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
2964
2886
|
return state._isAnisotropic || false;
|
|
2965
2887
|
},
|
|
2966
2888
|
set value(v) {
|
|
2967
|
-
var _a2;
|
|
2968
2889
|
if (v === state._isAnisotropic) return;
|
|
2969
2890
|
if (v) {
|
|
2970
2891
|
if (!enableAnisotropy(material))
|
|
@@ -2973,7 +2894,7 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
2973
2894
|
state._isAnisotropic = false;
|
|
2974
2895
|
if (material.setDirty) material.setDirty();
|
|
2975
2896
|
}
|
|
2976
|
-
|
|
2897
|
+
config.uiRefresh?.(true, "postFrame");
|
|
2977
2898
|
}
|
|
2978
2899
|
},
|
|
2979
2900
|
{
|
|
@@ -3005,9 +2926,8 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
3005
2926
|
label: value
|
|
3006
2927
|
})),
|
|
3007
2928
|
onChange: () => {
|
|
3008
|
-
var _a2;
|
|
3009
2929
|
if (material.setDirty) material.setDirty();
|
|
3010
|
-
|
|
2930
|
+
config.uiRefresh?.(true, "postFrame");
|
|
3011
2931
|
}
|
|
3012
2932
|
},
|
|
3013
2933
|
{
|
|
@@ -3034,35 +2954,29 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
3034
2954
|
},
|
|
3035
2955
|
// todo errors will be fixed on threepipe update
|
|
3036
2956
|
onMaterialUpdate: (material) => {
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
(_b2 = material.userData.__appliedMeshes) == null ? void 0 : _b2.forEach((m) => this.tryComputeTangents(m, [material]));
|
|
2957
|
+
if (!material.userData?._isAnisotropic) return;
|
|
2958
|
+
material.userData.__appliedMeshes?.forEach((m) => this.tryComputeTangents(m, [material]));
|
|
3040
2959
|
},
|
|
3041
2960
|
onRegister: (material) => {
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
(_b2 = material.userData.__appliedMeshes) == null ? void 0 : _b2.forEach((m) => this.tryComputeTangents(m, [material]));
|
|
2961
|
+
if (!material.userData?._isAnisotropic) return;
|
|
2962
|
+
material.userData.__appliedMeshes?.forEach((m) => this.tryComputeTangents(m, [material]));
|
|
3045
2963
|
},
|
|
3046
2964
|
onAddToMesh: (mesh) => {
|
|
3047
2965
|
if (!mesh.isMesh) return;
|
|
3048
2966
|
const m = mesh;
|
|
3049
2967
|
const mats = Array.isArray(m.material) ? m.material : [m.material];
|
|
3050
|
-
if (!mats.find((m1) =>
|
|
3051
|
-
var _a2;
|
|
3052
|
-
return (_a2 = m1 == null ? void 0 : m1.userData) == null ? void 0 : _a2._isAnisotropic;
|
|
3053
|
-
})) return;
|
|
2968
|
+
if (!mats.find((m1) => m1?.userData?._isAnisotropic)) return;
|
|
3054
2969
|
this.tryComputeTangents(m, mats);
|
|
3055
2970
|
}
|
|
3056
2971
|
};
|
|
3057
2972
|
this.setDirty = () => {
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
(_c = this._viewer) == null ? void 0 : _c.setDirty();
|
|
2973
|
+
this.materialExtension.setDirty?.();
|
|
2974
|
+
this._viewer?.setDirty();
|
|
3061
2975
|
};
|
|
3062
2976
|
Object.assign(this.materialExtension.extraUniforms, this._uniforms);
|
|
3063
2977
|
}
|
|
3064
2978
|
enableAnisotropy(material, map, factor, noise, directionMode) {
|
|
3065
|
-
const ud = material
|
|
2979
|
+
const ud = material?.userData;
|
|
3066
2980
|
if (!ud) return false;
|
|
3067
2981
|
if (ud._isAnisotropic === void 0) {
|
|
3068
2982
|
const meshes = material.appliedMeshes;
|
|
@@ -3097,8 +3011,7 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
3097
3011
|
}
|
|
3098
3012
|
if (possible) m.geometry.computeTangents();
|
|
3099
3013
|
else mats.map((m1) => {
|
|
3100
|
-
|
|
3101
|
-
if ((_a2 = m1 == null ? void 0 : m1.userData) == null ? void 0 : _a2._isAnisotropic) m1.userData._isAnisotropic = false;
|
|
3014
|
+
if (m1?.userData?._isAnisotropic) m1.userData._isAnisotropic = false;
|
|
3102
3015
|
});
|
|
3103
3016
|
}
|
|
3104
3017
|
}
|
|
@@ -3108,8 +3021,7 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
3108
3021
|
v.assetManager.registerGltfExtension(anisotropyGLTFExtension);
|
|
3109
3022
|
}
|
|
3110
3023
|
onRemove(v) {
|
|
3111
|
-
|
|
3112
|
-
(_a2 = v.assetManager.materials) == null ? void 0 : _a2.unregisterMaterialExtension(this.materialExtension);
|
|
3024
|
+
v.assetManager.materials?.unregisterMaterialExtension(this.materialExtension);
|
|
3113
3025
|
v.assetManager.unregisterGltfExtension(anisotropyGLTFExtension.name);
|
|
3114
3026
|
return super.onRemove(v);
|
|
3115
3027
|
}
|
|
@@ -3150,7 +3062,7 @@ class GLTFMaterialsAnisotropyExtensionImport {
|
|
|
3150
3062
|
let { anisotropyDirectionMode, anisotropyDirection } = extension;
|
|
3151
3063
|
if (!anisotropyDirectionMode) anisotropyDirectionMode = extension.anisotropyTextureMode;
|
|
3152
3064
|
if (!anisotropyDirection) anisotropyDirection = extension.anisotropyRotation;
|
|
3153
|
-
materialParams.userData._anisotropyDirectionMode = anisotropyDirectionMode && typeof
|
|
3065
|
+
materialParams.userData._anisotropyDirectionMode = anisotropyDirectionMode && typeof anisotropyDirection?.index === "number" ? anisotropyDirectionMode : "CONSTANT";
|
|
3154
3066
|
if (anisotropyDirectionMode === "ROTATION" || anisotropyDirectionMode === "DIRECTION") {
|
|
3155
3067
|
pending.push(parser.assignTexture(materialParams.userData, "_anisotropyDirectionMap", anisotropyDirection).then((t2) => {
|
|
3156
3068
|
t2.colorSpace = SRGBColorSpace;
|
|
@@ -3161,10 +3073,8 @@ class GLTFMaterialsAnisotropyExtensionImport {
|
|
|
3161
3073
|
return Promise.all(pending);
|
|
3162
3074
|
}
|
|
3163
3075
|
afterRoot(result) {
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
var _a3, _b2;
|
|
3167
|
-
const mat = (_b2 = (_a3 = object.material) == null ? void 0 : _a3.userData) == null ? void 0 : _b2._isAnisotropic;
|
|
3076
|
+
result.scene?.traverse((object) => {
|
|
3077
|
+
const mat = object.material?.userData?._isAnisotropic;
|
|
3168
3078
|
if (!mat) return;
|
|
3169
3079
|
const geom = object.geometry;
|
|
3170
3080
|
if (!geom.attributes.tangent) {
|
|
@@ -3277,10 +3187,7 @@ const _Reflector2 = class _Reflector22 extends Mesh2 {
|
|
|
3277
3187
|
isCompatible: (material2) => {
|
|
3278
3188
|
return material2.isPhysicalMaterial;
|
|
3279
3189
|
},
|
|
3280
|
-
setDirty: () =>
|
|
3281
|
-
var _a2, _b2;
|
|
3282
|
-
return (_b2 = (_a2 = this.materialExtension).__setDirty) == null ? void 0 : _b2.call(_a2);
|
|
3283
|
-
}
|
|
3190
|
+
setDirty: () => this.materialExtension.__setDirty?.()
|
|
3284
3191
|
};
|
|
3285
3192
|
this._renderTarget = renderTarget;
|
|
3286
3193
|
const reflectorPlane = new Plane();
|
|
@@ -3378,7 +3285,7 @@ const _Reflector2 = class _Reflector22 extends Mesh2 {
|
|
|
3378
3285
|
const sceneBackground = scene.background;
|
|
3379
3286
|
if (this.transparentReflectionBackground) scene.background = null;
|
|
3380
3287
|
const renderBackground = !this.transparentReflectionBackground;
|
|
3381
|
-
if (
|
|
3288
|
+
if (sceneBackground?.isTexture && renderBackground) {
|
|
3382
3289
|
if (!sceneBackground.userData) sceneBackground.userData = {};
|
|
3383
3290
|
sceneBackground.userData.flipX = !sceneBackground.userData.flipX;
|
|
3384
3291
|
}
|
|
@@ -3391,14 +3298,14 @@ const _Reflector2 = class _Reflector22 extends Mesh2 {
|
|
|
3391
3298
|
// todo: render transmissive objects somehow
|
|
3392
3299
|
screenSpaceRendering: false
|
|
3393
3300
|
}, () => renderer.render(scene, virtualCamera));
|
|
3394
|
-
if (
|
|
3301
|
+
if (sceneBackground?.isTexture && renderBackground) {
|
|
3395
3302
|
sceneBackground.userData.flipX = !sceneBackground.userData.flipX || void 0;
|
|
3396
3303
|
}
|
|
3397
3304
|
if (this.transparentReflectionBackground) scene.background = sceneBackground;
|
|
3398
3305
|
renderer.xr.enabled = currentXrEnabled;
|
|
3399
3306
|
renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
|
|
3400
3307
|
renderer.setRenderTarget(currentRenderTarget);
|
|
3401
|
-
if (
|
|
3308
|
+
if (viewOffset?.enabled && camera.setViewOffset)
|
|
3402
3309
|
camera.setViewOffset(viewOffset.fullWidth, viewOffset.fullHeight, viewOffset.offsetX, viewOffset.offsetY, viewOffset.width, viewOffset.height);
|
|
3403
3310
|
const viewport = camera.viewport;
|
|
3404
3311
|
if (viewport !== void 0) {
|
|
@@ -3422,9 +3329,8 @@ const _Reflector2 = class _Reflector22 extends Mesh2 {
|
|
|
3422
3329
|
}
|
|
3423
3330
|
// todo change to reflectBackground or something
|
|
3424
3331
|
_updateExtension() {
|
|
3425
|
-
var _a2, _b2;
|
|
3426
3332
|
this.transparentReflectionBackground = this.reflectorModePhysical;
|
|
3427
|
-
|
|
3333
|
+
this.materialExtension?.setDirty?.();
|
|
3428
3334
|
}
|
|
3429
3335
|
getRenderTarget() {
|
|
3430
3336
|
return this._renderTarget;
|
|
@@ -3962,9 +3868,8 @@ const _ShadowMapBaker = class _ShadowMapBaker2 extends SimpleEventDispatcher {
|
|
|
3962
3868
|
this.reset();
|
|
3963
3869
|
}
|
|
3964
3870
|
_alphaVignetteChanged() {
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
(_c = this._viewer) == null ? void 0 : _c.setDirty();
|
|
3871
|
+
this.materialExtension?.setDirty?.();
|
|
3872
|
+
this._viewer?.setDirty();
|
|
3968
3873
|
}
|
|
3969
3874
|
fromJSON(data, meta, _internal = false) {
|
|
3970
3875
|
if (!_internal) {
|
|
@@ -4108,16 +4013,15 @@ const _ShadowMapBaker = class _ShadowMapBaker2 extends SimpleEventDispatcher {
|
|
|
4108
4013
|
return true;
|
|
4109
4014
|
}
|
|
4110
4015
|
_updateMaterial(isNull = false) {
|
|
4111
|
-
var _a2, _b2, _c;
|
|
4112
4016
|
if (!this._attachedMesh) return;
|
|
4113
4017
|
if (isNull) {
|
|
4114
|
-
if (this._attachedMesh.material.alphaMap ===
|
|
4018
|
+
if (this._attachedMesh.material.alphaMap === this._target?.texture) {
|
|
4115
4019
|
this._attachedMesh.material.alphaMap = null;
|
|
4116
4020
|
}
|
|
4117
|
-
if (this._attachedMesh.material.aoMap ===
|
|
4021
|
+
if (this._attachedMesh.material.aoMap === this._target?.texture) {
|
|
4118
4022
|
this._attachedMesh.material.aoMap = null;
|
|
4119
4023
|
}
|
|
4120
|
-
if (this._attachedMesh.material.map ===
|
|
4024
|
+
if (this._attachedMesh.material.map === this._target?.texture) {
|
|
4121
4025
|
this._attachedMesh.material.map = null;
|
|
4122
4026
|
}
|
|
4123
4027
|
} else if (this._target) {
|
|
@@ -4200,8 +4104,7 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4200
4104
|
this.autoFrustumSize = true;
|
|
4201
4105
|
this.autoBakeShadows = true;
|
|
4202
4106
|
this.autoResetShadows = () => {
|
|
4203
|
-
|
|
4204
|
-
if (this.autoBakeShadows) (_a2 = this._shadowBaker) == null ? void 0 : _a2.reset();
|
|
4107
|
+
if (this.autoBakeShadows) this._shadowBaker?.reset();
|
|
4205
4108
|
};
|
|
4206
4109
|
this._onSceneUpdate = this._onSceneUpdate.bind(this);
|
|
4207
4110
|
console.log(this.uiConfig);
|
|
@@ -4228,31 +4131,26 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4228
4131
|
* bake shadows manually, to be used with {@see autoBakeShadows} set to false
|
|
4229
4132
|
*/
|
|
4230
4133
|
bakeShadows() {
|
|
4231
|
-
|
|
4232
|
-
(_a2 = this._shadowBaker) == null ? void 0 : _a2.reset();
|
|
4134
|
+
this._shadowBaker?.reset();
|
|
4233
4135
|
}
|
|
4234
4136
|
_createMesh(mesh) {
|
|
4235
4137
|
if (mesh) throw new Error("AdvancedGroundPlugin - mesh should not be provided");
|
|
4236
|
-
const reflector = new Reflector2(this._geometry, () => {
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
// isAntialiased: this._viewer.isAntialiased,
|
|
4250
|
-
});
|
|
4251
|
-
}, 0, this._createMaterial());
|
|
4138
|
+
const reflector = new Reflector2(this._geometry, () => this._viewer?.renderManager.createTarget({
|
|
4139
|
+
// type: HalfFloatType,
|
|
4140
|
+
type: UnsignedByteType,
|
|
4141
|
+
format: RGBAFormat,
|
|
4142
|
+
colorSpace: NoColorSpace,
|
|
4143
|
+
// todo: we can do rgbm if only opaque objects will be reflected
|
|
4144
|
+
size: { width: 1024, height: 1024 },
|
|
4145
|
+
generateMipmaps: true,
|
|
4146
|
+
depthBuffer: true,
|
|
4147
|
+
minFilter: LinearMipmapLinearFilter,
|
|
4148
|
+
magFilter: LinearFilter
|
|
4149
|
+
// isAntialiased: this._viewer.isAntialiased,
|
|
4150
|
+
}), 0, this._createMaterial());
|
|
4252
4151
|
const superOnBeforeRender = reflector.onBeforeRender;
|
|
4253
4152
|
reflector.onBeforeRender = (...params) => {
|
|
4254
|
-
|
|
4255
|
-
let ssr = (_a2 = this._viewer) == null ? void 0 : _a2.getPluginByType("SSReflectionPlugin");
|
|
4153
|
+
let ssr = this._viewer?.getPluginByType("SSReflectionPlugin");
|
|
4256
4154
|
if (ssr && ssr.isDisabled()) ssr = void 0;
|
|
4257
4155
|
if (ssr) ssr.disable(reflector.uuid, false);
|
|
4258
4156
|
superOnBeforeRender(...params);
|
|
@@ -4280,16 +4178,15 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4280
4178
|
return super.onRemove(viewer);
|
|
4281
4179
|
}
|
|
4282
4180
|
_removeMaterial() {
|
|
4283
|
-
var _a2, _b2, _c, _d;
|
|
4284
4181
|
if (!this._material) return;
|
|
4285
4182
|
if (this._shadowBaker && this._material.groundMatExtension) {
|
|
4286
|
-
|
|
4183
|
+
this._material.unregisterMaterialExtensions?.([this._shadowBaker.materialExtension]);
|
|
4287
4184
|
delete this._material.groundMatExtension;
|
|
4288
4185
|
}
|
|
4289
4186
|
if (this._material.reflectorMatExtension) {
|
|
4290
4187
|
const ext = this._mesh.materialExtension;
|
|
4291
4188
|
if (!ext) console.warn("WebGi GroundPlugin: unable to find the extension to unregister");
|
|
4292
|
-
|
|
4189
|
+
this._material.unregisterMaterialExtensions?.([ext]);
|
|
4293
4190
|
delete this._material.reflectorMatExtension;
|
|
4294
4191
|
}
|
|
4295
4192
|
super._removeMaterial();
|
|
@@ -4339,18 +4236,17 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4339
4236
|
return this;
|
|
4340
4237
|
}
|
|
4341
4238
|
_refreshMaterial() {
|
|
4342
|
-
var _a2, _b2, _c, _d;
|
|
4343
4239
|
if (!this._viewer) return false;
|
|
4344
4240
|
super._refreshMaterial();
|
|
4345
4241
|
if (!this._material) return;
|
|
4346
4242
|
if (this.groundReflection && this._mesh.isReflector2 && !this._material.reflectorMatExtension) {
|
|
4347
4243
|
const ext = this._mesh.materialExtension;
|
|
4348
4244
|
ext.updaters = [this._viewer.scene, this._viewer.renderManager];
|
|
4349
|
-
|
|
4245
|
+
this._material.registerMaterialExtensions?.([ext]);
|
|
4350
4246
|
this._material.reflectorMatExtension = true;
|
|
4351
4247
|
}
|
|
4352
4248
|
if (this.bakedShadows && this._shadowBaker && !this._material.groundMatExtension) {
|
|
4353
|
-
|
|
4249
|
+
this._material.registerMaterialExtensions?.([this._shadowBaker.materialExtension]);
|
|
4354
4250
|
this._material.groundMatExtension = true;
|
|
4355
4251
|
}
|
|
4356
4252
|
this._material.userData.ssreflDisabled = this.groundReflection;
|
|
@@ -4358,7 +4254,6 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4358
4254
|
this._viewer.setDirty(this);
|
|
4359
4255
|
}
|
|
4360
4256
|
_extraUiConfig() {
|
|
4361
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h;
|
|
4362
4257
|
return [
|
|
4363
4258
|
{
|
|
4364
4259
|
label: "Shadow Frames",
|
|
@@ -4374,18 +4269,12 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4374
4269
|
hidden: () => !this._material || (this._material.transmission || 0) < 1e-4 && !this._material.transparent,
|
|
4375
4270
|
property: () => [this._shadowBaker, "alphaVignette"],
|
|
4376
4271
|
limitedUi: true,
|
|
4377
|
-
onChange: () =>
|
|
4378
|
-
var _a3, _b3;
|
|
4379
|
-
return (_b3 = (_a3 = this.uiConfig) == null ? void 0 : _a3.uiRefresh) == null ? void 0 : _b3.call(_a3, true, "postFrame");
|
|
4380
|
-
}
|
|
4272
|
+
onChange: () => this.uiConfig?.uiRefresh?.(true, "postFrame")
|
|
4381
4273
|
},
|
|
4382
4274
|
{
|
|
4383
4275
|
label: "Alpha Vignette Axis",
|
|
4384
4276
|
type: "dropdown",
|
|
4385
|
-
hidden: () =>
|
|
4386
|
-
var _a3;
|
|
4387
|
-
return !((_a3 = this._shadowBaker) == null ? void 0 : _a3.alphaVignette) || !this._material || (this._material.transmission || 0) < 1e-4 && !this._material.transparent;
|
|
4388
|
-
},
|
|
4277
|
+
hidden: () => !this._shadowBaker?.alphaVignette || !this._material || (this._material.transmission || 0) < 1e-4 && !this._material.transparent,
|
|
4389
4278
|
property: () => [this._shadowBaker, "alphaVignetteAxis"],
|
|
4390
4279
|
children: ["x", "y", "xy"].map((v) => ({ label: v, value: v })),
|
|
4391
4280
|
limitedUi: true
|
|
@@ -4422,10 +4311,7 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4422
4311
|
{
|
|
4423
4312
|
type: "color",
|
|
4424
4313
|
label: "Color",
|
|
4425
|
-
property: () =>
|
|
4426
|
-
var _a3;
|
|
4427
|
-
return [(_a3 = this._shadowBaker) == null ? void 0 : _a3.light, "color"];
|
|
4428
|
-
}
|
|
4314
|
+
property: () => [this._shadowBaker?.light, "color"]
|
|
4429
4315
|
},
|
|
4430
4316
|
// {
|
|
4431
4317
|
// type: 'slider',
|
|
@@ -4442,77 +4328,53 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4442
4328
|
{
|
|
4443
4329
|
type: "slider",
|
|
4444
4330
|
bounds: [0, 1],
|
|
4445
|
-
property: () =>
|
|
4446
|
-
var _a3, _b3;
|
|
4447
|
-
return [(_b3 = (_a3 = this._shadowBaker) == null ? void 0 : _a3.light) == null ? void 0 : _b3.randomParams, "focus"];
|
|
4448
|
-
},
|
|
4331
|
+
property: () => [this._shadowBaker?.light?.randomParams, "focus"],
|
|
4449
4332
|
onChange: this.autoResetShadows
|
|
4450
4333
|
},
|
|
4451
4334
|
{
|
|
4452
4335
|
type: "slider",
|
|
4453
4336
|
bounds: [0, 1],
|
|
4454
|
-
property: () =>
|
|
4455
|
-
var _a3, _b3;
|
|
4456
|
-
return [(_b3 = (_a3 = this._shadowBaker) == null ? void 0 : _a3.light) == null ? void 0 : _b3.randomParams, "spread"];
|
|
4457
|
-
},
|
|
4337
|
+
property: () => [this._shadowBaker?.light?.randomParams, "spread"],
|
|
4458
4338
|
onChange: this.autoResetShadows,
|
|
4459
4339
|
limitedUi: true
|
|
4460
4340
|
},
|
|
4461
4341
|
{
|
|
4462
4342
|
type: "slider",
|
|
4463
4343
|
bounds: [0.01, 60],
|
|
4464
|
-
property: () =>
|
|
4465
|
-
|
|
4466
|
-
return [(_b3 = (_a3 = this._shadowBaker) == null ? void 0 : _a3.light) == null ? void 0 : _b3.randomParams, "distanceScale"];
|
|
4467
|
-
},
|
|
4468
|
-
onChange: [(_b2 = (_a2 = this._shadowBaker) == null ? void 0 : _a2.light) == null ? void 0 : _b2.updateShadowParams, this.autoResetShadows]
|
|
4344
|
+
property: () => [this._shadowBaker?.light?.randomParams, "distanceScale"],
|
|
4345
|
+
onChange: [this._shadowBaker?.light?.updateShadowParams, this.autoResetShadows]
|
|
4469
4346
|
},
|
|
4470
4347
|
{
|
|
4471
4348
|
type: "vec3",
|
|
4472
4349
|
bounds: [-1, 1],
|
|
4473
|
-
property: () =>
|
|
4474
|
-
var _a3, _b3;
|
|
4475
|
-
return [(_b3 = (_a3 = this._shadowBaker) == null ? void 0 : _a3.light) == null ? void 0 : _b3.randomParams, "direction"];
|
|
4476
|
-
},
|
|
4350
|
+
property: () => [this._shadowBaker?.light?.randomParams, "direction"],
|
|
4477
4351
|
onChange: this.autoResetShadows,
|
|
4478
4352
|
limitedUi: true
|
|
4479
4353
|
},
|
|
4480
4354
|
{
|
|
4481
4355
|
type: "vec3",
|
|
4482
4356
|
bounds: [-1, 1],
|
|
4483
|
-
property: () =>
|
|
4484
|
-
var _a3, _b3;
|
|
4485
|
-
return [(_b3 = (_a3 = this._shadowBaker) == null ? void 0 : _a3.light) == null ? void 0 : _b3.randomParams, "normalDirection"];
|
|
4486
|
-
},
|
|
4357
|
+
property: () => [this._shadowBaker?.light?.randomParams, "normalDirection"],
|
|
4487
4358
|
onChange: this.autoResetShadows,
|
|
4488
4359
|
limitedUi: true
|
|
4489
4360
|
},
|
|
4490
4361
|
{
|
|
4491
4362
|
type: "slider",
|
|
4492
4363
|
bounds: [0.01, 10],
|
|
4493
|
-
property: () =>
|
|
4494
|
-
|
|
4495
|
-
return [(_b3 = (_a3 = this._shadowBaker) == null ? void 0 : _a3.light) == null ? void 0 : _b3.shadowParams, "radius"];
|
|
4496
|
-
},
|
|
4497
|
-
onChange: [(_d = (_c = this._shadowBaker) == null ? void 0 : _c.light) == null ? void 0 : _d.updateShadowParams, this.autoResetShadows]
|
|
4364
|
+
property: () => [this._shadowBaker?.light?.shadowParams, "radius"],
|
|
4365
|
+
onChange: [this._shadowBaker?.light?.updateShadowParams, this.autoResetShadows]
|
|
4498
4366
|
},
|
|
4499
4367
|
{
|
|
4500
4368
|
type: "input",
|
|
4501
|
-
property: () =>
|
|
4502
|
-
var _a3, _b3;
|
|
4503
|
-
return [(_b3 = (_a3 = this._shadowBaker) == null ? void 0 : _a3.light) == null ? void 0 : _b3.shadowParams, "frustumSize"];
|
|
4504
|
-
},
|
|
4369
|
+
property: () => [this._shadowBaker?.light?.shadowParams, "frustumSize"],
|
|
4505
4370
|
hidden: () => this.autoFrustumSize,
|
|
4506
|
-
onChange: [
|
|
4371
|
+
onChange: [this._shadowBaker?.light?.updateShadowParams, this.autoResetShadows]
|
|
4507
4372
|
},
|
|
4508
4373
|
{
|
|
4509
4374
|
type: "slider",
|
|
4510
4375
|
bounds: [-0.1, 0.1],
|
|
4511
|
-
property: () =>
|
|
4512
|
-
|
|
4513
|
-
return [(_b3 = (_a3 = this._shadowBaker) == null ? void 0 : _a3.light) == null ? void 0 : _b3.shadowParams, "bias"];
|
|
4514
|
-
},
|
|
4515
|
-
onChange: [(_h = (_g = this._shadowBaker) == null ? void 0 : _g.light) == null ? void 0 : _h.updateShadowParams, this.autoResetShadows]
|
|
4376
|
+
property: () => [this._shadowBaker?.light?.shadowParams, "bias"],
|
|
4377
|
+
onChange: [this._shadowBaker?.light?.updateShadowParams, this.autoResetShadows]
|
|
4516
4378
|
}
|
|
4517
4379
|
]
|
|
4518
4380
|
}
|
|
@@ -4574,7 +4436,6 @@ let WatchHandsPlugin = class extends AViewerPluginSync {
|
|
|
4574
4436
|
this.hands = [];
|
|
4575
4437
|
this._lastEnabled = true;
|
|
4576
4438
|
this._preFrame = () => {
|
|
4577
|
-
var _a2, _b2, _c, _d;
|
|
4578
4439
|
if (!this.enabled) {
|
|
4579
4440
|
if (this._lastEnabled) {
|
|
4580
4441
|
this._lastEnabled = false;
|
|
@@ -4583,13 +4444,15 @@ let WatchHandsPlugin = class extends AViewerPluginSync {
|
|
|
4583
4444
|
h.object.rotation.fromArray(h.object.userData.initRotation);
|
|
4584
4445
|
h.object.updateMatrixWorld();
|
|
4585
4446
|
}
|
|
4586
|
-
|
|
4587
|
-
|
|
4447
|
+
this._viewer?.renderManager.resetShadows();
|
|
4448
|
+
this._viewer?.setDirty();
|
|
4588
4449
|
}
|
|
4589
4450
|
return;
|
|
4590
4451
|
}
|
|
4591
4452
|
this._lastEnabled = true;
|
|
4592
4453
|
if (!this.hands.length) return;
|
|
4454
|
+
const d = this._viewer?.getPlugin("ProgressivePlugin")?.postFrameConvergedRecordingDelta();
|
|
4455
|
+
if (d === 0) return;
|
|
4593
4456
|
const time = /* @__PURE__ */ new Date();
|
|
4594
4457
|
const invert = this.invertAxis ? -1 : 1;
|
|
4595
4458
|
const secondHandRotation = invert * (time.getSeconds() + (this.analog ? time.getMilliseconds() / 1e3 : 0) - this.secondOffset) * (Math.PI * 2) / 60;
|
|
@@ -4607,8 +4470,8 @@ let WatchHandsPlugin = class extends AViewerPluginSync {
|
|
|
4607
4470
|
hand.object.rotation[this.axis] = hourHandRotation;
|
|
4608
4471
|
}
|
|
4609
4472
|
}
|
|
4610
|
-
|
|
4611
|
-
|
|
4473
|
+
this._viewer?.renderManager.resetShadows();
|
|
4474
|
+
this._viewer?.setDirty();
|
|
4612
4475
|
}
|
|
4613
4476
|
};
|
|
4614
4477
|
this._addSceneObject = async (e2) => {
|
|
@@ -4627,9 +4490,8 @@ let WatchHandsPlugin = class extends AViewerPluginSync {
|
|
|
4627
4490
|
super.onRemove(viewer);
|
|
4628
4491
|
}
|
|
4629
4492
|
refresh() {
|
|
4630
|
-
var _a2;
|
|
4631
4493
|
this.hands = [];
|
|
4632
|
-
|
|
4494
|
+
this._viewer?.scene.modelRoot.traverse((o) => {
|
|
4633
4495
|
let isChild = false;
|
|
4634
4496
|
o.traverseAncestors((oa) => {
|
|
4635
4497
|
if (isChild) return;
|