Skip to content

Commit ff616c9

Browse files
committed
use more stuffs from vanilla; mesh distort
1 parent ab3b421 commit ff616c9

File tree

15 files changed

+135
-557
lines changed

15 files changed

+135
-557
lines changed

libs/soba/materials/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './lib/custom-shader-material';
2+
export * from './lib/mesh-distort-material';
23
export * from './lib/mesh-reflector-material';
34
export * from './lib/mesh-refraction-material';
45
export * from './lib/mesh-transmission-material';
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA, input } from '@angular/core';
2+
import { MeshDistortMaterial } from '@pmndrs/vanilla';
3+
import { injectBeforeRender, NgtArgs, NgtMeshPhysicalMaterial, omit, pick } from 'angular-three';
4+
import { MeshDistortMaterialParameters } from 'angular-three-soba/vanilla-exports';
5+
import { mergeInputs } from 'ngxtension/inject-inputs';
6+
7+
export interface NgtsMeshDistortMaterialOptions
8+
extends Partial<MeshDistortMaterialParameters>,
9+
Partial<NgtMeshPhysicalMaterial> {
10+
speed: number;
11+
factor?: number;
12+
}
13+
14+
const defaultOptions: NgtsMeshDistortMaterialOptions = {
15+
speed: 1,
16+
};
17+
18+
@Component({
19+
selector: 'ngts-mesh-distort-material',
20+
standalone: true,
21+
template: `
22+
<ngt-primitive *args="[material]" [attach]="attach()" [parameters]="parameters()">
23+
<ng-content />
24+
</ngt-primitive>
25+
`,
26+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
27+
changeDetection: ChangeDetectionStrategy.OnPush,
28+
imports: [NgtArgs],
29+
})
30+
export class NgtsMeshDistortMaterial {
31+
attach = input('material');
32+
options = input(defaultOptions, { transform: mergeInputs(defaultOptions) });
33+
parameters = omit(this.options, ['speed']);
34+
35+
material = new MeshDistortMaterial();
36+
37+
private speed = pick(this.options, 'speed');
38+
39+
constructor() {
40+
injectBeforeRender(({ clock }) => {
41+
this.material.time = clock.getElapsedTime() * this.speed();
42+
});
43+
}
44+
}

libs/soba/materials/src/lib/mesh-reflector-material.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
untracked,
1212
viewChild,
1313
} from '@angular/core';
14-
import { BlurPass, MeshReflectorMaterial } from '@pmndrs/vanilla';
1514
import {
1615
applyProps,
1716
getLocalState,
@@ -23,6 +22,7 @@ import {
2322
omit,
2423
pick,
2524
} from 'angular-three';
25+
import { BlurPass, MeshReflectorMaterial } from 'angular-three-soba/vanilla-exports';
2626
import { injectAutoEffect } from 'ngxtension/auto-effect';
2727
import { mergeInputs } from 'ngxtension/inject-inputs';
2828
import {

libs/soba/materials/src/lib/mesh-wobble-material.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ChangeDetectionStrategy, Component, computed, CUSTOM_ELEMENTS_SCHEMA, input } from '@angular/core';
22
import { injectBeforeRender, NgtArgs, omit } from 'angular-three';
3-
import { MeshWobbleMaterial, MeshWobbleMaterialOptions } from 'angular-three-soba/shaders';
3+
import { MeshWobbleMaterial, MeshWobbleMaterialParameters } from 'angular-three-soba/vanilla-exports';
44
import { mergeInputs } from 'ngxtension/inject-inputs';
55

6-
export interface NgtsMeshWobbleMaterialOptions extends MeshWobbleMaterialOptions {
6+
export interface NgtsMeshWobbleMaterialOptions extends MeshWobbleMaterialParameters {
77
speed: number;
88
}
99

libs/soba/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@angular/common": "^18.0.0",
3030
"@angular/core": "^18.0.0",
3131
"@monogrid/gainmap-js": "^3.0.0",
32-
"@pmndrs/vanilla": "^1.16.0",
32+
"@pmndrs/vanilla": "^1.19.0",
3333
"camera-controls": "^2.8.0",
3434
"hls.js": "^1.5.0",
3535
"meshline": "^3.1.0",

libs/soba/shaders/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
export * from './lib/caustics';
21
export * from './lib/grid-material';
32
export * from './lib/mesh-refraction-material';
4-
export * from './lib/mesh-wobble-material';

0 commit comments

Comments
 (0)