three+gsap实现正方体下螺旋梯子动画效果代码
代码语言:html
所属分类:三维
代码描述:three+gsap实现正方体下螺旋梯子动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> canvas { display: block; width: 100%; height: 100vh; cursor: -webkit-grab; cursor: grab; } body { background: #222; } a { position: fixed; top: 0; left: 0; color: #eee; padding: 2rem; } </style> </head> <body > <script type="module"> import * as THREE from '//cdn.skypack.dev/three@0.132?min' import { OrbitControls } from '//cdn.skypack.dev/three@0.132/examples/jsm/controls/OrbitControls?min' import { gsap } from "https://cdn.skypack.dev/gsap@3.7.1?min"; // ---- // main // ---- const renderer = new THREE.WebGLRenderer({ antialias: true }); const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera(75, 2, .1, 100); const controls = new OrbitControls(camera, renderer.domElement); scene.background = new THREE.Color(0); camera.position.set(0, 1, -4); controls.enableDamping = true; renderer.shadowMap.enabled = true; const light0 = new THREE.DirectionalLight(); light0.castShadow = true; light0.position.set(1, 5, 1); light0.shadow.bias = -0.00002; scene.add(light0); scene.add(new THREE.AmbientLight(0xffffff, .5)); const nInst = 24; const geom = new THREE.BoxGeometry(3, .025, .5).translate(1.5 - .1, 0, 0); const mat = new THREE.MeshPhongMaterial({}); const stair = new THREE.InstancedMesh(geom, mat, nInst); stair.castShadow = true; stair.receiveShadow = true;.........完整代码请登录后点击上方下载按钮下载查看
网友评论0