lythreeframe 1.1.10 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +194 -123
- package/dist/bundle.esm.js +194 -125
- package/dist/index.d.ts +3 -0
- package/dist/lythreeframe/Frame/Parameters/WorldParameter.d.ts +3 -0
- package/dist/lythreeframe/Frame/World.d.ts +7 -2
- package/dist/lythreeframe/Object/Actor.d.ts +1 -0
- package/dist/lythreeframe/Object/Actors/Level/LevelActor.d.ts +10 -0
- package/dist/lythreeframe/Object/BaseObject.d.ts +6 -2
- package/dist/lythreeframe/Object/Components/SceneComponent.d.ts +1 -0
- package/package.json +1 -1
package/dist/bundle.cjs.js
CHANGED
|
@@ -14,6 +14,7 @@ var MotionBlur_js = require('three/examples/jsm/tsl/display/MotionBlur.js');
|
|
|
14
14
|
var FXAANode_js = require('three/examples/jsm/tsl/display/FXAANode.js');
|
|
15
15
|
var SMAANode_js = require('three/examples/jsm/tsl/display/SMAANode.js');
|
|
16
16
|
var gsap = require('gsap');
|
|
17
|
+
var three = require('three');
|
|
17
18
|
var SkyMesh_js = require('three/examples/jsm/objects/SkyMesh.js');
|
|
18
19
|
var CSS2DRenderer_js = require('three/examples/jsm/renderers/CSS2DRenderer.js');
|
|
19
20
|
var PointerLockControls = require('three/examples/jsm/controls/PointerLockControls');
|
|
@@ -23,10 +24,10 @@ var TransformControls_js = require('three/examples/jsm/controls/TransformControl
|
|
|
23
24
|
* virtual class of 3D Object, should not be use directly.
|
|
24
25
|
*/
|
|
25
26
|
class BaseObject {
|
|
26
|
-
get
|
|
27
|
+
get isTickEnabled() {
|
|
27
28
|
return this.bCanTick;
|
|
28
29
|
}
|
|
29
|
-
set
|
|
30
|
+
set isTickEnabled(bCanTick) {
|
|
30
31
|
this.bCanTick = bCanTick;
|
|
31
32
|
}
|
|
32
33
|
get uuid() {
|
|
@@ -34,6 +35,7 @@ class BaseObject {
|
|
|
34
35
|
}
|
|
35
36
|
constructor(uuid = webgpu.MathUtils.generateUUID()) {
|
|
36
37
|
this.bCanTick = false;
|
|
38
|
+
this.tickEvents = [];
|
|
37
39
|
this.bCanTick = false;
|
|
38
40
|
this._uuid = uuid;
|
|
39
41
|
}
|
|
@@ -41,6 +43,21 @@ class BaseObject {
|
|
|
41
43
|
if (!this.bCanTick) {
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
46
|
+
this.tickEvents.forEach((elem) => {
|
|
47
|
+
elem(deltaTime);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
addTickEvent(event) {
|
|
51
|
+
this.tickEvents.push(event);
|
|
52
|
+
}
|
|
53
|
+
removeTickEvent(event) {
|
|
54
|
+
let index = this.tickEvents.indexOf(event);
|
|
55
|
+
if (index != -1) {
|
|
56
|
+
this.tickEvents.splice(index, 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
clearTickEvents() {
|
|
60
|
+
this.tickEvents = [];
|
|
44
61
|
}
|
|
45
62
|
destroy() {
|
|
46
63
|
}
|
|
@@ -106,7 +123,6 @@ class SceneComponent extends Component {
|
|
|
106
123
|
this._parentActor = value;
|
|
107
124
|
}
|
|
108
125
|
get parentActor() {
|
|
109
|
-
// 通过 _parentActor 私有字段访问父级 Actor
|
|
110
126
|
return this._parentActor;
|
|
111
127
|
}
|
|
112
128
|
get world() {
|
|
@@ -122,6 +138,12 @@ class SceneComponent extends Component {
|
|
|
122
138
|
createDefaultThreeObject() {
|
|
123
139
|
this.threeObject = new webgpu.Group();
|
|
124
140
|
}
|
|
141
|
+
tick(deltaTime) {
|
|
142
|
+
super.tick(deltaTime);
|
|
143
|
+
this.childrenComponents.forEach((elem) => {
|
|
144
|
+
elem.tick(deltaTime);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
125
147
|
get isVisible() {
|
|
126
148
|
if (!this.threeObject) {
|
|
127
149
|
return false;
|
|
@@ -899,7 +921,7 @@ class MaterialAssetPointer extends TAssetPointer {
|
|
|
899
921
|
try {
|
|
900
922
|
this.textures.set(name, texturePtr);
|
|
901
923
|
this.getValue()[name] = texture;
|
|
902
|
-
|
|
924
|
+
texturePtr.addRef();
|
|
903
925
|
mat.needsUpdate = true;
|
|
904
926
|
}
|
|
905
927
|
catch (e) {
|
|
@@ -1226,25 +1248,9 @@ const DefaultPostProcessParam = {
|
|
|
1226
1248
|
}
|
|
1227
1249
|
};
|
|
1228
1250
|
|
|
1229
|
-
class ThreeObjectLibrary {
|
|
1230
|
-
static disposeMeshMaterial(mesh) {
|
|
1231
|
-
let mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
1232
|
-
mats.forEach((elem) => {
|
|
1233
|
-
elem.dispose();
|
|
1234
|
-
});
|
|
1235
|
-
}
|
|
1236
|
-
static disposeMeshGeometry(mesh) {
|
|
1237
|
-
mesh.geometry.dispose();
|
|
1238
|
-
}
|
|
1239
|
-
static disposeMeshResource(mesh) {
|
|
1240
|
-
ThreeObjectLibrary.disposeMeshMaterial(mesh);
|
|
1241
|
-
ThreeObjectLibrary.disposeMeshGeometry(mesh);
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
1251
|
class World {
|
|
1246
1252
|
get scene() {
|
|
1247
|
-
return this.
|
|
1253
|
+
return this.rootActor.scene;
|
|
1248
1254
|
}
|
|
1249
1255
|
get viewport() {
|
|
1250
1256
|
return this.app.viewport;
|
|
@@ -1252,15 +1258,22 @@ class World {
|
|
|
1252
1258
|
get controller() {
|
|
1253
1259
|
return this.app.controller;
|
|
1254
1260
|
}
|
|
1255
|
-
constructor(app) {
|
|
1261
|
+
constructor(app, worldParam) {
|
|
1256
1262
|
this.actors = new Set();
|
|
1263
|
+
this.tickableActors = new Set();
|
|
1257
1264
|
this.app = app;
|
|
1258
|
-
this.
|
|
1265
|
+
this.rootActor = new worldParam.levelActorClass(app);
|
|
1259
1266
|
}
|
|
1260
1267
|
init() {
|
|
1261
1268
|
}
|
|
1269
|
+
addTickableActor(actor) {
|
|
1270
|
+
this.tickableActors.add(actor);
|
|
1271
|
+
}
|
|
1272
|
+
removeTickableActor(actor) {
|
|
1273
|
+
this.tickableActors.delete(actor);
|
|
1274
|
+
}
|
|
1262
1275
|
tick(deltaTime) {
|
|
1263
|
-
this.
|
|
1276
|
+
this.tickableActors.forEach((elem) => {
|
|
1264
1277
|
elem.tick(deltaTime);
|
|
1265
1278
|
});
|
|
1266
1279
|
}
|
|
@@ -1269,19 +1282,14 @@ class World {
|
|
|
1269
1282
|
elem.destroy();
|
|
1270
1283
|
});
|
|
1271
1284
|
this.actors.clear();
|
|
1272
|
-
this.
|
|
1273
|
-
if (child instanceof webgpu.Mesh) {
|
|
1274
|
-
ThreeObjectLibrary.disposeMeshResource(child);
|
|
1275
|
-
}
|
|
1276
|
-
});
|
|
1277
|
-
this.scene.clear();
|
|
1285
|
+
this.rootActor.destroy();
|
|
1278
1286
|
}
|
|
1279
1287
|
addActor(actor) {
|
|
1280
1288
|
if (!actor.rootComponent.threeObject) {
|
|
1281
|
-
throw Error("actor.threeObject is null");
|
|
1289
|
+
throw new Error("actor.threeObject is null");
|
|
1282
1290
|
}
|
|
1283
1291
|
actor.removeFromParent();
|
|
1284
|
-
this.
|
|
1292
|
+
this.rootActor.addChildActor(actor);
|
|
1285
1293
|
this.actors.add(actor);
|
|
1286
1294
|
actor.onAddedToWorld(this);
|
|
1287
1295
|
this.viewport.markRenderStateDirty();
|
|
@@ -2274,97 +2282,6 @@ const DefaultAppParam = {
|
|
|
2274
2282
|
}
|
|
2275
2283
|
};
|
|
2276
2284
|
|
|
2277
|
-
class ThreeJsApp {
|
|
2278
|
-
get camera() {
|
|
2279
|
-
return this._camera;
|
|
2280
|
-
}
|
|
2281
|
-
get clock() {
|
|
2282
|
-
return this._clock;
|
|
2283
|
-
}
|
|
2284
|
-
get world() {
|
|
2285
|
-
return this._world;
|
|
2286
|
-
}
|
|
2287
|
-
get viewport() {
|
|
2288
|
-
return this._viewport;
|
|
2289
|
-
}
|
|
2290
|
-
get controller() {
|
|
2291
|
-
return this._controller;
|
|
2292
|
-
}
|
|
2293
|
-
get assetManager() {
|
|
2294
|
-
return this._assetManager;
|
|
2295
|
-
}
|
|
2296
|
-
get appParam() {
|
|
2297
|
-
return this._appParam;
|
|
2298
|
-
}
|
|
2299
|
-
get onCameraChangedDelegate() {
|
|
2300
|
-
return this._onCameraChangedDelegate;
|
|
2301
|
-
}
|
|
2302
|
-
constructor(appParam = DefaultAppParam) {
|
|
2303
|
-
this._appParam = { viewportParam: DefaultViewportParam };
|
|
2304
|
-
this._onCameraChangedDelegate = new Delegate();
|
|
2305
|
-
this._appParam.cameraParam = appParam.cameraParam ? appParam.cameraParam : DefaultCameraParam;
|
|
2306
|
-
this._appParam.renderParam = appParam.renderParam ? appParam.renderParam : DefaultRenderParam;
|
|
2307
|
-
this._appParam.postProcessParam = appParam.postProcessParam ? appParam.postProcessParam : DefaultPostProcessParam;
|
|
2308
|
-
this._appParam.viewportParam = appParam.viewportParam ? appParam.viewportParam : DefaultViewportParam;
|
|
2309
|
-
this._appParam.classes = appParam.classes ? appParam.classes : {
|
|
2310
|
-
assetManagerClass: AssetManager,
|
|
2311
|
-
controllerClass: Controller,
|
|
2312
|
-
worldClass: World,
|
|
2313
|
-
viewportClass: Viewport,
|
|
2314
|
-
};
|
|
2315
|
-
this._clock = new webgpu.Clock();
|
|
2316
|
-
this._camera = CameraFactory.createCamera(this._appParam.cameraParam);
|
|
2317
|
-
this._world = new this._appParam.classes.worldClass(this);
|
|
2318
|
-
this._viewport = new this._appParam.classes.viewportClass(this, this._appParam.viewportParam, this._appParam.renderParam, this._appParam.postProcessParam);
|
|
2319
|
-
this._controller = new this._appParam.classes.controllerClass(this);
|
|
2320
|
-
this._assetManager = new this._appParam.classes.assetManagerClass(this);
|
|
2321
|
-
this.viewport.renderer.setAnimationLoop(() => {
|
|
2322
|
-
this.tick();
|
|
2323
|
-
});
|
|
2324
|
-
this.init();
|
|
2325
|
-
}
|
|
2326
|
-
init() {
|
|
2327
|
-
this.controller.init();
|
|
2328
|
-
this.world.init();
|
|
2329
|
-
this.viewport.init();
|
|
2330
|
-
}
|
|
2331
|
-
tick() {
|
|
2332
|
-
const delta = this._clock.getDelta();
|
|
2333
|
-
this._controller.tick(delta);
|
|
2334
|
-
this.world.tick(delta);
|
|
2335
|
-
this.viewport.render();
|
|
2336
|
-
}
|
|
2337
|
-
destroy() {
|
|
2338
|
-
this.onCameraChangedDelegate.clear();
|
|
2339
|
-
this.world.destroy();
|
|
2340
|
-
this.controller.destroy();
|
|
2341
|
-
this.viewport.destroy();
|
|
2342
|
-
this._assetManager.clearAssets();
|
|
2343
|
-
}
|
|
2344
|
-
updateCamera(param) {
|
|
2345
|
-
const previousCam = this.camera;
|
|
2346
|
-
this._camera = CameraFactory.updataCamera(param, this.camera);
|
|
2347
|
-
if (previousCam !== this.camera) {
|
|
2348
|
-
this._onCameraChangedDelegate.broadcast();
|
|
2349
|
-
}
|
|
2350
|
-
this._camera.updateProjectionMatrix();
|
|
2351
|
-
this.viewport.markRenderStateDirty();
|
|
2352
|
-
}
|
|
2353
|
-
onWindowResize(width, height) {
|
|
2354
|
-
if (this.camera instanceof webgpu.PerspectiveCamera) {
|
|
2355
|
-
this.camera.aspect = width / height;
|
|
2356
|
-
}
|
|
2357
|
-
// if(this.camera instanceof OrthographicCamera)
|
|
2358
|
-
// {
|
|
2359
|
-
// // to do
|
|
2360
|
-
// }
|
|
2361
|
-
this.camera.updateProjectionMatrix();
|
|
2362
|
-
}
|
|
2363
|
-
async renderAsImage(width = 1024, height = 1024) {
|
|
2364
|
-
return await this.viewport.renderAsImage(width, height);
|
|
2365
|
-
}
|
|
2366
|
-
}
|
|
2367
|
-
|
|
2368
2285
|
class Actor extends BaseObject {
|
|
2369
2286
|
get world() {
|
|
2370
2287
|
return this._world;
|
|
@@ -2417,6 +2334,15 @@ class Actor extends BaseObject {
|
|
|
2417
2334
|
get isVisible() {
|
|
2418
2335
|
return this.rootComponent ? this.rootComponent.isVisible : false;
|
|
2419
2336
|
}
|
|
2337
|
+
set isTickEnabled(bCanTick) {
|
|
2338
|
+
super.isTickEnabled = bCanTick;
|
|
2339
|
+
if (this.isTickEnabled) {
|
|
2340
|
+
this.app.world.addTickableActor(this);
|
|
2341
|
+
}
|
|
2342
|
+
else {
|
|
2343
|
+
this.app.world.removeTickableActor(this);
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2420
2346
|
constructor(app, myThreeObject = null) {
|
|
2421
2347
|
super();
|
|
2422
2348
|
this._name = "Actor";
|
|
@@ -2497,6 +2423,9 @@ class Actor extends BaseObject {
|
|
|
2497
2423
|
}
|
|
2498
2424
|
}
|
|
2499
2425
|
tick(deltaTime) {
|
|
2426
|
+
if (!this.isTickEnabled) {
|
|
2427
|
+
return;
|
|
2428
|
+
}
|
|
2500
2429
|
super.tick(deltaTime);
|
|
2501
2430
|
this.rootComponent.tick(deltaTime);
|
|
2502
2431
|
}
|
|
@@ -2742,6 +2671,146 @@ class Actor extends BaseObject {
|
|
|
2742
2671
|
}
|
|
2743
2672
|
}
|
|
2744
2673
|
|
|
2674
|
+
class ThreeObjectLibrary {
|
|
2675
|
+
static disposeMeshMaterial(mesh) {
|
|
2676
|
+
let mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
2677
|
+
mats.forEach((elem) => {
|
|
2678
|
+
elem.dispose();
|
|
2679
|
+
});
|
|
2680
|
+
}
|
|
2681
|
+
static disposeMeshGeometry(mesh) {
|
|
2682
|
+
mesh.geometry.dispose();
|
|
2683
|
+
}
|
|
2684
|
+
static disposeMeshResource(mesh) {
|
|
2685
|
+
ThreeObjectLibrary.disposeMeshMaterial(mesh);
|
|
2686
|
+
ThreeObjectLibrary.disposeMeshGeometry(mesh);
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
class LevelActor extends Actor {
|
|
2691
|
+
get scene() {
|
|
2692
|
+
if (!this._scene) {
|
|
2693
|
+
throw new Error("scene is null");
|
|
2694
|
+
}
|
|
2695
|
+
return this._scene;
|
|
2696
|
+
}
|
|
2697
|
+
constructor(app) {
|
|
2698
|
+
let scene = new webgpu.Scene();
|
|
2699
|
+
super(app, new webgpu.Scene());
|
|
2700
|
+
this._scene = null;
|
|
2701
|
+
this._scene = scene;
|
|
2702
|
+
this.isTickEnabled = false;
|
|
2703
|
+
}
|
|
2704
|
+
tick(_deltaTime) {
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2707
|
+
destroy() {
|
|
2708
|
+
this.childActors.forEach((elem) => {
|
|
2709
|
+
elem.destroy();
|
|
2710
|
+
});
|
|
2711
|
+
this.scene.traverse((child) => {
|
|
2712
|
+
if (child instanceof three.Mesh) {
|
|
2713
|
+
ThreeObjectLibrary.disposeMeshResource(child);
|
|
2714
|
+
}
|
|
2715
|
+
});
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
const DefaultWorldParam = {
|
|
2720
|
+
levelActorClass: LevelActor,
|
|
2721
|
+
};
|
|
2722
|
+
|
|
2723
|
+
class ThreeJsApp {
|
|
2724
|
+
get camera() {
|
|
2725
|
+
return this._camera;
|
|
2726
|
+
}
|
|
2727
|
+
get clock() {
|
|
2728
|
+
return this._clock;
|
|
2729
|
+
}
|
|
2730
|
+
get world() {
|
|
2731
|
+
return this._world;
|
|
2732
|
+
}
|
|
2733
|
+
get viewport() {
|
|
2734
|
+
return this._viewport;
|
|
2735
|
+
}
|
|
2736
|
+
get controller() {
|
|
2737
|
+
return this._controller;
|
|
2738
|
+
}
|
|
2739
|
+
get assetManager() {
|
|
2740
|
+
return this._assetManager;
|
|
2741
|
+
}
|
|
2742
|
+
get appParam() {
|
|
2743
|
+
return this._appParam;
|
|
2744
|
+
}
|
|
2745
|
+
get onCameraChangedDelegate() {
|
|
2746
|
+
return this._onCameraChangedDelegate;
|
|
2747
|
+
}
|
|
2748
|
+
constructor(appParam = DefaultAppParam) {
|
|
2749
|
+
this._appParam = { viewportParam: DefaultViewportParam };
|
|
2750
|
+
this._onCameraChangedDelegate = new Delegate();
|
|
2751
|
+
this._appParam.cameraParam = appParam.cameraParam ? appParam.cameraParam : DefaultCameraParam;
|
|
2752
|
+
this._appParam.renderParam = appParam.renderParam ? appParam.renderParam : DefaultRenderParam;
|
|
2753
|
+
this._appParam.postProcessParam = appParam.postProcessParam ? appParam.postProcessParam : DefaultPostProcessParam;
|
|
2754
|
+
this._appParam.viewportParam = appParam.viewportParam ? appParam.viewportParam : DefaultViewportParam;
|
|
2755
|
+
this._appParam.classes = appParam.classes ? appParam.classes : {
|
|
2756
|
+
assetManagerClass: AssetManager,
|
|
2757
|
+
controllerClass: Controller,
|
|
2758
|
+
worldClass: World,
|
|
2759
|
+
viewportClass: Viewport,
|
|
2760
|
+
};
|
|
2761
|
+
this._clock = new webgpu.Clock();
|
|
2762
|
+
this._camera = CameraFactory.createCamera(this._appParam.cameraParam);
|
|
2763
|
+
this._world = new this._appParam.classes.worldClass(this, this._appParam.worldParam ? this._appParam.worldParam : DefaultWorldParam);
|
|
2764
|
+
this._viewport = new this._appParam.classes.viewportClass(this, this._appParam.viewportParam, this._appParam.renderParam, this._appParam.postProcessParam);
|
|
2765
|
+
this._controller = new this._appParam.classes.controllerClass(this);
|
|
2766
|
+
this._assetManager = new this._appParam.classes.assetManagerClass(this);
|
|
2767
|
+
this.viewport.renderer.setAnimationLoop(() => {
|
|
2768
|
+
this.tick();
|
|
2769
|
+
});
|
|
2770
|
+
this.init();
|
|
2771
|
+
}
|
|
2772
|
+
init() {
|
|
2773
|
+
this.controller.init();
|
|
2774
|
+
this.world.init();
|
|
2775
|
+
this.viewport.init();
|
|
2776
|
+
}
|
|
2777
|
+
tick() {
|
|
2778
|
+
const delta = this._clock.getDelta();
|
|
2779
|
+
this._controller.tick(delta);
|
|
2780
|
+
this.world.tick(delta);
|
|
2781
|
+
this.viewport.render();
|
|
2782
|
+
}
|
|
2783
|
+
destroy() {
|
|
2784
|
+
this.onCameraChangedDelegate.clear();
|
|
2785
|
+
this.world.destroy();
|
|
2786
|
+
this.controller.destroy();
|
|
2787
|
+
this.viewport.destroy();
|
|
2788
|
+
this._assetManager.clearAssets();
|
|
2789
|
+
}
|
|
2790
|
+
updateCamera(param) {
|
|
2791
|
+
const previousCam = this.camera;
|
|
2792
|
+
this._camera = CameraFactory.updataCamera(param, this.camera);
|
|
2793
|
+
if (previousCam !== this.camera) {
|
|
2794
|
+
this._onCameraChangedDelegate.broadcast();
|
|
2795
|
+
}
|
|
2796
|
+
this._camera.updateProjectionMatrix();
|
|
2797
|
+
this.viewport.markRenderStateDirty();
|
|
2798
|
+
}
|
|
2799
|
+
onWindowResize(width, height) {
|
|
2800
|
+
if (this.camera instanceof webgpu.PerspectiveCamera) {
|
|
2801
|
+
this.camera.aspect = width / height;
|
|
2802
|
+
}
|
|
2803
|
+
// if(this.camera instanceof OrthographicCamera)
|
|
2804
|
+
// {
|
|
2805
|
+
// // to do
|
|
2806
|
+
// }
|
|
2807
|
+
this.camera.updateProjectionMatrix();
|
|
2808
|
+
}
|
|
2809
|
+
async renderAsImage(width = 1024, height = 1024) {
|
|
2810
|
+
return await this.viewport.renderAsImage(width, height);
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2745
2814
|
/*
|
|
2746
2815
|
* virtual class of light, should not be use directly.
|
|
2747
2816
|
*/
|
|
@@ -3231,12 +3300,14 @@ exports.DefaultSSRParam = DefaultSSRParam;
|
|
|
3231
3300
|
exports.DefaultSkyParam = DefaultSkyParam;
|
|
3232
3301
|
exports.DefaultToneMappingParams = DefaultToneMappingParams;
|
|
3233
3302
|
exports.DefaultViewportParam = DefaultViewportParam;
|
|
3303
|
+
exports.DefaultWorldParam = DefaultWorldParam;
|
|
3234
3304
|
exports.Delegate = Delegate;
|
|
3235
3305
|
exports.DirectionalLightActor = DirectionalLightActor;
|
|
3236
3306
|
exports.DirectionalLightComponent = DirectionalLightComponent;
|
|
3237
3307
|
exports.FirstPerson = FirstPerson;
|
|
3238
3308
|
exports.GeometryAssetPointer = GeometryAssetPointer;
|
|
3239
3309
|
exports.LabelComponent = LabelComponent;
|
|
3310
|
+
exports.LevelActor = LevelActor;
|
|
3240
3311
|
exports.MaterialAssetPointer = MaterialAssetPointer;
|
|
3241
3312
|
exports.MeshComponent = MeshComponent;
|
|
3242
3313
|
exports.Orbital = Orbital;
|
package/dist/bundle.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MathUtils, Group, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, LoadingManager, BufferGeometry, Texture, FileLoader, Material,
|
|
1
|
+
import { MathUtils, Group, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, LoadingManager, BufferGeometry, Texture, FileLoader, Material, NoToneMapping, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping, NeutralToneMapping, WebGPURenderer, PostProcessing, Color, Vector2, Raycaster, PerspectiveCamera, OrthographicCamera, Scene, Clock, DirectionalLight, MeshStandardMaterial, BoxGeometry, MeshBasicMaterial, PlaneGeometry, SphereGeometry, Object3D } from 'three/webgpu';
|
|
2
2
|
import { GLTFLoader, DRACOLoader, CSS2DRenderer, OrbitControls } from 'three/examples/jsm/Addons.js';
|
|
3
3
|
import { pass, mrt, output, uniform, velocity, metalness, transformedNormalView, blendColor, time, oscSine } from 'three/tsl';
|
|
4
4
|
import { bloom } from 'three/examples/jsm/tsl/display/BloomNode.js';
|
|
@@ -12,6 +12,7 @@ import { motionBlur } from 'three/examples/jsm/tsl/display/MotionBlur.js';
|
|
|
12
12
|
import { fxaa } from 'three/examples/jsm/tsl/display/FXAANode.js';
|
|
13
13
|
import { smaa } from 'three/examples/jsm/tsl/display/SMAANode.js';
|
|
14
14
|
import { gsap } from 'gsap';
|
|
15
|
+
import { Mesh as Mesh$1 } from 'three';
|
|
15
16
|
import { SkyMesh } from 'three/examples/jsm/objects/SkyMesh.js';
|
|
16
17
|
import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
|
|
17
18
|
import { PointerLockControls } from 'three/examples/jsm/controls/PointerLockControls';
|
|
@@ -21,10 +22,10 @@ import { TransformControls } from 'three/examples/jsm/controls/TransformControls
|
|
|
21
22
|
* virtual class of 3D Object, should not be use directly.
|
|
22
23
|
*/
|
|
23
24
|
class BaseObject {
|
|
24
|
-
get
|
|
25
|
+
get isTickEnabled() {
|
|
25
26
|
return this.bCanTick;
|
|
26
27
|
}
|
|
27
|
-
set
|
|
28
|
+
set isTickEnabled(bCanTick) {
|
|
28
29
|
this.bCanTick = bCanTick;
|
|
29
30
|
}
|
|
30
31
|
get uuid() {
|
|
@@ -32,6 +33,7 @@ class BaseObject {
|
|
|
32
33
|
}
|
|
33
34
|
constructor(uuid = MathUtils.generateUUID()) {
|
|
34
35
|
this.bCanTick = false;
|
|
36
|
+
this.tickEvents = [];
|
|
35
37
|
this.bCanTick = false;
|
|
36
38
|
this._uuid = uuid;
|
|
37
39
|
}
|
|
@@ -39,6 +41,21 @@ class BaseObject {
|
|
|
39
41
|
if (!this.bCanTick) {
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
44
|
+
this.tickEvents.forEach((elem) => {
|
|
45
|
+
elem(deltaTime);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
addTickEvent(event) {
|
|
49
|
+
this.tickEvents.push(event);
|
|
50
|
+
}
|
|
51
|
+
removeTickEvent(event) {
|
|
52
|
+
let index = this.tickEvents.indexOf(event);
|
|
53
|
+
if (index != -1) {
|
|
54
|
+
this.tickEvents.splice(index, 1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
clearTickEvents() {
|
|
58
|
+
this.tickEvents = [];
|
|
42
59
|
}
|
|
43
60
|
destroy() {
|
|
44
61
|
}
|
|
@@ -104,7 +121,6 @@ class SceneComponent extends Component {
|
|
|
104
121
|
this._parentActor = value;
|
|
105
122
|
}
|
|
106
123
|
get parentActor() {
|
|
107
|
-
// 通过 _parentActor 私有字段访问父级 Actor
|
|
108
124
|
return this._parentActor;
|
|
109
125
|
}
|
|
110
126
|
get world() {
|
|
@@ -120,6 +136,12 @@ class SceneComponent extends Component {
|
|
|
120
136
|
createDefaultThreeObject() {
|
|
121
137
|
this.threeObject = new Group();
|
|
122
138
|
}
|
|
139
|
+
tick(deltaTime) {
|
|
140
|
+
super.tick(deltaTime);
|
|
141
|
+
this.childrenComponents.forEach((elem) => {
|
|
142
|
+
elem.tick(deltaTime);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
123
145
|
get isVisible() {
|
|
124
146
|
if (!this.threeObject) {
|
|
125
147
|
return false;
|
|
@@ -897,7 +919,7 @@ class MaterialAssetPointer extends TAssetPointer {
|
|
|
897
919
|
try {
|
|
898
920
|
this.textures.set(name, texturePtr);
|
|
899
921
|
this.getValue()[name] = texture;
|
|
900
|
-
|
|
922
|
+
texturePtr.addRef();
|
|
901
923
|
mat.needsUpdate = true;
|
|
902
924
|
}
|
|
903
925
|
catch (e) {
|
|
@@ -1224,25 +1246,9 @@ const DefaultPostProcessParam = {
|
|
|
1224
1246
|
}
|
|
1225
1247
|
};
|
|
1226
1248
|
|
|
1227
|
-
class ThreeObjectLibrary {
|
|
1228
|
-
static disposeMeshMaterial(mesh) {
|
|
1229
|
-
let mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
1230
|
-
mats.forEach((elem) => {
|
|
1231
|
-
elem.dispose();
|
|
1232
|
-
});
|
|
1233
|
-
}
|
|
1234
|
-
static disposeMeshGeometry(mesh) {
|
|
1235
|
-
mesh.geometry.dispose();
|
|
1236
|
-
}
|
|
1237
|
-
static disposeMeshResource(mesh) {
|
|
1238
|
-
ThreeObjectLibrary.disposeMeshMaterial(mesh);
|
|
1239
|
-
ThreeObjectLibrary.disposeMeshGeometry(mesh);
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
1249
|
class World {
|
|
1244
1250
|
get scene() {
|
|
1245
|
-
return this.
|
|
1251
|
+
return this.rootActor.scene;
|
|
1246
1252
|
}
|
|
1247
1253
|
get viewport() {
|
|
1248
1254
|
return this.app.viewport;
|
|
@@ -1250,15 +1256,22 @@ class World {
|
|
|
1250
1256
|
get controller() {
|
|
1251
1257
|
return this.app.controller;
|
|
1252
1258
|
}
|
|
1253
|
-
constructor(app) {
|
|
1259
|
+
constructor(app, worldParam) {
|
|
1254
1260
|
this.actors = new Set();
|
|
1261
|
+
this.tickableActors = new Set();
|
|
1255
1262
|
this.app = app;
|
|
1256
|
-
this.
|
|
1263
|
+
this.rootActor = new worldParam.levelActorClass(app);
|
|
1257
1264
|
}
|
|
1258
1265
|
init() {
|
|
1259
1266
|
}
|
|
1267
|
+
addTickableActor(actor) {
|
|
1268
|
+
this.tickableActors.add(actor);
|
|
1269
|
+
}
|
|
1270
|
+
removeTickableActor(actor) {
|
|
1271
|
+
this.tickableActors.delete(actor);
|
|
1272
|
+
}
|
|
1260
1273
|
tick(deltaTime) {
|
|
1261
|
-
this.
|
|
1274
|
+
this.tickableActors.forEach((elem) => {
|
|
1262
1275
|
elem.tick(deltaTime);
|
|
1263
1276
|
});
|
|
1264
1277
|
}
|
|
@@ -1267,19 +1280,14 @@ class World {
|
|
|
1267
1280
|
elem.destroy();
|
|
1268
1281
|
});
|
|
1269
1282
|
this.actors.clear();
|
|
1270
|
-
this.
|
|
1271
|
-
if (child instanceof Mesh) {
|
|
1272
|
-
ThreeObjectLibrary.disposeMeshResource(child);
|
|
1273
|
-
}
|
|
1274
|
-
});
|
|
1275
|
-
this.scene.clear();
|
|
1283
|
+
this.rootActor.destroy();
|
|
1276
1284
|
}
|
|
1277
1285
|
addActor(actor) {
|
|
1278
1286
|
if (!actor.rootComponent.threeObject) {
|
|
1279
|
-
throw Error("actor.threeObject is null");
|
|
1287
|
+
throw new Error("actor.threeObject is null");
|
|
1280
1288
|
}
|
|
1281
1289
|
actor.removeFromParent();
|
|
1282
|
-
this.
|
|
1290
|
+
this.rootActor.addChildActor(actor);
|
|
1283
1291
|
this.actors.add(actor);
|
|
1284
1292
|
actor.onAddedToWorld(this);
|
|
1285
1293
|
this.viewport.markRenderStateDirty();
|
|
@@ -2272,97 +2280,6 @@ const DefaultAppParam = {
|
|
|
2272
2280
|
}
|
|
2273
2281
|
};
|
|
2274
2282
|
|
|
2275
|
-
class ThreeJsApp {
|
|
2276
|
-
get camera() {
|
|
2277
|
-
return this._camera;
|
|
2278
|
-
}
|
|
2279
|
-
get clock() {
|
|
2280
|
-
return this._clock;
|
|
2281
|
-
}
|
|
2282
|
-
get world() {
|
|
2283
|
-
return this._world;
|
|
2284
|
-
}
|
|
2285
|
-
get viewport() {
|
|
2286
|
-
return this._viewport;
|
|
2287
|
-
}
|
|
2288
|
-
get controller() {
|
|
2289
|
-
return this._controller;
|
|
2290
|
-
}
|
|
2291
|
-
get assetManager() {
|
|
2292
|
-
return this._assetManager;
|
|
2293
|
-
}
|
|
2294
|
-
get appParam() {
|
|
2295
|
-
return this._appParam;
|
|
2296
|
-
}
|
|
2297
|
-
get onCameraChangedDelegate() {
|
|
2298
|
-
return this._onCameraChangedDelegate;
|
|
2299
|
-
}
|
|
2300
|
-
constructor(appParam = DefaultAppParam) {
|
|
2301
|
-
this._appParam = { viewportParam: DefaultViewportParam };
|
|
2302
|
-
this._onCameraChangedDelegate = new Delegate();
|
|
2303
|
-
this._appParam.cameraParam = appParam.cameraParam ? appParam.cameraParam : DefaultCameraParam;
|
|
2304
|
-
this._appParam.renderParam = appParam.renderParam ? appParam.renderParam : DefaultRenderParam;
|
|
2305
|
-
this._appParam.postProcessParam = appParam.postProcessParam ? appParam.postProcessParam : DefaultPostProcessParam;
|
|
2306
|
-
this._appParam.viewportParam = appParam.viewportParam ? appParam.viewportParam : DefaultViewportParam;
|
|
2307
|
-
this._appParam.classes = appParam.classes ? appParam.classes : {
|
|
2308
|
-
assetManagerClass: AssetManager,
|
|
2309
|
-
controllerClass: Controller,
|
|
2310
|
-
worldClass: World,
|
|
2311
|
-
viewportClass: Viewport,
|
|
2312
|
-
};
|
|
2313
|
-
this._clock = new Clock();
|
|
2314
|
-
this._camera = CameraFactory.createCamera(this._appParam.cameraParam);
|
|
2315
|
-
this._world = new this._appParam.classes.worldClass(this);
|
|
2316
|
-
this._viewport = new this._appParam.classes.viewportClass(this, this._appParam.viewportParam, this._appParam.renderParam, this._appParam.postProcessParam);
|
|
2317
|
-
this._controller = new this._appParam.classes.controllerClass(this);
|
|
2318
|
-
this._assetManager = new this._appParam.classes.assetManagerClass(this);
|
|
2319
|
-
this.viewport.renderer.setAnimationLoop(() => {
|
|
2320
|
-
this.tick();
|
|
2321
|
-
});
|
|
2322
|
-
this.init();
|
|
2323
|
-
}
|
|
2324
|
-
init() {
|
|
2325
|
-
this.controller.init();
|
|
2326
|
-
this.world.init();
|
|
2327
|
-
this.viewport.init();
|
|
2328
|
-
}
|
|
2329
|
-
tick() {
|
|
2330
|
-
const delta = this._clock.getDelta();
|
|
2331
|
-
this._controller.tick(delta);
|
|
2332
|
-
this.world.tick(delta);
|
|
2333
|
-
this.viewport.render();
|
|
2334
|
-
}
|
|
2335
|
-
destroy() {
|
|
2336
|
-
this.onCameraChangedDelegate.clear();
|
|
2337
|
-
this.world.destroy();
|
|
2338
|
-
this.controller.destroy();
|
|
2339
|
-
this.viewport.destroy();
|
|
2340
|
-
this._assetManager.clearAssets();
|
|
2341
|
-
}
|
|
2342
|
-
updateCamera(param) {
|
|
2343
|
-
const previousCam = this.camera;
|
|
2344
|
-
this._camera = CameraFactory.updataCamera(param, this.camera);
|
|
2345
|
-
if (previousCam !== this.camera) {
|
|
2346
|
-
this._onCameraChangedDelegate.broadcast();
|
|
2347
|
-
}
|
|
2348
|
-
this._camera.updateProjectionMatrix();
|
|
2349
|
-
this.viewport.markRenderStateDirty();
|
|
2350
|
-
}
|
|
2351
|
-
onWindowResize(width, height) {
|
|
2352
|
-
if (this.camera instanceof PerspectiveCamera) {
|
|
2353
|
-
this.camera.aspect = width / height;
|
|
2354
|
-
}
|
|
2355
|
-
// if(this.camera instanceof OrthographicCamera)
|
|
2356
|
-
// {
|
|
2357
|
-
// // to do
|
|
2358
|
-
// }
|
|
2359
|
-
this.camera.updateProjectionMatrix();
|
|
2360
|
-
}
|
|
2361
|
-
async renderAsImage(width = 1024, height = 1024) {
|
|
2362
|
-
return await this.viewport.renderAsImage(width, height);
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
|
|
2366
2283
|
class Actor extends BaseObject {
|
|
2367
2284
|
get world() {
|
|
2368
2285
|
return this._world;
|
|
@@ -2415,6 +2332,15 @@ class Actor extends BaseObject {
|
|
|
2415
2332
|
get isVisible() {
|
|
2416
2333
|
return this.rootComponent ? this.rootComponent.isVisible : false;
|
|
2417
2334
|
}
|
|
2335
|
+
set isTickEnabled(bCanTick) {
|
|
2336
|
+
super.isTickEnabled = bCanTick;
|
|
2337
|
+
if (this.isTickEnabled) {
|
|
2338
|
+
this.app.world.addTickableActor(this);
|
|
2339
|
+
}
|
|
2340
|
+
else {
|
|
2341
|
+
this.app.world.removeTickableActor(this);
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2418
2344
|
constructor(app, myThreeObject = null) {
|
|
2419
2345
|
super();
|
|
2420
2346
|
this._name = "Actor";
|
|
@@ -2495,6 +2421,9 @@ class Actor extends BaseObject {
|
|
|
2495
2421
|
}
|
|
2496
2422
|
}
|
|
2497
2423
|
tick(deltaTime) {
|
|
2424
|
+
if (!this.isTickEnabled) {
|
|
2425
|
+
return;
|
|
2426
|
+
}
|
|
2498
2427
|
super.tick(deltaTime);
|
|
2499
2428
|
this.rootComponent.tick(deltaTime);
|
|
2500
2429
|
}
|
|
@@ -2740,6 +2669,146 @@ class Actor extends BaseObject {
|
|
|
2740
2669
|
}
|
|
2741
2670
|
}
|
|
2742
2671
|
|
|
2672
|
+
class ThreeObjectLibrary {
|
|
2673
|
+
static disposeMeshMaterial(mesh) {
|
|
2674
|
+
let mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
2675
|
+
mats.forEach((elem) => {
|
|
2676
|
+
elem.dispose();
|
|
2677
|
+
});
|
|
2678
|
+
}
|
|
2679
|
+
static disposeMeshGeometry(mesh) {
|
|
2680
|
+
mesh.geometry.dispose();
|
|
2681
|
+
}
|
|
2682
|
+
static disposeMeshResource(mesh) {
|
|
2683
|
+
ThreeObjectLibrary.disposeMeshMaterial(mesh);
|
|
2684
|
+
ThreeObjectLibrary.disposeMeshGeometry(mesh);
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
class LevelActor extends Actor {
|
|
2689
|
+
get scene() {
|
|
2690
|
+
if (!this._scene) {
|
|
2691
|
+
throw new Error("scene is null");
|
|
2692
|
+
}
|
|
2693
|
+
return this._scene;
|
|
2694
|
+
}
|
|
2695
|
+
constructor(app) {
|
|
2696
|
+
let scene = new Scene();
|
|
2697
|
+
super(app, new Scene());
|
|
2698
|
+
this._scene = null;
|
|
2699
|
+
this._scene = scene;
|
|
2700
|
+
this.isTickEnabled = false;
|
|
2701
|
+
}
|
|
2702
|
+
tick(_deltaTime) {
|
|
2703
|
+
return;
|
|
2704
|
+
}
|
|
2705
|
+
destroy() {
|
|
2706
|
+
this.childActors.forEach((elem) => {
|
|
2707
|
+
elem.destroy();
|
|
2708
|
+
});
|
|
2709
|
+
this.scene.traverse((child) => {
|
|
2710
|
+
if (child instanceof Mesh$1) {
|
|
2711
|
+
ThreeObjectLibrary.disposeMeshResource(child);
|
|
2712
|
+
}
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
const DefaultWorldParam = {
|
|
2718
|
+
levelActorClass: LevelActor,
|
|
2719
|
+
};
|
|
2720
|
+
|
|
2721
|
+
class ThreeJsApp {
|
|
2722
|
+
get camera() {
|
|
2723
|
+
return this._camera;
|
|
2724
|
+
}
|
|
2725
|
+
get clock() {
|
|
2726
|
+
return this._clock;
|
|
2727
|
+
}
|
|
2728
|
+
get world() {
|
|
2729
|
+
return this._world;
|
|
2730
|
+
}
|
|
2731
|
+
get viewport() {
|
|
2732
|
+
return this._viewport;
|
|
2733
|
+
}
|
|
2734
|
+
get controller() {
|
|
2735
|
+
return this._controller;
|
|
2736
|
+
}
|
|
2737
|
+
get assetManager() {
|
|
2738
|
+
return this._assetManager;
|
|
2739
|
+
}
|
|
2740
|
+
get appParam() {
|
|
2741
|
+
return this._appParam;
|
|
2742
|
+
}
|
|
2743
|
+
get onCameraChangedDelegate() {
|
|
2744
|
+
return this._onCameraChangedDelegate;
|
|
2745
|
+
}
|
|
2746
|
+
constructor(appParam = DefaultAppParam) {
|
|
2747
|
+
this._appParam = { viewportParam: DefaultViewportParam };
|
|
2748
|
+
this._onCameraChangedDelegate = new Delegate();
|
|
2749
|
+
this._appParam.cameraParam = appParam.cameraParam ? appParam.cameraParam : DefaultCameraParam;
|
|
2750
|
+
this._appParam.renderParam = appParam.renderParam ? appParam.renderParam : DefaultRenderParam;
|
|
2751
|
+
this._appParam.postProcessParam = appParam.postProcessParam ? appParam.postProcessParam : DefaultPostProcessParam;
|
|
2752
|
+
this._appParam.viewportParam = appParam.viewportParam ? appParam.viewportParam : DefaultViewportParam;
|
|
2753
|
+
this._appParam.classes = appParam.classes ? appParam.classes : {
|
|
2754
|
+
assetManagerClass: AssetManager,
|
|
2755
|
+
controllerClass: Controller,
|
|
2756
|
+
worldClass: World,
|
|
2757
|
+
viewportClass: Viewport,
|
|
2758
|
+
};
|
|
2759
|
+
this._clock = new Clock();
|
|
2760
|
+
this._camera = CameraFactory.createCamera(this._appParam.cameraParam);
|
|
2761
|
+
this._world = new this._appParam.classes.worldClass(this, this._appParam.worldParam ? this._appParam.worldParam : DefaultWorldParam);
|
|
2762
|
+
this._viewport = new this._appParam.classes.viewportClass(this, this._appParam.viewportParam, this._appParam.renderParam, this._appParam.postProcessParam);
|
|
2763
|
+
this._controller = new this._appParam.classes.controllerClass(this);
|
|
2764
|
+
this._assetManager = new this._appParam.classes.assetManagerClass(this);
|
|
2765
|
+
this.viewport.renderer.setAnimationLoop(() => {
|
|
2766
|
+
this.tick();
|
|
2767
|
+
});
|
|
2768
|
+
this.init();
|
|
2769
|
+
}
|
|
2770
|
+
init() {
|
|
2771
|
+
this.controller.init();
|
|
2772
|
+
this.world.init();
|
|
2773
|
+
this.viewport.init();
|
|
2774
|
+
}
|
|
2775
|
+
tick() {
|
|
2776
|
+
const delta = this._clock.getDelta();
|
|
2777
|
+
this._controller.tick(delta);
|
|
2778
|
+
this.world.tick(delta);
|
|
2779
|
+
this.viewport.render();
|
|
2780
|
+
}
|
|
2781
|
+
destroy() {
|
|
2782
|
+
this.onCameraChangedDelegate.clear();
|
|
2783
|
+
this.world.destroy();
|
|
2784
|
+
this.controller.destroy();
|
|
2785
|
+
this.viewport.destroy();
|
|
2786
|
+
this._assetManager.clearAssets();
|
|
2787
|
+
}
|
|
2788
|
+
updateCamera(param) {
|
|
2789
|
+
const previousCam = this.camera;
|
|
2790
|
+
this._camera = CameraFactory.updataCamera(param, this.camera);
|
|
2791
|
+
if (previousCam !== this.camera) {
|
|
2792
|
+
this._onCameraChangedDelegate.broadcast();
|
|
2793
|
+
}
|
|
2794
|
+
this._camera.updateProjectionMatrix();
|
|
2795
|
+
this.viewport.markRenderStateDirty();
|
|
2796
|
+
}
|
|
2797
|
+
onWindowResize(width, height) {
|
|
2798
|
+
if (this.camera instanceof PerspectiveCamera) {
|
|
2799
|
+
this.camera.aspect = width / height;
|
|
2800
|
+
}
|
|
2801
|
+
// if(this.camera instanceof OrthographicCamera)
|
|
2802
|
+
// {
|
|
2803
|
+
// // to do
|
|
2804
|
+
// }
|
|
2805
|
+
this.camera.updateProjectionMatrix();
|
|
2806
|
+
}
|
|
2807
|
+
async renderAsImage(width = 1024, height = 1024) {
|
|
2808
|
+
return await this.viewport.renderAsImage(width, height);
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2743
2812
|
/*
|
|
2744
2813
|
* virtual class of light, should not be use directly.
|
|
2745
2814
|
*/
|
|
@@ -3211,4 +3280,4 @@ class TransformGizmo extends Pawn {
|
|
|
3211
3280
|
}
|
|
3212
3281
|
}
|
|
3213
3282
|
|
|
3214
|
-
export { Actor, AssetManager, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAppParam, DefaultBloomParam, DefaultCameraParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOutlineParams, DefaultPostProcessParam, DefaultRenderParam, DefaultSSRParam, DefaultSkyParam, DefaultToneMappingParams, DefaultViewportParam, Delegate, DirectionalLightActor, DirectionalLightComponent, FirstPerson, GeometryAssetPointer, LabelComponent, MaterialAssetPointer, MeshComponent, Orbital, PlaneActor, PlaneComponent, SceneComponent, SkyActor, SkyComponent, SphereComponent, TAssetPointer, TSmartPointer, TextureAssetPointer, ThreeJsApp, ThreeObjectLibrary, ToneMappingOptions, TransformGizmo, Viewport, WebGPUPostProcessFactory, World };
|
|
3283
|
+
export { Actor, AssetManager, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAppParam, DefaultBloomParam, DefaultCameraParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOutlineParams, DefaultPostProcessParam, DefaultRenderParam, DefaultSSRParam, DefaultSkyParam, DefaultToneMappingParams, DefaultViewportParam, DefaultWorldParam, Delegate, DirectionalLightActor, DirectionalLightComponent, FirstPerson, GeometryAssetPointer, LabelComponent, LevelActor, MaterialAssetPointer, MeshComponent, Orbital, PlaneActor, PlaneComponent, SceneComponent, SkyActor, SkyComponent, SphereComponent, TAssetPointer, TSmartPointer, TextureAssetPointer, ThreeJsApp, ThreeObjectLibrary, ToneMappingOptions, TransformGizmo, Viewport, WebGPUPostProcessFactory, World };
|
package/dist/index.d.ts
CHANGED
|
@@ -16,11 +16,14 @@ export type { AppParam, AppClass } from "./lythreeframe/Frame/Parameters/AppPara
|
|
|
16
16
|
export { DefaultRenderParam, DefaultAppParam } from "./lythreeframe/Frame/Parameters/AppParameter";
|
|
17
17
|
export type { ViewportParam } from './lythreeframe/Frame/Parameters/ViewportParameters';
|
|
18
18
|
export { DefaultViewportParam } from './lythreeframe/Frame/Parameters/ViewportParameters';
|
|
19
|
+
export type { WorldParam } from "./lythreeframe/Frame/Parameters/WorldParameter";
|
|
20
|
+
export { DefaultWorldParam } from "./lythreeframe/Frame/Parameters/WorldParameter";
|
|
19
21
|
export { Actor } from "./lythreeframe/Object/Actor";
|
|
20
22
|
export { DirectionalLightActor } from "./lythreeframe/Object/Actors/Light/DirectionalLightActor";
|
|
21
23
|
export { BoxActor } from "./lythreeframe/Object/Actors/Shape/BoxActor";
|
|
22
24
|
export { SkyActor } from "./lythreeframe/Object/Actors/Sky/SkyActor";
|
|
23
25
|
export { PlaneActor } from "./lythreeframe/Object/Actors/Shape/PlaneActor";
|
|
26
|
+
export { LevelActor } from './lythreeframe/Object/Actors/Level/LevelActor';
|
|
24
27
|
export { SceneComponent } from "./lythreeframe/Object/Components/SceneComponent";
|
|
25
28
|
export { MeshComponent } from "./lythreeframe/Object/Components/Mesh/MeshComponent";
|
|
26
29
|
export { BoxComponent } from "./lythreeframe/Object/Components/Mesh/Shape/BoxComponent";
|
|
@@ -3,15 +3,20 @@ import { ThreeJsApp } from "../ThreeJsApp";
|
|
|
3
3
|
import { Viewport } from "./Viewport";
|
|
4
4
|
import { Controller } from "./Controller";
|
|
5
5
|
import { Actor } from "../Object/Actor";
|
|
6
|
+
import { LevelActor } from "../Object/Actors/Level/LevelActor";
|
|
7
|
+
import { WorldParam } from "./Parameters/WorldParameter";
|
|
6
8
|
export declare class World {
|
|
7
9
|
get scene(): Scene;
|
|
8
10
|
get viewport(): Viewport;
|
|
9
11
|
get controller(): Controller;
|
|
10
|
-
protected
|
|
12
|
+
protected rootActor: LevelActor;
|
|
11
13
|
protected app: ThreeJsApp;
|
|
12
14
|
protected actors: Set<Actor>;
|
|
13
|
-
|
|
15
|
+
protected tickableActors: Set<Actor>;
|
|
16
|
+
constructor(app: ThreeJsApp, worldParam: WorldParam);
|
|
14
17
|
init(): void;
|
|
18
|
+
addTickableActor(actor: Actor): void;
|
|
19
|
+
removeTickableActor(actor: Actor): void;
|
|
15
20
|
tick(deltaTime: number): void;
|
|
16
21
|
destroy(): void;
|
|
17
22
|
addActor(actor: Actor): void;
|
|
@@ -14,6 +14,7 @@ export declare class Actor extends BaseObject {
|
|
|
14
14
|
get childActors(): Actor[];
|
|
15
15
|
get parentActor(): Actor | null;
|
|
16
16
|
get isVisible(): boolean;
|
|
17
|
+
set isTickEnabled(bCanTick: boolean);
|
|
17
18
|
protected _name: string;
|
|
18
19
|
protected _rootComponent: SceneComponent | null;
|
|
19
20
|
protected _world: World | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Scene } from "three/webgpu";
|
|
2
|
+
import { ThreeJsApp } from "../../../ThreeJsApp";
|
|
3
|
+
import { Actor } from "../../Actor";
|
|
4
|
+
export declare class LevelActor extends Actor {
|
|
5
|
+
get scene(): Scene;
|
|
6
|
+
protected _scene: Scene | null;
|
|
7
|
+
constructor(app: ThreeJsApp);
|
|
8
|
+
tick(_deltaTime: number): void;
|
|
9
|
+
destroy(): void;
|
|
10
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export declare abstract class BaseObject {
|
|
2
|
-
get
|
|
3
|
-
set
|
|
2
|
+
get isTickEnabled(): boolean;
|
|
3
|
+
set isTickEnabled(bCanTick: boolean);
|
|
4
4
|
get uuid(): string;
|
|
5
5
|
protected bCanTick: boolean;
|
|
6
|
+
protected tickEvents: ((deltaTime: number) => void)[];
|
|
6
7
|
protected _uuid: string;
|
|
7
8
|
protected constructor(uuid?: string);
|
|
8
9
|
tick(deltaTime: number): void;
|
|
10
|
+
addTickEvent(event: (deltaTime: number) => void): void;
|
|
11
|
+
removeTickEvent(event: (deltaTime: number) => void): void;
|
|
12
|
+
clearTickEvents(): void;
|
|
9
13
|
destroy(): void;
|
|
10
14
|
}
|
|
@@ -13,6 +13,7 @@ export declare class SceneComponent extends Component {
|
|
|
13
13
|
protected app: ThreeJsApp;
|
|
14
14
|
constructor(app: ThreeJsApp, newThreeObject: Object3D);
|
|
15
15
|
createDefaultThreeObject(): void;
|
|
16
|
+
tick(deltaTime: number): void;
|
|
16
17
|
get isVisible(): boolean;
|
|
17
18
|
setVisible(bVisible: boolean): void;
|
|
18
19
|
setLayers(layer: number): void;
|