fix(resize): 新增3DTiles内置资源;增加内置资源对http(s)地址的支持;
This commit is contained in:
parent
87acdc4896
commit
915e83bc84
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
@ -1071,8 +1071,11 @@ export default {
|
||||
Fireworks: '烟花',
|
||||
},
|
||||
tiles:{
|
||||
/* 分类 */
|
||||
|
||||
// 工厂
|
||||
'A petrochemical plant':"石油化工厂",
|
||||
'Building group 1':"建筑群1",
|
||||
// 其他
|
||||
'Dragon':"龙",
|
||||
},
|
||||
|
||||
@ -41,15 +41,16 @@ const searchText = inject('searchText') as Ref<string>;
|
||||
const previewInfo = inject('previewInfo') as any;
|
||||
const previewRef = inject('previewRef') as any;
|
||||
|
||||
const activeSubCategory = ref('factory');
|
||||
const activeSubCategory = ref('building');
|
||||
const subCategories = ref([
|
||||
{key: 'factory', name: cpt('extra.resource.billboard.Factory')},
|
||||
{key: 'building', name: cpt('extra.resource.model.Building')},
|
||||
{key: 'other', name: cpt('extra.resource.model.Other')}
|
||||
]);
|
||||
|
||||
const allList = {
|
||||
"factory": [
|
||||
{key: "APetrochemicalPlant", image: "/static/images/resource/tiles/factory/APetrochemicalPlant.jpg", name: cpt('extra.resource.tiles.A petrochemical plant'), tileset: "/static/resource/tiles/factory/APetrochemicalPlant/tileset.json"},
|
||||
"building": [
|
||||
{key: "APetrochemicalPlant", image: "/static/images/resource/tiles/building/APetrochemicalPlant.jpg", name: cpt('extra.resource.tiles.A petrochemical plant'), tileset: "/static/resource/tiles/building/APetrochemicalPlant/tileset.json"},
|
||||
{key: "BuildingGroup1", image: "/static/images/resource/tiles/building/buildingGroup1.jpg", name: cpt('extra.resource.tiles.Building group 1'), tileset: "https://tiles.arcgis.com/tiles/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Utrecht_3D_Tiles_Integrated_Mesh/3DTilesServer/tileset.json"},
|
||||
],
|
||||
"other": [
|
||||
{key: "Dragon", image: "/static/images/resource/tiles/other/dragon.jpg", name: cpt('extra.resource.tiles.Dragon'), tileset: "/static/resource/tiles/other/dragon/tileset.json"},
|
||||
@ -67,9 +68,14 @@ function selectSubCategory(key: string) {
|
||||
|
||||
// 预览
|
||||
async function handlePreview(item){
|
||||
let url = item.tileset;
|
||||
if(!url.startsWith('http')){
|
||||
url = import.meta.env.VITE_GLOB_ORIGIN + item.tileset;
|
||||
}
|
||||
|
||||
previewInfo.name = (item.name as Ref<string>).value || item.name;
|
||||
previewInfo.type = "Tiles";
|
||||
previewInfo.fileOrUrl = import.meta.env.VITE_GLOB_ORIGIN + item.tileset;
|
||||
previewInfo.fileOrUrl = url;
|
||||
previewInfo.visible = true;
|
||||
|
||||
// TODO: [20250927] 直接赋值previewInfo.fileOrUrl就会在预览组件中自动加载模型,运行2个月没问题后删除下面注释
|
||||
@ -93,9 +99,14 @@ async function handlePreview(item){
|
||||
|
||||
//双击添加至场景..
|
||||
function addToScene(item, position?: Vector3) {
|
||||
let url = item.tileset;
|
||||
if(!url.startsWith('http')){
|
||||
url = import.meta.env.VITE_GLOB_ORIGIN + item.tileset;
|
||||
}
|
||||
|
||||
const tiles = new Tiles({
|
||||
// 内置的3dTiles打包时需要存入完整地址方可通过sdk加载回来
|
||||
url: import.meta.env.VITE_GLOB_ORIGIN + item.tileset,
|
||||
url: url,
|
||||
name:item.name.value || item.name,
|
||||
reset2origin:true,
|
||||
debug:false,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {TilesRenderer} from "3d-tiles-renderer";
|
||||
import {GLTFExtensionsPlugin,DebugTilesPlugin} from "3d-tiles-renderer/plugins";
|
||||
import {GLTFExtensionsPlugin,GLTFMeshFeaturesExtension,GLTFStructuralMetadataExtension,TilesFadePlugin,DebugTilesPlugin,UnloadTilesPlugin} from "3d-tiles-renderer/plugins";
|
||||
import Loader from "@/core/loader/Loader.ts";
|
||||
import {PerspectiveCamera, WebGLRenderer, Group, JSONMeta} from "three";
|
||||
import {deepAssign} from "@/utils";
|
||||
@ -14,7 +14,7 @@ export default class Tiles extends Group{
|
||||
reset2origin:true,
|
||||
debug:false,
|
||||
name:"Tiles",
|
||||
errorTarget: 5,
|
||||
errorTarget: 6,
|
||||
LRUCache:{
|
||||
maxSize: 4000,
|
||||
minSize: 3000,
|
||||
@ -68,11 +68,27 @@ export default class Tiles extends Group{
|
||||
tilesRenderer.registerPlugin(new GLTFExtensionsPlugin({
|
||||
dracoLoader: Loader.dracoLoader,
|
||||
ktxLoader: Loader.ktx2Loader,
|
||||
plugins:[() => new GLTFMeshFeaturesExtension(),() => new GLTFStructuralMetadataExtension()]
|
||||
}));
|
||||
// Loader.createGLTFLoader(tilesRenderer.manager).then(loader => {
|
||||
// loader.register(() => new GLTFMeshFeaturesExtension());
|
||||
// loader.register(() => new GLTFStructuralMetadataExtension());
|
||||
// tilesRenderer.manager.addHandler( /\.(gltf|glb)$/g, loader );
|
||||
// })
|
||||
|
||||
// 瓦片渐显隐
|
||||
tilesRenderer.registerPlugin(new TilesFadePlugin());
|
||||
// 从gpu卸载不可见瓦片数据,cpu上仍然存在
|
||||
tilesRenderer.registerPlugin(new UnloadTilesPlugin());
|
||||
if(this.options.debug){
|
||||
// 注册调试插件
|
||||
tilesRenderer.registerPlugin(new DebugTilesPlugin());
|
||||
// 获取调试插件
|
||||
const debugTilesPlugin = tilesRenderer.getPluginByName('DEBUG_TILES_PLUGIN') as DebugTilesPlugin;
|
||||
// 显示包围盒的线框
|
||||
debugTilesPlugin.displayBoxBounds = true;
|
||||
}
|
||||
|
||||
// 子级瓦片加载
|
||||
tilesRenderer.addEventListener('load-model', (e) => {
|
||||
e.scene.traverse(c => {
|
||||
@ -92,15 +108,6 @@ export default class Tiles extends Group{
|
||||
console.error(`${tilesRenderer.group.name} load error:`, e);
|
||||
});
|
||||
|
||||
if(this.options.debug){
|
||||
// 注册调试插件
|
||||
tilesRenderer.registerPlugin(new DebugTilesPlugin());
|
||||
// 获取调试插件
|
||||
const debugTilesPlugin = tilesRenderer.getPluginByName('DEBUG_TILES_PLUGIN') as DebugTilesPlugin;
|
||||
// 显示包围盒的线框
|
||||
debugTilesPlugin.displayBoxBounds = true;
|
||||
}
|
||||
|
||||
return tilesRenderer;
|
||||
}
|
||||
|
||||
|
||||
@ -149,6 +149,8 @@ export class TilesManage {
|
||||
}
|
||||
|
||||
update() {
|
||||
// this.camera.updateMatrixWorld();
|
||||
|
||||
for (const tiles of this.tilesMap.values()) {
|
||||
tiles.forEach(tile => tile.update());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user