GithubHelp home page GithubHelp logo

trenc / klee.js Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 17.01 MB

klee.js is a (data driven) generator and wrapper for the magnificent three.js

License: GNU Affero General Public License v3.0

HTML 15.83% CSS 0.43% JavaScript 83.75%
threejs webgl 3d 3d-graphics javascript generator

klee.js's Introduction

klee.js

klee.js is a (data driven) generator and wrapper for the magnificent three.js.

The main usage is to programmatically create a WebGL scene by a backend (CMS, database, server-side scripts etc.). The backend handles and manage the objects, textures, positions and so forth and pipes this info to the generator which then builds the scene via three.js.

Be aware: This project is fresh and raw so expect changes in the API.

data

The data that will generate the scene is written as JavaScript object literal and can come from a parsed JSON file and/or directly from a CMS.

data schema

The renderer, camera and scene are managed by an option object literal which is injected to init the app. The default options (default.options.js) are highly opinionated but can be changed. The options for the renderer are a bit different than for the other objects.

Meshs are builds from geometries and materials and can be added as array. See the basic-cube-and-sphere example.

In general the literal for a basic object looks like the following:

	const obj = {
		type: constructor, // a three.js constructor
		args: argArray, // the args for the constructor as array
		properties: { // object literal with properties
			property1: value,
			property2: { x: xValue, y: yValue }
		},
		methods: { // object literal with methods of this object/class
			method1: argsArray1, // method args as array
			method2: argsArray2
		}
	};

An item/mesh has an enhanced specification for material and textures:

	const item = {
		geometry: {
			type: constructor, // a three.js geometry constructor
			args: argArray // the args for the constructor as array
		},
		material: {
			type: constructor, // a three.js material constructor
			properties: { // object literal with properties for the material
				property1: value
			},
			textures: [ // array of textures images
				{
					type: constructor, // a three.js texture constructor (default: TextureLoader)
					map: mapType, // type of the map (normalMap, aoMap, bumpMap etc)
					url: path/to/image, // path to the image, array for cube texture
					properties: { // properties of the map/texture
						property1: value
					}
				}
			]
		},
		properties: { // item/mesh properties
			property1: value
		}
	}

For more details and clarifications see examples in the example folder and the default.options.js in /src.

demo/example

See the content in the example folder or see the deployment on the github pages: examples,

tests

Running tests with Cypress requires a running webserver. So first start it:

$ npm run test:serve &

Then start either the runner UI with

$ npm run test:cy:open

or run all tests in CLI mode:

$ npm run test:cy:run

TODO in no particular order

  • tests
  • simple objects
  • OrbitControls
  • textures
  • groups
  • raycaster
  • selections
  • backup/restore
  • transactions
  • Collada-, GLTF-Import
  • physics
  • collisions
  • constructive solid geometries
  • interactions
  • dragging
  • gridsystem
  • userData
  • examples
  • ...

credits

Examples contains assets from ambientCG.com and polyhaven.com, licensed under CC0 1.0 Universal.

klee.js's People

Contributors

trenc avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.