Skip to content

Commit

Permalink
fix: rename mesh distort shader provider
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Feb 11, 2023
1 parent 637ce8a commit 1ce9125
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@ interface Uniform<T> {
value: T;
}

/**
* npm i -D raw-loader glslify-loader
* Usage: import distort from 'raw-loader!glslify-loader!angular-three-soba/assets/distort.vert.glsl'
*
* provideNgtsMeshDistortMaterialShader(distort)
*/

export type MeshDistortMaterial = Type<{ time: number; distort: number; radius: number } & THREE.MeshPhysicalMaterial>;

export const NGTS_DISTORT_MATERIAL_SHADER = new InjectionToken<MeshDistortMaterial>('DistortMaterialShader');

export function provideDistortMaterialShader(distortShader: string) {
export function provideNgtsMeshDistortMaterialShader(distortShader: string) {
return {
provide: NGTS_DISTORT_MATERIAL_SHADER,
useFactory: () => {
return class MeshDistortMaterial extends THREE.MeshPhysicalMaterial {
return class extends THREE.MeshPhysicalMaterial {
_time: Uniform<number>;
_distort: Uniform<number>;
_radius: Uniform<number>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core';
import { Meta, moduleMetadata, StoryFn, StoryObj } from '@storybook/angular';
import { injectBeforeRender, injectNgtRef, NgtArgs } from 'angular-three';
import { NgtsMeshDistortMaterial } from 'angular-three-soba/materials';
import { MeshDistortMaterial, provideDistortMaterialShader } from 'angular-three-soba/shaders';
import { MeshDistortMaterial, provideNgtsMeshDistortMaterialShader } from 'angular-three-soba/shaders';
import { StorybookSetup } from '../setup-canvas';
// @ts-ignore
import distort from '../../shaders/src/assets/distort.vert.glsl';
Expand Down Expand Up @@ -50,7 +50,7 @@ export default {
decorators: [
moduleMetadata({
imports: [StorybookSetup],
providers: [provideDistortMaterialShader(distort)],
providers: [provideNgtsMeshDistortMaterialShader(distort)],
}),
],
} as Meta;
Expand Down

0 comments on commit 1ce9125

Please sign in to comment.