WebGL Starfield PointCloud Test

Developer
Size
3,098 Kb
Views
56,672

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 Previews

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 );
WebGL Starfield PointCloud Test - Script Codes
WebGL Starfield PointCloud Test - Script Codes
Home Page Home
Developer Michaela
Username Fischaela
Uploaded July 27, 2022
Rating 3
Size 3,098 Kb
Views 56,672
Do you need developer help for WebGL Starfield PointCloud Test?

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!

Michaela (Fischaela) Script Codes
Create amazing marketing copy with AI!

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!