
Frontend Forever App
We have a mobile app for you to download and use. And you can unlock many features in the app.
Get it nowIntall Later
We have a mobile app for you to download and use. And you can unlock many features in the app.
Get it nowHello reader, I am TomHinton. Nice to meet you again in this free code sharing website. In this post I am going to explain about #mathober2024. If you are new to this website, we recommend you to subscribe to our youtube channel and watch the videos. Ok lets dive into the code.
These are the output images of the code. You can click on the image to enlarge it. also you can click the try it button to see the output.
If you are a visual learner and want to learn how to use this code, you can watch the video below.
and also this video contains the clear step by step explanation and the output of the code.
This is the source code of the code. You can copy and paste the code to your editor.
xxxxxxxxxx
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="shader"></div>
<script id="vertex" type="x-shader/x-vertex">
varying vec2 vUv;
uniform float uTime;
attribute vec3 position2;
varying vec3 pos;
uniform float u_progress;
void coswarp(inout vec3 trip, float warpsScale ){
trip.xyz += warpsScale * .1 * cos(3. * trip.yzx + (uTime * .015));
trip.xyz += warpsScale * .05 * cos(11. * trip.yzx + (uTime * .015));
trip.xyz += warpsScale * .025 * cos(17. * trip.yzx + (uTime * .015));
}
void main(){
vec4 modelPosition = modelMatrix * vec4(position, 1.);
modelPosition.x += sin(uTime +modelPosition.y) *5.;
vec4 modelPosition2 = modelMatrix * vec4(position, 1.);
vec4 viewPosition = viewMatrix * modelPosition;
vec4 projectionPosition = projectionMatrix * viewPosition;
xxxxxxxxxx
@charset "UTF-8";
@import url(https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,600,700,800);
*,
:after,
:before {
box-sizing: border-box;
padding: 0;
margin: 0;
}
* {
margin: 0px;
cursor: pointer;
}
xxxxxxxxxx
material.uniforms.uResolution.value.y = renderer.domElement.height;
console.log("Event Fired")
import * as THREE from "https://cdn.skypack.dev/three@0.149.0";
let camera, scene, renderer, clock, points;
let uniforms;
let sphere = new THREE.SphereGeometry(7, 50, 50);
function init() {
const container = document.getElementById("shader");
clock = new THREE.Clock();
scene = new THREE.Scene();
uniforms = {
uTime: { type: "f", value: 1.0 },
uResolution: { type: "v2", value: new THREE.Vector2() },
u_progress: {
value: 0
},
uMouse: {
value: { x: 0.5, y: 0.5 }
}
};
const material = new THREE.ShaderMaterial({
uniforms,
vertexShader: document.getElementById("vertex").textContent,
fragmentShader: document.getElementById("fragment").textContent
});
material.transparent = true;
material.depthWrite = false;
const pointsGeometry = new THREE.BufferGeometry();
pointsGeometry.setAttribute(
"position",
new THREE.BufferAttribute(sphere.attributes.position.array, 3)
);
renderer = new THREE.WebGLRenderer();
And also you can click the try it button to see the output of the code in our web Code Playground.
You can also download the code to the zip format by clicking the download button. The download process is little bit complex, you need ti await for 10 seconds. after that you can download the code by clicking the generated download link.
Leave a Comment
You need to login first to comment.