trois icon indicating copy to clipboard operation
trois copied to clipboard

Adding new objects to render

Open StianWiu opened this issue 2 years ago • 3 comments

Hi, I'm trying to render a world of squares from a table, it is working but I am unable to add more squares after it has been rendered. This is using Vue-reactivity which I have read isn't a smart move if you want good performance.

Though I am not too bothered about the performance.

So how would I go about either forcing it to re-render or properly loading the items from the table? Or if there are any other smart ways of doing this I am open to suggestions.

StianWiu avatar Apr 14 '22 13:04 StianWiu

Try using the loops. If does not work reason it the update from ref(); or you need to watch variable change to update the render. Other reason is the update the ref doesn't update the render as I am not sure if is sync or compare changes to update it.

const entities = ref([]);
let objEnties = [];
watchEffect(()=>{
   objEnties = unref(entities.value);
})
<Renderer>
<Scene>
<template v-for="entity in objEntities" :key="entity.objectid">
  <box />
</template>
</Scene>
</Renderer>

Lightnet avatar Apr 15 '22 21:04 Lightnet

I am getting a bunch of not defined errors, "ref", "watchEffect" & "unref" is not defined when doing that. This might be a lot to ask but would you be up to sitting down with me for like 15 minutes on discord and help me? Would love to learn this, but I'm definitely not going about it the right way.

Pignuuu#3333 on discord if you can.

StianWiu avatar Apr 16 '22 12:04 StianWiu

Those are vue for ref, watchEffect, unref. https://vuejs.org/api/options-state.html#watch https://vuejs.org/api/reactivity-core.html#watcheffect

Lightnet avatar Apr 16 '22 16:04 Lightnet