-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(types): remove references to Shader type (#1765)
- Loading branch information
1 parent
cc8ea56
commit a82d0d4
Showing
3 changed files
with
17 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as React from 'react' | ||
import { MeshPhysicalMaterial, MeshPhysicalMaterialParameters, Shader } from 'three' | ||
import { IUniform, MeshPhysicalMaterial, MeshPhysicalMaterialParameters } from 'three' | ||
import { useFrame } from '@react-three/fiber' | ||
// eslint-disable-next-line | ||
// @ts-ignore | ||
|
@@ -42,7 +42,8 @@ class DistortMaterialImpl extends MeshPhysicalMaterial { | |
this._radius = { value: 1 } | ||
} | ||
|
||
onBeforeCompile(shader: Shader) { | ||
// FIXME Use `THREE.WebGLProgramParametersWithUniforms` type when able to target @types/[email protected] | ||
onBeforeCompile(shader: { vertexShader: string; uniforms: { [uniform: string]: IUniform } }) { | ||
shader.uniforms.time = this._time | ||
shader.uniforms.radius = this._radius | ||
shader.uniforms.distort = this._distort | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as React from 'react' | ||
import { MeshStandardMaterial, MeshStandardMaterialParameters, Shader } from 'three' | ||
import { IUniform, MeshStandardMaterial, MeshStandardMaterialParameters } from 'three' | ||
import { useFrame } from '@react-three/fiber' | ||
import { ForwardRefComponent } from '../helpers/ts-utils' | ||
|
||
|
@@ -37,7 +37,8 @@ class WobbleMaterialImpl extends MeshStandardMaterial { | |
this._factor = { value: 1 } | ||
} | ||
|
||
onBeforeCompile(shader: Shader) { | ||
// FIXME Use `THREE.WebGLProgramParametersWithUniforms` type when able to target @types/[email protected] | ||
onBeforeCompile(shader: { vertexShader: string; uniforms: { [uniform: string]: IUniform } }) { | ||
shader.uniforms.time = this._time | ||
shader.uniforms.factor = this._factor | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,9 +49,17 @@ const getIBLRadiance_patch = /* glsl */ ` | |
#endif | ||
` | ||
|
||
function boxProjectedEnvMap(shader: THREE.Shader, envMapPosition: THREE.Vector3, envMapSize: THREE.Vector3) { | ||
// FIXME Replace with `THREE.WebGLProgramParametersWithUniforms` type when able to target @types/[email protected] | ||
interface MaterialShader { | ||
vertexShader: string | ||
fragmentShader: string | ||
defines: { [define: string]: string | number | boolean } | undefined | ||
uniforms: { [uniform: string]: THREE.IUniform } | ||
} | ||
|
||
function boxProjectedEnvMap(shader: MaterialShader, envMapPosition: THREE.Vector3, envMapSize: THREE.Vector3) { | ||
// defines | ||
;(shader as any).defines.BOX_PROJECTED_ENV_MAP = true | ||
shader.defines!.BOX_PROJECTED_ENV_MAP = true | ||
// uniforms | ||
shader.uniforms.envMapPosition = { value: envMapPosition } | ||
shader.uniforms.envMapSize = { value: envMapSize } | ||
|
@@ -89,7 +97,7 @@ export function useBoxProjectedEnv( | |
const spread = React.useMemo( | ||
() => ({ | ||
ref, | ||
onBeforeCompile: (shader: THREE.Shader) => boxProjectedEnvMap(shader, config.position, config.size), | ||
onBeforeCompile: (shader: MaterialShader) => boxProjectedEnvMap(shader, config.position, config.size), | ||
customProgramCacheKey: () => JSON.stringify(config.position.toArray()) + JSON.stringify(config.size.toArray()), | ||
}), | ||
[...config.position.toArray(), ...config.size.toArray()] | ||
|
a82d0d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
drei – ./
drei.vercel.app
drei-git-master-pmndrs.vercel.app
drei-pmndrs.vercel.app
drei.react-spring.io
drei.pmnd.rs