lythreeframe 1.2.65 → 1.2.67

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.
@@ -1391,6 +1391,24 @@ class World {
1391
1391
  actor.onAddedToWorld(this);
1392
1392
  this.viewport.markRenderStateDirty();
1393
1393
  }
1394
+ removeActor(actor) {
1395
+ actor.destroy();
1396
+ this.actors.delete(actor);
1397
+ this.viewport.markRenderStateDirty();
1398
+ }
1399
+ removeActors(actors) {
1400
+ for (const actor of actors) {
1401
+ actor.destroy();
1402
+ this.actors.delete(actor);
1403
+ }
1404
+ this.viewport.markRenderStateDirty();
1405
+ }
1406
+ getActorById(id) {
1407
+ return this.rootActor.getChildActorById(id, true);
1408
+ }
1409
+ getActorsByIds(ids) {
1410
+ return this.rootActor.getChildActorsByIds(ids, true);
1411
+ }
1394
1412
  }
1395
1413
 
1396
1414
  class WebGPUPostProcessFactory {
@@ -2456,6 +2474,7 @@ class Controller {
2456
2474
  this.fireComponentClick(component, hit, isDoubleClick);
2457
2475
  // Actor level
2458
2476
  const actor = component.parentActor;
2477
+ //console.log("[Controller]fireClickEvents", actor, actor?.isClickEnabled)
2459
2478
  if (actor && actor.isClickEnabled) {
2460
2479
  this.fireActorClick(actor, component, hit, isDoubleClick);
2461
2480
  }
@@ -2491,7 +2510,13 @@ class Controller {
2491
2510
  this.raycaster.setFromCamera(this._raycastVec2, this.camera);
2492
2511
  const out = this.getAllHitResultFromScreenPoint(x, y);
2493
2512
  for (const hit of out) {
2494
- if (!hit.component.isHoverEnabled && !hit.component.isClickEnabled)
2513
+ // 检查 Component 级别的交互状态
2514
+ const componentInteractable = hit.component.isHoverEnabled || hit.component.isClickEnabled;
2515
+ // 检查 Actor 级别的交互状态
2516
+ const actor = hit.component.parentActor;
2517
+ const actorInteractable = actor && (actor.isHoverEnabled || actor.isClickEnabled);
2518
+ // 只要 Component 或 Actor 任一可交互,就返回该结果
2519
+ if (!componentInteractable && !actorInteractable)
2495
2520
  continue;
2496
2521
  return hit;
2497
2522
  }
@@ -2750,6 +2775,29 @@ class Actor extends BaseObject {
2750
2775
  }
2751
2776
  return null;
2752
2777
  }
2778
+ getChildActorsByIds(ids, bRecursive = true) {
2779
+ const result = [];
2780
+ const idSet = new Set(ids);
2781
+ const directChildren = this.childActors;
2782
+ for (const child of directChildren) {
2783
+ if (idSet.has(child.uuid)) {
2784
+ result.push(child);
2785
+ idSet.delete(child.uuid);
2786
+ }
2787
+ }
2788
+ if (bRecursive && idSet.size > 0) {
2789
+ for (const child of directChildren) {
2790
+ const foundInChildren = child.getChildActorsByIds([...idSet], true);
2791
+ for (const found of foundInChildren) {
2792
+ result.push(found);
2793
+ idSet.delete(found.uuid);
2794
+ }
2795
+ if (idSet.size === 0)
2796
+ break;
2797
+ }
2798
+ }
2799
+ return result;
2800
+ }
2753
2801
  getComponentById(id) {
2754
2802
  return this.rootComponent.getComponentById(id);
2755
2803
  }
@@ -1389,6 +1389,24 @@ class World {
1389
1389
  actor.onAddedToWorld(this);
1390
1390
  this.viewport.markRenderStateDirty();
1391
1391
  }
1392
+ removeActor(actor) {
1393
+ actor.destroy();
1394
+ this.actors.delete(actor);
1395
+ this.viewport.markRenderStateDirty();
1396
+ }
1397
+ removeActors(actors) {
1398
+ for (const actor of actors) {
1399
+ actor.destroy();
1400
+ this.actors.delete(actor);
1401
+ }
1402
+ this.viewport.markRenderStateDirty();
1403
+ }
1404
+ getActorById(id) {
1405
+ return this.rootActor.getChildActorById(id, true);
1406
+ }
1407
+ getActorsByIds(ids) {
1408
+ return this.rootActor.getChildActorsByIds(ids, true);
1409
+ }
1392
1410
  }
1393
1411
 
1394
1412
  class WebGPUPostProcessFactory {
@@ -2454,6 +2472,7 @@ class Controller {
2454
2472
  this.fireComponentClick(component, hit, isDoubleClick);
2455
2473
  // Actor level
2456
2474
  const actor = component.parentActor;
2475
+ //console.log("[Controller]fireClickEvents", actor, actor?.isClickEnabled)
2457
2476
  if (actor && actor.isClickEnabled) {
2458
2477
  this.fireActorClick(actor, component, hit, isDoubleClick);
2459
2478
  }
@@ -2489,7 +2508,13 @@ class Controller {
2489
2508
  this.raycaster.setFromCamera(this._raycastVec2, this.camera);
2490
2509
  const out = this.getAllHitResultFromScreenPoint(x, y);
2491
2510
  for (const hit of out) {
2492
- if (!hit.component.isHoverEnabled && !hit.component.isClickEnabled)
2511
+ // 检查 Component 级别的交互状态
2512
+ const componentInteractable = hit.component.isHoverEnabled || hit.component.isClickEnabled;
2513
+ // 检查 Actor 级别的交互状态
2514
+ const actor = hit.component.parentActor;
2515
+ const actorInteractable = actor && (actor.isHoverEnabled || actor.isClickEnabled);
2516
+ // 只要 Component 或 Actor 任一可交互,就返回该结果
2517
+ if (!componentInteractable && !actorInteractable)
2493
2518
  continue;
2494
2519
  return hit;
2495
2520
  }
@@ -2748,6 +2773,29 @@ class Actor extends BaseObject {
2748
2773
  }
2749
2774
  return null;
2750
2775
  }
2776
+ getChildActorsByIds(ids, bRecursive = true) {
2777
+ const result = [];
2778
+ const idSet = new Set(ids);
2779
+ const directChildren = this.childActors;
2780
+ for (const child of directChildren) {
2781
+ if (idSet.has(child.uuid)) {
2782
+ result.push(child);
2783
+ idSet.delete(child.uuid);
2784
+ }
2785
+ }
2786
+ if (bRecursive && idSet.size > 0) {
2787
+ for (const child of directChildren) {
2788
+ const foundInChildren = child.getChildActorsByIds([...idSet], true);
2789
+ for (const found of foundInChildren) {
2790
+ result.push(found);
2791
+ idSet.delete(found.uuid);
2792
+ }
2793
+ if (idSet.size === 0)
2794
+ break;
2795
+ }
2796
+ }
2797
+ return result;
2798
+ }
2751
2799
  getComponentById(id) {
2752
2800
  return this.rootComponent.getComponentById(id);
2753
2801
  }
@@ -22,4 +22,8 @@ export declare class World {
22
22
  tick(deltaTime: number): void;
23
23
  destroy(): void;
24
24
  addActor(actor: Actor): void;
25
+ removeActor(actor: Actor): void;
26
+ removeActors(actors: Actor[]): void;
27
+ getActorById(id: string): Actor | null;
28
+ getActorsByIds(ids: string[]): Actor[];
25
29
  }
@@ -33,6 +33,7 @@ export declare class Actor extends BaseObject {
33
33
  protected constructRootComponent(): SceneComponent;
34
34
  getBoundsCenterPosition(bInWorldSpace?: boolean): Vector3;
35
35
  getChildActorById(id: string, bRecursive?: boolean): Actor | null;
36
+ getChildActorsByIds(ids: string[], bRecursive?: boolean): Actor[];
36
37
  getComponentById(id: string): SceneComponent | null;
37
38
  getBoundsTopCenterPosition(bInWorldSpace?: boolean): Vector3;
38
39
  getBoundsBottomCenterPosition(bInWorldSpace?: boolean): Vector3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.2.65",
3
+ "version": "1.2.67",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",