UNPKG

matrix-engine

Version:

basic_timeline improved, VT func setup vide html element id with name arg.- DISABLE RAYCAST DEBUG TEST [2.3.3] Fix for GUI win desktop [2.3.0] DestrucMesh solution & loading convex objs for physics BASIC, SpriteAnimation CPU/texture solution added, Improv

50 lines (40 loc) 1.28 kB
/** *@Author Nikola Lukic zlatnaspirala *@Description Matrix Engine Api Example * WORKSHOP SCRIPT * Current theme : SceneController and * physics (cannon.js) implementation. */ import App from "../program/manifest"; import * as CANNON from 'cannon'; export var runThis = (world) => { App.camera.SceneController = true; var tex = { source: ["res/images/complex_texture_1/diffuse.webp"], mix_operation: "multiply", }; // Load Physics world! let gravityVector = [0, 0, -9.82]; let physics = world.loadPhysics(gravityVector); // Add ground physics.addGround(App, world, tex); const objGenerator = (n) => { for(var j = 0;j < n;j++) { setTimeout(() => { world.Add("sphereLightTex", 1, "BALL" + j, tex); var b2 = new CANNON.Body({ mass: 1, linearDamping: 0.005, angularDamping: 0.5, angularVelocity: new CANNON.Vec3(0.01, 0.01, 0), position: new CANNON.Vec3(1, -14.5, 15), shape: new CANNON.Sphere(1) }); physics.world.addBody(b2); App.scene['BALL' + j].physics.currentBody = b2; App.scene['BALL' + j].physics.enabled = true; }, 1000 * j) } } objGenerator(10) };