Giter VIP home page Giter VIP logo

physics-module-ammonext's Introduction

Three Build Status

Community chat. Join us!

Discord

Table of content

New releases

whs is currently at v2 major version. We had plans for v3 yet but development isn't active. So v2 will probably remain the main stable version until further notice.

We try to publish minor update releases for bug fixes, we will review PRs.

NPM

# Install npm version
$ npm install whs

For [email protected] (Three.js r92) use @beta tag

# Install npm version
$ npm install whs@beta

NPM Version

Basic setup

Download the minified library or link the one from CDN

<script src="js/three.min.js"></script>
<script src="js/whs.min.js"></script>

The code below makes a WHS.App instance which handles all your modules and components for better work with WebGL. This one creates a scene, camera and renderer - we add the following modules to the App.

const app = new WHS.App([
  new WHS.ElementModule(), // Apply to DOM.
  new WHS.SceneModule(), // Create a new THREE.Scene and set it to app.

  new WHS.DefineModule('camera', new WHS.PerspectiveCamera({ // Apply a camera.
    position: new THREE.Vector3(0, 0, 50)
  })),

  new WHS.RenderingModule({bgColor: 0x162129}), // Apply THREE.WebGLRenderer
  new WHS.ResizeModule() // Make it resizable.
]);

app.start(); // Run app.

Featured projects

https://moxy.studio/ https://rmallick6806.github.io/SolarSystemBuilder/ http://www.tpain.com/ http://artifacts.zone/lorenzav/ http://artifacts.zone/tree/ http://abdaily.surge.sh/4/ http://abdaily.surge.sh/2/ http://abdaily.surge.sh/1/ http://theroguepixel.com/ http://supertiny.agency/ https://alexbuzin.me/ https://spatial.100shapes.com/ http://plateaux.space/

Features

  • πŸ’Ž Simple in usage
  • πŸš€ Speeds up 3D scene prototyping
  • πŸ”Œ Component based scene graph
  • πŸ’£ Simple integration of any high performance physics even with Worker (Multithreading)
  • πŸ’« Automatization of rendering
  • πŸ†• ES2015+ based
  • πŸ”· Extension system (modules)
  • πŸ“¦ Webpack friendly
  • βœ”οΈ Integrated Three.js rendering engine
  • πŸ’ž Work with whs.js and Three.js at the same time

External Modules

Name Status Description
physics-module-ammonext NPM Version Physics module based on Ammo.js

Donate

OpenCollective Backers OpenCollective Sponsors

Backers

Support us with a monthly donation and help us continue framework developmentπŸŽ‰ and adding new featuresπŸ’‘πŸŽ.

physics-module-ammonext's People

Contributors

alkavan avatar caco26i avatar lucasleandro1204 avatar sasha240100 avatar utrobin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

physics-module-ammonext's Issues

Error when passing ammo.js path

Hey,

I've installed ammo.js with npm and did the following:

new PHYSICS.WorldModule({
    ammo: '../node_modules/ammo.js/ammo.js'
}),

I'm getting this error:

Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The URL '../node_modules/ammo.js/ammo.js' is invalid.

I've also tried with unpkg:

new PHYSICS.WorldModule({
    ammo: 'https://unpkg.com/[email protected]/ammo.js'
}),

And got this:

Uncaught TypeError: Ammo is not a constructor

Can you give me an example of how to do this?

Thanks!

An issue with node_modules/google-closure-compiler when building

I have an issue when executing build:

With JAVA:

openjdk version "1.8.0_144"
OpenJDK Runtime Environment (build 1.8.0_144-b01)
OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode)
Scene imported from external module 'three' but never used
created build/physics-module.native.js, build/physics-module.native.module.js in 15.2s

> [email protected] minify /home/wdna/Develop/Games/physics-module-ammonext
> java -jar node_modules/google-closure-compiler/compiler.jar --warning_level=VERBOSE --jscomp_off=globalThis --jscomp_off=checkTypes --language_in=ECMASCRIPT6_STRICT --externs tools/build/externs.js --js build/physics-module.js --js_output_file build/physics-module.min.js

ERROR - Cannot read file tools/build/externs.js: {1}

