WebGL Starfield PointCloud Test
How do I make an webgl starfield pointcloud test?
What is a webgl starfield pointcloud test? How do you make a webgl starfield pointcloud test? This script and codes were developed by Michaela on 27 July 2022, Wednesday.
WebGL Starfield PointCloud Test - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>WebGL Starfield PointCloud Test</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ html,
body,
#container { overflow: hidden; width: 100%; height: 100%;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div id="container"></div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/three.js/r70/three.min.js'></script>
<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/175711/THREE.OrbitControls.js'></script> <script src="js/index.js"></script>
</body>
</html>
WebGL Starfield PointCloud Test - Script Codes CSS Codes
html,
body,
#container { overflow: hidden; width: 100%; height: 100%;
}
WebGL Starfield PointCloud Test - Script Codes JS Codes
var axisHelper = {}, camera = {}, $container = {}, controls = {}, containerWidth = 0, containerHeight = 0, globalRenderID = {}, h = {}, particleSystem = {}, particleMaterials = [], particleMesh = {}, particleParameters = [], particleColor = {}, particleSize = 0, renderer = {}, scene = {};
function render () { var time = Date.now() * 0.00005; globalRenderID = requestAnimationFrame( render ); for ( i = 0; i < particleMaterials.length; i ++ ) { particleColor = particleParameters[ i ][ 0 ]; h = ( 360 * ( particleColor[ 0 ] + time ) % 360 ) / 360; particleMaterials[ i ].color.setHSL( h, particleColor[ 1 ], particleColor[ 2 ] ); } controls.update(); renderer.render( scene, camera );
}
function onWindowResize () { containerWidth = $container.innerWidth(); containerHeight = $container.innerHeight(); camera.aspect = containerWidth / containerHeight; camera.updateProjectionMatrix(); renderer.clear(); renderer.setSize( containerWidth, containerHeight );
}
THREE.ImageUtils.crossOrigin = '';
$container = $( '#container' );
containerWidth = $container.innerWidth();
containerHeight = $container.innerHeight();
renderer = new THREE.WebGLRenderer();
renderer.setSize( containerWidth, containerHeight );
renderer.antialias = true;
renderer.setClearColor( 0xffffff, 1 );
$container.get( 0 ).appendChild( renderer.domElement );
scene = new THREE.Scene();
axisHelper = new THREE.AxisHelper( 1000 );
camera = new THREE.PerspectiveCamera( 45, containerWidth / containerHeight, 1, 2000 );
camera.position.set( 0, 0, 1000 );
particleMesh = new THREE.Geometry();
for ( var i = 0, iMax = 50; i < iMax; i += 1 ) { var vertex = new THREE.Vector3(); vertex.x = Math.random() * 750 - 375; vertex.y = Math.random() * 750 - 375; vertex.z = Math.random() * 750 - 375; particleMesh.vertices.push( vertex );
}
particleParameters = [ [ [ 1, 1, 0.5 ], 50 ], [ [ 0.95, 1, 0.5 ], 40 ], [ [ 0.90, 1, 0.5 ], 30 ], [ [ 0.85, 1, 0.5 ], 20 ], [ [ 0.80, 1, 0.5 ], 10 ]
];
for ( i = 0; i < particleParameters.length; i ++ ) { particleColor = particleParameters[i][0]; particleSize = particleParameters[i][1]; particleMaterials[i] = new THREE.PointCloudMaterial( { map: THREE.ImageUtils.loadTexture( 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/26757/star.png' ), depthTest: false, transparent : true, size: particleSize } ); particleSystem = new THREE.PointCloud( particleMesh, particleMaterials[i] ); particleSystem.rotation.x = Math.random() * 6; particleSystem.rotation.y = Math.random() * 6; particleSystem.rotation.z = Math.random() * 6; controls = new THREE.OrbitControls( camera, $container.get( 0 ) ); controls.autoRotate = true; controls.autoRotateSpeed = 0.125; controls.noPan = true; controls.maxDistance = 800; controls.minDistance = 500; controls.zoomSpeed = 0.125; controls.rotateSpeed = 0.125; scene.add( particleSystem );
}
scene.add( camera, particleSystem );
window.addEventListener( 'resize', onWindowResize );
render();
onWindowResize();
console.log( particleSystem );
Developer | Michaela |
Username | Fischaela |
Uploaded | July 27, 2022 |
Rating | 3 |
Size | 3,098 Kb |
Views | 56,672 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Geildanke products | 5,250 Kb |
Projects geildanke with new animations | 6,186 Kb |
HTML5 game experiment with CreateJS | 4,135 Kb |
WebGL Game Endless Runner | 6,354 Kb |
IPad app prototype template | 2,396 Kb |
Animation tests | 2,748 Kb |
WebGL Template for ThreeJS | 2,713 Kb |
WebGL Wood with Sun Animation | 3,600 Kb |
Geildanke buttons | 3,154 Kb |
Animated progress bar | 3,495 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Sign Up Form | Sicontis | 5,272 Kb |
Animated Logo | Shakdaniel | 2,672 Kb |
Light Switch | Bartuc | 4,933 Kb |
CSS Social Media Icon | TychoBlender | 3,871 Kb |
Sass Radar | Jlong | 6,887 Kb |
Horizontal Navigation with Floats | Gymratpacks | 5,403 Kb |
Calculator - codevember 08 - 2016 | Caiocares | 3,260 Kb |
Zip Button test | Lje7462 | 1,932 Kb |
Responsive Boxes without Images | Andymcfee | 4,120 Kb |
Resizable SASS Icons | Marianarlt | 7,611 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!