Initial commit
This commit is contained in:
commit
b61cc66325
16 changed files with 1869 additions and 0 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/node_modules/
|
||||||
|
/public/build/
|
||||||
|
|
||||||
|
.DS_Store
|
107
README.md
Normal file
107
README.md
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
# This repo is no longer maintained. Consider using `npm init vite` and selecting the `svelte` option or — if you want a full-fledged app framework — use [SvelteKit](https://kit.svelte.dev), the official application framework for Svelte.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# svelte app
|
||||||
|
|
||||||
|
This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
|
||||||
|
|
||||||
|
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx degit sveltejs/template svelte-app
|
||||||
|
cd svelte-app
|
||||||
|
```
|
||||||
|
|
||||||
|
*Note that you will need to have [Node.js](https://nodejs.org) installed.*
|
||||||
|
|
||||||
|
|
||||||
|
## Get started
|
||||||
|
|
||||||
|
Install the dependencies...
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd svelte-app
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
...then start [Rollup](https://rollupjs.org):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Navigate to [localhost:8080](http://localhost:8080). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
|
||||||
|
|
||||||
|
By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
|
||||||
|
|
||||||
|
If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
|
||||||
|
|
||||||
|
## Building and running in production mode
|
||||||
|
|
||||||
|
To create an optimised version of the app:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
|
||||||
|
|
||||||
|
|
||||||
|
## Single-page app mode
|
||||||
|
|
||||||
|
By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
|
||||||
|
|
||||||
|
If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
|
||||||
|
|
||||||
|
```js
|
||||||
|
"start": "sirv public --single"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Using TypeScript
|
||||||
|
|
||||||
|
This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node scripts/setupTypeScript.js
|
||||||
|
```
|
||||||
|
|
||||||
|
Or remove the script via:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rm scripts/setupTypeScript.js
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to use `baseUrl` or `path` aliases within your `tsconfig`, you need to set up `@rollup/plugin-alias` to tell Rollup to resolve the aliases. For more info, see [this StackOverflow question](https://stackoverflow.com/questions/63427935/setup-tsconfig-path-in-svelte).
|
||||||
|
|
||||||
|
## Deploying to the web
|
||||||
|
|
||||||
|
### With [Vercel](https://vercel.com)
|
||||||
|
|
||||||
|
Install `vercel` if you haven't already:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g vercel
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, from within your project folder:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd public
|
||||||
|
vercel deploy --name my-project
|
||||||
|
```
|
||||||
|
|
||||||
|
### With [surge](https://surge.sh/)
|
||||||
|
|
||||||
|
Install `surge` if you haven't already:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g surge
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, from within your project folder:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
surge public my-project.surge.sh
|
||||||
|
```
|
1078
package-lock.json
generated
Normal file
1078
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
27
package.json
Normal file
27
package.json
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "svelte-app",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"predev": "node scripts/parse-comin.js",
|
||||||
|
"prebuild": "node scripts/parse-comin.js",
|
||||||
|
"build": "rollup -c",
|
||||||
|
"dev": "rollup -c -w",
|
||||||
|
"start": "sirv public --no-clear"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-commonjs": "^24.0.0",
|
||||||
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
||||||
|
"@rollup/plugin-terser": "^0.4.0",
|
||||||
|
"rollup": "^3.15.0",
|
||||||
|
"rollup-plugin-css-only": "^4.3.0",
|
||||||
|
"rollup-plugin-livereload": "^2.0.0",
|
||||||
|
"rollup-plugin-svelte": "^7.1.2",
|
||||||
|
"svelte": "^3.55.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"sirv-cli": "^2.0.0",
|
||||||
|
"three": "^0.173.0"
|
||||||
|
}
|
||||||
|
}
|
BIN
public/favicon.png
Normal file
BIN
public/favicon.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 3.1 KiB |
63
public/global.css
Normal file
63
public/global.css
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
html, body {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
color: #333;
|
||||||
|
margin: 0;
|
||||||
|
padding: 8px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: rgb(0,100,200);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:visited {
|
||||||
|
color: rgb(0,80,160);
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
input, button, select, textarea {
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
-webkit-padding: 0.4em 0;
|
||||||
|
padding: 0.4em;
|
||||||
|
margin: 0 0 0.5em 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:disabled {
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
color: #333;
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:disabled {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:not(:disabled):active {
|
||||||
|
background-color: #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:focus {
|
||||||
|
border-color: #666;
|
||||||
|
}
|
18
public/index.html
Normal file
18
public/index.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'>
|
||||||
|
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||||
|
|
||||||
|
<title>Svelte app</title>
|
||||||
|
|
||||||
|
<link rel='icon' type='image/png' href='/favicon.png'>
|
||||||
|
<link rel='stylesheet' href='/global.css'>
|
||||||
|
<link rel='stylesheet' href='/build/bundle.css'>
|
||||||
|
|
||||||
|
<script defer src='/build/bundle.js'></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
78
rollup.config.js
Normal file
78
rollup.config.js
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
import { spawn } from 'child_process';
|
||||||
|
import svelte from 'rollup-plugin-svelte';
|
||||||
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
|
import terser from '@rollup/plugin-terser';
|
||||||
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
|
import livereload from 'rollup-plugin-livereload';
|
||||||
|
import css from 'rollup-plugin-css-only';
|
||||||
|
|
||||||
|
const production = !process.env.ROLLUP_WATCH;
|
||||||
|
|
||||||
|
function serve() {
|
||||||
|
let server;
|
||||||
|
|
||||||
|
function toExit() {
|
||||||
|
if (server) server.kill(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
writeBundle() {
|
||||||
|
if (server) return;
|
||||||
|
server = spawn('npm', ['run', 'start', '--', '--dev'], {
|
||||||
|
stdio: ['ignore', 'inherit', 'inherit'],
|
||||||
|
shell: true
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('SIGTERM', toExit);
|
||||||
|
process.on('exit', toExit);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
input: 'src/main.js',
|
||||||
|
output: {
|
||||||
|
sourcemap: true,
|
||||||
|
format: 'iife',
|
||||||
|
name: 'app',
|
||||||
|
file: 'public/build/bundle.js'
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
svelte({
|
||||||
|
compilerOptions: {
|
||||||
|
// enable run-time checks when not in production
|
||||||
|
dev: !production
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// we'll extract any component CSS out into
|
||||||
|
// a separate file - better for performance
|
||||||
|
css({ output: 'bundle.css' }),
|
||||||
|
|
||||||
|
// If you have external dependencies installed from
|
||||||
|
// npm, you'll most likely need these plugins. In
|
||||||
|
// some cases you'll need additional configuration -
|
||||||
|
// consult the documentation for details:
|
||||||
|
// https://github.com/rollup/plugins/tree/master/packages/commonjs
|
||||||
|
resolve({
|
||||||
|
browser: true,
|
||||||
|
dedupe: ['svelte'],
|
||||||
|
exportConditions: ['svelte']
|
||||||
|
}),
|
||||||
|
commonjs(),
|
||||||
|
|
||||||
|
// In dev mode, call `npm run start` once
|
||||||
|
// the bundle has been generated
|
||||||
|
!production && serve(),
|
||||||
|
|
||||||
|
// Watch the `public` directory and refresh the
|
||||||
|
// browser on changes when not in production
|
||||||
|
!production && livereload('public'),
|
||||||
|
|
||||||
|
// If we're building for production (npm run build
|
||||||
|
// instead of npm run dev), minify
|
||||||
|
production && terser()
|
||||||
|
],
|
||||||
|
watch: {
|
||||||
|
clearScreen: false
|
||||||
|
}
|
||||||
|
};
|
32
scripts/parse-comin.js
Normal file
32
scripts/parse-comin.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// scripts/parse-comin.js
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
import { writeFileSync } from 'fs';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const output = execSync('comin status').toString();
|
||||||
|
|
||||||
|
// Extract commit ID
|
||||||
|
const commitMatch = output.match(/Commit ID (\b[0-9a-f]{40}\b)/);
|
||||||
|
const commitId = commitMatch ? commitMatch[1].substring(0, 7) : 'unknown';
|
||||||
|
|
||||||
|
// Check build success
|
||||||
|
const buildSuccess = output.includes('Evaluation succeeded') &&
|
||||||
|
output.includes('Built');
|
||||||
|
|
||||||
|
const result = {
|
||||||
|
commitId,
|
||||||
|
buildSuccess,
|
||||||
|
timestamp: new Date().toISOString()
|
||||||
|
};
|
||||||
|
|
||||||
|
writeFileSync('./src/lib/build-info.json', JSON.stringify(result, null, 2));
|
||||||
|
console.log('Build info saved:', result);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error parsing comin status:', error);
|
||||||
|
writeFileSync('./src/lib/build-info.json', JSON.stringify({
|
||||||
|
commitId: 'error',
|
||||||
|
buildSuccess: false,
|
||||||
|
timestamp: new Date().toISOString()
|
||||||
|
}));
|
||||||
|
}
|
134
scripts/setupTypeScript.js
Normal file
134
scripts/setupTypeScript.js
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
|
/** This script modifies the project to support TS code in .svelte files like:
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export let name: string;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
As well as validating the code for CI.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** To work on this script:
|
||||||
|
rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
|
||||||
|
*/
|
||||||
|
|
||||||
|
import fs from "fs"
|
||||||
|
import path from "path"
|
||||||
|
import { argv } from "process"
|
||||||
|
import url from 'url';
|
||||||
|
|
||||||
|
const __filename = url.fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
||||||
|
const projectRoot = argv[2] || path.join(__dirname, "..")
|
||||||
|
|
||||||
|
// Add deps to pkg.json
|
||||||
|
const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8"))
|
||||||
|
packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
|
||||||
|
"svelte-check": "^3.0.0",
|
||||||
|
"svelte-preprocess": "^5.0.0",
|
||||||
|
"@rollup/plugin-typescript": "^11.0.0",
|
||||||
|
"typescript": "^4.9.0",
|
||||||
|
"tslib": "^2.5.0",
|
||||||
|
"@tsconfig/svelte": "^3.0.0"
|
||||||
|
})
|
||||||
|
|
||||||
|
// Add script for checking
|
||||||
|
packageJSON.scripts = Object.assign(packageJSON.scripts, {
|
||||||
|
"check": "svelte-check"
|
||||||
|
})
|
||||||
|
|
||||||
|
// Write the package JSON
|
||||||
|
fs.writeFileSync(path.join(projectRoot, "package.json"), JSON.stringify(packageJSON, null, " "))
|
||||||
|
|
||||||
|
// mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
|
||||||
|
const beforeMainJSPath = path.join(projectRoot, "src", "main.js")
|
||||||
|
const afterMainTSPath = path.join(projectRoot, "src", "main.ts")
|
||||||
|
fs.renameSync(beforeMainJSPath, afterMainTSPath)
|
||||||
|
|
||||||
|
// Switch the app.svelte file to use TS
|
||||||
|
const appSveltePath = path.join(projectRoot, "src", "App.svelte")
|
||||||
|
let appFile = fs.readFileSync(appSveltePath, "utf8")
|
||||||
|
appFile = appFile.replace("<script>", '<script lang="ts">')
|
||||||
|
appFile = appFile.replace("export let name;", 'export let name: string;')
|
||||||
|
fs.writeFileSync(appSveltePath, appFile)
|
||||||
|
|
||||||
|
// Edit rollup config
|
||||||
|
const rollupConfigPath = path.join(projectRoot, "rollup.config.js")
|
||||||
|
let rollupConfig = fs.readFileSync(rollupConfigPath, "utf8")
|
||||||
|
|
||||||
|
// Edit imports
|
||||||
|
rollupConfig = rollupConfig.replace(`'rollup-plugin-css-only';`, `'rollup-plugin-css-only';
|
||||||
|
import sveltePreprocess from 'svelte-preprocess';
|
||||||
|
import typescript from '@rollup/plugin-typescript';`)
|
||||||
|
|
||||||
|
// Replace name of entry point
|
||||||
|
rollupConfig = rollupConfig.replace(`'src/main.js'`, `'src/main.ts'`)
|
||||||
|
|
||||||
|
// Add preprocessor
|
||||||
|
rollupConfig = rollupConfig.replace(
|
||||||
|
'compilerOptions:',
|
||||||
|
'preprocess: sveltePreprocess({ sourceMap: !production }),\n\t\t\tcompilerOptions:'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add TypeScript
|
||||||
|
rollupConfig = rollupConfig.replace(
|
||||||
|
'commonjs(),',
|
||||||
|
'commonjs(),\n\t\ttypescript({\n\t\t\tsourceMap: !production,\n\t\t\tinlineSources: !production\n\t\t}),'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(rollupConfigPath, rollupConfig)
|
||||||
|
|
||||||
|
// Add svelte.config.js
|
||||||
|
const tsconfig = `{
|
||||||
|
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||||
|
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["node_modules/*", "__sapper__/*", "public/*"]
|
||||||
|
}`
|
||||||
|
const tsconfigPath = path.join(projectRoot, "tsconfig.json")
|
||||||
|
fs.writeFileSync(tsconfigPath, tsconfig)
|
||||||
|
|
||||||
|
// Add TSConfig
|
||||||
|
const svelteConfig = `import sveltePreprocess from 'svelte-preprocess';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
preprocess: sveltePreprocess()
|
||||||
|
};
|
||||||
|
`
|
||||||
|
const svelteConfigPath = path.join(projectRoot, "svelte.config.js")
|
||||||
|
fs.writeFileSync(svelteConfigPath, svelteConfig)
|
||||||
|
|
||||||
|
// Add global.d.ts
|
||||||
|
const dtsPath = path.join(projectRoot, "src", "global.d.ts")
|
||||||
|
fs.writeFileSync(dtsPath, `/// <reference types="svelte" />`)
|
||||||
|
|
||||||
|
// Delete this script, but not during testing
|
||||||
|
if (!argv[2]) {
|
||||||
|
// Remove the script
|
||||||
|
fs.unlinkSync(path.join(__filename))
|
||||||
|
|
||||||
|
// Check for Mac's DS_store file, and if it's the only one left remove it
|
||||||
|
const remainingFiles = fs.readdirSync(path.join(__dirname))
|
||||||
|
if (remainingFiles.length === 1 && remainingFiles[0] === '.DS_store') {
|
||||||
|
fs.unlinkSync(path.join(__dirname, '.DS_store'))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the scripts folder is empty
|
||||||
|
if (fs.readdirSync(path.join(__dirname)).length === 0) {
|
||||||
|
// Remove the scripts folder
|
||||||
|
fs.rmdirSync(path.join(__dirname))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds the extension recommendation
|
||||||
|
fs.mkdirSync(path.join(projectRoot, ".vscode"), { recursive: true })
|
||||||
|
fs.writeFileSync(path.join(projectRoot, ".vscode", "extensions.json"), `{
|
||||||
|
"recommendations": ["svelte.svelte-vscode"]
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
console.log("Converted to TypeScript.")
|
||||||
|
|
||||||
|
if (fs.existsSync(path.join(projectRoot, "node_modules"))) {
|
||||||
|
console.log("\nYou will need to re-run your dependency manager to get started.")
|
||||||
|
}
|
62
src/App.svelte
Normal file
62
src/App.svelte
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<script>
|
||||||
|
import TopologyShader from "./TopologyShader.svelte";
|
||||||
|
import BuildInfo from "./BuildInfo.svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- <canvas bind:this={canvas} /> -->
|
||||||
|
|
||||||
|
<div class="center-text">
|
||||||
|
<h1>heroin.trade</h1>
|
||||||
|
</div>
|
||||||
|
<TopologyShader />
|
||||||
|
|
||||||
|
<style global>
|
||||||
|
:global(body) {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
|
||||||
|
Ubuntu, Cantarell, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center-text {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
font-size: 4rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: -0.05em;
|
||||||
|
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
|
||||||
|
user-select: none;
|
||||||
|
mix-blend-mode: screen;
|
||||||
|
|
||||||
|
/* Subtent animation */
|
||||||
|
animation: float 3s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes float {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translateY(-10px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
h1 {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
50
src/BuildInfo.svelte
Normal file
50
src/BuildInfo.svelte
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<script>
|
||||||
|
import buildInfo from "$lib/build-info.json";
|
||||||
|
|
||||||
|
const statusColor = buildInfo.buildSuccess ? "#4ade80" : "#f87171";
|
||||||
|
const statusText = buildInfo.buildSuccess ? "SUCCEEDED" : "FAILED";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="build-info">
|
||||||
|
<div class="commit-id">
|
||||||
|
<span class="label">COMMIT:</span>
|
||||||
|
<span class="value">{buildInfo.commitId}</span>
|
||||||
|
</div>
|
||||||
|
<div class="status" style:color={statusColor}>
|
||||||
|
{statusText}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.build-info {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
font-family: "Fira Code", monospace;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
background: rgba(0, 0, 0, 0.7);
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
|
display: flex;
|
||||||
|
gap: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.value {
|
||||||
|
color: white;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status {
|
||||||
|
font-weight: bold;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
</style>
|
175
src/TopologyShader.svelte
Normal file
175
src/TopologyShader.svelte
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
<script>
|
||||||
|
import { onMount, onDestroy } from "svelte";
|
||||||
|
import * as THREE from "three";
|
||||||
|
|
||||||
|
let canvas;
|
||||||
|
let renderer, scene, camera, material;
|
||||||
|
let animationFrame;
|
||||||
|
|
||||||
|
const vertexShader = `
|
||||||
|
varying vec2 vUv;
|
||||||
|
void main() {
|
||||||
|
vUv = uv;
|
||||||
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const fragmentShader = `
|
||||||
|
uniform float uTime;
|
||||||
|
uniform vec2 uResolution;
|
||||||
|
varying vec2 vUv;
|
||||||
|
|
||||||
|
// Simplex Noise by Ian McEwan, Ashima Arts
|
||||||
|
vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}
|
||||||
|
float snoise(vec3 v){
|
||||||
|
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
|
||||||
|
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
|
||||||
|
vec3 i = floor(v + dot(v, C.yyy));
|
||||||
|
vec3 x0 = v - i + dot(i, C.xxx);
|
||||||
|
vec3 g = step(x0.yzx, x0.xyz);
|
||||||
|
vec3 l = 1.0 - g;
|
||||||
|
vec3 i1 = min(g.xyz, l.zxy);
|
||||||
|
vec3 i2 = max(g.xyz, l.zxy);
|
||||||
|
vec3 x1 = x0 - i1 + C.xxx;
|
||||||
|
vec3 x2 = x0 - i2 + C.yyy;
|
||||||
|
vec3 x3 = x0 - D.yyy;
|
||||||
|
i = mod(i, 289.0);
|
||||||
|
vec4 p = permute(permute(permute(
|
||||||
|
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
|
||||||
|
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
|
||||||
|
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
|
||||||
|
float n_ = 0.142857142857;
|
||||||
|
vec3 ns = n_ * D.wyz - D.xzx;
|
||||||
|
vec4 j = p - 49.0 * floor(p * ns.z * ns.z);
|
||||||
|
vec4 x_ = floor(j * ns.z);
|
||||||
|
vec4 y_ = floor(j - 7.0 * x_);
|
||||||
|
vec4 x = x_ *ns.x + ns.yyyy;
|
||||||
|
vec4 y = y_ *ns.x + ns.yyyy;
|
||||||
|
vec4 h = 1.0 - abs(x) - abs(y);
|
||||||
|
vec4 b0 = vec4(x.xy, y.xy);
|
||||||
|
vec4 b1 = vec4(x.zw, y.zw);
|
||||||
|
vec4 s0 = floor(b0)*2.0 + 1.0;
|
||||||
|
vec4 s1 = floor(b1)*2.0 + 1.0;
|
||||||
|
vec4 sh = -step(h, vec4(0.0));
|
||||||
|
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy;
|
||||||
|
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww;
|
||||||
|
vec3 p0 = vec3(a0.xy, h.x);
|
||||||
|
vec3 p1 = vec3(a0.zw, h.y);
|
||||||
|
vec3 p2 = vec3(a1.xy, h.z);
|
||||||
|
vec3 p3 = vec3(a1.zw, h.w);
|
||||||
|
vec4 norm = 1.0/(vec4(dot(p0,p0), dot(p1,p1), dot(p2,p2), dot(p3,p3)));
|
||||||
|
p0 *= norm.x;
|
||||||
|
p1 *= norm.y;
|
||||||
|
p2 *= norm.z;
|
||||||
|
p3 *= norm.w;
|
||||||
|
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
|
||||||
|
m = m * m;
|
||||||
|
return 42.0 * dot(m*m, vec4(dot(p0,x0), dot(p1,x1),
|
||||||
|
dot(p2,x2), dot(p3,x3)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec2 uv = vUv * 2.0 - 1.0;
|
||||||
|
uv.x *= uResolution.x / uResolution.y;
|
||||||
|
|
||||||
|
// Generate terrain using noise
|
||||||
|
float elevation = snoise(vec3(uv * 2.0, uTime * 0.2)) * 0.5;
|
||||||
|
elevation += snoise(vec3(uv * 4.0, uTime * 0.3)) * 0.025;
|
||||||
|
elevation += snoise(vec3(uv * 8.0, uTime * 0.4)) * 0.0025;
|
||||||
|
|
||||||
|
// Create contour lines
|
||||||
|
float contour = smoothstep(0.97, 0.99, sin(elevation * 40.0 + uTime));
|
||||||
|
|
||||||
|
// Add subtle movement to lines
|
||||||
|
float lineDrift = sin(uTime * 0.5 + uv.x * 10.0) * 0.01;
|
||||||
|
contour += smoothstep(0.95, 0.97,
|
||||||
|
sin((.3 * elevation + lineDrift) * 80.0 + uv.y * 5.0 + .3 * uTime));
|
||||||
|
|
||||||
|
// Color scheme
|
||||||
|
vec3 color = mix(
|
||||||
|
vec3(0., 0., 0.), // Dark brown
|
||||||
|
vec3(1., 0., 0.), // Light sand
|
||||||
|
// smoothstep(-0.5, 0.5, elevation)
|
||||||
|
.3
|
||||||
|
);
|
||||||
|
|
||||||
|
// Apply contour lines
|
||||||
|
color = mix(color, vec3(0.0), contour * 1.3);
|
||||||
|
|
||||||
|
// Add subtle highlight to peaks
|
||||||
|
// float highlight = smoothstep(0.4, 0.6, elevation);
|
||||||
|
// color = mix(color, vec3(0.9), highlight * 0.3);
|
||||||
|
|
||||||
|
gl_FragColor = vec4(color, 1.0);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
scene = new THREE.Scene();
|
||||||
|
camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
||||||
|
|
||||||
|
renderer = new THREE.WebGLRenderer({
|
||||||
|
canvas,
|
||||||
|
antialias: true,
|
||||||
|
alpha: true,
|
||||||
|
});
|
||||||
|
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||||
|
|
||||||
|
material = new THREE.ShaderMaterial({
|
||||||
|
vertexShader,
|
||||||
|
fragmentShader,
|
||||||
|
uniforms: {
|
||||||
|
uTime: { value: 0 },
|
||||||
|
uResolution: { value: new THREE.Vector2() },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const geometry = new THREE.PlaneGeometry(2, 2);
|
||||||
|
const mesh = new THREE.Mesh(geometry, material);
|
||||||
|
scene.add(mesh);
|
||||||
|
|
||||||
|
const onResize = () => {
|
||||||
|
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||||
|
material.uniforms.uResolution.value.set(
|
||||||
|
window.innerWidth,
|
||||||
|
window.innerHeight,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
window.addEventListener("resize", onResize);
|
||||||
|
onResize();
|
||||||
|
|
||||||
|
const animate = (time) => {
|
||||||
|
animationFrame = requestAnimationFrame(animate);
|
||||||
|
material.uniforms.uTime.value = time * 0.001;
|
||||||
|
renderer.render(scene, camera);
|
||||||
|
};
|
||||||
|
animate(0);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("resize", onResize);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
if (animationFrame) cancelAnimationFrame(animationFrame);
|
||||||
|
if (renderer) renderer.dispose();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<canvas bind:this={canvas} />
|
||||||
|
|
||||||
|
<style>
|
||||||
|
:global(body) {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #1a1a1a;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
</style>
|
10
src/main.js
Normal file
10
src/main.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import App from './App.svelte';
|
||||||
|
|
||||||
|
const app = new App({
|
||||||
|
target: document.body,
|
||||||
|
props: {
|
||||||
|
name: 'world'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default app;
|
28
src/shaders/fragmentShader.glsl
Normal file
28
src/shaders/fragmentShader.glsl
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
uniform float u_time;
|
||||||
|
uniform vec2 u_resolution;
|
||||||
|
|
||||||
|
vec3 palette(float t) {
|
||||||
|
vec3 a = vec3(0.5, 0.5, 0.5);
|
||||||
|
vec3 b = vec3(0.5, 0.5, 0.5);
|
||||||
|
vec3 c = vec3(1.0, 1.0, 1.0);
|
||||||
|
vec3 d = vec3(0.263, 0.416, 0.557);
|
||||||
|
return a + b * cos(6.28318 * (c * t + d));
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec2 uv = (gl_FragCoord.xy * 2.0 - u_resolution) / min(u_resolution.x, u_resolution.y);
|
||||||
|
vec2 uv0 = uv;
|
||||||
|
vec3 finalColor = vec3(0.0);
|
||||||
|
|
||||||
|
for (float i = 0.0; i < 3.0; i++) {
|
||||||
|
uv = fract(uv * 1.5) - 0.5;
|
||||||
|
float d = length(uv) * exp(-length(uv0));
|
||||||
|
vec3 col = palette(length(uv0) + i * 0.4 + u_time * 0.4);
|
||||||
|
d = sin(d * 8.0 + u_time) / 8.0;
|
||||||
|
d = abs(d);
|
||||||
|
d = pow(0.01 / d, 1.2);
|
||||||
|
finalColor += col * d;
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_FragColor = vec4(finalColor, 1.0);
|
||||||
|
}
|
3
src/shaders/vertexShader.glsl
Normal file
3
src/shaders/vertexShader.glsl
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
void main() {
|
||||||
|
gl_Position = vec4(position, 1.0);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue