@qubixstudio/qunity
v0.3.11
Published
Helper framework for working with threejs based on Unity3D ideas.
Downloads
721
Maintainers
Readme
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