Sphere detail
How do I make an sphere detail?
What is a sphere detail? How do you make a sphere detail? This script and codes were developed by Darby Rathbone on 03 October 2022, Monday.
Sphere detail - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>sphere detail</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> sphere Detail
<input type="range" id='sphereDetail' name="points" min="2" max="200" value='5' style="width:300px;position:fixed;z-index:1;"></input> <script src="js/index.js"></script>
</body>
</html>
Sphere detail - Script Codes CSS Codes
canvas { position:fixed;
}
Sphere detail - Script Codes JS Codes
function Point3d(a, c, b) { this.x = (a === undefined) ? 0 : a; this.y = (c === undefined) ? 0 : c; this.z = (b === undefined) ? 0 : b; this.fl = 400; this.vpX = 0; this.vpY = 0; this.cX = 0; this.cY = 0; this.cZ = 0
}
Point3d.prototype = { setVanishingPoint: function (b, a) { this.vpX = b; this.vpY = a }, setCenter: function (c, b, a) { this.cX = c; this.cY = b; this.cZ = a }, rotateX: function (a) { var d = Math.cos(a), b = Math.sin(a), c = this.y * d - this.z * b, e = this.z * d + this.y * b; this.y = c; this.z = e; return this }, rotateY: function (a) { var d = Math.cos(a), c = Math.sin(a), b = this.x * d - this.z * c, e = this.z * d + this.x * c; this.x = b; this.z = e; return this }, rotateZ: function (a) { var d = Math.cos(a), b = Math.sin(a), c = this.x * d - this.y * b, e = this.y * d + this.x * b; this.x = c; this.y = e; return this }, getScreenX: function () { var a = this.fl / (this.fl + this.z + this.cZ); return this.vpX + (this.cX + this.x) * a }, getScreenY: function () { var a = this.fl / (this.fl + this.z + this.cZ); return this.vpY + (this.cY + this.y) * a }
};
var points = [];
var sd = document.getElementById('sphereDetail');
/*//////////////////////////////////////////////////////////////////*/
///*this is where it calculates all of the point information*////
/*//////////////////////////////////////////////////////////////////*/
function makepoints() { var sphereDetail = sd.value; points = []; points.push(new Point3d(0, 0, -1)); var change = Math.PI / sphereDetail; for (var j = 0; j < sphereDetail; j++) { for (var i = 0; i < sphereDetail; i++) { points.push(new Point3d(Math.sin(change * j) * Math.cos((2 * i * Math.PI / sphereDetail) + (j * Math.PI / sphereDetail)), Math.sin(change * j) * Math.sin((2 * i * Math.PI / sphereDetail) + (j * Math.PI / sphereDetail)), Math.cos(change * j))); } } points.push(new Point3d(0, 0, 1)); points = points.map(function (e) { return new Point3d(e.x * 400, e.y * 400, e.z * 400) });
}
/*//////////////////////////////////////////////////////////////////*/
///*ends here*////
/*//////////////////////////////////////////////////////////////////*/
sd.addEventListener('change', makepoints);
sd.addEventListener('mousedown', function () { makepoints(); sd.addEventListener('mousemove', makepoints); sd.addEventListener('mouseup', function () { sd.removeEventListener('mousemove', makepoints); sd.removeEventListener('mouseup', makepoints); makepoints(); });
});
function displaypoints(b) { context.fillRect(b.getScreenX(), b.getScreenY(), 3, 3);
}
var can = document.createElement("canvas");
can.width = 500;
can.height = 500;
var context = can.getContext("2d");
document.body.appendChild(can);
var mousex = 250, mousey = 250;
function displayer() { context.clearRect(0, 0, can.width, can.height); points.forEach(function (a) { a.rotateX((mousey - a.vpY) * 0.0001).rotateY((mousex - a.vpX) * 0.0001); a.setVanishingPoint(250, 250); a.setCenter(a.x, a.y, 1000) }); points.forEach(displaypoints); requestAnimationFrame(displayer);
}
requestAnimationFrame(displayer);
document.body.onmousemove = function (a) { mousex = a.pageX; mousey = a.pageY
};
makepoints();
Developer | Darby Rathbone |
Username | blackkbot |
Uploaded | October 03, 2022 |
Rating | 3 |
Size | 2,558 Kb |
Views | 30,360 |
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 |
3d pure javascript 2d canvas | 2,667 Kb |
3d hand | 18,673 Kb |
Graphing equations | 3,529 Kb |
Pendulum | 3,104 Kb |
Ball physics | 3,874 Kb |
Slow Delaunay triangulation | 3,316 Kb |
JQuery Number Counter Plugin | 3,195 Kb |
Java style console | 2,381 Kb |
Webworker with an editable textbox | 3,525 Kb |
Balls | 3,920 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 |
A Pen by Michael Parenteau | Michaelparenteau | 2,133 Kb |
Menubar compass mixin | Michaelparenteau | 4,925 Kb |
IbrahimJabbari-Effect21 | Ibrahimjabbari | 1,882 Kb |
A Pen by Anoop | Anoopjohn | 330,760 Kb |
P5.js data visualization | Enginarslan | 2,233 Kb |
Button shaking | SusanneLundblad | 2,227 Kb |
Weather App 2 | MightyJoeW | 2,877 Kb |
Off Canvas | Mariamarica | 1,870 Kb |
JavaScript Animation | Rcmeisty | 4,581 Kb |
CSS Chat Bubbles | Boylett | 2,094 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!