Skip to content

Commit af45513

Browse files
Chau TranChau Tran
authored andcommitted
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
});

0 commit comments

Comments
 (0)