fixed physics build bug
This commit is contained in:
parent
4c05c872b6
commit
b0bcda407a
|
|
@ -4,8 +4,8 @@
|
||||||
<title>Orion Reed</title>
|
<title>Orion Reed</title>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<link rel="icon" type="image/x-icon" href="src/assets/favicon.ico?v=4" />
|
<link rel="icon" type="image/x-icon" href="src/public/favicon.ico?v=4" />
|
||||||
<link rel="shortcut icon" type="image/x-icon" href="src/assets/favicon.ico?v=4" />
|
<link rel="shortcut icon" type="image/x-icon" href="src/public/favicon.ico?v=4" />
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
<link
|
<link
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build --base=./",
|
"build": "tsc && vite build --base=./",
|
||||||
"preview": "vite preview"
|
"preview": "tsc && vite build --base=./ && vite preview"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Orion Reed",
|
"author": "Orion Reed",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dimforge/rapier2d": "latest",
|
"@dimforge/rapier2d": "^0.11.2",
|
||||||
"@tldraw/tldraw": "2.0.2",
|
"@tldraw/tldraw": "2.0.2",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
|
@ -29,4 +29,4 @@
|
||||||
"vite-plugin-top-level-await": "^1.3.1",
|
"vite-plugin-top-level-await": "^1.3.1",
|
||||||
"vite-plugin-wasm": "^3.2.2"
|
"vite-plugin-wasm": "^3.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
10
src/App.tsx
10
src/App.tsx
|
|
@ -2,13 +2,13 @@ import "@tldraw/tldraw/tldraw.css";
|
||||||
import "@/css/style.css"
|
import "@/css/style.css"
|
||||||
import React, { } from "react";
|
import React, { } from "react";
|
||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from "react-dom/client";
|
||||||
import { Default } from "@/ts/components/Default";
|
import { Default } from "@/components/Default";
|
||||||
import { Canvas } from "@/ts/components/Canvas";
|
import { Canvas } from "@/components/Canvas";
|
||||||
import { Toggle } from "@/ts/components/Toggle";
|
import { Toggle } from "@/components/Toggle";
|
||||||
import { usePhysics } from "@/ts/hooks/usePhysics.ts"
|
import { usePhysics } from "@/hooks/usePhysics"
|
||||||
import { createShapes } from "@/utils";
|
import { createShapes } from "@/utils";
|
||||||
import { BrowserRouter, Route, Routes } from 'react-router-dom';
|
import { BrowserRouter, Route, Routes } from 'react-router-dom';
|
||||||
import { Contact } from "@/ts/components/Contact.tsx";
|
import { Contact } from "@/components/Contact";
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById("root")!).render(<App />);
|
ReactDOM.createRoot(document.getElementById("root")!).render(<App />);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Tldraw, TLShape, TLUiComponents } from "@tldraw/tldraw";
|
import { Tldraw, TLShape, TLUiComponents } from "@tldraw/tldraw";
|
||||||
import { SimController } from "@/ts/physics/PhysicsControls";
|
import { SimController } from "@/physics/PhysicsControls";
|
||||||
import { HTMLShapeUtil } from "@/ts/shapes/HTMLShapeUtil";
|
import { HTMLShapeUtil } from "@/shapes/HTMLShapeUtil";
|
||||||
|
|
||||||
const components: TLUiComponents = {
|
const components: TLUiComponents = {
|
||||||
HelpMenu: null,
|
HelpMenu: null,
|
||||||
|
|
@ -2,7 +2,7 @@ export function Toggle() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<button id="toggle-physics" onClick={() => window.dispatchEvent(new CustomEvent('togglePhysicsEvent'))}>
|
<button id="toggle-physics" onClick={() => window.dispatchEvent(new CustomEvent('togglePhysicsEvent'))}>
|
||||||
<img src="assets/gravity.svg" alt="Toggle Physics" />
|
<img src="/gravity-button.svg" alt="Toggle Physics" />
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
@ -142,7 +142,8 @@ ul {
|
||||||
|
|
||||||
.fade-out {
|
.fade-out {
|
||||||
opacity: 0 !important;
|
opacity: 0 !important;
|
||||||
transition: opacity 0.2s ease-in-out;
|
transition: opacity 0.5s ease-in-out;
|
||||||
|
transition-delay: 0.25s;
|
||||||
/* visibility: hidden; */
|
/* visibility: hidden; */
|
||||||
/* display: none; */
|
/* display: none; */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ type BodyWithShapeData = RAPIER.RigidBody & {
|
||||||
};
|
};
|
||||||
type RigidbodyLookup = { [key: TLShapeId]: RAPIER.RigidBody };
|
type RigidbodyLookup = { [key: TLShapeId]: RAPIER.RigidBody };
|
||||||
|
|
||||||
const START_DELAY = 1500;
|
const START_DELAY = 500;
|
||||||
|
|
||||||
export class PhysicsWorld {
|
export class PhysicsWorld {
|
||||||
private editor: Editor;
|
private editor: Editor;
|
||||||
|
|
@ -30,7 +30,6 @@ export class PhysicsWorld {
|
||||||
public start() {
|
public start() {
|
||||||
this.world = new RAPIER.World(GRAVITY);
|
this.world = new RAPIER.World(GRAVITY);
|
||||||
|
|
||||||
// setTimeout(() => {
|
|
||||||
this.addShapes(this.editor.getCurrentPageShapes());
|
this.addShapes(this.editor.getCurrentPageShapes());
|
||||||
|
|
||||||
const simLoop = () => {
|
const simLoop = () => {
|
||||||
|
|
@ -41,7 +40,6 @@ export class PhysicsWorld {
|
||||||
};
|
};
|
||||||
simLoop();
|
simLoop();
|
||||||
return () => cancelAnimationFrame(this.animFrame);
|
return () => cancelAnimationFrame(this.animFrame);
|
||||||
// }, START_DELAY);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public stop() {
|
public stop() {
|
||||||
|
|
@ -77,7 +75,6 @@ export class PhysicsWorld {
|
||||||
}
|
}
|
||||||
|
|
||||||
createShape(shape: TLGeoShape | TLDrawShape) {
|
createShape(shape: TLGeoShape | TLDrawShape) {
|
||||||
console.log('creating shape');
|
|
||||||
if (!shape.meta.fixed) {
|
if (!shape.meta.fixed) {
|
||||||
const rb = this.createRigidbody(shape, 1);
|
const rb = this.createRigidbody(shape, 1);
|
||||||
this.createCollider(shape, rb);
|
this.createCollider(shape, rb);
|
||||||
|
|
@ -383,7 +380,7 @@ export function usePhysicsSimulation(editor: Editor, enabled: boolean) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
sim.current.start();
|
setTimeout(() => sim.current.start(), START_DELAY);
|
||||||
return () => sim.current.stop();
|
return () => sim.current.stop();
|
||||||
}
|
}
|
||||||
}, [enabled, sim]);
|
}, [enabled, sim]);
|
||||||
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 816 B After Width: | Height: | Size: 816 B |
|
|
@ -9,6 +9,10 @@ export default defineConfig({
|
||||||
wasm(),
|
wasm(),
|
||||||
topLevelAwait()
|
topLevelAwait()
|
||||||
],
|
],
|
||||||
|
build: {
|
||||||
|
sourcemap: true, // Enable source maps for production
|
||||||
|
},
|
||||||
|
publicDir: 'src/public',
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': '/src',
|
'@': '/src',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue