three实现三维牛顿摆动画效果代码
代码语言:html
所属分类:三维
代码描述:three实现三维牛顿摆动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body{ overflow: hidden; margin: 0; } </style> </head> <body> <script type="module"> import * as THREE from "https://cdn.skypack.dev/three@0.136.0"; import { OrbitControls } from "https://cdn.skypack.dev/three@0.136.0/examples/jsm/controls/OrbitControls"; import { RoundedBoxGeometry } from "https://cdn.skypack.dev/three@0.136.0/examples/jsm/geometries/RoundedBoxGeometry"; import { mergeBufferGeometries } from "https://cdn.skypack.dev/three@0.136.0/examples/jsm/utils/BufferGeometryUtils"; import { RoomEnvironment } from "https://cdn.skypack.dev/three@0.136.0/examples/jsm/environments/RoomEnvironment"; console.clear(); class NewtonsCradle extends THREE.Group { constructor() { super(); // base let baseG = new RoundedBoxGeometry(14, 1, 7, 3, 0.25).translate(0, 0.5, 0); let baseM = new THREE.MeshLambertMaterial({ color: new THREE.Color(0, 0.75, 1).multiplyScalar(0.5) }); let base = new THREE.Mesh(baseG, baseM); this.add(base); // frame let frameR = 0.25; let frameRound = 1.5; let frameW = 12; let fra.........完整代码请登录后点击上方下载按钮下载查看
网友评论0