Skip to content

Commit

Permalink
Split materials in folders
Browse files Browse the repository at this point in the history
  • Loading branch information
kekkorider committed Aug 21, 2022
1 parent f2d9284 commit 327e55a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "threejs-starter",
"version": "1.2.6",
"version": "1.3.0",
"main": "src/index.js",
"author": "Francesco Michelini <hello@francescomichelini.com>",
"license": "MIT",
Expand Down
21 changes: 5 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
PerspectiveCamera,
BoxGeometry,
MeshStandardMaterial,
ShaderMaterial,
Mesh,
PointLight,
Color,
Expand All @@ -21,6 +20,8 @@ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'

import { Pane } from 'tweakpane'

import { SampleShaderMaterial } from './materials/SampleShaderMaterial'

class App {
#resizeCallback = () => this.#onResize()

Expand Down Expand Up @@ -129,13 +130,7 @@ class App {
#createShadedBox() {
const geometry = new BoxGeometry(1, 1, 1, 1, 1, 1)

const material = new ShaderMaterial({
vertexShader: require('./shaders/sample.vertex.glsl'),
fragmentShader: require('./shaders/sample.fragment.glsl'),
transparent: true
})

this.shadedBox = new Mesh(geometry, material)
this.shadedBox = new Mesh(geometry, SampleShaderMaterial)

this.shadedBox.scale.x = 4
this.shadedBox.scale.y = 4
Expand Down Expand Up @@ -176,14 +171,8 @@ class App {

mesh.position.z = 5

const material = new ShaderMaterial({
vertexShader: require('./shaders/sample.vertex.glsl'),
fragmentShader: require('./shaders/sample.fragment.glsl'),
transparent: true,
wireframe: true
})

mesh.material = material
mesh.material = SampleShaderMaterial.clone()
mesh.material.wireframe = true

this.scene.add(mesh)

Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions src/materials/SampleShaderMaterial/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ShaderMaterial } from 'three'

export const SampleShaderMaterial = new ShaderMaterial({
vertexShader: require('./vertex.glsl'),
fragmentShader: require('./fragment.glsl'),
transparent: true
})
File renamed without changes.

0 comments on commit 327e55a

Please sign in to comment.