Created
March 2, 2019 17:14
-
-
Save JacobMJones/40fc2505c2b83a9904692b1e69b88394 to your computer and use it in GitHub Desktop.
b+w sleek new lights
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
Lights: | |
import * as THREE from 'three' | |
export default scene => { | |
// const lightIn = new THREE.PointLight("blue", 30); | |
const lightOut = new THREE.DirectionalLight("fff", 1); | |
lightOut.position.set(40,20,400); | |
//scene.add(lightIn); | |
scene.add(lightOut); | |
const rad = 80; | |
function update(time) { | |
const x = rad * Math.sin(time*0.2) | |
lightOut.position.x = x; | |
} | |
return { | |
update | |
} | |
} | |
Marble: | |
import * as THREE from 'three' | |
import alphaTexture from './clean-grey-gradient.jpg'; | |
export default scene => { | |
const group = new THREE.Group(); | |
const subjectGeometry = deformGeometry(new THREE.IcosahedronGeometry(7, 5)); | |
const subjectMaterial = new THREE.MeshStandardMaterial({ color: "transparent", transparent: true, side: THREE.DoubleSide, alphaTest: 0.1 }); | |
subjectMaterial.alphaMap = new THREE.TextureLoader().load(alphaTexture); | |
subjectMaterial.alphaMap.magFilter = THREE.NearestFilter; | |
subjectMaterial.alphaMap.wrapT = THREE.RepeatWrapping; | |
subjectMaterial.alphaMap.repeat.y = 5; | |
const subjectMesh = new THREE.Mesh(subjectGeometry, subjectMaterial); | |
group.add(subjectMesh); | |
// group.add(subjectWireframe); | |
scene.add(group); | |
group.rotation.z = Math.PI/2; | |
const speed = 0.3; | |
const textureOffsetSpeed = .5; | |
function deformGeometry(geometry) { | |
// for (let i=0; i<geometry.vertices.length; i+=8) { | |
// const scalar = 1 - Math.random() * .2; | |
// geometry.vertices[i].multiplyScalar(scalar) | |
// } | |
return geometry; | |
} | |
function update(time) { | |
const angle = time*speed; | |
group.rotation.y = angle; | |
subjectMaterial.alphaMap.offset.y = 0.55 + time * textureOffsetSpeed; | |
// subjectWireframe.material.color.setHSL( Math.sin(angle*2), 0.5, 0.5 ); | |
const scale = (Math.sin(angle*8)+6.4)/5; | |
// subjectWireframe.scale.set(scale, scale, scale) | |
} | |
return { | |
update | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment