lunchboxjs
lunchboxjs copied to clipboard
Function to split contents of GLTF
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>