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