trois icon indicating copy to clipboard operation
trois copied to clipboard

Object3D lifecycle

Open klevron opened this issue 4 years ago • 2 comments

A lot of components extends Object3D (Group, Light, Mesh, InstancedMesh...), we have to find a nice way to handle life cycle (#25, #26).

Events could be :

  • created : https://github.com/troisjs/trois/commit/f90cb8d6f8e69ee9f2c69fd12b24a335e44fc3c7
  • ready (added to parent) : https://github.com/troisjs/trois/commit/5134ff91e6fa0f7cea185a416f0b88d7a40a2152
  • beforeRemove ?

Do we have to handle something like onSetGeometry, onSetMaterial ?

Thanks @SaFrMo for the help

klevron avatar Mar 20 '21 20:03 klevron

And something useful we have to handle : not remove the object when needed, example : https://troisjs.github.io/little-planet/ Objects are removed after tween is complete.

klevron avatar Mar 20 '21 20:03 klevron

About InstancedMesh and #25 :

<InstancedMesh :count="count" @created="initIMesh">
  <SphereGeometry :radius="5" />
  <BasicMaterial />
</InstancedMesh>
methods: {
  initIMesh(imesh) {
    // no need to set needsUpdate (object has not been rendered yet)
  },
},

klevron avatar Mar 20 '21 20:03 klevron