lythreeframe 1.2.22 → 1.2.24

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.
@@ -3,15 +3,12 @@
3
3
  var webgpu = require('three/webgpu');
4
4
  var Addons_js = require('three/examples/jsm/Addons.js');
5
5
  var tsl = require('three/tsl');
6
+ var DepthOfFieldNode_js = require('three/addons/tsl/display/DepthOfFieldNode.js');
6
7
  var BloomNode_js = require('three/examples/jsm/tsl/display/BloomNode.js');
7
8
  var DenoiseNode_js = require('three/examples/jsm/tsl/display/DenoiseNode.js');
8
- var DepthOfFieldNode_js = require('three/examples/jsm/tsl/display/DepthOfFieldNode.js');
9
+ var FXAANode_js = require('three/examples/jsm/tsl/display/FXAANode.js');
9
10
  var GTAONode_js = require('three/examples/jsm/tsl/display/GTAONode.js');
10
- var SSRNode_js = require('three/examples/jsm/tsl/display/SSRNode.js');
11
- var LensflareNode_js = require('three/examples/jsm/tsl/display/LensflareNode.js');
12
11
  var OutlineNode_js = require('three/examples/jsm/tsl/display/OutlineNode.js');
13
- var MotionBlur_js = require('three/examples/jsm/tsl/display/MotionBlur.js');
14
- var FXAANode_js = require('three/examples/jsm/tsl/display/FXAANode.js');
15
12
  var SMAANode_js = require('three/examples/jsm/tsl/display/SMAANode.js');
16
13
  var gsap = require('gsap');
17
14
  var three = require('three');
@@ -1263,68 +1260,18 @@ class Delegate {
1263
1260
  }
1264
1261
  }
1265
1262
 
1266
- const DefaultSSRParam = {
1267
- isEnabled: false,
1268
- maxDistance: 0.5,
1269
- opacity: 1,
1270
- thickness: 0.015,
1271
- };
1272
-
1273
- const DefaultDenoiseParam = {
1274
- denoiseRadius: 5,
1275
- lumaPhi: 5,
1276
- depthPhi: 5,
1277
- normalPhi: 5
1278
- };
1279
-
1280
- const DefaultGTAOParam = {
1281
- isEnabled: false,
1282
- distanceExponent: 1,
1283
- distanceFallOff: 1,
1284
- radius: 0.25,
1285
- scale: 1,
1286
- thickness: 1,
1287
- denoised: true,
1288
- denoiseParam: DefaultDenoiseParam,
1289
- };
1290
-
1291
- const DefaultBloomParam = {
1292
- isEnabled: false,
1293
- threshold: 0,
1294
- strength: 1,
1295
- radius: 0,
1296
- };
1297
-
1298
- const DefaultDOFParam = {
1299
- isEnabled: false,
1300
- focus: 500.0,
1301
- aperture: 5,
1302
- maxblur: 0.01
1303
- };
1304
-
1305
- const DefaultOutlineParams = {
1306
- isEnabled: false,
1307
- edgeStrength: 3.0,
1308
- edgeGlow: 1.0,
1309
- edgeThickness: 1.0,
1310
- pulsePeriod: 0.0,
1311
- visibleEdgeColor: 0xffffff,
1312
- hiddenEdgeColor: 0xffffff,
1313
- };
1314
-
1315
- const DefaultAAParams = {
1316
- isEnabled: false,
1317
- type: "fxaa",
1318
- };
1319
-
1320
1263
  const DefaultPostProcessParam = {
1321
- bloom: Object.assign({}, DefaultBloomParam),
1322
- dof: Object.assign({}, DefaultDOFParam),
1323
- ssr: Object.assign({}, DefaultSSRParam),
1324
- gtao: Object.assign({}, DefaultGTAOParam),
1325
- outline: Object.assign({}, DefaultOutlineParams),
1326
- aa: Object.assign({}, DefaultAAParams)
1264
+ steps: []
1327
1265
  };
