Skip to content

Commit

Permalink
live serving updates
Browse files Browse the repository at this point in the history
  • Loading branch information
N8 committed Dec 31, 2023
1 parent 1adbcc8 commit 755dd98
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 223 deletions.
23 changes: 23 additions & 0 deletions dev-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import express from 'express';
import cors from 'cors';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';

const app = express();

// Enable CORS for all routes
app.use(cors());

// Since __dirname is not defined in ES modules, you have to derive it
const __filename = fileURLToPath(
import.meta.url);
const __dirname = dirname(__filename);

// Serve static files from the 'public' directory (update the path as necessary)
app.use(express.static(__dirname));

const port = process.env.PORT || 8080;

app.listen(port, () => {
console.log(`Server running on port ${port}`);
});
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<body>
<script async src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js"></script>
<script type="importmap">
{ "imports": { "three": "https://unpkg.com/three@0.158.0/build/three.module.js", "three/examples/": "https://unpkg.com/three@0.158.0/examples/", "three/addons/": "https://unpkg.com/three@0.158.0/examples/jsm/", "postprocessing": "https://unpkg.com/postprocessing@6.33.0/build/index.js"}
{ "imports": { "three": "https://unpkg.com/three@0.160.0/build/three.module.js", "three/examples/": "https://unpkg.com/three@0.160.0/examples/", "three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/", "postprocessing": "https://unpkg.com/postprocessing@6.33.0/build/index.js"}
}
</script>
<p style="position:absolute;top:100%;transform:translate(4px, -200%);color:white;z-index:100000;background-color: black;">Elapsed Time for AO (<span id="aoMetadata"></span>): <span id="aoTime">0</span>ms </p>
Expand Down
12 changes: 6 additions & 6 deletions example/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ async function main() {

function animate() {
aoMeta.innerHTML = `${clientWidth}x${clientHeight}`
torusKnot.rotation.x += 0.033;
torusKnot.rotation.y += 0.033;
torusKnot2.rotation.x += 0.033;
torusKnot2.rotation.y += 0.033;
torusKnot3.rotation.x += 0.033;
torusKnot3.rotation.y += 0.033;
torusKnot.rotation.x = performance.now() * 0.002;
torusKnot.rotation.y = performance.now() * 0.002;
torusKnot2.rotation.x = performance.now() * 0.002;
torusKnot2.rotation.y = performance.now() * 0.002;
torusKnot3.rotation.x = performance.now() * 0.002;
torusKnot3.rotation.y = performance.now() * 0.002;
torusKnot2.material.opacity = Math.sin(performance.now() * 0.001) * 0.5 + 0.5;
torusKnot3.material.opacity = Math.cos(performance.now() * 0.001) * 0.5 + 0.5;
torusKnotShadow2.material.color.g = 1 - 0.6 * torusKnot2.material.opacity;
Expand Down
2 changes: 1 addition & 1 deletion example_postprocessing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<body>
<script async src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js"></script>
<script type="importmap">
{ "imports": { "three": "https://unpkg.com/three@0.158.0/build/three.module.js", "three/examples/": "https://unpkg.com/three@0.158.0/examples/", "three/addons/": "https://unpkg.com/three@0.158.0/examples/jsm/", "postprocessing": "https://unpkg.com/postprocessing@6.33.0/build/index.js"}
{ "imports": { "three": "https://unpkg.com/three@0.160.0/build/three.module.js", "three/examples/": "https://unpkg.com/three@0.160.0/examples/", "three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/", "postprocessing": "https://unpkg.com/postprocessing@6.33.0/build/index.js"}
}
</script>
<p style="position:absolute;top:100%;transform:translate(4px, -200%);color:white;z-index:100000;background-color: black;">Elapsed Time for AO (<span id="aoMetadata"></span>): <span id="aoTime">0</span>ms </p>
Expand Down
12 changes: 6 additions & 6 deletions example_postprocessing/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ async function main() {

function animate() {
aoMeta.innerHTML = `${clientWidth}x${clientHeight}`
torusKnot.rotation.x += 0.033;
torusKnot.rotation.y += 0.033;
torusKnot2.rotation.x += 0.033;
torusKnot2.rotation.y += 0.033;
torusKnot3.rotation.x += 0.033;
torusKnot3.rotation.y += 0.033;
torusKnot.rotation.x = performance.now() * 0.002;
torusKnot.rotation.y = performance.now() * 0.002;
torusKnot2.rotation.x = performance.now() * 0.002;
torusKnot2.rotation.y = performance.now() * 0.002;
torusKnot3.rotation.x = performance.now() * 0.002;
torusKnot3.rotation.y = performance.now() * 0.002;
torusKnot2.material.opacity = Math.sin(performance.now() * 0.001) * 0.5 + 0.5;
torusKnot3.material.opacity = Math.cos(performance.now() * 0.001) * 0.5 + 0.5;
torusKnotShadow2.material.color.g = 1 - 0.6 * torusKnot2.material.opacity;
Expand Down
Loading

0 comments on commit 755dd98

Please sign in to comment.