-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.custom..js
43 lines (31 loc) · 1.18 KB
/
app.custom..js
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
var scene = new THREE.Scene();
var W = window.innerWidth;
var H = window.innerHeight;
var renderer = new THREE.WebGLRenderer();
renderer.setClearColor(0x17293a);
renderer.setSize(W, H);
var camera = new THREE.PerspectiveCamera(40, W / H, 0.5, 100);
camera.position.set(0, 0, 30);
camera.lookAt(scene.position);
var flagImage = '/images/material.png';
var texture = new THREE.TextureLoader().load(flagImage);
var material = new THREE.MeshBasicMaterial({ map: texture, side: THREE.DoubleSide });
var geometry = new THREE.PlaneGeometry(15, 10, 32);
var plane = new THREE.Mesh(geometry, material);
scene.add(plane);
document.body.appendChild(renderer.domElement);
function renderScene() {
var center = new THREE.Vector2(0,0);
window.requestAnimationFrame(drawFrame);
var vLength = plance.geometry.vertices.length;
for (var i = 0; i < vLength; i++) {
var v = plane.geometry.vertices[i];
var dist = new THREE.Vector2(v.x, v.y).sub(center);
var size = 2.0;
var magnitude = 4;
v.z = Math.sin(dist.length() / -size + (ts / 900)) * magnitude;
}
plane.geometry.verticesNeedUpdate = true;
renderer.render(scene, camera);
}
renderScene();