1266
+ exports.PostProcessStepType = void 0;
1267
+ (function (PostProcessStepType) {
1268
+ PostProcessStepType[PostProcessStepType["Bloom"] = 0] = "Bloom";
1269
+ PostProcessStepType[PostProcessStepType["DepthOfField"] = 1] = "DepthOfField";
1270
+ PostProcessStepType[PostProcessStepType["ScreenSpaceReflection"] = 2] = "ScreenSpaceReflection";
1271
+ PostProcessStepType[PostProcessStepType["GroundTruthAmbientOcclusion"] = 3] = "GroundTruthAmbientOcclusion";
1272
+ PostProcessStepType[PostProcessStepType["Outline"] = 4] = "Outline";
1273
+ PostProcessStepType[PostProcessStepType["Antialiasing"] = 5] = "Antialiasing";
1274
+ })(exports.PostProcessStepType || (exports.PostProcessStepType = {}));
1328
1275
 
1329
1276
  class World {
1330
1277
  get scene() {
@@ -1394,7 +1341,10 @@ class World {
1394
1341
  class WebGPUPostProcessFactory {
1395
1342
  // scene pass
1396
1343
  static constructScenePass(scene, camera) {
1397
- const scenePass = tsl.pass(scene, camera);
1344
+ const scenePass = tsl.pass(scene, camera, { minFilter: webgpu.NearestFilter, magFilter: webgpu.NearestFilter });
1345
+ // scenePass.setMRT(mrt({
1346
+ // output: output,
1347
+ // }));
1398
1348
  scenePass.setMRT(tsl.mrt({
1399
1349
  output: tsl.output,
1400
1350
  }));
@@ -1404,12 +1354,12 @@ class WebGPUPostProcessFactory {
1404
1354
  let oldMRT = scenePass.getMRT();
1405
1355
  let newMRT = tsl.mrt(outputNodes);
1406
1356
  if (oldMRT) {
1407
- scenePass.setMRT(oldMRT.merge(newMRT));
1357
+ let merge = oldMRT.merge(newMRT);
1358
+ scenePass.setMRT(merge);
1408
1359
  }
1409
1360
  else {
1410
1361
  scenePass.setMRT(newMRT);
1411
1362
  }
1412
- console.log(scenePass.getMRT(), "MRTTTTTTT");
1413
1363
  }
1414
1364
  // bloom pass
1415
1365
  static constructBloomPass(scenePass, params) {
@@ -1427,34 +1377,37 @@ class WebGPUPostProcessFactory {
1427
1377
  static constructDOFPass(scenePass, params) {
1428
1378
  const scenePassColor = scenePass.getTextureNode('output');
1429
1379
  const scenePassViewZ = scenePass.getViewZNode();
1430
- return DepthOfFieldNode_js.dof(scenePassColor, scenePassViewZ, tsl.uniform(params.focus), tsl.uniform(params.aperture).mul(0.00001), tsl.uniform(params.maxblur));
1380
+ return DepthOfFieldNode_js.dof(scenePassColor, scenePassViewZ, tsl.uniform(params.focus), tsl.uniform(params.aperture), tsl.uniform(params.maxblur));
1431
1381
  }
1432
1382
  static updateDOFPass(dofPass, params) {
1433
1383
  dofPass.focus.value = params.focus;
1434
- dofPass.aperture.value = params.aperture * 0.00001;
1384
+ dofPass.aperture.value = params.aperture;
1435
1385
  dofPass.maxblur.value = params.maxblur;
1436
1386
  }
1437
1387
  // motion blur
1438
- static constructMotionBlurPass(lastNode, scenePass, param) {
1439
- WebGPUPostProcessFactory.updateScenePass(scenePass, { velocity: tsl.velocity });
1440
- const scenePassVelocity = scenePass.getTextureNode('velocity').mul(param.blurAmount);
1441
- const scenePassColor = scenePass.getTextureNode('output');
1442
- const motionBlurPass = MotionBlur_js.motionBlur(scenePassColor, scenePassVelocity);
1443
- return motionBlurPass;
1444
- }
1388
+ // static constructMotionBlurPass(lastNode:NodeRepresentation, scenePass: ShaderNodeObject<PassNode>, param:MotionBlurParam): ShaderNodeObject<Node>
1389
+ // {
1390
+ // WebGPUPostProcessFactory.updateScenePass(scenePass, {velocity})
1391
+ // const scenePassVelocity = scenePass.getTextureNode( 'velocity' ).mul( param.blurAmount );
1392
+ // const scenePassColor = scenePass.getTextureNode('output');
1393
+ // const motionBlurPass = motionBlur( scenePassColor, scenePassVelocity );
1394
+ // return motionBlurPass
1395
+ // }
1445
1396
  // ssr
1446
1397
  static constructSSRPass(scenePass, param) {
1447
1398
  WebGPUPostProcessFactory.updateScenePass(scenePass, {
1399
+ output: tsl.output,
1448
1400
  normal: tsl.transformedNormalView,
1449
- metalness: tsl.metalness,
1401
+ metalness: tsl.metalness
1450
1402
  });
1451
- const scenePassColor = scenePass.getTextureNode('output');
1452
- const scenePassNormal = scenePass.getTextureNode('normal');
1453
- const scenePassDepth = scenePass.getTextureNode('depth');
1454
- const scenePassMetalness = scenePass.getTextureNode('metalness');
1455
- const ssrPass = SSRNode_js.ssr(scenePassColor, scenePassDepth, scenePassNormal, scenePassMetalness, scenePass.camera);
1456
- ssrPass.resolutionScale = 1.0;
1457
- WebGPUPostProcessFactory.updateSSRPass(ssrPass, param);
1403
+ let ssrPass = null;
1404
+ scenePass.getTextureNode('output');
1405
+ scenePass.getTextureNode('depth');
1406
+ scenePass.getTextureNode('normal');
1407
+ //const scenePassMetalness = scenePass.getTextureNode('metalness');
1408
+ // const ssrPass = ssr(scenePassColor, scenePassDepth, scenePassNormal, scenePassMetalness, scenePass.camera)
1409
+ // ssrPass.resolutionScale = 1.0;
1410
+ //WebGPUPostProcessFactory.updateSSRPass(ssrPass, param);
1458
1411
  return ssrPass;
1459
1412
  }
1460
1413
  static updateSSRPass(ssrPass, params) {
@@ -1503,19 +1456,21 @@ class WebGPUPostProcessFactory {
1503
1456
  static updateGTAODenoisePass(denoisePass, params) {
1504
1457
  WebGPUPostProcessFactory.updateDenoisePass(denoisePass, params.denoiseParam);
1505
1458
  }
1506
- static constructLensFlarePass(inputNode, params) {
1507
- const lensflarePass = LensflareNode_js.lensflare(inputNode, {
1508
- threshold: tsl.uniform(params.threshold),
1509
- ghostAttenuationFactor: tsl.uniform(params.ghostAttenuationFactor),
1510
- ghostSpacing: tsl.uniform(params.ghostSpacing),
1511
- });
1512
- return lensflarePass;
1513
- }
1514
- static updateLensFlarPass(lensflarePass, params) {
1515
- lensflarePass.thresholdNode.value = params.threshold;
1516
- lensflarePass.ghostSpacingNode.value = params.ghostSpacing;
1517
- lensflarePass.ghostAttenuationFactorNode.value = params.ghostAttenuationFactor;
1518
- }
1459
+ // static constructLensFlarePass(inputNode: NodeRepresentation, params: LensFlareParam): ShaderNodeObject<LensflareNode>
1460
+ // {
1461
+ // const lensflarePass = lensflare(inputNode, {
1462
+ // threshold : uniform(params.threshold),
1463
+ // ghostAttenuationFactor: uniform(params.ghostAttenuationFactor),
1464
+ // ghostSpacing : uniform(params.ghostSpacing),
1465
+ // });
1466
+ // return lensflarePass;
1467
+ // }
1468
+ // static updateLensFlarPass(lensflarePass: ShaderNodeObject<LensflareNode>, params: LensFlareParam)
1469
+ // {
1470
+ // lensflarePass.thresholdNode.value = params.threshold
1471
+ // lensflarePass.ghostSpacingNode.value = params.ghostSpacing
1472
+ // lensflarePass.ghostAttenuationFactorNode.value = params.ghostAttenuationFactor
1473
+ // }
1519
1474
  static constructOutlinePass(scene, camera, outlineObjects, param) {
1520
1475
  const outlinePass = OutlineNode_js.outline(scene, camera, {
1521
1476
  selectedObjects: outlineObjects,
@@ -1563,17 +1518,6 @@ class Viewport {
1563
1518
  this._canvas = null;
1564
1519
  this.isRenderStateDirty = true;
1565
1520
  this.postProcessing = null;
1566
- this.scenePass = null;
1567
- this.bloomPass = null;
1568
- this.dofPass = null;
1569
- this.GTAOPass = null;
1570
- this.denoiseGTAOPass = null;
1571
- this.ssrPass = null;
1572
- this.outlinePass = null;
1573
- this.fxaaPass = null;
1574
- this.smaaPass = null;
1575
- // private motionBlurPass: ShaderNodeObject<Node> | null = null;
1576
- // private denoiseOutlinePass: ShaderNodeObject<DenoiseNode> | null = null;
1577
1521
  this.outlineObjects = [];
1578
1522
  this.postProcessParam = Object.assign({}, postProcessParam);
1579
1523
  this._app = app;
@@ -1635,221 +1579,144 @@ class Viewport {
1635
1579
  this.setupPostProcess();
1636
1580
  }
1637
1581
  setupPostProcess() {
1638
- // 检查各个效果是否启用
1639
- const isBloomEnabled = this.postProcessParam.bloom.isEnabled;
1640
- const isDOFEnabled = this.postProcessParam.dof.isEnabled;
1641
- const isSSREnabled = this.postProcessParam.ssr.isEnabled;
1642
- const isGTAOEnabled = this.postProcessParam.gtao.isEnabled;
1643
- const isOutlineEnabled = this.postProcessParam.outline.isEnabled;
1644
- const isAAEnabled = this.postProcessParam.aa.isEnabled;
1645
- if (!(isBloomEnabled) && !(isDOFEnabled) && !(isSSREnabled) && !(isGTAOEnabled) && !(isOutlineEnabled) && !(isAAEnabled)) {
1582
+ if (this.postProcessParam.steps.length === 0) {
1646
1583
  this.destroyPostProcess();
1647
- console.log("Remove post process");
1584
+ this.markRenderStateDirty();
1648
1585
  return;
1649
1586
  }
1650
1587
  if (!this.postProcessing) {
1651
1588
  this.postProcessing = new webgpu.PostProcessing(this.renderer);
1652
1589
  }
1653
- if (!this.scenePass) {
1654
- this.scenePass = WebGPUPostProcessFactory.constructScenePass(this.app.world.scene, this.app.camera);
1655
- }
1656
- let finalNode = this.scenePass.getTextureNode('output');
1657
- // bloom
1658
- if (isBloomEnabled) {
1659
- console.log("[PostProcess] Bloom 启用,参数:", this.postProcessParam.bloom);
1660
- if (!this.bloomPass) {
1661
- this.bloomPass = WebGPUPostProcessFactory.constructBloomPass(this.scenePass, this.postProcessParam.bloom);
1662
- console.log("[PostProcess] BloomPass 构建完成");
1663
- }
1664
- else {
1665
- WebGPUPostProcessFactory.updateBloomPass(this.bloomPass, this.postProcessParam.bloom);
1666
- console.log("[PostProcess] BloomPass 更新完成");
1667
- }
1668
- finalNode = finalNode.add(this.bloomPass);
1669
- }
1670
- else {
1671
- if (this.bloomPass) {
1672
- this.bloomPass.dispose();
1673
- this.bloomPass = null;
1674
- console.log("[PostProcess] BloomPass 已销毁");
1675
- }
1676
- }
1677
- // DOF
1678
- if (isDOFEnabled) {
1679
- console.log("[PostProcess] DOF 启用,参数:", this.postProcessParam.dof);
1680
- if (!this.dofPass) {
1681
- this.dofPass = WebGPUPostProcessFactory.constructDOFPass(this.scenePass, this.postProcessParam.dof);
1682
- console.log("[PostProcess] DOFPass 构建完成");
1683
- }
1684
- else {
1685
- WebGPUPostProcessFactory.updateDOFPass(this.dofPass, this.postProcessParam.dof);
1686
- console.log("[PostProcess] DOFPass 更新完成");
1687
- }
1688
- finalNode = this.dofPass;
1689
- }
1690
- else {
1691
- if (this.dofPass) {
1692
- this.dofPass.dispose();
1693
- this.dofPass = null;
1694
- console.log("[PostProcess] DOFPass 已销毁");
1695
- }
1696
- }
1697
- // ssr
1698
- if (isSSREnabled) {
1699
- console.log("[PostProcess] SSR 启用,参数:", this.postProcessParam.ssr);
1700
- if (!this.ssrPass) {
1701
- this.ssrPass = WebGPUPostProcessFactory.constructSSRPass(this.scenePass, this.postProcessParam.ssr);
1702
- console.log("[PostProcess] SSRPass 构建完成");
1703
- }
1704
- else {
1705
- WebGPUPostProcessFactory.updateSSRPass(this.ssrPass, this.postProcessParam.ssr);
1706
- console.log("[PostProcess] SSRPass 更新完成");
1707
- }
1708
- finalNode = tsl.blendColor(finalNode, this.ssrPass);
1709
- }
1710
- // GTAO
1711
- if (isGTAOEnabled) {
1712
- console.log("[PostProcess] GTAO 启用,参数:", this.postProcessParam.gtao);
1713
- if (!this.GTAOPass) {
1714
- this.GTAOPass = WebGPUPostProcessFactory.constructGTAOPass(this.scenePass, this.postProcessParam.gtao);
1715
- console.log("[PostProcess] GTAOPass 构建完成");
1716
- }
1717
- else {
1718
- WebGPUPostProcessFactory.updateGTAOPass(this.GTAOPass, this.postProcessParam.gtao);
1719
- console.log("[PostProcess] GTAOPass 更新完成");
1720
- }
1721
- if (this.postProcessParam.gtao.denoised) {
1722
- if (!this.denoiseGTAOPass) {
1723
- this.denoiseGTAOPass = WebGPUPostProcessFactory.constructGTAODenoisePass(this.scenePass, this.GTAOPass, this.postProcessParam.gtao);
1724
- console.log("[PostProcess] GTAODenoisePass 构建完成");
1725
- }
1726
- else {
1727
- WebGPUPostProcessFactory.updateGTAOPass(this.GTAOPass, this.postProcessParam.gtao);
1728
- console.log("[PostProcess] GTAODenoisePass 更新完成");
1729
- }
1730
- finalNode = this.denoiseGTAOPass.mul(finalNode);
1731
- }
1732
- else {
1733
- finalNode = this.GTAOPass.getTextureNode().mul(finalNode);
1734
- if (this.denoiseGTAOPass) {
1735
- this.denoiseGTAOPass.dispose();
1736
- this.denoiseGTAOPass = null;
1737
- console.log("[PostProcess] GTAODenoisePass 已销毁");
1738
- }
1739
- }
1740
- }
1741
- else {
1742
- if (this.GTAOPass) {
1743
- this.GTAOPass.dispose();
1744
- this.GTAOPass = null;
1745
- console.log("[PostProcess] GTAOPass 已销毁");
1746
- }
1747
- if (this.denoiseGTAOPass) {
1748
- this.denoiseGTAOPass.dispose();
1749
- this.denoiseGTAOPass = null;
1750
- console.log("[PostProcess] GTAODenoisePass 已销毁");
1751
- }
1752
- }
1753
- // outline
1754
- if (isOutlineEnabled) {
1755
- console.log("[PostProcess] Outline 启用,参数:", this.postProcessParam.outline);
1756
- if (!this.outlinePass) {
1757
- this.outlinePass = WebGPUPostProcessFactory.constructOutlinePass(this.app.world.scene, this.scenePass.camera, this.outlineObjects, this.postProcessParam.outline);
1758
- console.log("[PostProcess] OutlinePass 构建完成");
1759
- }
1760
- else {
1761
- WebGPUPostProcessFactory.updateOutlinePass(this.outlinePass, this.outlineObjects, this.postProcessParam.outline);
1762
- console.log("[PostProcess] OutlinePass 更新完成");
1763
- }
1764
- // ... existing code ...
1765
- }
1766
- else {
1767
- if (this.outlinePass) {
1768
- this.outlinePass.dispose();
1769
- this.outlinePass = null;
1770
- console.log("[PostProcess] OutlinePass 已销毁");
1771
- }
1772
- }
1773
- if (isAAEnabled) {
1774
- console.log("[PostProcess] AA 启用,类型:", this.postProcessParam.aa.type);
1775
- if (this.postProcessParam.aa.type === "fxaa") {
1776
- this.fxaaPass = WebGPUPostProcessFactory.constructFXAAPass(finalNode);
1777
- finalNode = this.fxaaPass;
1778
- console.log("[PostProcess] FXAAPass 构建完成");
1779
- }
1780
- if (this.postProcessParam.aa.type === "smaa") {
1781
- this.smaaPass = WebGPUPostProcessFactory.constructSMAAPass(finalNode);
1782
- finalNode = this.smaaPass;
1783
- console.log("[PostProcess] SMAAPass 构建完成");
1784
- }
1785
- }
1786
- else {
1787
- if (this.fxaaPass) {
1788
- this.fxaaPass.dispose();
1789
- this.fxaaPass = null;
1790
- console.log("[PostProcess] FXAAPass 已销毁");
1791
- }
1792
- if (this.smaaPass) {
1793
- this.smaaPass.dispose();
1794
- this.smaaPass = null;
1795
- console.log("[PostProcess] SMAAPass 已销毁");
1590
+ const scenePass = WebGPUPostProcessFactory.constructScenePass(this.app.world.scene, this.app.camera);
1591
+ let finalNode = scenePass.getTextureNode('output');
1592
+ this.postProcessParam.steps.forEach((step) => {
1593
+ switch (step.type) {
1594
+ case exports.PostProcessStepType.Bloom:
1595
+ {
1596
+ const bloomPass = WebGPUPostProcessFactory.constructBloomPass(scenePass, step);
1597
+ console.log("[PostProcess] BloomPass 构建完成");
1598
+ finalNode = finalNode.add(bloomPass);
1599
+ break;
1600
+ }
1601
+ case exports.PostProcessStepType.DepthOfField:
1602
+ {
1603
+ const dofPass = WebGPUPostProcessFactory.constructDOFPass(scenePass, step);
1604
+ console.log("[PostProcess] DOFPass 构建完成");
1605
+ finalNode = finalNode.add(dofPass);
1606
+ break;
1607
+ }
1608
+ case exports.PostProcessStepType.ScreenSpaceReflection:
1609
+ {
1610
+ console.warn("[PostProcess] SSR 目前存在技术问题,暂不支持。");
1611
+ // const ssrPass = WebGPUPostProcessFactory.constructSSRPass(scenePass, step as SSRParam);
1612
+ // console.log("[PostProcess] SSRPass 构建完成");
1613
+ //finalNode = blendColor(finalNode, ssrPass);
1614
+ break;
1615
+ }
1616
+ case exports.PostProcessStepType.GroundTruthAmbientOcclusion:
1617
+ {
1618
+ console.warn("[PostProcess] AO 目前存在技术问题,暂不支持。");
1619
+ // const stepParam = step as GTAOParam
1620
+ // const GTAOPass = WebGPUPostProcessFactory.constructGTAOPass(scenePass, stepParam);
1621
+ // console.log("[PostProcess] GTAOPass 构建完成");
1622
+ // if (stepParam.denoised)
1623
+ // {
1624
+ // const denoiseGTAOPass = WebGPUPostProcessFactory.constructGTAODenoisePass(scenePass, GTAOPass, stepParam);
1625
+ // console.log("[PostProcess] GTAODenoisePass 构建完成");
1626
+ // finalNode = denoiseGTAOPass.mul(finalNode);
1627
+ // }
1628
+ // else
1629
+ // {
1630
+ // finalNode = GTAOPass.getTextureNode().mul(finalNode);
1631
+ // }
1632
+ break;
1633
+ }
1634
+ case exports.PostProcessStepType.Outline:
1635
+ {
1636
+ const outlineParam = step;
1637
+ const outlinePass = WebGPUPostProcessFactory.constructOutlinePass(this.app.world.scene, scenePass.camera, this.outlineObjects, outlineParam);
1638
+ const { visibleEdge, hiddenEdge } = outlinePass;
1639
+ const pulsePeriod = tsl.uniform(outlineParam.pulsePeriod);
1640
+ const period = tsl.time.div(pulsePeriod).mul(2);
1641
+ const osc = tsl.oscSine(period).mul(.5).add(.5);
1642
+ const outlineColor = visibleEdge.mul(tsl.uniform(new webgpu.Color(outlineParam.visibleEdgeColor))).add(hiddenEdge.mul(tsl.uniform(new webgpu.Color(outlineParam.hiddenEdgeColor)))).mul(outlineParam.edgeStrength);
1643
+ const outlinePulse = pulsePeriod.greaterThan(0).select(outlineColor.mul(osc), outlineColor);
1644
+ // if(!this.denoiseOutlinePass)
1645
+ // {
1646
+ // this.denoiseOutlinePass = WebGPUPostProcessFactory.constructDenoisePass(this.scenePass, outlinePulse, DefaultDenoiseParam);
1647
+ // }
1648
+ // outlinePulse = this.denoiseOutlinePass.mul(outlinePulse)
1649
+ // finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
1650
+ finalNode = outlinePulse.add(finalNode);
1651
+ console.log("[PostProcess] OutlinePass 构建完成");
1652
+ break;
1653
+ }
1654
+ case exports.PostProcessStepType.Antialiasing:
1655
+ {
1656
+ const aaParam = step;
1657
+ if (aaParam.method === "fxaa") {
1658
+ finalNode = WebGPUPostProcessFactory.constructFXAAPass(finalNode);
1659
+ console.log("[PostProcess] FXAAPass 构建完成");
1660
+ }
1661
+ if (aaParam.method === "smaa") {
1662
+ finalNode = WebGPUPostProcessFactory.constructSMAAPass(finalNode);
1663
+ console.log("[PostProcess] SMAAPass 构建完成");
1664
+ }
1665
+ break;
1666
+ }
1796
1667
  }
1797
- }
1668
+ });
1798
1669
  this.postProcessing.outputNode = finalNode;
1670
+ this.postProcessing.needsUpdate = true;
1671
+ console.log("[PostProcess] setup complete", this.postProcessParam.steps);
1799
1672
  this.markRenderStateDirty();
1800
1673
  }
1801
- updateBloomPass(params) {
1802
- this.postProcessParam.bloom = Object.assign({}, params);
1803
- this.setupPostProcess();
1804
- }
1805
- updateGTAOParam(params) {
1806
- this.postProcessParam.gtao = Object.assign({}, params);
1807
- this.setupPostProcess();
1808
- }
1809
- updateDOFParam(params) {
1810
- this.postProcessParam.dof = Object.assign({}, params);
1811
- this.setupPostProcess();
1812
- }
1813
- updateSSRParam(params) {
1814
- this.postProcessParam.ssr = Object.assign({}, params);
1815
- this.setupPostProcess();
1816
- }
1817
- updateOutlineParam(params) {
1818
- this.postProcessParam.outline = Object.assign({}, params);
1819
- this.setupPostProcess();
1820
- }
1821
- updateAAParam(params) {
1822
- this.postProcessParam.aa = Object.assign({}, params);
1674
+ updatePostProcess(steps) {
1675
+ this.postProcessParam.steps = steps;
1823
1676
  this.setupPostProcess();
1824
1677
  }
1678
+ // updateBloomPass(params: BloomParam)
1679
+ // {
1680
+ // this.postProcessParam.bloom = { ...params };
1681
+ // this.setupPostProcess();
1682
+ // }
1683
+ // updateGTAOParam(params: GTAOParam)
1684
+ // {
1685
+ // this.postProcessParam.gtao = { ...params };
1686
+ // this.setupPostProcess();
1687
+ // }
1688
+ // updateDOFParam(params: DOFParam)
1689
+ // {
1690
+ // this.postProcessParam.dof = { ...params };
1691
+ // this.setupPostProcess();
1692
+ // }
1693
+ // updateSSRParam(params: SSRParam)
1694
+ // {
1695
+ // this.postProcessParam.ssr = { ...params };
1696
+ // this.setupPostProcess();
1697
+ // }
1698
+ // updateOutlineParam(params: OutlineParams)
1699
+ // {
1700
+ // this.postProcessParam.outline = { ...params }
1701
+ // this.setupPostProcess();
1702
+ // }
1703
+ // updateAAParam(params: AAParams)
1704
+ // {
1705
+ // this.postProcessParam.aa = { ...params };
1706
+ // this.setupPostProcess();
1707
+ // }
1825
1708
  addOutlineObject(obj) {
1826
1709
  if (!this.outlineObjects.includes(obj)) {
1827
1710
  this.outlineObjects.push(obj);
1828
1711
  }
1829
- if (!this.postProcessParam.outline) {
1830
- this.postProcessParam.outline = DefaultOutlineParams;
1831
- this.setupPostProcess();
1832
- }
1833
- else {
1834
- this.markRenderStateDirty();
1835
- }
1712
+ this.markRenderStateDirty();
1836
1713
  }
1837
1714
  setOutlineObjects(objects) {
1838
1715
  this.outlineObjects.length = 0;
1839
1716
  this.outlineObjects.push(...objects);
1840
- if (!this.postProcessParam.outline) {
1841
- this.postProcessParam.outline = DefaultOutlineParams;
1842
- this.setupPostProcess();
1843
- }
1844
- else {
1845
- this.markRenderStateDirty();
1846
- }
1717
+ this.markRenderStateDirty();
1847
1718
  }
1848
1719
  removeOutlineObject(obj) {
1849
- if (!this.postProcessParam.outline) {
1850
- this.outlineObjects = [];
1851
- return;
1852
- }
1853
1720
  const index = this.outlineObjects.indexOf(obj);
1854
1721
  if (index > -1) {
1855
1722
  this.outlineObjects.splice(index, 1);
@@ -1857,35 +1724,7 @@ class Viewport {
1857
1724
  this.markRenderStateDirty();
1858
1725
  }
1859
1726
  destroyPostProcess() {
1860
- if (this.bloomPass) {
1861
- this.bloomPass.dispose();
1862
- this.bloomPass = null;
1863
- }
1864
- if (this.dofPass) {
1865
- this.dofPass.dispose();
1866
- this.dofPass = null;
1867
- }
1868
- if (this.GTAOPass) {
1869
- this.GTAOPass.dispose();
1870
- this.GTAOPass = null;
1871
- }
1872
- if (this.denoiseGTAOPass) {
1873
- this.denoiseGTAOPass.dispose();
1874
- this.denoiseGTAOPass = null;
1875
- }
1876
- if (this.ssrPass) {
1877
- this.ssrPass.dispose();
1878
- this.ssrPass = null;
1879
- }
1880
- if (this.outlinePass) {
1881
- this.outlinePass.dispose();
1882
- this.outlinePass = null;
1883
- }
1884
1727
  this.outlineObjects = [];
1885
- if (this.scenePass) {
1886
- this.scenePass.dispose();
1887
- this.scenePass = null;
1888
- }
1889
1728
  if (this.postProcessing) {
1890
1729
  this.postProcessing.dispose();
1891
1730
  this.postProcessing = null;
@@ -3226,6 +3065,59 @@ class LabelComponent extends SceneComponent {
3226
3065
  // labelStyle.style.fontSize = "10px";
3227
3066
  // labelStyle.style.pointerEvents = 'auto';
3228
3067
 
3068
+ const DefaultBloomParam = {
3069
+ type: exports.PostProcessStepType.Bloom,
3070
+ threshold: 0,
3071
+ strength: 1,
3072
+ radius: 0,
3073
+ };
3074
+
3075
+ const DefaultDenoiseParam = {
3076
+ denoiseRadius: 5,
3077
+ lumaPhi: 5,
3078
+ depthPhi: 5,
3079
+ normalPhi: 5
3080
+ };
3081
+ const DefaultGTAOParam = {
3082
+ type: exports.PostProcessStepType.GroundTruthAmbientOcclusion,
3083
+ distanceExponent: 1,
3084
+ distanceFallOff: 1,
3085
+ radius: 0.25,
3086
+ scale: 1,
3087
+ thickness: 1,
3088
+ denoised: true,
3089
+ denoiseParam: DefaultDenoiseParam,
3090
+ };
3091
+
3092
+ const DefaultDOFParam = {
3093
+ type: exports.PostProcessStepType.DepthOfField,
3094
+ focus: 500.0,
3095
+ aperture: 5,
3096
+ maxblur: 0.01
3097
+ };
3098
+
3099
+ const DefaultOutlineParams = {
3100
+ type: exports.PostProcessStepType.Outline,
3101
+ edgeStrength: 3.0,
3102
+ edgeGlow: 1.0,
3103
+ edgeThickness: 1.0,
3104
+ pulsePeriod: 0.0,
3105
+ visibleEdgeColor: 0xffffff,
3106
+ hiddenEdgeColor: 0xffffff,
3107
+ };
3108
+
3109
+ const DefaultSSRParam = {
3110
+ type: exports.PostProcessStepType.ScreenSpaceReflection,
3111
+ maxDistance: 0.5,
3112
+ opacity: 1,
3113
+ thickness: 0.015,
3114
+ };
3115
+
3116
+ const DefaultAAParams = {
3117
+ type: exports.PostProcessStepType.Antialiasing,
3118
+ method: "fxaa"
3119
+ };
3120
+
3229
3121
  class FirstPerson extends Pawn {
3230
3122
  constructor(controller) {
3231
3123
  super(controller);