简体   繁体   English

Threebox Mapbox:我编辑的每个模型最终都变成了天空中的巨大球

[英]Threebox Mapbox: Every of my edited models ends up a as giant ball in the sky

When i add the truck.glb as a custom layer with threebox to a mapbox map, every thingworks fine.当我将 truck.glb 作为自定义层添加到 mapbox map 时,一切正常。 All the models from the examples are fine.示例中的所有模型都很好。 Every model edited by me with three.js editor or nunustudio.org is rendered as a giant grey ball far away in space hundreds of km's above the ground.我使用 three.js 编辑器或 nunustudio.org 编辑的每个 model 都在距离地面数百公里的太空中呈现为一个巨大的灰色球。

With the same code:使用相同的代码:

  // model
                var options = {
                    type: 'gltf',
                    obj: 'models/truck.glb',
                    scale: 100,
                    units: 'meters',
                    anchor: "bottom",
                    rotation: { x: 90, y: 90, z: 0 }, //rotation to postiion the truck and heading properly
                }

                tb.loadObj(options, function (model) {

                    truck = model.setCoords(origin_truck);
                    truck.set({ rotation: { x: 0, y: 0, z: 7200 }, duration: 200000 })
                    tb.add(truck);
                })

The models from the threebox examples is displayed as expected but EVERY other model exported as.glb or.gltf looks like a cliffhanger for a sequel from very bad science fiction movie:三盒示例中的模型按预期显示,但导出为 .glb 或 .gltf 的所有其他 model 看起来就像非常糟糕的科幻电影续集的悬念:

在此处输入图像描述

What am i doing wrong when exporting from three editor?从三个编辑器导出时我做错了什么?

Thx for a hint谢谢提示

Please find a model under请在下面找到 model

probolt.ch/test.glb probolt.ch/test.glb

Renders perfectly in the editor but one big black marble in the threebox.在编辑器中完美渲染,但在三框里有一个大的黑色大理石。 Thx for your support.感谢您的支持。

Your problem has nothing to do with Threebox or Three... I downloaded it and your model is just a sphere... Opened with 3D Viewer:您的问题与 Threebox 或 Three 无关...我下载了它,您的 model 只是一个球体...用 3D 查看器打开: 在此处输入图像描述

Opened with threejs.org/editor用threejs.org/editor打开在此处输入图像描述

The problem is that you have created a huge sphere around your model apparently to create the sky, which is unnecessary and not the way if you want to create an environment to cast and reflex lights.问题是您在 model 周围创建了一个巨大的球体,显然是为了创建天空,如果您想创建一个投射和反射光的环境,这是不必要的,也不是方法。

If you just hide or remove mesh_0 your model will be shown in any tool.如果您只是隐藏或删除mesh_0您的 model 将显示在任何工具中。 在此处输入图像描述

And also in Threebox还有三盒在此处输入图像描述

This is the relevant code (I added a tooltip, real sunlight & shadow):这是相关代码(我添加了一个工具提示,真实的阳光和阴影):

        mapboxgl.accessToken = 'PASTE YOUR TOKEN HERE!';

        var map = (window.map = new mapboxgl.Map({
            container: 'map',
            style: 'mapbox://styles/mapbox/satellite-v9',
            zoom: 18,
            center: [-4.0094,41.4104],
            pitch: 60,
            antialias: true 
        }));

        window.tb = new Threebox(
            map,
            map.getCanvas().getContext('webgl'),
            {
                realSunlight: true,
                enableSelectingObjects: true,
                enableTooltips: true
            }
        );

        let modelOrigin = [-4.0094, 41.4104];

        function createCustomLayer(layerName, origin) {
            let model;
            //create the layer
            let customLayer3D = {
                id: layerName,
                type: 'custom',
                renderingMode: '3d',
                onAdd: function (map, gl) {

                    let options = {
                        type: 'gltf', 
                        obj: './test.glb', //model url
                        units: 'meters', 
                        scale: 10,
                        rotation: { x: 90, y: 180, z: 0 }, 
                        anchor: 'center'
                    }
                    tb.loadObj(options, function (model) {
                        model.setCoords(origin);
                        model.addTooltip("A logo in the middle of nowhere", true);
                        tb.add(model);
                        model.castShadow = true;
                        tb.lights.dirLight.target = model;
                    });

                },
                render: function (gl, matrix) {
                    tb.update();
                }
            };
            return customLayer3D;

        };

        map.on('style.load', function () {
            map.addLayer(createCustomLayer('3d-model', modelOrigin));
        });

Sorry for my late answer.对不起我迟到的答案。 Please find a model under请在下面找到 model

probolt.ch/test.glb probolt.ch/test.glb

Renders perfectly in the editor but one big black marble in the threebox.在编辑器中完美渲染,但在三框里有一个大的黑色大理石。 Thx for your support.感谢您的支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM