three实现三维魔方旋转动画效果代码
代码语言:html
所属分类:三维
代码描述:three实现三维魔方旋转动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html, body { height: 100%; margin: 0; } #c { width: 100%; height: 100%; display: block; } </style> </head> <body> <canvas id="c"></canvas> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.125.js"></script> <script type="module" > function main() { const canvas = document.querySelector("#c"); const renderer = new THREE.WebGLRenderer({ canvas }); const fov = 75; const aspect = 2; // the canvas default const near = 0.1; const far = 5; const camera = new THREE.PerspectiveCamera(fov, aspect, near, far); camera.position.z = 2; const scene = new THREE.Scene(); const boxWidth = 1; const boxHeight = 1; const boxDepth = 1; const geometry = new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth); const fragmentShader = ` #include <common> uniform vec3 iResolution; uniform float iTime; uniform sampler2D iChannel0; // By Daedelus: https://www.shadertoy.com/user/Daedelus // license: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. #define TIMESCALE 0.25 #define TILES 8 #define COLOR 0..........完整代码请登录后点击上方下载按钮下载查看
网友评论0