lythreeframe 1.2.49 → 1.2.51
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 +105 -51
- package/dist/bundle.esm.js +107 -52
- package/dist/index.d.ts +0 -1
- package/dist/lythreeframe/Frame/Controller.d.ts +0 -1
- package/dist/lythreeframe/Frame/Parameters/AppParameter.d.ts +0 -2
- package/dist/lythreeframe/Frame/Parameters/ViewportParameters.d.ts +0 -1
- package/dist/lythreeframe/Frame/Viewport.d.ts +2 -6
- package/dist/lythreeframe/Object/Components/Curve/CurveComponent.d.ts +35 -0
- package/dist/lythreeframe/Object/Components/Light/AmbientLight/AmbientLightComponent.d.ts +1 -1
- package/package.json +1 -1
package/dist/bundle.cjs.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
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 three = require('three');
|
|
7
6
|
var DepthOfFieldNode_js = require('three/addons/tsl/display/DepthOfFieldNode.js');
|
|
8
7
|
var BloomNode_js = require('three/examples/jsm/tsl/display/BloomNode.js');
|
|
9
8
|
var DenoiseNode_js = require('three/examples/jsm/tsl/display/DenoiseNode.js');
|
|
@@ -12,6 +11,7 @@ var GTAONode_js = require('three/examples/jsm/tsl/display/GTAONode.js');
|
|
|
12
11
|
var OutlineNode_js = require('three/examples/jsm/tsl/display/OutlineNode.js');
|
|
13
12
|
var SMAANode_js = require('three/examples/jsm/tsl/display/SMAANode.js');
|
|
14
13
|
var gsap = require('gsap');
|
|
14
|
+
var three = require('three');
|
|
15
15
|
var SkyMesh_js = require('three/examples/jsm/objects/SkyMesh.js');
|
|
16
16
|
var CSS2DRenderer_js = require('three/examples/jsm/renderers/CSS2DRenderer.js');
|
|
17
17
|
var PointerLockControls_js = require('three/examples/jsm/controls/PointerLockControls.js');
|
|
@@ -1521,12 +1521,7 @@ class Viewport {
|
|
|
1521
1521
|
}
|
|
1522
1522
|
get renderer() {
|
|
1523
1523
|
if (!this._renderer) {
|
|
1524
|
-
|
|
1525
|
-
return this._webGLRenderer;
|
|
1526
|
-
}
|
|
1527
|
-
else {
|
|
1528
|
-
throw Error("Renderer is not initialized");
|
|
1529
|
-
}
|
|
1524
|
+
throw Error("Renderer is not initialized");
|
|
1530
1525
|
}
|
|
1531
1526
|
return this._renderer;
|
|
1532
1527
|
}
|
|
@@ -1539,7 +1534,6 @@ class Viewport {
|
|
|
1539
1534
|
constructor(app, viewportParam, rendererParam, postProcessParam) {
|
|
1540
1535
|
this._uiDom = null;
|
|
1541
1536
|
this._renderer = null;
|
|
1542
|
-
this._webGLRenderer = null;
|
|
1543
1537
|
this.labelRenderer = null;
|
|
1544
1538
|
this._app = null;
|
|
1545
1539
|
this.resizeObserver = null;
|
|
@@ -1553,7 +1547,6 @@ class Viewport {
|
|
|
1553
1547
|
if (viewportParam.elementId) {
|
|
1554
1548
|
this._outerContainer = document.getElementById(viewportParam.elementId);
|
|
1555
1549
|
}
|
|
1556
|
-
this.viewportParam = Object.assign({}, viewportParam);
|
|
1557
1550
|
this.createRenderer(rendererParam);
|
|
1558
1551
|
if (viewportParam.isLabelRendererNeeded) {
|
|
1559
1552
|
this.createLabelRenderer();
|
|
@@ -1602,29 +1595,15 @@ class Viewport {
|
|
|
1602
1595
|
renderP.logarithmicDepthBuffer = rendererParam.logarithmicDepthBuffer;
|
|
1603
1596
|
renderP.samples = rendererParam.samples;
|
|
1604
1597
|
renderP.colorBufferType = rendererParam.colorBufferType;
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
element.appendChild(this._webGLRenderer.domElement);
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
else {
|
|
1618
|
-
this._renderer = new webgpu.WebGPURenderer(renderP);
|
|
1619
|
-
this._renderer.setPixelRatio(window.devicePixelRatio);
|
|
1620
|
-
this._renderer.setSize(width, height);
|
|
1621
|
-
this._renderer.shadowMap.enabled = rendererParam.shadowMapEnabled;
|
|
1622
|
-
this._renderer.shadowMap.type = rendererParam.shadowMapType;
|
|
1623
|
-
this._renderer.toneMapping = rendererParam.toneMapping;
|
|
1624
|
-
this._renderer.toneMappingExposure = rendererParam.toneMappingExposure;
|
|
1625
|
-
if (element) {
|
|
1626
|
-
element.appendChild(this._renderer.domElement);
|
|
1627
|
-
}
|
|
1598
|
+
this._renderer = new webgpu.WebGPURenderer(renderP);
|
|
1599
|
+
this._renderer.setPixelRatio(window.devicePixelRatio);
|
|
1600
|
+
this._renderer.setSize(width, height);
|
|
1601
|
+
this._renderer.shadowMap.enabled = rendererParam.shadowMapEnabled;
|
|
1602
|
+
this._renderer.shadowMap.type = rendererParam.shadowMapType;
|
|
1603
|
+
this._renderer.toneMapping = rendererParam.toneMapping;
|
|
1604
|
+
this._renderer.toneMappingExposure = rendererParam.toneMappingExposure;
|
|
1605
|
+
if (element) {
|
|
1606
|
+
element.appendChild(this._renderer.domElement);
|
|
1628
1607
|
}
|
|
1629
1608
|
}
|
|
1630
1609
|
createLabelRenderer() {
|
|
@@ -1671,7 +1650,97 @@ class Viewport {
|
|
|
1671
1650
|
this.setupPostProcess();
|
|
1672
1651
|
}
|
|
1673
1652
|
setupPostProcess() {
|
|
1674
|
-
|
|
1653
|
+
if (this.postProcessParam.steps.length === 0) {
|
|
1654
|
+
this.destroyPostProcess();
|
|
1655
|
+
this.markRenderStateDirty();
|
|
1656
|
+
return;
|
|
1657
|
+
}
|
|
1658
|
+
if (!this.postProcessing) {
|
|
1659
|
+
this.postProcessing = new webgpu.PostProcessing(this.renderer);
|
|
1660
|
+
}
|
|
1661
|
+
const scenePass = WebGPUPostProcessFactory.constructScenePass(this.app.world.scene, this.app.camera);
|
|
1662
|
+
let finalNode = scenePass.getTextureNode('output');
|
|
1663
|
+
this.postProcessParam.steps.forEach((step) => {
|
|
1664
|
+
switch (step.type) {
|
|
1665
|
+
case exports.PostProcessStepType.Bloom:
|
|
1666
|
+
{
|
|
1667
|
+
const bloomPass = WebGPUPostProcessFactory.constructBloomPass(scenePass, step);
|
|
1668
|
+
//console.log("[PostProcess] BloomPass 构建完成");
|
|
1669
|
+
finalNode = finalNode.add(bloomPass);
|
|
1670
|
+
break;
|
|
1671
|
+
}
|
|
1672
|
+
case exports.PostProcessStepType.DepthOfField:
|
|
1673
|
+
{
|
|
1674
|
+
const dofPass = WebGPUPostProcessFactory.constructDOFPass(scenePass, step);
|
|
1675
|
+
//console.log("[PostProcess] DOFPass 构建完成");
|
|
1676
|
+
finalNode = finalNode.add(dofPass);
|
|
1677
|
+
break;
|
|
1678
|
+
}
|
|
1679
|
+
case exports.PostProcessStepType.ScreenSpaceReflection:
|
|
1680
|
+
{
|
|
1681
|
+
console.warn("[PostProcess] SSR 目前存在技术问题,暂不支持。");
|
|
1682
|
+
// const ssrPass = WebGPUPostProcessFactory.constructSSRPass(scenePass, step as SSRParam);
|
|
1683
|
+
// console.log("[PostProcess] SSRPass 构建完成");
|
|
1684
|
+
//finalNode = blendColor(finalNode, ssrPass);
|
|
1685
|
+
break;
|
|
1686
|
+
}
|
|
1687
|
+
case exports.PostProcessStepType.GroundTruthAmbientOcclusion:
|
|
1688
|
+
{
|
|
1689
|
+
console.warn("[PostProcess] AO 目前存在技术问题,暂不支持。");
|
|
1690
|
+
// const stepParam = step as GTAOParam
|
|
1691
|
+
// const GTAOPass = WebGPUPostProcessFactory.constructGTAOPass(scenePass, stepParam);
|
|
1692
|
+
// console.log("[PostProcess] GTAOPass 构建完成");
|
|
1693
|
+
// if (stepParam.denoised)
|
|
1694
|
+
// {
|
|
1695
|
+
// const denoiseGTAOPass = WebGPUPostProcessFactory.constructGTAODenoisePass(scenePass, GTAOPass, stepParam);
|
|
1696
|
+
// console.log("[PostProcess] GTAODenoisePass 构建完成");
|
|
1697
|
+
// finalNode = denoiseGTAOPass.mul(finalNode);
|
|
1698
|
+
// }
|
|
1699
|
+
// else
|
|
1700
|
+
// {
|
|
1701
|
+
// finalNode = GTAOPass.getTextureNode().mul(finalNode);
|
|
1702
|
+
// }
|
|
1703
|
+
break;
|
|
1704
|
+
}
|
|
1705
|
+
case exports.PostProcessStepType.Outline:
|
|
1706
|
+
{
|
|
1707
|
+
const outlineParam = step;
|
|
1708
|
+
const outlinePass = WebGPUPostProcessFactory.constructOutlinePass(this.app.world.scene, scenePass.camera, this.outlineObjects, outlineParam);
|
|
1709
|
+
const { visibleEdge, hiddenEdge } = outlinePass;
|
|
1710
|
+
const pulsePeriod = tsl.uniform(outlineParam.pulsePeriod);
|
|
1711
|
+
const period = tsl.time.div(pulsePeriod).mul(2);
|
|
1712
|
+
const osc = tsl.oscSine(period).mul(.5).add(.5);
|
|
1713
|
+
const outlineColor = visibleEdge.mul(tsl.uniform(new webgpu.Color(outlineParam.visibleEdgeColor))).add(hiddenEdge.mul(tsl.uniform(new webgpu.Color(outlineParam.hiddenEdgeColor)))).mul(outlineParam.edgeStrength);
|
|
1714
|
+
const outlinePulse = pulsePeriod.greaterThan(0).select(outlineColor.mul(osc), outlineColor);
|
|
1715
|
+
// if(!this.denoiseOutlinePass)
|
|
1716
|
+
// {
|
|
1717
|
+
// this.denoiseOutlinePass = WebGPUPostProcessFactory.constructDenoisePass(this.scenePass, outlinePulse, DefaultDenoiseParam);
|
|
1718
|
+
// }
|
|
1719
|
+
// outlinePulse = this.denoiseOutlinePass.mul(outlinePulse)
|
|
1720
|
+
// finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
|
|
1721
|
+
finalNode = outlinePulse.add(finalNode);
|
|
1722
|
+
//console.log("[PostProcess] OutlinePass 构建完成");
|
|
1723
|
+
break;
|
|
1724
|
+
}
|
|
1725
|
+
case exports.PostProcessStepType.Antialiasing:
|
|
1726
|
+
{
|
|
1727
|
+
const aaParam = step;
|
|
1728
|
+
if (aaParam.method === "fxaa") {
|
|
1729
|
+
finalNode = WebGPUPostProcessFactory.constructFXAAPass(finalNode);
|
|
1730
|
+
//console.log("[PostProcess] FXAAPass 构建完成");
|
|
1731
|
+
}
|
|
1732
|
+
if (aaParam.method === "smaa") {
|
|
1733
|
+
finalNode = WebGPUPostProcessFactory.constructSMAAPass(finalNode);
|
|
1734
|
+
//console.log("[PostProcess] SMAAPass 构建完成");
|
|
1735
|
+
}
|
|
1736
|
+
break;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
});
|
|
1740
|
+
this.postProcessing.outputNode = finalNode;
|
|
1741
|
+
this.postProcessing.needsUpdate = true;
|
|
1742
|
+
//console.log("[PostProcess] setup complete", this.postProcessParam.steps);
|
|
1743
|
+
this.markRenderStateDirty();
|
|
1675
1744
|
}
|
|
1676
1745
|
updatePostProcess(steps) {
|
|
1677
1746
|
this.postProcessParam.steps = steps;
|
|
@@ -1773,13 +1842,7 @@ class Viewport {
|
|
|
1773
1842
|
await this.postProcessing.renderAsync();
|
|
1774
1843
|
}
|
|
1775
1844
|
else {
|
|
1776
|
-
|
|
1777
|
-
await this._renderer.renderAsync(this.app.world.scene, this.app.camera);
|
|
1778
|
-
}
|
|
1779
|
-
else if (this._webGLRenderer) {
|
|
1780
|
-
console.log("render with gl");
|
|
1781
|
-
this._webGLRenderer.render(this.app.world.scene, this.app.camera);
|
|
1782
|
-
}
|
|
1845
|
+
await this.renderer.renderAsync(this.app.world.scene, this.app.camera);
|
|
1783
1846
|
}
|
|
1784
1847
|
// 检查 renderer.domElement 的尺寸
|
|
1785
1848
|
const sourceWidth = this.renderer.domElement.width;
|
|
@@ -2232,14 +2295,6 @@ class Controller {
|
|
|
2232
2295
|
focusTo(targetPos, targetQuat, distance, time, onGoing = null, onFinished = null) {
|
|
2233
2296
|
this.pawn.focusTo(targetPos, targetQuat, distance, time, onGoing, onFinished);
|
|
2234
2297
|
}
|
|
2235
|
-
setPawn(pawn) {
|
|
2236
|
-
if (this._pawn) {
|
|
2237
|
-
this._pawn.unpossess();
|
|
2238
|
-
this._pawn.destroy();
|
|
2239
|
-
}
|
|
2240
|
-
this._pawn = pawn;
|
|
2241
|
-
this._pawn.possess();
|
|
2242
|
-
}
|
|
2243
2298
|
}
|
|
2244
2299
|
|
|
2245
2300
|
class CameraFactory {
|
|
@@ -3082,7 +3137,7 @@ class AmbientLightComponent extends LightComponent {
|
|
|
3082
3137
|
this.threeObject.intensity = intensity;
|
|
3083
3138
|
}
|
|
3084
3139
|
createDefaultObject() {
|
|
3085
|
-
return new
|
|
3140
|
+
return new webgpu.AmbientLight(0xffffff, 10);
|
|
3086
3141
|
}
|
|
3087
3142
|
setPosition(...args) {
|
|
3088
3143
|
if (args.length === 1) {
|
|
@@ -3126,7 +3181,7 @@ class AmbientLightActor extends Actor {
|
|
|
3126
3181
|
}
|
|
3127
3182
|
|
|
3128
3183
|
class BoxComponent extends MeshComponent {
|
|
3129
|
-
constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshStandardMaterial(
|
|
3184
|
+
constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshStandardMaterial(), uuid) {
|
|
3130
3185
|
super(app, new webgpu.BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material, uuid);
|
|
3131
3186
|
}
|
|
3132
3187
|
}
|
|
@@ -3581,7 +3636,6 @@ exports.LevelComponent = LevelComponent;
|
|
|
3581
3636
|
exports.MaterialAssetPointer = MaterialAssetPointer;
|
|
3582
3637
|
exports.MeshComponent = MeshComponent;
|
|
3583
3638
|
exports.Orbital = Orbital;
|
|
3584
|
-
exports.Pawn = Pawn;
|
|
3585
3639
|
exports.PlaneActor = PlaneActor;
|
|
3586
3640
|
exports.PlaneComponent = PlaneComponent;
|
|
3587
3641
|
exports.SceneComponent = SceneComponent;
|
package/dist/bundle.esm.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { MathUtils, Object3D, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, LoadingManager, BufferGeometry, Texture, FileLoader, Material, NearestFilter, WebGPURenderer, Vector2, Raycaster, OrthographicCamera, PerspectiveCamera, 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, OrthographicCamera, PerspectiveCamera, Clock, DirectionalLight, AmbientLight, 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, metalness, transformedNormalView } from 'three/tsl';
|
|
4
|
-
import { WebGLRenderer, PCFSoftShadowMap, Scene, AmbientLight } from 'three';
|
|
3
|
+
import { pass, mrt, output, uniform, metalness, transformedNormalView, time, oscSine } from 'three/tsl';
|
|
5
4
|
import { dof } from 'three/addons/tsl/display/DepthOfFieldNode.js';
|
|
6
5
|
import { bloom } from 'three/examples/jsm/tsl/display/BloomNode.js';
|
|
7
6
|
import { denoise } from 'three/examples/jsm/tsl/display/DenoiseNode.js';
|
|
@@ -10,6 +9,7 @@ import { ao } from 'three/examples/jsm/tsl/display/GTAONode.js';
|
|
|
10
9
|
import { outline } from 'three/examples/jsm/tsl/display/OutlineNode.js';
|
|
11
10
|
import { smaa } from 'three/examples/jsm/tsl/display/SMAANode.js';
|
|
12
11
|
import { gsap } from 'gsap';
|
|
12
|
+
import { Scene } from 'three';
|
|
13
13
|
import { SkyMesh } from 'three/examples/jsm/objects/SkyMesh.js';
|
|
14
14
|
import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
|
|
15
15
|
import { PointerLockControls } from 'three/examples/jsm/controls/PointerLockControls.js';
|
|
@@ -1519,12 +1519,7 @@ class Viewport {
|
|
|
1519
1519
|
}
|
|
1520
1520
|
get renderer() {
|
|
1521
1521
|
if (!this._renderer) {
|
|
1522
|
-
|
|
1523
|
-
return this._webGLRenderer;
|
|
1524
|
-
}
|
|
1525
|
-
else {
|
|
1526
|
-
throw Error("Renderer is not initialized");
|
|
1527
|
-
}
|
|
1522
|
+
throw Error("Renderer is not initialized");
|
|
1528
1523
|
}
|
|
1529
1524
|
return this._renderer;
|
|
1530
1525
|
}
|
|
@@ -1537,7 +1532,6 @@ class Viewport {
|
|
|
1537
1532
|
constructor(app, viewportParam, rendererParam, postProcessParam) {
|
|
1538
1533
|
this._uiDom = null;
|
|
1539
1534
|
this._renderer = null;
|
|
1540
|
-
this._webGLRenderer = null;
|
|
1541
1535
|
this.labelRenderer = null;
|
|
1542
1536
|
this._app = null;
|
|
1543
1537
|
this.resizeObserver = null;
|
|
@@ -1551,7 +1545,6 @@ class Viewport {
|
|
|
1551
1545
|
if (viewportParam.elementId) {
|
|
1552
1546
|
this._outerContainer = document.getElementById(viewportParam.elementId);
|
|
1553
1547
|
}
|
|
1554
|
-
this.viewportParam = Object.assign({}, viewportParam);
|
|
1555
1548
|
this.createRenderer(rendererParam);
|
|
1556
1549
|
if (viewportParam.isLabelRendererNeeded) {
|
|
1557
1550
|
this.createLabelRenderer();
|
|
@@ -1600,29 +1593,15 @@ class Viewport {
|
|
|
1600
1593
|
renderP.logarithmicDepthBuffer = rendererParam.logarithmicDepthBuffer;
|
|
1601
1594
|
renderP.samples = rendererParam.samples;
|
|
1602
1595
|
renderP.colorBufferType = rendererParam.colorBufferType;
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
element.appendChild(this._webGLRenderer.domElement);
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
else {
|
|
1616
|
-
this._renderer = new WebGPURenderer(renderP);
|
|
1617
|
-
this._renderer.setPixelRatio(window.devicePixelRatio);
|
|
1618
|
-
this._renderer.setSize(width, height);
|
|
1619
|
-
this._renderer.shadowMap.enabled = rendererParam.shadowMapEnabled;
|
|
1620
|
-
this._renderer.shadowMap.type = rendererParam.shadowMapType;
|
|
1621
|
-
this._renderer.toneMapping = rendererParam.toneMapping;
|
|
1622
|
-
this._renderer.toneMappingExposure = rendererParam.toneMappingExposure;
|
|
1623
|
-
if (element) {
|
|
1624
|
-
element.appendChild(this._renderer.domElement);
|
|
1625
|
-
}
|
|
1596
|
+
this._renderer = new WebGPURenderer(renderP);
|
|
1597
|
+
this._renderer.setPixelRatio(window.devicePixelRatio);
|
|
1598
|
+
this._renderer.setSize(width, height);
|
|
1599
|
+
this._renderer.shadowMap.enabled = rendererParam.shadowMapEnabled;
|
|
1600
|
+
this._renderer.shadowMap.type = rendererParam.shadowMapType;
|
|
1601
|
+
this._renderer.toneMapping = rendererParam.toneMapping;
|
|
1602
|
+
this._renderer.toneMappingExposure = rendererParam.toneMappingExposure;
|
|
1603
|
+
if (element) {
|
|
1604
|
+
element.appendChild(this._renderer.domElement);
|
|
1626
1605
|
}
|
|
1627
1606
|
}
|
|
1628
1607
|
createLabelRenderer() {
|
|
@@ -1669,7 +1648,97 @@ class Viewport {
|
|
|
1669
1648
|
this.setupPostProcess();
|
|
1670
1649
|
}
|
|
1671
1650
|
setupPostProcess() {
|
|
1672
|
-
|
|
1651
|
+
if (this.postProcessParam.steps.length === 0) {
|
|
1652
|
+
this.destroyPostProcess();
|
|
1653
|
+
this.markRenderStateDirty();
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1656
|
+
if (!this.postProcessing) {
|
|
1657
|
+
this.postProcessing = new PostProcessing(this.renderer);
|
|
1658
|
+
}
|
|
1659
|
+
const scenePass = WebGPUPostProcessFactory.constructScenePass(this.app.world.scene, this.app.camera);
|
|
1660
|
+
let finalNode = scenePass.getTextureNode('output');
|
|
1661
|
+
this.postProcessParam.steps.forEach((step) => {
|
|
1662
|
+
switch (step.type) {
|
|
1663
|
+
case PostProcessStepType.Bloom:
|
|
1664
|
+
{
|
|
1665
|
+
const bloomPass = WebGPUPostProcessFactory.constructBloomPass(scenePass, step);
|
|
1666
|
+
//console.log("[PostProcess] BloomPass 构建完成");
|
|
1667
|
+
finalNode = finalNode.add(bloomPass);
|
|
1668
|
+
break;
|
|
1669
|
+
}
|
|
1670
|
+
case PostProcessStepType.DepthOfField:
|
|
1671
|
+
{
|
|
1672
|
+
const dofPass = WebGPUPostProcessFactory.constructDOFPass(scenePass, step);
|
|
1673
|
+
//console.log("[PostProcess] DOFPass 构建完成");
|
|
1674
|
+
finalNode = finalNode.add(dofPass);
|
|
1675
|
+
break;
|
|
1676
|
+
}
|
|
1677
|
+
case PostProcessStepType.ScreenSpaceReflection:
|
|
1678
|
+
{
|
|
1679
|
+
console.warn("[PostProcess] SSR 目前存在技术问题,暂不支持。");
|
|
1680
|
+
// const ssrPass = WebGPUPostProcessFactory.constructSSRPass(scenePass, step as SSRParam);
|
|
1681
|
+
// console.log("[PostProcess] SSRPass 构建完成");
|
|
1682
|
+
//finalNode = blendColor(finalNode, ssrPass);
|
|
1683
|
+
break;
|
|
1684
|
+
}
|
|
1685
|
+
case PostProcessStepType.GroundTruthAmbientOcclusion:
|
|
1686
|
+
{
|
|
1687
|
+
console.warn("[PostProcess] AO 目前存在技术问题,暂不支持。");
|
|
1688
|
+
// const stepParam = step as GTAOParam
|
|
1689
|
+
// const GTAOPass = WebGPUPostProcessFactory.constructGTAOPass(scenePass, stepParam);
|
|
1690
|
+
// console.log("[PostProcess] GTAOPass 构建完成");
|
|
1691
|
+
// if (stepParam.denoised)
|
|
1692
|
+
// {
|
|
1693
|
+
// const denoiseGTAOPass = WebGPUPostProcessFactory.constructGTAODenoisePass(scenePass, GTAOPass, stepParam);
|
|
1694
|
+
// console.log("[PostProcess] GTAODenoisePass 构建完成");
|
|
1695
|
+
// finalNode = denoiseGTAOPass.mul(finalNode);
|
|
1696
|
+
// }
|
|
1697
|
+
// else
|
|
1698
|
+
// {
|
|
1699
|
+
// finalNode = GTAOPass.getTextureNode().mul(finalNode);
|
|
1700
|
+
// }
|
|
1701
|
+
break;
|
|
1702
|
+
}
|
|
1703
|
+
case PostProcessStepType.Outline:
|
|
1704
|
+
{
|
|
1705
|
+
const outlineParam = step;
|
|
1706
|
+
const outlinePass = WebGPUPostProcessFactory.constructOutlinePass(this.app.world.scene, scenePass.camera, this.outlineObjects, outlineParam);
|
|
1707
|
+
const { visibleEdge, hiddenEdge } = outlinePass;
|
|
1708
|
+
const pulsePeriod = uniform(outlineParam.pulsePeriod);
|
|
1709
|
+
const period = time.div(pulsePeriod).mul(2);
|
|
1710
|
+
const osc = oscSine(period).mul(.5).add(.5);
|
|
1711
|
+
const outlineColor = visibleEdge.mul(uniform(new Color(outlineParam.visibleEdgeColor))).add(hiddenEdge.mul(uniform(new Color(outlineParam.hiddenEdgeColor)))).mul(outlineParam.edgeStrength);
|
|
1712
|
+
const outlinePulse = pulsePeriod.greaterThan(0).select(outlineColor.mul(osc), outlineColor);
|
|
1713
|
+
// if(!this.denoiseOutlinePass)
|
|
1714
|
+
// {
|
|
1715
|
+
// this.denoiseOutlinePass = WebGPUPostProcessFactory.constructDenoisePass(this.scenePass, outlinePulse, DefaultDenoiseParam);
|
|
1716
|
+
// }
|
|
1717
|
+
// outlinePulse = this.denoiseOutlinePass.mul(outlinePulse)
|
|
1718
|
+
// finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
|
|
1719
|
+
finalNode = outlinePulse.add(finalNode);
|
|
1720
|
+
//console.log("[PostProcess] OutlinePass 构建完成");
|
|
1721
|
+
break;
|
|
1722
|
+
}
|
|
1723
|
+
case PostProcessStepType.Antialiasing:
|
|
1724
|
+
{
|
|
1725
|
+
const aaParam = step;
|
|
1726
|
+
if (aaParam.method === "fxaa") {
|
|
1727
|
+
finalNode = WebGPUPostProcessFactory.constructFXAAPass(finalNode);
|
|
1728
|
+
//console.log("[PostProcess] FXAAPass 构建完成");
|
|
1729
|
+
}
|
|
1730
|
+
if (aaParam.method === "smaa") {
|
|
1731
|
+
finalNode = WebGPUPostProcessFactory.constructSMAAPass(finalNode);
|
|
1732
|
+
//console.log("[PostProcess] SMAAPass 构建完成");
|
|
1733
|
+
}
|
|
1734
|
+
break;
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
});
|
|
1738
|
+
this.postProcessing.outputNode = finalNode;
|
|
1739
|
+
this.postProcessing.needsUpdate = true;
|
|
1740
|
+
//console.log("[PostProcess] setup complete", this.postProcessParam.steps);
|
|
1741
|
+
this.markRenderStateDirty();
|
|
1673
1742
|
}
|
|
1674
1743
|
updatePostProcess(steps) {
|
|
1675
1744
|
this.postProcessParam.steps = steps;
|
|
@@ -1771,13 +1840,7 @@ class Viewport {
|
|
|
1771
1840
|
await this.postProcessing.renderAsync();
|
|
1772
1841
|
}
|
|
1773
1842
|
else {
|
|
1774
|
-
|
|
1775
|
-
await this._renderer.renderAsync(this.app.world.scene, this.app.camera);
|
|
1776
|
-
}
|
|
1777
|
-
else if (this._webGLRenderer) {
|
|
1778
|
-
console.log("render with gl");
|
|
1779
|
-
this._webGLRenderer.render(this.app.world.scene, this.app.camera);
|
|
1780
|
-
}
|
|
1843
|
+
await this.renderer.renderAsync(this.app.world.scene, this.app.camera);
|
|
1781
1844
|
}
|
|
1782
1845
|
// 检查 renderer.domElement 的尺寸
|
|
1783
1846
|
const sourceWidth = this.renderer.domElement.width;
|
|
@@ -2230,14 +2293,6 @@ class Controller {
|
|
|
2230
2293
|
focusTo(targetPos, targetQuat, distance, time, onGoing = null, onFinished = null) {
|
|
2231
2294
|
this.pawn.focusTo(targetPos, targetQuat, distance, time, onGoing, onFinished);
|
|
2232
2295
|
}
|
|
2233
|
-
setPawn(pawn) {
|
|
2234
|
-
if (this._pawn) {
|
|
2235
|
-
this._pawn.unpossess();
|
|
2236
|
-
this._pawn.destroy();
|
|
2237
|
-
}
|
|
2238
|
-
this._pawn = pawn;
|
|
2239
|
-
this._pawn.possess();
|
|
2240
|
-
}
|
|
2241
2296
|
}
|
|
2242
2297
|
|
|
2243
2298
|
class CameraFactory {
|
|
@@ -3124,7 +3179,7 @@ class AmbientLightActor extends Actor {
|
|
|
3124
3179
|
}
|
|
3125
3180
|
|
|
3126
3181
|
class BoxComponent extends MeshComponent {
|
|
3127
|
-
constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new MeshStandardMaterial(
|
|
3182
|
+
constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new MeshStandardMaterial(), uuid) {
|
|
3128
3183
|
super(app, new BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material, uuid);
|
|
3129
3184
|
}
|
|
3130
3185
|
}
|
|
@@ -3545,4 +3600,4 @@ class TransformGizmo extends Pawn {
|
|
|
3545
3600
|
}
|
|
3546
3601
|
}
|
|
3547
3602
|
|
|
3548
|
-
export { Actor, AmbientLightActor, AmbientLightComponent, AssetManager, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAAParams, DefaultAppParam, DefaultBloomParam, DefaultCameraParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOrthographicCameraParam, DefaultOutlineParams, DefaultPerspectiveCameraParam, DefaultPostProcessParam, DefaultRendererParameters, DefaultSSRParam, DefaultSkyParam, DefaultViewportParam, DefaultWorldParam, Delegate, DirectionalLightActor, DirectionalLightComponent, FirstPerson, GeometryAssetPointer, LabelComponent, LevelActor, LevelComponent, MaterialAssetPointer, MeshComponent, Orbital,
|
|
3603
|
+
export { Actor, AmbientLightActor, AmbientLightComponent, AssetManager, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAAParams, DefaultAppParam, DefaultBloomParam, DefaultCameraParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOrthographicCameraParam, DefaultOutlineParams, DefaultPerspectiveCameraParam, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -58,7 +58,6 @@ export { DefaultSSRParam } from "./lythreeframe/PostProcess/Param/SSR";
|
|
|
58
58
|
export type { SSRParam } from "./lythreeframe/PostProcess/Param/SSR";
|
|
59
59
|
export { DefaultAAParams } from "./lythreeframe/PostProcess/Param/AAParam";
|
|
60
60
|
export type { AAParams } from "./lythreeframe/PostProcess/Param/AAParam";
|
|
61
|
-
export { Pawn } from "./lythreeframe/Object/PawnV2/Pawn";
|
|
62
61
|
export { Orbital } from "./lythreeframe/Object/PawnV2/Oribital";
|
|
63
62
|
export { FirstPerson } from "./lythreeframe/Object/PawnV2/FirstPerson";
|
|
64
63
|
export type { ITransforming } from "./lythreeframe/Object/PawnV2/TransformControl";
|
|
@@ -40,5 +40,4 @@ export declare class Controller {
|
|
|
40
40
|
getHitResultUnderCursor(): Intersection | null;
|
|
41
41
|
getHitResultFromScreenPoint(x: number, y: number): Intersection | null;
|
|
42
42
|
focusTo(targetPos: Vector3, targetQuat: Quaternion | Euler, distance: number, time: number, onGoing?: (() => void) | null, onFinished?: (() => void) | null): void;
|
|
43
|
-
setPawn(pawn: Pawn): void;
|
|
44
43
|
}
|
|
@@ -7,7 +7,6 @@ import { ViewportParam } from "./ViewportParameters";
|
|
|
7
7
|
import { AssetManager } from "../../AssetManagement/AssetManager";
|
|
8
8
|
import { PostProcessParam } from "../../PostProcess/PostProcessParam";
|
|
9
9
|
import { RendererParameters } from "./RendererParameters";
|
|
10
|
-
import { ControllerParameters } from "./ControllerParameters";
|
|
11
10
|
export interface AppClass {
|
|
12
11
|
assetManagerClass: typeof AssetManager;
|
|
13
12
|
controllerClass: typeof Controller;
|
|
@@ -20,7 +19,6 @@ export interface AppParam {
|
|
|
20
19
|
postProcessParam?: PostProcessParam;
|
|
21
20
|
worldParam?: WorldParam;
|
|
22
21
|
viewportParam: ViewportParam;
|
|
23
|
-
controllerParam?: ControllerParameters;
|
|
24
22
|
classes?: AppClass;
|
|
25
23
|
isRenderEveryFrame?: boolean;
|
|
26
24
|
}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { WebGPURenderer } from "three/webgpu";
|
|
1
|
+
import { ShadowMapType, ToneMapping, WebGPURenderer, Object3D } from "three/webgpu";
|
|
3
2
|
import { ThreeJsApp } from "../ThreeJsApp";
|
|
4
3
|
import { PostProcessParam, PostProcessStepParam } from './../PostProcess/PostProcessParam';
|
|
5
4
|
import { RendererParameters } from './Parameters/RendererParameters';
|
|
6
5
|
import { ViewportParam } from './Parameters/ViewportParameters';
|
|
7
|
-
import { WebGLRenderer } from "three";
|
|
8
6
|
export declare class Viewport {
|
|
9
7
|
get uiDom(): HTMLDivElement | null;
|
|
10
8
|
protected _uiDom: HTMLDivElement | null;
|
|
11
9
|
get canvas(): HTMLElement | null;
|
|
12
10
|
get outer(): HTMLElement | null;
|
|
13
|
-
get renderer(): WebGPURenderer
|
|
11
|
+
get renderer(): WebGPURenderer;
|
|
14
12
|
get app(): ThreeJsApp;
|
|
15
13
|
private _renderer;
|
|
16
|
-
private _webGLRenderer;
|
|
17
14
|
private labelRenderer;
|
|
18
15
|
protected _app: ThreeJsApp | null;
|
|
19
16
|
private resizeObserver;
|
|
@@ -22,7 +19,6 @@ export declare class Viewport {
|
|
|
22
19
|
private isRenderStateDirty;
|
|
23
20
|
private postProcessParam;
|
|
24
21
|
private postProcessing;
|
|
25
|
-
private viewportParam;
|
|
26
22
|
private outlineObjects;
|
|
27
23
|
constructor(app: ThreeJsApp, viewportParam: ViewportParam, rendererParam: RendererParameters, postProcessParam: PostProcessParam);
|
|
28
24
|
protected createRenderer(rendererParam: RendererParameters): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ThreeJsApp } from 'lythreeframe/lythreeframe/ThreeJsApp';
|
|
2
|
+
import { SceneComponent } from './../SceneComponent';
|
|
3
|
+
import { CatmullRomCurve3, ColorRepresentation, Line, LineBasicMaterial, Vector3 } from 'three';
|
|
4
|
+
export interface CurveComponetSetup {
|
|
5
|
+
type?: 'centripetal' | 'chordal' | 'catmullrom';
|
|
6
|
+
tension?: number;
|
|
7
|
+
closed?: boolean;
|
|
8
|
+
color?: ColorRepresentation;
|
|
9
|
+
}
|
|
10
|
+
export declare class CurveComponent extends SceneComponent {
|
|
11
|
+
private points;
|
|
12
|
+
private curve;
|
|
13
|
+
private closed;
|
|
14
|
+
private curveType;
|
|
15
|
+
private tension;
|
|
16
|
+
private bCreateLine;
|
|
17
|
+
private sourcePoints;
|
|
18
|
+
get threeObject(): Line;
|
|
19
|
+
protected set threeObject(newThreeObject: Line);
|
|
20
|
+
get material(): LineBasicMaterial;
|
|
21
|
+
constructor(app: ThreeJsApp, points: Vector3[], setup?: CurveComponetSetup, bCreateLine?: boolean, uuid?: string);
|
|
22
|
+
isValid(): boolean;
|
|
23
|
+
protected createDefaultObject(): Line;
|
|
24
|
+
resetPoints(points: Vector3[]): void;
|
|
25
|
+
createLine(): void;
|
|
26
|
+
destroy(): void;
|
|
27
|
+
get SourcePoints(): Vector3[];
|
|
28
|
+
get Curve(): CatmullRomCurve3;
|
|
29
|
+
get Points(): Vector3[];
|
|
30
|
+
getPointAt(u: number): Vector3;
|
|
31
|
+
getTangentAt(u: number): Vector3;
|
|
32
|
+
getWorldPointAt(u: number): Vector3;
|
|
33
|
+
getWorldTangentAt(u: number): Vector3;
|
|
34
|
+
getLength(): number;
|
|
35
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LightComponent } from "../LightComponent";
|
|
2
|
-
import { ColorRepresentation, AmbientLight, Vector3 } from "three";
|
|
2
|
+
import { ColorRepresentation, AmbientLight, Vector3 } from "three/webgpu";
|
|
3
3
|
import { World } from "../../../../Frame/World";
|
|
4
4
|
import { ThreeJsApp } from "../../../../ThreeJsApp";
|
|
5
5
|
export declare class AmbientLightComponent extends LightComponent {
|