three实现简单三维人物角色修改配件效果代码
代码语言:html
所属分类:三维
代码描述:three实现简单三维人物角色修改配件效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html, body { margin: 0; padding: 0; overflow: hidden; } .background { background-color: #242424; } .attachment { content: " "; position: absolute; display: inline-flex; } .attachment-legs { left: 60%; top: 70%; } .attachment-weapon { left: 34%; top: 36%; } .attachment { width: 3rem; height: 3rem; border: 1px solid grey; cursor: pointer; } .attachment:hover .attachment__button-content { margin: 5%; height: 90%; width: 90%; background-color: rgba(255, 255, 255, 0.3); } .attachment__button-content { position: relative; margin: 10%; height: 80%; width: 80%; background-color: rgba(255, 255, 255, 0.1); transition: background-color 0.15s ease, margin 0.15s ease, height 0.15s ease, width 0.15s ease; } .add-sign-plus { transition: transform 0.2s ease; } .add-sign { color: lightgrey; top: 50%; left: 50%; position: absolute; transform: translate(-50%, -50%); font-size: 1.75rem; } .options { transition: opacity 0.2s ease; opacity: 0; visibility: hidden; } .attachment-options-legs { left: calc(60% + 3.1rem); top: 70%; } .attachment-options-weapon { left: calc(34% - 6.3rem); top: 36%; } .attachment-options { display: flex; position: absolute; height: min-content; width: auto; height: 3rem; cursor: pointer; } .option { position: relative; margin-left: 1px; height: 80%; width: 100%; height: 100%; transition: background-color 0.15s ease, margin 0.15s ease, height 0.15s ease, width 0.15s ease; opacity: 0.5; transition: opacity 0.2s ease; background-color: rgba(255, 255, 255, 0.1); border: 1px solid #4e4e4e; } .option:hover { opacity: 1; } .pegleg-svg, .leg-svg, .sword-svg, .axe-svg { width: 30px; height: 30px; margin-left: 0.55rem; margin-right: 0.5rem; margin-top: 0.5rem; } .tip { position: absolute; left: 50%; top: 1rem; transform: translateX(-50%); text-transform: uppercase; font-family: sans-serif; font-weight: 600; opacity: 0.35; font-size: 0.75rem; } </style> </head> <body> <div id="background" class="background"></div> <div class="tip">Drag the screen to look around</div> <div class="attachment attachment-weapon" onclick="toggleWeaponsMenu()"> <div class="attachment__button-content"> <div class="add-sign"> <div class="add-sign-plus add-sign-weapon"> + </div> </div> </div> </div> <div class="options weapon-options"> <div class="attachment-options attachment-options-weapon"> <div class="option" onclick="applyWeapon(0)"> <svg class="axe-svg" fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 20"><path d="M7 1a1 1 0 112 0v18a1 1 0 11-2 0V1z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M14.5 2.618a.5.5 0 00-.724-.447L9.275 4.42a.5.5 0 00.048.916l4.501 1.688a.5.5 0 00.676-.468V2.618zm-1.17-1.342a1.5 1.5 0 012.17 1.342v3.939a1.5 1.5 0 01-2.027 1.404L8.972 6.273c-1.227-.46-1.316-2.16-.144-2.746l4.501-2.25z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.618a.5.5 0 01.724-.447l4.501 2.25a.5.5 0 01-.048.916L2.176 7.025a.5.5 0 01-.676-.468V2.618zm1.17-1.342A1.5 1.5 0 00.5 2.618v3.939a1.5 1.5 0 002.027 1.404l4.501-1.688c1.227-.46 1.316-2.16.144-2.746l-4.501-2.25z" fill="#fff"/></svg> </div> <div class="option" onclick="applyWeapon(1)"> <svg class="sword-svg" fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14.5 6.382V16.5h-5V6.378c.56-1.389 1.049-2.392 1.493-3.043.474-.695.795-.838.976-.835.19.003.52.168 1.005.87.453.657.951 1.654 1.526 3.012zm-3 12.118h1V21a.5.5 0 01-1 0v-2.5z" stroke="#fff"/></svg></div> </div> </div> <div class="attachment attachment-legs" onclick="toggleLegsMenu()"> <div class="attachment__button-content"> <div class="add-sign"> <div class="add-sign-plus add-sign-legs"> + </div> </div> </div> </div> <div class="options leg-options"> <div class="attachment-options attachment-options-legs"> <div class="option" onclick="applyLegs(1)"> <svg class="pegleg-svg" fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill-rule="evenodd" clip-rule="evenodd" d="M17 4H7v3h10V4zM7 3a1 1 0 00-1 1v3a1 1 0 001 1h10a1 1 0 001-1V4a1 1 0 00-1-1H7z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M14 8h-4v4h4V8zm-4-1a1 1 0 00-1 1v4a1 1 0 001 1h4a1 1 0 001-1V8a1 1 0 00-1-1h-4z" fill="#fff"/><path d="M11 13h2v7h-2v-7zM10 20h4v1h-4v-1z" fill="#fff"/></svg> </div> <div class="option" onclick="applyLegs(0)"> <svg class="leg-svg" fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 4.5A1.5 1.5 0 017.5 3H12a1.5 1.5 0 011.5 1.5v10a.5.5 0 00.5.5h3a1.5 1.5 0 011.5 1.5v3A1.5 1.5 0 0117 21H7.5A1.5 1.5 0 016 19.5v-15zM7.5 4a.5.5 0 00-.5.5V9h5.5V4.5A.5.5 0 0012 4H7.5zm5 6H7v9.5a.5.5 0 00.5.5H17a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5h-3a1.5 1.5 0 01-1.5-1.5V10z" fill="#fff"/></svg> </div> </div> </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.110.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/GLTFLoader.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/OrbitControls.108.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three-js-csg.js"></script> <script > const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000); const renderer = new THREE.WebGLRenderer({ alpha: true }); const controls = new THREE.OrbitControls(camera, renderer.domElement); // Materials const materialDarkest = new THREE.MeshPhongMaterial({ color: 0x33281b }); const materialDark = new THREE.MeshPhongMaterial({ color: 0x664e31 }); const materialLight = new THREE.MeshPhongMaterial({ color: 0xa3835b }); const steelMaterial = new THREE.MeshPhongMaterial({ color: 0x878787 }); c.........完整代码请登录后点击上方下载按钮下载查看
网友评论0