JSDM

HTML

 
1

CSS

xxxxxxxxxx
10
 
1
* {
2
  margin: 0;
3
  padding: 0;
4
  outline: 0;
5
}
6
html, body {
7
  width: 100%;
8
  height: 100%;
9
  overflow: hidden;
10
}
? ?
? ?
必须是有效的URL
+ 添加另一个资源

JS

xxxxxxxxxx
95
 
1
var camera, scene, renderer,
2
    geometry, material, mesh;
3
 
4
init();
5
animate();
6
 
7
function init() {
8
    stats = new Stats();
9
    stats.setMode(0);
10
    stats.domElement.style.position = 'absolute';
11
    stats.domElement.style.left = '0px';
12
    stats.domElement.style.top = '0px';
13
    document.body.appendChild(stats.domElement);
14
15
    clock = new THREE.Clock();
16
17
    renderer = new THREE.WebGLRenderer();
18
    renderer.setSize( window.innerWidth, window.innerHeight );
19
20
    scene = new THREE.Scene();
21
 
22
    camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
23
    camera.position.z = 1000;
24
    scene.add( camera );
25
 
26
    geometry = new THREE.CubeGeometry( 200, 200, 200 );
27
    material = new THREE.MeshLambertMaterial( { color: 0xaa6666, wireframe: false } );
28
    mesh = new THREE.Mesh( geometry, material );
29
    //scene.add( mesh );
30
    cubeSineDriver = 0;
31
 
32
    textGeo = new THREE.PlaneGeometry(300,300);
33
    THREE.ImageUtils.crossOrigin = ''; //Need this to pull in crossdomain images from AWS
34
    textTexture = THREE.ImageUtils.loadTexture('https://s3-us-west-2.amazonaws.com/s.cdpn.io/95637/quickText.png');
35
    textMaterial = new THREE.MeshLambertMaterial({color: 0x00ffff, opacity: 1, map: textTexture, transparent: true, blending: THREE.AdditiveBlending})
36
    text = new THREE.Mesh(textGeo,textMaterial);
37
    text.position.z = 800;
38
    scene.add(text);
39
40
    light = new THREE.DirectionalLight(0xffffff,0.5);
41
    light.position.set(-1,0,1);
42
    scene.add(light);
43
  
44
    smokeTexture = THREE.ImageUtils.loadTexture('https://s3-us-west-2.amazonaws.com/s.cdpn.io/95637/Smoke-Element.png');
45
    smokeMaterial = new THREE.MeshLambertMaterial({color: 0x00dddd, map: smokeTexture, transparent: true});
46
    smokeGeo = new THREE.PlaneGeometry(300,300);
47
    smokeParticles = [];
48
49
50
    for (p = 0; p < 150; p++) {
51
        var particle = new THREE.Mesh(smokeGeo,smokeMaterial);
52
        particle.position.set(Math.random()*500-250,Math.random()*500-250,Math.random()*1000-100);
53
        particle.rotation.z = Math.random() * 360;
54
        scene.add(particle);
55
        smokeParticles.push(particle);
56
    }
57
 
58
    document.body.appendChild( renderer.domElement );
59
 
60
}
61
 
62
function animate() {
63
 
64
    // note: three.js includes requestAnimationFrame shim
65
    stats.begin();
66
    delta = clock.getDelta();
67
    requestAnimationFrame( animate );
68
    evolveSmoke();
69
    render();
70
    stats.end();
71
}
72
 
73
function evolveSmoke() {
74
    var sp = smokeParticles.length;
75
    while(sp--) {
76
        smokeParticles[sp].rotation.z += (delta * 0.2);
77
    }
78
}
79
80
function render() {
81
 
82
    mesh.rotation.x += 0.005;
83
    mesh.rotation.y += 0.01;
84
    cubeSineDriver += .01;
85
    mesh.position.z = 100 + (Math.sin(cubeSineDriver) * 500);
86
    renderer.render( scene, camera );
87
 
88
}
89
90
91
92
93
94
95
必须是有效的URL
请输入有效的URL
+ 添加另一个资源
Close

文件管理 点击文件查看URL

图片

  1. 暂无文件

CSS

  1. 暂无文件

JavaScript

  1. 暂无文件

其他

  1. 暂无文件
拖动文件到上面的区域或者:
加载中 ..................