Skip to content

Commit

Permalink
✨ Add screens
Browse files Browse the repository at this point in the history
  • Loading branch information
brunosimon committed Sep 3, 2021
1 parent 40b5631 commit 0d073e6
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/Experience/Screen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import * as THREE from 'three'

import Experience from './Experience.js'

export default class Screen
{
constructor(_mesh, _sourcePath)
{
this.experience = new Experience()
this.resources = this.experience.resources
this.debug = this.experience.debug
this.scene = this.experience.scene
this.world = this.experience.world

this.mesh = _mesh
this.sourcePath = _sourcePath

this.setModel()
}

setModel()
{
this.model = {}

// Element
this.model.element = document.createElement('video')
this.model.element.muted = true
this.model.element.loop = true
this.model.element.controls = true
this.model.element.playsInline = true
this.model.element.autoplay = true
this.model.element.src = this.sourcePath
this.model.element.play()

// Texture
this.model.texture = new THREE.VideoTexture(this.model.element)
this.model.texture.encoding = THREE.sRGBEncoding

// Material
this.model.material = new THREE.MeshBasicMaterial({
map: this.model.texture
})

// Mesh
this.model.mesh = this.mesh
this.model.mesh.material = this.model.material
this.scene.add(this.model.mesh)
}

update()
{
// this.model.group.rotation.y = Math.sin(this.time.elapsed * 0.0005) * 0.5
}
}
14 changes: 14 additions & 0 deletions src/Experience/World.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import CoffeeSteam from './CoffeeSteam.js'
import TopChair from './TopChair.js'
import ElgatoLight from './ElgatoLight.js'
import BouncingLogo from './BouncingLogo.js'
import Screen from './Screen.js'

export default class World
{
Expand All @@ -28,6 +29,7 @@ export default class World
this.setTopChair()
this.setElgatoLight()
this.setBouncingLogo()
this.setScreens()
}
})
}
Expand Down Expand Up @@ -94,6 +96,18 @@ export default class World
this.bouncingLogo = new BouncingLogo()
}

setScreens()
{
this.pcScreen = new Screen(
this.resources.items.pcScreenModel.scene.children[0],
'/assets/videoPortfolio.mp4'
)
this.macScreen = new Screen(
this.resources.items.macScreenModel.scene.children[0],
'/assets/videoPortfolio.mp4'
)
}

resize()
{
}
Expand Down
4 changes: 4 additions & 0 deletions src/Experience/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export default [

{ name: 'threejsJourneyLogoTexture', source: '/assets/threejsJourneyLogo.png', type: 'texture' },

{ name: 'pcScreenModel', source: '/assets/pcScreenModel.glb', type: 'model' },

{ name: 'macScreenModel', source: '/assets/macScreenModel.glb', type: 'model' },

{ name: 'bakedTexture', source: '/assets/baked.jpg', type: 'texture' },
{ name: 'roomModel', source: '/assets/roomModel.glb' },
]
Expand Down
Binary file added static/assets/macScreenModel.glb
Binary file not shown.
Binary file added static/assets/pcScreenModel.glb
Binary file not shown.
Binary file modified static/assets/roomModel.glb
Binary file not shown.
Binary file added static/assets/videoPortfolio.mp4
Binary file not shown.

1 comment on commit 0d073e6

@vercel
Copy link

@vercel vercel bot commented on 0d073e6 Sep 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.