lythreeframe 1.1.12 → 1.1.14

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.
@@ -1250,7 +1250,11 @@ const DefaultPostProcessParam = {
1250
1250
 
1251
1251
  class World {
1252
1252
  get scene() {
1253
- return this.rootActor.scene;
1253
+ let scene = this.rootActor.scene;
1254
+ if (!scene) {
1255
+ throw new Error("scene is null");
1256
+ }
1257
+ return scene;
1254
1258
  }
1255
1259
  get viewport() {
1256
1260
  return this.app.viewport;
@@ -1259,12 +1263,14 @@ class World {
1259
1263
  return this.app.controller;
1260
1264
  }
1261
1265
  constructor(app, worldParam) {
1266
+ this.rootActor = null;
1262
1267
  this.actors = new Set();
1263
1268
  this.tickableActors = new Set();
1264
1269
  this.app = app;
1265
- this.rootActor = new worldParam.levelActorClass(app);
1270
+ this.worldParam = worldParam;
1266
1271
  }
1267
1272
  init() {
1273
+ this.rootActor = new this.worldParam.levelActorClass(this.app);
1268
1274
  }
1269
1275
  addTickableActor(actor) {
1270
1276
  this.tickableActors.add(actor);
@@ -1278,6 +1284,7 @@ class World {
1278
1284
  });
1279
1285
  }
1280
1286
  destroy() {
1287
+ this.tickableActors.clear();
1281
1288
  this.actors.forEach((elem) => {
1282
1289
  elem.destroy();
1283
1290
  });
@@ -1547,9 +1554,9 @@ class Viewport {
1547
1554
  this.app.onCameraChangedDelegate.add(() => {
1548
1555
  this.setupPostProcess();
1549
1556
  });
1550
- this.setupPostProcess();
1551
1557
  }
1552
1558
  init() {
1559
+ this.setupPostProcess();
1553
1560
  }
1554
1561
  setupPostProcess() {
1555
1562
  if (this.postProcessParam.toneMapping) {
@@ -2064,6 +2071,8 @@ class Controller {
2064
2071
  this._pawn = new Orbital(this);
2065
2072
  this.pawn.possess();
2066
2073
  this.raycaster = new webgpu.Raycaster();
2074
+ }
2075
+ init() {
2067
2076
  if (this.viewPort.canvas) {
2068
2077
  this.viewPort.canvas.addEventListener("pointermove", this.onPointerMove);
2069
2078
  this.viewPort.canvas.addEventListener("pointerenter", this.onPointerEnter);
@@ -2072,8 +2081,6 @@ class Controller {
2072
2081
  this.viewPort.canvas.addEventListener("pointerdown", this.onPointerDown);
2073
2082
  }
2074
2083
  }
2075
- init() {
2076
- }
2077
2084
  tick(deltaTime) {
2078
2085
  this.pawn.tick(deltaTime);
2079
2086
  }
@@ -1248,7 +1248,11 @@ const DefaultPostProcessParam = {
1248
1248
 
1249
1249
  class World {
1250
1250
  get scene() {
1251
- return this.rootActor.scene;
1251
+ let scene = this.rootActor.scene;
1252
+ if (!scene) {
1253
+ throw new Error("scene is null");
1254
+ }
1255
+ return scene;
1252
1256
  }
1253
1257
  get viewport() {
1254
1258
  return this.app.viewport;
@@ -1257,12 +1261,14 @@ class World {
1257
1261
  return this.app.controller;
1258
1262
  }
1259
1263
  constructor(app, worldParam) {
1264
+ this.rootActor = null;
1260
1265
  this.actors = new Set();
1261
1266
  this.tickableActors = new Set();
1262
1267
  this.app = app;
1263
- this.rootActor = new worldParam.levelActorClass(app);
1268
+ this.worldParam = worldParam;
1264
1269
  }
1265
1270
  init() {
1271
+ this.rootActor = new this.worldParam.levelActorClass(this.app);
1266
1272
  }
1267
1273
  addTickableActor(actor) {
1268
1274
  this.tickableActors.add(actor);
@@ -1276,6 +1282,7 @@ class World {
1276
1282
  });
1277
1283
  }
1278
1284
  destroy() {
1285
+ this.tickableActors.clear();
1279
1286
  this.actors.forEach((elem) => {
1280
1287
  elem.destroy();
1281
1288
  });
@@ -1545,9 +1552,9 @@ class Viewport {
1545
1552
  this.app.onCameraChangedDelegate.add(() => {
1546
1553
  this.setupPostProcess();
1547
1554
  });
1548
- this.setupPostProcess();
1549
1555
  }
1550
1556
  init() {
1557
+ this.setupPostProcess();
1551
1558
  }
1552
1559
  setupPostProcess() {
1553
1560
  if (this.postProcessParam.toneMapping) {
@@ -2062,6 +2069,8 @@ class Controller {
2062
2069
  this._pawn = new Orbital(this);
2063
2070
  this.pawn.possess();
2064
2071
  this.raycaster = new Raycaster();
2072
+ }
2073
+ init() {
2065
2074
  if (this.viewPort.canvas) {
2066
2075
  this.viewPort.canvas.addEventListener("pointermove", this.onPointerMove);
2067
2076
  this.viewPort.canvas.addEventListener("pointerenter", this.onPointerEnter);
@@ -2070,8 +2079,6 @@ class Controller {
2070
2079
  this.viewPort.canvas.addEventListener("pointerdown", this.onPointerDown);
2071
2080
  }
2072
2081
  }
2073
- init() {
2074
- }
2075
2082
  tick(deltaTime) {
2076
2083
  this.pawn.tick(deltaTime);
2077
2084
  }
@@ -9,10 +9,11 @@ export declare class World {
9
9
  get scene(): Scene;
10
10
  get viewport(): Viewport;
11
11
  get controller(): Controller;
12
- protected rootActor: LevelActor;
12
+ protected rootActor: LevelActor | null;
13
13
  protected app: ThreeJsApp;
14
14
  protected actors: Set<Actor>;
15
15
  protected tickableActors: Set<Actor>;
16
+ protected worldParam: WorldParam;
16
17
  constructor(app: ThreeJsApp, worldParam: WorldParam);
17
18
  init(): void;
18
19
  addTickableActor(actor: Actor): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",