Skip to content

Commit

Permalink
'volume buttons, debulk files a bit'
Browse files Browse the repository at this point in the history
  • Loading branch information
foglabs committed Feb 24, 2021
1 parent 1aa241f commit 7b64db8
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 71 deletions.
2 changes: 1 addition & 1 deletion lib/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ class Character {
// set bounding box from mesh baby
this.bbox.setFromObject(this.mesh)
// push out the eedges a little so collision works better
this.bbox.expandByScalar(0.002)
this.bbox.expandByScalar(0.0022)

if(this.customBboxScale){
// alter by custom scale
Expand Down
12 changes: 7 additions & 5 deletions lib/DeskLamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ class DeskLamp extends Character {

let bbox = new THREE.Box3(new THREE.Vector3(), new THREE.Vector3())

super(null, bbox, [255,255,255], null, null, null, place.models["/models/desklamp.glb"] )
// hopefully make it so the box is a little less insane when grab
let customBboxScale = new THREE.Vector3(0.8,0.8,0.8)
super(null, bbox, [255,255,255], null, null, null, place.models["/models/desklamp.glb"], customBboxScale )

// the actual light 222200
this.desklight = new THREE.SpotLight("#555533", 0.0012)
this.desklight.castShadow = true
this.desklight.shadow.mapSize.width = 1024*4
this.desklight.shadow.mapSize.height = 1024*4
this.desklight.position.set(-0.85,1.262,-0.18)
this.desklight.position.set(-0.78,1.262,-0.22)
// this.desklight.position.set(-0.85,1.262,-0.78)
this.desklight.lookAt(-1,-5,0)
this.desklight.shadow.camera.near = 0.5; // default
Expand All @@ -33,8 +35,8 @@ class DeskLamp extends Character {
this.move(this.desklight.position.x,this.desklight.position.y,this.desklight.position.z)

this.mesh.scale.set(0.1,0.1,0.1)
this.flatRoty = Math.PI*-1.495
this.roty = Math.PI*-1.495
this.flatRoty = Math.PI*-1.295
this.roty = Math.PI*-1.295
this.mesh.rotation.y = this.roty

place.characters[this.mesh.id] = this
Expand All @@ -60,4 +62,4 @@ class DeskLamp extends Character {
}
}

export { DeskLamp }
export { DeskLamp }
26 changes: 17 additions & 9 deletions lib/MusicPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class MusicPlayer extends Character {
this.loadAlbum(this.album.trackUrls)
}

this.volume = 0.5
this.volumeTimer = new Timer()
this.volumeTimer.start()

// 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 Down Expand Up @@ -466,7 +470,7 @@ class MusicPlayer extends Character {
url = urls[i]

// wait to actually load cause its too much up front
sound = new Sound("track"+i, urls[i], 0.5, false, false, false)
sound = new Sound("track"+i, urls[i], this.volume, false, false, false)
sound.mesh.position.set(this.mesh.position.x,this.mesh.position.y,this.mesh.position.z)
this.tracks.push( sound )
}
Expand Down Expand Up @@ -503,15 +507,19 @@ class MusicPlayer extends Character {
changeVolume(inc){
if( this.playing && this.tracks.length>1 && this.tracks[this.currentTrack].loaded ){

// inc player volume
this.volume = util.incInRange(this.volume, inc, 0, 10)

// set vol for all tracks so it stays consistent after track change
for(var i=0; i<this.tracks.length; i++){
if(this.tracks[i].loaded){
this.tracks[i].setVolume(this.volume)
}
if(this.volumeTimer.time() > 800){
this.volumeTimer.reset()

// inc player volume
this.volume = util.incInRange(this.volume, inc, 0, 10)
// set vol for all tracks so it stays consistent after track change
for(var i=0; i<this.tracks.length; i++){
if(this.tracks[i].loaded){
this.tracks[i].setVolume(this.volume)
}
}
}

}
}

Expand Down
112 changes: 67 additions & 45 deletions lib/RelaxingRain.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,26 @@ class RelaxingRain extends Place {
characters[charqfgf20fm3nd2.mesh.id] = charqfgf20fm3nd2
console.log( 'its ', charqfgf20fm3nd2.mesh.id )


// da blox
var box
var boxPositions = []
let bp


for(var a=0; a<3;a++){
for(var b=0; b<3;b++){
for(var c=0; c<3;c++){
bp = {}
bp["a"] = a * 0.1 - 0.092
bp["b"] = b * 0.1 + 0.4 + FLOOR
bp["c"] = c * 0.1 - 1.042
boxPositions.push( bp )
}
}
}


// table
var charctw2g1t5rg5 = new Character( new THREE.BoxGeometry( 0.3100000000000002,0.39000000000000026,0.34000000000000025 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [110,110,110], new THREE.MeshStandardMaterial( { map: tableMap, bumpScale: 0.8, bumpMap: tableMapB}) )
charctw2g1t5rg5.move(-0.4,1.008,-0.9399999999999999)
Expand Down Expand Up @@ -282,23 +302,23 @@ class RelaxingRain extends Place {
sounds[sound1.name] = sound1

// same route as first one
let sound2 = new Sound("rain3", "/sounds/rain-Rclip.mp3", Math.max(0.4, Math.random() * 0.89 ) , true, true)
sound2.move(0.4, 3.2,-0.7)
sound2.routePoints = [[-0.4, 3.2,0.7], [0.4, 3.2,0.7], [0.4, 3.2,-0.7], [0.4, 3.2,-0.7] ]
sounds[sound2.name] = sound2
// let sound2 = new Sound("rain3", "/sounds/rain-Rclip.mp3", Math.max(0.4, Math.random() * 0.89 ) , true, true)
// sound2.move(0.4, 3.2,-0.7)
// sound2.routePoints = [[-0.4, 3.2,0.7], [0.4, 3.2,0.7], [0.4, 3.2,-0.7], [0.4, 3.2,-0.7] ]
// sounds[sound2.name] = sound2

// wioder
let sound3 = new Sound("rain4", "/sounds/rain-Rclip.mp3", Math.max(0.2, Math.random() * 0.89 ) , true, true)
sound3.move(0-3.6, 3.8,2.9)
sound3.routePoints = [[-3.6, 3.8,2.9], [3.6, 3.8,2.9], [3.6, 3.8,-2.9], [3.6, 3.8,-2.9]]
sounds[sound3.name] = sound3

let sound7 = new Sound("relaxrain", "/sounds/freerelax-rain-clipped.mp3", 2, true, true)
let sound7 = new Sound("relaxrain", "/sounds/freerelax-rain-clipped-short.mp3", 2, true, true)
sound7.move(-0.4,1.8,-0.4)
// sound7.routePoints = [[-0.6, 3.2,0.9], [0.6, 3.2,0.9], [0.6, 3.2,-0.9], [0.6, 3.2,-0.9]]
sounds[sound7.name] = sound7

let sound8 = new Sound("stream", "/sounds/gpStreamClip.mp3", 0.5, true, true)
let sound8 = new Sound("stream", "/sounds/gpStreamClip-short.mp3", 0.5, true, true)
sound8.move(0,-1,-2)
// sound8.routePoints = [[-0.6, 3.2,0.9], [0.6, 3.2,0.9], [0.6, 3.2,-0.9], [0.6, 3.2,-0.9]]
sounds[sound8.name] = sound8
Expand All @@ -314,6 +334,34 @@ class RelaxingRain extends Place {

super(backgroundHex, characters, floorObjects, sounds)

let boxClick = () => {
// shoot it in a random direction
for(var i=0; i<this.boxIds.length; i++){
this.characters[this.boxIds[i]].pushable = true
this.characters[this.boxIds[i]].accx = Math.random()
this.characters[this.boxIds[i]].accy = Math.random()
this.characters[this.boxIds[i]].accz = Math.random()
}

}

boxClick = boxClick.bind(this)

this.boxIds = []
for(var i=0; i<27; i++){

box = new Character( new THREE.BoxGeometry(0.07,0.07,0.07), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [255,0,255], new THREE.MeshPhysicalMaterial( { color: "#ff00ff" }), boxClick )
box.move( boxPositions[i].a, boxPositions[i].b, boxPositions[i].c )
box.mesh.castShadow = true
box.mesh.receiveShadow = true
box.pushable = false
box.clickable = true

scene.add( box.mesh )
this.characters[box.mesh.id] = box
this.boxIds.push(box.mesh.id)
}

// for updown buttons
this.spotlight = spotlight

Expand All @@ -331,14 +379,15 @@ class RelaxingRain extends Place {
this.stars = []

// // stars
let starsGeo, star
let starsGeo, star, numStars
let brightness = 1
// reused for rain
let pt,x,y,z
for(var q=0; q<12; q++){

starsGeo = new THREE.Geometry();
for(let i=0;i<1000;i++) {
numStars = 500 + Math.floor( Math.random() * 500)
for(let i=0;i<numStars;i++) {
// x = Math.random() * 200 - 100
// y = Math.random() * 200 - 100
// z = Math.random() * 200 - 100
Expand All @@ -359,9 +408,9 @@ class RelaxingRain extends Place {
scene.add( thisRain )

// vary next star set
starColor[0] = Math.max ( Math.floor( brightness * starColor[0] + Math.random() * 60 - 30 ), 0 )
starColor[1] = Math.max ( Math.floor( brightness * starColor[1] + Math.random() * 60 - 30 ), 0 )
starColor[2] = Math.max ( Math.floor( brightness * starColor[2] + Math.random() * 60 - 30 ), 0 )
starColor[0] = Math.max ( Math.floor( brightness * starColor[0] + Math.random() * 120 - 60 ), 0 )
starColor[1] = Math.max ( Math.floor( brightness * starColor[1] + Math.random() * 120 - 60 ), 0 )
starColor[2] = Math.max ( Math.floor( brightness * starColor[2] + Math.random() * 120 - 60 ), 0 )

// make next star set dimmer
brightness = brightness - (0.05 + Math.random() * 0.1)
Expand All @@ -385,7 +434,7 @@ class RelaxingRain extends Place {
pgroup.add(p)


gpscale = Math.random() * 3.6
gpscale = Math.random() * 1.8
gpopac = 0.8/gpscale

pm = new THREE.MeshBasicMaterial({blending: THREE.AdditiveBlending, transparent: true, opacity: gpopac, color: util.randomHex(255) })
Expand Down Expand Up @@ -453,8 +502,8 @@ class RelaxingRain extends Place {
// cloudTexture2.repeat = 1
let cloudMaterial2 = new THREE.MeshBasicMaterial({
// depthTest: false,
color: "#880088",
opacity: 0.08,
color: "#110011",
opacity: 0.22,
map: cloudTexture2,
transparent: true,
})
Expand Down Expand Up @@ -510,35 +559,16 @@ class RelaxingRain extends Place {
}

// mountain plane
let mountainGeo, mountainMat, selectedMap, mountainMap, mountainMap2, mountainMap3, forestMap, forestBump
let mountainGeo, mountainMat, selectedMap, mountainMap, mountainMap2, mountainMap3, forestMap

forestMap = textureLoader.load("/textures/forest.png")
// forestBump = textureLoader.load("/textures/forestB.png")

// mountainMap = textureLoader.load("/textures/mountainD.png")
// mountainMap2 = textureLoader.load("/textures/mountain2D.png")
// mountainMap3 = textureLoader.load("/textures/mountain3D.png")

// mountainGeo = new THREE.PlaneGeometry( 10, 10, 100, 100 )
forestMap = textureLoader.load("/textures/forest-small.png")
mountainGeo = new THREE.SphereGeometry( 0.8, 32, 32 )

// xyz
this.mountains = []
for(var i=0; i<6; i++){
// rando = Math.random()
// if(rando<0.33){
// selectedMap = mountainMap
// }else if(Math.random()<0.66){
// selectedMap = mountainMap2
// } else {
// selectedMap = mountainMap3
// }

// mountainMat = new THREE.MeshPhysicalMaterial( { map: forestMap, bumpMap: forestBump, color: "#ffffff", side: THREE.DoubleSide } )
mountainMat = new THREE.MeshBasicMaterial( { map: forestMap, color: "#000100", side: THREE.DoubleSide } )

// , displacementMap: selectedMap, displacementScale: 1, emissive: "#009900", emissiveIntensity: 0.01

this.mountains[i] = new THREE.Mesh( mountainGeo, mountainMat )
// too much shadow from clouds mane
this.mountains[i].receiveShadow = false
Expand All @@ -547,14 +577,9 @@ class RelaxingRain extends Place {
x = util.randomSign() * (Math.random() * 1 + 1.3)
y = -0.4
z = util.randomSign() * (Math.random() * 1 + 1.3)
// x = 0
// y = 0
// z = 0

this.mountains[i].position.set(x, y ,z)
this.mountains[i].scale.set(1 + Math.random(), 1 + Math.random(), 1 + Math.random())
// this.mountains[i].rotation.x = util.radian(90)
// this.mountains[i].rotation.z = util.radian(Math.random())
scene.add(this.mountains[i])
}

Expand Down Expand Up @@ -661,7 +686,7 @@ class RelaxingRain extends Place {
plant.mesh.scale.z = scale * sizeDiff
plant.mesh.position.set(position.x, position.y, position.z)

plant.pushable = true
plant.pushable = false
plant.grabbable = true
plant.clickable = false
plant.droppable = false
Expand Down Expand Up @@ -826,10 +851,7 @@ class RelaxingRain extends Place {
this.sounds[randomThunderName].play()
}
}


}

}

export { RelaxingRain }
export { RelaxingRain }
17 changes: 6 additions & 11 deletions lib/Remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ class Remote extends Character {
let mat = new THREE.MeshPhysicalMaterial( { color: "#000000", reflectivity: 1, roughness: 0, clearcoat: 1.0, clearcoatRoughness: 0.1, map: stereoMap, bumpMap: stereoBump, bumpScale: 1 })

// scale back the bbox on z dimension
let bboxScale = new THREE.Vector3(1.0,1.0,0.60)
let bboxScale = new THREE.Vector3(1.0,1.0,0.40)
console.log( 'hi scale', bboxScale )
super(geo, bbox, [0,0,255], mat, null, null, null, bboxScale)


textureLoader.load('/textures/buttonGrain.png', (tex) => {

textureLoader.load('/textures/buttonGrainB.png', (bump) => {
Expand Down Expand Up @@ -59,7 +58,6 @@ class Remote extends Character {
let upoffset = new THREE.Vector3(0.0125,0.01,-0.03)
let upClick = () => {
console.log( 'hey upper' )

place.spotlight.intensity = util.incInRange(place.spotlight.intensity, 0.001, 0, 0.048)
}

Expand Down Expand Up @@ -87,7 +85,7 @@ class Remote extends Character {
this.components.push( this.downButton )

// vol up button
let upVoloffset = new THREE.Vector3(0.0125,0.01,0.03)
let upVoloffset = new THREE.Vector3(-0.0125,0.01,0.03)
let upVolClick = () => {
console.log( 'upvol fucker' )
place.musicPlayer.changeVolume(-0.1)
Expand All @@ -100,7 +98,7 @@ class Remote extends Character {
this.components.push( this.upVolButton )

// vol down button
let downVoloffset = new THREE.Vector3(-0.0125,0.01,0.03)
let downVoloffset = new THREE.Vector3(0.0125,0.01,0.03)
let downVolClick = () => {
console.log( 'downvol fucker' )
place.musicPlayer.changeVolume(0.1)
Expand All @@ -112,18 +110,15 @@ class Remote extends Character {
scene.add(this.downVolButton.mesh)
this.components.push( this.downVolButton )


this.move(position.x,position.y,position.z)
})
})



this.move(position.x,position.y,position.z)

// dont rotate and flatten, makes this veeeery difficult
this.rotatable = false
this.lightness = 0.003
}
}

export { Remote }
export { Remote }

Binary file added sounds/freerelax-rain-clipped-short.mp3
Binary file not shown.
Binary file removed sounds/freerelax-rain-clipped.mp3
Binary file not shown.
Binary file added sounds/gpStreamClip-short.mp3
Binary file not shown.
Binary file removed sounds/gpStreamClip.mp3
Binary file not shown.
Binary file added textures/forest-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed textures/forest.png
Binary file not shown.
Binary file removed textures/forestB.png
Binary file not shown.

0 comments on commit 7b64db8

Please sign in to comment.