@qubixstudio/qunity
TypeScript icon, indicating that this package has built-in type declarations

0.3.11 • Public • Published

qunity

Three.js wrapper. Using Unity system of Gameobjects and components. Check example folder for some examples. Handle more camera in scene and their drawing. You can create own component in your project. Every component extends Monobehaviour.

Version 0.3.0

update three.js version, add three js as peer dependency

Component example

Each component should have a onDestroy method. Qunity handle destroing Gameobject and his components.

export abstract class Primitive extends Component {
  abstract mesh: Mesh;
  /** @internal */
  constructor() {
    super()
  }

  changePosition(): void {
    this.mesh.position.y += 1;
  }

  gameObjectSet(gameObject: GameObject): void {
    gameObject.attach(this.mesh);
  }

  onDestroy(): void {
    if(this.mesh)
      if(this.mesh.geometry)
        this.mesh.geometry.dispose()
      if(this.mesh.material)
        Utils3D.disposeMaterialSave(this.mesh.material);
  }
}

Gameobject

create new GameObject

const go = GameObject.create() // create new instance, the constructor cannot be used
this.transformControls = go.addComponent(TransformControls);
this.transformControls.addListener('dragging-changed', this.transformDraggingChange);
GameObject.add(go); //adding object to scene

Created by Qubix

https://www.qubixstudio.com/

Licence

https://opensource.org/licenses/MIT

Package Sidebar

Install

npm i @qubixstudio/qunity

Weekly Downloads

56

Version

0.3.11

License

MIT

Unpacked Size

1.11 MB

Total Files

143

Last publish

Collaborators

  • qubixstudio_office