three.js + haxe starter project

Overview

Haxe + three.js starter project

This is a batteries-included template project using three.js with the haxe language. Main.hx sets up a physically based rendering pipeline and some optimized HDR lighting environments are include in assets/env

See live

Screenshot 2022-01-10 at 15 43 34

Building and running

  • Download haxe 4.2
  • cd into this directory and install node modules with npm install
  • Start an live server with npm start
  • run haxe build.hxml to recompile the project into bin/

Editing

VSCode has great haxe IDE support with the haxe extension

I recommend installing the trigger task on save extension โ€“ this will trigger the project to recompile when you save haxe files, which is helpful for live editing

Project Overview

We can interact with three.js through externs generated from the typescript type definitions using the dts2hx tool. The generated externs are included in this repository in the .haxelib directory. To regenerate these files you can call npm run externs

three.js is included as a module by using require(), since browsers don't have require we use a bundler (esbuild) so we generate a single file โ€“ this is called by build.hxml. Alternatively we could have used three.js globally via a script tag if we generated the externs with --global

A haxe library, three-toolkit is included, which provides useful utilities for working with three.js and haxe, including

  • Post processing pipeline tools
  • A dat.gui extension: DevUI
  • CustomPhysicalMaterial for making pbr materials with custom shaders
  • Objects such as a soft mirror plane
  • Spring physics animation tooling

Why haxe not TypeScript?

Where TypeScript improves on JavaScript by adding types, haxe asks how could we build a better language from ECMAScript foundations, without maintaining the warts from js. On the surface syntactically it's similar to TS but differs in a few key ways:

  • metaprogrammig: you can mark functions for compile-time execution
  • there's only one way import code, simply import Module;
  • this only refers to the current type and does not change on context at runtime
  • it supports functional programming patterns inspired my meta languages like OCaml:
  • significantly faster compile-times
  • zero-cost abstraction types with abstracts

Have fun :D, feel free to open issues if you have questions

You might also like...

College project done for the CG Artwork lecture in 2022. Used HTML for the indexes and mainly JavaScript (using to THREE.js). Ended with the final A grade (17.3 in scale grade).

CG Artwork Project 2022 This project was done by a group of 3 in 2022 with an educational purpose for the CG Artwork lecture in Instituto Superior Tรฉc

Sep 19, 2022

Three.js boilerplate project configured with typescript, webpack and css/style loader, HTTPS local server, and a sample test codes !!

Three.js boilerplate project configured with typescript, webpack and css/style loader, HTTPS local server, and a sample test codes !!

three.js-boilerplate Welcome, this is a three.js boilerplate project where you can clone it and start to work !!! Installed and Configured Items: Type

Jul 6, 2022

This fictive project was created to showcase my current skills using Three.js and GSAP.

This fictive project was created to showcase my current skills using Three.js and GSAP.

Bike Demo Three.js This fictive project was created to showcase my current skills using Three.js and GSAP. It was inspired by the tutorial created by

Dec 29, 2022

Starter Project for Nuxt3 project with full tailwind3 implementation and also docker & docker-compose supprt

Nuxt 3 & Tailwind 3 Starter Including tailwindConfig and Tailwind Config Viewer! Be patient, this is just a Beta version of Nuxt3. For Nuxt3 Installat

Nov 10, 2022

This project is based on my nodejs starter kit. Simple CRUD project.

nodejs-crud-project Author - Akhil Sharma This project uses the nodeJS-starter project on my github. Just a demo to show you could build any project w

Dec 16, 2022

๐ŸŒ A Declarative 3D Globe Data Visualization Library built with Three.js

๐ŸŒ  A Declarative 3D Globe Data Visualization Library built with Three.js

Gio.js English | ไธญๆ–‡ React Version: react-giojs Wechat minigame: wechat usage Gio.js is an open source library for web 3D globe data visualization buil

Dec 29, 2022

๐Ÿ‡จ๐Ÿ‡ญ A React renderer for Three.js

๐Ÿ‡จ๐Ÿ‡ญ A React renderer for Three.js

