-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- First version of the WebGLRenderer (ColorFillMaterial and FaceColor…
…FillMaterial by now) - Matrix4.lookAt fix (CanvasRenderer and SVGRenderer now handle the -Y) - Color class now using 0-1 floats instead of 0-255 integers
- Loading branch information
Showing
17 changed files
with
555 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<!DOCTYPE HTML> | ||
<html lang="en"> | ||
<head> | ||
<title>three.js - particles - floor</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/> | ||
<style type="text/css"> | ||
body { | ||
background-color: #000000; | ||
margin: 0px; | ||
overflow: hidden; | ||
} | ||
|
||
a { | ||
color:#0078ff; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<script type="text/javascript" src="../build/three.js"></script> | ||
|
||
<script type="text/javascript"> | ||
|
||
var SCREEN_WIDTH = window.innerWidth, | ||
SCREEN_HEIGHT = window.innerHeight, | ||
|
||
mouseX = 0, mouseY = 0, | ||
|
||
windowHalfX = window.innerWidth / 2, | ||
windowHalfY = window.innerHeight / 2, | ||
|
||
SEPARATION = 200, | ||
AMOUNTX = 10, | ||
AMOUNTY = 10, | ||
|
||
camera, scene, renderer, | ||
|
||
stats; | ||
|
||
init(); | ||
setInterval(loop, 1000 / 60); | ||
|
||
function init() { | ||
|
||
var container, separation = 100, amountX = 50, amountY = 50, | ||
particles, particle, material; | ||
|
||
container = document.createElement('div'); | ||
document.body.appendChild(container); | ||
|
||
camera = new THREE.Camera( 75, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 10000 ); | ||
camera.position.z = 1000; | ||
|
||
scene = new THREE.Scene(); | ||
|
||
renderer = new THREE.CanvasRenderer(); | ||
renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT); | ||
container.appendChild(renderer.domElement); | ||
|
||
// floor | ||
|
||
material = new THREE.ColorFillMaterial(0xffffff, 1); | ||
|
||
for (var i = 0; i < 1000; i++) { | ||
|
||
particle = new THREE.Particle( material ); | ||
particle.position.x = Math.random() * 2 - 1; | ||
particle.position.y = Math.random() * 2 - 1; | ||
particle.position.z = Math.random() * 2 - 1; | ||
particle.position.normalize(); | ||
particle.position.multiplyScalar(Math.random() * 10 + 450); | ||
scene.add( particle ); | ||
|
||
} | ||
|
||
// lines | ||
|
||
for (var i = 0; i < 300; i++) { | ||
|
||
var geometry = new THREE.Geometry(); | ||
|
||
var vector = new THREE.Vector3(Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1); | ||
vector.normalize(); | ||
vector.multiplyScalar(450); | ||
|
||
geometry.vertices.push(new THREE.Vertex(vector)); | ||
|
||
var vector2 = vector.clone(); | ||
vector2.multiplyScalar(Math.random() * 0.3 + 1); | ||
|
||
geometry.vertices.push(new THREE.Vertex(vector2)); | ||
|
||
var line = new THREE.Line(geometry, new THREE.ColorStrokeMaterial(1, 0xffffff, Math.random())); | ||
scene.add(line); | ||
} | ||
|
||
/* | ||
stats = new Stats(); | ||
stats.domElement.style.position = 'absolute'; | ||
stats.domElement.style.top = '0px'; | ||
container.appendChild(stats.domElement); | ||
*/ | ||
|
||
document.addEventListener('mousemove', onDocumentMouseMove, false); | ||
document.addEventListener('touchstart', onDocumentTouchStart, false); | ||
document.addEventListener('touchmove', onDocumentTouchMove, false); | ||
} | ||
|
||
// | ||
|
||
function onDocumentMouseMove(event) { | ||
|
||
mouseX = event.clientX - windowHalfX; | ||
mouseY = event.clientY - windowHalfY; | ||
} | ||
|
||
function onDocumentTouchStart( event ) { | ||
|
||
if(event.touches.length > 1) { | ||
|
||
event.preventDefault(); | ||
|
||
mouseX = event.touches[0].pageX - windowHalfX; | ||
mouseY = event.touches[0].pageY - windowHalfY; | ||
} | ||
} | ||
|
||
function onDocumentTouchMove( event ) { | ||
|
||
if(event.touches.length == 1) { | ||
|
||
event.preventDefault(); | ||
|
||
mouseX = event.touches[0].pageX - windowHalfX; | ||
mouseY = event.touches[0].pageY - windowHalfY; | ||
} | ||
} | ||
|
||
// | ||
|
||
function loop() { | ||
|
||
camera.position.x += (mouseX - camera.position.x) * .05; | ||
camera.position.y += (-mouseY + 200 - camera.position.y) * .05; | ||
camera.updateMatrix(); | ||
|
||
renderer.render(scene, camera); | ||
|
||
// stats.update(); | ||
} | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.