Skip to content

Commit

Permalink
fix: test error
Browse files Browse the repository at this point in the history
  • Loading branch information
demike committed Dec 16, 2024
1 parent d36fe48 commit 132cb1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions projects/ngx-three/src/lib/loaders/LazyObject3dProxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Object3D, Object3DEventMap } from 'three';
import { createLazyObject3DProxy, LazyObject3DProxy } from './LazyObject3dProxy';

describe('LazyObj3DProxy', () => {
let proxy: LazyObject3DProxy;
let proxy: LazyObject3DProxy<{ click: { customAttr: string } } & Object3DEventMap>;

beforeEach(async () => {
proxy = createLazyObject3DProxy();
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('LazyObj3DProxy', () => {
});

it('should remove event listeners of the real object3D when it is applied', () => {
const obj = new Object3D();
const obj = new Object3D<{ click: { customAttr: string } } & Object3DEventMap>();
expect(obj.children.length).toBe(0);

const listener = () => {};
Expand Down
8 changes: 5 additions & 3 deletions projects/ngx-three/src/lib/loaders/LazyObject3dProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,18 @@ class Object3DProxyHandler implements ProxyHandler<Object3D> {
};
}

export interface LazyObject3DProxy extends Object3D {
export interface LazyObject3DProxy<TEventMap extends Object3DEventMap = Object3DEventMap> extends Object3D<TEventMap> {
// eslint-disable-next-line @typescript-eslint/naming-convention
readonly __isProxy?: boolean;
objRef?: Object3D;
applyToObject3D(real: Object3D): void;
}

export function createLazyObject3DProxy(target = new Object3D()): LazyObject3DProxy {
export function createLazyObject3DProxy<TEventMap extends Object3DEventMap = Object3DEventMap>(
target = new Object3D<TEventMap>(),
): LazyObject3DProxy<TEventMap> {
const handler = new Object3DProxyHandler(target);
return new Proxy<LazyObject3DProxy>(handler as unknown as LazyObject3DProxy, handler);
return new Proxy<LazyObject3DProxy<TEventMap>>(handler as unknown as LazyObject3DProxy<TEventMap>, handler);
}

export function isLazyObject3dProxy(object: Object3D | LazyObject3DProxy): object is LazyObject3DProxy {
Expand Down

0 comments on commit 132cb1b

Please sign in to comment.