🍰 An extensible, layer based shader material for ThreeJS

Overview

lamina

🍰 An extensible, layer based shader material for ThreeJS


Chat on Twitter Chat on Twitter


These demos are real, you can click them! They contain the full code, too. 📦 More examples here


lamina lets you create materials with a declarative, system of layers. Layers make it incredibly easy to stack and blend effects. This approach was first made popular by the Spline team.

import { LayerMaterial, Depth } from 'lamina'

function GradientSphere() {
  return (
    <Sphere>
      <LayerMaterial
        color="#ffffff" //
        lighting="physical"
        transmission={1}
      >
        <Depth
          colorA="#810000" //
          colorB="#ffd0d0"
          alpha={0.5}
          mode="multiply"
          near={0}
          far={2}
          origin={[1, 1, 1]}
        />
      </LayerMaterial>
    </Sphere>
  )
}
Show Vanilla example

Lamina can be used with vanilla Three.js. Each layer is just a class.

import { LayerMaterial, Depth } from 'lamina/vanilla'

const geometry = new THREE.SphereGeometry(1, 128, 64)
const material = new LayerMaterial({
  color: '#d9d9d9',
  lighting: 'physical',
  transmission: 1,
  layers: [
    new Depth({
      colorA: '#002f4b',
      colorB: '#f2fdff',
      alpha: 0.5,
      mode: 'multiply',
      near: 0,
      far: 2,
      origin: new THREE.Vector3(1, 1, 1),
    }),
  ],
})

const mesh = new THREE.Mesh(geometry, material)

Note: To match the colors of the react example, you must convert all colors to Linear encoding like so:

new Depth({
  colorA: new THREE.Color('#002f4b').convertSRGBToLinear(),
  colorB: new THREE.Color('#f2fdff').convertSRGBToLinear(),
  alpha: 0.5,
  mode: 'multiply',
  near: 0,
  far: 2,
  origin: new THREE.Vector3(1, 1, 1),
}),

Layers

LayerMaterial

LayerMaterial can take in the following parameters:

Prop Type Default
name string "LayerMaterial"
color THREE.ColorRepresentation | THREE.Color "white"
alpha number 1
lighting 'phong' | 'physical' | 'toon' | 'basic' | 'lambert' | 'standard' 'basic'
layers* Abstract[] []

The lighting prop controls the shading that is applied on the material. The material then accepts all the material properties supported by ThreeJS of the material type specified by the lighting prop.

* Note: the layers prop is only available on the LayerMaterial class, not the component. Pass in layers as children in React.

Built-in layers

Here are the layers that lamina currently provides

Name Function
Fragment Layers
Color Flat color.
Depth Depth based gradient.
Fresnel Fresnel shading (strip or rim-lights).
Gradient Linear gradient.
Matcap Load in a Matcap.
Noise White, perlin or simplex noise .
Normal Visualize vertex normals.
Texture Image texture.
Vertex Layers
Displace Displace vertices using. noise

See the section for each layer for the options on it.

Debugger

Lamina comes with a handy debugger that lets you tweek parameters till you're satisfied with the result! Then, just copy the JSX and paste!

Replace LayerMaterial with DebugLayerMaterial to enable it.

<DebugLayerMaterial color="#ffffff">
  <Depth
    colorA="#810000" //
    colorB="#ffd0d0"
    alpha={0.5}
    mode="multiply"
    near={0}
    far={2}
    origin={[1, 1, 1]}
  />
</DebugLayerMaterial>

Any custom layers are automatically compatible with the debugger. However, for advanced inputs, see the Advanced Usage section.

Writing your own layers

You can write your own layers by extending the Abstract class. The concept is simple:

Each layer can be treated as an isolated shader program that produces a vec4 color.

The color of each layer will be blended together using the specified blend mode. A list of all available blend modes can be found here

import { Abstract } from 'lamina/vanilla'

// Extend the Abstract layer
class CustomLayer extends Abstract {
  // Define stuff as static properties!

