lythreeframe 1.2.37 → 1.2.39

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.
@@ -900,29 +900,25 @@ class TAssetPointer extends TSmartPointer {
900
900
  if (this.value) {
901
901
  this.referenceCount--;
902
902
  if (this.referenceCount === 0) {
903
- try {
903
+ setTimeout(() => {
904
904
  this.value.dispose();
905
905
  this.value = null;
906
- }
907
- catch (e) {
908
- console.error("Error disposing asset pointer:", e);
909
- }
906
+ }, 0);
910
907
  }
911
908
  }
909
+ console.log("realease", this);
912
910
  }
913
911
  forceRelease() {
912
+ console.log("forceRelease", this);
914
913
  if (this.value) {
915
914
  if (this.value.userData && this.value.userData["assetPointer"]) {
916
915
  delete this.value.userData["assetPointer"];
917
916
  }
918
917
  if (typeof this.value.dispose === "function") {
919
- try {
918
+ setTimeout(() => {
920
919
  this.value.dispose();
921
920
  this.value = null;
922
- }
923
- catch (e) {
924
- console.warn("Error disposing asset pointer:", e);
925
- }
921
+ }, 0);
926
922
  }
927
923
  setTimeout(() => {
928
924
  //this.value = null;
@@ -1118,10 +1114,13 @@ class AssetManager {
1118
1114
  });
1119
1115
  }
1120
1116
  }
1121
- async loadGltfFromPath(path) {
1117
+ async loadGltfFromPathAsync(path) {
1122
1118
  let res = await this.gltfLoader.loadAsync(path);
1123
1119
  return res;
1124
1120
  }
1121
+ loadGltfFromPath(path, onLoadFinished) {
1122
+ this.gltfLoader.load(path, onLoadFinished);
1123
+ }
1125
1124
  loadGltfFromBuffer(data, path, onLoadFinished) {
1126
1125
  this.gltfLoader.parse(data, path, onLoadFinished);
1127
1126
  }
@@ -1285,6 +1284,7 @@ class World {
1285
1284
  this._rootActor = new this.worldParam.levelActorClass(this.app);
1286
1285
  }
1287
1286
  addTickableActor(actor) {
1287
+ console.log("addTickableActor", actor.name);
1288
1288
  this.tickableActors.add(actor);
1289
1289
  }
1290
1290
  removeTickableActor(actor) {
@@ -2405,6 +2405,9 @@ class Actor extends BaseObject {
2405
2405
  get isVisible() {
2406
2406
  return this.rootComponent ? this.rootComponent.isVisible : false;
2407
2407
  }
2408
+ get isTickEnabled() {
2409
+ return super.isTickEnabled;
2410
+ }
2408
2411
  set isTickEnabled(bCanTick) {
2409
2412
  super.isTickEnabled = bCanTick;
2410
2413
  if (this.isTickEnabled) {
@@ -2440,6 +2443,23 @@ class Actor extends BaseObject {
2440
2443
  return ret;
2441
2444
  }
2442
2445
  }
2446
+ getChildActorById(id, bRecursive = true) {
2447
+ const directChildren = this.childActors;
2448
+ for (const child of directChildren) {
2449
+ if (child.uuid === id) {
2450
+ return child;
2451
+ }
2452
+ }
2453
+ if (bRecursive) {
2454
+ for (const child of directChildren) {
2455
+ const foundInChild = child.getChildActorById(id, true);
2456
+ if (foundInChild) {
2457
+ return foundInChild;
2458
+ }
2459
+ }
2460
+ }
2461
+ return null;
2462
+ }
2443
2463
  getBoundsTopCenterPosition(bInWorldSpace = true) {
2444
2464
  let ret = new webgpu.Vector3();
2445
2465
  let bounds = this.rootComponent.getBounds();
@@ -898,29 +898,25 @@ class TAssetPointer extends TSmartPointer {
898
898
  if (this.value) {
899
899
  this.referenceCount--;
900
900
  if (this.referenceCount === 0) {
901
- try {
901
+ setTimeout(() => {
902
902
  this.value.dispose();
903
903
  this.value = null;
904
- }
905
- catch (e) {
906
- console.error("Error disposing asset pointer:", e);
907
- }
904
+ }, 0);
908
905
  }
909
906
  }
907
+ console.log("realease", this);
910
908
  }
911
909
  forceRelease() {
910
+ console.log("forceRelease", this);
912
911
  if (this.value) {
913
912
  if (this.value.userData && this.value.userData["assetPointer"]) {
914
913
  delete this.value.userData["assetPointer"];
915
914
  }
916
915
  if (typeof this.value.dispose === "function") {
917
- try {
916
+ setTimeout(() => {
918
917
  this.value.dispose();
919
918
  this.value = null;
920
- }
921
- catch (e) {
922
- console.warn("Error disposing asset pointer:", e);
923
- }
919
+ }, 0);
924
920
  }
925
921
  setTimeout(() => {
926
922
  //this.value = null;
@@ -1116,10 +1112,13 @@ class AssetManager {
1116
1112
  });
1117
1113
  }
1118
1114
  }
1119
- async loadGltfFromPath(path) {
1115
+ async loadGltfFromPathAsync(path) {
1120
1116
  let res = await this.gltfLoader.loadAsync(path);
1121
1117
  return res;
1122
1118
  }
1119
+ loadGltfFromPath(path, onLoadFinished) {
1120
+ this.gltfLoader.load(path, onLoadFinished);
1121
+ }
1123
1122
  loadGltfFromBuffer(data, path, onLoadFinished) {
1124
1123
  this.gltfLoader.parse(data, path, onLoadFinished);
1125
1124
  }
@@ -1283,6 +1282,7 @@ class World {
1283
1282
  this._rootActor = new this.worldParam.levelActorClass(this.app);
1284
1283
  }
1285
1284
  addTickableActor(actor) {
1285
+ console.log("addTickableActor", actor.name);
1286
1286
  this.tickableActors.add(actor);
1287
1287
  }
1288
1288
  removeTickableActor(actor) {
@@ -2403,6 +2403,9 @@ class Actor extends BaseObject {
2403
2403
  get isVisible() {
2404
2404
  return this.rootComponent ? this.rootComponent.isVisible : false;
2405
2405
  }
2406
+ get isTickEnabled() {
2407
+ return super.isTickEnabled;
2408
+ }
2406
2409
  set isTickEnabled(bCanTick) {
2407
2410
  super.isTickEnabled = bCanTick;
2408
2411
  if (this.isTickEnabled) {
@@ -2438,6 +2441,23 @@ class Actor extends BaseObject {
2438
2441
  return ret;
2439
2442
  }
2440
2443
  }
2444
+ getChildActorById(id, bRecursive = true) {
2445
+ const directChildren = this.childActors;
2446
+ for (const child of directChildren) {
2447
+ if (child.uuid === id) {
2448
+ return child;
2449
+ }
2450
+ }
2451
+ if (bRecursive) {
2452
+ for (const child of directChildren) {
2453
+ const foundInChild = child.getChildActorById(id, true);
2454
+ if (foundInChild) {
2455
+ return foundInChild;
2456
+ }
2457
+ }
2458
+ }
2459
+ return null;
2460
+ }
2441
2461
  getBoundsTopCenterPosition(bInWorldSpace = true) {
2442
2462
  let ret = new Vector3();
2443
2463
  let bounds = this.rootComponent.getBounds();
@@ -22,7 +22,8 @@ export declare class AssetManager {
22
22
  convertThreeObjectToLYObject(parentLYComponent: SceneComponent, threejsObject: any): SceneComponent | null;
23
23
  collectResourcesAndReferences(object: Object3D): void;
24
24
  checkMeshResource(mesh: Mesh): void;
25
- loadGltfFromPath(path: string): Promise<GLTF>;
25
+ loadGltfFromPathAsync(path: string): Promise<GLTF>;
26
+ loadGltfFromPath(path: string, onLoadFinished: (gltf: GLTF) => void): void;
26
27
  loadGltfFromBuffer(data: ArrayBuffer | string, path: string, onLoadFinished: (gltf: GLTF) => void): void;
27
28
  loadFile(filepath: string | undefined, onLoadFinished: (data: any) => void): void;
28
29
  addAsset(asset: BufferGeometry | Material | Texture, referenceCount?: number): TAssetPointer<BufferGeometry | Material | Texture> | undefined;
@@ -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
+ get isTickEnabled(): boolean;
17
18
  set isTickEnabled(bCanTick: boolean);
18
19
  protected _name: string;
19
20
  protected _rootComponent: SceneComponent | null;
@@ -26,6 +27,7 @@ export declare class Actor extends BaseObject {
26
27
  constructor(app: ThreeJsApp, uuid?: string);
27
28
  protected constructRootComponent(): SceneComponent;
28
29
  getBoundsCenterPosition(bInWorldSpace?: boolean): Vector3;
30
+ getChildActorById(id: string, bRecursive?: boolean): Actor | null;
29
31
  getBoundsTopCenterPosition(bInWorldSpace?: boolean): Vector3;
30
32
  getBoundsBottomCenterPosition(bInWorldSpace?: boolean): Vector3;
31
33
  getBounds(): import("three").Box3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.2.37",
3
+ "version": "1.2.39",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",