npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

matrix-engine-wgpu

v1.0.6

Published

webGPU powered pwa application. Crazy fast rendering with AmmoJS physics support.

Downloads

28

Readme

matrix-engine-wgpu

[not fully operative for now - WIP]

Author Nikola Lukic [email protected] 2024

Logo:

In logo i used webGPU logo from:

WebGPU logo by W3C. The logos are licensed under Creative Commons Attribution 4.0 International. Download from https://www.w3.org/2023/02/webgpu-logos.html

Used npm package wgpu-matrix for replacment of glmatrix library.Classis "modelViewProjectionMatrix" calculations. I publish (this repo) npm package with name matrix-engine-wgpu.

Objective

  • scene objects feature [objects/scene/transformation]
  • Make it similar to the matrix-engine webGL features.
  • Main base example is shadowMapping from webgpu-samples
  • Integrate ammojs

Support list

  • Only access to the object scene instance look like: mainRenderBundle is scene holder.

    app.mainRenderBundle[0];

    For now only addMeshObj works [Obj file loader].

Camera

Camera type: WASD | arcball

  mainCameraParams: {
    type: 'WASD',
    responseCoef: 1000
  }

Position

app.mainRenderBundle[0] -> position

Position is taken from matrix-engine[webgl] same struct.

app.mainRenderBundle[0].position.translateByX(12);

Teleport/ direct set

app.mainRenderBundle[0].position.SetX(-2);

Change speed of translation

app.mainRenderBundle[0].position.thrust = 0.1;

####Note: Position for Physics enabled object look like: No working .position and .rotation in physics enabled regime. You must use Ammo body funcs like : applyForce, setAngularVelocity, setLinearVelocity etc...

app.matrixAmmo.rigidBodies[0].setAngularVelocity(new Ammo.btVector3(0,2,0))
app.matrixAmmo.rigidBodies[0].setLinearVelocity(new Ammo.btVector3(0,7,0))

Rotation

app.mainRenderBundle[0].rotation

Rotate object by axis by degree:

app.mainRenderBundle[0].rotation.x = 45

Active rotation

app.mainRenderBundle[0].rotation.rotationSpeed.y = 10

Stop rotating

app.mainRenderBundle[0].rotation.rotationSpeed.y = 0

Note: In physics enabled object .rotation have no affect.

How to load obj [with uvs] file:

Main instance script:

import MatrixEngineWGPU from "./src/world.js";
import {downloadMeshes} from './src/engine/loader-obj.js';
import {LOG_FUNNY, LOG_INFO, LOG_MATRIX} from "./src/engine/utils.js";

export let application = new MatrixEngineWGPU({
  useSingleRenderPass: true,
  canvasSize: 'fullscreen',
  mainCameraParams: {
    type: 'WASD',
    responseCoef: 1000
  }
}, () => {

  addEventListener('AmmoReady', () => {
    downloadMeshes({
      welcomeText: "./res/meshes/blender/piramyd.obj",
      armor: "./res/meshes/obj/armor.obj",
      sphere: "./res/meshes/blender/sphere.obj",
      cube: "./res/meshes/blender/cube.obj",
    }, onLoadObj)
  })

  function onLoadObj(m) {
    application.myLoadedMeshes = m;
    for(var key in m) {
      console.log(`%c Loaded objs: ${key} `, LOG_MATRIX);
    }

    application.addMeshObj({
      position: {x: 0, y: 2, z: -10},
      rotation: {x: 0, y: 0, z: 0},
      rotationSpeed: {x: 0, y: 0, z: 0},
      texturesPaths: ['./res/meshes/blender/cube.png'],
      name: 'CubePhysics',
      mesh: m.cube,
      physics: {
        enabled: true,
        geometry: "Cube"
      }
    })

    application.addMeshObj({
      position: {x: 0, y: 2, z: -10},
      rotation: {x: 0, y: 0, z: 0},
      rotationSpeed: {x: 0, y: 0, z: 0},
      texturesPaths: ['./res/meshes/blender/cube.png'],
      name: 'SpherePhysics',
      mesh: m.sphere,
      physics: {
        enabled: true,
        geometry: "Sphere"
      }
    })
  }
})

window.app = application

NPM Scripts

Bundle compiler: watchify

  "main-worker": "watchify app-worker.js -p [esmify --noImplicitAny] -o public/app-worker.js",
  "examples": "watchify examples.js -p [esmify --noImplicitAny] -o public/examples.js",
  "main": "watchify main.js -p [esmify --noImplicitAny] -o public/app.js",
  "build-empty": "watchify empty.js -p [esmify --noImplicitAny] -o public/empty.js",
  "build-all": "npm run main-worker.js | npm run examples | npm run main | npm run build-empty"
  1. "main-worker" use same endpoint but with root wrapper.
  2. "examples" for now build just one current (just import script from ./examples/) instance.
  3. "main" this is build for main.js main instance.
  4. "build-empty" when you wanna use this engine on codepen or stackoverflow just build one empty instance and you can write megpu code.
  5. "build-all" build all at once [every output is diff name].

Resource

  • Resources place is ./public also this folder is root for output js builds, after all you get all needed stuff in one public folder (www).

LINKS

  • How to use it on codepen https://codepen.io/zlatnaspirala/pen/VwNKMar?editors=0011 I use empty build then i add/upload to my VPS public server you can use it: Usually last night build stable/unstable version. https://maximumroulette.com/apps/megpu/empty.js You can build your own with npm run build-empty.

LICENCE

Note:

"Just keep this text also any other about textual file / or code commnet with ref... and you can sell or what ever you want with your project."

  • Structural shema for project and personal learning inspired by: https://webgpu.github.io/webgpu-samples/samples/renderBundles also https://webgpu.github.io/webgpu-samples/?sample=shadowMapping

  • Obj loader [same like matrix-engine webgl engine] Obj loader source http://math.hws.edu/graphicsbook/source/webgl/cube-camera.html

BSD 3-Clause

https://github.com/webgpu/webgpu-samples/blob/main/LICENSE.txt

Copyright 2019 WebGPU Samples Contributors

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.