lythreeframe 1.0.5 → 1.0.7

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.
Files changed (136) hide show
  1. package/dist/bundle.cjs.js +2782 -0
  2. package/dist/bundle.esm.js +2747 -0
  3. package/dist/index.d.ts +42 -0
  4. package/dist/lythreeframe/AssetManagement/AssetDefines.d.ts +6 -0
  5. package/dist/lythreeframe/AssetManagement/AssetManager.d.ts +23 -0
  6. package/dist/lythreeframe/AssetManagement/AssetPointer/AssetPointer.d.ts +9 -0
  7. package/dist/lythreeframe/AssetManagement/Task/Task.d.ts +7 -0
  8. package/dist/lythreeframe/Container/SmartPointer.d.ts +10 -0
  9. package/dist/lythreeframe/Defines.d.ts +4 -0
  10. package/dist/lythreeframe/Delegate.d.ts +8 -0
  11. package/dist/lythreeframe/Factory/CameraFactory.d.ts +20 -0
  12. package/dist/lythreeframe/Factory/RendererFactory.d.ts +2 -0
  13. package/dist/lythreeframe/Frame/Controller.d.ts +40 -0
  14. package/dist/lythreeframe/Frame/Viewport.d.ts +50 -0
  15. package/dist/lythreeframe/Frame/World.d.ts +18 -0
  16. package/dist/lythreeframe/Geometry/PlaneGeometry.d.ts +3 -0
  17. package/dist/lythreeframe/Geometry/TriangleGeometry.d.ts +3 -0
  18. package/dist/lythreeframe/Library/ContainerLibrary.d.ts +3 -0
  19. package/dist/lythreeframe/Library/Math.d.ts +27 -0
  20. package/dist/lythreeframe/Library/ResourceLibrary.d.ts +6 -0
  21. package/dist/lythreeframe/Object/Actor.d.ts +86 -0
  22. package/dist/lythreeframe/Object/Actors/Camera/CameraActor.d.ts +4 -0
  23. package/dist/lythreeframe/Object/Actors/Light/DirectionalLightActor.d.ts +7 -0
  24. package/dist/lythreeframe/Object/Actors/Shape/BoxActor.d.ts +5 -0
  25. package/dist/lythreeframe/Object/Actors/Shape/PlaneActor.d.ts +9 -0
  26. package/dist/lythreeframe/Object/BaseObject.d.ts +10 -0
  27. package/dist/lythreeframe/Object/Components/2D/2DComponent.d.ts +13 -0
  28. package/dist/lythreeframe/Object/Components/Camera/CameraComponent.d.ts +26 -0
  29. package/dist/lythreeframe/Object/Components/Component.d.ts +17 -0
  30. package/dist/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.d.ts +15 -0
  31. package/dist/lythreeframe/Object/Components/Light/LightComponent.d.ts +12 -0
  32. package/dist/lythreeframe/Object/Components/Mesh/InstanceMesh/InstanceMeshComponent.d.ts +7 -0
  33. package/dist/lythreeframe/Object/Components/Mesh/InstanceMesh/MultiInstanceMeshComponent.d.ts +13 -0
  34. package/dist/lythreeframe/Object/Components/Mesh/MeshComponent.d.ts +22 -0
  35. package/dist/lythreeframe/Object/Components/Mesh/Shape/BoxComponent.d.ts +5 -0
  36. package/dist/lythreeframe/Object/Components/Mesh/Shape/PlaneComponent.d.ts +5 -0
  37. package/dist/lythreeframe/Object/Components/Mesh/Shape/SphereComponent.d.ts +5 -0
  38. package/dist/lythreeframe/Object/Components/Mesh/Sprite/SpriteComponent.d.ts +8 -0
  39. package/dist/lythreeframe/Object/Components/SceneComponent.d.ts +66 -0
  40. package/dist/lythreeframe/Object/PawnV2/FirstPerson.d.ts +5 -0
  41. package/dist/lythreeframe/Object/PawnV2/Oribital.d.ts +12 -0
  42. package/dist/lythreeframe/Object/PawnV2/Pawn.d.ts +14 -0
  43. package/dist/lythreeframe/Object/PawnV2/TransformControl.d.ts +46 -0
  44. package/dist/lythreeframe/PostProcess/Param/Bloom.d.ts +6 -0
  45. package/dist/lythreeframe/PostProcess/Param/DOF.d.ts +6 -0
  46. package/dist/lythreeframe/PostProcess/Param/Denoise.d.ts +7 -0
  47. package/dist/lythreeframe/PostProcess/Param/GTAO.d.ts +11 -0
  48. package/dist/lythreeframe/PostProcess/Param/LensFlare.d.ts +6 -0
  49. package/dist/lythreeframe/PostProcess/Param/MotionBlur.d.ts +4 -0
  50. package/dist/lythreeframe/PostProcess/Param/Outline.d.ts +17 -0
  51. package/dist/lythreeframe/PostProcess/Param/SSR.d.ts +6 -0
  52. package/dist/lythreeframe/PostProcess/Param/ToneMapping.d.ts +9 -0
  53. package/dist/lythreeframe/PostProcess/PostProcessParam.d.ts +16 -0
  54. package/dist/lythreeframe/PostProcess/WebGPUPostProcessFactory.d.ts +43 -0
  55. package/dist/lythreeframe/Shader/Postprocess/ColorShader.d.ts +29 -0
  56. package/dist/lythreeframe/ThreeJsApp.d.ts +35 -0
  57. package/package.json +26 -14
  58. package/dist/index.ts +0 -80
  59. package/rollup.config.js +0 -31
  60. package/src/draco/README.md +0 -32
  61. package/src/draco/draco_decoder.js +0 -34
  62. package/src/draco/draco_decoder.wasm +0 -0
  63. package/src/draco/draco_encoder.js +0 -33
  64. package/src/draco/draco_wasm_wrapper.js +0 -117
  65. package/src/draco/gltf/draco_decoder.js +0 -33
  66. package/src/draco/gltf/draco_decoder.wasm +0 -0
  67. package/src/draco/gltf/draco_encoder.js +0 -33
  68. package/src/draco/gltf/draco_wasm_wrapper.js +0 -116
  69. package/src/index.ts +0 -44
  70. package/src/lythreeframe/AssetManagement/AssetDefines.ts +0 -8
  71. package/src/lythreeframe/AssetManagement/AssetManager.ts +0 -288
  72. package/src/lythreeframe/AssetManagement/AssetPointer/AssetPointer.ts +0 -41
  73. package/src/lythreeframe/AssetManagement/Task/Task.ts +0 -24
  74. package/src/lythreeframe/Container/SmartPointer.ts +0 -54
  75. package/src/lythreeframe/Defines.ts +0 -11
  76. package/src/lythreeframe/Delegate.ts +0 -37
  77. package/src/lythreeframe/Factory/CameraFactory.ts +0 -81
  78. package/src/lythreeframe/Factory/RendererFactory.ts +0 -7
  79. package/src/lythreeframe/Frame/Controller.ts +0 -261
  80. package/src/lythreeframe/Frame/Viewport.ts +0 -516
  81. package/src/lythreeframe/Frame/World.ts +0 -59
  82. package/src/lythreeframe/Frame.ts +0 -511
  83. package/src/lythreeframe/Geometry/PlaneGeometry.ts +0 -53
  84. package/src/lythreeframe/Geometry/TriangleGeometry.ts +0 -50
  85. package/src/lythreeframe/Library/ContainerLibrary.ts +0 -21
  86. package/src/lythreeframe/Library/MaterialLibrary.ts +0 -292
  87. package/src/lythreeframe/Library/Math.ts +0 -154
  88. package/src/lythreeframe/Library/ResourceLibrary.ts +0 -21
  89. package/src/lythreeframe/Object/Actor.ts +0 -571
  90. package/src/lythreeframe/Object/Actors/Camera/CameraActor.ts +0 -11
  91. package/src/lythreeframe/Object/Actors/Light/DirectionalLightActor.ts +0 -18
  92. package/src/lythreeframe/Object/Actors/Shape/BoxActor.ts +0 -20
  93. package/src/lythreeframe/Object/Actors/Shape/CurveActor.ts +0 -11
  94. package/src/lythreeframe/Object/Actors/Shape/PlaneActor.ts +0 -27
  95. package/src/lythreeframe/Object/Actors/Shape/TubeActor.ts +0 -37
  96. package/src/lythreeframe/Object/BaseObject.ts +0 -45
  97. package/src/lythreeframe/Object/Components/2D/2DComponent.ts +0 -64
  98. package/src/lythreeframe/Object/Components/Camera/CameraComponent.ts +0 -113
  99. package/src/lythreeframe/Object/Components/Component.ts +0 -67
  100. package/src/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.ts +0 -78
  101. package/src/lythreeframe/Object/Components/Light/LightComponent.ts +0 -54
  102. package/src/lythreeframe/Object/Components/Mesh/InstanceMesh/InstanceMeshComponent.ts +0 -39
  103. package/src/lythreeframe/Object/Components/Mesh/InstanceMesh/MultiInstanceMeshComponent.ts +0 -115
  104. package/src/lythreeframe/Object/Components/Mesh/Line/CurveComponent.ts +0 -221
  105. package/src/lythreeframe/Object/Components/Mesh/MeshComponent.ts +0 -162
  106. package/src/lythreeframe/Object/Components/Mesh/Shape/BoxComponent.ts +0 -17
  107. package/src/lythreeframe/Object/Components/Mesh/Shape/PlaneComponent.ts +0 -10
  108. package/src/lythreeframe/Object/Components/Mesh/Shape/SphereComponent.ts +0 -10
  109. package/src/lythreeframe/Object/Components/Mesh/Sprite/SpriteComponent.ts +0 -32
  110. package/src/lythreeframe/Object/Components/SceneComponent.ts +0 -811
  111. package/src/lythreeframe/Object/Controller/Controller.ts +0 -764
  112. package/src/lythreeframe/Object/Pawn/CameraStatus.ts +0 -262
  113. package/src/lythreeframe/Object/Pawn/FirstPerson.ts +0 -230
  114. package/src/lythreeframe/Object/Pawn/Oribital.ts +0 -276
  115. package/src/lythreeframe/Object/Pawn/PawnBase.ts +0 -189
  116. package/src/lythreeframe/Object/Pawn/TopView.ts +0 -205
  117. package/src/lythreeframe/Object/Pawn/TransformControl.ts +0 -215
  118. package/src/lythreeframe/Object/Pawn/staticCamera.ts +0 -80
  119. package/src/lythreeframe/Object/PawnV2/FirstPerson.ts +0 -12
  120. package/src/lythreeframe/Object/PawnV2/Oribital.ts +0 -45
  121. package/src/lythreeframe/Object/PawnV2/Pawn.ts +0 -50
  122. package/src/lythreeframe/Object/PawnV2/TransformControl.ts +0 -202
  123. package/src/lythreeframe/PostProcess/Param/Bloom.ts +0 -12
  124. package/src/lythreeframe/PostProcess/Param/DOF.ts +0 -13
  125. package/src/lythreeframe/PostProcess/Param/Denoise.ts +0 -14
  126. package/src/lythreeframe/PostProcess/Param/GTAO.ts +0 -21
  127. package/src/lythreeframe/PostProcess/Param/LensFlare.ts +0 -11
  128. package/src/lythreeframe/PostProcess/Param/MotionBlur.ts +0 -8
  129. package/src/lythreeframe/PostProcess/Param/Outline.ts +0 -20
  130. package/src/lythreeframe/PostProcess/Param/SSR.ts +0 -11
  131. package/src/lythreeframe/PostProcess/Param/ToneMapping.ts +0 -31
  132. package/src/lythreeframe/PostProcess/PostProcessParam.ts +0 -26
  133. package/src/lythreeframe/PostProcess/WebGPUPostProcessFactory.ts +0 -217
  134. package/src/lythreeframe/Shader/Postprocess/ColorShader.ts +0 -49
  135. package/src/lythreeframe/ThreeJsApp.ts +0 -124
  136. package/tsconfig.json +0 -105
