Test: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
Line 18: | Line 18: | ||
<html> | <html> | ||
< | <!-- MediaWiki HTML snippet for 3D Bear Model --> | ||
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script> | |||
<!-- Bear Texture Selection --> | |||
<div style="margin-bottom: 10px;"> | |||
<label for="bearTexture" style="font-weight: bold; margin-right: 10px;">Bear Type:</label> | |||
<select id="bearTexture" onchange="changeBearTexture()" style="padding: 5px; border: 1px solid #ccc; border-radius: 4px;"> | |||
<option value="brown">Brown Bear</option> | |||
<option value="black">Black Bear</option> | |||
</ | </select> | ||
< | </div> | ||
<model-viewer id="bearModel" | |||
<model-viewer | |||
id="bearModel" | |||
src="https://survivalcraft.wiki/content/Models/Bear.glb" | |||
alt="3D Bear Model from Survivalcraft" | |||
auto-rotate | |||
camera-controls | |||
background-color="#f0f0f0" | |||
shadow-intensity="1" | |||
style="width: 400px; height: 400px; border: 1px solid #ccc; border-radius: 8px;" | |||
loading="lazy" | |||
reveal="interaction"> | |||
<!-- Fallback content for browsers that don't support model-viewer --> | |||
<div slot="poster" style="display: flex; align-items: center; justify-content: center; height: 100%; background: #f5f5f5; color: #666;"> | |||
<p>3D Bear Model<br><small>Click to load interactive model</small></p> | |||
</div> | |||
<!-- Error fallback --> | |||
<div slot="error" style="display: flex; align-items: center; justify-content: center; height: 100%; background: #ffe6e6; color: #d63031;"> | |||
<p>⚠️ Unable to load 3D model</p> | |||
</div> | |||
</model-viewer> | </model-viewer> | ||
<script | <!-- JavaScript for texture switching --> | ||
const | <script> | ||
function changeBearTexture() { | |||
modelViewer. | const selector = document.getElementById('bearTexture'); | ||
const modelViewer = document.getElementById('bearModel'); | |||
const selectedTexture = selector.value; | |||
// | // Define texture URLs | ||
const | const textures = { | ||
brown: 'https://survivalcraft.wiki/content/Textures/Creatures/Bear_Brown.png', | |||
black: 'https://survivalcraft.wiki/content/Textures/Creatures/Bear_Black.png' | |||
}; | |||
// Wait for model to load, then apply texture | |||
modelViewer.addEventListener('load', () => { | |||
const material = modelViewer.model.materials[0]; | |||
if (material && material.pbrMetallicRoughness) { | |||
// Create a new texture | |||
const textureLoader = new THREE.TextureLoader(); | |||
textureLoader.load(textures[selectedTexture], (texture) => { | |||
material.pbrMetallicRoughness.baseColorTexture.source.source = texture.image; | |||
material.pbrMetallicRoughness.baseColorTexture.needsUpdate = true; | |||
// Create | }); | ||
const | |||
} | |||
} | } | ||
}, { once: false }); | |||
// | // Trigger model reload to apply texture | ||
modelViewer.src = modelViewer.src; | |||
} | |||
// Initialize with brown bear texture | |||
document.addEventListener('DOMContentLoaded', () => { | |||
changeBearTexture(); | |||
}); | }); | ||
</script> | |||
</ | <!-- Controls information --> | ||
</ | <div style="margin-top: 10px; font-size: 12px; color: #666;"> | ||
<strong>Controls:</strong> Click and drag to rotate • Scroll to zoom • Right-click and drag to pan | |||
</div> | |||
</html> | </html> |
Revision as of 17:52, 28 July 2025
This is a notice message |
This is a content issue |
This is a style issue |
3D Bear Model
Click to load interactive model
⚠️ Unable to load 3D model
Controls: Click and drag to rotate • Scroll to zoom • Right-click and drag to pan
Cell 1 | Cell 2 |
Cell 3 | Cell 4 |