lunchboxjs icon indicating copy to clipboard operation
lunchboxjs copied to clipboard

Function to split contents of GLTF

Open SaFrMo opened this issue 2 years ago • 0 comments

Problem: User wants to load a model and work with the scene.children individually. In Lunchbox, the gltf plugin handles loading and adding a model to a scene, but the object is only available to work with via the single gltf component in HTML or by splitting elements via JS.

Suggested fix: Add a lunchbox-holder or similar that can serve as a Lunchbox <-> JS translation layer - something like:

<template>
  <!-- ... -->
    <lunchbox-holder v-for="obj in objects" :contents="obj" />
  <!-- ... -->
</template>

<script lang="ts">
const objects = ref<THREE.Object3D[]>([])
const gltf = await doSomethingToLoadModel()
objects.value = gltf.scene.children
// now there's a `lunchbox-holder` for each child of the GLTF, with props and children bound correctly
</script>

SaFrMo avatar Jan 15 '23 15:01 SaFrMo