Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有的模型能加载成功,但是有的模型加载失败 #289

Open
CWZ152 opened this issue Dec 26, 2023 · 2 comments
Open

有的模型能加载成功,但是有的模型加载失败 #289

CWZ152 opened this issue Dec 26, 2023 · 2 comments

Comments

@CWZ152
Copy link

CWZ152 commented Dec 26, 2023

用这个工具转换osgb后,有的模型加载成功,有的模型加载失败。

  1. 加载成功的模型:
    image
    image
    image

  2. 加载失败的模型:
    image
    image
    image

似乎Data文件夹下有很多文件夹时就会加载失败,这是为什么呢?

加载失败的模型里,单独加载一个文件夹下的是可以的,但是用父文件夹下的json就不行。在加载时,只能加载所有的json,但是加载不了.b3dm,

@fanvanzh
Copy link
Owner

看你的描述,好像是 json 文件内容出错了,能配合 cesium 代码排查定位一下问题吗

@CWZ152
Copy link
Author

CWZ152 commented Jan 4, 2024

看你的描述,好像是 json 文件内容出错了,能配合 cesium 代码排查定位一下问题吗

我看json文件内容的格式并没有什么问题,是不是因为osgb太大了,大概有70多G,cesium代码是如下:

import React, { Component } from 'react';

class Tiles extends Component {
  state = {
    points: [],
  };

  componentDidMount() {
    if (window.Cesium) {
      window.startupCalled = true;
      const Cesium = window.Cesium;
      const viewer = new Cesium.Viewer('cesiumContainer', {
        animation: false,
        baseLayerPicker: false,
        geocoder: false,
        timeline: false,
        sceneModePicker: false,
        navigationHelpButton: false,
        navigation: false,
        infoBox: false,
        selectionIndicator: false,
      });

      // 去除水印
      viewer._cesiumWidget._creditContainer.style.display = 'none';
      // 显示帧率信息
      viewer.scene.debugShowFramesPerSecond = true;

      try {
        // 加载本地的3D Tiles
        const tileset = new Cesium.Cesium3DTileset({
          url: 'Data/miluo/tileset.json', // 替换成你本地3D Tiles 数据的路径
        });
        console.log(tileset);

        viewer.scene.primitives.add(tileset);

        // 设置相机位置,使其能够观察整个3D Tiles场景
        viewer.zoomTo(tileset);
      } catch (error) {
        console.log(`Error loading tileset: ${error}`);
      } 
    }
  }

  render() {
    return (
      <div style={{ display: 'flex', width: '100%', height: '100%' }}>
        <div id="cesiumContainer" style={{ width: '100%', height: '100%' }}></div>
      </div>
    );
  }

  // 清除所有的实体
  clear = () => {
    this.setState({ points: [] });
    this.viewer.entities.removeAll();
  }
}

export default Tiles;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants