0.0.19 • Published 3 years ago

convex-pixel v0.0.19

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

ConvexPixel

cpx

A library for creating pseudo 3d interactive scenes based on web gl

dependencies

🔧 Installation

yarn add convex-pixel

or

npm install convex-pixel

Examples

Go checkout examples !

Live demo

Look at the demo !

Getting started

Let's demonstrate simple usage with basic example:

import CPX from "convex-pixel";

class App extends CPX.core.App<MyRoom> {

  constructor(appConfig: CPX.core.IAppConfig) {
    super(appConfig);

    this._room = new MyRoom(appConfig);

    this._room.setSize(DEFAULT_ROOM_WIDTH, DEFAULT_ROOM_HEIGHT);

    this.pixi.stage.addChild(this.room);

    this.createConvexObject();
  }

  private createConvexObject() {
    const cpxObj = new CPX.display.ConvexObject(this.appContext, {
      depth: 2.5;
      hitArea: [0,0,200,0,200,200,0,200];
      diffuseMap: "./assets/diffuse.png";
      depthMap: "./assets/depth.png";
      ...
    });

    scene.addChild(cpxObj);
  }
}

class MyRoom<C extends CPX.core.App = any> extends CPX.display.BaseRoom<C> {

  constructor(appContext: C) {
    super(appContext, {
      camera: {
        class: CPX.camera.Camera,
        config: {
          pov: 1;
          maxXOffset: 2;
          maxYOffset: 2;
          xOffset: 1;
          yOffset: 0.75
        },
        controllers: [
          CPX.camera.CameraMouseController,
          CPX.camera.CameraGyroscopeController,
        ],
      },
      autosize: CPX.utils.display.O_FILL,
    });
  }
}

const APP_CONFIG: CPX.core.IAppConfig = {
  transparent: true,
  view: document.getElementById('dom-el'),
}

new App(APP_CONFIG);

MIT License

Copyright (c) 2019 djonnyx djonnyx@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.0.19

3 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago