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.
update three.js version, add three js as peer dependency
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);
}
}
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