Skip to content

Commit

Permalink
'desklight'
Browse files Browse the repository at this point in the history
  • Loading branch information
foglabs committed Feb 14, 2021
1 parent e724ae3 commit 7c08ea0
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 158 deletions.
4 changes: 4 additions & 0 deletions lib/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ class Character {
}
}

resetComponents(){
this.move(this.mesh.position.x,this.mesh.position.y,this.mesh.position.z)
}


addPoint(x,y,z){
// can use this to snap coordinates to game area edges
Expand Down
139 changes: 44 additions & 95 deletions lib/MusicPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,9 @@ class MusicPlayer extends Character {
let geo, bbox, mat, mat2
geo = new THREE.BoxGeometry( 0.2, 0.1, 0.1 )
bbox = new THREE.Box3(new THREE.Vector3(), new THREE.Vector3())

super(null, bbox, [255,255,255], null, null, null, place.models["/models/stereo.glb"] )

// let stereoMap = textureLoader.load('/textures/stereo.png')
// stereoMap.wrapS = THREE.RepeatWrapping
// stereoMap.wrapT = THREE.RepeatWrapping
// stereoMap.repeat.set(1,0.5)
// let stereoBump = textureLoader.load('/textures/stereoB.png')
// stereoBump.wrapS = THREE.RepeatWrapping
// stereoBump.wrapT = THREE.RepeatWrapping
// stereoBump.repeat.set(1,0.5)

// let stereoFrontMap = textureLoader.load('/textures/stereo-front.png')
// stereoFrontMap.wrapS = THREE.RepeatWrapping
// stereoFrontMap.wrapT = THREE.RepeatWrapping
// stereoFrontMap.repeat.set(1,0.5)
// let stereoFrontBump = textureLoader.load('/textures/stereo-frontB.png')
// stereoFrontBump.wrapS = THREE.RepeatWrapping
// stereoFrontBump.wrapT = THREE.RepeatWrapping
// stereoFrontBump.repeat.set(1,0.5)

// let buttonMap = textureLoader.load('/textures/button.png')
// buttonMap.wrapS = THREE.RepeatWrapping
// buttonMap.wrapT = THREE.RepeatWrapping
// buttonMap.repeat.set(1,1)

let playButtonBump = textureLoader.load('/textures/playButtonBumpB.png')
playButtonBump.wrapS = THREE.RepeatWrapping
Expand All @@ -46,7 +26,48 @@ class MusicPlayer extends Character {
stopButtonBump.wrapT = THREE.RepeatWrapping
stopButtonBump.repeat.set(1,1)

let nextButtonBump = textureLoader.load('/textures/nextButtonBumpB.png')
let createPrevButton = (nextTex) => {
// make this as proc so we get the correct 'this'
// needs to be after load function because we can't clone nexttex until after we got the image
// prev tex is just a rotation of next

let prevTex = nextTex.clone()
prevTex.needsUpdate = true
prevTex.rotation = Math.PI

let prevgeo = new THREE.BoxGeometry( 0.03, 0.02, 0.04 )
let prevmat = new THREE.MeshStandardMaterial( { color: "#ffff00", bumpMap: prevTex, bumpScale: 0.008 })
let prevoffset = new THREE.Vector3(0.005,-0.015,0.1)
let prevClick = () => {
if(this.state == CLOSED){
if(this.album){
this.prevTrack()
}
} else {
this.showText("TRAY OPEN! ")
}
}

this.prevButton = new Component( this, prevoffset, prevgeo, [100,0,100], prevmat, prevClick )
this.prevButton.clickable = true
// this.prevButton.roty = util.radian(90)
// this.prevButton.mesh.rotation.y = this.prevButton.roty
scene.add(this.prevButton.mesh)
this.components.push( this.prevButton )

// move to current mesh position so components follow
this.resetComponents()
// initialize as closed
this.insert()
}
// bound to be this
createPrevButton = createPrevButton.bind(this)


let nextButtonBump = textureLoader.load('/textures/nextButtonBumpB.png', (nextTex) => {
createPrevButton(nextTex)
})

nextButtonBump.wrapS = THREE.RepeatWrapping
nextButtonBump.wrapT = THREE.RepeatWrapping
nextButtonBump.repeat.set(1,1)
Expand All @@ -56,36 +77,11 @@ class MusicPlayer extends Character {
ejectButtonBump.wrapS = THREE.RepeatWrapping
ejectButtonBump.wrapT = THREE.RepeatWrapping


// let trayMap = textureLoader.load('/textures/stereo-tray.png')
// trayMap.wrapS = THREE.RepeatWrapping
// trayMap.wrapT = THREE.RepeatWrapping
// trayMap.repeat.set(1,1)
let trayBump = textureLoader.load('/textures/stereo-trayB.png')
trayBump.wrapS = THREE.RepeatWrapping
trayBump.wrapT = THREE.RepeatWrapping
trayBump.repeat.set(1,1)

// mat = new THREE.MeshPhysicalMaterial( { map: stereoMap, bumpMap: stereoBump, bumpScale: 0.8 })
// mat2 = new THREE.MeshPhysicalMaterial( { map: stereoFrontMap, bumpMap: stereoFrontBump, bumpScale: 0.8 })

// var mater = new THREE.MeshBasicMaterial([mat, mat2])

// old
// super(geo, bbox, [255,255,255], mat2 )
super(null, bbox, [255,255,255], null, null, null, place.models["/models/stereo.glb"] )

// let stereoNormal = textureLoader.load("/textures/stereoB.png")
// stereoNormal.mapping = THREE.UVMapping
// this.mesh.material.normalMap = stereoNormal

// let stereoBimg = textureLoader.load("/textures/stereoB.png", (txt) => {
// // txt.mapping = THREE.UVMapping
// console.log( 'stbmpa', stBMap )
// this.mesh.material.needsUpdate = true
// this.mesh.material.bumpMap = txt
// })

this.mesh.scale.set(0.035,0.035,0.035)
this.mesh.rotation.y = util.radian(180)
this.roty = util.radian(180)
Expand All @@ -105,24 +101,6 @@ class MusicPlayer extends Character {
this.loadAlbum(this.album.trackUrls)
}

// let faciageo = new THREE.BoxGeometry( 0.16, 0.03, 0.04 )
// let faciamat = new THREE.MeshStandardMaterial( { map: stereoMap, bumpMap: stereoBump, color: "#ffffff", bumpScale: 0.008 })
// let faciaoffset = new THREE.Vector3(0,-0.015,0.045)

// this.buttonFacia = new Component( this, faciaoffset, faciageo, [255,255,255], faciamat )
// this.buttonFacia.pushable = false
// scene.add(this.buttonFacia.mesh)
// this.components.push( this.buttonFacia )

// let ejectfaciageo = new THREE.BoxGeometry( 0.16, 0.03, 0.04 )
// let ejectfaciamat = new THREE.MeshStandardMaterial( { map: stereoMap, bumpMap: stereoBump, color: "#ffffff", bumpScale: 0.008 })
// let ejectfaciaoffset = new THREE.Vector3(0,0.07,0.045)

// this.buttonejectFacia = new Component( this, ejectfaciaoffset, ejectfaciageo, [255,255,255], ejectfaciamat )
// this.buttonejectFacia.pushable = false
// scene.add(this.buttonejectFacia.mesh)
// this.components.push( this.buttonejectFacia )

// juz do buttons
let stopgeo = new THREE.BoxGeometry( 0.03, 0.02, 0.04 )
let stopmat = new THREE.MeshStandardMaterial( { bumpMap: stopButtonBump, color: "#ff00ff", bumpScale: 0.008 })
Expand All @@ -149,15 +127,6 @@ class MusicPlayer extends Character {
let playgeo = new THREE.BoxGeometry( 0.03, 0.02, 0.04 )
let playmat = new THREE.MeshStandardMaterial( { color: "#00ff00", bumpMap: playButtonBump, bumpScale: 0.008 })

// let playmats = [
// playmat,
// new THREE.MeshStandardMaterial( { color: "#00ff00" }),
// new THREE.MeshStandardMaterial( { color: "#00ff00" }),
// new THREE.MeshStandardMaterial( { color: "#00ff00" }),
// new THREE.MeshStandardMaterial( { color: "#00ff00" }),
// new THREE.MeshStandardMaterial( { color: "#00ff00" })
// ]

let playOffset = new THREE.Vector3(0.085,-0.015,0.1)

let pbClick = (id) => {
Expand Down Expand Up @@ -198,26 +167,6 @@ class MusicPlayer extends Character {
scene.add(this.nextButton.mesh)
this.components.push( this.nextButton )

let prevgeo = new THREE.BoxGeometry( 0.03, 0.02, 0.04 )
let prevmat = new THREE.MeshStandardMaterial( { color: "#ffff00", bumpMap: nextButtonBump, bumpScale: 0.008 })
let prevoffset = new THREE.Vector3(0.005,-0.015,0.1)
let prevClick = () => {
if(this.state == CLOSED){
if(this.album){
this.prevTrack()
}
} else {
this.showText("TRAY OPEN! ")
}
}

this.prevButton = new Component( this, prevoffset, prevgeo, [100,0,100], prevmat, prevClick )
this.prevButton.clickable = true
// this.prevButton.roty = util.radian(90)
// this.prevButton.mesh.rotation.y = this.prevButton.roty
scene.add(this.prevButton.mesh)
this.components.push( this.prevButton )

let ejectgeo = new THREE.BoxGeometry( 0.03, 0.02, 0.04 )
let ejectmat = new THREE.MeshStandardMaterial( { bumpMap: ejectButtonBump, bumpScale: 0.008, color: "#ffff00" })
let ejectoffset = new THREE.Vector3(0.005,0.059,0.1)
Expand Down
78 changes: 52 additions & 26 deletions lib/RelaxingRain.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ class RelaxingRain extends Place {
// var lighter = new THREE.HemisphereLight("#ffffff", "#000000", 0.006)
// scene.add(lighter)

var spotlight2 = new THREE.SpotLight("#dddddd", 0.002)
var spotlight2 = new THREE.SpotLight("#ddddaa", 0.0008)
spotlight2.castShadow = true
spotlight2.shadow.mapSize.width = 1024*4
spotlight2.shadow.mapSize.height = 1024*4
spotlight2.position.set(-1,1.8,0)
spotlight2.lookAt(1,-1,2)
spotlight2.position.set(-1.06,1,0.4)
spotlight2.lookAt(-1,-5,0)
scene.add(spotlight2)
// light.shadow.mapSize.width = 512; // default
// light.shadow.mapSize.height = 512; // default
spotlight2.shadow.camera.near = 0.5; // default
spotlight2.shadow.camera.far = 500; // default
spotlight2.shadow.focus = 1; // default
Expand All @@ -74,6 +72,55 @@ class RelaxingRain extends Place {

let characters = {}

var door = new Character( new THREE.BoxGeometry( 0.02,0.8,0.3 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [150,150,150], new THREE.MeshPhysicalMaterial( { map: null, bumpScale: 0.8, bumpMap: null }) )
door.move(spotlight2.position.x+0.05,spotlight2.position.y+0.354,spotlight2.position.z-0.08)
door.mesh.rotation.set(0,0,0)
door.mesh.castShadow = true
door.mesh.receiveShadow = true

door.pushable = false

scene.add( door.mesh )
characters[door.mesh.id] = door




var desklight = new THREE.SpotLight("#222200", 0.004)
desklight.castShadow = true
desklight.shadow.mapSize.width = 1024*4
desklight.shadow.mapSize.height = 1024*4
desklight.position.set(-0.85,1.3,-0.18)
desklight.lookAt(-1,-5,0)
scene.add(desklight)
desklight.shadow.camera.near = 0.5; // default
desklight.shadow.camera.far = 500; // default
desklight.shadow.focus = 1; // default
scene.add(desklight)

var desklamp = new Character( new THREE.BoxGeometry( 0.06,0.06,0.06 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [255,255,255], new THREE.MeshPhysicalMaterial( { map: null, bumpScale: 0.8, bumpMap: null }) )
desklamp.move(desklight.position.x,desklight.position.y,desklight.position.z)
desklamp.mesh.rotation.set(0,0,0)
desklamp.mesh.castShadow = true
desklamp.mesh.receiveShadow = true
desklamp.pushable = false
scene.add( desklamp.mesh )
characters[desklamp.mesh.id] = desklamp

var desklamp2 = new Character( new THREE.BoxGeometry( 0.01,0.13 ,0.01 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [0,0,0], new THREE.MeshPhysicalMaterial( { map: null, bumpScale: 0.8, bumpMap: null }) )
desklamp2.move(desklight.position.x,desklight.position.y-0.048,desklight.position.z)
desklamp2.mesh.rotation.set(0,0,0)
desklamp2.mesh.castShadow = true
desklamp2.mesh.receiveShadow = true
desklamp2.pushable = false
scene.add( desklamp2.mesh )
characters[desklamp2.mesh.id] = desklamp2






// roof
// { map: wallMap, transparent: true, transmission: 0.5, reflectivity: 1, roughness: 0, clearcoat: 1.0, clearcoatRoughness: 0.1 })
// var char4wd7el71edr = new Character( new THREE.BoxGeometry( 1.369999999999997,0.030000000000000016,1.389999999999997 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [150,150,150], new THREE.MeshPhysicalMaterial( { map: roofMap, bumpMap: roofBump, bumpScale: 0.0009 }) )
Expand Down Expand Up @@ -483,15 +530,8 @@ class RelaxingRain extends Place {
this.musicPlayer.move(-0.49,1.24,-0.9499999999999999)

this.characters[this.musicPlayer.mesh.id] = this.musicPlayer
this.characters[this.musicPlayer.playButton.mesh.id] = this.musicPlayer.playButton
this.characters[this.musicPlayer.stopButton.mesh.id] = this.musicPlayer.stopButton
this.characters[this.musicPlayer.nextButton.mesh.id] = this.musicPlayer.nextButton
this.characters[this.musicPlayer.prevButton.mesh.id] = this.musicPlayer.prevButton

scene.add( this.musicPlayer.mesh )

// initialize as closed
this.musicPlayer.insert()
})

// light.lookAt(this.musicPlayer.mesh)
Expand Down Expand Up @@ -577,20 +617,6 @@ class RelaxingRain extends Place {
plant.mesh.scale.z = scale * sizeDiff
plant.mesh.position.set(position.x, position.y, position.z)

let rx,ry,rz

// rx = Math.random() * 2 * Math.PI
rx = 0
ry = Math.random() * 2 * Math.PI
rz = 0

plant.rotx = rx
plant.roty = ry
plant.rotz = rz
plant.mesh.rotation.x = rx
plant.mesh.rotation.y = ry
plant.mesh.rotation.z = rz

plant.pushable = true
plant.grabbable = false
plant.clickable = false
Expand Down
Loading

0 comments on commit 7c08ea0

Please sign in to comment.