import * as THREE from 'three'
export default class ViewPort{
constructor(container,config){
this.container = container
this.config = config
this.devicePix = window.devicePixelRatio
return this.initScene()
}
initScene(){
const scene = new THREE.Scene()
const camera = new THREE.PerspectiveCamera(
60,
this.container.clientWidth / this.container.clientHeight,
0.1,
1000
)
camera.position.copy(this.config.cameraPosition)
scene.add(camera)
const renderer = new THREE.WebGL1Renderer({
alpha:true,
antialias:true
})
renderer.setSize(this.container.clientWidth, this.container.clientHeight)
renderer.setPixelRatio(this.devicePix)
this.container.appendChild(renderer.domElement)
function render(){
window.requestAnimationFrame(render)
renderer.render(scene, camera)
}
render()
const axes = new THREE.AxesHelper(5)
scene.add(axes)
const orbitControls = new OrbitControls(camera, renderer.domElement)
scene.add(orbitControls)
return scene
}
}