lythreeframe 1.2.59 → 1.2.61

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.
@@ -2264,11 +2264,11 @@ class Controller {
2264
2264
  if (this._pointButtonIsDown.size > 0)
2265
2265
  return;
2266
2266
  const hits = this.getHitResultUnderCursor();
2267
- const component = hits === null || hits === void 0 ? void 0 : hits.object.userData["LYObject"];
2267
+ const component = hits === null || hits === void 0 ? void 0 : hits.component;
2268
2268
  if (component !== this.hoveringComponent) {
2269
2269
  this.clearHoveringComponent();
2270
2270
  if (component instanceof SceneComponent && component.isHoverEnabled && hits) {
2271
- this.fireHoverEvent(component, hits, true);
2271
+ this.fireHoverEvent(component, hits.hit, true);
2272
2272
  }
2273
2273
  }
2274
2274
  }
@@ -2319,10 +2319,10 @@ class Controller {
2319
2319
  }
2320
2320
  handleFirstClick() {
2321
2321
  const hit = this.getHitResultUnderCursor();
2322
- const component = hit === null || hit === void 0 ? void 0 : hit.object.userData["LYObject"];
2322
+ const component = hit === null || hit === void 0 ? void 0 : hit.component;
2323
2323
  if (component instanceof SceneComponent && component.isClickEnabled && hit) {
2324
2324
  this.prepareClickComponent = component;
2325
- this.prepareClickHit = hit;
2325
+ this.prepareClickHit = hit.hit;
2326
2326
  this.leftClickTimer = window.setTimeout(() => {
2327
2327
  this.leftClickTimer = null;
2328
2328
  if (this.prepareClickComponent && this.prepareClickHit) {
@@ -2375,9 +2375,9 @@ class Controller {
2375
2375
  }
2376
2376
  // 广播组件按下事件
2377
2377
  const hit = this.getHitResultUnderCursor();
2378
- const component = hit === null || hit === void 0 ? void 0 : hit.object.userData["LYObject"];
2378
+ const component = hit === null || hit === void 0 ? void 0 : hit.component;
2379
2379
  if (component instanceof SceneComponent && hit) {
2380
- this.firePointerDownEvent(component, hit, event.button);
2380
+ this.firePointerDownEvent(component, hit.hit, event.button);
2381
2381
  }
2382
2382
  }
2383
2383
  firePointerDownEvent(component, hit, button) {
@@ -2412,18 +2412,31 @@ class Controller {
2412
2412
  getHitResultFromScreenPoint(x, y) {
2413
2413
  this._raycastVec2.set(x, y);
2414
2414
  this.raycaster.setFromCamera(this._raycastVec2, this.camera);
2415
- const out = this.raycaster.intersectObjects(this.world.scene.children, true);
2415
+ const out = this.getAllHitResultFromScreenPoint(x, y);
2416
2416
  for (const hit of out) {
2417
+ if (!hit.component.isHoverEnabled && !hit.component.isClickEnabled)
2418
+ continue;
2419
+ return hit;
2420
+ }
2421
+ return null;
2422
+ }
2423
+ getAllHitResultFromScreenPoint(x, y) {
2424
+ this._raycastVec2.set(x, y);
2425
+ this.raycaster.setFromCamera(this._raycastVec2, this.camera);
2426
+ const hits = this.raycaster.intersectObjects(this.world.scene.children, true);
2427
+ let out = [];
2428
+ for (const hit of hits) {
2417
2429
  if (hit.object.userData["rayIgnored"])
2418
2430
  continue;
2419
2431
  const component = hit.object.userData["LYObject"];
2420
2432
  if (!component)
2421
2433
  continue;
2422
- if (!component.isHoverEnabled && !component.isClickEnabled)
2423
- continue;
2424
- return hit;
2434
+ out.push({
2435
+ component: component,
2436
+ hit: hit
2437
+ });
2425
2438
  }
2426
- return null;
2439
+ return out;
2427
2440
  }
2428
2441
  focusTo(targetPos, targetQuat, distance, time, onGoing = null, onFinished = null) {
2429
2442
  this.pawn.focusTo(targetPos, targetQuat, distance, time, onGoing, onFinished);
@@ -2262,11 +2262,11 @@ class Controller {
2262
2262
  if (this._pointButtonIsDown.size > 0)
2263
2263
  return;
2264
2264
  const hits = this.getHitResultUnderCursor();
2265
- const component = hits === null || hits === void 0 ? void 0 : hits.object.userData["LYObject"];
2265
+ const component = hits === null || hits === void 0 ? void 0 : hits.component;
2266
2266
  if (component !== this.hoveringComponent) {
2267
2267
  this.clearHoveringComponent();
2268
2268
  if (component instanceof SceneComponent && component.isHoverEnabled && hits) {
2269
- this.fireHoverEvent(component, hits, true);
2269
+ this.fireHoverEvent(component, hits.hit, true);
2270
2270
  }
2271
2271
  }
2272
2272
  }
@@ -2317,10 +2317,10 @@ class Controller {
2317
2317
  }
2318
2318
  handleFirstClick() {
2319
2319
  const hit = this.getHitResultUnderCursor();
2320
- const component = hit === null || hit === void 0 ? void 0 : hit.object.userData["LYObject"];
2320
+ const component = hit === null || hit === void 0 ? void 0 : hit.component;
2321
2321
  if (component instanceof SceneComponent && component.isClickEnabled && hit) {
2322
2322
  this.prepareClickComponent = component;
2323
- this.prepareClickHit = hit;
2323
+ this.prepareClickHit = hit.hit;
2324
2324
  this.leftClickTimer = window.setTimeout(() => {
2325
2325
  this.leftClickTimer = null;
2326
2326
  if (this.prepareClickComponent && this.prepareClickHit) {
@@ -2373,9 +2373,9 @@ class Controller {
2373
2373
  }
2374
2374
  // 广播组件按下事件
2375
2375
  const hit = this.getHitResultUnderCursor();
2376
- const component = hit === null || hit === void 0 ? void 0 : hit.object.userData["LYObject"];
2376
+ const component = hit === null || hit === void 0 ? void 0 : hit.component;
2377
2377
  if (component instanceof SceneComponent && hit) {
2378
- this.firePointerDownEvent(component, hit, event.button);
2378
+ this.firePointerDownEvent(component, hit.hit, event.button);
2379
2379
  }
2380
2380
  }
2381
2381
  firePointerDownEvent(component, hit, button) {
@@ -2410,18 +2410,31 @@ class Controller {
2410
2410
  getHitResultFromScreenPoint(x, y) {
2411
2411
  this._raycastVec2.set(x, y);
2412
2412
  this.raycaster.setFromCamera(this._raycastVec2, this.camera);
2413
- const out = this.raycaster.intersectObjects(this.world.scene.children, true);
2413
+ const out = this.getAllHitResultFromScreenPoint(x, y);
2414
2414
  for (const hit of out) {
2415
+ if (!hit.component.isHoverEnabled && !hit.component.isClickEnabled)
2416
+ continue;
2417
+ return hit;
2418
+ }
2419
+ return null;
2420
+ }
2421
+ getAllHitResultFromScreenPoint(x, y) {
2422
+ this._raycastVec2.set(x, y);
2423
+ this.raycaster.setFromCamera(this._raycastVec2, this.camera);
2424
+ const hits = this.raycaster.intersectObjects(this.world.scene.children, true);
2425
+ let out = [];
2426
+ for (const hit of hits) {
2415
2427
  if (hit.object.userData["rayIgnored"])
2416
2428
  continue;
2417
2429
  const component = hit.object.userData["LYObject"];
2418
2430
  if (!component)
2419
2431
  continue;
2420
- if (!component.isHoverEnabled && !component.isClickEnabled)
2421
- continue;
2422
- return hit;
2432
+ out.push({
2433
+ component: component,
2434
+ hit: hit
2435
+ });
2423
2436
  }
2424
- return null;
2437
+ return out;
2425
2438
  }
2426
2439
  focusTo(targetPos, targetQuat, distance, time, onGoing = null, onFinished = null) {
2427
2440
  this.pawn.focusTo(targetPos, targetQuat, distance, time, onGoing, onFinished);
@@ -5,6 +5,10 @@ import { Viewport } from "./Viewport";
5
5
  import { Pawn } from "../Object/PawnV2/Pawn";
6
6
  import { SceneComponent } from "../Object/Components/SceneComponent";
7
7
  import { Delegate } from "../Delegate";
8
+ export interface HitResult {
9
+ component: SceneComponent;
10
+ hit: Intersection;
11
+ }
8
12
  /** 组件交互事件基类 */
9
13
  export interface ComponentInteractionEvent {
10
14
  component: SceneComponent;
@@ -97,7 +101,8 @@ export declare class Controller {
97
101
  protected onPointerLeaveEvent(_event: MouseEvent): void;
98
102
  protected addCorePointerListeners(): void;
99
103
  protected removeCorePointerListeners(): void;
100
- getHitResultUnderCursor(): Intersection | null;
101
- getHitResultFromScreenPoint(x: number, y: number): Intersection | null;
104
+ getHitResultUnderCursor(): HitResult | null;
105
+ getHitResultFromScreenPoint(x: number, y: number): HitResult | null;
106
+ getAllHitResultFromScreenPoint(x: number, y: number): HitResult[];
102
107
  focusTo(targetPos: Vector3, targetQuat: Quaternion | Euler, distance: number, time: number, onGoing?: (() => void) | null, onFinished?: (() => void) | null): void;
103
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.2.59",
3
+ "version": "1.2.61",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",