Jump to content

Test: Difference between revisions

No edit summary
No edit summary
 
(52 intermediate revisions by 2 users not shown)
Line 4: Line 4:




<table>
{{#widget:ModelViewer
<tr>
|src=https://survivalcraft.wiki/content/Models/Moose.glb
<td>Cell 1</td>
|alt=Brown Bear
<td> Cell 2</td>
|width=270px
</tr>
|height=200px
|interactionPrompt=false
|backgroundColor=transparent
|cameraControls=true
|disableZoom=true
|cameraOrbit=220deg 75deg 4m
|ar=true
|arModes=scene-viewer quick-look webxr
|poster=https://survivalcraft.wiki/content/Models/Bear_Brown.webp}}


<tr>
{{#widget:ModelViewer
<td>Cell 3</td>
|src=https://survivalcraft.wiki/content/Models/Boat.glb
<td> Cell 4</td>
|alt=Donkey
</tr>
|width=270px
|height=200px
|interactionPrompt=false
|backgroundColor=transparent
|cameraControls=true
|disableZoom=true
|cameraOrbit=220deg 75deg 4m
|ar=true
|arModes=scene-viewer quick-look webxr
|poster=https://survivalcraft.wiki/content/Models/Bear_Brown.webp
}}


 
{{#widget:ModelViewer
 
|src=https://survivalcraft.wiki/content/Models/SoundGenerator.glb
<html>
|alt=Donkey
<head>
|width=270px
  <script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
|height=200px
</head>
|interactionPrompt=false
<body>
|backgroundColor=transparent
<model-viewer id="bearModel"
|cameraControls=true
  src="https://survivalcraft.wiki/content/Models/Bear.glb"
|disableZoom=true
  ar shadow-intensity="1" camera-controls touch-action="pan-y">
|cameraOrbit=220deg 75deg 4m
</model-viewer>
|ar=true
 
|arModes=scene-viewer quick-look webxr
<script type="module">
|poster=https://survivalcraft.wiki/content/Models/SoundGenerator.webp
const modelViewer = document.querySelector('#bearModel');
}}
 
modelViewer.addEventListener('load', async () => {
  const materials = modelViewer.model.materials;
 
  console.log('Found materials:', materials.map(m => m.name)); // debug
 
  const material = materials[0]; // or find by name if you know it
 
  // Create an HTMLImageElement
  const texture = new Image();
  texture.src = 'https://survivalcraft.wiki/content/Textures/Creatures/Bear_Brown.png';
  await texture.decode();
 
  // Use the setTexture method:
  // first argument: name of texture slot (e.g., 'baseColorTexture')
  // second argument: Image or HTMLCanvasElement
  await material.setTexture('baseColorTexture', texture);
});
 
</script>
</body>
</html>