  // Uniforms: Must begin with prefix "u_".
  // Assign them their default value.
  // Any unifroms here will automatically be set as properties on the class as setters and getters.
  // There setters and getters will update the underlying unifrom.
  static u_color = 'red' // Can be accessed as CustomLayer.color
  static u_alpha = 1 // Can be accessed as CustomLayer.alpha

  // Define your fragment shader just like you already do!
  // Only difference is, you must return the final color of this layer
  static fragmentShader = `   
    uniform vec3 u_color;
    uniform float u_alpha;

    // Varyings must be prefixed by "v_"
    varying vec3 v_Position;

    vec4 main() {
      // Local variables must be prefixed by "f_"
      vec4 f_color = vec4(u_color, u_alpha);
      return f_color;
    }
  `

  // Optionally Define a vertex shader!
  // Same rules as fragment shaders, except no blend modes.
  // Return a non-projected vec3 position.
  static vertexShader = `   
    // Varyings must be prefixed by "v_"
    varying vec3 v_Position;

    void main() {
      v_Position = position;
      return position * 2.;
    }
  `

  constructor(props) {
    // You MUST call `super` with the current constructor as the first argument.
    // Second argument is optional and provides non-uniform parameters like blend mode, name and visibility.
    super(CustomLayer, {
      name: 'CustomLayer',
      ...props,
    })
  }
}

👉 Note: The vertex shader must return a vec3. You do not need to set gl_Position or transform the model view. lamina will handle this automatically down the chain.

👉 Note: You can use lamina's noise functions inside of your own layer without any additional imports: lamina_noise_perlin(), lamina_noise_simplex(), lamina_noise_worley(), lamina_noise_white(), lamina_noise_swirl().

If you need a specialized or advance use-case, see the Advanced Usage section

Using your own layers

Custom layers are Vanilla compatible by default.

To use them with React-three-fiber, you must use the extend function to add the layer to your component library!

import { extend } from "@react-three/fiber"

extend({ CustomLayer })

// ...
const ref = useRef();

// Animate uniforms using a ref.
useFrame(({ clock }) => {
  ref.current.color.setRGB(
    Math.sin(clock.elapsedTime),
    Math.cos(clock.elapsedTime),
    Math.sin(clock.elapsedTime),
  )
})

<LayerMaterial>
  <customLayer
    ref={ref}     // Imperative instance of CustomLayer. Can be used to animate unifroms
    color="green" // Uniforms can be set directly
    alpha={0.5}
  />
</LayerMaterial>

Advanced Usage

For more advanced custom layers, lamina provides the onParse event.

This event runs after the layer's shader and uniforms are parsed.

This means you can use it to inject functionality that isn't by the basic layer extension syntax.

Here is a common use case - Adding non-uniform options to layers that directly sub out shader code.

class CustomLayer extends Abstract {
  static u_color = 'red'
  static u_alpha = 1

  static vertexShader = `...`
  static fragmentShader = `
    // ...
    float f_dist = lamina_mapping_template; // Temp value, will be used to inject code later on.
    // ...
  `

  // Get some shader code based off mapping parameter
  static getMapping(mapping) {
    switch (mapping) {
      default:
      case 'uv':
        return `some_shader_code`

      case 'world':
        return `some_other_shader_code`
    }
  }

  // Set non-uniform defaults.
  mapping: 'uv' | 'world' = 'uv'

  // Non unifrom params must be passed to the constructor
  constructor(props) {
    super(
      CustomLayer,
      {
        name: 'CustomLayer',
        ...props,
      },
      // This is onParse callback
      (self: CustomLayer) => {
        // Add to Leva (debugger) schema.
        // This will create a dropdown select component on the debugger.
        self.schema.push({
          value: self.mapping,
          label: 'mapping',
          options: ['uv', 'world'],
        })

        // Get shader chunk based off selected mapping value
        const mapping = CustomLayer.getMapping(self.mapping)

        // Inject shader chunk in current layer's shader code
        self.fragmentShader = self.fragmentShader.replace('lamina_mapping_template', mapping)
      }
    )
  }
}

In react...

