89<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
90<script>
91document.addEventListener('DOMContentLoaded', function () {
92if (typeof THREE === 'undefined') {
93console.error('THREE is not defined. Make sure Three.js is loaded correctly.');
106const debugElement = document.getElementById('debug');
107108function createTextureCanvas() {
109const canvas = document.createElement('canvas');
110const ctx = canvas.getContext('2d');
130}
131132function init() {
133scene = new THREE.Scene();
134camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
163}
164165function onMouseMove(event) {
166currentPoint.set(event.clientX, window.innerHeight - event.clientY);
167if (isPressed) {
172}
173174function onMouseDown(event) {
175isPressed = true;
176clickPoint.set(event.clientX, window.innerHeight - event.clientY);
181}
182183function onMouseUp() {
184isPressed = false;
185}
186187function updateUniforms() {
188if (material) {
189material.uniforms.uClickPoint.value = clickPoint;
194}
195196function onWindowResize() {
197const width = window.innerWidth;
198const height = window.innerHeight;
204}
205206function animate() {
207requestAnimationFrame(animate);
208
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
4142// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
4683const writer = writable.getWriter();
84const textEncoder = new TextEncoder();
85function write(text) {
86writer.write(textEncoder.encode(text));
87}
149</div>
150<script>
151function updateValName(valName) {
152const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
153const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
157document.getElementById('open-link').href = previewUrl;
158}
159function saveVal() {
160if (window.codeMirrorEditor) {
161document.getElementById("save-icon").classList.remove("hidden");
177return false;
178})
179function openTab(tab) {
180const tabButtonCode = document.getElementById("tab-button-code");
181const tabButtonPreview = document.getElementById("tab-button-preview");
197}
198}
199function toggleTab() {
200openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
201}
255(() => {
256const scrollingElement = document.getElementById("conversation-container");
257const callback = function (mutationsList, observer) {
258scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
259};
328window.setCodeMirrorContent({ doc: '', old: ''});
329let fullStr = "";
330window.addToken = function(str) {
331fullStr += str;
332const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
4142// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
4684const writer = writable.getWriter();
85const textEncoder = new TextEncoder();
86function write(text) {
87writer.write(textEncoder.encode(text));
88}
164</div>
165<script>
166function updateValName(valName) {
167const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
168const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
172document.getElementById('open-link').href = previewUrl;
173}
174function saveVal() {
175if (window.codeMirrorEditor) {
176document.getElementById("save-icon").classList.remove("hidden");
192return false;
193})
194function openTab(tab) {
195const tabButtonCode = document.getElementById("tab-button-code");
196const tabButtonPreview = document.getElementById("tab-button-preview");
212}
213}
214function toggleTab() {
215openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
216}
270(() => {
271const scrollingElement = document.getElementById("conversation-container");
272const callback = function (mutationsList, observer) {
273scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
274};
343window.setCodeMirrorContent({ doc: '', old: ''});
344let fullStr = "";
345window.addToken = function(str) {
346fullStr += str;
347const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
4142// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
4683const writer = writable.getWriter();
84const textEncoder = new TextEncoder();
85function write(text) {
86writer.write(textEncoder.encode(text));
87}
174</div>
175<script>
176function updateValName(valName) {
177const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
178const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
182document.getElementById('open-link').href = previewUrl;
183}
184function saveVal() {
185if (window.codeMirrorEditor) {
186document.getElementById("save-icon").classList.remove("hidden");
202return false;
203})
204function openTab(tab) {
205const tabButtonCode = document.getElementById("tab-button-code");
206const tabButtonPreview = document.getElementById("tab-button-preview");
222}
223}
224function toggleTab() {
225openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
226}
280(() => {
281const scrollingElement = document.getElementById("conversation-container");
282const callback = function (mutationsList, observer) {
283scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "smooth" });
284};
32the simplest way to achieve the goal, though you can add some inline comments to explain your
33reasoning (not for every line, but for major groups of lines). Don't use any environment variables
34unless strictly necessary, for example use APIs that don't require a key, prefer internal function
35imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
36functions where possible. Unless specified, don't add error handling,
37make sure that errors bubble up to the caller.
38There should be no comments like "more content here", it should be complete and directly runnable.
39The val should create a "export default async function main() {" which
40is the main function that gets executed on every HTTP request.
41`.replace("\n", " ");
4279const writer = writable.getWriter();
80const textEncoder = new TextEncoder();
81function write(text) {
82writer.write(textEncoder.encode(text));
83}
143</div>
144<script>
145function updateValName(valName) {
146const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
147const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
151document.getElementById('open-link').href = previewUrl;
152}
153function saveVal() {
154if (window.codeMirrorEditor) {
155document.getElementById("save-icon").classList.remove("hidden");
171return false;
172})
173function openTab(tab) {
174const tabButtonCode = document.getElementById("tab-button-code");
175const tabButtonPreview = document.getElementById("tab-button-preview");
191}
192}
193function toggleTab() {
194openTab(document.getElementById("tab-panel-code").classList.contains("hidden") ? "code" : "preview");
195}
250(() => {
251const scrollingElement = document.getElementById("conversation-container");
252const callback = function (mutationsList, observer) {
253scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
254};
322window.setCodeMirrorContent({ doc: '', old: ''});
323let fullStr = "";
324window.addToken = function(str) {
325fullStr += str;
326const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main() {" which
39is the main function that gets executed on every HTTP request.
40`
4178const writer = writable.getWriter();
79const textEncoder = new TextEncoder();
80function write(text) {
81writer.write(textEncoder.encode(text));
82}
152</div>
153<script>
154function updateValName(valName) {
155const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
156const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
160document.getElementById('open-link').href = previewUrl;
161}
162function saveVal() {
163if (window.codeMirrorEditor) {
164document.getElementById("save-icon").classList.remove("hidden");
180return false;
181})
182function openTab(tab) {
183const tabButtonCode = document.getElementById("tab-button-code");
184const tabButtonPreview = document.getElementById("tab-button-preview");
200}
201}
202function toggleTab() {
203openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
204}
258(() => {
259const scrollingElement = document.getElementById("conversation-container");
260const callback = function (mutationsList, observer) {
261scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
262};
331window.setCodeMirrorContent({ doc: '', old: ''});
332let fullStr = "";
333window.addToken = function(str) {
334fullStr += str;
335const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
4142// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
4685const writer = writable.getWriter();
86const textEncoder = new TextEncoder();
87function write(text) {
88writer.write(textEncoder.encode(text));
89}
159(() => {
160const scrollingElement = document.getElementById("conversation-container");
161const callback = function (mutationsList, observer) {
162scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
163};
232window.setCodeMirrorContent({ doc: '', old: ''});
233let fullStr = "";
234window.addToken = function(str) {
235fullStr += str;
236const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
1// This val will respond with a colorful and fun HTML page
23export default async function main(): Promise<Response> {
4const htmlContent = `
5<!DOCTYPE html>
1// This val will respond with a fun and styled HTML page saying "Hello, world!"
23export default async function main(): Promise<Response> {
4const htmlContent = `
5<!DOCTYPE html>
1// This val will respond with a funky HTML page with crazy fonts and gradients!
23export default async function main(): Promise<Response> {
4const htmlContent = `
5<!DOCTYPE html>