Hi, as commented previously on a different post, I am currently in the process of updating from peterqliu's threebox library to this forked version, I think I may of come across a bug with the 'duplicate' function. Below is the JavaScript code from a modified example of logistics (also a google drive shareable link which contains the whole example HTML file), which duplicates a model and tires to call setCoords. However once setCoords is called an error is thrown in the console and the model is not added to the map.
const origin = [-122.4340, 37.7353];
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/dark-v9',
center: origin,
zoom: 14,
pitch: 60,
bearing: 90
});
map.on('style.load', function () {
map
.addLayer({
id: 'custom_layer',
type: 'custom',
renderingMode: '3d',
onAdd: function (map, mbxContext) {
window.tb = new Threebox(
map,
mbxContext,
{ defaultLights: true }
);
var options = {
type: 'gltf',
// converted the truck example to glb but I seem to get the same error with obj files
obj: 'models/truck.glb',
scale: 10,
units: 'meters',
rotation: { x: 90, y: 180, z: 0 },
}
tb.loadObj(options, function (model) {
truck = model.setCoords(origin);
tb.add(truck);
// const new_truck = truck; Works without duplication however only shows last added model
const new_truck = truck.duplicate();
tb.add(new_truck);
// where the error is being thrown
new_truck.setCoords([-122.4702, 37.6879]);
})
},
render: function (gl, matrix) {
tb.update();
}
});
});`