代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CloudModel</title>
<meta name="description" content="CloudModel">
<meta name="keywords" content="CloudModel">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google-site-verification" content="pLPl8oqL0Adf4p5s9zT-pXnpfF-2TMlOTEjoDl7DpSY" />
<meta name="baidu-site-verification" content="code-gZR6EVVpaO" />
<link rel="shortcut icon" href="favicon.ico">
<script type="module" src="js/model-viewer.min.js"></script>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<model-viewer id="mv" alt="A 3D model" poster="" skybox-image="" src="" ios-src="" seamless-poster
shadow-intensity="1" loading="auto" reveal="auto" ar ar-modes="webxr scene-viewer quick-look" ar-scale="auto"
ar-placement="floor" xr-environment auto-rotate camera-controls>
<div class="models">
<button title="Bing Dwen Dwen" onclick="getModel('bingdwendwen')">冰墩墩</button>
<button title="Shuey Rhon Rhon" onclick="getModel('shueyrhonrhon')">雪容融</button>
<button title="Bing Dwen Dwen & Shuey Rhon Rhon" onclick="getModel('bingxue')">冰墩墩&雪容融</button>
<button title="Earth" onclick="getModel('earth')">地球</button>
<button title="Astronaut" onclick="getModel('astronaut')">宇航员</button>
</div>
<div class="controls">
<button title="Export GLB" onclick="exportScene()">导出为GLB</button>
<button title="Export GLTF" onclick="exportScene(false)">导出为GLTF</button>
</div>
</model-viewer>
<script>
async function exportScene(binary = true) {
let options = {
binary: binary,
trs: true,
onlyVisible: true,
maxTextureSize: 256,
forcePowerOfTwoTextures: true,
includeCustomExtensions: false,
embedImages: true,
};
let modelViewer = document.getElementById('mv');
const glTF = await modelViewer.exportScene(options);
var file = new File([glTF], binary ? 'model.glb' : 'model.gltf');
var link = document.createElement('a');
link.download = file.name;
link.href = URL.createObjectURL(file);
link.click();
}
function getModel(name) {
const model = document.getElementById('mv');
const modelName = `${location.origin}${location.pathname}models/${name}`;
const srcReg = /[^\s]+.(gltf|glb)$/;
model.setAttribute('src', srcReg.test(modelName) ? modelName : `${modelName}.glb`);
model.setAttribute('ios-src', modelName.includes('.usdz') ? modelName : `${modelName}.usdz`);
}
const hash = location.hash.slice(1);
getModel(hash || 'bingdwendwen');
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。