js实现在线三维预览高斯泼溅3dgs文件splat或ply文件代码

代码语言:html

所属分类:三维

代码描述:js实现在线三维预览高斯泼溅3dgs文件splat或ply文件代码,本地选择高斯泼溅文件,支持格式splat或ply

代码标签: js 在线 三维 预览 高斯泼溅 3dgs 文件 splat ply 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
    <title>Local WebGL Gaussian Splat Viewer</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <style>
        body {
            overflow: hidden;
            margin: 0;
            height: 100vh;
            width: 100vw;
            font-family: sans-serif;
            background: black;
            text-shadow: 0 0 3px black;
        }
        a, body {
            color: white;
        }
        #info {
            z-index: 100;
            position: absolute;
            top: 10px;
            left: 15px;
            max-width: 300px;
        }
        h3 {
            margin: 5px 0;
        }
        p {
            margin: 5px 0;
            font-size: small;
        }
        
        /* File Input Styling */
        .file-upload-container {
            margin-top: 10px;
            margin-bottom: 10px;
            background: rgba(255, 255, 255, 0.1);
            padding: 10px;
            border-radius: 8px;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }
        input[type="file"] {
            width: 100%;
            color: white;
            font-size: 0.9em;
        }

        .cube-wrapper {
            transform-style: preserve-3d;
        }

        .cube {
            transform-style: preserve-3d;
            transform: rotateX(45deg) rotateZ(45deg);
            animation: rotation 2s infinite;
        }

        .cube-faces {
            transform-style: preserve-3d;
            height: 80px;
            width: 80px;
            position: relative;
            transform-origin: 0 0;
            transform: translateX(0) translateY(0) translateZ(-40px);
        }

        .cube-face {
            position: absolute;
            inset: 0;
            background: #0017ff;
            border: solid 1px #ffffff;
        }
        .cube-face.top { transform: translateZ(80px); }
        .cube-face.front { transform-origin: 0 50%; transform: rotateY(-90deg); }
        .cube-face.back { transform-origin: 0 50%; transform: rotateY(-90deg) translateZ(-80px); }
        .cube-face.right { transform-origin: 50% 0; transform: rotateX(-90deg) translateY(-80px); }
        .cube-face.left { transform-origin: 50% 0; transform: rotateX(-90deg) translateY(-80px) translateZ(80px); }

        @keyframes rotation {
            0% { transform: rotateX(45deg) rotateY(0) rotateZ(45deg); animation-timing-function: cubic-bezier(0.17, 0.84, 0.44, 1); }
            50% { transform: rotateX(45deg) rotateY(0) rotateZ(225deg); animation-timing-function: cubic-bezier(0.76, 0.05, 0.86, 0.06); }
            100% { transform: rotateX(45deg) rotateY(0) rotateZ(405deg); animation-timing-function: cubic-bezier(0.17, 0.84, 0.44, 1); }
        }

        .scene, #message {
            position: absolute;
            display: flex;
            top: 0;
            right: 0;
            left: 0;
            bottom: 0;
            z-index: 2;
            height: 100%;
            width: 100%;
            align-items: center;
            justify-content: center;
            pointer-events: none;
        }
        #message {
            font-weight: bold;
            font-size: large;
            color: red;
        }

        details {
            font-size: small;
            background: rgba(0,0,0,0.6);
            padding: 5px;
            border-radius: 5px;
            margin-top: 5px;
        }

        #progress {
            position: absolute;
            top: 0;
            height: 5px;
            background: blue;
            z-index: 99;
            transition: width 0.1s ease-in-out;
            width: 0%;
        }

        #quality {
            position: absolute;
            bottom: 10px;
            z-index: 999;
            right: 10px;
        }

        #caminfo {
            position: absolute;
            top: 10px;
            z-index: 999;
            right: 10px;
        }
        #canvas {
            display: block;
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            touch-action: none;
        }

        #instructions {
            white-space: pre-wrap;
            padding: 10px;
            font-size: x-small;
        }
    </style>
</head>
<body>
    <div id="info">
        <h3>WebGL 3D Gaussian Splat Viewer</h3>
        
        <!-- NEW FILE INPUT -->
        <div class="file-upload-container">
            <label for="splat-file-input"><strong>Load local  splat or .ply file:</strong></label><br>
            <input type="file" id="splat-file-input" accept=".splat,.ply">
        </div>

        <p>
          
        </p>

        <details>
            <summary>Controls & Instructions</summary>
            <div id="instructions">movement (arrow keys)
- left/right arrow keys to strafe side to side
- up/down arrow keys to move forward/back
- space to jump

camera angle (wasd)
- a/d to turn camera left/right
- w/s to tilt camera up/down
- q/e to roll camera counterclockwise/clockwise
- i/k and j/l to orbit

trackpad
- scroll up/down/left/right to orbit
- pinch to move forward/back
- ctrl key + scroll to move forward/back
- shift + scroll to move up/d.........完整代码请登录后点击上方下载按钮下载查看

网友评论0