easy-threesdk 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +45 -45
- package/package.json +1 -1
- package/plugins/ModelControl.js +28 -28
package/index.js
CHANGED
|
@@ -558,20 +558,20 @@ class ThreeSdk {
|
|
|
558
558
|
textureLoader.load(
|
|
559
559
|
textureImage,
|
|
560
560
|
(texture) => {
|
|
561
|
-
console.log("✅ 全景图片加载成功!");
|
|
562
|
-
console.log(
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
);
|
|
561
|
+
// console.log("✅ 全景图片加载成功!");
|
|
562
|
+
// console.log(
|
|
563
|
+
// "图片尺寸:",
|
|
564
|
+
// texture.image.width,
|
|
565
|
+
// "x",
|
|
566
|
+
// texture.image.height
|
|
567
|
+
// );
|
|
568
568
|
//创建3d场景
|
|
569
569
|
|
|
570
570
|
//-------------------- 方法1:使用 EquirectangularReflectionMapping + 翻转X轴
|
|
571
571
|
|
|
572
|
-
console.log(
|
|
573
|
-
|
|
574
|
-
);
|
|
572
|
+
// console.log(
|
|
573
|
+
// "🔧 使用方法1: EquirectangularReflectionMapping + scale(1,-1,-1)"
|
|
574
|
+
// );
|
|
575
575
|
|
|
576
576
|
texture.mapping = THREE.EquirectangularReflectionMapping;
|
|
577
577
|
texture.minFilter = THREE.LinearFilter;
|
|
@@ -607,17 +607,17 @@ class ThreeSdk {
|
|
|
607
607
|
|
|
608
608
|
this.scene.add(this._PanoramaSphere);
|
|
609
609
|
|
|
610
|
-
console.log("✅ 全景球体创建成功!");
|
|
611
|
-
console.log("球体位置:", this._PanoramaSphere.position);
|
|
612
|
-
console.log("相机位置:", this.camera.position);
|
|
613
|
-
console.log("材质配置:", {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
});
|
|
610
|
+
// console.log("✅ 全景球体创建成功!");
|
|
611
|
+
// console.log("球体位置:", this._PanoramaSphere.position);
|
|
612
|
+
// console.log("相机位置:", this.camera.position);
|
|
613
|
+
// console.log("材质配置:", {
|
|
614
|
+
// hasTexture: !!this._PanoramaSphere.material.map,
|
|
615
|
+
// side: this._PanoramaSphere.material.side,
|
|
616
|
+
// mapping: texture.mapping,
|
|
617
|
+
// textureSize: texture.image
|
|
618
|
+
// ? `${texture.image.width}x${texture.image.height}`
|
|
619
|
+
// : "未知",
|
|
620
|
+
// });
|
|
621
621
|
|
|
622
622
|
// 确保相机朝向正确
|
|
623
623
|
// this.camera.lookAt(0, 0, -1);
|
|
@@ -626,11 +626,11 @@ class ThreeSdk {
|
|
|
626
626
|
// 加载进度
|
|
627
627
|
if (progress.total > 0) {
|
|
628
628
|
const percent = (progress.loaded / progress.total) * 100;
|
|
629
|
-
console.log("加载进度:", percent.toFixed(2) + "%");
|
|
629
|
+
// console.log("加载进度:", percent.toFixed(2) + "%");
|
|
630
630
|
}
|
|
631
631
|
},
|
|
632
632
|
(error) => {
|
|
633
|
-
console.error("❌ 全景图片加载失败:", error);
|
|
633
|
+
// console.error("❌ 全景图片加载失败:", error);
|
|
634
634
|
document.getElementById("loading").textContent =
|
|
635
635
|
"图片加载失败,请检查路径: ../resource/sence/citrus_orchard_road_puresky.jpg";
|
|
636
636
|
}
|
|
@@ -669,20 +669,20 @@ class ThreeSdk {
|
|
|
669
669
|
|
|
670
670
|
// 允许用户从各个角度查看(移除垂直角度限制)
|
|
671
671
|
this.controls.maxPolarAngle = Math.PI; // 允许从下方查看
|
|
672
|
-
console.log(
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
);
|
|
679
|
-
console.log(
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
);
|
|
672
|
+
// console.log(
|
|
673
|
+
// ` 相机位置: (${this.camera.position.x.toFixed(
|
|
674
|
+
// 2
|
|
675
|
+
// )}, ${this.camera.position.y.toFixed(
|
|
676
|
+
// 2
|
|
677
|
+
// )}, ${this.camera.position.z.toFixed(2)})`
|
|
678
|
+
// );
|
|
679
|
+
// console.log(
|
|
680
|
+
// ` 控制器目标: (${this.controls.target.x.toFixed(
|
|
681
|
+
// 2
|
|
682
|
+
// )}, ${this.controls.target.y.toFixed(
|
|
683
|
+
// 2
|
|
684
|
+
// )}, ${this.controls.target.z.toFixed(2)})`
|
|
685
|
+
// );
|
|
686
686
|
console.log(`💡 现在可以用鼠标拖拽围绕相机自身旋转查看四周,滚轮缩放`);
|
|
687
687
|
}
|
|
688
688
|
|
|
@@ -753,13 +753,13 @@ class ThreeSdk {
|
|
|
753
753
|
this.camera.position.y = this._RoamConfig.cameraHeight;
|
|
754
754
|
}
|
|
755
755
|
|
|
756
|
-
console.log("✅ 进入视角漫游模式");
|
|
757
|
-
console.log("📍 当前相机位置:", this.camera.position);
|
|
758
|
-
console.log("⌨️ 操作说明:");
|
|
759
|
-
console.log(" • 鼠标悬停地面显示圆圈");
|
|
760
|
-
console.log(" • 点击地面跳转视角");
|
|
761
|
-
console.log(" • WASD/方向键移动");
|
|
762
|
-
console.log(" • 鼠标拖拽改变朝向");
|
|
756
|
+
// console.log("✅ 进入视角漫游模式");
|
|
757
|
+
// console.log("📍 当前相机位置:", this.camera.position);
|
|
758
|
+
// console.log("⌨️ 操作说明:");
|
|
759
|
+
// console.log(" • 鼠标悬停地面显示圆圈");
|
|
760
|
+
// console.log(" • 点击地面跳转视角");
|
|
761
|
+
// console.log(" • WASD/方向键移动");
|
|
762
|
+
// console.log(" • 鼠标拖拽改变朝向");
|
|
763
763
|
}
|
|
764
764
|
|
|
765
765
|
exitRoamMode() {
|
|
@@ -859,7 +859,7 @@ class ThreeSdk {
|
|
|
859
859
|
transformControls.updateMatrixWorld();
|
|
860
860
|
}
|
|
861
861
|
|
|
862
|
-
console.log("✅ 信息已应用到 mesh:", mesh.userData.name || "未命名对象");
|
|
862
|
+
// console.log("✅ 信息已应用到 mesh:", mesh.userData.name || "未命名对象");
|
|
863
863
|
}
|
|
864
864
|
|
|
865
865
|
/**
|
package/package.json
CHANGED
package/plugins/ModelControl.js
CHANGED
|
@@ -51,7 +51,7 @@ export default class ModelControl {
|
|
|
51
51
|
modelPath,
|
|
52
52
|
// 加载成功的回调
|
|
53
53
|
(gltf) => {
|
|
54
|
-
console.log("GLTF 建筑物模型加载成功!");
|
|
54
|
+
// console.log("GLTF 建筑物模型加载成功!");
|
|
55
55
|
|
|
56
56
|
const model = gltf.scene;
|
|
57
57
|
|
|
@@ -69,11 +69,11 @@ export default class ModelControl {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// 打印网格信息
|
|
72
|
-
console.log(`GLTF 网格: "${child.name}"`);
|
|
72
|
+
// console.log(`GLTF 网格: "${child.name}"`);
|
|
73
73
|
|
|
74
74
|
if (child.material) {
|
|
75
|
-
console.log(" 材质:", child.material.name || "未命名");
|
|
76
|
-
console.log(" 有贴图:", child.material.map ? "是" : "否");
|
|
75
|
+
// console.log(" 材质:", child.material.name || "未命名");
|
|
76
|
+
// console.log(" 有贴图:", child.material.map ? "是" : "否");
|
|
77
77
|
if (!child.userData.originalMaterial) {
|
|
78
78
|
child.userData.originalMaterial = child.material.clone(); //copy方法是浅拷贝,内部的color是引用类型,所以需要单独保存
|
|
79
79
|
child.userData.originalMaterialColor =
|
|
@@ -116,20 +116,20 @@ export default class ModelControl {
|
|
|
116
116
|
// 添加到场景
|
|
117
117
|
this.ThreeSdk.scene.add(model);
|
|
118
118
|
|
|
119
|
-
console.log("GLTF 建筑物已添加到场景");
|
|
120
|
-
console.log(" 缩放:", scaleFactor);
|
|
121
|
-
console.log(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
);
|
|
127
|
-
console.log(" 原始大小:", size.x, "x", size.y, "x", size.z);
|
|
119
|
+
// console.log("GLTF 建筑物已添加到场景");
|
|
120
|
+
// console.log(" 缩放:", scaleFactor);
|
|
121
|
+
// console.log(
|
|
122
|
+
// " 位置:",
|
|
123
|
+
// model.position.x,
|
|
124
|
+
// model.position.y,
|
|
125
|
+
// model.position.z
|
|
126
|
+
// );
|
|
127
|
+
// console.log(" 原始大小:", size.x, "x", size.y, "x", size.z);
|
|
128
128
|
|
|
129
129
|
// 添加边界框辅助线(可选,用于调试)
|
|
130
130
|
const helper = new THREE.BoxHelper(model, 0x00ff00);
|
|
131
131
|
// scene.add(helper);
|
|
132
|
-
console.log("已添加绿色边界框辅助线");
|
|
132
|
+
// console.log("已添加绿色边界框辅助线");
|
|
133
133
|
|
|
134
134
|
this._ModelMap.set(ModelID, model);
|
|
135
135
|
res(model);
|
|
@@ -137,12 +137,12 @@ export default class ModelControl {
|
|
|
137
137
|
// 加载进度的回调
|
|
138
138
|
(xhr) => {
|
|
139
139
|
const percentComplete = (xhr.loaded / xhr.total) * 100;
|
|
140
|
-
console.log(`GLTF 建筑物加载进度: ${Math.round(percentComplete)}%`);
|
|
140
|
+
// console.log(`GLTF 建筑物加载进度: ${Math.round(percentComplete)}%`);
|
|
141
141
|
onLoadProcess && onLoadProcess(percentComplete);
|
|
142
142
|
},
|
|
143
143
|
// 加载错误的回调
|
|
144
144
|
(error) => {
|
|
145
|
-
console.error("加载 GLTF 建筑物时出错:", error);
|
|
145
|
+
// console.error("加载 GLTF 建筑物时出错:", error);
|
|
146
146
|
rej(error);
|
|
147
147
|
}
|
|
148
148
|
);
|
|
@@ -183,10 +183,10 @@ export default class ModelControl {
|
|
|
183
183
|
this._hoveredObject.userData.originalMaterialColor
|
|
184
184
|
);
|
|
185
185
|
this._hoveredObject.material.needsUpdate = true;
|
|
186
|
-
console.log(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
);
|
|
186
|
+
// console.log(
|
|
187
|
+
// "恢复之前悬停对象的材质",
|
|
188
|
+
// this._hoveredObject.userData.originalMaterial
|
|
189
|
+
// );
|
|
190
190
|
}
|
|
191
191
|
this._hoveredObject = object;
|
|
192
192
|
// 保存原始材质
|
|
@@ -248,14 +248,14 @@ export default class ModelControl {
|
|
|
248
248
|
if (intersects.length > 0) {
|
|
249
249
|
const clickedObject = intersects[0].object;
|
|
250
250
|
const clickedPoint = intersects[0].point;
|
|
251
|
-
console.log("=== 点击事件触发 ===");
|
|
252
|
-
console.log(`点击对象: ${clickedObject.userData.name}`);
|
|
253
|
-
console.log(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
);
|
|
258
|
-
console.log(`对象信息:`, clickedObject.userData);
|
|
251
|
+
// console.log("=== 点击事件触发 ===");
|
|
252
|
+
// console.log(`点击对象: ${clickedObject.userData.name}`);
|
|
253
|
+
// console.log(
|
|
254
|
+
// `点击位置: (${clickedPoint.x.toFixed(2)}, ${clickedPoint.y.toFixed(
|
|
255
|
+
// 2
|
|
256
|
+
// )}, ${clickedPoint.z.toFixed(2)})`
|
|
257
|
+
// );
|
|
258
|
+
// console.log(`对象信息:`, clickedObject.userData);
|
|
259
259
|
|
|
260
260
|
// 执行点击动画
|
|
261
261
|
this._animateClick(clickedObject);
|