Skip to content

Commit

Permalink
'desklamp and door'
Browse files Browse the repository at this point in the history
  • Loading branch information
foglabs committed Feb 15, 2021
1 parent 7c08ea0 commit eee2e52
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 56 deletions.
143 changes: 87 additions & 56 deletions lib/RelaxingRain.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,28 @@ class RelaxingRain extends Place {


// dfeault 0.018
var spotlight = new THREE.SpotLight("#0000bb", 0.018)
var spotlight = new THREE.SpotLight("#0000bb", 0.008)
spotlight.castShadow = true
spotlight.shadow.mapSize.width = 1024*4
spotlight.shadow.mapSize.height = 1024*4
spotlight.position.set(-0.6600000000000004,2,-1.0300000000000002)
spotlight.lookAt(0,1.2,-0.3499999999999999)

// light.shadow.mapSize.width = 512; // default
// light.shadow.mapSize.height = 512; // default
// spotlight.position.set(-0.6600000000000004,2,-1.0300000000000002)
// spotlight.lookAt(0,1.2,-0.3499999999999999)
spotlight.position.set(-1, 1.8, -0.75)
spotlight.lookAt(0,-2,0)
spotlight.shadow.camera.near = 0.5; // default
spotlight.shadow.camera.far = 30; // default
spotlight.shadow.focus = 1; // default

scene.add(spotlight)

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


// var lighter = new THREE.HemisphereLight("#ffffff", "#000000", 0.006)
// scene.add(lighter)

Expand All @@ -72,7 +79,18 @@ 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 }) )


let doorMap = textureLoader.load('/textures/door.png')
doorMap.wrapS = THREE.RepeatWrapping
doorMap.wrapT = THREE.RepeatWrapping
doorMap.repeat.set(1,1)
let doorBump = textureLoader.load('/textures/doorB.png')
doorBump.wrapS = THREE.RepeatWrapping
doorBump.wrapT = THREE.RepeatWrapping
doorBump.repeat.set(1,1)

var door = new Character( new THREE.BoxGeometry( 0.02,0.8,0.3 ), new THREE.Box3(new THREE.Vector3(), new THREE.Vector3()), [255,255,255], new THREE.MeshPhysicalMaterial( { map: doorMap, bumpScale: 0.01, bumpMap: doorBump }) )
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
Expand All @@ -83,44 +101,18 @@ class RelaxingRain extends Place {
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.position.set(-0.85,1.262,-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 @@ -339,26 +331,61 @@ class RelaxingRain extends Place {
this.thunderTimer = new Timer()
this.thunderTimer.start()



this.loadModel('/models/desklamp.glb', (model) => {

// we'll ref the model through tis inside MusicPlayer
this.models['/models/desklamp.glb'] = model

let bbox = new THREE.Box3(new THREE.Vector3(), new THREE.Vector3())
this.desklamp = new Character(null, bbox, [255,255,255], null, null, null, this.models["/models/desklamp.glb"] )
this.desklamp.pushable = false
this.desklamp.grabbable = false
this.desklamp.move(desklight.position.x,desklight.position.y,desklight.position.z)

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

this.characters[this.desklamp.mesh.id] = this.desklamp

scene.add( this.desklamp.mesh )
})

// let starColor = "#dddd22"
let starColor = [221,221,34]
this.stars = []

// // stars
let starsGeo, star
// reused for rain
let x,y,z
starsGeo = new THREE.Geometry();
for(let i=0;i<1000;i++) {
x = Math.random() * 200 - 100
y = Math.random() * 200 - 100
z = Math.random() * 200 - 100

star = new THREE.Vector3( x,y,z )
starsGeo.vertices.push(star);
}
for(var q=0; q<10; q++){

let starsMaterial = new THREE.PointsMaterial({
color: "#dddd22",
size: 0.03
// size: 0.02,
})
this.stars = new THREE.Points(starsGeo,starsMaterial)
scene.add(this.stars)
starsGeo = new THREE.Geometry();
for(let i=0;i<1000;i++) {
x = Math.random() * 200 - 100
y = Math.random() * 200 - 100
z = Math.random() * 200 - 100

star = new THREE.Vector3( x,y,z )
starsGeo.vertices.push(star);
}
let starsMaterial = new THREE.PointsMaterial({
color: util.rgbToHex(starColor[0],starColor[1],starColor[2]),
size: 0.03
// size: 0.02,
})
let thisRain = new THREE.Points(starsGeo,starsMaterial)
this.stars.push( thisRain )
scene.add( thisRain )

// vary next star set
starColor[0] = starColor[0] + Math.random() * 20 - 10
starColor[1] = starColor[1] + Math.random() * 20 - 10
starColor[2] = starColor[2] + Math.random() * 20 - 10
}

// rain baby
let rainGeo, rainDrop
Expand Down Expand Up @@ -568,9 +595,9 @@ class RelaxingRain extends Place {

// now actually use them here:
let depth, lat
for(var i=0; i<10; i++){
for(var i=0; i<5; i++){
depth = 0.4 + Math.random()/6
lat = i/6 - 0.8
lat = i/4 - 0.4
if(Math.random() < 0.33 ){
// ensure that its loaded, then make it
this.createPlant(this.models['/models/pottedplant.glb'].clone(), new THREE.Vector3(lat,1,depth), 0.06 )
Expand All @@ -581,9 +608,9 @@ class RelaxingRain extends Place {
}
}

for(var i=0; i<6; i++){
for(var i=0; i<3; i++){
depth = 0.4 + Math.random()/6
lat = i/6 - 0.8
lat = i/5 - 0.8
if(Math.random() < 0.33 ){
// ensure that its loaded, then make it
this.createPlant(this.models['/models/pottedplant.glb'].clone(), new THREE.Vector3(depth,1,lat), 0.06 )
Expand Down Expand Up @@ -749,7 +776,11 @@ class RelaxingRain extends Place {

if(this.stars){
// slowly rotate the star field, just like mom used to make!
this.stars.rotation.x += 0.00001
// this.stars.rotation0.x += 0.00001

for(var i=0; i<this.stars.length; i++){
this.stars[i].rotation.x += 0.00001
}
}

this.clouds.forEach(p => {
Expand Down
Binary file added models/desklamp.glb
Binary file not shown.
Binary file added textures/door.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 added textures/doorB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit eee2e52

Please sign in to comment.