Skip to content

Commit af45513

Browse files
Chau TranChau Tran
Chau Tran
authored and
Chau Tran
committed
fix(core): rename requestAnimationInInjectionContext to requestAnimationFrameInInjectionContext
1 parent 3ef325d commit af45513

File tree

21 files changed

+48
-57
lines changed

21 files changed

+48
-57
lines changed

libs/angular-three/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ export * from './lib/utils/instance';
2020
export * from './lib/utils/is';
2121
export * from './lib/utils/make';
2222
export * from './lib/utils/safe-detect-changes';
23-
export * from './lib/utils/signal';
2423
export * from './lib/utils/timing';
2524
export * from './lib/utils/update';

libs/angular-three/src/lib/loader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type {
1111
import { assertInjectionContext } from './utils/assert-in-injection-context';
1212
import { makeObjectGraph } from './utils/make';
1313
import { safeDetectChanges } from './utils/safe-detect-changes';
14-
import { requestAnimationInInjectionContext } from './utils/timing';
14+
import { requestAnimationFrameInInjectionContext } from './utils/timing';
1515

1616
export type NgtLoaderResults<
1717
TInput extends string | string[] | Record<string, string>,
@@ -96,7 +96,7 @@ export function injectNgtLoader<
9696
const cdr = inject(ChangeDetectorRef);
9797
const effector = load(loaderConstructorFactory, inputs, { extensions, onProgress });
9898

99-
requestAnimationInInjectionContext(() => {
99+
requestAnimationFrameInInjectionContext(() => {
100100
effect(
101101
() => {
102102
const originalUrls = inputs();

libs/angular-three/src/lib/portal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import type { NgtEventManager, NgtRenderState, NgtSize, NgtState } from './types
2929
import { getLocalState, prepare } from './utils/instance';
3030
import { is } from './utils/is';
3131
import { safeDetectChanges } from './utils/safe-detect-changes';
32-
import { queueMicrotaskInInjectionContext } from './utils/timing';
32+
import { requestAnimationFrameInInjectionContext } from './utils/timing';
3333
import { updateCamera } from './utils/update';
3434

3535
const privateKeys = [
@@ -70,7 +70,7 @@ export class NgtPortalBeforeRender {
7070

7171
constructor() {
7272
let oldClear: boolean;
73-
queueMicrotaskInInjectionContext(() => {
73+
requestAnimationFrameInInjectionContext(() => {
7474
injectBeforeRender(
7575
({ delta, frame }) => {
7676
this.beforeRender.emit({ ...this.#portalStore.get(), delta, frame });
Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
import { Injector, runInInjectionContext } from '@angular/core';
22
import { assertInjectionContext } from './assert-in-injection-context';
33

4-
export function requestAnimationInInjectionContext(cb: () => void, injector?: Injector) {
5-
injector = assertInjectionContext(requestAnimationInInjectionContext, injector);
4+
export function requestAnimationFrameInInjectionContext(cb: () => void, injector?: Injector) {
5+
injector = assertInjectionContext(requestAnimationFrameInInjectionContext, injector);
66
return requestAnimationFrame(() => {
77
return runInInjectionContext(injector!, cb);
88
});
99
}
10-
11-
export function queueMicrotaskInInjectionContext(cb: () => void, injector?: Injector) {
12-
injector = assertInjectionContext(requestAnimationInInjectionContext, injector);
13-
return queueMicrotask(() => {
14-
return runInInjectionContext(injector!, cb);
15-
});
16-
}
17-
18-
export function queueMacrotaskInInjectionContext(cb: () => void, injector?: Injector) {
19-
injector = assertInjectionContext(requestAnimationInInjectionContext, injector);
20-
return setTimeout(() => {
21-
return runInInjectionContext(injector!, cb);
22-
});
23-
}

libs/cannon/src/physics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
NgtSignalStore,
2323
NgtStore,
2424
injectBeforeRender,
25-
requestAnimationInInjectionContext,
25+
requestAnimationFrameInInjectionContext,
2626
type NgtRenderState,
2727
} from 'angular-three';
2828
import * as THREE from 'three';
@@ -203,7 +203,7 @@ export class NgtcPhysics extends NgtSignalStore<NgtcPhysicsState> {
203203
stepSize: 1 / 60,
204204
tolerance: 0.001,
205205
});
206-
requestAnimationInInjectionContext(() => {
206+
requestAnimationFrameInInjectionContext(() => {
207207
this.#connectWorker();
208208
this.#updateWorkerProp('axisIndex');
209209
this.#updateWorkerProp('broadphase');

libs/postprocessing/effects/src/lut/lut.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { CUSTOM_ELEMENTS_SCHEMA, Component, Input, computed, effect, inject } from '@angular/core';
2-
import { NgtArgs, NgtSignalStore, NgtStore, injectNgtRef, requestAnimationInInjectionContext } from 'angular-three';
2+
import {
3+
NgtArgs,
4+
NgtSignalStore,
5+
NgtStore,
6+
injectNgtRef,
7+
requestAnimationFrameInInjectionContext,
8+
} from 'angular-three';
39
import { BlendFunction, LUT3DEffect } from 'postprocessing';
410

511
export interface NgtpLUTState {
@@ -47,7 +53,7 @@ export class NgtpLUT extends NgtSignalStore<NgtpLUTState> {
4753

4854
constructor() {
4955
super();
50-
requestAnimationInInjectionContext(() => {
56+
requestAnimationFrameInInjectionContext(() => {
5157
this.#setProps();
5258
});
5359
}

libs/postprocessing/src/effect-composer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
extend,
1515
injectBeforeRender,
1616
injectNgtRef,
17-
requestAnimationInInjectionContext,
17+
requestAnimationFrameInInjectionContext,
1818
} from 'angular-three';
1919
import { DepthDownsamplingPass, EffectComposer, EffectPass, NormalPass, RenderPass } from 'postprocessing';
2020
import * as THREE from 'three';
@@ -191,7 +191,7 @@ export class NgtpEffectComposer extends NgtSignalStore<NgtpEffectComposerState>
191191
multisampling: 8,
192192
frameBufferType: THREE.HalfFloatType,
193193
});
194-
requestAnimationInInjectionContext(() => {
194+
requestAnimationFrameInInjectionContext(() => {
195195
this.#setComposerSize();
196196
this.#updateEffectPasses();
197197
this.#setBeforeRender();

libs/postprocessing/src/effect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
NgtStore,
66
getLocalState,
77
injectNgtRef,
8-
requestAnimationInInjectionContext,
8+
requestAnimationFrameInInjectionContext,
99
} from 'angular-three';
1010
import { BlendFunction, Effect } from 'postprocessing';
1111

@@ -59,7 +59,7 @@ export abstract class NgtpEffect<T extends Effect> extends NgtSignalStore<{
5959

6060
constructor() {
6161
super();
62-
requestAnimationInInjectionContext(() => {
62+
requestAnimationFrameInInjectionContext(() => {
6363
this.#setBlendMode();
6464
});
6565
}

libs/soba/abstractions/src/gizmo-helper/gizmo-viewcube/gizmo-viewcube.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NgFor } from '@angular/common';
22
import { Component, CUSTOM_ELEMENTS_SCHEMA, EventEmitter, Output } from '@angular/core';
3-
import { extend, NgtThreeEvent, requestAnimationInInjectionContext } from 'angular-three';
3+
import { extend, NgtThreeEvent, requestAnimationFrameInInjectionContext } from 'angular-three';
44
import { AmbientLight, Group, PointLight } from 'three';
55
import { cornerDimensions, corners, edgeDimensions, edges } from './constants';
66
import { NgtsGizmoViewcubeEdgeCube } from './gizmo-viewcube-edge';
@@ -47,7 +47,7 @@ export class NgtsGizmoViewcube extends NgtsGizmoViewcubeInputs {
4747

4848
constructor() {
4949
super();
50-
requestAnimationInInjectionContext(() => {
50+
requestAnimationFrameInInjectionContext(() => {
5151
if (this.clicked.observed) {
5252
this.set({ clickEmitter: this.clicked });
5353
}

libs/soba/abstractions/src/line/line.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CUSTOM_ELEMENTS_SCHEMA, Component, Input, computed, effect, inject } from '@angular/core';
2-
import { NgtArgs, NgtStore, injectNgtRef, requestAnimationInInjectionContext } from 'angular-three';
2+
import { NgtArgs, NgtStore, injectNgtRef, requestAnimationFrameInInjectionContext } from 'angular-three';
33
import * as THREE from 'three';
44
import { Line2, LineGeometry, LineMaterial, LineSegments2, LineSegmentsGeometry } from 'three-stdlib';
55
import { NgtsLineInputs, type NgtsLineState } from './line-input';
@@ -122,7 +122,7 @@ export class NgtsLine extends NgtsLineInputs {
122122
constructor() {
123123
super();
124124
this.set({ segments: false });
125-
requestAnimationInInjectionContext(() => {
125+
requestAnimationFrameInInjectionContext(() => {
126126
this.#disposeGeometry();
127127
this.#computeLineDistances();
128128
});

libs/soba/cameras/src/camera/camera.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
injectNgtRef,
44
NgtSignalStore,
55
NgtStore,
6-
requestAnimationInInjectionContext,
6+
requestAnimationFrameInInjectionContext,
77
type NgtCamera,
88
} from 'angular-three';
99
import { injectNgtsFBO } from 'angular-three-soba/misc';
@@ -46,7 +46,7 @@ export abstract class NgtsCamera<TCamera extends NgtCamera> extends NgtSignalSto
4646

4747
constructor() {
4848
super({ resolution: 256, frames: Infinity, makeDefault: false, manual: false });
49-
requestAnimationInInjectionContext(() => {
49+
requestAnimationFrameInInjectionContext(() => {
5050
this.#setDefaultCamera();
5151
this.#updateProjectionMatrix();
5252
});

libs/soba/performance/src/instances/instance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CUSTOM_ELEMENTS_SCHEMA, Component, effect, inject } from '@angular/core';
2-
import { extend, injectNgtRef, requestAnimationInInjectionContext } from 'angular-three';
2+
import { extend, injectNgtRef, requestAnimationFrameInInjectionContext } from 'angular-three';
33
import { NGTS_INSTANCES_API } from './instances';
44
import { PositionMesh } from './position-mesh';
55

@@ -25,7 +25,7 @@ export class NgtsInstance {
2525
protected readonly instancesApi = inject(NGTS_INSTANCES_API);
2626

2727
constructor() {
28-
requestAnimationInInjectionContext(() => {
28+
requestAnimationFrameInInjectionContext(() => {
2929
effect((onCleanup) => {
3030
onCleanup(this.instancesApi().subscribe(this.positionMeshRef));
3131
});

libs/soba/performance/src/instances/instances.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
extend,
1717
injectBeforeRender,
1818
injectNgtRef,
19-
requestAnimationInInjectionContext,
19+
requestAnimationFrameInInjectionContext,
2020
} from 'angular-three';
2121
import * as THREE from 'three';
2222
import { InstancedBufferAttribute, InstancedMesh } from 'three';
@@ -126,7 +126,7 @@ export class NgtsInstances extends NgtSignalStore<NgtsInstancesState> {
126126

127127
constructor() {
128128
super({ limit: 1000, frames: Infinity });
129-
requestAnimationInInjectionContext(() => {
129+
requestAnimationFrameInInjectionContext(() => {
130130
this.#checkUpdate();
131131
this.#setBeforeRender();
132132
});

libs/soba/staging/src/accumulative-shadows/accumulative-shadows.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
getLocalState,
1717
injectBeforeRender,
1818
injectNgtRef,
19-
requestAnimationInInjectionContext,
19+
requestAnimationFrameInInjectionContext,
2020
type NgtGroup,
2121
} from 'angular-three';
2222
import { SoftShadowMaterial, SoftShadowMaterialInputs } from 'angular-three-soba/shaders';
@@ -257,7 +257,7 @@ export class NgtsAccumulativeShadows extends NgtSignalStore<NgtsAccumulativeShad
257257
toneMapped: true,
258258
temporal: false,
259259
});
260-
requestAnimationInInjectionContext(() => {
260+
requestAnimationFrameInInjectionContext(() => {
261261
this.#configure();
262262
this.#resetAndUpdate();
263263
});

libs/soba/staging/src/accumulative-shadows/randomized-lights.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
NgtSignalStore,
66
extend,
77
injectNgtRef,
8-
requestAnimationInInjectionContext,
8+
requestAnimationFrameInInjectionContext,
99
type NgtGroup,
1010
} from 'angular-three';
1111
import * as THREE from 'three';
@@ -206,7 +206,7 @@ export class NgtsRandomizedLights extends NgtSignalStore<NgtsRandomizedLightsSta
206206
intensity: 1,
207207
ambient: 0.5,
208208
});
209-
requestAnimationInInjectionContext(() => {
209+
requestAnimationFrameInInjectionContext(() => {
210210
this.#updateLightsMap();
211211
});
212212
}

libs/soba/staging/src/bounds/bounds.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
is,
1919
NgtSignalStore,
2020
NgtStore,
21-
requestAnimationInInjectionContext,
21+
requestAnimationFrameInInjectionContext,
2222
type NgtRenderState,
2323
} from 'angular-three';
2424
import * as THREE from 'three';
@@ -283,7 +283,7 @@ export class NgtsBounds extends NgtSignalStore<NgtsBoundsState> {
283283
constructor() {
284284
super({ damping: 6, fit: false, clip: false, observe: false, margin: 1.2, eps: 0.01 });
285285
this.#preventDragHijacking();
286-
requestAnimationInInjectionContext(() => {
286+
requestAnimationFrameInInjectionContext(() => {
287287
this.#scalePointer();
288288
injectBeforeRender(this.#onBeforeRender.bind(this));
289289
});

libs/soba/staging/src/caustics/caustisc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NgIf } from '@angular/common';
22
import { Component, computed, CUSTOM_ELEMENTS_SCHEMA, effect, ElementRef, inject, Input } from '@angular/core';
3-
import { extend, injectNgtRef, NgtSignalStore, NgtStore, requestAnimationInInjectionContext } from 'angular-three';
3+
import { extend, injectNgtRef, NgtSignalStore, NgtStore, requestAnimationFrameInInjectionContext } from 'angular-three';
44
import { NgtsEdges } from 'angular-three-soba/abstractions';
55
import { injectNgtsFBO } from 'angular-three-soba/misc';
66
import { CausticsMaterial, CausticsProjectionMaterial } from 'angular-three-soba/shaders';
@@ -225,7 +225,7 @@ export class NgtsCaustics extends NgtSignalStore<NgtsCausticsState> {
225225
resolution: 2024,
226226
lightSource: [5, 5, 5],
227227
});
228-
requestAnimationInInjectionContext(() => {
228+
requestAnimationFrameInInjectionContext(() => {
229229
this.#updateWorldMatrix();
230230
this.#setBeforeRender();
231231
});

libs/soba/staging/src/environment/environment-cube.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Directive, Input, computed, effect, inject } from '@angular/core';
2-
import { NgtStore, requestAnimationInInjectionContext } from 'angular-three';
2+
import { NgtStore, requestAnimationFrameInInjectionContext } from 'angular-three';
33
import { NgtsEnvironmentInput } from './environment-input';
44
import { injectNgtsEnvironment, setEnvProps } from './utils';
55

@@ -18,7 +18,7 @@ export class NgtsEnvironmentCube {
1818

1919
constructor() {
2020
this.environmentInput.patch({ background: false });
21-
requestAnimationInInjectionContext(() => {
21+
requestAnimationFrameInInjectionContext(() => {
2222
this.#setEnvProps();
2323
});
2424
}

libs/soba/staging/src/environment/environment-map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Directive, Input, computed, effect, inject } from '@angular/core';
2-
import { NgtStore, requestAnimationInInjectionContext } from 'angular-three';
2+
import { NgtStore, requestAnimationFrameInInjectionContext } from 'angular-three';
33
import { NgtsEnvironmentInput } from './environment-input';
44
import { setEnvProps } from './utils';
55

@@ -21,7 +21,7 @@ export class NgtsEnvironmentMap {
2121

2222
constructor() {
2323
this.environmentInput.patch({ background: false });
24-
requestAnimationInInjectionContext(() => {
24+
requestAnimationFrameInInjectionContext(() => {
2525
this.#setEnvProps();
2626
});
2727
}

libs/soba/staging/src/environment/environment-portal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
NgtRenderState,
1111
NgtStore,
1212
prepare,
13-
requestAnimationInInjectionContext,
13+
requestAnimationFrameInInjectionContext,
1414
} from 'angular-three';
1515
import * as THREE from 'three';
1616
import { CubeCamera } from 'three';
@@ -77,7 +77,7 @@ export class NgtsEnvironmentPortal {
7777
background: false,
7878
preset: undefined,
7979
});
80-
requestAnimationInInjectionContext(() => {
80+
requestAnimationFrameInInjectionContext(() => {
8181
this.#setEnvProps();
8282
});
8383
injectBeforeRender(this.#onBeforeRender.bind(this, 1));

libs/soba/staging/src/spot-light/spot-light-shadow-mesh.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
extend,
1616
injectBeforeRender,
1717
injectNgtRef,
18-
requestAnimationInInjectionContext,
18+
requestAnimationFrameInInjectionContext,
1919
} from 'angular-three';
2020
import * as THREE from 'three';
2121
import { Mesh, MeshBasicMaterial, PlaneGeometry } from 'three';
@@ -40,7 +40,7 @@ function injectShadowMeshCommon(
4040
const pos = new THREE.Vector3();
4141
const dir = new THREE.Vector3();
4242

43-
requestAnimationInInjectionContext(() => {
43+
requestAnimationFrameInInjectionContext(() => {
4444
effect(() => {
4545
const spotLight = spotLightRef.nativeElement;
4646
if (!spotLight) return;
@@ -111,7 +111,7 @@ export class NgtsSpotLightShadowMeshNoShader {
111111
constructor() {
112112
this.shadowMeshInput.patch({ distance: 0.4, alphaTest: 0.5, width: 512, height: 512, scale: 1 });
113113

114-
requestAnimationInInjectionContext(() => {
114+
requestAnimationFrameInInjectionContext(() => {
115115
effect(() => {
116116
const map = this.shadowMeshInput.shadowMeshMap();
117117
if (map) {
@@ -218,7 +218,7 @@ export class NgtsSpotLightShadowMeshShader {
218218
}
219219
});
220220

221-
requestAnimationInInjectionContext(() => {
221+
requestAnimationFrameInInjectionContext(() => {
222222
effect(() => {
223223
const map = this.shadowMeshInput.shadowMeshMap();
224224
if (map) {

0 commit comments

Comments
 (0)