Skip to content

Commit 71d6822

Browse files
authored
Merge pull request #60 from demike/perf/use-on-push
perf: use on push
2 parents 5f30f08 + db1f551 commit 71d6822

File tree

14 files changed

+49
-19
lines changed

14 files changed

+49
-19
lines changed

projects/ngx-three-demo/src/app/app.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { Component } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component } from '@angular/core';
22

33
@Component({
44
selector: 'app-root',
55
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.scss']
6+
styleUrls: ['./app.component.scss'],
7+
changeDetection: ChangeDetectionStrategy.OnPush,
78
})
89
export class AppComponent {
910
title = 'ngx-three-demo';

projects/ngx-three-demo/src/app/dynamic-loader-example/dynamic-loader-example.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ASSET_PATH } from '../assets';
55
@Component({
66
selector: 'app-dynamic-loader-example',
77
templateUrl: './dynamic-loader-example.component.html',
8-
changeDetection: ChangeDetectionStrategy.Default,
8+
changeDetection: ChangeDetectionStrategy.OnPush,
99
})
1010
export class DynamicLoaderExampleComponent implements OnDestroy {
1111
public modelUrl: string;

projects/ngx-three-demo/src/app/example-page/example-page.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { Component, Type } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, Type } from '@angular/core';
22
import { ActivatedRoute } from '@angular/router';
33
import { EditorService } from '../code/EditorService';
44

55
@Component({
66
selector: 'app-example-page',
77
templateUrl: './example-page.component.html',
88
styleUrls: ['./example-page.component.scss'],
9+
changeDetection: ChangeDetectionStrategy.OnPush,
910
})
1011
export class ExamplePageComponent {
1112
public exampleComponent: Type<any> | null = null;

projects/ngx-three-demo/src/app/outline-pass-events-example/outline-pass-events-example.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
22
import { RaycasterEmitEvent, ThMesh, ThObject3D, ThOutlinePass } from 'ngx-three';
33
import { Color, MeshPhongMaterial, Vector2 } from 'three';
44
import GUI from 'lil-gui';
55

66
@Component({
77
selector: 'app-outline-pass-events-example',
88
templateUrl: './outline-pass-events-example.component.html',
9-
styleUrls: ['./outline-pass-events-example.component.scss']
9+
styleUrls: ['./outline-pass-events-example.component.scss'],
10+
changeDetection: ChangeDetectionStrategy.OnPush,
1011
})
1112
export class OutlinePassEventsExampleComponent implements OnInit {
1213
protected outlinePassResolution = new Vector2(window.innerWidth, window.innerHeight);
@@ -53,7 +54,7 @@ export class OutlinePassEventsExampleComponent implements OnInit {
5354
x: Math.random() * 4 - 2,
5455
y: Math.random() * 4 - 2,
5556
z: Math.random() * 4 - 2,
56-
scale: Math.random() * 0.3 + 0.1
57+
scale: Math.random() * 0.3 + 0.1,
5758
});
5859
}
5960
}

projects/ngx-three-demo/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ if (environment.production) {
99
}
1010

1111
platformBrowserDynamic()
12-
.bootstrapModule(AppModule)
12+
.bootstrapModule(AppModule, { ngZoneEventCoalescing: true, ngZoneRunCoalescing: true /*, ngZone: 'noop' */ })
1313
.catch((err) => console.error(err));

projects/ngx-three/src/lib/ThControlBase.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, inject, OnDestroy } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, inject, OnDestroy } from '@angular/core';
22
import { Subscription } from 'rxjs';
33
import { EventDispatcher } from 'three';
44
import { ThObject3D } from './generated/ThObject3D';
@@ -8,6 +8,7 @@ import { ThWrapperBase } from './ThWrapperBase';
88
@Component({
99
selector: 'th-abs-control',
1010
template: '',
11+
changeDetection: ChangeDetectionStrategy.OnPush,
1112
})
1213
// eslint-disable-next-line @angular-eslint/component-class-suffix
1314
export class ThControlBase<T, ARGS> extends ThWrapperBase<T, ARGS> implements OnDestroy {

projects/ngx-three/src/lib/ThGeometryBase.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Component } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { BufferGeometry, NormalOrGLBufferAttributes } from 'three';
33
import { ThObject3D } from './generated/ThObject3D';
44
import { ThWrapperBase } from './ThWrapperBase';
55
@Component({
66
selector: 'th-abs-geometry',
7-
template: ''
7+
template: '',
8+
changeDetection: ChangeDetectionStrategy.OnPush,
89
})
910
// eslint-disable-next-line @angular-eslint/component-class-suffix
1011
export class ThGeometryBase<T extends BufferGeometry<NormalOrGLBufferAttributes>, ARGS> extends ThWrapperBase<T, ARGS> {

projects/ngx-three/src/lib/ThMaterialBase.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Component } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { Material, Mesh } from 'three';
33
import { ThObject3D } from './generated/ThObject3D';
44
import { ThWrapperBase } from './ThWrapperBase';
55
@Component({
66
selector: 'th-abs-material',
7-
template: ''
7+
template: '',
8+
changeDetection: ChangeDetectionStrategy.OnPush,
89
})
910
// eslint-disable-next-line @angular-eslint/component-class-suffix
1011
export class ThMaterialBase<T extends Material, ARGS> extends ThWrapperBase<T, ARGS> {

projects/ngx-three/src/lib/ThObjectBase.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { Component, Input, OnInit } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
22
import { Object3D, Vector3 } from 'three';
33
import { ThWrapperBase } from './ThWrapperBase';
44
@Component({
55
selector: 'th-abs-object',
6-
template: '<ng-content/>'
6+
template: '<ng-content/>',
7+
changeDetection: ChangeDetectionStrategy.OnPush,
78
})
89
// eslint-disable-next-line @angular-eslint/component-class-suffix
910
export class ThObjectBase<T extends Object3D, ARGS = unknown> extends ThWrapperBase<T, ARGS> implements OnInit {

projects/ngx-three/src/lib/ThPassBase.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Component, OnInit, Optional } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, OnInit, Optional } from '@angular/core';
22
import { ThEffectComposer } from './generated/overrides/ThEffectComposer';
33
import { Pass } from 'three/examples/jsm/postprocessing/Pass.js';
44
import { ThWrapperBase } from './ThWrapperBase';
55
@Component({
66
selector: 'th-abs-control',
77
template: '',
8+
changeDetection: ChangeDetectionStrategy.OnPush,
89
})
910
// eslint-disable-next-line @angular-eslint/component-class-suffix
1011
export class ThPassBase<T extends Pass = Pass, ARGS = unknown> extends ThWrapperBase<T, ARGS> implements OnInit {

0 commit comments

Comments
 (0)