lythreeframe 1.1.17 → 1.1.19

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.
@@ -1251,7 +1251,7 @@ const DefaultPostProcessParam = {
1251
1251
  class World {
1252
1252
  get scene() {
1253
1253
  var _a;
1254
- let scene = (_a = this.rootActor) === null || _a === void 0 ? void 0 : _a.scene;
1254
+ let scene = (_a = this._rootActor) === null || _a === void 0 ? void 0 : _a.scene;
1255
1255
  if (!scene) {
1256
1256
  throw new Error("scene is null");
1257
1257
  }
@@ -1263,15 +1263,21 @@ class World {
1263
1263
  get controller() {
1264
1264
  return this.app.controller;
1265
1265
  }
1266
+ get rootActor() {
1267
+ if (!this._rootActor) {
1268
+ throw new Error("rootActor is null");
1269
+ }
1270
+ return this._rootActor;
1271
+ }
1266
1272
  constructor(app, worldParam) {
1267
- this.rootActor = null;
1273
+ this._rootActor = null;
1268
1274
  this.actors = new Set();
1269
1275
  this.tickableActors = new Set();
1270
1276
  this.app = app;
1271
1277
  this.worldParam = worldParam;
1272
1278
  }
1273
1279
  init() {
1274
- this.rootActor = new this.worldParam.levelActorClass(this.app);
1280
+ this._rootActor = new this.worldParam.levelActorClass(this.app);
1275
1281
  }
1276
1282
  addTickableActor(actor) {
1277
1283
  this.tickableActors.add(actor);
@@ -1291,8 +1297,8 @@ class World {
1291
1297
  elem.destroy();
1292
1298
  });
1293
1299
  this.actors.clear();
1294
- (_a = this.rootActor) === null || _a === void 0 ? void 0 : _a.destroy();
1295
- this.rootActor = null;
1300
+ (_a = this._rootActor) === null || _a === void 0 ? void 0 : _a.destroy();
1301
+ this._rootActor = null;
1296
1302
  }
1297
1303
  addActor(actor) {
1298
1304
  var _a;
@@ -1300,7 +1306,7 @@ class World {
1300
1306
  throw new Error("actor.threeObject is null");
1301
1307
  }
1302
1308
  actor.removeFromParent();
1303
- (_a = this.rootActor) === null || _a === void 0 ? void 0 : _a.addChildActor(actor, exports.AttachmentRules.KeepRelative);
1309
+ (_a = this._rootActor) === null || _a === void 0 ? void 0 : _a.addChildActor(actor, exports.AttachmentRules.KeepRelative);
1304
1310
  this.actors.add(actor);
1305
1311
  actor.onAddedToWorld(this);
1306
1312
  this.viewport.markRenderStateDirty();
@@ -2713,9 +2719,15 @@ class LevelActor extends Actor {
2713
2719
  this.isTickEnabled = false;
2714
2720
  }
2715
2721
  tick(_deltaTime) {
2716
- return;
2722
+ if (!this.isTickEnabled) {
2723
+ return;
2724
+ }
2725
+ super.tick(_deltaTime);
2717
2726
  }
2718
2727
  destroy() {
2728
+ this.clearLevel();
2729
+ }
2730
+ clearLevel() {
2719
2731
  this.childActors.forEach((elem) => {
2720
2732
  elem.destroy();
2721
2733
  });
@@ -1249,7 +1249,7 @@ const DefaultPostProcessParam = {
1249
1249
  class World {
1250
1250
  get scene() {
1251
1251
  var _a;
1252
- let scene = (_a = this.rootActor) === null || _a === void 0 ? void 0 : _a.scene;
1252
+ let scene = (_a = this._rootActor) === null || _a === void 0 ? void 0 : _a.scene;
1253
1253
  if (!scene) {
1254
1254
  throw new Error("scene is null");
1255
1255
  }
@@ -1261,15 +1261,21 @@ class World {
1261
1261
  get controller() {
1262
1262
  return this.app.controller;
1263
1263
  }
1264
+ get rootActor() {
1265
+ if (!this._rootActor) {
1266
+ throw new Error("rootActor is null");
1267
+ }
1268
+ return this._rootActor;
1269
+ }
1264
1270
  constructor(app, worldParam) {
1265
- this.rootActor = null;
1271
+ this._rootActor = null;
1266
1272
  this.actors = new Set();
1267
1273
  this.tickableActors = new Set();
1268
1274
  this.app = app;
1269
1275
  this.worldParam = worldParam;
1270
1276
  }
1271
1277
  init() {
1272
- this.rootActor = new this.worldParam.levelActorClass(this.app);
1278
+ this._rootActor = new this.worldParam.levelActorClass(this.app);
1273
1279
  }
1274
1280
  addTickableActor(actor) {
1275
1281
  this.tickableActors.add(actor);
@@ -1289,8 +1295,8 @@ class World {
1289
1295
  elem.destroy();
1290
1296
  });
1291
1297
  this.actors.clear();
1292
- (_a = this.rootActor) === null || _a === void 0 ? void 0 : _a.destroy();
1293
- this.rootActor = null;
1298
+ (_a = this._rootActor) === null || _a === void 0 ? void 0 : _a.destroy();
1299
+ this._rootActor = null;
1294
1300
  }
1295
1301
  addActor(actor) {
1296
1302
  var _a;
@@ -1298,7 +1304,7 @@ class World {
1298
1304
  throw new Error("actor.threeObject is null");
1299
1305
  }
1300
1306
  actor.removeFromParent();
1301
- (_a = this.rootActor) === null || _a === void 0 ? void 0 : _a.addChildActor(actor, AttachmentRules.KeepRelative);
1307
+ (_a = this._rootActor) === null || _a === void 0 ? void 0 : _a.addChildActor(actor, AttachmentRules.KeepRelative);
1302
1308
  this.actors.add(actor);
1303
1309
  actor.onAddedToWorld(this);
1304
1310
  this.viewport.markRenderStateDirty();
@@ -2711,9 +2717,15 @@ class LevelActor extends Actor {
2711
2717
  this.isTickEnabled = false;
2712
2718
  }
2713
2719
  tick(_deltaTime) {
2714
- return;
2720
+ if (!this.isTickEnabled) {
2721
+ return;
2722
+ }
2723
+ super.tick(_deltaTime);
2715
2724
  }
2716
2725
  destroy() {
2726
+ this.clearLevel();
2727
+ }
2728
+ clearLevel() {
2717
2729
  this.childActors.forEach((elem) => {
2718
2730
  elem.destroy();
2719
2731
  });
@@ -9,7 +9,8 @@ export declare class World {
9
9
  get scene(): Scene;
10
10
  get viewport(): Viewport;
11
11
  get controller(): Controller;
12
- protected rootActor: LevelActor | null;
12
+ get rootActor(): LevelActor;
13
+ protected _rootActor: LevelActor | null;
13
14
  protected app: ThreeJsApp;
14
15
  protected actors: Set<Actor>;
15
16
  protected tickableActors: Set<Actor>;
@@ -7,4 +7,5 @@ export declare class LevelActor extends Actor {
7
7
  constructor(app: ThreeJsApp);
8
8
  tick(_deltaTime: number): void;
9
9
  destroy(): void;
10
+ clearLevel(): void;
10
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.1.17",
3
+ "version": "1.1.19",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",