https local dev server
This commit is contained in:
parent
cd626be1e0
commit
936422b243
|
|
@ -21,13 +21,14 @@
|
||||||
"webcola": "^3.4.0"
|
"webcola": "^3.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier-plugin-organize-imports": "^4.1.0",
|
|
||||||
"@types/leaflet": "^1.9.14",
|
"@types/leaflet": "^1.9.14",
|
||||||
"@types/node": "^22.10.1",
|
"@types/node": "^22.10.1",
|
||||||
"@webgpu/types": "^0.1.51",
|
"@webgpu/types": "^0.1.51",
|
||||||
"bun-types": "^1.1.38",
|
"bun-types": "^1.1.38",
|
||||||
"mitata": "^1.0.20",
|
"mitata": "^1.0.20",
|
||||||
|
"prettier-plugin-organize-imports": "^4.1.0",
|
||||||
"typescript": "^5.7.2",
|
"typescript": "^5.7.2",
|
||||||
"vite": "^6.0.3"
|
"vite": "^6.0.3",
|
||||||
|
"vite-plugin-mkcert": "^1.17.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { resolve } from 'node:path';
|
|
||||||
import { readdirSync } from 'node:fs';
|
import { readdirSync } from 'node:fs';
|
||||||
|
import { resolve } from 'node:path';
|
||||||
import { defineConfig, IndexHtmlTransformContext, Plugin } from 'vite';
|
import { defineConfig, IndexHtmlTransformContext, Plugin } from 'vite';
|
||||||
|
import mkcert from 'vite-plugin-mkcert';
|
||||||
|
|
||||||
const canvasWebsiteDir = resolve(__dirname, './website/canvas');
|
const canvasWebsiteDir = resolve(__dirname, './website/canvas');
|
||||||
|
|
||||||
|
|
@ -16,19 +17,22 @@ const linkGenerator = (): Plugin => {
|
||||||
const files = getCanvasFiles();
|
const files = getCanvasFiles();
|
||||||
// First, handle ungrouped files
|
// First, handle ungrouped files
|
||||||
const ungroupedFiles = files.filter(
|
const ungroupedFiles = files.filter(
|
||||||
(file) => !file.includes('index') && !file.startsWith('_') && !file.match(/^\[([^\]]+)\]/)
|
(file) => !file.includes('index') && !file.startsWith('_') && !file.match(/^\[([^\]]+)\]/),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Then handle grouped files
|
// Then handle grouped files
|
||||||
const groups = files
|
const groups = files
|
||||||
.filter((file) => !file.includes('index') && file.match(/^\[([^\]]+)\]/))
|
.filter((file) => !file.includes('index') && file.match(/^\[([^\]]+)\]/))
|
||||||
.reduce((acc, file) => {
|
.reduce(
|
||||||
const match = file.match(/^\[([^\]]+)\](.+)\.html$/);
|
(acc, file) => {
|
||||||
const group = match![1];
|
const match = file.match(/^\[([^\]]+)\](.+)\.html$/);
|
||||||
if (!acc[group]) acc[group] = [];
|
const group = match![1];
|
||||||
acc[group].push(file);
|
if (!acc[group]) acc[group] = [];
|
||||||
return acc;
|
acc[group].push(file);
|
||||||
}, {} as Record<string, string[]>);
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, string[]>,
|
||||||
|
);
|
||||||
|
|
||||||
// Generate ungrouped HTML first
|
// Generate ungrouped HTML first
|
||||||
const ungroupedHtml = ungroupedFiles
|
const ungroupedHtml = ungroupedFiles
|
||||||
|
|
@ -72,16 +76,19 @@ export default defineConfig({
|
||||||
'@propagators': resolve(__dirname, './propagators'),
|
'@propagators': resolve(__dirname, './propagators'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [linkGenerator()],
|
plugins: [linkGenerator(), mkcert()],
|
||||||
build: {
|
build: {
|
||||||
target: 'esnext',
|
target: 'esnext',
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input: {
|
input: {
|
||||||
index: resolve(__dirname, './website/index.html'),
|
index: resolve(__dirname, './website/index.html'),
|
||||||
...getCanvasFiles().reduce((acc, file) => {
|
...getCanvasFiles().reduce(
|
||||||
acc[`canvas/${file.replace('.html', '')}`] = resolve(canvasWebsiteDir, file);
|
(acc, file) => {
|
||||||
return acc;
|
acc[`canvas/${file.replace('.html', '')}`] = resolve(canvasWebsiteDir, file);
|
||||||
}, {} as Record<string, string>),
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, string>,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
modulePreload: {
|
modulePreload: {
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
expression="textContent: to.textContent + '!'"
|
expression="textContent: to.textContent + '!'"
|
||||||
></folk-event-propagator>
|
></folk-event-propagator>
|
||||||
|
|
||||||
<!-- <folk-shape id="box3" x="350" y="200" width="30" height="30"></folk-shape>
|
<folk-shape id="box3" x="350" y="200" width="30" height="30"></folk-shape>
|
||||||
<folk-shape id="box4" x="500" y="250" width="30" height="30"></folk-shape>
|
<folk-shape id="box4" x="500" y="250" width="30" height="30"></folk-shape>
|
||||||
<folk-event-propagator
|
<folk-event-propagator
|
||||||
source="#box3"
|
source="#box3"
|
||||||
|
|
@ -61,13 +61,14 @@
|
||||||
trigger="transform"
|
trigger="transform"
|
||||||
expression="y: from.x,
|
expression="y: from.x,
|
||||||
rotation: from.x"
|
rotation: from.x"
|
||||||
></folk-event-propagator> -->
|
></folk-event-propagator>
|
||||||
|
|
||||||
<folk-gizmos></folk-gizmos>
|
<folk-gizmos></folk-gizmos>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import { requestAnimationFrame } from '@lib';
|
import { requestAnimationFrame } from '@lib';
|
||||||
import { Vector } from '@lib/Vector';
|
import { Vector } from '@lib/Vector';
|
||||||
|
|
||||||
import '@labs/standalone/folk-shape.ts';
|
import '@labs/standalone/folk-shape.ts';
|
||||||
import '@labs/standalone/folk-event-propagator.ts';
|
import '@labs/standalone/folk-event-propagator.ts';
|
||||||
import { Gizmos } from '@lib/folk-gizmos';
|
import { Gizmos } from '@lib/folk-gizmos';
|
||||||
|
|
@ -83,7 +84,6 @@ rotation: from.x"
|
||||||
const ropes = Array.from(document.querySelectorAll('folk-event-propagator'));
|
const ropes = Array.from(document.querySelectorAll('folk-event-propagator'));
|
||||||
let orientationEvent;
|
let orientationEvent;
|
||||||
|
|
||||||
let gravityScale = 3000;
|
|
||||||
const gravitySlider = document.getElementById('gravityScale');
|
const gravitySlider = document.getElementById('gravityScale');
|
||||||
const gravityScaleValue = document.getElementById('gravityScaleValue');
|
const gravityScaleValue = document.getElementById('gravityScaleValue');
|
||||||
|
|
||||||
|
|
@ -92,12 +92,12 @@ rotation: from.x"
|
||||||
gravityScaleValue.textContent = gravityScale;
|
gravityScaleValue.textContent = gravityScale;
|
||||||
|
|
||||||
gravitySlider.addEventListener('input', (e) => {
|
gravitySlider.addEventListener('input', (e) => {
|
||||||
gravityScale = parseInt(e.target.value);
|
gravityScaleValue.textContent = gravitySlider.value;
|
||||||
gravityScaleValue.textContent = gravityScale;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function tick() {
|
function tick() {
|
||||||
requestAnimationFrame(tick);
|
requestAnimationFrame(tick);
|
||||||
|
|
||||||
if (orientationEvent === undefined) return;
|
if (orientationEvent === undefined) return;
|
||||||
|
|
||||||
window.alpha.textContent = Math.round(orientationEvent.alpha);
|
window.alpha.textContent = Math.round(orientationEvent.alpha);
|
||||||
|
|
@ -116,7 +116,7 @@ rotation: from.x"
|
||||||
const direction = Vector.normalized(downwardVector);
|
const direction = Vector.normalized(downwardVector);
|
||||||
|
|
||||||
// Scale the vector by gravity constant
|
// Scale the vector by gravity constant
|
||||||
const gravity = Vector.scale(direction, magnitude * gravityScale);
|
const gravity = Vector.scale(direction, magnitude * gravitySlider.valueAsNumber);
|
||||||
|
|
||||||
window.gravity.textContent = `${Math.round(gravity.x)}, ${Math.round(gravity.y)}`;
|
window.gravity.textContent = `${Math.round(gravity.x)}, ${Math.round(gravity.y)}`;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue