Hello,
I have a problem with the example project of the Tree animation placement, if you guys can help.
All im trying to do is to load a different 3D Object instead of the trees.
In the projects code, inside the place-ground-scene-module.js file,
in line 7, i changed the file path to the object i loaded through the bundle : const modelFile = require(‘./assets/concrete002.gltf’)
the first error it pops out in the console is:
TypeError: Cannot read properties of undefined (reading ‘children’)
I saw that the GLTFLoader constructor is non-defined, and that’s an error that was also before with the tree object. so i tried to use it’s parent class constructor.
Instead of writing:
const loader = new GLTFLoader()
i wrote:
const loader = new THREE.GLTFLoader()
then it shoots out an error:
Uncaught TypeError: THREE.GLTFLoader is not a constructor
any idea what’s the problem here? you can accesses the project and the files through the quickstart
thanks for any help
const animateIn = (model, pointX, pointZ, yDegrees) => {
const scale = {...startScale}
model.scene.rotation.set(0.0, yDegrees, 0.0)
model.scene.position.set(pointX, 0.0, pointZ)
model.scene.scale.set(scale.x, scale.y, scale.z)
// Set castShadow on the first child of the scene, if it exists
if (model.scene.children.length > 0 && model.scene.children[0]) {
model.scene.children[0].castShadow = true
} else {
console.error('No children found in the model to cast shadow.')
}
XR8.Threejs.xrScene().scene.add(model.scene)
Hey man, sorry for the late reply
your code solved it! thank you very much
the problem was it was trying to access and arbitrary model and not a scene specific object?