I've developed a 3D lamp model in blender and loaded it on to a web using three.js
.
The model is pretty basic, but what matters to me is that I would like somebody to give me an idea of how produce a light in three.js
that should give the illusion of coming from inside the lamp, because you can find lots of examples of how to light an object from far away but what about of emitting the light from one side of an object (and specifically a model) like this lamp scenario.
Please understand that I'm not being lazy, is just that the three.js
documentation is so limited and I haven't been able to find an example or an explanation specific to my need.
This is the code that I have so far which loads the model:
<!DOCTYPE html>
<html>
<head>
<title>example 1: load model</title>
<script type="text/javascript" src="js/three.js"></script>
<script src="js/TrackballControls.js"></script>
<script type="text/javascript">
var controls;
var init = function() {
var canv = document.getElementsByTagName("canvas")[0];
var w = canv.clientWidth;
var h = canv.clientHeight;
var renderer = new THREE.WebGLRenderer({canvas:canv, antialias: true});
renderer.setSize( w, h );
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
40, // Field of view
w / h, // Aspect ratio
5, // Near
10000 // Far
);
camera.position.set( -10, 7, 10 );
camera.lookAt(scene.position);
// CONTROLS
controls = new THREE.TrackballControls( camera );
light = new THREE.PointLight( 0xFFFFDD );
light.position.set( -15, 10, 15 );
scene.add( light );
var loader = new THREE.JSONLoader( );
var onGeometry = function(geom, mats) {
var mesh = new THREE.Mesh( geom, new THREE.MeshFaceMaterial( mats ) );
scene.add(mesh);
};
loader.load("models/lamp.js", onGeometry);
var render = function() {
renderer.render(scene, camera);
controls.update();
};
setInterval(render,10);
};
window.onload = init;
window.onresize = init;
</script>
</head>
<body><canvas style="width:100%;height:95%;border:1px gray solid;"></body>
</html>