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
@@ -0,0 +1,2782 @@
1
+ 'use strict';
2
+
3
+ var three = require('three');
4
+ var Addons_js = require('three/examples/jsm/Addons.js');
5
+ var tsl = require('three/tsl');
6
+ var webgpu = require('three/webgpu');
7
+ var BloomNode_js = require('three/examples/jsm/tsl/display/BloomNode.js');
8
+ var DenoiseNode_js = require('three/examples/jsm/tsl/display/DenoiseNode.js');
9
+ var DepthOfFieldNode_js = require('three/examples/jsm/tsl/display/DepthOfFieldNode.js');
10
+ var GTAONode_js = require('three/examples/jsm/tsl/display/GTAONode.js');
11
+ var SSRNode_js = require('three/examples/jsm/tsl/display/SSRNode.js');
12
+ var LensflareNode_js = require('three/examples/jsm/tsl/display/LensflareNode.js');
13
+ var OutlineNode_js = require('three/examples/jsm/tsl/display/OutlineNode.js');
14
+ var MotionBlur_js = require('three/examples/jsm/tsl/display/MotionBlur.js');
15
+ var FXAANode_js = require('three/examples/jsm/tsl/display/FXAANode.js');
16
+ var SMAANode_js = require('three/examples/jsm/tsl/display/SMAANode.js');
17
+ var CSS2DRenderer_js = require('three/examples/jsm/renderers/CSS2DRenderer.js');
18
+ var PointerLockControls = require('three/examples/jsm/controls/PointerLockControls');
19
+ var TransformControls_js = require('three/examples/jsm/controls/TransformControls.js');
20
+
21
+ class LYLoadTask {
22
+ constructor(paths, onLoaded) {
23
+ this.paths = paths;
24
+ this.onLoaded = onLoaded;
25
+ }
26
+ get Paths() {
27
+ return this.paths;
28
+ }
29
+ onLoadingFinished(loaded) {
30
+ if (this.onLoaded) {
31
+ this.onLoaded(loaded);
32
+ }
33
+ }
34
+ }
35
+
36
+ /*
37
+ * virtual class of 3D Object, should not be use directly.
38
+ */
39
+ class BaseObject {
40
+ get IsTickable() {
41
+ return this.bCanTick;
42
+ }
43
+ set IsTickable(bCanTick) {
44
+ this.bCanTick = bCanTick;
45
+ }
46
+ get uuid() {
47
+ return this._uuid;
48
+ }
49
+ constructor(uuid = three.MathUtils.generateUUID()) {
50
+ this.bCanTick = false;
51
+ this.bCanTick = false;
52
+ this._uuid = uuid;
53
+ }
54
+ tick(deltaTime) {
55
+ if (!this.bCanTick) {
56
+ return;
57
+ }
58
+ }
59
+ destroy() {
60
+ }
61
+ }
62
+
63
+ class Component extends BaseObject {
64
+ set parentActor(value) {
65
+ this._parentActor = value;
66
+ }
67
+ get parentActor() {
68
+ return this._parentActor;
69
+ }
70
+ get threeObject() {
71
+ return this.obj;
72
+ }
73
+ set threeObject(newThreeObject) {
74
+ this.obj = newThreeObject;
75
+ if (this.obj) {
76
+ this.obj.userData["LYObject"] = this;
77
+ }
78
+ }
79
+ get name() {
80
+ return this._name;
81
+ }
82
+ set name(name) {
83
+ this._name = name;
84
+ }
85
+ constructor(newThreeObject) {
86
+ super(newThreeObject.uuid);
87
+ this.obj = null;
88
+ this._parentActor = null;
89
+ this._name = "Component";
90
+ this._parentActor = null;
91
+ this.threeObject = newThreeObject;
92
+ this._name = `${newThreeObject.type}Component`;
93
+ }
94
+ destroyObject() {
95
+ if (!this.obj) {
96
+ return;
97
+ }
98
+ }
99
+ destroy() {
100
+ this.destroyObject();
101
+ }
102
+ }
103
+
104
+ // export const LYAttachmentRules =
105
+ // {
106
+ // KeepWorld: 1,
107
+ // KeepRelative: 2,
108
+ // }
109
+ exports.AttachmentRules = void 0;
110
+ (function (AttachmentRules) {
111
+ AttachmentRules[AttachmentRules["KeepWorld"] = 1] = "KeepWorld";
112
+ AttachmentRules[AttachmentRules["KeepRelative"] = 2] = "KeepRelative";
113
+ })(exports.AttachmentRules || (exports.AttachmentRules = {}));
114
+
115
+ class SceneComponent extends Component {
116
+ set parentActor(value) {
117
+ this.childrenComponents.forEach((elem) => {
118
+ elem.parentActor = value;
119
+ });
120
+ this._parentActor = value;
121
+ }
122
+ get parentActor() {
123
+ // 通过 _parentActor 私有字段访问父级 Actor
124
+ return this._parentActor;
125
+ }
126
+ constructor(newThreeObject) {
127
+ super(newThreeObject);
128
+ this.bCanHover = false;
129
+ this.bCanClick = false;
130
+ this.world = null;
131
+ this._name = "SceneComponent";
132
+ }
133
+ createDefaultThreeObject() {
134
+ this.threeObject = new three.Group();
135
+ }
136
+ get isVisible() {
137
+ if (!this.threeObject) {
138
+ return false;
139
+ }
140
+ return this.threeObject.visible;
141
+ }
142
+ setVisible(bVisible) {
143
+ if (!this.threeObject) {
144
+ throw Error("threeObject is invalid");
145
+ }
146
+ this.threeObject.visible = bVisible;
147
+ if (this.world) {
148
+ this.world.viewport.markRenderStateDirty();
149
+ }
150
+ }
151
+ setLayers(layer) {
152
+ if (!this.threeObject) {
153
+ throw Error("threeObject is invalid");
154
+ }
155
+ this.threeObject.layers.set(layer);
156
+ let childComps = this.childrenComponents;
157
+ childComps.forEach((elem) => {
158
+ elem.setLayers(layer);
159
+ });
160
+ }
161
+ getBoundsCenterPositionWS() {
162
+ let ret = new three.Vector3();
163
+ this.getBounds().getCenter(ret);
164
+ return this.getWorldPosition();
165
+ }
166
+ getBoundsTopCenterPositionWS() {
167
+ let ret = new three.Vector3();
168
+ let bounds = this.getBounds();
169
+ bounds.getCenter(ret);
170
+ ret.y = bounds.max.y;
171
+ return ret;
172
+ }
173
+ getBoundsBottomCenterPositionWS() {
174
+ let ret = new three.Vector3();
175
+ let bounds = this.getBounds();
176
+ bounds.getCenter(ret);
177
+ ret.y = bounds.min.y;
178
+ return ret;
179
+ }
180
+ getBounds() {
181
+ if (!this.threeObject) {
182
+ throw Error("threeObject is invalid");
183
+ }
184
+ let ret = new three.Box3();
185
+ ret.setFromObject(this.threeObject, false);
186
+ if (ret.isEmpty()) {
187
+ ret.min = ret.max = this.getWorldPosition();
188
+ }
189
+ return ret;
190
+ }
191
+ get parentComponent() {
192
+ var _a, _b;
193
+ if (!this.threeObject) {
194
+ throw Error("threeObject is invalid");
195
+ }
196
+ let target = (_b = (_a = this.threeObject) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.userData.LYObject;
197
+ if (!target) {
198
+ return null;
199
+ }
200
+ if (!(target instanceof SceneComponent)) {
201
+ return null;
202
+ }
203
+ if (target.parentActor !== this.parentActor) {
204
+ return null;
205
+ }
206
+ return target;
207
+ }
208
+ get childrenComponents() {
209
+ if (!this.threeObject) {
210
+ throw Error("threeObject is invalid");
211
+ }
212
+ let childrens = [];
213
+ for (let i = 0; i < this.threeObject.children.length; ++i) {
214
+ if (!this.threeObject.children[i].userData.LYObject) {
215
+ console.warn("One of children component has no parentActor", this.threeObject.children[i].userData.LYObject, this.threeObject.children[i]);
216
+ continue;
217
+ }
218
+ if (this.threeObject.children[i].userData.LYObject.parentActor === this.parentActor) {
219
+ childrens.push(this.threeObject.children[i].userData.LYObject);
220
+ }
221
+ }
222
+ return childrens;
223
+ }
224
+ onAddedToWorld(world) {
225
+ this.world = world;
226
+ let childrens = this.childrenComponents;
227
+ for (let i = 0; i < childrens.length; ++i) {
228
+ childrens[i].onAddedToWorld(this.world);
229
+ }
230
+ }
231
+ destroy() {
232
+ this.isHoverEnabled = false;
233
+ this.isClickEnabled = false;
234
+ this.detachFromParentActor();
235
+ this.detachFromParentComponent();
236
+ this.destroyChildren();
237
+ this.destroyObject();
238
+ if (this.world) {
239
+ this.world.viewport.markRenderStateDirty();
240
+ }
241
+ }
242
+ destroyObject() {
243
+ if (!this.threeObject) {
244
+ return;
245
+ }
246
+ if (this.threeObject.parent) {
247
+ this.threeObject.parent.remove(this.threeObject);
248
+ }
249
+ super.destroyObject();
250
+ }
251
+ // Local Transforms
252
+ // // Position
253
+ getPosition() {
254
+ if (!this.threeObject) {
255
+ throw Error("threeObject is invalid");
256
+ }
257
+ if (this.threeObject.matrixAutoUpdate) {
258
+ return this.threeObject.position.clone();
259
+ }
260
+ else {
261
+ const position = new three.Vector3();
262
+ const quaternion = new three.Quaternion();
263
+ const scale = new three.Vector3();
264
+ this.threeObject.matrix.decompose(position, quaternion, scale);
265
+ return position;
266
+ }
267
+ }
268
+ setPosition(...args) {
269
+ if (!this.threeObject) {
270
+ throw Error("threeObject is invalid");
271
+ }
272
+ let newPosition = null;
273
+ if (args.length === 1 && args[0] instanceof three.Vector3) {
274
+ newPosition = new three.Vector3().copy(args[0]);
275
+ }
276
+ else if (args.length === 3 &&
277
+ typeof args[0] === "number" &&
278
+ typeof args[1] === "number" &&
279
+ typeof args[2] === "number") {
280
+ newPosition = new three.Vector3(args[0], args[1], args[2]);
281
+ }
282
+ if (!newPosition) {
283
+ return;
284
+ }
285
+ this.threeObject.position.copy(newPosition);
286
+ if (!this.threeObject.matrixAutoUpdate) {
287
+ this.threeObject.matrix.setPosition(newPosition.x, newPosition.y, newPosition.z);
288
+ }
289
+ this.threeObject.updateMatrix();
290
+ this.threeObject.updateMatrixWorld(true);
291
+ if (this.world) {
292
+ this.world.viewport.markRenderStateDirty();
293
+ }
294
+ }
295
+ // // Rotation
296
+ getRotation() {
297
+ if (!this.threeObject) {
298
+ throw Error("threeObject is invalid");
299
+ }
300
+ if (this.threeObject.matrixAutoUpdate) {
301
+ return this.threeObject.rotation.clone();
302
+ }
303
+ else {
304
+ const position = new three.Vector3();
305
+ const quaternion = new three.Quaternion();
306
+ const scale = new three.Vector3();
307
+ this.threeObject.matrix.decompose(position, quaternion, scale);
308
+ return new three.Euler().setFromQuaternion(quaternion);
309
+ }
310
+ }
311
+ setRotation(...args) {
312
+ if (!this.threeObject) {
313
+ throw Error("threeObject is invalid");
314
+ }
315
+ let newRotation = null;
316
+ if (args[0] instanceof three.Euler) {
317
+ newRotation = new three.Euler().copy(args[0]);
318
+ }
319
+ if (typeof (args[0]) === "number" && typeof (args[1]) === "number" && typeof (args[2]) === "number") {
320
+ newRotation = new three.Euler(args[0], args[1], args[2]);
321
+ }
322
+ if (!newRotation) {
323
+ return;
324
+ }
325
+ this.threeObject.rotation.copy(newRotation);
326
+ this.threeObject.updateMatrix();
327
+ this.threeObject.updateMatrixWorld(true);
328
+ if (this.world) {
329
+ this.world.viewport.markRenderStateDirty();
330
+ }
331
+ }
332
+ // // quat
333
+ getQuaternion() {
334
+ if (!this.threeObject) {
335
+ throw Error("threeObject is invalid");
336
+ }
337
+ if (this.threeObject.matrixAutoUpdate) {
338
+ return this.threeObject.quaternion.clone();
339
+ }
340
+ else {
341
+ const position = new three.Vector3();
342
+ const quaternion = new three.Quaternion();
343
+ const scale = new three.Vector3();
344
+ this.threeObject.matrix.decompose(position, quaternion, scale);
345
+ return quaternion;
346
+ }
347
+ }
348
+ setQuaternion(...args) {
349
+ if (!this.threeObject) {
350
+ throw Error("threeObject is invalid");
351
+ }
352
+ let newQuat = null;
353
+ if (args[0] instanceof three.Quaternion) {
354
+ newQuat = new three.Quaternion().copy(args[0]);
355
+ }
356
+ if (typeof args[0] === "number" && typeof args[1] === "number" && typeof args[2] === "number" && typeof args[3] === "number") {
357
+ newQuat = new three.Quaternion(args[0], args[1], args[2], args[3]);
358
+ }
359
+ if (!newQuat) {
360
+ console.error("setQuaternion failed,param is invalid", args);
361
+ return;
362
+ }
363
+ this.threeObject.quaternion.copy(newQuat);
364
+ if (!this.threeObject.matrixAutoUpdate) {
365
+ const position = new three.Vector3();
366
+ const quaternion = new three.Quaternion();
367
+ const scale = new three.Vector3();
368
+ this.threeObject.matrix.decompose(position, quaternion, scale);
369
+ this.threeObject.matrix.compose(position, newQuat, scale);
370
+ }
371
+ if (this.world) {
372
+ this.world.viewport.markRenderStateDirty();
373
+ }
374
+ this.threeObject.updateMatrix();
375
+ this.threeObject.updateMatrixWorld(true);
376
+ }
377
+ // // Scale
378
+ getScale() {
379
+ if (!this.threeObject) {
380
+ throw Error("threeObject is invalid");
381
+ }
382
+ if (this.threeObject.matrixAutoUpdate) {
383
+ return this.threeObject.scale.clone();
384
+ }
385
+ else {
386
+ const position = new three.Vector3();
387
+ const quaternion = new three.Quaternion();
388
+ const scale = new three.Vector3();
389
+ this.threeObject.matrix.decompose(position, quaternion, scale);
390
+ return scale;
391
+ }
392
+ }
393
+ setScale(...args) {
394
+ if (!this.threeObject) {
395
+ throw Error("threeObject is invalid");
396
+ }
397
+ let newScale = null;
398
+ if (args[0] instanceof three.Vector3) {
399
+ newScale = new three.Vector3().copy(args[0]);
400
+ }
401
+ if (typeof (args[0]) === "number" && typeof (args[1]) === "number" && typeof (args[2]) === "number") {
402
+ newScale = new three.Vector3(args[0], args[1], args[2]);
403
+ }
404
+ if (!newScale) {
405
+ return;
406
+ }
407
+ this.threeObject.scale.copy(newScale);
408
+ // if(!this.threeObject.matrixAutoUpdate)
409
+ // {
410
+ // const position = new Vector3();
411
+ // const quaternion = new Quaternion()
412
+ // const scale = new Vector3();
413
+ // this.threeObject.matrix.decompose(position, quaternion, scale)
414
+ // this.threeObject.matrix.compose(position, quaternion, new Vector3(param1, param2, param3))
415
+ // }
416
+ this.threeObject.updateMatrix();
417
+ this.threeObject.updateMatrixWorld(true);
418
+ if (this.world) {
419
+ this.world.viewport.markRenderStateDirty();
420
+ }
421
+ }
422
+ // matrix
423
+ getMatrix() {
424
+ if (!this.threeObject) {
425
+ throw Error("threeObject is invalid");
426
+ }
427
+ return this.threeObject.matrix;
428
+ }
429
+ setMatrix(matrix) {
430
+ var _a;
431
+ if (!this.threeObject) {
432
+ throw Error("threeObject is invalid");
433
+ }
434
+ // this.threeObject.matrix.copy(matrix)
435
+ matrix.decompose(this.threeObject.position, this.threeObject.quaternion, this.threeObject.scale);
436
+ this.threeObject.updateMatrix();
437
+ this.threeObject.updateMatrixWorld(true);
438
+ (_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport.markRenderStateDirty();
439
+ }
440
+ // World Transform
441
+ // // WorldPosition
442
+ getWorldPosition() {
443
+ if (!this.threeObject) {
444
+ throw Error("threeObject is invalid");
445
+ }
446
+ let location = new three.Vector3();
447
+ this.threeObject.getWorldPosition(location);
448
+ return location;
449
+ }
450
+ // // rotation(euler)
451
+ getWorldRotation() {
452
+ if (!this.threeObject) {
453
+ throw Error("threeObject is invalid");
454
+ }
455
+ let rotation = new three.Quaternion();
456
+ this.threeObject.getWorldQuaternion(rotation);
457
+ return new three.Euler().setFromQuaternion(rotation);
458
+ }
459
+ // // rotation(quat)
460
+ getWorldQuaternion() {
461
+ if (!this.threeObject) {
462
+ throw Error("threeObject is invalid");
463
+ }
464
+ let rotation = new three.Quaternion();
465
+ this.threeObject.getWorldQuaternion(rotation);
466
+ return rotation;
467
+ }
468
+ // // Scale
469
+ getWorldScale() {
470
+ if (!this.threeObject) {
471
+ throw Error("threeObject is invalid");
472
+ }
473
+ let scale = new three.Vector3();
474
+ this.threeObject.getWorldScale(scale);
475
+ return scale;
476
+ }
477
+ // // Matrix
478
+ getWorldMatrix() {
479
+ if (!this.threeObject) {
480
+ throw Error("threeObject is invalid");
481
+ }
482
+ this.threeObject.updateMatrixWorld(true);
483
+ return this.threeObject.matrixWorld.clone();
484
+ }
485
+ setWorldMatrix(newMatrix) {
486
+ if (!this.threeObject) {
487
+ throw Error("threeObject is invalid");
488
+ }
489
+ if (this.threeObject.parent) {
490
+ this.threeObject.parent.updateMatrixWorld(true);
491
+ // 计算父对象的逆世界矩阵
492
+ const parentInverseWorldMatrix = this.threeObject.parent.matrixWorld.clone().invert();
493
+ // 计算物体的本地矩阵
494
+ const cLocalMatrix = new three.Matrix4().multiplyMatrices(parentInverseWorldMatrix, newMatrix);
495
+ // 更新物体的本地矩阵
496
+ this.setMatrix(cLocalMatrix);
497
+ // this.threeObject.matrix.copy(cLocalMatrix);
498
+ // this.threeObject.matrixAutoUpdate = false;
499
+ // this.threeObject.matrix.decompose(this.threeObject.position, this.threeObject.quaternion, this.threeObject.scale);
500
+ }
501
+ else {
502
+ this.setMatrix(newMatrix);
503
+ // // 没有父对象时直接设置世界矩阵为本地矩阵
504
+ // this.threeObject.matrix.copy(newMatrix);
505
+ // this.threeObject.matrixAutoUpdate = false;
506
+ }
507
+ // 更新世界矩阵
508
+ this.threeObject.updateMatrixWorld(true);
509
+ if (this.world) {
510
+ // 强制场景重新渲染
511
+ this.world.viewport.markRenderStateDirty();
512
+ }
513
+ }
514
+ getWorldForwardDirection() {
515
+ if (!this.threeObject) {
516
+ throw Error("threeObject is invalid");
517
+ }
518
+ let ret = new three.Vector3();
519
+ this.threeObject.getWorldDirection(ret);
520
+ return ret;
521
+ }
522
+ getWorldUpDirection() {
523
+ if (!this.threeObject) {
524
+ throw Error("threeObject is invalid");
525
+ }
526
+ let ret = new three.Vector3(0, 1, 0);
527
+ ret.applyQuaternion(this.getWorldQuaternion());
528
+ return ret;
529
+ }
530
+ getWorldRightDirection() {
531
+ if (!this.threeObject) {
532
+ throw Error("threeObject is invalid");
533
+ }
534
+ let ret = new three.Vector3(1, 0, 0);
535
+ ret.applyQuaternion(this.getWorldQuaternion());
536
+ return ret;
537
+ }
538
+ worldToLocal(vec) {
539
+ if (!this.threeObject) {
540
+ throw Error("threeObject is invalid");
541
+ }
542
+ return this.threeObject.worldToLocal(vec);
543
+ }
544
+ localToWorld(vec) {
545
+ if (!this.threeObject) {
546
+ throw Error("threeObject is invalid");
547
+ }
548
+ return this.threeObject.localToWorld(vec);
549
+ }
550
+ // Attachment
551
+ // // to another component
552
+ // this function will not set newComponent's parentActor
553
+ attachComponent(newComponent) {
554
+ if (!this.threeObject) {
555
+ throw Error("threeObject is invalid");
556
+ }
557
+ if (!newComponent.threeObject) {
558
+ throw Error("newComponent threeObject is invalid");
559
+ }
560
+ this.threeObject.add(newComponent.threeObject);
561
+ if (this.world) {
562
+ newComponent.onAddedToWorld(this.world);
563
+ }
564
+ }
565
+ detachComponent(target) {
566
+ if (!this.threeObject) {
567
+ throw Error("threeObject is invalid");
568
+ }
569
+ if (!target.threeObject) {
570
+ throw Error("target threeObject is invalid");
571
+ }
572
+ this.threeObject.remove(target.threeObject);
573
+ }
574
+ // newComponent's parentActor will be the same as this
575
+ addChildComponent(newComponent, attachmentRule = exports.AttachmentRules.KeepRelative) {
576
+ if (!this.threeObject) {
577
+ throw Error("threeObject is invalid");
578
+ }
579
+ if (!newComponent.threeObject) {
580
+ throw Error("newComponent threeObject is invalid");
581
+ }
582
+ newComponent.parentActor = this.parentActor;
583
+ if (attachmentRule = exports.AttachmentRules.KeepWorld) {
584
+ let worldMatrix = newComponent.getWorldMatrix();
585
+ this.threeObject.add(newComponent.threeObject);
586
+ newComponent.setWorldMatrix(worldMatrix);
587
+ }
588
+ else {
589
+ this.threeObject.add(newComponent.threeObject);
590
+ }
591
+ if (this.world) {
592
+ newComponent.onAddedToWorld(this.world);
593
+ }
594
+ this.threeObject.updateMatrix();
595
+ this.threeObject.updateMatrixWorld(true);
596
+ }
597
+ removeChildComponent(targetComponent) {
598
+ if (!this.threeObject) {
599
+ throw Error("threeObject is invalid");
600
+ }
601
+ if (!targetComponent.threeObject) {
602
+ throw Error("targetComponent threeObject is invalid");
603
+ }
604
+ this.threeObject.remove(targetComponent.threeObject);
605
+ targetComponent.destroy();
606
+ }
607
+ detachFromParentComponent() {
608
+ if (this.parentComponent) {
609
+ this.parentComponent.removeChildComponent(this);
610
+ }
611
+ }
612
+ detachFromParentActor() {
613
+ if (this.parentActor) {
614
+ this.parentActor = null;
615
+ }
616
+ }
617
+ destroyChildren() {
618
+ if (!this.threeObject) {
619
+ return;
620
+ }
621
+ for (let i = 0; i < this.threeObject.children.length; ++i) {
622
+ this.threeObject.children[i].userData.LYObject.destroy();
623
+ }
624
+ }
625
+ /* horver */
626
+ set isHoverEnabled(bCanHorver) {
627
+ this.bCanHover = bCanHorver;
628
+ let children = this.childrenComponents;
629
+ for (let i = 0; i < children.length; ++i) {
630
+ children[i].isHoverEnabled = this.bCanHover;
631
+ }
632
+ }
633
+ get isHoverEnabled() {
634
+ return this.bCanHover;
635
+ }
636
+ // click
637
+ set isClickEnabled(bCanClick) {
638
+ this.bCanClick = bCanClick;
639
+ let children = this.childrenComponents;
640
+ for (let i = 0; i < children.length; ++i) {
641
+ children[i].isClickEnabled = this.bCanClick;
642
+ }
643
+ }
644
+ get isClickEnabled() {
645
+ return this.bCanClick;
646
+ }
647
+ onHorveringBegin() {
648
+ if (!this.isHoverEnabled) {
649
+ return;
650
+ }
651
+ if (this.parentActor) {
652
+ let comp = this;
653
+ this.parentActor.onComponentHorveringBegin(comp);
654
+ }
655
+ }
656
+ onHorveringEnd() {
657
+ if (!this.isHoverEnabled) {
658
+ return;
659
+ }
660
+ if (this.parentActor) {
661
+ let comp = this;
662
+ this.parentActor.onComponentHorveringEnd(comp);
663
+ }
664
+ }
665
+ /* click */
666
+ onClicked() {
667
+ if (this.parentActor) {
668
+ let comp = this;
669
+ this.parentActor.onComponentClicked(comp);
670
+ }
671
+ }
672
+ onDoubleClicked() {
673
+ if (this.parentActor) {
674
+ let comp = this;
675
+ this.parentActor.onComponentDoubleClicked(comp);
676
+ }
677
+ }
678
+ }
679
+
680
+ class MeshComponent extends SceneComponent {
681
+ get threeObject() {
682
+ return this.obj;
683
+ }
684
+ set threeObject(newThreeObject) {
685
+ this.obj = newThreeObject;
686
+ if (this.obj) {
687
+ this.obj.userData["LYObject"] = this;
688
+ }
689
+ }
690
+ get geometry() {
691
+ return this.threeObject ? this.threeObject.geometry : null;
692
+ }
693
+ set geometry(geo) {
694
+ if (!this.threeObject) {
695
+ return;
696
+ }
697
+ this.threeObject.geometry = geo;
698
+ }
699
+ get material() {
700
+ return this.threeObject ? this.threeObject.material : null;
701
+ }
702
+ set material(newMat) {
703
+ if (!this.threeObject) {
704
+ return;
705
+ }
706
+ this.threeObject.material = newMat;
707
+ if (this.world) {
708
+ this.world.viewport.markRenderStateDirty();
709
+ }
710
+ }
711
+ constructor(...args) {
712
+ let newMesh = null;
713
+ if (args[0] instanceof three.Mesh) {
714
+ newMesh = args[0];
715
+ }
716
+ else {
717
+ if (args[0] instanceof three.BufferGeometry && (args[1] instanceof three.Material || Array.isArray(args[1]))) {
718
+ newMesh = new three.Mesh(args[0], args[1]);
719
+ }
720
+ else {
721
+ throw new Error('Invalid arguments for A constructor');
722
+ }
723
+ }
724
+ super(newMesh);
725
+ this.obj = null;
726
+ this.threeObject = newMesh;
727
+ LYAssetManager.Get().checkMeshResource(newMesh);
728
+ }
729
+ set castShadow(bCast) {
730
+ if (this.threeObject)
731
+ this.threeObject.castShadow = bCast;
732
+ }
733
+ get castShadow() {
734
+ return this.threeObject ? this.threeObject.castShadow : false;
735
+ }
736
+ set receiveShadow(bReceive) {
737
+ if (!this.threeObject) {
738
+ return;
739
+ }
740
+ this.threeObject.receiveShadow = bReceive;
741
+ }
742
+ get receiveShadow() {
743
+ return this.threeObject ? this.threeObject.receiveShadow : false;
744
+ }
745
+ getBoundsCenterPosition() {
746
+ let ret = new three.Vector3();
747
+ this.getBounds().getCenter(ret);
748
+ return ret;
749
+ }
750
+ getBoundsTopCenterPosition() {
751
+ let ret = new three.Vector3();
752
+ let bounds = this.getBounds();
753
+ bounds.getCenter(ret);
754
+ ret.y = bounds.max.y;
755
+ return ret;
756
+ }
757
+ getBoundsBottomCenterPosition() {
758
+ let ret = new three.Vector3();
759
+ let bounds = this.getBounds();
760
+ bounds.getCenter(ret);
761
+ ret.y = bounds.min.y;
762
+ return ret;
763
+ }
764
+ destroyObject() {
765
+ if (this.world && this.world.scene && this.threeObject) {
766
+ this.world.scene.remove(this.threeObject);
767
+ }
768
+ let assetManager = LYAssetManager.Get();
769
+ const mats = Array.isArray(this.material) ? this.material : [this.material];
770
+ mats.forEach((material) => {
771
+ if (material instanceof three.Material) {
772
+ Object.entries(material).forEach(([key, value]) => {
773
+ if (value instanceof three.Texture) {
774
+ assetManager.releaseAsset(value);
775
+ value = null;
776
+ }
777
+ });
778
+ assetManager.releaseAsset(material);
779
+ }
780
+ });
781
+ this.material = [];
782
+ if (this.geometry instanceof three.BufferGeometry) {
783
+ assetManager.releaseAsset(this.geometry);
784
+ this.geometry = null;
785
+ }
786
+ }
787
+ }
788
+
789
+ class TSmartPointer {
790
+ constructor(value, referenceCount = 1) {
791
+ this.referenceCount = 1;
792
+ this.value = null;
793
+ this.value = value;
794
+ this.referenceCount = referenceCount;
795
+ }
796
+ getRefCount() {
797
+ return this.referenceCount;
798
+ }
799
+ addRef(count = 1) {
800
+ if (this.value !== null) {
801
+ this.referenceCount += count;
802
+ }
803
+ }
804
+ release() {
805
+ if (this.value !== null) {
806
+ this.referenceCount--;
807
+ console.log(`Reference count decreased to: ${this.referenceCount}`);
808
+ if (this.referenceCount === 0) {
809
+ console.log("No more references. Deleting object.");
810
+ this.value = null;
811
+ }
812
+ }
813
+ }
814
+ forceRelease() {
815
+ if (this.value !== null) {
816
+ this.value = null;
817
+ this.referenceCount = 0;
818
+ }
819
+ }
820
+ getValue() {
821
+ return this.value;
822
+ }
823
+ }
824
+
825
+ class TAssetPointer extends TSmartPointer {
826
+ get uuid() {
827
+ return this._uuid;
828
+ }
829
+ constructor(value, referenceCount = 1) {
830
+ super(value, referenceCount);
831
+ this._uuid = value.uuid;
832
+ }
833
+ release() {
834
+ if (this.value !== null) {
835
+ this.referenceCount--;
836
+ if (this.referenceCount === 0) {
837
+ this.value.dispose();
838
+ this.value = null;
839
+ }
840
+ }
841
+ }
842
+ forceRelease() {
843
+ if (this.value !== null) {
844
+ this.value.dispose();
845
+ this.value = null;
846
+ this.referenceCount = 0;
847
+ }
848
+ }
849
+ }
850
+
851
+ // this class should be a singleton
852
+ class LYAssetManager {
853
+ constructor() {
854
+ this.assetPointer = new Map();
855
+ this.loadingManager = new three.LoadingManager();
856
+ this.dracoLoader = new Addons_js.DRACOLoader(this.loadingManager);
857
+ this.dracoLoader.setDecoderPath(`../../draco/`);
858
+ this.dracoLoader.setDecoderConfig({ type: "js" });
859
+ this.dracoLoader.preload();
860
+ this.gltfLoader = new Addons_js.GLTFLoader(this.loadingManager);
861
+ this.gltfLoader.setDRACOLoader(this.dracoLoader);
862
+ }
863
+ get LoadingManager() {
864
+ return this.loadingManager;
865
+ }
866
+ static Get() {
867
+ return assetManager;
868
+ }
869
+ static ClearAssets() {
870
+ assetManager.clearAssets();
871
+ }
872
+ convertThreeObjectToLYObject(parentLYComponent, threejsObject) {
873
+ let location = threejsObject.position.clone();
874
+ let rotation = threejsObject.rotation.clone();
875
+ let scale = threejsObject.scale.clone();
876
+ let newComp = null;
877
+ let children = threejsObject.children;
878
+ threejsObject.children = [];
879
+ if (threejsObject.type === "Group" || threejsObject.type === "Object3D") {
880
+ newComp = new SceneComponent(threejsObject);
881
+ }
882
+ else if (threejsObject.isMesh) {
883
+ let obj = threejsObject;
884
+ newComp = new MeshComponent(obj);
885
+ // assetManager.#collectMatAndGeoInMesh(threejsObject)
886
+ threejsObject.layers.set(0);
887
+ }
888
+ else {
889
+ newComp = new SceneComponent(threejsObject);
890
+ }
891
+ if (newComp === null) {
892
+ threejsObject.children = children;
893
+ //threejsObject.parent = parent
894
+ console.log("Unprocess", threejsObject);
895
+ return null;
896
+ }
897
+ parentLYComponent.addChildComponent(newComp);
898
+ newComp.setPosition(location);
899
+ newComp.setRotation(rotation);
900
+ newComp.setScale(scale);
901
+ for (let i = 0; i < children.length; ++i) {
902
+ this.convertThreeObjectToLYObject(newComp, children[i]);
903
+ }
904
+ return threejsObject.userData.LYObject;
905
+ }
906
+ collectResourcesAndReferences(gltf) {
907
+ function countResource(map, resource) {
908
+ if (!map.has(resource)) {
909
+ map.set(resource, 1);
910
+ }
911
+ else {
912
+ map.set(resource, map.get(resource) + 1);
913
+ }
914
+ }
915
+ const resources = {
916
+ geometries: new Map(),
917
+ materials: new Map(),
918
+ textures: new Map()
919
+ };
920
+ gltf.scene.traverse((child) => {
921
+ if (child.geometry && child.geometry instanceof three.BufferGeometry) {
922
+ countResource(resources.geometries, child.geometry);
923
+ }
924
+ if (child.material) {
925
+ const mats = Array.isArray(child.material) ? child.material : [child.material];
926
+ mats.forEach((mat) => {
927
+ if (mat) {
928
+ countResource(resources.materials, mat);
929
+ Object.entries(mat).forEach(([key, value]) => {
930
+ if (value instanceof three.Texture) {
931
+ countResource(resources.textures, value);
932
+ }
933
+ });
934
+ }
935
+ });
936
+ }
937
+ });
938
+ function createPointer(manager, map) {
939
+ map.forEach((value, key) => {
940
+ manager.addAsset(key, value);
941
+ });
942
+ }
943
+ createPointer(this, resources.geometries);
944
+ createPointer(this, resources.materials);
945
+ createPointer(this, resources.textures);
946
+ // console.log('Geometries:', Array.from(resources.geometries.entries()));
947
+ // console.log('Materials:', Array.from(resources.materials.entries()));
948
+ // console.log('Textures:', Array.from(resources.textures.entries()));
949
+ // console.log('assetPointer:', this.assetPointer);
950
+ }
951
+ checkMeshResource(mesh) {
952
+ if (mesh.geometry) {
953
+ if (!mesh.geometry.userData["assetPointer"]) {
954
+ this.addAsset(mesh.geometry);
955
+ }
956
+ }
957
+ if (mesh.material) {
958
+ const mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
959
+ mats.forEach((material) => {
960
+ if (material) {
961
+ if (!material.userData["assetPointer"]) {
962
+ this.addAsset(material);
963
+ }
964
+ Object.entries(material).forEach(([key, value]) => {
965
+ if (value instanceof three.Texture) {
966
+ if (!value.userData["assetPointer"]) {
967
+ this.addAsset(value);
968
+ }
969
+ }
970
+ });
971
+ }
972
+ });
973
+ }
974
+ }
975
+ loadMultiGLTFAsGroup(tasks, onProgress = null, onAllFinished = null) {
976
+ this.loadingManager.onLoad = onAllFinished ? () => {
977
+ this.loadingManager.onLoad = () => {
978
+ };
979
+ onAllFinished();
980
+ } : () => {
981
+ this.loadingManager.onLoad = () => {
982
+ };
983
+ };
984
+ this.loadingManager.onProgress = onProgress ? (url, loaded, total) => {
985
+ onProgress(url, loaded, total);
986
+ } : () => {
987
+ };
988
+ tasks.forEach((task) => {
989
+ task.Paths.forEach((path) => {
990
+ const onGlbLoaded = (glb) => {
991
+ task.onLoadingFinished(glb);
992
+ this.collectResourcesAndReferences(glb);
993
+ };
994
+ try {
995
+ this.gltfLoader.load(path, (glb) => {
996
+ onGlbLoaded(glb);
997
+ });
998
+ }
999
+ catch (e) {
1000
+ console.error(e, path);
1001
+ }
1002
+ });
1003
+ });
1004
+ }
1005
+ loadFile(filepath = '', onLoadFinished) {
1006
+ const loader = new three.FileLoader();
1007
+ loader.load(filepath, (data) => {
1008
+ onLoadFinished(data);
1009
+ });
1010
+ }
1011
+ addAsset(asset, referenceCount = 1) {
1012
+ let pointer = null;
1013
+ if (!asset.userData["assetPointer"]) {
1014
+ pointer = new TAssetPointer(asset, referenceCount);
1015
+ asset.userData["assetPointer"] = pointer;
1016
+ }
1017
+ else {
1018
+ pointer = asset.userData["assetPointer"];
1019
+ pointer.addRef(referenceCount);
1020
+ }
1021
+ if (pointer) {
1022
+ this.assetPointer.set(pointer.uuid, pointer);
1023
+ }
1024
+ }
1025
+ releaseAsset(asset) {
1026
+ // let uuid = asset.uuid
1027
+ let p = asset.userData["assetPointer"];
1028
+ if (p) {
1029
+ p.release();
1030
+ }
1031
+ else {
1032
+ asset.dispose();
1033
+ }
1034
+ }
1035
+ clearAssets() {
1036
+ let pointers = Array.from(this.assetPointer.values());
1037
+ pointers.forEach((p) => {
1038
+ p.forceRelease();
1039
+ });
1040
+ this.assetPointer.clear();
1041
+ }
1042
+ }
1043
+ let assetManager = new LYAssetManager();
1044
+
1045
+ class Delegate {
1046
+ constructor() {
1047
+ this.functions = [];
1048
+ }
1049
+ broadcast(...args) {
1050
+ this.functions.forEach((func) => func(...args));
1051
+ }
1052
+ add(func) {
1053
+ this.functions.push(func);
1054
+ }
1055
+ remove(func) {
1056
+ const index = this.functions.indexOf(func);
1057
+ if (index >= 0) {
1058
+ this.functions.splice(index, 1);
1059
+ }
1060
+ else {
1061
+ console.warn("function not found");
1062
+ }
1063
+ }
1064
+ clear() {
1065
+ this.functions = [];
1066
+ }
1067
+ }
1068
+
1069
+ const DefaultPostProcessParam = {
1070
+ toneMapping: {
1071
+ exposure: 1,
1072
+ toneMapping: "AgX"
1073
+ }
1074
+ };
1075
+
1076
+ class World {
1077
+ get scene() {
1078
+ return this._scene;
1079
+ }
1080
+ get viewport() {
1081
+ return this.app.viewport;
1082
+ }
1083
+ get controller() {
1084
+ return this.app.controller;
1085
+ }
1086
+ constructor(app) {
1087
+ this.actors = new Set();
1088
+ this.app = app;
1089
+ this._scene = new three.Scene();
1090
+ }
1091
+ init() {
1092
+ }
1093
+ tick(deltaTime) {
1094
+ this.actors.forEach((elem) => {
1095
+ elem.tick(deltaTime);
1096
+ });
1097
+ }
1098
+ addActor(actor) {
1099
+ if (!actor.rootComponent.threeObject) {
1100
+ throw Error("actor.threeObject is null");
1101
+ }
1102
+ actor.removeFromParent();
1103
+ this.scene.add(actor.rootComponent.threeObject);
1104
+ this.actors.add(actor);
1105
+ actor.onAddedToWorld(this);
1106
+ this.viewport.markRenderStateDirty();
1107
+ }
1108
+ destroy() {
1109
+ }
1110
+ }
1111
+
1112
+ const DefaultToneMappingParams = {
1113
+ exposure: 1.0,
1114
+ toneMapping: 'AgX',
1115
+ };
1116
+ const ToneMappingOptions = new Map([
1117
+ ["None", three.NoToneMapping],
1118
+ ["Linear", three.LinearToneMapping],
1119
+ ["Reinhard", three.ReinhardToneMapping],
1120
+ ["Cineon", three.CineonToneMapping],
1121
+ ["ACESFilmic", three.ACESFilmicToneMapping],
1122
+ ["AgX", three.AgXToneMapping],
1123
+ ["Neutral", three.NeutralToneMapping]
1124
+ ]);
1125
+
1126
+ class WebGPUPostProcessFactory {
1127
+ // scene pass
1128
+ static constructScenePass(scene, camera) {
1129
+ const scenePass = tsl.pass(scene, camera);
1130
+ scenePass.setMRT(tsl.mrt({
1131
+ output: tsl.output,
1132
+ }));
1133
+ return scenePass;
1134
+ }
1135
+ static updateScenePass(scenePass, outputNodes) {
1136
+ let oldMRT = scenePass.getMRT();
1137
+ let newMRT = tsl.mrt(outputNodes);
1138
+ if (oldMRT) {
1139
+ scenePass.setMRT(oldMRT.merge(newMRT));
1140
+ }
1141
+ else {
1142
+ scenePass.setMRT(newMRT);
1143
+ }
1144
+ console.log(scenePass.getMRT(), "MRTTTTTTT");
1145
+ }
1146
+ // bloom pass
1147
+ static constructBloomPass(scenePass, params) {
1148
+ const scenePassColor = scenePass.getTextureNode('output');
1149
+ const bloomPass = BloomNode_js.bloom(scenePassColor);
1150
+ WebGPUPostProcessFactory.updateBloomPass(bloomPass, params);
1151
+ return bloomPass;
1152
+ }
1153
+ static updateBloomPass(bloomPass, params) {
1154
+ bloomPass.threshold.value = params.threshold;
1155
+ bloomPass.strength.value = params.strength;
1156
+ bloomPass.radius.value = params.radius;
1157
+ }
1158
+ // DOF pass
1159
+ static constructDOFPass(scenePass, params) {
1160
+ const scenePassColor = scenePass.getTextureNode('output');
1161
+ const scenePassViewZ = scenePass.getViewZNode();
1162
+ return DepthOfFieldNode_js.dof(scenePassColor, scenePassViewZ, tsl.uniform(params.focus), tsl.uniform(params.aperture).mul(0.00001), tsl.uniform(params.maxblur));
1163
+ }
1164
+ static updateDOFPass(dofPass, params) {
1165
+ dofPass.focus.value = params.focus;
1166
+ dofPass.aperture.value = params.aperture * 0.00001;
1167
+ dofPass.maxblur.value = params.maxblur;
1168
+ }
1169
+ // motion blur
1170
+ static constructMotionBlurPass(lastNode, scenePass, param) {
1171
+ WebGPUPostProcessFactory.updateScenePass(scenePass, { velocity: tsl.velocity });
1172
+ const scenePassVelocity = scenePass.getTextureNode('velocity').mul(param.blurAmount);
1173
+ const scenePassColor = scenePass.getTextureNode('output');
1174
+ const motionBlurPass = MotionBlur_js.motionBlur(scenePassColor, scenePassVelocity);
1175
+ return motionBlurPass;
1176
+ }
1177
+ // ssr
1178
+ static constructSSRPass(scenePass, param) {
1179
+ WebGPUPostProcessFactory.updateScenePass(scenePass, {
1180
+ normal: tsl.transformedNormalView,
1181
+ metalness: tsl.metalness,
1182
+ });
1183
+ const scenePassColor = scenePass.getTextureNode('output');
1184
+ const scenePassNormal = scenePass.getTextureNode('normal');
1185
+ const scenePassDepth = scenePass.getTextureNode('depth');
1186
+ const scenePassMetalness = scenePass.getTextureNode('metalness');
1187
+ const ssrPass = SSRNode_js.ssr(scenePassColor, scenePassDepth, scenePassNormal, scenePassMetalness, scenePass.camera);
1188
+ ssrPass.resolutionScale = 1.0;
1189
+ WebGPUPostProcessFactory.updateSSRPass(ssrPass, param);
1190
+ return ssrPass;
1191
+ }
1192
+ static updateSSRPass(ssrPass, params) {
1193
+ ssrPass.maxDistance.value = params.maxDistance;
1194
+ ssrPass.opacity.value = params.opacity;
1195
+ ssrPass.thickness.value = params.thickness;
1196
+ }
1197
+ // GTAO
1198
+ static constructGTAOPass(scenePass, params) {
1199
+ WebGPUPostProcessFactory.updateScenePass(scenePass, {
1200
+ normal: tsl.transformedNormalView,
1201
+ });
1202
+ const scenePassNormal = scenePass.getTextureNode('normal');
1203
+ const scenePassDepth = scenePass.getTextureNode('depth');
1204
+ const aoPass = GTAONode_js.ao(scenePassDepth, scenePassNormal, scenePass.camera);
1205
+ aoPass.resolutionScale = 0.5;
1206
+ WebGPUPostProcessFactory.updateGTAOPass(aoPass, params);
1207
+ return aoPass;
1208
+ }
1209
+ static updateGTAOPass(gtaoPass, params) {
1210
+ gtaoPass.distanceExponent.value = params.distanceExponent;
1211
+ gtaoPass.distanceFallOff.value = params.distanceFallOff;
1212
+ gtaoPass.radius.value = params.radius;
1213
+ gtaoPass.scale.value = params.scale;
1214
+ gtaoPass.thickness.value = params.thickness;
1215
+ }
1216
+ static constructDenoisePass(scenePass, inputNode, params) {
1217
+ WebGPUPostProcessFactory.updateScenePass(scenePass, {
1218
+ normal: tsl.transformedNormalView,
1219
+ });
1220
+ const scenePassNormal = scenePass.getTextureNode('normal');
1221
+ const scenePassDepth = scenePass.getTextureNode('depth');
1222
+ const denoisePass = DenoiseNode_js.denoise(inputNode, scenePassDepth, scenePassNormal, scenePass.camera);
1223
+ WebGPUPostProcessFactory.updateDenoisePass(denoisePass, params);
1224
+ return denoisePass;
1225
+ }
1226
+ static updateDenoisePass(denoisePass, params) {
1227
+ denoisePass.radius.value = params.denoiseRadius;
1228
+ denoisePass.lumaPhi.value = params.lumaPhi;
1229
+ denoisePass.depthPhi.value = params.depthPhi;
1230
+ denoisePass.normalPhi.value = params.normalPhi;
1231
+ }
1232
+ static constructGTAODenoisePass(scenePass, gtaoPass, params) {
1233
+ return WebGPUPostProcessFactory.constructDenoisePass(scenePass, gtaoPass.getTextureNode(), params.denoiseParam);
1234
+ }
1235
+ static updateGTAODenoisePass(denoisePass, params) {
1236
+ WebGPUPostProcessFactory.updateDenoisePass(denoisePass, params.denoiseParam);
1237
+ }
1238
+ static constructLensFlarePass(inputNode, params) {
1239
+ const lensflarePass = LensflareNode_js.lensflare(inputNode, {
1240
+ threshold: tsl.uniform(params.threshold),
1241
+ ghostAttenuationFactor: tsl.uniform(params.ghostAttenuationFactor),
1242
+ ghostSpacing: tsl.uniform(params.ghostSpacing),
1243
+ });
1244
+ return lensflarePass;
1245
+ }
1246
+ static updateLensFlarPass(lensflarePass, params) {
1247
+ lensflarePass.thresholdNode.value = params.threshold;
1248
+ lensflarePass.ghostSpacingNode.value = params.ghostSpacing;
1249
+ lensflarePass.ghostAttenuationFactorNode.value = params.ghostAttenuationFactor;
1250
+ }
1251
+ static constructOutlinePass(scene, camera, outlineObjects, param) {
1252
+ const outlinePass = OutlineNode_js.outline(scene, camera, {
1253
+ selectedObjects: outlineObjects,
1254
+ edgeGlow: param.edgeGlow,
1255
+ edgeThickness: param.edgeThickness
1256
+ });
1257
+ return outlinePass;
1258
+ }
1259
+ static updateOutlinePass(outlinePass, outlineObjects, params) {
1260
+ outlinePass.edgeGlowNode.value = params.edgeGlow;
1261
+ outlinePass.edgeThicknessNode.value = params.edgeThickness;
1262
+ outlinePass.selectedObjects = outlineObjects;
1263
+ }
1264
+ // fxaa
1265
+ static constructFXAAPass(inputNode) {
1266
+ return FXAANode_js.fxaa(inputNode);
1267
+ }
1268
+ // smaa
1269
+ static constructSMAAPass(inputNode) {
1270
+ return SMAANode_js.smaa(inputNode);
1271
+ }
1272
+ }
1273
+
1274
+ const DefaultOutlineParams = {
1275
+ edgeStrength: 3.0,
1276
+ edgeGlow: 1.0,
1277
+ edgeThickness: 1.0,
1278
+ pulsePeriod: 0.0,
1279
+ visibleEdgeColor: 0xffffff,
1280
+ hiddenEdgeColor: 0xffffff,
1281
+ };
1282
+
1283
+ class Viewport {
1284
+ get canvas() {
1285
+ if (!this._canvas) {
1286
+ throw Error("Canvas is not initialized");
1287
+ }
1288
+ return this._canvas;
1289
+ }
1290
+ get renderer() {
1291
+ if (!this._renderer) {
1292
+ throw Error("Renderer is not initialized");
1293
+ }
1294
+ return this._renderer;
1295
+ }
1296
+ get app() {
1297
+ if (!this._app) {
1298
+ throw Error("App is not initialized");
1299
+ }
1300
+ return this._app;
1301
+ }
1302
+ constructor(app, elementId, rendererParam = { antialias: true }, postProcessParam = {}) {
1303
+ this._renderer = null;
1304
+ this.labelRenderer = null;
1305
+ this._app = null;
1306
+ this.resizeObserver = null;
1307
+ this._canvas = null;
1308
+ this.isRenderStateDirty = true;
1309
+ this.postProcessParam = {};
1310
+ this.postProcessing = null;
1311
+ this.scenePass = null;
1312
+ this.bloomPass = null;
1313
+ this.dofPass = null;
1314
+ this.GTAOPass = null;
1315
+ this.denoiseGTAOPass = null;
1316
+ // private denoiseOutlinePass: ShaderNodeObject<DenoiseNode> | null = null;
1317
+ this.ssrPass = null;
1318
+ this.outlinePass = null;
1319
+ // private motionBlurPass: ShaderNodeObject<Node> | null = null;
1320
+ this.fxaaPass = null;
1321
+ this.smaaPass = null;
1322
+ this.outlineObjects = [];
1323
+ this.postProcessParam = postProcessParam;
1324
+ this._app = app;
1325
+ let element = document.getElementById(elementId);
1326
+ if (!element) {
1327
+ throw Error(`Can not find domElement which id is ${elementId}`);
1328
+ }
1329
+ this._renderer = new webgpu.WebGPURenderer(rendererParam);
1330
+ this._renderer.setPixelRatio(window.devicePixelRatio);
1331
+ this._renderer.setSize(element.clientWidth, element.clientHeight);
1332
+ this._renderer.shadowMap.enabled = true;
1333
+ this.labelRenderer = new Addons_js.CSS2DRenderer();
1334
+ this.labelRenderer.setSize(element.clientWidth, element.clientHeight);
1335
+ this.labelRenderer.domElement.style.pointerEvents = 'none';
1336
+ this.labelRenderer.domElement.style.position = 'absolute';
1337
+ this.labelRenderer.domElement.style.top = '0px';
1338
+ this.labelRenderer.domElement.className = 'scene-labelRenderer';
1339
+ element.appendChild(this.labelRenderer.domElement);
1340
+ element.appendChild(this._renderer.domElement);
1341
+ this._canvas = element;
1342
+ this.resizeObserver = new ResizeObserver((entries) => {
1343
+ for (let entry of entries) {
1344
+ if (entry.contentBoxSize) {
1345
+ this.onWindowResize();
1346
+ }
1347
+ }
1348
+ });
1349
+ this.resizeObserver.observe(this._canvas);
1350
+ this.setupPostProcess();
1351
+ }
1352
+ init() {
1353
+ }
1354
+ setupPostProcess() {
1355
+ if (this.postProcessParam.toneMapping) {
1356
+ let toneMapping = ToneMappingOptions.get(this.postProcessParam.toneMapping.toneMapping);
1357
+ if (toneMapping) {
1358
+ this.renderer.toneMapping = toneMapping;
1359
+ }
1360
+ this.renderer.toneMappingExposure = this.postProcessParam.toneMapping.exposure;
1361
+ }
1362
+ if (!(Object.keys(this.postProcessParam).some(key => ['bloom', 'dof', 'gtao', 'ssr', "outline"].includes(key)))) {
1363
+ this.destroyPostProcess();
1364
+ return;
1365
+ }
1366
+ if (!this.postProcessing) {
1367
+ this.postProcessing = new webgpu.PostProcessing(this.renderer);
1368
+ }
1369
+ if (!this.scenePass) {
1370
+ this.scenePass = WebGPUPostProcessFactory.constructScenePass(this.app.world.scene, this.app.camera);
1371
+ }
1372
+ let finalNode = this.scenePass.getTextureNode('output');
1373
+ // bloom
1374
+ if (this.postProcessParam.bloom) {
1375
+ if (!this.bloomPass) {
1376
+ this.bloomPass = WebGPUPostProcessFactory.constructBloomPass(this.scenePass, this.postProcessParam.bloom);
1377
+ }
1378
+ else {
1379
+ WebGPUPostProcessFactory.updateBloomPass(this.bloomPass, this.postProcessParam.bloom);
1380
+ }
1381
+ finalNode = finalNode.add(this.bloomPass);
1382
+ }
1383
+ else {
1384
+ if (this.bloomPass) {
1385
+ this.bloomPass.dispose();
1386
+ this.bloomPass = null;
1387
+ }
1388
+ }
1389
+ // DOF
1390
+ if (this.postProcessParam.dof) {
1391
+ if (!this.dofPass) {
1392
+ this.dofPass = WebGPUPostProcessFactory.constructDOFPass(this.scenePass, this.postProcessParam.dof);
1393
+ }
1394
+ else {
1395
+ WebGPUPostProcessFactory.updateDOFPass(this.dofPass, this.postProcessParam.dof);
1396
+ }
1397
+ finalNode = this.dofPass;
1398
+ }
1399
+ else {
1400
+ if (this.dofPass) {
1401
+ this.dofPass.dispose();
1402
+ this.dofPass = null;
1403
+ }
1404
+ }
1405
+ // motion blur
1406
+ // if (this.postProcessParam.motionBlur)
1407
+ // {
1408
+ // if (!this.motionBlurPass)
1409
+ // {
1410
+ // this.motionBlurPass = WebGPUPostProcessFactory.constructMotionBlurPass(finalNode, this.scenePass, this.postProcessParam.motionBlur);
1411
+ // }
1412
+ // const vignette = screenUV.distance(.5).remap(.6, 1).mul(2).clamp().oneMinus();
1413
+ // finalNode = mix(this.motionBlurPass, this.scenePass.getTextureNode("velocity"), 0).mul(vignette);
1414
+ // }
1415
+ // else
1416
+ // {
1417
+ // if (this.motionBlurPass)
1418
+ // {
1419
+ // this.motionBlurPass.dispose();
1420
+ // this.motionBlurPass = null;
1421
+ // }
1422
+ // }
1423
+ // ssr
1424
+ if (this.postProcessParam.ssr) {
1425
+ if (!this.ssrPass) {
1426
+ this.ssrPass = WebGPUPostProcessFactory.constructSSRPass(this.scenePass, this.postProcessParam.ssr);
1427
+ }
1428
+ else {
1429
+ WebGPUPostProcessFactory.updateSSRPass(this.ssrPass, this.postProcessParam.ssr);
1430
+ }
1431
+ finalNode = tsl.blendColor(finalNode, this.ssrPass);
1432
+ }
1433
+ // GTAO
1434
+ if (this.postProcessParam.gtao) {
1435
+ if (!this.GTAOPass) {
1436
+ this.GTAOPass = WebGPUPostProcessFactory.constructGTAOPass(this.scenePass, this.postProcessParam.gtao);
1437
+ }
1438
+ else {
1439
+ WebGPUPostProcessFactory.updateGTAOPass(this.GTAOPass, this.postProcessParam.gtao);
1440
+ }
1441
+ if (this.postProcessParam.gtao.denoised) {
1442
+ if (!this.denoiseGTAOPass) {
1443
+ this.denoiseGTAOPass = WebGPUPostProcessFactory.constructGTAODenoisePass(this.scenePass, this.GTAOPass, this.postProcessParam.gtao);
1444
+ }
1445
+ else {
1446
+ WebGPUPostProcessFactory.updateGTAOPass(this.GTAOPass, this.postProcessParam.gtao);
1447
+ }
1448
+ finalNode = this.denoiseGTAOPass.mul(finalNode);
1449
+ }
1450
+ else {
1451
+ finalNode = this.GTAOPass.getTextureNode().mul(finalNode);
1452
+ if (this.denoiseGTAOPass) {
1453
+ this.denoiseGTAOPass.dispose();
1454
+ this.denoiseGTAOPass = null;
1455
+ }
1456
+ }
1457
+ }
1458
+ else {
1459
+ if (this.GTAOPass) {
1460
+ this.GTAOPass.dispose();
1461
+ this.GTAOPass = null;
1462
+ }
1463
+ if (this.denoiseGTAOPass) {
1464
+ this.denoiseGTAOPass.dispose();
1465
+ this.denoiseGTAOPass = null;
1466
+ }
1467
+ }
1468
+ // outline
1469
+ if (this.postProcessParam.outline) {
1470
+ if (!this.outlinePass) {
1471
+ this.outlinePass = WebGPUPostProcessFactory.constructOutlinePass(this.app.world.scene, this.scenePass.camera, this.outlineObjects, this.postProcessParam.outline);
1472
+ }
1473
+ else {
1474
+ WebGPUPostProcessFactory.updateOutlinePass(this.outlinePass, this.outlineObjects, this.postProcessParam.outline);
1475
+ }
1476
+ const { visibleEdge, hiddenEdge } = this.outlinePass;
1477
+ const pulsePeriod = tsl.uniform(this.postProcessParam.outline.pulsePeriod);
1478
+ const period = tsl.time.div(pulsePeriod).mul(2);
1479
+ const osc = tsl.oscSine(period).mul(.5).add(.5);
1480
+ const outlineColor = visibleEdge.mul(tsl.uniform(new webgpu.Color(this.postProcessParam.outline.visibleEdgeColor))).add(hiddenEdge.mul(tsl.uniform(new webgpu.Color(this.postProcessParam.outline.hiddenEdgeColor)))).mul(this.postProcessParam.outline.edgeStrength);
1481
+ const outlinePulse = pulsePeriod.greaterThan(0).select(outlineColor.mul(osc), outlineColor);
1482
+ // if(!this.denoiseOutlinePass)
1483
+ // {
1484
+ // this.denoiseOutlinePass = WebGPUPostProcessFactory.constructDenoisePass(this.scenePass, outlinePulse, DefaultDenoiseParam);
1485
+ // }
1486
+ // outlinePulse = this.denoiseOutlinePass.mul(outlinePulse)
1487
+ // finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
1488
+ finalNode = outlinePulse.add(finalNode);
1489
+ // finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
1490
+ }
1491
+ else {
1492
+ if (this.outlinePass) {
1493
+ this.outlinePass.dispose();
1494
+ this.outlinePass = null;
1495
+ }
1496
+ }
1497
+ if (this.postProcessParam.aa) {
1498
+ if (this.postProcessParam.aa === "fxaa") {
1499
+ this.fxaaPass = WebGPUPostProcessFactory.constructFXAAPass(finalNode);
1500
+ finalNode = this.fxaaPass;
1501
+ }
1502
+ if (this.postProcessParam.aa === "smaa") {
1503
+ this.smaaPass = WebGPUPostProcessFactory.constructSMAAPass(finalNode);
1504
+ finalNode = this.smaaPass;
1505
+ }
1506
+ }
1507
+ else {
1508
+ if (this.fxaaPass) {
1509
+ this.fxaaPass.dispose();
1510
+ this.fxaaPass = null;
1511
+ }
1512
+ if (this.smaaPass) {
1513
+ this.smaaPass.dispose();
1514
+ this.smaaPass = null;
1515
+ }
1516
+ }
1517
+ console.log(this.postProcessParam, "sssssssssssssssssssss");
1518
+ this.postProcessing.outputNode = finalNode;
1519
+ this.markRenderStateDirty();
1520
+ }
1521
+ updateToneMappingParam(params) {
1522
+ this.postProcessParam.toneMapping = params;
1523
+ this.setupPostProcess();
1524
+ this.markRenderStateDirty();
1525
+ }
1526
+ updateBloomPass(params) {
1527
+ this.postProcessParam.bloom = params;
1528
+ this.setupPostProcess();
1529
+ }
1530
+ updateGTAOParam(params) {
1531
+ this.postProcessParam.gtao = params;
1532
+ this.setupPostProcess();
1533
+ }
1534
+ updateDOFParam(params) {
1535
+ this.postProcessParam.dof = params;
1536
+ this.setupPostProcess();
1537
+ }
1538
+ updateSSRParam(params) {
1539
+ this.postProcessParam.ssr = params;
1540
+ this.setupPostProcess();
1541
+ }
1542
+ updateOutlineParam(params) {
1543
+ this.postProcessParam.outline = params;
1544
+ this.setupPostProcess();
1545
+ }
1546
+ addOutlineObject(obj) {
1547
+ if (!this.outlineObjects.includes(obj)) {
1548
+ this.outlineObjects.push(obj);
1549
+ }
1550
+ if (!this.postProcessParam.outline) {
1551
+ this.postProcessParam.outline = DefaultOutlineParams;
1552
+ this.setupPostProcess();
1553
+ }
1554
+ else {
1555
+ this.markRenderStateDirty();
1556
+ }
1557
+ }
1558
+ removeOutlineObject(obj) {
1559
+ if (!this.postProcessParam.outline) {
1560
+ this.outlineObjects = [];
1561
+ return;
1562
+ }
1563
+ const index = this.outlineObjects.indexOf(obj);
1564
+ if (index > -1) {
1565
+ this.outlineObjects.splice(index, 1);
1566
+ }
1567
+ this.markRenderStateDirty();
1568
+ }
1569
+ destroyPostProcess() {
1570
+ if (this.bloomPass) {
1571
+ this.bloomPass.dispose();
1572
+ this.bloomPass = null;
1573
+ }
1574
+ if (this.dofPass) {
1575
+ this.dofPass.dispose();
1576
+ this.dofPass = null;
1577
+ }
1578
+ if (this.GTAOPass) {
1579
+ this.GTAOPass.dispose();
1580
+ this.GTAOPass = null;
1581
+ }
1582
+ if (this.denoiseGTAOPass) {
1583
+ this.denoiseGTAOPass.dispose();
1584
+ this.denoiseGTAOPass = null;
1585
+ }
1586
+ if (this.ssrPass) {
1587
+ this.ssrPass.dispose();
1588
+ this.ssrPass = null;
1589
+ }
1590
+ if (this.outlinePass) {
1591
+ this.outlinePass.dispose();
1592
+ this.outlinePass = null;
1593
+ }
1594
+ this.outlineObjects = [];
1595
+ if (this.scenePass) {
1596
+ this.scenePass.dispose();
1597
+ this.scenePass = null;
1598
+ }
1599
+ if (this.postProcessing) {
1600
+ this.postProcessing.dispose();
1601
+ this.postProcessing = null;
1602
+ }
1603
+ }
1604
+ onWindowResize() {
1605
+ console.log("resize");
1606
+ let ele = this._canvas;
1607
+ if (!ele) {
1608
+ return;
1609
+ }
1610
+ this.app.onWindowResize(ele.clientWidth, ele.clientHeight);
1611
+ this.renderer.setSize(ele.clientWidth, ele.clientHeight);
1612
+ if (this.labelRenderer)
1613
+ this.labelRenderer.setSize(ele.clientWidth, ele.clientHeight);
1614
+ this.markRenderStateDirty();
1615
+ }
1616
+ markRenderStateDirty() {
1617
+ this.isRenderStateDirty = true;
1618
+ }
1619
+ render() {
1620
+ if (!this.isRenderStateDirty) {
1621
+ return;
1622
+ }
1623
+ if (this.postProcessing) {
1624
+ this.postProcessing.render();
1625
+ }
1626
+ else { //console.log("render renderer");
1627
+ this.renderer.render(this.app.world.scene, this.app.camera);
1628
+ }
1629
+ this.isRenderStateDirty = false;
1630
+ }
1631
+ destroy() {
1632
+ var _a;
1633
+ this.destroyPostProcess();
1634
+ this.renderer.setAnimationLoop(null);
1635
+ if (this.resizeObserver) {
1636
+ this.resizeObserver.disconnect();
1637
+ this.resizeObserver = null;
1638
+ }
1639
+ if (this.labelRenderer) {
1640
+ this.labelRenderer.domElement.remove();
1641
+ this.labelRenderer = null;
1642
+ }
1643
+ if (this._renderer) {
1644
+ this.renderer.domElement.remove();
1645
+ this._renderer.dispose();
1646
+ this._renderer = null;
1647
+ }
1648
+ (_a = this.postProcessing) === null || _a === void 0 ? void 0 : _a.dispose();
1649
+ this._canvas = null;
1650
+ this._app = null;
1651
+ this._renderer = null;
1652
+ this.outlineObjects = [];
1653
+ }
1654
+ }
1655
+
1656
+ class Pawn {
1657
+ get camera() {
1658
+ return this.controller.camera;
1659
+ }
1660
+ set enabled(value) {
1661
+ this.control.enabled = value;
1662
+ }
1663
+ get control() {
1664
+ if (!this._control) {
1665
+ throw new Error("Control not initialized");
1666
+ }
1667
+ return this._control;
1668
+ }
1669
+ constructor(controller) {
1670
+ this._control = null;
1671
+ this.isTickEnabled = false;
1672
+ this.controller = controller;
1673
+ }
1674
+ tick(deltaTime) {
1675
+ return;
1676
+ }
1677
+ possess() {
1678
+ }
1679
+ unpossess() {
1680
+ }
1681
+ destroy() {
1682
+ }
1683
+ }
1684
+
1685
+ class Orbital extends Pawn {
1686
+ get control() {
1687
+ if (!this._control) {
1688
+ throw new Error("Control not initialized");
1689
+ }
1690
+ return this._control;
1691
+ }
1692
+ constructor(controller) {
1693
+ super(controller);
1694
+ this.changeEvent = () => { this.onChange(); };
1695
+ this._control = new Addons_js.OrbitControls(controller.camera, controller.viewPort.canvas);
1696
+ this.control.target.set(0, 0, 0);
1697
+ controller.camera.position.set(0, 4, 4);
1698
+ this.control.update();
1699
+ }
1700
+ possess() {
1701
+ super.possess();
1702
+ this.control.addEventListener('change', this.changeEvent);
1703
+ }
1704
+ unpossess() {
1705
+ super.unpossess();
1706
+ this.control.removeEventListener("change", this.changeEvent);
1707
+ }
1708
+ onChange() {
1709
+ this.controller.viewPort.markRenderStateDirty();
1710
+ }
1711
+ }
1712
+
1713
+ class Controller {
1714
+ get camera() {
1715
+ return this.app.camera;
1716
+ }
1717
+ get world() {
1718
+ return this.app.world;
1719
+ }
1720
+ get viewPort() {
1721
+ return this.app.viewport;
1722
+ }
1723
+ get pawn() {
1724
+ if (!this._pawn) {
1725
+ throw Error("pawn is null");
1726
+ }
1727
+ return this._pawn;
1728
+ }
1729
+ get onClickNothingDelegate() {
1730
+ return this._onClickNothingDelegate;
1731
+ }
1732
+ constructor(app) {
1733
+ this.prepareClickComponent = null;
1734
+ this._pawn = null;
1735
+ this.onPointerMove = (event) => { this.onPointerMoveEvent(event); };
1736
+ this.onPointerEnter = (event) => { this.onPointerEnterEvent(event); };
1737
+ this.onPointerLeave = (event) => { this.onPointerLeaveEvent(event); };
1738
+ this.onPointerUp = (event) => { this.onPointerUpEvent(event); };
1739
+ this.onPointerDown = (event) => { this.onPointerDownEvent(event); };
1740
+ this.pointerPosition = new three.Vector2();
1741
+ this.doubleClickDelay = 250; // 双击判定时间间隔(毫秒)
1742
+ this.leftClickTimer = null;
1743
+ this.pointerLeftDownPosition = new three.Vector2();
1744
+ this.hoveringComponent = null;
1745
+ this._pointButtonIsDown = new Set();
1746
+ this._onClickNothingDelegate = new Delegate();
1747
+ this.app = app;
1748
+ this._pawn = new Orbital(this);
1749
+ this.pawn.possess();
1750
+ this.raycaster = new three.Raycaster();
1751
+ if (!this.viewPort.canvas) {
1752
+ throw Error("canvas is null");
1753
+ }
1754
+ this.viewPort.canvas.addEventListener("pointermove", this.onPointerMove);
1755
+ this.viewPort.canvas.addEventListener("pointerenter", this.onPointerEnter);
1756
+ this.viewPort.canvas.addEventListener("pointerleave", this.onPointerLeave);
1757
+ this.viewPort.canvas.addEventListener("pointerup", this.onPointerUp);
1758
+ this.viewPort.canvas.addEventListener("pointerdown", this.onPointerDown);
1759
+ }
1760
+ init() {
1761
+ }
1762
+ tick(deltaTime) {
1763
+ this.pawn.tick(deltaTime);
1764
+ }
1765
+ destroy() {
1766
+ if (this.leftClickTimer) {
1767
+ clearTimeout(this.leftClickTimer);
1768
+ this.leftClickTimer = null;
1769
+ }
1770
+ if (this.viewPort.canvas) {
1771
+ this.viewPort.canvas.removeEventListener("pointermove", this.onPointerMove);
1772
+ this.viewPort.canvas.removeEventListener("pointerenter", this.onPointerEnter);
1773
+ this.viewPort.canvas.removeEventListener("pointerleave", this.onPointerLeave);
1774
+ this.viewPort.canvas.removeEventListener("pointerup", this.onPointerUp);
1775
+ this.viewPort.canvas.removeEventListener("pointerdown", this.onPointerDown);
1776
+ }
1777
+ this.pawn.unpossess();
1778
+ this.pawn.destroy();
1779
+ this._pawn = null;
1780
+ }
1781
+ onPointerMoveEvent(event) {
1782
+ var _a, _b;
1783
+ if (!this.viewPort.canvas) {
1784
+ throw Error("canvas is null");
1785
+ }
1786
+ const canvasRect = this.viewPort.canvas.getBoundingClientRect();
1787
+ const offsetX = canvasRect.left;
1788
+ const offsetY = canvasRect.top;
1789
+ const pointer = new three.Vector2(((event.clientX - offsetX) / this.viewPort.canvas.clientWidth) * 2 - 1, 1 - ((event.clientY - offsetY) / this.viewPort.canvas.clientHeight) * 2);
1790
+ this.pointerPosition = pointer;
1791
+ if (this._pointButtonIsDown.size > 0) {
1792
+ return;
1793
+ }
1794
+ const hits = this.getHitResultUnderCursor();
1795
+ if (hits) {
1796
+ let component = hits.object.userData["LYObject"];
1797
+ if (component != this.hoveringComponent) {
1798
+ (_a = this.hoveringComponent) === null || _a === void 0 ? void 0 : _a.onHorveringEnd();
1799
+ this.hoveringComponent = null;
1800
+ if (component instanceof SceneComponent && component.isHoverEnabled) {
1801
+ component.onHorveringBegin();
1802
+ this.hoveringComponent = component;
1803
+ }
1804
+ }
1805
+ }
1806
+ else {
1807
+ (_b = this.hoveringComponent) === null || _b === void 0 ? void 0 : _b.onHorveringEnd();
1808
+ this.hoveringComponent = null;
1809
+ }
1810
+ }
1811
+ onPointerUpEvent(event) {
1812
+ this._pointButtonIsDown.delete(event.button);
1813
+ if (event.button === 0) {
1814
+ const pointerOffset = new three.Vector2().subVectors(this.pointerLeftDownPosition, this.pointerPosition).length();
1815
+ if (pointerOffset > 0.005) {
1816
+ if (this.leftClickTimer) {
1817
+ window.clearTimeout(this.leftClickTimer);
1818
+ this.leftClickTimer = null;
1819
+ }
1820
+ return;
1821
+ }
1822
+ if (!this.leftClickTimer) {
1823
+ const hit = this.getHitResultUnderCursor();
1824
+ let component = hit ? hit.object.userData["LYObject"] : null;
1825
+ if (component && component instanceof SceneComponent && component.isClickEnabled) {
1826
+ this.prepareClickComponent = component;
1827
+ this.leftClickTimer = window.setTimeout(() => {
1828
+ this.leftClickTimer = null;
1829
+ if (this.prepareClickComponent) {
1830
+ this.prepareClickComponent.onClicked();
1831
+ this.prepareClickComponent = null;
1832
+ }
1833
+ }, this.doubleClickDelay);
1834
+ }
1835
+ else {
1836
+ this._onClickNothingDelegate.broadcast();
1837
+ }
1838
+ }
1839
+ else {
1840
+ console.log("up 2, ", this.prepareClickComponent);
1841
+ window.clearTimeout(this.leftClickTimer);
1842
+ this.leftClickTimer = null;
1843
+ if (this.prepareClickComponent) {
1844
+ this.prepareClickComponent.onDoubleClicked();
1845
+ }
1846
+ else {
1847
+ this._onClickNothingDelegate.broadcast();
1848
+ }
1849
+ this.prepareClickComponent = null;
1850
+ }
1851
+ }
1852
+ }
1853
+ onPointerDownEvent(event) {
1854
+ this._pointButtonIsDown.add(event.button);
1855
+ if (event.button === 0) {
1856
+ this.pointerLeftDownPosition = this.pointerPosition.clone();
1857
+ }
1858
+ }
1859
+ onPointerEnterEvent(event) {
1860
+ if (!this.viewPort.canvas) {
1861
+ throw Error("canvas is null");
1862
+ }
1863
+ this.viewPort.canvas.addEventListener("pointermove", this.onPointerMove);
1864
+ this.viewPort.canvas.addEventListener("pointerup", this.onPointerUp);
1865
+ this.viewPort.canvas.addEventListener("pointerdown", this.onPointerDown);
1866
+ }
1867
+ onPointerLeaveEvent(event) {
1868
+ if (!this.viewPort.canvas) {
1869
+ throw Error("canvas is null");
1870
+ }
1871
+ this.viewPort.canvas.removeEventListener("pointermove", this.onPointerMove);
1872
+ this.viewPort.canvas.removeEventListener("pointerup", this.onPointerUp);
1873
+ this.viewPort.canvas.removeEventListener("pointerdown", this.onPointerDown);
1874
+ }
1875
+ getHitResultUnderCursor() {
1876
+ return this.getHitResultFromScreenPoint(this.pointerPosition.x, this.pointerPosition.y);
1877
+ }
1878
+ getHitResultFromScreenPoint(x, y) {
1879
+ this.raycaster.setFromCamera(new three.Vector2(x, y), this.camera);
1880
+ let out = this.raycaster.intersectObjects(this.world.scene.children, true);
1881
+ for (let i = 0; i < out.length; i++) {
1882
+ if (out[i].object.userData["rayIgnored"]) {
1883
+ continue;
1884
+ }
1885
+ return out[i];
1886
+ }
1887
+ return null;
1888
+ }
1889
+ }
1890
+
1891
+ class CameraFactory {
1892
+ static createCamera(param) {
1893
+ let cam = null;
1894
+ if ("fov" in param.param && "aspect" in param.param) {
1895
+ cam = new three.PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
1896
+ }
1897
+ if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param) {
1898
+ cam = new three.OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
1899
+ }
1900
+ if (!cam) {
1901
+ console.error("create camera failed");
1902
+ debugger;
1903
+ throw Error("create camera failed");
1904
+ }
1905
+ return cam;
1906
+ }
1907
+ static updataCamera(param, camera) {
1908
+ if ("fov" in param.param && "aspect" in param.param) {
1909
+ if (camera instanceof three.PerspectiveCamera) {
1910
+ camera.near = param.near;
1911
+ camera.far = param.far;
1912
+ camera.fov = param.param.fov;
1913
+ camera.aspect = param.param.aspect;
1914
+ return camera;
1915
+ }
1916
+ else {
1917
+ return new three.PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
1918
+ }
1919
+ }
1920
+ if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param) {
1921
+ if (camera instanceof three.OrthographicCamera) {
1922
+ camera.near = param.near;
1923
+ camera.far = param.far;
1924
+ camera.left = param.param.left;
1925
+ camera.right = param.param.right;
1926
+ camera.top = param.param.top;
1927
+ camera.bottom = param.param.bottom;
1928
+ return camera;
1929
+ }
1930
+ else {
1931
+ return new three.OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
1932
+ }
1933
+ }
1934
+ }
1935
+ }
1936
+
1937
+ const DefaultRenderParam = {
1938
+ antialias: true,
1939
+ };
1940
+ const DefaultCameraParam = {
1941
+ near: 0.1,
1942
+ far: 1000,
1943
+ param: {
1944
+ fov: 50,
1945
+ aspect: 1,
1946
+ }
1947
+ };
1948
+ const DefaultAppParam = {
1949
+ renderParam: DefaultRenderParam,
1950
+ cameraParam: DefaultCameraParam,
1951
+ postProcessParam: DefaultPostProcessParam,
1952
+ };
1953
+ class ThreeJsApp {
1954
+ get camera() {
1955
+ return this._camera;
1956
+ }
1957
+ get clock() {
1958
+ return this._clock;
1959
+ }
1960
+ get world() {
1961
+ return this._world;
1962
+ }
1963
+ get viewport() {
1964
+ return this._viewport;
1965
+ }
1966
+ get controller() {
1967
+ return this._controller;
1968
+ }
1969
+ get worldClass() {
1970
+ return World;
1971
+ }
1972
+ get viewportClass() {
1973
+ return Viewport;
1974
+ }
1975
+ get controllerClass() {
1976
+ return Controller;
1977
+ }
1978
+ constructor(elementId, appParam = DefaultAppParam) {
1979
+ this._clock = new three.Clock();
1980
+ this._camera = CameraFactory.createCamera(appParam.cameraParam ? appParam.cameraParam : DefaultCameraParam);
1981
+ this._world = new this.worldClass(this);
1982
+ this._viewport = new this.viewportClass(this, elementId, appParam.renderParam ? appParam.renderParam : DefaultRenderParam, appParam.postProcessParam ? appParam.postProcessParam : DefaultPostProcessParam);
1983
+ this._controller = new this.controllerClass(this);
1984
+ this.viewport.renderer.setAnimationLoop(() => {
1985
+ this.tick();
1986
+ });
1987
+ this.init();
1988
+ }
1989
+ init() {
1990
+ this.controller.init();
1991
+ this.world.init();
1992
+ this.viewport.init();
1993
+ }
1994
+ tick() {
1995
+ const delta = this._clock.getDelta();
1996
+ this._controller.tick(delta);
1997
+ this.world.tick(delta);
1998
+ this.viewport.render();
1999
+ }
2000
+ onWindowResize(width, height) {
2001
+ if (this.camera instanceof three.PerspectiveCamera) {
2002
+ this.camera.aspect = width / height;
2003
+ }
2004
+ // if(this.camera instanceof OrthographicCamera)
2005
+ // {
2006
+ // // to do
2007
+ // }
2008
+ this.camera.updateProjectionMatrix();
2009
+ }
2010
+ destroy() {
2011
+ this.world.destroy();
2012
+ this.controller.destroy();
2013
+ this.viewport.destroy();
2014
+ }
2015
+ }
2016
+
2017
+ class Actor extends BaseObject {
2018
+ get world() {
2019
+ return this._world;
2020
+ }
2021
+ get name() {
2022
+ console.log("getname", this._name);
2023
+ return this._name;
2024
+ }
2025
+ set name(name) {
2026
+ this._name = name;
2027
+ }
2028
+ get rootComponent() {
2029
+ if (!this._rootComponent) {
2030
+ throw Error("rootComponent is invalid");
2031
+ }
2032
+ return this._rootComponent;
2033
+ }
2034
+ set rootComponent(newRoot) {
2035
+ newRoot.detachFromParentComponent();
2036
+ newRoot.parentActor = this;
2037
+ if (this._rootComponent) {
2038
+ let child = this.rootComponent.childrenComponents;
2039
+ for (let i = 0; i < child.length; ++i) {
2040
+ newRoot.addChildComponent(child[i]);
2041
+ }
2042
+ this.rootComponent.destroy();
2043
+ }
2044
+ this._rootComponent = newRoot;
2045
+ }
2046
+ get childrenComponents() {
2047
+ return this.rootComponent.childrenComponents;
2048
+ }
2049
+ get childActors() {
2050
+ var _a;
2051
+ let ret = [];
2052
+ (_a = this.rootComponent.threeObject) === null || _a === void 0 ? void 0 : _a.children.forEach((elem) => {
2053
+ var _a;
2054
+ let p = (_a = elem.userData["LYObject"]) === null || _a === void 0 ? void 0 : _a.parentActor;
2055
+ if (p !== this && p instanceof Actor) {
2056
+ ret.push(p);
2057
+ }
2058
+ });
2059
+ return ret;
2060
+ }
2061
+ get parentActor() {
2062
+ var _a, _b;
2063
+ let parent = (_b = (_a = this.rootComponent.threeObject) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.userData["LYObject"].parentActor;
2064
+ return parent === this ? null : parent;
2065
+ }
2066
+ get isVisible() {
2067
+ return this.rootComponent ? this.rootComponent.isVisible : false;
2068
+ }
2069
+ constructor(myThreeObject = null) {
2070
+ super();
2071
+ this._name = "Actor";
2072
+ this._rootComponent = null;
2073
+ this._world = null;
2074
+ this.onClickedEvent = [];
2075
+ this.onDoubleClickedEvent = [];
2076
+ this.onHoverBeginEvent = [];
2077
+ this.onHoverEndEvent = [];
2078
+ this.constructRootComponent(myThreeObject);
2079
+ }
2080
+ constructRootComponent(myThreeObject = null) {
2081
+ let tObject = myThreeObject ? myThreeObject : new three.Group();
2082
+ if (tObject.isMesh) {
2083
+ let mesh = tObject;
2084
+ this._rootComponent = new MeshComponent(mesh);
2085
+ this.rootComponent.parentActor = this;
2086
+ }
2087
+ else {
2088
+ this._rootComponent = new SceneComponent(tObject);
2089
+ this.rootComponent.parentActor = this;
2090
+ }
2091
+ }
2092
+ getBoundsCenterPosition(bInWorldSpace = true) {
2093
+ let ret = new three.Vector3();
2094
+ this.getBounds().getCenter(ret);
2095
+ if (!bInWorldSpace) {
2096
+ return ret.sub(this.getPosition());
2097
+ }
2098
+ else {
2099
+ return ret;
2100
+ }
2101
+ }
2102
+ getBoundsTopCenterPosition(bInWorldSpace = true) {
2103
+ let ret = new three.Vector3();
2104
+ let bounds = this.rootComponent.getBounds();
2105
+ bounds.getCenter(ret);
2106
+ ret.y = bounds.max.y;
2107
+ if (!bInWorldSpace) {
2108
+ return ret.sub(this.getPosition());
2109
+ }
2110
+ else {
2111
+ return ret;
2112
+ }
2113
+ }
2114
+ getBoundsBottomCenterPosition(bInWorldSpace = true) {
2115
+ let ret = new three.Vector3();
2116
+ let bounds = this.getBounds();
2117
+ bounds.getCenter(ret);
2118
+ ret.y = bounds.min.y;
2119
+ if (!bInWorldSpace) {
2120
+ return ret.sub(this.getPosition());
2121
+ }
2122
+ else {
2123
+ return ret;
2124
+ }
2125
+ }
2126
+ getBounds() {
2127
+ return this.rootComponent.getBounds();
2128
+ }
2129
+ destroy() {
2130
+ let childActors = this.childActors;
2131
+ childActors.forEach((elem) => {
2132
+ elem.destroy();
2133
+ });
2134
+ this.rootComponent.destroy();
2135
+ }
2136
+ setVisible(bVisible) {
2137
+ this.rootComponent.setVisible(bVisible);
2138
+ }
2139
+ setLayers(layer, bAffectChildActor = true) {
2140
+ this.rootComponent.setLayers(layer);
2141
+ if (bAffectChildActor) {
2142
+ this.childActors.forEach((child) => {
2143
+ child.setLayers(layer, bAffectChildActor);
2144
+ });
2145
+ }
2146
+ }
2147
+ tick(deltaTime) {
2148
+ super.tick(deltaTime);
2149
+ this.rootComponent.tick(deltaTime);
2150
+ }
2151
+ // Local Transforms
2152
+ // // Position
2153
+ getPosition() {
2154
+ return this.rootComponent.getPosition();
2155
+ }
2156
+ setPosition(...args) {
2157
+ if (args.length === 1) {
2158
+ this.rootComponent.setPosition(args[0]);
2159
+ }
2160
+ else {
2161
+ this.rootComponent.setPosition(args[0], args[1], args[2]);
2162
+ }
2163
+ }
2164
+ // // Rotation (euler)
2165
+ getRotation() {
2166
+ return this.rootComponent.getRotation();
2167
+ }
2168
+ setRotation(...args) {
2169
+ if (args.length === 1) {
2170
+ this.rootComponent.setRotation(args[0]);
2171
+ }
2172
+ else {
2173
+ this.rootComponent.setRotation(args[0], args[1], args[2]);
2174
+ }
2175
+ }
2176
+ // // quat
2177
+ getQuaternion() {
2178
+ return this.rootComponent.getQuaternion();
2179
+ }
2180
+ setQuaternion(...args) {
2181
+ if (args.length === 1) {
2182
+ this.rootComponent.setQuaternion(args[0]);
2183
+ }
2184
+ else {
2185
+ this.rootComponent.setQuaternion(args[0], args[1], args[2], args[3]);
2186
+ }
2187
+ }
2188
+ // // Scale
2189
+ getScale() {
2190
+ return this.rootComponent.getScale();
2191
+ }
2192
+ setScale(...args) {
2193
+ if (args.length === 1) {
2194
+ this.rootComponent.setScale(args[0]);
2195
+ }
2196
+ else {
2197
+ this.rootComponent.setScale(args[0], args[1], args[2]);
2198
+ }
2199
+ }
2200
+ // World Transform
2201
+ // // Matrix
2202
+ getWorldMatrix() {
2203
+ return this.rootComponent.getWorldMatrix();
2204
+ }
2205
+ setWorldMatrix(newMatrix) {
2206
+ this.rootComponent.setWorldMatrix(newMatrix);
2207
+ }
2208
+ // // WorldPosition
2209
+ getWorldPosition() {
2210
+ return this.rootComponent.getWorldPosition();
2211
+ }
2212
+ // setWorldPosition(param1, param2 = undefined, param3 = undefined)
2213
+ // {
2214
+ // }
2215
+ // // rotation(euler)
2216
+ getWorldRotation() {
2217
+ return this.rootComponent.getWorldRotation();
2218
+ }
2219
+ // // rotation(quat)
2220
+ getWorldQuaternion() {
2221
+ return this.rootComponent.getWorldQuaternion();
2222
+ }
2223
+ // // Scale
2224
+ getWorldScale() {
2225
+ return this.rootComponent.getWorldScale();
2226
+ }
2227
+ getWorldForwardDirection() {
2228
+ return this.rootComponent.getWorldForwardDirection();
2229
+ }
2230
+ getWorldUpDirection() {
2231
+ return this.rootComponent.getWorldUpDirection();
2232
+ }
2233
+ getWorldRightDirection() {
2234
+ return this.rootComponent.getWorldRightDirection();
2235
+ }
2236
+ addLocalOffset(axis, value) {
2237
+ let pos = this.getPosition();
2238
+ this.setPosition(pos.x + axis.x * value, pos.y + axis.y * value, pos.z + axis.z * value);
2239
+ }
2240
+ worldToLocal(vec) {
2241
+ return this.rootComponent.worldToLocal(vec);
2242
+ }
2243
+ localToWorld(vec) {
2244
+ return this.rootComponent.localToWorld(vec);
2245
+ }
2246
+ getComponents() {
2247
+ return this.rootComponent.childrenComponents;
2248
+ }
2249
+ addComponent(newComponent, attachmentRule = exports.AttachmentRules.KeepRelative) {
2250
+ this.rootComponent.addChildComponent(newComponent, attachmentRule);
2251
+ if (this._world) {
2252
+ newComponent.onAddedToWorld(this._world);
2253
+ }
2254
+ }
2255
+ removeComponent(targetComponent) {
2256
+ if (targetComponent === this._rootComponent) {
2257
+ return;
2258
+ }
2259
+ this.rootComponent.removeChildComponent(targetComponent);
2260
+ }
2261
+ clearComponent() {
2262
+ this.rootComponent.destroyChildren();
2263
+ }
2264
+ addChildActor(newActor, attachmentRule = exports.AttachmentRules.KeepWorld) {
2265
+ if (!(newActor.rootComponent)) {
2266
+ console.error("Actor :: addChildActor : the 'newActor' you want to add has no rootcomponent");
2267
+ return;
2268
+ }
2269
+ if (newActor.parentActor === this) {
2270
+ return;
2271
+ }
2272
+ if (attachmentRule === exports.AttachmentRules.KeepRelative) {
2273
+ this.rootComponent.attachComponent(newActor.rootComponent);
2274
+ }
2275
+ if (attachmentRule === exports.AttachmentRules.KeepWorld) {
2276
+ let worldMatrix = newActor.getWorldMatrix();
2277
+ this.rootComponent.attachComponent(newActor.rootComponent);
2278
+ newActor.setWorldMatrix(worldMatrix);
2279
+ }
2280
+ if (this._world) {
2281
+ this._world.viewport.markRenderStateDirty();
2282
+ }
2283
+ }
2284
+ removeChildActor(target) {
2285
+ let worldMatrix = target.getWorldMatrix();
2286
+ this.rootComponent.detachComponent(target.rootComponent);
2287
+ target.setWorldMatrix(worldMatrix);
2288
+ }
2289
+ removeFromParent() {
2290
+ if (this.parentActor) {
2291
+ this.parentActor.removeChildActor(this);
2292
+ }
2293
+ }
2294
+ onAddedToWorld(world) {
2295
+ this._world = world;
2296
+ this.rootComponent.onAddedToWorld(this._world);
2297
+ this.childActors.forEach((elem) => {
2298
+ elem.onAddedToWorld(world);
2299
+ });
2300
+ }
2301
+ onRemovedFromWorld() {
2302
+ this._world = null;
2303
+ }
2304
+ get isHoverEnabled() {
2305
+ return this.rootComponent.isHoverEnabled;
2306
+ }
2307
+ set isHoverEnabled(bCanHorver) {
2308
+ this.rootComponent.isHoverEnabled = bCanHorver;
2309
+ }
2310
+ get isClickEnabled() {
2311
+ return this.rootComponent.isClickEnabled;
2312
+ }
2313
+ set isClickEnabled(bCanHorver) {
2314
+ this.rootComponent.isClickEnabled = bCanHorver;
2315
+ }
2316
+ // hovering begin
2317
+ addHoveringBeginEvent(newFunc) {
2318
+ this.onHoverBeginEvent.push(newFunc);
2319
+ }
2320
+ removeHoveringBeginEvent(target) {
2321
+ let index = this.onHoverBeginEvent.indexOf(target);
2322
+ if (index >= 0) {
2323
+ this.onHoverBeginEvent.splice(index, 1);
2324
+ }
2325
+ }
2326
+ clearHoveringBeginEvent() {
2327
+ this.onHoverBeginEvent = [];
2328
+ }
2329
+ onComponentHorveringBegin(component) {
2330
+ for (let i = 0; i < this.onHoverBeginEvent.length; ++i) {
2331
+ this.onHoverBeginEvent[i](component);
2332
+ }
2333
+ }
2334
+ // hovering end
2335
+ addHoveringEndEvent(newFunc) {
2336
+ this.onHoverEndEvent.push(newFunc);
2337
+ }
2338
+ removeHoveringEndEvent(target) {
2339
+ let index = this.onHoverEndEvent.indexOf(target);
2340
+ if (index >= 0) {
2341
+ this.onHoverEndEvent.splice(index, 1);
2342
+ }
2343
+ }
2344
+ clearHoveringEndEvent() {
2345
+ this.onHoverEndEvent = [];
2346
+ }
2347
+ onComponentHorveringEnd(component) {
2348
+ // console.log("onComponentHorveringEnd", this)
2349
+ for (let i = 0; i < this.onHoverEndEvent.length; ++i) {
2350
+ this.onHoverEndEvent[i](component);
2351
+ }
2352
+ }
2353
+ //click
2354
+ addClickEvent(newFunc) {
2355
+ this.onClickedEvent.push(newFunc);
2356
+ }
2357
+ removeClickEvent(target) {
2358
+ let index = this.onClickedEvent.indexOf(target);
2359
+ if (index >= 0) {
2360
+ this.onClickedEvent.splice(index, 1);
2361
+ }
2362
+ }
2363
+ clearClickEvent() {
2364
+ this.onClickedEvent = [];
2365
+ }
2366
+ onComponentClicked(component) {
2367
+ //console.log("onComponentClicked", this.Name, component)
2368
+ for (let i = 0; i < this.onClickedEvent.length; ++i) {
2369
+ this.onClickedEvent[i](component);
2370
+ }
2371
+ }
2372
+ // double click
2373
+ addDoubleClickEvent(newFunc) {
2374
+ this.onDoubleClickedEvent.push(newFunc);
2375
+ }
2376
+ removeDoubleClickEvent(target) {
2377
+ let index = this.onClickedEvent.indexOf(target);
2378
+ if (index >= 0) {
2379
+ this.onDoubleClickedEvent.splice(index, 1);
2380
+ }
2381
+ }
2382
+ onComponentDoubleClicked(component) {
2383
+ //console.log("onComponentClicked", this.Name, component)
2384
+ for (let i = 0; i < this.onDoubleClickedEvent.length; ++i) {
2385
+ this.onDoubleClickedEvent[i](component);
2386
+ }
2387
+ }
2388
+ clearDoubleClickEvent() {
2389
+ this.onDoubleClickedEvent = [];
2390
+ }
2391
+ }
2392
+
2393
+ /*
2394
+ * virtual class of light, should not be use directly.
2395
+ */
2396
+ class LightComponent extends SceneComponent {
2397
+ get threeObject() {
2398
+ if (!this.obj) {
2399
+ throw Error("three object is invalid");
2400
+ }
2401
+ return this.obj;
2402
+ }
2403
+ set threeObject(newThreeObject) {
2404
+ this.obj = newThreeObject;
2405
+ if (this.obj) {
2406
+ this.obj.userData["LYObject"] = this;
2407
+ }
2408
+ }
2409
+ get color() {
2410
+ return this.threeObject.color.getHex();
2411
+ }
2412
+ set color(color) {
2413
+ this.threeObject.color.set(color);
2414
+ }
2415
+ get intensity() {
2416
+ return this.threeObject.intensity;
2417
+ }
2418
+ set intensity(intensity) {
2419
+ this.threeObject.intensity = intensity;
2420
+ }
2421
+ constructor(light) {
2422
+ super(light);
2423
+ this.obj = light;
2424
+ }
2425
+ }
2426
+
2427
+ class DirectionalLightComponent extends LightComponent {
2428
+ get threeObject() {
2429
+ if (!this.obj) {
2430
+ throw Error("three object is invalid");
2431
+ }
2432
+ return this.obj;
2433
+ }
2434
+ set threeObject(newThreeObject) {
2435
+ this.obj = newThreeObject;
2436
+ if (this.obj) {
2437
+ this.obj.userData["LYObject"] = this;
2438
+ }
2439
+ }
2440
+ get castShadow() {
2441
+ return this.threeObject.castShadow;
2442
+ }
2443
+ set castShadow(value) {
2444
+ this.threeObject.castShadow = value;
2445
+ }
2446
+ constructor(color = 0xffffff, intensity = 10) {
2447
+ let obj = new three.DirectionalLight(color, intensity);
2448
+ super(obj);
2449
+ this.obj = obj;
2450
+ obj.castShadow = true;
2451
+ }
2452
+ setPosition(...args) {
2453
+ if (args.length === 1) {
2454
+ super.setPosition(args[0]);
2455
+ }
2456
+ else {
2457
+ super.setPosition(args[0], args[1], args[2]);
2458
+ }
2459
+ this.update();
2460
+ }
2461
+ update() {
2462
+ if (this.world)
2463
+ this.world.viewport.markRenderStateDirty();
2464
+ }
2465
+ onAddedToWorld(world) {
2466
+ if (!this.threeObject) {
2467
+ throw Error("three object is invalid");
2468
+ }
2469
+ super.onAddedToWorld(world);
2470
+ }
2471
+ destroy() {
2472
+ super.destroy();
2473
+ }
2474
+ }
2475
+
2476
+ class DirectionalLightActor extends Actor {
2477
+ constructor(color = 0xffffff, intensity = 1) {
2478
+ super();
2479
+ this.lightComponent = new DirectionalLightComponent(color, intensity);
2480
+ this.rootComponent = this.lightComponent;
2481
+ this.lightComponent.castShadow = true;
2482
+ }
2483
+ }
2484
+
2485
+ class BoxComponent extends MeshComponent {
2486
+ constructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new three.MeshStandardMaterial()) {
2487
+ super(new three.BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material);
2488
+ }
2489
+ }
2490
+
2491
+ class BoxActor extends Actor {
2492
+ constructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new three.MeshBasicMaterial()) {
2493
+ super();
2494
+ this.addComponent(new BoxComponent(width, height, depth, widthSegments, heightSegments, depthSegments, material));
2495
+ }
2496
+ }
2497
+
2498
+ class PlaneComponent extends MeshComponent {
2499
+ constructor(width, height, material, widthSegments = 1, heightSegments = 1) {
2500
+ super(new three.PlaneGeometry(width, height, widthSegments, heightSegments), material);
2501
+ }
2502
+ }
2503
+
2504
+ class PlaneActor extends Actor {
2505
+ get planeComponent() {
2506
+ return this._planeComponent;
2507
+ }
2508
+ constructor(width, height, material = new three.MeshBasicMaterial(), widthSegments = 1, heightSegments = 1) {
2509
+ super();
2510
+ this._planeComponent = new PlaneComponent(width, height, material, widthSegments, heightSegments);
2511
+ this._planeComponent.setRotation(Math.PI * 0.5 * -1, 0, 0);
2512
+ this.addComponent(this._planeComponent);
2513
+ this._planeComponent.receiveShadow = true;
2514
+ }
2515
+ destroy() {
2516
+ var _a;
2517
+ (_a = this._planeComponent) === null || _a === void 0 ? void 0 : _a.destroy();
2518
+ this._planeComponent = null;
2519
+ super.destroy();
2520
+ }
2521
+ }
2522
+
2523
+ const DefaultBloomParam = {
2524
+ threshold: 0,
2525
+ strength: 1,
2526
+ radius: 0,
2527
+ };
2528
+
2529
+ const DefaultDenoiseParam = {
2530
+ denoiseRadius: 5,
2531
+ lumaPhi: 5,
2532
+ depthPhi: 5,
2533
+ normalPhi: 5
2534
+ };
2535
+
2536
+ const DefaultDOFParam = {
2537
+ focus: 500.0,
2538
+ aperture: 5,
2539
+ maxblur: 0.01
2540
+ };
2541
+
2542
+ const DefaultGTAOParam = {
2543
+ distanceExponent: 1,
2544
+ distanceFallOff: 1,
2545
+ radius: 0.25,
2546
+ scale: 1,
2547
+ thickness: 1,
2548
+ denoised: true,
2549
+ denoiseParam: DefaultDenoiseParam,
2550
+ };
2551
+
2552
+ const DefaultSSRParam = {
2553
+ maxDistance: 0.5,
2554
+ opacity: 1,
2555
+ thickness: 0.015,
2556
+ };
2557
+
2558
+ class SphereComponent extends MeshComponent {
2559
+ constructor(radius, material = new three.MeshBasicMaterial(), widthSegments = 32, heightSegments = 16) {
2560
+ super(new three.SphereGeometry(radius, widthSegments, heightSegments), material);
2561
+ }
2562
+ }
2563
+
2564
+ class LabelComponent extends SceneComponent {
2565
+ get threeObject() {
2566
+ return this.obj;
2567
+ }
2568
+ set threeObject(newThreeObject) {
2569
+ this.obj = newThreeObject;
2570
+ if (this.obj) {
2571
+ this.obj.userData["LYObject"] = this;
2572
+ }
2573
+ }
2574
+ constructor(domElement, center = new three.Vector2(0.5, 1)) {
2575
+ let obj = new CSS2DRenderer_js.CSS2DObject(domElement);
2576
+ super(obj);
2577
+ this.obj = obj;
2578
+ obj.center = center;
2579
+ }
2580
+ set isHoverEnabled(bCanHorver) {
2581
+ return;
2582
+ }
2583
+ set isClickEnabled(bCanClick) {
2584
+ return;
2585
+ }
2586
+ setVisible(bVisible) {
2587
+ super.setVisible(bVisible);
2588
+ }
2589
+ destroy() {
2590
+ if (this.threeObject.element && this.threeObject.element.parentNode) {
2591
+ this.threeObject.element.innerHTML = '';
2592
+ this.threeObject.element.remove();
2593
+ }
2594
+ super.destroy();
2595
+ }
2596
+ }
2597
+ // example
2598
+ // const labelStyle = document.createElement( 'div' );
2599
+ //
2600
+ // labelStyle.textContent = "this.POIData.name";
2601
+ // labelStyle.className = 'label';
2602
+ // labelStyle.style.color = 'white'
2603
+ // labelStyle.style.backgroundColor = 'transparent';
2604
+ // labelStyle.style.fontSize = "10px";
2605
+ // labelStyle.style.pointerEvents = 'auto';
2606
+
2607
+ class FirstPerson extends Pawn {
2608
+ constructor(controller) {
2609
+ super(controller);
2610
+ this._control = new PointerLockControls.PointerLockControls(controller.camera, controller.viewPort.canvas);
2611
+ }
2612
+ }
2613
+
2614
+ class TransformGizmo extends Pawn {
2615
+ get control() {
2616
+ if (!this._control) {
2617
+ throw new Error("Control not initialized");
2618
+ }
2619
+ return this._control;
2620
+ }
2621
+ constructor(controller) {
2622
+ super(controller);
2623
+ this._control = null;
2624
+ this.helperObject = new three.Object3D();
2625
+ this.targets = [];
2626
+ this.primaryTarget = null;
2627
+ this.targetMatrixMap = new Map();
2628
+ this.onDraggingChangedEvent = (param) => { this.onDraggingChanged(param); };
2629
+ this.onObjectChangeEvent = () => { this.onObjectChanged(); };
2630
+ this.onChangeEvent = () => { this.onChange(); };
2631
+ this.onUpdateFunctions = [];
2632
+ this.onDraggingFunctions = [];
2633
+ this._control = new TransformControls_js.TransformControls(controller.camera, controller.viewPort.canvas);
2634
+ this.control.getHelper().traverse((elem) => {
2635
+ elem.userData["rayIgnored"] = true;
2636
+ });
2637
+ this.helperObject.name = "TransformHelperObject";
2638
+ }
2639
+ possess() {
2640
+ var _a;
2641
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.add(this.helperObject);
2642
+ this.control.attach(this.helperObject);
2643
+ this.control.addEventListener('change', this.onChangeEvent);
2644
+ this.control.addEventListener('dragging-changed', this.onDraggingChangedEvent);
2645
+ this.control.addEventListener('objectChange', this.onObjectChangeEvent);
2646
+ }
2647
+ unpossess() {
2648
+ var _a;
2649
+ this.control.removeEventListener('change', this.onChangeEvent);
2650
+ this.control.removeEventListener('dragging-changed', this.onDraggingChangedEvent);
2651
+ this.control.removeEventListener('objectChange', this.onObjectChangeEvent);
2652
+ this.control.detach();
2653
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.remove(this.helperObject);
2654
+ }
2655
+ onChange() {
2656
+ this.controller.viewPort.markRenderStateDirty();
2657
+ }
2658
+ onDraggingChanged(event) {
2659
+ if (this.primaryTarget) {
2660
+ let tMatrix = this.primaryTarget.getMatrixInWorld();
2661
+ tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
2662
+ }
2663
+ this.onDraggingFunctions.forEach((elem) => {
2664
+ elem(event.value);
2665
+ });
2666
+ }
2667
+ onObjectChanged() {
2668
+ if (this.primaryTarget) {
2669
+ //const TA1 = this.primaryTarget.getMatrixInWorld();
2670
+ this.helperObject.updateMatrixWorld(true);
2671
+ const TA2 = this.helperObject.matrixWorld.clone();
2672
+ this.primaryTarget.onTransforming(TA2);
2673
+ // const TA1Inverse = TA1.clone().invert();
2674
+ //const transformMatrix = new Matrix4().multiplyMatrices(TA2, TA1Inverse);
2675
+ this.targets.forEach((tar) => {
2676
+ if (tar !== this.primaryTarget) {
2677
+ let t = this.targetMatrixMap.get(tar);
2678
+ if (t) {
2679
+ let TB2 = new three.Matrix4().multiplyMatrices(TA2, t); // B
2680
+ tar.onTransforming(TB2);
2681
+ }
2682
+ }
2683
+ });
2684
+ }
2685
+ this.onUpdateFunctions.forEach((elem) => {
2686
+ elem();
2687
+ });
2688
+ }
2689
+ set enable(newEnable) {
2690
+ this.control.enabled = newEnable;
2691
+ }
2692
+ setTarget(primaryTarget, multiTargets, onUpdate = null, onDragging = null) {
2693
+ var _a;
2694
+ this.targetMatrixMap.clear();
2695
+ let tMatrix = primaryTarget.getMatrixInWorld();
2696
+ tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
2697
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.add(this.control.getHelper());
2698
+ // this.control.attach(this.helperObject);
2699
+ this.primaryTarget = primaryTarget;
2700
+ this.targets = multiTargets;
2701
+ this.targets.forEach((elem) => {
2702
+ const tarMatrix = elem.getMatrixInWorld();
2703
+ const TB_local = tMatrix.clone().invert().multiply(tarMatrix);
2704
+ this.targetMatrixMap.set(elem, TB_local);
2705
+ });
2706
+ if (onUpdate) {
2707
+ this.onUpdateFunctions.push(onUpdate);
2708
+ }
2709
+ if (onUpdate) {
2710
+ this.onUpdateFunctions.push(onUpdate);
2711
+ }
2712
+ if (onDragging) {
2713
+ this.onDraggingFunctions.push(onDragging);
2714
+ }
2715
+ this.isTickEnabled = true;
2716
+ }
2717
+ getMode() {
2718
+ return this.control.getMode();
2719
+ }
2720
+ setMode(mode) {
2721
+ this.control.setMode(mode);
2722
+ }
2723
+ setSpace(space) {
2724
+ this.control.setSpace(space);
2725
+ }
2726
+ setAxis(axis) {
2727
+ this.control.showX = axis ? axis === null || axis === void 0 ? void 0 : axis.includes("X") : false;
2728
+ this.control.showY = axis ? axis === null || axis === void 0 ? void 0 : axis.includes("Y") : false;
2729
+ this.control.showZ = axis ? axis === null || axis === void 0 ? void 0 : axis.includes("Z") : false;
2730
+ }
2731
+ setSize(size) {
2732
+ this.control.setSize(size);
2733
+ }
2734
+ destroy() {
2735
+ var _a;
2736
+ this.isTickEnabled = false;
2737
+ this.unpossess();
2738
+ this.targetMatrixMap.clear();
2739
+ this.targets = [];
2740
+ this.primaryTarget = null;
2741
+ this.onUpdateFunctions = [];
2742
+ this.onDraggingFunctions = [];
2743
+ (_a = this._control) === null || _a === void 0 ? void 0 : _a.dispose();
2744
+ this._control = null;
2745
+ super.destroy();
2746
+ }
2747
+ }
2748
+
2749
+ exports.Actor = Actor;
2750
+ exports.BoxActor = BoxActor;
2751
+ exports.BoxComponent = BoxComponent;
2752
+ exports.Controller = Controller;
2753
+ exports.DefaultAppParam = DefaultAppParam;
2754
+ exports.DefaultBloomParam = DefaultBloomParam;
2755
+ exports.DefaultCameraParam = DefaultCameraParam;
2756
+ exports.DefaultDOFParam = DefaultDOFParam;
2757
+ exports.DefaultDenoiseParam = DefaultDenoiseParam;
2758
+ exports.DefaultGTAOParam = DefaultGTAOParam;
2759
+ exports.DefaultOutlineParams = DefaultOutlineParams;
2760
+ exports.DefaultPostProcessParam = DefaultPostProcessParam;
2761
+ exports.DefaultRenderParam = DefaultRenderParam;
2762
+ exports.DefaultSSRParam = DefaultSSRParam;
2763
+ exports.DefaultToneMappingParams = DefaultToneMappingParams;
2764
+ exports.Delegate = Delegate;
2765
+ exports.DirectionalLightActor = DirectionalLightActor;
2766
+ exports.DirectionalLightComponent = DirectionalLightComponent;
2767
+ exports.FirstPerson = FirstPerson;
2768
+ exports.LYAssetManager = LYAssetManager;
2769
+ exports.LYLoadTask = LYLoadTask;
2770
+ exports.LabelComponent = LabelComponent;
2771
+ exports.MeshComponent = MeshComponent;
2772
+ exports.Orbital = Orbital;
2773
+ exports.PlaneActor = PlaneActor;
2774
+ exports.PlaneComponent = PlaneComponent;
2775
+ exports.SceneComponent = SceneComponent;
2776
+ exports.SphereComponent = SphereComponent;
2777
+ exports.ThreeJsApp = ThreeJsApp;
2778
+ exports.ToneMappingOptions = ToneMappingOptions;
2779
+ exports.TransformGizmo = TransformGizmo;
2780
+ exports.Viewport = Viewport;
2781
+ exports.WebGPUPostProcessFactory = WebGPUPostProcessFactory;
2782
+ exports.World = World;