<script setup lang="ts">
import { useGLTF } from '@tresjs/cientos'
import { Box3, Vector3 } from 'three';
const props = defineProps(['modelUrl'])
const { scene } = await useGLTF(props.modelUrl)
console.log(scene, props.modelUrl)
scene.receiveShadow = true
scene.castShadow = true

const box = new Box3();
box.expandByObject(scene.children[0]);
let center = new Vector3();
box.getCenter(center)
let size = new Vector3();
box.getSize(size)

const box_size = [size.x, size.y, size.z]

scene.children.forEach((el:any) => {
    el.castShadow = true
    el.receiveShadow = true
});
</script>
<template>
    <TresGroup>
        <TresMesh :position="center" cast-shadow receive-shadow v-if="false">
            <TresBoxGeometry :args="box_size" />
            <TresMeshPhysicalMaterial :opacity="0" color="pink" :transparent="true" />
        </TresMesh>
        <primitive :object="scene" cast-shadow receive-shadow />
    </TresGroup>
</template>