1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
| <div id="div_canvas_1194" style="text-align:center;">
<script>
var camera, scene, renderer;
init();
initScene();
initLight();
initLensFlare();
animate();
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 75, 1, 1, 10000 );
camera.position.z = 1000;
scene.add( camera );
div_canvas = document.getElementById( 'div_canvas_1194' );
renderer = new THREE.WebGLRenderer();
renderer.setSize( 500, 500 );
renderer.setClearColorHex( 0x000000, 1 );
div_canvas.appendChild( renderer.domElement );
trackball = new THREE.TrackballControls( camera, renderer.domElement );
}
function initScene() {
material_green = new THREE.MeshLambertMaterial( { color: 0x00ff00, ambient: 0x00ff00, shading: THREE.FlatShading } );
material_red = new THREE.MeshLambertMaterial( { color: 0xff0000, ambient: 0xff0000, shading: THREE.FlatShading } );
material_blue = new THREE.MeshLambertMaterial( { color: 0x0000ff, ambient: 0x0000ff, shading: THREE.FlatShading } );
material_white = new THREE.MeshLambertMaterial( { color: 0xffffff, ambient: 0xffffff, shading: THREE.FlatShading } );
cubeGeometry = new THREE.CubeGeometry( 100, 100, 100 );
cubeMesh = new THREE.Mesh( cubeGeometry, material_green );
cubeMesh.position.y = 200;
scene.add( cubeMesh );
sphereGeometry = new THREE.SphereGeometry( 100, 16, 16 );
sphereMesh = new THREE.Mesh( sphereGeometry, material_red );
sphereMesh.position.x = -200;
sphereMesh.position.y = 200;
scene.add( sphereMesh );
octahedronGeometry = new THREE.OctahedronGeometry( 100, 2 );
octahedronMesh = new THREE.Mesh( octahedronGeometry, material_blue );
octahedronMesh.position.x = 200;
octahedronMesh.position.y = 200;
scene.add( octahedronMesh );
planeGeometry = new THREE.PlaneGeometry( 1000, 1000, 15, 15 );
planeMesh = new THREE.Mesh( planeGeometry, material_white );
planeMesh.position.y = -100;
planeMesh.rotation.x = -90 * 2 * Math.PI / 360;
scene.add( planeMesh );
}
function initLight()
{
point_light = new THREE.PointLight( 0xffffff, 1, 0 );
scene.add( point_light );
ambient_light = new THREE.AmbientLight( 0x444444 );
scene.add( ambient_light );
}
function initLensFlare()
{
texture_00 = THREE.ImageUtils.loadTexture( "http://www.soft-syokunin.com/wp-content/uploads/lens_flare00.png" );
texture_01 = THREE.ImageUtils.loadTexture( "http://www.soft-syokunin.com/wp-content/uploads/lens_flare01.png" );
texture_02 = THREE.ImageUtils.loadTexture( "http://www.soft-syokunin.com/wp-content/uploads/lens_flare02.png" );
lens_flare = new THREE.LensFlare( texture_02, 16, 0, THREE.AdditiveBlending, new THREE.Color( 0xffffff ) );
lens_flare.add( texture_02, 32, 0.2, THREE.AdditiveBlending, new THREE.Color( 0xffffff ), 0.3 );
lens_flare.add( texture_01, 32, 0.4, THREE.AdditiveBlending, new THREE.Color( 0xffffff ), 0.3 );
lens_flare.add( texture_02, 48, 0.5, THREE.AdditiveBlending, new THREE.Color( 0xffffff ), 0.2 );
lens_flare.add( texture_00, 64, 0.7, THREE.AdditiveBlending, new THREE.Color( 0xffffff ), 0.3 );
lens_flare.add( texture_00, 96, 1, THREE.AdditiveBlending, new THREE.Color( 0xffffff ), 0.4 );
scene.add( lens_flare );
}
function animate() {
// note: three.js includes requestAnimationFrame shim
requestAnimationFrame( animate );
render();
}
function render() {
trackball.update();
renderer.render( scene, camera );
}
</script>
</div> |