-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: init
three.js
& @quick-three/reactive
### Description - install `three.js` & `@quick-three/reactive` - Use demo code for web
- Loading branch information
1 parent
32ff699
commit 4470038
Showing
8 changed files
with
145 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
html, | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
top: 0; | ||
left: 0; | ||
overflow: hidden; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
import "./style.css"; | ||
import { register } from "@quick-threejs/reactive"; | ||
|
||
document.querySelector<HTMLDivElement>("#app")!.innerHTML = ` | ||
<h1>Chess-D</h1> | ||
`; | ||
import "./assets/styles/main.css"; | ||
|
||
register({ | ||
location: new URL("./main.worker.ts", import.meta.url) as unknown as string, | ||
enableDebug: true, | ||
axesSizes: 5, | ||
gridSizes: 10, | ||
withMiniCamera: true, | ||
onReady: (app) => { | ||
app | ||
.gui() | ||
?.add({ torusX: 0 }, "torusX") | ||
.step(0.01) | ||
.onChange((value: any) => { | ||
app.worker()?.postMessage({ type: "torus-x-gui-event", value }); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { launchApp } from "@quick-threejs/reactive/worker"; | ||
import { | ||
AmbientLight, | ||
Color, | ||
DirectionalLight, | ||
Mesh, | ||
MeshToonMaterial, | ||
TorusKnotGeometry | ||
} from "three"; | ||
|
||
launchApp({ | ||
onReady: (app) => { | ||
const ambientLight = new AmbientLight(0xffffff, 0.1); | ||
const directionalLight = new DirectionalLight(0xffffff, 0.8); | ||
directionalLight.position.set(0, 0, 1); | ||
|
||
const torus = new Mesh( | ||
new TorusKnotGeometry(0.8, 0.35, 100, 16), | ||
new MeshToonMaterial({ | ||
color: 0x454545 | ||
}) | ||
); | ||
|
||
self.onmessage = (event: MessageEvent) => { | ||
if (event.data?.type === "torus-x-gui-event") { | ||
torus.position.x = event.data.value; | ||
} | ||
}; | ||
|
||
app.world.scene().background = new Color("#211d20"); | ||
app.world.scene().add(ambientLight, directionalLight, torus); | ||
|
||
app.resize$?.().subscribe((event) => { | ||
console.log(event.type); | ||
}); | ||
|
||
app.wheel$?.().subscribe((event) => { | ||
console.log(event.type); | ||
}); | ||
|
||
app.timer.step$().subscribe(() => { | ||
torus.rotateY(0.05); | ||
torus.rotateX(0.001); | ||
}); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.