// ...
<LayerMaterial>
  <customLayer
    ref={ref}
    color="green"
    alpha={0.5}
    args={[mapping]} // Non unifrom params must be passed to the constructor using `args`
  />
</LayerMaterial>

Layers

Every layer has these props in common.

Prop Type Default
mode BlendMode "normal"
name string <this.constructor.name>
visible boolean true

All props are optional.

Color

Flat color.

Prop Type Default
color THREE.ColorRepresentation | THREE.Color "red"
alpha number 1

Normal

Visualize vertex normals

Prop Type Default
direction THREE.Vector3 | [number,number,number] [0, 0, 0]
alpha number 1

Depth

Depth based gradient. Colors are lerp-ed based on mapping props which may have the following values:

  • vector: distance from origin to fragment's world position.
  • camera: distance from camera to fragment's world position.
  • world: distance from fragment to center (0, 0, 0).
Prop Type Default
colorA THREE.ColorRepresentation | THREE.Color "white"
colorB THREE.ColorRepresentation | THREE.Color "black"
alpha number 1
near number 2
far number 10
origin THREE.Vector3 | [number,number,number] [0, 0, 0]
mapping "vector" | "camera" | "world" "vector"

Fresnel

Fresnel shading.

Prop Type Default
color THREE.ColorRepresentation | THREE.Color "white"
alpha number 1
power number 0
intensity number 1
bias number 2

Gradient

Linear gradient based off distance from start to end in a specified axes. start and end are points on the axes selected. The distance between start and end is used to lerp the colors.

Prop Type Default
colorA THREE.ColorRepresentation | THREE.Color "white"
colorB THREE.ColorRepresentation | THREE.Color "black"
alpha number 1
contrast number 1
start number 1
end number -1
axes "x" | "y" | "z" "x"
mapping "local" | "world" | "uv" "local"

Noise

Various noise functions.

Prop Type Default
colorA THREE.ColorRepresentation | THREE.Color "white"
colorB THREE.ColorRepresentation | THREE.Color "black"
colorC THREE.ColorRepresentation | THREE.Color "white"
colorD THREE.ColorRepresentation | THREE.Color "black"
alpha number 1
scale number 1
offset THREE.Vector3 | [number, number, number] [0, 0, 0]
mapping "local" | "world" | "uv" "local"
type "perlin' | "simplex" | "cell" | "curl" "perlin"

Matcap

Set a Matcap texture.

Prop Type Default
map THREE.Texture undefined
alpha number 1

Texture

Set a texture.

Prop Type Default
map THREE.Texture undefined
alpha number 1

BlendMode

Blend modes currently available in lamina

normal divide
add overlay
subtract screen
multiply softlight
lighten reflect
darken negation

Vertex layers

Layers that affect the vertex shader

Displace

Displace vertices with various noise.

