Compare commits

..

3 Commits

Author SHA1 Message Date
wangqiujuan0808 34f1b1c11f 123 2023-12-09 03:35:34 +08:00
wangqiujuan0808 13c5c1a86f Merge branch 'main' of https://git.shikicc.com/wangqiujuan0808/bw into main 2023-12-09 00:53:55 +08:00
wangqiujuan0808 71f00363bd 123 2023-12-09 00:53:51 +08:00
2 changed files with 47 additions and 49 deletions

BIN
dist.7z Normal file

Binary file not shown.

View File

@ -59,31 +59,21 @@ watch(() => props.sceneUrl, val => {
init();
loadSence();
});
let objArr = [];
let objM = [];
//
Bus.on('clickBuild', (isParent) => {
// Todo
console.log('clickBuild', isParent);
if (!isParent) {//
var clickName = bimStore().activateTree.clickName;
console.log(123, clickName);
//
if (selectedObject && selectedMaterial) {
selectedObject.material = selectedMaterial;
selectedObject = null;
selectedMaterial = null;
}
cleanColor();
var Floor = gltfObj.value.scene.getObjectByName(clickName);
if (Floor.length > 0) {
//
selectedObject = Floor;
selectedMaterial = selectedObject.material;
}
console.log(1, Floor);
Floor.traverse(e => {
e.material = new THREE.MeshLambertMaterial({
color: 0x00ff00,
});
nearCamera(e);
})
}
@ -107,12 +97,29 @@ onMounted(() => {
renderScene();
document.addEventListener("click", onMouseDown);
});
const cleanColor = () => {
//
if (objArr.length > 0 && objM.length > 0) {
objArr.forEach((ele, index) => {
console.log(objM[index]);
ele.material = objM[index]
})
objArr = [];
objM = [];
}
gltfObj.value.scene.traverse(e => {
objArr.push(e);
objM.push(e.material);
})
}
const init = () => {
scene = new THREE.Scene("#00ffff");
// const texture = new THREE.TextureLoader().load(homeIcon);
// texture.mapping = THREE.EquirectangularReflectionMapping;
// scene.background = texture
// scene.environment = texture
const texture = new THREE.TextureLoader().load(homeIcon);
texture.mapping = THREE.EquirectangularReflectionMapping;
scene.background = texture
scene.environment = texture
const canvas = document.querySelector("#three");
var cubeLoader = new THREE.CubeTextureLoader();
@ -127,11 +134,6 @@ const init = () => {
//
camera.position.set(-192.936, 180.990, -28.179);
camera.lookAt(scene.position);
<<<<<<< HEAD
=======
>>>>>>> c61eb163e061fb935e88a57641d1dc70e363d7b5
//
orbit = new OrbitControls(camera, renderer.domElement);
orbit.autoRotate = true;
@ -207,17 +209,12 @@ let selectedObject = null;
let selectedMaterial = null;
const onMouseDown = (event) => {
var raycaster = new THREE.Raycaster()
//
if (selectedObject && selectedMaterial) {
selectedObject.material = selectedMaterial;
selectedObject = null;
selectedMaterial = null;
}
//
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
var raycaster = new THREE.Raycaster()
cleanColor();
// 线
raycaster.setFromCamera(mouse, camera);
// 线
@ -227,7 +224,6 @@ const onMouseDown = (event) => {
const clickedObject = intersects[0].object;
//
selectedObject = clickedObject;
selectedMaterial = clickedObject.material;
// 绿
selectedObject.material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
nearCamera(intersects);
@ -236,30 +232,32 @@ const onMouseDown = (event) => {
}
const nearCamera = (intersects) => {
//
if (!intersects[0]) {
return;
} else {
if (intersects[0].object.name) {
selectedObjects = [];
selectedObjects.push(intersects[0].object);
positionObj = {
x: intersects[0].object.position.x,
y: intersects[0].object.position.y,
z: intersects[0].object.position.z,
};
console.log(5555, intersects)
//
if (!intersects[0]) {
return;
} else {
if (intersects[0].object.name) {
selectedObjects = [];
selectedObjects.push(intersects[0].object);
positionObj = {
x: intersects[0].object.position.x,
y: intersects[0].object.position.y,
z: intersects[0].object.position.z,
};
initTween(
positionObj.x,
positionObj.y,
positionObj.z+10
);
}
initTween(
positionObj.x,
positionObj.y,
positionObj.z + 10
);
}
}
}
const toHomeView = () => {
camera.position.set(-192.936, 180.990, -28.179);
camera.lookAt(scene.position);
cleanColor();
}
//
const toHomeView1 = () => {