This is not an issue! 3D Models in this version!
@yunikkk
I'm thinking of doing a PR by adding ModelSource for the next version.
any news thanks
any update?
you can use flutter_map and then The Marker.builder property will work with any widget Regardless of whether it's 2D or 3D. So anything inside the builder is out of scope of FM @favazHF
@fodedoumbouya @favazHF
await mapController.style.addStyleSource(
'test3d',
jsonEncode(
{
'type': 'model',
'models': {
'defaultModel': {
'uri':
'https://github.com/ezesoftchao/soscuba/raw/main/confort_last.glb',
'orientation': [0.0, 0.0, 90.0],
'position': [
-82,
23,
]
}
},
},
),
);
await mapController.style
.styleLayerExists('test3d')
.then((value) async {
if (!value) {
final layer = {
'id': 'test3d',
'source': 'test3d',
'visibility': 'visible',
'type': 'model'
};
await mapController.style
.addPersistentStyleLayer(json.encode(layer), null);
final properties = {
'paint': {
'model-rotation': [1.0, 1.0, bearing],
'model-opacity': 1.0,
'model-translation': [0.0, 0.0, 0.0],
'model-scale': [
'interpolate',
['exponential', 0.5],
['zoom'],
12,
[
'literal',
[80, 80, 80]
],
13,
[
'literal',
[60, 60, 60]
],
14,
[
'literal',
[50, 50, 50]
],
19,
[
'literal',
[3, 3, 3]
],
22,
[
'literal',
[1, 1, 1]
],
23,
[
'literal',
[0.2, 0.2, 0.2]
]
],
'model-type': 'common-3d'
},
};
await mapController.style
.styleLayerExists(
'test3d',
)
.then((exist) async {
if (exist) {
try {
await mapController.style.setStyleLayerProperties(
'test3d',
json.encode(properties),
);
} catch (e) {
if (kDebugMode) {
print(e);
}
}
}
});
}
});
thank you man @ezesoftchao
thank you man @ezesoftchao
don't worry, you must test first with the glb example, later gltf
@evil159 Hi bro! I've seen the new model layer. Could you add a model source object for 3D in future features, like the suggestion in this suggestion: https://github.com/mapbox/mapbox-maps-flutter/issues/243#issue-1909283287
@fodedoumbouya @favazHF
await mapController.style.addStyleSource( 'test3d', jsonEncode( { 'type': 'model', 'models': { 'defaultModel': { 'uri': 'https://github.com/ezesoftchao/soscuba/raw/main/confort_last.glb', 'orientation': [0.0, 0.0, 90.0], 'position': [ -82, 23, ] } }, }, ), );await mapController.style .styleLayerExists('test3d') .then((value) async { if (!value) { final layer = { 'id': 'test3d', 'source': 'test3d', 'visibility': 'visible', 'type': 'model' }; await mapController.style .addPersistentStyleLayer(json.encode(layer), null); final properties = { 'paint': { 'model-rotation': [1.0, 1.0, bearing], 'model-opacity': 1.0, 'model-translation': [0.0, 0.0, 0.0], 'model-scale': [ 'interpolate', ['exponential', 0.5], ['zoom'], 12, [ 'literal', [80, 80, 80] ], 13, [ 'literal', [60, 60, 60] ], 14, [ 'literal', [50, 50, 50] ], 19, [ 'literal', [3, 3, 3] ], 22, [ 'literal', [1, 1, 1] ], 23, [ 'literal', [0.2, 0.2, 0.2] ] ], 'model-type': 'common-3d' }, }; await mapController.style .styleLayerExists( 'test3d', ) .then((exist) async { if (exist) { try { await mapController.style.setStyleLayerProperties( 'test3d', json.encode(properties), ); } catch (e) { if (kDebugMode) { print(e); } } } }); } });
Thanks you @ezesoftchao it works like a charm !
I've some questions :
• Can I use a local asset ?
• It works with the mapbox gltf model too : https://docs.mapbox.com/mapbox-gl-js/assets/34M_17/34M_17.gltf. But when I save this gltf and your glb exemple files on Firebase Storage nothing appear. Do you have an idea ? CORS problem ?
Regards,
@fodedoumbouya @favazHF
await mapController.style.addStyleSource( 'test3d', jsonEncode( { 'type': 'model', 'models': { 'defaultModel': { 'uri': 'https://github.com/ezesoftchao/soscuba/raw/main/confort_last.glb', 'orientation': [0.0, 0.0, 90.0], 'position': [ -82, 23, ] } }, }, ), );await mapController.style .styleLayerExists('test3d') .then((value) async { if (!value) { final layer = { 'id': 'test3d', 'source': 'test3d', 'visibility': 'visible', 'type': 'model' }; await mapController.style .addPersistentStyleLayer(json.encode(layer), null); final properties = { 'paint': { 'model-rotation': [1.0, 1.0, bearing], 'model-opacity': 1.0, 'model-translation': [0.0, 0.0, 0.0], 'model-scale': [ 'interpolate', ['exponential', 0.5], ['zoom'], 12, [ 'literal', [80, 80, 80] ], 13, [ 'literal', [60, 60, 60] ], 14, [ 'literal', [50, 50, 50] ], 19, [ 'literal', [3, 3, 3] ], 22, [ 'literal', [1, 1, 1] ], 23, [ 'literal', [0.2, 0.2, 0.2] ] ], 'model-type': 'common-3d' }, }; await mapController.style .styleLayerExists( 'test3d', ) .then((exist) async { if (exist) { try { await mapController.style.setStyleLayerProperties( 'test3d', json.encode(properties), ); } catch (e) { if (kDebugMode) { print(e); } } } }); } });Thanks you @ezesoftchao it works like a charm !
I've some questions :
• Can I use a local asset ? • It works with the mapbox gltf model too :
https://docs.mapbox.com/mapbox-gl-js/assets/34M_17/34M_17.gltf. But when I save this gltf and your glb exemple files on Firebase Storage nothing appear. Do you have an idea ? CORS problem ?Regards,
Possibly it's a CORS issue, I haven't actually tried with Firebase Storage.
@evil159 Hi bro! I've seen the new model layer. Could you add a model source object for 3D in future features, like the suggestion in this suggestion: #243 (comment)
@ezesoftchao You can directly add model to the style and pass it to model layer: https://github.com/mapbox/mapbox-maps-flutter/blob/80d7b37cd9d04f40bd92adf9d6764f631b57c473/example/lib/model_layer.dart#L61-L64 https://github.com/mapbox/mapbox-maps-flutter/blob/80d7b37cd9d04f40bd92adf9d6764f631b57c473/example/lib/model_layer.dart#L73-L74
As for using local 3D assets for models, please note currently(as of 2.1.0) model paths are expected to be platform specific, we have addressed this issue in https://github.com/mapbox/mapbox-maps-flutter/pull/608, with introducing asset:// url scheme for 3D models, this change will be released in 2.2.0.
As for using local 3D assets for models, please note currently(as of 2.1.0) model paths are expected to be platform specific, we have addressed this issue in #608, with introducing
asset://url scheme for 3D models, this change will be released in 2.2.0.
Ohhhh, improvements I hadn't seen, sorry, it's just that I published the "issue" when that didn't exist yet, but I'm glad to know that there's full support now.