Jsfiddle Help WebGL function Quest
The beautiful Life of the Sun Vulcan (http://blog.csdn.net/opengl_es)
This article follows "Attribution-non-commercial use-consistent" authoring public agreement
Reprint Please keep this sentence: Sun Vulcan's Beautiful Life-this blog focuses on Agile development and mobile and IoT device research: IOS, Android, HTML5, Arduino, Pcduino , Otherwise, the article from this blog refused to reprint or re-reproduced, thank you for your cooperation.
The following example can produce a shadow projection of the basic geometry, there is another piece of code that cannot be projected, and the code that can be projected by this part is not much different, but it is not always the law, need to check further, to know the specific differences in where, which key parts of the role of shadow projection.
Or calm down, and make clear every line of code, this is the shortest way!
Often the pursuit of short-cut results, is the elephant, and finally, the more you feel the more outrageous, even the original unconscious world did not.
So the Buddha warned us to pursue the truth, like a child.
In fact, is to remove delusion and speculation, realistically according to the matter of the face to consider the problem, it will not be the wrong side of guessing things affect your mood, even deviate from the right way, produce trouble.
In the spread of a message, the general meaning is, as long as you think, you will go unknowingly to do, do it will produce effects, the effect lasts for a long time, will become a habit, more accustomed to form a character, and character determines the fate.
So, to change, start with the idea.
This is not an idealist theory, sometimes feeling, pure materialism, often let people neglect and people's thinking and subconscious changes in the physical world.
The reason why human beings are distinguished from animals is that human beings can change their own world by thinking, and of course, this state is one of the many choices inherent in the physical world, but at least it can be chosen.
If we do not control, it will become a random choice, the state of the physical world is good and bad, the results of random selection can be imagined, completely bad state may not have no.
To sum up, the human advanced, is to be able to think through the action, ultimately change the default selection, and preferred to choose the advantageous option.
http://jsfiddle.net/4Txgp/13/embedded
var screen_width = Window.innerwidth-100;var Screen_height = Window.innerheight-100;var camera, Scene;var CanvasRender Er, Webglrenderer;var container, mesh, geometry, plane;var windowhalfx = Window.innerwidth/2;var Windowhalfy = window.in Nerheight/2;init (); animate (); function init () {container = document.createelement (' div '); Document.body.appendChild (container); Camera = new three. Perspectivecamera (Window.innerwidth/window.innerheight, 1, 100000); camera.position.x = 1200; CAMERA.POSITION.Y = 1000; Camera.lookat ({x:0, y:0, z:0}); Scene = new three. Scene (); var groundmaterial = new three. Meshphongmaterial ({color:0x6c6c6c}); Plane = new three. Mesh (new three. Planegeometry (a), groundmaterial); plane.rotation.x =-MATH.PI/2; Plane.receiveshadow = true; Scene.add (plane); LIGHTS Scene.add (new three. Ambientlight (0x666666)); var light; Light = new three. DirectionalLight (0xdfeBFF, 1.75); Light.position.set (300, 400, 50); Light.position.multiplyScalar (1.3); Light.castshadow = true; Light.shadowcameravisible = true; Light.shadowmapwidth = 512; Light.shadowmapheight = 512; var d = 200; Light.shadowcameraleft =-D; Light.shadowcameraright = D; Light.shadowcameratop = D; Light.shadowcamerabottom =-D; Light.shadowcamerafar = 1000; light.shadowdarkness = 0.2; Scene.add (light); var boxgeometry = new three. Cubegeometry (100, 100, 100); var boxmaterial = new three. Meshlambertmaterial ({COLOR:0X0AEEDF}); var cube = new three. Mesh (Boxgeometry, boxmaterial); Cube.castshadow = true; cube.position.x = 0; CUBE.POSITION.Y = 100; cube.position.z = 0; Scene.add (Cube); RENDERER webglrenderer = new three. Webglrenderer (); Webglrenderer.setsize (Screen_width, screen_height); WebglRenderer.domElement.style.position = "relative"; Webglrenderer.shadowmapenabled = true; Webglrenderer. Shadowmapsoft = true; Container.appendchild (webglrenderer.domelement); Window.addeventlistener (' Resize ', onwindowresize, false);} function Onwindowresize () {windowhalfx = WINDOW.INNERWIDTH/2; Windowhalfy = WINDOW.INNERHEIGHT/2; Camera.aspect = Window.innerwidth/window.innerheight; Camera.updateprojectionmatrix (); Webglrenderer.setsize (Window.innerwidth, window.innerheight);} function animate () {var timer = Date.now () * 0.0002; camera.position.x = Math.Cos (timer) * 1000; CAMERA.POSITION.Z = Math.sin (timer) * 1000; Requestanimationframe (animate); Render ();} function render () {Camera.lookat (scene.position); Webglrenderer.render (scene, camera);}