lythreeframe 1.2.47 → 1.2.49
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 +54 -106
- package/dist/bundle.esm.js +55 -108
- package/dist/index.d.ts +1 -0
- package/dist/lythreeframe/Frame/Controller.d.ts +1 -0
- package/dist/lythreeframe/Frame/Parameters/AppParameter.d.ts +2 -0
- package/dist/lythreeframe/Frame/Parameters/ControllerParameters.d.ts +2 -0
- package/dist/lythreeframe/Frame/Parameters/ViewportParameters.d.ts +1 -0
- package/dist/lythreeframe/Frame/Viewport.d.ts +6 -2
- package/dist/lythreeframe/Object/Components/Light/AmbientLight/AmbientLightComponent.d.ts +1 -1
- package/package.json +1 -1
package/dist/bundle.cjs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
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');
|
|
6
7
|
var DepthOfFieldNode_js = require('three/addons/tsl/display/DepthOfFieldNode.js');
|
|
7
8
|
var BloomNode_js = require('three/examples/jsm/tsl/display/BloomNode.js');
|
|
8
9
|
var DenoiseNode_js = require('three/examples/jsm/tsl/display/DenoiseNode.js');
|
|
@@ -11,7 +12,6 @@ var GTAONode_js = require('three/examples/jsm/tsl/display/GTAONode.js');
|
|
|
11
12
|
var OutlineNode_js = require('three/examples/jsm/tsl/display/OutlineNode.js');
|
|
12
13
|
var SMAANode_js = require('three/examples/jsm/tsl/display/SMAANode.js');
|
|
13
14
|
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');
|
|
@@ -645,7 +645,7 @@ class SceneComponent extends Component {
|
|
|
645
645
|
throw Error("targetComponent threeObject is invalid");
|
|
646
646
|
}
|
|
647
647
|
this.obj.remove(targetComponent.threeObject);
|
|
648
|
-
targetComponent.destroy();
|
|
648
|
+
// targetComponent.destroy();
|
|
649
649
|
}
|
|
650
650
|
detachFromParentComponent() {
|
|
651
651
|
if (this.parentComponent) {
|
|
@@ -1148,6 +1148,7 @@ class AssetManager {
|
|
|
1148
1148
|
}
|
|
1149
1149
|
}
|
|
1150
1150
|
async loadGltfFromPathAsync(path) {
|
|
1151
|
+
this.setupDracoLoader("/SceneResource/draco/");
|
|
1151
1152
|
let res = await this.gltfLoader.loadAsync(path);
|
|
1152
1153
|
return res;
|
|
1153
1154
|
}
|
|
@@ -1155,6 +1156,7 @@ class AssetManager {
|
|
|
1155
1156
|
this.gltfLoader.load(path, onLoadFinished);
|
|
1156
1157
|
}
|
|
1157
1158
|
loadGltfFromBuffer(data, path, onLoadFinished) {
|
|
1159
|
+
this.setupDracoLoader("/SceneResource/draco/");
|
|
1158
1160
|
this.gltfLoader.parse(data, path, onLoadFinished);
|
|
1159
1161
|
}
|
|
1160
1162
|
loadFile(filepath = '', onLoadFinished) {
|
|
@@ -1519,7 +1521,12 @@ class Viewport {
|
|
|
1519
1521
|
}
|
|
1520
1522
|
get renderer() {
|
|
1521
1523
|
if (!this._renderer) {
|
|
1522
|
-
|
|
1524
|
+
if (this._webGLRenderer) {
|
|
1525
|
+
return this._webGLRenderer;
|
|
1526
|
+
}
|
|
1527
|
+
else {
|
|
1528
|
+
throw Error("Renderer is not initialized");
|
|
1529
|
+
}
|
|
1523
1530
|
}
|
|
1524
1531
|
return this._renderer;
|
|
1525
1532
|
}
|
|
@@ -1532,6 +1539,7 @@ class Viewport {
|
|
|
1532
1539
|
constructor(app, viewportParam, rendererParam, postProcessParam) {
|
|
1533
1540
|
this._uiDom = null;
|
|
1534
1541
|
this._renderer = null;
|
|
1542
|
+
this._webGLRenderer = null;
|
|
1535
1543
|
this.labelRenderer = null;
|
|
1536
1544
|
this._app = null;
|
|
1537
1545
|
this.resizeObserver = null;
|
|
@@ -1545,6 +1553,7 @@ class Viewport {
|
|
|
1545
1553
|
if (viewportParam.elementId) {
|
|
1546
1554
|
this._outerContainer = document.getElementById(viewportParam.elementId);
|
|
1547
1555
|
}
|
|
1556
|
+
this.viewportParam = Object.assign({}, viewportParam);
|
|
1548
1557
|
this.createRenderer(rendererParam);
|
|
1549
1558
|
if (viewportParam.isLabelRendererNeeded) {
|
|
1550
1559
|
this.createLabelRenderer();
|
|
@@ -1593,15 +1602,29 @@ class Viewport {
|
|
|
1593
1602
|
renderP.logarithmicDepthBuffer = rendererParam.logarithmicDepthBuffer;
|
|
1594
1603
|
renderP.samples = rendererParam.samples;
|
|
1595
1604
|
renderP.colorBufferType = rendererParam.colorBufferType;
|
|
1596
|
-
this.
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
element
|
|
1605
|
+
if (this.viewportParam.usingWebGLRenderer) {
|
|
1606
|
+
this._webGLRenderer = new three.WebGLRenderer();
|
|
1607
|
+
this._webGLRenderer.setPixelRatio(window.devicePixelRatio);
|
|
1608
|
+
this._webGLRenderer.setSize(width, height);
|
|
1609
|
+
this._webGLRenderer.shadowMap.enabled = rendererParam.shadowMapEnabled;
|
|
1610
|
+
this._webGLRenderer.shadowMap.type = rendererParam.shadowMapType ? rendererParam.shadowMapType : three.PCFSoftShadowMap;
|
|
1611
|
+
this._webGLRenderer.toneMapping = rendererParam.toneMapping;
|
|
1612
|
+
this._webGLRenderer.toneMappingExposure = rendererParam.toneMappingExposure;
|
|
1613
|
+
if (element) {
|
|
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
|
+
}
|
|
1605
1628
|
}
|
|
1606
1629
|
}
|
|
1607
1630
|
createLabelRenderer() {
|
|
@@ -1648,97 +1671,7 @@ class Viewport {
|
|
|
1648
1671
|
this.setupPostProcess();
|
|
1649
1672
|
}
|
|
1650
1673
|
setupPostProcess() {
|
|
1651
|
-
|
|
1652
|
-
this.destroyPostProcess();
|
|
1653
|
-
this.markRenderStateDirty();
|
|
1654
|
-
return;
|
|
1655
|
-
}
|
|
1656
|
-
if (!this.postProcessing) {
|
|
1657
|
-
this.postProcessing = new webgpu.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 exports.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 exports.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 exports.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 exports.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 exports.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 = tsl.uniform(outlineParam.pulsePeriod);
|
|
1709
|
-
const period = tsl.time.div(pulsePeriod).mul(2);
|
|
1710
|
-
const osc = tsl.oscSine(period).mul(.5).add(.5);
|
|
1711
|
-
const outlineColor = visibleEdge.mul(tsl.uniform(new webgpu.Color(outlineParam.visibleEdgeColor))).add(hiddenEdge.mul(tsl.uniform(new webgpu.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 exports.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();
|
|
1674
|
+
return;
|
|
1742
1675
|
}
|
|
1743
1676
|
updatePostProcess(steps) {
|
|
1744
1677
|
this.postProcessParam.steps = steps;
|
|
@@ -1840,7 +1773,13 @@ class Viewport {
|
|
|
1840
1773
|
await this.postProcessing.renderAsync();
|
|
1841
1774
|
}
|
|
1842
1775
|
else {
|
|
1843
|
-
|
|
1776
|
+
if (this._renderer) {
|
|
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
|
+
}
|
|
1844
1783
|
}
|
|
1845
1784
|
// 检查 renderer.domElement 的尺寸
|
|
1846
1785
|
const sourceWidth = this.renderer.domElement.width;
|
|
@@ -2293,6 +2232,14 @@ class Controller {
|
|
|
2293
2232
|
focusTo(targetPos, targetQuat, distance, time, onGoing = null, onFinished = null) {
|
|
2294
2233
|
this.pawn.focusTo(targetPos, targetQuat, distance, time, onGoing, onFinished);
|
|
2295
2234
|
}
|
|
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
|
+
}
|
|
2296
2243
|
}
|
|
2297
2244
|
|
|
2298
2245
|
class CameraFactory {
|
|
@@ -3135,7 +3082,7 @@ class AmbientLightComponent extends LightComponent {
|
|
|
3135
3082
|
this.threeObject.intensity = intensity;
|
|
3136
3083
|
}
|
|
3137
3084
|
createDefaultObject() {
|
|
3138
|
-
return new
|
|
3085
|
+
return new three.AmbientLight(0xffffff, 10);
|
|
3139
3086
|
}
|
|
3140
3087
|
setPosition(...args) {
|
|
3141
3088
|
if (args.length === 1) {
|
|
@@ -3179,7 +3126,7 @@ class AmbientLightActor extends Actor {
|
|
|
3179
3126
|
}
|
|
3180
3127
|
|
|
3181
3128
|
class BoxComponent extends MeshComponent {
|
|
3182
|
-
constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshStandardMaterial(), uuid) {
|
|
3129
|
+
constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshStandardMaterial({ color: 0x00ff00 }), uuid) {
|
|
3183
3130
|
super(app, new webgpu.BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material, uuid);
|
|
3184
3131
|
}
|
|
3185
3132
|
}
|
|
@@ -3634,6 +3581,7 @@ exports.LevelComponent = LevelComponent;
|
|
|
3634
3581
|
exports.MaterialAssetPointer = MaterialAssetPointer;
|
|
3635
3582
|
exports.MeshComponent = MeshComponent;
|
|
3636
3583
|
exports.Orbital = Orbital;
|
|
3584
|
+
exports.Pawn = Pawn;
|
|
3637
3585
|
exports.PlaneActor = PlaneActor;
|
|
3638
3586
|
exports.PlaneComponent = PlaneComponent;
|
|
3639
3587
|
exports.SceneComponent = SceneComponent;
|
package/dist/bundle.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { MathUtils, Object3D, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, LoadingManager, BufferGeometry, Texture, FileLoader, Material, NearestFilter, WebGPURenderer,
|
|
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';
|
|
2
2
|
import { GLTFLoader, DRACOLoader, CSS2DRenderer, OrbitControls } from 'three/examples/jsm/Addons.js';
|
|
3
|
-
import { pass, mrt, output, uniform, metalness, transformedNormalView
|
|
3
|
+
import { pass, mrt, output, uniform, metalness, transformedNormalView } from 'three/tsl';
|
|
4
|
+
import { WebGLRenderer, PCFSoftShadowMap, Scene, AmbientLight } from 'three';
|
|
4
5
|
import { dof } from 'three/addons/tsl/display/DepthOfFieldNode.js';
|
|
5
6
|
import { bloom } from 'three/examples/jsm/tsl/display/BloomNode.js';
|
|
6
7
|
import { denoise } from 'three/examples/jsm/tsl/display/DenoiseNode.js';
|
|
@@ -9,7 +10,6 @@ import { ao } from 'three/examples/jsm/tsl/display/GTAONode.js';
|
|
|
9
10
|
import { outline } from 'three/examples/jsm/tsl/display/OutlineNode.js';
|
|
10
11
|
import { smaa } from 'three/examples/jsm/tsl/display/SMAANode.js';
|
|
11
12
|
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';
|
|
@@ -643,7 +643,7 @@ class SceneComponent extends Component {
|
|
|
643
643
|
throw Error("targetComponent threeObject is invalid");
|
|
644
644
|
}
|
|
645
645
|
this.obj.remove(targetComponent.threeObject);
|
|
646
|
-
targetComponent.destroy();
|
|
646
|
+
// targetComponent.destroy();
|
|
647
647
|
}
|
|
648
648
|
detachFromParentComponent() {
|
|
649
649
|
if (this.parentComponent) {
|
|
@@ -1146,6 +1146,7 @@ class AssetManager {
|
|
|
1146
1146
|
}
|
|
1147
1147
|
}
|
|
1148
1148
|
async loadGltfFromPathAsync(path) {
|
|
1149
|
+
this.setupDracoLoader("/SceneResource/draco/");
|
|
1149
1150
|
let res = await this.gltfLoader.loadAsync(path);
|
|
1150
1151
|
return res;
|
|
1151
1152
|
}
|
|
@@ -1153,6 +1154,7 @@ class AssetManager {
|
|
|
1153
1154
|
this.gltfLoader.load(path, onLoadFinished);
|
|
1154
1155
|
}
|
|
1155
1156
|
loadGltfFromBuffer(data, path, onLoadFinished) {
|
|
1157
|
+
this.setupDracoLoader("/SceneResource/draco/");
|
|
1156
1158
|
this.gltfLoader.parse(data, path, onLoadFinished);
|
|
1157
1159
|
}
|
|
1158
1160
|
loadFile(filepath = '', onLoadFinished) {
|
|
@@ -1517,7 +1519,12 @@ class Viewport {
|
|
|
1517
1519
|
}
|
|
1518
1520
|
get renderer() {
|
|
1519
1521
|
if (!this._renderer) {
|
|
1520
|
-
|
|
1522
|
+
if (this._webGLRenderer) {
|
|
1523
|
+
return this._webGLRenderer;
|
|
1524
|
+
}
|
|
1525
|
+
else {
|
|
1526
|
+
throw Error("Renderer is not initialized");
|
|
1527
|
+
}
|
|
1521
1528
|
}
|
|
1522
1529
|
return this._renderer;
|
|
1523
1530
|
}
|
|
@@ -1530,6 +1537,7 @@ class Viewport {
|
|
|
1530
1537
|
constructor(app, viewportParam, rendererParam, postProcessParam) {
|
|
1531
1538
|
this._uiDom = null;
|
|
1532
1539
|
this._renderer = null;
|
|
1540
|
+
this._webGLRenderer = null;
|
|
1533
1541
|
this.labelRenderer = null;
|
|
1534
1542
|
this._app = null;
|
|
1535
1543
|
this.resizeObserver = null;
|
|
@@ -1543,6 +1551,7 @@ class Viewport {
|
|
|
1543
1551
|
if (viewportParam.elementId) {
|
|
1544
1552
|
this._outerContainer = document.getElementById(viewportParam.elementId);
|
|
1545
1553
|
}
|
|
1554
|
+
this.viewportParam = Object.assign({}, viewportParam);
|
|
1546
1555
|
this.createRenderer(rendererParam);
|
|
1547
1556
|
if (viewportParam.isLabelRendererNeeded) {
|
|
1548
1557
|
this.createLabelRenderer();
|
|
@@ -1591,15 +1600,29 @@ class Viewport {
|
|
|
1591
1600
|
renderP.logarithmicDepthBuffer = rendererParam.logarithmicDepthBuffer;
|
|
1592
1601
|
renderP.samples = rendererParam.samples;
|
|
1593
1602
|
renderP.colorBufferType = rendererParam.colorBufferType;
|
|
1594
|
-
this.
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
element
|
|
1603
|
+
if (this.viewportParam.usingWebGLRenderer) {
|
|
1604
|
+
this._webGLRenderer = new WebGLRenderer();
|
|
1605
|
+
this._webGLRenderer.setPixelRatio(window.devicePixelRatio);
|
|
1606
|
+
this._webGLRenderer.setSize(width, height);
|
|
1607
|
+
this._webGLRenderer.shadowMap.enabled = rendererParam.shadowMapEnabled;
|
|
1608
|
+
this._webGLRenderer.shadowMap.type = rendererParam.shadowMapType ? rendererParam.shadowMapType : PCFSoftShadowMap;
|
|
1609
|
+
this._webGLRenderer.toneMapping = rendererParam.toneMapping;
|
|
1610
|
+
this._webGLRenderer.toneMappingExposure = rendererParam.toneMappingExposure;
|
|
1611
|
+
if (element) {
|
|
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
|
+
}
|
|
1603
1626
|
}
|
|
1604
1627
|
}
|
|
1605
1628
|
createLabelRenderer() {
|
|
@@ -1646,97 +1669,7 @@ class Viewport {
|
|
|
1646
1669
|
this.setupPostProcess();
|
|
1647
1670
|
}
|
|
1648
1671
|
setupPostProcess() {
|
|
1649
|
-
|
|
1650
|
-
this.destroyPostProcess();
|
|
1651
|
-
this.markRenderStateDirty();
|
|
1652
|
-
return;
|
|
1653
|
-
}
|
|
1654
|
-
if (!this.postProcessing) {
|
|
1655
|
-
this.postProcessing = new PostProcessing(this.renderer);
|
|
1656
|
-
}
|
|
1657
|
-
const scenePass = WebGPUPostProcessFactory.constructScenePass(this.app.world.scene, this.app.camera);
|
|
1658
|
-
let finalNode = scenePass.getTextureNode('output');
|
|
1659
|
-
this.postProcessParam.steps.forEach((step) => {
|
|
1660
|
-
switch (step.type) {
|
|
1661
|
-
case PostProcessStepType.Bloom:
|
|
1662
|
-
{
|
|
1663
|
-
const bloomPass = WebGPUPostProcessFactory.constructBloomPass(scenePass, step);
|
|
1664
|
-
//console.log("[PostProcess] BloomPass 构建完成");
|
|
1665
|
-
finalNode = finalNode.add(bloomPass);
|
|
1666
|
-
break;
|
|
1667
|
-
}
|
|
1668
|
-
case PostProcessStepType.DepthOfField:
|
|
1669
|
-
{
|
|
1670
|
-
const dofPass = WebGPUPostProcessFactory.constructDOFPass(scenePass, step);
|
|
1671
|
-
//console.log("[PostProcess] DOFPass 构建完成");
|
|
1672
|
-
finalNode = finalNode.add(dofPass);
|
|
1673
|
-
break;
|
|
1674
|
-
}
|
|
1675
|
-
case PostProcessStepType.ScreenSpaceReflection:
|
|
1676
|
-
{
|
|
1677
|
-
console.warn("[PostProcess] SSR 目前存在技术问题,暂不支持。");
|
|
1678
|
-
// const ssrPass = WebGPUPostProcessFactory.constructSSRPass(scenePass, step as SSRParam);
|
|
1679
|
-
// console.log("[PostProcess] SSRPass 构建完成");
|
|
1680
|
-
//finalNode = blendColor(finalNode, ssrPass);
|
|
1681
|
-
break;
|
|
1682
|
-
}
|
|
1683
|
-
case PostProcessStepType.GroundTruthAmbientOcclusion:
|
|
1684
|
-
{
|
|
1685
|
-
console.warn("[PostProcess] AO 目前存在技术问题,暂不支持。");
|
|
1686
|
-
// const stepParam = step as GTAOParam
|
|
1687
|
-
// const GTAOPass = WebGPUPostProcessFactory.constructGTAOPass(scenePass, stepParam);
|
|
1688
|
-
// console.log("[PostProcess] GTAOPass 构建完成");
|
|
1689
|
-
// if (stepParam.denoised)
|
|
1690
|
-
// {
|
|
1691
|
-
// const denoiseGTAOPass = WebGPUPostProcessFactory.constructGTAODenoisePass(scenePass, GTAOPass, stepParam);
|
|
1692
|
-
// console.log("[PostProcess] GTAODenoisePass 构建完成");
|
|
1693
|
-
// finalNode = denoiseGTAOPass.mul(finalNode);
|
|
1694
|
-
// }
|
|
1695
|
-
// else
|
|
1696
|
-
// {
|
|
1697
|
-
// finalNode = GTAOPass.getTextureNode().mul(finalNode);
|
|
1698
|
-
// }
|
|
1699
|
-
break;
|
|
1700
|
-
}
|
|
1701
|
-
case PostProcessStepType.Outline:
|
|
1702
|
-
{
|
|
1703
|
-
const outlineParam = step;
|
|
1704
|
-
const outlinePass = WebGPUPostProcessFactory.constructOutlinePass(this.app.world.scene, scenePass.camera, this.outlineObjects, outlineParam);
|
|
1705
|
-
const { visibleEdge, hiddenEdge } = outlinePass;
|
|
1706
|
-
const pulsePeriod = uniform(outlineParam.pulsePeriod);
|
|
1707
|
-
const period = time.div(pulsePeriod).mul(2);
|
|
1708
|
-
const osc = oscSine(period).mul(.5).add(.5);
|
|
1709
|
-
const outlineColor = visibleEdge.mul(uniform(new Color(outlineParam.visibleEdgeColor))).add(hiddenEdge.mul(uniform(new Color(outlineParam.hiddenEdgeColor)))).mul(outlineParam.edgeStrength);
|
|
1710
|
-
const outlinePulse = pulsePeriod.greaterThan(0).select(outlineColor.mul(osc), outlineColor);
|
|
1711
|
-
// if(!this.denoiseOutlinePass)
|
|
1712
|
-
// {
|
|
1713
|
-
// this.denoiseOutlinePass = WebGPUPostProcessFactory.constructDenoisePass(this.scenePass, outlinePulse, DefaultDenoiseParam);
|
|
1714
|
-
// }
|
|
1715
|
-
// outlinePulse = this.denoiseOutlinePass.mul(outlinePulse)
|
|
1716
|
-
// finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
|
|
1717
|
-
finalNode = outlinePulse.add(finalNode);
|
|
1718
|
-
//console.log("[PostProcess] OutlinePass 构建完成");
|
|
1719
|
-
break;
|
|
1720
|
-
}
|
|
1721
|
-
case PostProcessStepType.Antialiasing:
|
|
1722
|
-
{
|
|
1723
|
-
const aaParam = step;
|
|
1724
|
-
if (aaParam.method === "fxaa") {
|
|
1725
|
-
finalNode = WebGPUPostProcessFactory.constructFXAAPass(finalNode);
|
|
1726
|
-
//console.log("[PostProcess] FXAAPass 构建完成");
|
|
1727
|
-
}
|
|
1728
|
-
if (aaParam.method === "smaa") {
|
|
1729
|
-
finalNode = WebGPUPostProcessFactory.constructSMAAPass(finalNode);
|
|
1730
|
-
//console.log("[PostProcess] SMAAPass 构建完成");
|
|
1731
|
-
}
|
|
1732
|
-
break;
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
});
|
|
1736
|
-
this.postProcessing.outputNode = finalNode;
|
|
1737
|
-
this.postProcessing.needsUpdate = true;
|
|
1738
|
-
//console.log("[PostProcess] setup complete", this.postProcessParam.steps);
|
|
1739
|
-
this.markRenderStateDirty();
|
|
1672
|
+
return;
|
|
1740
1673
|
}
|
|
1741
1674
|
updatePostProcess(steps) {
|
|
1742
1675
|
this.postProcessParam.steps = steps;
|
|
@@ -1838,7 +1771,13 @@ class Viewport {
|
|
|
1838
1771
|
await this.postProcessing.renderAsync();
|
|
1839
1772
|
}
|
|
1840
1773
|
else {
|
|
1841
|
-
|
|
1774
|
+
if (this._renderer) {
|
|
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
|
+
}
|
|
1842
1781
|
}
|
|
1843
1782
|
// 检查 renderer.domElement 的尺寸
|
|
1844
1783
|
const sourceWidth = this.renderer.domElement.width;
|
|
@@ -2291,6 +2230,14 @@ class Controller {
|
|
|
2291
2230
|
focusTo(targetPos, targetQuat, distance, time, onGoing = null, onFinished = null) {
|
|
2292
2231
|
this.pawn.focusTo(targetPos, targetQuat, distance, time, onGoing, onFinished);
|
|
2293
2232
|
}
|
|
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
|
+
}
|
|
2294
2241
|
}
|
|
2295
2242
|
|
|
2296
2243
|
class CameraFactory {
|
|
@@ -3177,7 +3124,7 @@ class AmbientLightActor extends Actor {
|
|
|
3177
3124
|
}
|
|
3178
3125
|
|
|
3179
3126
|
class BoxComponent extends MeshComponent {
|
|
3180
|
-
constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new MeshStandardMaterial(), uuid) {
|
|
3127
|
+
constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new MeshStandardMaterial({ color: 0x00ff00 }), uuid) {
|
|
3181
3128
|
super(app, new BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material, uuid);
|
|
3182
3129
|
}
|
|
3183
3130
|
}
|
|
@@ -3598,4 +3545,4 @@ class TransformGizmo extends Pawn {
|
|
|
3598
3545
|
}
|
|
3599
3546
|
}
|
|
3600
3547
|
|
|
3601
|
-
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 };
|
|
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, Pawn, PlaneActor, PlaneComponent, PostProcessStepType, SceneComponent, SkyActor, SkyComponent, SphereComponent, TAssetPointer, TSmartPointer, TextureAssetPointer, ThreeJsApp, ThreeObjectLibrary, TransformGizmo, Viewport, WebGPUPostProcessFactory, World };
|
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ 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";
|
|
61
62
|
export { Orbital } from "./lythreeframe/Object/PawnV2/Oribital";
|
|
62
63
|
export { FirstPerson } from "./lythreeframe/Object/PawnV2/FirstPerson";
|
|
63
64
|
export type { ITransforming } from "./lythreeframe/Object/PawnV2/TransformControl";
|
|
@@ -40,4 +40,5 @@ 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;
|
|
43
44
|
}
|
|
@@ -7,6 +7,7 @@ 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";
|
|
10
11
|
export interface AppClass {
|
|
11
12
|
assetManagerClass: typeof AssetManager;
|
|
12
13
|
controllerClass: typeof Controller;
|
|
@@ -19,6 +20,7 @@ export interface AppParam {
|
|
|
19
20
|
postProcessParam?: PostProcessParam;
|
|
20
21
|
worldParam?: WorldParam;
|
|
21
22
|
viewportParam: ViewportParam;
|
|
23
|
+
controllerParam?: ControllerParameters;
|
|
22
24
|
classes?: AppClass;
|
|
23
25
|
isRenderEveryFrame?: boolean;
|
|
24
26
|
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { ShadowMapType, ToneMapping
|
|
1
|
+
import { Object3D, ShadowMapType, ToneMapping } from "three";
|
|
2
|
+
import { WebGPURenderer } from "three/webgpu";
|
|
2
3
|
import { ThreeJsApp } from "../ThreeJsApp";
|
|
3
4
|
import { PostProcessParam, PostProcessStepParam } from './../PostProcess/PostProcessParam';
|
|
4
5
|
import { RendererParameters } from './Parameters/RendererParameters';
|
|
5
6
|
import { ViewportParam } from './Parameters/ViewportParameters';
|
|
7
|
+
import { WebGLRenderer } from "three";
|
|
6
8
|
export declare class Viewport {
|
|
7
9
|
get uiDom(): HTMLDivElement | null;
|
|
8
10
|
protected _uiDom: HTMLDivElement | null;
|
|
9
11
|
get canvas(): HTMLElement | null;
|
|
10
12
|
get outer(): HTMLElement | null;
|
|
11
|
-
get renderer(): WebGPURenderer;
|
|
13
|
+
get renderer(): WebGPURenderer | WebGLRenderer;
|
|
12
14
|
get app(): ThreeJsApp;
|
|
13
15
|
private _renderer;
|
|
16
|
+
private _webGLRenderer;
|
|
14
17
|
private labelRenderer;
|
|
15
18
|
protected _app: ThreeJsApp | null;
|
|
16
19
|
private resizeObserver;
|
|
@@ -19,6 +22,7 @@ export declare class Viewport {
|
|
|
19
22
|
private isRenderStateDirty;
|
|
20
23
|
private postProcessParam;
|
|
21
24
|
private postProcessing;
|
|
25
|
+
private viewportParam;
|
|
22
26
|
private outlineObjects;
|
|
23
27
|
constructor(app: ThreeJsApp, viewportParam: ViewportParam, rendererParam: RendererParameters, postProcessParam: PostProcessParam);
|
|
24
28
|
protected createRenderer(rendererParam: RendererParameters): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LightComponent } from "../LightComponent";
|
|
2
|
-
import { ColorRepresentation, AmbientLight, Vector3 } from "three
|
|
2
|
+
import { ColorRepresentation, AmbientLight, Vector3 } from "three";
|
|
3
3
|
import { World } from "../../../../Frame/World";
|
|
4
4
|
import { ThreeJsApp } from "../../../../ThreeJsApp";
|
|
5
5
|
export declare class AmbientLightComponent extends LightComponent {
|