提交 92f74167 authored 作者: 詹银鑫's avatar 詹银鑫

3d模型加载

上级 0d7dba15
...@@ -45,7 +45,6 @@ export class Assets { ...@@ -45,7 +45,6 @@ export class Assets {
name: "china", name: "china",
path: base_url + "assets/json/中华人民共和国.json", path: base_url + "assets/json/中华人民共和国.json",
}, },
{ {
type: "File", type: "File",
name: "mapJson", name: "mapJson",
...@@ -60,6 +59,12 @@ export class Assets { ...@@ -60,6 +59,12 @@ export class Assets {
// path: base_url + "assets/json/zger.json", // path: base_url + "assets/json/zger.json",
path: base_url + "assets/json/jiedao.json", path: base_url + "assets/json/jiedao.json",
}, },
{
type: "File",
name: "mapTerrain",
path: base_url + "assets/json/Scene_cq15_200.gltf",
// path: base_url + "assets/json/Scene.gltf",
},
{ type: "Texture", name: "huiguang", path: huiguang }, { type: "Texture", name: "huiguang", path: huiguang },
{ type: "Texture", name: "rotationBorder1", path: rotationBorder1 }, { type: "Texture", name: "rotationBorder1", path: rotationBorder1 },
......
...@@ -52,6 +52,10 @@ import infoData from "./map/infoData" ...@@ -52,6 +52,10 @@ import infoData from "./map/infoData"
import gsap from "gsap" import gsap from "gsap"
import emitter from "@/utils/emitter" import emitter from "@/utils/emitter"
import { InteractionManager } from "three.interactive" import { InteractionManager } from "three.interactive"
// 引入模型加载模块
import { Resource } from "@/mini3d/utils/Resource"
function sortByValue(data) { function sortByValue(data) {
data.sort((a, b) => b.value - a.value) data.sort((a, b) => b.value - a.value)
return data return data
...@@ -100,6 +104,7 @@ export class World extends Mini3d { ...@@ -100,6 +104,7 @@ export class World extends Mini3d {
// 创建环境光 // 创建环境光
this.initEnvironment() this.initEnvironment()
this.init() this.init()
console.log("执行了 这些代码")
} }
init() { init() {
// 标签组 // 标签组
...@@ -117,6 +122,10 @@ export class World extends Mini3d { ...@@ -117,6 +122,10 @@ export class World extends Mini3d {
// 鼠标移上移除的材质 // 鼠标移上移除的材质
this.defaultMaterial = null // 默认材质 this.defaultMaterial = null // 默认材质
this.defaultLightMaterial = null // 高亮材质 this.defaultLightMaterial = null // 高亮材质
// 创建地形模型初始化
this.terrainResource = new Resource()
// 创建底部高亮 // 创建底部高亮
this.createBottomBg() this.createBottomBg()
// 模糊边线 // 模糊边线
...@@ -144,6 +153,8 @@ export class World extends Mini3d { ...@@ -144,6 +153,8 @@ export class World extends Mini3d {
this.createInfoPoint() this.createInfoPoint()
// 创建轮廓 // 创建轮廓
this.createStorke() this.createStorke()
// 创造3d地形
this.createTerrain()
// this.time.on("tick", () => { // this.time.on("tick", () => {
// console.log(this.camera.instance.position); // console.log(this.camera.instance.position);
// }); // });
...@@ -1266,6 +1277,25 @@ export class World extends Mini3d { ...@@ -1266,6 +1277,25 @@ export class World extends Mini3d {
texture.offset.x += 0.005 texture.offset.x += 0.005
}) })
} }
// 创建地形模型
createTerrain() {
console.log("this.terrainResource",this.terrainResource);
// let terrainData = this.assets.instance.getResource("mapTerrain");
// console.log("terrainData", terrainData);
this.terrainResource.loaders.GLTF.load("../../../public/assets/json/Scene_cq15_200.gltf",
(gltf) => {
let terrain = gltf.scene;
this.scene.add(terrain);
},
(xhr) => {
console.log((xhr.loaded / xhr.total * 100) + '% 已加载');
},
(error) => {
console.error('加载模型出错:', error);
}
)
// this.scene.add(barGroup)
}
geoProjection(args) { geoProjection(args) {
return geoMercator().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0, 0])(args) return geoMercator().center(this.geoProjectionCenter).scale(this.geoProjectionScale).translate([0, 0])(args)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论