react-three-fiber react-three-fiber is a React renderer for threejs. npm install three @react-three/fiber Why? Build your scene declaratively with re-

Jan 9, 2023

CSS 3D renderer for Three.js.

CSS 3D renderer for Three.js.

CSS3D.js by Steven Wittens CSS 3D renderer for Three.js Note: this library is mostly obsolete now that Three.js has its own CSS 3D renderer which is i

Aug 27, 2022

BadTV Effect for Three.js

BadTV Effect for Three.js

Bad TV Shader for Three.js Simulates a bad TV via horizontal distortion and vertical roll. Screenshot Demo View Demo Uniforms time steadily increasing

Dec 21, 2022

3D graph viewer powered by WebGL (three.js)

3D graph viewer powered by WebGL (three.js)

Graphosaurus A three-dimensional static graph viewer. (click the image to try it out) Demos EVE Online map Add nodes incrementally Documentation JSDoc

Dec 4, 2022

Adding volumetric effects to a built-in Three.js shader.

Adding volumetric effects to a built-in Three.js shader.

Magical Marbles in Three.js Adding volumetric effects to a built-in Three.js shader. Article on Codrops Demo Installation Install dependencies: yarn

Dec 9, 2022

Interactive digital art with head-coupled perspective effect using Three.js and TensorFlow.js

Interactive digital art with head-coupled perspective effect using Three.js and TensorFlow.js

Interactive digital frame with head-tracking using Three.js & TensorFlow.js Using TensorFlow.js and Three.js, this project is a prototype of an intera

Dec 12, 2022

3D web map rendering engine written in TypeScript using three.js

3D web map rendering engine written in TypeScript using three.js

3D web map rendering engine written in TypeScript using three.js

Dec 30, 2022

An intro to Three.js and React :) Workshop materials and demo from HackTheNorth 2021

An intro to Three.js and React :) Workshop materials and demo from HackTheNorth 2021

๐Ÿš„ Speedy 3D - A Quick Intro to Three.js & React This workshop was originally created for Hack The North 2021! My personal motivation was to: learn th

Dec 17, 2021

bare bones demo of svelte-three

create-svelte Everything you need to build a Svelte project, powered by create-svelte; Creating a project If you're seeing this, you've probably alrea

Jul 30, 2022

Real-time motion planner and autonomous vehicle simulator in the browser, built with WebGL and Three.js.

Real-time motion planner and autonomous vehicle simulator in the browser, built with WebGL and Three.js.

Dash Self-Driving Car Simulator Real-time motion planner and autonomous vehicle simulator in the browser, built with WebGL and Three.js. This project

Dec 3, 2022

Interactive 3D plotting with a simple function call using Three.js

Interactive 3D plotting with a simple function call using Three.js

About Generate interactive 3d plots with a simple function call. Function returns a Three.js scene which can be customized as needed. Basic function c

Oct 20, 2022
Comments
  • Is there a way cast to generic type without knowing T๏ผŸ

    Is there a way cast to generic type without knowing T๏ผŸ

    I'm practicing the offical case code, read fbx model and do something with it

    object.traverse(function (child) {
         if ((child as THREE.Mesh).isMesh) {   
               // do something
        }
    })
    

    where in haxe THREE.Mesh is defined as extern class Mesh<TGeometry, TMaterial> extends Object3D<Event> Iโ€™cant just call(cast child: Mesh).isMesh, there will be โ€œno enough parametersโ€ error, what should i do?

    opened by FlowSand 4
  • Compilation error occurs when using this template library to directly apply the official case code

    Compilation error occurs when using this template library to directly apply the official case code

    Recently, I am using haxe+electron to develop an app. I need to use the Threejs library for 3D model rendering, so I noticed the dts2hx solution. I downloaded this template library and modified some code for testing. According to the official example (written in js), I found that the calling method of some official cases is not feasible in haxe, for example๏ผš

    var dirLight = new DirectionalLight(0xffffffff);
    dirLight.shadow.camera.top = -5;
    dirLight.shadow.camera.left = -5;
    

    The camera member in LightShadow is Camera type, while the top and left fields are defined in the OrthographicCamera class, which extends from camera. It cannot be called directly in haxe like js. Is there any other way to call it?

    opened by FlowSand 2
  • Some of class was not created in src of three.js

    Some of class was not created in src of three.js

    three.js v 135

    Some of class was not created in src of three.js

    ShapeGeometry.hx

    I can find ShapeGeometry.d.ts in@types\three\src\geometries\ShapeGeometry.d.ts

    opened by sonygod 1
  • InteractionEventsManager  not work for the other renderer?

    InteractionEventsManager not work for the other renderer?

    InteractionEventsManager not work for the other renderer?

    I copy your template some code to do that and find it only works for one render.

    screenshot-localhost_2009-2022 01 14-16_08_25 haxe-threejs-template.zip

    opened by sonygod 3
