<OrbitControlsView camera={this.camera}>
<GLView
style={style}
onContextCreate={gl => this.onContextCreate(gl)}
/>
</OrbitControlsView>
async componentDidMount() {
const selected = {
type: 'obj',
name: 'BloodCell',
isometric: false,
model: require('./models/blood/BloodCell.obj'),
textures: [
{
name: 'axepCube3',
image: require('./models/blood/BloodCell_BaseColor.png')
}
]
}
this.model = await loadModel(selected)
this.setState({isLoading: false})
}
onContextCreate = async gl => {
try {
const {drawingBufferWidth: width, drawingBufferHeight: height} = gl
const sceneColor = 'transparent'
this.renderer = new Renderer({gl})
this.renderer.setSize(width, height)
this.camera = new PerspectiveCamera(75, width / height, 0.5, 1000)
this.camera.position.set(0, 0, 10)
this.scene = new Scene()
this.pointLight = new PointLight(0xffffff, 2, 1000, 1)
this.pointLight.position.set(0, 30, 100)
const hemisphereLight = new HemisphereLight(0xffffbb, 0x080820, 1)
this.scene.add(hemisphereLight)
const ambientLight = new AmbientLight(0x404040) // soft white light
this.scene.add(ambientLight)
// center pivot
const bbox = new Box3().setFromObject(this.model)
const center = new Vector3()
bbox.getCenter(center)
this.model.position.sub(center)
let models = []
this.scene.add(this.model)
models.push(this.model)
this.setState({camera: this.camera})
const render = () => {
this.timeout = requestAnimationFrame(render)
this.renderer.render(this.scene, this.camera)
gl.endFrameEXP()
}
render()
} catch (error) {
console.log('error', error)
}
}
Can anyone please help me, i am not able to fix this.