OPyPdmm模拟真实窗帘垂体鼠标交互重力碰撞动画效果代码
代码语言:html
所属分类:动画
代码描述:OPyPdmm模拟真实窗帘垂体鼠标交互重力碰撞动画效果代码
代码标签: OPyPdmm 模拟 真实 窗帘 垂体 鼠标 交互 重力 碰撞 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
@import url("https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap");
body {
background: #EEE;
margin: 0;
display: flex;
min-height: 100vh;
align-items: center;
justify-content: center;
overflow: hidden;
}
canvas {
max-height: 100vh;
max-width: 100vw;
height: auto;
width: auto;
/* border: 1px solid silver; */
}
#container {
box-shadow: 0 0 20px rgba(0,0,0,.05);
border: 1px solid rgba(0,0,0,.1);
position: relative;
display: flex;
align-items: center;
justify-content: center;
touch-action: none;
}
h1 {
font-family: Rubik;
font-size: 100px;
font-weight: 800;
line-height: 1em;
position: absolute;
color: #fff;
}
</style>
</head>
<body translate="no">
<div id="container"></div>
<script type="module">
import { Pane } from "//repo.bfw.wiki/bfwrepo/js/tweakpane.4.0.3.js";
import {
lerp,
getPointsForGridId,
getEdgeIdsForGridId,
getPointID,
hash,
smoothstep } from
"//repo.bfw.wiki/bfwrepo/js/OPyPdmm.js";
console.clear();
const CONFIG = {
width: 400,
height: 400,
gridW: 100,
gridH: 40,
gravity: .2,
damping: .99,
iterationsPerFrame: 10,
compressFactor: .2,
stretchFactor: 1.1,
pointRadius: 0,
lineWidth: 3,
mouseSize: 4000,
mouseStrength: 4,
contain: false,
randomSolve: false,
preset: '' };
// --- PANE ---
const pane = new Pane();
const f1 = pane.addFolder({
title: "Config",
expanded: false });
const f2 = pane.addFolder({
title: "Simulation",
expanded: false });
f1.addBinding(CONFIG, "width");
f1.addBinding(CONFIG, "height");
f1.addBinding(CONFIG, "gridW", {
step: 1,
min: 2,
max: 200 });
f1.addBinding(CONFIG, "gridH", {
step: 1,
min: 2,
max: 100 });
f2.addBinding(CONFIG, "gravity", {
step: .05,
min: 0,
max: 2 });
f2.addBinding(CONFIG, "damping", {
step: .001,
min: .5,
max: 1.02 });
f2.addBinding(CONFIG, "iterationsPerFrame", {
step: 1,
min: 1,
max: 20 });
f2.addBinding(CONFIG, "stretchFactor", {
step: .01,
min: 1.0,
max: 2.0,
label: "Max Stretch" });
f2.addBinding(CONFIG, "compressFactor", {
step: .01,
min: 0.1,
max: 1.0,
l.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0