Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77,959 changes: 0 additions & 77,959 deletions build/three.cjs

This file was deleted.

59,014 changes: 2 additions & 59,012 deletions build/three.core.js

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions build/three.core.min.js

This file was deleted.

18,522 changes: 2 additions & 18,520 deletions build/three.module.js

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions build/three.module.min.js

This file was deleted.

646 changes: 2 additions & 644 deletions build/three.tsl.js

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions build/three.tsl.min.js

This file was deleted.

80,971 changes: 2 additions & 80,969 deletions build/three.webgpu.js

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions build/three.webgpu.min.js

This file was deleted.

80,742 changes: 2 additions & 80,740 deletions build/three.webgpu.nodes.js

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions build/three.webgpu.nodes.min.js

This file was deleted.

106 changes: 106 additions & 0 deletions manual/en/copy-test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Copy Button Demo</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- ========== BASIC PAGE STYLE (Optional) ========== -->
<style>
body {
font-family: system-ui, sans-serif;
background: #181a1b;
color: #e6e6e6;
padding: 24px;
}

h1 {
margin-bottom: 20px;
}

/* Code block styling */
pre {
background: #2a2c2d;
border-radius: 6px;
padding: 16px;
position: relative;
overflow: auto;
margin-bottom: 20px;
}

pre code {
font-family: Consolas, Monaco, monospace;
color: #c5e887;
white-space: pre;
display: block;
}

/* COPY BUTTON STYLES */
.copy-btn {
position: absolute;
top: 8px;
right: 8px;
padding: 6px 10px;
background: #4a4a4a;
border: 1px solid #666;
border-radius: 4px;
color: white;
cursor: pointer;
font-size: 12px;
opacity: 0.7;
transition: 0.15s ease;
}

.copy-btn:hover {
opacity: 1;
}
</style>
</head>
<body>

<h1>Code Copy Button Demo</h1>

<p>This page demonstrates a working copy button like the one we want in the Three.js manual.</p>

<!-- ========== SAMPLE CODE BLOCK ========== -->
<pre><code>
// Create an AnimationMixer
const mixer = new THREE.AnimationMixer(mesh);

// Update each frame
function update() {
mixer.update(deltaSeconds);
}
</code></pre>

<!-- ========== COPY BUTTON SCRIPT ========== -->
<script>
document.addEventListener("DOMContentLoaded", () => {

// Select all <pre><code> blocks
const blocks = document.querySelectorAll("pre");

blocks.forEach(block => {

// Create button
const button = document.createElement("button");
button.className = "copy-btn";
button.textContent = "Copy";

// Copy handler
button.onclick = async () => {
const text = block.innerText;
await navigator.clipboard.writeText(text);
button.textContent = "Copied!";
setTimeout(() => button.textContent = "Copy", 1200);
};

// Add button to pre
block.appendChild(button);
});
});
</script>

</body>
</html>
15 changes: 15 additions & 0 deletions manual/resources/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
document.querySelectorAll("pre code").forEach(block => {
const button = document.createElement("button");
button.textContent = "Copy";
button.className = "copy-btn";

button.onclick = async () => {
await navigator.clipboard.writeText(block.textContent);
button.textContent = "Copied!";
setTimeout(() => (button.textContent = "Copy"), 1500);
};

block.parentElement.style.position = "relative";
block.parentElement.appendChild(button);
});

17 changes: 17 additions & 0 deletions manual/resources/lesson.css
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,20 @@ div.threejs_bottombar code {
}

}
.copy-btn {
position: absolute;
top: 8px;
right: 8px;
border: none;
background: rgba(255,255,255,0.15);
padding: 4px 8px;
border-radius: 6px;
cursor: pointer;
color: #fff;
font-size: 12px;
transition: 0.2s;
}

.copy-btn:hover {
background: rgba(255,255,255,0.3);
}
40 changes: 40 additions & 0 deletions manual/resources/lesson.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,43 @@

// ios needs this to allow touch events in an iframe
window.addEventListener( 'touchstart', {} );

document.addEventListener("DOMContentLoaded", () => {

const blocks = document.querySelectorAll("pre");

blocks.forEach(pre => {

// Create the copy button
const button = document.createElement("button");
button.className = "copy-btn";
button.innerHTML = "📋";

// Copy logic
button.addEventListener("click", async () => {

// Clone the node and remove the button before copying
const clone = pre.cloneNode(true);
clone.querySelector(".copy-btn")?.remove();

const code = clone.innerText.trim();

await navigator.clipboard.writeText(code);

button.innerText = "✔";
setTimeout(() => (button.innerHTML = "📋"), 1200);
});

// Position button
pre.style.position = "relative";
pre.appendChild(button);


});

});

// Leave this line as-is
document.body.appendChild(VRButton.createButton(renderer));