Skip to content

object3d

Lightnet edited this page Apr 17, 2022 · 2 revisions

Information:

Object3d troisjs has setup call and emit events for mesh and init set mesh for handle users data.

As well get parent scene and renderer checks. When the create/mount/setup event default by vue api.

Note that mesh.userData is being used to assign component and physics.

It can found in src/core/object3d.

https://github.com/troisjs/trois/blob/master/src/core/Object3D.ts

emits: ['created', 'ready'],

https://github.com/troisjs/trois/blob/master/src/meshes/Mesh.ts

mounted() {
    // TODO : proper ?
    if (!this.mesh && !this.loading) this.initMesh()
},

render example:

It depend on the vue component setup.

function initMesh(iMesh){
  iMesh.userData.mass = 1;
  iMesh.userData.collisionFilterGroup = GROUP1;
  iMesh.userData.collisionFilterMask = GROUP3;
}
<Box @created="initMesh" :position="{ x: 0, y: 10, z: 0 }">
  <PhongMaterial color="#ffffff" />
</Box>
Clone this wiki locally