Prop Type Default
strength number 1
scale number 1
mapping "local" | "world" | "uv" "local"
type "perlin' | "simplex" | "cell" | "curl" "perlin"
offset THREE.Vector3 | [number,number,number] [0, 0, 0]
Comments
  • Setting Alpha in vanilla material doesn't work.

    Setting Alpha in vanilla material doesn't work.

    export class JourneySphereMaterial extends LayerMaterial {
    	constructor() {
    		super({
    			color: 'white',
    			lighting: 'physical',
    			transparent: true,
    			transmission: 1,
    			// @ts-ignore
    			thickness: 0,
    			alpha: 0.8,
    		});
    //This doesn't work, nor does using opacity.
    		this.alpha= 0.2;
    	}
    }
    
    bug 
    opened by supermoos 9
  • [feat] Add copy vanilla js button

    [feat] Add copy vanilla js button

    Adds a button to the debugger to copy the vanilla js code and some util fns to support the serializing.

    Let me know what you think!

    Examples from the configurator (formatting varies depending on where you paste):

    JSX:

    
        <LayerMaterial color={16711422} name={"Monkey w/ freckles"}>
          <Depth near={-0.06800000000000028} far={5} origin={[0,0,3]} colorA={"#fe96dc"} colorB={"#68eefb"} />
    	<Depth near={1} far={3} origin={[0,0,-1.3670000000000089]} colorA={"#feb600"} colorB={"#000000"} mode={"screen"} />
    	<Fresnel color={"#fefefe"} power={1.9099999999999757} mode={"softlight"} />
    	<Noise colorA={"#84fee9"} colorB={"#969696"} colorC={"#000000"} colorD={"#000000"} scale={50} offset={[0,0,0]} name={"noise"} mode={"lighten"} />
        </LayerMaterial>
        
    

    Vanilla JS:

     new LayerMaterial({
      color: new THREE.Color('#fefefe'),
      name: 'Monkey w/ freckles',
    
      layers: [
        new Depth({
          near: -0.06800000000000028,
          far: 5,
          origin: [0, 0, 3],
          colorA: new THREE.Color('#fe96dc'),
          colorB: new THREE.Color('#68eefb')
        }),
        new Depth({
          near: 1,
          far: 3,
          origin: [0, 0, -1.3670000000000089],
          colorA: new THREE.Color('#feb600'),
          colorB: new THREE.Color('#000000'),
          mode: 'screen'
        }),
        new Fresnel({
          color: new THREE.Color('#fefefe'),
          power: 1.9099999999999757,
          mode: 'softlight'
        }),
        new Noise({
          colorA: new THREE.Color('#84fee9'),
          colorB: new THREE.Color('#969696'),
          colorC: new THREE.Color('#000000'),
          colorD: new THREE.Color('#000000'),
          scale: 50,
          offset: [0, 0, 0],
          name: 'noise',
          mode: 'lighten'
        })
      ]
    });
    
    
    opened by AlexWarnes 4
  • Skinned Meshes stop working with Lamina

    Skinned Meshes stop working with Lamina

    Skinned meshes stop working when using Lamina. I think it might be because the shader is not implementing skinned meshes maybe?

    Example without lamina:

    Screen Shot 2022-04-16 at 19 26 13

    Screen Shot 2022-04-16 at 19 26 05

    When i add Lamina:

    Screen Shot 2022-04-16 at 19 26 27

    Screen Shot 2022-04-16 at 19 26 35

    bug 
    opened by alejandromizraji 4
  • Possible to update vertex positions?

    Possible to update vertex positions?

    first off wanted to say lamina is awesome, have really enjoyed playing around with it so far!

    I was interested in making some custom layers that modified vertex positions eg:

    1. fullscreen layer (gl_Position = vec4(position * 2.0, 1.0) ...)
    2. height-map displacement layer (gl_Position.z += texture2d(map, uv).r)

    Is this kinda thing out of scope for Lamina?

    took a stab at implementing these but ran into issues because the ${body.vert} is included before gl_position is set and currently gl_position is determined entirely by unmodifiable input values. (modelViewMatrix, position, & projectionMatrix).

    opened by nwpointer 4
  • Create reasonable defaults to make things cleaner, best practices, and fault tolerant

    Create reasonable defaults to make things cleaner, best practices, and fault tolerant

    Can you spot the "mistakes?"

    <mesh>
        <sphereGeometry args={[1, 64, 64]} />
        <LayerMaterial>
            <Base color="#603295" />
            <Depth colorA="white" colorB="#0F1C4D" alpha={0.5} mode="normal" near={0} far={2} origin={[1, 1, 1]} />
            <Depth colorA="red"  alpha={0.5} mode="add" near={3} far={2} origin={[-1, 1, 1]} />
            <Fresnel mode="add" color="orange" intensity={0.5} power={2} bias={0.05} />
            <Noise scale={2} mapping="world" type="curl"  colorA="white" colorB="0x000000" mode="softlight" />
            <Noise mapping="local" /*type="curl" */ scale={100} colorA="#aaa" colorB="black" type="simplex" mode="softlight" />
            <Noise mapping="local" type="simplex" scale={100} colorA="white" colorB="black" mode="subtract" alpha={0.2} />
        </LayerMaterial>
        </mesh>
        <mesh>
        <circleGeometry args={[2, 16]} />
        <LayerMaterial transparent depthWrite={false} side={THREE.FrontSide} blending={THREE.AdditiveBlending}>
            <Depth colorA="orange" colorB="black" alpha={1} mode="normal" near={-2} far={1.4} origin={[0, 0, 0]} />
            <Noise mapping="local" type="simplex" scale={200} colorA="#fff" colorB="black" mode="multiply" />
        </LayerMaterial>
    </mesh>
    

    Desktop - 1 (1)

    With the complex interweaving it can get incredibly difficult to debug or even correctly configure things on even relatively simple 2 mesh layouts. This totally isn't "bad"

    but people will make bad..

    Now obviously if people go in an and configure things "correctly" they will have complex files as well, however I think some of the things can have baselines, where the changing or overriding is clear by performing it at all. Consider <noise>

    BTW are we missing Noise props? This page mede it clear to understand, but our inputs are unique

    ---- This is real.. We used this in a multiple demos ----

    <Noise scale={2} mapping="world" type="curl"  colorA="white" colorB="0x000000" mode="softlight" />
    <Noise mapping="local" /*type="curl" */ scale={100} colorA="#aaa" colorB="black" type="simplex" mode="softlight" />
    <Noise mapping="local" type="simplex" scale={100} colorA="white" colorB="black" mode="subtract" alpha={0.2} />
    

    With Baseline configurations

    <Noise  type="curl" mapping="world"   colorA="#ff0000" colorB="0x000000" mode="softlight" />
    <Noise colorA="#aaa"  scale={2} mode="softlight" />
    <Noise  alpha={0.2} mode="subtract" />
    

    I feel like it's a LOT clearer what I'm fiddling with, and when I change the type Im doing it knowingly..

    Maybe even catch it:

    <LayerMaterial>
      <Noise type="curl" />
      <Noise type="curl" />
      <Noise type="curl" />
      <Noise type="curl" />
    </LayerMaterial>
    /***WARNING** More than 3 Noise Layers can cause significant frame loss: https://levadocs.io/curl */
    opened by DennisSmolek 4
  • LayerMaterial should create it's base by default

    LayerMaterial should create it's base by default

    The base can only be called once and at the origin

    <LayerMaterial>
        <Base color="#603295" >
    </LayerMaterial>
    

    becomes:

    <LayerMaterial color="#603295" >
    ...
    </LayerMaterial>
    

    Similar to how R3f handles camera. Now base only has 3 arguments and only 1 will regularly be set, but if they had a specific requirement or need and really wanted they still could still do:

    <LayerMaterial>
        <Base color={compareAllyColors{userColorVar, safeColorVar)} alpha={() => isDarkMode ? 1 : .5}  blend={/**No idea why base blends?**/} >
    </LayerMaterial>
    

    R3F Canvas & Camera:

    <Canvas camera={{ positon: [0,5,0] }}>
        <Lights >
            <mesh></mesh>
    </Canvas>
    
    <Canvas>
        <perspectiveCamera ref="camRef" position={ [0,5,0 }>
            <Lights >
            <mesh></mesh>
    </Canvas>
    
    opened by DennisSmolek 4
  • fix: children should refresh the parent

    fix: children should refresh the parent

    lamina will re-create the shader on every render because "children" is not a stable reference. children should rather inform lamina on mount, and when certain props have changed that it must refresh. this of course would duplicate refresh multiple times once you're dealing with multiple layers — this draft would try to work against that.

    opened by drcmda 3
  • Module not found: Can't resolve 'react-dom/client'

    Module not found: Can't resolve 'react-dom/client'

    On NextJS

    info  - automatically enabled Fast Refresh for 1 custom loader
    wait  - compiling /_error (client and server)...
    error - ./node_modules/lamina/index.js:12:0
    Module not found: Can't resolve 'react-dom/client
    

    package.json

    "dependencies": {
     ...
        "lamina": "^1.1.9",
        "react": "17.0.2",
        "react-dom": "17.0.2",
    ...
      },
    

    Thanks for any input!

    opened by bramses 3
  • Why does CustomLayer example change the position if the comment says it shouldn't be transformed?

    Why does CustomLayer example change the position if the comment says it shouldn't be transformed?

    Am I the only one that thinks that the implementation of https://github.com/pmndrs/lamina/blob/main/README.md?plain=1#L205-L216 is confusing when looking at the comment?

    For me it sounds like, that a CustomLayer should't change the position via the vertex-shader, but in the example it totally does exactly that:

      // Optionally Define a vertex shader!
      // Same rules as fragment shaders, except no blend modes.
      // Return a non-transformed vec3 position.
      static vertexShader = `   
        // Varyings must be prefixed by "v_"
        varying vec3 v_Position;
        void main() {
          v_Position = position;
          return position * 2.;
        }
    

    So Return a non-transformed vec3 position. sounds to me that return position * 2.; shouldn't be done (I mean of course you can do that, but as a best practise it shouldn't right?).

    When I copied the example I was surprised that my mesh had increased in size.

    opened by TimPietrusky 2
  • Simplify inputs for common symbols/types

    Simplify inputs for common symbols/types

    Consider this blend effect

            <LayerMaterial transparent depthWrite={false} side={THREE.FrontSide} blending={THREE.AdditiveBlending}>
    

    With strings:

            <LayerMaterial transparent depthWrite={false} side="front" blending="additive">
    

    Side has 3 options, front, back, both. Blending does have a lot more, so you could still allow it to be passed, but otherwise make it easier...

    opened by DennisSmolek 2
  • LayerMaterials: With Base baked in, transparency should be the default and can be deterministic

    LayerMaterials: With Base baked in, transparency should be the default and can be deterministic

    If we bake in the base as mentioned in #8 there's no need to call transparent. You still could I guess, just to be 100% sure or if you planned on adjusting the other values later.

    But if you place a color in base:

     <LayerMaterial>
        <Base color="#603295" />
    </LaterMaterial>
    

    or by #8 :

    <LayerMaterial color="#603295">
    

    There's no alpha set so it is 100% opaque

    where this becomes confusing is actually on the inverse:

     <LayerMaterial>
        <Base color="#603295" alpha=".5" />
    </LaterMaterial>
    

    You would think that layer is 50% see through (opaque) but it's not...

    Transparent maps to the material, while base and alpha map to the material color map..

    I have NO IDEA what this would do..

    //simplified from @Fasani Blob experiment
    <mesh>
      <sphereGeometry args={[0.8, 128, 128]} />
      <LayerMaterial>
        <Base color="#603295" />
              {...}
      </LayerMaterial>
    </mesh>
    <mesh ref={glow} scale={0.6} visible={showGlow}>
        <circleGeometry args={[2, 16]} />
        <LayerMaterial depthWrite={false} side={THREE.FrontSide} blending={THREE.AdditiveBlending}>
            {...}
        </LayerMaterial>
    </mesh>
    

    In that instance the user accidentally left of the transparent value on glow. Now, because the blending mode isnt the default we know we're supposed to be transparent..

    TLDR: based on input props we can assume the intended transparency value

    Transparency on meshStandardMaterial in Three.js doscs

    opened by DennisSmolek 2
  • Blend two normal maps

    Blend two normal maps

    Hello,

    I want to create a PBR material that blends two normals maps. The first one should use uv index 0 and the second one should use uv index 1.

    Is that possible with lamina?

    Best

    opened by samevision 0
  • LayerMaterial clone() method doesn't works

    LayerMaterial clone() method doesn't works

    clone material is not same as origin material

    const material = new LayerMaterial({
          color: new THREE.Color(0xff0000),
          lighting: 'physical',
        });
    
    const cube = new THREE.Mesh(geometry, material.clone());
    
    Wrong Result, Should be red (0xff0000)
    截屏2022-07-03 上午2 53 26

    And no matter I clone multiple materials, the clone materials always have the same uuid ... 截屏2022-07-03 上午3 06 14

    bug CSM 
    opened by bufffun 1
  • RFC: Change behavior of how vertex shader layers are modifying positions

    RFC: Change behavior of how vertex shader layers are modifying positions

    It's great that Lamina layers can also provide vertex shaders that modify the vertex positions, but unless I've severely misunderstood something (and please tell me if I did), the way that vertex shaders are currently set up makes it kinda iffy to have multiple vertex-shading layers stacked in sequence.

    As far as I understand, from the perspective of a layer's vertex shader, the following happens:

    • A position variable is provided, containing the original vertex position from the geometry buffer.
    • The vertex shader is expected to implement a void main that returns a new, modified position.
    • If you have multiple Lamina layers that do this, each new layer will start with position being set to the original vertex position, essentially overwriting what the layers before already did to mutate it.

    This makes it very hard to implement stacks of animation shaders (where one, for example, would animate the vertices based on velocity applied over time, and another apply a rotation) without completely bypassing this setup and writing all changes into a shared global variable, only to then have the final layer write into the actual position.

    I don't know if this has implications (beyond potentially breaking existing code), so consider this an RFC: I propose that the system is changed to expect layer vertex shaders to mutate an existing position variable, eg.:

    // wobble position vertexShader
    void main() {
      position.x += sin(u_time);
    }
    
    // wobble scale vertexShader
    void main() {
      position *= 2.0 + cos(u_time);
    }
    
    // etc.
    

    Blend modes and ratios do not make sense here, so plain old mutation like this should be fine, but I'd be happy to hear what kind of stuff this will break.

    enhancement 1.2.0 
    opened by hmans 2
  • Uncaught TypeError: type is not a function

    Uncaught TypeError: type is not a function

    I'm running into this error while using the current version of @react-three/fiber (first affected version is 8.0.21). For example, updating the dependencies in the complex-material leads to the following:

    yarn.lock:

     "@react-three/fiber@^8.0.3":
    -  version "8.0.9"
    -  resolved "https://registry.yarnpkg.com/@react-three/fiber/-/fiber-8.0.9.tgz#e231626dc923a7fefd1d47588ce2c5af09726213"
    -  integrity sha512-9hh3w0JjPwtoqRexCnAVSPK3kdjtTqpaeTDZOW2RHmfU0gSYaKijY+PtaiHjoym/2oTfa21mCmaROXXS2jDvvQ==
    +  version "8.0.22"
    +  resolved "https://registry.yarnpkg.com/@react-three/fiber/-/fiber-8.0.22.tgz#68c69ba7c0c4f5354562c5acfd5f0c9c64b9a64d"
    +  integrity sha512-HkQR+SKm0Bi4qq9sxCV2rv2aXxEhWPcj52bLOCiW3WpF8sGJtmdc/pP4ih5gXwN7I5NMTa2eDeoSYkIPOwt1/g==
    

    Error:

    Uncaught TypeError: type is not a function
        at attach (index-f1b43982.esm.js:194:1)
        at switchInstance (index-f1b43982.esm.js:1024:1)
        at commitUpdate (index-f1b43982.esm.js:1119:1)
        at commitWork (react-reconciler.development.js:15871:1)
        at commitMutationEffectsOnFiber (react-reconciler.development.js:16204:1)
        at commitMutationEffects_complete (react-reconciler.development.js:16057:1)
        at commitMutationEffects_begin (react-reconciler.development.js:16046:1)
        at commitMutationEffects (react-reconciler.development.js:16016:1)
        at commitRootImpl (react-reconciler.development.js:18932:1)
        at commitRoot (react-reconciler.development.js:18811:1)
    

    Line:

    } else child.__r3f.previousAttach = type(parent, child);
    
    bug 
    opened by tothandras 0
  • flatShading prop has no effect on LayerMaterial

    flatShading prop has no effect on LayerMaterial

    Adding flatShading prop to the LayerMaterial doesn't affect the shading.

    flatshading

    Left: <meshMatcapMaterial matcap={matcap} flatShading />

    Right: <LayerMaterial flatShading> <Matcap map={matcap} /> </LayerMaterial>

    https://codesandbox.io/s/lamina-matcap-ho7v4z?file=/src/App.js

    bug 
    opened by marcelmusiol 0
Owner
Poimandres
Open source developer collective
Poimandres
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Adding volumetric effects to a built-in Three.js shader.

Magical Marbles in Three.js Adding volumetric effects to a built-in Three.js shader. Article on Codrops Demo Installation Install dependencies: yarn

Matt Rossman 68 Dec 9, 2022
Interactive visualiser 🌠 for a 3D raymarching engine written in GLSL and computed in a fragment shader on the 2D Plane.

Getting Started Node version used : 16.13.1 First install dependencies with: npm install # or yarn install Then, run the development server: npm run d

Michal Zalobny 22 Nov 12, 2022
Next-level mongoose caching layer with event based cache clearing

SpeedGoose ## About The Project This project is a next-level mongoose caching library which is fully written in typescript. It's caching on two levels

Arkadiusz Gil 17 Dec 15, 2022
Ektogamat Three Graces Design Concept using threejs

In this project, I wanted to show that creating a fancy design like this using #threejs is not as difficult as it looks.

Anderson Mancini 81 Dec 18, 2022
✨ ThreeJS Toys ⚡

✨ ThreeJS Toys - Made with ?? Work in progress... Sponsors (Thanks ?? !!!) Usage - npm npm install three threejs-toys Toys Particles Cursor - https:/

Kevin LEVRON 166 Dec 28, 2022
A basic USDZ file (Pixar Universal Scene Description) loader for ThreeJS

Three USDZ Loader A basic USDZ (binary Universal Scene Description) reader for Three.js The plugins supports animation as well as loading multiple USD

Pierre-Olivier NAHOUM 37 Dec 13, 2022
Futuristic tank game. Pure JavaScript with ThreeJS. Open Source

Retro-futuristic tank game. Pure JavaScript with ThreeJS. Open Source SYNTHBLAST.COM Gameplay shoot tanks Run over all yellow pads to advance a level

Brian Risk 107 Dec 11, 2022
The Web 3.0 social layer built on top of Twitter

Niftycase – The Web 3.0 Chrome extension for Twitter Niftycase is a open-source Chrome extension that allows you to view anybody's NFTs directly on Tw

Matt Welter 16 Jul 14, 2022
Solid.js library adding a services layer for global shared state.

Solid Services Services are "global" objects useful for features that require shared state or persistent connections. Example uses of services might i

Maciej Kwaśniak 55 Dec 30, 2022
Absolutely minimal view layer for building web interfaces.

Superfine Superfine is a minimal view layer for building web interfaces. Think Hyperapp without the framework—no state machines, effects, or subscript

Jorge Bucaran 1.6k Dec 29, 2022
DOM ViewModel - A thin, fast, dependency-free vdom view layer

domvm (DOM ViewModel) A thin, fast, dependency-free vdom view layer (MIT Licensed) Introduction domvm is a flexible, pure-js view layer for building h

null 604 Dec 8, 2022
A platform designed specifically as an additional layer on top of Google Classroom for students to gain the best out of online evaluations

Peer-Learning-Platform A platform designed specifically as an additional layer on top of Google Classroom for students to gain the best out of online

Rahul Dhakar 3 Jun 12, 2022
BI, API and Automation layer for your Engineering Operations data

Faros Community Edition Faros Community Edition (CE) is an open-source engineering operations platform that connects the dots between all your operati

Faros AI 272 Dec 23, 2022
🪐 The IPFS gateway for NFT.Storage is not "another gateway", but a caching layer for NFTs that sits on top of existing IPFS public gateways.

nftstorage.link The IPFS gateway for nft.storage is not "another gateway", but a caching layer for NFT’s that sits on top of existing IPFS public gate

NFT.Storage 37 Dec 19, 2022
An abstraction layer on top of @replit/crosis that makes Repl connection management and operations so easy, a Furret could do it! 🎉

Crosis4Furrets An abstraction layer on top of @replit/crosis that makes Repl connection management and operations so easy, a Furret could do it! ?? In

Ray 18 Dec 29, 2022
An extensible HTML DOM window manager with a professional look and feel

Wingman An extensible HTML DOM window manager with a professional look and feel. Installation Wingman only requires two files: wingman.css and wingman

nethe550 1 Jan 21, 2022