Owner
George Corney
Hi! I write and help maintain libraries for the haxe community. I also _love_ graphics programming and try to open source everything I can there :)
George Corney
A helper to send whatsapp without scheduling a contact, the project developed using TDD with Jest, Javascript classes, BotstrapVue and SweetAlert.

Project setup npm install Compiles and hot-reloads for development npm run serve Compiles and minifies for production npm run build Lints and fixes

Magascript 7 Sep 13, 2022
An example project using Node.js to run some common tasks including directory backup

All code from this tutorial as a complete package is available in this repository. If you find this tutorial helpful, please share it with your friend

Alex 11 Sep 28, 2022
three.js examples. if you are first in learning three.js , this will give you much help.

three-projected-material Three.js Material which lets you do Texture Projection on a 3d Model. Installation After having installed three.js, install i

null 22 Nov 2, 2022
Text Engraving & Extrusion demo based on Three.js is implemented with Typescript and webpack5. Used THREE-CSGMesh as the core tech to achieve engraving and extrusion results

Text Engraving & Extrusion Text Engraving & Extrusion demo is implemented using Three.js, with Typescript and webpack5. Used THREE-CSGMesh as the core

Jiahong Li 3 Oct 12, 2022
GitHub starter project link: https://github.com/buildspace/waveportal-starter-project

Running React on Repl.it React is a popular JavaScript library for building user interfaces. Vite is a blazing fast frontend build tool that includes

MD Rafi Uddin 0 Jun 5, 2022
NFT Game Starter Project: https://github.com/buildspace/buildspace-nft-game-starter

Running React on Repl.it React is a popular JavaScript library for building user interfaces. Vite is a blazing fast frontend build tool that includes

Zahuis 2 Feb 11, 2022
Starter-gatsby-blog - Gatsby starter for a Contentful project from the community.

Contentful Gatsby Starter Blog Create a Gatsby blog powered by Contentful. Static sites are scalable, secure and have very little required maintenance

Priya Chakraborty 0 Jan 29, 2022
Node-cli-starter - Basic starter kit for building Node CLI applications with TypeScript.

node-cli-starter Minimal starter kit for building Node CLI applications with TypeScript. Getting Started To get started clone repo locally and run npm

Cory Rylan 7 May 17, 2022
Simple Three js game project

Simple Game This is a simple game developed with three.js library. Usage To run the game, we must start a web server with the command "python -m http.

Aydฤฑn BaลŸkara 1 Jun 22, 2022
project using three.js and mediapipe

three.js-with-mediapipe project using three.js and mediapipe KOR ๋ฏธ๋””์–ดํŒŒ์ดํ”„์™€ three js๋ฅผ ์ด์šฉํ•œ ํ”„๋กœ์ ํŠธ ์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น ์ฝ”๋“œ ์ž‘๋™์„ ์œ„ํ•ด์„œ๋Š” ์˜์ƒ์„ ๋„ฃ์–ด์ฃผ๊ฑฐ๋‚˜, video๊ฐ€ ์•„๋‹Œ camera์‚ฌ์šฉํ•˜๋„๋ก ์ˆ˜์ •ํ•˜์—ฌ์•ผ

donguk 4 Sep 20, 2022