dorkhub

three-elements

Web Components-powered custom HTML elements for building Three.js-powered games and interactive experiences. ๐ŸŽ‰

hmans
TypeScriptโ˜… 401โ‘‚ 14 forksMITupdated 1 month ago
git clone https://github.com/hmans/three-elements.githmans/three-elements

New Maintainer Wanted!

I am no longer working on this library (since I am also no longer using it, unfortunately.) If you're interested in taking over, please contact me at hendrik@mans.de. Thanks!




Version Version CI Downloads Bundle Size Discord

 __   __    ๐Ÿ—ป     ๐Ÿ—ป   โ›ฐ
|  |_|  |--.----.-----.-----.          ๐Ÿฆ…                                      ๐ŸŒž
|   _|     |   _|  -__|  -__|
|____|__|__|__| |_____|_____|  ๐Ÿ—ป  ๐ŸŒฒ๐ŸŒณ      __  ๐ŸŒฒ  ๐ŸŒณ                ๐Ÿฆ…
    .-----.|  |.-----.--------.-----.-----.|  |_.-----.
    |  -__||  ||  -__|        |  -__|     ||   _|__ --|
    |_____||__||_____|__|__|__|_____|__|__||____|_____|   ๐ŸŒณ๐ŸŒฒ ๐Ÿก ๐ŸŒฒ   ๐ŸŒฒ๐ŸŒณ  ๐Ÿ„   ๐ŸŒฒ ๐ŸŒฒ๐ŸŒณ     ๐ŸŒณ

three-elements provides Web Components-powered custom HTML elements for building Three.js-powered games and interactive experiences. ๐ŸŽ‰

WARNING: It is early days for this library, so please proceed with caution!

  • Directly exposes all Three.js classes as HTML elements (eg. <three-mesh> for THREE.Mesh!)
  • Elements are fully reactive; if their attributes change, this is immediately reflected in the Three.js scene.
  • Optimized rendering: Frames are only rendered when something has changed in the scene, or if your code explicitly requests it.
  • Input event handling: Your 3D scene automatically handles pointer events (clicks, hover, etc). Just hook into the same HTML DOM events you would use in any other web application (onclick et al.)
  • Use it with any framework that emits or modifies HTML DOM, or no framework at all!
  • Works with any version of Three.js, including your own fork if you have one.
  • Built-in templating support lets you reuse objects or entire scenes across your project without the need for any JavaScript component framework.
<!-- Load three-elements -->
<script type="module" src="https://jspm.dev/three-elements"></script>

<!-- Create a Three.js game with a default camera. -->
<three-game autorender>
  <three-scene background-color="#444">
    <!-- Lights on! -->
    <three-ambient-light intensity="0.2"></three-ambient-light>
    <three-directional-light intensity="0.8" position="10, 10, 50"></three-directional-light>

    <!-- Spinning dodecahedron! -->
    <three-mesh tick="object.rotation.z += dt">
      <three-dodecahedron-buffer-geometry></three-dodecahedron-buffer-geometry>
      <three-mesh-standard-material color="red"></three-mesh-standard-material>
    </three-mesh>
  </three-scene>
</three-game>

DOCUMENTATION

COMMUNITY

CONTRIBUTING

Please get in touch before submitting Pull Requests (ideally, before even implementing them.) At this stage in its development, three-elements still is heavily in flux. If there is something you would like to contribute, please open an issue and describe your suggestion.

If you want to do some hacking, just run yarn dev, which will compile the package in watch mode and spawn a server on localhost:5000 that serves the contents of the examples/ directory.

THANKS

  • Three.js for being the 3D library for the web.
  • A-Frame for introducing Web Components-powered easy to use 3D and VR.
  • react-three-fiber for its smart approach of mirroring THREE.* classes 1:1 instead of building a library of custom components.

more like this

lottery

๐ŸŽ‰๐ŸŒŸโœจ๐ŸŽˆๅนดไผšๆŠฝๅฅ–็จ‹ๅบ๏ผŒๅŸบไบŽ Express + Three.js็š„ 3D ็ƒไฝ“ๆŠฝๅฅ–็จ‹ๅบ๏ผŒๅฅ–ๅ“๐Ÿงง๐ŸŽ๏ผŒๆ–‡ๅญ—๏ผŒๅ›พ็‰‡๏ผŒๆŠฝๅฅ–่ง„ๅˆ™ๅ‡ๅฏ้…็ฝฎ๏ผŒ๐Ÿ˜œๆŠฝๅฅ–ไบบๅ‘˜ไฟกๆฏExcelไธ€้”ฎๅฏผๅ…ฅ๐Ÿ˜๏ผŒๆŠฝๅฅ–็ป“ๆžœExcelๅฏผๅ‡บ๐Ÿ˜Ž๏ผŒ็ป™ไฝ ็š„ๆŠฝๅฅ–ๆดปๅŠจๅธฆๆฅๅ…จๆ–ฐ้…ท็‚ซไฝ“้ชŒ๐Ÿš€๐Ÿš€๐Ÿš€

JavaScriptโ˜… 4.6k

search

search projects, people, and tags