You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(core): Revise optimizations and remove specs
This commit incorporates feedback on previous optimizations:
1. **`libs/core/src/lib/instance.ts` (`prepare` function):**
* Reverted the definition of `setPointerEvent`, `addInteraction`, and `removeInteraction` methods to use `Object.defineProperty` and `Object.defineProperties` respectively. This restores their original definition style, ensuring properties like non-enumerability are maintained as intended.
2. **`libs/core/src/lib/events.ts` (`intersect` function):**
* The sorting mechanism for `raycastResults` has been updated to use a `WeakMap`.
* Before sorting, a `WeakMap` is populated where keys are the `THREE.Intersection` objects and values are their calculated `priority` and `stateExists` status.
* The sort comparator then uses this `WeakMap` to access these pre-calculated values. This approach avoids intermediate array mapping, potentially improving memory efficiency while still preventing redundant `getInstanceState` calls within the sort.
3. **Spec Files Removed:**
* Deleted `libs/core/src/lib/events.spec.ts`.
* Deleted `libs/core/src/lib/instance.spec.ts`.
* Deleted `libs/core/src/lib/loader.spec.ts`.
Unit tests will be handled separately as per feedback.
The optimization for `libs/core/src/lib/loader.ts` (`_injectLoader` effect) from the previous set of changes remains in place.
0 commit comments