lythreeframe 1.2.21 → 1.2.22

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.
@@ -1644,6 +1644,7 @@ class Viewport {
1644
1644
  const isAAEnabled = this.postProcessParam.aa.isEnabled;
1645
1645
  if (!(isBloomEnabled) && !(isDOFEnabled) && !(isSSREnabled) && !(isGTAOEnabled) && !(isOutlineEnabled) && !(isAAEnabled)) {
1646
1646
  this.destroyPostProcess();
1647
+ console.log("Remove post process");
1647
1648
  return;
1648
1649
  }
1649
1650
  if (!this.postProcessing) {
@@ -1655,11 +1656,14 @@ class Viewport {
1655
1656
  let finalNode = this.scenePass.getTextureNode('output');
1656
1657
  // bloom
1657
1658
  if (isBloomEnabled) {
1659
+ console.log("[PostProcess] Bloom 启用,参数:", this.postProcessParam.bloom);
1658
1660
  if (!this.bloomPass) {
1659
1661
  this.bloomPass = WebGPUPostProcessFactory.constructBloomPass(this.scenePass, this.postProcessParam.bloom);
1662
+ console.log("[PostProcess] BloomPass 构建完成");
1660
1663
  }
1661
1664
  else {
1662
1665
  WebGPUPostProcessFactory.updateBloomPass(this.bloomPass, this.postProcessParam.bloom);
1666
+ console.log("[PostProcess] BloomPass 更新完成");
1663
1667
  }
1664
1668
  finalNode = finalNode.add(this.bloomPass);
1665
1669
  }
@@ -1667,15 +1671,19 @@ class Viewport {
1667
1671
  if (this.bloomPass) {
1668
1672
  this.bloomPass.dispose();
1669
1673
  this.bloomPass = null;
1674
+ console.log("[PostProcess] BloomPass 已销毁");
1670
1675
  }
1671
1676
  }
1672
1677
  // DOF
1673
1678
  if (isDOFEnabled) {
1679
+ console.log("[PostProcess] DOF 启用,参数:", this.postProcessParam.dof);
1674
1680
  if (!this.dofPass) {
1675
1681
  this.dofPass = WebGPUPostProcessFactory.constructDOFPass(this.scenePass, this.postProcessParam.dof);
1682
+ console.log("[PostProcess] DOFPass 构建完成");
1676
1683
  }
1677
1684
  else {
1678
1685
  WebGPUPostProcessFactory.updateDOFPass(this.dofPass, this.postProcessParam.dof);
1686
+ console.log("[PostProcess] DOFPass 更新完成");
1679
1687
  }
1680
1688
  finalNode = this.dofPass;
1681
1689
  }
@@ -1683,32 +1691,41 @@ class Viewport {
1683
1691
  if (this.dofPass) {
1684
1692
  this.dofPass.dispose();
1685
1693
  this.dofPass = null;
1694
+ console.log("[PostProcess] DOFPass 已销毁");
1686
1695
  }
1687
1696
  }
1688
1697
  // ssr
1689
1698
  if (isSSREnabled) {
1699
+ console.log("[PostProcess] SSR 启用,参数:", this.postProcessParam.ssr);
1690
1700
  if (!this.ssrPass) {
1691
1701
  this.ssrPass = WebGPUPostProcessFactory.constructSSRPass(this.scenePass, this.postProcessParam.ssr);
1702
+ console.log("[PostProcess] SSRPass 构建完成");
1692
1703
  }
1693
1704
  else {
1694
1705
  WebGPUPostProcessFactory.updateSSRPass(this.ssrPass, this.postProcessParam.ssr);
1706
+ console.log("[PostProcess] SSRPass 更新完成");
1695
1707
  }
1696
1708
  finalNode = tsl.blendColor(finalNode, this.ssrPass);
1697
1709
  }
1698
1710
  // GTAO
1699
1711
  if (isGTAOEnabled) {
1712
+ console.log("[PostProcess] GTAO 启用,参数:", this.postProcessParam.gtao);
1700
1713
  if (!this.GTAOPass) {
1701
1714
  this.GTAOPass = WebGPUPostProcessFactory.constructGTAOPass(this.scenePass, this.postProcessParam.gtao);
1715
+ console.log("[PostProcess] GTAOPass 构建完成");
1702
1716
  }
1703
1717
  else {
1704
1718
  WebGPUPostProcessFactory.updateGTAOPass(this.GTAOPass, this.postProcessParam.gtao);
1719
+ console.log("[PostProcess] GTAOPass 更新完成");
1705
1720
  }
1706
1721
  if (this.postProcessParam.gtao.denoised) {
1707
1722
  if (!this.denoiseGTAOPass) {
1708
1723
  this.denoiseGTAOPass = WebGPUPostProcessFactory.constructGTAODenoisePass(this.scenePass, this.GTAOPass, this.postProcessParam.gtao);
1724
+ console.log("[PostProcess] GTAODenoisePass 构建完成");
1709
1725
  }
1710
1726
  else {
1711
1727
  WebGPUPostProcessFactory.updateGTAOPass(this.GTAOPass, this.postProcessParam.gtao);
1728
+ console.log("[PostProcess] GTAODenoisePass 更新完成");
1712
1729
  }
1713
1730
  finalNode = this.denoiseGTAOPass.mul(finalNode);
1714
1731
  }
@@ -1717,6 +1734,7 @@ class Viewport {
1717
1734
  if (this.denoiseGTAOPass) {
1718
1735
  this.denoiseGTAOPass.dispose();
1719
1736
  this.denoiseGTAOPass = null;
1737
+ console.log("[PostProcess] GTAODenoisePass 已销毁");
1720
1738
  }
1721
1739
  }
1722
1740
  }
@@ -1724,59 +1742,57 @@ class Viewport {
1724
1742
  if (this.GTAOPass) {
1725
1743
  this.GTAOPass.dispose();
1726
1744
  this.GTAOPass = null;
1745
+ console.log("[PostProcess] GTAOPass 已销毁");
1727
1746
  }
1728
1747
  if (this.denoiseGTAOPass) {
1729
1748
  this.denoiseGTAOPass.dispose();
1730
1749
  this.denoiseGTAOPass = null;
1750
+ console.log("[PostProcess] GTAODenoisePass 已销毁");
1731
1751
  }
1732
1752
  }
1733
1753
  // outline
1734
1754
  if (isOutlineEnabled) {
1755
+ console.log("[PostProcess] Outline 启用,参数:", this.postProcessParam.outline);
1735
1756
  if (!this.outlinePass) {
1736
1757
  this.outlinePass = WebGPUPostProcessFactory.constructOutlinePass(this.app.world.scene, this.scenePass.camera, this.outlineObjects, this.postProcessParam.outline);
1758
+ console.log("[PostProcess] OutlinePass 构建完成");
1737
1759
  }
1738
1760
  else {
1739
1761
  WebGPUPostProcessFactory.updateOutlinePass(this.outlinePass, this.outlineObjects, this.postProcessParam.outline);
1762
+ console.log("[PostProcess] OutlinePass 更新完成");
1740
1763
  }
1741
- const { visibleEdge, hiddenEdge } = this.outlinePass;
1742
- const pulsePeriod = tsl.uniform(this.postProcessParam.outline.pulsePeriod);
1743
- const period = tsl.time.div(pulsePeriod).mul(2);
1744
- const osc = tsl.oscSine(period).mul(.5).add(.5);
1745
- const outlineColor = visibleEdge.mul(tsl.uniform(new webgpu.Color(this.postProcessParam.outline.visibleEdgeColor))).add(hiddenEdge.mul(tsl.uniform(new webgpu.Color(this.postProcessParam.outline.hiddenEdgeColor)))).mul(this.postProcessParam.outline.edgeStrength);
1746
- const outlinePulse = pulsePeriod.greaterThan(0).select(outlineColor.mul(osc), outlineColor);
1747
- // if(!this.denoiseOutlinePass)
1748
- // {
1749
- // this.denoiseOutlinePass = WebGPUPostProcessFactory.constructDenoisePass(this.scenePass, outlinePulse, DefaultDenoiseParam);
1750
- // }
1751
- // outlinePulse = this.denoiseOutlinePass.mul(outlinePulse)
1752
- // finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
1753
- finalNode = outlinePulse.add(finalNode);
1754
- // finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
1764
+ // ... existing code ...
1755
1765
  }
1756
1766
  else {
1757
1767
  if (this.outlinePass) {
1758
1768
  this.outlinePass.dispose();
1759
1769
  this.outlinePass = null;
1770
+ console.log("[PostProcess] OutlinePass 已销毁");
1760
1771
  }
1761
1772
  }
1762
1773
  if (isAAEnabled) {
1774
+ console.log("[PostProcess] AA 启用,类型:", this.postProcessParam.aa.type);
1763
1775
  if (this.postProcessParam.aa.type === "fxaa") {
1764
1776
  this.fxaaPass = WebGPUPostProcessFactory.constructFXAAPass(finalNode);
1765
1777
  finalNode = this.fxaaPass;
1778
+ console.log("[PostProcess] FXAAPass 构建完成");
1766
1779
  }
1767
1780
  if (this.postProcessParam.aa.type === "smaa") {
1768
1781
  this.smaaPass = WebGPUPostProcessFactory.constructSMAAPass(finalNode);
1769
1782
  finalNode = this.smaaPass;
1783
+ console.log("[PostProcess] SMAAPass 构建完成");
1770
1784
  }
1771
1785
  }
1772
1786
  else {
1773
1787
  if (this.fxaaPass) {
1774
1788
  this.fxaaPass.dispose();
1775
1789
  this.fxaaPass = null;
1790
+ console.log("[PostProcess] FXAAPass 已销毁");
1776
1791
  }
1777
1792
  if (this.smaaPass) {
1778
1793
  this.smaaPass.dispose();
1779
1794
  this.smaaPass = null;
1795
+ console.log("[PostProcess] SMAAPass 已销毁");
1780
1796
  }
1781
1797
  }
1782
1798
  this.postProcessing.outputNode = finalNode;
@@ -1,6 +1,6 @@
1
- import { MathUtils, Object3D, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, LoadingManager, BufferGeometry, Texture, FileLoader, Material, WebGPURenderer, PostProcessing, Color, Vector2, Raycaster, PerspectiveCamera, OrthographicCamera, Clock, DirectionalLight, MeshStandardMaterial, BoxGeometry, MeshBasicMaterial, PlaneGeometry, SphereGeometry } from 'three/webgpu';
1
+ import { MathUtils, Object3D, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, LoadingManager, BufferGeometry, Texture, FileLoader, Material, WebGPURenderer, PostProcessing, Vector2, Raycaster, PerspectiveCamera, OrthographicCamera, Clock, DirectionalLight, MeshStandardMaterial, BoxGeometry, MeshBasicMaterial, PlaneGeometry, SphereGeometry } from 'three/webgpu';
2
2
  import { GLTFLoader, DRACOLoader, CSS2DRenderer, OrbitControls } from 'three/examples/jsm/Addons.js';
3
- import { pass, mrt, output, uniform, velocity, metalness, transformedNormalView, blendColor, time, oscSine } from 'three/tsl';
3
+ import { pass, mrt, output, uniform, velocity, metalness, transformedNormalView, blendColor } from 'three/tsl';
4
4
  import { bloom } from 'three/examples/jsm/tsl/display/BloomNode.js';
5
5
  import { denoise } from 'three/examples/jsm/tsl/display/DenoiseNode.js';
6
6
  import { dof } from 'three/examples/jsm/tsl/display/DepthOfFieldNode.js';
@@ -1642,6 +1642,7 @@ class Viewport {
1642
1642
  const isAAEnabled = this.postProcessParam.aa.isEnabled;
1643
1643
  if (!(isBloomEnabled) && !(isDOFEnabled) && !(isSSREnabled) && !(isGTAOEnabled) && !(isOutlineEnabled) && !(isAAEnabled)) {
1644
1644
  this.destroyPostProcess();
1645
+ console.log("Remove post process");
1645
1646
  return;
1646
1647
  }
1647
1648
  if (!this.postProcessing) {
@@ -1653,11 +1654,14 @@ class Viewport {
1653
1654
  let finalNode = this.scenePass.getTextureNode('output');
1654
1655
  // bloom
1655
1656
  if (isBloomEnabled) {
1657
+ console.log("[PostProcess] Bloom 启用,参数:", this.postProcessParam.bloom);
1656
1658
  if (!this.bloomPass) {
1657
1659
  this.bloomPass = WebGPUPostProcessFactory.constructBloomPass(this.scenePass, this.postProcessParam.bloom);
1660
+ console.log("[PostProcess] BloomPass 构建完成");
1658
1661
  }
1659
1662
  else {
1660
1663
  WebGPUPostProcessFactory.updateBloomPass(this.bloomPass, this.postProcessParam.bloom);
1664
+ console.log("[PostProcess] BloomPass 更新完成");
1661
1665
  }
1662
1666
  finalNode = finalNode.add(this.bloomPass);
1663
1667
  }
@@ -1665,15 +1669,19 @@ class Viewport {
1665
1669
  if (this.bloomPass) {
1666
1670
  this.bloomPass.dispose();
1667
1671
  this.bloomPass = null;
1672
+ console.log("[PostProcess] BloomPass 已销毁");
1668
1673
  }
1669
1674
  }
1670
1675
  // DOF
1671
1676
  if (isDOFEnabled) {
1677
+ console.log("[PostProcess] DOF 启用,参数:", this.postProcessParam.dof);
1672
1678
  if (!this.dofPass) {
1673
1679
  this.dofPass = WebGPUPostProcessFactory.constructDOFPass(this.scenePass, this.postProcessParam.dof);
1680
+ console.log("[PostProcess] DOFPass 构建完成");
1674
1681
  }
1675
1682
  else {
1676
1683
  WebGPUPostProcessFactory.updateDOFPass(this.dofPass, this.postProcessParam.dof);
1684
+ console.log("[PostProcess] DOFPass 更新完成");
1677
1685
  }
1678
1686
  finalNode = this.dofPass;
1679
1687
  }
@@ -1681,32 +1689,41 @@ class Viewport {
1681
1689
  if (this.dofPass) {
1682
1690
  this.dofPass.dispose();
1683
1691
  this.dofPass = null;
1692
+ console.log("[PostProcess] DOFPass 已销毁");
1684
1693
  }
1685
1694
  }
1686
1695
  // ssr
1687
1696
  if (isSSREnabled) {
1697
+ console.log("[PostProcess] SSR 启用,参数:", this.postProcessParam.ssr);
1688
1698
  if (!this.ssrPass) {
1689
1699
  this.ssrPass = WebGPUPostProcessFactory.constructSSRPass(this.scenePass, this.postProcessParam.ssr);
1700
+ console.log("[PostProcess] SSRPass 构建完成");
1690
1701
  }
1691
1702
  else {
1692
1703
  WebGPUPostProcessFactory.updateSSRPass(this.ssrPass, this.postProcessParam.ssr);
1704
+ console.log("[PostProcess] SSRPass 更新完成");
1693
1705
  }
1694
1706
  finalNode = blendColor(finalNode, this.ssrPass);
1695
1707
  }
1696
1708
  // GTAO
1697
1709
  if (isGTAOEnabled) {
1710
+ console.log("[PostProcess] GTAO 启用,参数:", this.postProcessParam.gtao);
1698
1711
  if (!this.GTAOPass) {
1699
1712
  this.GTAOPass = WebGPUPostProcessFactory.constructGTAOPass(this.scenePass, this.postProcessParam.gtao);
1713
+ console.log("[PostProcess] GTAOPass 构建完成");
1700
1714
  }
1701
1715
  else {
1702
1716
  WebGPUPostProcessFactory.updateGTAOPass(this.GTAOPass, this.postProcessParam.gtao);
1717
+ console.log("[PostProcess] GTAOPass 更新完成");
1703
1718
  }
1704
1719
  if (this.postProcessParam.gtao.denoised) {
1705
1720
  if (!this.denoiseGTAOPass) {
1706
1721
  this.denoiseGTAOPass = WebGPUPostProcessFactory.constructGTAODenoisePass(this.scenePass, this.GTAOPass, this.postProcessParam.gtao);
1722
+ console.log("[PostProcess] GTAODenoisePass 构建完成");
1707
1723
  }
1708
1724
  else {
1709
1725
  WebGPUPostProcessFactory.updateGTAOPass(this.GTAOPass, this.postProcessParam.gtao);
1726
+ console.log("[PostProcess] GTAODenoisePass 更新完成");
1710
1727
  }
1711
1728
  finalNode = this.denoiseGTAOPass.mul(finalNode);
1712
1729
  }
@@ -1715,6 +1732,7 @@ class Viewport {
1715
1732
  if (this.denoiseGTAOPass) {
1716
1733
  this.denoiseGTAOPass.dispose();
1717
1734
  this.denoiseGTAOPass = null;
1735
+ console.log("[PostProcess] GTAODenoisePass 已销毁");
1718
1736
  }
1719
1737
  }
1720
1738
  }
@@ -1722,59 +1740,57 @@ class Viewport {
1722
1740
  if (this.GTAOPass) {
1723
1741
  this.GTAOPass.dispose();
1724
1742
  this.GTAOPass = null;
1743
+ console.log("[PostProcess] GTAOPass 已销毁");
1725
1744
  }
1726
1745
  if (this.denoiseGTAOPass) {
1727
1746
  this.denoiseGTAOPass.dispose();
1728
1747
  this.denoiseGTAOPass = null;
1748
+ console.log("[PostProcess] GTAODenoisePass 已销毁");
1729
1749
  }
1730
1750
  }
1731
1751
  // outline
1732
1752
  if (isOutlineEnabled) {
1753
+ console.log("[PostProcess] Outline 启用,参数:", this.postProcessParam.outline);
1733
1754
  if (!this.outlinePass) {
1734
1755
  this.outlinePass = WebGPUPostProcessFactory.constructOutlinePass(this.app.world.scene, this.scenePass.camera, this.outlineObjects, this.postProcessParam.outline);
1756
+ console.log("[PostProcess] OutlinePass 构建完成");
1735
1757
  }
1736
1758
  else {
1737
1759
  WebGPUPostProcessFactory.updateOutlinePass(this.outlinePass, this.outlineObjects, this.postProcessParam.outline);
1760
+ console.log("[PostProcess] OutlinePass 更新完成");
1738
1761
  }
1739
- const { visibleEdge, hiddenEdge } = this.outlinePass;
1740
- const pulsePeriod = uniform(this.postProcessParam.outline.pulsePeriod);
1741
- const period = time.div(pulsePeriod).mul(2);
1742
- const osc = oscSine(period).mul(.5).add(.5);
1743
- const outlineColor = visibleEdge.mul(uniform(new Color(this.postProcessParam.outline.visibleEdgeColor))).add(hiddenEdge.mul(uniform(new Color(this.postProcessParam.outline.hiddenEdgeColor)))).mul(this.postProcessParam.outline.edgeStrength);
1744
- const outlinePulse = pulsePeriod.greaterThan(0).select(outlineColor.mul(osc), outlineColor);
1745
- // if(!this.denoiseOutlinePass)
1746
- // {
1747
- // this.denoiseOutlinePass = WebGPUPostProcessFactory.constructDenoisePass(this.scenePass, outlinePulse, DefaultDenoiseParam);
1748
- // }
1749
- // outlinePulse = this.denoiseOutlinePass.mul(outlinePulse)
1750
- // finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
1751
- finalNode = outlinePulse.add(finalNode);
1752
- // finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
1762
+ // ... existing code ...
1753
1763
  }
1754
1764
  else {
1755
1765
  if (this.outlinePass) {
1756
1766
  this.outlinePass.dispose();
1757
1767
  this.outlinePass = null;
1768
+ console.log("[PostProcess] OutlinePass 已销毁");
1758
1769
  }
1759
1770
  }
1760
1771
  if (isAAEnabled) {
1772
+ console.log("[PostProcess] AA 启用,类型:", this.postProcessParam.aa.type);
1761
1773
  if (this.postProcessParam.aa.type === "fxaa") {
1762
1774
  this.fxaaPass = WebGPUPostProcessFactory.constructFXAAPass(finalNode);
1763
1775
  finalNode = this.fxaaPass;
1776
+ console.log("[PostProcess] FXAAPass 构建完成");
1764
1777
  }
1765
1778
  if (this.postProcessParam.aa.type === "smaa") {
1766
1779
  this.smaaPass = WebGPUPostProcessFactory.constructSMAAPass(finalNode);
1767
1780
  finalNode = this.smaaPass;
1781
+ console.log("[PostProcess] SMAAPass 构建完成");
1768
1782
  }
1769
1783
  }
1770
1784
  else {
1771
1785
  if (this.fxaaPass) {
1772
1786
  this.fxaaPass.dispose();
1773
1787
  this.fxaaPass = null;
1788
+ console.log("[PostProcess] FXAAPass 已销毁");
1774
1789
  }
1775
1790
  if (this.smaaPass) {
1776
1791
  this.smaaPass.dispose();
1777
1792
  this.smaaPass = null;
1793
+ console.log("[PostProcess] SMAAPass 已销毁");
1778
1794
  }
1779
1795
  }
1780
1796
  this.postProcessing.outputNode = finalNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.2.21",
3
+ "version": "1.2.22",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",