@@ -1,516 +0,0 @@
1
- 
2
- import { PostProcessParam } from './../PostProcess/PostProcessParam';
3
- import OutlineNode from 'three/examples/jsm/tsl/display/OutlineNode.js';
4
- import { CSS2DRenderer } from "three/examples/jsm/Addons.js";
5
- import BloomNode from "three/examples/jsm/tsl/display/BloomNode.js";
6
- import DenoiseNode from "three/examples/jsm/tsl/display/DenoiseNode.js";
7
- import DepthOfFieldNode from "three/examples/jsm/tsl/display/DepthOfFieldNode.js";
8
- import GTAONode from "three/examples/jsm/tsl/display/GTAONode.js";
9
- import { WebGPURendererParameters } from "three/src/renderers/webgpu/WebGPURenderer.js";
10
- import { blendColor, oscSine, ShaderNodeObject, time, uniform } from "three/tsl";
11
- import { WebGPURenderer, PostProcessing, PassNode, Color, Node } from "three/webgpu";
12
- import { BloomParam } from "../PostProcess/Param/Bloom";
13
- import { GTAOParam } from "../PostProcess/Param/GTAO";
14
- import { ToneMappingParams, ToneMappingOptions } from "../PostProcess/Param/ToneMapping";
15
- import { WebGPUPostProcessFactory } from "../PostProcess/WebGPUPostProcessFactory";
16
- import { ThreeJsApp } from "../ThreeJsApp";
17
- import SSRNode from "three/examples/jsm/tsl/display/SSRNode.js";
18
- import { SSRParam } from "../PostProcess/Param/SSR";
19
- import { DefaultOutlineParams, OutlineParams } from '../PostProcess/Param/Outline';
20
- import { Object3D } from 'three/src/Three.WebGPU.Nodes.js';
21
- import { DOFParam } from '../PostProcess/Param/DOF';
22
- import FXAANode from 'three/examples/jsm/tsl/display/FXAANode.js';
23
- import { SMAANode } from 'three/examples/jsm/tsl/display/SMAANode.js';
24
-
25
-
26
- export class Viewport
27
- {
28
- get canvas(): HTMLElement
29
- {
30
- if (!this._canvas)
31
- {
32
- throw Error("Canvas is not initialized");
33
- }
34
- return this._canvas;
35
- }
36
- get renderer(): WebGPURenderer
37
- {
38
- if (!this._renderer)
39
- {
40
- throw Error("Renderer is not initialized");
41
- }
42
- return this._renderer;
43
- }
44
- get app(): ThreeJsApp
45
- {
46
- if (!this._app)
47
- {
48
- throw Error("App is not initialized");
49
- }
50
- return this._app;
51
- }
52
-
53
- private _renderer: WebGPURenderer | null = null;
54
- private labelRenderer: CSS2DRenderer | null = null;
55
-
56
- protected _app: ThreeJsApp | null = null;
57
- private resizeObserver: ResizeObserver | null = null;
58
- private _canvas: HTMLElement | null = null;
59
- private isRenderStateDirty: boolean = true;
60
-
61
- private postProcessParam: PostProcessParam = {};
62
- private postProcessing: PostProcessing | null = null;
63
- private scenePass: ShaderNodeObject<PassNode> | null = null;
64
- private bloomPass: ShaderNodeObject<BloomNode> | null = null;
65
- private dofPass: ShaderNodeObject<DepthOfFieldNode> | null = null;
66
- private GTAOPass: ShaderNodeObject<GTAONode> | null = null;
67
- private denoiseGTAOPass: ShaderNodeObject<DenoiseNode> | null = null;
68
- // private denoiseOutlinePass: ShaderNodeObject<DenoiseNode> | null = null;
69
- private ssrPass: ShaderNodeObject<SSRNode> | null = null;
70
- private outlinePass: ShaderNodeObject<OutlineNode> | null = null;
71
- // private motionBlurPass: ShaderNodeObject<Node> | null = null;
72
- private fxaaPass: ShaderNodeObject<FXAANode> | null = null;
73
- private smaaPass: ShaderNodeObject<SMAANode> | null = null;
74
-
75
- private outlineObjects: Object3D[] = [];
76
- constructor(app: ThreeJsApp, elementId: string, rendererParam: WebGPURendererParameters = { antialias: true }, postProcessParam: PostProcessParam = {})
77
- {
78
- this.postProcessParam = postProcessParam
79
- this._app = app;
80
- let element = document.getElementById(elementId);
81
- if (!element)
82
- {
83
- throw Error(`Can not find domElement which id is ${elementId}`);
84
- }
85
- this._renderer = new WebGPURenderer(rendererParam);
86
- this._renderer.setPixelRatio(window.devicePixelRatio);
87
- this._renderer.setSize(element.clientWidth, element.clientHeight);
88
- this._renderer.shadowMap.enabled = true;
89
- this.labelRenderer = new CSS2DRenderer();
90
- this.labelRenderer.setSize(element.clientWidth, element.clientHeight);
91
- this.labelRenderer.domElement.style.pointerEvents = 'none';
92
- this.labelRenderer.domElement.style.position = 'absolute';
93
- this.labelRenderer.domElement.style.top = '0px';
94
- this.labelRenderer.domElement.className = 'scene-labelRenderer';
95
-
96
- element.appendChild(this.labelRenderer.domElement);
97
- element.appendChild(this._renderer.domElement);
98
- this._canvas = element;
99
-
100
- this.resizeObserver = new ResizeObserver((entries) =>
101
- {
102
- for (let entry of entries)
103
- {
104
- if (entry.contentBoxSize)
105
- {
106
- this.onWindowResize();
107
- }
108
- }
109
- });
110
- this.resizeObserver.observe(this._canvas);
111
-
112
- this.setupPostProcess();
113
- }
114
-
115
- init()
116
- {
117
-
118
- }
119
-
120
- setupPostProcess()
121
- {
122
- if (this.postProcessParam.toneMapping)
123
- {
124
- let toneMapping = ToneMappingOptions.get(this.postProcessParam.toneMapping.toneMapping);
125
- if (toneMapping)
126
- {
127
- this.renderer.toneMapping = toneMapping;
128
- }
129
- this.renderer.toneMappingExposure = this.postProcessParam.toneMapping.exposure;
130
- }
131
- if (!(Object.keys(this.postProcessParam).some(key => ['bloom', 'dof', 'gtao', 'ssr', "outline"].includes(key))))
132
- {
133
- this.destroyPostProcess();
134
- return
135
- }
136
- if (!this.postProcessing)
137
- {
138
- this.postProcessing = new PostProcessing(this.renderer);
139
- }
140
-
141
- if (!this.scenePass)
142
- {
143
- this.scenePass = WebGPUPostProcessFactory.constructScenePass(this.app.world.scene, this.app.camera);
144
- }
145
- let finalNode = this.scenePass.getTextureNode('output');
146
-
147
- // bloom
148
- if (this.postProcessParam.bloom)
149
- {
150
- if (!this.bloomPass)
151
- {
152
- this.bloomPass = WebGPUPostProcessFactory.constructBloomPass(this.scenePass, this.postProcessParam.bloom);
153
- }
154
- else
155
- {
156
- WebGPUPostProcessFactory.updateBloomPass(this.bloomPass, this.postProcessParam.bloom);
157
- }
158
- finalNode = finalNode.add(this.bloomPass);
159
- }
160
- else
161
- {
162
- if (this.bloomPass)
163
- {
164
- this.bloomPass.dispose();
165
- this.bloomPass = null;
166
- }
167
- }
168
- // DOF
169
- if (this.postProcessParam.dof)
170
- {
171
- if (!this.dofPass)
172
- {
173
- this.dofPass = WebGPUPostProcessFactory.constructDOFPass(this.scenePass, this.postProcessParam.dof);
174
- }
175
- else
176
- {
177
- WebGPUPostProcessFactory.updateDOFPass(this.dofPass, this.postProcessParam.dof);
178
- }
179
- finalNode = this.dofPass;
180
- }
181
- else
182
- {
183
- if (this.dofPass)
184
- {
185
- this.dofPass.dispose();
186
- this.dofPass = null;
187
- }
188
- }
189
-
190
- // motion blur
191
- // if (this.postProcessParam.motionBlur)
192
- // {
193
- // if (!this.motionBlurPass)
194
- // {
195
- // this.motionBlurPass = WebGPUPostProcessFactory.constructMotionBlurPass(finalNode, this.scenePass, this.postProcessParam.motionBlur);
196
- // }
197
- // const vignette = screenUV.distance(.5).remap(.6, 1).mul(2).clamp().oneMinus();
198
- // finalNode = mix(this.motionBlurPass, this.scenePass.getTextureNode("velocity"), 0).mul(vignette);
199
- // }
200
- // else
201
- // {
202
- // if (this.motionBlurPass)
203
- // {
204
- // this.motionBlurPass.dispose();
205
- // this.motionBlurPass = null;
206
- // }
207
- // }
208
-
209
- // ssr
210
- if (this.postProcessParam.ssr)
211
- {
212
- if (!this.ssrPass)
213
- {
214
- this.ssrPass = WebGPUPostProcessFactory.constructSSRPass(this.scenePass, this.postProcessParam.ssr);
215
- }
216
- else
217
- {
218
- WebGPUPostProcessFactory.updateSSRPass(this.ssrPass, this.postProcessParam.ssr);
219
- }
220
- finalNode = blendColor(finalNode, this.ssrPass)
221
- }
222
- // GTAO
223
- if (this.postProcessParam.gtao)
224
- {
225
- if (!this.GTAOPass)
226
- {
227
- this.GTAOPass = WebGPUPostProcessFactory.constructGTAOPass(this.scenePass, this.postProcessParam.gtao);
228
- }
229
- else
230
- {
231
- WebGPUPostProcessFactory.updateGTAOPass(this.GTAOPass, this.postProcessParam.gtao);
232
- }
233
- if (this.postProcessParam.gtao.denoised)
234
- {
235
- if (!this.denoiseGTAOPass)
236
- {
237
- this.denoiseGTAOPass = WebGPUPostProcessFactory.constructGTAODenoisePass(this.scenePass, this.GTAOPass, this.postProcessParam.gtao);
238
- }
239
- else
240
- {
241
- WebGPUPostProcessFactory.updateGTAOPass(this.GTAOPass, this.postProcessParam.gtao);
242
- }
243
- finalNode = this.denoiseGTAOPass.mul(finalNode);
244
- }
245
- else
246
- {
247
- finalNode = this.GTAOPass.getTextureNode().mul(finalNode);
248
- if (this.denoiseGTAOPass)
249
- {
250
- this.denoiseGTAOPass.dispose();
251
- this.denoiseGTAOPass = null;
252
- }
253
- }
254
- }
255
- else
256
- {
257
- if (this.GTAOPass)
258
- {
259
- this.GTAOPass.dispose();
260
- this.GTAOPass = null;
261
- }
262
- if (this.denoiseGTAOPass)
263
- {
264
- this.denoiseGTAOPass.dispose();
265
- this.denoiseGTAOPass = null;
266
- }
267
- }
268
- // outline
269
- if (this.postProcessParam.outline)
270
- {
271
- if (!this.outlinePass)
272
- {
273
- this.outlinePass = WebGPUPostProcessFactory.constructOutlinePass(this.app.world.scene, this.scenePass.camera, this.outlineObjects, this.postProcessParam.outline);
274
- }
275
- else
276
- {
277
- WebGPUPostProcessFactory.updateOutlinePass(this.outlinePass, this.outlineObjects, this.postProcessParam.outline);
278
- }
279
- const { visibleEdge, hiddenEdge } = this.outlinePass;
280
- const pulsePeriod = uniform(this.postProcessParam.outline.pulsePeriod);
281
- const period = time.div(pulsePeriod).mul(2);
282
- const osc = oscSine(period).mul(.5).add(.5);
283
-
284
- const outlineColor = visibleEdge.mul(uniform(new Color(this.postProcessParam.outline.visibleEdgeColor))).add(hiddenEdge.mul(uniform(new Color(this.postProcessParam.outline.hiddenEdgeColor)))).mul(this.postProcessParam.outline.edgeStrength);
285
- const outlinePulse = pulsePeriod.greaterThan(0).select(outlineColor.mul(osc), outlineColor);
286
-
287
- // if(!this.denoiseOutlinePass)
288
- // {
289
- // this.denoiseOutlinePass = WebGPUPostProcessFactory.constructDenoisePass(this.scenePass, outlinePulse, DefaultDenoiseParam);
290
- // }
291
- // outlinePulse = this.denoiseOutlinePass.mul(outlinePulse)
292
- // finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
293
- finalNode = outlinePulse.add(finalNode);
294
- // finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
295
- }
296
- else
297
- {
298
- if (this.outlinePass)
299
- {
300
- this.outlinePass.dispose();
301
- this.outlinePass = null;
302
- }
303
- }
304
-
305
- if (this.postProcessParam.aa)
306
- {
307
- if (this.postProcessParam.aa === "fxaa")
308
- {
309
- this.fxaaPass = WebGPUPostProcessFactory.constructFXAAPass(finalNode)
310
- finalNode = this.fxaaPass;
311
- }
312
- if (this.postProcessParam.aa === "smaa")
313
- {
314
- this.smaaPass = WebGPUPostProcessFactory.constructSMAAPass(finalNode)
315
- finalNode = this.smaaPass;
316
- }
317
- }
318
- else
319
- {
320
- if (this.fxaaPass)
321
- {
322
- this.fxaaPass.dispose();
323
- this.fxaaPass = null;
324
- }
325
- if (this.smaaPass)
326
- {
327
- this.smaaPass.dispose();
328
- this.smaaPass = null;
329
- }
330
- }
331
- console.log(this.postProcessParam, "sssssssssssssssssssss")
332
- this.postProcessing.outputNode = finalNode;
333
- this.markRenderStateDirty()
334
- }
335
-
336
- updateToneMappingParam(params: ToneMappingParams)
337
- {
338
- this.postProcessParam.toneMapping = params;
339
- this.setupPostProcess();
340
- this.markRenderStateDirty();
341
- }
342
-
343
- updateBloomPass(params: BloomParam)
344
- {
345
- this.postProcessParam.bloom = params;
346
- this.setupPostProcess();
347
- }
348
-
349
- updateGTAOParam(params: GTAOParam | null)
350
- {
351
- this.postProcessParam.gtao = params;
352
- this.setupPostProcess();
353
- }
354
-
355
- updateDOFParam(params: DOFParam | null)
356
- {
357
- this.postProcessParam.dof = params;
358
- this.setupPostProcess();
359
- }
360
-
361
- updateSSRParam(params: SSRParam | null)
362
- {
363
- this.postProcessParam.ssr = params;
364
- this.setupPostProcess();
365
- }
366
-
367
- updateOutlineParam(params: OutlineParams | null)
368
- {
369
- this.postProcessParam.outline = params
370
- this.setupPostProcess();
371
- }
372
-
373
- addOutlineObject(obj: Object3D)
374
- {
375
- if(!this.outlineObjects.includes(obj))
376
- {
377
- this.outlineObjects.push(obj);
378
- }
379
-
380
- if (!this.postProcessParam.outline)
381
- {
382
- this.postProcessParam.outline = DefaultOutlineParams
383
- this.setupPostProcess();
384
- }
385
- else
386
- {
387
- this.markRenderStateDirty();
388
- }
389
- }
390
-
391
- removeOutlineObject(obj: Object3D)
392
- {
393
- if (!this.postProcessParam.outline)
394
- {
395
- this.outlineObjects = [];
396
- return
397
- }
398
- const index = this.outlineObjects.indexOf(obj);
399
- if(index > -1)
400
- {
401
- this.outlineObjects.splice(index, 1);
402
- }
403
- this.markRenderStateDirty();
404
- }
405
-
406
- destroyPostProcess()
407
- {
408
- if (this.bloomPass)
409
- {
410
- this.bloomPass.dispose()
411
- this.bloomPass = null;
412
- }
413
- if (this.dofPass)
414
- {
415
- this.dofPass.dispose()
416
- this.dofPass = null;
417
- }
418
- if (this.GTAOPass)
419
- {
420
- this.GTAOPass.dispose()
421
- this.GTAOPass = null;
422
- }
423
- if (this.denoiseGTAOPass)
424
- {
425
- this.denoiseGTAOPass.dispose()
426
- this.denoiseGTAOPass = null;
427
- }
428
- if (this.ssrPass)
429
- {
430
- this.ssrPass.dispose()
431
- this.ssrPass = null;
432
- }
433
- if (this.outlinePass)
434
- {
435
- this.outlinePass.dispose()
436
- this.outlinePass = null;
437
- }
438
- this.outlineObjects = [];
439
- if (this.scenePass)
440
- {
441
- this.scenePass.dispose()
442
- this.scenePass = null;
443
- }
444
- if (this.postProcessing)
445
- {
446
- this.postProcessing.dispose();
447
- this.postProcessing = null;
448
- }
449
- }
450
-
451
- onWindowResize()
452
- {
453
- console.log("resize")
454
- let ele = this._canvas;
455
- if (!ele)
456
- {
457
- return;
458
- }
459
- this.app.onWindowResize(ele.clientWidth, ele.clientHeight);
460
- this.renderer.setSize(ele.clientWidth, ele.clientHeight);
461
- if(this.labelRenderer)
462
- this.labelRenderer.setSize(ele.clientWidth, ele.clientHeight);
463
- this.markRenderStateDirty();
464
- }
465
-
466
- markRenderStateDirty()
467
- {
468
- this.isRenderStateDirty = true;
469
- }
470
-
471
- render()
472
- {
473
- if(!this.isRenderStateDirty)
474
- {
475
- return
476
- }
477
- if (this.postProcessing)
478
- {
479
- this.postProcessing.render();
480
- }
481
- else
482
- { //console.log("render renderer");
483
- this.renderer.render(this.app.world.scene, this.app.camera);
484
- }
485
- this.isRenderStateDirty = false;
486
- }
487
-
488
- destroy()
489
- {
490
- this.destroyPostProcess();
491
- this.renderer.setAnimationLoop(null);
492
- if (this.resizeObserver)
493
- {
494
- this.resizeObserver.disconnect();
495
- this.resizeObserver = null;
496
- }
497
- if (this.labelRenderer)
498
- {
499
- this.labelRenderer.domElement.remove();
500
- this.labelRenderer = null;
501
- }
502
- if (this._renderer)
503
- {
504
- this.renderer.domElement.remove();
505
- this._renderer.dispose();
506
- this._renderer = null;
507
- }
508
-
509
-
510
- this.postProcessing?.dispose();
511
- this._canvas = null;
512
- this._app = null;
513
- this._renderer = null;
514
- this.outlineObjects = [];
515
- }
516
- }
@@ -1,59 +0,0 @@
1
- import {Scene} from "three";
2
- import {ThreeJsApp} from "../ThreeJsApp";
3
- import { Viewport } from "./Viewport";
4
- import { Controller } from "./Controller";
5
- import { Actor } from "../Object/Actor";
6
-
7
- export class World
8
- {
9
- get scene():Scene
10
- {
11
- return this._scene;
12
- }
13
- get viewport(): Viewport
14
- {
15
- return this.app.viewport
16
- }
17
- get controller(): Controller
18
- {
19
- return this.app.controller
20
- }
21
- protected _scene:Scene
22
- protected app:ThreeJsApp
23
- protected actors:Set<Actor> = new Set()
24
- constructor(app:ThreeJsApp,)
25
- {
26
- this.app = app
27
- this._scene = new Scene();
28
- }
29
-
30
- init()
31
- {
32
-
33
- }
34
-
35
- tick(deltaTime:number)
36
- {
37
- this.actors.forEach((elem)=>{
38
- elem.tick(deltaTime)
39
- })
40
- }
41
-
42
- addActor(actor:Actor)
43
- {
44
- if(!actor.rootComponent.threeObject)
45
- {
46
- throw Error("actor.threeObject is null")
47
- }
48
- actor.removeFromParent();
49
- this.scene.add(actor.rootComponent.threeObject)
50
- this.actors.add(actor)
51
- actor.onAddedToWorld(this)
52
- this.viewport.markRenderStateDirty()
53
- }
54
-
55
- destroy()
56
- {
57
-
58
- }
59
- }