Skip to content

Commit

Permalink
'fixes, minicabin'
Browse files Browse the repository at this point in the history
  • Loading branch information
foglabs committed Nov 3, 2020
1 parent 8c18fca commit c194bc5
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 44 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>FOG VR</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link type="text/css" rel="stylesheet" href="main.css">
<link type="text/css" rel="stylesheet" href="places.css">
</head>
<body>
<script type="text/javascript">
Expand Down
14 changes: 7 additions & 7 deletions lib/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ class Character {
// let dist = Math.sqrt(ydiff * ydiff + xdiff * xdiff)

let speed
if(xdiff < 0.05 && ydiff < 0.05 && zdiff < 0.05){
// 2x speed once were close.. somehow helps us get there
speed = 0.06 * speedFactor
} else {
speed = 0.04 * speedFactor
// if(xdiff < 0.05 && ydiff < 0.05 && zdiff < 0.05){
// // 2x speed once were close.. somehow helps us get there
// speed = 0.06 * speedFactor
// } else {
// speed = 0.04 * speedFactor

}
// speed = 0.04 * speedFactor
// }
speed = 0.04 * speedFactor

if(startx < destx){
this.accx += speed
Expand Down
2 changes: 1 addition & 1 deletion lib/Place.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Place {
if(sound){
sound.handle()
}
// if(sound.playing){
// if(sound.playing()){
// console.log("she playin wittem")
// } else {
// console.log( 'she is not playin wittem' )
Expand Down
29 changes: 19 additions & 10 deletions lib/Sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@ import { listener, audioLoader, scene } from "./main.js"

class Sound extends Character {
constructor(soundFilePath, volume=3.0, loop=true, playLength=null, omni=null){
let sphere = new THREE.SphereBufferGeometry( 1, 32, 16 )
let sphere = new THREE.SphereBufferGeometry( 0.2, 32, 16 )
let material = new THREE.MeshPhongMaterial( { color: 0xff2200 } )
super(sphere, new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [0,0,255], material)

this.soundFilePath = soundFilePath
if(omni){

this.volume = volume
this.loop = loop
this.omni = omni

this.playLength = playLength
this.playTimer = new Timer()
this.playTimer.start()

this.loaded = false

if(this.omni){

this.soundFile = new THREE.Audio(listener)
} else {
Expand All @@ -21,18 +32,12 @@ class Sound extends Character {

scene.add( this.mesh )

this.volume = volume
this.loaded = false

this.loadSound(this.soundFile, this.volume, this.loop, () => {
this.loaded = true
this.play()
console.log( 'oh boy im done' )
console.log( 'oh boy im done', this.playing() )
})

this.playLength = playLength
this.playTimer = new Timer()
this.playTimer.start()
}

loadSound(soundFile, volume, loop, imDone){
Expand Down Expand Up @@ -73,10 +78,14 @@ class Sound extends Character {

handle(){
// lets change all this crap over bby!
if(this.playTimer.time() > this.playLength){
if(this.playLength && this.playTimer.time() > this.playLength){
// iiim done
this.stop()
}

this.animation()
this.handleMovement()
this.handleCollision()
}
}

Expand Down
89 changes: 64 additions & 25 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,109 +83,109 @@
// textyMap.wrapS = THREE.RepeatWrapping
// textyMap.wrapT = THREE.RepeatWrapping

let chars = {}
let characters = {}

let wall = new JunkPiece(new THREE.BoxGeometry(2, 2, 0.1), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [120,120,120])
wall.setPosition(0,0.8,2.5)
wall.pushable = false
scene.add(wall.mesh)
chars[wall.mesh.id] = wall
characters[wall.mesh.id] = wall

let wall2 = new JunkPiece(new THREE.BoxGeometry(1, 1, 0.1), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [120,120,120])
wall2.setPosition(0,0.8,-2.5)
wall.pushable = false
scene.add(wall2.mesh)
chars[wall2.mesh.id] = wall2
characters[wall2.mesh.id] = wall2

var char23491miehjf = new Character( new THREE.BoxGeometry( 0.08000000000000002,0.5499999999999997,0.08000000000000002 ), k [76,234,141], new THREE.MeshPhysicalMaterial( { color: '#ffffff', transparent: true, transmission: 0.5, reflectivity: 1, roughness: 0, clearcoat: 1.0, clearcoatRoughness: 0.1 }) )
char23491miehjf.mesh.position.set(0.2,1,-0.5)
char23491miehjf.mesh.rotation.set(0,0,0)
scene.add( char23491miehjf.mesh )
chars[char23491miehjf.mesh.id] = char23491miehjf
characters[char23491miehjf.mesh.id] = char23491miehjf

var char6dlf0kvj5bk = new Character( new THREE.BoxGeometry( 0.08000000000000002,0.5499999999999997,0.08000000000000002 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [21,116,100], new THREE.MeshPhysicalMaterial( { color: '#ffffff', transparent: true, transmission: 0.5, reflectivity: 1, roughness: 0, clearcoat: 1.0, clearcoatRoughness: 0.1 }) )
char6dlf0kvj5bk.mesh.position.set(0.11999999999999998,1,-0.5)
char6dlf0kvj5bk.mesh.rotation.set(0,0,0)
scene.add( char6dlf0kvj5bk.mesh )
chars[char6dlf0kvj5bk.mesh.id] = char6dlf0kvj5bk
characters[char6dlf0kvj5bk.mesh.id] = char6dlf0kvj5bk

var charemk64ptg2g6 = new Character( new THREE.BoxGeometry( 0.08000000000000002,0.5499999999999997,0.08000000000000002 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [208,51,118], new THREE.MeshPhysicalMaterial( { color: '#ffffff', transparent: true, transmission: 0.5, reflectivity: 1, roughness: 0, clearcoat: 1.0, clearcoatRoughness: 0.1 }) )
charemk64ptg2g6.mesh.position.set(-0.04000000000000005,1,-0.5)
charemk64ptg2g6.mesh.rotation.set(0,0,0)
scene.add( charemk64ptg2g6.mesh )
chars[charemk64ptg2g6.mesh.id] = charemk64ptg2g6
characters[charemk64ptg2g6.mesh.id] = charemk64ptg2g6

var charhqrbj6qyll = new Character( new THREE.BoxGeometry( 0.08000000000000002,0.5499999999999997,0.08000000000000002 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [61,243,107], new THREE.MeshPhysicalMaterial( { color: '#ffffff', transparent: true, transmission: 0.5, reflectivity: 1, roughness: 0, clearcoat: 1.0, clearcoatRoughness: 0.1 }) )
charhqrbj6qyll.mesh.position.set(-0.16000000000000015,1,-0.5)
charhqrbj6qyll.mesh.rotation.set(0,0,0)
scene.add( charhqrbj6qyll.mesh )
chars[charhqrbj6qyll.mesh.id] = charhqrbj6qyll
characters[charhqrbj6qyll.mesh.id] = charhqrbj6qyll

var charspsd61t1nrf = new Character( new THREE.BoxGeometry( 0.08000000000000002,0.5499999999999997,0.08000000000000002 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [55,170,168], new THREE.MeshStandardMaterial( { color: '#37aaa8', transparent: true }) )
charspsd61t1nrf.mesh.position.set(-0.27000000000000025,1,-0.5)
charspsd61t1nrf.mesh.rotation.set(0,0,0)
scene.add( charspsd61t1nrf.mesh )
chars[charspsd61t1nrf.mesh.id] = charspsd61t1nrf
characters[charspsd61t1nrf.mesh.id] = charspsd61t1nrf

var char6d65qt1pvt9 = new Character( new THREE.SphereGeometry( 0.1, 32, 32 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [255,255,255], new THREE.MeshStandardMaterial( { color: '#3cbc2e', transparent: true }) )
char6d65qt1pvt9.mesh.position.set(-0.00000000000000004,1,-0.5)
char6d65qt1pvt9.mesh.rotation.set(0,0,0)
scene.add( char6d65qt1pvt9.mesh )
chars[char6d65qt1pvt9.mesh.id] = char6d65qt1pvt9
characters[char6d65qt1pvt9.mesh.id] = char6d65qt1pvt9

var charsbpl14mlaw = new Character( new THREE.BoxGeometry( 0.5399999999999998,1.9100000000000006,0.5199999999999999 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [64,50,170], new THREE.MeshPhysicalMaterial( { color: '#ffffff', transparent: true, transmission: 0.9, reflectivity: 0.5, roughness: 0, clearcoat: 1.0, clearcoatRoughness: 0.4 }) )
charsbpl14mlaw.mesh.position.set(0,1.4,-2)
charsbpl14mlaw.mesh.rotation.set(0,0.2,0)
scene.add( charsbpl14mlaw.mesh )
chars[charsbpl14mlaw.mesh.id] = charsbpl14mlaw
characters[charsbpl14mlaw.mesh.id] = charsbpl14mlaw

var charps8qiin114 = new Character( new THREE.BoxGeometry( 0.1,1.5099999999999965,0.1 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [128,104,57], new THREE.MeshPhysicalMaterial( { color: '#ffffff', transparent: true, transmission: 0.9, reflectivity: 0.5, roughness: 0, clearcoat: 1.0, clearcoatRoughness: 0.4 }) )
charps8qiin114.mesh.position.set(0,0,0)
charps8qiin114.mesh.rotation.set(0,0.5,0)
scene.add( charps8qiin114.mesh )
chars[charps8qiin114.mesh.id] = charps8qiin114
characters[charps8qiin114.mesh.id] = charps8qiin114

var charpz9evj23her = new Character( new THREE.BoxGeometry( 0.1,1.5099999999999965,0.1 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [0,99,26], new THREE.MeshStandardMaterial( { color: '#00631a', transparent: true }) )
charpz9evj23her.mesh.position.set(0.36000000000000015,1.2,-0.03)
charpz9evj23her.mesh.rotation.set(0,-0.7,0)
scene.add( charpz9evj23her.mesh )
chars[charpz9evj23her.mesh.id] = charpz9evj23her
characters[charpz9evj23her.mesh.id] = charpz9evj23her

var charivk9xnmlmh = new Character( new THREE.BoxGeometry( 0.1,1.5099999999999965,0.1 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [115,25,18], new THREE.MeshStandardMaterial( { color: '#731912', transparent: true }) )
charivk9xnmlmh.mesh.position.set(0.36000000000000015,1.2,-0.5200000000000002)
charivk9xnmlmh.mesh.rotation.set(0,0.6,0)
scene.add( charivk9xnmlmh.mesh )
chars[charivk9xnmlmh.mesh.id] = charivk9xnmlmh
characters[charivk9xnmlmh.mesh.id] = charivk9xnmlmh

var charyqwybqd5wm = new Character( new THREE.BoxGeometry( 0.1,1.5099999999999965,0.1 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [190,38,142], new THREE.MeshStandardMaterial( { color: '#be268e', transparent: true }) )
charyqwybqd5wm.mesh.position.set(0.8100000000000005,1.2,-0.26)
charyqwybqd5wm.mesh.rotation.set(0,1.2,0)
scene.add( charyqwybqd5wm.mesh )
chars[charyqwybqd5wm.mesh.id] = charyqwybqd5wm
characters[charyqwybqd5wm.mesh.id] = charyqwybqd5wm

var char8nlhojct64c = new Character( new THREE.BoxGeometry( 0.1,1.5099999999999965,0.1 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [152,75,139], new THREE.MeshStandardMaterial( { color: '#984b8b', transparent: true }) )
char8nlhojct64c.mesh.position.set(0.05999999999999992,1.2,-0.29000000000000004)
char8nlhojct64c.mesh.rotation.set(0,0.4,0)
scene.add( char8nlhojct64c.mesh )
chars[char8nlhojct64c.mesh.id] = char8nlhojct64c
characters[char8nlhojct64c.mesh.id] = char8nlhojct64c

var charq9c90nqtfbc = new Character( new THREE.BoxGeometry( 0.1,1.5099999999999965,0.1 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [115,230,151], new THREE.MeshStandardMaterial( { color: '#73e697', transparent: true }) )
charq9c90nqtfbc.mesh.position.set(0.7000000000000004,1.2,-0.44000000000000017)
charq9c90nqtfbc.mesh.rotation.set(0.1,0.19999999999999998,0)
scene.add( charq9c90nqtfbc.mesh )
chars[charq9c90nqtfbc.mesh.id] = charq9c90nqtfbc
characters[charq9c90nqtfbc.mesh.id] = charq9c90nqtfbc

var charpfmmm449km9 = new Character( new THREE.BoxGeometry( 0.1,1.5099999999999965,0.1 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [102,165,128], new THREE.MeshStandardMaterial( { color: '#66a580', transparent: true }) )
charpfmmm449km9.mesh.position.set(0.5300000000000002,1.2,-0.6000000000000003)
charpfmmm449km9.mesh.rotation.set(0.1,0.4,0)
scene.add( charpfmmm449km9.mesh )
chars[charpfmmm449km9.mesh.id] = charpfmmm449km9
characters[charpfmmm449km9.mesh.id] = charpfmmm449km9

var charxw9srji3yj = new Character( new THREE.BoxGeometry( 0.1,1.5099999999999965,0.1 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [131,58,150], new THREE.MeshStandardMaterial( { color: '#833a96', transparent: true }) )
charxw9srji3yj.mesh.position.set(0.6300000000000003,1.2,-0.16999999999999993)
charxw9srji3yj.mesh.rotation.set(0,0.6,0)
scene.add( charxw9srji3yj.mesh )
chars[charxw9srji3yj.mesh.id] = charxw9srji3yj
characters[charxw9srji3yj.mesh.id] = charxw9srji3yj


// add a fuckin cube
Expand All @@ -197,7 +197,7 @@
scene.add( cube.mesh )
cube.routePoints = [[-0.2,1.1,-0.5],[-0.2,1.1,-0.3],[0.1,1.1,-0.3],[0.1,1.1,-0.5]]
// cube.routePoints = [[-0.2,1.2,-1],[-0.4,1.2,-1]]
chars[cube.mesh.id] = cube
characters[cube.mesh.id] = cube

return chars

Expand All @@ -212,10 +212,46 @@
scene.add( lightMarker.mesh )
scene.add( light )



let chars = {}
return chars
let characters = {}

var charkudnuoszbld = new Character( new THREE.BoxGeometry( 0.2800000000000002,0.13000000000000003,0.020000000000000018 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [7,114,108], new THREE.MeshStandardMaterial( { color: '#07726c', transparent: true }) )
// 0,2,-0.5
charkudnuoszbld.mesh.position.set(0,2,-0.5)
charkudnuoszbld.mesh.rotation.set(0,0,0)
scene.add( charkudnuoszbld.mesh )
characters[charkudnuoszbld.mesh.id] = charkudnuoszbld

var charb4ny0c9wylc = new Character( new THREE.BoxGeometry( 0.2800000000000002,0.13000000000000003,0.020000000000000018 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [245,250,152], new THREE.MeshStandardMaterial( { color: '#f5fa98', transparent: true }) )
charb4ny0c9wylc.mesh.position.set(0,2,-0.12)
charb4ny0c9wylc.mesh.rotation.set(0,0,0)
scene.add( charb4ny0c9wylc.mesh )
characters[charb4ny0c9wylc.mesh.id] = charb4ny0c9wylc

var charcd7zg8xwgm4 = new Character( new THREE.BoxGeometry( 0.3900000000000003,0.13000000000000003,0.020000000000000018 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [36,26,14], new THREE.MeshStandardMaterial( { color: '#241a0e', transparent: true }) )
charcd7zg8xwgm4.mesh.position.set(-0.13999999999999999,2,-0.31)
charcd7zg8xwgm4.mesh.rotation.set(0,-1.6000000000000003,0)
scene.add( charcd7zg8xwgm4.mesh )
characters[charcd7zg8xwgm4.mesh.id] = charcd7zg8xwgm4

var charppryxix4xbk = new Character( new THREE.BoxGeometry( 0.1,0.05000000000000002,0.1 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [214,148,169], new THREE.MeshStandardMaterial( { color: '#d694a9', transparent: true }) )
charppryxix4xbk.mesh.position.set(0.20000000000000004,1.95,-0.32)
charppryxix4xbk.mesh.rotation.set(0,0,0)
scene.add( charppryxix4xbk.mesh )
characters[charppryxix4xbk.mesh.id] = charppryxix4xbk

var chari78j236w8f = new Character( new THREE.BoxGeometry( 0.35000000000000026,0.010000000000000016,0.3000000000000002 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [186,159,93], new THREE.MeshStandardMaterial( { color: '#ba9f5d', transparent: true }) )
chari78j236w8f.mesh.position.set(-0.009999999999999997,2.12999999999999998,-0.2)
chari78j236w8f.mesh.rotation.set(0.7,0,0)
scene.add( chari78j236w8f.mesh )
characters[chari78j236w8f.mesh.id] = chari78j236w8f

var charju0qy20bv3 = new Character( new THREE.BoxGeometry( 0.36000000000000026,0.010000000000000016,0.3000000000000002 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [174,80,236], new THREE.MeshStandardMaterial( { color: '#ae50ec', transparent: true }) )
charju0qy20bv3.mesh.position.set(-0.019999999999999997,2.12999999999999998,-0.421)
charju0qy20bv3.mesh.rotation.set(-0.7,2.7755575615628914e-17,0)
scene.add( charju0qy20bv3.mesh )
characters[charju0qy20bv3.mesh.id] = charju0qy20bv3

return characters
}
}

Expand All @@ -236,7 +272,7 @@
textyMap.wrapS = THREE.RepeatWrapping
textyMap.wrapT = THREE.RepeatWrapping

floor = new JunkPiece(new THREE.BoxGeometry(1, 0.1, 1), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [255,255,255], new THREE.MeshPhysicalMaterial( { map: textyMap, transparent: true, transmission: 0, reflectivity: 1, roughness: 0.5, clearcoat: 1.0, clearcoatRoughness: 0.1 }) )
floor = new JunkPiece(new THREE.BoxGeometry(1.5, 0.1, 1.5), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [255,255,255], new THREE.MeshPhysicalMaterial( { map: textyMap, transparent: true, transmission: 0, reflectivity: 1, roughness: 0.5, clearcoat: 1.0, clearcoatRoughness: 0.1 }) )
floor.setPosition(0,FLOOR,0)
floor.pushable = false
scene.add(floor.mesh)
Expand All @@ -254,8 +290,10 @@
} else if(type == RELAXINGRAIN){

let sound = new Sound("/sounds/rain-Rclip.mp3", 1)
sound.mesh.position.set(0, 1.2,-1)
sound.mesh.position.set(0, 1.2,-0.7)
sound.routePoints = [ [0.1, 1.2,-0.7], [-0.1, 1.2,-0.7] ]
sounds[sound.mesh.id] = sound

}

return sounds
Expand Down Expand Up @@ -288,6 +326,7 @@
scene = new THREE.Scene()

place = createPlace(RELAXINGRAIN)
console.log( 'exist', place.sounds[util.k(place.sounds)[0]] )
place.sounds[util.k(place.sounds)[0]].play()

// scene.background = new THREE.Color( '#330203' );
Expand Down
1 change: 1 addition & 0 deletions places.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* this css intentionally left blank */
4 changes: 4 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ app.get('/', function(req, res, next){
res.header('Content-Type', 'text/html')
res.sendFile(path.join(__dirname, 'index.html'))
})
app.get('/places.css', function(req, res, next){
res.header('Content-Type', 'text/css')
res.sendFile(path.join(__dirname, 'places.css'))
})
app.get('/lib/three.module.js', function(req, res){
res.header('Content-Type', 'text/javascript')
res.sendFile(path.join(__dirname, 'lib', 'three.module.js'))
Expand Down

0 comments on commit c194bc5

Please sign in to comment.