Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Showing 8 changed files with 166 additions and 16 deletions.
22 changes: 20 additions & 2 deletions libs/core/attributes/src/lib/color-attribute/color-attribute.ts
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ import {
SkipSelf,
} from '@angular/core';
import * as THREE from 'three';
import type { Subscription } from 'rxjs';

@Component({
selector: 'ngt-color[color]',
@@ -29,11 +30,28 @@ import * as THREE from 'three';
export class NgtColorAttribute extends NgtInstance<THREE.Color> {
@Input() set color(color: NgtColor) {
this.zone.runOutsideAngular(() => {
const instance = this.prepareInstance(makeColor(color));
this.set({ instance });
if (this.initSubscription) {
this.initSubscription.unsubscribe();
}

this.initSubscription = this.onCanvasReady(
this.store.ready$,
() => {
this.set({
instance: this.prepareInstance(makeColor(color)),
});

return () => {
this.initSubscription?.unsubscribe();
};
},
true
);
});
}

private initSubscription?: Subscription;

constructor(
zone: NgZone,
store: NgtStore,
22 changes: 20 additions & 2 deletions libs/core/attributes/src/lib/fog-attribute/fog-attribute.ts
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ import {
SkipSelf,
} from '@angular/core';
import * as THREE from 'three';
import type { Subscription } from 'rxjs';

@Component({
selector: 'ngt-fog[fog]',
@@ -29,11 +30,28 @@ import * as THREE from 'three';
export class NgtFogAttribute extends NgtInstance<THREE.Fog> {
@Input() set fog(fog: NgtFog) {
this.zone.runOutsideAngular(() => {
const instance = this.prepareInstance(make(THREE.Fog, fog));
this.set({ instance });
if (this.initSubscription) {
this.initSubscription.unsubscribe();
}

this.initSubscription = this.onCanvasReady(
this.store.ready$,
() => {
this.set({
instance: this.prepareInstance(make(THREE.Fog, fog)),
});

return () => {
this.initSubscription?.unsubscribe();
};
},
true
);
});
}

private initSubscription?: Subscription;

constructor(
zone: NgZone,
store: NgtStore,
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ import {
SkipSelf,
} from '@angular/core';
import * as THREE from 'three';
import type { Subscription } from 'rxjs';

@Component({
selector: 'ngt-fog-exp2[fogExp2]',
@@ -29,11 +30,30 @@ import * as THREE from 'three';
export class NgtFogExp2Attribute extends NgtInstance<THREE.FogExp2> {
@Input() set fogExp2(fogExp2: NgtFogExp2) {
this.zone.runOutsideAngular(() => {
const instance = this.prepareInstance(make(THREE.FogExp2, fogExp2));
this.set({ instance });
if (this.initSubscription) {
this.initSubscription.unsubscribe();
}

this.initSubscription = this.onCanvasReady(
this.store.ready$,
() => {
this.set({
instance: this.prepareInstance(
make(THREE.FogExp2, fogExp2)
),
});

return () => {
this.initSubscription?.unsubscribe();
};
},
true
);
});
}

private initSubscription?: Subscription;

constructor(
zone: NgZone,
store: NgtStore,
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ import {
SkipSelf,
} from '@angular/core';
import * as THREE from 'three';
import type { Subscription } from 'rxjs';

@Component({
selector: 'ngt-matrix3[matrix3]',
@@ -29,11 +30,30 @@ import * as THREE from 'three';
export class NgtMatrix3Attribute extends NgtInstance<THREE.Matrix3> {
@Input() set matrix3(matrix3: NgtMatrix3) {
this.zone.runOutsideAngular(() => {
const instance = this.prepareInstance(make(THREE.Matrix3, matrix3));
this.set({ instance });
if (this.initSubscription) {
this.initSubscription.unsubscribe();
}

this.initSubscription = this.onCanvasReady(
this.store.ready$,
() => {
this.set({
instance: this.prepareInstance(
make(THREE.Matrix3, matrix3)
),
});

return () => {
this.initSubscription?.unsubscribe();
};
},
true
);
});
}

private initSubscription?: Subscription;

constructor(
zone: NgZone,
store: NgtStore,
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ import {
SkipSelf,
} from '@angular/core';
import * as THREE from 'three';
import type { Subscription } from 'rxjs';

@Component({
selector: 'ngt-matrix4[matrix4]',
@@ -29,11 +30,30 @@ import * as THREE from 'three';
export class NgtMatrix4Attribute extends NgtInstance<THREE.Matrix4> {
@Input() set matrix4(matrix4: NgtMatrix4) {
this.zone.runOutsideAngular(() => {
const instance = this.prepareInstance(make(THREE.Matrix4, matrix4));
this.set({ instance });
if (this.initSubscription) {
this.initSubscription.unsubscribe();
}

this.initSubscription = this.onCanvasReady(
this.store.ready$,
() => {
this.set({
instance: this.prepareInstance(
make(THREE.Matrix4, matrix4)
),
});

return () => {
this.initSubscription?.unsubscribe();
};
},
true
);
});
}

private initSubscription?: Subscription;

constructor(
zone: NgZone,
store: NgtStore,
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ import {
SkipSelf,
} from '@angular/core';
import * as THREE from 'three';
import type { Subscription } from 'rxjs';

@Component({
selector: 'ngt-vector2[vector2]',
@@ -29,11 +30,28 @@ import * as THREE from 'three';
export class NgtVector2Attribute extends NgtInstance<THREE.Vector2> {
@Input() set vector2(vector2: NgtVector2) {
this.zone.runOutsideAngular(() => {
const instance = this.prepareInstance(makeVector2(vector2));
this.set({ instance });
if (this.initSubscription) {
this.initSubscription.unsubscribe();
}

this.initSubscription = this.onCanvasReady(
this.store.ready$,
() => {
this.set({
instance: this.prepareInstance(makeVector2(vector2)),
});

return () => {
this.initSubscription?.unsubscribe();
};
},
true
);
});
}

private initSubscription?: Subscription;

constructor(
zone: NgZone,
store: NgtStore,
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ import {
SkipSelf,
} from '@angular/core';
import * as THREE from 'three';
import type { Subscription } from 'rxjs';

@Component({
selector: 'ngt-vector3[vector3]',
@@ -29,11 +30,28 @@ import * as THREE from 'three';
export class NgtVector3Attribute extends NgtInstance<THREE.Vector3> {
@Input() set vector3(vector3: NgtVector3) {
this.zone.runOutsideAngular(() => {
const instance = this.prepareInstance(makeVector3(vector3));
this.set({ instance });
if (this.initSubscription) {
this.initSubscription.unsubscribe();
}

this.initSubscription = this.onCanvasReady(
this.store.ready$,
() => {
this.set({
instance: this.prepareInstance(makeVector3(vector3)),
});

return () => {
this.initSubscription?.unsubscribe();
};
},
true
);
});
}

private initSubscription?: Subscription;

constructor(
zone: NgZone,
store: NgtStore,
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ import {
SkipSelf,
} from '@angular/core';
import * as THREE from 'three';
import type { Subscription } from 'rxjs';

@Component({
selector: 'ngt-vector4[vector4]',
@@ -29,11 +30,28 @@ import * as THREE from 'three';
export class NgtVector4Attribute extends NgtInstance<THREE.Vector4> {
@Input() set vector4(vector4: NgtVector4) {
this.zone.runOutsideAngular(() => {
const instance = this.prepareInstance(makeVector4(vector4));
this.set({ instance });
if (this.initSubscription) {
this.initSubscription.unsubscribe();
}

this.initSubscription = this.onCanvasReady(
this.store.ready$,
() => {
this.set({
instance: this.prepareInstance(makeVector4(vector4)),
});

return () => {
this.initSubscription?.unsubscribe();
};
},
true
);
});
}

private initSubscription?: Subscription;

constructor(
zone: NgZone,
store: NgtStore,

0 comments on commit 6b0be6d

Please sign in to comment.