JSFiddle - React, Tailwind, and code Playground

by ysmood

HTML

<canvas class="scene"></canvas>

CoffeeScript

class Stage
	constructor: ->
		@init_scene()
		@make_meshes()

	init_scene: ->
		@scene = new THREE.Scene

		# Renderer
		width = window.innerWidth;
		height = window.innerHeight;
		@renderer = new THREE.WebGLRenderer({
			canvas: document.querySelector('.scene')
		})
		@renderer.setSize(width, height)

		# Camera
		@camera = new THREE.PerspectiveCamera(
			45,					# fov
			width / height,		# aspect
			1,					# near
			1000				# far
		)
		@camera.position.z = 200;
		@scene.add(@camera)

	make_meshes: ->
		size = 20
		@mesh = new THREE.Mesh(
			new THREE.CylinderGeometry(
				0, size, size
			),
			new THREE.MeshNormalMaterial()
		)
		@scene.add(@mesh)

		# I want the mesh's tip point to right, but it doesn't work.
		@mesh.lookAt(new THREE.Vector3(1, 0, 0))

	draw: =>
		@renderer.render(@scene, @camera)

stage = new Stage
stage.draw()