1 error(s), 0 warning(s)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] minify: `java -jar node_modules/google-closure-compiler/compiler.jar --warning_level=VERBOSE --jscomp_off=globalThis --jscomp_off=checkTypes --language_in=ECMASCRIPT6_STRICT --externs tools/build/externs.js --js build/physics-module.js --js_output_file build/physics-module.min.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] minify script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
...

I'm actually trying to fix an issue with (I assume):

import PhysicsWorker from 'worker!../worker.js';

Cause:

ERROR in ./node_modules/physics-module-ammonext/src/modules/WorldModule.js
Module not found: Error: Can't resolve 'worker' in '/home/wdna/Develop/Games/ste/node_modules/physics-module-ammonext/src/modules'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
                 You need to specify 'worker-loader' instead of 'worker',
                 see https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed
 @ ./node_modules/physics-module-ammonext/src/modules/WorldModule.js 5:0-48
 @ ./node_modules/physics-module-ammonext/src/modules/index.js
 @ ./app/main.js

In main application.

A possible typo and undefined attributes - reportConstraints function

Hello!

Ive been looking through your nice library and I found some puzzling things about the reportConstraints function.

1. Typo

It seems like there might be a typo here where .lenght should be .length

index = _constraints.lenght;

It also seems as if it was not fixed for quite a while.

2. .ta attribute is defined conditionally

The .ta attribute is set in the addConstraint function for the slider, conetwist, and dof types.

constraint.ta = transforma;
constraint.tb = transformb;

The .ta attribute is only used in the reportConstraints function for ALL constraints regardless of type.

while (index--) {
if (_constraints[index]) {
var _constraint = _constraints[index];
var offset_body = _constraint.a;
var transform = _constraint.ta;
var origin = transform.getOrigin();
// add values to report
offset = 1 + i++ * CONSTRAINTREPORT_ITEMSIZE;
constraintreport[offset] = index;
constraintreport[offset + 1] = offset_body.id;
constraintreport[offset + 2] = origin.x;
constraintreport[offset + 3] = origin.y;
constraintreport[offset + 4] = origin.z;
constraintreport[offset + 5] = _constraint.getBreakingImpulseThreshold();
}
}

Therefore, if you create a constraint that does not set the .ta attribute, you will get an error when this function is run:

screen shot 2018-07-31 at 11 52 10 pm

Unclear on how to apply force or manipulate the physics body.

Trying out a prototype idea with whitestorm. Was able to setup a scene, but running into issues trying to do things with the physics engine. I see a number of useful methods here: https://github.com/WhitestormJS/physics-module-ammonext/blob/master/src/modules/physicsPrototype.js, but i have no way to execute them. I've tried accessing:

object.modules[0], which is the instance of PHYSICS.BoxModule i'm using, but it has none of these methods.

THREE is not define.

In these case:

import { $colors, getBasicLights, appModules } from '../global';

import { Vector3, Vector2, MeshPhongMaterial, DoubleSide } from 'three';
import { HeightfieldModule, SphereModule } from 'physics-module-ammonext';
import { Parametric } from 'whs';

const func = (u, v) => {
  return new Vector3(u * 100, Math.sin(u * 10) * 4, v * 100);
};

try {
  const params = {
    geometry: {
      func,
      slices: 40,
      stacks: 40
    },

    shadow: {
      cast: false
    },

    material: new MeshPhongMaterial({
      color: $colors.mesh,
      side: DoubleSide
    }),

    modules: [
      new HeightfieldModule({
        mass: 0,
        size: new Vector2(40, 40),
        autoAlign: true
      })
    ]
  };
  const p = new Parametric(params);
} catch (error) {
  console.log('Parametric error', error);
}

error:
image

  1. When i remove params.modules, all exceptions are gone.
  2. Import three to global scope, everything are well.
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/87/three.min.js"></script>
...
</head>
...
</html

Must i import three to global scope?

Physics doesn't work for objects in groups

Hi,

Applying any kind of PHYSICS.XXXModule to an object inside a group doesn't apply physics to that object.

An example:

This works:

  const mesh = new WHS.Plane({
    geometry: {
      width: 1000,
      height: 1000,
    },
    rotation: new THREE.Euler(-Math.PI / 2,0,0),
    modules: [
      new PHYSICS.PlaneModule({
        mass: 0,
        restitution: 0,
      }),
    ],
    material: new THREE.MeshPhongMaterial({ color: 0xffffff })
  });

ground.addTo(app);

But if I replace the last line by:

const group = new WHS.Group(ground);
group.addTo(app);

The plane will not have any physics.

Documentation for this module

Hi,

This module is really awesome! Is there a official documentation to introduce the details including all properties for all methods? Thanks!

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.